summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2018-01-25 11:54:35 +0100
committerIago Toral Quiroga <[email protected]>2018-01-26 14:06:47 +0100
commit75a4802060095da87283e6de8239cdb03147c8d8 (patch)
tree166a518988e7d78514d93aec8b3d6311204ce14f
parente1a49f974bc086c54b567471908f78c53b467072 (diff)
anv/cmd_buffer: add the pipeline layout to the pipeline state
We need to access the pipeline layout to compute correct dynamic offsets for dyamic UBO/SSBO descriptors when we emit draw commands. Instead of taking it from the pipeline object, store the layout in the command buffer pipeline state. Suggested-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/intel/vulkan/anv_cmd_buffer.c8
-rw-r--r--src/intel/vulkan/anv_private.h1
-rw-r--r--src/intel/vulkan/genX_cmd_buffer.c8
3 files changed, 12 insertions, 5 deletions
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c
index 521cf6b6a54..d703d7a8335 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -547,6 +547,14 @@ anv_cmd_buffer_bind_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
cmd_buffer->state.descriptors_dirty |=
set_layout->shader_stages & VK_SHADER_STAGE_ALL_GRAPHICS;
}
+
+ /* Pipeline layout objects are required to live at least while any command
+ * buffers that use them are in recording state. We need to grab a reference
+ * to the pipeline layout being bound here so we can compute correct dynamic
+ * offsets for VK_DESCRIPTOR_TYPE_*_DYNAMIC in dynamic_offset_for_binding()
+ * when we record draw commands that come after this.
+ */
+ pipe_state->layout = layout;
}
void anv_CmdBindDescriptorSets(
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 701a49823e4..257124ca72d 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1694,6 +1694,7 @@ struct anv_attachment_state {
*/
struct anv_cmd_pipeline_state {
struct anv_pipeline *pipeline;
+ struct anv_pipeline_layout *layout;
struct anv_descriptor_set *descriptors[MAX_SETS];
uint32_t dynamic_offsets[MAX_DYNAMIC_BUFFERS];
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index c23a54fb7b9..cd2f69288aa 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1476,7 +1476,6 @@ anv_descriptor_for_binding(const struct anv_cmd_pipeline_state *pipe_state,
static uint32_t
dynamic_offset_for_binding(const struct anv_cmd_pipeline_state *pipe_state,
- const struct anv_pipeline *pipeline,
const struct anv_pipeline_binding *binding)
{
assert(binding->set < MAX_SETS);
@@ -1484,7 +1483,7 @@ dynamic_offset_for_binding(const struct anv_cmd_pipeline_state *pipe_state,
pipe_state->descriptors[binding->set];
uint32_t dynamic_offset_idx =
- pipeline->layout->set[binding->set].dynamic_offset_start +
+ pipe_state->layout->set[binding->set].dynamic_offset_start +
set->layout->binding[binding->binding].dynamic_offset_index +
binding->index;
@@ -1672,7 +1671,7 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
/* Compute the offset within the buffer */
uint32_t dynamic_offset =
- dynamic_offset_for_binding(pipe_state, pipeline, binding);
+ dynamic_offset_for_binding(pipe_state, binding);
uint64_t offset = desc->offset + dynamic_offset;
/* Clamp to the buffer size */
offset = MIN2(offset, desc->buffer->size);
@@ -1947,8 +1946,7 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer,
assert(desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);
uint32_t dynamic_offset =
- dynamic_offset_for_binding(&gfx_state->base,
- pipeline, binding);
+ dynamic_offset_for_binding(&gfx_state->base, binding);
uint32_t buf_offset =
MIN2(desc->offset + dynamic_offset, desc->buffer->size);
uint32_t buf_range =