This function is also moved from hlsl.y to hlsl.h, since it can be useful in other files.
Signed-off-by: Francisco Casas fcasas@codeweavers.com ---
This is done in preparation for changing write_sm4_ld() in hlsl_sm4.c.
Signed-off-by: Francisco Casas fcasas@codeweavers.com --- libs/vkd3d-shader/hlsl.h | 23 +++++++++++++++++++++++ libs/vkd3d-shader/hlsl.y | 17 ----------------- 2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 334610df..927dca02 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -107,6 +107,29 @@ enum hlsl_sampler_dim HLSL_SAMPLER_DIM_MAX = HLSL_SAMPLER_DIM_CUBEARRAY, };
+static inline unsigned int sampler_dim_count(enum hlsl_sampler_dim dim) +{ + switch (dim) + { + case HLSL_SAMPLER_DIM_1D: + return 1; + case HLSL_SAMPLER_DIM_1DARRAY: + case HLSL_SAMPLER_DIM_2D: + case HLSL_SAMPLER_DIM_2DMS: + return 2; + case HLSL_SAMPLER_DIM_2DARRAY: + case HLSL_SAMPLER_DIM_2DMSARRAY: + case HLSL_SAMPLER_DIM_3D: + case HLSL_SAMPLER_DIM_CUBE: + return 3; + case HLSL_SAMPLER_DIM_CUBEARRAY: + return 4; + default: + assert(0); + return 0; + } +} + enum hlsl_matrix_majority { HLSL_COLUMN_MAJOR, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index b7446454..389ff057 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;
On 12/17/21 13:12, Francisco Casas wrote:
This function is also moved from hlsl.y to hlsl.h, since it can be useful in other files.
I would prefer to do that only in the patch where it's actually used.
Is there a reason to make it a static inline function, instead of just linking to it?
December 17, 2021 8:35 PM, "Zebediah Figura (she/her)" zfigura@codeweavers.com wrote:
On 12/17/21 13:12, Francisco Casas wrote:
This function is also moved from hlsl.y to hlsl.h, since it can be useful in other files.
I would prefer to do that only in the patch where it's actually used.
Okay.
Is there a reason to make it a static inline function, instead of just linking to it?
Since this function is small and so closely related to enum hlsl_sampler_dim, I had the feeling that it would be good to keep it close to it.
But I can move it to hlsl.c.
On Mon, Dec 20, 2021 at 7:11 PM Francisco Casas fcasas@codeweavers.com wrote:
December 17, 2021 8:35 PM, "Zebediah Figura (she/her)" zfigura@codeweavers.com wrote:
On 12/17/21 13:12, Francisco Casas wrote:
This function is also moved from hlsl.y to hlsl.h, since it can be useful in other files.
I would prefer to do that only in the patch where it's actually used.
Okay.
Agreed.
Is there a reason to make it a static inline function, instead of just linking to it?
Since this function is small and so closely related to enum hlsl_sampler_dim, I had the feeling that it would be good to keep it close to it.
But I can move it to hlsl.c.
I think it's fine to have it in the header, but either way works.