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 <jordan.l.justen@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user