-
Notifications
You must be signed in to change notification settings - Fork 827
Open
Labels
Description
Description
The following code compiles fine without debug info, however it breaks with debug info
Compilation error: fatal error: generated SPIR-V is invalid: ID '403[%403]' has not been defined
%402 = OpExtInst %void %2 DebugValue %198 %403 %340 %int_0
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Steps to Reproduce
#line 1 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
#line 1 "D:/repos/Lib/Source/Shaders\\Common.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders/VertexInput.hlsli"
struct PositionOnlyVSInput
{
float3 Position : ATTRIBUTE0;
};
struct PositionOnlyVSOutput
{
float4 Position : SV_POSITION;
};
struct StaticMeshVS
{
float3 Position : ATTRIBUTE0;
float4 Normal : ATTRIBUTE1;
float4 Tangent : ATTRIBUTE2;
float2 TexCoord : ATTRIBUTE3;
};
struct StaticMeshVS2PS
{
float4 Position : SV_POSITION;
float3 Normal : NORMAL;
float4 Tangent : TANGENT;
float2 TexCoord : TEXCOORD;
};
struct TriangleVertexVS
{
float2 Position : ATTRIBUTE0;
float2 TexCoord : ATTRIBUTE1;
};
struct TriangleVertexVS2PS
{
float4 Position : SV_POSITION;
float2 TexCoord : TEXCOORD;
};
struct UIVertexVS
{
float2 Position : ATTRIBUTE0;
float2 TexCoord : ATTRIBUTE1;
float4 Color : ATTRIBUTE2;
};
struct UIVertexVS2PS
{
float4 Position : SV_POSITION;
float4 Color : COLOR;
float2 TexCoord : TEXCOORD;
};
TriangleVertexVS GetTriangleVertexFromId(uint vertexId)
{
TriangleVertexVS vertex;
vertex.TexCoord = float2((vertexId << 1) & 2, vertexId & 2);
vertex.Position = vertex.TexCoord * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f);
return vertex;
}
TriangleVertexVS2PS GetTriangleOutput(TriangleVertexVS vertex)
{
TriangleVertexVS2PS output;
output.Position = float4(vertex.Position, 0, 1);
output.TexCoord = vertex.TexCoord;
return output;
}
#line 4 "D:/repos/Lib/Source/Shaders\\Common.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders/ThreadGroupTilingX.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders/Math.hlsli"
#line 10 "D:/repos/Lib/Source/Shaders/Math.hlsli"
template <typename T>
T Pow2(T x)
{
return x * x;
}
template <typename T>
T Pow3(T x)
{
return Pow2(x) * x;
}
template <typename T>
T Pow4(T x)
{
return Pow3(x) * x;
}
template <typename T>
T Pow5(T x)
{
return Pow4(x) * x;
}
float Remap(float value, float rangeAStart, float rangeAEnd, float rangeBStart, float rangeBEnd)
{
return (value - rangeAStart) / (rangeAEnd - rangeAStart) * (rangeBEnd - rangeBStart) + rangeBStart;
}
template <typename T, typename U>
T DivideAndRoundUp(T dividend, U divisor)
{
return (dividend + divisor - 1) / divisor;
}
template <typename T, typename U>
T GetDispatchGroupCount(T textureSize, U divisor)
{
return DivideAndRoundUp(textureSize, divisor);
}
template <typename T, typename U>
T mod(T x, U y)
{
return x - y * floor(x / y);
}
float MinOf(float2 v) { return min(v.x, v.y); }
float MinOf(float3 v) { return min(v.x, min(v.y, v.z)); }
float MinOf(float4 v) { return min(min(v.x, min(v.y, v.z)), v.w); }
float4 MinOf(float4 v0, float4 v1) { return min(v0, v1); }
float4 MinOf(float4 v0, float4 v1, float4 v2) { return MinOf(v0, MinOf(v1, v2)); }
float4 MinOf(float4 v0, float4 v1, float4 v2, float4 v3) { return MinOf(v0, MinOf(v1, v2, v3)); }
float MaxOf(float2 v) { return max(v.x, v.y); }
float MaxOf(float3 v) { return max(v.x, max(v.y, v.z)); }
float MaxOf(float4 v) { return max(max(v.x, max(v.y, v.z)), v.w); }
float4 MaxOf(float4 v0, float4 v1) { return max(v0, v1); }
float4 MaxOf(float4 v0, float4 v1, float4 v2) { return MaxOf(v0, MaxOf(v1, v2)); }
float4 MaxOf(float4 v0, float4 v1, float4 v2, float4 v3) { return MaxOf(v0, MaxOf(v1, v2, v3)); }
#line 2 "D:/repos/Lib/Source/Shaders/ThreadGroupTilingX.hlsli"
#line 34 "D:/repos/Lib/Source/Shaders/ThreadGroupTilingX.hlsli"
uint2 ThreadGroupTilingX(
const uint2 dipatchGridDim,
const uint2 ctaDim,
const uint maxTileWidth,
const uint2 groupThreadID,
const uint2 groupId
)
{
const uint Number_of_CTAs_in_a_perfect_tile = maxTileWidth * dipatchGridDim.y;
const uint Number_of_perfect_tiles = dipatchGridDim.x / maxTileWidth;
const uint Total_CTAs_in_all_perfect_tiles = Number_of_perfect_tiles * maxTileWidth * dipatchGridDim.y;
const uint vThreadGroupIDFlattened = dipatchGridDim.x * groupId.y + groupId.x;
const uint Tile_ID_of_current_CTA = vThreadGroupIDFlattened / Number_of_CTAs_in_a_perfect_tile;
const uint Local_CTA_ID_within_current_tile = vThreadGroupIDFlattened % Number_of_CTAs_in_a_perfect_tile;
uint Local_CTA_ID_y_within_current_tile;
uint Local_CTA_ID_x_within_current_tile;
if (Total_CTAs_in_all_perfect_tiles <= vThreadGroupIDFlattened)
{
uint X_dimension_of_last_tile = dipatchGridDim.x % maxTileWidth;
X_dimension_of_last_tile = max(1, X_dimension_of_last_tile);
Local_CTA_ID_y_within_current_tile = Local_CTA_ID_within_current_tile / X_dimension_of_last_tile;
Local_CTA_ID_x_within_current_tile = Local_CTA_ID_within_current_tile % X_dimension_of_last_tile;
}
else
{
Local_CTA_ID_y_within_current_tile = Local_CTA_ID_within_current_tile / maxTileWidth;
Local_CTA_ID_x_within_current_tile = Local_CTA_ID_within_current_tile % maxTileWidth;
}
const uint Swizzled_vThreadGroupIDFlattened =
Tile_ID_of_current_CTA * maxTileWidth +
Local_CTA_ID_y_within_current_tile * dipatchGridDim.x +
Local_CTA_ID_x_within_current_tile;
uint2 SwizzledvThreadGroupID;
SwizzledvThreadGroupID.y = Swizzled_vThreadGroupIDFlattened / dipatchGridDim.x;
SwizzledvThreadGroupID.x = Swizzled_vThreadGroupIDFlattened % dipatchGridDim.x;
uint2 SwizzledvThreadID;
SwizzledvThreadID.x = ctaDim.x * SwizzledvThreadGroupID.x + groupThreadID.x;
SwizzledvThreadID.y = ctaDim.y * SwizzledvThreadGroupID.y + groupThreadID.y;
return SwizzledvThreadID.xy;
}
uint2 FullTextureThreadGroupTilingX(
const uint2 screenSize,
const uint ctaDim,
const uint2 groupThreadID,
const uint2 groupId
)
{
return ThreadGroupTilingX(
GetDispatchGroupCount(screenSize, ctaDim),
ctaDim.xx,
8,
groupThreadID,
groupId);
}
#line 5 "D:/repos/Lib/Source/Shaders\\Common.hlsli"
#line 45 "D:/repos/Lib/Source/Shaders\\Common.hlsli"
template <typename T>
T SampleTexture(Texture1D<T> texture, SamplerState s, float texCoord)
{
return texture.Sample(s, texCoord);
}
template <typename T>
T SampleTexture(Texture2D<T> texture, SamplerState s, float2 texCoord)
{
return texture.Sample(s, texCoord);
}
template <typename T>
T SampleTexture(Texture3D<T> texture, SamplerState s, float3 texCoord)
{
return texture.Sample(s, texCoord);
}
template <typename T>
T SampleTexture(TextureCube<T> texture, SamplerState s, float3 texCoord)
{
return texture.Sample(s, texCoord);
}
float3 PackNormal(float3 n)
{
return 0.5 * n + 0.5;
}
float3 UnpackNormalDXT5N(float4 packedNormal)
{
float3 n;
n.xy = packedNormal.wy * 2.0 - 1.0;
n.z = sqrt(saturate(1.0 - dot(n.xy, n.xy)));
return n;
}
float3 UnpackNormalRG(float2 packed)
{
float3 n;
n.xy = packed * 2.0 - 1.0;
n.z = sqrt(saturate(1.0 - dot(n.xy, n.xy)));
return n;
}
float3 UnpackNormalDefault(float4 packedNormal)
{
float4 unpacked = 2.0 * packedNormal - 1.0;
return normalize(unpacked.xyz);
}
float3 UnpackNormal(float4 packedNormal)
{
return UnpackNormalDXT5N(packedNormal);
}
float3 SampleNormal(Texture2D normal, SamplerState s, float2 texCoord)
{
return UnpackNormal(SampleTexture(normal, s, texCoord));
}
float LinearizeDepth(float z, float zNear,float zFar)
{
return zNear * zFar / (zFar + z * (zNear - zFar));
}
float4 TransformPosition(float4 pos, float4x4 transformation)
{
return mul(transformation, pos);
}
float4 TransformPosition(float3 pos, float4x4 transformation)
{
return TransformPosition(float4(pos, 1.0), transformation);
}
float3 TransformDirection(float3 dir, float4x4 transformation)
{
return normalize(mul((float3x3)transformation, dir));
}
float2 PixelToTexCoord(uint2 dt, float2 textureSize)
{
return float2(dt + 0.5) * rcp(textureSize);
}
float3 ScreenSpaceToNDC(float4 screenPos)
{
return screenPos.xyz * rcp(screenPos.w);
}
float2 NDCToTexCoord(float3 ndcPoint)
{
float2 texCoord = (ndcPoint.xy + 1.0) * 0.5;
texCoord.y = 1.0 - texCoord.y;
return texCoord;
}
float2 TexCoordToNDC(float2 texCoord)
{
return texCoord * float2(2.0, -2.0) + float2(-1.0, 1.0);
}
float3 TexCoordToNDC(float2 texCoord, float z)
{
return float3(TexCoordToNDC(texCoord), z);
}
float3 NDCToTexCoord3D(float3 ndcPoint)
{
return float3(NDCToTexCoord(ndcPoint), ndcPoint.z);
}
float2 ScreenSpaceToTexCoord(float4 screenPos)
{
float3 ndc = ScreenSpaceToNDC(screenPos);
return NDCToTexCoord(ndc);
}
float3 ScreenSpaceToTexCoord3D(float4 screenPos)
{
float3 ndc = ScreenSpaceToNDC(screenPos);
return NDCToTexCoord3D(ndc);
}
float3 WSPositionFromDepth(float2 texCoord, float z, float4x4 invViewProjectionMatrix)
{
float3 ndc = TexCoordToNDC(texCoord, z);
float4 position = TransformPosition(ndc, invViewProjectionMatrix);
return position.xyz * rcp(position.w);
}
uint GenerateRandomSeed(uint2 dt, uint width, uint frameIndex)
{
uint s0 = 0;
uint index = dt.x + dt.y * width;
[unroll]
for (uint n = 0; n < 16; n++)
{
s0 += 0x9e3779b9;
index += ((frameIndex << 4) + 0xa341316c) ^ (index + s0) ^ ((index >> 5) + 0xc8013ea4);
frameIndex += ((index << 4) + 0xad90777d) ^ (index + s0) ^ ((index >> 5) + 0x7e95761e);
}
return index;
}
float RandomFloat(inout uint s)
{
s = (1664525u * s + 1013904223u);
return float(s & 0x00FFFFFF) / float(0x01000000);
}
#line 2 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
#line 1 "D:/repos/Lib/Source/Shaders\\Hash.hlsli"
#line 34 "D:/repos/Lib/Source/Shaders\\Hash.hlsli"
float Hash11(float p)
{
p = frac(p * .1031);
p *= p + 33.33;
p *= p + p;
return frac(p);
}
float Hash12(float2 p)
{
float3 p3 = frac(float3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return frac((p3.x + p3.y) * p3.z);
}
float Hash13(float3 p3)
{
p3 = frac(p3 * .1031);
p3 += dot(p3, p3.zyx + 33.33);
return frac((p3.x + p3.y) * p3.z);
}
float Hash14(float4 p4)
{
p4 = frac(p4 * float4(.1031, .1030, .0973, .1099));
p4 += dot(p4, p4.wzxy + 33.33);
return frac((p4.x + p4.y) * (p4.z + p4.w));
}
float2 Hash21(float p)
{
float3 p3 = frac(float3(p.xxx) * float3(.1031, .1030, .0973));
p3 += dot(p3, p3.yzx + 33.33);
return frac((p3.xx + p3.yz) * p3.zy);
}
float2 Hash22(float2 p)
{
float3 p3 = frac(float3(p.xyx) * float3(.1031, .1030, .0973));
p3 += dot(p3, p3.yzx + 33.33);
return frac((p3.xx + p3.yz) * p3.zy);
}
float2 Hash23(float3 p3)
{
p3 = frac(p3 * float3(.1031, .1030, .0973));
p3 += dot(p3, p3.yzx + 33.33);
return frac((p3.xx + p3.yz) * p3.zy);
}
float3 Hash31(float p)
{
float3 p3 = frac(float3(p.xxx) * float3(.1031, .1030, .0973));
p3 += dot(p3, p3.yzx + 33.33);
return frac((p3.xxy + p3.yzz) * p3.zyx);
}
float3 Hash32(float2 p)
{
float3 p3 = frac(float3(p.xyx) * float3(.1031, .1030, .0973));
p3 += dot(p3, p3.yxz + 33.33);
return frac((p3.xxy + p3.yzz) * p3.zyx);
}
float3 Hash33(float3 p3)
{
p3 = frac(p3 * float3(.1031, .1030, .0973));
p3 += dot(p3, p3.yxz + 33.33);
return frac((p3.xxy + p3.yxx) * p3.zyx);
}
float4 Hash41(float p)
{
float4 p4 = frac(float4(p.xxxx) * float4(.1031, .1030, .0973, .1099));
p4 += dot(p4, p4.wzxy + 33.33);
return frac((p4.xxyz + p4.yzzw) * p4.zywx);
}
float4 Hash42(float2 p)
{
float4 p4 = frac(float4(p.xyxy) * float4(.1031, .1030, .0973, .1099));
p4 += dot(p4, p4.wzxy + 33.33);
return frac((p4.xxyz + p4.yzzw) * p4.zywx);
}
float4 Hash43(float3 p)
{
float4 p4 = frac(float4(p.xyzx) * float4(.1031, .1030, .0973, .1099));
p4 += dot(p4, p4.wzxy + 33.33);
return frac((p4.xxyz + p4.yzzw) * p4.zywx);
}
float4 Hash44(float4 p4)
{
p4 = frac(p4 * float4(.1031, .1030, .0973, .1099));
p4 += dot(p4, p4.wzxy + 33.33);
return frac((p4.xxyz + p4.yzzw) * p4.zywx);
}
#line 3 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
#line 1 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/VoxelCommon.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders\\Math.hlsli"
#line 4 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/VoxelCommon.hlsli"
float EaseOutQuint(float x)
{
return 1.0 - Pow5(1.0 - x);
}
float EaseOutCirc(float x)
{
return sqrt(1.0 - Pow2(x - 1.0));
}
float Easing(float x)
{
if (x < 0.5)
{
return min(1.0, 2 * x * x);
}
else
{
return min(1.0, 1.0 - (1.0 / (5.0 * (2.0 * x - 0.8) + 1)));
}
}
uint3 LinearToVoxelIndex(uint index, uint3 voxelRes)
{
uint x = (index % voxelRes.x);
uint y = (index / voxelRes.x) % voxelRes.y;
uint z = index / (voxelRes.x * voxelRes.y);
return uint3(x, y, z);
}
uint VoxelToLinearIndex(uint3 voxel, uint3 voxelRes)
{
return voxel.x + voxel.y * voxelRes.x + voxel.z * voxelRes.x * voxelRes.y;
}
#line 4 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
#line 1 "D:/repos/Lib/Source/Shaders\\ShaderStructs/WorldBuffer.h"
#line 1 "D:/repos/Lib/Source/Shaders\\ShaderStructs/Shared.h"
#line 4 "D:/repos/Lib/Source/Shaders\\ShaderStructs/WorldBuffer.h"
struct WorldBufferStruct {
matrix ViewProjectionMatrix;
matrix ViewProjectionJitterMatrix;
matrix InvViewProjectionMatrix;
matrix PrevViewProjectionMatrix;
matrix ScreenSpaceReprojectionMatrix;
float3 ViewPosition;
float NearPlane;
float3 ViewDirection;
float FarPlane;
float3 ViewUp;
float Padding0;
float Time;
float DeltaTime;
uint Frame;
float Padding1;
float2 ScreenSize;
float2 JitterDelta;
};
#line 6 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
#line 1 "D:/repos/Lib/Source/Shaders\\ShaderStructs/VoxelSmoke.h"
struct VoxelSmokeBufferStruct {
float3 VoxelResolution;
float VoxelSize;
float3 BoundsExtent;
float GrowthDuration;
float CreationTime;
float3 WorldPositionOffset;
float StepSize;
float Absorption;
float Scattering;
uint MaxSteps;
float ColorBandingNoiseStrength;
float AlphaThreshold;
float RussianRouletteProbability;
uint MaxLightSteps;
float LightStepSize;
uint PhaseFunctionType;
float PhaseFunctionG;
float PhaseFunctionTwoLobesLerp;
float3 AnimationDirection;
float NoiseScale;
float DensityFalloff;
float NoiseStrengthCentral;
float NoiseWispiness;
float NoiseLayerTexCoordOffset;
float NoiseMin;
float NoiseMax;
float NoiseWispyMin;
float NoiseWispyMax;
uint MultiScatteringOctaves;
float MultiScatteringAttenuation;
float MultiScatteringContribution;
float MultiScatteringEccentricityAttenuation;
};
struct StaticVoxelsBufferStruct {
float3 SceneAABBMin;
float ResolutionDepth;
float3 SceneAABBMax;
float LeafDepth;
float3 SceneResolution;
float SceneVoxelSize;
};
struct SVOGPUNode
{
uint Child[8];
uint LeafMask;
};
#line 7 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
#line 1 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/SparseVoxelOctree.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders\\Math.hlsli"
#line 5 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/SparseVoxelOctree.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders\\Primitives/Primitives.hlsli"
#line 1 "D:/repos/Lib/Source/Shaders\\Math.hlsli"
#line 4 "D:/repos/Lib/Source/Shaders\\Primitives/Primitives.hlsli"
struct Triangle
{
float3 A;
float3 B;
float3 C;
};
Triangle TransformTriangle(Triangle tri, float4x4 transformation)
{
Triangle result;
result.A = TransformPosition(tri.A, transformation).xyz;
result.B = TransformPosition(tri.B, transformation).xyz;
result.C = TransformPosition(tri.C, transformation).xyz;
return result;
}
struct Ellipsoid
{
float3 Center;
float3 Radius;
};
struct AABB
{
float3 Min;
float3 Max;
};
AABB AABBCreate(float3 min, float3 max)
{
AABB result;
result.Min = min;
result.Max = max;
return result;
}
float3 GetAABBSize(AABB aabb)
{
return aabb.Max - aabb.Min;
}
float3 GetAABBExtent(AABB aabb)
{
return GetAABBSize(aabb) * 0.5f;
}
float3 GetAABBCenter(AABB aabb)
{
return (aabb.Max + aabb.Min) * 0.5f;
}
struct Ray
{
float3 Origin;
float3 Direction;
};
Ray RayCreate(float3 origin, float3 direction)
{
Ray ray;
ray.Origin = origin;
ray.Direction = direction;
return ray;
}
float3 RayPosition(Ray ray, float t)
{
return ray.Origin + t * ray.Direction;
}
bool RayIntersectsAABB(Ray ray, AABB aabb, out float tMin, out float tMax)
{
float3 invDir = 1.0 / ray.Direction;
float3 t0 = (aabb.Min - ray.Origin) * invDir;
float3 t1 = (aabb.Max - ray.Origin) * invDir;
float3 tMinVec = min(t0, t1);
float3 tMaxVec = max(t0, t1);
tMin = MaxOf(tMinVec);
tMax = MinOf(tMaxVec);
return tMax >= max(tMin, 0.0);
}
bool RayIntersectsEllipsoid(Ray ray, Ellipsoid eli, out float tMin, out float tMax)
{
float3 invRadius = 1.0 / eli.Radius;
float3 oc = ray.Origin - eli.Center;
float3 ocn = oc * invRadius;
float3 rdn = ray.Direction * invRadius;
float a = dot(rdn, rdn);
float b = dot(ocn, rdn);
float c = dot(ocn, ocn);
float h = b * b - a * (c - 1.0);
float rootH = sqrt(h);
tMin = (-b - rootH) / a;
tMax = (-b + rootH) / a;
return h >= 0 && tMax >= max(tMin, 0.0);
}
bool TriangleIntersectsAABB_SAT(Triangle tri, float3 aabbExtents, float3 axis)
{
float p0 = dot(tri.A, axis);
float p1 = dot(tri.B, axis);
float p2 = dot(tri.C, axis);
float r = aabbExtents.x * abs(dot(float3(1, 0, 0), axis)) +
aabbExtents.y * abs(dot(float3(0, 1, 0), axis)) +
aabbExtents.z * abs(dot(float3(0, 0, 1), axis));
float maxP = max(p0, max(p1, p2));
float minP = min(p0, min(p1, p2));
return !(max(-maxP, minP) > r);
}
bool TriangleIntersectsAABB(Triangle tri, AABB aabb)
{
float3 aabbCenter = GetAABBCenter(aabb);
float3 aabbExtents = GetAABBExtent(aabb);
tri.A -= aabbCenter;
tri.B -= aabbCenter;
tri.C -= aabbCenter;
float3 ab = normalize(tri.B - tri.A);
float3 bc = normalize(tri.C - tri.B);
float3 ca = normalize(tri.A - tri.C);
float3 a00 = float3(0.0, -ab.z, ab.y);
float3 a01 = float3(0.0, -bc.z, bc.y);
float3 a02 = float3(0.0, -ca.z, ca.y);
float3 a10 = float3(ab.z, 0.0, -ab.x);
float3 a11 = float3(bc.z, 0.0, -bc.x);
float3 a12 = float3(ca.z, 0.0, -ca.x);
float3 a20 = float3(-ab.y, ab.x, 0.0);
float3 a21 = float3(-bc.y, bc.x, 0.0);
float3 a22 = float3(-ca.y, ca.x, 0.0);
return TriangleIntersectsAABB_SAT(tri, aabbExtents, a00)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a01)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a02)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a10)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a11)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a12)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a20)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a21)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, a22)
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, float3(1, 0, 0))
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, float3(0, 1, 0))
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, float3(0, 0, 1))
&& TriangleIntersectsAABB_SAT(tri, aabbExtents, cross(ab, bc));
}
#line 6 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/SparseVoxelOctree.hlsli"
#line 29 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/SparseVoxelOctree.hlsli"
StructuredBuffer<SVOGPUNode> StaticVoxels : register(t0, space1);
cbuffer ConstantStaticVoxelsBuffer : register(b1, space1)
{
StaticVoxelsBufferStruct StaticVoxelsBuffer;
};
#line 48 "D:/repos/Lib/Source/Shaders\\VoxelSmoke/SparseVoxelOctree.hlsli"
bool IsVoxelOccupied_FromSVO(int3 voxelPos)
{
uint nodeIndex = 0;
uint level = 0;
while (true)
{
SVOGPUNode node = StaticVoxels[nodeIndex];
uint shift = (StaticVoxelsBuffer.ResolutionDepth - level - 1);
uint cx = (voxelPos.x >> shift) & 1u;
uint cy = (voxelPos.y >> shift) & 1u;
uint cz = (voxelPos.z >> shift) & 1u;
uint childSlot = cx | (cy << 1) | (cz << 2);
if (level + 1 == StaticVoxelsBuffer.LeafDepth)
{
return ((node.LeafMask >> childSlot) & 1u) != 0u;
}
uint childPtr = node.Child[childSlot];
if (childPtr == 0u) return false;
nodeIndex = childPtr - 1u;
level++;
}
}
bool IsVoxelOccupied(float3 worldPos)
{
if (any(worldPos < StaticVoxelsBuffer.SceneAABBMin) || any(worldPos >= StaticVoxelsBuffer.SceneAABBMax))
{
return false;
}
float3 localPos = worldPos - StaticVoxelsBuffer.SceneAABBMin;
float3 voxelIndex = localPos;
voxelIndex /= (StaticVoxelsBuffer.SceneAABBMax - StaticVoxelsBuffer.SceneAABBMin);
voxelIndex *= StaticVoxelsBuffer.SceneResolution;
return IsVoxelOccupied_FromSVO(voxelIndex);
}
#line 13 "D:/repos/Lib/Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl"
cbuffer ConstantWorldBuffer : register(b0, space0)
{
WorldBufferStruct WorldBuffer;
};
struct VSInput
{
float3 Position : ATTRIBUTE0;
float4 Normal : ATTRIBUTE1;
float4 Tangent : ATTRIBUTE2;
float2 TexCoord : ATTRIBUTE3;
uint InstanceId : SV_INSTANCEID;
};
struct VSOutput
{
float4 Position : SV_POSITION;
float3 Color : COLOR0;
};
void VSMain(VSInput input, out VSOutput output)
{
uint3 voxelIndex = LinearToVoxelIndex(input.InstanceId, StaticVoxelsBuffer.SceneResolution);
float3 voxelPosition = input.Position + voxelIndex;
voxelPosition *= StaticVoxelsBuffer.SceneVoxelSize;
voxelPosition -= (StaticVoxelsBuffer.SceneAABBMax - StaticVoxelsBuffer.SceneAABBMin) * 0.5;
output.Position = mul(WorldBuffer.ViewProjectionMatrix, float4(voxelPosition, 1.0f));
output.Position *= IsVoxelOccupied_FromSVO(voxelIndex);
output.Color = Hash13(input.InstanceId);
}
Commandline:
dxc.exe -E VSMain -T vs_6_0 -Zi -Zss -Qembed_debug -Zpc -all_resources_bound -flegacy-macro-expansion -flegacy-resource-reservation -I Source/ -ISource/Shaders -D SHADER_COMPILE=1 -D PLATFORM_DESKTOP=1 -D PLATFORM_MOBILE=0 -D HAS_DXT5NM_COMPRESSION=1 -D BACKEND_D3D11=0 -D BACKEND_D3D12=0 -D BACKEND_OPENGL=0 -D BACKEND_GLES=0 -D BACKEND_METAL=0 -D FULLSCREEN_THREAD_GROUP_SIZE=16 -D COMPUTE_SHADER=0 -D COMPILE_DXC -spirv -fspv-preserve-bindings -fspv-target-env=universal1.5 -fspv-debug=vulkan-with-source -P -Fi Build/Shaders/Preprocessed/DebugDrawStaticVoxelsVS.hlsl Source/Shaders/VoxelSmoke/DebugDrawStaticVoxelsVS.hlsl
Actual Behavior
To run
Environment
- DXC version "dxcompiler.dll: 1.8 - 1.8.0.4775 (d39324e); dxil.dll: 1.9(1.8.2505.32)"
- Host Operating System "Windows 11 Pro 25H2 26200.7623"
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
For Google