[Mesa-dev] [PATCH 7/9] anv: Optimized the emission of the default locations on Gen8+

Eleni Maria Stea estea at igalia.com
Mon Mar 11 15:04:57 UTC 2019


We only emit sample locations when the extension is enabled by the user.
In all other cases the default locations are emitted once when the device
is initialized to increase performance.
---
 src/intel/vulkan/anv_genX.h        |  3 ++-
 src/intel/vulkan/genX_cmd_buffer.c |  2 +-
 src/intel/vulkan/genX_pipeline.c   | 11 +++++++----
 src/intel/vulkan/genX_state.c      |  8 +++++---
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h
index e82d83465ef..7f33a2b0a68 100644
--- a/src/intel/vulkan/anv_genX.h
+++ b/src/intel/vulkan/anv_genX.h
@@ -93,4 +93,5 @@ 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);
+                         bool custom_sample_locations,
+                         bool sample_locations_ext_enabled);
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 4752c66f350..ae7c5a80a3c 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2654,7 +2654,7 @@ cmd_buffer_emit_sample_locations(struct anv_cmd_buffer *cmd_buffer)
    anv_samples = cmd_buffer->state.gfx.dynamic.sample_locations.anv_samples;
 
    genX(emit_ms_state)(&cmd_buffer->batch, anv_samples, samples,
-                       log2_samples, true);
+                       log2_samples, true, true);
 }
 
 void
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 8afc08f0320..12adfa65da8 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -573,10 +573,12 @@ emit_sample_mask(struct anv_pipeline *pipeline,
 }
 
 static void
-emit_ms_state(struct anv_pipeline *pipeline,
+emit_ms_state(struct anv_device *device,
+              struct anv_pipeline *pipeline,
               const VkPipelineMultisampleStateCreateInfo *info,
               const VkPipelineDynamicStateCreateInfo *dinfo)
 {
+   bool sample_loc_enabled = device->enabled_extensions.EXT_sample_locations;
    struct anv_sample anv_samples[MAX_SAMPLE_LOCATIONS];
    VkSampleLocationsInfoEXT *sl;
    bool custom_locations = false;
@@ -588,7 +590,7 @@ emit_ms_state(struct anv_pipeline *pipeline,
    if (info) {
       samples = info->rasterizationSamples;
 
-      if (info->pNext) {
+      if (sample_loc_enabled && info->pNext) {
          VkPipelineSampleLocationsStateCreateInfoEXT *slinfo =
             (VkPipelineSampleLocationsStateCreateInfoEXT *)info->pNext;
 
@@ -617,7 +619,7 @@ emit_ms_state(struct anv_pipeline *pipeline,
    }
 
    genX(emit_ms_state)(&pipeline->batch, anv_samples, samples, log2_samples,
-                       custom_locations);
+                       custom_locations, sample_loc_enabled);
 }
 
 static const uint32_t vk_to_gen_logic_op[] = {
@@ -1947,7 +1949,8 @@ genX(graphics_pipeline_create)(
    assert(pCreateInfo->pRasterizationState);
    emit_rs_state(pipeline, pCreateInfo->pRasterizationState,
                  pCreateInfo->pMultisampleState, pass, subpass);
-   emit_ms_state(pipeline, pCreateInfo->pMultisampleState, pCreateInfo->pDynamicState);
+   emit_ms_state(device, pipeline, pCreateInfo->pMultisampleState,
+                 pCreateInfo->pDynamicState);
    emit_ds_state(pipeline, pCreateInfo->pDepthStencilState, pass, subpass);
    emit_cb_state(pipeline, pCreateInfo->pColorBlendState,
                            pCreateInfo->pMultisampleState);
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index 804cfab3a56..bc6b5870d8d 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -552,12 +552,14 @@ 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)
+              bool custom_sample_locations,
+              bool sample_locations_ext_enabled)
 {
    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);
+   if (sample_locations_ext_enabled)
+      emit_sample_locations(batch, anv_samples, num_samples,
+                            custom_sample_locations);
 #endif
 }
-- 
2.20.1



More information about the mesa-dev mailing list