summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-09-11 15:56:19 -0700
committerJason Ekstrand <[email protected]>2015-09-11 15:56:19 -0700
commit8c8ad6dddf127e7a4facd40ec378a93a5719e5b1 (patch)
tree4d47d7394b6a6ed8223f0d8ad1b32641f9252502
parent2b4a2eb592fab5a61abeaa9b60c14bdc9d565fce (diff)
vk: Use push constants for dynamic buffers
-rw-r--r--src/vulkan/anv_cmd_buffer.c44
-rw-r--r--src/vulkan/anv_compiler.cpp8
2 files changed, 29 insertions, 23 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c
index c2024e4dd60..cca5cfae3ef 100644
--- a/src/vulkan/anv_cmd_buffer.c
+++ b/src/vulkan/anv_cmd_buffer.c
@@ -326,17 +326,28 @@ void anv_CmdBindDescriptorSets(
ANV_FROM_HANDLE(anv_descriptor_set, set, pDescriptorSets[i]);
set_layout = layout->set[firstSet + i].layout;
- cmd_buffer->state.descriptors[firstSet + i].set = set;
+ if (cmd_buffer->state.descriptors[firstSet + i].set != set) {
+ cmd_buffer->state.descriptors[firstSet + i].set = set;
+ cmd_buffer->state.descriptors_dirty |= set_layout->shader_stages;
+ }
+
+ if (set_layout->num_dynamic_buffers > 0) {
+ uint32_t s;
+ for_each_bit(s, set_layout->shader_stages) {
+ anv_cmd_buffer_ensure_push_constant_field(cmd_buffer, s,
+ dynamic_offsets);
+ uint32_t *offsets =
+ cmd_buffer->state.push_constants[s]->dynamic_offsets +
+ layout->set[firstSet + i].dynamic_offset_start;
- assert(set_layout->num_dynamic_buffers <
- ARRAY_SIZE(cmd_buffer->state.descriptors[0].dynamic_offsets));
- memcpy(cmd_buffer->state.descriptors[firstSet + i].dynamic_offsets,
- pDynamicOffsets + dynamic_slot,
- set_layout->num_dynamic_buffers * sizeof(*pDynamicOffsets));
+ memcpy(offsets, pDynamicOffsets + dynamic_slot,
+ set_layout->num_dynamic_buffers * sizeof(*pDynamicOffsets));
- cmd_buffer->state.descriptors_dirty |= set_layout->shader_stages;
+ }
+ cmd_buffer->state.push_constants_dirty |= set_layout->shader_stages;
- dynamic_slot += set_layout->num_dynamic_buffers;
+ dynamic_slot += set_layout->num_dynamic_buffers;
+ }
}
}
@@ -464,21 +475,8 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
if (state.map == NULL)
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
- uint32_t offset;
- if (surface_slots[b].dynamic_slot >= 0) {
- uint32_t dynamic_offset =
- d->dynamic_offsets[surface_slots[b].dynamic_slot];
-
- offset = view->offset + dynamic_offset;
- anv_fill_buffer_surface_state(cmd_buffer->device,
- state.map, view->format, offset,
- view->range - dynamic_offset);
- } else {
- offset = view->offset;
- memcpy(state.map, view->surface_state.map, 64);
- }
-
- add_surface_state_reloc(cmd_buffer, state, view->bo, offset);
+ memcpy(state.map, view->surface_state.map, 64);
+ add_surface_state_reloc(cmd_buffer, state, view->bo, view->offset);
bt_map[start + b] = state.offset;
}
diff --git a/src/vulkan/anv_compiler.cpp b/src/vulkan/anv_compiler.cpp
index e19486ac95d..dcd5581f957 100644
--- a/src/vulkan/anv_compiler.cpp
+++ b/src/vulkan/anv_compiler.cpp
@@ -26,6 +26,7 @@
#include <fcntl.h>
#include "anv_private.h"
+#include "anv_nir.h"
#include <brw_context.h>
#include <brw_wm.h> /* brw_new_shader_program is here */
@@ -130,6 +131,9 @@ create_params_array(struct anv_pipeline *pipeline,
num_params += MAX_PUSH_CONSTANTS_SIZE / sizeof(float);
}
+ if (pipeline->layout && pipeline->layout->stage[stage].has_dynamic_offsets)
+ num_params += MAX_DYNAMIC_BUFFERS;
+
if (num_params == 0)
return;
@@ -212,6 +216,8 @@ really_do_vs_prog(struct brw_context *brw,
mem_ctx = ralloc_context(NULL);
create_params_array(pipeline, vs, &prog_data->base.base);
+ anv_nir_apply_dynamic_offsets(pipeline, vs->Program->nir,
+ &prog_data->base.base);
GLbitfield64 outputs_written = vp->program.Base.OutputsWritten;
prog_data->inputs_read = vp->program.Base.InputsRead;
@@ -501,6 +507,7 @@ really_do_wm_prog(struct brw_context *brw,
prog_data->computed_depth_mode = computed_depth_mode(&fp->program);
create_params_array(pipeline, fs, &prog_data->base);
+ anv_nir_apply_dynamic_offsets(pipeline, fs->Program->nir, &prog_data->base);
prog_data->barycentric_interp_modes =
brw_compute_barycentric_interp_modes(brw, key->flat_shade,
@@ -607,6 +614,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
set_binding_table_layout(&prog_data->base, pipeline, VK_SHADER_STAGE_COMPUTE);
create_params_array(pipeline, cs, &prog_data->base);
+ anv_nir_apply_dynamic_offsets(pipeline, cs->Program->nir, &prog_data->base);
program = brw_cs_emit(brw, mem_ctx, key, prog_data,
&cp->program, prog, &program_size);