feat: Support TRANSIENT_ATTACHMENT for Textures and add an escape hatch#2692
feat: Support TRANSIENT_ATTACHMENT for Textures and add an escape hatch#2692reczkok wants to merge 8 commits into
TRANSIENT_ATTACHMENT for Textures and add an escape hatch#2692Conversation
TRANSIENT_ATTACHMENT for TexturesTRANSIENT_ATTACHMENT for Textures
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 0.20%) | ❔ Unknown |
|---|---|---|---|
| 0 | 299 | 21 | 0 |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
Click to reveal the results table (297 entries).
| Test | tsdown |
|---|---|
| d_Void.ts | 87.65 kB ( |
| d_sampler.ts | 87.66 kB ( |
| d_isPtr.ts | 87.65 kB ( |
| d_comparisonSampler.ts | 87.67 kB ( |
| d_isSizeAttrib.ts | 87.66 kB ( |
| d_isWgslArray.ts | 87.66 kB ( |
| d_isAlignAttrib.ts | 87.66 kB ( |
| d_isWgslStruct.ts | 87.66 kB ( |
| d_isAtomic.ts | 87.66 kB ( |
| d_isBuiltinAttrib.ts | 87.66 kB ( |
| d_isLocationAttrib.ts | 87.67 kB ( |
| d_isDecorated.ts | 87.66 kB ( |
| d_isInterpolateAttrib.ts | 87.67 kB ( |
| d_atomic.ts | 87.66 kB ( |
| d_ptrHandle.ts | 87.66 kB ( |
| d_ptrUniform.ts | 87.66 kB ( |
| d_ptrStorage.ts | 87.66 kB ( |
| d_ptrPrivate.ts | 87.66 kB ( |
| d_ptrFn.ts | 87.65 kB ( |
| d_ptrWorkgroup.ts | 87.66 kB ( |
| d_textureExternal.ts | 87.66 kB ( |
| d_textureStorage1d.ts | 87.67 kB ( |
| d_textureStorage2d.ts | 87.67 kB ( |
| d_textureStorage3d.ts | 87.67 kB ( |
| d_textureStorage2dArray.ts | 87.67 kB ( |
| d_isDisarray.ts | 87.66 kB ( |
| d_isUnstruct.ts | 87.66 kB ( |
| d_isLooseDecorated.ts | 87.67 kB ( |
| d_isLooseData.ts | 87.66 kB ( |
| d_isWgslData.ts | 87.66 kB ( |
| d_unstruct.ts | 87.66 kB ( |
| d_isData.ts | 87.66 kB ( |
| d_deepEqual.ts | 87.66 kB ( |
| d_struct.ts | 87.66 kB ( |
| d_ref.ts | 87.65 kB ( |
| std_discard.ts | 105.47 kB ( |
| std_isBeingTranspiled.ts | 105.48 kB ( |
| std_copy.ts | 105.47 kB ( |
| std_arrayLength.ts | 105.48 kB ( |
| std_getTargetShaderLanguage.ts | 105.49 kB ( |
| std_extensionEnabled.ts | 105.48 kB ( |
| std_range.ts | 105.47 kB ( |
| std_dpdx.ts | 105.47 kB ( |
| std_fwidthCoarse.ts | 105.48 kB ( |
| std_dpdxCoarse.ts | 105.47 kB ( |
| std_dpdyCoarse.ts | 105.47 kB ( |
| std_fwidthFine.ts | 105.47 kB ( |
| std_dpdxFine.ts | 105.47 kB ( |
| std_dpdyFine.ts | 105.47 kB ( |
| std_fwidth.ts | 105.47 kB ( |
| std_dpdy.ts | 105.47 kB ( |
| d_bool.ts | 87.65 kB ( |
| d_f16.ts | 87.65 kB ( |
| d_f32.ts | 87.65 kB ( |
| d_i32.ts | 87.65 kB ( |
| d_u32.ts | 87.65 kB ( |
| d_u16.ts | 87.65 kB ( |
| std_atomicLoad.ts | 105.47 kB ( |
| std_textureBarrier.ts | 105.48 kB ( |
| std_atomicStore.ts | 105.48 kB ( |
| std_workgroupBarrier.ts | 105.48 kB ( |
| std_storageBarrier.ts | 105.48 kB ( |
| std_atomicAdd.ts | 105.47 kB ( |
| std_atomicAnd.ts | 105.47 kB ( |
| std_atomicMax.ts | 105.47 kB ( |
| std_atomicMin.ts | 105.47 kB ( |
| std_atomicSub.ts | 105.47 kB ( |
| std_atomicXor.ts | 105.47 kB ( |
| std_atomicOr.ts | 105.47 kB ( |
| d_textureDepth2d.ts | 87.66 kB ( |
| d_textureDepthCube.ts | 87.67 kB ( |
| d_texture1d.ts | 87.66 kB ( |
| d_texture2d.ts | 87.66 kB ( |
| d_texture3d.ts | 87.66 kB ( |
| d_textureDepth2dArray.ts | 87.67 kB ( |
| d_textureCube.ts | 87.66 kB ( |
| d_textureDepthCubeArray.ts | 87.67 kB ( |
| d_textureDepthMultisampled2d.ts | 87.67 kB ( |
| d_texture2dArray.ts | 87.66 kB ( |
| d_textureCubeArray.ts | 87.67 kB ( |
| d_textureMultisampled2d.ts | 87.67 kB ( |
| d_disarrayOf.ts | 87.66 kB ( |
| d_vec2b.ts | 87.65 kB ( |
| d_vec2f.ts | 87.65 kB ( |
| d_vec2h.ts | 87.65 kB ( |
| d_vec2i.ts | 87.65 kB ( |
| d_vec2u.ts | 87.65 kB ( |
| d_vec3b.ts | 87.65 kB ( |
| d_vec3f.ts | 87.65 kB ( |
| d_vec3h.ts | 87.65 kB ( |
| d_vec3i.ts | 87.65 kB ( |
| d_vec3u.ts | 87.65 kB ( |
| d_vec4b.ts | 87.65 kB ( |
| d_vec4f.ts | 87.65 kB ( |
| d_vec4h.ts | 87.65 kB ( |
| d_vec4i.ts | 87.65 kB ( |
| d_vec4u.ts | 87.65 kB ( |
| std_subgroupAdd.ts | 105.48 kB ( |
| std_subgroupBroadcastFirst.ts | 105.49 kB ( |
| std_subgroupExclusiveAdd.ts | 105.48 kB ( |
| std_subgroupExclusiveMul.ts | 105.48 kB ( |
| std_subgroupInclusiveAdd.ts | 105.48 kB ( |
| std_subgroupInclusiveMul.ts | 105.48 kB ( |
| std_subgroupShuffleDown.ts | 105.48 kB ( |
| std_subgroupShuffleXor.ts | 105.48 kB ( |
| std_subgroupBroadcast.ts | 105.48 kB ( |
| std_subgroupShuffleUp.ts | 105.48 kB ( |
| std_subgroupShuffle.ts | 105.48 kB ( |
| std_subgroupBallot.ts | 105.48 kB ( |
| std_subgroupElect.ts | 105.48 kB ( |
| std_subgroupAll.ts | 105.48 kB ( |
| std_subgroupAnd.ts | 105.48 kB ( |
| std_subgroupAny.ts | 105.48 kB ( |
| std_subgroupMax.ts | 105.48 kB ( |
| std_subgroupMin.ts | 105.48 kB ( |
| std_subgroupMul.ts | 105.48 kB ( |
| std_subgroupXor.ts | 105.48 kB ( |
| std_subgroupOr.ts | 105.47 kB ( |
| d_formatToWGSLType.ts | 87.67 kB ( |
| d_uint8.ts | 87.65 kB ( |
| d_unorm10_10_10_2.ts | 87.66 kB ( |
| d_unorm8x4_bgra.ts | 87.66 kB ( |
| d_float16x2.ts | 87.66 kB ( |
| d_float16x4.ts | 87.66 kB ( |
| d_float32x2.ts | 87.66 kB ( |
| d_float32x3.ts | 87.66 kB ( |
| d_float32x4.ts | 87.66 kB ( |
| d_snorm16x2.ts | 87.66 kB ( |
| d_snorm16x4.ts | 87.66 kB ( |
| d_unorm16x2.ts | 87.66 kB ( |
| d_unorm16x4.ts | 87.66 kB ( |
| d_sint16x2.ts | 87.66 kB ( |
| d_sint16x4.ts | 87.66 kB ( |
| d_sint32x2.ts | 87.66 kB ( |
| d_sint32x3.ts | 87.66 kB ( |
| d_sint32x4.ts | 87.66 kB ( |
| d_snorm8x2.ts | 87.66 kB ( |
| d_snorm8x4.ts | 87.66 kB ( |
| d_uint16x2.ts | 87.66 kB ( |
| d_uint16x4.ts | 87.66 kB ( |
| d_uint32x2.ts | 87.66 kB ( |
| d_uint32x3.ts | 87.66 kB ( |
| d_uint32x4.ts | 87.66 kB ( |
| d_unorm8x2.ts | 87.66 kB ( |
| d_unorm8x4.ts | 87.66 kB ( |
| d_float16.ts | 87.66 kB ( |
| d_float32.ts | 87.66 kB ( |
| d_sint8x2.ts | 87.66 kB ( |
| d_sint8x4.ts | 87.66 kB ( |
| d_snorm16.ts | 87.66 kB ( |
| d_uint8x2.ts | 87.66 kB ( |
| d_uint8x4.ts | 87.66 kB ( |
| d_unorm16.ts | 87.66 kB ( |
| d_sint16.ts | 87.66 kB ( |
| d_sint32.ts | 87.66 kB ( |
| d_snorm8.ts | 87.66 kB ( |
| d_uint16.ts | 87.66 kB ( |
| d_uint32.ts | 87.66 kB ( |
| d_unorm8.ts | 87.66 kB ( |
| d_sint8.ts | 87.65 kB ( |
| d_packedFormats.ts | 87.66 kB ( |
| d_isPackedData.ts | 87.66 kB ( |
| std_textureDimensions.ts | 105.48 kB ( |
| std_textureGather.ts | 105.48 kB ( |
| std_textureSampleBaseClampToEdge.ts | 105.49 kB ( |
| std_textureSampleCompareLevel.ts | 105.49 kB ( |
| std_textureSampleCompare.ts | 105.48 kB ( |
| std_textureSampleLevel.ts | 105.48 kB ( |
| std_textureSampleBias.ts | 105.48 kB ( |
| std_textureSampleGrad.ts | 105.48 kB ( |
| std_textureSample.ts | 105.48 kB ( |
| std_textureStore.ts | 105.48 kB ( |
| std_textureLoad.ts | 105.48 kB ( |
| d_alignmentOf.ts | 87.66 kB ( |
| std_translation4.ts | 105.48 kB ( |
| std_rotationX4.ts | 105.47 kB ( |
| std_rotationY4.ts | 105.47 kB ( |
| std_rotationZ4.ts | 105.47 kB ( |
| std_identity2.ts | 105.47 kB ( |
| std_identity3.ts | 105.47 kB ( |
| std_identity4.ts | 105.47 kB ( |
| std_scaling4.ts | 105.47 kB ( |
| d_isBuiltin.ts | 87.66 kB ( |
| d_sizeOf.ts | 87.66 kB ( |
| d_isContiguous.ts | 87.66 kB ( |
| d_getLongestContiguousPrefix.ts | 87.67 kB ( |
| d_arrayOf.ts | 87.66 kB ( |
| d_size.ts | 87.65 kB ( |
| d_align.ts | 87.65 kB ( |
| d_location.ts | 87.66 kB ( |
| d_interpolate.ts | 87.66 kB ( |
| d_invariant.ts | 87.66 kB ( |
| d_mat4x4f.ts | 87.66 kB ( |
| d_mat2x2f.ts | 87.66 kB ( |
| d_mat3x3f.ts | 87.66 kB ( |
| d_matToArray.ts | 87.66 kB ( |
| d_builtin.ts | 87.66 kB ( |
| std_unpack2x16float.ts | 105.48 kB ( |
| std_unpack4x8unorm.ts | 105.48 kB ( |
| std_pack2x16float.ts | 105.48 kB ( |
| std_pack4x8unorm.ts | 105.48 kB ( |
| std_bitcastU32toF32.ts | 105.48 kB ( |
| std_bitcastU32toI32.ts | 105.48 kB ( |
| std_neg.ts | 105.47 kB ( |
| std_bitShiftRight.ts | 105.48 kB ( |
| std_bitShiftLeft.ts | 105.48 kB ( |
| std_add.ts | 105.47 kB ( |
| std_div.ts | 105.47 kB ( |
| std_mod.ts | 105.47 kB ( |
| std_mul.ts | 105.47 kB ( |
| std_sub.ts | 105.47 kB ( |
| std_translate4.ts | 105.47 kB ( |
| std_rotateX4.ts | 105.47 kB ( |
| std_scale4.ts | 105.47 kB ( |
| std_rotateY4.ts | 105.47 kB ( |
| std_rotateZ4.ts | 105.47 kB ( |
| d_memoryLayoutOf.ts | 87.66 kB ( |
| std_and.ts | 105.47 kB ( |
| std_or.ts | 105.47 kB ( |
| std_select.ts | 105.47 kB ( |
| std_allEq.ts | 105.47 kB ( |
| std_all.ts | 105.47 kB ( |
| std_not.ts | 105.47 kB ( |
| std_eq.ts | 105.47 kB ( |
| std_lt.ts | 105.47 kB ( |
| std_ne.ts | 105.47 kB ( |
| std_isCloseTo.ts | 105.47 kB ( |
| std_any.ts | 105.47 kB ( |
| std_ge.ts | 105.47 kB ( |
| std_gt.ts | 105.47 kB ( |
| std_le.ts | 105.47 kB ( |
| std_dot4U8Packed.ts | 105.48 kB ( |
| std_length.ts | 105.47 kB ( |
| std_countTrailingZeros.ts | 105.48 kB ( |
| std_distance.ts | 105.47 kB ( |
| std_dot.ts | 105.47 kB ( |
| std_countLeadingZeros.ts | 105.48 kB ( |
| std_firstTrailingBit.ts | 105.48 kB ( |
| std_firstLeadingBit.ts | 105.48 kB ( |
| std_fract.ts | 105.47 kB ( |
| std_frexp.ts | 105.47 kB ( |
| std_modf.ts | 105.47 kB ( |
| std_quantizeToF16.ts | 105.48 kB ( |
| std_mix.ts | 105.47 kB ( |
| std_countOneBits.ts | 105.48 kB ( |
| std_dot4I8Packed.ts | 105.48 kB ( |
| std_determinant.ts | 105.48 kB ( |
| std_extractBits.ts | 105.48 kB ( |
| std_faceForward.ts | 105.48 kB ( |
| std_inverseSqrt.ts | 105.48 kB ( |
| std_reverseBits.ts | 105.48 kB ( |
| std_insertBits.ts | 105.47 kB ( |
| std_smoothstep.ts | 105.47 kB ( |
| std_normalize.ts | 105.47 kB ( |
| std_transpose.ts | 105.47 kB ( |
| std_saturate.ts | 105.47 kB ( |
| std_degrees.ts | 105.47 kB ( |
| std_radians.ts | 105.47 kB ( |
| std_reflect.ts | 105.47 kB ( |
| std_refract.ts | 105.47 kB ( |
| std_acosh.ts | 105.47 kB ( |
| std_asinh.ts | 105.47 kB ( |
| std_atan2.ts | 105.47 kB ( |
| std_atanh.ts | 105.47 kB ( |
| std_clamp.ts | 105.47 kB ( |
| std_cross.ts | 105.47 kB ( |
| std_floor.ts | 105.47 kB ( |
| std_ldexp.ts | 105.47 kB ( |
| std_round.ts | 105.47 kB ( |
| std_trunc.ts | 105.47 kB ( |
| std_acos.ts | 105.47 kB ( |
| std_asin.ts | 105.47 kB ( |
| std_atan.ts | 105.47 kB ( |
| std_ceil.ts | 105.47 kB ( |
| std_cosh.ts | 105.47 kB ( |
| std_exp2.ts | 105.47 kB ( |
| std_log2.ts | 105.47 kB ( |
| std_sign.ts | 105.47 kB ( |
| std_sinh.ts | 105.47 kB ( |
| std_sqrt.ts | 105.47 kB ( |
| std_step.ts | 105.47 kB ( |
| std_tanh.ts | 105.47 kB ( |
| std_abs.ts | 105.47 kB ( |
| std_cos.ts | 105.47 kB ( |
| std_exp.ts | 105.47 kB ( |
| std_fma.ts | 105.47 kB ( |
| std_log.ts | 105.47 kB ( |
| std_max.ts | 105.47 kB ( |
| std_min.ts | 105.47 kB ( |
| std_pow.ts | 105.47 kB ( |
| std_sin.ts | 105.47 kB ( |
| std_tan.ts | 105.47 kB ( |
| common_fullScreenTriangle.ts | 57.18 kB ( |
| common_writeSoA.ts | 57.17 kB ( |
| STATIC_allImports.ts | 289.92 kB ( |
| STATIC_d.ts | 87.65 kB ( |
| STATIC_std.ts | 105.46 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.91, 1.85, 4.25, 6.10, 6.59, 9.58, 20.85, 21.27]
line [0.87, 1.71, 3.79, 6.21, 7.05, 9.96, 21.13, 24.71]
line [0.83, 1.78, 3.73, 5.69, 6.55, 10.46, 20.71, 23.26]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.26, 0.49, 0.63, 0.85, 1.08, 1.15, 1.35, 1.51]
line [0.25, 0.46, 0.61, 0.72, 1.08, 1.07, 1.29, 1.47]
line [0.27, 0.49, 0.64, 0.76, 1.07, 1.13, 1.34, 1.46]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.92, 1.98, 3.66, 5.86, 11.64, 24.45, 51.43, 106.59]
line [0.80, 1.98, 3.43, 5.92, 11.93, 24.65, 51.65, 105.50]
line [0.99, 2.03, 3.56, 5.89, 11.66, 24.59, 51.95, 104.82]
|
There was a problem hiding this comment.
Pull request overview
Adds support for creating “transient” (memoryless) textures by exposing a new $usage('transient') option and mapping it to WebGPU’s GPUTextureUsage.TRANSIENT_ATTACHMENT usage bit.
Changes:
- Added a new
'transient'usage literal to the texture usage extension/type system. - Updated
TgpuTextureImpl.$usage()to applyGPUTextureUsage.TRANSIENT_ATTACHMENT | GPUTextureUsage.RENDER_ATTACHMENTwhen'transient'is requested. - Added a test asserting transient textures are created with the exact intended WebGPU usage bits.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/typegpu/tests/texture.test.ts | Adds a regression test asserting transient textures are created with `TRANSIENT_ATTACHMENT |
| packages/typegpu/src/core/texture/usageExtension.ts | Extends AllowedUsages and the literal-to-flag map to include 'transient'. |
| packages/typegpu/src/core/texture/texture.ts | Implements 'transient' handling in $usage() by manipulating GPUTextureUsage flags and usableAsRender. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TRANSIENT_ATTACHMENT for TexturesTRANSIENT_ATTACHMENT for Textures and add an escape hatch
There was a problem hiding this comment.
Important
transient can currently be combined with incompatible texture usages that produce an invalid WebGPU descriptor.
Reviewed changes — Added support for the WebGPU TRANSIENT_ATTACHMENT texture usage through a new transient usage literal.
packages/typegpu/src/core/texture/texture.ts— Extended$usageto accept'transient'and set the requiredTRANSIENT_ATTACHMENT | RENDER_ATTACHMENTbits while clearing copy flags.packages/typegpu/src/core/texture/usageExtension.ts— MappedtransienttoRenderFlagand added it toAllowedUsages.packages/typegpu/tests/texture.test.ts— Added a test verifying the exact WebGPU usage bits and resulting type.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The new $setFlags escape hatch overwrites #flags without updating the runtime usableAs* booleans, leaving internal state inconsistent.
Reviewed changes (since 38e05a4) — Added a $setFlags(flags) method that lets callers overwrite a texture's WebGPU usage flags directly.
packages/typegpu/src/core/texture/texture.ts— Added$setFlagsto theTgpuTextureinterface and toTgpuTextureImpl.packages/typegpu/tests/texture.test.ts— Added a test verifying$setFlagspasses the exact flags through tocreateTexture.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The transient-conflict validation added in this commit looks correct, but the outstanding $setFlags runtime-state concern from the prior review still needs to be addressed before merging.
Reviewed changes (since f466301) — Added runtime validation and tests to prevent transient from being combined with sampled or storage.
packages/typegpu/src/core/texture/texture.ts— Now throws whentransientis combined withsampled/storageand assigns the exactTRANSIENT_ATTACHMENT | RENDER_ATTACHMENTbits.packages/typegpu/tests/texture.test.ts— Added a test covering the runtime rejection oftransient+sampled.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The new $overrideFlags escape hatch creates a false positive in the $usage('transient') conflict guard.
Reviewed changes — Renamed the raw-flags escape hatch to $overrideFlags, documented it, and updated its runtime-boolean behavior.
- Renamed
$setFlagsto$overrideFlagsinpackages/typegpu/src/core/texture/texture.tsand updated the test accordingly. - Updated
$overrideFlagsreturn type and side effects — it now setsusableAsSampled,usableAsStorage, andusableAsRendertotrueand returnsthis & SampledFlag & StorageFlag & RenderFlag. - Added documentation for
$overrideFlagsinapps/typegpu-docs/src/content/docs/apis/textures.mdxwith a caution note explaining that it replaces inferred flags and marks the texture as usable through all typed APIs.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
test
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
|
||
| if (hasTransient) { | ||
| this.#flags = GPUTextureUsage.TRANSIENT_ATTACHMENT | GPUTextureUsage.RENDER_ATTACHMENT; | ||
| } |
There was a problem hiding this comment.
I think you're doing this already above on line 289
this.#flags |= hasTransient
? GPUTextureUsage.TRANSIENT_ATTACHMENT | GPUTextureUsage.RENDER_ATTACHMENT
: 0;There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — Refined $overrideFlags typing and the transient-conflict guard in .$usage().
- Changed
$overrideFlagsreturn type inpackages/typegpu/src/core/texture/texture.tsfromUnionToIntersection<LiteralToExtensionMap['sampled' | 'storage' | 'render']>to the equivalentStorageFlag & SampledFlag & RenderFlagintersection. - Simplified the transient-conflict guard so it checks actual GPU usage bits in
#flagsinstead ofusableAs*booleans, and restores the previous flags before throwing. - Updated type imports to pull
StorageFlag,SampledFlag, andRenderFlagdirectly from their source modules.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — Refactored the $usage() flag logic in packages/typegpu/src/core/texture/texture.ts for readability without changing behavior.
- Reordered
packages/typegpu/src/core/texture/texture.tsso that$usage()computesbindingFlags,transientFlags, andnextFlagsbefore checking the transient-vs-sampled/storage conflict, throwing before mutating#flagsrather than assigning then restoring. - The conflict guard now derives
hasTransientUsageandhasSampledOrStorageUsagefrom the same precomputed flags, making the mutually-exclusive transient rule easier to follow. - Texture unit tests continue to pass (
38 passed).
Kimi K2 (free via Pullfrog for OSS) | 𝕏

This PR also adds
setFlagsfor textures, it's notaddFlagslike for the buffers because i believe for the escape hatch we should give full control (for exampleaddFlagswould've not been enough for users wanting to use TRANSIENT_ATTACHMENT before we officially support it since it is exclusive with the default copy flags, I believe buffers should also expose such a method in the future)