Fixes A8_UNORM views.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- 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 400d3671d3e3..2244db5cb6f6 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 ff2846840892..b8a3568d7efe 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 20e626cd433a..19945cf30e88 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
On Wed, Oct 10, 2018 at 2:33 PM Józef Kucia jkucia@codeweavers.com wrote:
Fixes A8_UNORM views.
Signed-off-by: Józef Kucia jkucia@codeweavers.com
I wrote an almost identical (but a bit uglier) patch before I noticed this one :/ FWIW this fixes the "blocky" text in the Battle.net application with core profile contexts.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com