mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/tpf: Make sysval_semantic_from_hlsl() independent of HLSL IR.
This commit is contained in:
parent
7cc8151b81
commit
a243862b8c
Notes:
Henri Verbeet
2024-10-16 21:46:52 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1152
@ -1629,9 +1629,6 @@ int d3dbc_compile(struct vsir_program *program, uint64_t config_flags,
|
||||
const struct vkd3d_shader_compile_info *compile_info, const struct vkd3d_shader_code *ctab,
|
||||
struct vkd3d_shader_code *out, struct vkd3d_shader_message_context *message_context);
|
||||
|
||||
bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
||||
const struct vkd3d_shader_version *version, bool semantic_compat_mapping,
|
||||
const struct hlsl_semantic *hlsl_semantic, bool output);
|
||||
bool hlsl_sm4_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
const struct hlsl_semantic *semantic, bool output, enum vkd3d_shader_register_type *type, bool *has_idx);
|
||||
|
||||
|
@ -5217,7 +5217,8 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var
|
||||
enum vkd3d_shader_sysval_semantic semantic;
|
||||
bool has_idx;
|
||||
|
||||
if (!sysval_semantic_from_hlsl(&semantic, &version, ctx->semantic_compat_mapping, &var->semantic, output))
|
||||
if (!sm4_sysval_semantic_from_semantic_name(&semantic, &version,
|
||||
ctx->semantic_compat_mapping, var->semantic.name, output))
|
||||
{
|
||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
|
||||
"Invalid semantic '%s'.", var->semantic.name);
|
||||
@ -6299,8 +6300,8 @@ static void generate_vsir_signature_entry(struct hlsl_ctx *ctx,
|
||||
struct vkd3d_string_buffer *string;
|
||||
bool has_idx, ret;
|
||||
|
||||
ret = sysval_semantic_from_hlsl(&sysval, &program->shader_version,
|
||||
ctx->semantic_compat_mapping, &var->semantic, output);
|
||||
ret = sm4_sysval_semantic_from_semantic_name(&sysval, &program->shader_version,
|
||||
ctx->semantic_compat_mapping, var->semantic.name, output);
|
||||
VKD3D_ASSERT(ret);
|
||||
if (sysval == ~0u)
|
||||
return;
|
||||
|
@ -3044,9 +3044,9 @@ bool hlsl_sm4_register_from_semantic(const struct vkd3d_shader_version *version,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
||||
const struct vkd3d_shader_version *version, bool semantic_compat_mapping,
|
||||
const struct hlsl_semantic *hlsl_semantic, bool output)
|
||||
bool sm4_sysval_semantic_from_semantic_name(enum vkd3d_shader_sysval_semantic *sysval_semantic,
|
||||
const struct vkd3d_shader_version *version,
|
||||
bool semantic_compat_mapping, const char *semantic_name, bool output)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -3094,16 +3094,16 @@ bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
||||
{"sv_rendertargetarrayindex", true, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_RENDER_TARGET_ARRAY_INDEX},
|
||||
{"sv_viewportarrayindex", true, VKD3D_SHADER_TYPE_VERTEX, VKD3D_SHADER_SV_VIEWPORT_ARRAY_INDEX},
|
||||
};
|
||||
bool needs_compat_mapping = ascii_strncasecmp(hlsl_semantic->name, "sv_", 3);
|
||||
bool needs_compat_mapping = ascii_strncasecmp(semantic_name, "sv_", 3);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(semantics); ++i)
|
||||
{
|
||||
if (!ascii_strcasecmp(hlsl_semantic->name, semantics[i].name)
|
||||
if (!ascii_strcasecmp(semantic_name, semantics[i].name)
|
||||
&& output == semantics[i].output
|
||||
&& (semantic_compat_mapping == needs_compat_mapping || !needs_compat_mapping)
|
||||
&& version->type == semantics[i].shader_type)
|
||||
{
|
||||
*semantic = semantics[i].semantic;
|
||||
*sysval_semantic = semantics[i].semantic;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -3111,7 +3111,7 @@ bool sysval_semantic_from_hlsl(enum vkd3d_shader_sysval_semantic *semantic,
|
||||
if (!needs_compat_mapping)
|
||||
return false;
|
||||
|
||||
*semantic = VKD3D_SHADER_SV_NONE;
|
||||
*sysval_semantic = VKD3D_SHADER_SV_NONE;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4745,7 +4745,8 @@ static void write_sm4_dcl_semantic(const struct tpf_compiler *tpf, const struct
|
||||
if (instr.dsts[0].reg.type == VKD3DSPR_DEPTHOUT)
|
||||
instr.dsts[0].reg.dimension = VSIR_DIMENSION_SCALAR;
|
||||
|
||||
sysval_semantic_from_hlsl(&semantic, version, tpf->ctx->semantic_compat_mapping, &var->semantic, output);
|
||||
sm4_sysval_semantic_from_semantic_name(&semantic, version,
|
||||
tpf->ctx->semantic_compat_mapping, var->semantic.name, output);
|
||||
if (semantic == ~0u)
|
||||
semantic = VKD3D_SHADER_SV_NONE;
|
||||
|
||||
|
@ -1606,6 +1606,9 @@ bool sm1_register_from_semantic_name(const struct vkd3d_shader_version *version,
|
||||
unsigned int semantic_index, bool output, enum vkd3d_shader_register_type *type, unsigned int *reg);
|
||||
bool sm1_usage_from_semantic_name(const char *semantic_name,
|
||||
uint32_t semantic_index, enum vkd3d_decl_usage *usage, uint32_t *usage_idx);
|
||||
bool sm4_sysval_semantic_from_semantic_name(enum vkd3d_shader_sysval_semantic *sysval_semantic,
|
||||
const struct vkd3d_shader_version *version,
|
||||
bool semantic_compat_mapping, const char *semantic_name, bool output);
|
||||
|
||||
int d3dbc_parse(const struct vkd3d_shader_compile_info *compile_info, uint64_t config_flags,
|
||||
struct vkd3d_shader_message_context *message_context, struct vsir_program *program);
|
||||
|
Loading…
Reference in New Issue
Block a user