nvk/draw: Map cbuf slots to shaders, not cbuf_maps

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27156>
This commit is contained in:
Faith Ekstrand 2024-01-18 15:04:38 -06:00 committed by Marge Bot
parent 2b47e93c8a
commit 148971f232

View file

@ -1965,24 +1965,27 @@ nvk_flush_descriptors(struct nvk_cmd_buffer *cmd)
memcpy(root_desc_map, &desc->root, sizeof(desc->root));
/* Find cbuf maps for the 5 cbuf groups */
const struct nvk_cbuf_map *cbuf_maps[5] = { NULL, };
const struct nvk_shader *cbuf_shaders[5] = { NULL, };
for (gl_shader_stage stage = 0; stage < MESA_SHADER_STAGES; stage++) {
const struct nvk_shader *shader = pipeline->base.shaders[stage];
if (!shader || shader->code_size == 0)
continue;
uint32_t group = nvk_cbuf_binding_for_stage(stage);
assert(group < ARRAY_SIZE(cbuf_maps));
cbuf_maps[group] = &shader->cbuf_map;
assert(group < ARRAY_SIZE(cbuf_shaders));
cbuf_shaders[group] = shader;
}
uint32_t root_cbuf_count = 0;
for (uint32_t group = 0; group < ARRAY_SIZE(cbuf_maps); group++) {
if (cbuf_maps[group] == NULL)
for (uint32_t group = 0; group < ARRAY_SIZE(cbuf_shaders); group++) {
if (cbuf_shaders[group] == NULL)
continue;
for (uint32_t c = 0; c < cbuf_maps[group]->cbuf_count; c++) {
const struct nvk_cbuf *cbuf = &cbuf_maps[group]->cbufs[c];
const struct nvk_shader *shader = cbuf_shaders[group];
const struct nvk_cbuf_map *cbuf_map = &shader->cbuf_map;
for (uint32_t c = 0; c < cbuf_map->cbuf_count; c++) {
const struct nvk_cbuf *cbuf = &cbuf_map->cbufs[c];
/* We bind these at the very end */
if (cbuf->type == NVK_CBUF_TYPE_ROOT_DESC) {
@ -2044,12 +2047,14 @@ nvk_flush_descriptors(struct nvk_cmd_buffer *cmd)
P_NV9097_SET_CONSTANT_BUFFER_SELECTOR_B(p, root_desc_addr >> 32);
P_NV9097_SET_CONSTANT_BUFFER_SELECTOR_C(p, root_desc_addr);
for (uint32_t group = 0; group < ARRAY_SIZE(cbuf_maps); group++) {
if (cbuf_maps[group] == NULL)
for (uint32_t group = 0; group < ARRAY_SIZE(cbuf_shaders); group++) {
if (cbuf_shaders[group] == NULL)
continue;
for (uint32_t c = 0; c < cbuf_maps[group]->cbuf_count; c++) {
const struct nvk_cbuf *cbuf = &cbuf_maps[group]->cbufs[c];
const struct nvk_cbuf_map *cbuf_map = &cbuf_shaders[group]->cbuf_map;
for (uint32_t c = 0; c < cbuf_map->cbuf_count; c++) {
const struct nvk_cbuf *cbuf = &cbuf_map->cbufs[c];
if (cbuf->type == NVK_CBUF_TYPE_ROOT_DESC) {
P_IMMD(p, NV9097, BIND_GROUP_CONSTANT_BUFFER(group), {
.valid = VALID_TRUE,