summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-09-26 23:26:20 +0200
committerSamuel Pitoiset <[email protected]>2017-09-27 09:26:44 +0200
commit8860b39d9432216dd40b825fc5750d3601b6cf4e (patch)
tree671c3a14818c9ed08f1712bf6e99ff03e96096fe
parentbd7fd6a0e4e9bfe3f713955c511b6ca6a6120231 (diff)
radv: store the amount of saved constants in the compute state
It's safer and more elegant. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r--src/amd/vulkan/radv_meta.c15
-rw-r--r--src/amd/vulkan/radv_meta.h4
-rw-r--r--src/amd/vulkan/radv_meta_buffer.c4
-rw-r--r--src/amd/vulkan/radv_meta_clear.c2
-rw-r--r--src/amd/vulkan/radv_meta_copy.c6
-rw-r--r--src/amd/vulkan/radv_meta_resolve_cs.c4
-rw-r--r--src/amd/vulkan/radv_query.c2
7 files changed, 20 insertions, 17 deletions
diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c
index 2e16c9b9f46..3ddbc2e9af4 100644
--- a/src/amd/vulkan/radv_meta.c
+++ b/src/amd/vulkan/radv_meta.c
@@ -112,23 +112,26 @@ radv_meta_save_compute(struct radv_meta_saved_compute_state *state,
{
state->old_pipeline = cmd_buffer->state.compute_pipeline;
state->old_descriptor_set0 = cmd_buffer->state.descriptors[0];
+ state->push_constant_size = push_constant_size;
- if (push_constant_size)
- memcpy(state->push_constants, cmd_buffer->push_constants, push_constant_size);
+ if (state->push_constant_size) {
+ memcpy(state->push_constants, cmd_buffer->push_constants,
+ state->push_constant_size);
+ }
}
void
radv_meta_restore_compute(const struct radv_meta_saved_compute_state *state,
- struct radv_cmd_buffer *cmd_buffer,
- unsigned push_constant_size)
+ struct radv_cmd_buffer *cmd_buffer)
{
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE,
radv_pipeline_to_handle(state->old_pipeline));
cmd_buffer->state.descriptors[0] = state->old_descriptor_set0;
- if (push_constant_size) {
- memcpy(cmd_buffer->push_constants, state->push_constants, push_constant_size);
+ if (state->push_constant_size) {
+ memcpy(cmd_buffer->push_constants, state->push_constants,
+ state->push_constant_size);
cmd_buffer->push_constant_stages |= VK_SHADER_STAGE_COMPUTE_BIT;
}
}
diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
index 8a443fa1b17..20b4498ab3a 100644
--- a/src/amd/vulkan/radv_meta.h
+++ b/src/amd/vulkan/radv_meta.h
@@ -56,6 +56,7 @@ struct radv_meta_saved_compute_state {
struct radv_descriptor_set *old_descriptor_set0;
struct radv_pipeline *old_pipeline;
+ unsigned push_constant_size;
char push_constants[128];
};
@@ -103,8 +104,7 @@ void radv_meta_save_compute(struct radv_meta_saved_compute_state *state,
unsigned push_constant_size);
void radv_meta_restore_compute(const struct radv_meta_saved_compute_state *state,
- struct radv_cmd_buffer *cmd_buffer,
- unsigned push_constant_size);
+ struct radv_cmd_buffer *cmd_buffer);
VkImageViewType radv_meta_get_view_type(const struct radv_image *image);
diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c
index a16c65aab81..14f848664c2 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -340,7 +340,7 @@ static void fill_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
radv_CmdDispatch(radv_cmd_buffer_to_handle(cmd_buffer), block_count, 1, 1);
- radv_meta_restore_compute(&saved_state, cmd_buffer, 4);
+ radv_meta_restore_compute(&saved_state, cmd_buffer);
}
static void copy_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
@@ -404,7 +404,7 @@ static void copy_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
radv_CmdDispatch(radv_cmd_buffer_to_handle(cmd_buffer), block_count, 1, 1);
- radv_meta_restore_compute(&saved_state, cmd_buffer, 0);
+ radv_meta_restore_compute(&saved_state, cmd_buffer);
}
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index b1cbb505ad0..62c920e869f 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1401,7 +1401,7 @@ void radv_CmdClearColorImage(
rangeCount, pRanges, cs);
if (cs)
- radv_meta_restore_compute(&saved_state.compute, cmd_buffer, 16);
+ radv_meta_restore_compute(&saved_state.compute, cmd_buffer);
else
radv_meta_restore(&saved_state.gfx, cmd_buffer);
}
diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index fdef37f39f0..f3e41ff0569 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -203,7 +203,7 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,
}
}
if (cs)
- radv_meta_restore_compute(&saved_state.compute, cmd_buffer, 12);
+ radv_meta_restore_compute(&saved_state.compute, cmd_buffer);
else
radv_meta_restore(&saved_state.gfx, cmd_buffer);
}
@@ -304,7 +304,7 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,
slice_array++;
}
}
- radv_meta_restore_compute(&saved_state, cmd_buffer, 12);
+ radv_meta_restore_compute(&saved_state, cmd_buffer);
}
void radv_CmdCopyImageToBuffer(
@@ -414,7 +414,7 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
}
if (cs)
- radv_meta_restore_compute(&saved_state.compute, cmd_buffer, 16);
+ radv_meta_restore_compute(&saved_state.compute, cmd_buffer);
else
radv_meta_restore(&saved_state.gfx, cmd_buffer);
}
diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c
index ce02884d2d6..05a212b6d93 100644
--- a/src/amd/vulkan/radv_meta_resolve_cs.c
+++ b/src/amd/vulkan/radv_meta_resolve_cs.c
@@ -462,7 +462,7 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer,
&(VkExtent2D) {extent.width, extent.height });
}
}
- radv_meta_restore_compute(&saved_state, cmd_buffer, 16);
+ radv_meta_restore_compute(&saved_state, cmd_buffer);
}
/**
@@ -529,7 +529,7 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
&(VkExtent2D) { fb->width, fb->height });
}
- radv_meta_restore_compute(&saved_state, cmd_buffer, 16);
+ radv_meta_restore_compute(&saved_state, cmd_buffer);
for (uint32_t i = 0; i < subpass->color_count; ++i) {
VkAttachmentReference dest_att = subpass->resolve_attachments[i];
diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c
index 1dbc493e1b7..f63497a4457 100644
--- a/src/amd/vulkan/radv_query.c
+++ b/src/amd/vulkan/radv_query.c
@@ -737,7 +737,7 @@ static void radv_query_shader(struct radv_cmd_buffer *cmd_buffer,
RADV_CMD_FLAG_INV_VMEM_L1 |
RADV_CMD_FLAG_CS_PARTIAL_FLUSH;
- radv_meta_restore_compute(&saved_state, cmd_buffer, 16);
+ radv_meta_restore_compute(&saved_state, cmd_buffer);
}
VkResult radv_CreateQueryPool(