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

TSL: Introduce attributeArray and instancedArray #1415

Merged
merged 11 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
168 changes: 86 additions & 82 deletions src-testing/changes.patch

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions types/three/src/nodes/TSL.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export * from "./tsl/TSLBase.js";

// accessors
export * from "./accessors/AccessorsUtils.js";
export * from "./accessors/Arrays.js";
export * from "./accessors/BatchNode.js";
export * from "./accessors/Bitangent.js";
export * from "./accessors/BufferAttributeNode.js";
Expand Down
6 changes: 6 additions & 0 deletions types/three/src/nodes/accessors/Arrays.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ShaderNodeObject } from "../tsl/TSLCore.js";
import StorageBufferNode from "./StorageBufferNode.js";

export const attributeArray: (count: number, type?: string) => ShaderNodeObject<StorageBufferNode>;

export const instancedArray: (count: number, type?: string) => ShaderNodeObject<StorageBufferNode>;
18 changes: 9 additions & 9 deletions types/three/src/nodes/accessors/StorageBufferNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import StorageBufferAttribute from "../../renderers/common/StorageBufferAttribute.js";
import StorageInstancedBufferAttribute from "../../renderers/common/StorageInstancedBufferAttribute.js";
import { GPUBufferBindingType } from "../../renderers/webgpu/utils/WebGPUConstants.js";
import { NodeOrType, NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
import { NodeAccess } from "../core/constants.js";
import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
import StorageArrayElementNode from "../utils/StorageArrayElementNode.js";
import BufferNode from "./BufferNode.js";

export default class StorageBufferNode extends BufferNode {
readonly isStorageBufferNode: true;
bufferObject: boolean;

access: GPUBufferBindingType;
access: NodeAccess;

constructor(
value: StorageBufferAttribute | StorageInstancedBufferAttribute,
bufferType: string,
bufferType?: string | null,
bufferCount?: number,
);

element(indexNode: NodeRepresentation): ShaderNodeObject<StorageArrayElementNode>;

setBufferObject(value: boolean): this;

setAccess(value: GPUBufferBindingType): this;
setAccess(value: NodeAccess): this;

toReadOnly(): this;
}

export const storage: (
value: StorageBufferAttribute | StorageInstancedBufferAttribute,
nodeOrType: NodeOrType,
count: number,
type?: string | null,
count?: number,
) => ShaderNodeObject<StorageBufferNode>;
export const storageObject: (
value: StorageBufferAttribute | StorageInstancedBufferAttribute,
nodeOrType: NodeOrType,
count: number,
type?: string | null,
count?: number,
) => ShaderNodeObject<StorageBufferNode>;
8 changes: 5 additions & 3 deletions types/three/src/nodes/accessors/StorageTextureNode.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GPUStorageTextureAccess } from "../../renderers/webgpu/utils/WebGPUConstants.js";
import { Texture } from "../../textures/Texture.js";
import { NodeAccess } from "../core/constants.js";
import Node from "../core/Node.js";
import NodeBuilder from "../core/NodeBuilder.js";
import { NodeRepresentation, ShaderNodeObject } from "../tsl/TSLCore.js";
Expand All @@ -10,15 +10,17 @@ export default class StorageTextureNode extends TextureNode {

readonly isStorageTextureNode: true;

access: GPUStorageTextureAccess;
access: NodeAccess;

constructor(
value: Texture,
uvNode?: ShaderNodeObject<Node> | null,
storeNode?: Node | null,
);

setAccess(value: GPUStorageTextureAccess): this;
setAccess(value: NodeAccess): this;

toReadWrite(): this;

toReadOnly(): this;

Expand Down
7 changes: 7 additions & 0 deletions types/three/src/nodes/core/NodeUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ export const hashArray: (array: number[]) => number;
export const hash: (...params: number[]) => number;

export function getCacheKey(object: Node, force?: boolean): number;

export function getNodeChildren(object: Node): Generator<NodeChild, void>;

export function getTypeFromLength(length: number): string | undefined;

export function getLengthFromType(type: string): number | undefined;

export function getValueType(value: unknown): string | null;

export function getValueFromType(
type: string,
...params: number[]
Expand Down
6 changes: 6 additions & 0 deletions types/three/src/nodes/core/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ export declare const NodeType: {
readonly MATRIX3: "mat3";
readonly MATRIX4: "mat4";
};
export declare const NodeAccess: {
readonly READ_ONLY: "readOnly";
readonly WRITE_ONLY: "writeOnly";
readonly READ_WRITE: "readWrite";
};
export type NodeShaderStage = "vertex" | "fragment" | "compute";
export type NodeUpdateType = "none" | "frame" | "render" | "object";
export type NodeAccess = "readOnly" | "writeOnly" | "readWrite";
export declare const defaultShaderStages: NodeShaderStage[];
export declare const defaultBuildStages: string[];
export declare const shaderStages: NodeShaderStage[];
Expand Down
Loading