Skip to content

Commit 4c8b2ad

Browse files
committed
Guard particle spawn texcoord fetch against missing UVs
The particle spawn compute shader read emitter UVs unconditionally. For a mesh without UVs, spawnMeshTexcoordsIdx == BINDING_INDEX_INVALID (0xFFFF), so reading geometries[0xFFFF] is an out-of-range bindless descriptor access that faults the GPU (VK_ERROR_DEVICE_LOST). Wrap the texcoord fetch and its use in a BINDING_INDEX_INVALID guard, matching the existing color and prev-position guards, so emitter meshes lacking UVs no longer crash. Fixes #1100
1 parent 19ff0c9 commit 4c8b2ad

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/dxvk/shaders/rtx/pass/particles/particle_system_spawn.comp.slang

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,19 @@ GpuParticle respawn(uint particleIdx, uint spawnCtxIdx, const GpuParticleSystem
106106
color += unorm4x8ToFloat4x32(colorBits).zyxw * randomBary[i];
107107
}
108108

109-
const uint baseSrcTexcoordOffset = (spawnCtx.spawnMeshTexcoordsOffset + index * spawnCtx.spawnMeshTexcoordsStride) / 4;
110-
float2 texcoord = float2(BUFFER_ARRAY(geometries, (uint)spawnCtx.spawnMeshTexcoordsIdx, baseSrcTexcoordOffset + 0),
111-
BUFFER_ARRAY(geometries, (uint)spawnCtx.spawnMeshTexcoordsIdx, baseSrcTexcoordOffset + 1));
109+
// Only fetch emitter UVs when a valid texcoord buffer is bound. For a mesh without UVs,
110+
// spawnMeshTexcoordsIdx == BINDING_INDEX_INVALID (0xFFFF); reading geometries[0xFFFF] is an
111+
// out-of-range bindless descriptor access and faults the GPU (device loss). Mirrors the
112+
// existing guards on the color and prev-position reads above.
113+
float2 texcoord = float2(0.0f, 0.0f);
114+
if (spawnCtx.spawnMeshTexcoordsIdx != BINDING_INDEX_INVALID)
115+
{
116+
const uint baseSrcTexcoordOffset = (spawnCtx.spawnMeshTexcoordsOffset + index * spawnCtx.spawnMeshTexcoordsStride) / 4;
117+
texcoord = float2(BUFFER_ARRAY(geometries, (uint)spawnCtx.spawnMeshTexcoordsIdx, baseSrcTexcoordOffset + 0),
118+
BUFFER_ARRAY(geometries, (uint)spawnCtx.spawnMeshTexcoordsIdx, baseSrcTexcoordOffset + 1));
119+
}
112120

113-
if (particleSystem.desc.useSpawnTexcoords)
121+
if (particleSystem.desc.useSpawnTexcoords && spawnCtx.spawnMeshTexcoordsIdx != BINDING_INDEX_INVALID)
114122
{
115123
if (i == 0)
116124
{

0 commit comments

Comments
 (0)