Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 22 +++++++++++++++++++--- libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index f03777a65..2dba001ee 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -261,6 +261,21 @@ struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name, s return type; }
+struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim) +{ + struct hlsl_type *type; + + if (!(type = vkd3d_calloc(1, sizeof(*type)))) + return NULL; + type->type = HLSL_CLASS_OBJECT; + type->base_type = HLSL_TYPE_TEXTURE; + type->dimx = 4; + type->dimy = 1; + type->sampler_dim = dim; + list_add_tail(&ctx->types, &type->entry); + return type; +} + struct hlsl_type *hlsl_get_type(struct hlsl_scope *scope, const char *name, bool recursive) { struct rb_entry *entry = rb_get(&scope->types, name); @@ -329,7 +344,8 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2 return false; if (t1->base_type != t2->base_type) return false; - if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim) + if ((t1->base_type == HLSL_TYPE_SAMPLER || t1->base_type == HLSL_TYPE_TEXTURE) + && t1->sampler_dim != t2->sampler_dim) return false; if ((t1->modifiers & HLSL_MODIFIER_ROW_MAJOR) != (t2->modifiers & HLSL_MODIFIER_ROW_MAJOR)) @@ -734,8 +750,8 @@ static int compare_param_hlsl_types(const struct hlsl_type *t1, const struct hls } if (t1->base_type != t2->base_type) return t1->base_type - t2->base_type; - if (t1->base_type == HLSL_TYPE_SAMPLER && t1->sampler_dim != t2->sampler_dim) - return t1->sampler_dim - t2->sampler_dim; + if ((t1->base_type == HLSL_TYPE_SAMPLER || t1->base_type == HLSL_TYPE_TEXTURE) + && t1->sampler_dim != t2->sampler_dim) if (t1->dimx != t2->dimx) return t1->dimx - t2->dimx; if (t1->dimy != t2->dimy) diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 77b4ce928..65c6f34e0 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -655,6 +655,7 @@ struct hlsl_ir_swizzle *hlsl_new_swizzle(struct hlsl_ctx *ctx, DWORD s, unsigned struct hlsl_ir_node *val, struct vkd3d_shader_location *loc); struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, const struct vkd3d_shader_location loc); +struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, const struct vkd3d_shader_location loc); struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 6f1794e79..b8149950d 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2451,6 +2451,26 @@ type: { $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_3D]; } + | KW_TEXTURE + { + $$ = hlsl_new_texture_type(ctx, HLSL_SAMPLER_DIM_GENERIC); + } + | KW_TEXTURE1D + { + $$ = hlsl_new_texture_type(ctx, HLSL_SAMPLER_DIM_1D); + } + | KW_TEXTURE2D + { + $$ = hlsl_new_texture_type(ctx, HLSL_SAMPLER_DIM_2D); + } + | KW_TEXTURE3D + { + $$ = hlsl_new_texture_type(ctx, HLSL_SAMPLER_DIM_3D); + } + | KW_TEXTURECUBE + { + $$ = hlsl_new_texture_type(ctx, HLSL_SAMPLER_DIM_CUBE); + } | TYPE_IDENTIFIER { $$ = hlsl_get_type(ctx->cur_scope, $1, true);