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: Fix integer uniforms #1418

Merged
merged 7 commits into from
Dec 14, 2024
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
43 changes: 26 additions & 17 deletions src-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6701,7 +6701,7 @@ index 28aac0d7..2479d00d 100644

this.isUniformBuffer = true;
diff --git a/src-testing/src/renderers/common/UniformsGroup.ts b/src-testing/src/renderers/common/UniformsGroup.ts
index e2b62671..55209311 100644
index aa27776a..a31eb060 100644
--- a/src-testing/src/renderers/common/UniformsGroup.ts
+++ b/src-testing/src/renderers/common/UniformsGroup.ts
@@ -1,8 +1,24 @@
Expand Down Expand Up @@ -6784,7 +6784,7 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -126,7 +142,7 @@ class UniformsGroup extends UniformBuffer {
@@ -127,7 +143,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

Expand All @@ -6793,7 +6793,7 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -145,7 +161,7 @@ class UniformsGroup extends UniformBuffer {
@@ -147,7 +163,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

Expand All @@ -6802,7 +6802,7 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -165,7 +181,7 @@ class UniformsGroup extends UniformBuffer {
@@ -168,7 +184,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

Expand All @@ -6811,7 +6811,7 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -186,7 +202,7 @@ class UniformsGroup extends UniformBuffer {
@@ -190,7 +206,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

Expand All @@ -6820,7 +6820,7 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -206,7 +222,7 @@ class UniformsGroup extends UniformBuffer {
@@ -210,7 +226,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

Expand All @@ -6829,7 +6829,7 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -242,7 +258,7 @@ class UniformsGroup extends UniformBuffer {
@@ -246,7 +262,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

Expand All @@ -6838,7 +6838,16 @@ index e2b62671..55209311 100644
let updated = false;

const a = this.values;
@@ -260,13 +276,13 @@ class UniformsGroup extends UniformBuffer {
@@ -263,7 +279,7 @@ class UniformsGroup extends UniformBuffer {
return updated;
}

- _getBufferForType(type) {
+ _getBufferForType(type: string | null): Int32Array | Uint32Array | Float32Array {
if (type === 'int' || type === 'ivec2' || type === 'ivec3' || type === 'ivec4')
return new Int32Array(this.buffer.buffer);
if (type === 'uint' || type === 'uvec2' || type === 'uvec3' || type === 'uvec4')
@@ -272,13 +288,13 @@ class UniformsGroup extends UniformBuffer {
}
}

Expand Down Expand Up @@ -7025,7 +7034,7 @@ index e3bbbe44..8b8312fc 100644
console.warn(`Redefinition of node ${baseClass.name}`);
return;
diff --git a/src-testing/src/renderers/common/nodes/NodeUniform.ts b/src-testing/src/renderers/common/nodes/NodeUniform.ts
index 659f5a82..d4f47579 100644
index 6412da90..02408606 100644
--- a/src-testing/src/renderers/common/nodes/NodeUniform.ts
+++ b/src-testing/src/renderers/common/nodes/NodeUniform.ts
@@ -7,9 +7,18 @@ import {
Expand All @@ -7048,7 +7057,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -21,7 +30,9 @@ class NumberNodeUniform extends NumberUniform {
@@ -25,7 +34,9 @@ class NumberNodeUniform extends NumberUniform {
}

class Vector2NodeUniform extends Vector2Uniform {
Expand All @@ -7059,7 +7068,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -33,7 +44,9 @@ class Vector2NodeUniform extends Vector2Uniform {
@@ -41,7 +52,9 @@ class Vector2NodeUniform extends Vector2Uniform {
}

class Vector3NodeUniform extends Vector3Uniform {
Expand All @@ -7070,7 +7079,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -45,7 +58,9 @@ class Vector3NodeUniform extends Vector3Uniform {
@@ -57,7 +70,9 @@ class Vector3NodeUniform extends Vector3Uniform {
}

class Vector4NodeUniform extends Vector4Uniform {
Expand All @@ -7081,7 +7090,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -57,7 +72,9 @@ class Vector4NodeUniform extends Vector4Uniform {
@@ -73,7 +88,9 @@ class Vector4NodeUniform extends Vector4Uniform {
}

class ColorNodeUniform extends ColorUniform {
Expand All @@ -7092,7 +7101,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -69,7 +86,9 @@ class ColorNodeUniform extends ColorUniform {
@@ -89,7 +106,9 @@ class ColorNodeUniform extends ColorUniform {
}

class Matrix3NodeUniform extends Matrix3Uniform {
Expand All @@ -7103,7 +7112,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -81,7 +100,9 @@ class Matrix3NodeUniform extends Matrix3Uniform {
@@ -105,7 +124,9 @@ class Matrix3NodeUniform extends Matrix3Uniform {
}

class Matrix4NodeUniform extends Matrix4Uniform {
Expand All @@ -7114,7 +7123,7 @@ index 659f5a82..d4f47579 100644
super(nodeUniform.name, nodeUniform.value);

this.nodeUniform = nodeUniform;
@@ -101,3 +122,11 @@ export {
@@ -129,3 +150,11 @@ export {
Matrix3NodeUniform,
Matrix4NodeUniform,
};
Expand Down Expand Up @@ -7949,7 +7958,7 @@ index 9de87c2f..77fb975a 100644
const nodeData = this.getDataFromNode(node, shaderStage, this.globalCache);

diff --git a/src-testing/src/renderers/webgpu/WebGPUBackend.ts b/src-testing/src/renderers/webgpu/WebGPUBackend.ts
index d29fe26c..7c98ca73 100644
index 5d45dac4..3367d544 100644
--- a/src-testing/src/renderers/webgpu/WebGPUBackend.ts
+++ b/src-testing/src/renderers/webgpu/WebGPUBackend.ts
@@ -984,7 +984,7 @@ class WebGPUBackend extends Backend {
Expand Down
1 change: 1 addition & 0 deletions types/three/src/renderers/common/UniformsGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ declare class UniformsGroup extends UniformBuffer {
updateColor(uniform: ColorNodeUniform): boolean;
updateMatrix3(uniform: Matrix3NodeUniform): boolean;
updateMatrix4(uniform: Matrix4NodeUniform): boolean;
_getBufferForType(type: string | null): Int32Array | Uint32Array | Float32Array;
}
export default UniformsGroup;
7 changes: 7 additions & 0 deletions types/three/src/renderers/common/nodes/NodeUniform.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,43 @@ declare class NumberNodeUniform extends NumberUniform {
nodeUniform: NodeUniform<number>;
constructor(nodeUniform: NodeUniform<number>);
getValue(): number;
getType(): string | null;
}
declare class Vector2NodeUniform extends Vector2Uniform {
nodeUniform: NodeUniform<Vector2>;
constructor(nodeUniform: NodeUniform<Vector2>);
getValue(): Vector2;
getType(): string | null;
}
declare class Vector3NodeUniform extends Vector3Uniform {
nodeUniform: NodeUniform<Vector3>;
constructor(nodeUniform: NodeUniform<Vector3>);
getValue(): Vector3;
getType(): string | null;
}
declare class Vector4NodeUniform extends Vector4Uniform {
nodeUniform: NodeUniform<Vector4>;
constructor(nodeUniform: NodeUniform<Vector4>);
getValue(): Vector4;
getType(): string | null;
}
declare class ColorNodeUniform extends ColorUniform {
nodeUniform: NodeUniform<Color>;
constructor(nodeUniform: NodeUniform<Color>);
getValue(): Color;
getType(): string | null;
}
declare class Matrix3NodeUniform extends Matrix3Uniform {
nodeUniform: NodeUniform<Matrix3>;
constructor(nodeUniform: NodeUniform<Matrix3>);
getValue(): Matrix3;
getType(): string | null;
}
declare class Matrix4NodeUniform extends Matrix4Uniform {
nodeUniform: NodeUniform<Matrix4>;
constructor(nodeUniform: NodeUniform<Matrix4>);
getValue(): Matrix4;
getType(): string | null;
}
export {
ColorNodeUniform,
Expand Down
Loading