mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Do not emit HLSL_OP1_ABS for unsigned types.
This commit is contained in:
committed by
Henri Verbeet
parent
cdc74a9377
commit
a06b9f6646
Notes:
Henri Verbeet
2025-05-14 15:27:19 +02:00
Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1497
@@ -372,6 +372,27 @@ bool hlsl_base_type_is_integer(enum hlsl_base_type type)
|
|||||||
vkd3d_unreachable();
|
vkd3d_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hlsl_type_is_signed_integer(const struct hlsl_type *type)
|
||||||
|
{
|
||||||
|
VKD3D_ASSERT(hlsl_is_numeric_type(type));
|
||||||
|
|
||||||
|
switch (type->e.numeric.type)
|
||||||
|
{
|
||||||
|
case HLSL_TYPE_INT:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case HLSL_TYPE_BOOL:
|
||||||
|
case HLSL_TYPE_DOUBLE:
|
||||||
|
case HLSL_TYPE_FLOAT:
|
||||||
|
case HLSL_TYPE_HALF:
|
||||||
|
case HLSL_TYPE_MIN16UINT:
|
||||||
|
case HLSL_TYPE_UINT:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vkd3d_unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
bool hlsl_type_is_integer(const struct hlsl_type *type)
|
bool hlsl_type_is_integer(const struct hlsl_type *type)
|
||||||
{
|
{
|
||||||
VKD3D_ASSERT(hlsl_is_numeric_type(type));
|
VKD3D_ASSERT(hlsl_is_numeric_type(type));
|
||||||
|
@@ -1771,6 +1771,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty
|
|||||||
bool hlsl_type_is_integer(const struct hlsl_type *type);
|
bool hlsl_type_is_integer(const struct hlsl_type *type);
|
||||||
bool hlsl_type_is_floating_point(const struct hlsl_type *type);
|
bool hlsl_type_is_floating_point(const struct hlsl_type *type);
|
||||||
bool hlsl_type_is_row_major(const struct hlsl_type *type);
|
bool hlsl_type_is_row_major(const struct hlsl_type *type);
|
||||||
|
bool hlsl_type_is_signed_integer(const struct hlsl_type *type);
|
||||||
unsigned int hlsl_type_minor_size(const struct hlsl_type *type);
|
unsigned int hlsl_type_minor_size(const struct hlsl_type *type);
|
||||||
unsigned int hlsl_type_major_size(const struct hlsl_type *type);
|
unsigned int hlsl_type_major_size(const struct hlsl_type *type);
|
||||||
unsigned int hlsl_type_element_count(const struct hlsl_type *type);
|
unsigned int hlsl_type_element_count(const struct hlsl_type *type);
|
||||||
|
@@ -3189,6 +3189,11 @@ static bool elementwise_intrinsic_uint_convert_args(struct hlsl_ctx *ctx,
|
|||||||
static bool intrinsic_abs(struct hlsl_ctx *ctx,
|
static bool intrinsic_abs(struct hlsl_ctx *ctx,
|
||||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
|
const struct hlsl_type *type = params->args[0]->data_type;
|
||||||
|
|
||||||
|
if (!hlsl_type_is_floating_point(type) && !hlsl_type_is_signed_integer(type))
|
||||||
|
return true;
|
||||||
|
|
||||||
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], loc);
|
return !!add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_ABS, params->args[0], loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,14 +51,11 @@ static bool fold_abs(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
|||||||
dst->u[k].i = abs(src->value.u[k].i);
|
dst->u[k].i = abs(src->value.u[k].i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HLSL_TYPE_BOOL:
|
||||||
case HLSL_TYPE_MIN16UINT:
|
case HLSL_TYPE_MIN16UINT:
|
||||||
case HLSL_TYPE_UINT:
|
case HLSL_TYPE_UINT:
|
||||||
dst->u[k].u = src->value.u[k].u;
|
/* Should not occur. */
|
||||||
break;
|
vkd3d_unreachable();
|
||||||
|
|
||||||
default:
|
|
||||||
FIXME("Fold abs() for type %s.\n", debug_hlsl_type(ctx, dst_type));
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@@ -13,3 +13,20 @@ probe (0, 0) rgba (0.1, 0.7, 0.4, 0.4)
|
|||||||
uniform 0 float4 -0.7 0.1 0.0 0.0
|
uniform 0 float4 -0.7 0.1 0.0 0.0
|
||||||
draw quad
|
draw quad
|
||||||
probe (0, 0) rgba (0.7, 0.1, 1.2, 0.4)
|
probe (0, 0) rgba (0.7, 0.1, 1.2, 0.4)
|
||||||
|
|
||||||
|
[pixel shader fail(sm<2)]
|
||||||
|
uniform float u;
|
||||||
|
|
||||||
|
float4 main() : sv_target
|
||||||
|
{
|
||||||
|
int i = u;
|
||||||
|
return float4(abs(i), abs(-8), abs(uint(3)), abs(bool(true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[test]
|
||||||
|
uniform 0 float 2.0
|
||||||
|
todo(msl) draw quad
|
||||||
|
probe (0, 0) rgba(2, 8, 3, 1)
|
||||||
|
uniform 0 float -1.0
|
||||||
|
todo(msl) draw quad
|
||||||
|
probe (0, 0) rgba(1, 8, 3, 1)
|
||||||
|
Reference in New Issue
Block a user