mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Run folding passes again after lower_nonconstant_array_loads.
This is because lower_nonconstant_array_loads() can potentially turn nonconstant loads into constant loads, allowing copy-prop to turn these loads into previous instructions, which might help other passes as well. This patch lowers the number of required temps for the following ps_2_0 shader from 19 to 16: int i; float3x3 mats[4]; float4 main() : sv_target { return mul(mats[i], float3(1, 2, 3)).xyzz; }
This commit is contained in:
committed by
Henri Verbeet
parent
e60c89c532
commit
153b7c8460
Notes:
Henri Verbeet
2025-02-20 16:06:52 +01:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Elizabeth Figura (@zfigura) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1367
@@ -7024,6 +7024,24 @@ void hlsl_lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
|||||||
lower_ir(ctx, lower_index_loads, body);
|
lower_ir(ctx, lower_index_loads, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hlsl_run_folding_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
||||||
|
{
|
||||||
|
bool progress;
|
||||||
|
|
||||||
|
hlsl_transform_ir(ctx, fold_redundant_casts, body, NULL);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
progress = hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, body, NULL);
|
||||||
|
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_identities, body, NULL);
|
||||||
|
progress |= hlsl_transform_ir(ctx, hlsl_normalize_binary_exprs, body, NULL);
|
||||||
|
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_swizzles, body, NULL);
|
||||||
|
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);
|
||||||
|
progress |= hlsl_transform_ir(ctx, remove_trivial_conditional_branches, body, NULL);
|
||||||
|
} while (progress);
|
||||||
|
}
|
||||||
|
|
||||||
void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
||||||
{
|
{
|
||||||
bool progress;
|
bool progress;
|
||||||
@@ -7048,19 +7066,8 @@ void hlsl_run_const_passes(struct hlsl_ctx *ctx, struct hlsl_block *body)
|
|||||||
lower_ir(ctx, lower_int_abs, body);
|
lower_ir(ctx, lower_int_abs, body);
|
||||||
lower_ir(ctx, lower_casts_to_bool, body);
|
lower_ir(ctx, lower_casts_to_bool, body);
|
||||||
lower_ir(ctx, lower_float_modulus, body);
|
lower_ir(ctx, lower_float_modulus, body);
|
||||||
hlsl_transform_ir(ctx, fold_redundant_casts, body, NULL);
|
|
||||||
|
|
||||||
do
|
hlsl_run_folding_passes(ctx, body);
|
||||||
{
|
|
||||||
progress = hlsl_transform_ir(ctx, hlsl_fold_constant_exprs, body, NULL);
|
|
||||||
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_identities, body, NULL);
|
|
||||||
progress |= hlsl_transform_ir(ctx, hlsl_normalize_binary_exprs, body, NULL);
|
|
||||||
progress |= hlsl_transform_ir(ctx, hlsl_fold_constant_swizzles, body, NULL);
|
|
||||||
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);
|
|
||||||
progress |= hlsl_transform_ir(ctx, remove_trivial_conditional_branches, body, NULL);
|
|
||||||
} while (progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_program *program,
|
static void generate_vsir_signature_entry(struct hlsl_ctx *ctx, struct vsir_program *program,
|
||||||
@@ -12577,6 +12584,8 @@ static void process_entry_function(struct hlsl_ctx *ctx,
|
|||||||
|
|
||||||
lower_ir(ctx, validate_nonconstant_vector_store_derefs, body);
|
lower_ir(ctx, validate_nonconstant_vector_store_derefs, body);
|
||||||
|
|
||||||
|
hlsl_run_folding_passes(ctx, body);
|
||||||
|
|
||||||
do
|
do
|
||||||
compute_liveness(ctx, entry_func);
|
compute_liveness(ctx, entry_func);
|
||||||
while (hlsl_transform_ir(ctx, dce, body, NULL));
|
while (hlsl_transform_ir(ctx, dce, body, NULL));
|
||||||
|
Reference in New Issue
Block a user