OpenGL: GLSL always supported

In gpu lib:
- GPU_glsl_support() always returns true
- internal cleanup & comments

Outside gpu lib:
- remove check from various code, remove the “else” path

- sprinkled a few C99-isms

We can remove GPU_glsl_support() when BGE stops calling it.
This commit is contained in:
2015-11-25 11:49:46 -05:00
parent feb574f21c
commit 816cdf262b
6 changed files with 24 additions and 59 deletions

View File

@@ -1151,7 +1151,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
Mesh *me = ob->data;
TexMatCallback data = {scene, ob, me, dm};
bool (*set_face_cb)(void *, int);
bool glsl, picking = (G.f & G_PICKSEL) != 0;
bool picking = (G.f & G_PICKSEL) != 0;
/* face hiding callback depending on mode */
if (ob == scene->obedit)
@@ -1162,7 +1162,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
set_face_cb = NULL;
/* test if we can use glsl */
glsl = (v3d->drawtype == OB_MATERIAL) && GPU_glsl_support() && !picking;
bool glsl = (v3d->drawtype == OB_MATERIAL) && !picking;
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);

View File

@@ -289,8 +289,6 @@ static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
bool draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt)
{
if (!GPU_glsl_support())
return false;
if (G.f & G_PICKSEL)
return false;
if (!check_object_draw_texture(scene, v3d, dt))

View File

@@ -2969,17 +2969,16 @@ void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d)
static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
{
if (scene->world && (v3d->flag3 & V3D_SHOW_WORLD)) {
bool glsl = GPU_glsl_support() && BKE_scene_use_new_shading_nodes(scene) && scene->world->nodetree && scene->world->use_nodes;
bool glsl = BKE_scene_use_new_shading_nodes(scene) && scene->world->nodetree && scene->world->use_nodes;
if (glsl) {
RegionView3D *rv3d = ar->regiondata;
GPUMaterial *gpumat = GPU_material_world(scene, scene->world);
bool material_not_bound;
/* calculate full shader for background */
GPU_material_bind(gpumat, 1, 1, 1.0, false, rv3d->viewmat, rv3d->viewinv, rv3d->viewcamtexcofac, (v3d->scenelock != 0));
material_not_bound = !GPU_material_bound(gpumat);
bool material_not_bound = !GPU_material_bound(gpumat);
if (material_not_bound) {
glMatrixMode(GL_PROJECTION);
@@ -3023,7 +3022,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
#define VIEWGRAD_RES_Y 16
GLubyte grid_col[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][4];
static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][3];
static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][3];
static GLushort indices[VIEWGRAD_RES_X - 1][VIEWGRAD_RES_X - 1][4];
static bool buf_calculated = false;

View File

@@ -109,12 +109,9 @@ static struct GPUGlobal {
GLint maxtexsize;
GLint maxtextures;
GLuint currentfb;
int glslsupport;
int extdisabled;
bool extdisabled;
int colordepth;
int samples_color_texture_max;
int npotdisabled; /* ATI 3xx-5xx (and more) chipsets support NPoT partially (== not enough) */
int dlistsdisabled; /* Legacy ATI driver does not support display lists well */
GPUDeviceType device;
GPUOSType os;
GPUDriverType driver;
@@ -148,7 +145,7 @@ bool GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
void GPU_extensions_disable(void)
{
GG.extdisabled = 1;
GG.extdisabled = true;
}
int GPU_max_texture_size(void)
@@ -163,9 +160,6 @@ void GPU_get_dfdy_factors(float fac[2])
void gpu_extensions_init(void)
{
GLint r, g, b;
const char *vendor, *renderer, *version;
/* BLI_assert(GLEW_VERSION_2_1); */
/* ^-- maybe a bit extreme? */
@@ -173,8 +167,7 @@ void gpu_extensions_init(void)
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
GG.glslsupport = 1;
GLint r, g, b;
glGetIntegerv(GL_RED_BITS, &r);
glGetIntegerv(GL_GREEN_BITS, &g);
glGetIntegerv(GL_BLUE_BITS, &b);
@@ -184,9 +177,9 @@ void gpu_extensions_init(void)
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES , &GG.samples_color_texture_max);
}
vendor = (const char *)glGetString(GL_VENDOR);
renderer = (const char *)glGetString(GL_RENDERER);
version = (const char *)glGetString(GL_VERSION);
const char *vendor = (const char *)glGetString(GL_VENDOR);
const char *renderer = (const char *)glGetString(GL_RENDERER);
const char *version = (const char *)glGetString(GL_VERSION);
if (strstr(vendor, "ATI")) {
GG.device = GPU_DEVICE_ATI;
@@ -274,18 +267,23 @@ void gpu_extensions_exit(void)
bool GPU_glsl_support(void)
{
return GG.glslsupport;
/* always supported, still queried by game engine */
return true;
}
bool GPU_non_power_of_two_support(void)
{
/* still relevant for OpenGL ES */
return !GG.npotdisabled;
/* always supported on full GL but still relevant for OpenGL ES */
return true;
}
bool GPU_display_list_support(void)
{
return !GG.dlistsdisabled;
/* deprecated in GL 3
* supported on older GL and compatibility profile
* still queried by game engine
*/
return true;
}
bool GPU_bicubic_bump_support(void)

View File

@@ -2278,9 +2278,6 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
GLint lastbindcode;
int i, liblen, fraglen;
if (!GPU_glsl_support())
return NULL;
/* TODO(sergey): How to detemine whether we need OSD or not here? */
mat = GPU_material_from_blender(scene, ma, false);
pass = (mat)? mat->pass: NULL;

View File

@@ -173,29 +173,10 @@ static GPUShader *gpu_simple_shader(int options)
void GPU_simple_shader_bind(int options)
{
if (GPU_glsl_support()) {
GPUShader *shader = gpu_simple_shader(options);
GPUShader *shader = gpu_simple_shader(options);
if (shader)
GPU_shader_bind(shader);
}
else {
// XXX where does this fit, depends on ortho/persp?
if (options & GPU_SHADER_LIGHTING)
glEnable(GL_LIGHTING);
if (options & GPU_SHADER_TWO_SIDED)
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
if (options & GPU_SHADER_OVERRIDE_DIFFUSE) {
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
}
if (options & GPU_SHADER_TEXTURE_2D)
glEnable(GL_TEXTURE_2D);
}
if (shader)
GPU_shader_bind(shader);
/* temporary hack, should be solved outside of this file */
GPU_MATERIAL_STATE.need_normals = (options & GPU_SHADER_LIGHTING);
@@ -203,15 +184,7 @@ void GPU_simple_shader_bind(int options)
void GPU_simple_shader_unbind(void)
{
if (GPU_glsl_support()) {
GPU_shader_unbind();
}
else {
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_TEXTURE_2D);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
}
GPU_shader_unbind();
}
/* Material Colors */