OpenGL: drop support for EXT_geometry_shader4
authorMike Erwin <significant.bit@gmail.com>
Sat, 8 Apr 2017 06:21:13 +0000 (02:21 -0400)
committerMike Erwin <significant.bit@gmail.com>
Sat, 8 Apr 2017 06:21:13 +0000 (02:21 -0400)
See gpu_shader.c for the main changes.

EXT_geometry_shader4 brought this feature to GL versions < 3.2, but now it's just cluttering up our code.

Soon all platforms will be on version 3.3 so we won't even have to check support at runtime!

source/blender/draw/intern/draw_manager.c
source/blender/gpu/GPU_extensions.h
source/blender/gpu/GPU_shader.h
source/blender/gpu/intern/gpu_basic_shader.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_shader.c
source/blender/gpu/shaders/gpu_shader_fx_dof_hq_geo.glsl
source/blender/gpu/shaders/gpu_shader_geometry.glsl

index d233caedbd15f5eb9ffad110b2c898a328cd5614..100d5994b67aa23a76eb932c50d99847c5b9e9e6 100644 (file)
@@ -325,7 +325,7 @@ void DRW_uniformbuffer_free(GPUUniformBuffer *ubo)
 
 GPUShader *DRW_shader_create(const char *vert, const char *geom, const char *frag, const char *defines)
 {
-       return GPU_shader_create(vert, frag, geom, NULL, defines, 0, 0, 0);
+       return GPU_shader_create(vert, frag, geom, NULL, defines);
 }
 
 GPUShader *DRW_shader_create_with_lib(const char *vert, const char *geom, const char *frag, const char *lib, const char *defines)
@@ -355,7 +355,7 @@ GPUShader *DRW_shader_create_with_lib(const char *vert, const char *geom, const
                BLI_dynstr_free(ds_geom);
        }
 
-       sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines, 0, 0, 0);
+       sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines);
 
        MEM_freeN(vert_with_lib);
        MEM_freeN(frag_with_lib);
@@ -368,17 +368,17 @@ GPUShader *DRW_shader_create_with_lib(const char *vert, const char *geom, const
 
 GPUShader *DRW_shader_create_2D(const char *frag, const char *defines)
 {
-       return GPU_shader_create(datatoc_gpu_shader_2D_vert_glsl, frag, NULL, NULL, defines, 0, 0, 0);
+       return GPU_shader_create(datatoc_gpu_shader_2D_vert_glsl, frag, NULL, NULL, defines);
 }
 
 GPUShader *DRW_shader_create_3D(const char *frag, const char *defines)
 {
-       return GPU_shader_create(datatoc_gpu_shader_3D_vert_glsl, frag, NULL, NULL, defines, 0, 0, 0);
+       return GPU_shader_create(datatoc_gpu_shader_3D_vert_glsl, frag, NULL, NULL, defines);
 }
 
 GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines)
 {
-       return GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, frag, NULL, NULL, defines, 0, 0, 0);
+       return GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, frag, NULL, NULL, defines);
 }
 
 GPUShader *DRW_shader_create_3D_depth_only(void)
index ff00a83d00b68b7cab9eed3df5573eacac047028..8cfab11dbef0d4d420ae1721362dde10d05e4df8 100644 (file)
@@ -45,7 +45,6 @@ bool GPU_full_non_power_of_two_support(void);
 bool GPU_display_list_support(void);
 bool GPU_bicubic_bump_support(void);
 bool GPU_geometry_shader_support(void);
-bool GPU_geometry_shader_support_via_extension(void);
 bool GPU_instanced_drawing_support(void);
 
 int GPU_max_texture_size(void);
index 71a1e3a65917a0bb058e8cd22c346e229a4d425d..5eb137c69c61ece0f86eeeae3416e3a4018edccd 100644 (file)
@@ -55,15 +55,13 @@ GPUShader *GPU_shader_create(
         const char *fragcode,
         const char *geocode,
         const char *libcode,
-        const char *defines,
-        int input, int output, int number);
+        const char *defines);
 GPUShader *GPU_shader_create_ex(
         const char *vertexcode,
         const char *fragcode,
         const char *geocode,
         const char *libcode,
         const char *defines,
-        int input, int output, int number,
         const int flags);
 void GPU_shader_free(GPUShader *shader);
 
index 960181df54552c011d6ad832280d2d565c3d5371..bbd28c8803d3bc19b502f724cb8579cdca3be4ba 100644 (file)
@@ -262,7 +262,7 @@ static GPUShader *gpu_basic_shader(int options)
                        datatoc_gpu_shader_basic_frag_glsl,
                        geom_glsl,
                        NULL,
