Skip to content

Commit 2cbfe72

Browse files
svens-unityEvergreen
authored andcommitted
Disable indirect draws for non-tessellated quad topology in GRD.
1 parent 8da15ff commit 2cbfe72

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/Batching/InstanceCullingBatcherBurst.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,24 @@ private static void ProcessRenderer(InstanceHandle instance,
141141
// Scan all materials once to retrieve whether this renderer is indirect-compatible or not (and store it in the RangeKey).
142142
// Also cache hash map lookups since we need them right after.
143143
bool supportsIndirect = true;
144-
NativeArray<GPUDrivenMaterial> subMaterials = new NativeArray<GPUDrivenMaterial>(subMaterialIDs.Length, Allocator.Temp);
144+
bool isMetal = SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal;
145+
var subMaterials = new NativeArray<GPUDrivenMaterial>(subMaterialIDs.Length, Allocator.Temp);
145146
for (int i = 0; i < subMaterialIDs.Length; i++)
146147
{
147148
EntityId subMaterialID = subMaterialIDs[i];
148149
if (!materialMap.TryGetValue(subMaterialID, out GPUDrivenMaterial subMaterial))
149150
continue;
150151

151-
supportsIndirect &= subMaterial.isIndirectSupported;
152152
subMaterials[i] = subMaterial;
153+
154+
int subMeshIndex = subMeshStartIndex + i;
155+
int lodLoopCount = math.max(mesh.meshLodCount, 1);
156+
var subMesh = mesh.subMeshes[subMeshIndex * lodLoopCount];
157+
158+
// The indirect path does not support topology adjustment; use the direct path when this is required.
159+
// Concretely, for quads, only use the indirect path if we allow quads natively (e.g. tessellation shaders).
160+
supportsIndirect &= subMesh.topology != MeshTopology.Quads || subMaterial.hasTessellation;
161+
supportsIndirect &= !isMetal || !subMaterial.hasTessellation;
153162
}
154163

155164
var rangeKey = new RangeKey

0 commit comments

Comments
 (0)