dwords[0] = get_basic_srv_uav_res_props_dword(true, false, false /*TODO*/, false,
dxil_sampler_dim_to_resource_kind(nir_intrinsic_image_dim(intr),
nir_intrinsic_image_array(intr)));
+ unsigned num_comps = intr->num_components ? intr->num_components : 1;
+ if (nir_intrinsic_has_format(intr)) {
+ enum pipe_format format = nir_intrinsic_format(intr);
+ if (format != PIPE_FORMAT_NONE)
+ num_comps = util_format_get_nr_components(format);
+ }
dwords[1] = get_typed_srv_uav_res_props_dword(comp_type_from_alu_type(alu_type_from_image_intr(intr)),
- intr->num_components ? intr->num_components : 1,
- 0);
+ num_comps, 0);
const struct dxil_value *values[2] = {
dxil_module_get_int32_const(m, dwords[0]),
enum dxil_resource_kind res_kind = dxil_get_resource_kind(var->type);
const char *name = var->name;
- return emit_uav(ctx, binding, space, count, comp_type, 4, res_kind, name);
+ return emit_uav(ctx, binding, space, count, comp_type,
+ util_format_get_nr_components(var->data.image.format),
+ res_kind, name);
}
static void
store_dest(ctx, &intr->dest, i, component);
}
- if (num_components > 1)
+ if (util_format_get_nr_components(nir_intrinsic_format(intr)) > 1)
ctx->mod.feats.typed_uav_load_additional_formats = true;
return true;
NIR_PASS_V(s, dxil_nir_move_consts);
NIR_PASS_V(s, nir_opt_dce);
+ NIR_PASS_V(s, dxil_nir_guess_image_formats);
+
if (debug_dxil & DXIL_DEBUG_VERBOSE)
nir_print_shader(s, stderr);