Skip to content

Commit

Permalink
Revert "fix possible overrideMaterial material with .wireframe and cl…
Browse files Browse the repository at this point in the history
…eanup"

This reverts commit 7dcd85e.
  • Loading branch information
sunag committed Apr 2, 2023
1 parent 7dcd85e commit 5370b40
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
11 changes: 6 additions & 5 deletions examples/jsm/renderers/webgpu/WebGPURenderPipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class WebGPURenderPipeline {

}

init( cacheKey, stageVertex, stageFragment, renderObject, nodeBuilder ) {
init( cacheKey, stageVertex, stageFragment, object, nodeBuilder ) {

const { object, material, geometry } = renderObject;
const { material, geometry } = object;

// determine shader attributes

Expand Down Expand Up @@ -84,7 +84,7 @@ class WebGPURenderPipeline {

//

const primitiveState = this._getPrimitiveState( object, geometry, material );
const primitiveState = this._getPrimitiveState( object, material );
const colorWriteMask = this._getColorWriteMask( material );
const depthCompare = this._getDepthCompare( material );
const colorFormat = this._utils.getCurrentColorFormat();
Expand Down Expand Up @@ -425,14 +425,15 @@ class WebGPURenderPipeline {

}

_getPrimitiveState( object, geometry, material ) {
_getPrimitiveState( object, material ) {

const descriptor = {};

descriptor.topology = this._utils.getPrimitiveTopology( object, material );
descriptor.topology = this._utils.getPrimitiveTopology( object );

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

const geometry = object.geometry;
const count = ( geometry.index ) ? geometry.index.count : geometry.attributes.position.count;
descriptor.stripIndexFormat = ( count > 65535 ) ? GPUIndexFormat.Uint32 : GPUIndexFormat.Uint16; // define data type for primitive restart value

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

// determine render pipeline

currentPipeline = this._acquirePipeline( stageVertex, stageFragment, renderObject );
currentPipeline = this._acquirePipeline( stageVertex, stageFragment, renderObject.object, nodeBuilder );
cache.currentPipeline = currentPipeline;

// keep track of all used times
Expand Down Expand Up @@ -92,14 +92,14 @@ class WebGPURenderPipelines {

}

_acquirePipeline( stageVertex, stageFragment, renderObject ) {
_acquirePipeline( stageVertex, stageFragment, object, nodeBuilder ) {

let pipeline;
const pipelines = this.pipelines;

// check for existing pipeline

const cacheKey = this._computeCacheKey( stageVertex, stageFragment, renderObject );
const cacheKey = this._computeCacheKey( stageVertex, stageFragment, object );

for ( let i = 0, il = pipelines.length; i < il; i ++ ) {

Expand All @@ -117,7 +117,7 @@ class WebGPURenderPipelines {
if ( pipeline === undefined ) {

pipeline = new WebGPURenderPipeline( this.device, this.utils );
pipeline.init( cacheKey, stageVertex, stageFragment, renderObject, this.nodes.get( renderObject ) );
pipeline.init( cacheKey, stageVertex, stageFragment, object, nodeBuilder );

pipelines.push( pipeline );

Expand All @@ -127,9 +127,9 @@ class WebGPURenderPipelines {

}

_computeCacheKey( stageVertex, stageFragment, renderObject ) {
_computeCacheKey( stageVertex, stageFragment, object ) {

const { object, material } = renderObject;
const material = object.material;
const utils = this.utils;

const parameters = [
Expand All @@ -145,7 +145,7 @@ class WebGPURenderPipelines {
material.side,
utils.getSampleCount(),
utils.getCurrentEncoding(), utils.getCurrentColorFormat(), utils.getCurrentDepthStencilFormat(),
utils.getPrimitiveTopology( object, material )
utils.getPrimitiveTopology( object )
];

return parameters.join();
Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/renderers/webgpu/WebGPUUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class WebGPUUtils {

}

getPrimitiveTopology( object, material ) {
getPrimitiveTopology( object ) {

if ( object.isPoints ) return GPUPrimitiveTopology.PointList;
else if ( object.isLineSegments || ( object.isMesh && material.wireframe === true ) ) return GPUPrimitiveTopology.LineList;
else if ( object.isLineSegments || ( object.isMesh && object.material.wireframe === true ) ) return GPUPrimitiveTopology.LineList;
else if ( object.isLine ) return GPUPrimitiveTopology.LineStrip;
else if ( object.isMesh ) return GPUPrimitiveTopology.TriangleList;

Expand Down

0 comments on commit 5370b40

Please sign in to comment.