Commit 35b27b4a authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Implement Vulkan buffer shader resource view descriptors.

parent bd63ec2f
......@@ -1383,6 +1383,7 @@ static void adapter_vk_destroy_shader_resource_view(struct wined3d_shader_resour
vk_buffer_view = &view_vk->u.vk_buffer_view;
else
vk_image_view = &view_vk->u.vk_image_info.imageView;
list_remove(&view_vk->bo_user.entry);
wined3d_shader_resource_view_cleanup(&srv_vk->v);
wined3d_view_vk_destroy(device, vk_buffer_view, vk_image_view,
NULL, NULL, &view_vk->command_buffer_id, srv_vk);
......
......@@ -1336,6 +1336,7 @@ static bool wined3d_context_vk_update_descriptors(struct wined3d_context_vk *con
VkDescriptorSet vk_descriptor_set;
struct wined3d_view_vk *view_vk;
struct wined3d_buffer *buffer;
VkBufferView *buffer_view;
VkDescriptorType type;
VkResult vr;
size_t i;
......@@ -1378,8 +1379,9 @@ static bool wined3d_context_vk_update_descriptors(struct wined3d_context_vk *con
view_vk = &wined3d_shader_resource_view_vk(srv)->view_vk;
if (resource->type == WINED3D_RTYPE_BUFFER)
{
FIXME("Buffer SRV descriptors not implemented.\n");
return false;
image_info = NULL;
buffer_view = &view_vk->u.vk_buffer_view;
type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
}
else
{
......@@ -1389,11 +1391,12 @@ static bool wined3d_context_vk_update_descriptors(struct wined3d_context_vk *con
image_info = &view_vk->u.vk_image_info;
else
image_info = wined3d_texture_vk_get_default_image_info(texture_vk, context_vk);
buffer_view = NULL;
type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
}
if (!wined3d_shader_descriptor_writes_vk_add_write(writes, vk_descriptor_set,
binding->binding_idx, type, NULL, image_info, NULL))
binding->binding_idx, type, NULL, image_info, buffer_view))
return false;
break;
......@@ -1500,6 +1503,7 @@ static void wined3d_context_vk_load_shader_resources(struct wined3d_context_vk *
const struct wined3d_shader_resource_bindings *bindings = &context_vk->compute.bindings;
struct wined3d_shader_descriptor_writes_vk *writes = &context_vk->descriptor_writes;
const struct wined3d_shader_resource_binding *binding;
struct wined3d_shader_resource_view_vk *srv_vk;
struct wined3d_shader_resource_view *srv;
struct wined3d_buffer_vk *buffer_vk;
struct wined3d_buffer *buffer;
......@@ -1527,9 +1531,21 @@ static void wined3d_context_vk_load_shader_resources(struct wined3d_context_vk *
if (!(srv = state->shader_resource_view[binding->shader_type][binding->resource_idx]))
break;
if (srv->resource->type != WINED3D_RTYPE_BUFFER)
srv_vk = wined3d_shader_resource_view_vk(srv);
if (srv->resource->type == WINED3D_RTYPE_BUFFER)
{
if (!srv_vk->view_vk.bo_user.valid)
{
wined3d_shader_resource_view_vk_update(srv_vk, context_vk);
context_invalidate_compute_state(&context_vk->c, STATE_COMPUTE_SHADER_RESOURCE_BINDING);
}
wined3d_buffer_load(buffer_from_resource(srv->resource), &context_vk->c, state);
}
else
{
wined3d_texture_load(texture_from_resource(srv->resource), &context_vk->c, FALSE);
wined3d_context_vk_reference_shader_resource_view(context_vk, wined3d_shader_resource_view_vk(srv));
}
wined3d_context_vk_reference_shader_resource_view(context_vk, srv_vk);
break;
case WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER:
......
......@@ -1011,12 +1011,32 @@ HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view
return hr;
}
void wined3d_shader_resource_view_vk_update(struct wined3d_shader_resource_view_vk *srv_vk,
struct wined3d_context_vk *context_vk)
{
const struct wined3d_format_vk *view_format_vk = wined3d_format_vk(srv_vk->v.format);
const struct wined3d_view_desc *desc = &srv_vk->v.desc;
struct wined3d_resource *resource = srv_vk->v.resource;
struct wined3d_view_vk *view_vk = &srv_vk->view_vk;
struct wined3d_buffer_vk *buffer_vk;
VkBufferView vk_buffer_view;
buffer_vk = wined3d_buffer_vk(buffer_from_resource(resource));
wined3d_context_vk_destroy_buffer_view(context_vk, view_vk->u.vk_buffer_view, view_vk->command_buffer_id);
if ((vk_buffer_view = wined3d_view_vk_create_buffer_view(context_vk, desc, buffer_vk, view_format_vk)))
{
view_vk->u.vk_buffer_view = vk_buffer_view;
view_vk->bo_user.valid = true;
}
}
static void wined3d_shader_resource_view_vk_cs_init(void *object)
{
struct wined3d_shader_resource_view_vk *srv_vk = object;
struct wined3d_view_desc *desc = &srv_vk->v.desc;
struct wined3d_texture_vk *texture_vk;
const struct wined3d_format *format;
struct wined3d_buffer_vk *buffer_vk;
struct wined3d_resource *resource;
struct wined3d_context *context;
VkBufferView vk_buffer_view;
......@@ -1028,9 +1048,11 @@ static void wined3d_shader_resource_view_vk_cs_init(void *object)
if (resource->type == WINED3D_RTYPE_BUFFER)
{
buffer_vk = wined3d_buffer_vk(buffer_from_resource(resource));
context = context_acquire(resource->device, NULL, 0);
vk_buffer_view = wined3d_view_vk_create_buffer_view(wined3d_context_vk(context),
desc, wined3d_buffer_vk(buffer_from_resource(resource)), wined3d_format_vk(format));
desc, buffer_vk, wined3d_format_vk(format));
context_release(context);
if (!vk_buffer_view)
......@@ -1039,6 +1061,8 @@ static void wined3d_shader_resource_view_vk_cs_init(void *object)
TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
srv_vk->view_vk.u.vk_buffer_view = vk_buffer_view;
srv_vk->view_vk.bo_user.valid = true;
list_add_head(&buffer_vk->bo.users, &srv_vk->view_vk.bo_user.entry);
return;
}
......@@ -1087,6 +1111,7 @@ HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view
if (FAILED(hr = wined3d_shader_resource_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
return hr;
list_init(&view_vk->view_vk.bo_user.entry);
wined3d_cs_init_object(resource->device->cs, wined3d_shader_resource_view_vk_cs_init, view_vk);
return hr;
......
......@@ -4698,6 +4698,7 @@ HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view
struct wined3d_view_vk
{
struct wined3d_bo_user_vk bo_user;
union
{
VkBufferView vk_buffer_view;
......@@ -4721,6 +4722,8 @@ static inline struct wined3d_shader_resource_view_vk *wined3d_shader_resource_vi
HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk *view_vk,
const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
void wined3d_shader_resource_view_vk_update(struct wined3d_shader_resource_view_vk *view_vk,
struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
struct wined3d_unordered_access_view
{
......
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