mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Remove trivial swizzles.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b4aacec5cd
commit
93a40c1c57
@ -475,6 +475,27 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool remove_trivial_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||
{
|
||||
struct hlsl_ir_swizzle *swizzle;
|
||||
unsigned int i;
|
||||
|
||||
if (instr->type != HLSL_IR_SWIZZLE)
|
||||
return false;
|
||||
swizzle = hlsl_ir_swizzle(instr);
|
||||
|
||||
if (instr->data_type->dimx != swizzle->val.node->data_type->dimx)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < instr->data_type->dimx; ++i)
|
||||
if (((swizzle->swizzle >> (2 * i)) & 3) != i)
|
||||
return false;
|
||||
|
||||
replace_node(instr, swizzle->val.node);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Lower DIV to RCP + MUL. */
|
||||
static bool lower_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||
{
|
||||
@ -1355,6 +1376,7 @@ int hlsl_emit_dxbc(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry_fun
|
||||
}
|
||||
while (progress);
|
||||
while (transform_ir(ctx, fold_constants, body, NULL));
|
||||
transform_ir(ctx, remove_trivial_swizzles, body, NULL);
|
||||
|
||||
if (ctx->profile->major_version < 4)
|
||||
transform_ir(ctx, lower_division, body, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user