summaryrefslogtreecommitdiff
path: root/source/slang/type-system-shared.h
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-02-23 17:22:36 -0500
committerYong He <yonghe@outlook.com>2018-02-23 17:41:46 -0500
commit5ab20eb2d20d491e258047bd94d9d9d0ac5a5dbf (patch)
treebe054fb8e5767daa3cfe42c51e812f21b6fbdd72 /source/slang/type-system-shared.h
parent706675949e70b17860e9ca514c01461fdf9aa95d (diff)
Refactor IR type system, step 0
Pull BaseType, TextureFlavor and SamplerStateFlavor enums and helper functions into a shared file "type-system-shared.h".
Diffstat (limited to 'source/slang/type-system-shared.h')
-rw-r--r--source/slang/type-system-shared.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/source/slang/type-system-shared.h b/source/slang/type-system-shared.h
new file mode 100644
index 000000000..5316dfa6e
--- /dev/null
+++ b/source/slang/type-system-shared.h
@@ -0,0 +1,77 @@
+#ifndef SLANG_TYPE_SYSTEM_SHARED_H
+#define SLANG_TYPE_SYSTEM_SHARED_H
+
+#include "../../slang.h"
+
+namespace Slang
+{
+ enum class BaseType
+ {
+ Void = 0,
+ Bool,
+ Int,
+ UInt,
+ UInt64,
+ Half,
+ Float,
+ Double,
+ };
+
+ struct TextureFlavor
+ {
+ enum
+ {
+ // Mask for the overall "shape" of the texture
+ ShapeMask = SLANG_RESOURCE_BASE_SHAPE_MASK,
+
+ // Flag for whether the shape has "array-ness"
+ ArrayFlag = SLANG_TEXTURE_ARRAY_FLAG,
+
+ // Whether or not the texture stores multiple samples per pixel
+ MultisampleFlag = SLANG_TEXTURE_MULTISAMPLE_FLAG,
+
+ // Whether or not this is a shadow texture
+ //
+ // TODO(tfoley): is this even meaningful/used?
+ // ShadowFlag = 0x80,
+ };
+
+ enum Shape : uint8_t
+ {
+ Shape1D = SLANG_TEXTURE_1D,
+ Shape2D = SLANG_TEXTURE_2D,
+ Shape3D = SLANG_TEXTURE_3D,
+ ShapeCube = SLANG_TEXTURE_CUBE,
+ ShapeBuffer = SLANG_TEXTURE_BUFFER,
+
+ Shape1DArray = Shape1D | ArrayFlag,
+ Shape2DArray = Shape2D | ArrayFlag,
+ // No Shape3DArray
+ ShapeCubeArray = ShapeCube | ArrayFlag,
+ };
+
+ uint16_t flavor;
+
+ Shape GetBaseShape() const { return Shape(flavor & ShapeMask); }
+ bool isArray() const { return (flavor & ArrayFlag) != 0; }
+ bool isMultisample() const { return (flavor & MultisampleFlag) != 0; }
+ // bool isShadow() const { return (flavor & ShadowFlag) != 0; }
+
+ SlangResourceShape getShape() const { return flavor & 0xFF; }
+ SlangResourceAccess getAccess() const { return (flavor >> 8) & 0xFF; }
+
+ TextureFlavor() = default;
+ TextureFlavor(uint32_t tag) { flavor = (uint16_t)tag; }
+
+ static TextureFlavor create(SlangResourceShape shape, SlangResourceAccess access);
+ };
+
+ enum class SamplerStateFlavor : uint8_t
+ {
+ SamplerState,
+ SamplerComparisonState,
+ };
+
+}
+
+#endif \ No newline at end of file