Skip to content

Commit

Permalink
WebGPURenderer: More clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 committed Sep 8, 2020
1 parent 201e67b commit b906fb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions examples/jsm/renderers/webgpu/WebGPUBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class WebGPUBindings {
array.set( object.matrixWorld.elements, 0 );
array.set( object.modelViewMatrix.elements, 16 );

return true; // @TODO: implement caching (return false when cache hits occurs)
return true; // @TODO: Implement caching (return false when cache hits occurs)

} );

Expand Down Expand Up @@ -316,7 +316,7 @@ class WebGPUBindings {
array.set( object.matrixWorld.elements, 0 );
array.set( object.modelViewMatrix.elements, 16 );

return true; // @TODO: implement caching (return false when cache hits occurs)
return true; // @TODO: Implement caching (return false when cache hits occurs)

} );

Expand Down Expand Up @@ -346,7 +346,7 @@ class WebGPUBindings {
array.set( object.matrixWorld.elements, 0 );
array.set( object.modelViewMatrix.elements, 16 );

return true; // @TODO: implement caching (return false when cache hits occurs)
return true; // @TODO: Implement caching (return false when cache hits occurs)

} );

Expand All @@ -372,7 +372,7 @@ class WebGPUBindings {
array.set( camera.projectionMatrix.elements, 0 );
array.set( camera.matrixWorldInverse.elements, 16 );

return true; // @TODO: implement caching (return false when cache hits occurs)
return true; // @TODO: Implement caching (return false when cache hits occurs)

} );

Expand Down
12 changes: 7 additions & 5 deletions examples/jsm/renderers/webgpu/WebGPURenderPipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class WebGPURenderPipelines {

} else {

console.error( 'WebGPURenderer: Unknwon shader type' );
console.error( 'WebGPURenderer: Unknwon shader type.' );

}

Expand Down Expand Up @@ -95,8 +95,10 @@ class WebGPURenderPipelines {
const vertexBuffers = [];
const shaderAttributes = [];

// Find "layout (location = num) in type name" in vertex shader
// find "layout (location = num) in type name" in vertex shader

const regex = /^\s*layout\s*\(\s*location\s*=\s*(?<location>[0-9]+)\s*\)\s*in\s+(?<type>\w+)\s+(?<name>\w+)\s*;/gmi;

let shaderAttribute = null;

while ( shaderAttribute = regex.exec( shader.vertexShader ) ) {
Expand All @@ -121,7 +123,7 @@ class WebGPURenderPipelines {

const count = ( geometry.index ) ? geometry.index.count : geometry.attributes.position.count;

indexFormat = ( count > 65535 ) ? GPUIndexFormat.Uint32 : GPUIndexFormat.Uint16; // define data type the primitive restart value
indexFormat = ( count > 65535 ) ? GPUIndexFormat.Uint32 : GPUIndexFormat.Uint16; // define data type for primitive restart value

}

Expand Down Expand Up @@ -195,7 +197,7 @@ class WebGPURenderPipelines {

_getArrayStride( type ) {

// This code is GLSL specific. We need to update when we switch to WGSL.
// @TODO: This code is GLSL specific. We need to update when we switch to WGSL.

if ( type === 'float' ) return 4;
if ( type === 'vec2' ) return 8;
Expand Down Expand Up @@ -259,7 +261,7 @@ class WebGPURenderPipelines {

_getVertexFormat( type ) {

// This code is GLSL specific. We need to update when we switch to WGSL.
// @TODO: This code is GLSL specific. We need to update when we switch to WGSL.

if ( type === 'float' ) return GPUVertexFormat.Float;
if ( type === 'vec2' ) return GPUVertexFormat.Float2;
Expand Down

0 comments on commit b906fb3

Please sign in to comment.