-                       defines, 0, 0, 0);
+                       defines);
                
                if (shader) {
                        /* set texture map to first texture unit */
index df3b6f962e5551abb50d8ea482a46a40acbb2e21..faf1b907570b982929cb4a564116c5668c2df780 100644 (file)
@@ -1686,9 +1686,6 @@ GPUPass *GPU_generate_pass(
                                      geometrycode,
                                      glsl_material_library,
                                      NULL,
-                                     0,
-                                     0,
-                                     0,
                                      flags);
 
        /* failed? */
index d7ed65e853ebb5f305824f48322c728a8b22120f..175fb9de041cd140a5dd0faa2274789a8f0ff936 100644 (file)
@@ -61,7 +61,6 @@
  * EXT_framebuffer_multisample_blit_scaled: ???
  * ARB_draw_instanced: 3.1
  * ARB_texture_multisample: 3.2
- * EXT_geometry_shader4: 3.2
  * ARB_texture_query_lod: 4.0
  */
 
@@ -334,16 +333,10 @@ bool GPU_bicubic_bump_support(void)
 
 bool GPU_geometry_shader_support(void)
 {
-       /* in GL 3.2 geometry shaders are fully supported
+       /* starting with GL 3.2 geometry shaders are fully supported
         * core profile clashes with our other shaders so accept compatibility only
-        * other GL versions can use EXT_geometry_shader4 if available
         */
-       return (GLEW_VERSION_3_2 && GPU_legacy_support()) || GLEW_EXT_geometry_shader4;
-}
-
-bool GPU_geometry_shader_support_via_extension(void)
-{
-       return GLEW_EXT_geometry_shader4 && !(GLEW_VERSION_3_2 && GPU_legacy_support());
+       return GLEW_VERSION_3_2 && GPU_legacy_support();
 }
 
 bool GPU_instanced_drawing_support(void)
index 1532bf87c7c2183fc7d9c54aa2e76ac5cfb49538..984bad1f6c0f8ff32f849b7643cb5ee2577fe1da 100644 (file)
@@ -207,7 +207,7 @@ static const char *gpu_shader_version(void)
 #endif
 }
 
-static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH], bool use_geometry_shader)
+static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH])
 {
        /* enable extensions for features that are not part of our base GLSL version
         * don't use an extension for something already available!
@@ -219,10 +219,6 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH],
        }
 
 #ifdef WITH_LEGACY_OPENGL
-       if (use_geometry_shader && GPU_geometry_shader_support_via_extension()) {
-               strcat(defines, "#extension GL_EXT_geometry_shader4: enable\n");
-       }
-
        if (GLEW_VERSION_3_1 && !GLEW_VERSION_3_2 && GLEW_ARB_compatibility) {
                strcat(defines, "#extension GL_ARB_compatibility: enable\n");
        }
@@ -236,8 +232,6 @@ static void gpu_shader_standard_extensions(char defines[MAX_EXT_DEFINE_LENGTH],
                        strcat(defines, "#extension GL_EXT_gpu_shader4: require\n");
                }
        }
-#else
-       (void)use_geometry_shader;
 #endif
 }
 
@@ -297,19 +291,13 @@ GPUShader *GPU_shader_create(const char *vertexcode,
                              const char *fragcode,
                              const char *geocode,
                              const char *libcode,
-                             const char *defines,
-                             int input,
-                             int output,
-                             int number)
+                             const char *defines)
 {
        return GPU_shader_create_ex(vertexcode,
                                    fragcode,
                                    geocode,
                                    libcode,
                                    defines,
-                                   input,
-                                   output,
-                                   number,
                                    GPU_SHADER_FLAGS_NONE);
 }
 
@@ -318,9 +306,6 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
                                 const char *geocode,
                                 const char *libcode,
                                 const char *defines,
-                                int input,
-                                int output,
-                                int number,
                                 const int flags)
 {
 #ifdef WITH_OPENSUBDIV
@@ -367,7 +352,7 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
        gpu_shader_standard_defines(standard_defines,
                                    use_opensubdiv,
                                    (flags & GPU_SHADER_FLAGS_NEW_SHADING) != 0);
-       gpu_shader_standard_extensions(standard_extensions, geocode != NULL);
+       gpu_shader_standard_extensions(standard_extensions);
 
        if (vertexcode) {
                const char *source[5];
@@ -459,20 +444,12 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
                        GPU_shader_free(shader);
                        return NULL;
                }
-               
-               if (!use_opensubdiv) {
-                       GPU_shader_geometry_stage_primitive_io(shader, input, output, number);
-               }
        }
 
 #ifdef WITH_OPENSUBDIV
        if (use_opensubdiv) {
                glBindAttribLocation(shader->program, 0, "position");
                glBindAttribLocation(shader->program, 1, "normal");
-               GPU_shader_geometry_stage_primitive_io(shader,
-                                                      GL_LINES_ADJACENCY_EXT,
-                                                      GL_TRIANGLE_STRIP,
-                                                      4);
        }
 #endif
 
@@ -610,16 +587,6 @@ void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value)
        glUniform1i(location, value);
 }
 
-void GPU_shader_geometry_stage_primitive_io(GPUShader *shader, int input, int output, int number)
-{
-       if (GPU_geometry_shader_support_via_extension()) {
-               /* geometry shaders must provide this info themselves for #version 150 and up */
-               glProgramParameteriEXT(shader->program, GL_GEOMETRY_INPUT_TYPE_EXT, input);
-               glProgramParameteriEXT(shader->program, GL_GEOMETRY_OUTPUT_TYPE_EXT, output);
-               glProgramParameteriEXT(shader->program, GL_GEOMETRY_VERTICES_OUT_EXT, number);
-       }
-}
-
 void GPU_shader_uniform_buffer(GPUShader *shader, int location, GPUUniformBuffer *ubo)
 {
        int bindpoint = GPU_uniformbuffer_bindpoint(ubo);
@@ -809,8 +776,7 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
                }
 
                /* common case */
