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

Eleni Maria Stea estea at igalia.com
Thu Mar 14 19:52:05 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   | 13 ++++++++-----
 src/intel/vulkan/genX_state.c      |  8 +++++---
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h
index 82fe5cc93bf..f28ee0b1a76 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,
                          const VkSampleLocationEXT *sl,
                          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 57dd94bfbd7..63913dd0668 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2651,7 +2651,7 @@ cmd_buffer_emit_sample_locations(struct anv_cmd_buffer *cmd_buffer)
 
    genX(emit_ms_state)(&cmd_buffer->batch,
                        dyn_state->sample_locations.positions,
-                       samples, log2_samples, true);
+                       samples, log2_samples, true, true);
 }
 
 void
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index 21b21a719da..1245090386c 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -572,10 +572,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;
    VkSampleLocationsInfoEXT *sl;
    bool custom_locations = false;
    uint32_t samples = 1;
@@ -586,7 +588,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;
 
@@ -613,8 +615,8 @@ emit_ms_state(struct anv_pipeline *pipeline,
       log2_samples = __builtin_ffs(samples) - 1;
    }
 
-   genX(emit_ms_state)(&pipeline->batch, sl->pSampleLocations, samples, log2_samples,
-                       custom_locations);
+   genX(emit_ms_state)(&pipeline->batch, sl->pSampleLocations, samples,
+                       log2_samples, custom_locations, sample_loc_enabled);
 }
 
 static const uint32_t vk_to_gen_logic_op[] = {
@@ -1944,7 +1946,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 9b05506f3af..6e13001b74f 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -568,12 +568,14 @@ genX(emit_ms_state)(struct anv_batch *batch,
                     const VkSampleLocationEXT *sl,
                     uint32_t num_samples,
                     uint32_t log2_samples,
-                    bool custom_sample_locations)
+                    bool custom_sample_locations,
+                    bool sample_locations_ext_enabled)
 {
    emit_multisample(batch, sl, num_samples, log2_samples,
                     custom_sample_locations);
 #if GEN_GEN >= 8
-   emit_sample_locations(batch, sl, num_samples,
-                         custom_sample_locations);
+   if (sample_locations_ext_enabled)
+      emit_sample_locations(batch, sl, num_samples,
+                            custom_sample_locations);
 #endif
 }
-- 
2.20.1



More information about the mesa-dev mailing list