mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-shader/hlsl: Write SM4 negation instructions.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
2fb1643ee0
commit
7e353ce62b
@@ -277,10 +277,7 @@ XFAIL_TESTS = \
|
|||||||
tests/hlsl-vector-indexing-uniform.shader_test \
|
tests/hlsl-vector-indexing-uniform.shader_test \
|
||||||
tests/math.shader_test \
|
tests/math.shader_test \
|
||||||
tests/trigonometry.shader_test \
|
tests/trigonometry.shader_test \
|
||||||
tests/writemask-assignop-0.shader_test \
|
tests/writemask-assignop-1.shader_test
|
||||||
tests/writemask-assignop-1.shader_test \
|
|
||||||
tests/writemask-assignop-2.shader_test \
|
|
||||||
tests/writemask-assignop-3.shader_test
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_DEMOS
|
if BUILD_DEMOS
|
||||||
|
@@ -561,6 +561,7 @@ struct sm4_register
|
|||||||
unsigned int idx_count;
|
unsigned int idx_count;
|
||||||
enum vkd3d_sm4_dimension dim;
|
enum vkd3d_sm4_dimension dim;
|
||||||
uint32_t immconst_uint[4];
|
uint32_t immconst_uint[4];
|
||||||
|
unsigned int mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sm4_instruction
|
struct sm4_instruction
|
||||||
@@ -710,6 +711,8 @@ static uint32_t sm4_register_order(const struct sm4_register *reg)
|
|||||||
if (reg->type == VKD3D_SM4_RT_IMMCONST)
|
if (reg->type == VKD3D_SM4_RT_IMMCONST)
|
||||||
order += reg->dim == VKD3D_SM4_DIMENSION_VEC4 ? 4 : 1;
|
order += reg->dim == VKD3D_SM4_DIMENSION_VEC4 ? 4 : 1;
|
||||||
order += reg->idx_count;
|
order += reg->idx_count;
|
||||||
|
if (reg->mod)
|
||||||
|
++order;
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -743,8 +746,13 @@ static void write_sm4_instruction(struct vkd3d_bytecode_buffer *buffer, const st
|
|||||||
token = sm4_encode_register(&instr->srcs[i].reg);
|
token = sm4_encode_register(&instr->srcs[i].reg);
|
||||||
token |= sm4_swizzle_type(instr->srcs[i].reg.type) << VKD3D_SM4_SWIZZLE_TYPE_SHIFT;
|
token |= sm4_swizzle_type(instr->srcs[i].reg.type) << VKD3D_SM4_SWIZZLE_TYPE_SHIFT;
|
||||||
token |= instr->srcs[i].swizzle << VKD3D_SM4_SWIZZLE_SHIFT;
|
token |= instr->srcs[i].swizzle << VKD3D_SM4_SWIZZLE_SHIFT;
|
||||||
|
if (instr->srcs[i].reg.mod)
|
||||||
|
token |= VKD3D_SM4_REGISTER_MODIFIER;
|
||||||
put_u32(buffer, token);
|
put_u32(buffer, token);
|
||||||
|
|
||||||
|
if (instr->srcs[i].reg.mod)
|
||||||
|
put_u32(buffer, instr->srcs[i].reg.mod);
|
||||||
|
|
||||||
for (j = 0; j < instr->srcs[i].reg.idx_count; ++j)
|
for (j = 0; j < instr->srcs[i].reg.idx_count; ++j)
|
||||||
put_u32(buffer, instr->srcs[i].reg.idx[j]);
|
put_u32(buffer, instr->srcs[i].reg.idx[j]);
|
||||||
|
|
||||||
@@ -894,6 +902,26 @@ static void write_sm4_ret(struct vkd3d_bytecode_buffer *buffer)
|
|||||||
write_sm4_instruction(buffer, &instr);
|
write_sm4_instruction(buffer, &instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_sm4_unary_op(struct vkd3d_bytecode_buffer *buffer, enum vkd3d_sm4_opcode opcode,
|
||||||
|
const struct hlsl_ir_node *dst, const struct hlsl_ir_node *src, unsigned int src_mod)
|
||||||
|
{
|
||||||
|
struct sm4_instruction instr;
|
||||||
|
unsigned int writemask;
|
||||||
|
|
||||||
|
memset(&instr, 0, sizeof(instr));
|
||||||
|
instr.opcode = opcode;
|
||||||
|
|
||||||
|
sm4_register_from_node(&instr.dst.reg, &instr.dst.writemask, dst);
|
||||||
|
instr.has_dst = 1;
|
||||||
|
|
||||||
|
sm4_register_from_node(&instr.srcs[0].reg, &writemask, src);
|
||||||
|
instr.srcs[0].swizzle = hlsl_map_swizzle(hlsl_swizzle_from_writemask(writemask), instr.dst.writemask);
|
||||||
|
instr.srcs[0].reg.mod = src_mod;
|
||||||
|
instr.src_count = 1;
|
||||||
|
|
||||||
|
write_sm4_instruction(buffer, &instr);
|
||||||
|
}
|
||||||
|
|
||||||
static void write_sm4_binary_op(struct vkd3d_bytecode_buffer *buffer, enum vkd3d_sm4_opcode opcode,
|
static void write_sm4_binary_op(struct vkd3d_bytecode_buffer *buffer, enum vkd3d_sm4_opcode opcode,
|
||||||
const struct hlsl_ir_node *dst, const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2)
|
const struct hlsl_ir_node *dst, const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2)
|
||||||
{
|
{
|
||||||
@@ -953,6 +981,10 @@ static void write_sm4_expr(struct hlsl_ctx *ctx,
|
|||||||
{
|
{
|
||||||
switch (expr->op)
|
switch (expr->op)
|
||||||
{
|
{
|
||||||
|
case HLSL_OP1_NEG:
|
||||||
|
write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV, &expr->node, arg1, VKD3D_SM4_REGISTER_MODIFIER_NEGATE);
|
||||||
|
break;
|
||||||
|
|
||||||
case HLSL_OP2_ADD:
|
case HLSL_OP2_ADD:
|
||||||
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2);
|
write_sm4_binary_op(buffer, VKD3D_SM4_OP_ADD, &expr->node, arg1, arg2);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user