-               builtin_shaders[shader] = GPU_shader_create(stages->vert, stages->frag, stages->geom,
-                                                           NULL, defines, 0, 0, 0);
+               builtin_shaders[shader] = GPU_shader_create(stages->vert, stages->frag, stages->geom, NULL, defines);
        }
 
        return builtin_shaders[shader];
@@ -838,52 +804,51 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effect, bool persp)
 
                switch (effect) {
                        case GPU_SHADER_FX_SSAO:
-                               shader = GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, datatoc_gpu_shader_fx_ssao_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, datatoc_gpu_shader_fx_ssao_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_ONE:
                                strcat(defines, "#define FIRST_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_TWO:
                                strcat(defines, "#define SECOND_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_THREE:
                                strcat(defines, "#define THIRD_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FOUR:
                                strcat(defines, "#define FOURTH_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FIVE:
                                strcat(defines, "#define FIFTH_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_HQ_PASS_ONE:
                                strcat(defines, "#define FIRST_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_HQ_PASS_TWO:
                                strcat(defines, "#define SECOND_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, datatoc_gpu_shader_fx_dof_hq_geo_glsl, datatoc_gpu_shader_fx_lib_glsl,
-                                                          defines, GL_POINTS, GL_TRIANGLE_STRIP, 4);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, datatoc_gpu_shader_fx_dof_hq_geo_glsl, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_HQ_PASS_THREE:
                                strcat(defines, "#define THIRD_PASS\n");
-                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, NULL, datatoc_gpu_shader_fx_lib_glsl, defines);
                                break;
 
                        case GPU_SHADER_FX_DEPTH_RESOLVE:
-                               shader = GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, datatoc_gpu_shader_fx_depth_resolve_glsl, NULL, NULL, defines, 0, 0, 0);
+                               shader = GPU_shader_create(datatoc_gpu_shader_fullscreen_vert_glsl, datatoc_gpu_shader_fx_depth_resolve_glsl, NULL, NULL, defines);
                                break;
                }
 
index c9a726a007ecfdd479e58be1ee20f305965495ec..52d0a9be4996b20fc68fab8061d8fc29f9daa66b 100644 (file)
@@ -5,27 +5,14 @@ uniform vec2 layerselection;
 
 uniform sampler2D cocbuffer;
 
-#if __VERSION__ >= 150
-  layout(points) in;
-  layout(triangle_strip, max_vertices = 4) out;
-
-  #define POS gl_in[0].gl_Position
-#else
-  /* use the EXT_geometry_shader4 way */
-  #define POS gl_PositionIn[0]
-#endif
-
-/* initial uv coordinate */
-#if __VERSION__ < 130
-  varying in vec2 uvcoord[];
-  varying out vec2 particlecoord;
-  varying out vec4 color;
-  #define textureLod texture2DLod
-#else
-  in vec2 uvcoord[];
-  out vec2 particlecoord;
-  flat out vec4 color;
-#endif
+layout(points) in;
+layout(triangle_strip, max_vertices = 4) out;
+
+#define POS gl_in[0].gl_Position
+
+in vec2 uvcoord[];
+out vec2 particlecoord;
+flat out vec4 color;
 
 #define M_PI 3.1415926535897932384626433832795
 
index 545910d39ca8a623aac2e3f2be60b2d0a7ad9095..7586050b2580220fdd9ebe44fc8063c079469e43 100644 (file)
@@ -4,10 +4,8 @@ uniform mat4 ProjectionMatrix;
 uniform int PrimitiveIdBase;
 uniform int osd_active_uv_offset;
 
-#if __VERSION__ >= 150
-  layout(lines_adjacency) in;
-  layout(triangle_strip, max_vertices = 4) out;
-#endif
+layout(lines_adjacency) in;
+layout(triangle_strip, max_vertices = 4) out;
 
 in block {
        VertexData v;