wined3d: Set texture swizzle for texture views.

Fixes A8_UNORM views.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-10-10 14:33:12 +02:00 committed by Alexandre Julliard
parent 07111f9691
commit ecea7a94c9
3 changed files with 34 additions and 21 deletions

View File

@ -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;
GLint swizzle[4];
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)");
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");
}
}

View File

@ -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);
}

View File

@ -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