wined3d: Implement structured buffer views.

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-02-23 15:00:57 +01:00 committed by Alexandre Julliard
parent d867c6aa1e
commit 48e1989cb9
1 changed files with 49 additions and 13 deletions

View File

@ -187,12 +187,14 @@ static void create_buffer_view(struct wined3d_gl_view *view,
if (desc->format_id == WINED3DFMT_UNKNOWN) if (desc->format_id == WINED3DFMT_UNKNOWN)
{ {
FIXME("Structured buffer views not supported.\n"); offset = desc->u.buffer.start_idx * buffer->desc.structure_byte_stride;
return; size = desc->u.buffer.count * buffer->desc.structure_byte_stride;
}
else
{
offset = desc->u.buffer.start_idx * view_format->byte_count;
size = desc->u.buffer.count * view_format->byte_count;
} }
offset = desc->u.buffer.start_idx * view_format->byte_count;
size = desc->u.buffer.count * view_format->byte_count;
create_buffer_texture(view, buffer, view_format, offset, size); create_buffer_texture(view, buffer, view_format, offset, size);
} }
@ -546,14 +548,31 @@ static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_
if (resource->type == WINED3D_RTYPE_BUFFER) if (resource->type == WINED3D_RTYPE_BUFFER)
{ {
struct wined3d_buffer *buffer = buffer_from_resource(resource); struct wined3d_buffer *buffer = buffer_from_resource(resource);
unsigned int buffer_size, element_size;
if (view_format->byte_count) if (buffer->desc.structure_byte_stride)
{ {
unsigned int buffer_size = buffer->resource.size / view_format->byte_count; if (desc->format_id != WINED3DFMT_UNKNOWN)
if (desc->u.buffer.start_idx >= buffer_size {
|| desc->u.buffer.count > buffer_size - desc->u.buffer.start_idx) WARN("Invalid format %s for structured buffer view.\n", debug_d3dformat(desc->format_id));
return E_INVALIDARG; return E_INVALIDARG;
}
view_format = wined3d_get_format(gl_info, WINED3DFMT_R32_UINT, resource->usage);
element_size = buffer->desc.structure_byte_stride;
} }
else
{
element_size = view_format->byte_count;
}
if (!element_size)
return E_INVALIDARG;
buffer_size = buffer->resource.size / element_size;
if (desc->u.buffer.start_idx >= buffer_size
|| desc->u.buffer.count > buffer_size - desc->u.buffer.start_idx)
return E_INVALIDARG;
} }
else else
{ {
@ -756,14 +775,31 @@ static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_acces
if (resource->type == WINED3D_RTYPE_BUFFER) if (resource->type == WINED3D_RTYPE_BUFFER)
{ {
struct wined3d_buffer *buffer = buffer_from_resource(resource); struct wined3d_buffer *buffer = buffer_from_resource(resource);
unsigned int buffer_size, element_size;
if (view->format->byte_count) if (buffer->desc.structure_byte_stride)
{ {
unsigned int buffer_size = buffer->resource.size / view->format->byte_count; if (desc->format_id != WINED3DFMT_UNKNOWN)
if (desc->u.buffer.start_idx >= buffer_size {
|| desc->u.buffer.count > buffer_size - desc->u.buffer.start_idx) WARN("Invalid format %s for structured buffer view.\n", debug_d3dformat(desc->format_id));
return E_INVALIDARG; return E_INVALIDARG;
}
view->format = wined3d_get_format(gl_info, WINED3DFMT_R32_UINT, resource->usage);
element_size = buffer->desc.structure_byte_stride;
} }
else
{
element_size = view->format->byte_count;
}
if (!element_size)
return E_INVALIDARG;
buffer_size = buffer->resource.size / element_size;
if (desc->u.buffer.start_idx >= buffer_size
|| desc->u.buffer.count > buffer_size - desc->u.buffer.start_idx)
return E_INVALIDARG;
} }
else else
{ {