diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-26 02:31:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-26 02:33:14 +0300 |
commit | 1b6da95ccb1180924bc13d7c3a404aff15e08572 (patch) | |
tree | ad62f82977ef01596073eb20aab065ffe7a95b80 | |
parent | 13933352274c9a3493d0b2c9e607d2c2c9d75ff9 (diff) |
Cleanup: avoid static vars to store legacy shaders
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 4cbdefc09a9..4456f13e223 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -1111,28 +1111,28 @@ static const GPUShaderStages builtin_shader_stages[GPU_NUM_BUILTIN_SHADERS] = { GPUShader *GPU_shader_get_builtin_shader(eGPUBuiltinShader shader) { - BLI_assert(shader != GPU_NUM_BUILTIN_SHADERS); /* don't be a troll */ + BLI_assert(shader < GPU_NUM_BUILTIN_SHADERS); if (builtin_shaders[shader] == NULL) { + GPUShaderStages stages_legacy = {NULL}; const GPUShaderStages *stages = &builtin_shader_stages[shader]; - if (shader == GPU_SHADER_EDGES_FRONT_BACK_PERSP && !GLEW_VERSION_3_2) { + if (shader == GPU_SHADER_EDGES_FRONT_BACK_PERSP) { /* TODO: remove after switch to core profile (maybe) */ - static const GPUShaderStages legacy_fancy_edges = { - .vert = datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl, - .frag = datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl, - }; - stages = &legacy_fancy_edges; + if (!GLEW_VERSION_3_2) { + stages_legacy.vert = datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl; + stages_legacy.frag = datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl; + stages = &stages_legacy; + } } - - if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR && !GLEW_VERSION_3_2) { + else if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR) { /* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */ /* TODO: remove after switch to core profile (maybe) */ - static const GPUShaderStages legacy_dashed_lines = { - .vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl, - .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, - }; - stages = &legacy_dashed_lines; + if (!GLEW_VERSION_3_2) { + stages_legacy.vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl; + stages_legacy.frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl; + stages = &stages_legacy; + } } /* common case */ |