Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer: Revert "Fix SampledTexture not correctly bound (#28289)" #28402

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion examples/jsm/renderers/common/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,30 @@ class Bindings extends DataMap {

} else if ( binding.isSampledTexture ) {

const texture = binding.texture;

if ( binding.needsBindingsUpdate ) needsBindingsUpdate = true;

const updated = binding.update();

if ( updated ) {

this.textures.updateTexture( binding.texture );

}

const textureData = backend.get( binding.texture );

if ( backend.isWebGPUBackend === true && textureData.texture === undefined && textureData.externalTexture === undefined ) {

// TODO: Remove this once we found why updated === false isn't bound to a texture in the WebGPU backend
console.error( 'Bindings._update: binding should be available:', binding, updated, binding.texture, binding.textureNode.value );

this.textures.updateTexture( binding.texture );
needsBindingsUpdate = true;

}

const texture = binding.texture;

if ( texture.isStorageTexture === true ) {

Expand Down
8 changes: 8 additions & 0 deletions examples/jsm/renderers/common/SampledTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ class SampledTexture extends Binding {

}

get needsBindingsUpdate() {

const { texture, version } = this;

return texture.isVideoTexture ? true : version !== texture.version; // @TODO: version === 0 && texture.version > 0 ( add it just to External Textures like PNG,JPG )

}

update() {

const { texture, version } = this;
Expand Down
6 changes: 6 additions & 0 deletions examples/jsm/renderers/common/nodes/NodeSampledTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class NodeSampledTexture extends SampledTexture {

}

get needsBindingsUpdate() {

return this.textureNode.value !== this.texture || super.needsBindingsUpdate;

}

update() {

const { textureNode } = this;
Expand Down