-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed plum circular dependency. (#291)
- Loading branch information
Showing
21 changed files
with
197 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Can be assigned a name. Not to be confused with | ||
* being able to HAVE a name. | ||
*/ | ||
export interface TgpuNamable { | ||
$name(label?: string | undefined): this; | ||
} | ||
|
||
export function isNamable(value: unknown): value is TgpuNamable { | ||
return ( | ||
!!value && | ||
(typeof value === 'object' || typeof value === 'function') && | ||
'$name' in value | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { TgpuNamable } from './namable'; | ||
|
||
export type Getter = <T>(plum: TgpuPlum<T>) => T; | ||
export type Unsubscribe = () => unknown; | ||
export type ExtractPlumValue<T> = T extends TgpuPlum<infer TValue> | ||
? TValue | ||
: never; | ||
|
||
export interface TgpuPlum<TValue = unknown> extends TgpuNamable { | ||
readonly __brand: 'TgpuPlum'; | ||
|
||
/** | ||
* Computes the value of this plum. Circumvents the store | ||
* memoization, so use with care. | ||
*/ | ||
compute(get: Getter): TValue; | ||
} | ||
|
||
export const TgpuExternalPlumTrait = Symbol( | ||
`This plum's value is sourced from outside the runtime.`, | ||
); | ||
|
||
export interface TgpuExternalPlum { | ||
readonly [TgpuExternalPlumTrait]: true; | ||
|
||
readonly version: number; | ||
subscribe(listener: () => unknown): Unsubscribe; | ||
} | ||
|
||
export function isExternalPlum( | ||
value: unknown | TgpuExternalPlum, | ||
): value is TgpuExternalPlum { | ||
return (value as TgpuExternalPlum)[TgpuExternalPlumTrait] === true; | ||
} | ||
|
||
export function isPlum<T>(value: TgpuPlum<T> | unknown): value is TgpuPlum<T> { | ||
return (value as TgpuPlum).__brand === 'TgpuPlum'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.