Files
larp/shaders/replace/f607780aa8e502d0.compute.hlsl

296 lines
17 KiB
HLSL

// f607780aa8e502d0, compute: IrradianceCache_ShadowTrace_WithFar.
//
// 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, 20 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
// f607780aa8e502d0.compute.views (view 0 at t248 space1, table at root parameter 1 dword 32; view 1 at t249
// space1, table at root parameter 1 dword 24). 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):
//
// IrradianceCache_ShadowTrace_WithFar (wave32, 64-bit node test). Per thread a shadow
// ray from the probe's position towards the light (direction the negated constant
// vector at +0x110 of the constant buffer, t max the constant at +0x44): a near query,
// then, when it missed and the far distance is past the near one, a far query against
// the second structure from the moved origin with what is left of t max. Each walk
// keeps the committed triangle's node pointer in v7 (0 before the walk) and leaves at
// the first commit; the code after it reads only whether v7 is 0.
//
// Site 1 (entry 0x438):
// Near: structure view at table +0x80 (s[20:23], loaded at 0x5c); the root pointer
// loaded at 0x384 from header +48. The loop is entered at 0x438 (from 0x428);
// 0x430, which puts EXEC back, is reached only by its back edge from 0xb34; the
// walk leaves to 0xb38. Instance mask: the instance's bit 30 of +48 (0x7d0), mask
// bit 6. The cull multiplier folded at 0x940 is 0: no culling. The triangle path
// commits without an opaque test (force opaque) and a commit ends the lane's walk
// (0x9f8, 0xb28: accept the first hit). A triangle is taken at 0 <= t < t max
// (0x9d8, 0x9f0): t min 0.
//
// Site 2 (entry 0xc30):
// Far: structure view at table +0x60 (s[0:3], loaded at 0xb58); the root pointer
// loaded at 0xbc4. Entered at 0xc30 (from 0xc24); 0xc28 only by the back edge
// from 0x133c; leaves to 0x1340. Mask bit 6 (0xfc8). The cull multiplier at
// 0x1148 is -1: with the instance's flags (no cull disable, clockwise front) a
// positive denominator, a front face, is rejected: cull front faces. Force opaque,
// first hit and t min 0 as the near walk.
#include "view_heap_layout.hlsli"
static uint _162;
ByteAddressBuffer table_lists : register(t252, space1);
ByteAddressBuffer view_shifts : register(t253, space1);
cbuffer _36_38 : register(b0, space0)
{
float4 _38_m0[5] : packoffset(c0);
};
// The host top level of structure view 0 (table at root parameter 1, dword 32; site 1).
uniform RaytracingAccelerationStructure _31 : register(t248, space1);
// The host top level of structure view 1 (table at root parameter 1, dword 24; site 2).
uniform RaytracingAccelerationStructure _32 : register(t249, 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; }
RWBuffer<float4> heap_RWBuffer_float4(uint i) { RWBuffer<float4> 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;
};
groupshared uint _42[512];
static RayQuery<RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH> _619;
static RayQuery<RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES> _715;
void comp_main()
{
uint _60 = WaveReadLaneFirst(gl_LocalInvocationIndex);
uint4 _71 = asuint(_38_m0[1u]);
uint _72 = _71.y;
uint _73 = _71.z;
uint _94 = ((gl_WorkGroupID.x + asuint(_38_m0[3u]).x) << 5u) + (((_60 & 4294967264u) + WaveGetLaneIndex()) % 32u);
if (asuint(heap_Buffer_float4(min(asuint(asfloat(table_lists.Load<uint>((min((((_72 + 64u) >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0))), NULL_SLOT)).Load(min(_73, 134217727u)).x) > _94)
{
uint _108 = min((((_72 + 32u) >> 5u) << 2u), 2147483584u);
uint _228;
uint _229;
if (_73 != 16u)
{
uint _223 = asuint(heap_Buffer_float4(min(asuint(asfloat(table_lists.Load<uint>((min(((_72 >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0))), NULL_SLOT)).Load(min(_94, 134217727u)).x);
_228 = 268435455u & _223;
_229 = _223 >> 29u;
}
else
{
uint _137 = asuint(heap_Buffer_float4(min(asuint(asfloat(table_lists.Load<uint>((min((((_72 + 160u) >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0))), NULL_SLOT)).Load(min(_94, 134217727u)).x);
uint _147 = asuint(asfloat(table_lists.Load<uint>((min((((_72 + 224u) >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
bool _150 = (_147 >> 31u) != 0u;
uint _156 = min((_150 ? HEAP_VIEW_SLOT : _147), NULL_SLOT);
uint _171 = asuint(asfloat(uint2(_162, heap_ByteAddressBuffer(_156).Load<uint>(((min(((_150 ? (_147 << 4u) : 0u) + 16u), 2147483584u) >> 2u) + 1u) * 4 + 0))).y);
precise float _174 = 1.0f / float(_171);
precise float _176 = 4294966784.0f * _174;
uint _182 = WaveReadLaneFirst(uint((_174 == 0.0f) ? 0.0f : _176));
uint _196 = uint((uint64_t(_137) * uint64_t(_182 + uint((uint64_t(_182) * uint64_t((-_171) * _182)) >> 32ull))) >> 32ull);
uint _199 = _137 - (_196 * _171);
bool _200 = _171 <= _199;
uint _202 = _200 ? (1u + _196) : _196;
uint _203 = _200 ? (_199 - _171) : _199;
bool _205 = _171 <= _203;
_228 = _205 ? (_203 - _171) : _203;
_229 = _205 ? (1u + _202) : _202;
}
uint _230 = _229 << 4u;
uint _235 = asuint(asfloat(table_lists.Load<uint>((min((((_71.x + 640u) >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _236 = min(_235, NULL_SLOT);
uint _246 = asuint(asfloat(view_shifts.Load<uint>((min((min(_235, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _247 = 1420u + _246;
uint _256 = asuint(asfloat(heap_ByteAddressBuffer(_236).Load<uint>((min(((_247 < _246) ? 1420u : _247), 2147483584u) >> 2u) * 4 + 0)));
uint _257 = 1424u + _246;
uint _266 = asuint(asfloat(heap_ByteAddressBuffer(_236).Load<uint>((min(((_257 < _246) ? 1424u : _257), 2147483584u) >> 2u) * 4 + 0)));
uint _267 = 1992u + _246;
float _275 = asfloat(heap_ByteAddressBuffer(_236).Load<uint>((min(((_267 < _246) ? 1992u : _267), 2147483584u) >> 2u) * 4 + 0));
uint _276 = 1428u + _230;
uint _278 = _276 + _246;
uint _282 = min(((_278 < _246) ? _276 : _278), 2147483584u) >> 2u;
float4 _295 = asfloat(uint4(heap_ByteAddressBuffer(_236).Load<uint>(_282 * 4 + 0), heap_ByteAddressBuffer(_236).Load<uint>((_282 + 1u) * 4 + 0), heap_ByteAddressBuffer(_236).Load<uint>((_282 + 2u) * 4 + 0), heap_ByteAddressBuffer(_236).Load<uint>((_282 + 3u) * 4 + 0)));
float _298 = _295.z;
float _300 = _295.w;
uint _301 = 1520u + _230;
uint _303 = _301 + _246;
uint _312 = _266 * _256;
precise float _313 = 0.699999988079071044921875f * _275;
float _316 = (_275 == 0.0f) ? 0.0f : _313;
precise float _319 = 1.0f / float(_266);
precise float _322 = 1.0f / float(_312);
precise float _323 = _316 * _316;
float _325 = (_316 == 0.0f) ? 0.0f : _323;
precise float _327 = 1.0f / float(_256);
precise float _328 = 4294966784.0f * _319;
bool _329 = _319 == 0.0f;
precise float _331 = 4294966784.0f * _322;
precise float _335 = 4294966784.0f * _327;
bool _336 = _327 == 0.0f;
uint _338 = WaveReadLaneFirst(uint(_329 ? 0.0f : _328));
uint _342 = WaveReadLaneFirst(uint((_322 == 0.0f) ? 0.0f : _331));
uint _348 = WaveReadLaneFirst(uint(_336 ? 0.0f : _335));
uint64_t _350 = uint64_t(_228);
uint _354 = uint((_350 * uint64_t(_338 + uint((uint64_t(_338) * uint64_t((-_266) * _338)) >> 32ull))) >> 32ull);
uint _372 = uint((_350 * uint64_t(_342 + uint((uint64_t(_342) * uint64_t((-_312) * _342)) >> 32ull))) >> 32ull);
uint _376 = _228 - (_354 * _266);
bool _378 = _266 <= _376;
uint _380 = _228 - (_372 * _312);
uint _381 = _378 ? (1u + _354) : _354;
uint _382 = _378 ? (_376 - _266) : _376;
bool _383 = _312 <= _380;
bool _386 = _266 <= _382;
uint _387 = _383 ? (1u + _372) : _372;
uint _390 = _386 ? (1u + _381) : _381;
precise float _403 = 0.5f + float(_386 ? (_382 - _266) : _382);
precise float _405 = 0.5f + float((_312 <= (_383 ? (_380 - _312) : _380)) ? (1u + _387) : _387);
precise float _406 = _403 * _319;
uint _410 = _390 - (uint((uint64_t(_390) * uint64_t(_348 + uint((uint64_t(_348) * uint64_t((-_256) * _348)) >> 32ull))) >> 32ull) * _256);
precise float _411 = _405 * _327;
uint _421 = (_256 <= _410) ? (_410 - _256) : _410;
precise float _426 = 0.5f + float((_256 <= _421) ? (_421 - _256) : _421);
precise float _427 = _426 * _327;
float _432 = mad(_300, mad(((_426 == 0.0f) || _336) ? 0.0f : _427, 2.0f, -1.0f), _295.y);
float _433 = mad(_300, mad(((_405 == 0.0f) || _336) ? 0.0f : _411, 2.0f, -1.0f), _295.x);
float _434 = mad(asfloat(heap_ByteAddressBuffer(_236).Load<uint>((min(((_303 < _246) ? _301 : _303), 2147483584u) >> 2u) * 4 + 0)), mad(((_403 == 0.0f) || _329) ? 0.0f : _406, 2.0f, -1.0f), _298);
precise float _435 = _432 * _432;
bool _436 = _432 == 0.0f;
float _439 = mad(_434, _434, mad(_433, _433, _436 ? 0.0f : _435));
bool _440 = _439 < _325;
uint _504;
if (_440)
{
uint _445 = asuint(asfloat(table_lists.Load<uint>((_108 >> 2u) * 4 + 0)));
uint _446 = min(_445, NULL_SLOT);
uint _455 = asuint(asfloat(view_shifts.Load<uint>((min((min(_445, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _456 = 272u + _455;
uint _465 = 276u + _455;
float _473 = asfloat(heap_ByteAddressBuffer(_446).Load<uint>((min(((_465 < _455) ? 276u : _465), 2147483584u) >> 2u) * 4 + 0));
uint _474 = 280u + _455;
precise float _483 = _325 - _439;
precise float _484 = _473 * _432;
precise float _488 = (-0.0f) - asfloat(heap_ByteAddressBuffer(_446).Load<uint>((min(((_456 < _455) ? 272u : _456), 2147483584u) >> 2u) * 4 + 0));
precise float _490 = (-0.0f) - (((_473 == 0.0f) || _436) ? 0.0f : _484);
precise float _492 = (-0.0f) - _434;
float _493 = mad(_492, asfloat(heap_ByteAddressBuffer(_446).Load<uint>((min(((_474 < _455) ? 280u : _474), 2147483584u) >> 2u) * 4 + 0)), mad(_433, _488, _490));
precise float _496 = sqrt(mad(_493, _493, _483)) - _493;
_504 = asuint(((asuint(_496) & 2147483647u) == 0u) ? 0.0f : max(0.0f, _496));
}
else
{
_504 = asuint(_298);
}
uint _511 = asuint(asfloat(table_lists.Load<uint>((_108 >> 2u) * 4 + 0)));
uint _512 = min(_511, NULL_SLOT);
uint _521 = asuint(asfloat(view_shifts.Load<uint>((min((min(_511, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _522 = 272u + _521;
uint _530 = 276u + _521;
uint _538 = 280u + _521;
uint _549 = min((((_72 + 224u) >> 5u) << 2u), 2147483584u);
uint _554 = asuint(asfloat(table_lists.Load<uint>((_549 >> 2u) * 4 + 0)));
bool _556 = (_554 >> 31u) != 0u;
uint _560 = min((_556 ? HEAP_VIEW_SLOT : _554), NULL_SLOT);
float2 _569 = asfloat(uint2(_162, heap_ByteAddressBuffer(_560).Load<uint>(((min(((_556 ? (_554 << 4u) : 0u) + 64u), 2147483584u) >> 2u) + 1u) * 4 + 0)));
float _570 = _569.y;
precise float _580 = 0.0f - asfloat(heap_ByteAddressBuffer(_512).Load<uint>((min(((_530 < _521) ? 276u : _530), 2147483584u) >> 2u) * 4 + 0));
precise float _581 = 0.0f - asfloat(heap_ByteAddressBuffer(_512).Load<uint>((min(((_522 < _521) ? 272u : _522), 2147483584u) >> 2u) * 4 + 0));
precise float _582 = 0.0f - asfloat(heap_ByteAddressBuffer(_512).Load<uint>((min(((_538 < _521) ? 280u : _538), 2147483584u) >> 2u) * 4 + 0));
uint _583 = (countbits((WaveGetLaneIndex() >= 32u) ? 4294967295u : ((1u << (WaveGetLaneIndex() & 31u)) - 1u)) << 2u) >> 2u;
_42[_583] = 4294967295u;
bool _626;
if (((((((0.0f <= _570) && (!(isnan(_433) || isnan(_433)))) && (!(isnan(_432) || isnan(_432)))) && (!(isnan(_434) || isnan(_434)))) && (!(isnan(_581) || isnan(_581)))) && (!(isnan(_580) || isnan(_580)))) && (!(isnan(_582) || isnan(_582))))
{
RayDesc _2ident = {float3(_433, _432, _434), 0.0f, float3(_581, _580, _582), _570};
// Site 1 (console entry 0x438): structure view 0, flags RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH, mask 0x40.
_619.TraceRayInline(_31, 5u, 64u, _2ident);
bool _623;
do
{
_623 = _619.Proceed();
} while (_623);
uint _624 = _619.CommittedStatus();
_626 = _624 == 1u;
}
else
{
_626 = false;
}
uint _628 = uint(_626);
float _629 = asfloat((!_440) ? 0u : _504);
precise float _630 = _570 - _629;
uint _724;
if ((0u == _628) ? (!(0.0f < _630)) : true)
{
_724 = _628;
}
else
{
uint _640 = asuint(asfloat(table_lists.Load<uint>((_108 >> 2u) * 4 + 0)));
uint _641 = min(_640, NULL_SLOT);
uint _650 = asuint(asfloat(view_shifts.Load<uint>((min((min(_640, 2097151u) << 2u), 2147483584u) >> 2u) * 4 + 0)));
uint _651 = 272u + _650;
float _658 = asfloat(heap_ByteAddressBuffer(_641).Load<uint>((min(((_651 < _650) ? 272u : _651), 2147483584u) >> 2u) * 4 + 0));
uint _659 = 276u + _650;
float _666 = asfloat(heap_ByteAddressBuffer(_641).Load<uint>((min(((_659 < _650) ? 276u : _659), 2147483584u) >> 2u) * 4 + 0));
uint _667 = 280u + _650;
float _674 = asfloat(heap_ByteAddressBuffer(_641).Load<uint>((min(((_667 < _650) ? 280u : _667), 2147483584u) >> 2u) * 4 + 0));
_42[_583] = 4294967295u;
precise float _675 = (-0.0f) - _658;
float _676 = mad(_675, _629, _433);
precise float _677 = (-0.0f) - _666;
float _678 = mad(_677, _629, _432);
precise float _679 = (-0.0f) - _674;
float _680 = mad(_679, _629, _434);
precise float _681 = 0.0f - _674;
precise float _682 = 0.0f - _658;
precise float _683 = 0.0f - _666;
bool _722;
if (((((((0.0f <= _630) && (!(isnan(_676) || isnan(_676)))) && (!(isnan(_678) || isnan(_678)))) && (!(isnan(_680) || isnan(_680)))) && (!(isnan(_682) || isnan(_682)))) && (!(isnan(_683) || isnan(_683)))) && (!(isnan(_681) || isnan(_681))))
{
RayDesc _3ident = {float3(_676, _678, _680), 0.0f, float3(_682, _683, _681), _630};
// Site 2 (console entry 0xc30): structure view 1, flags RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES, mask 0x40.
_715.TraceRayInline(_32, 37u, 64u, _3ident);
bool _719;
do
{
_719 = _715.Proceed();
} while (_719);
uint _720 = _715.CommittedStatus();
_722 = _720 == 1u;
}
else
{
_722 = false;
}
_724 = uint(_722);
}
uint _729 = asuint(asfloat(table_lists.Load<uint>((_549 >> 2u) * 4 + 0)));
bool _731 = (_729 >> 31u) != 0u;
uint _735 = min((_731 ? HEAP_VIEW_SLOT : _729), NULL_SLOT);
heap_RWBuffer_float4(min(asuint(asfloat(table_lists.Load<uint>((min((((_72 + 192u) >> 5u) << 2u), 2147483584u) >> 2u) * 4 + 0))), NULL_SLOT))[min(((asuint(asfloat(uint2(_162, heap_ByteAddressBuffer(_735).Load<uint>(((min(((_731 ? (_729 << 4u) : 0u) + 16u), 2147483584u) >> 2u) + 1u) * 4 + 0))).y) * _229) + _228), 134217727u)] = asfloat((0u == _724) ? 1056964608u : 0u).xxxx;
}
}
[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();
}