diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index c239a473f12..286e6eea153 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5813,6 +5813,21 @@ static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer shader_addline(buffer, " discard;\n"); } +static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer, + const struct wined3d_gl_info *gl_info) +{ + if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) + shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n"); + if (gl_info->supported[ARB_TEXTURE_QUERY_LEVELS]) + shader_addline(buffer, "#extension GL_ARB_texture_query_levels : enable\n"); + if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) + shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); + if (gl_info->supported[EXT_GPU_SHADER4]) + shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); + if (gl_info->supported[EXT_TEXTURE_ARRAY]) + shader_addline(buffer, "#extension GL_EXT_texture_array : enable\n"); +} + /* Context activation is done by the caller. */ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context, struct wined3d_string_buffer *buffer, struct wined3d_string_buffer_list *string_buffers, @@ -5835,22 +5850,13 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context shader_addline(buffer, "%s\n", shader_glsl_get_version(gl_info, ®_maps->shader_version)); - if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) - shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n"); + shader_glsl_enable_extensions(buffer, gl_info); if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); - if (gl_info->supported[ARB_TEXTURE_QUERY_LEVELS]) - shader_addline(buffer, "#extension GL_ARB_texture_query_levels : enable\n"); /* The spec says that it doesn't have to be explicitly enabled, but the * nvidia drivers write a warning if we don't do so. */ if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); - if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) - shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); - if (gl_info->supported[EXT_GPU_SHADER4]) - shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); - if (gl_info->supported[EXT_TEXTURE_ARRAY]) - shader_addline(buffer, "#extension GL_EXT_texture_array : enable\n"); /* Base Declarations */ shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx); @@ -5961,20 +5967,11 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context shader_addline(buffer, "%s\n", shader_glsl_get_version(gl_info, ®_maps->shader_version)); + shader_glsl_enable_extensions(buffer, gl_info); if (gl_info->supported[ARB_DRAW_INSTANCED]) shader_addline(buffer, "#extension GL_ARB_draw_instanced : enable\n"); if (gl_info->supported[ARB_EXPLICIT_ATTRIB_LOCATION]) shader_addline(buffer, "#extension GL_ARB_explicit_attrib_location : enable\n"); - if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) - shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n"); - if (gl_info->supported[ARB_TEXTURE_QUERY_LEVELS]) - shader_addline(buffer, "#extension GL_ARB_texture_query_levels : enable\n"); - if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) - shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); - if (gl_info->supported[EXT_GPU_SHADER4]) - shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); - if (gl_info->supported[EXT_TEXTURE_ARRAY]) - shader_addline(buffer, "#extension GL_EXT_texture_array : enable\n"); memset(&priv_ctx, 0, sizeof(priv_ctx)); priv_ctx.cur_vs_args = args; @@ -6057,18 +6054,9 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context shader_addline(buffer, "%s\n", shader_glsl_get_version(gl_info, ®_maps->shader_version)); + shader_glsl_enable_extensions(buffer, gl_info); if (gl_info->supported[ARB_GEOMETRY_SHADER4]) shader_addline(buffer, "#extension GL_ARB_geometry_shader4 : enable\n"); - if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) - shader_addline(buffer, "#extension GL_ARB_shader_bit_encoding : enable\n"); - if (gl_info->supported[ARB_TEXTURE_QUERY_LEVELS]) - shader_addline(buffer, "#extension GL_ARB_texture_query_levels : enable\n"); - if (gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT]) - shader_addline(buffer, "#extension GL_ARB_uniform_buffer_object : enable\n"); - if (gl_info->supported[EXT_GPU_SHADER4]) - shader_addline(buffer, "#extension GL_EXT_gpu_shader4 : enable\n"); - if (gl_info->supported[EXT_TEXTURE_ARRAY]) - shader_addline(buffer, "#extension GL_EXT_texture_array : enable\n"); memset(&priv_ctx, 0, sizeof(priv_ctx)); priv_ctx.string_buffers = string_buffers;