nvk: Add a cbuf_bind_map to nvk_shader

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26615>
This commit is contained in:
Faith Ekstrand 2023-12-08 16:53:30 -06:00 committed by Marge Bot
parent bdec097bb8
commit 107a09e7dd
4 changed files with 30 additions and 9 deletions

View file

@ -184,20 +184,20 @@ nvk_compute_pipeline_create(struct nvk_device *dev,
if (result != VK_SUCCESS)
goto fail;
nvk_lower_nir(dev, nir, &robustness, false, pipeline_layout);
struct nvk_shader *shader = &pipeline->base.shaders[MESA_SHADER_COMPUTE];
nvk_lower_nir(dev, nir, &robustness, false, pipeline_layout, shader);
result = nvk_compile_nir(pdev, nir, pipeline_flags, &robustness, NULL,
&pipeline->base.shaders[MESA_SHADER_COMPUTE]);
shader);
ralloc_free(nir);
if (result != VK_SUCCESS)
goto fail;
result = nvk_shader_upload(dev,
&pipeline->base.shaders[MESA_SHADER_COMPUTE]);
result = nvk_shader_upload(dev, shader);
if (result != VK_SUCCESS)
goto fail;
struct nvk_shader *shader = &pipeline->base.shaders[MESA_SHADER_COMPUTE];
if (pdev->info.cls_compute >= AMPERE_COMPUTE_A)
nvc6c0_compute_setup_launch_desc_template(pipeline->qmd_template, shader);
else if (pdev->info.cls_compute >= VOLTA_COMPUTE_A)

View file

@ -343,7 +343,8 @@ nvk_graphics_pipeline_create(struct nvk_device *dev,
const VkPipelineShaderStageCreateInfo *sinfo = &pCreateInfo->pStages[i];
gl_shader_stage stage = vk_to_mesa_shader_stage(sinfo->stage);
nvk_lower_nir(dev, nir[stage], &robustness[stage],
state.rp->view_mask != 0, pipeline_layout);
state.rp->view_mask != 0, pipeline_layout,
&pipeline->base.shaders[stage]);
}
for (gl_shader_stage stage = 0; stage < MESA_SHADER_STAGES; stage++) {

View file

@ -297,7 +297,8 @@ void
nvk_lower_nir(struct nvk_device *dev, nir_shader *nir,
const struct vk_pipeline_robustness_state *rs,
bool is_multiview,
const struct vk_pipeline_layout *layout)
const struct vk_pipeline_layout *layout,
struct nvk_shader *shader)
{
struct nvk_physical_device *pdev = nvk_device_physical(dev);
@ -348,7 +349,24 @@ nvk_lower_nir(struct nvk_device *dev, nir_shader *nir,
*/
assert(dev->pdev->info.cls_eng3d >= MAXWELL_A || !nir_has_image_var(nir));
NIR_PASS(_, nir, nvk_nir_lower_descriptors, rs, layout, NULL);
struct nvk_cbuf_map *cbuf_map = NULL;
if (use_nak(pdev, nir->info.stage) && 0) {
cbuf_map = &shader->cbuf_map;
} else {
/* Codegen sometimes puts stuff in cbuf 1 and adds 1 to our cbuf indices
* so we can't really rely on it for lowering to cbufs and instead place
* the root descriptors in both cbuf 0 and cbuf 1.
*/
shader->cbuf_map = (struct nvk_cbuf_map) {
.cbuf_count = 2,
.cbufs = {
{ .type = NVK_CBUF_TYPE_ROOT_DESC },
{ .type = NVK_CBUF_TYPE_ROOT_DESC },
}
};
}
NIR_PASS(_, nir, nvk_nir_lower_descriptors, rs, layout, cbuf_map);
NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_global,
nir_address_format_64bit_global);
NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_ssbo,

View file

@ -47,6 +47,7 @@ struct nvk_cbuf_map {
struct nvk_shader {
struct nak_shader_info info;
struct nvk_cbuf_map cbuf_map;
struct nak_shader_bin *nak;
const void *code_ptr;
@ -107,7 +108,8 @@ void
nvk_lower_nir(struct nvk_device *dev, nir_shader *nir,
const struct vk_pipeline_robustness_state *rs,
bool is_multiview,
const struct vk_pipeline_layout *layout);
const struct vk_pipeline_layout *layout,
struct nvk_shader *shader);
VkResult
nvk_compile_nir(struct nvk_physical_device *dev, nir_shader *nir,