mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/d3dbc: Don't require a hlsl_semantic to get register and usage.
This commit is contained in:
parent
003f4c7600
commit
704ce03561
Notes:
Henri Verbeet
2024-07-09 21:08:22 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/877
@ -1354,8 +1354,8 @@ int d3dbc_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t c
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
const struct hlsl_semantic *semantic, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg)
|
||||
bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version, const char *semantic_name,
|
||||
unsigned int semantic_index, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -1405,7 +1405,7 @@ bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(register_table); ++i)
|
||||
{
|
||||
if (!ascii_strcasecmp(semantic->name, register_table[i].semantic)
|
||||
if (!ascii_strcasecmp(semantic_name, register_table[i].semantic)
|
||||
&& output == register_table[i].output
|
||||
&& version->type == register_table[i].shader_type
|
||||
&& version->major == register_table[i].major_version)
|
||||
@ -1414,7 +1414,7 @@ bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
if (register_table[i].type == VKD3DSPR_MISCTYPE || register_table[i].type == VKD3DSPR_RASTOUT)
|
||||
*reg = register_table[i].offset;
|
||||
else
|
||||
*reg = semantic->index;
|
||||
*reg = semantic_index;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1422,7 +1422,8 @@ bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hlsl_sm1_usage_from_semantic(const struct hlsl_semantic *semantic, D3DDECLUSAGE *usage, uint32_t *usage_idx)
|
||||
bool hlsl_sm1_usage_from_semantic(const char *semantic_name,
|
||||
uint32_t semantic_index, D3DDECLUSAGE *usage, uint32_t *usage_idx)
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
@ -1454,10 +1455,10 @@ bool hlsl_sm1_usage_from_semantic(const struct hlsl_semantic *semantic, D3DDECLU
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(semantics); ++i)
|
||||
{
|
||||
if (!ascii_strcasecmp(semantic->name, semantics[i].name))
|
||||
if (!ascii_strcasecmp(semantic_name, semantics[i].name))
|
||||
{
|
||||
*usage = semantics[i].usage;
|
||||
*usage_idx = semantic->index;
|
||||
*usage_idx = semantic_index;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2167,14 +2168,14 @@ static void d3dbc_write_semantic_dcl(struct d3dbc_compiler *d3dbc, const struct
|
||||
if ((!output && !var->last_read) || (output && !var->first_write))
|
||||
return;
|
||||
|
||||
if (hlsl_sm1_register_from_semantic(version, &var->semantic, output, ®.type, ®.reg))
|
||||
if (hlsl_sm1_register_from_semantic(version, var->semantic.name, var->semantic.index, output, ®.type, ®.reg))
|
||||
{
|
||||
usage = 0;
|
||||
usage_idx = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx);
|
||||
ret = hlsl_sm1_usage_from_semantic(var->semantic.name, var->semantic.index, &usage, &usage_idx);
|
||||
assert(ret);
|
||||
reg.type = output ? VKD3DSPR_OUTPUT : VKD3DSPR_INPUT;
|
||||
reg.reg = var->regs[HLSL_REGSET_NUMERIC].id;
|
||||
@ -2572,8 +2573,8 @@ static void d3dbc_write_load(struct d3dbc_compiler *d3dbc, const struct hlsl_ir_
|
||||
}
|
||||
else if (load->src.var->is_input_semantic)
|
||||
{
|
||||
if (!hlsl_sm1_register_from_semantic(&d3dbc->program->shader_version, &load->src.var->semantic,
|
||||
false, &sm1_instr.srcs[0].type, &sm1_instr.srcs[0].reg))
|
||||
if (!hlsl_sm1_register_from_semantic(&d3dbc->program->shader_version, load->src.var->semantic.name,
|
||||
load->src.var->semantic.index, false, &sm1_instr.srcs[0].type, &sm1_instr.srcs[0].reg))
|
||||
{
|
||||
assert(reg.allocated);
|
||||
sm1_instr.srcs[0].type = VKD3DSPR_INPUT;
|
||||
@ -2693,8 +2694,8 @@ static void d3dbc_write_store(struct d3dbc_compiler *d3dbc, const struct hlsl_ir
|
||||
sm1_instr.dst.type = VKD3DSPR_TEMP;
|
||||
sm1_instr.dst.reg = 0;
|
||||
}
|
||||
else if (!hlsl_sm1_register_from_semantic(&d3dbc->program->shader_version,
|
||||
&store->lhs.var->semantic, true, &sm1_instr.dst.type, &sm1_instr.dst.reg))
|
||||
else if (!hlsl_sm1_register_from_semantic(&d3dbc->program->shader_version, store->lhs.var->semantic.name,
|
||||
store->lhs.var->semantic.index, true, &sm1_instr.dst.type, &sm1_instr.dst.reg))
|
||||
{
|
||||
assert(reg.allocated);
|
||||
sm1_instr.dst.type = VKD3DSPR_OUTPUT;
|
||||
|
@ -1469,9 +1469,10 @@ bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx,
|
||||
|
||||
D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type);
|
||||
D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type);
|
||||
bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
const struct hlsl_semantic *semantic, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg);
|
||||
bool hlsl_sm1_usage_from_semantic(const struct hlsl_semantic *semantic, D3DDECLUSAGE *usage, uint32_t *usage_idx);
|
||||
bool hlsl_sm1_register_from_semantic(const struct vkd3d_shader_version *version, const char *semantic_name,
|
||||
unsigned int semantic_index, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg);
|
||||
bool hlsl_sm1_usage_from_semantic(const char *semantic_name,
|
||||
uint32_t semantic_index, D3DDECLUSAGE *usage, uint32_t *usage_idx);
|
||||
|
||||
void write_sm1_uniforms(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer);
|
||||
int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
|
@ -4727,8 +4727,9 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
||||
version.major = ctx->profile->major_version;
|
||||
version.minor = ctx->profile->minor_version;
|
||||
version.type = ctx->profile->type;
|
||||
builtin = hlsl_sm1_register_from_semantic(&version, &var->semantic, output, &type, ®);
|
||||
if (!builtin && !hlsl_sm1_usage_from_semantic(&var->semantic, &usage, &usage_idx))
|
||||
builtin = hlsl_sm1_register_from_semantic(&version,
|
||||
var->semantic.name, var->semantic.index, output, &type, ®);
|
||||
if (!builtin && !hlsl_sm1_usage_from_semantic(var->semantic.name, var->semantic.index, &usage, &usage_idx))
|
||||
{
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
|
||||
"Invalid semantic '%s'.", var->semantic.name);
|
||||
|
Loading…
Reference in New Issue
Block a user