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:
@@ -1151,7 +1151,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
|
|||||||
Mesh *me = ob->data;
|
Mesh *me = ob->data;
|
||||||
TexMatCallback data = {scene, ob, me, dm};
|
TexMatCallback data = {scene, ob, me, dm};
|
||||||
bool (*set_face_cb)(void *, int);
|
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 */
|
/* face hiding callback depending on mode */
|
||||||
if (ob == scene->obedit)
|
if (ob == scene->obedit)
|
||||||
@@ -1162,7 +1162,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d,
|
|||||||
set_face_cb = NULL;
|
set_face_cb = NULL;
|
||||||
|
|
||||||
/* test if we can use glsl */
|
/* 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);
|
GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL);
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
bool draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt)
|
||||||
{
|
{
|
||||||
if (!GPU_glsl_support())
|
|
||||||
return false;
|
|
||||||
if (G.f & G_PICKSEL)
|
if (G.f & G_PICKSEL)
|
||||||
return false;
|
return false;
|
||||||
if (!check_object_draw_texture(scene, v3d, dt))
|
if (!check_object_draw_texture(scene, v3d, dt))
|
||||||
|
|||||||
@@ -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)
|
static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
|
||||||
{
|
{
|
||||||
if (scene->world && (v3d->flag3 & V3D_SHOW_WORLD)) {
|
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) {
|
if (glsl) {
|
||||||
RegionView3D *rv3d = ar->regiondata;
|
RegionView3D *rv3d = ar->regiondata;
|
||||||
GPUMaterial *gpumat = GPU_material_world(scene, scene->world);
|
GPUMaterial *gpumat = GPU_material_world(scene, scene->world);
|
||||||
bool material_not_bound;
|
|
||||||
|
|
||||||
/* calculate full shader for background */
|
/* calculate full shader for background */
|
||||||
GPU_material_bind(gpumat, 1, 1, 1.0, false, rv3d->viewmat, rv3d->viewinv, rv3d->viewcamtexcofac, (v3d->scenelock != 0));
|
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) {
|
if (material_not_bound) {
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
|||||||
@@ -109,12 +109,9 @@ static struct GPUGlobal {
|
|||||||
GLint maxtexsize;
|
GLint maxtexsize;
|
||||||
GLint maxtextures;
|
GLint maxtextures;
|
||||||
GLuint currentfb;
|
GLuint currentfb;
|
||||||
int glslsupport;
|
bool extdisabled;
|
||||||
int extdisabled;
|
|
||||||
int colordepth;
|
int colordepth;
|
||||||
int samples_color_texture_max;
|
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;
|
GPUDeviceType device;
|
||||||
GPUOSType os;
|
GPUOSType os;
|
||||||
GPUDriverType driver;
|
GPUDriverType driver;
|
||||||
@@ -148,7 +145,7 @@ bool GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver)
|
|||||||
|
|
||||||
void GPU_extensions_disable(void)
|
void GPU_extensions_disable(void)
|
||||||
{
|
{
|
||||||
GG.extdisabled = 1;
|
GG.extdisabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GPU_max_texture_size(void)
|
int GPU_max_texture_size(void)
|
||||||
@@ -163,9 +160,6 @@ void GPU_get_dfdy_factors(float fac[2])
|
|||||||
|
|
||||||
void gpu_extensions_init(void)
|
void gpu_extensions_init(void)
|
||||||
{
|
{
|
||||||
GLint r, g, b;
|
|
||||||
const char *vendor, *renderer, *version;
|
|
||||||
|
|
||||||
/* BLI_assert(GLEW_VERSION_2_1); */
|
/* BLI_assert(GLEW_VERSION_2_1); */
|
||||||
/* ^-- maybe a bit extreme? */
|
/* ^-- maybe a bit extreme? */
|
||||||
|
|
||||||
@@ -173,8 +167,7 @@ void gpu_extensions_init(void)
|
|||||||
|
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &GG.maxtexsize);
|
||||||
|
|
||||||
GG.glslsupport = 1;
|
GLint r, g, b;
|
||||||
|
|
||||||
glGetIntegerv(GL_RED_BITS, &r);
|
glGetIntegerv(GL_RED_BITS, &r);
|
||||||
glGetIntegerv(GL_GREEN_BITS, &g);
|
glGetIntegerv(GL_GREEN_BITS, &g);
|
||||||
glGetIntegerv(GL_BLUE_BITS, &b);
|
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);
|
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES , &GG.samples_color_texture_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
vendor = (const char *)glGetString(GL_VENDOR);
|
const char *vendor = (const char *)glGetString(GL_VENDOR);
|
||||||
renderer = (const char *)glGetString(GL_RENDERER);
|
const char *renderer = (const char *)glGetString(GL_RENDERER);
|
||||||
version = (const char *)glGetString(GL_VERSION);
|
const char *version = (const char *)glGetString(GL_VERSION);
|
||||||
|
|
||||||
if (strstr(vendor, "ATI")) {
|
if (strstr(vendor, "ATI")) {
|
||||||
GG.device = GPU_DEVICE_ATI;
|
GG.device = GPU_DEVICE_ATI;
|
||||||
@@ -274,18 +267,23 @@ void gpu_extensions_exit(void)
|
|||||||
|
|
||||||
bool GPU_glsl_support(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)
|
bool GPU_non_power_of_two_support(void)
|
||||||
{
|
{
|
||||||
/* still relevant for OpenGL ES */
|
/* always supported on full GL but still relevant for OpenGL ES */
|
||||||
return !GG.npotdisabled;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPU_display_list_support(void)
|
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)
|
bool GPU_bicubic_bump_support(void)
|
||||||
|
|||||||
@@ -2278,9 +2278,6 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
|
|||||||
GLint lastbindcode;
|
GLint lastbindcode;
|
||||||
int i, liblen, fraglen;
|
int i, liblen, fraglen;
|
||||||
|
|
||||||
if (!GPU_glsl_support())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* TODO(sergey): How to detemine whether we need OSD or not here? */
|
/* TODO(sergey): How to detemine whether we need OSD or not here? */
|
||||||
mat = GPU_material_from_blender(scene, ma, false);
|
mat = GPU_material_from_blender(scene, ma, false);
|
||||||
pass = (mat)? mat->pass: NULL;
|
pass = (mat)? mat->pass: NULL;
|
||||||
|
|||||||
@@ -173,29 +173,10 @@ static GPUShader *gpu_simple_shader(int options)
|
|||||||
|
|
||||||
void GPU_simple_shader_bind(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)
|
if (shader)
|
||||||
GPU_shader_bind(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* temporary hack, should be solved outside of this file */
|
/* temporary hack, should be solved outside of this file */
|
||||||
GPU_MATERIAL_STATE.need_normals = (options & GPU_SHADER_LIGHTING);
|
GPU_MATERIAL_STATE.need_normals = (options & GPU_SHADER_LIGHTING);
|
||||||
@@ -203,16 +184,8 @@ void GPU_simple_shader_bind(int options)
|
|||||||
|
|
||||||
void GPU_simple_shader_unbind(void)
|
void GPU_simple_shader_unbind(void)
|
||||||
{
|
{
|
||||||
if (GPU_glsl_support()) {
|
|
||||||
GPU_shader_unbind();
|
GPU_shader_unbind();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
glDisable(GL_COLOR_MATERIAL);
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Material Colors */
|
/* Material Colors */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user