summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_cmd_buffer.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-08-26 17:57:51 -0700
committerJason Ekstrand <[email protected]>2015-08-27 10:25:58 -0700
commit4e3ee043c0ab68faf5c853dd361e68974b55e8db (patch)
tree7dbdd2282e477ee430db279d7de47ff334cac8cd /src/vulkan/anv_cmd_buffer.c
parent375a65d5de218fc3686b6b2bc719acf1c82a410c (diff)
vk/gen8: Add support for push constants
Diffstat (limited to 'src/vulkan/anv_cmd_buffer.c')
-rw-r--r--src/vulkan/anv_cmd_buffer.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index a2a2833b62e..963edcf06ca 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -661,6 +661,34 @@ void anv_CmdWaitEvents(
stub();
}
+struct anv_state
+anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer,
+ VkShaderStage stage)
+{
+ struct anv_push_constant_data *data =
+ cmd_buffer->state.push_constants[stage].data;
+ struct brw_stage_prog_data *prog_data =
+ cmd_buffer->state.pipeline->prog_data[stage];
+
+ /* If we don't actually have any push constants, bail. */
+ if (data == NULL || prog_data->nr_params == 0)
+ return (struct anv_state) { .offset = 0 };
+
+ struct anv_state state =
+ anv_cmd_buffer_alloc_dynamic_state(cmd_buffer,
+ prog_data->nr_params * sizeof(float),
+ 32 /* bottom 5 bits MBZ */);
+
+ /* Walk through the param array and fill the buffer with data */
+ uint32_t *u32_map = state.map;
+ for (unsigned i = 0; i < prog_data->nr_params; i++) {
+ uint32_t offset = (uintptr_t)prog_data->param[i];
+ u32_map[i] = *(uint32_t *)((uint8_t *)data + offset);
+ }
+
+ return state;
+}
+
void anv_CmdPushConstants(
VkCmdBuffer cmdBuffer,
VkPipelineLayout layout,