vkd3d-shader/hlsl: Implement tex*grad() functions.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-06-28 12:06:53 +02:00 committed by Henri Verbeet
parent 4ff288bd32
commit 2176294df8
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
2 changed files with 48 additions and 0 deletions

View File

@ -4449,6 +4449,12 @@ static bool intrinsic_tex1D(struct hlsl_ctx *ctx,
return intrinsic_tex(ctx, params, loc, "tex1D", HLSL_SAMPLER_DIM_1D); return intrinsic_tex(ctx, params, loc, "tex1D", HLSL_SAMPLER_DIM_1D);
} }
static bool intrinsic_tex1Dgrad(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_tex(ctx, params, loc, "tex1Dgrad", HLSL_SAMPLER_DIM_1D);
}
static bool intrinsic_tex2D(struct hlsl_ctx *ctx, static bool intrinsic_tex2D(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)
{ {
@ -4461,6 +4467,12 @@ static bool intrinsic_tex2Dbias(struct hlsl_ctx *ctx,
return intrinsic_tex(ctx, params, loc, "tex2Dbias", HLSL_SAMPLER_DIM_2D); return intrinsic_tex(ctx, params, loc, "tex2Dbias", HLSL_SAMPLER_DIM_2D);
} }
static bool intrinsic_tex2Dgrad(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_tex(ctx, params, loc, "tex2Dgrad", HLSL_SAMPLER_DIM_2D);
}
static bool intrinsic_tex2Dlod(struct hlsl_ctx *ctx, static bool intrinsic_tex2Dlod(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)
{ {
@ -4479,6 +4491,12 @@ static bool intrinsic_tex3D(struct hlsl_ctx *ctx,
return intrinsic_tex(ctx, params, loc, "tex3D", HLSL_SAMPLER_DIM_3D); return intrinsic_tex(ctx, params, loc, "tex3D", HLSL_SAMPLER_DIM_3D);
} }
static bool intrinsic_tex3Dgrad(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_tex(ctx, params, loc, "tex3Dgrad", HLSL_SAMPLER_DIM_3D);
}
static bool intrinsic_tex3Dproj(struct hlsl_ctx *ctx, static bool intrinsic_tex3Dproj(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)
{ {
@ -4491,6 +4509,12 @@ static bool intrinsic_texCUBE(struct hlsl_ctx *ctx,
return intrinsic_tex(ctx, params, loc, "texCUBE", HLSL_SAMPLER_DIM_CUBE); return intrinsic_tex(ctx, params, loc, "texCUBE", HLSL_SAMPLER_DIM_CUBE);
} }
static bool intrinsic_texCUBEgrad(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_tex(ctx, params, loc, "texCUBEgrad", HLSL_SAMPLER_DIM_CUBE);
}
static bool intrinsic_texCUBEproj(struct hlsl_ctx *ctx, static bool intrinsic_texCUBEproj(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)
{ {
@ -4680,13 +4704,17 @@ intrinsic_functions[] =
{"tan", 1, true, intrinsic_tan}, {"tan", 1, true, intrinsic_tan},
{"tanh", 1, true, intrinsic_tanh}, {"tanh", 1, true, intrinsic_tanh},
{"tex1D", -1, false, intrinsic_tex1D}, {"tex1D", -1, false, intrinsic_tex1D},
{"tex1Dgrad", 4, false, intrinsic_tex1Dgrad},
{"tex2D", -1, false, intrinsic_tex2D}, {"tex2D", -1, false, intrinsic_tex2D},
{"tex2Dbias", 2, false, intrinsic_tex2Dbias}, {"tex2Dbias", 2, false, intrinsic_tex2Dbias},
{"tex2Dgrad", 4, false, intrinsic_tex2Dgrad},
{"tex2Dlod", 2, false, intrinsic_tex2Dlod}, {"tex2Dlod", 2, false, intrinsic_tex2Dlod},
{"tex2Dproj", 2, false, intrinsic_tex2Dproj}, {"tex2Dproj", 2, false, intrinsic_tex2Dproj},
{"tex3D", -1, false, intrinsic_tex3D}, {"tex3D", -1, false, intrinsic_tex3D},
{"tex3Dgrad", 4, false, intrinsic_tex3Dgrad},
{"tex3Dproj", 2, false, intrinsic_tex3Dproj}, {"tex3Dproj", 2, false, intrinsic_tex3Dproj},
{"texCUBE", -1, false, intrinsic_texCUBE}, {"texCUBE", -1, false, intrinsic_texCUBE},
{"texCUBEgrad", 4, false, intrinsic_texCUBEgrad},
{"texCUBEproj", 2, false, intrinsic_texCUBEproj}, {"texCUBEproj", 2, false, intrinsic_texCUBEproj},
{"transpose", 1, true, intrinsic_transpose}, {"transpose", 1, true, intrinsic_transpose},
{"trunc", 1, true, intrinsic_trunc}, {"trunc", 1, true, intrinsic_trunc},

View File

@ -35,6 +35,26 @@ uniform 0 float4 2.0 2.0 2.0 2.0
todo(glsl) draw quad todo(glsl) draw quad
probe (0,0) rgba (0.0, 0.0, 1.0, 0.0) probe (0,0) rgba (0.0, 0.0, 1.0, 0.0)
[pixel shader fail(sm>=6)]
sampler s;
float4 grad;
float4 main() : sv_target
{
return tex2Dgrad(s, float2(0.5, 0.5), grad.xy, grad.zw);
}
[test]
uniform 0 float4 0.0 0.0 0.0 0.0
todo(glsl) draw quad
probe (0,0) rgba (1.0, 0.0, 1.0, 0.0)
uniform 0 float4 1.0 1.0 1.0 1.0
todo(glsl) draw quad
probe (0,0) rgba (0.0, 0.0, 1.0, 0.0)
uniform 0 float4 2.0 2.0 2.0 2.0
todo(glsl) draw quad
probe (0,0) rgba (0.0, 0.0, 1.0, 0.0)
[require] [require]
shader model >= 4.0 shader model >= 4.0