nvk: Lower images to addresses on Kepler

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34975>
This commit is contained in:
Faith Ekstrand 2025-04-18 12:08:42 -05:00 committed by Marge Bot
parent bb3f4b86bf
commit 82d789d22a
2 changed files with 27 additions and 10 deletions

View file

@ -1110,6 +1110,21 @@ lower_image_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
return true;
}
static bool
lower_load_image_info(nir_builder *b, nir_intrinsic_instr *load,
const struct lower_descriptors_ctx *ctx)
{
b->cursor = nir_before_instr(&load->instr);
nir_deref_instr *deref = nir_src_as_deref(load->src[0]);
unsigned offset = nir_intrinsic_base(load);
assert(load->def.bit_size == 32);
nir_def *desc = load_resource_deref_desc(b, load->num_components, 32,
deref, offset, ctx);
nir_def_rewrite_uses(&load->def, desc);
return true;
}
static bool
lower_interp_at_sample(nir_builder *b, nir_intrinsic_instr *interp,
const struct lower_descriptors_ctx *ctx)
@ -1187,6 +1202,9 @@ try_lower_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
case nir_intrinsic_image_deref_samples:
return lower_image_intrin(b, intrin, ctx);
case nir_intrinsic_image_deref_load_info_nv:
return lower_load_image_info(b, intrin, ctx);
case nir_intrinsic_interp_deref_at_sample:
return lower_interp_at_sample(b, intrin, ctx);

View file

@ -484,6 +484,15 @@ nvk_lower_nir(struct nvk_device *dev, nir_shader *nir,
.is_vulkan = true,
};
NIR_PASS(_, nir, nir_opt_access, &opt_access_options);
/* On Kepler, we have to lower images to addresses */
if (pdev->info.cls_eng3d < MAXWELL_A) {
if (use_nak(pdev, nir->info.stage))
NIR_PASS(_, nir, nak_nir_lower_image_addrs, pdev->nak);
else
assert(!nir_has_image_var(nir));
}
NIR_PASS(_, nir, nvk_nir_lower_descriptors, pdev, shader_flags, rs,
set_layout_count, set_layouts, cbuf_map);
NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_global,
@ -962,22 +971,12 @@ nvk_compile_shader(struct nvk_device *dev,
const VkAllocationCallbacks* pAllocator,
struct vk_shader **shader_out)
{
const struct nvk_physical_device *pdev = nvk_device_physical(dev);
struct nvk_shader *shader;
VkResult result;
/* We consume the NIR, regardless of success or failure */
nir_shader *nir = info->nir;
/* TODO: Kepler image lowering requires image params to be loaded from the
* descriptor set, which we don't currently support.
*/
if (pdev->info.cls_eng3d < MAXWELL_A && nir_has_image_var(nir)) {
ralloc_free(nir);
return vk_errorf(dev, VK_ERROR_UNKNOWN,
"Storage images are not supported on Kepler");
}
shader = vk_shader_zalloc(&dev->vk, &nvk_shader_ops, info->stage,
pAllocator, sizeof(*shader));
if (shader == NULL) {