mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Allow 'const' modifier without initializer in the global scope.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
committed by
Alexandre Julliard
parent
7fd10bb6bc
commit
4f2e07a45d
Notes:
Alexandre Julliard
2023-08-15 22:06:39 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/302
@ -2131,6 +2131,12 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
|
|||||||
if (var->semantic.name)
|
if (var->semantic.name)
|
||||||
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
|
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
|
||||||
"Semantics are not allowed on local variables.");
|
"Semantics are not allowed on local variables.");
|
||||||
|
|
||||||
|
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count && !(modifiers & HLSL_STORAGE_STATIC))
|
||||||
|
{
|
||||||
|
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
|
||||||
|
"Const variable \"%s\" is missing an initializer.", var->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((var->storage_modifiers & HLSL_STORAGE_STATIC) && type_has_numeric_components(var->data_type)
|
if ((var->storage_modifiers & HLSL_STORAGE_STATIC) && type_has_numeric_components(var->data_type)
|
||||||
@ -2140,15 +2146,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
|
|||||||
"Static variables cannot have both numeric and resource components.");
|
"Static variables cannot have both numeric and resource components.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((type->modifiers & HLSL_MODIFIER_CONST) && !v->initializer.args_count
|
|
||||||
&& !(modifiers & (HLSL_STORAGE_STATIC | HLSL_STORAGE_UNIFORM)))
|
|
||||||
{
|
|
||||||
hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
|
|
||||||
"Const variable \"%s\" is missing an initializer.", var->name);
|
|
||||||
hlsl_free_var(var);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hlsl_add_var(ctx, var, local))
|
if (!hlsl_add_var(ctx, var, local))
|
||||||
{
|
{
|
||||||
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
|
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
const float4 f1;
|
const float4 f1;
|
||||||
const uniform float4 f2;
|
const uniform float4 f2;
|
||||||
|
|
||||||
@ -10,8 +10,8 @@ float4 main() : sv_target
|
|||||||
[test]
|
[test]
|
||||||
uniform 0 float4 1.0 2.0 3.0 4.0
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
||||||
uniform 4 float4 0.1 0.2 0.3 0.4
|
uniform 4 float4 0.1 0.2 0.3 0.4
|
||||||
todo draw quad
|
draw quad
|
||||||
todo probe all rgba (1.1, 2.2, 3.3, 4.4)
|
probe all rgba (1.1, 2.2, 3.3, 4.4)
|
||||||
|
|
||||||
[pixel shader fail]
|
[pixel shader fail]
|
||||||
float4 main() : sv_target
|
float4 main() : sv_target
|
||||||
|
Reference in New Issue
Block a user