=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Set texture swizzle for texture views.

Alexandre Julliard julliard at winehq.org
Wed Oct 10 15:41:01 CDT 2018


Module: wine
Branch: master
Commit: ecea7a94c94e28e23ddc6ea179f1367435c2eddb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ecea7a94c94e28e23ddc6ea179f1367435c2eddb

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Wed Oct 10 14:33:12 2018 +0200

wined3d: Set texture swizzle for texture views.

Fixes A8_UNORM views.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
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/texture.c         | 44 ++++++++++++++++++++++--------------------
 dlls/wined3d/view.c            | 11 ++++++++++-
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 400d367..2244db5 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -925,6 +925,24 @@ void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined
     wined3d_resource_update_draw_binding(&texture->resource);
 }
 
+void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup)
+{
+    static const GLenum swizzle_source[] =
+    {
+        GL_ZERO,  /* CHANNEL_SOURCE_ZERO */
+        GL_ONE,   /* CHANNEL_SOURCE_ONE */
+        GL_RED,   /* CHANNEL_SOURCE_X */
+        GL_GREEN, /* CHANNEL_SOURCE_Y */
+        GL_BLUE,  /* CHANNEL_SOURCE_Z */
+        GL_ALPHA, /* CHANNEL_SOURCE_W */
+    };
+
+    swizzle[0] = swizzle_source[fixup.x_source];
+    swizzle[1] = swizzle_source[fixup.y_source];
+    swizzle[2] = swizzle_source[fixup.z_source];
+    swizzle[3] = swizzle_source[fixup.w_source];
+}
+
 /* Context activation is done by the caller. */
 void wined3d_texture_bind(struct wined3d_texture *texture,
         struct wined3d_context *context, BOOL srgb)
@@ -1040,27 +1058,11 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
 
     if (!is_identity_fixup(fixup) && can_use_texture_swizzle(gl_info, format))
     {
-        static const GLenum swizzle_source[] =
-        {
-            GL_ZERO,  /* CHANNEL_SOURCE_ZERO */
-            GL_ONE,   /* CHANNEL_SOURCE_ONE */
-            GL_RED,   /* CHANNEL_SOURCE_X */
-            GL_GREEN, /* CHANNEL_SOURCE_Y */
-            GL_BLUE,  /* CHANNEL_SOURCE_Z */
-            GL_ALPHA, /* CHANNEL_SOURCE_W */
-        };
-        struct
-        {
-            GLint x, y, z, w;
-        }
-        swizzle;
-
-        swizzle.x = swizzle_source[fixup.x_source];
-        swizzle.y = swizzle_source[fixup.y_source];
-        swizzle.z = swizzle_source[fixup.z_source];
-        swizzle.w = swizzle_source[fixup.w_source];
-        gl_info->gl_ops.gl.p_glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, &swizzle.x);
-        checkGLcall("glTexParameteriv(GL_TEXTURE_SWIZZLE_RGBA)");
+        GLint swizzle[4];
+
+        wined3d_gl_texture_swizzle_from_color_fixup(swizzle, fixup);
+        gl_info->gl_ops.gl.p_glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+        checkGLcall("set format swizzle");
     }
 }
 
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c
index ff28468..b8a3568 100644
--- a/dlls/wined3d/view.c
+++ b/dlls/wined3d/view.c
@@ -207,7 +207,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
             level_idx, desc->u.texture.level_count, layer_idx, layer_count));
     checkGLcall("create texture view");
 
-    if (is_stencil_view_format(&view_format_gl->f))
+    if (is_stencil_view_format(view_format))
     {
         static const GLint swizzle[] = {GL_ZERO, GL_RED, GL_ZERO, GL_ZERO};
 
@@ -226,6 +226,15 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target
         context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
         context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
     }
+    else if (!is_identity_fixup(view_format->color_fixup) && can_use_texture_swizzle(gl_info, view_format))
+    {
+        GLint swizzle[4];
+
+        context_bind_texture(context, view->target, view->name);
+        wined3d_gl_texture_swizzle_from_color_fixup(swizzle, view_format->color_fixup);
+        gl_info->gl_ops.gl.p_glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+        checkGLcall("set format swizzle");
+    }
 
     context_release(context);
 }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 20e626c..19945cf 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3390,6 +3390,8 @@ void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, un
 void wined3d_texture_validate_location(struct wined3d_texture *texture,
         unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
 
+void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
+
 #define WINED3D_LOCATION_DISCARDED      0x00000001
 #define WINED3D_LOCATION_SYSMEM         0x00000002
 #define WINED3D_LOCATION_USER_MEMORY    0x00000004




More information about the wine-cvs mailing list