UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

30 lines (29 loc) 1.07 kB
import { $internal } from "../../shared/symbols.js"; import { isQuerySet } from "../querySet/querySet.js"; import { isGPUCanvasContext } from "../pipeline/typeGuards.js"; import { isTexture, isTextureView, } from "../texture/texture.js"; export function unwrapAttachmentView(root, view) { if (isTexture(view)) { return root.unwrap(view).createView(); } if (isTextureView(view)) { return root.unwrap(view); } if (isGPUCanvasContext(view)) { return view.getCurrentTexture().createView(); } return view; } export function unwrapTimestampWrites(root, timestampWrites) { const { querySet, beginningOfPassWriteIndex, endOfPassWriteIndex } = timestampWrites; const result = { querySet: isQuerySet(querySet) ? root.unwrap(querySet) : querySet, }; if (beginningOfPassWriteIndex !== undefined) { result.beginningOfPassWriteIndex = beginningOfPassWriteIndex; } if (endOfPassWriteIndex !== undefined) { result.endOfPassWriteIndex = endOfPassWriteIndex; } return result; }