mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/hlsl: Use LOGIC_OR instead of BIT_OR in any().
Note that BIT_OR is not available for SM1 bools, so we must prefer LOGIC_OR when possible.
This commit is contained in:
parent
2621fc9572
commit
53e4d6eedb
Notes:
Alexandre Julliard
2024-04-09 15:44:37 -05:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/744
@ -2728,6 +2728,38 @@ static bool intrinsic_acos(struct hlsl_ctx *ctx,
|
||||
return write_acos_or_asin(ctx, params, loc, false);
|
||||
}
|
||||
|
||||
/* Find the type corresponding to the given source type, with the same
|
||||
* dimensions but a different base type. */
|
||||
static struct hlsl_type *convert_numeric_type(const struct hlsl_ctx *ctx,
|
||||
const struct hlsl_type *type, enum hlsl_base_type base_type)
|
||||
{
|
||||
return hlsl_get_numeric_type(ctx, type->class, base_type, type->dimx, type->dimy);
|
||||
}
|
||||
|
||||
static bool add_combine_components(struct hlsl_ctx *ctx, const struct parse_initializer *params,
|
||||
struct hlsl_ir_node *arg, enum hlsl_ir_expr_op op, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_node *res, *load;
|
||||
unsigned int i, count;
|
||||
|
||||
count = hlsl_type_component_count(arg->data_type);
|
||||
|
||||
if (!(res = hlsl_add_load_component(ctx, params->instrs, arg, 0, loc)))
|
||||
return false;
|
||||
|
||||
for (i = 1; i < count; ++i)
|
||||
{
|
||||
if (!(load = hlsl_add_load_component(ctx, params->instrs, arg, i, loc)))
|
||||
return false;
|
||||
|
||||
if (!(res = hlsl_new_binary_expr(ctx, op, res, load)))
|
||||
return NULL;
|
||||
hlsl_block_add_instr(params->instrs, res);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool intrinsic_all(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
@ -2757,52 +2789,17 @@ static bool intrinsic_all(struct hlsl_ctx *ctx,
|
||||
return !!add_binary_comparison_expr(ctx, params->instrs, HLSL_OP2_NEQUAL, mul, zero, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_any(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
static bool intrinsic_any(struct hlsl_ctx *ctx, const struct parse_initializer *params,
|
||||
const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
struct hlsl_ir_node *arg = params->args[0], *dot, *or, *zero, *bfalse, *load;
|
||||
unsigned int i, count;
|
||||
struct hlsl_ir_node *arg = params->args[0], *cast;
|
||||
struct hlsl_type *bool_type;
|
||||
|
||||
if (arg->data_type->class != HLSL_CLASS_VECTOR && arg->data_type->class != HLSL_CLASS_SCALAR)
|
||||
{
|
||||
hlsl_fixme(ctx, loc, "any() implementation for non-vector, non-scalar");
|
||||
bool_type = convert_numeric_type(ctx, arg->data_type, HLSL_TYPE_BOOL);
|
||||
if (!(cast = add_cast(ctx, params->instrs, arg, bool_type, loc)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arg->data_type->base_type == HLSL_TYPE_FLOAT)
|
||||
{
|
||||
if (!(zero = hlsl_new_float_constant(ctx, 0.0f, loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(params->instrs, zero);
|
||||
|
||||
if (!(dot = add_binary_dot_expr(ctx, params->instrs, arg, arg, loc)))
|
||||
return false;
|
||||
|
||||
return !!add_binary_comparison_expr(ctx, params->instrs, HLSL_OP2_NEQUAL, dot, zero, loc);
|
||||
}
|
||||
else if (arg->data_type->base_type == HLSL_TYPE_BOOL)
|
||||
{
|
||||
if (!(bfalse = hlsl_new_bool_constant(ctx, false, loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(params->instrs, bfalse);
|
||||
|
||||
or = bfalse;
|
||||
|
||||
count = hlsl_type_component_count(arg->data_type);
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
if (!(load = hlsl_add_load_component(ctx, params->instrs, arg, i, loc)))
|
||||
return false;
|
||||
|
||||
if (!(or = add_binary_bitwise_expr(ctx, params->instrs, HLSL_OP2_BIT_OR, or, load, loc)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
hlsl_fixme(ctx, loc, "any() implementation for non-float, non-bool");
|
||||
return false;
|
||||
return add_combine_components(ctx, params, cast, HLSL_OP2_LOGIC_OR, loc);
|
||||
}
|
||||
|
||||
static bool intrinsic_asin(struct hlsl_ctx *ctx,
|
||||
@ -2903,15 +2900,6 @@ static bool intrinsic_atan2(struct hlsl_ctx *ctx,
|
||||
return write_atan_or_atan2(ctx, params, loc, true);
|
||||
}
|
||||
|
||||
|
||||
/* Find the type corresponding to the given source type, with the same
|
||||
* dimensions but a different base type. */
|
||||
static struct hlsl_type *convert_numeric_type(const struct hlsl_ctx *ctx,
|
||||
const struct hlsl_type *type, enum hlsl_base_type base_type)
|
||||
{
|
||||
return hlsl_get_numeric_type(ctx, type->class, base_type, type->dimx, type->dimy);
|
||||
}
|
||||
|
||||
static bool intrinsic_asfloat(struct hlsl_ctx *ctx,
|
||||
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
|
||||
[pixel shader todo(sm<4)]
|
||||
[pixel shader]
|
||||
uniform uint4 b;
|
||||
|
||||
float4 main() : sv_target
|
||||
@ -60,30 +60,30 @@ float4 main() : sv_target
|
||||
[test]
|
||||
if(sm<4) uniform 0 float4 1 1 1 1
|
||||
if(sm>=4) uniform 0 uint4 1 1 1 1
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
if(sm<4) uniform 0 float4 1 0 0 0
|
||||
if(sm>=4) uniform 0 uint4 1 0 0 0
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
if(sm<4) uniform 0 float4 0 1 0 0
|
||||
if(sm>=4) uniform 0 uint4 0 1 0 0
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
if(sm<4) uniform 0 float4 0 0 1 0
|
||||
if(sm>=4) uniform 0 uint4 0 0 1 0
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
if(sm<4) uniform 0 float4 0 0 0 1
|
||||
if(sm>=4) uniform 0 uint4 0 0 0 1
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
if(sm<4) uniform 0 float4 0 0 0 0
|
||||
if(sm>=4) uniform 0 uint4 0 0 0 0
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (0.0, 0.0, 0.0, 0.0)
|
||||
|
||||
[pixel shader todo(sm<4)]
|
||||
[pixel shader]
|
||||
uniform uint b;
|
||||
|
||||
float4 main() : sv_target
|
||||
@ -94,9 +94,9 @@ float4 main() : sv_target
|
||||
[test]
|
||||
if(sm<4) uniform 0 float4 1 0 0 0
|
||||
if(sm>=4) uniform 0 uint4 1 0 0 0
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (1.0, 1.0, 1.0, 1.0)
|
||||
if(sm<4) uniform 0 float4 0 0 0 0
|
||||
if(sm>=4) uniform 0 uint4 0 0 0 0
|
||||
todo(sm<4 | glsl) draw quad
|
||||
todo(glsl) draw quad
|
||||
probe all rgba (0.0, 0.0, 0.0, 0.0)
|
||||
|
Loading…
Reference in New Issue
Block a user