Ver Fonte

WebGPURenderer: Revert #28289 (#28402)

* revert #28289

* log patch should only cover webgpu

* prettify code
Renaud Rohlinger há 1 ano atrás
pai
commit
8f5d9e7f30

+ 14 - 1
examples/jsm/renderers/common/Bindings.js

@@ -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 ) {
 

+ 8 - 0
examples/jsm/renderers/common/SampledTexture.js

@@ -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;

+ 6 - 0
examples/jsm/renderers/common/nodes/NodeSampledTexture.js

@@ -10,6 +10,12 @@ class NodeSampledTexture extends SampledTexture {
 
 	}
 
+	get needsBindingsUpdate() {
+
+		return this.textureNode.value !== this.texture || super.needsBindingsUpdate;
+
+	}
+
 	update() {
 
 		const { textureNode } = this;