mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader: Implement tex*() functions variants with gradient arguments.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
committed by
Henri Verbeet
parent
4cd2dd50f9
commit
4ff288bd32
Notes:
Henri Verbeet
2024-07-08 18:54:32 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/917
@@ -4279,6 +4279,7 @@ static bool intrinsic_tanh(struct hlsl_ctx *ctx,
|
||||
static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *params,
|
||||
const struct vkd3d_shader_location *loc, const char *name, enum hlsl_sampler_dim dim)
|
||||
{
|
||||
unsigned int sampler_dim = hlsl_sampler_dim_count(dim);
|
||||
struct hlsl_resource_load_params load_params = { 0 };
|
||||
const struct hlsl_type *sampler_type;
|
||||
struct hlsl_ir_node *coords, *sample;
|
||||
@@ -4290,11 +4291,6 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params->args_count == 4)
|
||||
{
|
||||
hlsl_fixme(ctx, loc, "Samples with gradients are not implemented.");
|
||||
}
|
||||
|
||||
sampler_type = params->args[0]->data_type;
|
||||
if (sampler_type->class != HLSL_CLASS_SAMPLER
|
||||
|| (sampler_type->sampler_dim != dim && sampler_type->sampler_dim != HLSL_SAMPLER_DIM_GENERIC))
|
||||
@@ -4318,12 +4314,12 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
|
||||
else
|
||||
load_params.type = HLSL_RESOURCE_SAMPLE_LOD_BIAS;
|
||||
|
||||
if (!(c = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), hlsl_sampler_dim_count(dim), params->args[1], loc)))
|
||||
if (!(c = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), sampler_dim, params->args[1], loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(params->instrs, c);
|
||||
|
||||
if (!(coords = add_implicit_conversion(ctx, params->instrs, c, hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT,
|
||||
hlsl_sampler_dim_count(dim)), loc)))
|
||||
if (!(coords = add_implicit_conversion(ctx, params->instrs, c,
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -4350,14 +4346,13 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
|
||||
|
||||
if (hlsl_version_ge(ctx, 4, 0))
|
||||
{
|
||||
unsigned int count = hlsl_sampler_dim_count(dim);
|
||||
struct hlsl_ir_node *divisor;
|
||||
|
||||
if (!(divisor = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(W, W, W, W), count, coords, loc)))
|
||||
if (!(divisor = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(W, W, W, W), sampler_dim, coords, loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(params->instrs, divisor);
|
||||
|
||||
if (!(coords = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), count, coords, loc)))
|
||||
if (!(coords = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), sampler_dim, coords, loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(params->instrs, coords);
|
||||
|
||||
@@ -4371,12 +4366,34 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
|
||||
load_params.type = HLSL_RESOURCE_SAMPLE_PROJ;
|
||||
}
|
||||
}
|
||||
else if (params->args_count == 4) /* Gradient sampling. */
|
||||
{
|
||||
if (!(coords = add_implicit_conversion(ctx, params->instrs, params->args[1],
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(load_params.ddx = add_implicit_conversion(ctx, params->instrs, params->args[2],
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(load_params.ddy = add_implicit_conversion(ctx, params->instrs, params->args[3],
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
load_params.type = HLSL_RESOURCE_SAMPLE_GRAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
load_params.type = HLSL_RESOURCE_SAMPLE;
|
||||
|
||||
if (!(coords = add_implicit_conversion(ctx, params->instrs, params->args[1],
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, hlsl_sampler_dim_count(dim)), loc)))
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user