Matteo Bruni : wined3d: Use non-deprecated texture sample builtins in shaders on core profile.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Oct 16 09:03:45 CDT 2015


Module: wine
Branch: master
Commit: 78bd9c9811a268fd805c88b6526c5f7a7c942998
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=78bd9c9811a268fd805c88b6526c5f7a7c942998

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Thu Oct 15 22:01:06 2015 +0200

wined3d: Use non-deprecated texture sample builtins in shaders on core profile.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/glsl_shader.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 9373486..34abe5e 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -66,6 +66,7 @@ struct glsl_sample_function
     struct wined3d_string_buffer *name;
     DWORD coord_mask;
     enum wined3d_data_type data_type;
+    BOOL output_single_component;
 };
 
 enum heap_node_op
@@ -2657,21 +2658,24 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
     if (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_CUBE)
         projected = FALSE;
 
-    if (shadow)
-        base = "shadow";
+    if (needs_legacy_glsl_syntax(gl_info))
+    {
+        if (shadow)
+            base = "shadow";
 
-    type_part = resource_types[resource_type].type_part;
-    if (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2D && texrect)
-        type_part = "2DRect";
-    if (!type_part[0])
-        FIXME("Unhandled resource type %#x.\n", resource_type);
+        type_part = resource_types[resource_type].type_part;
+        if (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_2D && texrect)
+            type_part = "2DRect";
+        if (!type_part[0])
+            FIXME("Unhandled resource type %#x.\n", resource_type);
 
-    if (!lod && grad && !gl_info->supported[EXT_GPU_SHADER4])
-    {
-        if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
-            suffix = "ARB";
-        else
-            FIXME("Unsupported grad function.\n");
+        if (!lod && grad && !gl_info->supported[EXT_GPU_SHADER4])
+        {
+            if (gl_info->supported[ARB_SHADER_TEXTURE_LOD])
+                suffix = "ARB";
+            else
+                FIXME("Unsupported grad function.\n");
+        }
     }
 
     sample_function->name = string_buffer_get(priv->string_buffers);
@@ -2682,6 +2686,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
     if (shadow)
         ++coord_size;
     sample_function->coord_mask = (1u << coord_size) - 1;
+    sample_function->output_single_component = shadow && !needs_legacy_glsl_syntax(gl_info);
 }
 
 static void shader_glsl_release_sample_function(const struct wined3d_shader_context *ctx,
@@ -2828,6 +2833,9 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s
 
     shader_glsl_append_dst_ext(ins->ctx->buffer, ins, &ins->dst[0], sample_function->data_type);
 
+    if (sample_function->output_single_component)
+        shader_addline(ins->ctx->buffer, "vec4(");
+
     shader_addline(ins->ctx->buffer, "%s(%s_sampler%u, ",
             sample_function->name->buffer, shader_glsl_get_prefix(version->type), sampler);
 
@@ -2874,6 +2882,9 @@ static void PRINTF_ATTR(8, 9) shader_glsl_gen_sample_code(const struct wined3d_s
     else
         shader_addline(ins->ctx->buffer, ")");
 
+    if (sample_function->output_single_component)
+        shader_addline(ins->ctx->buffer, ")");
+
     shader_addline(ins->ctx->buffer, "%s);\n", dst_swizzle);
 
     if (!is_identity_fixup(fixup))




More information about the wine-cvs mailing list