diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-05-15 15:29:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-05-15 16:02:46 +0300 |
commit | 0538d00cc23904779183f5ea86d1e83c1c0fe90d (patch) | |
tree | 21fa400fbe1c6a6d7dccd0c55b7b6ff5cba77e2d /source/blender/gpu/intern | |
parent | 86580c437bb51a5a9c5f7875ad414bd619083886 (diff) |
Cleanup: Put GPU_state_init inside gpu_state.c
Also put glDisable(GL_DITHER) in it since we don't even use it (but is
enabled by default).
Also leave GL_MULTISAMPLE on by default since it has no impact on non-MSAA
framebuffers.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 63 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.c | 40 |
3 files changed, 40 insertions, 67 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 350c616e359..2a8a4d416d8 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1481,66 +1481,3 @@ void GPU_free_images_old(Main *bmain) ima = ima->id.next; } } - -static void gpu_disable_multisample(void) -{ -#ifdef __linux__ - /* changing multisample from the default (enabled) causes problems on some - * systems (NVIDIA/Linux) when the pixel format doesn't have a multisample buffer */ - bool toggle_ok = true; - - if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_UNIX, GPU_DRIVER_ANY)) { - int samples = 0; - glGetIntegerv(GL_SAMPLES, &samples); - - if (samples == 0) { - toggle_ok = false; - } - } - - if (toggle_ok) { - glDisable(GL_MULTISAMPLE); - } -#else - glDisable(GL_MULTISAMPLE); -#endif -} - -/* Default OpenGL State - * - * This is called on startup, for opengl offscreen render. - * Generally we should always return to this state when - * temporarily modifying the state for drawing, though that are (undocumented) - * exceptions that we should try to get rid of. */ - -void GPU_state_init(void) -{ - GPU_program_point_size(false); - - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - - glDepthFunc(GL_LEQUAL); - - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_COLOR_LOGIC_OP); - glDisable(GL_STENCIL_TEST); - - glDepthRange(0.0, 1.0); - - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glDisable(GL_CULL_FACE); - - gpu_disable_multisample(); - - /* This is a bit dangerous since addons could change this. */ - glEnable(GL_PRIMITIVE_RESTART); - glPrimitiveRestartIndex((GLuint)0xFFFFFFFF); - - /* TODO: Should become default. But needs at least GL 4.3 */ - if (GLEW_ARB_ES3_compatibility) { - /* Takes predecence over GL_PRIMITIVE_RESTART */ - glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); - } -} diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index e6092b55fc4..5af9364b92c 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -541,10 +541,6 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb) } #endif - if (fb->multisample) { - glEnable(GL_MULTISAMPLE); - } - glViewport(0, 0, fb->width, fb->height); } diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index d6f044a79e3..908f5fa5771 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -370,4 +370,44 @@ void gpuPopAttr(void) #undef Attr #undef AttrStack +/* Default OpenGL State + * + * This is called on startup, for opengl offscreen render. + * Generally we should always return to this state when + * temporarily modifying the state for drawing, though that are (undocumented) + * exceptions that we should try to get rid of. */ + +void GPU_state_init(void) +{ + GPU_program_point_size(false); + + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDisable(GL_COLOR_LOGIC_OP); + glDisable(GL_STENCIL_TEST); + glDisable(GL_DITHER); + + glDepthFunc(GL_LEQUAL); + glDepthRange(0.0, 1.0); + + glFrontFace(GL_CCW); + glCullFace(GL_BACK); + glDisable(GL_CULL_FACE); + + /* Is default but better be explicit. */ + glEnable(GL_MULTISAMPLE); + + /* This is a bit dangerous since addons could change this. */ + glEnable(GL_PRIMITIVE_RESTART); + glPrimitiveRestartIndex((GLuint)0xFFFFFFFF); + + /* TODO: Should become default. But needs at least GL 4.3 */ + if (GLEW_ARB_ES3_compatibility) { + /* Takes predecence over GL_PRIMITIVE_RESTART */ + glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); + } +} + /** \} */ |