From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/d3dbc.c | 13 ++++--- libs/vkd3d-shader/fx.c | 8 +++++ libs/vkd3d-shader/hlsl.c | 61 ++++++++++++++++++++++++++------ libs/vkd3d-shader/hlsl.h | 2 +- libs/vkd3d-shader/hlsl_codegen.c | 3 ++ libs/vkd3d-shader/tpf.c | 1 + 6 files changed, 71 insertions(+), 17 deletions(-)
diff --git a/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d-shader/d3dbc.c index 4685afa08..78818b366 100644 --- a/libs/vkd3d-shader/d3dbc.c +++ b/libs/vkd3d-shader/d3dbc.c @@ -1514,10 +1514,11 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type) return D3DXPC_STRUCT; case HLSL_CLASS_VECTOR: return D3DXPC_VECTOR; - default: - ERR("Invalid class %#x.\n", type->class); - vkd3d_unreachable(); + case HLSL_CLASS_VOID: + /* This shouldn't happen. */ } + + vkd3d_unreachable(); }
D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type) @@ -1595,8 +1596,6 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type) break; case HLSL_TYPE_VERTEXSHADER: return D3DXPT_VERTEXSHADER; - case HLSL_TYPE_VOID: - return D3DXPT_VOID; default: vkd3d_unreachable(); } @@ -1607,6 +1606,10 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
case HLSL_CLASS_STRUCT: return D3DXPT_VOID; + + case HLSL_CLASS_VOID: + /* This shouldn't happen. */ + break; }
vkd3d_unreachable(); diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 1d90cd70e..c94552da1 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -436,6 +436,11 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
case HLSL_CLASS_ARRAY: vkd3d_unreachable(); + + case HLSL_CLASS_VOID: + FIXME("Writing type class %u is not implemented.\n", type->class); + set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED); + return 0; }
size = stride = type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float); @@ -814,6 +819,9 @@ static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type default: return false; } + + case HLSL_CLASS_VOID: + return false; }
vkd3d_unreachable(); diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index ed80e2b75..6859e1a33 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -365,6 +365,9 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type } break; } + + case HLSL_CLASS_VOID: + break; } }
@@ -377,6 +380,25 @@ unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type, return type->reg_size[regset]; }
+static struct hlsl_type *hlsl_new_simple_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class class) +{ + struct hlsl_type *type; + + if (!(type = hlsl_alloc(ctx, sizeof(*type)))) + return NULL; + if (!(type->name = hlsl_strdup(ctx, name))) + { + vkd3d_free(type); + return NULL; + } + type->class = class; + hlsl_type_calculate_reg_size(ctx, type); + + list_add_tail(&ctx->types, &type->entry); + + return type; +} + static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class type_class, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) { @@ -402,7 +424,22 @@ static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, e
static bool type_is_single_component(const struct hlsl_type *type) { - return type->class == HLSL_CLASS_SCALAR || type->class == HLSL_CLASS_OBJECT; + switch (type->class) + { + case HLSL_CLASS_SCALAR: + case HLSL_CLASS_OBJECT: + return true; + + case HLSL_CLASS_VECTOR: + case HLSL_CLASS_MATRIX: + case HLSL_CLASS_STRUCT: + case HLSL_CLASS_ARRAY: + return false; + + case HLSL_CLASS_VOID: + break; + } + vkd3d_unreachable(); }
/* Given a type and a component index, this function moves one step through the path required to @@ -525,7 +562,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty assert(idx == 0); break;
- default: + case HLSL_CLASS_VOID: vkd3d_unreachable(); } type = next_type; @@ -752,7 +789,6 @@ struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, if (!(type = hlsl_alloc(ctx, sizeof(*type)))) return NULL; type->class = HLSL_CLASS_STRUCT; - type->base_type = HLSL_TYPE_VOID; type->name = name; type->dimy = 1; type->e.record.fields = fields; @@ -896,9 +932,11 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type) case HLSL_CLASS_OBJECT: return 1;
- default: - vkd3d_unreachable(); + case HLSL_CLASS_VOID: + break; } + + vkd3d_unreachable(); }
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2) @@ -2313,15 +2351,16 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru return string;
default: - vkd3d_string_buffer_printf(string, "<unexpected type>"); - return string; + break; } }
- default: - vkd3d_string_buffer_printf(string, "<unexpected type>"); - return string; + case HLSL_CLASS_VOID: + break; } + + vkd3d_string_buffer_printf(string, "<unexpected type>"); + return string; }
struct vkd3d_string_buffer *hlsl_component_to_string(struct hlsl_ctx *ctx, const struct hlsl_ir_var *var, @@ -3609,7 +3648,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx) ctx->builtin_types.sampler[bt] = type; }
- ctx->builtin_types.Void = hlsl_new_type(ctx, "void", HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1); + ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
for (i = 0; i < ARRAY_SIZE(effect_types); ++i) { diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 3cb98b765..97bc087f8 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_VOID, };
enum hlsl_base_type @@ -101,7 +102,6 @@ enum hlsl_base_type HLSL_TYPE_TECHNIQUE, HLSL_TYPE_EFFECT_GROUP, HLSL_TYPE_STRING, - HLSL_TYPE_VOID, };
enum hlsl_sampler_dim diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index eaa72836d..511b1a66e 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1634,6 +1634,9 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx, /* FIXME: Actually we shouldn't even get here, but we don't split * matrices yet. */ return false; + + case HLSL_CLASS_VOID: + vkd3d_unreachable(); }
if (copy_propagation_replace_with_constant_vector(ctx, state, load, HLSL_SWIZZLE(X, Y, Z, W), &load->node)) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index d5019a5dd..d0f0111f9 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3008,6 +3008,7 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type) case HLSL_CLASS_ARRAY: case HLSL_CLASS_STRUCT: case HLSL_CLASS_OBJECT: + case HLSL_CLASS_VOID: break; } vkd3d_unreachable();