summaryrefslogtreecommitdiff
path: root/prelude
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-09-24 14:30:12 -0700
committerGitHub <noreply@github.com>2020-09-24 14:30:12 -0700
commitb72353ec3fe529237828cacbe710233d31eb4837 (patch)
tree2aec9af97efe52b722cb730f8db1c44641e58c62 /prelude
parent150218bec9e992d32833dd9a0c1396a4d7c12b7e (diff)
Enable default cpp prelude. (#1560)
* Enable default cpp prelude. * Print the "#include" line as a normal source if the file does not exist. * Bug fix * Fix. * Fix c++ prelude header. * Remove unnecessary fopen call.
Diffstat (limited to 'prelude')
-rw-r--r--prelude/slang-cpp-prelude.h6
-rw-r--r--prelude/slang-cpp-scalar-intrinsics.h6
-rw-r--r--prelude/slang-cpp-types.h46
3 files changed, 48 insertions, 10 deletions
diff --git a/prelude/slang-cpp-prelude.h b/prelude/slang-cpp-prelude.h
index b00f34d8f..23619d102 100644
--- a/prelude/slang-cpp-prelude.h
+++ b/prelude/slang-cpp-prelude.h
@@ -1,8 +1,6 @@
#ifndef SLANG_CPP_PRELUDE_H
#define SLANG_CPP_PRELUDE_H
-#include "../slang.h"
-
// Because the signiture of isnan, isfinite, and is isinf changed in C++, we use the macro
// to use the version in the std namespace.
// https://stackoverflow.com/questions/39130040/cmath-hides-isnan-in-math-h-in-c14-c11
@@ -42,7 +40,7 @@
#include "slang-cpp-scalar-intrinsics.h"
// TODO(JS): Hack! Output C++ code from slang can copy uninitialized variables.
-#if SLANG_VC
+#if defined(_MSC_VER)
# pragma warning(disable : 4700)
#endif
@@ -66,4 +64,4 @@ gfx_PipelineState_0* buildPipelineState_0(gfx_ShaderProgram_0* _0, gfx_Renderer_
void dispatchComputation_0(gfx_Renderer_0* _0, gfx_PipelineState_0* _1, gfx_PipelineLayout_0* _2, gfx_DescriptorSet_0* _3, uint32_t _4, uint32_t _5, uint32_t _6);
gfx_BufferResource_0* unconvertBuffer_0(RWStructuredBuffer<float> _0);
-#endif \ No newline at end of file
+#endif
diff --git a/prelude/slang-cpp-scalar-intrinsics.h b/prelude/slang-cpp-scalar-intrinsics.h
index ec3882cfb..7ee62dbc6 100644
--- a/prelude/slang-cpp-scalar-intrinsics.h
+++ b/prelude/slang-cpp-scalar-intrinsics.h
@@ -1,13 +1,15 @@
#ifndef SLANG_PRELUDE_SCALAR_INTRINSICS_H
#define SLANG_PRELUDE_SCALAR_INTRINSICS_H
-#include "../slang.h"
-
#if SLANG_PROCESSOR_X86_64 && SLANG_VC
// If we have visual studio and 64 bit processor, we can assume we have popcnt, and can include x86 intrinsics
# include <intrin.h>
#endif
+#ifndef SLANG_FORCE_INLINE
+# define SLANG_FORCE_INLINE inline
+#endif
+
#ifdef SLANG_PRELUDE_NAMESPACE
namespace SLANG_PRELUDE_NAMESPACE {
#endif
diff --git a/prelude/slang-cpp-types.h b/prelude/slang-cpp-types.h
index 69e69f8df..b0a9c68f6 100644
--- a/prelude/slang-cpp-types.h
+++ b/prelude/slang-cpp-types.h
@@ -1,8 +1,6 @@
#ifndef SLANG_PRELUDE_CPP_TYPES_H
#define SLANG_PRELUDE_CPP_TYPES_H
-
-#include "../slang.h"
-
+#include <stdint.h>
#ifndef SLANG_PRELUDE_ASSERT
# ifdef _DEBUG
# define SLANG_PRELUDE_ASSERT(VALUE) assert(VALUE)
@@ -11,6 +9,10 @@
# endif
#endif
+#ifndef SLANG_FORCE_INLINE
+# define SLANG_FORCE_INLINE inline
+#endif
+
#ifdef SLANG_PRELUDE_NAMESPACE
namespace SLANG_PRELUDE_NAMESPACE {
#endif
@@ -294,6 +296,42 @@ struct SamplerComparisonState
ISamplerComparisonState* state;
};
+#ifndef SLANG_RESOURCE_SHAPE
+# define SLANG_RESOURCE_SHAPE
+typedef unsigned int SlangResourceShape;
+enum
+{
+ SLANG_RESOURCE_BASE_SHAPE_MASK = 0x0F,
+
+ SLANG_RESOURCE_NONE = 0x00,
+
+ SLANG_TEXTURE_1D = 0x01,
+ SLANG_TEXTURE_2D = 0x02,
+ SLANG_TEXTURE_3D = 0x03,
+ SLANG_TEXTURE_CUBE = 0x04,
+ SLANG_TEXTURE_BUFFER = 0x05,
+
+ SLANG_STRUCTURED_BUFFER = 0x06,
+ SLANG_BYTE_ADDRESS_BUFFER = 0x07,
+ SLANG_RESOURCE_UNKNOWN = 0x08,
+ SLANG_ACCELERATION_STRUCTURE = 0x09,
+
+ SLANG_RESOURCE_EXT_SHAPE_MASK = 0xF0,
+
+ SLANG_TEXTURE_FEEDBACK_FLAG = 0x10,
+ SLANG_TEXTURE_ARRAY_FLAG = 0x40,
+ SLANG_TEXTURE_MULTISAMPLE_FLAG = 0x80,
+
+ SLANG_TEXTURE_1D_ARRAY = SLANG_TEXTURE_1D | SLANG_TEXTURE_ARRAY_FLAG,
+ SLANG_TEXTURE_2D_ARRAY = SLANG_TEXTURE_2D | SLANG_TEXTURE_ARRAY_FLAG,
+ SLANG_TEXTURE_CUBE_ARRAY = SLANG_TEXTURE_CUBE | SLANG_TEXTURE_ARRAY_FLAG,
+
+ SLANG_TEXTURE_2D_MULTISAMPLE = SLANG_TEXTURE_2D | SLANG_TEXTURE_MULTISAMPLE_FLAG,
+ SLANG_TEXTURE_2D_MULTISAMPLE_ARRAY =
+ SLANG_TEXTURE_2D | SLANG_TEXTURE_MULTISAMPLE_FLAG | SLANG_TEXTURE_ARRAY_FLAG,
+};
+#endif
+
//
struct TextureDimensions
{
@@ -393,7 +431,7 @@ struct TextureDimensions
}
}
- SlangResourceShape shape;
+ uint32_t shape;
uint32_t width, height, depth;
uint32_t numberOfLevels;
uint32_t arrayElementCount; ///< For array types, 0 otherwise