@@ -40,6 +40,7 @@ context.configure({
4040// Create the model vertex buffer.
4141const kVertexStride = 8 ;
4242const vertexBuffer = device . createBuffer ( {
43+ label : 'model vertex buffer' ,
4344 // position: vec3, normal: vec3, uv: vec2
4445 size : mesh . positions . length * kVertexStride * Float32Array . BYTES_PER_ELEMENT ,
4546 usage : GPUBufferUsage . VERTEX ,
@@ -58,6 +59,7 @@ const vertexBuffer = device.createBuffer({
5859// Create the model index buffer.
5960const indexCount = mesh . triangles . length * 3 ;
6061const indexBuffer = device . createBuffer ( {
62+ label : 'model index buffer' ,
6163 size : indexCount * Uint16Array . BYTES_PER_ELEMENT ,
6264 usage : GPUBufferUsage . INDEX ,
6365 mappedAtCreation : true ,
@@ -88,9 +90,9 @@ const depthTexture = device.createTexture({
8890} ) ;
8991
9092const gBufferTextureViews = [
91- gBufferTexture2DFloat16 . createView ( ) ,
92- gBufferTextureAlbedo . createView ( ) ,
93- depthTexture . createView ( ) ,
93+ gBufferTexture2DFloat16 . createView ( { label : 'gbuffer texture normal' } ) ,
94+ gBufferTextureAlbedo . createView ( { label : 'gbuffer texture albedo' } ) ,
95+ depthTexture . createView ( { label : 'depth normal' } ) ,
9496] ;
9597
9698const vertexBuffers : Iterable < GPUVertexBufferLayout > = [
@@ -125,6 +127,7 @@ const primitive: GPUPrimitiveState = {
125127} ;
126128
127129const writeGBuffersPipeline = device . createRenderPipeline ( {
130+ label : 'write gbuffers' ,
128131 layout : 'auto' ,
129132 vertex : {
130133 module : device . createShaderModule ( {
@@ -204,6 +207,7 @@ const lightsBufferBindGroupLayout = device.createBindGroupLayout({
204207} ) ;
205208
206209const gBuffersDebugViewPipeline = device . createRenderPipeline ( {
210+ label : 'debug view' ,
207211 layout : device . createPipelineLayout ( {
208212 bindGroupLayouts : [ gBufferTexturesBindGroupLayout ] ,
209213 } ) ,
@@ -230,6 +234,7 @@ const gBuffersDebugViewPipeline = device.createRenderPipeline({
230234} ) ;
231235
232236const deferredRenderPipeline = device . createRenderPipeline ( {
237+ label : 'deferred final' ,
233238 layout : device . createPipelineLayout ( {
234239 bindGroupLayouts : [
235240 gBufferTexturesBindGroupLayout ,
@@ -272,7 +277,7 @@ const writeGBufferPassDescriptor: GPURenderPassDescriptor = {
272277 } ,
273278 ] ,
274279 depthStencilAttachment : {
275- view : depthTexture . createView ( ) ,
280+ view : gBufferTextureViews [ 2 ] ,
276281
277282 depthClearValue : 1.0 ,
278283 depthLoadOp : 'clear' ,
@@ -299,6 +304,7 @@ const settings = {
299304} ;
300305const configUniformBuffer = ( ( ) => {
301306 const buffer = device . createBuffer ( {
307+ label : 'config uniforms' ,
302308 size : Uint32Array . BYTES_PER_ELEMENT ,
303309 mappedAtCreation : true ,
304310 usage : GPUBufferUsage . UNIFORM | GPUBufferUsage . COPY_DST ,
@@ -322,11 +328,13 @@ gui
322328 } ) ;
323329
324330const modelUniformBuffer = device . createBuffer ( {
331+ label : 'model matrix uniform' ,
325332 size : 4 * 16 * 2 , // two 4x4 matrix
326333 usage : GPUBufferUsage . UNIFORM | GPUBufferUsage . COPY_DST ,
327334} ) ;
328335
329336const cameraUniformBuffer = device . createBuffer ( {
337+ label : 'camera matrix uniform' ,
330338 size : 4 * 16 * 2 , // two 4x4 matrix
331339 usage : GPUBufferUsage . UNIFORM | GPUBufferUsage . COPY_DST ,
332340} ) ;
@@ -374,6 +382,7 @@ const lightDataStride = 8;
374382const bufferSizeInByte =
375383 Float32Array . BYTES_PER_ELEMENT * lightDataStride * kMaxNumLights ;
376384const lightsBuffer = device . createBuffer ( {
385+ label : 'lights storage' ,
377386 size : bufferSizeInByte ,
378387 usage : GPUBufferUsage . STORAGE ,
379388 mappedAtCreation : true ,
@@ -404,6 +413,7 @@ for (let i = 0; i < kMaxNumLights; i++) {
404413lightsBuffer . unmap ( ) ;
405414
406415const lightExtentBuffer = device . createBuffer ( {
416+ label : 'light extent uniform' ,
407417 size : 4 * 8 ,
408418 usage : GPUBufferUsage . UNIFORM | GPUBufferUsage . COPY_DST ,
409419} ) ;
@@ -419,6 +429,7 @@ device.queue.writeBuffer(
419429) ;
420430
421431const lightUpdateComputePipeline = device . createComputePipeline ( {
432+ label : 'light update' ,
422433 layout : 'auto' ,
423434 compute : {
424435 module : device . createShaderModule ( {
0 commit comments