diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2020-03-09 09:02:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-09 09:02:36 -0700 |
| commit | b1317cd16ab9c827596a28ccf4258ef1bb672d92 (patch) | |
| tree | 4a98d5a6acd6a58230b2dd2a2ea913eda920e4e0 /tests/bugs/vk-structured-buffer-load.hlsl.glsl | |
| parent | 4760829c77a58325fb0533e037b5394c383b3f04 (diff) | |
Yet more definitions moved into the stdlib (#1263)
The only big catch that I ran into with this batch was that I found the `float.getPi()` function was being emitted to the output GLSL even when that function wasn't being used. This seems to have been a latent problem in the earlier PR, but was only surfaced in the tests once a Slang->GLSL test started using another intrinsic that led to the `float : __BuiltinFloatingPointType` witness table being live in the IR.
The fix for the gotcha here was to add a late IR pass that basically empties out all witness tables in the IR, so that functions that are only referenced by witness tables can then be removed as dead code. This pass is something we should *not* apply if/when we start supporting real dynamic dispatch through witness tables, but that is a problem to be solved on another day.
The remaining tricky pieces of this change were:
* Needed to remember to mark functions as target intrinsics on HLSL and/or GLSL as appropriate (hopefully I caught all the cases) so they don't get emitted as source there.
* The `msad4` function in HLSL is very poorly documented, so filling in its definition was tricky. I made my best effort based on how it is described on MSDN, but it is likely that if anybody wants to rely on this function they will need us to vet our results with some tests.
Diffstat (limited to 'tests/bugs/vk-structured-buffer-load.hlsl.glsl')
| -rw-r--r-- | tests/bugs/vk-structured-buffer-load.hlsl.glsl | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl index 016e49b25..8a545ad1e 100644 --- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl +++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl @@ -6,28 +6,42 @@ layout(row_major) uniform; layout(row_major) buffer; #extension GL_NV_ray_tracing : require +#define rcp_tmp _S2 +#define RayData _S3 +#define Attributes _S4 + +#define tmpA _S5 +#define tmpB _S6 +#define tmpC _S7 + layout(std430, binding = 1) readonly buffer _S1 { float _data[]; } gParamBlock_sbuf_0; +float rcp_0(float x_0) +{ + float rcp_tmp = float(1.00000000000000000000) / x_0; + return rcp_tmp; +} + struct RayHitInfoPacked_0 { vec4 PackedHitInfoA_0; }; -rayPayloadInNV RayHitInfoPacked_0 _S2; +rayPayloadInNV RayHitInfoPacked_0 RayData; struct BuiltInTriangleIntersectionAttributes_0 { vec2 barycentrics_0; }; -hitAttributeNV BuiltInTriangleIntersectionAttributes_0 _S3; +hitAttributeNV BuiltInTriangleIntersectionAttributes_0 Attributes; void main() { float HitT_0 = (gl_HitTNV); - _S2.PackedHitInfoA_0.x = HitT_0; + RayData.PackedHitInfoA_0.x = HitT_0; const uint use_rcp_0 = uint(0); @@ -38,9 +52,9 @@ void main() if(bool(use_rcp_1)) { - float _S4 = (1.0/((offsfloat_0))); + float tmpA = rcp_0(offsfloat_0); - _S2.PackedHitInfoA_0.y = _S4; + RayData.PackedHitInfoA_0.y = tmpA; } else @@ -49,16 +63,16 @@ void main() if(use_rcp_1 > uint(0)&&offsfloat_0 == 0.00000000000000000000) { - float _S5 = (inversesqrt((offsfloat_0 + 1.00000000000000000000))); + float tmpB = (inversesqrt((offsfloat_0 + 1.00000000000000000000))); - _S2.PackedHitInfoA_0.y = _S5; + RayData.PackedHitInfoA_0.y = tmpB; } else { - float _S6 = (inversesqrt((offsfloat_0))); + float tmpC = (inversesqrt((offsfloat_0))); - _S2.PackedHitInfoA_0.y = _S6; + RayData.PackedHitInfoA_0.y = tmpC; } |
