Skip to content
Open
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
9 changes: 2 additions & 7 deletions packages/typegpu-gl/src/glslGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
withValue,
} from 'typegpu/~internal';
import type {
AutoStruct,
ResolutionCtx,
FunctionDefinitionOptions,
ConstantDefinitionOptions,
Expand Down Expand Up @@ -1010,13 +1011,7 @@ export class GlslGenerator extends WgslGenerator {
// Is this an auto-detected output struct? If so, register each prop so the
// output struct's propTypes reflects what the body actually returns.
const isAutoStruct = expectedReturnType?.type === 'auto-struct';
const autoStruct = isAutoStruct
? (expectedReturnType as unknown as {
completeStruct: d.WgslStruct;
accessProp(key: string): { prop: string; type: d.BaseData } | undefined;
provideProp(key: string, type: d.BaseData): { prop: string; type: d.BaseData };
})
: undefined;
const autoStruct = isAutoStruct ? (expectedReturnType as unknown as AutoStruct) : undefined;

// Resolve each RHS first so module-level references get reserved (and types become
// available) before we allocate our LHS output identifiers.
Expand Down
8 changes: 5 additions & 3 deletions packages/typegpu/src/data/autoStruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export class AutoStruct implements BaseData, SelfResolvable {
#cachedStruct: WgslStruct | undefined;
#typeForExtraProps: BaseData | undefined;

static {
AutoStruct.prototype[$internal] = {};
AutoStruct.prototype.type = 'auto-struct';
}

constructor(
validProps: Record<string, BaseData>,
typeForExtraProps: BaseData | undefined,
Expand Down Expand Up @@ -116,6 +121,3 @@ export class AutoStruct implements BaseData, SelfResolvable {
return `auto-struct:${getName(this) ?? '<unnamed>'}`;
}
}

AutoStruct.prototype[$internal] = {};
AutoStruct.prototype.type = 'auto-struct';
1 change: 1 addition & 0 deletions packages/typegpu/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export {
// types
export type { ResolutionCtx, FunctionArgument } from './types.ts';
export type { Snippet, ResolvedSnippet, Origin } from './data/snippet.ts';
export type { AutoStruct } from './data/autoStruct.ts';

export type {
ShaderGenerator,
Expand Down
Loading