vkd3d-shader/hlsl: Track objects sampling dimension.

This commit is contained in:
Francisco Casas 2022-11-25 20:38:33 -03:00 committed by Alexandre Julliard
parent 4dba38e6c8
commit 3e9a9c5051
Notes: Alexandre Julliard 2023-05-08 22:34:16 +02: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/159
6 changed files with 39 additions and 1 deletions

View File

@ -1353,6 +1353,9 @@ struct hlsl_ir_node *hlsl_new_resource_load(struct hlsl_ctx *ctx,
hlsl_src_from_node(&load->coords, params->coords);
hlsl_src_from_node(&load->texel_offset, params->texel_offset);
hlsl_src_from_node(&load->lod, params->lod);
load->sampling_dim = params->sampling_dim;
if (load->sampling_dim == HLSL_SAMPLER_DIM_GENERIC)
load->sampling_dim = hlsl_deref_get_type(ctx, &load->resource)->sampler_dim;
return &load->node;
}
@ -1641,6 +1644,7 @@ static struct hlsl_ir_node *clone_resource_load(struct hlsl_ctx *ctx,
clone_src(map, &dst->coords, &src->coords);
clone_src(map, &dst->lod, &src->lod);
clone_src(map, &dst->texel_offset, &src->texel_offset);
dst->sampling_dim = src->sampling_dim;
return &dst->node;
}

View File

@ -409,6 +409,8 @@ struct hlsl_ir_var
struct
{
bool used;
enum hlsl_sampler_dim sampler_dim;
struct vkd3d_shader_location first_sampler_dim_loc;
} *objects_usage[HLSL_REGSET_LAST_OBJECT + 1];
uint32_t is_input_semantic : 1;
@ -622,6 +624,7 @@ struct hlsl_ir_resource_load
enum hlsl_resource_load_type load_type;
struct hlsl_deref resource, sampler;
struct hlsl_src coords, lod, texel_offset;
enum hlsl_sampler_dim sampling_dim;
};
struct hlsl_ir_resource_store
@ -823,6 +826,7 @@ struct hlsl_resource_load_params
enum hlsl_resource_load_type type;
struct hlsl_ir_node *resource, *sampler;
struct hlsl_ir_node *coords, *lod, *texel_offset;
enum hlsl_sampler_dim sampling_dim;
};
static inline struct hlsl_ir_call *hlsl_ir_call(const struct hlsl_ir_node *node)

View File

@ -3338,6 +3338,7 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
load_params.coords = coords;
load_params.resource = params->args[0];
load_params.format = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 4);
load_params.sampling_dim = dim;
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc)))
return false;

View File

@ -2919,12 +2919,30 @@ static bool track_object_components_usage(struct hlsl_ctx *ctx, struct hlsl_ir_n
if (regset == HLSL_REGSET_SAMPLERS)
{
assert(!load->sampler.var);
enum hlsl_sampler_dim dim;
assert(!load->sampler.var);
if (!hlsl_regset_index_from_deref(ctx, &load->resource, regset, &index))
return false;
dim = var->objects_usage[regset][index].sampler_dim;
if (dim != load->sampling_dim)
{
if (dim == HLSL_SAMPLER_DIM_GENERIC)
{
var->objects_usage[regset][index].first_sampler_dim_loc = instr->loc;
}
else
{
hlsl_error(ctx, &instr->loc, VKD3D_SHADER_ERROR_HLSL_INCONSISTENT_SAMPLER,
"Inconsistent generic sampler usage dimension.");
hlsl_note(ctx, &var->objects_usage[regset][index].first_sampler_dim_loc,
VKD3D_SHADER_LOG_ERROR, "First use is here.");
return false;
}
}
var->objects_usage[regset][index].used = true;
var->objects_usage[regset][index].sampler_dim = load->sampling_dim;
}
else
{
@ -2932,6 +2950,7 @@ static bool track_object_components_usage(struct hlsl_ctx *ctx, struct hlsl_ir_n
return false;
var->objects_usage[regset][index].used = true;
var->objects_usage[regset][index].sampler_dim = load->sampling_dim;
if (load->sampler.var)
{

View File

@ -125,6 +125,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_HLSL_INVALID_THREAD_COUNT = 5023,
VKD3D_SHADER_ERROR_HLSL_MISSING_ATTRIBUTE = 5024,
VKD3D_SHADER_ERROR_HLSL_RECURSIVE_CALL = 5025,
VKD3D_SHADER_ERROR_HLSL_INCONSISTENT_SAMPLER = 5026,
VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
VKD3D_SHADER_WARNING_HLSL_DIVISION_BY_ZERO = 5301,

View File

@ -54,3 +54,12 @@ float4 main() : sv_target
{
return tex3D(s, float3(0.0, 0.0, 0.0));
}
[pixel shader fail]
sampler s;
float4 main() : sv_target
{
return tex2D(s, float2(0.0, 0.0)) + tex3D(s, float3(0.0, 0.0, 0.0));
}