mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Allow accounting for interpolation mode when allocating semantics.
For now this has no effect since semantics are allocated with reg_size 4, but will have effect when optimizing interstage signatures.
This commit is contained in:
parent
b65f5fb069
commit
7fd6c29ee8
Notes:
Henri Verbeet
2024-10-22 20:54:15 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1193
@ -1636,6 +1636,9 @@ int tpf_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context,
|
||||
struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_func);
|
||||
|
||||
enum vkd3d_shader_interpolation_mode sm4_get_interpolation_mode(struct hlsl_type *type,
|
||||
unsigned int storage_modifiers);
|
||||
|
||||
struct hlsl_ir_function_decl *hlsl_compile_internal_function(struct hlsl_ctx *ctx, const char *name, const char *hlsl);
|
||||
|
||||
int hlsl_lexer_compile(struct hlsl_ctx *ctx, const struct vkd3d_shader_code *hlsl);
|
||||
|
@ -5190,6 +5190,36 @@ uint32_t allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_ir_function_d
|
||||
return allocator.reg_count;
|
||||
}
|
||||
|
||||
enum vkd3d_shader_interpolation_mode sm4_get_interpolation_mode(struct hlsl_type *type, unsigned int storage_modifiers)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
static const struct
|
||||
{
|
||||
unsigned int modifiers;
|
||||
enum vkd3d_shader_interpolation_mode mode;
|
||||
}
|
||||
modes[] =
|
||||
{
|
||||
{HLSL_STORAGE_CENTROID | HLSL_STORAGE_NOPERSPECTIVE, VKD3DSIM_LINEAR_NOPERSPECTIVE_CENTROID},
|
||||
{HLSL_STORAGE_NOPERSPECTIVE, VKD3DSIM_LINEAR_NOPERSPECTIVE},
|
||||
{HLSL_STORAGE_CENTROID, VKD3DSIM_LINEAR_CENTROID},
|
||||
{HLSL_STORAGE_CENTROID | HLSL_STORAGE_LINEAR, VKD3DSIM_LINEAR_CENTROID},
|
||||
};
|
||||
|
||||
if ((storage_modifiers & HLSL_STORAGE_NOINTERPOLATION)
|
||||
|| base_type_get_semantic_equivalent(type->e.numeric.type) == HLSL_TYPE_UINT)
|
||||
return VKD3DSIM_CONSTANT;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(modes); ++i)
|
||||
{
|
||||
if ((storage_modifiers & modes[i].modifiers) == modes[i].modifiers)
|
||||
return modes[i].mode;
|
||||
}
|
||||
|
||||
return VKD3DSIM_LINEAR;
|
||||
}
|
||||
|
||||
static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var *var,
|
||||
struct register_allocator *allocator, bool output, bool is_patch_constant_func)
|
||||
{
|
||||
@ -5259,7 +5289,10 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
||||
}
|
||||
else
|
||||
{
|
||||
var->regs[HLSL_REGSET_NUMERIC] = allocate_register(ctx, allocator, 1, UINT_MAX, 4, var->data_type->dimx, 0);
|
||||
int mode = (ctx->profile->major_version < 4)
|
||||
? 0 : sm4_get_interpolation_mode(var->data_type, var->storage_modifiers);
|
||||
|
||||
var->regs[HLSL_REGSET_NUMERIC] = allocate_register(ctx, allocator, 1, UINT_MAX, 4, var->data_type->dimx, mode);
|
||||
|
||||
TRACE("Allocated %s to %s.\n", var->name, debug_register(output ? 'o' : 'v',
|
||||
var->regs[HLSL_REGSET_NUMERIC], var->data_type));
|
||||
@ -6328,16 +6361,15 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_prog
|
||||
if (sm4_register_from_semantic_name(&program->shader_version, var->semantic.name, output, &type, &has_idx))
|
||||
{
|
||||
register_index = has_idx ? var->semantic.index : ~0u;
|
||||
mask = (1u << var->data_type->dimx) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
VKD3D_ASSERT(var->regs[HLSL_REGSET_NUMERIC].allocated);
|
||||
register_index = var->regs[HLSL_REGSET_NUMERIC].id;
|
||||
mask = var->regs[HLSL_REGSET_NUMERIC].writemask;
|
||||
}
|
||||
|
||||
/* NOTE: remember to change this to the actually allocated mask once
|
||||
* we start optimizing interstage signatures. */
|
||||
mask = (1u << var->data_type->dimx) - 1;
|
||||
use_mask = mask; /* FIXME: retrieve use mask accurately. */
|
||||
|
||||
switch (var->data_type->e.numeric.type)
|
||||
|
@ -4894,38 +4894,9 @@ static void tpf_write_dcl_semantic(const struct tpf_compiler *tpf,
|
||||
|
||||
if (version->type == VKD3D_SHADER_TYPE_PIXEL)
|
||||
{
|
||||
enum vkd3d_shader_interpolation_mode mode = VKD3DSIM_LINEAR;
|
||||
|
||||
if ((var->storage_modifiers & HLSL_STORAGE_NOINTERPOLATION) || type_is_integer(var->data_type))
|
||||
{
|
||||
mode = VKD3DSIM_CONSTANT;
|
||||
}
|
||||
else
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
unsigned int modifiers;
|
||||
enum vkd3d_shader_interpolation_mode mode;
|
||||
}
|
||||
modes[] =
|
||||
{
|
||||
{ HLSL_STORAGE_CENTROID | HLSL_STORAGE_NOPERSPECTIVE, VKD3DSIM_LINEAR_NOPERSPECTIVE_CENTROID },
|
||||
{ HLSL_STORAGE_NOPERSPECTIVE, VKD3DSIM_LINEAR_NOPERSPECTIVE },
|
||||
{ HLSL_STORAGE_CENTROID, VKD3DSIM_LINEAR_CENTROID },
|
||||
{ HLSL_STORAGE_CENTROID | HLSL_STORAGE_LINEAR, VKD3DSIM_LINEAR_CENTROID },
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(modes); ++i)
|
||||
{
|
||||
if ((var->storage_modifiers & modes[i].modifiers) == modes[i].modifiers)
|
||||
{
|
||||
mode = modes[i].mode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mode = sm4_get_interpolation_mode(var->data_type, var->storage_modifiers);
|
||||
instr.extra_bits |= mode << VKD3D_SM4_INTERPOLATION_MODE_SHIFT;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user