mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 13:30:11 +01:00
microsoft/compiler: Add support for get_ssbo_size to translator
Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11629>
This commit is contained in:
parent
b4369de27f
commit
ddad83fc97
2 changed files with 41 additions and 3 deletions
|
|
@ -3147,6 +3147,36 @@ emit_image_size(struct ntd_context *ctx, nir_intrinsic_instr *intr)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
emit_get_ssbo_size(struct ntd_context *ctx, nir_intrinsic_instr *intr)
|
||||
{
|
||||
const struct dxil_value* handle = NULL;
|
||||
if (ctx->opts->vulkan_environment) {
|
||||
handle = get_src_ssa(ctx, intr->src[0].ssa, 0);
|
||||
} else {
|
||||
int binding = nir_src_as_int(intr->src[0]);
|
||||
handle = ctx->uav_handles[binding];
|
||||
}
|
||||
|
||||
if (!handle)
|
||||
return false;
|
||||
|
||||
struct texop_parameters params = {
|
||||
.tex = handle,
|
||||
.lod_or_sample = dxil_module_get_undef(
|
||||
&ctx->mod, dxil_module_get_int_type(&ctx->mod, 32))
|
||||
};
|
||||
|
||||
const struct dxil_value *dimensions = emit_texture_size(ctx, ¶ms);
|
||||
if (!dimensions)
|
||||
return false;
|
||||
|
||||
const struct dxil_value *retval = dxil_emit_extractval(&ctx->mod, dimensions, 0);
|
||||
store_dest(ctx, &intr->dest, 0, retval, nir_type_uint);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
emit_ssbo_atomic(struct ntd_context *ctx, nir_intrinsic_instr *intr,
|
||||
enum dxil_atomic_op op, nir_alu_type type)
|
||||
|
|
@ -3452,6 +3482,8 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
|
|||
case nir_intrinsic_image_deref_size:
|
||||
case nir_intrinsic_image_size:
|
||||
return emit_image_size(ctx, intr);
|
||||
case nir_intrinsic_get_ssbo_size:
|
||||
return emit_get_ssbo_size(ctx, intr);
|
||||
|
||||
case nir_intrinsic_vulkan_resource_index:
|
||||
return emit_vulkan_resource_index(ctx, intr);
|
||||
|
|
|
|||
|
|
@ -37,9 +37,15 @@ spirv_to_dxil(const uint32_t *words, size_t word_count,
|
|||
if (stage == MESA_SHADER_NONE || stage == MESA_SHADER_KERNEL)
|
||||
return false;
|
||||
|
||||
struct spirv_to_nir_options spirv_opts = {0};
|
||||
spirv_opts.ubo_addr_format = nir_address_format_32bit_index_offset;
|
||||
spirv_opts.ssbo_addr_format = nir_address_format_32bit_index_offset;
|
||||
struct spirv_to_nir_options spirv_opts = {
|
||||
.ubo_addr_format = nir_address_format_32bit_index_offset,
|
||||
.ssbo_addr_format = nir_address_format_32bit_index_offset,
|
||||
// use_deref_buffer_array_length + nir_lower_explicit_io force
|
||||
// get_ssbo_size to take in the return from load_vulkan_descriptor
|
||||
// instead of vulkan_resource_index. This makes it much easier to
|
||||
// get the DXIL handle for the SSBO.
|
||||
.use_deref_buffer_array_length = true
|
||||
};
|
||||
|
||||
glsl_type_singleton_init_or_ref();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue