wined3d: Create textures views for depth views.

In Direct3D a different format is used for sampling depth textures, but
this is not the case in OpenGL. We still need to create a texture view
when a texture type is different than a view type, or when a shader
resource view is being created for a subset of sub-resources.

Signed-off-by: Józef Kucia <jkucia@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 2017-11-06 10:55:21 +01:00 committed by Alexandre Julliard
parent fcd549345d
commit 14da948b74
3 changed files with 26 additions and 5 deletions

View file

@ -285,16 +285,17 @@ struct wined3d_typeless_format_depth_stencil_info
enum wined3d_format_id depth_stencil_id;
enum wined3d_format_id depth_view_id;
enum wined3d_format_id stencil_view_id;
BOOL separate_depth_view_format;
};
static const struct wined3d_typeless_format_depth_stencil_info typeless_depth_stencil_formats[] =
{
{WINED3DFMT_R32G8X24_TYPELESS, WINED3DFMT_D32_FLOAT_S8X24_UINT,
WINED3DFMT_R32_FLOAT_X8X24_TYPELESS, WINED3DFMT_X32_TYPELESS_G8X24_UINT},
WINED3DFMT_R32_FLOAT_X8X24_TYPELESS, WINED3DFMT_X32_TYPELESS_G8X24_UINT, TRUE},
{WINED3DFMT_R24G8_TYPELESS, WINED3DFMT_D24_UNORM_S8_UINT,
WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_X24_TYPELESS_G8_UINT},
{WINED3DFMT_R32_TYPELESS, WINED3DFMT_D32_FLOAT},
{WINED3DFMT_R16_TYPELESS, WINED3DFMT_D16_UNORM},
WINED3DFMT_R24_UNORM_X8_TYPELESS, WINED3DFMT_X24_TYPELESS_G8_UINT, TRUE},
{WINED3DFMT_R32_TYPELESS, WINED3DFMT_D32_FLOAT, WINED3DFMT_R32_FLOAT},
{WINED3DFMT_R16_TYPELESS, WINED3DFMT_D16_UNORM, WINED3DFMT_R16_UNORM},
};
struct wined3d_format_ddi_info
@ -3536,7 +3537,8 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
typeless_format->flags[j] &= ~(WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL);
}
if ((format_id = typeless_depth_stencil_formats[i].depth_view_id))
if ((format_id = typeless_depth_stencil_formats[i].depth_view_id)
&& typeless_depth_stencil_formats[i].separate_depth_view_format)
{
if (!(depth_view_format = get_format_internal(gl_info, format_id)))
return FALSE;
@ -3753,6 +3755,19 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl
return format;
}
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
enum wined3d_format_id view_format_id)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i)
{
if (typeless_depth_stencil_formats[i].typeless_id == resource_format_id)
return typeless_depth_stencil_formats[i].depth_view_id == view_format_id;
}
return FALSE;
}
void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch)
{

View file

@ -712,6 +712,10 @@ static void wined3d_shader_resource_view_cs_init(void *object)
{
create_texture_view(&view->gl_view, view_target, desc, texture, view_format);
}
else if (wined3d_format_is_depth_view(resource->format->id, view_format->id))
{
create_texture_view(&view->gl_view, view_target, desc, texture, resource->format);
}
else
{
FIXME("Shader resource view not supported, resource format %s, view format %s.\n",

View file

@ -4244,6 +4244,8 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
const struct wined3d_color *color) DECLSPEC_HIDDEN;
void wined3d_format_get_float_color_key(const struct wined3d_format *format,
const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;