mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Handle static constants in array size expressions.
This commit is contained in:
parent
38c89442ac
commit
d856be0519
Notes:
Alexandre Julliard
2023-06-12 23:10:20 +02:00
Approved-by: Zebediah Figura (@zfigura) Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/228
@ -1213,6 +1213,7 @@ bool hlsl_offset_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref
|
||||
unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
|
||||
struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
|
||||
|
||||
bool hlsl_copy_propagation_execute(struct hlsl_ctx *ctx, struct hlsl_block *block);
|
||||
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context);
|
||||
bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context);
|
||||
bool hlsl_transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *),
|
||||
|
@ -1098,12 +1098,17 @@ static unsigned int evaluate_static_expression_as_uint(struct hlsl_ctx *ctx, str
|
||||
struct hlsl_ir_constant *constant;
|
||||
struct hlsl_ir_node *node;
|
||||
unsigned int ret = 0;
|
||||
bool progress;
|
||||
|
||||
if (!add_implicit_conversion(ctx, &block->instrs, node_from_list(&block->instrs),
|
||||
hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc))
|
||||
return 0;
|
||||
|
||||
while (hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, block, NULL));
|
||||
do
|
||||
{
|
||||
progress = hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, block, NULL);
|
||||
progress |= hlsl_copy_propagation_execute(ctx, block);
|
||||
} while (progress);
|
||||
|
||||
node = node_from_list(&block->instrs);
|
||||
if (node->type == HLSL_IR_CONSTANT)
|
||||
@ -5494,7 +5499,7 @@ arrays:
|
||||
uint32_t *new_array;
|
||||
unsigned int size;
|
||||
|
||||
hlsl_block_init(&block);
|
||||
hlsl_clone_block(ctx, &block, &ctx->static_initializers);
|
||||
list_move_tail(&block.instrs, $2);
|
||||
|
||||
size = evaluate_static_expression_as_uint(ctx, &block, &@2);
|
||||
|
@ -1649,7 +1649,7 @@ static bool copy_propagation_transform_block(struct hlsl_ctx *ctx, struct hlsl_b
|
||||
return progress;
|
||||
}
|
||||
|
||||
static bool copy_propagation_execute(struct hlsl_ctx *ctx, struct hlsl_block *block)
|
||||
bool hlsl_copy_propagation_execute(struct hlsl_ctx *ctx, struct hlsl_block *block)
|
||||
{
|
||||
struct copy_propagation_state state;
|
||||
bool progress;
|
||||
@ -4073,7 +4073,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
|
||||
{
|
||||
progress = hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, body, NULL);
|
||||
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_swizzles, body, NULL);
|
||||
progress |= copy_propagation_execute(ctx, body);
|
||||
progress |= hlsl_copy_propagation_execute(ctx, body);
|
||||
progress |= hlsl_transform_ir(ctx, fold_swizzle_chains, body, NULL);
|
||||
progress |= hlsl_transform_ir(ctx, remove_trivial_swizzles, body, NULL);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ float4 main() : SV_TARGET
|
||||
draw quad
|
||||
probe all rgba (61, 62, 63, 64)
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
static const int size = 8;
|
||||
static const float array[size] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
@ -49,5 +49,5 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
todo probe all rgba (2, 3, 6, 1)
|
||||
draw quad
|
||||
probe all rgba (2, 3, 6, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user