mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Store SM4 RCP in the vsir program.
This commit is contained in:
parent
3c4889add3
commit
2e3f4a01bf
Notes:
Henri Verbeet
2024-11-06 23:02:23 +01:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1251
@ -8018,6 +8018,33 @@ static void sm4_generate_vsir_expr_with_two_destinations(struct hlsl_ctx *ctx, s
|
|||||||
vsir_src_from_hlsl_node(&ins->src[i], ctx, expr->operands[i].node, dst_param->write_mask);
|
vsir_src_from_hlsl_node(&ins->src[i], ctx, expr->operands[i].node, dst_param->write_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sm4_generate_vsir_rcp_using_div(struct hlsl_ctx *ctx,
|
||||||
|
struct vsir_program *program, const struct hlsl_ir_expr *expr)
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *operand = expr->operands[0].node;
|
||||||
|
const struct hlsl_ir_node *instr = &expr->node;
|
||||||
|
struct vkd3d_shader_dst_param *dst_param;
|
||||||
|
struct hlsl_constant_value value = {0};
|
||||||
|
struct vkd3d_shader_instruction *ins;
|
||||||
|
|
||||||
|
VKD3D_ASSERT(type_is_float(expr->node.data_type));
|
||||||
|
|
||||||
|
if (!(ins = generate_vsir_add_program_instruction(ctx, program, &instr->loc, VKD3DSIH_DIV, 1, 2)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
dst_param = &ins->dst[0];
|
||||||
|
vsir_dst_from_hlsl_node(dst_param, ctx, instr);
|
||||||
|
|
||||||
|
value.u[0].f = 1.0f;
|
||||||
|
value.u[1].f = 1.0f;
|
||||||
|
value.u[2].f = 1.0f;
|
||||||
|
value.u[3].f = 1.0f;
|
||||||
|
vsir_src_from_hlsl_constant_value(&ins->src[0], ctx, &value,
|
||||||
|
VKD3D_DATA_FLOAT, instr->data_type->dimx, dst_param->write_mask);
|
||||||
|
|
||||||
|
vsir_src_from_hlsl_node(&ins->src[1], ctx, operand, dst_param->write_mask);
|
||||||
|
}
|
||||||
|
|
||||||
static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
|
static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
|
||||||
struct vsir_program *program, struct hlsl_ir_expr *expr, const char *dst_type_name)
|
struct vsir_program *program, struct hlsl_ir_expr *expr, const char *dst_type_name)
|
||||||
{
|
{
|
||||||
@ -8141,6 +8168,22 @@ static bool sm4_generate_vsir_instr_expr(struct hlsl_ctx *ctx,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case HLSL_OP1_RCP:
|
||||||
|
switch (dst_type->e.numeric.type)
|
||||||
|
{
|
||||||
|
case HLSL_TYPE_FLOAT:
|
||||||
|
/* SM5 comes with a RCP opcode */
|
||||||
|
if (hlsl_version_ge(ctx, 5, 0))
|
||||||
|
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_RCP, 0, 0, true);
|
||||||
|
else
|
||||||
|
sm4_generate_vsir_rcp_using_div(ctx, program, expr);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
hlsl_fixme(ctx, &expr->node.loc, "SM4 %s rcp expression.", dst_type_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
case HLSL_OP1_REINTERPRET:
|
case HLSL_OP1_REINTERPRET:
|
||||||
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
|
generate_vsir_instr_expr_single_instr_op(ctx, program, expr, VKD3DSIH_MOV, 0, 0, true);
|
||||||
return true;
|
return true;
|
||||||
|
@ -5331,7 +5331,6 @@ static bool type_is_float(const struct hlsl_type *type)
|
|||||||
|
|
||||||
static void write_sm4_expr(const struct tpf_compiler *tpf, const struct hlsl_ir_expr *expr)
|
static void write_sm4_expr(const struct tpf_compiler *tpf, const struct hlsl_ir_expr *expr)
|
||||||
{
|
{
|
||||||
const struct vkd3d_shader_version *version = &tpf->program->shader_version;
|
|
||||||
const struct hlsl_ir_node *arg1 = expr->operands[0].node;
|
const struct hlsl_ir_node *arg1 = expr->operands[0].node;
|
||||||
const struct hlsl_ir_node *arg2 = expr->operands[1].node;
|
const struct hlsl_ir_node *arg2 = expr->operands[1].node;
|
||||||
const struct hlsl_type *dst_type = expr->node.data_type;
|
const struct hlsl_type *dst_type = expr->node.data_type;
|
||||||
@ -5344,44 +5343,6 @@ static void write_sm4_expr(const struct tpf_compiler *tpf, const struct hlsl_ir_
|
|||||||
|
|
||||||
switch (expr->op)
|
switch (expr->op)
|
||||||
{
|
{
|
||||||
case HLSL_OP1_RCP:
|
|
||||||
switch (dst_type->e.numeric.type)
|
|
||||||
{
|
|
||||||
case HLSL_TYPE_FLOAT:
|
|
||||||
/* SM5 comes with a RCP opcode */
|
|
||||||
if (vkd3d_shader_ver_ge(version, 5, 0))
|
|
||||||
{
|
|
||||||
write_sm4_unary_op(tpf, VKD3D_SM5_OP_RCP, &expr->node, arg1, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* For SM4, implement as DIV dst, 1.0, src */
|
|
||||||
struct sm4_instruction instr;
|
|
||||||
struct hlsl_constant_value one;
|
|
||||||
|
|
||||||
VKD3D_ASSERT(type_is_float(dst_type));
|
|
||||||
|
|
||||||
memset(&instr, 0, sizeof(instr));
|
|
||||||
instr.opcode = VKD3D_SM4_OP_DIV;
|
|
||||||
|
|
||||||
sm4_dst_from_node(&instr.dsts[0], &expr->node);
|
|
||||||
instr.dst_count = 1;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 4; i++)
|
|
||||||
one.u[i].f = 1.0f;
|
|
||||||
sm4_src_from_constant_value(&instr.srcs[0], &one, dst_type->dimx, instr.dsts[0].write_mask);
|
|
||||||
sm4_src_from_node(tpf, &instr.srcs[1], arg1, instr.dsts[0].write_mask);
|
|
||||||
instr.src_count = 2;
|
|
||||||
|
|
||||||
write_sm4_instruction(tpf, &instr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s rcp expression.", dst_type_string->buffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HLSL_OP1_SAT:
|
case HLSL_OP1_SAT:
|
||||||
VKD3D_ASSERT(type_is_float(dst_type));
|
VKD3D_ASSERT(type_is_float(dst_type));
|
||||||
write_sm4_unary_op(tpf, VKD3D_SM4_OP_MOV
|
write_sm4_unary_op(tpf, VKD3D_SM4_OP_MOV
|
||||||
@ -5920,6 +5881,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
|
|||||||
|
|
||||||
case VKD3DSIH_ADD:
|
case VKD3DSIH_ADD:
|
||||||
case VKD3DSIH_AND:
|
case VKD3DSIH_AND:
|
||||||
|
case VKD3DSIH_DIV:
|
||||||
case VKD3DSIH_DSX:
|
case VKD3DSIH_DSX:
|
||||||
case VKD3DSIH_DSX_COARSE:
|
case VKD3DSIH_DSX_COARSE:
|
||||||
case VKD3DSIH_DSX_FINE:
|
case VKD3DSIH_DSX_FINE:
|
||||||
@ -5956,6 +5918,7 @@ static void tpf_handle_instruction(struct tpf_compiler *tpf, const struct vkd3d_
|
|||||||
case VKD3DSIH_NEU:
|
case VKD3DSIH_NEU:
|
||||||
case VKD3DSIH_NOT:
|
case VKD3DSIH_NOT:
|
||||||
case VKD3DSIH_OR:
|
case VKD3DSIH_OR:
|
||||||
|
case VKD3DSIH_RCP:
|
||||||
case VKD3DSIH_ROUND_NE:
|
case VKD3DSIH_ROUND_NE:
|
||||||
case VKD3DSIH_ROUND_NI:
|
case VKD3DSIH_ROUND_NI:
|
||||||
case VKD3DSIH_ROUND_PI:
|
case VKD3DSIH_ROUND_PI:
|
||||||
|
Loading…
Reference in New Issue
Block a user