From 184dc5cd6998b6277881fae4a68d91de86e2d63f Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 28 Mar 2018 08:17:48 -0700 Subject: Merge from v0.9.15 (#460) * Fix bug when subscripting a type that must be split (#396) The logic was creating a `PairPseudoExpr` as part of a subscript (`operator[]`) operation, but neglecting to fill in its `pairInfo` field, which led to a null-pointer crash further along. * Allow writes to UAV textures (#416) Work on #415 This issue is already fixed in the `v0.10.*` line, but I'm back-porting the fix to `v0.9.*`. The issue here was that the stdlib declarations for texture types were only including the `get` accessor for subscript operations, even if the texture was write-able. I've also included the fixes for other subscript accessors in the stdlib (notably that `OutputPatch` is readable, but not writable, despite what the name seems to imply). * Fix infinite loop in semantic parsing (#424) The code for parsing semantics was looking for a fixed set of tokens to terminate a semantic list, rather than assuming that whenever you don't see a `:` ahead, you probably are done with semantics. This meant that you could get into an infinite loop just with simple mistakes like leaving out a `;`. This change fixes the parser to note infinite loop in this case, and adds a test case to verify the fix. * Expose HLSL `shared` modifier through reflection. (#436) This is a request from Falcor, because the `shared` modifier can be used as a hint to optimize the grouping of parameters for binding. The intention is that `shared` marks shader parameters (including parameter blocks) that will us the same values across many draw calls (e.g., per-frame data, as opposed to per-model or per-instance). The mechanism I'm using here is to provide a general reflection API for exposing the `Modifier`s already attached to declarations. While the only modifier exposed is `shared`, and the only modifier information being exposed is presence/absence, this interface could be extended down the line. --- tests/reflection/shared-modifier.hlsl | 12 +++++++ tests/reflection/shared-modifier.hlsl.expected | 47 ++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/reflection/shared-modifier.hlsl create mode 100644 tests/reflection/shared-modifier.hlsl.expected (limited to 'tests/reflection') diff --git a/tests/reflection/shared-modifier.hlsl b/tests/reflection/shared-modifier.hlsl new file mode 100644 index 000000000..45a1dfac8 --- /dev/null +++ b/tests/reflection/shared-modifier.hlsl @@ -0,0 +1,12 @@ +// shared-modifier.hlsl +//TEST:REFLECTION:-profile ps_5_0 -target hlsl + +// Confirm that we expose the `shared` modifier in reflection data. + +Texture2D t; +shared SamplerState s; + +float4 main(float2 uv : UV) : SV_Target +{ + return t.Sample(s, uv); +} \ No newline at end of file diff --git a/tests/reflection/shared-modifier.hlsl.expected b/tests/reflection/shared-modifier.hlsl.expected new file mode 100644 index 000000000..ddb982177 --- /dev/null +++ b/tests/reflection/shared-modifier.hlsl.expected @@ -0,0 +1,47 @@ +result code = 0 +standard error = { +} +standard output = { +{ + "parameters": [ + { + "name": "t", + "binding": {"kind": "shaderResource", "index": 0}, + "type": { + "kind": "resource", + "baseShape": "texture2D" + } + }, + { + "name": "s", + "shared": true, + "binding": {"kind": "samplerState", "index": 0}, + "type": { + "kind": "samplerState" + } + } + ], + "entryPoints": [ + { + "name": "main", + "stage:": "fragment", + "parameters": [ + { + "name": "uv", + "stage": "fragment", + "binding": {"kind": "varyingInput", "index": 0}, + "semanticName": "UV", + "type": { + "kind": "vector", + "elementCount": 2, + "elementType": { + "kind": "scalar", + "scalarType": "float32" + } + } + } + ] + } + ] +} +} -- cgit v1.2.3