[Mesa-dev] [PATCH v5 08/11] anv: Added support for dynamic sample locations
Jason Ekstrand
jason at jlekstrand.net
Fri Mar 15 00:08:27 UTC 2019
From: Eleni Maria Stea <estea at igalia.com>
Added support for setting the locations when the pipeline has been
created with the dynamic state bit enabled according to the Vulkan
Specification section [26.5. Custom Sample Locations] for the function:
'vkCmdSetSampleLocationsEXT'
The reason that we preferred to store the boolean valid inside the
dynamic state struct for locations instead of using a dirty bit
(ANV_CMD_DIRTY_SAMPLE_LOCATIONS for example) is that other functions
can modify the value of the dirty bits causing unexpected behavior.
v2: Removed all the anv* structs used with sample locations to store
the locations in order for dynamic case. (see also the patch for
the non-dynamic case. (Jason Ekstrand)
---
src/intel/vulkan/anv_cmd_buffer.c | 17 +++++++++++++++++
src/intel/vulkan/anv_private.h | 6 ++++++
src/intel/vulkan/genX_cmd_buffer.c | 11 +++++++++++
3 files changed, 34 insertions(+)
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c
index 1b34644a434..7f31300857b 100644
--- a/src/intel/vulkan/anv_cmd_buffer.c
+++ b/src/intel/vulkan/anv_cmd_buffer.c
@@ -558,6 +558,23 @@ void anv_CmdSetStencilReference(
cmd_buffer->state.gfx.dirty |= ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE;
}
+void
+anv_CmdSetSampleLocationsEXT(VkCommandBuffer commandBuffer,
+ const VkSampleLocationsInfoEXT *pSampleLocationsInfo)
+{
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
+
+ struct anv_dynamic_state *dyn_state = &cmd_buffer->state.gfx.dynamic;
+ uint32_t samples = pSampleLocationsInfo->sampleLocationsPerPixel;
+
+ assert(pSampleLocationsInfo);
+ dyn_state->sample_locations.samples = samples;
+ typed_memcpy(dyn_state->sample_locations.locations,
+ pSampleLocationsInfo->pSampleLocations, samples);
+
+ dyn_state->sample_locations.valid = true;
+}
+
static void
anv_cmd_buffer_bind_descriptor_set(struct anv_cmd_buffer *cmd_buffer,
VkPipelineBindPoint bind_point,
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index a39195733cd..94c9db14028 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2124,6 +2124,12 @@ struct anv_dynamic_state {
uint32_t front;
uint32_t back;
} stencil_reference;
+
+ struct {
+ bool valid;
+ uint32_t samples;
+ VkSampleLocationEXT locations[MAX_SAMPLE_LOCATIONS];
+ } sample_locations;
};
extern const struct anv_dynamic_state default_dynamic_state;
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 7687507e6b7..5d2b17cf8ae 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2796,6 +2796,17 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
ANV_CMD_DIRTY_RENDER_TARGETS))
gen7_cmd_buffer_emit_scissor(cmd_buffer);
+ if (cmd_buffer->state.gfx.dynamic.sample_locations.valid) {
+ uint32_t samples = cmd_buffer->state.gfx.dynamic.sample_locations.samples;
+ const VkSampleLocationEXT *locations =
+ cmd_buffer->state.gfx.dynamic.sample_locations.locations;
+ genX(emit_multisample)(&cmd_buffer->batch, samples, locations);
+#if GEN_GEN >= 8
+ genX(emit_sample_pattern)(&cmd_buffer->batch, samples, locations);
+#endif
+ cmd_buffer->state.gfx.dynamic.sample_locations.valid = false;
+ }
+
genX(cmd_buffer_flush_dynamic_state)(cmd_buffer);
genX(cmd_buffer_apply_pipe_flushes)(cmd_buffer);
--
2.20.1
More information about the mesa-dev
mailing list