}
}
-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)
{
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);
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,
{
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,
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,
{
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,
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);
}
}
}
-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,
{
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(
};
}
-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,
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++) {
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(
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++) {
slice_array++;
}
}
- radv_meta_restore_compute(&saved_state, cmd_buffer);
+
+ radv_meta_restore(&saved_state, cmd_buffer);
}
void radv_CmdCopyImageToBuffer(
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:
*
* 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 ==
}
}
- 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(
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 = ®ions[r];
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 = ®ions[r];
&(VkExtent2D) {extent.width, extent.height });
}
}
- radv_meta_restore_compute(&saved_state, cmd_buffer);
+ radv_meta_restore(&saved_state, 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:
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];
&(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];
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,
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(