[Mesa-dev] [PATCH v2 6/9] anv: Added support for dynamic and non-dynamic sample locations on Gen7

Eleni Maria Stea estea at igalia.com
Tue Mar 12 10:34:51 UTC 2019


Allowing setting dynamic and non-dynamic sample locations on Gen7.
---
 src/intel/vulkan/anv_genX.h        | 13 ++---
 src/intel/vulkan/genX_cmd_buffer.c |  9 ++--
 src/intel/vulkan/genX_pipeline.c   | 13 +----
 src/intel/vulkan/genX_state.c      | 86 +++++++++++++++++++++---------
 4 files changed, 70 insertions(+), 51 deletions(-)

diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h
index f84fe457152..e82d83465ef 100644
--- a/src/intel/vulkan/anv_genX.h
+++ b/src/intel/vulkan/anv_genX.h
@@ -89,11 +89,8 @@ void genX(cmd_buffer_mi_memset)(struct anv_cmd_buffer *cmd_buffer,
 void genX(blorp_exec)(struct blorp_batch *batch,
                       const struct blorp_params *params);
 
-void genX(emit_multisample)(struct anv_batch *batch,
-                            uint32_t samples,
-                            uint32_t log2_samples);
-
-void genX(emit_sample_locations)(struct anv_batch *batch,
-                                 const struct anv_sample *anv_samples,
-                                 uint32_t num_samples,
-                                 bool custom_locations);
+void genX(emit_ms_state)(struct anv_batch *batch,
+                         struct anv_sample *anv_samples,
+                         uint32_t num_samples,
+                         uint32_t log2_samples,
+                         bool custom_sample_locations);
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 9229df84caa..4752c66f350 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2643,8 +2643,7 @@ cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer,
 static void
 cmd_buffer_emit_sample_locations(struct anv_cmd_buffer *cmd_buffer)
 {
-#if GEN_GEN >= 8
-   const struct anv_sample *anv_samples;
+   struct anv_sample *anv_samples;
    uint32_t log2_samples;
    uint32_t samples;
 
@@ -2654,10 +2653,8 @@ cmd_buffer_emit_sample_locations(struct anv_cmd_buffer *cmd_buffer)
    log2_samples = __builtin_ffs(samples) - 1;
    anv_samples = cmd_buffer->state.gfx.dynamic.sample_locations.anv_samples;
 
-   genX(emit_multisample)(&cmd_buffer->batch, samples, log2_samples);
-   genX(emit_sample_locations)(&cmd_buffer->batch, anv_samples, samples,
-                              true);
-#endif
+   genX(emit_ms_state)(&cmd_buffer->batch, anv_samples, samples,
+                       log2_samples, true);
 }
 
 void
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index fa42e622077..8afc08f0320 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -577,12 +577,9 @@ emit_ms_state(struct anv_pipeline *pipeline,
               const VkPipelineMultisampleStateCreateInfo *info,
               const VkPipelineDynamicStateCreateInfo *dinfo)
 {
-#if GEN_GEN >= 8
    struct anv_sample anv_samples[MAX_SAMPLE_LOCATIONS];
    VkSampleLocationsInfoEXT *sl;
    bool custom_locations = false;
-#endif
-
    uint32_t samples = 1;
    uint32_t log2_samples = 0;
 
@@ -591,7 +588,6 @@ emit_ms_state(struct anv_pipeline *pipeline,
    if (info) {
       samples = info->rasterizationSamples;
 
-#if GEN_GEN >= 8
       if (info->pNext) {
          VkPipelineSampleLocationsStateCreateInfoEXT *slinfo =
             (VkPipelineSampleLocationsStateCreateInfoEXT *)info->pNext;
@@ -616,17 +612,12 @@ emit_ms_state(struct anv_pipeline *pipeline,
             }
          }
       }
-#endif
 
       log2_samples = __builtin_ffs(samples) - 1;
    }
 
-   genX(emit_multisample(&pipeline->batch, samples, log2_samples));
-
-#if GEN_GEN >= 8
-   genX(emit_sample_locations)(&pipeline->batch, anv_samples, samples,
-                               custom_locations);
-#endif
+   genX(emit_ms_state)(&pipeline->batch, anv_samples, samples, log2_samples,
+                       custom_locations);
 }
 
 static const uint32_t vk_to_gen_logic_op[] = {
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index 44cfc925ed5..804cfab3a56 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -437,10 +437,12 @@ VkResult genX(CreateSampler)(
    return VK_SUCCESS;
 }
 
-void
-genX(emit_multisample)(struct anv_batch *batch,
-                       uint32_t samples,
-                       uint32_t log2_samples)
+static void
+emit_multisample(struct anv_batch *batch,
+                 const struct anv_sample *anv_samples,
+                 uint32_t samples,
+                 uint32_t log2_samples,
+                 bool custom_locations)
 {
    anv_batch_emit(batch, GENX(3DSTATE_MULTISAMPLE), ms) {
       ms.NumberofMultisamples = log2_samples;
@@ -453,34 +455,52 @@ genX(emit_multisample)(struct anv_batch *batch,
        */
       ms.PixelPositionOffsetEnable  = false;
 #else
-      switch (samples) {
-      case 1:
-         GEN_SAMPLE_POS_1X(ms.Sample);
-         break;
-      case 2:
-         GEN_SAMPLE_POS_2X(ms.Sample);
-         break;
-      case 4:
-         GEN_SAMPLE_POS_4X(ms.Sample);
-         break;
-      case 8:
-         GEN_SAMPLE_POS_8X(ms.Sample);
-         break;
-      default:
-         break;
+      if (custom_locations) {
+         switch (samples) {
+         case 1:
+            SET_SAMPLE_POS(ms.Sample, 0);
+            break;
+         case 2:
+            SET_SAMPLE_POS_2X(ms.Sample);
+            break;
+         case 4:
+            SET_SAMPLE_POS_4X(ms.Sample);
+            break;
+         case 8:
+            SET_SAMPLE_POS_8X(ms.Sample);
+            break;
+         default:
+            break;
+         }
+      } else {
+         switch (samples) {
+         case 1:
+            GEN_SAMPLE_POS_1X(ms.Sample);
+            break;
+         case 2:
+            GEN_SAMPLE_POS_2X(ms.Sample);
+            break;
+         case 4:
+            GEN_SAMPLE_POS_4X(ms.Sample);
+            break;
+         case 8:
+            GEN_SAMPLE_POS_8X(ms.Sample);
+            break;
+         default:
+            break;
+         }
       }
 #endif
    }
 }
 
-void
-genX(emit_sample_locations)(struct anv_batch *batch,
-                            const struct anv_sample *anv_samples,
-                            uint32_t num_samples,
-                            bool custom_locations)
-{
 #if GEN_GEN >= 8
-
+static void
+emit_sample_locations(struct anv_batch *batch,
+                      const struct anv_sample *anv_samples,
+                      uint32_t num_samples,
+                      bool custom_locations)
+{
 #if GEN_GEN == 10
    gen10_emit_wa_cs_stall_flush(batch);
 #endif
@@ -524,6 +544,20 @@ genX(emit_sample_locations)(struct anv_batch *batch,
 #if GEN_GEN == 10
    gen10_emit_wa_lri_to_cache_mode_zero(batch);
 #endif
+}
+#endif
 
+void
+genX(emit_ms_state)(struct anv_batch *batch,
+              struct anv_sample *anv_samples,
+              uint32_t num_samples,
+              uint32_t log2_samples,
+              bool custom_sample_locations)
+{
+   emit_multisample(batch, anv_samples, num_samples, log2_samples,
+                    custom_sample_locations);
+#if GEN_GEN >= 8
+   emit_sample_locations(batch, anv_samples, num_samples,
+                         custom_sample_locations);
 #endif
 }
-- 
2.20.1



More information about the mesa-dev mailing list