From bbf5f36d354157ef765576f23b290a9d308c7eb5 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Wed, 20 Jul 2022 10:51:32 +0200 Subject: [PATCH] WebGPURenderer: Fix render pipeline selection. (#24373) --- .../jsm/renderers/webgpu/WebGPURenderPipeline.js | 13 ++----------- .../jsm/renderers/webgpu/WebGPURenderPipelines.js | 3 ++- examples/jsm/renderers/webgpu/WebGPURenderer.js | 11 ++++++++++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js b/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js index 4a4463ab53b508..2b7278a4521002 100644 --- a/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +++ b/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js @@ -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, @@ -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 ) { @@ -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; diff --git a/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js b/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js index 8e938c775844d9..3a3a555affc6ab 100644 --- a/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +++ b/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js @@ -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(); diff --git a/examples/jsm/renderers/webgpu/WebGPURenderer.js b/examples/jsm/renderers/webgpu/WebGPURenderer.js index ad7eeab009f09c..03d26b5d8d4725 100644 --- a/examples/jsm/renderers/webgpu/WebGPURenderer.js +++ b/examples/jsm/renderers/webgpu/WebGPURenderer.js @@ -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'; @@ -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 );