This moves the compute stuff into a anv_push_constants::cs sub-struct.
It also moves dynamic offsets into the push constants. This means we
have to duplicate the data per-stage but that doesn't seem like the end
of the world and one day we may wish to make dynamic offsets per-stage
anyway.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
uint32_t dynamic_offset_start =
layout->set[set_index].dynamic_offset_start;
- /* Assert that everything is in range */
- assert(set_layout->dynamic_offset_count <= *dynamic_offset_count);
- assert(dynamic_offset_start + set_layout->dynamic_offset_count <=
- ARRAY_SIZE(pipe_state->dynamic_offsets));
+ anv_foreach_stage(stage, set_layout->shader_stages) {
+ struct anv_push_constants *push =
+ &cmd_buffer->state.push_constants[stage];
- typed_memcpy(&pipe_state->dynamic_offsets[dynamic_offset_start],
- *dynamic_offsets, set_layout->dynamic_offset_count);
+ /* Assert that everything is in range */
+ assert(set_layout->dynamic_offset_count <= *dynamic_offset_count);
+ assert(dynamic_offset_start + set_layout->dynamic_offset_count <=
+ ARRAY_SIZE(push->dynamic_offsets));
+
+ typed_memcpy(&push->dynamic_offsets[dynamic_offset_start],
+ *dynamic_offsets, set_layout->dynamic_offset_count);
+ }
*dynamic_offsets += set_layout->dynamic_offset_count;
*dynamic_offset_count -= set_layout->dynamic_offset_count;
case BRW_PARAM_BUILTIN_ZERO:
return 0;
case BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_X:
- return data->base_work_group_id[0];
+ return data->cs.base_work_group_id[0];
case BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Y:
- return data->base_work_group_id[1];
+ return data->cs.base_work_group_id[1];
case BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Z:
- return data->base_work_group_id[2];
+ return data->cs.base_work_group_id[2];
default:
unreachable("Invalid param builtin");
}
} else if (ANV_PARAM_IS_DYN_OFFSET(param)) {
unsigned idx = ANV_PARAM_DYN_OFFSET_IDX(param);
assert(idx < MAX_DYNAMIC_BUFFERS);
- return state->dynamic_offsets[idx];
+ return data->dynamic_offsets[idx];
}
assert(!"Invalid param");
#define ANV_PARAM_DYN_OFFSET_IDX(param) ((param) & 0xffff)
struct anv_push_constants {
- /* Push constant data provided by the client through vkPushConstants */
+ /** Push constant data provided by the client through vkPushConstants */
uint8_t client_data[MAX_PUSH_CONSTANTS_SIZE];
- /* Used for vkCmdDispatchBase */
- uint32_t base_work_group_id[3];
+ /** Dynamic offsets for dynamic UBOs and SSBOs */
+ uint32_t dynamic_offsets[MAX_DYNAMIC_BUFFERS];
+
+ struct {
+ /** Base workgroup ID
+ *
+ * Used for vkCmdDispatchBase.
+ */
+ uint32_t base_work_group_id[3];
+
+ /** Subgroup ID
+ *
+ * This is never set by software but is implicitly filled out when
+ * uploading the push constants for compute shaders.
+ */
+ uint32_t subgroup_id;
+ } cs;
};
struct anv_dynamic_state {
struct anv_pipeline *pipeline;
struct anv_descriptor_set *descriptors[MAX_SETS];
- uint32_t dynamic_offsets[MAX_DYNAMIC_BUFFERS];
-
struct anv_push_descriptor_set *push_descriptors[MAX_SETS];
};
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
/* Compute the offset within the buffer */
+ struct anv_push_constants *push =
+ &cmd_buffer->state.push_constants[stage];
+
uint32_t dynamic_offset =
- pipe_state->dynamic_offsets[binding->dynamic_offset_index];
+ push->dynamic_offsets[binding->dynamic_offset_index];
uint64_t offset = desc->offset + dynamic_offset;
/* Clamp to the buffer size */
offset = MIN2(offset, desc->buffer->size);
addr = desc->buffer_view->address;
} else {
assert(desc->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);
+ struct anv_push_constants *push =
+ &cmd_buffer->state.push_constants[stage];
uint32_t dynamic_offset =
- gfx_state->base.dynamic_offsets[range->dynamic_offset_index];
+ push->dynamic_offsets[range->dynamic_offset_index];
addr = anv_address_add(desc->buffer->address,
desc->offset + dynamic_offset);
}
struct anv_push_constants *push =
&cmd_buffer->state.push_constants[MESA_SHADER_COMPUTE];
- if (push->base_work_group_id[0] != baseGroupX ||
- push->base_work_group_id[1] != baseGroupY ||
- push->base_work_group_id[2] != baseGroupZ) {
- push->base_work_group_id[0] = baseGroupX;
- push->base_work_group_id[1] = baseGroupY;
- push->base_work_group_id[2] = baseGroupZ;
+ if (push->cs.base_work_group_id[0] != baseGroupX ||
+ push->cs.base_work_group_id[1] != baseGroupY ||
+ push->cs.base_work_group_id[2] != baseGroupZ) {
+ push->cs.base_work_group_id[0] = baseGroupX;
+ push->cs.base_work_group_id[1] = baseGroupY;
+ push->cs.base_work_group_id[2] = baseGroupZ;
cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_COMPUTE_BIT;
}