mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Split matrix copies.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Francisco Casas <fcasas@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d1fac2660c
commit
e38ee49e99
@ -672,6 +672,57 @@ static bool split_struct_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int minor_size(const struct hlsl_type *type)
|
||||||
|
{
|
||||||
|
if (type->type == HLSL_CLASS_VECTOR || type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||||
|
return type->dimx;
|
||||||
|
else
|
||||||
|
return type->dimy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int major_size(const struct hlsl_type *type)
|
||||||
|
{
|
||||||
|
if (type->type == HLSL_CLASS_VECTOR || type->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||||
|
return type->dimy;
|
||||||
|
else
|
||||||
|
return type->dimx;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool split_matrix_copies(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||||
|
{
|
||||||
|
const struct hlsl_ir_node *rhs;
|
||||||
|
struct hlsl_type *element_type;
|
||||||
|
const struct hlsl_type *type;
|
||||||
|
unsigned int i;
|
||||||
|
struct hlsl_ir_store *store;
|
||||||
|
|
||||||
|
if (instr->type != HLSL_IR_STORE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
store = hlsl_ir_store(instr);
|
||||||
|
rhs = store->rhs.node;
|
||||||
|
type = rhs->data_type;
|
||||||
|
if (type->type != HLSL_CLASS_MATRIX)
|
||||||
|
return false;
|
||||||
|
element_type = hlsl_get_vector_type(ctx, type->base_type, minor_size(type));
|
||||||
|
|
||||||
|
if (rhs->type != HLSL_IR_LOAD)
|
||||||
|
{
|
||||||
|
hlsl_fixme(ctx, &instr->loc, "Copying from unsupported node type.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < major_size(type); ++i)
|
||||||
|
{
|
||||||
|
if (!split_copy(ctx, store, hlsl_ir_load(rhs), 4 * i, element_type))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
list_remove(&store->node.entry);
|
||||||
|
hlsl_free_instr(&store->node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
static bool lower_narrowing_casts(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
|
||||||
{
|
{
|
||||||
const struct hlsl_type *src_type, *dst_type;
|
const struct hlsl_type *src_type, *dst_type;
|
||||||
@ -1685,6 +1736,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
|
|||||||
progress |= transform_ir(ctx, split_struct_copies, body, NULL);
|
progress |= transform_ir(ctx, split_struct_copies, body, NULL);
|
||||||
}
|
}
|
||||||
while (progress);
|
while (progress);
|
||||||
|
transform_ir(ctx, split_matrix_copies, body, NULL);
|
||||||
transform_ir(ctx, lower_narrowing_casts, body, NULL);
|
transform_ir(ctx, lower_narrowing_casts, body, NULL);
|
||||||
transform_ir(ctx, lower_casts_to_bool, body, NULL);
|
transform_ir(ctx, lower_casts_to_bool, body, NULL);
|
||||||
do
|
do
|
||||||
|
@ -45,3 +45,20 @@ uniform 8 float4 9.0 10.0 11.0 12.0
|
|||||||
uniform 12 float4 13.0 14.0 15.0 16.0
|
uniform 12 float4 13.0 14.0 15.0 16.0
|
||||||
todo draw quad
|
todo draw quad
|
||||||
probe all rgba (1.0, 5.0, 7.0, 12.0)
|
probe all rgba (1.0, 5.0, 7.0, 12.0)
|
||||||
|
|
||||||
|
[pixel shader]
|
||||||
|
uniform float4x4 m;
|
||||||
|
|
||||||
|
float4 main() : SV_TARGET
|
||||||
|
{
|
||||||
|
float4x4 m2 = m;
|
||||||
|
return float4(m2[0][0], m2[1][0], m2[1][2], m2[2][3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float4 1.0 2.0 3.0 4.0
|
||||||
|
uniform 4 float4 5.0 6.0 7.0 8.0
|
||||||
|
uniform 8 float4 9.0 10.0 11.0 12.0
|
||||||
|
uniform 12 float4 13.0 14.0 15.0 16.0
|
||||||
|
todo draw quad
|
||||||
|
probe all rgba (1.0, 2.0, 10.0, 15.0)
|
||||||
|
Loading…
Reference in New Issue
Block a user