vulkan: make VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT conditional
[mesa.git] / src / amd / vulkan / radv_meta.h
index d58b08514fe1b39862a970da9ae945b925eab3a9..c6f63f76e44e6de69403649ae518d7065489b838 100644 (file)
@@ -58,6 +58,33 @@ struct radv_meta_saved_state {
        struct radv_attachment_state *attachments;
        struct radv_framebuffer *framebuffer;
        VkRect2D render_area;
+
+       VkCullModeFlags cull_mode;
+       VkFrontFace front_face;
+
+       unsigned primitive_topology;
+
+       bool depth_test_enable;
+       bool depth_write_enable;
+       unsigned depth_compare_op;
+       bool depth_bounds_test_enable;
+       bool stencil_test_enable;
+
+       struct {
+               struct {
+                       VkStencilOp fail_op;
+                       VkStencilOp pass_op;
+                       VkStencilOp depth_fail_op;
+                       VkCompareOp compare_op;
+               } front;
+
+               struct {
+                       VkStencilOp fail_op;
+                       VkStencilOp pass_op;
+                       VkStencilOp depth_fail_op;
+                       VkCompareOp compare_op;
+               } back;
+       } stencil_op;
 };
 
 VkResult radv_device_init_meta_clear_state(struct radv_device *device, bool on_demand);
@@ -167,14 +194,14 @@ void radv_meta_clear_image_cs(struct radv_cmd_buffer *cmd_buffer,
                              struct radv_meta_blit2d_surf *dst,
                              const VkClearColorValue *clear_color);
 
-void radv_decompress_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
-                                        struct radv_image *image,
-                                        VkImageSubresourceRange *subresourceRange,
-                                        struct radv_sample_locations_state *sample_locs);
-void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer,
-                                         struct radv_image *image,
-                                         VkImageSubresourceRange *subresourceRange,
-                                         struct radv_sample_locations_state *sample_locs);
+void radv_decompress_depth_stencil(struct radv_cmd_buffer *cmd_buffer,
+                                  struct radv_image *image,
+                                  const VkImageSubresourceRange *subresourceRange,
+                                  struct radv_sample_locations_state *sample_locs);
+void radv_resummarize_depth_stencil(struct radv_cmd_buffer *cmd_buffer,
+                                   struct radv_image *image,
+                                   const VkImageSubresourceRange *subresourceRange,
+                                   struct radv_sample_locations_state *sample_locs);
 void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer,
                                         struct radv_image *image,
                                         const VkImageSubresourceRange *subresourceRange);
@@ -212,16 +239,63 @@ void radv_decompress_resolve_src(struct radv_cmd_buffer *cmd_buffer,
                                 const VkImageResolve *regions);
 
 uint32_t radv_clear_cmask(struct radv_cmd_buffer *cmd_buffer,
-                         struct radv_image *image, uint32_t value);
+                         struct radv_image *image,
+                         const VkImageSubresourceRange *range, uint32_t value);
 uint32_t radv_clear_fmask(struct radv_cmd_buffer *cmd_buffer,
-                         struct radv_image *image, uint32_t value);
+                         struct radv_image *image,
+                         const VkImageSubresourceRange *range, uint32_t value);
 uint32_t radv_clear_dcc(struct radv_cmd_buffer *cmd_buffer,
                        struct radv_image *image,
                        const VkImageSubresourceRange *range, uint32_t value);
 uint32_t radv_clear_htile(struct radv_cmd_buffer *cmd_buffer,
-                         struct radv_image *image,
+                         const struct radv_image *image,
                          const VkImageSubresourceRange *range, uint32_t value);
 
+/**
+ * Return whether the bound pipeline is the FMASK decompress pass.
+ */
+static inline bool
+radv_is_fmask_decompress_pipeline(struct radv_cmd_buffer *cmd_buffer)
+{
+       struct radv_meta_state *meta_state = &cmd_buffer->device->meta_state;
+       struct radv_pipeline *pipeline = cmd_buffer->state.pipeline;
+
+       return radv_pipeline_to_handle(pipeline) ==
+              meta_state->fast_clear_flush.fmask_decompress_pipeline;
+}
+
+/**
+ * Return whether the bound pipeline is the DCC decompress pass.
+ */
+static inline bool
+radv_is_dcc_decompress_pipeline(struct radv_cmd_buffer *cmd_buffer)
+{
+       struct radv_meta_state *meta_state = &cmd_buffer->device->meta_state;
+       struct radv_pipeline *pipeline = cmd_buffer->state.pipeline;
+
+       return radv_pipeline_to_handle(pipeline) ==
+              meta_state->fast_clear_flush.dcc_decompress_pipeline;
+}
+
+/**
+ * Return whether the bound pipeline is the hardware resolve path.
+ */
+static inline bool
+radv_is_hw_resolve_pipeline(struct radv_cmd_buffer *cmd_buffer)
+{
+       struct radv_meta_state *meta_state = &cmd_buffer->device->meta_state;
+       struct radv_pipeline *pipeline = cmd_buffer->state.pipeline;
+
+       for (uint32_t i = 0; i < NUM_META_FS_KEYS; ++i) {
+               VkFormat format = radv_fs_key_format_exemplars[i];
+               unsigned fs_key = radv_format_meta_fs_key(format);
+
+               if (radv_pipeline_to_handle(pipeline) == meta_state->resolve.pipeline[fs_key])
+                       return true;
+       }
+       return false;
+}
+
 /* common nir builder helpers */
 #include "nir/nir_builder.h"