mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Add separate helpers to generate object methods.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
4fe4784e8a
commit
c166ab9727
Notes:
Alexandre Julliard
2023-04-26 22:59:27 +02:00
Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/172
@ -3612,27 +3612,10 @@ static unsigned int hlsl_offset_dim_count(enum hlsl_sampler_dim dim)
|
||||
}
|
||||
}
|
||||
|
||||
static bool add_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 struct hlsl_type *object_type = object->data_type;
|
||||
|
||||
if (object_type->class != HLSL_CLASS_OBJECT || object_type->base_type != HLSL_TYPE_TEXTURE
|
||||
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
|
||||
if ((string = hlsl_type_to_string(ctx, object_type)))
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Type '%s' does not have methods.", string->buffer);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!strcmp(name, "Load")
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBE
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_CUBEARRAY)
|
||||
{
|
||||
const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
|
||||
const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim);
|
||||
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_LOAD};
|
||||
@ -3679,10 +3662,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
||||
list_add_tail(instrs, &load->node.entry);
|
||||
return true;
|
||||
}
|
||||
else if (!strcmp(name, "Sample")
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY)
|
||||
|
||||
static bool add_sample_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 struct hlsl_type *object_type = object->data_type;
|
||||
const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
|
||||
const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim);
|
||||
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_SAMPLE};
|
||||
@ -3736,13 +3720,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
||||
|
||||
return true;
|
||||
}
|
||||
else if ((!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue")
|
||||
|| !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))
|
||||
|
||||
static bool add_gather_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 struct hlsl_type *object_type = object->data_type;
|
||||
const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
|
||||
const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim);
|
||||
struct hlsl_resource_load_params load_params = {0};
|
||||
@ -3836,10 +3818,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
||||
list_add_tail(instrs, &load->node.entry);
|
||||
return true;
|
||||
}
|
||||
else if (!strcmp(name, "SampleLevel")
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY)
|
||||
|
||||
static bool add_sample_level_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 struct hlsl_type *object_type = object->data_type;
|
||||
struct hlsl_resource_load_params load_params = {.type = HLSL_RESOURCE_SAMPLE_LOD};
|
||||
const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
|
||||
const unsigned int offset_dim = hlsl_offset_dim_count(object_type->sampler_dim);
|
||||
@ -3894,6 +3877,51 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
|
||||
list_add_tail(instrs, &load->node.entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool add_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 struct hlsl_type *object_type = object->data_type;
|
||||
|
||||
if (object_type->class != HLSL_CLASS_OBJECT || object_type->base_type != HLSL_TYPE_TEXTURE
|
||||
|| object_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
|
||||
if ((string = hlsl_type_to_string(ctx, object_type)))
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Type '%s' does not have methods.", string->buffer);
|
||||
hlsl_release_string_buffer(ctx, string);
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if ((!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue")
|
||||
|| !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);
|
||||
}
|
||||
else if (!strcmp(name, "SampleLevel")
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMS
|
||||
&& object_type->sampler_dim != HLSL_SAMPLER_DIM_2DMSARRAY)
|
||||
{
|
||||
return add_sample_level_method_call(ctx, instrs, object, name, params, loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user