vkd3d-shader/hlsl: Produce 2D resource declarations and loads for tex1D().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2023-09-11 12:23:04 +02:00 committed by Alexandre Julliard
parent 61b403a032
commit 177ea3bcbd
Notes: Alexandre Julliard 2023-09-13 23:18:39 +02:00
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Giovanni Mascellani (@giomasce)
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/339
2 changed files with 39 additions and 4 deletions

View File

@ -3457,7 +3457,42 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
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)))
coords = params->args[1];
{
return false;
}
/* tex1D() functions never produce 1D resource declarations. For newer profiles half offset
is used for the second coordinate, while older ones appear to replicate first coordinate.*/
if (dim == HLSL_SAMPLER_DIM_1D)
{
struct hlsl_ir_load *load;
struct hlsl_ir_node *half;
struct hlsl_ir_var *var;
unsigned int idx = 0;
if (!(var = hlsl_new_synthetic_var(ctx, "coords", hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 2), loc)))
return false;
initialize_var_components(ctx, params->instrs, var, &idx, coords);
if (shader_profile_version_ge(ctx, 4, 0))
{
if (!(half = hlsl_new_float_constant(ctx, 0.5f, loc)))
return false;
hlsl_block_add_instr(params->instrs, half);
initialize_var_components(ctx, params->instrs, var, &idx, half);
}
else
initialize_var_components(ctx, params->instrs, var, &idx, coords);
if (!(load = hlsl_new_var_load(ctx, var, loc)))
return false;
hlsl_block_add_instr(params->instrs, &load->node);
coords = &load->node;
dim = HLSL_SAMPLER_DIM_2D;
}
load_params.coords = coords;
load_params.resource = params->args[0];

View File

@ -121,7 +121,7 @@ float4 main() : sv_target
}
[pixel shader todo]
[pixel shader]
sampler sam[2];
float4 main() : sv_target
@ -130,8 +130,8 @@ float4 main() : sv_target
}
[test]
todo draw quad
todo probe all rgba (1, 1, 1, 11)
draw quad
probe all rgba (1, 1, 1, 11)
[require]