New values for enum hlsl_sampler_dim are added in order to represent dimension types for textures that don't have their analog sampler, like Texture2DArray.
enum hlsl_sampler_dim is then renamed to enum hlsl_resource_dim to convey that it no longer represents just sampler types.
Parsing and initialization of Texture2DArray, Texture2DMS, Texture2DMSArray, and TextureCubeArray is added.
sampler_dim_count() is moved from hlsl.y to hlsl.h since it can be useful in other files, like in write_sm4_ld() in hlsl_sm4.c.
---
This patch is an alternative to 221390, which proposed to separate sampler_dim into sampler_dim and texture_dim. It will probably be resent after Matteo's batch is reviewed.
Signed-off-by: Francisco Casas fcasas@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 52 +++++++------- libs/vkd3d-shader/hlsl.h | 55 +++++++++++---- libs/vkd3d-shader/hlsl.l | 1 + libs/vkd3d-shader/hlsl.y | 81 ++++++++++++---------- libs/vkd3d-shader/hlsl_sm1.c | 28 ++++---- libs/vkd3d-shader/hlsl_sm4.c | 129 ++++++++++++++++++++--------------- 6 files changed, 205 insertions(+), 141 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 9824c56d..f2fb8e20 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -261,7 +261,7 @@ 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 *format) +struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_resource_dim dim, struct hlsl_type *format) { struct hlsl_type *type;
@@ -271,7 +271,7 @@ struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_ type->base_type = HLSL_TYPE_TEXTURE; type->dimx = 4; type->dimy = 1; - type->sampler_dim = dim; + type->resource_dim = dim; type->e.resource_format = format; list_add_tail(&ctx->types, &type->entry); return type; @@ -347,9 +347,9 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2 return false; if (t1->base_type == HLSL_TYPE_SAMPLER || t1->base_type == HLSL_TYPE_TEXTURE) { - if (t1->sampler_dim != t2->sampler_dim) + if (t1->resource_dim != t2->resource_dim) return false; - if (t1->base_type == HLSL_TYPE_TEXTURE && t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC + if (t1->base_type == HLSL_TYPE_TEXTURE && t1->resource_dim != HLSL_RESOURCE_DIM_GENERIC && !hlsl_types_are_equal(t1->e.resource_format, t2->e.resource_format)) return false; } @@ -413,7 +413,7 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old, type->modifiers = old->modifiers | modifiers; if (!(type->modifiers & HLSL_MODIFIERS_MAJORITY_MASK)) type->modifiers |= default_majority; - type->sampler_dim = old->sampler_dim; + type->resource_dim = old->resource_dim; switch (old->type) { case HLSL_CLASS_ARRAY: @@ -778,12 +778,11 @@ 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->base_type == HLSL_TYPE_TEXTURE) - && t1->sampler_dim != t2->sampler_dim) + if (t1->base_type == HLSL_TYPE_SAMPLER || t1->base_type == HLSL_TYPE_TEXTURE) { - if (t1->sampler_dim != t2->sampler_dim) - return t1->sampler_dim - t2->sampler_dim; - if (t1->base_type == HLSL_TYPE_TEXTURE && t1->sampler_dim != HLSL_SAMPLER_DIM_GENERIC + if (t1->resource_dim != t2->resource_dim) + return t1->resource_dim - t2->resource_dim; + if (t1->base_type == HLSL_TYPE_TEXTURE && t1->resource_dim != HLSL_RESOURCE_DIM_GENERIC && (r = compare_param_hlsl_types(t1->e.resource_format, t2->e.resource_format))) return r; } @@ -917,24 +916,29 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru { static const char *const dimensions[] = { - [HLSL_SAMPLER_DIM_1D] = "1D", - [HLSL_SAMPLER_DIM_2D] = "2D", - [HLSL_SAMPLER_DIM_3D] = "3D", - [HLSL_SAMPLER_DIM_CUBE] = "Cube" + [HLSL_RESOURCE_DIM_1D] = "1D", + [HLSL_RESOURCE_DIM_2D] = "2D", + [HLSL_RESOURCE_DIM_3D] = "3D", + [HLSL_RESOURCE_DIM_CUBE] = "Cube", + [HLSL_RESOURCE_DIM_1DARRAY] = "1DArray", + [HLSL_RESOURCE_DIM_2DARRAY] = "2DArray", + [HLSL_RESOURCE_DIM_2DMS] = "2DMS", + [HLSL_RESOURCE_DIM_2DMSARRAY] = "2DMSArray", + [HLSL_RESOURCE_DIM_CUBEARRAY] = "CubeArray", };
switch (type->base_type) { case HLSL_TYPE_TEXTURE: - if (type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC) + if (type->resource_dim == HLSL_RESOURCE_DIM_GENERIC) { vkd3d_string_buffer_printf(string, "Texture"); return string; }
- assert(type->sampler_dim < ARRAY_SIZE(dimensions)); + assert(type->resource_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], + vkd3d_string_buffer_printf(string, "Texture%s<%s%u>", dimensions[type->resource_dim], base_types[type->e.resource_format->base_type], type->e.resource_format->dimx); return string;
@@ -1744,11 +1748,11 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
static const char *const sampler_names[] = { - "sampler", - "sampler1D", - "sampler2D", - "sampler3D", - "samplerCUBE" + [HLSL_RESOURCE_DIM_GENERIC] = "sampler", + [HLSL_RESOURCE_DIM_1D] = "sampler1D", + [HLSL_RESOURCE_DIM_2D] = "sampler2D", + [HLSL_RESOURCE_DIM_3D] = "sampler3D", + [HLSL_RESOURCE_DIM_CUBE] = "samplerCUBE" };
static const struct @@ -1800,10 +1804,10 @@ static void declare_predefined_types(struct hlsl_ctx *ctx) } }
- for (bt = 0; bt <= HLSL_SAMPLER_DIM_MAX; ++bt) + for (bt = 0; bt <= HLSL_RESOURCE_DIM_MAX_SAMPLER; ++bt) { type = hlsl_new_type(ctx, sampler_names[bt], HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1); - type->sampler_dim = bt; + type->resource_dim = bt; ctx->builtin_types.sampler[bt] = type; }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index e7bdb45e..fd9617aa 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -91,15 +91,46 @@ enum hlsl_base_type HLSL_TYPE_VOID, };
-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_MAX = HLSL_SAMPLER_DIM_CUBE -}; +/* Used for both textures and samplers. + * HLSL_RESOURCE_DIM_MAX_SAMPLER can be used to check whether a dimension value is a valid + * sampler dimension. */ +enum hlsl_resource_dim +{ + HLSL_RESOURCE_DIM_GENERIC, + HLSL_RESOURCE_DIM_1D, + HLSL_RESOURCE_DIM_2D, + HLSL_RESOURCE_DIM_3D, + HLSL_RESOURCE_DIM_CUBE, + HLSL_RESOURCE_DIM_MAX_SAMPLER = HLSL_RESOURCE_DIM_CUBE, /* Last valid dimension for samplers. */ + HLSL_RESOURCE_DIM_1DARRAY, + HLSL_RESOURCE_DIM_2DARRAY, + HLSL_RESOURCE_DIM_2DMS, + HLSL_RESOURCE_DIM_2DMSARRAY, + HLSL_RESOURCE_DIM_CUBEARRAY, + HLSL_RESOURCE_DIM_MAX = HLSL_RESOURCE_DIM_CUBEARRAY, +}; + +static inline unsigned int sampler_dim_count(enum hlsl_resource_dim dim) { + switch (dim) + { + case HLSL_RESOURCE_DIM_1D: + return 1; + case HLSL_RESOURCE_DIM_1DARRAY: + case HLSL_RESOURCE_DIM_2D: + case HLSL_RESOURCE_DIM_2DMS: + return 2; + case HLSL_RESOURCE_DIM_2DARRAY: + case HLSL_RESOURCE_DIM_2DMSARRAY: + case HLSL_RESOURCE_DIM_3D: + case HLSL_RESOURCE_DIM_CUBE: + return 3; + case HLSL_RESOURCE_DIM_CUBEARRAY: + return 4; + default: + assert(0); + return 0; + } +}
enum hlsl_matrix_majority { @@ -113,7 +144,7 @@ struct hlsl_type struct rb_entry scope_entry; enum hlsl_type_class type; enum hlsl_base_type base_type; - enum hlsl_sampler_dim sampler_dim; + enum hlsl_resource_dim resource_dim; const char *name; unsigned int modifiers; unsigned int dimx; @@ -484,7 +515,7 @@ struct hlsl_ctx struct hlsl_type *vector[HLSL_TYPE_LAST_SCALAR + 1][4]; /* matrix[float][2][4] is a float4x2, i.e. dimx = 2, dimy = 4 */ struct hlsl_type *matrix[HLSL_TYPE_LAST_SCALAR + 1][4][4]; - struct hlsl_type *sampler[HLSL_SAMPLER_DIM_MAX + 1]; + struct hlsl_type *sampler[HLSL_RESOURCE_DIM_MAX_SAMPLER + 1]; struct hlsl_type *Void; } builtin_types;
@@ -716,7 +747,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_type *format); +struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_resource_dim dim, struct hlsl_type *format); 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.l b/libs/vkd3d-shader/hlsl.l index caf8fe8f..759c8da5 100644 --- a/libs/vkd3d-shader/hlsl.l +++ b/libs/vkd3d-shader/hlsl.l @@ -134,6 +134,7 @@ Texture3D {return KW_TEXTURE3D; } Texture3DArray {return KW_TEXTURE3DARRAY; } textureCUBE {return KW_TEXTURECUBE; } TextureCube {return KW_TEXTURECUBE; } +TextureCubeArray {return KW_TEXTURECUBEARRAY; } true {return KW_TRUE; } typedef {return KW_TYPEDEF; } uniform {return KW_UNIFORM; } diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index ff35c09e..ddd25904 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -1512,23 +1512,6 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t return statements_list; }
-static unsigned int sampler_dim_count(enum hlsl_sampler_dim dim) -{ - switch (dim) - { - case HLSL_SAMPLER_DIM_1D: - return 1; - case HLSL_SAMPLER_DIM_2D: - return 2; - case HLSL_SAMPLER_DIM_3D: - case HLSL_SAMPLER_DIM_CUBE: - return 3; - default: - assert(0); - return 0; - } -} - struct find_function_call_args { const struct parse_initializer *params; @@ -1831,7 +1814,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct hlsl_ir_load *object_load;
if (object_type->type != HLSL_CLASS_OBJECT || object_type->base_type != HLSL_TYPE_TEXTURE - || object_type->sampler_dim == HLSL_SAMPLER_DIM_GENERIC) + || object_type->resource_dim == HLSL_RESOURCE_DIM_GENERIC) { struct vkd3d_string_buffer *string;
@@ -1845,9 +1828,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl /* Only HLSL_IR_LOAD can return an object. */ object_load = hlsl_ir_load(object);
- if (!strcmp(name, "Load")) + if (!strcmp(name, "Load") + && object_type->resource_dim != HLSL_RESOURCE_DIM_CUBE + && object_type->resource_dim != HLSL_RESOURCE_DIM_CUBEARRAY) { - const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim); + const unsigned int sampler_dim = sampler_dim_count(object_type->resource_dim); struct hlsl_ir_resource_load *load; struct hlsl_ir_node *coords;
@@ -1862,7 +1847,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
/* +1 for the mipmap level */ if (!(coords = add_implicit_conversion(ctx, instrs, params->args[0], - hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + 1), loc))) + hlsl_get_vector_type(ctx, HLSL_TYPE_INT, (sampler_dim==4)? 4 : sampler_dim + 1), loc))) return false;
if (!(load = hlsl_new_resource_load(ctx, object_type->e.resource_format, HLSL_RESOURCE_LOAD, @@ -1871,9 +1856,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl list_add_tail(instrs, &load->node.entry); return true; } - else if (!strcmp(name, "Sample")) + else if (!strcmp(name, "Sample") + && object_type->resource_dim != HLSL_RESOURCE_DIM_2DMS + && object_type->resource_dim != HLSL_RESOURCE_DIM_2DMSARRAY) { - const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim); + const unsigned int sampler_dim = sampler_dim_count(object_type->resource_dim); const struct hlsl_type *sampler_type; struct hlsl_ir_resource_load *load; struct hlsl_ir_load *sampler_load; @@ -1890,7 +1877,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
sampler_type = params->args[0]->data_type; if (sampler_type->type != HLSL_CLASS_OBJECT || sampler_type->base_type != HLSL_TYPE_SAMPLER - || sampler_type->sampler_dim != HLSL_SAMPLER_DIM_GENERIC) + || sampler_type->resource_dim != HLSL_RESOURCE_DIM_GENERIC) { struct vkd3d_string_buffer *string;
@@ -1959,7 +1946,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl struct parse_colon_attribute colon_attribute; struct hlsl_semantic semantic; enum hlsl_buffer_type buffer_type; - enum hlsl_sampler_dim sampler_dim; + enum hlsl_resource_dim resource_dim; }
%token KW_BLENDSTATE @@ -2024,6 +2011,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl %token KW_TEXTURE3D %token KW_TEXTURE3DARRAY %token KW_TEXTURECUBE +%token KW_TEXTURECUBEARRAY %token KW_TRUE %token KW_TYPEDEF %token KW_UNIFORM @@ -2134,7 +2122,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
%type <reg_reservation> register_opt
-%type <sampler_dim> texture_type +%type <resource_dim> texture_type
%type <semantic> semantic
@@ -2554,21 +2542,40 @@ input_mod: texture_type: KW_TEXTURE1D { - $$ = HLSL_SAMPLER_DIM_1D; + $$ = HLSL_RESOURCE_DIM_1D; } | KW_TEXTURE2D { - $$ = HLSL_SAMPLER_DIM_2D; + $$ = HLSL_RESOURCE_DIM_2D; } | KW_TEXTURE3D { - $$ = HLSL_SAMPLER_DIM_3D; + $$ = HLSL_RESOURCE_DIM_3D; } | KW_TEXTURECUBE { - $$ = HLSL_SAMPLER_DIM_CUBE; + $$ = HLSL_RESOURCE_DIM_CUBE; + } + | KW_TEXTURE1DARRAY + { + $$ = HLSL_RESOURCE_DIM_1DARRAY; + } + | KW_TEXTURE2DARRAY + { + $$ = HLSL_RESOURCE_DIM_2DARRAY; + } + | KW_TEXTURE2DMS + { + $$ = HLSL_RESOURCE_DIM_2DMS; + } + | KW_TEXTURE2DMSARRAY + { + $$ = HLSL_RESOURCE_DIM_2DMSARRAY; + } + | KW_TEXTURECUBEARRAY + { + $$ = HLSL_RESOURCE_DIM_CUBEARRAY; } - type: KW_VECTOR '<' type ',' C_INTEGER '>' { @@ -2634,27 +2641,27 @@ type: } | KW_SAMPLER { - $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_GENERIC]; + $$ = ctx->builtin_types.sampler[HLSL_RESOURCE_DIM_GENERIC]; } | KW_SAMPLER1D { - $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_1D]; + $$ = ctx->builtin_types.sampler[HLSL_RESOURCE_DIM_1D]; } | KW_SAMPLER2D { - $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_2D]; + $$ = ctx->builtin_types.sampler[HLSL_RESOURCE_DIM_2D]; } | KW_SAMPLER3D { - $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_3D]; + $$ = ctx->builtin_types.sampler[HLSL_RESOURCE_DIM_3D]; } | KW_SAMPLERCUBE { - $$ = ctx->builtin_types.sampler[HLSL_SAMPLER_DIM_3D]; + $$ = ctx->builtin_types.sampler[HLSL_RESOURCE_DIM_3D]; } | KW_TEXTURE { - $$ = hlsl_new_texture_type(ctx, HLSL_SAMPLER_DIM_GENERIC, NULL); + $$ = hlsl_new_texture_type(ctx, HLSL_RESOURCE_DIM_GENERIC, NULL); } | texture_type { diff --git a/libs/vkd3d-shader/hlsl_sm1.c b/libs/vkd3d-shader/hlsl_sm1.c index 4ff552bc..d40d572e 100644 --- a/libs/vkd3d-shader/hlsl_sm1.c +++ b/libs/vkd3d-shader/hlsl_sm1.c @@ -179,39 +179,39 @@ static D3DXPARAMETER_TYPE sm1_base_type(const struct hlsl_type *type) case HLSL_TYPE_PIXELSHADER: return D3DXPT_PIXELSHADER; case HLSL_TYPE_SAMPLER: - switch (type->sampler_dim) + switch (type->resource_dim) { - case HLSL_SAMPLER_DIM_1D: + case HLSL_RESOURCE_DIM_1D: return D3DXPT_SAMPLER1D; - case HLSL_SAMPLER_DIM_2D: + case HLSL_RESOURCE_DIM_2D: return D3DXPT_SAMPLER2D; - case HLSL_SAMPLER_DIM_3D: + case HLSL_RESOURCE_DIM_3D: return D3DXPT_SAMPLER3D; - case HLSL_SAMPLER_DIM_CUBE: + case HLSL_RESOURCE_DIM_CUBE: return D3DXPT_SAMPLERCUBE; - case HLSL_SAMPLER_DIM_GENERIC: + case HLSL_RESOURCE_DIM_GENERIC: return D3DXPT_SAMPLER; default: - ERR("Invalid dimension %#x.\n", type->sampler_dim); + ERR("Invalid dimension %#x.\n", type->resource_dim); } break; case HLSL_TYPE_STRING: return D3DXPT_STRING; case HLSL_TYPE_TEXTURE: - switch (type->sampler_dim) + switch (type->resource_dim) { - case HLSL_SAMPLER_DIM_1D: + case HLSL_RESOURCE_DIM_1D: return D3DXPT_TEXTURE1D; - case HLSL_SAMPLER_DIM_2D: + case HLSL_RESOURCE_DIM_2D: return D3DXPT_TEXTURE2D; - case HLSL_SAMPLER_DIM_3D: + case HLSL_RESOURCE_DIM_3D: return D3DXPT_TEXTURE3D; - case HLSL_SAMPLER_DIM_CUBE: + case HLSL_RESOURCE_DIM_CUBE: return D3DXPT_TEXTURECUBE; - case HLSL_SAMPLER_DIM_GENERIC: + case HLSL_RESOURCE_DIM_GENERIC: return D3DXPT_TEXTURE; default: - ERR("Invalid dimension %#x.\n", type->sampler_dim); + ERR("Invalid dimension %#x.\n", type->resource_dim); } break; case HLSL_TYPE_VERTEXSHADER: diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c0c26f80..1691f59e 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -283,17 +283,17 @@ static D3D_SHADER_VARIABLE_TYPE sm4_base_type(const struct hlsl_type *type) case HLSL_TYPE_PIXELSHADER: return D3D_SVT_PIXELSHADER; case HLSL_TYPE_SAMPLER: - switch (type->sampler_dim) + switch (type->resource_dim) { - case HLSL_SAMPLER_DIM_1D: + case HLSL_RESOURCE_DIM_1D: return D3D_SVT_SAMPLER1D; - case HLSL_SAMPLER_DIM_2D: + case HLSL_RESOURCE_DIM_2D: return D3D_SVT_SAMPLER2D; - case HLSL_SAMPLER_DIM_3D: + case HLSL_RESOURCE_DIM_3D: return D3D_SVT_SAMPLER3D; - case HLSL_SAMPLER_DIM_CUBE: + case HLSL_RESOURCE_DIM_CUBE: return D3D_SVT_SAMPLERCUBE; - case HLSL_SAMPLER_DIM_GENERIC: + case HLSL_RESOURCE_DIM_GENERIC: return D3D_SVT_SAMPLER; default: assert(0); @@ -302,18 +302,22 @@ static D3D_SHADER_VARIABLE_TYPE sm4_base_type(const struct hlsl_type *type) case HLSL_TYPE_STRING: return D3D_SVT_STRING; case HLSL_TYPE_TEXTURE: - switch (type->sampler_dim) + switch (type->resource_dim) { - case HLSL_SAMPLER_DIM_1D: + case HLSL_RESOURCE_DIM_1D: return D3D_SVT_TEXTURE1D; - case HLSL_SAMPLER_DIM_2D: + case HLSL_RESOURCE_DIM_2D: return D3D_SVT_TEXTURE2D; - case HLSL_SAMPLER_DIM_3D: + case HLSL_RESOURCE_DIM_3D: return D3D_SVT_TEXTURE3D; - case HLSL_SAMPLER_DIM_CUBE: + case HLSL_RESOURCE_DIM_CUBE: return D3D_SVT_TEXTURECUBE; - case HLSL_SAMPLER_DIM_GENERIC: + case HLSL_RESOURCE_DIM_GENERIC: return D3D_SVT_TEXTURE; + case HLSL_RESOURCE_DIM_1DARRAY: + return D3D_SVT_TEXTURE1DARRAY; + case HLSL_RESOURCE_DIM_2DARRAY: + return D3D_SVT_TEXTURE2DARRAY; default: assert(0); } @@ -424,20 +428,34 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type
static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *type) { - switch (type->sampler_dim) + if (type->base_type == HLSL_TYPE_TEXTURE) { - case HLSL_SAMPLER_DIM_1D: - return D3D_SRV_DIMENSION_TEXTURE1D; - case HLSL_SAMPLER_DIM_2D: - return D3D_SRV_DIMENSION_TEXTURE2D; - case HLSL_SAMPLER_DIM_3D: - return D3D_SRV_DIMENSION_TEXTURE3D; - case HLSL_SAMPLER_DIM_CUBE: - return D3D_SRV_DIMENSION_TEXTURECUBE; - default: - assert(0); - return D3D_SRV_DIMENSION_UNKNOWN; + switch (type->resource_dim) + { + case HLSL_RESOURCE_DIM_1D: + return D3D_SRV_DIMENSION_TEXTURE1D; + case HLSL_RESOURCE_DIM_1DARRAY: + return D3D_SRV_DIMENSION_TEXTURE1DARRAY; + case HLSL_RESOURCE_DIM_2D: + return D3D_SRV_DIMENSION_TEXTURE2D; + case HLSL_RESOURCE_DIM_2DARRAY: + return D3D_SRV_DIMENSION_TEXTURE2DARRAY; + case HLSL_RESOURCE_DIM_2DMS: + return D3D_SRV_DIMENSION_TEXTURE2DMS; + case HLSL_RESOURCE_DIM_2DMSARRAY: + return D3D_SRV_DIMENSION_TEXTURE2DMSARRAY; + case HLSL_RESOURCE_DIM_3D: + return D3D_SRV_DIMENSION_TEXTURE3D; + case HLSL_RESOURCE_DIM_CUBE: + return D3D_SRV_DIMENSION_TEXTURECUBE; + case HLSL_RESOURCE_DIM_CUBEARRAY: + return D3D_SRV_DIMENSION_TEXTURECUBEARRAY; + default: + assert(0); + return D3D_SRV_DIMENSION_UNKNOWN; + } } + assert(0); }
static int sm4_compare_externs(const struct hlsl_ir_var *a, const struct hlsl_ir_var *b) @@ -711,20 +729,34 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
static enum vkd3d_sm4_resource_type sm4_resource_dimension(const struct hlsl_type *type) { - switch (type->sampler_dim) - { - case HLSL_SAMPLER_DIM_1D: - return VKD3D_SM4_RESOURCE_TEXTURE_1D; - case HLSL_SAMPLER_DIM_2D: - return VKD3D_SM4_RESOURCE_TEXTURE_2D; - case HLSL_SAMPLER_DIM_3D: - return VKD3D_SM4_RESOURCE_TEXTURE_3D; - case HLSL_SAMPLER_DIM_CUBE: - return VKD3D_SM4_RESOURCE_TEXTURE_CUBE; - default: - assert(0); - return 0; + if (type->base_type == HLSL_TYPE_TEXTURE) { + switch (type->resource_dim) + { + case HLSL_RESOURCE_DIM_1D: + return VKD3D_SM4_RESOURCE_TEXTURE_1D; + case HLSL_RESOURCE_DIM_2D: + return VKD3D_SM4_RESOURCE_TEXTURE_2D; + case HLSL_RESOURCE_DIM_3D: + return VKD3D_SM4_RESOURCE_TEXTURE_3D; + case HLSL_RESOURCE_DIM_CUBE: + return VKD3D_SM4_RESOURCE_TEXTURE_CUBE; + case HLSL_RESOURCE_DIM_1DARRAY: + return VKD3D_SM4_RESOURCE_TEXTURE_1DARRAY; + case HLSL_RESOURCE_DIM_2DARRAY: + return VKD3D_SM4_RESOURCE_TEXTURE_2DARRAY; + case HLSL_RESOURCE_DIM_2DMS: + return VKD3D_SM4_RESOURCE_TEXTURE_2DMS; + case HLSL_RESOURCE_DIM_2DMSARRAY: + return VKD3D_SM4_RESOURCE_TEXTURE_2DMSARRAY; + case HLSL_RESOURCE_DIM_CUBEARRAY: + return VKD3D_SM4_RESOURCE_TEXTURE_CUBEARRAY; + default: + assert(0); + return 0; + } } + assert(0); + return 0; }
struct sm4_register @@ -1198,6 +1230,7 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf const struct hlsl_deref *resource, const struct hlsl_ir_node *coords) { struct sm4_instruction instr; + unsigned int sampler_dim; unsigned int writemask;
memset(&instr, 0, sizeof(instr)); @@ -1211,23 +1244,11 @@ static void write_sm4_ld(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buf
/* Mipmap level is in the last component in the IR, but needs to be in the W * component in the instruction. */ - switch (resource_type->sampler_dim) - { - case HLSL_SAMPLER_DIM_1D: - instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4); - break; - - case HLSL_SAMPLER_DIM_2D: - instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, Y, X, Z), 4); - break; - - case HLSL_SAMPLER_DIM_3D: - case HLSL_SAMPLER_DIM_CUBE: - break; - - case HLSL_SAMPLER_DIM_GENERIC: - assert(0); - } + sampler_dim = sampler_dim_count(resource_type->resource_dim); + if (sampler_dim == 1) + instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, X, X, Y), 4); + if (sampler_dim == 2) + instr.srcs[0].swizzle = hlsl_combine_swizzles(instr.srcs[0].swizzle, HLSL_SWIZZLE(X, Y, X, Z), 4);
sm4_register_from_deref(ctx, &instr.srcs[1].reg, &writemask, &instr.srcs[1].swizzle_type, resource, resource_type);
Signed-off-by: Francisco Casas fcasas@codeweavers.com
---
Sorry, it seems I have to add the sign-off before the "---" for it to be parsed.
I realized that the initialization of Texture2DMS, and Texture2DMSArray is not correct on this patch.
These textures require a "number of samples" parameter, as in Gio's branch.
Still, the rest of the patch may be worth considering.
On 12/6/21 12:28, Francisco Casas wrote:
New values for enum hlsl_sampler_dim are added in order to represent dimension types for textures that don't have their analog sampler, like Texture2DArray.
enum hlsl_sampler_dim is then renamed to enum hlsl_resource_dim to convey that it no longer represents just sampler types.
Parsing and initialization of Texture2DArray, Texture2DMS, Texture2DMSArray, and TextureCubeArray is added.
sampler_dim_count() is moved from hlsl.y to hlsl.h since it can be useful in other files, like in write_sm4_ld() in hlsl_sm4.c.
This patch is an alternative to 221390, which proposed to separate sampler_dim into sampler_dim and texture_dim. It will probably be resent after Matteo's batch is reviewed.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
As one can tell from the commit message, this patch does at least two things at once, which is at least one too many ;-)
Personally I'm not sure that "sampler_dim" (or any of the associated names) need to be changed. I may be looking at things with GLSL-coloured glasses, but it seems to me there's no conceptual reason why a sampler couldn't have an array dimension; but rather HLSL just doesn't have a "sample2DArray" keyword.
@@ -1845,9 +1828,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl /* Only HLSL_IR_LOAD can return an object. */ object_load = hlsl_ir_load(object);
- if (!strcmp(name, "Load"))
- if (!strcmp(name, "Load")
&& object_type->resource_dim != HLSL_RESOURCE_DIM_CUBE
&& object_type->resource_dim != HLSL_RESOURCE_DIM_CUBEARRAY) {
const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
const unsigned int sampler_dim = sampler_dim_count(object_type->resource_dim); struct hlsl_ir_resource_load *load; struct hlsl_ir_node *coords;
This should also be a separate patch.
@@ -1862,7 +1847,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
/* +1 for the mipmap level */ if (!(coords = add_implicit_conversion(ctx, instrs, params->args[0],
hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + 1), loc)))
hlsl_get_vector_type(ctx, HLSL_TYPE_INT, (sampler_dim==4)? 4 : sampler_dim + 1), loc))) return false; if (!(load = hlsl_new_resource_load(ctx, object_type->e.resource_format, HLSL_RESOURCE_LOAD,
This seems redundant; with the above hunk we can't hit this path for cube arrays.
@@ -1871,9 +1856,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl list_add_tail(instrs, &load->node.entry); return true; }
- else if (!strcmp(name, "Sample"))
- else if (!strcmp(name, "Sample")
&& object_type->resource_dim != HLSL_RESOURCE_DIM_2DMS
&& object_type->resource_dim != HLSL_RESOURCE_DIM_2DMSARRAY) {
const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
const unsigned int sampler_dim = sampler_dim_count(object_type->resource_dim); const struct hlsl_type *sampler_type; struct hlsl_ir_resource_load *load; struct hlsl_ir_load *sampler_load;
This should also be a separate patch.
@@ -424,20 +428,34 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type
static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *type) {
- switch (type->sampler_dim)
- if (type->base_type == HLSL_TYPE_TEXTURE)
Does this need to be a conditional? Should this just be an assertion instead?
{
case HLSL_SAMPLER_DIM_1D:
return D3D_SRV_DIMENSION_TEXTURE1D;
case HLSL_SAMPLER_DIM_2D:
return D3D_SRV_DIMENSION_TEXTURE2D;
case HLSL_SAMPLER_DIM_3D:
return D3D_SRV_DIMENSION_TEXTURE3D;
case HLSL_SAMPLER_DIM_CUBE:
return D3D_SRV_DIMENSION_TEXTURECUBE;
default:
assert(0);
return D3D_SRV_DIMENSION_UNKNOWN;
switch (type->resource_dim)
{
case HLSL_RESOURCE_DIM_1D:
return D3D_SRV_DIMENSION_TEXTURE1D;
case HLSL_RESOURCE_DIM_1DARRAY:
return D3D_SRV_DIMENSION_TEXTURE1DARRAY;
case HLSL_RESOURCE_DIM_2D:
return D3D_SRV_DIMENSION_TEXTURE2D;
case HLSL_RESOURCE_DIM_2DARRAY:
return D3D_SRV_DIMENSION_TEXTURE2DARRAY;
case HLSL_RESOURCE_DIM_2DMS:
return D3D_SRV_DIMENSION_TEXTURE2DMS;
case HLSL_RESOURCE_DIM_2DMSARRAY:
return D3D_SRV_DIMENSION_TEXTURE2DMSARRAY;
case HLSL_RESOURCE_DIM_3D:
return D3D_SRV_DIMENSION_TEXTURE3D;
case HLSL_RESOURCE_DIM_CUBE:
return D3D_SRV_DIMENSION_TEXTURECUBE;
case HLSL_RESOURCE_DIM_CUBEARRAY:
return D3D_SRV_DIMENSION_TEXTURECUBEARRAY;
default:
assert(0);
return D3D_SRV_DIMENSION_UNKNOWN;
} }
assert(0); }
static int sm4_compare_externs(const struct hlsl_ir_var *a, const struct hlsl_ir_var *b)
@@ -711,20 +729,34 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
static enum vkd3d_sm4_resource_type sm4_resource_dimension(const struct hlsl_type *type) {
- switch (type->sampler_dim)
- {
case HLSL_SAMPLER_DIM_1D:
return VKD3D_SM4_RESOURCE_TEXTURE_1D;
case HLSL_SAMPLER_DIM_2D:
return VKD3D_SM4_RESOURCE_TEXTURE_2D;
case HLSL_SAMPLER_DIM_3D:
return VKD3D_SM4_RESOURCE_TEXTURE_3D;
case HLSL_SAMPLER_DIM_CUBE:
return VKD3D_SM4_RESOURCE_TEXTURE_CUBE;
default:
assert(0);
return 0;
- if (type->base_type == HLSL_TYPE_TEXTURE) {
Same here.
switch (type->resource_dim)
{
case HLSL_RESOURCE_DIM_1D:
return VKD3D_SM4_RESOURCE_TEXTURE_1D;
case HLSL_RESOURCE_DIM_2D:
return VKD3D_SM4_RESOURCE_TEXTURE_2D;
case HLSL_RESOURCE_DIM_3D:
return VKD3D_SM4_RESOURCE_TEXTURE_3D;
case HLSL_RESOURCE_DIM_CUBE:
return VKD3D_SM4_RESOURCE_TEXTURE_CUBE;
case HLSL_RESOURCE_DIM_1DARRAY:
return VKD3D_SM4_RESOURCE_TEXTURE_1DARRAY;
case HLSL_RESOURCE_DIM_2DARRAY:
return VKD3D_SM4_RESOURCE_TEXTURE_2DARRAY;
case HLSL_RESOURCE_DIM_2DMS:
return VKD3D_SM4_RESOURCE_TEXTURE_2DMS;
case HLSL_RESOURCE_DIM_2DMSARRAY:
return VKD3D_SM4_RESOURCE_TEXTURE_2DMSARRAY;
case HLSL_RESOURCE_DIM_CUBEARRAY:
return VKD3D_SM4_RESOURCE_TEXTURE_CUBEARRAY;
default:
assert(0);
return 0;
} }
assert(0);
return 0; }
struct sm4_register
December 7, 2021 2:58 PM, "Zebediah Figura" zfigura@codeweavers.com wrote:
As one can tell from the commit message, this patch does at least two things at once, which is at least one too many ;-)
Acknowledged!
Personally I'm not sure that "sampler_dim" (or any of the associated names) need to be changed. I may be looking at things with GLSL-coloured glasses, but it seems to me there's no conceptual reason why a sampler couldn't have an array dimension; but rather HLSL just doesn't have a "sample2DArray" keyword.
Okay then. After some thought I have been more inclined to think that way too. More because the number of things that have to be changed is significant. At least this experiment helped me to understand on which parts of the codebase sampler_dim is used.
@@ -1845,9 +1828,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl /* Only HLSL_IR_LOAD can return an object. */ object_load = hlsl_ir_load(object);
- if (!strcmp(name, "Load"))
- if (!strcmp(name, "Load")
- && object_type->resource_dim != HLSL_RESOURCE_DIM_CUBE
- && object_type->resource_dim != HLSL_RESOURCE_DIM_CUBEARRAY)
{
- const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
- const unsigned int sampler_dim = sampler_dim_count(object_type->resource_dim);
struct hlsl_ir_resource_load *load; struct hlsl_ir_node *coords;
This should also be a separate patch.
Okay.
@@ -1862,7 +1847,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
/* +1 for the mipmap level */
if (!(coords = add_implicit_conversion(ctx, instrs, params->args[0],
- hlsl_get_vector_type(ctx, HLSL_TYPE_INT, sampler_dim + 1), loc)))
- hlsl_get_vector_type(ctx, HLSL_TYPE_INT, (sampler_dim==4)? 4 : sampler_dim + 1), loc)))
return false;
if (!(load = hlsl_new_resource_load(ctx, object_type->e.resource_format, HLSL_RESOURCE_LOAD,
This seems redundant; with the above hunk we can't hit this path for cube arrays.
Yes, my mistake.
@@ -1871,9 +1856,11 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl list_add_tail(instrs, &load->node.entry); return true; }
- else if (!strcmp(name, "Sample"))
- else if (!strcmp(name, "Sample")
- && object_type->resource_dim != HLSL_RESOURCE_DIM_2DMS
- && object_type->resource_dim != HLSL_RESOURCE_DIM_2DMSARRAY)
{
- const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
- const unsigned int sampler_dim = sampler_dim_count(object_type->resource_dim);
const struct hlsl_type *sampler_type; struct hlsl_ir_resource_load *load; struct hlsl_ir_load *sampler_load;
This should also be a separate patch.
O-ho-kay (I changed the intonation of the Okay to not sound repetitive).
@@ -424,20 +428,34 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type
static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *type)
{
- switch (type->sampler_dim)
- if (type->base_type == HLSL_TYPE_TEXTURE)
Does this need to be a conditional? Should this just be an assertion instead?
I did it because the return type D3D_SRV_DIMENSION had the D3D_SRV_DIMENSION_BUFFER D3D_SRV_DIMENSION_BUFFEREX values for buffer types and because sm4_rdef_resource_dimension() is called from a path that seems could be used for other types than HLSL_TYPE_TEXTURE. But maybe is too soon to care about that, yes, an assertion for now would do.
{
- case HLSL_SAMPLER_DIM_1D:
- return D3D_SRV_DIMENSION_TEXTURE1D;
- case HLSL_SAMPLER_DIM_2D:
- return D3D_SRV_DIMENSION_TEXTURE2D;
- case HLSL_SAMPLER_DIM_3D:
- return D3D_SRV_DIMENSION_TEXTURE3D;
- case HLSL_SAMPLER_DIM_CUBE:
- return D3D_SRV_DIMENSION_TEXTURECUBE;
- default:
- assert(0);
- return D3D_SRV_DIMENSION_UNKNOWN;
- switch (type->resource_dim)
- {
- case HLSL_RESOURCE_DIM_1D:
- return D3D_SRV_DIMENSION_TEXTURE1D;
- case HLSL_RESOURCE_DIM_1DARRAY:
- return D3D_SRV_DIMENSION_TEXTURE1DARRAY;
- case HLSL_RESOURCE_DIM_2D:
- return D3D_SRV_DIMENSION_TEXTURE2D;
- case HLSL_RESOURCE_DIM_2DARRAY:
- return D3D_SRV_DIMENSION_TEXTURE2DARRAY;
- case HLSL_RESOURCE_DIM_2DMS:
- return D3D_SRV_DIMENSION_TEXTURE2DMS;
- case HLSL_RESOURCE_DIM_2DMSARRAY:
- return D3D_SRV_DIMENSION_TEXTURE2DMSARRAY;
- case HLSL_RESOURCE_DIM_3D:
- return D3D_SRV_DIMENSION_TEXTURE3D;
- case HLSL_RESOURCE_DIM_CUBE:
- return D3D_SRV_DIMENSION_TEXTURECUBE;
- case HLSL_RESOURCE_DIM_CUBEARRAY:
- return D3D_SRV_DIMENSION_TEXTURECUBEARRAY;
- default:
- assert(0);
- return D3D_SRV_DIMENSION_UNKNOWN;
- }
}
- assert(0);
}
static int sm4_compare_externs(const struct hlsl_ir_var *a, const struct hlsl_ir_var *b)
@@ -711,20 +729,34 @@ static void write_sm4_rdef(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc)
static enum vkd3d_sm4_resource_type sm4_resource_dimension(const struct hlsl_type *type)
{
- switch (type->sampler_dim)
- {
- case HLSL_SAMPLER_DIM_1D:
- return VKD3D_SM4_RESOURCE_TEXTURE_1D;
- case HLSL_SAMPLER_DIM_2D:
- return VKD3D_SM4_RESOURCE_TEXTURE_2D;
- case HLSL_SAMPLER_DIM_3D:
- return VKD3D_SM4_RESOURCE_TEXTURE_3D;
- case HLSL_SAMPLER_DIM_CUBE:
- return VKD3D_SM4_RESOURCE_TEXTURE_CUBE;
- default:
- assert(0);
- return 0;
- if (type->base_type == HLSL_TYPE_TEXTURE) {
Same here.
Yes, same answer as before.
- switch (type->resource_dim)
- {
- case HLSL_RESOURCE_DIM_1D:
- return VKD3D_SM4_RESOURCE_TEXTURE_1D;
- case HLSL_RESOURCE_DIM_2D:
- return VKD3D_SM4_RESOURCE_TEXTURE_2D;
- case HLSL_RESOURCE_DIM_3D:
- return VKD3D_SM4_RESOURCE_TEXTURE_3D;
- case HLSL_RESOURCE_DIM_CUBE:
- return VKD3D_SM4_RESOURCE_TEXTURE_CUBE;
- case HLSL_RESOURCE_DIM_1DARRAY:
- return VKD3D_SM4_RESOURCE_TEXTURE_1DARRAY;
- case HLSL_RESOURCE_DIM_2DARRAY:
- return VKD3D_SM4_RESOURCE_TEXTURE_2DARRAY;
- case HLSL_RESOURCE_DIM_2DMS:
- return VKD3D_SM4_RESOURCE_TEXTURE_2DMS;
- case HLSL_RESOURCE_DIM_2DMSARRAY:
- return VKD3D_SM4_RESOURCE_TEXTURE_2DMSARRAY;
- case HLSL_RESOURCE_DIM_CUBEARRAY:
- return VKD3D_SM4_RESOURCE_TEXTURE_CUBEARRAY;
- default:
- assert(0);
- return 0;
- }
}
- assert(0);
- return 0;
}
struct sm4_register
I will split the patch and and fix the problems to make (another) batch for sending after Matteo's is reviewed.
Thanks for the patience!
On 12/7/21 13:08, Francisco Casas wrote:
@@ -424,20 +428,34 @@ static D3D_RESOURCE_RETURN_TYPE sm4_resource_format(const struct hlsl_type *type
static D3D_SRV_DIMENSION sm4_rdef_resource_dimension(const struct hlsl_type *type)
{
- switch (type->sampler_dim)
- if (type->base_type == HLSL_TYPE_TEXTURE)
Does this need to be a conditional? Should this just be an assertion instead?
I did it because the return type D3D_SRV_DIMENSION had the D3D_SRV_DIMENSION_BUFFER D3D_SRV_DIMENSION_BUFFEREX values for buffer types and because sm4_rdef_resource_dimension() is called from a path that seems could be used for other types than HLSL_TYPE_TEXTURE. But maybe is too soon to care about that, yes, an assertion for now would do.
Yeah, fair enough. I'm mostly inclined to concur with "too soon to care".
Who knows, we might do something crazy like generalize HLSL_TYPE_TEXTURE to HLSL_TYPE_RESOURCE and store both buffers and textures the same way :-)