diff options
author | Jason Ekstrand <[email protected]> | 2017-09-28 16:25:31 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-10-12 22:39:29 -0700 |
commit | 2975e4c56a7aeade5a324aa4d446f18cc176fa06 (patch) | |
tree | f08787f03d0781b1d7823095acabf3e86d5522ec /src/intel/vulkan/anv_cmd_buffer.c | |
parent | faad828b16448c1008a1b15ac8d8a72b13005c09 (diff) |
intel: Rewrite the world of push/pull params
This moves us away to the array of pointers model and onto a model where
each param is represented by a generic uint32_t handle. We reserve 2^16
of these handles for builtins that get generated by somewhere inside the
compiler and have well-defined meanings. Generic params have handles
whose meanings are defined by the driver.
The primary downside to this new approach is that it moves a little bit
of the work that we would normally do at compile time to draw time. On
my laptop this hurts OglBatch6 by no more than 1% and doesn't seem to
have any measurable affect on OglBatch7. So, while this may come back
to bite us, it doesn't look too bad.
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_cmd_buffer.c')
-rw-r--r-- | src/intel/vulkan/anv_cmd_buffer.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/intel/vulkan/anv_cmd_buffer.c b/src/intel/vulkan/anv_cmd_buffer.c index 5eec67cb607..64d1417f5b1 100644 --- a/src/intel/vulkan/anv_cmd_buffer.c +++ b/src/intel/vulkan/anv_cmd_buffer.c @@ -629,6 +629,26 @@ anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer, return state; } +static uint32_t +anv_push_constant_value(struct anv_push_constants *data, uint32_t param) +{ + if (BRW_PARAM_IS_BUILTIN(param)) { + switch (param) { + case BRW_PARAM_BUILTIN_ZERO: + return 0; + default: + unreachable("Invalid param builtin"); + } + } else { + uint32_t offset = ANV_PARAM_PUSH_OFFSET(param); + assert(offset % sizeof(uint32_t) == 0); + if (offset < data->size) + return *(uint32_t *)((uint8_t *)data + offset); + else + return 0; + } +} + struct anv_state anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer, gl_shader_stage stage) @@ -653,10 +673,8 @@ anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer, /* 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); - } + for (unsigned i = 0; i < prog_data->nr_params; i++) + u32_map[i] = anv_push_constant_value(data, prog_data->param[i]); anv_state_flush(cmd_buffer->device, state); @@ -695,8 +713,7 @@ anv_cmd_buffer_cs_push_constants(struct anv_cmd_buffer *cmd_buffer) for (unsigned i = 0; i < cs_prog_data->push.cross_thread.dwords; i++) { - uint32_t offset = (uintptr_t)prog_data->param[i]; - u32_map[i] = *(uint32_t *)((uint8_t *)data + offset); + u32_map[i] = anv_push_constant_value(data, prog_data->param[i]); } } @@ -708,8 +725,8 @@ anv_cmd_buffer_cs_push_constants(struct anv_cmd_buffer *cmd_buffer) unsigned src = cs_prog_data->push.cross_thread.dwords; for ( ; src < prog_data->nr_params; src++, dst++) { if (src != cs_prog_data->thread_local_id_index) { - uint32_t offset = (uintptr_t)prog_data->param[src]; - u32_map[dst] = *(uint32_t *)((uint8_t *)data + offset); + u32_map[dst] = + anv_push_constant_value(data, prog_data->param[src]); } else { u32_map[dst] = t * cs_prog_data->simd_size; } |