Skip to content

Commit 4bde706

Browse files
committed
unwrap texture
1 parent b9eb0c1 commit 4bde706

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

packages/typegpu/src/core/pipeline/renderPipeline.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isBuiltin } from '../../data/attributes.ts';
88
import { type Disarray, getCustomLocation } from '../../data/dataTypes.ts';
99
import { sizeOf } from '../../data/sizeOf.ts';
1010
import { type ResolvedSnippet, snip } from '../../data/snippet.ts';
11+
import type { WgslTexture } from '../../data/texture.ts';
1112
import {
1213
type AnyWgslData,
1314
isWgslData,
@@ -46,7 +47,12 @@ import type { TgpuVertexFn } from '../function/tgpuVertexFn.ts';
4647
import { namespace } from '../resolve/namespace.ts';
4748
import type { ExperimentalTgpuRoot } from '../root/rootTypes.ts';
4849
import type { TgpuSlot } from '../slot/slotTypes.ts';
49-
import { isTexture, type TgpuTexture } from '../texture/texture.ts';
50+
import {
51+
isTexture,
52+
isTextureView,
53+
type TgpuTexture,
54+
type TgpuTextureView,
55+
} from '../texture/texture.ts';
5056
import type { RenderFlag } from '../texture/usageExtension.ts';
5157
import { connectAttributesToShader } from '../vertexLayout/connectAttributesToShader.ts';
5258
import {
@@ -155,7 +161,10 @@ export interface ColorAttachment {
155161
* A {@link GPUTextureView} describing the texture subresource that will be output to for this
156162
* color attachment.
157163
*/
158-
view: (TgpuTexture & RenderFlag) | GPUTextureView;
164+
view:
165+
| (TgpuTexture & RenderFlag)
166+
| GPUTextureView
167+
| TgpuTextureView<WgslTexture>;
159168
/**
160169
* Indicates the depth slice index of {@link GPUTextureViewDimension#"3d"} {@link GPURenderPassColorAttachment#view}
161170
* that will be output to for this color attachment.
@@ -506,6 +515,13 @@ class TgpuRenderPipelineImpl implements TgpuRenderPipeline {
506515
};
507516
}
508517

518+
if (isTextureView(attachment.view)) {
519+
return {
520+
...attachment,
521+
view: branch.unwrap(attachment.view),
522+
};
523+
}
524+
509525
return attachment;
510526
}) as GPURenderPassColorAttachment[]
511527
: [null];

0 commit comments

Comments
 (0)