Commit ecea7a94 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Set texture swizzle for texture views.

Fixes A8_UNORM views. Signed-off-by: 's avatarJózef Kucia <jkucia@codeweavers.com> Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 07111f96
...@@ -925,6 +925,24 @@ void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined ...@@ -925,6 +925,24 @@ void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined
wined3d_resource_update_draw_binding(&texture->resource); 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. */ /* Context activation is done by the caller. */
void wined3d_texture_bind(struct wined3d_texture *texture, void wined3d_texture_bind(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) struct wined3d_context *context, BOOL srgb)
...@@ -1040,27 +1058,11 @@ void wined3d_texture_bind(struct wined3d_texture *texture, ...@@ -1040,27 +1058,11 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
if (!is_identity_fixup(fixup) && can_use_texture_swizzle(gl_info, format)) if (!is_identity_fixup(fixup) && can_use_texture_swizzle(gl_info, format))
{ {
static const GLenum swizzle_source[] = GLint swizzle[4];
{
GL_ZERO, /* CHANNEL_SOURCE_ZERO */ wined3d_gl_texture_swizzle_from_color_fixup(swizzle, fixup);
GL_ONE, /* CHANNEL_SOURCE_ONE */ gl_info->gl_ops.gl.p_glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
GL_RED, /* CHANNEL_SOURCE_X */ checkGLcall("set format swizzle");
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)");
} }
} }
......
...@@ -207,7 +207,7 @@ static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target ...@@ -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)); level_idx, desc->u.texture.level_count, layer_idx, layer_count));
checkGLcall("create texture view"); 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}; 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 ...@@ -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_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
context_invalidate_state(context, STATE_GRAPHICS_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); context_release(context);
} }
......
...@@ -3390,6 +3390,8 @@ void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, un ...@@ -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, void wined3d_texture_validate_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN; 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_DISCARDED 0x00000001
#define WINED3D_LOCATION_SYSMEM 0x00000002 #define WINED3D_LOCATION_SYSMEM 0x00000002
#define WINED3D_LOCATION_USER_MEMORY 0x00000004 #define WINED3D_LOCATION_USER_MEMORY 0x00000004
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment