wined3d: Fix wined3d_rendertarget_view_desc validation for 3D textures.

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 2016-06-08 14:54:58 +02:00 committed by Alexandre Julliard
parent 723f73aeb6
commit 6c39a1aeab
1 changed files with 12 additions and 3 deletions

View File

@ -109,12 +109,21 @@ static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *
else else
{ {
struct wined3d_texture *texture = texture_from_resource(resource); struct wined3d_texture *texture = texture_from_resource(resource);
unsigned int depth_or_layer_count;
if (resource->type == WINED3D_RTYPE_TEXTURE_3D)
depth_or_layer_count = wined3d_texture_get_level_depth(texture, desc->u.texture.level_idx);
else
depth_or_layer_count = texture->layer_count;
if (desc->u.texture.level_idx >= texture->level_count if (desc->u.texture.level_idx >= texture->level_count
|| desc->u.texture.layer_idx >= texture->layer_count || desc->u.texture.layer_idx >= depth_or_layer_count
|| desc->u.texture.layer_count > texture->layer_count - desc->u.texture.layer_idx) || desc->u.texture.layer_count > depth_or_layer_count - desc->u.texture.layer_idx)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
view->sub_resource_idx = desc->u.texture.layer_idx * texture->level_count + desc->u.texture.level_idx;
view->sub_resource_idx = desc->u.texture.level_idx;
if (resource->type != WINED3D_RTYPE_TEXTURE_3D)
view->sub_resource_idx += desc->u.texture.layer_idx * texture->level_count;
view->buffer_offset = 0; view->buffer_offset = 0;
view->width = wined3d_texture_get_level_width(texture, desc->u.texture.level_idx); view->width = wined3d_texture_get_level_width(texture, desc->u.texture.level_idx);
view->height = wined3d_texture_get_level_height(texture, desc->u.texture.level_idx); view->height = wined3d_texture_get_level_height(texture, desc->u.texture.level_idx);