[Mesa-dev] [PATCH 08/10] radv: add radv_meta_save() helper
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Oct 3 18:52:43 UTC 2017
And merge radv_meta_save_novertex() with
radv_meta_save_graphics_reset_vport_scissor_novertex().
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/amd/vulkan/radv_meta.c | 33 ++++++++++++---------------------
src/amd/vulkan/radv_meta.h | 7 +++----
src/amd/vulkan/radv_meta_blit.c | 8 ++++----
src/amd/vulkan/radv_meta_clear.c | 27 ++++++++++++---------------
src/amd/vulkan/radv_meta_copy.c | 17 ++++++++---------
src/amd/vulkan/radv_meta_decompress.c | 6 +++---
src/amd/vulkan/radv_meta_fast_clear.c | 6 +++---
src/amd/vulkan/radv_meta_resolve.c | 6 ++----
src/amd/vulkan/radv_meta_resolve_fs.c | 16 ++++++++--------
9 files changed, 55 insertions(+), 71 deletions(-)
diff --git a/src/amd/vulkan/radv_meta.c b/src/amd/vulkan/radv_meta.c
index 83932a84a3..6972a0b592 100644
--- a/src/amd/vulkan/radv_meta.c
+++ b/src/amd/vulkan/radv_meta.c
@@ -30,10 +30,9 @@
#include <pwd.h>
#include <sys/stat.h>
-static void
-radv_meta_save_novertex(struct radv_meta_saved_state *state,
- const struct radv_cmd_buffer *cmd_buffer,
- uint32_t flags)
+void
+radv_meta_save(struct radv_meta_saved_state *state,
+ struct radv_cmd_buffer *cmd_buffer, uint32_t flags)
{
state->flags = flags;
@@ -51,6 +50,15 @@ radv_meta_save_novertex(struct radv_meta_saved_state *state,
typed_memcpy(state->scissor.scissors,
cmd_buffer->state.dynamic.scissor.scissors,
MAX_SCISSORS);
+
+ /* The most common meta operations all want to have the
+ * viewport reset and any scissors disabled. The rest of the
+ * dynamic state should have no effect.
+ */
+ cmd_buffer->state.dynamic.viewport.count = 0;
+ cmd_buffer->state.dynamic.scissor.count = 0;
+ cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT |
+ 1 << VK_DYNAMIC_STATE_SCISSOR;
}
if (state->flags & RADV_META_SAVE_DESCRIPTORS) {
@@ -419,23 +427,6 @@ radv_device_finish_meta(struct radv_device *device)
radv_pipeline_cache_finish(&device->meta_state.cache);
}
-/*
- * The most common meta operations all want to have the viewport
- * reset and any scissors disabled. The rest of the dynamic state
- * should have no effect.
- */
-void
-radv_meta_save_graphics_reset_vport_scissor_novertex(struct radv_meta_saved_state *saved_state,
- struct radv_cmd_buffer *cmd_buffer,
- uint32_t flags)
-{
- radv_meta_save_novertex(saved_state, cmd_buffer, flags);
- cmd_buffer->state.dynamic.viewport.count = 0;
- cmd_buffer->state.dynamic.scissor.count = 0;
- cmd_buffer->state.dirty |= 1 << VK_DYNAMIC_STATE_VIEWPORT |
- 1 << VK_DYNAMIC_STATE_SCISSOR;
-}
-
nir_ssa_def *radv_meta_gen_rect_vertices_comp2(nir_builder *vs_b, nir_ssa_def *comp2)
{
diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h
index 6500c9118c..5c94ff5a84 100644
--- a/src/amd/vulkan/radv_meta.h
+++ b/src/amd/vulkan/radv_meta.h
@@ -95,6 +95,9 @@ void radv_device_finish_meta_resolve_compute_state(struct radv_device *device);
VkResult radv_device_init_meta_resolve_fragment_state(struct radv_device *device);
void radv_device_finish_meta_resolve_fragment_state(struct radv_device *device);
+void radv_meta_save(struct radv_meta_saved_state *saved_state,
+ struct radv_cmd_buffer *cmd_buffer, uint32_t flags);
+
void radv_meta_restore(const struct radv_meta_saved_state *state,
struct radv_cmd_buffer *cmd_buffer);
@@ -182,10 +185,6 @@ void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
struct radv_image *image,
const VkImageSubresourceRange *subresourceRange);
-void radv_meta_save_graphics_reset_vport_scissor_novertex(struct radv_meta_saved_state *saved_state,
- struct radv_cmd_buffer *cmd_buffer,
- uint32_t flags);
-
void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer,
struct radv_image *src_image,
VkImageLayout src_image_layout,
diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c
index 55f9a8807b..6878d3b04e 100644
--- a/src/amd/vulkan/radv_meta_blit.c
+++ b/src/amd/vulkan/radv_meta_blit.c
@@ -512,10 +512,10 @@ void radv_CmdBlitImage(
assert(src_image->info.samples == 1);
assert(dest_image->info.samples == 1);
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (unsigned r = 0; r < regionCount; r++) {
const VkImageSubresourceLayers *src_res = &pRegions[r].srcSubresource;
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 1d137d3303..6dc40fcaca 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -1139,9 +1139,9 @@ radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer *cmd_buffer)
if (!radv_subpass_needs_clear(cmd_buffer))
return;
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS);
for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) {
@@ -1384,10 +1384,9 @@ void radv_CmdClearColorImage(
if (cs)
radv_meta_save_compute(&saved_state.compute, cmd_buffer, 16);
else
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state.gfx, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS);
-
+ radv_meta_save(&saved_state.gfx, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS);
radv_cmd_clear_image(cmd_buffer, image, imageLayout,
(const VkClearValue *) pColor,
@@ -1411,10 +1410,9 @@ void radv_CmdClearDepthStencilImage(
RADV_FROM_HANDLE(radv_image, image, image_h);
struct radv_meta_saved_state saved_state;
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS);
-
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS);
radv_cmd_clear_image(cmd_buffer, image, imageLayout,
(const VkClearValue *) pDepthStencil,
@@ -1438,10 +1436,9 @@ void radv_CmdClearAttachments(
if (!cmd_buffer->state.subpass)
return;
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS);
-
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS);
/* FINISHME: We can do better than this dumb loop. It thrashes too much
* state.
diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index 5272a3af4b..25a9370264 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -123,10 +123,10 @@ meta_copy_buffer_to_image(struct radv_cmd_buffer *cmd_buffer,
if (cs)
radv_meta_save_compute(&saved_state.compute, cmd_buffer, 12);
else
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state.gfx, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
+ radv_meta_save(&saved_state.gfx, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (unsigned r = 0; r < regionCount; r++) {
@@ -345,11 +345,10 @@ meta_copy_image(struct radv_cmd_buffer *cmd_buffer,
if (cs)
radv_meta_save_compute(&saved_state.compute, cmd_buffer, 16);
else
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state.gfx, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
-
+ radv_meta_save(&saved_state.gfx, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (unsigned r = 0; r < regionCount; r++) {
assert(pRegions[r].srcSubresource.aspectMask ==
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index 6aa833ea23..339a38174e 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -319,9 +319,9 @@ static void radv_process_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
if (!image->surface.htile_size)
return;
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_PASS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_PASS);
switch (op) {
case DEPTH_DECOMPRESS:
diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c
index c02e201413..251a02a864 100644
--- a/src/amd/vulkan/radv_meta_fast_clear.c
+++ b/src/amd/vulkan/radv_meta_fast_clear.c
@@ -345,9 +345,9 @@ radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
assert(cmd_buffer->queue_family_index == RADV_QUEUE_GENERAL);
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_PASS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_PASS);
if (image->fmask.size > 0) {
pipeline = cmd_buffer->device->meta_state.fast_clear_flush.fmask_decompress_pipeline;
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 455a8f389c..2fd9cdba63 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -370,8 +370,7 @@ void radv_CmdResolveImage(
return;
}
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS);
+ radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS);
assert(src_image->info.samples > 1);
if (src_image->info.samples <= 1) {
@@ -579,8 +578,7 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer)
return;
}
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS);
+ radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS);
for (uint32_t i = 0; i < subpass->color_count; ++i) {
VkAttachmentReference src_att = subpass->color_attachments[i];
diff --git a/src/amd/vulkan/radv_meta_resolve_fs.c b/src/amd/vulkan/radv_meta_resolve_fs.c
index 3b633f6e5d..13a09d9471 100644
--- a/src/amd/vulkan/radv_meta_resolve_fs.c
+++ b/src/amd/vulkan/radv_meta_resolve_fs.c
@@ -471,10 +471,10 @@ void radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer,
}
rp = device->meta_state.resolve_fragment.rc[samples_log2].render_pass[fs_key];
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (uint32_t r = 0; r < region_count; ++r) {
const VkImageResolve *region = ®ions[r];
@@ -601,10 +601,10 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer)
if (!subpass->has_resolve)
return;
- radv_meta_save_graphics_reset_vport_scissor_novertex(&saved_state, cmd_buffer,
- RADV_META_SAVE_GRAPHICS |
- RADV_META_SAVE_CONSTANTS |
- RADV_META_SAVE_DESCRIPTORS);
+ radv_meta_save(&saved_state, cmd_buffer,
+ RADV_META_SAVE_GRAPHICS |
+ RADV_META_SAVE_CONSTANTS |
+ RADV_META_SAVE_DESCRIPTORS);
for (uint32_t i = 0; i < subpass->color_count; ++i) {
--
2.14.2
More information about the mesa-dev
mailing list