[Mesa-dev] [PATCH v4 6/9] anv: Added support for dynamic and non-dynamic sample locations on Gen7
Eleni Maria Stea
estea at igalia.com
Thu Mar 14 19:52:04 UTC 2019
Allowing setting dynamic and non-dynamic sample locations on Gen7.
v2: Similarly to the previous patches, removed structs and functions
that were used to sort and store the sorted sample positions (Jason
Ekstrand)
---
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 5c618a6666b..82fe5cc93bf 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 VkSampleLocationEXT *sl,
- uint32_t num_samples,
- bool custom_locations);
+void genX(emit_ms_state)(struct anv_batch *batch,
+ const VkSampleLocationEXT *sl,
+ 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 5d7c9b51a84..57dd94bfbd7 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2642,7 +2642,6 @@ 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
struct anv_dynamic_state *dyn_state = &cmd_buffer->state.gfx.dynamic;
uint32_t samples = dyn_state->sample_locations.num_samples;
uint32_t log2_samples;
@@ -2650,11 +2649,9 @@ cmd_buffer_emit_sample_locations(struct anv_cmd_buffer *cmd_buffer)
assert(samples > 0);
log2_samples = __builtin_ffs(samples) - 1;
- genX(emit_multisample)(&cmd_buffer->batch, samples, log2_samples);
- genX(emit_sample_locations)(&cmd_buffer->batch,
- dyn_state->sample_locations.positions,
- samples, true);
-#endif
+ genX(emit_ms_state)(&cmd_buffer->batch,
+ dyn_state->sample_locations.positions,
+ samples, log2_samples, true);
}
void
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index ada022620d1..21b21a719da 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -576,11 +576,8 @@ emit_ms_state(struct anv_pipeline *pipeline,
const VkPipelineMultisampleStateCreateInfo *info,
const VkPipelineDynamicStateCreateInfo *dinfo)
{
-#if GEN_GEN >= 8
VkSampleLocationsInfoEXT *sl;
bool custom_locations = false;
-#endif
-
uint32_t samples = 1;
uint32_t log2_samples = 0;
@@ -589,7 +586,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;
@@ -613,17 +609,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, sl->pSampleLocations,
- samples, custom_locations);
-#endif
+ genX(emit_ms_state)(&pipeline->batch, sl->pSampleLocations, 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 4fdb74111a5..9b05506f3af 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -436,10 +436,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 VkSampleLocationEXT *sl,
+ uint32_t samples,
+ uint32_t log2_samples,
+ bool custom_locations)
{
anv_batch_emit(batch, GENX(3DSTATE_MULTISAMPLE), ms) {
ms.NumberofMultisamples = log2_samples;
@@ -452,31 +454,51 @@ 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:
+ GEN_SAMPLE_POS_1X_ARRAY(ms.Sample, sl);
+ break;
+ case 2:
+ GEN_SAMPLE_POS_2X_ARRAY(ms.Sample, sl);
+ break;
+ case 4:
+ GEN_SAMPLE_POS_4X_ARRAY(ms.Sample, sl);
+ break;
+ case 8:
+ GEN_SAMPLE_POS_8X_ARRAY(ms.Sample, sl);
+ 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 VkSampleLocationEXT *sl,
- uint32_t num_samples,
- bool custom_locations)
+#if GEN_GEN >= 8
+static void
+emit_sample_locations(struct anv_batch *batch,
+ const VkSampleLocationEXT *sl,
+ uint32_t num_samples,
+ bool custom_locations)
{
/* The Skylake PRM Vol. 2a "3DSTATE_SAMPLE_PATTERN" says:
* "When programming the sample offsets (for NUMSAMPLES_4 or _8 and
@@ -495,8 +517,6 @@ genX(emit_sample_locations)(struct anv_batch *batch,
* that it be the one closest to center.
*/
-#if GEN_GEN >= 8
-
#if GEN_GEN == 10
gen10_emit_wa_cs_stall_flush(batch);
#endif
@@ -540,6 +560,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,
+ const VkSampleLocationEXT *sl,
+ uint32_t num_samples,
+ uint32_t log2_samples,
+ bool custom_sample_locations)
+{
+ 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);
#endif
}
--
2.20.1
More information about the mesa-dev
mailing list