mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 02:48:06 +02:00
vulkan: adjust lowering of descriptor heaps
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40768>
This commit is contained in:
parent
fb96f85d19
commit
d2b9ccf20b
1 changed files with 22 additions and 43 deletions
|
|
@ -462,9 +462,8 @@ vk_build_descriptor_heap_address(nir_builder *b,
|
|||
static bool
|
||||
var_is_heap_ptr(nir_variable *var)
|
||||
{
|
||||
return (var->data.mode == nir_var_uniform || var->data.mode == nir_var_image) &&
|
||||
(var->data.location == SYSTEM_VALUE_SAMPLER_HEAP_PTR ||
|
||||
var->data.location == SYSTEM_VALUE_RESOURCE_HEAP_PTR);
|
||||
return var->data.mode == nir_var_resource_heap ||
|
||||
var->data.mode == nir_var_sampler_heap;
|
||||
}
|
||||
|
||||
static nir_deref_instr *
|
||||
|
|
@ -488,39 +487,6 @@ deref_get_root_cast(nir_deref_instr *deref)
|
|||
return deref;
|
||||
}
|
||||
|
||||
static bool
|
||||
deref_cast_is_heap_ptr(nir_deref_instr *deref)
|
||||
{
|
||||
assert(deref->deref_type == nir_deref_type_cast);
|
||||
nir_intrinsic_instr *intrin = nir_src_as_intrinsic(deref->parent);
|
||||
if (intrin == NULL) {
|
||||
nir_deref_instr *parent_deref = nir_src_as_deref(deref->parent);
|
||||
if (parent_deref != NULL && parent_deref->deref_type == nir_deref_type_var)
|
||||
return var_is_heap_ptr(parent_deref->var);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (intrin->intrinsic) {
|
||||
case nir_intrinsic_load_deref: {
|
||||
nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
if (var == NULL || var->data.mode != nir_var_system_value)
|
||||
return false;
|
||||
|
||||
return var->data.location == SYSTEM_VALUE_SAMPLER_HEAP_PTR ||
|
||||
var->data.location == SYSTEM_VALUE_RESOURCE_HEAP_PTR;
|
||||
}
|
||||
|
||||
case nir_intrinsic_load_sampler_heap_ptr:
|
||||
case nir_intrinsic_load_resource_heap_ptr:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
get_deref_resource_binding(nir_deref_instr *deref,
|
||||
uint32_t *set, uint32_t *binding,
|
||||
|
|
@ -663,9 +629,6 @@ build_deref_heap_offset(nir_builder *b, nir_deref_instr *deref,
|
|||
if (root_cast == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!deref_cast_is_heap_ptr(root_cast))
|
||||
return NULL;
|
||||
|
||||
/* We're building an offset. It starts at zero */
|
||||
b->cursor = nir_before_instr(&root_cast->instr);
|
||||
nir_def *base_addr = nir_imm_int(b, 0);
|
||||
|
|
@ -753,14 +716,18 @@ lower_heaps_tex(nir_builder *b, nir_tex_instr *tex,
|
|||
|
||||
static bool
|
||||
lower_heaps_image(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
struct heap_mapping_ctx *ctx)
|
||||
struct heap_mapping_ctx *ctx, bool deref)
|
||||
{
|
||||
nir_deref_instr *image = nir_src_as_deref(intrin->src[0]);
|
||||
nir_def *heap_offset = build_deref_heap_offset(b, image, false, ctx);
|
||||
if (heap_offset == NULL)
|
||||
return false;
|
||||
|
||||
nir_rewrite_image_intrinsic(intrin, heap_offset, nir_image_intrinsic_type_heap);
|
||||
if (deref) {
|
||||
nir_rewrite_image_intrinsic(intrin, heap_offset, nir_image_intrinsic_type_heap);
|
||||
} else {
|
||||
nir_src_rewrite(&intrin->src[0], heap_offset);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -889,7 +856,7 @@ lower_heaps_load_buffer_ptr(nir_builder *b, nir_intrinsic_instr *ptr_load,
|
|||
nir_deref_instr *deref = nir_src_as_deref(ptr_load->src[0]);
|
||||
|
||||
nir_deref_instr *root_cast = deref_get_root_cast(deref);
|
||||
if (!deref_cast_is_heap_ptr(root_cast))
|
||||
if (root_cast == NULL)
|
||||
return false;
|
||||
|
||||
/* We're building an offset. It starts at zero */
|
||||
|
|
@ -988,7 +955,19 @@ lower_heaps_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
case nir_intrinsic_image_deref_store_raw_intel:
|
||||
case nir_intrinsic_image_deref_fragment_mask_load_amd:
|
||||
case nir_intrinsic_image_deref_store_block_agx:
|
||||
return lower_heaps_image(b, intrin, ctx);
|
||||
return lower_heaps_image(b, intrin, ctx, true);
|
||||
case nir_intrinsic_image_heap_load:
|
||||
case nir_intrinsic_image_heap_sparse_load:
|
||||
case nir_intrinsic_image_heap_store:
|
||||
case nir_intrinsic_image_heap_atomic:
|
||||
case nir_intrinsic_image_heap_atomic_swap:
|
||||
case nir_intrinsic_image_heap_size:
|
||||
case nir_intrinsic_image_heap_samples:
|
||||
case nir_intrinsic_image_heap_load_raw_intel:
|
||||
case nir_intrinsic_image_heap_store_raw_intel:
|
||||
case nir_intrinsic_image_heap_fragment_mask_load_amd:
|
||||
case nir_intrinsic_image_heap_store_block_agx:
|
||||
return lower_heaps_image(b, intrin, ctx, false);
|
||||
|
||||
case nir_intrinsic_load_deref:
|
||||
case nir_intrinsic_store_deref:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue