Skip to content

Commit

Permalink
WebGPURenderer: Fix render pipeline selection. (mrdoob#24373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 authored and snagy committed Sep 21, 2022
1 parent 446a13f commit bbf5f36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
13 changes: 2 additions & 11 deletions examples/jsm/renderers/webgpu/WebGPURenderPipeline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GPUPrimitiveTopology, GPUIndexFormat, GPUCompareFunction, GPUFrontFace, GPUCullMode, GPUVertexFormat, GPUBlendFactor, GPUBlendOperation, BlendColorFactor, OneMinusBlendColorFactor, GPUColorWriteFlags, GPUStencilOperation, GPUInputStepMode } from './constants.js';
import { GPUIndexFormat, GPUCompareFunction, GPUFrontFace, GPUCullMode, GPUVertexFormat, GPUBlendFactor, GPUBlendOperation, BlendColorFactor, OneMinusBlendColorFactor, GPUColorWriteFlags, GPUStencilOperation, GPUInputStepMode } from './constants.js';
import {
FrontSide, BackSide, DoubleSide,
NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth,
Expand Down Expand Up @@ -430,7 +430,7 @@ class WebGPURenderPipeline {

const descriptor = {};

descriptor.topology = this._getPrimitiveTopology( object );
descriptor.topology = this._renderer.getPrimitiveTopology( object );

if ( object.isLine === true && object.isLineSegments !== true ) {

Expand Down Expand Up @@ -467,15 +467,6 @@ class WebGPURenderPipeline {

}

_getPrimitiveTopology( object ) {

if ( object.isMesh ) return GPUPrimitiveTopology.TriangleList;
else if ( object.isPoints ) return GPUPrimitiveTopology.PointList;
else if ( object.isLineSegments ) return GPUPrimitiveTopology.LineList;
else if ( object.isLine ) return GPUPrimitiveTopology.LineStrip;

}

_getStencilCompare( material ) {

let stencilCompare;
Expand Down
3 changes: 2 additions & 1 deletion examples/jsm/renderers/webgpu/WebGPURenderPipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class WebGPURenderPipelines {
material.stencilFuncMask, material.stencilWriteMask,
material.side,
this.sampleCount,
renderer.getCurrentEncoding(), renderer.getCurrentColorFormat(), renderer.getCurrentDepthStencilFormat()
renderer.getCurrentEncoding(), renderer.getCurrentColorFormat(), renderer.getCurrentDepthStencilFormat(),
renderer.getPrimitiveTopology( object )
];

return parameters.join();
Expand Down
11 changes: 10 additions & 1 deletion examples/jsm/renderers/webgpu/WebGPURenderer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GPUIndexFormat, GPUTextureFormat, GPUStoreOp } from './constants.js';
import { GPUIndexFormat, GPUTextureFormat, GPUStoreOp, GPUPrimitiveTopology } from './constants.js';
import WebGPUObjects from './WebGPUObjects.js';
import WebGPUAttributes from './WebGPUAttributes.js';
import WebGPUGeometries from './WebGPUGeometries.js';
Expand Down Expand Up @@ -531,6 +531,15 @@ class WebGPURenderer {

}

getPrimitiveTopology( object ) {

if ( object.isMesh ) return GPUPrimitiveTopology.TriangleList;
else if ( object.isPoints ) return GPUPrimitiveTopology.PointList;
else if ( object.isLineSegments ) return GPUPrimitiveTopology.LineList;
else if ( object.isLine ) return GPUPrimitiveTopology.LineStrip;

}

getClearColor( target ) {

return target.copy( this._clearColor );
Expand Down

0 comments on commit bbf5f36

Please sign in to comment.