Files
larp/shaders/replace/32ed072b9f845048.compute.hlsl

160 lines
8.0 KiB
HLSL

// 32ed072b9f845048, compute: LaserLightShadowRaytracing.
//
// The layer's translation of the console program with its query sites as host ray queries (the translator's
// substitution of the walks, emit/sites.rs, by the program's entry in emit/sites/table.rs), turned into
// HLSL (dxil-spirv, then SPIRV-Cross) with its bindings restored as
// the translation makes them (README "Bindings"): heap views through ResourceDescriptorHeap typed as the
// translation's handles, at the slots it reads from the table lists (t252 space1), with this host's view
// heap clamps (null slot 999999); user data b0 space0, 12 dwords as the translation without a table entry
// numbers them (the substituted translation numbers every dword the code reads the same); each RayQuery
// with the flags the DXIL allocates it with; [WaveSize(32)] [numthreads(32, 1, 1)]; the structure views in
// 32ed072b9f845048.compute.views (view 0 at t248 space1, table at root parameter 1 dword 8). Every name is
// a number of the decompile. Each TraceRayInline is marked with its site.
//
// The reading of the sites (the comments of the program's entry in emit/sites/table.rs):
//
// LaserLightShadowRaytracing (wave32, 32-bit node tests: the top level walked by the
// whole wave together, the bottom level per lane). Per thread a ray from a light's
// origin along its normalised direction with t max from the light's record; the output
// is t + 0.04 where a triangle was committed, else the largest float. Closest hit: a
// commit keeps the triangle's node pointer and shortens t max to its t, and the walk
// goes on.
//
// Site 1 (entry 0x170):
// Structure view at table +0x20 (s[12:15], loaded at 0x74); the root pointer
// loaded at 0xc4 from header +48 into a scalar (a root not above 0 skips the walk
// as a miss, 0xec). Entered at 0x170, the loop head, by falling in from the
// direction's setup (0x16c) and by back edges from inside the walk; leaves to
// 0xcc8. The walk keeps EXEC as at E (each narrowing is put back before the walk
// goes on or leaves). Top-level node test at 0x1c8 (descriptor base from the
// view), bottom-level node test at 0x880. Instance mask: +48 against 0xd5000000
// (0x3bc): 0xd5. The cull multiplier at 0x7f0 is 1: cull back faces. No opaque
// test on the triangle path: force opaque. A triangle is taken at 0 <= t < t max
// (0xaec, 0xaf8): t min 0; it sets v7 to its node pointer (0 before the walk) and
// v4 to t. v14 counts iterations from 0 (0x180, 0x894); the code after X takes
// a count past 0xfffe as a hit.
#include "view_heap_layout.hlsli"
ByteAddressBuffer table_lists : register(t252, space1);
ByteAddressBuffer view_shifts : register(t253, space1);
cbuffer _36_38 : register(b0, space0)
{
float4 _38_m0[3] : packoffset(c0);
};
// The host top level of structure view 0 (table at root parameter 1, dword 8; site 1).
uniform RaytracingAccelerationStructure _32 : register(t248, space1);
// The views the code takes from the view heap by index, typed as the translation's handles.
Buffer<float4> heap_Buffer_float4(uint i) { Buffer<float4> r = ResourceDescriptorHeap[i]; return r; }
ByteAddressBuffer heap_ByteAddressBuffer(uint i) { ByteAddressBuffer r = ResourceDescriptorHeap[i]; return r; }
RWByteAddressBuffer heap_RWByteAddressBuffer(uint i) { RWByteAddressBuffer r = ResourceDescriptorHeap[i]; return r; }
static uint3 gl_WorkGroupID;
static uint gl_LocalInvocationIndex;
struct SPIRV_Cross_Input
{
uint3 gl_WorkGroupID : SV_GroupID;
uint gl_LocalInvocationIndex : SV_GroupIndex;
};
static RayQuery<RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES> _241;
uint spvPackHalf2x16(float2 value)
{
uint2 Packed = f32tof16(value);
return Packed.x | (Packed.y << 16);
}
float2 spvUnpackHalf2x16(uint value)
{
return f16tof32(uint2(value & 0xffff, value >> 16));
}
void comp_main()
{
uint4 _51 = asuint(_38_m0[1u]);
uint _56 = WaveReadLaneFirst(gl_LocalInvocationIndex);
uint _64 = _51.y;
uint _67 = ((gl_WorkGroupID.x + _51.z) << 5u) + (((_56 & 4294967264u) + WaveGetLaneIndex()) % 32u);
uint _264;
if (0u != (asuint(heap_Buffer_float4(min(asuint(asfloat(table_lists.Load<uint>((min(((_64 >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0))), NULL_SLOT)).Load(min((_67 >> 5u), 134217727u)).x) & (1u << (_67 & 31u))))
{
uint _108 = min((((_51.x + 160u) >> 5u) << 2u), 2147483584u);
uint _113 = asuint(asfloat(table_lists.Load<uint>((_108 >> 2u) * 4 + 0)));
uint _114 = min(_113, NULL_SLOT);
uint _125 = asuint(asfloat(view_shifts.Load<uint>((min((min(_113, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _126 = _67 * 512u;
uint _128 = _126 + _125;
uint _132 = min(((_128 < _125) ? _126 : _128), 2147483584u) >> 2u;
float4 _145 = asfloat(uint4(heap_ByteAddressBuffer(_114).Load<uint>(_132 * 4 + 0), heap_ByteAddressBuffer(_114).Load<uint>((_132 + 1u) * 4 + 0), heap_ByteAddressBuffer(_114).Load<uint>((_132 + 2u) * 4 + 0), heap_ByteAddressBuffer(_114).Load<uint>((_132 + 3u) * 4 + 0)));
float _146 = _145.x;
float _147 = _145.y;
float _148 = _145.z;
float2 _156 = spvUnpackHalf2x16((asuint(_145.w) >> 16u) & 65535u);
float _157 = _156.x;
uint _159 = _126 + 20u;
uint _165 = asuint(asfloat(table_lists.Load<uint>((_108 >> 2u) * 4 + 0)));
uint _173 = asuint(asfloat(view_shifts.Load<uint>((min((min(_165, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _174 = _159 + _173;
uint _177 = min(_165, NULL_SLOT);
uint _180 = min(((_174 < _173) ? _159 : _174), 2147483584u) >> 2u;
float2 _188 = asfloat(uint2(heap_ByteAddressBuffer(_177).Load<uint>(_180 * 4 + 0), heap_ByteAddressBuffer(_177).Load<uint>((_180 + 1u) * 4 + 0)));
uint _190 = asuint(_188.x);
float2 _194 = spvUnpackHalf2x16(_190 >> 16u);
float _195 = _194.x;
float2 _198 = spvUnpackHalf2x16(_190);
float _199 = _198.x;
float2 _201 = spvUnpackHalf2x16(asuint(_188.y));
float _202 = _201.x;
float _204 = rsqrt(mad(_202, _202, mad(_199, _199, mad(_195, _195, 0.0f))));
float _205 = mad(_204, _199, 0.0f);
float _206 = mad(_204, _195, 0.0f);
float _207 = mad(_204, _202, 0.0f);
bool _251;
float _253;
if (((((((0.0f <= _157) && (!(isnan(_146) || isnan(_146)))) && (!(isnan(_147) || isnan(_147)))) && (!(isnan(_148) || isnan(_148)))) && (!(isnan(_205) || isnan(_205)))) && (!(isnan(_206) || isnan(_206)))) && (!(isnan(_207) || isnan(_207))))
{
RayDesc _1ident = {float3(_146, _147, _148), 0.0f, float3(_205, _206, _207), _157};
// Site 1 (console entry 0x170): structure view 0, flags RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES, mask 0xd5.
_241.TraceRayInline(_32, 17u, 213u, _1ident);
bool _247;
do
{
_247 = _241.Proceed();
} while (_247);
uint _248 = _241.CommittedStatus();
float _250 = _241.CommittedRayT();
_251 = _248 == 1u;
_253 = _250;
}
else
{
_251 = false;
_253 = 0.0f;
}
precise float _259 = 0.039999999105930328369140625f + asfloat(_251 ? asuint(_253) : asuint(_157));
_264 = (0u != uint(_251)) ? asuint(_259) : 2139095039u;
}
else
{
_264 = 2139095039u;
}
uint _265 = _67 * 8u;
uint _271 = asuint(asfloat(table_lists.Load<uint>((min((((_64 + 64u) >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _279 = asuint(asfloat(view_shifts.Load<uint>((min((min(_271, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _280 = _265 + _279;
uint _283 = min(_271, NULL_SLOT);
heap_RWByteAddressBuffer(_283).Store<uint>((min(((_280 < _279) ? _265 : _280), 2147483584u) >> 2u) * 4 + 0, _264);
}
[WaveSize(32)]
[numthreads(32, 1, 1)]
void main(SPIRV_Cross_Input stage_input)
{
gl_WorkGroupID = stage_input.gl_WorkGroupID;
gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex;
comp_main();
}