microsoft/compiler: Handle domain location intrinsic

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
This commit is contained in:
Jesse Natalie 2022-01-02 15:23:06 -08:00 committed by Marge Bot
parent 8524d04783
commit 9aca56b137
2 changed files with 41 additions and 0 deletions

View File

@ -74,6 +74,7 @@ static struct predefined_func_descr predefined_funcs[] = {
{"dx.op.primitiveID", "i", "i", DXIL_ATTR_KIND_READ_NONE},
{"dx.op.outputControlPointID", "i", "i", DXIL_ATTR_KIND_READ_NONE},
{"dx.op.gsInstanceID", "i", "i", DXIL_ATTR_KIND_READ_NONE},
{"dx.op.domainLocation", "f", "ii", DXIL_ATTR_KIND_READ_NONE},
{"dx.op.legacyF16ToF32", "f", "ii", DXIL_ATTR_KIND_READ_ONLY},
{"dx.op.legacyF32ToF16", "i", "if", DXIL_ATTR_KIND_READ_ONLY},
{"dx.op.makeDouble", "g", "iii", DXIL_ATTR_KIND_READ_NONE},

View File

@ -290,6 +290,7 @@ enum dxil_intr {
DXIL_INTR_LOAD_OUTPUT_CONTROL_POINT = 103,
DXIL_INTR_LOAD_PATCH_CONSTANT = 104,
DXIL_INTR_DOMAIN_LOCATION = 105,
DXIL_INTR_STORE_PATCH_CONSTANT = 106,
DXIL_INTR_OUTPUT_CONTROL_POINT_ID = 107,
DXIL_INTR_PRIMITIVE_ID = 108,
@ -2638,6 +2639,43 @@ emit_load_sample_mask_in(struct ntd_context *ctx, nir_intrinsic_instr *intr)
return true;
}
static bool
emit_load_tess_coord(struct ntd_context *ctx,
nir_intrinsic_instr *intr)
{
const struct dxil_func *func =
dxil_get_function(&ctx->mod, "dx.op.domainLocation", DXIL_F32);
if (!func)
return false;
const struct dxil_value *opcode =
dxil_module_get_int32_const(&ctx->mod, DXIL_INTR_DOMAIN_LOCATION);
if (!opcode)
return false;
unsigned num_coords = ctx->shader->info.tess._primitive_mode == TESS_PRIMITIVE_TRIANGLES ? 3 : 2;
for (unsigned i = 0; i < num_coords; ++i) {
unsigned component_idx = i;
const struct dxil_value *component = dxil_module_get_int32_const(&ctx->mod, component_idx);
if (!component)
return false;
const struct dxil_value *args[] = { opcode, component };
const struct dxil_value *value =
dxil_emit_call(&ctx->mod, func, args, ARRAY_SIZE(args));
store_dest_value(ctx, &intr->dest, i, value);
}
for (unsigned i = num_coords; i < intr->dest.ssa.num_components; ++i) {
const struct dxil_value *value = dxil_module_get_float_const(&ctx->mod, 0.0f);
store_dest_value(ctx, &intr->dest, i, value);
}
return true;
}
static const struct dxil_value *
get_int32_undef(struct dxil_module *m)
{
@ -3987,6 +4025,8 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
}
case nir_intrinsic_load_sample_mask_in:
return emit_load_sample_mask_in(ctx, intr);
case nir_intrinsic_load_tess_coord:
return emit_load_tess_coord(ctx, intr);
case nir_intrinsic_load_shared_dxil:
return emit_load_shared(ctx, intr);
case nir_intrinsic_load_scratch_dxil: