|
| 1 | +// Copyright (C) 2022 - DevSH Graphics Programming Sp. z O.O. |
| 2 | +// This file is part of the "Nabla Engine". |
| 3 | +// For conditions of distribution and use, see copyright notice in nabla.h |
| 4 | +#ifndef _NBL_BUILTIN_HLSL_MACROS_INCLUDED_ |
| 5 | +#define _NBL_BUILTIN_HLSL_MACROS_INCLUDED_ |
| 6 | + |
| 7 | +#define NBL_HLSL_EVAL(X) X |
| 8 | + |
| 9 | +#define NBL_HLSL_EQUAL(X,Y) (NBL_HLSL_EVAL(X)==NBL_HLSL_EVAL(Y)) |
| 10 | +#define NBL_HLSL_NOT_EQUAL(X,Y) (NBL_HLSL_EVAL(X)!=NBL_HLSL_EVAL(Y)) |
| 11 | + |
| 12 | +#define NBL_HLSL_LESS(X,Y) (NBL_HLSL_EVAL(X)<NBL_HLSL_EVAL(Y)) |
| 13 | +#define NBL_HLSL_GREATER(X,Y) (NBL_HLSL_EVAL(X)>NBL_HLSL_EVAL(Y)) |
| 14 | + |
| 15 | +#define NBL_HLSL_IS_NOT_POT(v) (NBL_HLSL_EVAL(v)&(NBL_HLSL_EVAL(v)-1))!=0 |
| 16 | +#define NBL_HLSL_IS_POT(v) (!NBL_HLSL_IS_NOT_POT(v)) |
| 17 | + |
| 18 | +#define NBL_HLSL_CONCAT_IMPL2(X,Y) X ## Y |
| 19 | +#define NBL_HLSL_CONCAT_IMPL(X,Y) NBL_HLSL_CONCAT_IMPL2(X,Y) |
| 20 | +#define NBL_HLSL_CONCATENATE2(X,Y) NBL_HLSL_CONCAT_IMPL(NBL_HLSL_EVAL(X),NBL_HLSL_EVAL(Y)) |
| 21 | +#define NBL_HLSL_CONCATENATE3(X,Y,Z) NBL_HLSL_CONCATENATE2(NBL_HLSL_CONCATENATE2(X,Y),NBL_HLSL_EVAL(Z)) |
| 22 | +#define NBL_HLSL_CONCATENATE4(X,Y,Z,W) NBL_HLSL_CONCATENATE2(NBL_HLSL_CONCATENATE2(X,Y),NBL_HLSL_CONCATENATE2(Z,W)) |
| 23 | + |
| 24 | +#define NBL_HLSL_AND(X,Y) (NBL_HLSL_EVAL(X)&NBL_HLSL_EVAL(Y)) |
| 25 | +#define NBL_HLSL_OR(X,Y) (NBL_HLSL_EVAL(X)|NBL_HLSL_EVAL(Y)) |
| 26 | +#define NBL_HLSL_XOR(X,Y) (NBL_HLSL_EVAL(X)^NBL_HLSL_EVAL(Y)) |
| 27 | + |
| 28 | +#define NBL_HLSL_ADD(X,Y) (NBL_HLSL_EVAL(X)+NBL_HLSL_EVAL(Y)) |
| 29 | +#define NBL_HLSL_SUB(X,Y) (NBL_HLSL_EVAL(X)-NBL_HLSL_EVAL(Y)) |
| 30 | +#define NBL_HLSL_MUL(X,Y) (NBL_HLSL_EVAL(X)*NBL_HLSL_EVAL(Y)) |
| 31 | + |
| 32 | +// https://github.com/google/shaderc/issues/1155 |
| 33 | +// This issue still seems to exist |
| 34 | +// #define NBL_HLSL_MAX(X,Y) (((NBL_HLSL_EVAL(X))>(NBL_HLSL_EVAL(Y))) ? (NBL_HLSL_EVAL(X)):(NBL_HLSL_EVAL(Y))) |
| 35 | +// #define NBL_HLSL_MIN(X,Y) (((NBL_HLSL_EVAL(X))<(NBL_HLSL_EVAL(Y))) ? (NBL_HLSL_EVAL(X)):(NBL_HLSL_EVAL(Y))) |
| 36 | + |
| 37 | +#endif |
0 commit comments