summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/amd/vulkan/radv_meta.c31
-rw-r--r--src/amd/vulkan/radv_meta.h15
-rw-r--r--src/amd/vulkan/radv_meta_buffer.c17
-rw-r--r--src/amd/vulkan/radv_meta_clear.c24
-rw-r--r--src/amd/vulkan/radv_meta_copy.c55
-rw-r--r--src/amd/vulkan/radv_meta_resolve_cs.c18
-rw-r--r--src/amd/vulkan/radv_query.c9
7 files changed, 62 insertions, 107 deletions
diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c
index a35e23167a9..3f57618ad28 100644
--- a/src/amd/vulkan/radv_meta.c
+++ b/src/amd/vulkan/radv_meta.c
@@ -149,37 +149,6 @@ radv_meta_restore(const struct radv_meta_saved_state *state,
}
}
-void
-radv_meta_save_compute(struct radv_meta_saved_compute_state *state,
- const struct radv_cmd_buffer *cmd_buffer,
- unsigned push_constant_size)
-{
- 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 (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)
-{
- 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 (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;
- }
-}
-
VkImageViewType
radv_meta_get_view_type(const struct radv_image *image)
{
diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
index 358df705991..d10ec994137 100644
--- a/src/amd/vulkan/radv_meta.h
+++ b/src/amd/vulkan/radv_meta.h
@@ -58,14 +58,6 @@ struct radv_meta_saved_state {
VkRect2D render_area;
};
-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];
-};
-
VkResult radv_device_init_meta_clear_state(struct radv_device *device);
void radv_device_finish_meta_clear_state(struct radv_device *device);
@@ -102,13 +94,6 @@ void radv_meta_save(struct radv_meta_saved_state *saved_state,
void radv_meta_restore(const struct radv_meta_saved_state *state,
struct radv_cmd_buffer *cmd_buffer);
-void radv_meta_save_compute(struct radv_meta_saved_compute_state *state,
- const struct radv_cmd_buffer *cmd_buffer,
- unsigned push_constant_size);
-
-void radv_meta_restore_compute(const struct radv_meta_saved_compute_state *state,
- struct radv_cmd_buffer *cmd_buffer);
-
VkImageViewType radv_meta_get_view_type(const struct radv_image *image);
uint32_t radv_meta_get_iview_layer(const struct radv_image *dest_image,
diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c
index ea11ed18c4f..e009234f045 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -285,9 +285,12 @@ static void fill_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
{
struct radv_device *device = cmd_buffer->device;
uint64_t block_count = round_up_u64(size, 1024);
- struct radv_meta_saved_compute_state saved_state;
+ struct radv_meta_saved_state saved_state;
- radv_meta_save_compute(&saved_state, cmd_buffer, 4);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
struct radv_buffer dst_buffer = {
.bo = bo,
@@ -325,7 +328,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);
+ radv_meta_restore(&saved_state, cmd_buffer);
}
static void copy_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
@@ -336,9 +339,11 @@ static void copy_buffer_shader(struct radv_cmd_buffer *cmd_buffer,
{
struct radv_device *device = cmd_buffer->device;
uint64_t block_count = round_up_u64(size, 1024);
- struct radv_meta_saved_compute_state saved_state;
+ struct radv_meta_saved_state saved_state;
- radv_meta_save_compute(&saved_state, cmd_buffer, 0);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_DESCRIPTORS);
struct radv_buffer dst_buffer = {
.bo = dst_bo,
@@ -389,7 +394,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);
+ radv_meta_restore(&saved_state, cmd_buffer);
}
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index d4a95b8bdda..0f895f8c50f 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1368,11 +1368,6 @@ radv_cmd_clear_image(struct radv_cmd_buffer *cmd_buffer,
}
}
-union meta_saved_state {
- struct radv_meta_saved_state gfx;
- struct radv_meta_saved_compute_state compute;
-};
-
void radv_CmdClearColorImage(
VkCommandBuffer commandBuffer,
VkImage image_h,
@@ -1383,24 +1378,25 @@ void radv_CmdClearColorImage(
{
RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer);
RADV_FROM_HANDLE(radv_image, image, image_h);
- union meta_saved_state saved_state;
+ struct radv_meta_saved_state saved_state;
bool cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE;
- if (cs)
- radv_meta_save_compute(&saved_state.compute, cmd_buffer, 16);
- else
- radv_meta_save(&saved_state.gfx, cmd_buffer,
+ if (cs) {
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
+ } else {
+ radv_meta_save(&saved_state, cmd_buffer,
RADV_META_SAVE_GRAPHICS_PIPELINE |
RADV_META_SAVE_CONSTANTS);
+ }
radv_cmd_clear_image(cmd_buffer, image, imageLayout,
(const VkClearValue *) pColor,
rangeCount, pRanges, cs);
- if (cs)
- radv_meta_restore_compute(&saved_state.compute, cmd_buffer);
- else
- radv_meta_restore(&saved_state.gfx, cmd_buffer);
+ radv_meta_restore(&saved_state, cmd_buffer);
}
void radv_CmdClearDepthStencilImage(
diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index 09bd3ec608a..a42b15a01af 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -100,11 +100,6 @@ blit_surf_for_image_level_layer(struct radv_image *image,
};
}
-union meta_saved_state {
- struct radv_meta_saved_state gfx;
- struct radv_meta_saved_compute_state compute;
-};
-
static void
meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,
struct radv_buffer* buffer,
@@ -113,20 +108,18 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,
const VkBufferImageCopy* pRegions)
{
bool cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE;
- union meta_saved_state saved_state;
+ struct radv_meta_saved_state saved_state;
/* The Vulkan 1.0 spec says "dstImage must have a sample count equal to
* VK_SAMPLE_COUNT_1_BIT."
*/
assert(image->info.samples == 1);
- if (cs)
- radv_meta_save_compute(&saved_state.compute, cmd_buffer, 12);
- else
- radv_meta_save(&saved_state.gfx, cmd_buffer,
- RADV_META_SAVE_GRAPHICS_PIPELINE |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ (cs ? RADV_META_SAVE_COMPUTE_PIPELINE :
+ RADV_META_SAVE_GRAPHICS_PIPELINE) |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (unsigned r = 0; r < regionCount; r++) {
@@ -205,10 +198,8 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,
slice_array++;
}
}
- if (cs)
- radv_meta_restore_compute(&saved_state.compute, cmd_buffer);
- else
- radv_meta_restore(&saved_state.gfx, cmd_buffer);
+
+ radv_meta_restore(&saved_state, cmd_buffer);
}
void radv_CmdCopyBufferToImage(
@@ -234,9 +225,12 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,
uint32_t regionCount,
const VkBufferImageCopy* pRegions)
{
- struct radv_meta_saved_compute_state saved_state;
+ struct radv_meta_saved_state saved_state;
- radv_meta_save_compute(&saved_state, cmd_buffer, 12);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (unsigned r = 0; r < regionCount; r++) {
@@ -307,7 +301,8 @@ meta_copy_image_to_buffer(struct radv_cmd_buffer *cmd_buffer,
slice_array++;
}
}
- radv_meta_restore_compute(&saved_state, cmd_buffer);
+
+ radv_meta_restore(&saved_state, cmd_buffer);
}
void radv_CmdCopyImageToBuffer(
@@ -334,7 +329,7 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
const VkImageCopy *pRegions)
{
bool cs = cmd_buffer->queue_family_index == RADV_QUEUE_COMPUTE;
- union meta_saved_state saved_state;
+ struct radv_meta_saved_state saved_state;
/* From the Vulkan 1.0 spec:
*
@@ -342,13 +337,12 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
* images, but both images must have the same number of samples.
*/
assert(src_image->info.samples == dest_image->info.samples);
- if (cs)
- radv_meta_save_compute(&saved_state.compute, cmd_buffer, 16);
- else
- radv_meta_save(&saved_state.gfx, cmd_buffer,
- RADV_META_SAVE_GRAPHICS_PIPELINE |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
+
+ radv_meta_save(&saved_state, cmd_buffer,
+ (cs ? RADV_META_SAVE_COMPUTE_PIPELINE :
+ RADV_META_SAVE_GRAPHICS_PIPELINE) |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (unsigned r = 0; r < regionCount; r++) {
assert(pRegions[r].srcSubresource.aspectMask ==
@@ -419,10 +413,7 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
}
}
- if (cs)
- radv_meta_restore_compute(&saved_state.compute, cmd_buffer);
- else
- radv_meta_restore(&saved_state.gfx, cmd_buffer);
+ radv_meta_restore(&saved_state, cmd_buffer);
}
void radv_CmdCopyImage(
diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c
index 7104ccd35f5..3833faa1247 100644
--- a/src/amd/vulkan/radv_meta_resolve_cs.c
+++ b/src/amd/vulkan/radv_meta_resolve_cs.c
@@ -377,7 +377,7 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer,
uint32_t region_count,
const VkImageResolve *regions)
{
- struct radv_meta_saved_compute_state saved_state;
+ struct radv_meta_saved_state saved_state;
for (uint32_t r = 0; r < region_count; ++r) {
const VkImageResolve *region = &regions[r];
@@ -393,7 +393,10 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer,
radv_fast_clear_flush_image_inplace(cmd_buffer, src_image, &range);
}
- radv_meta_save_compute(&saved_state, cmd_buffer, 16);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (uint32_t r = 0; r < region_count; ++r) {
const VkImageResolve *region = &regions[r];
@@ -460,7 +463,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);
+ radv_meta_restore(&saved_state, cmd_buffer);
}
/**
@@ -471,7 +474,7 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
{
struct radv_framebuffer *fb = cmd_buffer->state.framebuffer;
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
- struct radv_meta_saved_compute_state saved_state;
+ struct radv_meta_saved_state saved_state;
/* FINISHME(perf): Skip clears for resolve attachments.
*
* From the Vulkan 1.0 spec:
@@ -509,7 +512,10 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer)
radv_fast_clear_flush_image_inplace(cmd_buffer, src_iview->image, &range);
}
- radv_meta_save_compute(&saved_state, cmd_buffer, 16);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (uint32_t i = 0; i < subpass->color_count; ++i) {
VkAttachmentReference src_att = subpass->color_attachments[i];
@@ -527,7 +533,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);
+ radv_meta_restore(&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 40faf22b082..b2ef8055f48 100644
--- a/src/amd/vulkan/radv_query.c
+++ b/src/amd/vulkan/radv_query.c
@@ -649,9 +649,12 @@ static void radv_query_shader(struct radv_cmd_buffer *cmd_buffer,
uint32_t pipeline_stats_mask, uint32_t avail_offset)
{
struct radv_device *device = cmd_buffer->device;
- struct radv_meta_saved_compute_state saved_state;
+ struct radv_meta_saved_state saved_state;
- radv_meta_save_compute(&saved_state, cmd_buffer, 16);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_COMPUTE_PIPELINE |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
struct radv_buffer dst_buffer = {
.bo = dst_bo,
@@ -735,7 +738,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);
+ radv_meta_restore(&saved_state, cmd_buffer);
}
VkResult radv_CreateQueryPool(