From 4f946d87a220706d35150c7b525712d97db14914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Fri, 22 Jul 2016 12:28:16 +0200 Subject: [PATCH] wined3d: Introduce helper function for enabling common GLSL extensions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 48 ++++++++++++++------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) 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;