Skip to content

Commit

Permalink
Update Graphics markers to display better with hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Valigursky committed Apr 25, 2024
1 parent af5a66d commit dab1c70
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
6 changes: 6 additions & 0 deletions src/scene/mesh-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
9 changes: 1 addition & 8 deletions src/scene/renderer/forward-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -637,7 +631,6 @@ class ForwardRenderer extends Renderer {
}

DebugGraphics.popGpuMarker(device);
DebugGraphics.popGpuMarker(device);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/scene/renderer/render-pass-forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -302,7 +301,6 @@ class RenderPassForward extends RenderPass {
}
}

DebugGraphics.popGpuMarker(this.device);
DebugGraphics.popGpuMarker(this.device);

// #if _PROFILER
Expand Down
12 changes: 0 additions & 12 deletions src/scene/renderer/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -335,8 +333,6 @@ class Renderer {
h = Math.floor(scissorRect.w * pixelHeight);
}
device.setScissor(x, y, w, h);

DebugGraphics.popGpuMarker(device);
}

setCameraUniforms(camera, target) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -924,8 +914,6 @@ class Renderer {
// matrices are already set
device.draw(mesh.primitive[style], undefined, true);
}

DebugGraphics.popGpuMarker(device);
}

/**
Expand Down

0 comments on commit dab1c70

Please sign in to comment.