microsoft/compiler: Emit CBVs via variables for Vulkan

The resources need to be emitted in a particular order, so CBVs
have to be emitted first and can't be emitted as we iterate through
instructions.

Reviewed-by: Enrico Galli <enrico.galli@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>
This commit is contained in:
Jesse Natalie 2021-04-09 14:39:44 -07:00 committed by Marge Bot
parent debdc81ccf
commit 15de712270

View file

@ -3209,12 +3209,6 @@ emit_load_vulkan_descriptor(struct ntd_context *ctx, nir_intrinsic_instr *intr)
switch (nir_intrinsic_desc_type(intr)) {
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: {
if (ctx->cbv_handles[binding])
break;
char name[64];
snprintf(name, sizeof(name), "__ubo%d", binding);
if (!emit_cbv(ctx, binding, 16384 /*4096 vec4's*/, 1, name))
return false;
break;
}
default:
@ -4008,7 +4002,7 @@ prepare_phi_values(struct ntd_context *ctx, nir_shader *shader)
static bool
emit_cbvs(struct ntd_context *ctx, nir_shader *s)
{
if (s->info.stage == MESA_SHADER_KERNEL) {
if (s->info.stage == MESA_SHADER_KERNEL || ctx->opts->vulkan_environment) {
nir_foreach_variable_with_modes(var, s, nir_var_mem_ubo) {
if (!emit_ubo_var(ctx, var))
return false;
@ -4099,9 +4093,8 @@ emit_module(struct ntd_context *ctx, nir_shader *s, const struct nir_to_dxil_opt
sort_uniforms_by_binding_and_remove_structs(s);
/* CBVs */
if(!opts->vulkan_environment)
if (!emit_cbvs(ctx, s))
return false;
if (!emit_cbvs(ctx, s, opts))
return false;
/* Samplers */
binding = 0;