From dab1c703d06b807597f9dda9750d946dad82ce0c Mon Sep 17 00:00:00 2001 From: Martin Valigursky Date: Thu, 25 Apr 2024 17:31:28 +0100 Subject: [PATCH] Update Graphics markers to display better with hierarchy --- src/scene/mesh-instance.js | 6 ++++++ src/scene/renderer/forward-renderer.js | 9 +-------- src/scene/renderer/render-pass-forward.js | 4 +--- src/scene/renderer/renderer.js | 12 ------------ 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/scene/mesh-instance.js b/src/scene/mesh-instance.js index 1a9a0678611..24df3a06aad 100644 --- a/src/scene/mesh-instance.js +++ b/src/scene/mesh-instance.js @@ -20,6 +20,7 @@ import { import { GraphNode } from './graph-node.js'; import { getDefaultMaterial } from './materials/default-material.js'; import { LightmapCache } from './graphics/lightmap-cache.js'; +import { DebugGraphics } from '../platform/graphics/debug-graphics.js'; let id = 0; const _tmpAabb = new BoundingBox(); @@ -519,9 +520,14 @@ class MeshInstance { // cache miss in the material variants if (!shaderInstance.shader) { + // marker to allow us to see the source node for shader alloc + DebugGraphics.pushGpuMarker(this.mesh.device, `Node: ${this.node.name}`); + const shader = mat.getShaderVariant(this.mesh.device, scene, shaderDefs, null, shaderPass, sortedLights, viewUniformFormat, viewBindGroupFormat, this._mesh.vertexBuffer?.format); + DebugGraphics.popGpuMarker(this.mesh.device); + // add it to the material variants cache mat.variants.set(variantKey, shader); diff --git a/src/scene/renderer/forward-renderer.js b/src/scene/renderer/forward-renderer.js index 38946d67a9a..186abf6a0fe 100644 --- a/src/scene/renderer/forward-renderer.js +++ b/src/scene/renderer/forward-renderer.js @@ -516,13 +516,8 @@ class ForwardRenderer extends Renderer { } } - // marker to allow us to see the source node for shader alloc - DebugGraphics.pushGpuMarker(device, `Node: ${drawCall.node.name}`); - const shaderInstance = drawCall.getShaderInstance(pass, lightHash, scene, this.viewUniformFormat, this.viewBindGroupFormat, sortedLights); - DebugGraphics.popGpuMarker(device); - addCall(drawCall, shaderInstance, material !== prevMaterial, !prevMaterial || lightMask !== prevLightMask); prevMaterial = material; @@ -576,8 +571,7 @@ class ForwardRenderer extends Renderer { device.setAlphaToCoverage(material.alphaToCoverage); } - DebugGraphics.pushGpuMarker(device, `Node: ${drawCall.node.name}`); - DebugGraphics.pushGpuMarker(device, `Material: ${material.name}`); + DebugGraphics.pushGpuMarker(device, `Node: ${drawCall.node.name}, Material: ${material.name}`); this.setupCullMode(camera._cullFaces, flipFactor, drawCall); @@ -637,7 +631,6 @@ class ForwardRenderer extends Renderer { } DebugGraphics.popGpuMarker(device); - DebugGraphics.popGpuMarker(device); } } diff --git a/src/scene/renderer/render-pass-forward.js b/src/scene/renderer/render-pass-forward.js index 5ff87e9737f..6ec090b3dfa 100644 --- a/src/scene/renderer/render-pass-forward.js +++ b/src/scene/renderer/render-pass-forward.js @@ -237,8 +237,7 @@ class RenderPassForward extends RenderPass { const { layer, transparent, camera } = renderAction; const cameraPass = layerComposition.camerasMap.get(camera); - DebugGraphics.pushGpuMarker(this.device, camera ? camera.entity.name : 'Unnamed'); - DebugGraphics.pushGpuMarker(this.device, `${layer.name}(${transparent ? 'TRANSP' : 'OPAQUE'})`); + DebugGraphics.pushGpuMarker(this.device, `Camera: ${camera ? camera.entity.name : 'Unnamed'}, Layer: ${layer.name}(${transparent ? 'TRANSP' : 'OPAQUE'})`); // #if _PROFILER const drawTime = now(); @@ -302,7 +301,6 @@ class RenderPassForward extends RenderPass { } } - DebugGraphics.popGpuMarker(this.device); DebugGraphics.popGpuMarker(this.device); // #if _PROFILER diff --git a/src/scene/renderer/renderer.js b/src/scene/renderer/renderer.js index 02d5c4ac3bc..e194c0b562f 100644 --- a/src/scene/renderer/renderer.js +++ b/src/scene/renderer/renderer.js @@ -314,8 +314,6 @@ class Renderer { setupViewport(camera, renderTarget) { const device = this.device; - DebugGraphics.pushGpuMarker(device, 'SETUP-VIEWPORT'); - const pixelWidth = renderTarget ? renderTarget.width : device.width; const pixelHeight = renderTarget ? renderTarget.height : device.height; @@ -335,8 +333,6 @@ class Renderer { h = Math.floor(scissorRect.w * pixelHeight); } device.setScissor(x, y, w, h); - - DebugGraphics.popGpuMarker(device); } setCameraUniforms(camera, target) { @@ -883,8 +879,6 @@ class Renderer { drawInstance(device, meshInstance, mesh, style, normal) { - DebugGraphics.pushGpuMarker(device, meshInstance.node.name); - const modelMatrix = meshInstance.node.worldTransform; this.modelMatrixId.setValue(modelMatrix.data); if (normal) { @@ -903,15 +897,11 @@ class Renderer { } else { device.draw(mesh.primitive[style]); } - - DebugGraphics.popGpuMarker(device); } // used for stereo drawInstance2(device, meshInstance, mesh, style) { - DebugGraphics.pushGpuMarker(device, meshInstance.node.name); - const instancingData = meshInstance.instancingData; if (instancingData) { if (instancingData.count > 0) { @@ -924,8 +914,6 @@ class Renderer { // matrices are already set device.draw(mesh.primitive[style], undefined, true); } - - DebugGraphics.popGpuMarker(device); } /**