diff options
author | Jason Ekstrand <[email protected]> | 2015-11-10 15:14:11 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-11-10 15:14:11 -0800 |
commit | 9d18555c8d24f9037f3e4094c6aa5b80604b9324 (patch) | |
tree | 9138a6a13ba60c1f9e404b1f6cf1c62037561440 | |
parent | 427978d9334d887715e00c7609a36aedaac1b4cf (diff) |
anv/gen7: Add push constant support
-rw-r--r-- | src/vulkan/gen7_cmd_buffer.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/vulkan/gen7_cmd_buffer.c b/src/vulkan/gen7_cmd_buffer.c index af76126c3a9..b3619df2c2e 100644 --- a/src/vulkan/gen7_cmd_buffer.c +++ b/src/vulkan/gen7_cmd_buffer.c @@ -29,6 +29,40 @@ #include "anv_private.h" +static void +gen7_cmd_buffer_flush_push_constants(struct anv_cmd_buffer *cmd_buffer) +{ + static const uint32_t push_constant_opcodes[] = { + [VK_SHADER_STAGE_VERTEX] = 21, + [VK_SHADER_STAGE_TESS_CONTROL] = 25, /* HS */ + [VK_SHADER_STAGE_TESS_EVALUATION] = 26, /* DS */ + [VK_SHADER_STAGE_GEOMETRY] = 22, + [VK_SHADER_STAGE_FRAGMENT] = 23, + [VK_SHADER_STAGE_COMPUTE] = 0, + }; + + VkShaderStage stage; + VkShaderStageFlags flushed = 0; + + for_each_bit(stage, cmd_buffer->state.push_constants_dirty) { + struct anv_state state = anv_cmd_buffer_push_constants(cmd_buffer, stage); + + if (state.offset == 0) + continue; + + anv_batch_emit(&cmd_buffer->batch, GEN7_3DSTATE_CONSTANT_VS, + ._3DCommandSubOpcode = push_constant_opcodes[stage], + .ConstantBody = { + .PointerToConstantBuffer0 = { .offset = state.offset }, + .ConstantBuffer0ReadLength = DIV_ROUND_UP(state.alloc_size, 32), + }); + + flushed |= 1 << stage; + } + + cmd_buffer->state.push_constants_dirty &= ~flushed; +} + void gen7_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer) @@ -256,6 +290,9 @@ gen7_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) if (cmd_buffer->state.descriptors_dirty) anv_flush_descriptor_sets(cmd_buffer); + if (cmd_buffer->state.push_constants_dirty) + gen7_cmd_buffer_flush_push_constants(cmd_buffer); + if (cmd_buffer->state.dirty & ANV_CMD_DIRTY_DYNAMIC_VIEWPORT) anv_cmd_buffer_emit_viewport(cmd_buffer); |