vkd3d-shader/hlsl: Implement tex2Dproj().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2023-11-09 18:43:41 +01:00 committed by Alexandre Julliard
parent 0c5c18bdce
commit dd6a9135f4
Notes: Alexandre Julliard 2023-11-10 21:38:13 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/219
5 changed files with 45 additions and 0 deletions

View File

@ -2337,6 +2337,8 @@ static void write_sm1_resource_load(struct hlsl_ctx *ctx, struct vkd3d_bytecode_
.src_count = 2, .src_count = 2,
}; };
if (load->load_type == HLSL_RESOURCE_SAMPLE_PROJ)
sm1_instr.opcode |= VKD3DSI_TEXLD_PROJECT << VKD3D_SM1_INSTRUCTION_FLAGS_SHIFT;
assert(instr->reg.allocated); assert(instr->reg.allocated);

View File

@ -679,6 +679,7 @@ enum hlsl_resource_load_type
HLSL_RESOURCE_SAMPLE_LOD, HLSL_RESOURCE_SAMPLE_LOD,
HLSL_RESOURCE_SAMPLE_LOD_BIAS, HLSL_RESOURCE_SAMPLE_LOD_BIAS,
HLSL_RESOURCE_SAMPLE_GRAD, HLSL_RESOURCE_SAMPLE_GRAD,
HLSL_RESOURCE_SAMPLE_PROJ,
HLSL_RESOURCE_GATHER_RED, HLSL_RESOURCE_GATHER_RED,
HLSL_RESOURCE_GATHER_GREEN, HLSL_RESOURCE_GATHER_GREEN,
HLSL_RESOURCE_GATHER_BLUE, HLSL_RESOURCE_GATHER_BLUE,

View File

@ -3572,6 +3572,37 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
return false; return false;
} }
} }
else if (!strcmp(name, "tex2Dproj"))
{
if (!(coords = add_implicit_conversion(ctx, params->instrs, params->args[1],
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 4), loc)))
{
return false;
}
if (shader_profile_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)))
return false;
hlsl_block_add_instr(params->instrs, divisor);
if (!(coords = hlsl_new_swizzle(ctx, HLSL_SWIZZLE(X, Y, Z, W), count, coords, loc)))
return false;
hlsl_block_add_instr(params->instrs, coords);
if (!(coords = add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_DIV, coords, divisor, loc)))
return false;
load_params.type = HLSL_RESOURCE_SAMPLE;
}
else
{
load_params.type = HLSL_RESOURCE_SAMPLE_PROJ;
}
}
else else
{ {
load_params.type = HLSL_RESOURCE_SAMPLE; load_params.type = HLSL_RESOURCE_SAMPLE;
@ -3645,6 +3676,12 @@ static bool intrinsic_tex2Dlod(struct hlsl_ctx *ctx,
return intrinsic_tex(ctx, params, loc, "tex2Dlod", HLSL_SAMPLER_DIM_2D); return intrinsic_tex(ctx, params, loc, "tex2Dlod", HLSL_SAMPLER_DIM_2D);
} }
static bool intrinsic_tex2Dproj(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
return intrinsic_tex(ctx, params, loc, "tex2Dproj", HLSL_SAMPLER_DIM_2D);
}
static bool intrinsic_tex3D(struct hlsl_ctx *ctx, static bool intrinsic_tex3D(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)
{ {
@ -3831,6 +3868,7 @@ intrinsic_functions[] =
{"tex1D", -1, false, intrinsic_tex1D}, {"tex1D", -1, false, intrinsic_tex1D},
{"tex2D", -1, false, intrinsic_tex2D}, {"tex2D", -1, false, intrinsic_tex2D},
{"tex2Dlod", 2, false, intrinsic_tex2Dlod}, {"tex2Dlod", 2, false, intrinsic_tex2Dlod},
{"tex2Dproj", 2, false, intrinsic_tex2Dproj},
{"tex3D", -1, false, intrinsic_tex3D}, {"tex3D", -1, false, intrinsic_tex3D},
{"texCUBE", -1, false, intrinsic_texCUBE}, {"texCUBE", -1, false, intrinsic_texCUBE},
{"transpose", 1, true, intrinsic_transpose}, {"transpose", 1, true, intrinsic_transpose},

View File

@ -2419,6 +2419,7 @@ static bool lower_combined_samples(struct hlsl_ctx *ctx, struct hlsl_ir_node *in
case HLSL_RESOURCE_SAMPLE: case HLSL_RESOURCE_SAMPLE:
case HLSL_RESOURCE_SAMPLE_LOD: case HLSL_RESOURCE_SAMPLE_LOD:
case HLSL_RESOURCE_SAMPLE_LOD_BIAS: case HLSL_RESOURCE_SAMPLE_LOD_BIAS:
case HLSL_RESOURCE_SAMPLE_PROJ:
break; break;
} }
if (load->sampler.var) if (load->sampler.var)

View File

@ -5574,6 +5574,9 @@ static void write_sm4_resource_load(const struct tpf_writer *tpf, const struct h
case HLSL_RESOURCE_RESINFO: case HLSL_RESOURCE_RESINFO:
write_sm4_resinfo(tpf, load); write_sm4_resinfo(tpf, load);
break; break;
case HLSL_RESOURCE_SAMPLE_PROJ:
vkd3d_unreachable();
} }
} }