diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-12-20 17:35:10 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-20 17:35:10 -0800 |
| commit | 6f681279d99e72e717bb2b91763b80e570ae725b (patch) | |
| tree | 501c547ff405aa5227a0ad165b9ec371fcd94ef8 /tests/compute | |
| parent | 35318fb2b08c82f80cbd464e93d81ebe719c40be (diff) | |
IR: fixes for subscript accessors (#322)
* IR: fixes for subscript accessors
Fixes #320
This is a bunch of fixes for handling of `__subscript` operations on builtin types (notably `RWStructuredBuffer` and `StructuredBuffer` at this point).
- Automatically add a `GetterDecl` to any subscript decalratio was declithout any accessors. This avoids hitting a null- dereference in the emit logic.
- Add a notion of a `RefAccessor` (declared with `ref`) as a peer to getters and setters. The idea is that a `ref` accessor returns a pointer to the element data, so that it can be used for both getting and setting values. This is closer to the behavior of `RWStructuredBuffer` element access in HLSL.
- Fixes for dealing with "access chains" where there might be a combination of a subscript (where the is a `get` and `set` but no `ref`) and member access, so that we have to read the base value into a temp, modify it, and then write it back.
- This logic is still a bit of a mess, so we will eventually want to take a more consistent pass over this to deal with how we "materialize" values for setters.
- Update `RWStructuredBuffer` to have a `ref` accessor, and then fix up the IR tests to handle the new opcode that I added for it.
- Note: I didn't handle this as an intrinsic simply because the `tests/ir/*` tests aren't really set up to handle builtins with ugly mangled names.
* Fixup: type error in VM for buffer element ref
I was using the result type of the op as the element type for computing the element address, but the result type is a pointer to the real element type.
This caused test failures on 64-bit platforms, where the stride of the buffer in the `ir/factorial` test needs to be 4.
The fix is to assume the result type is a pointer, and extract the pointed-to type out of that.
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/write-structured-buffer-field.slang | 19 | ||||
| -rw-r--r-- | tests/compute/write-structured-buffer-field.slang.expected.txt | 32 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/compute/write-structured-buffer-field.slang b/tests/compute/write-structured-buffer-field.slang new file mode 100644 index 000000000..b824644b2 --- /dev/null +++ b/tests/compute/write-structured-buffer-field.slang @@ -0,0 +1,19 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir + +//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32], stride=32):dxbinding(0),glbinding(0),out + +struct S +{ + int4 a; + int4 b; +}; + +RWStructuredBuffer<S> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + outputBuffer[tid].b.y = outputBuffer[0].a.x; +}
\ No newline at end of file diff --git a/tests/compute/write-structured-buffer-field.slang.expected.txt b/tests/compute/write-structured-buffer-field.slang.expected.txt new file mode 100644 index 000000000..475b4f578 --- /dev/null +++ b/tests/compute/write-structured-buffer-field.slang.expected.txt @@ -0,0 +1,32 @@ +1 +2 +3 +4 +5 +1 +7 +8 +9 +A +B +C +D +1 +F +10 +11 +12 +13 +14 +15 +1 +17 +18 +19 +1A +1B +1C +1D +1 +1F +20 |
