summaryrefslogtreecommitdiff
path: root/source/slang/hlsl.meta.slang
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-09-11 09:33:46 -0700
committerTim Foley <tfoley@nvidia.com>2017-09-11 14:06:02 -0700
commit2055d540c5dd420448a6924d784d5aed0efcd93d (patch)
tree29167b8abb5001cd3c2803807ec5c8eb3bc2329f /source/slang/hlsl.meta.slang
parent80fb7b05b851e645d821331fdbbcea1add686c9a (diff)
Support IR-based codegen for a few more examples.
The main interesting change here is around support for lowering of calls to "subscript" operations (what a C++ programmer would think of as `operator[]`). An important infrastructure change here was to add an explicit AST-node representation for a "static member expression" which we use whenever a member is looked up in a type as opposed to a value. The implementation of this probably isn't robust yet, but it turns out to be important to be able to tell such cases apart.
Diffstat (limited to 'source/slang/hlsl.meta.slang')
-rw-r--r--source/slang/hlsl.meta.slang21
1 files changed, 18 insertions, 3 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 3b4b85b91..7c7d3fda0 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -38,7 +38,8 @@ __generic<T> __magic_type(HLSLStructuredBufferType) struct StructuredBuffer
__intrinsic_op T Load(int location);
__intrinsic_op T Load(int location, out uint status);
- __intrinsic_op __subscript(uint index) -> T;
+ __intrinsic_op(bufferLoad)
+ __subscript(uint index) -> T;
};
__generic<T> __magic_type(HLSLConsumeStructuredBufferType) struct ConsumeStructuredBuffer
@@ -173,7 +174,13 @@ __magic_type(HLSLRWByteAddressBufferType) struct RWByteAddressBuffer
uint4 value);
};
-__generic<T> __magic_type(HLSLRWStructuredBufferType) struct RWStructuredBuffer
+__generic<T>
+__magic_type(HLSLRWStructuredBufferType)
+__intrinsic_type(${{
+ // TODO: we really need a simple way to write an "expression splice"
+ sb << kIROp_readWriteStructuredBufferType;
+}})
+struct RWStructuredBuffer
{
__intrinsic_op uint DecrementCounter();
@@ -186,7 +193,15 @@ __generic<T> __magic_type(HLSLRWStructuredBufferType) struct RWStructuredBuffer
__intrinsic_op T Load(int location);
__intrinsic_op T Load(int location, out uint status);
- __intrinsic_op __subscript(uint index) -> T { get; set; }
+ __intrinsic_op
+ __subscript(uint index) -> T
+ {
+ __intrinsic_op(bufferLoad)
+ get;
+
+ __intrinsic_op(bufferStore)
+ set;
+ }
};
__generic<T> __magic_type(HLSLPointStreamType) struct PointStream