[Mesa-stable] [PATCH] anv: fix push descriptors with set > 0
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Wed Sep 27 16:57:22 UTC 2017
When writing to set > 0, we were just wrongly writing to set 0. This
commit fixes this by allocating each set from the dynamic state stream
as we write to them.
Cc: "17.2 17.1" <mesa-stable at lists.freedesktop.org>
Fixes: 9f60ed98e501 ("anv: add VK_KHR_push_descriptor support")
Reported-by: Daniel Ribeiro Maciel <daniel.maciel at gmail.com>
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/vulkan/anv_cmd_buffer.c | 35 +++++++++++++++++++++++++++++------
src/intel/vulkan/anv_private.h | 2 +-
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c
index 3b59af8f6f4..3a80a4994b1 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -216,8 +216,8 @@ static VkResult anv_create_cmd_buffer(
anv_state_stream_init(&cmd_buffer->dynamic_state_stream,
&device->dynamic_state_pool, 16384);
- memset(&cmd_buffer->state.push_descriptor, 0,
- sizeof(cmd_buffer->state.push_descriptor));
+ memset(cmd_buffer->state.push_descriptors, 0,
+ sizeof(cmd_buffer->state.push_descriptors));
if (pool) {
list_addtail(&cmd_buffer->pool_link, &pool->cmd_buffers);
@@ -834,6 +834,24 @@ anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer *cmd_buffer)
return iview;
}
+static struct anv_push_descriptor_set *
+anv_cmd_buffer_ensure_push_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
+ uint32_t set)
+{
+ assert(set < MAX_SETS);
+ if (!cmd_buffer->state.push_descriptors[set]) {
+ struct anv_state state =
+ anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
+ sizeof(*cmd_buffer->state.push_descriptors[set]), 8);
+ cmd_buffer->state.push_descriptors[set] = state.map;
+
+ memset(cmd_buffer->state.push_descriptors[set], 0,
+ sizeof(*cmd_buffer->state.push_descriptors[set]));
+ }
+
+ return cmd_buffer->state.push_descriptors[set];
+}
+
void anv_CmdPushDescriptorSetKHR(
VkCommandBuffer commandBuffer,
VkPipelineBindPoint pipelineBindPoint,
@@ -851,12 +869,14 @@ void anv_CmdPushDescriptorSetKHR(
const struct anv_descriptor_set_layout *set_layout =
layout->set[_set].layout;
- struct anv_descriptor_set *set = &cmd_buffer->state.push_descriptor.set;
+ struct anv_push_descriptor_set *push_set =
+ anv_cmd_buffer_ensure_push_descriptor_set(cmd_buffer, _set);
+ struct anv_descriptor_set *set = &push_set->set;
set->layout = set_layout;
set->size = anv_descriptor_set_layout_size(set_layout);
set->buffer_count = set_layout->buffer_count;
- set->buffer_views = cmd_buffer->state.push_descriptor.buffer_views;
+ set->buffer_views = push_set->buffer_views;
/* Go through the user supplied descriptors. */
for (uint32_t i = 0; i < descriptorWriteCount; i++) {
@@ -937,12 +957,15 @@ void anv_CmdPushDescriptorSetWithTemplateKHR(
const struct anv_descriptor_set_layout *set_layout =
layout->set[_set].layout;
- struct anv_descriptor_set *set = &cmd_buffer->state.push_descriptor.set;
+
+ struct anv_push_descriptor_set *push_set =
+ anv_cmd_buffer_ensure_push_descriptor_set(cmd_buffer, _set);
+ struct anv_descriptor_set *set = &push_set->set;
set->layout = set_layout;
set->size = anv_descriptor_set_layout_size(set_layout);
set->buffer_count = set_layout->buffer_count;
- set->buffer_views = cmd_buffer->state.push_descriptor.buffer_views;
+ set->buffer_views = push_set->buffer_views;
anv_descriptor_set_write_template(set,
cmd_buffer->device,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 3ba623a37fd..11ff33c8912 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1686,7 +1686,7 @@ struct anv_cmd_state {
struct anv_dynamic_state dynamic;
bool need_query_wa;
- struct anv_push_descriptor_set push_descriptor;
+ struct anv_push_descriptor_set * push_descriptors[MAX_SETS];
/**
* Whether or not the gen8 PMA fix is enabled. We ensure that, at the top
--
2.14.2
More information about the mesa-stable
mailing list