summaryrefslogtreecommitdiff
path: root/source/slang/hlsl.meta.slang
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-03-08 12:35:00 -0800
committerGitHub <noreply@github.com>2018-03-08 12:35:00 -0800
commita22b7520745334ecef3cbd920a0331f01c905935 (patch)
treef5ecf29f957f6b40f3fb5a4f987b2a1d00dd3bed /source/slang/hlsl.meta.slang
parented718ba1048ef856efbf0d02902e4d60f173b207 (diff)
Cleanups on slang-generate (#437)
* Cleanups on slang-generate There is nothing too significant in these changes, but I'm trying to get things in place so that we can: - Clean up the stdlib code to do less explicit `StringBuilder` operations and instead to use more of the "template engine" approach - Start using slang-generate for code other than the slang stdlib, so that we can generate more of our boilerplate. The main new functionality here is that in a template/meta file, you can now enclose an expression in `$(...)` to indicate that is should be spliced into the result. E.g. instead of: class ${{ sb << someClassName; }} { ... } We can now write: class $(someClassName) { ... } The other bit of new functionality is support for a whole-line statement escape, so that instead of: ${{ for( auto a : someCollection ) { }} void $(a)() { ... } ${{ } }} We can instead write: $: for(auto a : someCollection) { void $(a)() { ... } $: } I haven't yet tried to use that functionality in the stdlib meta-code, but doing so would be an obvious next step. * Fixup: change some $P to $p The capitalization on some of the GLSL intrinsic mappings got messed up during a find-and-replace operation when removing the double `$` that used to be required to escape things.
Diffstat (limited to 'source/slang/hlsl.meta.slang')
-rw-r--r--source/slang/hlsl.meta.slang20
1 files changed, 6 insertions, 14 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 03b48e805..15579e512 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -31,10 +31,7 @@ __magic_type(HLSLByteAddressBufferType) struct ByteAddressBuffer
__generic<T>
__magic_type(HLSLStructuredBufferType)
-__intrinsic_type(${{
- // TODO: we really need a simple way to write an "expression splice"
- sb << kIROp_structuredBufferType;
-}})
+__intrinsic_type($(kIROp_structuredBufferType))
struct StructuredBuffer
{
void GetDimensions(
@@ -181,10 +178,7 @@ __magic_type(HLSLRWByteAddressBufferType) struct RWByteAddressBuffer
__generic<T>
__magic_type(HLSLRWStructuredBufferType)
-__intrinsic_type(${{
- // TODO: we really need a simple way to write an "expression splice"
- sb << kIROp_readWriteStructuredBufferType;
-}})
+__intrinsic_type($(kIROp_readWriteStructuredBufferType))
struct RWStructuredBuffer
{
uint DecrementCounter();
@@ -265,7 +259,7 @@ __target_intrinsic(glsl, "bool($0)")
bool any(T x);
__generic<T : __BuiltinType, let N : int>
-__target_intrinsic(glsl, "any(bvec$$N0($0))")
+__target_intrinsic(glsl, "any(bvec$N0($0))")
bool any(vector<T,N> x);
__generic<T : __BuiltinType, let N : int, let M : int>
@@ -1053,7 +1047,6 @@ __generic<T : __BuiltinType, let N : int, let M : int> matrix<T,N,M> WaveReadLan
typedef Texture2D texture2D;
${{{{
-
// Component-wise multiplication ops
for(auto op : binaryOps)
{
@@ -1109,14 +1102,14 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa)
sb << "void GetDimensions(out uint dim);\n";
- sb << "__target_intrinsic(glsl, \"texelFetch($$P, $1)$$z\")\n";
+ sb << "__target_intrinsic(glsl, \"texelFetch($P, $1)$z\")\n";
sb << "T Load(int location);\n";
sb << "T Load(int location, out uint status);\n";
sb << "__subscript(uint index) -> T {\n";
- sb << "__target_intrinsic(glsl, \"texelFetch($$P, int($1))$$z\") get;\n";
+ sb << "__target_intrinsic(glsl, \"texelFetch($P, int($1))$z\") get;\n";
if (kBaseBufferAccessLevels[aa].access != SLANG_RESOURCE_ACCESS_READ)
{
@@ -1127,5 +1120,4 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa)
sb << "};\n";
}
-
-}}}} \ No newline at end of file
+}}}}