Module: vkd3d Branch: master Commit: ee2bde3aba8d85e7a15560d3f17355f11f2a8baa URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/ee2bde3aba8d85e7a15560d3f17355...
Author: Zebediah Figura zfigura@codeweavers.com Date: Tue Feb 27 13:31:20 2024 -0600
vkd3d-shader/hlsl: Make HLSL_TYPE_DEPTHSTENCILVIEW into a separate class.
---
libs/vkd3d-shader/d3dbc.c | 2 ++ libs/vkd3d-shader/fx.c | 40 ++++++++++++++++++++++++++-------------- libs/vkd3d-shader/hlsl.c | 7 ++++++- libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl_codegen.c | 1 + libs/vkd3d-shader/tpf.c | 1 + 6 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index 6299239b..88f5630f 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1517,6 +1517,7 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type) case HLSL_CLASS_STRING: case HLSL_CLASS_TEXTURE: return D3DXPC_OBJECT; + case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_EFFECT_GROUP: case HLSL_CLASS_PASS: case HLSL_CLASS_TECHNIQUE: @@ -1617,6 +1618,7 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type) case HLSL_CLASS_STRING: return D3DXPT_STRING;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_EFFECT_GROUP: case HLSL_CLASS_PASS: case HLSL_CLASS_TECHNIQUE: diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 73160b63..1ed2c4b7 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -354,7 +354,6 @@ static const char * get_fx_4_type_name(const struct hlsl_type *type) [HLSL_TYPE_PIXELSHADER] = "PixelShader", [HLSL_TYPE_VERTEXSHADER] = "VertexShader", [HLSL_TYPE_RENDERTARGETVIEW] = "RenderTargetView", - [HLSL_TYPE_DEPTHSTENCILVIEW] = "DepthStencilView", }; static const char * const texture_type_names[] = { @@ -380,19 +379,28 @@ static const char * get_fx_4_type_name(const struct hlsl_type *type) [HLSL_SAMPLER_DIM_STRUCTURED_BUFFER] = "RWStructuredBuffer", };
- if (type->class == HLSL_CLASS_TEXTURE) - return texture_type_names[type->sampler_dim]; + switch (type->class) + { + case HLSL_CLASS_TEXTURE: + return texture_type_names[type->sampler_dim];
- if (type->class == HLSL_CLASS_UAV) - return uav_type_names[type->sampler_dim]; + case HLSL_CLASS_UAV: + return uav_type_names[type->sampler_dim]; + + case HLSL_CLASS_DEPTH_STENCIL_VIEW: + return "DepthStencilView"; + + case HLSL_CLASS_OBJECT: + switch (type->base_type) + { + case HLSL_TYPE_PIXELSHADER: + case HLSL_TYPE_VERTEXSHADER: + case HLSL_TYPE_RENDERTARGETVIEW: + return object_type_names[type->base_type]; + default: + return type->name; + }
- switch (type->base_type) - { - case HLSL_TYPE_PIXELSHADER: - case HLSL_TYPE_VERTEXSHADER: - case HLSL_TYPE_RENDERTARGETVIEW: - case HLSL_TYPE_DEPTHSTENCILVIEW: - return object_type_names[type->base_type]; default: return type->name; } @@ -426,6 +434,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co put_u32_unaligned(buffer, 1); break;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_OBJECT: case HLSL_CLASS_TEXTURE: case HLSL_CLASS_UAV: @@ -513,6 +522,10 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
put_u32_unaligned(buffer, uav_type[type->sampler_dim]); } + else if (type->class == HLSL_CLASS_DEPTH_STENCIL_VIEW) + { + put_u32_unaligned(buffer, 20); + } else if (type->class == HLSL_CLASS_OBJECT) { static const uint32_t object_type[] = @@ -520,12 +533,10 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co [HLSL_TYPE_PIXELSHADER] = 5, [HLSL_TYPE_VERTEXSHADER] = 6, [HLSL_TYPE_RENDERTARGETVIEW] = 19, - [HLSL_TYPE_DEPTHSTENCILVIEW] = 20, };
switch (type->base_type) { - case HLSL_TYPE_DEPTHSTENCILVIEW: case HLSL_TYPE_PIXELSHADER: case HLSL_TYPE_RENDERTARGETVIEW: case HLSL_TYPE_VERTEXSHADER: @@ -834,6 +845,7 @@ static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type hlsl_fixme(ctx, loc, "Write fx 2.0 parameter class %#x.", type->class); return false;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_UAV: case HLSL_CLASS_VOID: return false; diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index b5bb72a9..ba297153 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -363,6 +363,7 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type type->reg_size[HLSL_REGSET_UAVS] = 1; break;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_EFFECT_GROUP: case HLSL_CLASS_OBJECT: case HLSL_CLASS_PASS: @@ -428,6 +429,7 @@ static bool type_is_single_component(const struct hlsl_type *type) { switch (type->class) { + case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_SCALAR: case HLSL_CLASS_OBJECT: case HLSL_CLASS_SAMPLER: @@ -567,6 +569,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty } break;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_OBJECT: case HLSL_CLASS_SAMPLER: case HLSL_CLASS_STRING: @@ -943,6 +946,7 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type) case HLSL_CLASS_ARRAY: return hlsl_type_component_count(type->e.array.type) * type->e.array.elements_count;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_OBJECT: case HLSL_CLASS_SAMPLER: case HLSL_CLASS_STRING: @@ -2366,6 +2370,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru } return string;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_EFFECT_GROUP: case HLSL_CLASS_OBJECT: case HLSL_CLASS_PASS: @@ -3550,7 +3555,6 @@ static void declare_predefined_types(struct hlsl_ctx *ctx) {"pixelshader", HLSL_CLASS_OBJECT, HLSL_TYPE_PIXELSHADER, 1, 1}, {"vertexshader", HLSL_CLASS_OBJECT, HLSL_TYPE_VERTEXSHADER, 1, 1}, {"RenderTargetView",HLSL_CLASS_OBJECT, HLSL_TYPE_RENDERTARGETVIEW, 1, 1}, - {"DepthStencilView",HLSL_CLASS_OBJECT, HLSL_TYPE_DEPTHSTENCILVIEW, 1, 1}, };
static const struct @@ -3662,6 +3666,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx) }
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID); + hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilView", HLSL_CLASS_DEPTH_STENCIL_VIEW)); hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "fxgroup", HLSL_CLASS_EFFECT_GROUP)); hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "pass", HLSL_CLASS_PASS)); hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "STRING", HLSL_CLASS_STRING)); diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index a9e47c6f..452aec16 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -79,6 +79,7 @@ enum hlsl_type_class HLSL_CLASS_STRUCT, HLSL_CLASS_ARRAY, HLSL_CLASS_OBJECT, + HLSL_CLASS_DEPTH_STENCIL_VIEW, HLSL_CLASS_EFFECT_GROUP, HLSL_CLASS_PASS, HLSL_CLASS_SAMPLER, @@ -101,7 +102,6 @@ enum hlsl_base_type HLSL_TYPE_PIXELSHADER, HLSL_TYPE_VERTEXSHADER, HLSL_TYPE_RENDERTARGETVIEW, - HLSL_TYPE_DEPTHSTENCILVIEW, };
enum hlsl_sampler_dim diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 5681761c..0669ff40 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1638,6 +1638,7 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx, * matrices yet. */ return false;
+ case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_EFFECT_GROUP: case HLSL_CLASS_PASS: case HLSL_CLASS_STRING: diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 52e6eac8..e01d8d91 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3006,6 +3006,7 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type) return D3D_SVC_VECTOR;
case HLSL_CLASS_ARRAY: + case HLSL_CLASS_DEPTH_STENCIL_VIEW: case HLSL_CLASS_EFFECT_GROUP: case HLSL_CLASS_STRUCT: case HLSL_CLASS_OBJECT: