mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-shader/hlsl: Introduce hlsl_type.e.resource.
This commit is contained in:
parent
d9c68ee481
commit
49d14613a5
Notes:
Alexandre Julliard
2024-02-21 23:33:25 +01:00
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/659
@ -751,7 +751,7 @@ struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_
|
||||
type->dimx = 4;
|
||||
type->dimy = 1;
|
||||
type->sampler_dim = dim;
|
||||
type->e.resource_format = format;
|
||||
type->e.resource.format = format;
|
||||
type->sample_count = sample_count;
|
||||
hlsl_type_calculate_reg_size(ctx, type);
|
||||
list_add_tail(&ctx->types, &type->entry);
|
||||
@ -771,7 +771,7 @@ struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx,
|
||||
type->dimy = 1;
|
||||
type->sampler_dim = dim;
|
||||
type->modifiers = modifiers;
|
||||
type->e.resource_format = format;
|
||||
type->e.resource.format = format;
|
||||
hlsl_type_calculate_reg_size(ctx, type);
|
||||
list_add_tail(&ctx->types, &type->entry);
|
||||
return type;
|
||||
@ -888,7 +888,7 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
|
||||
if (t1->sampler_dim != t2->sampler_dim)
|
||||
return false;
|
||||
if (t1->base_type == HLSL_TYPE_TEXTURE && t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC
|
||||
&& !hlsl_types_are_equal(t1->e.resource_format, t2->e.resource_format))
|
||||
&& !hlsl_types_are_equal(t1->e.resource.format, t2->e.resource.format))
|
||||
return false;
|
||||
}
|
||||
if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||
@ -1009,7 +1009,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
|
||||
if (type->base_type == HLSL_TYPE_TECHNIQUE)
|
||||
type->e.version = old->e.version;
|
||||
if (old->base_type == HLSL_TYPE_TEXTURE || old->base_type == HLSL_TYPE_UAV)
|
||||
type->e.resource_format = old->e.resource_format;
|
||||
type->e.resource.format = old->e.resource.format;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1573,7 +1573,7 @@ struct hlsl_ir_node *hlsl_new_index(struct hlsl_ctx *ctx, struct hlsl_ir_node *v
|
||||
return NULL;
|
||||
|
||||
if (type->class == HLSL_CLASS_OBJECT)
|
||||
type = type->e.resource_format;
|
||||
type = type->e.resource.format;
|
||||
else if (type->class == HLSL_CLASS_MATRIX)
|
||||
type = hlsl_get_vector_type(ctx, type->base_type, type->dimx);
|
||||
else
|
||||
@ -2201,7 +2201,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
return string;
|
||||
}
|
||||
|
||||
assert(type->e.resource_format->base_type < ARRAY_SIZE(base_types));
|
||||
assert(type->e.resource.format->base_type < ARRAY_SIZE(base_types));
|
||||
if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
|
||||
{
|
||||
vkd3d_string_buffer_printf(string, "Buffer");
|
||||
@ -2211,7 +2211,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
assert(type->sampler_dim < ARRAY_SIZE(dimensions));
|
||||
vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]);
|
||||
}
|
||||
if ((inner_string = hlsl_type_to_string(ctx, type->e.resource_format)))
|
||||
if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
|
||||
{
|
||||
vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
|
||||
hlsl_release_string_buffer(ctx, inner_string);
|
||||
@ -2225,7 +2225,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
vkd3d_string_buffer_printf(string, "RWStructuredBuffer");
|
||||
else
|
||||
vkd3d_string_buffer_printf(string, "RWTexture%s", dimensions[type->sampler_dim]);
|
||||
if ((inner_string = hlsl_type_to_string(ctx, type->e.resource_format)))
|
||||
if ((inner_string = hlsl_type_to_string(ctx, type->e.resource.format)))
|
||||
{
|
||||
vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer);
|
||||
hlsl_release_string_buffer(ctx, inner_string);
|
||||
|
@ -194,9 +194,13 @@ struct hlsl_type
|
||||
/* Array length, or HLSL_ARRAY_ELEMENTS_COUNT_IMPLICIT if it is not known yet at parse time. */
|
||||
unsigned int elements_count;
|
||||
} array;
|
||||
/* Format of the data contained within the type if the base_type is HLSL_TYPE_TEXTURE or
|
||||
* HLSL_TYPE_UAV. */
|
||||
struct hlsl_type *resource_format;
|
||||
/* Additional information if the base_type is HLSL_TYPE_TEXTURE or
|
||||
* HLSL_TYPE_UAV. */
|
||||
struct
|
||||
{
|
||||
/* Format of the data contained within the type. */
|
||||
struct hlsl_type *format;
|
||||
} resource;
|
||||
/* Additional field to distinguish object types. Currently used only for technique types. */
|
||||
unsigned int version;
|
||||
} e;
|
||||
|
@ -1942,7 +1942,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct hlsl_blo
|
||||
|
||||
dim_count = hlsl_sampler_dim_count(resource_type->sampler_dim);
|
||||
|
||||
if (writemask != ((1u << resource_type->e.resource_format->dimx) - 1))
|
||||
if (writemask != ((1u << resource_type->e.resource.format->dimx) - 1))
|
||||
hlsl_error(ctx, &lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK,
|
||||
"Resource store expressions must write to all components.");
|
||||
|
||||
@ -4308,7 +4308,7 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + !multisampled), loc)))
|
||||
return false;
|
||||
|
||||
load_params.format = object_type->e.resource_format;
|
||||
load_params.format = object_type->e.resource.format;
|
||||
load_params.resource = object;
|
||||
|
||||
if (!(load = hlsl_new_resource_load(ctx, &load_params, loc)))
|
||||
@ -4366,7 +4366,7 @@ static bool add_sample_method_call(struct hlsl_ctx *ctx, struct hlsl_block *bloc
|
||||
if (params->args_count > 3 + !!offset_dim)
|
||||
hlsl_fixme(ctx, loc, "Tiled resource status argument.");
|
||||
|
||||
load_params.format = object_type->e.resource_format;
|
||||
load_params.format = object_type->e.resource.format;
|
||||
load_params.resource = object;
|
||||
load_params.sampler = params->args[0];
|
||||
|
||||
@ -4436,7 +4436,7 @@ static bool add_sample_cmp_method_call(struct hlsl_ctx *ctx, struct hlsl_block *
|
||||
if (params->args_count > 4 + !!offset_dim)
|
||||
hlsl_fixme(ctx, loc, "Tiled resource status argument.");
|
||||
|
||||
load_params.format = object_type->e.resource_format;
|
||||
load_params.format = object_type->e.resource.format;
|
||||
load_params.resource = object;
|
||||
load_params.sampler = params->args[0];
|
||||
|
||||
@ -4526,7 +4526,7 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct hlsl_block *bloc
|
||||
return false;
|
||||
}
|
||||
|
||||
if (read_channel >= object_type->e.resource_format->dimx)
|
||||
if (read_channel >= object_type->e.resource.format->dimx)
|
||||
{
|
||||
hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
|
||||
"Method %s() requires at least %u channels.", name, read_channel + 1);
|
||||
@ -4537,7 +4537,7 @@ static bool add_gather_method_call(struct hlsl_ctx *ctx, struct hlsl_block *bloc
|
||||
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, sampler_dim), loc)))
|
||||
return false;
|
||||
|
||||
load_params.format = hlsl_get_vector_type(ctx, object_type->e.resource_format->base_type, 4);
|
||||
load_params.format = hlsl_get_vector_type(ctx, object_type->e.resource.format->base_type, 4);
|
||||
load_params.resource = object;
|
||||
load_params.sampler = params->args[0];
|
||||
|
||||
@ -4781,7 +4781,7 @@ static bool add_sample_lod_method_call(struct hlsl_ctx *ctx, struct hlsl_block *
|
||||
if (params->args_count > 3 + !!offset_dim)
|
||||
hlsl_fixme(ctx, loc, "Tiled resource status argument.");
|
||||
|
||||
load_params.format = object_type->e.resource_format;
|
||||
load_params.format = object_type->e.resource.format;
|
||||
load_params.resource = object;
|
||||
load_params.sampler = params->args[0];
|
||||
|
||||
@ -4848,7 +4848,7 @@ static bool add_sample_grad_method_call(struct hlsl_ctx *ctx, struct hlsl_block
|
||||
if (params->args_count > 4 + !!offset_dim)
|
||||
hlsl_fixme(ctx, loc, "Tiled resource status argument.");
|
||||
|
||||
load_params.format = object_type->e.resource_format;
|
||||
load_params.format = object_type->e.resource.format;
|
||||
load_params.resource = object;
|
||||
load_params.sampler = params->args[0];
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
|
||||
params.type = HLSL_RESOURCE_LOAD;
|
||||
params.resource = val;
|
||||
params.coords = coords;
|
||||
params.format = val->data_type->e.resource_format;
|
||||
params.format = val->data_type->e.resource.format;
|
||||
|
||||
if (!(resource_load = hlsl_new_resource_load(ctx, ¶ms, &instr->loc)))
|
||||
return false;
|
||||
|
@ -3156,7 +3156,7 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type
|
||||
if (type->class == HLSL_CLASS_ARRAY)
|
||||
return sm4_resource_format(type->e.array.type);
|
||||
|
||||
switch (type->e.resource_format->base_type)
|
||||
switch (type->e.resource.format->base_type)
|
||||
{
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
return D3D_RETURN_TYPE_DOUBLE;
|
||||
@ -3446,7 +3446,7 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int dimx = hlsl_type_get_component_type(ctx, resource->data_type, 0)->e.resource_format->dimx;
|
||||
unsigned int dimx = hlsl_type_get_component_type(ctx, resource->data_type, 0)->e.resource.format->dimx;
|
||||
|
||||
put_u32(&buffer, sm4_resource_format(resource->data_type));
|
||||
put_u32(&buffer, sm4_rdef_resource_dimension(resource->data_type));
|
||||
@ -4253,7 +4253,7 @@ static void write_sm4_dcl_textures(const struct tpf_writer *tpf, const struct ex
|
||||
{
|
||||
case HLSL_SAMPLER_DIM_STRUCTURED_BUFFER:
|
||||
instr.opcode = VKD3D_SM5_OP_DCL_UAV_STRUCTURED;
|
||||
instr.byte_stride = resource->data_type->e.resource_format->reg_size[HLSL_REGSET_NUMERIC] * 4;
|
||||
instr.byte_stride = resource->data_type->e.resource.format->reg_size[HLSL_REGSET_NUMERIC] * 4;
|
||||
break;
|
||||
default:
|
||||
instr.opcode = VKD3D_SM5_OP_DCL_UAV_TYPED;
|
||||
|
Loading…
Reference in New Issue
Block a user