mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Move object type checks to methods handlers.
This commit is contained in:
parent
aa17d139be
commit
87cd3f872b
Notes:
Alexandre Julliard
2023-05-29 22:32:35 +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/206
@ -3721,6 +3721,18 @@ static unsigned int hlsl_offset_dim_count(enum hlsl_sampler_dim dim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool raise_invalid_method_object_type(struct hlsl_ctx *ctx, const struct hlsl_type *object_type,
|
||||||
|
const char *method, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct vkd3d_string_buffer *string;
|
||||||
|
|
||||||
|
if ((string = hlsl_type_to_string(ctx, object_type)))
|
||||||
|
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
|
||||||
|
"Method '%s' is not defined on type '%s'.", method, string->buffer);
|
||||||
|
hlsl_release_string_buffer(ctx, string);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool add_load_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *object,
|
static bool add_load_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_node *object,
|
||||||
const char *name, const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
const char *name, const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
|
||||||
{
|
{
|
||||||
@ -3731,6 +3743,12 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct list *instrs, stru
|
|||||||
struct hlsl_ir_node *load;
|
struct hlsl_ir_node *load;
|
||||||
bool multisampled;
|
bool multisampled;
|
||||||
|
|
||||||
|
if (object_type->sampler_dim == HLSL_SAMPLER_DIM_CUBE
|
||||||
|
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_CUBEARRAY)
|
||||||
|
{
|
||||||
|
return raise_invalid_method_object_type(ctx, object_type, name, loc);
|
||||||
|
}
|
||||||
|
|
||||||
multisampled = object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS
|
multisampled = object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS
|
||||||
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY;
|
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY;
|
||||||
|
|
||||||
@ -3784,6 +3802,12 @@ static bool add_sample_method_call(struct hlsl_ctx *ctx, struct list *instrs, st
|
|||||||
const struct hlsl_type *sampler_type;
|
const struct hlsl_type *sampler_type;
|
||||||
struct hlsl_ir_node *load;
|
struct hlsl_ir_node *load;
|
||||||
|
|
||||||
|
if (object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS
|
||||||
|
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY)
|
||||||
|
{
|
||||||
|
return raise_invalid_method_object_type(ctx, object_type, name, loc);
|
||||||
|
}
|
||||||
|
|
||||||
if (params->args_count < 2 || params->args_count > 4 + !!offset_dim)
|
if (params->args_count < 2 || params->args_count > 4 + !!offset_dim)
|
||||||
{
|
{
|
||||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
|
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
|
||||||
@ -3843,6 +3867,14 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct list *instrs, st
|
|||||||
struct hlsl_ir_node *load;
|
struct hlsl_ir_node *load;
|
||||||
unsigned int read_channel;
|
unsigned int read_channel;
|
||||||
|
|
||||||
|
if (object_type->sampler_dim != HLSL_SAMPLER_DIM_2D
|
||||||
|
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DARRAY
|
||||||
|
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBE
|
||||||
|
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBEARRAY)
|
||||||
|
{
|
||||||
|
return raise_invalid_method_object_type(ctx, object_type, name, loc);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(name, "GatherGreen"))
|
if (!strcmp(name, "GatherGreen"))
|
||||||
{
|
{
|
||||||
load_params.type = HLSL_RESOURCE_GATHER_GREEN;
|
load_params.type = HLSL_RESOURCE_GATHER_GREEN;
|
||||||
@ -3940,6 +3972,12 @@ static bool add_sample_lod_method_call(struct hlsl_ctx *ctx, struct list *instrs
|
|||||||
const struct hlsl_type *sampler_type;
|
const struct hlsl_type *sampler_type;
|
||||||
struct hlsl_ir_node *load;
|
struct hlsl_ir_node *load;
|
||||||
|
|
||||||
|
if (object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS
|
||||||
|
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY)
|
||||||
|
{
|
||||||
|
return raise_invalid_method_object_type(ctx, object_type, name, loc);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(name, "SampleLevel"))
|
if (!strcmp(name, "SampleLevel"))
|
||||||
load_params.type = HLSL_RESOURCE_SAMPLE_LOD;
|
load_params.type = HLSL_RESOURCE_SAMPLE_LOD;
|
||||||
else
|
else
|
||||||
@ -4076,36 +4114,24 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(name, "Load")
|
if (!strcmp(name, "Load"))
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBE
|
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBEARRAY)
|
|
||||||
{
|
{
|
||||||
return add_load_method_call(ctx, instrs, object, name, params, loc);
|
return add_load_method_call(ctx, instrs, object, name, params, loc);
|
||||||
}
|
}
|
||||||
else if (!strcmp(name, "Sample")
|
else if (!strcmp(name, "Sample"))
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS
|
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY)
|
|
||||||
{
|
{
|
||||||
return add_sample_method_call(ctx, instrs, object, name, params, loc);
|
return add_sample_method_call(ctx, instrs, object, name, params, loc);
|
||||||
}
|
}
|
||||||
else if ((!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue")
|
else if ((!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue")
|
||||||
|| !strcmp(name, "GatherGreen") || !strcmp(name, "GatherAlpha"))
|
|| !strcmp(name, "GatherGreen") || !strcmp(name, "GatherAlpha")))
|
||||||
&& (object_type->sampler_dim == HLSL_SAMPLER_DIM_2D
|
|
||||||
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_2DARRAY
|
|
||||||
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_CUBE
|
|
||||||
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_CUBEARRAY))
|
|
||||||
{
|
{
|
||||||
return add_gather_method_call(ctx, instrs, object, name, params, loc);
|
return add_gather_method_call(ctx, instrs, object, name, params, loc);
|
||||||
}
|
}
|
||||||
else if (!strcmp(name, "SampleLevel")
|
else if (!strcmp(name, "SampleLevel"))
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS
|
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY)
|
|
||||||
{
|
{
|
||||||
return add_sample_lod_method_call(ctx, instrs, object, name, params, loc);
|
return add_sample_lod_method_call(ctx, instrs, object, name, params, loc);
|
||||||
}
|
}
|
||||||
else if (!strcmp(name, "SampleBias")
|
else if (!strcmp(name, "SampleBias"))
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS
|
|
||||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY)
|
|
||||||
{
|
{
|
||||||
return add_sample_lod_method_call(ctx, instrs, object, name, params, loc);
|
return add_sample_lod_method_call(ctx, instrs, object, name, params, loc);
|
||||||
}
|
}
|
||||||
@ -4117,13 +4143,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct vkd3d_string_buffer *string;
|
return raise_invalid_method_object_type(ctx, object_type, name, loc);
|
||||||
|
|
||||||
if ((string = hlsl_type_to_string(ctx, object_type)))
|
|
||||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED,
|
|
||||||
"Method '%s' is not defined on type '%s'.", name, string->buffer);
|
|
||||||
hlsl_release_string_buffer(ctx, string);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user