Francisco Casas : vkd3d-shader/hlsl: Move sampler_dim_count() to hlsl.h.
Alexandre Julliard
julliard at winehq.org
Wed Feb 9 16:03:04 CST 2022
Module: vkd3d
Branch: master
Commit: ce2454db6dc3f301cc0df5727dda2be717ef99e2
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=ce2454db6dc3f301cc0df5727dda2be717ef99e2
Author: Francisco Casas <fcasas at codeweavers.com>
Date: Thu Jan 27 15:31:22 2022 -0300
vkd3d-shader/hlsl: Move sampler_dim_count() to hlsl.h.
Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.h | 17 +++++++++++++++++
libs/vkd3d-shader/hlsl.y | 23 +++--------------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 5b69186..e9c513e 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -668,6 +668,23 @@ static inline struct hlsl_type *hlsl_get_numeric_type(const struct hlsl_ctx *ctx
return hlsl_get_matrix_type(ctx, base_type, dimx, dimy);
}
+static inline unsigned int hlsl_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;
+ }
+}
+
const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op);
const char *debug_hlsl_type(struct hlsl_ctx *ctx, const struct hlsl_type *type);
const char *debug_hlsl_writemask(unsigned int writemask);
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 5b98b56..d51b56e 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -1513,23 +1513,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;
@@ -1890,7 +1873,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
if (!strcmp(name, "Load"))
{
- const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
+ const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
struct hlsl_ir_resource_load *load;
struct hlsl_ir_node *coords;
@@ -1916,7 +1899,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
}
else if (!strcmp(name, "Sample"))
{
- const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
+ const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
const struct hlsl_type *sampler_type;
struct hlsl_ir_resource_load *load;
struct hlsl_ir_node *offset = NULL;
@@ -1967,7 +1950,7 @@ static bool add_method_call(struct hlsl_ctx *ctx, struct list *instrs, struct hl
else if (!strcmp(name, "Gather") || !strcmp(name, "GatherRed") || !strcmp(name, "GatherBlue")
|| !strcmp(name, "GatherGreen") || !strcmp(name, "GatherAlpha"))
{
- const unsigned int sampler_dim = sampler_dim_count(object_type->sampler_dim);
+ const unsigned int sampler_dim = hlsl_sampler_dim_count(object_type->sampler_dim);
enum hlsl_resource_load_type load_type;
const struct hlsl_type *sampler_type;
struct hlsl_ir_resource_load *load;
More information about the wine-cvs
mailing list