mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-30 15:50:32 +01:00
tu: Rework passing shared consts
The way this works now is awkward to map to shader objects. We don't have the pipeline layout when "linking" shaders at draw time, so we have to piece it together from the shaders. Store the information we need in the shaders and piece it together. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25276>
This commit is contained in:
parent
efaf77bbdd
commit
26352d26bf
5 changed files with 28 additions and 35 deletions
|
|
@ -4309,10 +4309,10 @@ tu6_emit_shared_consts(struct tu_cs *cs,
|
|||
uint32_t *push_constants,
|
||||
bool compute)
|
||||
{
|
||||
if (pipeline->shared_consts.dwords > 0) {
|
||||
if (pipeline->program.shared_consts.dwords > 0) {
|
||||
/* Offset and num_units for shared consts are in units of dwords. */
|
||||
unsigned num_units = pipeline->shared_consts.dwords;
|
||||
unsigned offset = pipeline->shared_consts.lo;
|
||||
unsigned num_units = pipeline->program.shared_consts.dwords;
|
||||
unsigned offset = pipeline->program.shared_consts.lo;
|
||||
|
||||
enum a6xx_state_type st = compute ? ST6_UBO : ST6_CONSTANTS;
|
||||
uint32_t cp_load_state = compute ? CP_LOAD_STATE6_FRAG : CP_LOAD_STATE6;
|
||||
|
|
@ -4338,8 +4338,8 @@ tu6_const_size(struct tu_cmd_buffer *cmd,
|
|||
{
|
||||
uint32_t dwords = 0;
|
||||
|
||||
if (pipeline->shared_consts.dwords > 0) {
|
||||
dwords += pipeline->shared_consts.dwords + 4;
|
||||
if (pipeline->program.shared_consts.dwords > 0) {
|
||||
dwords += pipeline->program.shared_consts.dwords + 4;
|
||||
}
|
||||
|
||||
if (compute) {
|
||||
|
|
@ -4367,7 +4367,7 @@ tu6_emit_consts(struct tu_cmd_buffer *cmd,
|
|||
struct tu_cs cs;
|
||||
tu_cs_begin_sub_stream(&cmd->sub_cs, dwords, &cs);
|
||||
|
||||
if (pipeline->shared_consts.dwords > 0) {
|
||||
if (pipeline->program.shared_consts.dwords > 0) {
|
||||
tu6_emit_shared_consts(&cs, pipeline, cmd->push_constants, compute);
|
||||
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(pipeline->program.link); i++) {
|
||||
|
|
|
|||
|
|
@ -1760,13 +1760,6 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder,
|
|||
must_compile = true;
|
||||
}
|
||||
|
||||
if (tu6_shared_constants_enable(&builder->layout, builder->device->compiler)) {
|
||||
pipeline->shared_consts = (struct tu_push_constant_range) {
|
||||
.lo = 0,
|
||||
.dwords = builder->layout.push_constant_size / 4,
|
||||
};
|
||||
}
|
||||
|
||||
/* Forward declare everything due to the goto usage */
|
||||
nir_shader *nir[ARRAY_SIZE(stage_infos)] = { NULL };
|
||||
struct tu_shader *shaders[ARRAY_SIZE(stage_infos)] = { NULL };
|
||||
|
|
@ -2163,18 +2156,6 @@ tu_pipeline_builder_parse_libraries(struct tu_pipeline_builder *builder,
|
|||
if (pipeline->type == TU_PIPELINE_GRAPHICS_LIB)
|
||||
tu_pipeline_to_graphics_lib(pipeline)->state |= library->state;
|
||||
|
||||
if (library->state &
|
||||
VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT) {
|
||||
pipeline->shared_consts = library->base.shared_consts;
|
||||
}
|
||||
|
||||
if (library->state &
|
||||
VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT) {
|
||||
pipeline->ds = library->base.ds;
|
||||
pipeline->lrz.lrz_status |= library->base.lrz.lrz_status;
|
||||
pipeline->shared_consts = library->base.shared_consts;
|
||||
}
|
||||
|
||||
if (library->state &
|
||||
VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT) {
|
||||
pipeline->output = library->base.output;
|
||||
|
|
@ -2337,6 +2318,11 @@ tu_pipeline_builder_parse_shader_stages(struct tu_pipeline_builder *builder,
|
|||
tu_pipeline_set_linkage(&pipeline->program.link[i],
|
||||
&pipeline->shaders[i]->const_state,
|
||||
variants[i]);
|
||||
|
||||
if (pipeline->shaders[i]->shared_consts.dwords != 0) {
|
||||
pipeline->program.shared_consts =
|
||||
pipeline->shaders[i]->shared_consts;
|
||||
}
|
||||
}
|
||||
|
||||
const struct ir3_shader_variant *vs = variants[MESA_SHADER_VERTEX];
|
||||
|
|
@ -4297,13 +4283,6 @@ tu_compute_pipeline_create(VkDevice device,
|
|||
VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
||||
}
|
||||
|
||||
if (tu6_shared_constants_enable(layout, dev->compiler)) {
|
||||
pipeline->base.shared_consts = (struct tu_push_constant_range) {
|
||||
.lo = 0,
|
||||
.dwords = layout->push_constant_size / 4,
|
||||
};
|
||||
}
|
||||
|
||||
char *nir_initial_disasm = NULL;
|
||||
|
||||
if (!shader) {
|
||||
|
|
@ -4339,6 +4318,8 @@ tu_compute_pipeline_create(VkDevice device,
|
|||
creation_feedback->pPipelineStageCreationFeedbacks[0] = pipeline_feedback;
|
||||
}
|
||||
|
||||
pipeline->base.program.shared_consts = shader->shared_consts;
|
||||
|
||||
pipeline->base.active_desc_sets = shader->active_desc_sets;
|
||||
|
||||
v = shader->variant;
|
||||
|
|
|
|||
|
|
@ -135,8 +135,6 @@ struct tu_pipeline
|
|||
/* draw states for the pipeline */
|
||||
struct tu_draw_state load_state;
|
||||
|
||||
struct tu_push_constant_range shared_consts;
|
||||
|
||||
struct tu_shader *shaders[MESA_SHADER_STAGES];
|
||||
|
||||
struct
|
||||
|
|
@ -151,6 +149,8 @@ struct tu_pipeline
|
|||
|
||||
uint32_t hs_param_dwords;
|
||||
|
||||
struct tu_push_constant_range shared_consts;
|
||||
|
||||
struct tu_program_descriptor_linkage link[MESA_SHADER_STAGES];
|
||||
|
||||
bool per_view_viewport;
|
||||
|
|
|
|||
|
|
@ -2084,6 +2084,7 @@ tu_shader_serialize(struct vk_pipeline_cache_object *object,
|
|||
container_of(object, struct tu_shader, base);
|
||||
|
||||
blob_write_bytes(blob, &shader->const_state, sizeof(shader->const_state));
|
||||
blob_write_bytes(blob, &shader->shared_consts, sizeof(shader->shared_consts));
|
||||
blob_write_uint32(blob, shader->view_mask);
|
||||
blob_write_uint8(blob, shader->active_desc_sets);
|
||||
|
||||
|
|
@ -2125,6 +2126,7 @@ tu_shader_deserialize(struct vk_pipeline_cache *cache,
|
|||
return NULL;
|
||||
|
||||
blob_copy_bytes(blob, &shader->const_state, sizeof(shader->const_state));
|
||||
blob_copy_bytes(blob, &shader->shared_consts, sizeof(shader->shared_consts));
|
||||
shader->view_mask = blob_read_uint32(blob);
|
||||
shader->active_desc_sets = blob_read_uint8(blob);
|
||||
|
||||
|
|
@ -2276,8 +2278,13 @@ tu_shader_create(struct tu_device *dev,
|
|||
ir3_finalize_nir(dev->compiler, nir);
|
||||
|
||||
bool shared_consts_enable = tu6_shared_constants_enable(layout, dev->compiler);
|
||||
if (shared_consts_enable)
|
||||
if (shared_consts_enable) {
|
||||
assert(!shader->const_state.push_consts.dwords);
|
||||
shader->shared_consts = (struct tu_push_constant_range) {
|
||||
.lo = 0,
|
||||
.dwords = layout->push_constant_size / 4,
|
||||
};
|
||||
}
|
||||
|
||||
const struct ir3_shader_options options = {
|
||||
.reserved_user_consts = reserved_consts_vec4,
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ struct tu_shader
|
|||
uint32_t view_mask;
|
||||
uint8_t active_desc_sets;
|
||||
|
||||
/* This is the range of shared consts used by all shaders. It must be the
|
||||
* same between shaders.
|
||||
*/
|
||||
struct tu_push_constant_range shared_consts;
|
||||
|
||||
union {
|
||||
struct {
|
||||
unsigned patch_type;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue