mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-07 08:18:24 +02:00
nir: introduce nir_descriptor_type for Vulkan like descriptors
This removes a Vulkan dependency in NIR core. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40670>
This commit is contained in:
parent
ee7c6e3752
commit
9d059a60f5
19 changed files with 130 additions and 112 deletions
|
|
@ -136,8 +136,8 @@ visit_vulkan_resource_index(nir_builder *b, apply_layout_state *state, nir_intri
|
|||
static void
|
||||
visit_vulkan_resource_reindex(nir_builder *b, apply_layout_state *state, nir_intrinsic_instr *intrin)
|
||||
{
|
||||
VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
|
||||
nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type == nir_descriptor_type_acceleration_structure) {
|
||||
nir_def *set_ptr = nir_unpack_64_2x32_split_x(b, intrin->src[0].ssa);
|
||||
nir_def *binding_ptr = nir_unpack_64_2x32_split_y(b, intrin->src[0].ssa);
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ visit_vulkan_resource_reindex(nir_builder *b, apply_layout_state *state, nir_int
|
|||
|
||||
nir_def_rewrite_uses(&intrin->def, nir_pack_64_2x32_split(b, set_ptr, binding_ptr));
|
||||
} else {
|
||||
assert(desc_type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER || desc_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
assert(desc_type == nir_descriptor_type_uniform_buffer || desc_type == nir_descriptor_type_storage_buffer);
|
||||
|
||||
nir_def *binding_ptr = nir_channel(b, intrin->src[0].ssa, 1);
|
||||
nir_def *stride = nir_channel(b, intrin->src[0].ssa, 2);
|
||||
|
|
@ -163,7 +163,7 @@ visit_vulkan_resource_reindex(nir_builder *b, apply_layout_state *state, nir_int
|
|||
static void
|
||||
visit_load_vulkan_descriptor(nir_builder *b, apply_layout_state *state, nir_intrinsic_instr *intrin)
|
||||
{
|
||||
if (nir_intrinsic_desc_type(intrin) == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
|
||||
if (nir_intrinsic_desc_type(intrin) == nir_descriptor_type_acceleration_structure) {
|
||||
nir_def *addr = convert_pointer_to_64_bit(b, state,
|
||||
nir_iadd(b, nir_unpack_64_2x32_split_x(b, intrin->src[0].ssa),
|
||||
nir_unpack_64_2x32_split_y(b, intrin->src[0].ssa)));
|
||||
|
|
|
|||
|
|
@ -219,12 +219,13 @@ static bool
|
|||
try_lower_load_vulkan_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
ASSERTED const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
ASSERTED const nir_descriptor_type desc_type =
|
||||
nir_intrinsic_desc_type(intrin);
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
nir_intrinsic_instr *idx_intrin = nir_src_as_intrinsic(intrin->src[0]);
|
||||
if (idx_intrin == NULL || !is_idx_intrin(idx_intrin)) {
|
||||
assert(desc_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
assert(desc_type == nir_descriptor_type_storage_buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -748,8 +749,8 @@ static bool
|
|||
lower_ssbo_resource_index(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != nir_descriptor_type_storage_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
|
@ -818,8 +819,8 @@ static bool
|
|||
lower_ssbo_resource_reindex(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != nir_descriptor_type_storage_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
|
@ -842,8 +843,8 @@ static bool
|
|||
lower_load_ssbo_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != nir_descriptor_type_storage_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ get_set_event_cs(const nir_shader_compiler_options *options)
|
|||
nir_vulkan_resource_index(&b, 2, 32, nir_imm_int(&b, 0),
|
||||
.desc_set = 0,
|
||||
.binding = 0,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
|
||||
nir_def *offset =
|
||||
nir_load_push_constant(&b, 1, 32, nir_imm_int(&b, 0), .base = 0, .range = 4);
|
||||
|
|
@ -62,7 +62,7 @@ get_wait_event_cs(const nir_shader_compiler_options *options)
|
|||
nir_vulkan_resource_index(&b, 2, 32, nir_imm_int(&b, 0),
|
||||
.desc_set = 0,
|
||||
.binding = 0,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
|
||||
nir_def *offset =
|
||||
nir_load_push_constant(&b, 1, 32, nir_imm_int(&b, 0), .base = 0, .range = 4);
|
||||
|
|
|
|||
|
|
@ -1454,7 +1454,7 @@ get_set_query_availability_cs(const nir_shader_compiler_options *options)
|
|||
nir_vulkan_resource_index(&b, 2, 32, nir_imm_int(&b, 0),
|
||||
.desc_set = 0,
|
||||
.binding = 0,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
|
||||
/* This assumes a local size of 1 and a horizontal-only dispatch. If we
|
||||
* ever change any of these parameters we need to update how we compute the
|
||||
|
|
@ -1517,7 +1517,7 @@ get_reset_occlusion_query_cs(const nir_shader_compiler_options *options)
|
|||
nir_vulkan_resource_index(&b, 2, 32, nir_imm_int(&b, 0),
|
||||
.desc_set = 0,
|
||||
.binding = 0,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
|
||||
/* This assumes a local size of 1 and a horizontal-only dispatch. If we
|
||||
* ever change any of these parameters we need to update how we compute the
|
||||
|
|
@ -1573,13 +1573,13 @@ get_copy_query_results_cs(const nir_shader_compiler_options *options,
|
|||
nir_vulkan_resource_index(&b, 2, 32, nir_imm_int(&b, 0),
|
||||
.desc_set = 0,
|
||||
.binding = 0,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
|
||||
nir_def *buf_out =
|
||||
nir_vulkan_resource_index(&b, 2, 32, nir_imm_int(&b, 0),
|
||||
.desc_set = 1,
|
||||
.binding = 0,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
|
||||
/* Read push constants */
|
||||
nir_def *avail_offset =
|
||||
|
|
|
|||
|
|
@ -196,6 +196,15 @@ typedef enum {
|
|||
nir_resource_type_acceleration_structure = 1u << 8,
|
||||
} nir_resource_type;
|
||||
|
||||
/**
|
||||
* Descriptor types.
|
||||
*/
|
||||
typedef enum {
|
||||
nir_descriptor_type_uniform_buffer = 0,
|
||||
nir_descriptor_type_storage_buffer = 1,
|
||||
nir_descriptor_type_acceleration_structure = 2,
|
||||
} nir_descriptor_type;
|
||||
|
||||
/**
|
||||
* Rounding modes.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -248,8 +248,8 @@ index("unsigned", "offset_shift")
|
|||
# Similar to offset_shift except it is applied only to the non uniform offset src, not the base.
|
||||
index("unsigned", "offset_shift_nv")
|
||||
|
||||
# The Vulkan descriptor type for a vulkan_resource_[re]index intrinsic.
|
||||
index("unsigned", "desc_type")
|
||||
# The NIR descriptor type for a vulkan_resource_[re]index intrinsic.
|
||||
index("nir_descriptor_type", "desc_type")
|
||||
|
||||
# The NIR resource type according to VkSpirvResourceTypeFlagsKHR.
|
||||
index("nir_resource_type", "resource_type")
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include "util/memstream.h"
|
||||
#include "util/mesa-blake3.h"
|
||||
#include "util/ralloc.h"
|
||||
#include "vulkan/vulkan_core.h"
|
||||
#include "nir.h"
|
||||
#include "nir_builder.h"
|
||||
|
||||
|
|
@ -1203,39 +1202,15 @@ print_deref_instr(nir_deref_instr *instr, print_state *state)
|
|||
}
|
||||
|
||||
static const char *
|
||||
vulkan_descriptor_type_name(VkDescriptorType type)
|
||||
nir_descriptor_type_name(nir_descriptor_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
return "sampler";
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
return "texture+sampler";
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
return "texture";
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
return "image";
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
return "texture-buffer";
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
return "image-buffer";
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return "UBO";
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return "SSBO";
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
return "UBO";
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
return "SSBO";
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
return "input-att";
|
||||
case VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK:
|
||||
return "inline-UBO";
|
||||
case VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR:
|
||||
case nir_descriptor_type_acceleration_structure:
|
||||
return "accel-struct";
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM:
|
||||
return "sample-weight-image";
|
||||
case VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM:
|
||||
return "block-match-image";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
|
|
@ -1450,8 +1425,8 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
|
|||
}
|
||||
|
||||
case NIR_INTRINSIC_DESC_TYPE: {
|
||||
VkDescriptorType desc_type = nir_intrinsic_desc_type(instr);
|
||||
fprintf(fp, "desc_type=%s", vulkan_descriptor_type_name(desc_type));
|
||||
nir_descriptor_type desc_type = nir_intrinsic_desc_type(instr);
|
||||
fprintf(fp, "desc_type=%s", nir_descriptor_type_name(desc_type));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ nir_load_store_vectorize_test::get_resource(uint32_t binding, bool ssbo)
|
|||
res->num_components = 1;
|
||||
res->src[0] = nir_src_for_ssa(nir_imm_zero(b, 1, 32));
|
||||
nir_intrinsic_set_desc_type(
|
||||
res, ssbo ? 7/*VK_DESCRIPTOR_TYPE_STORAGE_BUFFER*/ : 6/*VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER*/);
|
||||
res, ssbo ? nir_descriptor_type_storage_buffer : nir_descriptor_type_uniform_buffer);
|
||||
nir_intrinsic_set_desc_set(res, 0);
|
||||
nir_intrinsic_set_binding(res, binding);
|
||||
nir_builder_instr_insert(b, &res->instr);
|
||||
|
|
|
|||
|
|
@ -206,16 +206,16 @@ vtn_access_link_as_ssa(struct vtn_builder *b, struct vtn_access_link link,
|
|||
}
|
||||
}
|
||||
|
||||
static VkDescriptorType
|
||||
vk_desc_type_for_mode(struct vtn_builder *b, enum vtn_variable_mode mode)
|
||||
static nir_descriptor_type
|
||||
nir_desc_type_for_mode(struct vtn_builder *b, enum vtn_variable_mode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case vtn_variable_mode_ubo:
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
return nir_descriptor_type_uniform_buffer;
|
||||
case vtn_variable_mode_ssbo:
|
||||
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
return nir_descriptor_type_storage_buffer;
|
||||
case vtn_variable_mode_accel_struct:
|
||||
return VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
|
||||
return nir_descriptor_type_acceleration_structure;
|
||||
default:
|
||||
vtn_fail("Invalid mode for vulkan_resource_index");
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ vtn_variable_resource_index(struct vtn_builder *b, struct vtn_variable *var,
|
|||
instr->src[0] = nir_src_for_ssa(desc_array_index);
|
||||
nir_intrinsic_set_desc_set(instr, var->descriptor_set);
|
||||
nir_intrinsic_set_binding(instr, var->binding);
|
||||
nir_intrinsic_set_desc_type(instr, vk_desc_type_for_mode(b, var->mode));
|
||||
nir_intrinsic_set_desc_type(instr, nir_desc_type_for_mode(b, var->mode));
|
||||
nir_intrinsic_set_resource_type(instr, var->var->data.resource_type);
|
||||
|
||||
nir_address_format addr_format = vtn_mode_to_address_format(b, var->mode);
|
||||
|
|
@ -265,7 +265,7 @@ vtn_resource_reindex(struct vtn_builder *b, enum vtn_variable_mode mode,
|
|||
nir_intrinsic_vulkan_resource_reindex);
|
||||
instr->src[0] = nir_src_for_ssa(base_index);
|
||||
instr->src[1] = nir_src_for_ssa(offset_index);
|
||||
nir_intrinsic_set_desc_type(instr, vk_desc_type_for_mode(b, mode));
|
||||
nir_intrinsic_set_desc_type(instr, nir_desc_type_for_mode(b, mode));
|
||||
|
||||
nir_address_format addr_format = vtn_mode_to_address_format(b, mode);
|
||||
nir_def_init(&instr->instr, &instr->def,
|
||||
|
|
@ -287,7 +287,7 @@ vtn_descriptor_load(struct vtn_builder *b, enum vtn_variable_mode mode,
|
|||
nir_intrinsic_instr_create(b->nb.shader,
|
||||
nir_intrinsic_load_vulkan_descriptor);
|
||||
desc_load->src[0] = nir_src_for_ssa(desc_index);
|
||||
nir_intrinsic_set_desc_type(desc_load, vk_desc_type_for_mode(b, mode));
|
||||
nir_intrinsic_set_desc_type(desc_load, nir_desc_type_for_mode(b, mode));
|
||||
|
||||
nir_address_format addr_format = vtn_mode_to_address_format(b, mode);
|
||||
nir_def_init(&desc_load->instr, &desc_load->def,
|
||||
|
|
|
|||
|
|
@ -114,14 +114,14 @@ bti_multiplier(const struct apply_pipeline_layout_state *state,
|
|||
}
|
||||
|
||||
static nir_address_format
|
||||
addr_format_for_desc_type(VkDescriptorType desc_type,
|
||||
addr_format_for_desc_type(nir_descriptor_type desc_type,
|
||||
struct apply_pipeline_layout_state *state)
|
||||
{
|
||||
switch (desc_type) {
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return state->ssbo_addr_format;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return state->ubo_addr_format;
|
||||
|
||||
default:
|
||||
|
|
@ -186,7 +186,7 @@ const VkDescriptorBindingFlags non_pushable_binding_flags =
|
|||
|
||||
static void
|
||||
add_binding_type(struct apply_pipeline_layout_state *state,
|
||||
uint32_t set, uint32_t binding, VkDescriptorType type)
|
||||
uint32_t set, uint32_t binding, nir_descriptor_type type)
|
||||
{
|
||||
add_binding(state, set, binding, false);
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ add_binding_type(struct apply_pipeline_layout_state *state,
|
|||
set_layout->binding[binding].type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC ||
|
||||
set_layout->binding[binding].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK ||
|
||||
set_layout->binding[binding].type == VK_DESCRIPTOR_TYPE_MUTABLE_EXT) &&
|
||||
type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)
|
||||
type == nir_descriptor_type_uniform_buffer)
|
||||
state->set[set].binding[binding].properties |= BINDING_PROPERTY_PUSHABLE;
|
||||
}
|
||||
|
||||
|
|
@ -1588,7 +1588,7 @@ lower_direct_buffer_instr(nir_builder *b, nir_instr *instr, void *_state)
|
|||
|
||||
case nir_intrinsic_load_vulkan_descriptor:
|
||||
if (nir_intrinsic_desc_type(intrin) ==
|
||||
VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR)
|
||||
nir_descriptor_type_acceleration_structure)
|
||||
return lower_load_accel_struct_desc(b, intrin, state);
|
||||
return false;
|
||||
|
||||
|
|
@ -1633,18 +1633,34 @@ lower_res_reindex_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
return true;
|
||||
}
|
||||
|
||||
static VkDescriptorType
|
||||
nir_to_vk_descriptor_type(nir_descriptor_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
case nir_descriptor_type_acceleration_structure:
|
||||
return VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
|
||||
default:
|
||||
UNREACHABLE("Invalid nir_descriptor_type");
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_load_vulkan_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
struct apply_pipeline_layout_state *state)
|
||||
{
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
const VkDescriptorType vk_desc_type = nir_to_vk_descriptor_type(desc_type);
|
||||
nir_address_format addr_format = addr_format_for_desc_type(desc_type, state);
|
||||
|
||||
nir_def *desc =
|
||||
build_buffer_addr_for_res_index(b,
|
||||
desc_type, intrin->src[0].ssa,
|
||||
vk_desc_type, intrin->src[0].ssa,
|
||||
addr_format, state);
|
||||
|
||||
assert(intrin->def.bit_size == desc->bit_size);
|
||||
|
|
|
|||
|
|
@ -59,14 +59,14 @@ struct apply_pipeline_layout_state {
|
|||
};
|
||||
|
||||
static nir_address_format
|
||||
addr_format_for_desc_type(VkDescriptorType desc_type,
|
||||
addr_format_for_desc_type(nir_descriptor_type desc_type,
|
||||
struct apply_pipeline_layout_state *state)
|
||||
{
|
||||
switch (desc_type) {
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return state->ssbo_addr_format;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return state->ubo_addr_format;
|
||||
|
||||
default:
|
||||
|
|
@ -723,7 +723,7 @@ lower_direct_buffer_instr(nir_builder *b, nir_instr *instr, void *_state)
|
|||
|
||||
case nir_intrinsic_load_vulkan_descriptor:
|
||||
if (nir_intrinsic_desc_type(intrin) ==
|
||||
VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR)
|
||||
nir_descriptor_type_acceleration_structure)
|
||||
return lower_load_accel_struct_desc(b, intrin, state);
|
||||
return false;
|
||||
|
||||
|
|
@ -775,17 +775,33 @@ lower_res_reindex_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
return true;
|
||||
}
|
||||
|
||||
static VkDescriptorType
|
||||
nir_to_vk_descriptor_type(nir_descriptor_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
case nir_descriptor_type_acceleration_structure:
|
||||
return VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR;
|
||||
default:
|
||||
UNREACHABLE("Invalid nir_descriptor_type");
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_load_vulkan_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
struct apply_pipeline_layout_state *state)
|
||||
{
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
const VkDescriptorType vk_desc_type = nir_to_vk_descriptor_type(desc_type);
|
||||
nir_address_format addr_format = addr_format_for_desc_type(desc_type, state);
|
||||
|
||||
nir_def *desc =
|
||||
build_buffer_addr_for_res_index(b, desc_type, intrin->src[0].ssa,
|
||||
build_buffer_addr_for_res_index(b, vk_desc_type, intrin->src[0].ssa,
|
||||
addr_format, state);
|
||||
|
||||
assert(intrin->def.bit_size == desc->bit_size);
|
||||
|
|
@ -805,7 +821,7 @@ lower_get_ssbo_size(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
nir_address_format addr_format =
|
||||
addr_format_for_desc_type(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, state);
|
||||
addr_format_for_desc_type(nir_descriptor_type_storage_buffer, state);
|
||||
|
||||
nir_def *desc =
|
||||
build_buffer_addr_for_res_index(b, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
|
|
|
|||
|
|
@ -238,12 +238,13 @@ static bool
|
|||
try_lower_load_vulkan_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
ASSERTED const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
ASSERTED const nir_descriptor_type desc_type =
|
||||
nir_intrinsic_desc_type(intrin);
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
nir_intrinsic_instr *idx_intrin = nir_src_as_intrinsic(intrin->src[0]);
|
||||
if (idx_intrin == NULL || !is_idx_intrin(idx_intrin)) {
|
||||
assert(desc_type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
assert(desc_type == nir_descriptor_type_storage_buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -578,8 +579,8 @@ static bool
|
|||
lower_ssbo_resource_index(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != nir_descriptor_type_storage_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
|
@ -644,8 +645,8 @@ static bool
|
|||
lower_ssbo_resource_reindex(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != nir_descriptor_type_storage_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
|
@ -668,8 +669,8 @@ static bool
|
|||
lower_load_ssbo_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != VK_DESCRIPTOR_TYPE_STORAGE_BUFFER)
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (desc_type != nir_descriptor_type_storage_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&intrin->instr);
|
||||
|
|
|
|||
|
|
@ -1544,7 +1544,7 @@ lower_ubo_array_one_to_static(struct nir_builder *b,
|
|||
if (nir_src_is_const(index->src[0]) && nir_src_as_uint(index->src[0]) == 0)
|
||||
return false;
|
||||
|
||||
if (nir_intrinsic_desc_type(index) != VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER)
|
||||
if (nir_intrinsic_desc_type(index) != nir_descriptor_type_uniform_buffer)
|
||||
return false;
|
||||
|
||||
b->cursor = nir_instr_remove(&index->instr);
|
||||
|
|
|
|||
|
|
@ -4473,11 +4473,11 @@ emit_load_vulkan_descriptor(struct ntd_context *ctx, nir_intrinsic_instr *intr)
|
|||
enum dxil_resource_class resource_class;
|
||||
enum dxil_resource_kind resource_kind;
|
||||
switch (nir_intrinsic_desc_type(intr)) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
resource_class = DXIL_RESOURCE_CLASS_CBV;
|
||||
resource_kind = DXIL_RESOURCE_KIND_CBUFFER;
|
||||
break;
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
resource_class = DXIL_RESOURCE_CLASS_UAV;
|
||||
resource_kind = DXIL_RESOURCE_KIND_RAW_BUFFER;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -284,12 +284,12 @@ lower_shader_system_values(struct nir_builder *builder, nir_instr *instr,
|
|||
nir_imm_int(builder, 0),
|
||||
.desc_set = conf->runtime_data_cbv.register_space,
|
||||
.binding = conf->runtime_data_cbv.base_shader_register,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
.desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *load_desc = nir_load_vulkan_descriptor(
|
||||
builder, nir_address_format_num_components(ubo_format),
|
||||
nir_address_format_bit_size(ubo_format),
|
||||
index, .desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
index, .desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *load_data = nir_load_ubo(
|
||||
builder,
|
||||
|
|
@ -371,12 +371,12 @@ lower_load_push_constant(struct nir_builder *builder, nir_instr *instr,
|
|||
nir_address_format_bit_size(ubo_format),
|
||||
nir_imm_int(builder, 0),
|
||||
.desc_set = data->desc_set, .binding = data->binding,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
.desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *load_desc = nir_load_vulkan_descriptor(
|
||||
builder, nir_address_format_num_components(ubo_format),
|
||||
nir_address_format_bit_size(ubo_format),
|
||||
index, .desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
index, .desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *offset = intrin->src[0].ssa;
|
||||
nir_def *load_data = nir_load_ubo(
|
||||
|
|
@ -465,12 +465,12 @@ lower_yz_flip(struct nir_builder *builder, nir_instr *instr,
|
|||
nir_imm_int(builder, 0),
|
||||
.desc_set = rt_conf->runtime_data_cbv.register_space,
|
||||
.binding = rt_conf->runtime_data_cbv.base_shader_register,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
.desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *load_desc = nir_load_vulkan_descriptor(
|
||||
builder, nir_address_format_num_components(ubo_format),
|
||||
nir_address_format_bit_size(ubo_format),
|
||||
index, .desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
index, .desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
dyn_yz_flip_mask =
|
||||
nir_load_ubo(builder, 1, 32,
|
||||
|
|
@ -620,12 +620,12 @@ write_pntc_with_pos(nir_builder *b, nir_instr *instr, void *_data)
|
|||
nir_imm_int(b, 0),
|
||||
.desc_set = data->conf->runtime_data_cbv.register_space,
|
||||
.binding = data->conf->runtime_data_cbv.base_shader_register,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
.desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *load_desc = nir_load_vulkan_descriptor(
|
||||
b, nir_address_format_num_components(ubo_format),
|
||||
nir_address_format_bit_size(ubo_format),
|
||||
index, .desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
index, .desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *transform = nir_channels(b,
|
||||
nir_load_ubo(b, 4, 32,
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ load_vulkan_ssbo(nir_builder *b, unsigned buf_idx,
|
|||
nir_imm_int(b, 0),
|
||||
.desc_set = 0,
|
||||
.binding = buf_idx,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
nir_def *descriptor =
|
||||
nir_load_vulkan_descriptor(b, 2, 32, res_index,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
return nir_load_ssbo(b, num_comps, 32,
|
||||
nir_channel(b, descriptor, 0),
|
||||
offset,
|
||||
|
|
@ -287,7 +287,7 @@ lower_buffer_device_address(nir_builder *b, nir_intrinsic_instr *intr, void *dat
|
|||
nir_def *index = nir_iand_imm(b, nir_unpack_64_2x32_split_y(b, pointer), 0xffffff);
|
||||
|
||||
nir_def *descriptor = nir_load_vulkan_descriptor(b, 2, 32, nir_vec2(b, index, offset),
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
.desc_type = nir_descriptor_type_storage_buffer);
|
||||
nir_deref_instr *head = nir_build_deref_cast_with_alignment(b, descriptor, nir_var_mem_ssbo, old_head->type,
|
||||
old_head->cast.ptr_stride,
|
||||
old_head->cast.align_mul,
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ dzn_nir_create_bo_desc(nir_builder *b,
|
|||
else
|
||||
b->shader->info.num_ssbos++;
|
||||
|
||||
VkDescriptorType desc_type =
|
||||
nir_descriptor_type desc_type =
|
||||
var->data.mode == nir_var_mem_ubo ?
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER :
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
nir_descriptor_type_uniform_buffer :
|
||||
nir_descriptor_type_storage_buffer;
|
||||
nir_address_format addr_format = nir_address_format_32bit_index_offset;
|
||||
nir_def *index =
|
||||
nir_vulkan_resource_index(b,
|
||||
|
|
@ -813,12 +813,12 @@ load_dynamic_depth_bias(nir_builder *b, struct dzn_nir_point_gs_info *info)
|
|||
nir_imm_int(b, 0),
|
||||
.desc_set = info->runtime_data_cbv.register_space,
|
||||
.binding = info->runtime_data_cbv.base_shader_register,
|
||||
.desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
.desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
nir_def *load_desc = nir_load_vulkan_descriptor(
|
||||
b, nir_address_format_num_components(ubo_format),
|
||||
nir_address_format_bit_size(ubo_format),
|
||||
index, .desc_type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
index, .desc_type = nir_descriptor_type_uniform_buffer);
|
||||
|
||||
return nir_load_ubo(
|
||||
b, 1, 32,
|
||||
|
|
|
|||
|
|
@ -68,10 +68,10 @@ struct lower_descriptors_ctx {
|
|||
};
|
||||
|
||||
static bool
|
||||
descriptor_type_is_ubo(VkDescriptorType desc_type)
|
||||
descriptor_type_is_ubo(nir_descriptor_type desc_type)
|
||||
{
|
||||
switch (desc_type) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
|
@ -80,10 +80,10 @@ descriptor_type_is_ubo(VkDescriptorType desc_type)
|
|||
}
|
||||
|
||||
static bool
|
||||
descriptor_type_is_ssbo(VkDescriptorType desc_type)
|
||||
descriptor_type_is_ssbo(nir_descriptor_type desc_type)
|
||||
{
|
||||
switch (desc_type) {
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
|
@ -723,7 +723,7 @@ load_descriptor_for_idx_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
uint32_t binding = nir_intrinsic_binding(intrin);
|
||||
index = nir_iadd(b, index, intrin->src[0].ssa);
|
||||
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
if (descriptor_type_is_ubo(desc_type) && ctx->use_bindless_cbuf) {
|
||||
nir_def *desc = load_descriptor(b, 1, 64, set, binding, index, 0, ctx);
|
||||
|
||||
|
|
@ -746,7 +746,7 @@ static bool
|
|||
try_lower_load_vulkan_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
const struct lower_descriptors_ctx *ctx)
|
||||
{
|
||||
ASSERTED const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
ASSERTED const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
nir_intrinsic_instr *idx_intrin = nir_src_as_intrinsic(intrin->src[0]);
|
||||
|
|
|
|||
|
|
@ -60,14 +60,14 @@ struct lower_desc_ctx {
|
|||
};
|
||||
|
||||
static nir_address_format
|
||||
addr_format_for_desc_type(VkDescriptorType desc_type,
|
||||
addr_format_for_desc_type(nir_descriptor_type desc_type,
|
||||
const struct lower_desc_ctx *ctx)
|
||||
{
|
||||
switch (desc_type) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case nir_descriptor_type_uniform_buffer:
|
||||
return ctx->ubo_addr_format;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case nir_descriptor_type_storage_buffer:
|
||||
return ctx->ssbo_addr_format;
|
||||
|
||||
default:
|
||||
|
|
@ -433,7 +433,7 @@ lower_res_intrinsic(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
{
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
|
||||
const VkDescriptorType desc_type = nir_intrinsic_desc_type(intrin);
|
||||
const nir_descriptor_type desc_type = nir_intrinsic_desc_type(intrin);
|
||||
nir_address_format addr_format = addr_format_for_desc_type(desc_type, ctx);
|
||||
|
||||
nir_def *res;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue