diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-12-07 13:31:06 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-07 13:31:06 -0800 |
| commit | 135eaff6b892fc91a398714ddcf7ef377cd4cccb (patch) | |
| tree | e69f30a4fadfdb834ea141c1ec9efc862ccc70d3 /tests/vkray | |
| parent | b0c2423f00b910f2f4d5010e6a04114112e294fd (diff) | |
Change how buffers are emitted (#741)
* Change how buffers are emitted
This is a change with a lot of pieces, which can't always be separated out cleanly. I'm going to walk through them in what I hope is a logical order.
The main goal of this change was to allow arrays of structured buffers to translate to Vulkan. Consider two declarations of structured buffers in HLSL/Slang:
```hlsl
StructuredBuffer<X> single;
StructuredBuffer<Y> multiple[10];
```
The current translation logic was handling `single` by translating it into an *unnamed* GLSL `buffer` block like:
```glsl
layout(std430)
buffer _S1
{
X single[];
};
```
That syntax allows an expression like `single[i]` in Slang to be translated simply as `single[i]` in GLSL.
But that naive translating doesn't work for `multiple`, since we need to declare a array of blocks in GLSL, which requires giving the whole thing a name:
```glsl
layout(std430)
buffer _S2
{
Y _data[];
} multiple[10];
```
Now a reference to `multiple[i][j]` in Slang needs to become `multiple[i]._data[j]` in GLSL.
To avoid having way too many special cases around single structured buffers vs. arrays, it makes sense to allows emit things in the latter form, so that we instead lower `single` as:
```glsl
layout(std430)
buffer _S1
{
X _data[];
} single;
```
So that now a reference to `single[i]` becomes `single._data[i]` in GLSL.
Most of that can be handled in the standard library translation of the structured buffer indexing operations.
The only wrinkle there is that there were some *old* special-case instructions in the IR intended to handle buffer load/store operations (these were added back when I was trying to keep the "VM" path working). These aren't really needed to have structured-buffer operations work; they can be handled as ordinary functions as far as the stdlib is concerned. I removed the old instructions.
Along the way, it became clear that a few other cases follow the same pattern. Byte-addressed buffers are an obvious case. We were lowering HLSL/Slang:
```hlsl
ByteAddressBuffer b;
...
uint x = b.Load(0);
```
to GLSL like:
```glsl
layout(std430)
buffer _S1
{
uint b[];
};
...
uint x = b[0];
```
That logic would fail for arrays the same way that the structured buffer case was failing. The fix is the same: use named `buffer` blocks and then introduce an explicit `_data` field:
```glsl
layout(std430)
buffer _S1
{
uint _data[];
} b;
...
uint x = b._data[0];
```
Just like with structured buffers, all of the VK translation for operations on byte-addressed buffers can be implemented directly in teh stdlib, so once the emit logic was changed it was just a matter of adding `._data` to a bunch of VK tranlsations.
It turns out that arrays of constant buffers have more or less the same problem, and furthermore we have some problems with any code that directly uses the modern HLSL `ConstantBuffer<T>` type.
Note: the emit logic around constant buffers sometimes refers to "parameter groups" because that is being used in the compiler as a catch-all term for constant buffers, texture buffers, and parameter blocks.
The existing code was going out of its way to reproduce the way that constant buffer declarations are implicitly referenced in HLSL:
```hlsl
cbuffer C { float f; }
...
float tmp = f; // No reference to `C` here
```
This can be seen in the emit logic with the `isDerefBaseImplicit` function, which is used to take the internal IR representation for a reference to `f` (which is closer to the expression `(*C).f` or `C->f`) and leave off any reference to `C` so that we emit just `f`.
That kind of logic just flat out doesn't work in some important cases. Arrays of constant buffers are a clear one:
```hlsl
ConstantBuffer<X> cbArray[3];
...
X x = cbArray[0];
```
There is no way to translate that to an ordinary `cbuffer` declaration at all. The same problem can be created without arrays, though:
```hlsl
ConstantBuffer<X> singleCB;
...
X x = singleCB;
```
The current strategy for translating constant buffers was translating `singleCB` into a `cbuffer` declaration that reproduced the fields of `X` as its members, which just wouldn't work:
```hlsl
cbuffer singleCB
{
float f; // field of `X`
}
...
X x = singleCB; // ERROR: there is nothing named `singleCB` in this HLSL
```
The new strategy is more consistent. We still generate a `cbuffer` declaration for a single constant buffer, but we always give it a single field of the chosen element type:
```hlsl
cbuffer singleCB
{
X singleCB;
}
...
X x = singleCB; // this works fine!
```
And in the array case we generate code that uses the explicit `ConstantBuffer<T>` type:
```hlsl
ConstantBuffer<X> cbArray[3];
...
X x = cbArray[0];
```
The GLSL output is more complicated because unlike with HLSL there is no implicit conversion from a uniform block to its element type (there is no notion of an element type). The array case thus needs a `_data` field similar to what we do for structured buffers:
```glsl
layout(std140)
uniform _S3
{
X _data;
} cbArray[3];
...
X x = cbArray[0]._data;
```
And then the non-array case needs to have a similar `_data` field for consistency:
```glsl
layout(std140)
uniform _S1
{
X _data;
} singleCB;
...
X x = singleCB._data;
```
This is handled by inserting the necessary reference to `_data` whenever we dereference a constant buffer, either as part of a load instruction (loading from the whole CB as a pointer), or an `IRFieldAddress` instruction which forms a pointer into the CB (e.g., `&(singleCB->f)` becomes `singleCB._data.f`).
The current emit logic handles `ParameterBlock<X>` differently from `ConstantBuffer<X>`, but really only to allow parameter blocks to be explicitly named in the output, while constant buffers were left implicit by default. Thus the only difference was a legacy one (from back when trying to exactly reproduce the HLSL text we got as input was considered an important goal), and the new approach to emitting constant buffers would get rid of it.
I removed the separate logic for emitting `ParameterBlock<X>` and just let the handling for constant buffers deal with it.
Note that any resource types inside of a `ParameterBlock<X>` would have been moved out as part of legalization, so that a parameter block is 100% equivalent to a constant buffer when it comes time to emit code.
Unsurprisingly, changing the way we generate HLSL and GLSL output for all these buffer types meant that any tests that were directly comparing the output of `slangc` against `fxc`, `dxc`, or `glslang` broke.
The basic approach to fixing the breakage in GLSL tests was to update the GLSL baseline to reflect the new output startegy. In some cases I used macros to name the various `_S<digits>` temporaries so that future renaming will hopefully be easier (it would be great if we auto-generated temporary names with a bit more context). There was one GLSL test (`tests/bugs/vk-structured-buffer-binding`) that was using raw GLSL expected output, and this was changed to use a GLSL baseline to generate SPIR-V for comparison.
For HLSL tests we were sometimes running the same input file through `slangc` and `fxc`/`dxc`, and in these cases I macro-ized the various `cbuffer` declarations to generate different declarations depending on the compiler.
I completely dropped the tests coming from the D3D SDK because they aren't providing much coverage, and updating them would change them so far from the original code that the purported benefit (using a body of existing shaders) would be lost.
I also dropped the explicit matrix layout qualifiers in the `matrix-layout` test because the new output strategy breaks those for GLSL (you can't put matrix layout qualifiers on `struct` fields, and now the body of every constant buffer is inside a `struct`). This isn't as big of a loss as it seems, because our handling of those qualifiers wasn't really right to begin with. Slang users should only be setting the matrix layout mode globally (and we should probably switch to error out on the explicit qualifiers for now).
The other thing that got dropped is tests involving `packoffset` modifiers.
Slang already warns that it doesn't support these, and the way they were used in the test cases is actually misleading. For the binding/layout-related tests, the goal was to show that Slang reproduces the same layout as fxc, in which case explicitly enforcing a layout via `packoffset` seems like cheating (are we sure we enforced the layout fxc would have produced?). The real reason was that Slang used to emit explicit `packoffset` on *every* field of a `cbuffer` it would output, because of an `fxc` bug where you couldn't use `register` on textures/samplers declared inside a `cbuffer` unless *every* field in the `cbuffer` used a `register` or `packoffset` modifier. Slang hasn't required that behavior in a while because it now splits textures and samplers, and the one test case where we needed `packoffset` to work around the `fxc` bug in the baseline HLSL has been macro-ified even more to work around the bug.
The amount of churn in the test cases is unfortunate, but it continues to point at the weakness of any testing strategy that checks for exact equivalent between Slang's output and that of other compilers. We need to keep working to replace these tests with better alternatives.
In `check.cpp` there is logic to perform implicit dereferencing, so that if you write `obj.f` where `obj` is a `ConstantBuffer<X>` (or some other "pointer-like" type) and `f` is a field in `X`, then this effectively translates as `(*obj).f`. That is, we dereference the value of type `ConstantBuffer<X>` to get a value of type `X`, and then refer to the field of the `X` value.
There was a problem where the logic to insert that kind of implicit dereference operation was using a reference (`auto& type = ...`) for the type of the expression being dereferenced, and then clobbering it. This would mean that an expression of type `ConstantBuffer<X>` would have its type overwritten to be just `X` and then codegen would break later on.
I'm not sure how we haven't run into that before.
The `array-of-buffers` test case was added to confirm that we now support arrays of constant, structured, and byte-address buffers for both DXIL and SPIR-V output.
Okay, so that was a lot of stuff, but hopefully it is clear how this all works to make the output of the compiler more consistent and explicit, while also supporting the required new functionality.
* fixup: review feedback
Diffstat (limited to 'tests/vkray')
| -rw-r--r-- | tests/vkray/anyhit.slang.glsl | 6 | ||||
| -rw-r--r-- | tests/vkray/callable-caller.slang.glsl | 40 | ||||
| -rw-r--r-- | tests/vkray/closesthit.slang.glsl | 58 | ||||
| -rw-r--r-- | tests/vkray/intersection.slang.glsl | 62 | ||||
| -rw-r--r-- | tests/vkray/raygen.slang.glsl | 152 |
5 files changed, 204 insertions, 114 deletions
diff --git a/tests/vkray/anyhit.slang.glsl b/tests/vkray/anyhit.slang.glsl index 43fd29e01..07789cdbd 100644 --- a/tests/vkray/anyhit.slang.glsl +++ b/tests/vkray/anyhit.slang.glsl @@ -10,8 +10,8 @@ struct Params_0 layout(binding = 0) layout(std140) uniform _S1 { - Params_0 gParams_0; -}; + Params_0 _data; +} gParams_0; layout(binding = 1) uniform texture2D gParams_alphaMap_0; @@ -35,7 +35,7 @@ void main() { SphereHitAttributes_0 _S4 = _S2; - if(bool(gParams_0.mode_0)) + if(bool(gParams_0._data.mode_0)) { float val_0 = textureLod( sampler2D(gParams_alphaMap_0, gParams_sampler_0), diff --git a/tests/vkray/callable-caller.slang.glsl b/tests/vkray/callable-caller.slang.glsl index 2704e6720..b0d174381 100644 --- a/tests/vkray/callable-caller.slang.glsl +++ b/tests/vkray/callable-caller.slang.glsl @@ -4,16 +4,26 @@ layout(row_major) uniform; layout(row_major) buffer; #extension GL_NV_ray_tracing : require +#define tmp_ubo _S1 +#define tmp_launchid _S2 +#define tmp_luanchidf _S3 +#define tmp_launchsize _S4 +#define tmp_launchpos _S5 +#define tmp_shaderidx _S6 +#define tmp_payload _S7 +#define tmp_launchid2 _S8 + struct SLANG_ParameterGroup_C_0 { uint shaderIndex_0; }; layout(binding = 0) -layout(std140) uniform C_0 +layout(std140) +uniform tmp_ubo { - uint shaderIndex_0; -}; + SLANG_ParameterGroup_C_0 _data; +} C_0; struct MaterialPayload_0 { @@ -43,25 +53,25 @@ void main() MaterialPayload_0 payload_1; payload_1.albedo_0 = vec4(0); - uvec3 _S1 = gl_LaunchIDNV; - vec2 _S2 = vec2(_S1.xy); + uvec3 tmp_launchid = gl_LaunchIDNV; + vec2 tmp_luanchidf = vec2(tmp_launchid.xy); - uvec3 _S3 = gl_LaunchSizeNV; - vec2 _S4 = _S2 / vec2(_S3.xy); + uvec3 tmp_launchsize = gl_LaunchSizeNV; + vec2 tmp_launchpos = tmp_luanchidf / vec2(tmp_launchsize.xy); - payload_1.uv_0 = _S4; + payload_1.uv_0 = tmp_launchpos; - uint _S5 = shaderIndex_0; + uint tmp_shaderidx = C_0._data.shaderIndex_0; - MaterialPayload_0 _S6; - _S6 = payload_1; - CallShader_0(_S5, _S6); - payload_1 = _S6; + MaterialPayload_0 tmp_payload; + tmp_payload = payload_1; + CallShader_0(tmp_shaderidx, tmp_payload); + payload_1 = tmp_payload; - uvec3 _S7 = gl_LaunchIDNV; + uvec3 tmp_launchid2 = gl_LaunchIDNV; imageStore( gImage_0, - ivec2(_S7.xy), + ivec2(tmp_launchid2.xy), payload_1.albedo_0); return; } diff --git a/tests/vkray/closesthit.slang.glsl b/tests/vkray/closesthit.slang.glsl index a056b7809..79fd3afbe 100644 --- a/tests/vkray/closesthit.slang.glsl +++ b/tests/vkray/closesthit.slang.glsl @@ -2,50 +2,70 @@ #version 460 #extension GL_NV_ray_tracing : require -layout(shaderRecordNV) -buffer ShaderRecord_0 +#define tmp_shaderrecord _S1 +#define tmp_colors _S2 +#define tmp_hitattrs _S3 +#define tmp_payload _S4 +#define tmp_localattrs _S5 +#define tmp_customidx _S6 +#define tmp_instanceid _S7 +#define tmp_add_0 _S8 +#define tmp_primid _S9 +#define tmp_add_1 _S10 +#define tmp_hitkind _S11 +#define tmp_hitt _S12 +#define tmp_tmin _S13 + +struct SLANG_ParameterGroup_ShaderRecord_0 { - uint shaderRecordID_0; + uint shaderRecordID_0; }; -layout(std430, binding = 0) buffer _S1 +layout(shaderRecordNV) +buffer tmp_shaderrecord { - vec4 colors_0[]; -}; + SLANG_ParameterGroup_ShaderRecord_0 _data; +} ShaderRecord_0; + +layout(std430, binding = 0) buffer tmp_colors +{ + vec4 _data[]; +} colors_0; struct BuiltInTriangleIntersectionAttributes_0 { vec2 barycentrics_0; }; -hitAttributeNV BuiltInTriangleIntersectionAttributes_0 _S2; + +hitAttributeNV BuiltInTriangleIntersectionAttributes_0 tmp_hitattrs; struct ReflectionRay_0 { vec4 color_0; }; -rayPayloadInNV ReflectionRay_0 _S3; +rayPayloadInNV ReflectionRay_0 tmp_payload; void main() { - BuiltInTriangleIntersectionAttributes_0 _S4 = _S2; + BuiltInTriangleIntersectionAttributes_0 tmp_localattrs = tmp_hitattrs; - uint _S5 = gl_InstanceCustomIndexNV; - uint _S6 = gl_InstanceID; + uint tmp_customidx = gl_InstanceCustomIndexNV; + uint tmp_instanceid = gl_InstanceID; - uint _S7 = _S5 + _S6; - uint _S8 = gl_PrimitiveID; + uint tmp_add_0 = tmp_customidx + tmp_instanceid; + uint tmp_primid = gl_PrimitiveID; - uint _S9 = _S7 + _S8; - uint _S10 = gl_HitKindNV; + uint tmp_add_1 = tmp_add_0 + tmp_primid; + uint tmp_hitkind = gl_HitKindNV; - vec4 color_1 = colors_0[_S9 + _S10 + shaderRecordID_0]; + vec4 color_1 = colors_0._data[tmp_add_1 + tmp_hitkind + ShaderRecord_0._data.shaderRecordID_0]; - float _S11 = gl_HitTNV; - float _S12 = gl_RayTminNV; + float tmp_hitt = gl_HitTNV; + float tmp_tmin = gl_RayTminNV; - _S3.color_0 = color_1 * (_S11 - _S12); + tmp_payload.color_0 = color_1 * (tmp_hitt - tmp_tmin); return; } diff --git a/tests/vkray/intersection.slang.glsl b/tests/vkray/intersection.slang.glsl index cfa53efa7..09d7e63a5 100644 --- a/tests/vkray/intersection.slang.glsl +++ b/tests/vkray/intersection.slang.glsl @@ -3,19 +3,37 @@ #extension GL_NV_ray_tracing : require +#define tmp_ubo _S1 +#define tmp_reportHit _S2 +#define tmp_origin _S3 +#define tmp_direction _S4 +#define tmp_tmin _S5 +#define tmp_tmax _S6 +#define tmp_ray _S7 +#define tmp_sphere _S8 +#define tmp_thit _S9 +#define tmp_hitattrs _S10 +#define tmp_dithit _S11 +#define tmp_reportresult _S12 + struct Sphere_0 { vec3 position_0; float radius_0; }; -layout(binding = 0) -layout(std140) -uniform U_0 +struct SLANG_ParameterGroup_U_0 { Sphere_0 gSphere_0; }; +layout(binding = 0) +layout(std140) +uniform tmp_ubo +{ + SLANG_ParameterGroup_U_0 _data; +} U_0; + struct RayDesc_0 { vec3 Origin_0; @@ -45,40 +63,40 @@ hitAttributeNV SphereHitAttributes_0 a_0; bool ReportHit_0(float tHit_1, uint hitKind_0, SphereHitAttributes_0 attributes_0) { a_0 = attributes_0; - bool _S1 = reportIntersectionNV(tHit_1, hitKind_0); - return _S1; + bool tmp_reportHit = reportIntersectionNV(tHit_1, hitKind_0); + return tmp_reportHit; } void main() { RayDesc_0 ray_1; - vec3 _S2 = gl_ObjectRayOriginNV; - ray_1.Origin_0 = _S2; - vec3 _S3 = gl_ObjectRayDirectionNV; + vec3 tmp_origin = gl_ObjectRayOriginNV; + ray_1.Origin_0 = tmp_origin; - ray_1.Direction_0 = _S3; - float _S4 = gl_RayTminNV; + vec3 tmp_direction = gl_ObjectRayDirectionNV; + ray_1.Direction_0 = tmp_direction; - ray_1.TMin_0 = _S4; - float _S5 = gl_RayTmaxNV; + float tmp_tmin = gl_RayTminNV; + ray_1.TMin_0 = tmp_tmin; - ray_1.TMax_0 = _S5; + float tmp_tmax = gl_RayTmaxNV; + ray_1.TMax_0 = tmp_tmax; - RayDesc_0 _S6 = ray_1; + RayDesc_0 tmp_ray = ray_1; - Sphere_0 _S7 = gSphere_0; + Sphere_0 tmp_sphere = U_0._data.gSphere_0; - float _S8; - SphereHitAttributes_0 _S9; - bool _S10 = rayIntersectsSphere_0(_S6, _S7, _S8, _S9); + float tmp_thit; + SphereHitAttributes_0 tmp_hitattrs; + bool tmp_dithit = rayIntersectsSphere_0(tmp_ray, tmp_sphere, tmp_thit, tmp_hitattrs); - float tHit_2 = _S8; - SphereHitAttributes_0 attrs_1 = _S9; + float tHit_2 = tmp_thit; + SphereHitAttributes_0 attrs_1 = tmp_hitattrs; - if(_S10) + if(tmp_dithit) { - bool _S11 = ReportHit_0(tHit_2, (uint((0))), attrs_1); + bool tmp_reportresult = ReportHit_0(tHit_2, (uint((0))), attrs_1); } return; diff --git a/tests/vkray/raygen.slang.glsl b/tests/vkray/raygen.slang.glsl index 512215a73..f65053ecf 100644 --- a/tests/vkray/raygen.slang.glsl +++ b/tests/vkray/raygen.slang.glsl @@ -1,10 +1,46 @@ //TEST_IGNORE_FILE: #version 460 +layout(row_major) uniform; + #extension GL_NV_ray_tracing : require #define TRACING_EPSILON 1e-6 +#define tmp_ubo _S1 +#define tmp_saturate _S2 +#define tmp_launchID_x _S3 +#define tmp_add_x _S4 +#define tmp_launchSize_x _S5 +#define tmp_div_x _S6 +#define tmp_launchID_y _S7 +#define tmp_add_y _S8 +#define tmp_launchSize_y _S9 +#define tmp_div_y _S10 +#define tmp_tex_pos _S11 +#define tmp_tex_nrm _S12 +#define tmp_light_invDist _S13 +#define tmp_trace_A _S14 +#define tmp_trace_B _S15 +#define tmp_trace_C _S16 +#define tmp_trace_D _S17 +#define tmp_trace_E _S18 +#define tmp_trace_ray _S19 +#define tmp_trace_payload _S20 +#define tmp_cmp _S21 +#define tmp_color _S22 +#define tmp_dot _S23 +#define tmp_sat _S24 +#define tmp_trace2_A _S25 +#define tmp_trace2_B _S26 +#define tmp_trace2_C _S27 +#define tmp_trace2_D _S28 +#define tmp_trace2_E _S29 +#define tmp_trace2_ray _S30 +#define tmp_trace2_payload _S31 +#define tmp_storeIdx _S32 + + layout(binding = 0) uniform texture2D samplerPosition_0; layout(binding = 2) uniform sampler sampler_0; layout(binding = 1) uniform texture2D samplerNormal_0; @@ -17,15 +53,20 @@ struct Light_0 #define NUM_LIGHTS 17 -layout(binding = 3) -layout(std140) uniform ubo_0 +struct Uniforms_0 { Light_0 light_0; vec4 viewPos_0; - layout(row_major) mat4x4 view_0; - layout(row_major) mat4x4 model_0; + mat4x4 view_0; + mat4x4 model_0; }; +layout(binding = 3) +layout(std140) uniform tmp_ubo +{ + Uniforms_0 _data; +} ubo_0; + layout(binding = 5) uniform accelerationStructureNV as_0; struct ShadowRay_0 @@ -79,8 +120,8 @@ void TraceRay_0( float saturate_0(float x_0) { - float _S1 = clamp(x_0, float(0), float(1)); - return _S1; + float tmp_saturate = clamp(x_0, float(0), float(1)); + return tmp_saturate; } void TraceRay_1( @@ -114,27 +155,28 @@ void main() { float atten_0; - uvec3 _S2 = gl_LaunchIDNV; - float _S3 = float(_S2.x) + 0.5; - uvec3 _S4 = gl_LaunchSizeNV; - float _S5 = _S3 / float(_S4.x); - uvec3 _S6 = gl_LaunchIDNV; - float _S7 = float(_S6.y) + 0.5; - uvec3 _S8 = gl_LaunchSizeNV; - float _S9 = _S7 / float(_S8.y); - vec2 inUV_0 = vec2(_S5, _S9); + uvec3 tmp_launchID_x = gl_LaunchIDNV; + float tmp_add_x = float(tmp_launchID_x.x) + 0.5; + uvec3 tmp_launchSize_x = gl_LaunchSizeNV; + float tmp_div_x = tmp_add_x / float(tmp_launchSize_x.x); + + uvec3 tmp_launchID_y = gl_LaunchIDNV; + float tmp_add_y = float(tmp_launchID_y.y) + 0.5; + uvec3 tmp_launchSize_y = gl_LaunchSizeNV; + float tmp_div_y = tmp_add_y / float(tmp_launchSize_y.y); + vec2 inUV_0 = vec2(tmp_div_x, tmp_div_y); - vec4 _S10 = texture(sampler2D(samplerPosition_0, sampler_0), inUV_0); - vec3 P_0 = _S10.xyz; + vec4 tmp_tex_pos = texture(sampler2D(samplerPosition_0, sampler_0), inUV_0); + vec3 P_0 = tmp_tex_pos.xyz; - vec4 _S11 = texture(sampler2D(samplerNormal_0, sampler_0), inUV_0); - vec3 N_0 = _S11.xyz * 2.0 - 1.0; + vec4 tmp_tex_nrm = texture(sampler2D(samplerNormal_0, sampler_0), inUV_0); + vec3 N_0 = tmp_tex_nrm.xyz * 2.0 - 1.0; - vec3 lightDelta_0 = light_0.position_0.xyz - P_0; + vec3 lightDelta_0 = ubo_0._data.light_0.position_0.xyz - P_0; float lightDist_0 = length(lightDelta_0); vec3 L_0 = normalize(lightDelta_0); - float _S12 = 1.0 / (lightDist_0 * lightDist_0); + float tmp_light_invDist = 1.0 / (lightDist_0 * lightDist_0); RayDesc_0 ray_0; ray_0.Origin_0 = P_0; @@ -144,47 +186,47 @@ void main() ShadowRay_0 shadowRay_0; shadowRay_0.hitDistance_0 = float(0); - const uint _S13 = uint(1); - const uint _S14 = uint(0xFF); - const uint _S15 = uint(0); - const uint _S16 = uint(0); - const uint _S17 = uint(2); - - RayDesc_0 _S18 = ray_0; - ShadowRay_0 _S19; - _S19 = shadowRay_0; - TraceRay_0(as_0, _S13, _S14, _S15, _S16, _S17, _S18, _S19); - shadowRay_0 = _S19; - - bool _S20 = shadowRay_0.hitDistance_0 < lightDist_0; + const uint tmp_trace_A = uint(1); + const uint tmp_trace_B = uint(0xFF); + const uint tmp_trace_C = uint(0); + const uint tmp_trace_D = uint(0); + const uint tmp_trace_E = uint(2); + + RayDesc_0 tmp_trace_ray = ray_0; + ShadowRay_0 tmp_trace_payload; + tmp_trace_payload = shadowRay_0; + TraceRay_0(as_0, tmp_trace_A, tmp_trace_B, tmp_trace_C, tmp_trace_D, tmp_trace_E, tmp_trace_ray, tmp_trace_payload); + shadowRay_0 = tmp_trace_payload; + + bool tmp_cmp = shadowRay_0.hitDistance_0 < lightDist_0; ReflectionRay_0 reflectionRay_0; - if(_S20) + if(tmp_cmp) { atten_0 = (0.00000000000000000000); } else { - atten_0 = _S12; + atten_0 = tmp_light_invDist; } - vec3 _S21 = light_0.color_0.xyz; - float _S22 = dot(N_0, L_0); - float _S23 = saturate_0(_S22); - vec3 color_2 = (_S21 * _S23) * atten_0; - - const uint _S24 = uint(1); - const uint _S25 = uint(255); - const uint _S26 = uint(0); - const uint _S27 = uint(0); - const uint _S28 = uint(2); - RayDesc_0 _S29 = ray_0; - ReflectionRay_0 _S30; - _S30 = reflectionRay_0; - TraceRay_1(as_0, _S24, _S25, _S26, _S27, _S28, _S29, _S30); - - vec3 color_3 = color_2 + _S30.color_1; - - uvec3 _S31 = gl_LaunchIDNV; - imageStore(outputImage_0, ivec2(uvec2(ivec2(_S31.xy))), vec4(color_3, 1.0)); + vec3 tmp_color = ubo_0._data.light_0.color_0.xyz; + float tmp_dot = dot(N_0, L_0); + float tmp_sat = saturate_0(tmp_dot); + vec3 color_2 = (tmp_color * tmp_sat) * atten_0; + + const uint tmp_trace2_A = uint(1); + const uint tmp_trace2_B = uint(255); + const uint tmp_trace2_C = uint(0); + const uint tmp_trace2_D = uint(0); + const uint tmp_trace2_E = uint(2); + RayDesc_0 tmp_trace2_ray = ray_0; + ReflectionRay_0 tmp_trace2_payload; + tmp_trace2_payload = reflectionRay_0; + TraceRay_1(as_0, tmp_trace2_A, tmp_trace2_B, tmp_trace2_C, tmp_trace2_D, tmp_trace2_E, tmp_trace2_ray, tmp_trace2_payload); + + vec3 color_3 = color_2 + tmp_trace2_payload.color_1; + + uvec3 tmp_storeIdx = gl_LaunchIDNV; + imageStore(outputImage_0, ivec2(uvec2(ivec2(tmp_storeIdx.xy))), vec4(color_3, 1.0)); return; } |
