mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Disallow certain instruction types from constant expressions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
committed by
Alexandre Julliard
parent
a65c0b0e22
commit
06040d2a30
Notes:
Alexandre Julliard
2023-07-04 23:25:55 +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/256
@@ -1143,6 +1143,28 @@ static unsigned int evaluate_static_expression_as_uint(struct hlsl_ctx *ctx, str
|
||||
unsigned int ret = 0;
|
||||
bool progress;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(node, &block->instrs, struct hlsl_ir_node, entry)
|
||||
{
|
||||
switch (node->type)
|
||||
{
|
||||
case HLSL_IR_CONSTANT:
|
||||
case HLSL_IR_EXPR:
|
||||
case HLSL_IR_SWIZZLE:
|
||||
case HLSL_IR_LOAD:
|
||||
case HLSL_IR_INDEX:
|
||||
continue;
|
||||
case HLSL_IR_CALL:
|
||||
case HLSL_IR_IF:
|
||||
case HLSL_IR_LOOP:
|
||||
case HLSL_IR_JUMP:
|
||||
case HLSL_IR_RESOURCE_LOAD:
|
||||
case HLSL_IR_RESOURCE_STORE:
|
||||
case HLSL_IR_STORE:
|
||||
hlsl_error(ctx, &node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
|
||||
"Expected literal expression.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!hlsl_clone_block(ctx, &expr, &ctx->static_initializers))
|
||||
return 0;
|
||||
hlsl_block_add_block(&expr, block);
|
||||
@@ -1169,7 +1191,7 @@ static unsigned int evaluate_static_expression_as_uint(struct hlsl_ctx *ctx, str
|
||||
else
|
||||
{
|
||||
hlsl_error(ctx, &node->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
|
||||
"Failed to evaluate constant expression %d.", node->type);
|
||||
"Failed to evaluate constant expression.");
|
||||
}
|
||||
|
||||
hlsl_block_cleanup(&expr);
|
||||
|
||||
Reference in New Issue
Block a user