mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Add support for RWBuffer object.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
44a90f5d41
commit
3de824bfd8
Notes:
Alexandre Julliard
2023-05-22 23:19:48 +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/193
@ -1937,7 +1937,7 @@ static int compare_function_decl_rb(const void *key, const struct rb_entry *entr
|
||||
|
||||
struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const struct hlsl_type *type)
|
||||
{
|
||||
struct vkd3d_string_buffer *string;
|
||||
struct vkd3d_string_buffer *string, *inner_string;
|
||||
|
||||
static const char *const base_types[] =
|
||||
{
|
||||
@ -1977,7 +1977,6 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
|
||||
case HLSL_CLASS_ARRAY:
|
||||
{
|
||||
struct vkd3d_string_buffer *inner_string;
|
||||
const struct hlsl_type *t;
|
||||
|
||||
for (t = type; t->class == HLSL_CLASS_ARRAY; t = t->e.array.type)
|
||||
@ -2029,13 +2028,24 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
|
||||
assert(type->sampler_dim < ARRAY_SIZE(dimensions));
|
||||
assert(type->e.resource_format->base_type < ARRAY_SIZE(base_types));
|
||||
vkd3d_string_buffer_printf(string, "Texture%s<%s%u>", dimensions[type->sampler_dim],
|
||||
base_types[type->e.resource_format->base_type], type->e.resource_format->dimx);
|
||||
vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]);
|
||||
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);
|
||||
}
|
||||
return string;
|
||||
|
||||
case HLSL_TYPE_UAV:
|
||||
vkd3d_string_buffer_printf(string, "RWTexture%s<%s%u>", dimensions[type->sampler_dim],
|
||||
base_types[type->e.resource_format->base_type], type->e.resource_format->dimx);
|
||||
if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER)
|
||||
vkd3d_string_buffer_printf(string, "RWBuffer");
|
||||
else
|
||||
vkd3d_string_buffer_printf(string, "RWTexture%s", dimensions[type->sampler_dim]);
|
||||
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);
|
||||
}
|
||||
return string;
|
||||
|
||||
default:
|
||||
|
@ -104,18 +104,20 @@ enum hlsl_base_type
|
||||
|
||||
enum hlsl_sampler_dim
|
||||
{
|
||||
HLSL_SAMPLER_DIM_GENERIC,
|
||||
HLSL_SAMPLER_DIM_1D,
|
||||
HLSL_SAMPLER_DIM_2D,
|
||||
HLSL_SAMPLER_DIM_3D,
|
||||
HLSL_SAMPLER_DIM_CUBE,
|
||||
HLSL_SAMPLER_DIM_LAST_SAMPLER = HLSL_SAMPLER_DIM_CUBE,
|
||||
HLSL_SAMPLER_DIM_1DARRAY,
|
||||
HLSL_SAMPLER_DIM_2DARRAY,
|
||||
HLSL_SAMPLER_DIM_2DMS,
|
||||
HLSL_SAMPLER_DIM_2DMSARRAY,
|
||||
HLSL_SAMPLER_DIM_CUBEARRAY,
|
||||
HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_CUBEARRAY,
|
||||
HLSL_SAMPLER_DIM_GENERIC,
|
||||
HLSL_SAMPLER_DIM_1D,
|
||||
HLSL_SAMPLER_DIM_2D,
|
||||
HLSL_SAMPLER_DIM_3D,
|
||||
HLSL_SAMPLER_DIM_CUBE,
|
||||
HLSL_SAMPLER_DIM_LAST_SAMPLER = HLSL_SAMPLER_DIM_CUBE,
|
||||
HLSL_SAMPLER_DIM_1DARRAY,
|
||||
HLSL_SAMPLER_DIM_2DARRAY,
|
||||
HLSL_SAMPLER_DIM_2DMS,
|
||||
HLSL_SAMPLER_DIM_2DMSARRAY,
|
||||
HLSL_SAMPLER_DIM_CUBEARRAY,
|
||||
HLSL_SAMPLER_DIM_LAST_TEXTURE = HLSL_SAMPLER_DIM_CUBEARRAY,
|
||||
HLSL_SAMPLER_DIM_BUFFER,
|
||||
HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_BUFFER,
|
||||
};
|
||||
|
||||
enum hlsl_regset
|
||||
@ -143,9 +145,10 @@ struct hlsl_type
|
||||
enum hlsl_base_type base_type;
|
||||
|
||||
/* If base_type is HLSL_TYPE_SAMPLER, then sampler_dim is <= HLSL_SAMPLER_DIM_LAST_SAMPLER.
|
||||
* If base_type is HLSL_TYPE_TEXTURE, then sampler_dim can have any value of the enum.
|
||||
* If base_type is HLSL_TYPE_UAV, them sampler_dim must be one of HLSL_SAMPLER_DIM_1D,
|
||||
* HLSL_SAMPLER_DIM_2D, HLSL_SAMPLER_DIM_3D, HLSL_SAMPLER_DIM_1DARRAY, or HLSL_SAMPLER_DIM_2DARRAY.
|
||||
* If base_type is HLSL_TYPE_TEXTURE, then sampler_dim is <= HLSL_SAMPLER_DIM_LAST_TEXTURE.
|
||||
* If base_type is HLSL_TYPE_UAV, then sampler_dim must be one of HLSL_SAMPLER_DIM_1D,
|
||||
* HLSL_SAMPLER_DIM_2D, HLSL_SAMPLER_DIM_3D, HLSL_SAMPLER_DIM_1DARRAY, HLSL_SAMPLER_DIM_2DARRAY,
|
||||
* or HLSL_SAMPLER_DIM_BUFFER.
|
||||
* Otherwise, sampler_dim is not used */
|
||||
enum hlsl_sampler_dim sampler_dim;
|
||||
/* Name, in case the type is a named struct or a typedef. */
|
||||
@ -1023,6 +1026,7 @@ static inline unsigned int hlsl_sampler_dim_count(enum hlsl_sampler_dim dim)
|
||||
switch (dim)
|
||||
{
|
||||
case HLSL_SAMPLER_DIM_1D:
|
||||
case HLSL_SAMPLER_DIM_BUFFER:
|
||||
return 1;
|
||||
case HLSL_SAMPLER_DIM_1DARRAY:
|
||||
case HLSL_SAMPLER_DIM_2D:
|
||||
|
@ -104,6 +104,7 @@ RasterizerState {return KW_RASTERIZERSTATE; }
|
||||
RenderTargetView {return KW_RENDERTARGETVIEW; }
|
||||
return {return KW_RETURN; }
|
||||
register {return KW_REGISTER; }
|
||||
RWBuffer {return KW_RWBUFFER; }
|
||||
RWTexture1D {return KW_RWTEXTURE1D; }
|
||||
RWTexture2D {return KW_RWTEXTURE2D; }
|
||||
RWTexture3D {return KW_RWTEXTURE3D; }
|
||||
|
@ -4146,6 +4146,7 @@ static void validate_texture_format_type(struct hlsl_ctx *ctx, struct hlsl_type
|
||||
%token KW_RETURN
|
||||
%token KW_REGISTER
|
||||
%token KW_ROW_MAJOR
|
||||
%token KW_RWBUFFER
|
||||
%token KW_RWTEXTURE1D
|
||||
%token KW_RWTEXTURE2D
|
||||
%token KW_RWTEXTURE3D
|
||||
@ -4955,7 +4956,11 @@ texture_ms_type:
|
||||
}
|
||||
|
||||
uav_type:
|
||||
KW_RWTEXTURE1D
|
||||
KW_RWBUFFER
|
||||
{
|
||||
$$ = HLSL_SAMPLER_DIM_BUFFER;
|
||||
}
|
||||
| KW_RWTEXTURE1D
|
||||
{
|
||||
$$ = HLSL_SAMPLER_DIM_1D;
|
||||
}
|
||||
|
@ -2959,6 +2959,8 @@ static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *typ
|
||||
return D3D_SRV_DIMENSION_TEXTURE2DMSARRAY;
|
||||
case HLSL_SAMPLER_DIM_CUBEARRAY:
|
||||
return D3D_SRV_DIMENSION_TEXTURECUBEARRAY;
|
||||
case HLSL_SAMPLER_DIM_BUFFER:
|
||||
return D3D_SRV_DIMENSION_BUFFER;
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
@ -3258,6 +3260,8 @@ static enum vkd3d_sm4_resource_type sm4_resource_dimension(const struct hlsl_typ
|
||||
return VKD3D_SM4_RESOURCE_TEXTURE_2DMSARRAY;
|
||||
case HLSL_SAMPLER_DIM_CUBEARRAY:
|
||||
return VKD3D_SM4_RESOURCE_TEXTURE_CUBEARRAY;
|
||||
case HLSL_SAMPLER_DIM_BUFFER:
|
||||
return VKD3D_SM4_RESOURCE_BUFFER;
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user