@carbonenginejs/runtime 0.1.0-alpha.6 → 0.1.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @carbonenginejs/runtime might be problematic. Click here for more details.
- package/dist/global/consts/effectPaths.js +4 -1
- package/dist/global/consts/effectPaths.js.map +1 -1
- package/dist/global/consts/index.js +1 -1
- package/dist/global/index.js +1 -1
- package/dist/index.js +3 -3
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +19 -2
- package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
- package/dist/resource/format/index.js +1 -1
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js +121 -65
- package/dist/resource/formats/hlsl/core/carbonTypedViews.js.map +1 -1
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +10 -7
- package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js +3 -1
- package/dist/resource/formats/webgpu/core/effectBackendBodySet.js.map +1 -1
- package/dist/resource/formats/webgpu/core/packageEffect.js +5 -0
- package/dist/resource/formats/webgpu/core/packageEffect.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js +20 -0
- package/dist/resource/formats/webgpu/core/wgsl/emitWgsl.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js +93 -4
- package/dist/resource/formats/webgpu/core/wgsl/emulatedAddressing.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +74 -64
- package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js +16 -7
- package/dist/resource/formats/webgpu/core/wgsl/lowerFragmentProgram.js.map +1 -1
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js +69 -27
- package/dist/resource/formats/webgpu/core/wgsl/wgslTypedViews.js.map +1 -1
- package/dist/resource/geometry/registerGeometryResources.js +10 -1
- package/dist/resource/geometry/registerGeometryResources.js.map +1 -1
- package/dist/sof/EveSOFDNA.js +4 -2
- package/dist/sof/EveSOFDNA.js.map +1 -1
- package/dist/sof/EveSOFDataMgr.js +83 -69
- package/dist/sof/EveSOFDataMgr.js.map +1 -1
- package/dist/trinity/core/Tr2Denoiser.js +6 -1
- package/dist/trinity/core/Tr2Denoiser.js.map +1 -1
- package/dist/trinity/core/Tr2ShadowMap.js +7 -2
- package/dist/trinity/core/Tr2ShadowMap.js.map +1 -1
- package/dist/trinity/core/context/Tr2RenderContext.js +43 -0
- package/dist/trinity/core/context/Tr2RenderContext.js.map +1 -1
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js +134 -0
- package/dist/trinity/core/device/Tr2GpuStructuredBuffer.js.map +1 -0
- package/dist/trinity/core/index.js +1 -0
- package/dist/trinity/core/index.js.map +1 -1
- package/dist/trinity/core/lighting/Tr2LightManager.js +410 -124
- package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js +303 -312
- package/dist/trinity/eve/effect/lensflare/EveLensflare.js.map +1 -1
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js +117 -0
- package/dist/trinity/eve/effect/lensflare/EveOccluder.js.map +1 -0
- package/dist/trinity/eve/index.js +1 -0
- package/dist/trinity/eve/index.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceScene.js +286 -6
- package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +212 -32
- package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
- package/dist/trinity/generated/eve/effect/index.js +0 -1
- package/dist/trinity/generated/eve/effect/index.js.map +1 -1
- package/dist/trinity/generated/eve/index.js +0 -1
- package/dist/trinity/generated/eve/index.js.map +1 -1
- package/dist/trinity/generated/index.js +0 -2
- package/dist/trinity/generated/index.js.map +1 -1
- package/dist/trinity/generated/trinityCore/index.js +0 -1
- package/dist/trinity/generated/trinityCore/index.js.map +1 -1
- package/dist/trinity/index.js +2 -2
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js +4 -1
- package/dist/trinity/postProcess/Tr2PostProcessRenderer.js.map +1 -1
- package/dist/trinity/postProcess/Tr2SSAO.js +282 -21
- package/dist/trinity/postProcess/Tr2SSAO.js.map +1 -1
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js +71 -53
- package/dist/trinity/shader/parameter/Tr2RuntimeTextureParameter.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +81 -18
- package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js +46 -4
- package/dist/trinityal/webgpu/CjsWebgpuResourceSetAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js +32 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js +27 -0
- package/dist/trinityal/webgpu/CjsWebgpuShaderProgramAL.js.map +1 -1
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +29 -4
- package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js +32 -2
- package/dist/trinityal/webgpu/core/CjsWebgpuPsoDescription.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +57 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -1
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js +111 -5
- package/dist/trinityal/webgpu/core/CjsWebgpuWorkQueue.js.map +1 -1
- package/docs/trinity/reference/classes/generated.md +20 -20
- package/docs/trinity/reference/classes/post-process.md +1 -1
- package/package.json +1 -1
- package/dist/trinity/generated/eve/effect/EveOccluder.js +0 -38
- package/dist/trinity/generated/eve/effect/EveOccluder.js.map +0 -1
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js +0 -48
- package/dist/trinity/generated/trinityCore/Tr2GpuStructuredBuffer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsWebgpuTextureAL.js","sources":["../../../../src/trinityal/webgpu/CjsWebgpuTextureAL.js"],"sourcesContent":["// Source: trinity/trinityal/include/Tr2TextureAL.h\n// trinity/trinityal/metal/Tr2TextureALMetal.mm\n// trinity/trinityal/stub/Tr2TextureALStub.cpp\n//\n// A `Tr2TextureAL` holding a real `GPUTexture`.\n//\n// CREATED WITH ITS DATA, NEVER UPDATED INTO. Carbon's texture resource creates\n// its texture from the decoded bitmap with one `Tr2SubresourceData` per\n// (mip, layer), indexed `mip + layer * mipCount`\n// (`Tr2ImageIOHelpers.cpp:104-128`), and Metal uploads them one\n// `replaceRegion` per (slice, mip) (`Tr2TextureALMetal.mm:140-268`). This does\n// the same with one `writeTexture` per subresource.\n//\n// THE sRGB VIEW IS A FORMAT-REINTERPRETING VIEW, as Metal's is: `MetalContext.mm:342-357`\n// makes `newTextureViewWithPixelFormat:` of the sRGB sibling for RGBA8, BGRA8,\n// BC1, BC2, BC3 and BC7, and `GetSRGBViewMetalTexture()` is what a\n// `COLOR_SPACE_SRGB` SRV binds. WebGPU needs the sibling declared in\n// `viewFormats` at creation, so it is.\n//\n// FIELDS ARE PUBLIC AND CARBON-NAMED, for the reason recorded on `CjsWebgpuShaderAL`.\nimport { CjsSchema } from \"#schema\";\nimport { ALResult, CopyRegion, Crop, Tr2ALMemoryType, Tr2MsaaDesc, Tr2TextureSubresource } from \"#trinityal\";\nimport { PixelFormat, TextureType, Tr2CpuUsage, Tr2GpuUsage, HasFlag, IsWritable } from \"#consts/render-context\";\nimport { RenderContextALOf } from \"../renderContextAL.js\";\n\nconst NO_HEAP_INDEX = 0xffffffff;\n\n/** Carbon texture type to WebGPU's view dimension for the texture as a whole. */\nconst VIEW_DIMENSION_OF_TYPE = Object.freeze({\n [TextureType.TEX_TYPE_2D]: \"2d\",\n [TextureType.TEX_TYPE_CUBE]: \"cube\",\n [TextureType.TEX_TYPE_3D]: \"3d\"\n});\n\n/**\n * The formats core WebGPU accepts with STORAGE_BINDING (the WebGPU spec's\n * texture format capabilities table). D3D lets far more formats be UAVs.\n */\nconst STORAGE_FORMATS = new Set([\n \"rgba8unorm\", \"rgba8snorm\", \"rgba8uint\", \"rgba8sint\",\n \"rgba16uint\", \"rgba16sint\", \"rgba16float\",\n \"r32uint\", \"r32sint\", \"r32float\",\n \"rg32uint\", \"rg32sint\", \"rg32float\",\n \"rgba32uint\", \"rgba32sint\", \"rgba32float\"\n]);\n\n/**\n * The format a UAV texture is created in when WebGPU cannot store to the one\n * Carbon asked for. An sRGB format takes its linear sibling (same bytes; the\n * sRGB format stays a sampling view); anything else takes rgba16float, the\n * substitute Carbon's own DX12 path chooses for a non-UAV-compatible target\n * (Tr2ReflectionProbe.cpp:235-236).\n *\n * @param {string} format The requested `GPUTextureFormat`.\n * @returns {string} A storage-capable format.\n */\nfunction StorageFormatFor(format)\n{\n if (STORAGE_FORMATS.has(format)) return format;\n const linear = format.replace(/-srgb$/u, \"\");\n return STORAGE_FORMATS.has(linear) ? linear : \"rgba16float\";\n}\n\n\n/**\n * A `Tr2TextureAL` backed by a WebGPU `GPUTexture`, created with all of its data.\n */\nexport class CjsWebgpuTextureAL\n{\n /** m_desc, a `Tr2BitmapDimensions`. */\n m_desc = null;\n\n m_msaa = new Tr2MsaaDesc();\n\n m_gpuUsage = Tr2GpuUsage.NONE;\n\n m_cpuUsage = Tr2CpuUsage.NONE;\n\n /** The `GPUTexture`, or null before Create. */\n m_texture = null;\n\n /** The `GPUTextureFormat` it was created with. */\n m_format = null;\n\n /** The sRGB sibling format, when the format has one and a view of it exists. */\n m_srgbFormat = null;\n\n /** Views by `dimension:colorSpace`, made on first request. */\n m_views = new Map();\n\n m_webgpu = null;\n\n m_name = \"\";\n\n /**\n * Creates the texture and uploads its initial data.\n *\n * @param {object} desc A `Tr2BitmapDimensions`.\n * @param {object} options `{ gpuUsage, cpuUsage, msaa, initialData }`;\n * `initialData` is an array of `Tr2SubresourceData`\n * indexed `mip + layer * mipCount`, as Carbon's is.\n * @param {object} renderContext The render context, Trinity's or the AL.\n * @returns {number} An `ALResult` value.\n */\n Create(desc, options, renderContext)\n {\n this.Destroy();\n\n const { gpuUsage = Tr2GpuUsage.NONE, cpuUsage = Tr2CpuUsage.NONE, msaa = new Tr2MsaaDesc(), initialData = null } = options ?? {};\n const al = RenderContextALOf(renderContext);\n\n if (!al || !al.IsValid()) return ALResult.E_FAIL;\n if (!desc || desc.GetWidth() === 0 || desc.GetHeight() === 0) return ALResult.E_INVALIDARG;\n if (msaa.samples > 1) return ALResult.E_INVALIDARG;\n\n const type = desc.GetType();\n const dimension = VIEW_DIMENSION_OF_TYPE[type];\n\n if (!dimension) return ALResult.E_INVALIDARG;\n if (type === TextureType.TEX_TYPE_CUBE && desc.GetArraySize() % 6 !== 0) return ALResult.E_INVALIDARG;\n\n // Carbon's own rule (the stub's last check): a texture nothing can ever\n // write that arrives with no pixels samples black forever. Refused.\n const writable = HasFlag(gpuUsage, Tr2GpuUsage.RENDER_TARGET) || HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS)\n || HasFlag(gpuUsage, Tr2GpuUsage.DEPTH_STENCIL) || HasFlag(cpuUsage, Tr2CpuUsage.WRITE);\n\n if (!writable && !initialData) return ALResult.E_INVALIDARG;\n\n const requestedFormat = al.m_utils.GetGPUTextureFormat(desc.GetFormat());\n\n if (!requestedFormat) return ALResult.E_INVALIDARG;\n\n // A UAV texture is created in a format WebGPU can store to. Only a\n // same-bytes sibling keeps initial data valid; pixels laid out for the\n // requested format cannot be uploaded into rgba16float, so that pairing\n // is refused rather than uploaded wrong.\n const format = HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS) ? StorageFormatFor(requestedFormat) : requestedFormat;\n const sameBytes = format === requestedFormat || format === requestedFormat.replace(/-srgb$/u, \"\");\n\n if (initialData && !sameBytes) return ALResult.E_INVALIDARG;\n\n const webgpu = al.GetWebgpu();\n if (!webgpu) return ALResult.E_INVALIDCALL;\n\n const device = webgpu.GetDevice();\n const usageFlags = webgpu.GetTextureUsage();\n const srgbFormat = requestedFormat !== format && requestedFormat.endsWith(\"-srgb\")\n ? requestedFormat\n : al.m_utils.GetSRGBViewFormat(format);\n const mipCount = Math.max(1, desc.GetTrueMipCount());\n const layers = type === TextureType.TEX_TYPE_3D ? Math.max(1, desc.GetDepth()) : Math.max(1, desc.GetArraySize());\n let usage = usageFlags.TEXTURE_BINDING | usageFlags.COPY_DST;\n\n if (HasFlag(gpuUsage, Tr2GpuUsage.RENDER_TARGET) || HasFlag(gpuUsage, Tr2GpuUsage.DEPTH_STENCIL))\n {\n usage |= usageFlags.RENDER_ATTACHMENT ?? 0;\n }\n\n // An unordered-access texture is written through a storage binding;\n // D3D's UAV is WebGPU's STORAGE_BINDING, where the format allows one.\n if (HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS)) usage |= usageFlags.STORAGE_BINDING ?? 0;\n\n // A texture something renders or computes into is also a copy source, as\n // D3D resources are without a flag: CopySubresourceRegion reads it.\n if (HasFlag(gpuUsage, Tr2GpuUsage.RENDER_TARGET) || HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS))\n {\n usage |= usageFlags.COPY_SRC ?? 0;\n }\n\n // A sampled depth texture is copied into its float shadow (see _CreateDepthShadow).\n const depthShadow = format === \"depth32float\" && HasFlag(gpuUsage, Tr2GpuUsage.DEPTH_STENCIL)\n && HasFlag(gpuUsage, Tr2GpuUsage.SHADER_RESOURCE);\n\n if (depthShadow) usage |= usageFlags.COPY_SRC ?? 0;\n\n this.m_texture = device.createTexture({\n label: this.m_name || \"Tr2TextureAL\",\n size: { width: desc.GetWidth(), height: desc.GetHeight(), depthOrArrayLayers: layers },\n mipLevelCount: mipCount,\n sampleCount: 1,\n dimension: type === TextureType.TEX_TYPE_3D ? \"3d\" : \"2d\",\n format,\n usage,\n ...(srgbFormat ? { viewFormats: [ srgbFormat ] } : {})\n });\n this.m_format = format;\n this.m_srgbFormat = srgbFormat;\n this.m_desc = desc;\n this.m_msaa = msaa;\n this.m_gpuUsage = gpuUsage;\n this.m_cpuUsage = cpuUsage;\n this.m_webgpu = webgpu;\n\n if (depthShadow) this._CreateDepthShadow(device, usageFlags);\n if (initialData) this._Upload(initialData, mipCount, type);\n\n return ALResult.S_OK;\n }\n\n /**\n * The r32float copy a sampled depth texture is read through, or null.\n *\n * D3D creates Carbon's sampled depth as R32_TYPELESS, with the depth view in\n * D32_FLOAT and the shader view in R32_FLOAT, so a shader samples depth as an\n * ordinary float texture through any sampler. WebGPU binds depth32float only\n * as \"depth\" or \"unfilterable-float\", and the translated shaders declare\n * `texture_2d<f32>` in a filterable slot: the GPU refused the bind group.\n * No view can reinterpret depth32float as r32float and a texture-to-texture\n * copy needs matching formats, so the depth goes through a buffer:\n * `EncodeDepthShadowCopy` copies depth into it and on into this texture,\n * which is what the shader view returns. The context encodes that copy\n * whenever the depth stencil is unbound, which is when its pass has ended.\n */\n _depthShadow = null;\n\n /** Makes the float shadow and the row-aligned buffer the copy passes through. */\n _CreateDepthShadow(device, usageFlags)\n {\n const width = this.m_desc.GetWidth();\n const height = this.m_desc.GetHeight();\n // copyTextureToBuffer rows are 256-byte aligned.\n const bytesPerRow = Math.ceil((width * 4) / 256) * 256;\n const bufferUsage = this.m_webgpu.GetBufferUsage();\n\n this._depthShadow = {\n bytesPerRow,\n texture: device.createTexture({\n label: `${this.m_name || \"Tr2TextureAL\"} depth shadow`,\n size: { width, height, depthOrArrayLayers: 1 },\n format: \"r32float\",\n usage: usageFlags.TEXTURE_BINDING | usageFlags.COPY_DST\n }),\n buffer: device.createBuffer({\n label: `${this.m_name || \"Tr2TextureAL\"} depth shadow`,\n size: bytesPerRow * height,\n usage: bufferUsage.COPY_SRC | bufferUsage.COPY_DST\n })\n };\n }\n\n /**\n * Copies the depth into its float shadow, on the frame's command encoder\n * and outside any pass. Nothing for a texture without one.\n *\n * @param {GPUCommandEncoder} commandEncoder The frame's encoder.\n * @returns {boolean} Whether a copy was encoded.\n */\n EncodeDepthShadowCopy(commandEncoder)\n {\n const shadow = this._depthShadow;\n\n if (!shadow || !commandEncoder) return false;\n\n const size = { width: this.m_desc.GetWidth(), height: this.m_desc.GetHeight(), depthOrArrayLayers: 1 };\n const layout = { offset: 0, bytesPerRow: shadow.bytesPerRow, rowsPerImage: size.height };\n\n commandEncoder.copyTextureToBuffer({ texture: this.m_texture, aspect: \"depth-only\" }, { buffer: shadow.buffer, ...layout }, size);\n commandEncoder.copyBufferToTexture({ buffer: shadow.buffer, ...layout }, { texture: shadow.texture }, size);\n\n return true;\n }\n\n /** One `writeTexture` per subresource, Carbon's `mip + layer * mipCount` order. */\n _Upload(initialData, mipCount, type)\n {\n const desc = this.m_desc;\n const queue = this.m_webgpu.GetDevice().queue;\n const layerCount = type === TextureType.TEX_TYPE_3D ? 1 : Math.max(1, desc.GetArraySize());\n\n for (let layer = 0; layer < layerCount; layer += 1)\n {\n for (let mip = 0; mip < mipCount; mip += 1)\n {\n const subresource = initialData[mip + layer * mipCount];\n\n if (!subresource || !subresource.m_sysMem) continue;\n\n const bytes = subresource.m_sysMem;\n const pitch = subresource.m_sysMemPitch;\n const slicePitch = subresource.m_sysMemSlicePitch || bytes.byteLength;\n const depth = type === TextureType.TEX_TYPE_3D ? Math.max(1, desc.GetMipDepth(mip)) : 1;\n\n queue.writeTexture(\n { texture: this.m_texture, mipLevel: mip, origin: { x: 0, y: 0, z: layer } },\n bytes,\n { offset: 0, bytesPerRow: pitch, rowsPerImage: pitch ? Math.max(1, Math.floor(slicePitch / pitch)) : undefined },\n { width: desc.GetMipWidth(mip), height: desc.GetMipHeight(mip), depthOrArrayLayers: depth }\n );\n }\n }\n }\n\n /**\n * The view a resource set binds: linear or sRGB, in the layout's dimension.\n *\n * Metal's `GetMetalTexture()` / `GetSRGBViewMetalTexture()`\n * (`Tr2TextureALMetal.h:49-54`), with the dimension added because a WebGPU\n * view must name it and a cube texture is legitimately bound as a 2d-array.\n *\n * @param {string} [viewDimension] A `GPUTextureViewDimension`.\n * @param {number} [colorSpace] A `Tr2ColorSpace`; non-zero means sRGB.\n * @returns {object|null} A `GPUTextureView`, or null before Create.\n */\n GetDeviceTextureView(viewDimension = VIEW_DIMENSION_OF_TYPE[this.m_desc?.GetType()] ?? \"2d\", colorSpace = 0)\n {\n if (!this.m_texture) return null;\n\n // A sampled depth texture is read through its float shadow.\n const source = this._depthShadow ? this._depthShadow.texture : this.m_texture;\n const srgb = colorSpace !== 0 && this.m_srgbFormat !== null;\n const key = `${viewDimension}:${srgb ? \"srgb\" : \"linear\"}`;\n let view = this.m_views.get(key) ?? null;\n\n if (!view)\n {\n view = source.createView({\n label: `${this.m_name || \"Tr2TextureAL\"} ${key}`,\n dimension: viewDimension,\n ...(srgb ? { format: this.m_srgbFormat } : {})\n });\n this.m_views.set(key, view);\n }\n\n return view;\n }\n\n /**\n * The view a storage (UAV) binding writes: ONE mip level, every layer.\n *\n * Carbon binds a UAV at a mip (`Tr2ResourceSetDescriptionAL::SetUav`'s\n * `mip`), and a WebGPU storage view must name exactly one. A cube is bound\n * as a 2d-array of its faces, which is how a compute shader writes one.\n *\n * @param {string} viewDimension The binding's `storageTexture.viewDimension`.\n * @param {number} mip The mip level.\n * @returns {GPUTextureView|null} The view, or null before Create or for a texture created without UAV usage.\n */\n GetDeviceStorageView(viewDimension, mip)\n {\n // Only a texture created with UNORDERED_ACCESS carries STORAGE_BINDING.\n if (!this.m_texture || !HasFlag(this.m_gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS)) return null;\n\n const key = `storage:${viewDimension}:${mip}`;\n let view = this.m_views.get(key) ?? null;\n\n if (!view)\n {\n view = this.m_texture.createView({\n label: `${this.m_name || \"Tr2TextureAL\"} ${key}`,\n dimension: viewDimension,\n baseMipLevel: mip,\n mipLevelCount: 1\n });\n this.m_views.set(key, view);\n }\n\n return view;\n }\n\n /**\n * The view a render pass attaches: mip zero of one slice, in the created\n * format. Metal attaches the texture with a `slice` on the pass descriptor\n * (`MetalWorkQueue.mm:2000-2014`); a WebGPU attachment view must name exactly\n * one mip and one layer instead.\n *\n * @param {number} [slice] The array slice or cube face.\n * @returns {GPUTextureView|null} The view, or null before Create.\n */\n GetDeviceRenderTargetView(slice = 0)\n {\n if (!this.m_texture) return null;\n\n const key = `attachment:${slice}`;\n let view = this.m_views.get(key) ?? null;\n\n if (!view)\n {\n view = this.m_texture.createView({\n label: `${this.m_name || \"Tr2TextureAL\"} ${key}`,\n dimension: \"2d\",\n baseMipLevel: 0,\n mipLevelCount: 1,\n baseArrayLayer: slice,\n arrayLayerCount: 1\n });\n this.m_views.set(key, view);\n }\n\n return view;\n }\n\n /**\n * The `GPUTextureFormat` the texture was created in. A UAV texture may differ\n * from its Carbon format (see `StorageFormatFor`), so a render pass or\n * pipeline targeting it reads this, not the description's format.\n *\n * @returns {string|null} The format, or null before Create.\n */\n GetDeviceFormat()\n {\n return this.m_format;\n }\n\n /** The `GPUTexture`; Metal's `GetMetalTexture` under this backend's name. */\n GetDeviceTexture()\n {\n return this.m_texture;\n }\n\n /** Whether the texture holds a `GPUTexture`. */\n IsValid()\n {\n return this.m_texture !== null;\n }\n\n /** Shared textures need a native handle WebGPU does not expose; always fails. */\n OpenShared()\n {\n return ALResult.E_FAIL;\n }\n\n /** The `Tr2BitmapDimensions` this texture was created from, or null. */\n GetDesc()\n {\n return this.m_desc;\n }\n\n /** The multisample description; this backend creates single-sampled textures. */\n GetMsaaDesc()\n {\n return this.m_msaa;\n }\n\n /** The `Tr2GpuUsage` flags it was created with. */\n GetGpuUsage()\n {\n return this.m_gpuUsage;\n }\n\n /** The `Tr2CpuUsage` flags it was created with. */\n GetCpuUsage()\n {\n return this.m_cpuUsage;\n }\n\n /** Width in texels of mip zero, or zero before Create. */\n GetWidth()\n {\n return this.m_desc ? this.m_desc.GetWidth() : 0;\n }\n\n /** Height in texels of mip zero, or zero before Create. */\n GetHeight()\n {\n return this.m_desc ? this.m_desc.GetHeight() : 0;\n }\n\n /** Depth in texels of mip zero, which is one unless the texture is 3D. */\n GetDepth()\n {\n return this.m_desc ? this.m_desc.GetDepth() : 0;\n }\n\n /** The mip count requested at creation, which may be zero for a full chain. */\n GetMipCount()\n {\n return this.m_desc ? this.m_desc.GetMipCount() : 0;\n }\n\n /** The mip count actually created, with a requested zero resolved. */\n GetTrueMipCount()\n {\n return this.m_desc ? this.m_desc.GetTrueMipCount() : 0;\n }\n\n /** The Carbon `PixelFormat`, or `PIXEL_FORMAT_UNKNOWN` before Create. */\n GetFormat()\n {\n return this.m_desc ? this.m_desc.GetFormat() : PixelFormat.PIXEL_FORMAT_UNKNOWN;\n }\n\n /** The Carbon `TextureType`, or `TEX_TYPE_INVALID` before Create. */\n GetType()\n {\n return this.m_desc ? this.m_desc.GetType() : TextureType.TEX_TYPE_INVALID;\n }\n\n /** The layer count, which for a cube counts its six faces. */\n GetArraySize()\n {\n return this.m_desc ? this.m_desc.GetArraySize() : 0;\n }\n\n /**\n * The byte size of one mip across all layers.\n *\n * @param {number} level The mip level.\n * @returns {number} Its size in bytes, or zero before Create.\n */\n GetMipSize(level)\n {\n return this.m_desc ? this.m_desc.GetMipSize(level) : 0;\n }\n\n /** Reading back needs a staging buffer and an await; refused by name. */\n MapForReading(_region, _synchronize, _renderContext)\n {\n return { result: ALResult.E_FAIL, data: null, pitch: 0 };\n }\n\n /** Paired with `MapForReading`, which this backend refuses. */\n UnmapForReading(_renderContext)\n {\n return ALResult.E_FAIL;\n }\n\n /** The CPU copy a write mapping hands out; kept between maps for WRITE_OFTEN. */\n _mappedData = null;\n\n /** The subresource the current write mapping covers, or null when unmapped. */\n _mappedRegion = null;\n\n /**\n * Hands out memory for writing one subresource, Carbon's `MapForWriting`,\n * with the stub's checks (`Tr2TextureALStub.MapForWriting`).\n *\n * WebGPU has no mappable texture memory, so the memory is a CPU copy of the\n * mip, uploaded by `UnmapForWriting` with `queue.writeTexture` - the shape\n * this backend's constant buffers already use. The copy starts zeroed, not\n * with the texture's contents, because WebGPU cannot read a texture back\n * synchronously; so a region with a box is refused rather than letting the\n * upload overwrite the texels outside it. `Tr2DataTextureManager` maps the\n * whole of subresource 0.\n *\n * @param {object} region A `Tr2TextureSubresource`.\n * @param {object} renderContext The render context, Trinity's or the AL.\n * @returns {{result: number, data: Uint8Array|null, pitch: number}} The mapping.\n */\n MapForWriting(region, renderContext)\n {\n if (!HasFlag(this.m_cpuUsage, Tr2CpuUsage.WRITE)) return { result: ALResult.E_INVALIDCALL, data: null, pitch: 0 };\n\n const al = RenderContextALOf(renderContext);\n\n if (!this.IsValid() || !al || !al.IsValid()) return { result: ALResult.E_FAIL, data: null, pitch: 0 };\n if (!region.IsValidForBitmap(this.m_desc) || !region.IsSingleSubresource() || region.HasBox())\n {\n return { result: ALResult.E_INVALIDARG, data: null, pitch: 0 };\n }\n\n const mip = region.m_startMipLevel;\n const pitch = this.m_desc.GetMipPitch(mip);\n const size = pitch * this.m_desc.GetMipHeight(mip);\n\n if (size === 0) return { result: ALResult.E_FAIL, data: null, pitch: 0 };\n if (this._mappedData === null || this._mappedData.length !== size) this._mappedData = new Uint8Array(size);\n\n this._mappedRegion = region;\n\n return { result: ALResult.S_OK, data: this._mappedData, pitch };\n }\n\n /**\n * Uploads what was written into the mapping, Carbon's `UnmapForWriting`.\n * The CPU copy is kept for the next map only when the texture was created\n * `WRITE_OFTEN`, as the stub keeps its buffer.\n *\n * @param {object} renderContext The render context, Trinity's or the AL.\n * @returns {number} An `ALResult` value.\n */\n UnmapForWriting(renderContext)\n {\n if (this._mappedRegion === null) return ALResult.E_INVALIDCALL;\n\n const region = this._mappedRegion;\n const mip = region.m_startMipLevel;\n const pitch = this.m_desc.GetMipPitch(mip);\n const result = this.UpdateSubresource(region, this._mappedData, pitch, pitch * this.m_desc.GetMipHeight(mip), renderContext);\n\n this._mappedRegion = null;\n if (!HasFlag(this.m_cpuUsage, Tr2CpuUsage.WRITE_OFTEN)) this._mappedData = null;\n\n return result;\n }\n\n /**\n * Replaces one mip of one slice, Carbon's `UpdateSubresource`.\n *\n * @param {object} region A `Tr2TextureSubresource` naming one mip and slice.\n * @param {ArrayBufferView} source The texels.\n * @param {number} pitch Bytes per row.\n * @param {number} slicePitch Bytes per slice.\n * @returns {number} An `ALResult` value.\n */\n UpdateSubresource(region, source, pitch, slicePitch, _renderContext)\n {\n if (!this.IsValid()) return ALResult.E_INVALIDCALL;\n if (!region || !source) return ALResult.E_INVALIDARG;\n\n const mip = region.m_startMipLevel ?? 0;\n const layer = region.m_startFace ?? 0;\n\n this.m_webgpu.GetDevice().queue.writeTexture(\n { texture: this.m_texture, mipLevel: mip, origin: { x: 0, y: 0, z: layer } },\n source,\n { offset: 0, bytesPerRow: pitch, rowsPerImage: pitch ? Math.max(1, Math.floor((slicePitch || source.byteLength) / pitch)) : undefined },\n { width: this.m_desc.GetMipWidth(mip), height: this.m_desc.GetMipHeight(mip), depthOrArrayLayers: 1 }\n );\n\n return ALResult.S_OK;\n }\n\n /**\n * Copies a region of another texture into this one, as Metal does\n * (`Tr2TextureALMetal.mm:744-791`): validate, crop both regions against their\n * textures, then one work-queue copy per slice and mip.\n *\n * @param {Tr2TextureSubresource} destSubresource The region to write.\n * @param {CjsWebgpuTextureAL} source The texture to read.\n * @param {Tr2TextureSubresource} sourceSubresource The region to read.\n * @param {object} renderContext The context whose work queue records it.\n * @returns {number} An `ALResult` value.\n */\n CopySubresourceRegion(destSubresource, source, sourceSubresource, renderContext)\n {\n if (!this.IsValid() || !renderContext?.IsValid()) return ALResult.E_INVALIDCALL;\n if (!source?.IsValid()) return ALResult.E_INVALIDARG;\n if (!HasFlag(this.m_cpuUsage, Tr2CpuUsage.WRITE) && !IsWritable(this.m_gpuUsage)) return ALResult.E_INVALIDCALL;\n\n // Carbon takes both regions by value and Crop mutates them.\n const src = CopyRegion(sourceSubresource);\n const dst = CopyRegion(destSubresource);\n\n if (!Crop(src, source.m_desc, dst, this.m_desc)) return ALResult.E_FAIL;\n\n const queue = RenderContextALOf(renderContext).GetWorkQueue();\n const slices = src.m_endFace - src.m_startFace;\n const mips = src.m_endMipLevel - src.m_startMipLevel;\n\n for (let slice = 0; slice < slices; ++slice)\n {\n for (let mip = 0; mip < mips; ++mip)\n {\n queue.CopyTextureToTexture(\n source.m_texture,\n src.m_startFace + slice,\n src.m_startMipLevel + mip,\n { x: src.m_box.left, y: src.m_box.top, z: src.m_box.front },\n { width: src.GetWidth(), height: src.GetHeight(), depthOrArrayLayers: src.GetDepth() },\n this.m_texture,\n dst.m_startFace + slice,\n dst.m_startMipLevel + mip,\n { x: dst.m_box.left, y: dst.m_box.top, z: dst.m_box.front }\n );\n }\n }\n\n return ALResult.S_OK;\n }\n\n /**\n * Regenerates the mip chain, as Metal's `GenerateMipMaps` does\n * (`Tr2TextureALMetal.mm:795-805`): only a render target that is also a\n * shader resource can be, and the work queue encodes it. WebGPU has no\n * generator of its own, so the context's CjsWebgpuMipGenerator stands in for\n * Metal's blit encoder.\n *\n * @param {object} renderContext The context whose work queue encodes it.\n * @returns {number} An `ALResult` value.\n */\n GenerateMipMaps(renderContext)\n {\n if (!HasFlag(this.m_gpuUsage, Tr2GpuUsage.RENDER_TARGET) || !HasFlag(this.m_gpuUsage, Tr2GpuUsage.SHADER_RESOURCE))\n {\n return ALResult.E_INVALIDCALL;\n }\n\n const al = RenderContextALOf(renderContext);\n\n al.GetWorkQueue().GenerateMipMaps(this.m_texture, al.GetMipGenerator());\n\n return ALResult.S_OK;\n }\n\n /**\n * Resolves into `destination`. With one sample every Carbon backend falls\n * back to a plain copy (`Tr2TextureALMetal.mm:807-812`,\n * `Tr2TextureALDx11.cpp:1183-1186`); this backend has no multisampled\n * textures, so the multisample arm fails.\n *\n * @param {CjsWebgpuTextureAL} destination The texture to resolve into.\n * @param {object} renderContext The context whose work queue records it.\n * @returns {number} An `ALResult` value.\n */\n Resolve(destination, renderContext)\n {\n if ((this.m_msaa?.samples ?? 1) <= 1)\n {\n return destination.CopySubresourceRegion(new Tr2TextureSubresource(), this, new Tr2TextureSubresource(), renderContext);\n }\n\n return ALResult.E_FAIL;\n }\n\n /** The native shared handle, which WebGPU does not expose. */\n GetSharedHandle()\n {\n return null;\n }\n\n /** The descriptor-heap slot, which only the D3D12 backend has. */\n GetSrvIndexInHeap()\n {\n return NO_HEAP_INDEX;\n }\n\n /** The descriptor-heap slot, which only the D3D12 backend has. */\n GetUavIndexInHeap()\n {\n return NO_HEAP_INDEX;\n }\n\n /** Releases the `GPUTexture` and its views, leaving the AL invalid. */\n Destroy()\n {\n this.m_texture?.destroy?.();\n this.m_texture = null;\n this._depthShadow?.texture.destroy?.();\n this._depthShadow?.buffer.destroy?.();\n this._depthShadow = null;\n this.m_views = new Map();\n this._mappedData = null;\n this._mappedRegion = null;\n this.m_desc = null;\n this.m_format = null;\n this.m_srgbFormat = null;\n this.m_webgpu = null;\n this.m_gpuUsage = Tr2GpuUsage.NONE;\n this.m_cpuUsage = Tr2CpuUsage.NONE;\n }\n\n /** Where the texture lives, which for this backend is always video memory. */\n GetMemoryClass()\n {\n return Tr2ALMemoryType.AL_MEMORY_VIDEO;\n }\n\n /**\n * Fills in what this AL knows for a memory report.\n *\n * @param {object} description The description to fill in.\n * @returns {object} The same description.\n */\n Describe(description)\n {\n if (!description) return description;\n\n description.memoryClass = this.GetMemoryClass();\n\n return description;\n }\n\n /**\n * Names the texture, which reaches the `GPUTexture` label for debugging.\n *\n * @param {string} name The name.\n * @returns {number} An `ALResult` value.\n */\n SetName(name)\n {\n this.m_name = String(name ?? \"\");\n\n if (this.m_texture) this.m_texture.label = this.m_name;\n\n return ALResult.S_OK;\n }\n\n /** The name given by `SetName`. */\n GetName()\n {\n return this.m_name;\n }\n}\n\n// DECLARED AS A CALL, NOT A DECORATOR, for the reason recorded in\n// Tr2BitmapDimensions.js: the layer is imported straight from source by its\n// tests and raw Node cannot parse decorator syntax.\n//\n// The donor is NAMED rather than left to be derived from this class's name.\n// Carbon calls every backend's class the same thing and carries the backend in\n// the FILE name, because only one backend compiles at a time; we ship them\n// together, so the backend moves onto the class name. That divergence is the\n// author's to declare, never a checker's to guess.\nCjsSchema.define(CjsWebgpuTextureAL, { className: \"CjsWebgpuTextureAL\", carbon: \"Tr2TextureAL\" });\n"],"names":["NO_HEAP_INDEX","VIEW_DIMENSION_OF_TYPE","Object","freeze","TextureType","TEX_TYPE_2D","TEX_TYPE_CUBE","TEX_TYPE_3D","STORAGE_FORMATS","Set","StorageFormatFor","format","has","linear","replace","CjsWebgpuTextureAL","m_desc","m_msaa","Tr2MsaaDesc","m_gpuUsage","Tr2GpuUsage","NONE","m_cpuUsage","Tr2CpuUsage","m_texture","m_format","m_srgbFormat","m_views","Map","m_webgpu","m_name","Create","desc","options","renderContext","Destroy","gpuUsage","cpuUsage","msaa","initialData","al","RenderContextALOf","IsValid","ALResult","E_FAIL","GetWidth","GetHeight","E_INVALIDARG","samples","type","GetType","dimension","GetArraySize","writable","HasFlag","RENDER_TARGET","UNORDERED_ACCESS","DEPTH_STENCIL","WRITE","requestedFormat","m_utils","GetGPUTextureFormat","GetFormat","sameBytes","webgpu","GetWebgpu","E_INVALIDCALL","device","GetDevice","usageFlags","GetTextureUsage","srgbFormat","endsWith","GetSRGBViewFormat","mipCount","Math","max","GetTrueMipCount","layers","GetDepth","usage","TEXTURE_BINDING","COPY_DST","RENDER_ATTACHMENT","STORAGE_BINDING","COPY_SRC","depthShadow","SHADER_RESOURCE","createTexture","label","size","width","height","depthOrArrayLayers","mipLevelCount","sampleCount","viewFormats","_CreateDepthShadow","_Upload","S_OK","_depthShadow","bytesPerRow","ceil","bufferUsage","GetBufferUsage","texture","buffer","createBuffer","EncodeDepthShadowCopy","commandEncoder","shadow","layout","offset","rowsPerImage","copyTextureToBuffer","aspect","copyBufferToTexture","queue","layerCount","layer","mip","subresource","m_sysMem","bytes","pitch","m_sysMemPitch","slicePitch","m_sysMemSlicePitch","byteLength","depth","GetMipDepth","writeTexture","mipLevel","origin","x","y","z","floor","undefined","GetMipWidth","GetMipHeight","GetDeviceTextureView","viewDimension","colorSpace","source","srgb","key","view","get","createView","set","GetDeviceStorageView","baseMipLevel","GetDeviceRenderTargetView","slice","baseArrayLayer","arrayLayerCount","GetDeviceFormat","GetDeviceTexture","OpenShared","GetDesc","GetMsaaDesc","GetGpuUsage","GetCpuUsage","GetMipCount","PixelFormat","PIXEL_FORMAT_UNKNOWN","TEX_TYPE_INVALID","GetMipSize","level","MapForReading","_region","_synchronize","_renderContext","result","data","UnmapForReading","_mappedData","_mappedRegion","MapForWriting","region","IsValidForBitmap","IsSingleSubresource","HasBox","m_startMipLevel","GetMipPitch","length","Uint8Array","UnmapForWriting","UpdateSubresource","WRITE_OFTEN","m_startFace","CopySubresourceRegion","destSubresource","sourceSubresource","IsWritable","src","CopyRegion","dst","Crop","GetWorkQueue","slices","m_endFace","mips","m_endMipLevel","CopyTextureToTexture","m_box","left","top","front","GenerateMipMaps","GetMipGenerator","Resolve","destination","Tr2TextureSubresource","GetSharedHandle","GetSrvIndexInHeap","GetUavIndexInHeap","destroy","GetMemoryClass","Tr2ALMemoryType","AL_MEMORY_VIDEO","Describe","description","memoryClass","SetName","name","String","GetName","CjsSchema","define","className","carbon"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA,MAAMA,aAAa,GAAG,UAAU;;AAEhC;AACA,MAAMC,sBAAsB,GAAGC,MAAM,CAACC,MAAM,CAAC;AAC3C,EAAA,CAACC,WAAW,CAACC,WAAW,GAAG,IAAI;AAC/B,EAAA,CAACD,WAAW,CAACE,aAAa,GAAG,MAAM;EACnC,CAACF,WAAW,CAACG,WAAW,G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AACC,UAAU,GAAGC,WAAW,CAACF,IAAI;AACpC,EAAA;;AAEA;AACAsM,EAAAA,cAAcA,GACd;IACE,OAAOC,eAAe,CAACC,eAAe;AACxC,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACEC,QAAQA,CAACC,WAAW,EACpB;AACE,IAAA,IAAI,CAACA,WAAW,EAAE,OAAOA,WAAW;AAEpCA,IAAAA,WAAW,CAACC,WAAW,GAAG,IAAI,CAACL,cAAc,EAAE;AAE/C,IAAA,OAAOI,WAAW;AACpB,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACEE,OAAOA,CAACC,IAAI,EACZ;IACE,IAAI,CAACpM,MAAM,GAAGqM,MAAM,CAACD,IAAI,IAAI,EAAE,CAAC;AAEhC,IAAA,IAAI,IAAI,CAAC1M,SAAS,EAAE,IAAI,CAACA,SAAS,CAACiE,KAAK,GAAG,IAAI,CAAC3D,MAAM;IAEtD,OAAOa,QAAQ,CAACwD,IAAI;AACtB,EAAA;;AAEA;AACAiI,EAAAA,OAAOA,GACP;IACE,OAAO,IAAI,CAACtM,MAAM;AACpB,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAuM,SAAS,CAACC,MAAM,CAACvN,kBAAkB,EAAE;AAAEwN,EAAAA,SAAS,EAAE,oBAAoB;AAAEC,EAAAA,MAAM,EAAE;AAAe,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsWebgpuTextureAL.js","sources":["../../../../src/trinityal/webgpu/CjsWebgpuTextureAL.js"],"sourcesContent":["// Source: trinity/trinityal/include/Tr2TextureAL.h\n// trinity/trinityal/metal/Tr2TextureALMetal.mm\n// trinity/trinityal/stub/Tr2TextureALStub.cpp\n//\n// A `Tr2TextureAL` holding a real `GPUTexture`.\n//\n// CREATED WITH ITS DATA, NEVER UPDATED INTO. Carbon's texture resource creates\n// its texture from the decoded bitmap with one `Tr2SubresourceData` per\n// (mip, layer), indexed `mip + layer * mipCount`\n// (`Tr2ImageIOHelpers.cpp:104-128`), and Metal uploads them one\n// `replaceRegion` per (slice, mip) (`Tr2TextureALMetal.mm:140-268`). This does\n// the same with one `writeTexture` per subresource.\n//\n// THE sRGB VIEW IS A FORMAT-REINTERPRETING VIEW, as Metal's is: `MetalContext.mm:342-357`\n// makes `newTextureViewWithPixelFormat:` of the sRGB sibling for RGBA8, BGRA8,\n// BC1, BC2, BC3 and BC7, and `GetSRGBViewMetalTexture()` is what a\n// `COLOR_SPACE_SRGB` SRV binds. WebGPU needs the sibling declared in\n// `viewFormats` at creation, so it is.\n//\n// FIELDS ARE PUBLIC AND CARBON-NAMED, for the reason recorded on `CjsWebgpuShaderAL`.\nimport { CjsSchema } from \"#schema\";\nimport { ALResult, CopyRegion, Crop, Tr2ALMemoryType, Tr2MsaaDesc, Tr2TextureSubresource } from \"#trinityal\";\nimport { PixelFormat, TextureType, Tr2CpuUsage, Tr2GpuUsage, HasFlag, IsWritable } from \"#consts/render-context\";\nimport { RenderContextALOf } from \"../renderContextAL.js\";\n\nconst NO_HEAP_INDEX = 0xffffffff;\n\n/** Carbon texture type to WebGPU's view dimension for the texture as a whole. */\nconst VIEW_DIMENSION_OF_TYPE = Object.freeze({\n [TextureType.TEX_TYPE_2D]: \"2d\",\n [TextureType.TEX_TYPE_CUBE]: \"cube\",\n [TextureType.TEX_TYPE_3D]: \"3d\"\n});\n\n/**\n * The formats core WebGPU accepts with STORAGE_BINDING (the WebGPU spec's\n * texture format capabilities table). D3D lets far more formats be UAVs.\n */\nconst STORAGE_FORMATS = new Set([\n \"rgba8unorm\", \"rgba8snorm\", \"rgba8uint\", \"rgba8sint\",\n \"rgba16uint\", \"rgba16sint\", \"rgba16float\",\n \"r32uint\", \"r32sint\", \"r32float\",\n \"rg32uint\", \"rg32sint\", \"rg32float\",\n \"rgba32uint\", \"rgba32sint\", \"rgba32float\"\n]);\n\n/**\n * The format a UAV texture is created in when WebGPU cannot store to the one\n * Carbon asked for. An sRGB format takes its linear sibling (same bytes; the\n * sRGB format stays a sampling view); anything else takes rgba16float, the\n * substitute Carbon's own DX12 path chooses for a non-UAV-compatible target\n * (Tr2ReflectionProbe.cpp:235-236).\n *\n * @param {string} format The requested `GPUTextureFormat`.\n * @returns {string} A storage-capable format.\n */\nfunction StorageFormatFor(format)\n{\n if (STORAGE_FORMATS.has(format)) return format;\n const linear = format.replace(/-srgb$/u, \"\");\n return STORAGE_FORMATS.has(linear) ? linear : \"rgba16float\";\n}\n\n\n/**\n * A `Tr2TextureAL` backed by a WebGPU `GPUTexture`, created with all of its data.\n */\nexport class CjsWebgpuTextureAL\n{\n /** m_desc, a `Tr2BitmapDimensions`. */\n m_desc = null;\n\n m_msaa = new Tr2MsaaDesc();\n\n m_gpuUsage = Tr2GpuUsage.NONE;\n\n m_cpuUsage = Tr2CpuUsage.NONE;\n\n /** The `GPUTexture`, or null before Create. */\n m_texture = null;\n\n /** Whether the texture is a float stand-in for a UNORM format (CjsWebgpuUtils.IsUnormSubstitute). */\n m_unormSubstitute = false;\n\n /**\n * Whether a pipeline rendering to this texture must store as UNORM does.\n *\n * @returns {boolean} True for a float stand-in for a 16-bit UNORM format.\n */\n IsUnormSubstitute()\n {\n return this.m_unormSubstitute;\n }\n\n /** The `GPUTextureFormat` it was created with. */\n m_format = null;\n\n /** The sRGB sibling format, when the format has one and a view of it exists. */\n m_srgbFormat = null;\n\n /** Views by `dimension:colorSpace`, made on first request. */\n m_views = new Map();\n\n m_webgpu = null;\n\n m_name = \"\";\n\n /**\n * Creates the texture and uploads its initial data.\n *\n * @param {object} desc A `Tr2BitmapDimensions`.\n * @param {object} options `{ gpuUsage, cpuUsage, msaa, initialData }`;\n * `initialData` is an array of `Tr2SubresourceData`\n * indexed `mip + layer * mipCount`, as Carbon's is.\n * @param {object} renderContext The render context, Trinity's or the AL.\n * @returns {number} An `ALResult` value.\n */\n Create(desc, options, renderContext)\n {\n this.Destroy();\n\n const { gpuUsage = Tr2GpuUsage.NONE, cpuUsage = Tr2CpuUsage.NONE, msaa = new Tr2MsaaDesc(), initialData = null } = options ?? {};\n const al = RenderContextALOf(renderContext);\n\n if (!al || !al.IsValid()) return ALResult.E_FAIL;\n if (!desc || desc.GetWidth() === 0 || desc.GetHeight() === 0) return ALResult.E_INVALIDARG;\n if (msaa.samples > 1) return ALResult.E_INVALIDARG;\n\n const type = desc.GetType();\n const dimension = VIEW_DIMENSION_OF_TYPE[type];\n\n if (!dimension) return ALResult.E_INVALIDARG;\n if (type === TextureType.TEX_TYPE_CUBE && desc.GetArraySize() % 6 !== 0) return ALResult.E_INVALIDARG;\n\n // Carbon's own rule (the stub's last check): a texture nothing can ever\n // write that arrives with no pixels samples black forever. Refused.\n const writable = HasFlag(gpuUsage, Tr2GpuUsage.RENDER_TARGET) || HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS)\n || HasFlag(gpuUsage, Tr2GpuUsage.DEPTH_STENCIL) || HasFlag(cpuUsage, Tr2CpuUsage.WRITE);\n\n if (!writable && !initialData) return ALResult.E_INVALIDARG;\n\n const requestedFormat = al.m_utils.GetGPUTextureFormat(desc.GetFormat());\n\n if (!requestedFormat) return ALResult.E_INVALIDARG;\n\n // A UAV texture is created in a format WebGPU can store to. Only a\n // same-bytes sibling keeps initial data valid; pixels laid out for the\n // requested format cannot be uploaded into rgba16float, so that pairing\n // is refused rather than uploaded wrong.\n const format = HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS) ? StorageFormatFor(requestedFormat) : requestedFormat;\n const sameBytes = format === requestedFormat || format === requestedFormat.replace(/-srgb$/u, \"\");\n\n if (initialData && !sameBytes) return ALResult.E_INVALIDARG;\n\n const webgpu = al.GetWebgpu();\n if (!webgpu) return ALResult.E_INVALIDCALL;\n\n const device = webgpu.GetDevice();\n\n // A size past the device's limit is refused here: createTexture would make\n // an invalid texture, and every command buffer using it would fail to\n // submit. Carbon's cascaded shadow atlas is 16384 wide at its default\n // 2048 cell (Tr2ShadowMap.h:14, eight cells a row).\n const maxDimension = type === TextureType.TEX_TYPE_3D ? device.limits.maxTextureDimension3D : device.limits.maxTextureDimension2D;\n\n if (desc.GetWidth() > maxDimension || desc.GetHeight() > maxDimension) return ALResult.E_INVALIDARG;\n const usageFlags = webgpu.GetTextureUsage();\n const srgbFormat = requestedFormat !== format && requestedFormat.endsWith(\"-srgb\")\n ? requestedFormat\n : al.m_utils.GetSRGBViewFormat(format);\n const mipCount = Math.max(1, desc.GetTrueMipCount());\n const layers = type === TextureType.TEX_TYPE_3D ? Math.max(1, desc.GetDepth()) : Math.max(1, desc.GetArraySize());\n let usage = usageFlags.TEXTURE_BINDING | usageFlags.COPY_DST;\n\n if (HasFlag(gpuUsage, Tr2GpuUsage.RENDER_TARGET) || HasFlag(gpuUsage, Tr2GpuUsage.DEPTH_STENCIL))\n {\n usage |= usageFlags.RENDER_ATTACHMENT ?? 0;\n }\n\n // An unordered-access texture is written through a storage binding;\n // D3D's UAV is WebGPU's STORAGE_BINDING, where the format allows one.\n if (HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS)) usage |= usageFlags.STORAGE_BINDING ?? 0;\n\n // A texture something renders or computes into is also a copy source, as\n // D3D resources are without a flag: CopySubresourceRegion reads it.\n if (HasFlag(gpuUsage, Tr2GpuUsage.RENDER_TARGET) || HasFlag(gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS))\n {\n usage |= usageFlags.COPY_SRC ?? 0;\n }\n\n // A sampled depth texture is copied into its float shadow (see _CreateDepthShadow).\n const depthShadow = format === \"depth32float\" && HasFlag(gpuUsage, Tr2GpuUsage.DEPTH_STENCIL)\n && HasFlag(gpuUsage, Tr2GpuUsage.SHADER_RESOURCE);\n\n if (depthShadow) usage |= usageFlags.COPY_SRC ?? 0;\n\n this.m_texture = device.createTexture({\n label: this.m_name || \"Tr2TextureAL\",\n size: { width: desc.GetWidth(), height: desc.GetHeight(), depthOrArrayLayers: layers },\n mipLevelCount: mipCount,\n sampleCount: 1,\n dimension: type === TextureType.TEX_TYPE_3D ? \"3d\" : \"2d\",\n format,\n usage,\n ...(srgbFormat ? { viewFormats: [ srgbFormat ] } : {})\n });\n this.m_format = format;\n this.m_srgbFormat = srgbFormat;\n this.m_unormSubstitute = al.m_utils.IsUnormSubstitute(desc.GetFormat());\n this.m_desc = desc;\n this.m_msaa = msaa;\n this.m_gpuUsage = gpuUsage;\n this.m_cpuUsage = cpuUsage;\n this.m_webgpu = webgpu;\n\n if (depthShadow) this._CreateDepthShadow(device, usageFlags);\n // A substitute format's data is converted as it uploads (16-bit unorm to\n // half floats; CjsWebgpuUtils.UPLOAD_CONVERSIONS).\n if (initialData) this._Upload(initialData, mipCount, type, al.m_utils.GetUploadConversion(desc.GetFormat()));\n\n return ALResult.S_OK;\n }\n\n /**\n * The r32float copy a sampled depth texture is read through, or null.\n *\n * D3D creates Carbon's sampled depth as R32_TYPELESS, with the depth view in\n * D32_FLOAT and the shader view in R32_FLOAT, so a shader samples depth as an\n * ordinary float texture through any sampler. WebGPU binds depth32float only\n * as \"depth\" or \"unfilterable-float\", and the translated shaders declare\n * `texture_2d<f32>` in a filterable slot: the GPU refused the bind group.\n * No view can reinterpret depth32float as r32float and a texture-to-texture\n * copy needs matching formats, so the depth goes through a buffer:\n * `EncodeDepthShadowCopy` copies depth into it and on into this texture,\n * which is what the shader view returns. The context encodes that copy\n * whenever the depth stencil is unbound, which is when its pass has ended.\n */\n _depthShadow = null;\n\n /** Makes the float shadow and the row-aligned buffer the copy passes through. */\n _CreateDepthShadow(device, usageFlags)\n {\n const width = this.m_desc.GetWidth();\n const height = this.m_desc.GetHeight();\n // copyTextureToBuffer rows are 256-byte aligned.\n const bytesPerRow = Math.ceil((width * 4) / 256) * 256;\n const bufferUsage = this.m_webgpu.GetBufferUsage();\n\n this._depthShadow = {\n bytesPerRow,\n texture: device.createTexture({\n label: `${this.m_name || \"Tr2TextureAL\"} depth shadow`,\n size: { width, height, depthOrArrayLayers: 1 },\n format: \"r32float\",\n usage: usageFlags.TEXTURE_BINDING | usageFlags.COPY_DST\n }),\n buffer: device.createBuffer({\n label: `${this.m_name || \"Tr2TextureAL\"} depth shadow`,\n size: bytesPerRow * height,\n usage: bufferUsage.COPY_SRC | bufferUsage.COPY_DST\n })\n };\n }\n\n /**\n * Copies the depth into its float shadow, on the frame's command encoder\n * and outside any pass. Nothing for a texture without one.\n *\n * @param {GPUCommandEncoder} commandEncoder The frame's encoder.\n * @returns {boolean} Whether a copy was encoded.\n */\n EncodeDepthShadowCopy(commandEncoder)\n {\n const shadow = this._depthShadow;\n\n if (!shadow || !commandEncoder) return false;\n\n const size = { width: this.m_desc.GetWidth(), height: this.m_desc.GetHeight(), depthOrArrayLayers: 1 };\n const layout = { offset: 0, bytesPerRow: shadow.bytesPerRow, rowsPerImage: size.height };\n\n commandEncoder.copyTextureToBuffer({ texture: this.m_texture, aspect: \"depth-only\" }, { buffer: shadow.buffer, ...layout }, size);\n commandEncoder.copyBufferToTexture({ buffer: shadow.buffer, ...layout }, { texture: shadow.texture }, size);\n\n return true;\n }\n\n /**\n * One `writeTexture` per subresource, Carbon's `mip + layer * mipCount`\n * order, each through `convert` when the format needs one.\n */\n _Upload(initialData, mipCount, type, convert = null)\n {\n const desc = this.m_desc;\n const queue = this.m_webgpu.GetDevice().queue;\n const layerCount = type === TextureType.TEX_TYPE_3D ? 1 : Math.max(1, desc.GetArraySize());\n\n for (let layer = 0; layer < layerCount; layer += 1)\n {\n for (let mip = 0; mip < mipCount; mip += 1)\n {\n const subresource = initialData[mip + layer * mipCount];\n\n if (!subresource || !subresource.m_sysMem) continue;\n\n const bytes = convert ? convert(subresource.m_sysMem) : subresource.m_sysMem;\n const pitch = subresource.m_sysMemPitch;\n const slicePitch = subresource.m_sysMemSlicePitch || bytes.byteLength;\n const depth = type === TextureType.TEX_TYPE_3D ? Math.max(1, desc.GetMipDepth(mip)) : 1;\n\n queue.writeTexture(\n { texture: this.m_texture, mipLevel: mip, origin: { x: 0, y: 0, z: layer } },\n bytes,\n { offset: 0, bytesPerRow: pitch, rowsPerImage: pitch ? Math.max(1, Math.floor(slicePitch / pitch)) : undefined },\n { width: desc.GetMipWidth(mip), height: desc.GetMipHeight(mip), depthOrArrayLayers: depth }\n );\n }\n }\n }\n\n /**\n * The view a resource set binds: linear or sRGB, in the layout's dimension.\n *\n * Metal's `GetMetalTexture()` / `GetSRGBViewMetalTexture()`\n * (`Tr2TextureALMetal.h:49-54`), with the dimension added because a WebGPU\n * view must name it and a cube texture is legitimately bound as a 2d-array.\n *\n * @param {string} [viewDimension] A `GPUTextureViewDimension`.\n * @param {number} [colorSpace] A `Tr2ColorSpace`; non-zero means sRGB.\n * @returns {object|null} A `GPUTextureView`, or null before Create.\n */\n GetDeviceTextureView(viewDimension = VIEW_DIMENSION_OF_TYPE[this.m_desc?.GetType()] ?? \"2d\", colorSpace = 0)\n {\n if (!this.m_texture) return null;\n\n // A sampled depth texture is read through its float shadow.\n const source = this._depthShadow ? this._depthShadow.texture : this.m_texture;\n const srgb = colorSpace !== 0 && this.m_srgbFormat !== null;\n const key = `${viewDimension}:${srgb ? \"srgb\" : \"linear\"}`;\n let view = this.m_views.get(key) ?? null;\n\n if (!view)\n {\n view = source.createView({\n label: `${this.m_name || \"Tr2TextureAL\"} ${key}`,\n dimension: viewDimension,\n ...(srgb ? { format: this.m_srgbFormat } : {})\n });\n this.m_views.set(key, view);\n }\n\n return view;\n }\n\n /**\n * The view a storage (UAV) binding writes: ONE mip level, every layer.\n *\n * Carbon binds a UAV at a mip (`Tr2ResourceSetDescriptionAL::SetUav`'s\n * `mip`), and a WebGPU storage view must name exactly one. A cube is bound\n * as a 2d-array of its faces, which is how a compute shader writes one.\n *\n * @param {string} viewDimension The binding's `storageTexture.viewDimension`.\n * @param {number} mip The mip level.\n * @returns {GPUTextureView|null} The view, or null before Create or for a texture created without UAV usage.\n */\n GetDeviceStorageView(viewDimension, mip)\n {\n // Only a texture created with UNORDERED_ACCESS carries STORAGE_BINDING.\n if (!this.m_texture || !HasFlag(this.m_gpuUsage, Tr2GpuUsage.UNORDERED_ACCESS)) return null;\n\n const key = `storage:${viewDimension}:${mip}`;\n let view = this.m_views.get(key) ?? null;\n\n if (!view)\n {\n view = this.m_texture.createView({\n label: `${this.m_name || \"Tr2TextureAL\"} ${key}`,\n dimension: viewDimension,\n baseMipLevel: mip,\n mipLevelCount: 1\n });\n this.m_views.set(key, view);\n }\n\n return view;\n }\n\n /**\n * The view a render pass attaches: mip zero of one slice, in the created\n * format. Metal attaches the texture with a `slice` on the pass descriptor\n * (`MetalWorkQueue.mm:2000-2014`); a WebGPU attachment view must name exactly\n * one mip and one layer instead.\n *\n * @param {number} [slice] The array slice or cube face.\n * @returns {GPUTextureView|null} The view, or null before Create.\n */\n GetDeviceRenderTargetView(slice = 0)\n {\n if (!this.m_texture) return null;\n\n const key = `attachment:${slice}`;\n let view = this.m_views.get(key) ?? null;\n\n if (!view)\n {\n view = this.m_texture.createView({\n label: `${this.m_name || \"Tr2TextureAL\"} ${key}`,\n dimension: \"2d\",\n baseMipLevel: 0,\n mipLevelCount: 1,\n baseArrayLayer: slice,\n arrayLayerCount: 1\n });\n this.m_views.set(key, view);\n }\n\n return view;\n }\n\n /**\n * The `GPUTextureFormat` the texture was created in. A UAV texture may differ\n * from its Carbon format (see `StorageFormatFor`), so a render pass or\n * pipeline targeting it reads this, not the description's format.\n *\n * @returns {string|null} The format, or null before Create.\n */\n GetDeviceFormat()\n {\n return this.m_format;\n }\n\n /** The `GPUTexture`; Metal's `GetMetalTexture` under this backend's name. */\n GetDeviceTexture()\n {\n return this.m_texture;\n }\n\n /** Whether the texture holds a `GPUTexture`. */\n IsValid()\n {\n return this.m_texture !== null;\n }\n\n /** Shared textures need a native handle WebGPU does not expose; always fails. */\n OpenShared()\n {\n return ALResult.E_FAIL;\n }\n\n /** The `Tr2BitmapDimensions` this texture was created from, or null. */\n GetDesc()\n {\n return this.m_desc;\n }\n\n /** The multisample description; this backend creates single-sampled textures. */\n GetMsaaDesc()\n {\n return this.m_msaa;\n }\n\n /** The `Tr2GpuUsage` flags it was created with. */\n GetGpuUsage()\n {\n return this.m_gpuUsage;\n }\n\n /** The `Tr2CpuUsage` flags it was created with. */\n GetCpuUsage()\n {\n return this.m_cpuUsage;\n }\n\n /** Width in texels of mip zero, or zero before Create. */\n GetWidth()\n {\n return this.m_desc ? this.m_desc.GetWidth() : 0;\n }\n\n /** Height in texels of mip zero, or zero before Create. */\n GetHeight()\n {\n return this.m_desc ? this.m_desc.GetHeight() : 0;\n }\n\n /** Depth in texels of mip zero, which is one unless the texture is 3D. */\n GetDepth()\n {\n return this.m_desc ? this.m_desc.GetDepth() : 0;\n }\n\n /** The mip count requested at creation, which may be zero for a full chain. */\n GetMipCount()\n {\n return this.m_desc ? this.m_desc.GetMipCount() : 0;\n }\n\n /** The mip count actually created, with a requested zero resolved. */\n GetTrueMipCount()\n {\n return this.m_desc ? this.m_desc.GetTrueMipCount() : 0;\n }\n\n /** The Carbon `PixelFormat`, or `PIXEL_FORMAT_UNKNOWN` before Create. */\n GetFormat()\n {\n return this.m_desc ? this.m_desc.GetFormat() : PixelFormat.PIXEL_FORMAT_UNKNOWN;\n }\n\n /** The Carbon `TextureType`, or `TEX_TYPE_INVALID` before Create. */\n GetType()\n {\n return this.m_desc ? this.m_desc.GetType() : TextureType.TEX_TYPE_INVALID;\n }\n\n /** The layer count, which for a cube counts its six faces. */\n GetArraySize()\n {\n return this.m_desc ? this.m_desc.GetArraySize() : 0;\n }\n\n /**\n * The byte size of one mip across all layers.\n *\n * @param {number} level The mip level.\n * @returns {number} Its size in bytes, or zero before Create.\n */\n GetMipSize(level)\n {\n return this.m_desc ? this.m_desc.GetMipSize(level) : 0;\n }\n\n /** Reading back needs a staging buffer and an await; refused by name. */\n MapForReading(_region, _synchronize, _renderContext)\n {\n return { result: ALResult.E_FAIL, data: null, pitch: 0 };\n }\n\n /** Paired with `MapForReading`, which this backend refuses. */\n UnmapForReading(_renderContext)\n {\n return ALResult.E_FAIL;\n }\n\n /** The CPU copy a write mapping hands out; kept between maps for WRITE_OFTEN. */\n _mappedData = null;\n\n /** The subresource the current write mapping covers, or null when unmapped. */\n _mappedRegion = null;\n\n /**\n * Hands out memory for writing one subresource, Carbon's `MapForWriting`,\n * with the stub's checks (`Tr2TextureALStub.MapForWriting`).\n *\n * WebGPU has no mappable texture memory, so the memory is a CPU copy of the\n * mip, uploaded by `UnmapForWriting` with `queue.writeTexture` - the shape\n * this backend's constant buffers already use. The copy starts zeroed, not\n * with the texture's contents, because WebGPU cannot read a texture back\n * synchronously; so a region with a box is refused rather than letting the\n * upload overwrite the texels outside it. `Tr2DataTextureManager` maps the\n * whole of subresource 0.\n *\n * @param {object} region A `Tr2TextureSubresource`.\n * @param {object} renderContext The render context, Trinity's or the AL.\n * @returns {{result: number, data: Uint8Array|null, pitch: number}} The mapping.\n */\n MapForWriting(region, renderContext)\n {\n if (!HasFlag(this.m_cpuUsage, Tr2CpuUsage.WRITE)) return { result: ALResult.E_INVALIDCALL, data: null, pitch: 0 };\n\n const al = RenderContextALOf(renderContext);\n\n if (!this.IsValid() || !al || !al.IsValid()) return { result: ALResult.E_FAIL, data: null, pitch: 0 };\n if (!region.IsValidForBitmap(this.m_desc) || !region.IsSingleSubresource() || region.HasBox())\n {\n return { result: ALResult.E_INVALIDARG, data: null, pitch: 0 };\n }\n\n const mip = region.m_startMipLevel;\n const pitch = this.m_desc.GetMipPitch(mip);\n const size = pitch * this.m_desc.GetMipHeight(mip);\n\n if (size === 0) return { result: ALResult.E_FAIL, data: null, pitch: 0 };\n if (this._mappedData === null || this._mappedData.length !== size) this._mappedData = new Uint8Array(size);\n\n this._mappedRegion = region;\n\n return { result: ALResult.S_OK, data: this._mappedData, pitch };\n }\n\n /**\n * Uploads what was written into the mapping, Carbon's `UnmapForWriting`.\n * The CPU copy is kept for the next map only when the texture was created\n * `WRITE_OFTEN`, as the stub keeps its buffer.\n *\n * @param {object} renderContext The render context, Trinity's or the AL.\n * @returns {number} An `ALResult` value.\n */\n UnmapForWriting(renderContext)\n {\n if (this._mappedRegion === null) return ALResult.E_INVALIDCALL;\n\n const region = this._mappedRegion;\n const mip = region.m_startMipLevel;\n const pitch = this.m_desc.GetMipPitch(mip);\n const result = this.UpdateSubresource(region, this._mappedData, pitch, pitch * this.m_desc.GetMipHeight(mip), renderContext);\n\n this._mappedRegion = null;\n if (!HasFlag(this.m_cpuUsage, Tr2CpuUsage.WRITE_OFTEN)) this._mappedData = null;\n\n return result;\n }\n\n /**\n * Replaces one mip of one slice, Carbon's `UpdateSubresource`.\n *\n * @param {object} region A `Tr2TextureSubresource` naming one mip and slice.\n * @param {ArrayBufferView} source The texels.\n * @param {number} pitch Bytes per row.\n * @param {number} slicePitch Bytes per slice.\n * @returns {number} An `ALResult` value.\n */\n UpdateSubresource(region, source, pitch, slicePitch, _renderContext)\n {\n if (!this.IsValid()) return ALResult.E_INVALIDCALL;\n if (!region || !source) return ALResult.E_INVALIDARG;\n\n const mip = region.m_startMipLevel ?? 0;\n const layer = region.m_startFace ?? 0;\n\n this.m_webgpu.GetDevice().queue.writeTexture(\n { texture: this.m_texture, mipLevel: mip, origin: { x: 0, y: 0, z: layer } },\n source,\n { offset: 0, bytesPerRow: pitch, rowsPerImage: pitch ? Math.max(1, Math.floor((slicePitch || source.byteLength) / pitch)) : undefined },\n { width: this.m_desc.GetMipWidth(mip), height: this.m_desc.GetMipHeight(mip), depthOrArrayLayers: 1 }\n );\n\n return ALResult.S_OK;\n }\n\n /**\n * Copies a region of another texture into this one, as Metal does\n * (`Tr2TextureALMetal.mm:744-791`): validate, crop both regions against their\n * textures, then one work-queue copy per slice and mip.\n *\n * @param {Tr2TextureSubresource} destSubresource The region to write.\n * @param {CjsWebgpuTextureAL} source The texture to read.\n * @param {Tr2TextureSubresource} sourceSubresource The region to read.\n * @param {object} renderContext The context whose work queue records it.\n * @returns {number} An `ALResult` value.\n */\n CopySubresourceRegion(destSubresource, source, sourceSubresource, renderContext)\n {\n if (!this.IsValid() || !renderContext?.IsValid()) return ALResult.E_INVALIDCALL;\n if (!source?.IsValid()) return ALResult.E_INVALIDARG;\n if (!HasFlag(this.m_cpuUsage, Tr2CpuUsage.WRITE) && !IsWritable(this.m_gpuUsage)) return ALResult.E_INVALIDCALL;\n\n // Carbon takes both regions by value and Crop mutates them.\n const src = CopyRegion(sourceSubresource);\n const dst = CopyRegion(destSubresource);\n\n if (!Crop(src, source.m_desc, dst, this.m_desc)) return ALResult.E_FAIL;\n\n const queue = RenderContextALOf(renderContext).GetWorkQueue();\n const slices = src.m_endFace - src.m_startFace;\n const mips = src.m_endMipLevel - src.m_startMipLevel;\n\n for (let slice = 0; slice < slices; ++slice)\n {\n for (let mip = 0; mip < mips; ++mip)\n {\n queue.CopyTextureToTexture(\n source.m_texture,\n src.m_startFace + slice,\n src.m_startMipLevel + mip,\n { x: src.m_box.left, y: src.m_box.top, z: src.m_box.front },\n { width: src.GetWidth(), height: src.GetHeight(), depthOrArrayLayers: src.GetDepth() },\n this.m_texture,\n dst.m_startFace + slice,\n dst.m_startMipLevel + mip,\n { x: dst.m_box.left, y: dst.m_box.top, z: dst.m_box.front }\n );\n }\n }\n\n return ALResult.S_OK;\n }\n\n /**\n * Regenerates the mip chain, as Metal's `GenerateMipMaps` does\n * (`Tr2TextureALMetal.mm:795-805`): only a render target that is also a\n * shader resource can be, and the work queue encodes it. WebGPU has no\n * generator of its own, so the context's CjsWebgpuMipGenerator stands in for\n * Metal's blit encoder.\n *\n * @param {object} renderContext The context whose work queue encodes it.\n * @returns {number} An `ALResult` value.\n */\n GenerateMipMaps(renderContext)\n {\n if (!HasFlag(this.m_gpuUsage, Tr2GpuUsage.RENDER_TARGET) || !HasFlag(this.m_gpuUsage, Tr2GpuUsage.SHADER_RESOURCE))\n {\n return ALResult.E_INVALIDCALL;\n }\n\n const al = RenderContextALOf(renderContext);\n\n al.GetWorkQueue().GenerateMipMaps(this.m_texture, al.GetMipGenerator());\n\n return ALResult.S_OK;\n }\n\n /**\n * Resolves into `destination`. With one sample every Carbon backend falls\n * back to a plain copy (`Tr2TextureALMetal.mm:807-812`,\n * `Tr2TextureALDx11.cpp:1183-1186`); this backend has no multisampled\n * textures, so the multisample arm fails.\n *\n * @param {CjsWebgpuTextureAL} destination The texture to resolve into.\n * @param {object} renderContext The context whose work queue records it.\n * @returns {number} An `ALResult` value.\n */\n Resolve(destination, renderContext)\n {\n if ((this.m_msaa?.samples ?? 1) <= 1)\n {\n return destination.CopySubresourceRegion(new Tr2TextureSubresource(), this, new Tr2TextureSubresource(), renderContext);\n }\n\n return ALResult.E_FAIL;\n }\n\n /** The native shared handle, which WebGPU does not expose. */\n GetSharedHandle()\n {\n return null;\n }\n\n /** The descriptor-heap slot, which only the D3D12 backend has. */\n GetSrvIndexInHeap()\n {\n return NO_HEAP_INDEX;\n }\n\n /** The descriptor-heap slot, which only the D3D12 backend has. */\n GetUavIndexInHeap()\n {\n return NO_HEAP_INDEX;\n }\n\n /** Releases the `GPUTexture` and its views, leaving the AL invalid. */\n Destroy()\n {\n this.m_texture?.destroy?.();\n this.m_texture = null;\n this._depthShadow?.texture.destroy?.();\n this._depthShadow?.buffer.destroy?.();\n this._depthShadow = null;\n this.m_views = new Map();\n this._mappedData = null;\n this._mappedRegion = null;\n this.m_desc = null;\n this.m_format = null;\n this.m_srgbFormat = null;\n this.m_webgpu = null;\n this.m_gpuUsage = Tr2GpuUsage.NONE;\n this.m_cpuUsage = Tr2CpuUsage.NONE;\n }\n\n /** Where the texture lives, which for this backend is always video memory. */\n GetMemoryClass()\n {\n return Tr2ALMemoryType.AL_MEMORY_VIDEO;\n }\n\n /**\n * Fills in what this AL knows for a memory report.\n *\n * @param {object} description The description to fill in.\n * @returns {object} The same description.\n */\n Describe(description)\n {\n if (!description) return description;\n\n description.memoryClass = this.GetMemoryClass();\n\n return description;\n }\n\n /**\n * Names the texture, which reaches the `GPUTexture` label for debugging.\n *\n * @param {string} name The name.\n * @returns {number} An `ALResult` value.\n */\n SetName(name)\n {\n this.m_name = String(name ?? \"\");\n\n if (this.m_texture) this.m_texture.label = this.m_name;\n\n return ALResult.S_OK;\n }\n\n /** The name given by `SetName`. */\n GetName()\n {\n return this.m_name;\n }\n}\n\n// DECLARED AS A CALL, NOT A DECORATOR, for the reason recorded in\n// Tr2BitmapDimensions.js: the layer is imported straight from source by its\n// tests and raw Node cannot parse decorator syntax.\n//\n// The donor is NAMED rather than left to be derived from this class's name.\n// Carbon calls every backend's class the same thing and carries the backend in\n// the FILE name, because only one backend compiles at a time; we ship them\n// together, so the backend moves onto the class name. That divergence is the\n// author's to declare, never a checker's to guess.\nCjsSchema.define(CjsWebgpuTextureAL, { className: \"CjsWebgpuTextureAL\", carbon: \"Tr2TextureAL\" });\n"],"names":["NO_HEAP_INDEX","VIEW_DIMENSION_OF_TYPE","Object","freeze","TextureType","TEX_TYPE_2D","TEX_TYPE_CUBE","TEX_TYPE_3D","STORAGE_FORMATS","Set","StorageFormatFor","format","has","linear","replace","CjsWebgpuTextureAL","m_desc","m_msaa","Tr2MsaaDesc","m_gpuUsage","Tr2GpuUsage","NONE","m_cpuUsage","Tr2CpuUsage","m_texture","m_unormSubstitute","IsUnormSubstitute","m_format","m_srgbFormat","m_views","Map","m_webgpu","m_name","Create","desc","options","renderContext","Destroy","gpuUsage","cpuUsage","msaa","initialData","al","RenderContextALOf","IsValid","ALResult","E_FAIL","GetWidth","GetHeight","E_INVALIDARG","samples","type","GetType","dimension","GetArraySize","writable","HasFlag","RENDER_TARGET","UNORDERED_ACCESS","DEPTH_STENCIL","WRITE","requestedFormat","m_utils","GetGPUTextureFormat","GetFormat","sameBytes","webgpu","GetWebgpu","E_INVALIDCALL","device","GetDevice","maxDimension","limits","maxTextureDimension3D","maxTextureDimension2D","usageFlags","GetTextureUsage","srgbFormat","endsWith","GetSRGBViewFormat","mipCount","Math","max","GetTrueMipCount","layers","GetDepth","usage","TEXTURE_BINDING","COPY_DST","RENDER_ATTACHMENT","STORAGE_BINDING","COPY_SRC","depthShadow","SHADER_RESOURCE","createTexture","label","size","width","height","depthOrArrayLayers","mipLevelCount","sampleCount","viewFormats","_CreateDepthShadow","_Upload","GetUploadConversion","S_OK","_depthShadow","bytesPerRow","ceil","bufferUsage","GetBufferUsage","texture","buffer","createBuffer","EncodeDepthShadowCopy","commandEncoder","shadow","layout","offset","rowsPerImage","copyTextureToBuffer","aspect","copyBufferToTexture","convert","queue","layerCount","layer","mip","subresource","m_sysMem","bytes","pitch","m_sysMemPitch","slicePitch","m_sysMemSlicePitch","byteLength","depth","GetMipDepth","writeTexture","mipLevel","origin","x","y","z","floor","undefined","GetMipWidth","GetMipHeight","GetDeviceTextureView","viewDimension","colorSpace","source","srgb","key","view","get","createView","set","GetDeviceStorageView","baseMipLevel","GetDeviceRenderTargetView","slice","baseArrayLayer","arrayLayerCount","GetDeviceFormat","GetDeviceTexture","OpenShared","GetDesc","GetMsaaDesc","GetGpuUsage","GetCpuUsage","GetMipCount","PixelFormat","PIXEL_FORMAT_UNKNOWN","TEX_TYPE_INVALID","GetMipSize","level","MapForReading","_region","_synchronize","_renderContext","result","data","UnmapForReading","_mappedData","_mappedRegion","MapForWriting","region","IsValidForBitmap","IsSingleSubresource","HasBox","m_startMipLevel","GetMipPitch","length","Uint8Array","UnmapForWriting","UpdateSubresource","WRITE_OFTEN","m_startFace","CopySubresourceRegion","destSubresource","sourceSubresource","IsWritable","src","CopyRegion","dst","Crop","GetWorkQueue","slices","m_endFace","mips","m_endMipLevel","CopyTextureToTexture","m_box","left","top","front","GenerateMipMaps","GetMipGenerator","Resolve","destination","Tr2TextureSubresource","GetSharedHandle","GetSrvIndexInHeap","GetUavIndexInHeap","destroy","GetMemoryClass","Tr2ALMemoryType","AL_MEMORY_VIDEO","Describe","description","memoryClass","SetName","name","String","GetName","CjsSchema","define","className","carbon"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA,MAAMA,aAAa,GAAG,UAAU;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E/C,IAAA,OAAOI,WAAW;AACpB,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACEE,OAAOA,CAACC,IAAI,EACZ;IACE,IAAI,CAAC1M,MAAM,GAAG2M,MAAM,CAACD,IAAI,IAAI,EAAE,CAAC;AAEhC,IAAA,IAAI,IAAI,CAAClN,SAAS,EAAE,IAAI,CAACA,SAAS,CAACuE,KAAK,GAAG,IAAI,CAAC/D,MAAM;IAEtD,OAAOa,QAAQ,CAAC6D,IAAI;AACtB,EAAA;;AAEA;AACAkI,EAAAA,OAAOA,GACP;IACE,OAAO,IAAI,CAAC5M,MAAM;AACpB,EAAA;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA6M,SAAS,CAACC,MAAM,CAAC/N,kBAAkB,EAAE;AAAEgO,EAAAA,SAAS,EAAE,oBAAoB;AAAEC,EAAAA,MAAM,EAAE;AAAe,CAAC,CAAC;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CjsSchema } from '#schema';
|
|
2
|
+
import { CARBON_BACKEND_UNORM_TARGET_OVERRIDE } from '#resource/format';
|
|
2
3
|
import { RenderPipelineKey } from './CjsWebgpuPipelineCache.js';
|
|
3
4
|
import { TOPOLOGIES } from './topology.js';
|
|
4
5
|
|
|
@@ -77,6 +78,19 @@ class CjsWebgpuPsoDescription {
|
|
|
77
78
|
/** m_sampleDesc, reduced to the one field WebGPU exposes. */
|
|
78
79
|
sampleCount = 1;
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Per colour slot, whether the bound target is a float stand-in for a
|
|
83
|
+
* 16-bit UNORM format (CjsWebgpuTextureAL.IsUnormSubstitute).
|
|
84
|
+
*/
|
|
85
|
+
unormTargets = [];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* RS_DEPTH_CLIP_ENABLE off, where the device can honour it: WebGPU's
|
|
89
|
+
* `primitive.unclippedDepth`, behind the depth-clip-control feature. Carbon
|
|
90
|
+
* turns depth clip off to draw its shadow cascades (EveSpaceScene.cpp:748).
|
|
91
|
+
*/
|
|
92
|
+
unclippedDepth = false;
|
|
93
|
+
|
|
80
94
|
/**
|
|
81
95
|
* Whether the description names everything a pipeline needs.
|
|
82
96
|
*
|
|
@@ -136,11 +150,24 @@ class CjsWebgpuPsoDescription {
|
|
|
136
150
|
...target
|
|
137
151
|
};
|
|
138
152
|
};
|
|
153
|
+
|
|
154
|
+
// A FLOAT STAND-IN FOR A UNORM TARGET stores what UNORM would: the
|
|
155
|
+
// shader's per-target override clamps the output to [0, 1] and makes NaN 0,
|
|
156
|
+
// as D3D does writing to UNORM. TAA's R16G16B16A16_UNORM history kept a
|
|
157
|
+
// NaN forever without it. Only overrides the module declares may be set.
|
|
158
|
+
const overrides = typeof this.shaderProgram.GetUnormTargetOverrides === "function" ? this.shaderProgram.GetUnormTargetOverrides() : [];
|
|
159
|
+
const constants = {};
|
|
160
|
+
for (const location of overrides) {
|
|
161
|
+
if (this.unormTargets[location]) constants[`${CARBON_BACKEND_UNORM_TARGET_OVERRIDE}${location}`] = 1;
|
|
162
|
+
}
|
|
139
163
|
return {
|
|
140
164
|
...state,
|
|
141
165
|
primitive: {
|
|
142
166
|
...projected.primitive,
|
|
143
|
-
topology: TOPOLOGIES[this.topology]
|
|
167
|
+
topology: TOPOLOGIES[this.topology],
|
|
168
|
+
...(this.unclippedDepth ? {
|
|
169
|
+
unclippedDepth: true
|
|
170
|
+
} : {})
|
|
144
171
|
},
|
|
145
172
|
vertex: {
|
|
146
173
|
buffers: this.vertexBufferLayouts
|
|
@@ -148,7 +175,10 @@ class CjsWebgpuPsoDescription {
|
|
|
148
175
|
fragment: {
|
|
149
176
|
// An unbound slot between bound ones is a null target, as it is a null
|
|
150
177
|
// colour attachment in the pass.
|
|
151
|
-
targets: this.colorFormats.map(colourTarget)
|
|
178
|
+
targets: this.colorFormats.map(colourTarget),
|
|
179
|
+
...(Object.keys(constants).length ? {
|
|
180
|
+
constants
|
|
181
|
+
} : {})
|
|
152
182
|
},
|
|
153
183
|
multisample: {
|
|
154
184
|
count: this.sampleCount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsWebgpuPsoDescription.js","sources":["../../../../../src/trinityal/webgpu/core/CjsWebgpuPsoDescription.js"],"sourcesContent":["// Source: trinity/trinityal/dx12/util/PsoDescription.h\n// trinity/trinityal/dx12/util/PsoDescription.cpp\n// trinity/trinityal/dx12/Tr2RenderContextDx12.cpp (the setters and SetAllState)\n//\n// The pipeline description a draw resolves, and the fourth piece of the\n// immediate-draw route.\n//\n// WHAT CARBON DOES. Its backend does not assemble a pipeline per draw. The\n// setters describe one incrementally and mark it dirty\n// (`Tr2RenderContextDx12.cpp:315-338`: each compares before dirtying, so a\n// redundant apply costs nothing), and the draw resolves it:\n//\n// m_psoDescription.UpdateHash(); // cpp:793\n// auto found = m_ownerDevice->m_pipelineStates.find( m_psoDescription );\n// if( found != end ) return found->second;\n// m_psoDescription.CreatePipelineState( device, pipelineState );\n// m_ownerDevice->m_pipelineStates[ m_psoDescription ] = pipelineState;\n//\n// THE CACHE IS ON THE DEVICE, NOT THE CONTEXT (`Tr2PrimaryRenderContextDx12.h:319`),\n// which is why two contexts drawing the same material share one pipeline. Ours\n// is `CjsWebgpuPipelineCache`, already on `CjsWebgpuDevice` and already serving\n// the batch path - this describes, and hands the description to that.\n//\n// Carbon's fields, and where each lives here:\n//\n// m_vertexLayout -> vertexBufferLayouts, from the bound layout\n// m_shaderProgram -> shaderProgram, a CjsWebgpuShaderProgramAL\n// m_topologyType -> topology, mapped through the AL's own table\n// m_blendDesc }\n// m_rasterizerDesc } all three -> renderStateSetup + overrides, which\n// m_depthStencilDesc } `GetWebgpuRecipe` projects. WebGPU folds state into\n// a pipeline at creation, so the three descriptors\n// are one projection rather than three structs.\n// m_renderTargetFormats -> colorFormats\n// m_depthStencilFormat -> depthFormat\n// m_sampleDesc -> sampleCount\n// m_vertexStreamMask -> derived from vertexBufferLayouts\n//\n// THE PROJECTION IS NOT REIMPLEMENTED HERE. `Tr2RenderStateSetup.GetWebgpuRecipe`\n// already turns an interpreted setup into WebGPU state, applies the render-state\n// overrides while doing it, and refuses a fill mode WebGPU cannot rasterize. A\n// second translator is the mistake this whole lane exists to undo.\nimport { CjsSchema } from \"#schema\";\nimport { RenderPipelineKey } from \"./CjsWebgpuPipelineCache.js\";\nimport { TOPOLOGIES } from \"./topology.js\";\n\n\n/**\n * A pipeline description, filled by the abstraction layer's setters.\n *\n * Carbon's `PSODescription` is a plain struct with an `operator==` and a hash;\n * this is the same, with `GetKey` standing in for both because a canonical key\n * compares and hashes at once.\n */\nexport class CjsWebgpuPsoDescription\n{\n /** m_shaderProgram */\n shaderProgram = null;\n\n /** m_vertexLayout, as WebGPU buffer layouts. */\n vertexBufferLayouts = [];\n\n /** m_topologyType, in the abstraction layer's vocabulary. */\n topology = null;\n\n /** The authored state, projected at resolve time. */\n renderStateSetup = null;\n\n /** The state manager's overrides, applied by the projection. */\n renderStateOverrides = null;\n\n /** m_renderTargetFormats[MAX_RENDER_TARGET] */\n colorFormats = [];\n\n /** m_depthStencilFormat; null means no depth attachment. */\n depthFormat = null;\n\n /** m_sampleDesc, reduced to the one field WebGPU exposes. */\n sampleCount = 1;\n\n /**\n * Whether the description names everything a pipeline needs.\n *\n * Carbon's `GetPipelineState` returns null and `SetAllState` fails\n * (`cpp:847-851`) rather than creating a partial pipeline; this is the same\n * check, made before the attempt so the caller can say what is missing.\n *\n * @returns {string|null} What is missing, or null when complete.\n */\n GetMissing()\n {\n if (!this.shaderProgram || !this.shaderProgram.IsValid()) return \"a linked shader program\";\n if (!this.renderStateSetup) return \"a render-state setup\";\n if (this.topology === null || TOPOLOGIES[this.topology] === undefined) return \"a topology WebGPU can draw\";\n if (this.colorFormats.length === 0 && this.depthFormat === null) return \"a colour or depth attachment\";\n\n return null;\n }\n\n /**\n * The WebGPU pipeline descriptor this description resolves to.\n *\n * Carbon's `CreatePipelineState` builds a `D3D12_GRAPHICS_PIPELINE_STATE_DESC`\n * from the same fields. Ours produces the recipe shape the device's pipeline\n * factory already takes from the batch path, so both paths create pipelines\n * the same way.\n *\n * @returns {object} The recipe.\n */\n BuildRecipe()\n {\n const projected = this.renderStateSetup.GetWebgpuRecipe({\n depthFormat: this.depthFormat,\n invertedDepthTest: !!this.renderStateOverrides?.invertedDepthTest,\n invertedCullMode: !!this.renderStateOverrides?.invertedCullMode\n });\n\n // The authored blend and colour write mask are the projection's `target`\n // (Tr2RenderStateSetup.GetWebgpuRecipe); each colour target carries them,\n // as D3D11's non-independent blend gives every RTV RenderTarget[0]'s state\n // (Tr2RenderContextDx11.cpp:784-785).\n const { target, ...state } = projected;\n\n // A BOUND TARGET THE PIXEL SHADER DOES NOT WRITE gets writeMask 0 and no\n // blend. D3D11 leaves such an RTV untouched; WebGPU rejects the pipeline\n // unless its mask is 0. That is what lets the velocity target stay bound at\n // slot 1 through opaque draws whose shaders never output SV_Target1.\n const outputs = typeof this.shaderProgram.GetFragmentOutputs === \"function\"\n ? this.shaderProgram.GetFragmentOutputs()\n : null;\n const colourTarget = (format, index) =>\n {\n if (!format) return null;\n if (outputs && !outputs.includes(index)) return { format, writeMask: 0 };\n return { format, ...target };\n };\n\n return {\n ...state,\n primitive: { ...projected.primitive, topology: TOPOLOGIES[this.topology] },\n vertex: { buffers: this.vertexBufferLayouts },\n fragment: {\n // An unbound slot between bound ones is a null target, as it is a null\n // colour attachment in the pass.\n targets: this.colorFormats.map(colourTarget)\n },\n multisample: { count: this.sampleCount }\n };\n }\n\n /**\n * The cache key, which is Carbon's `UpdateHash` plus `operator==` at once.\n *\n * Two descriptions with the same key resolve to the same pipeline, which is\n * the whole point of describing rather than assembling: a frame that draws\n * two hundred objects through one material creates one pipeline.\n *\n * @returns {string|null} The key, or null when the description is incomplete.\n */\n GetKey()\n {\n if (this.GetMissing()) return null;\n\n // A real program names itself; a stand-in keys on its own fields. Metal\n // hashes the function pointers for this (`MetalWorkQueue.mm:1610-1611`),\n // and canonicalising a program's modules would serialise device objects.\n const identity = typeof this.shaderProgram.GetIdentity === \"function\"\n ? this.shaderProgram.GetIdentity()\n : this.shaderProgram;\n\n return RenderPipelineKey(identity, this.BuildRecipe());\n }\n\n /**\n * Whether two descriptions resolve to the same pipeline.\n *\n * @param {CjsWebgpuPsoDescription} other The description to compare.\n * @returns {boolean} True when both are complete and equal.\n */\n Equals(other)\n {\n if (!other) return false;\n\n const key = this.GetKey();\n\n return key !== null && key === other.GetKey();\n }\n}\n\n\n// DECLARED AS A CALL, NOT A DECORATOR. The abstraction layer is imported\n// straight from source by its tests - `#trinityal/...` resolves to `src/` - and\n// raw Node cannot parse decorator syntax, so a decorator here breaks every test\n// that reaches this file without a build first. `CjsSchema.define` is the same\n// metadata through the door the schema already provides for exactly this, and\n// it keeps the layer free of the decorator chain it has never carried.\nCjsSchema.define(CjsWebgpuPsoDescription, { className: \"CjsWebgpuPsoDescription\", carbon: \"PSODescription\" });\n"],"names":["CjsWebgpuPsoDescription","shaderProgram","vertexBufferLayouts","topology","renderStateSetup","renderStateOverrides","colorFormats","depthFormat","sampleCount","GetMissing","IsValid","TOPOLOGIES","undefined","length","BuildRecipe","projected","GetWebgpuRecipe","invertedDepthTest","invertedCullMode","target","state","outputs","GetFragmentOutputs","colourTarget","format","index","includes","writeMask","primitive","vertex","buffers","fragment","targets","map","multisample","count","GetKey","identity","GetIdentity","RenderPipelineKey","Equals","other","key","CjsSchema","define","className","carbon"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,CACpC;AACE;AACAC,EAAAA,aAAa,GAAG,IAAI;;AAEpB;AACAC,EAAAA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vB,WAAW,EAAE,CAAC;AACxD,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACE0B,MAAMA,CAACC,KAAK,EACZ;AACE,IAAA,IAAI,CAACA,KAAK,EAAE,OAAO,KAAK;AAExB,IAAA,MAAMC,GAAG,GAAG,IAAI,CAACN,MAAM,EAAE;IAEzB,OAAOM,GAAG,KAAK,IAAI,IAAIA,GAAG,KAAKD,KAAK,CAACL,MAAM,EAAE;AAC/C,EAAA;AACF;;AAGA;AACA;AACA;AACA;AACA;AACA;AACAO,SAAS,CAACC,MAAM,CAAC5C,uBAAuB,EAAE;AAAE6C,EAAAA,SAAS,EAAE,yBAAyB;AAAEC,EAAAA,MAAM,EAAE;AAAiB,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsWebgpuPsoDescription.js","sources":["../../../../../src/trinityal/webgpu/core/CjsWebgpuPsoDescription.js"],"sourcesContent":["// Source: trinity/trinityal/dx12/util/PsoDescription.h\n// trinity/trinityal/dx12/util/PsoDescription.cpp\n// trinity/trinityal/dx12/Tr2RenderContextDx12.cpp (the setters and SetAllState)\n//\n// The pipeline description a draw resolves, and the fourth piece of the\n// immediate-draw route.\n//\n// WHAT CARBON DOES. Its backend does not assemble a pipeline per draw. The\n// setters describe one incrementally and mark it dirty\n// (`Tr2RenderContextDx12.cpp:315-338`: each compares before dirtying, so a\n// redundant apply costs nothing), and the draw resolves it:\n//\n// m_psoDescription.UpdateHash(); // cpp:793\n// auto found = m_ownerDevice->m_pipelineStates.find( m_psoDescription );\n// if( found != end ) return found->second;\n// m_psoDescription.CreatePipelineState( device, pipelineState );\n// m_ownerDevice->m_pipelineStates[ m_psoDescription ] = pipelineState;\n//\n// THE CACHE IS ON THE DEVICE, NOT THE CONTEXT (`Tr2PrimaryRenderContextDx12.h:319`),\n// which is why two contexts drawing the same material share one pipeline. Ours\n// is `CjsWebgpuPipelineCache`, already on `CjsWebgpuDevice` and already serving\n// the batch path - this describes, and hands the description to that.\n//\n// Carbon's fields, and where each lives here:\n//\n// m_vertexLayout -> vertexBufferLayouts, from the bound layout\n// m_shaderProgram -> shaderProgram, a CjsWebgpuShaderProgramAL\n// m_topologyType -> topology, mapped through the AL's own table\n// m_blendDesc }\n// m_rasterizerDesc } all three -> renderStateSetup + overrides, which\n// m_depthStencilDesc } `GetWebgpuRecipe` projects. WebGPU folds state into\n// a pipeline at creation, so the three descriptors\n// are one projection rather than three structs.\n// m_renderTargetFormats -> colorFormats\n// m_depthStencilFormat -> depthFormat\n// m_sampleDesc -> sampleCount\n// m_vertexStreamMask -> derived from vertexBufferLayouts\n//\n// THE PROJECTION IS NOT REIMPLEMENTED HERE. `Tr2RenderStateSetup.GetWebgpuRecipe`\n// already turns an interpreted setup into WebGPU state, applies the render-state\n// overrides while doing it, and refuses a fill mode WebGPU cannot rasterize. A\n// second translator is the mistake this whole lane exists to undo.\nimport { CjsSchema } from \"#schema\";\nimport { CARBON_BACKEND_UNORM_TARGET_OVERRIDE } from \"#resource/format\";\nimport { RenderPipelineKey } from \"./CjsWebgpuPipelineCache.js\";\nimport { TOPOLOGIES } from \"./topology.js\";\n\n\n/**\n * A pipeline description, filled by the abstraction layer's setters.\n *\n * Carbon's `PSODescription` is a plain struct with an `operator==` and a hash;\n * this is the same, with `GetKey` standing in for both because a canonical key\n * compares and hashes at once.\n */\nexport class CjsWebgpuPsoDescription\n{\n /** m_shaderProgram */\n shaderProgram = null;\n\n /** m_vertexLayout, as WebGPU buffer layouts. */\n vertexBufferLayouts = [];\n\n /** m_topologyType, in the abstraction layer's vocabulary. */\n topology = null;\n\n /** The authored state, projected at resolve time. */\n renderStateSetup = null;\n\n /** The state manager's overrides, applied by the projection. */\n renderStateOverrides = null;\n\n /** m_renderTargetFormats[MAX_RENDER_TARGET] */\n colorFormats = [];\n\n /** m_depthStencilFormat; null means no depth attachment. */\n depthFormat = null;\n\n /** m_sampleDesc, reduced to the one field WebGPU exposes. */\n sampleCount = 1;\n\n /**\n * Per colour slot, whether the bound target is a float stand-in for a\n * 16-bit UNORM format (CjsWebgpuTextureAL.IsUnormSubstitute).\n */\n unormTargets = [];\n\n /**\n * RS_DEPTH_CLIP_ENABLE off, where the device can honour it: WebGPU's\n * `primitive.unclippedDepth`, behind the depth-clip-control feature. Carbon\n * turns depth clip off to draw its shadow cascades (EveSpaceScene.cpp:748).\n */\n unclippedDepth = false;\n\n /**\n * Whether the description names everything a pipeline needs.\n *\n * Carbon's `GetPipelineState` returns null and `SetAllState` fails\n * (`cpp:847-851`) rather than creating a partial pipeline; this is the same\n * check, made before the attempt so the caller can say what is missing.\n *\n * @returns {string|null} What is missing, or null when complete.\n */\n GetMissing()\n {\n if (!this.shaderProgram || !this.shaderProgram.IsValid()) return \"a linked shader program\";\n if (!this.renderStateSetup) return \"a render-state setup\";\n if (this.topology === null || TOPOLOGIES[this.topology] === undefined) return \"a topology WebGPU can draw\";\n if (this.colorFormats.length === 0 && this.depthFormat === null) return \"a colour or depth attachment\";\n\n return null;\n }\n\n /**\n * The WebGPU pipeline descriptor this description resolves to.\n *\n * Carbon's `CreatePipelineState` builds a `D3D12_GRAPHICS_PIPELINE_STATE_DESC`\n * from the same fields. Ours produces the recipe shape the device's pipeline\n * factory already takes from the batch path, so both paths create pipelines\n * the same way.\n *\n * @returns {object} The recipe.\n */\n BuildRecipe()\n {\n const projected = this.renderStateSetup.GetWebgpuRecipe({\n depthFormat: this.depthFormat,\n invertedDepthTest: !!this.renderStateOverrides?.invertedDepthTest,\n invertedCullMode: !!this.renderStateOverrides?.invertedCullMode\n });\n\n // The authored blend and colour write mask are the projection's `target`\n // (Tr2RenderStateSetup.GetWebgpuRecipe); each colour target carries them,\n // as D3D11's non-independent blend gives every RTV RenderTarget[0]'s state\n // (Tr2RenderContextDx11.cpp:784-785).\n const { target, ...state } = projected;\n\n // A BOUND TARGET THE PIXEL SHADER DOES NOT WRITE gets writeMask 0 and no\n // blend. D3D11 leaves such an RTV untouched; WebGPU rejects the pipeline\n // unless its mask is 0. That is what lets the velocity target stay bound at\n // slot 1 through opaque draws whose shaders never output SV_Target1.\n const outputs = typeof this.shaderProgram.GetFragmentOutputs === \"function\"\n ? this.shaderProgram.GetFragmentOutputs()\n : null;\n const colourTarget = (format, index) =>\n {\n if (!format) return null;\n if (outputs && !outputs.includes(index)) return { format, writeMask: 0 };\n return { format, ...target };\n };\n\n // A FLOAT STAND-IN FOR A UNORM TARGET stores what UNORM would: the\n // shader's per-target override clamps the output to [0, 1] and makes NaN 0,\n // as D3D does writing to UNORM. TAA's R16G16B16A16_UNORM history kept a\n // NaN forever without it. Only overrides the module declares may be set.\n const overrides = typeof this.shaderProgram.GetUnormTargetOverrides === \"function\"\n ? this.shaderProgram.GetUnormTargetOverrides()\n : [];\n const constants = {};\n\n for (const location of overrides)\n {\n if (this.unormTargets[location]) constants[`${CARBON_BACKEND_UNORM_TARGET_OVERRIDE}${location}`] = 1;\n }\n\n return {\n ...state,\n primitive: {\n ...projected.primitive,\n topology: TOPOLOGIES[this.topology],\n ...(this.unclippedDepth ? { unclippedDepth: true } : {})\n },\n vertex: { buffers: this.vertexBufferLayouts },\n fragment: {\n // An unbound slot between bound ones is a null target, as it is a null\n // colour attachment in the pass.\n targets: this.colorFormats.map(colourTarget),\n ...(Object.keys(constants).length ? { constants } : {})\n },\n multisample: { count: this.sampleCount }\n };\n }\n\n /**\n * The cache key, which is Carbon's `UpdateHash` plus `operator==` at once.\n *\n * Two descriptions with the same key resolve to the same pipeline, which is\n * the whole point of describing rather than assembling: a frame that draws\n * two hundred objects through one material creates one pipeline.\n *\n * @returns {string|null} The key, or null when the description is incomplete.\n */\n GetKey()\n {\n if (this.GetMissing()) return null;\n\n // A real program names itself; a stand-in keys on its own fields. Metal\n // hashes the function pointers for this (`MetalWorkQueue.mm:1610-1611`),\n // and canonicalising a program's modules would serialise device objects.\n const identity = typeof this.shaderProgram.GetIdentity === \"function\"\n ? this.shaderProgram.GetIdentity()\n : this.shaderProgram;\n\n return RenderPipelineKey(identity, this.BuildRecipe());\n }\n\n /**\n * Whether two descriptions resolve to the same pipeline.\n *\n * @param {CjsWebgpuPsoDescription} other The description to compare.\n * @returns {boolean} True when both are complete and equal.\n */\n Equals(other)\n {\n if (!other) return false;\n\n const key = this.GetKey();\n\n return key !== null && key === other.GetKey();\n }\n}\n\n\n// DECLARED AS A CALL, NOT A DECORATOR. The abstraction layer is imported\n// straight from source by its tests - `#trinityal/...` resolves to `src/` - and\n// raw Node cannot parse decorator syntax, so a decorator here breaks every test\n// that reaches this file without a build first. `CjsSchema.define` is the same\n// metadata through the door the schema already provides for exactly this, and\n// it keeps the layer free of the decorator chain it has never carried.\nCjsSchema.define(CjsWebgpuPsoDescription, { className: \"CjsWebgpuPsoDescription\", carbon: \"PSODescription\" });\n"],"names":["CjsWebgpuPsoDescription","shaderProgram","vertexBufferLayouts","topology","renderStateSetup","renderStateOverrides","colorFormats","depthFormat","sampleCount","unormTargets","unclippedDepth","GetMissing","IsValid","TOPOLOGIES","undefined","length","BuildRecipe","projected","GetWebgpuRecipe","invertedDepthTest","invertedCullMode","target","state","outputs","GetFragmentOutputs","colourTarget","format","index","includes","writeMask","overrides","GetUnormTargetOverrides","constants","location","CARBON_BACKEND_UNORM_TARGET_OVERRIDE","primitive","vertex","buffers","fragment","targets","map","Object","keys","multisample","count","GetKey","identity","GetIdentity","RenderPipelineKey","Equals","other","key","CjsSchema","define","className","carbon"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,CACpC;AACE;AACAC,EAAAA,aAAa,GAAG,IAAI;;AAEpB;AACAC,EAAAA,mBAAmB,GAAG,EAAE;;AAExB;AACAC,EAAAA,QAA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OAAqB;AAC7CoC,MAAAA,QAAQ,EAAE;AACR;AACA;QACAC,OAAO,EAAE,IAAI,CAACjC,YAAY,CAACkC,GAAG,CAACf,YAAY,CAAC;QAC5C,IAAIgB,MAAM,CAACC,IAAI,CAACV,SAAS,CAAC,CAACjB,MAAM,GAAG;AAAEiB,UAAAA;SAAW,GAAG,EAAE;OACvD;AACDW,MAAAA,WAAW,EAAE;QAAEC,KAAK,EAAE,IAAI,CAACpC;AAAY;KACxC;AACH,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEqC,EAAAA,MAAMA,GACN;AACE,IAAA,IAAI,IAAI,CAAClC,UAAU,EAAE,EAAE,OAAO,IAAI;;AAElC;AACA;AACA;IACA,MAAMmC,QAAQ,GAAG,OAAO,IAAI,CAAC7C,aAAa,CAAC8C,WAAW,KAAK,UAAU,GACjE,IAAI,CAAC9C,aAAa,CAAC8C,WAAW,EAAE,GAChC,IAAI,CAAC9C,aAAa;IAEtB,OAAO+C,iBAAiB,CAACF,QAAQ,EAAE,IAAI,CAAC9B,WAAW,EAAE,CAAC;AACxD,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;EACEiC,MAAMA,CAACC,KAAK,EACZ;AACE,IAAA,IAAI,CAACA,KAAK,EAAE,OAAO,KAAK;AAExB,IAAA,MAAMC,GAAG,GAAG,IAAI,CAACN,MAAM,EAAE;IAEzB,OAAOM,GAAG,KAAK,IAAI,IAAIA,GAAG,KAAKD,KAAK,CAACL,MAAM,EAAE;AAC/C,EAAA;AACF;;AAGA;AACA;AACA;AACA;AACA;AACA;AACAO,SAAS,CAACC,MAAM,CAACrD,uBAAuB,EAAE;AAAEsD,EAAAA,SAAS,EAAE,yBAAyB;AAAEC,EAAAA,MAAM,EAAE;AAAiB,CAAC,CAAC;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CjsSchema } from '#schema';
|
|
2
2
|
import { PixelFormat } from '#consts/render-context';
|
|
3
|
+
import { num } from '#math/num';
|
|
3
4
|
|
|
4
5
|
// Source: trinity/trinityal/metal/MetalUtils.h
|
|
5
6
|
// trinity/trinityal/metal/MetalUtils.mm:12-133, 353-357
|
|
@@ -25,8 +26,9 @@ const {
|
|
|
25
26
|
* depth format behind an optional feature), the entry is absent, which is
|
|
26
27
|
* Metal's `MTLPixelFormatInvalid`: the texture is refused.
|
|
27
28
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* The 16-bit unorm formats are substituted rather than refused: TAA renders
|
|
30
|
+
* into R16G16B16A16_UNORM, and CORTAO's lookup table is R16_UNORM data
|
|
31
|
+
* (`Tr2SSAO.cpp:108`). See their entries and `UPLOAD_CONVERSIONS`.
|
|
30
32
|
*
|
|
31
33
|
* One entry differs from Metal on purpose. Metal maps `D24_UNORM_S8_UINT` to
|
|
32
34
|
* `Depth32Float` because Apple GPUs lack a 24-bit depth format; WebGPU has
|
|
@@ -36,13 +38,39 @@ const PIXEL_FORMATS = [[PixelFormat.PIXEL_FORMAT_R32G32B32A32_FLOAT, "rgba32floa
|
|
|
36
38
|
// DIVERGENCE: rgba16unorm is not core WebGPU (Metal has RGBA16Unorm). Carbon
|
|
37
39
|
// renders TAA's accumulators in it (Tr2PostProcessRenderer.cpp:1450-1463);
|
|
38
40
|
// rgba16float holds every 16-bit unorm value's range, a little less exactly
|
|
39
|
-
// near 1.
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
// near 1. Pixel data uploaded into it is converted (UPLOAD_CONVERSIONS).
|
|
42
|
+
[PixelFormat.PIXEL_FORMAT_R16G16B16A16_UNORM, "rgba16float"], [PixelFormat.PIXEL_FORMAT_R16G16B16A16_UINT, "rgba16uint"], [PixelFormat.PIXEL_FORMAT_R16G16B16A16_SINT, "rgba16sint"], [PixelFormat.PIXEL_FORMAT_R32G32_FLOAT, "rg32float"], [PixelFormat.PIXEL_FORMAT_R32G32_UINT, "rg32uint"], [PixelFormat.PIXEL_FORMAT_R32G32_SINT, "rg32sint"], [PixelFormat.PIXEL_FORMAT_R10G10B10A2_UNORM, "rgb10a2unorm"], [PixelFormat.PIXEL_FORMAT_R10G10B10A2_UINT, "rgb10a2uint"], [PixelFormat.PIXEL_FORMAT_R11G11B10_FLOAT, "rg11b10ufloat"], [PixelFormat.PIXEL_FORMAT_R8G8B8A8_UNORM, "rgba8unorm"], [PixelFormat.PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, "rgba8unorm-srgb"], [PixelFormat.PIXEL_FORMAT_R8G8B8A8_UINT, "rgba8uint"], [PixelFormat.PIXEL_FORMAT_R8G8B8A8_SNORM, "rgba8snorm"], [PixelFormat.PIXEL_FORMAT_R8G8B8A8_SINT, "rgba8sint"], [PixelFormat.PIXEL_FORMAT_R16G16_FLOAT, "rg16float"], [PixelFormat.PIXEL_FORMAT_R16G16_UINT, "rg16uint"], [PixelFormat.PIXEL_FORMAT_R16G16_SINT, "rg16sint"], [PixelFormat.PIXEL_FORMAT_D32_FLOAT, "depth32float"], [PixelFormat.PIXEL_FORMAT_R32_FLOAT, "r32float"], [PixelFormat.PIXEL_FORMAT_R32_UINT, "r32uint"], [PixelFormat.PIXEL_FORMAT_R32_SINT, "r32sint"], [PixelFormat.PIXEL_FORMAT_D24_UNORM_S8_UINT, "depth24plus-stencil8"], [PixelFormat.PIXEL_FORMAT_R8G8_UNORM, "rg8unorm"], [PixelFormat.PIXEL_FORMAT_R8G8_UINT, "rg8uint"], [PixelFormat.PIXEL_FORMAT_R8G8_SNORM, "rg8snorm"], [PixelFormat.PIXEL_FORMAT_R8G8_SINT, "rg8sint"], [PixelFormat.PIXEL_FORMAT_R16_FLOAT, "r16float"],
|
|
43
|
+
// DIVERGENCE, as R16G16B16A16_UNORM: r16unorm needs texture-formats-tier1
|
|
44
|
+
// and even then cannot be filtered, where D3D and Metal filter it and
|
|
45
|
+
// CORTAO samples its lookup table linearly.
|
|
46
|
+
[PixelFormat.PIXEL_FORMAT_R16_UNORM, "r16float"], [PixelFormat.PIXEL_FORMAT_D16_UNORM, "depth16unorm"], [PixelFormat.PIXEL_FORMAT_R16_UINT, "r16uint"], [PixelFormat.PIXEL_FORMAT_R16_SINT, "r16sint"], [PixelFormat.PIXEL_FORMAT_R8_UNORM, "r8unorm"], [PixelFormat.PIXEL_FORMAT_R8_UINT, "r8uint"], [PixelFormat.PIXEL_FORMAT_R8_SNORM, "r8snorm"], [PixelFormat.PIXEL_FORMAT_R8_SINT, "r8sint"], [PixelFormat.PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, "rgb9e5ufloat"], [PixelFormat.PIXEL_FORMAT_BC1_UNORM, "bc1-rgba-unorm"], [PixelFormat.PIXEL_FORMAT_BC1_UNORM_SRGB, "bc1-rgba-unorm-srgb"], [PixelFormat.PIXEL_FORMAT_BC2_UNORM, "bc2-rgba-unorm"], [PixelFormat.PIXEL_FORMAT_BC2_UNORM_SRGB, "bc2-rgba-unorm-srgb"], [PixelFormat.PIXEL_FORMAT_BC3_UNORM, "bc3-rgba-unorm"], [PixelFormat.PIXEL_FORMAT_BC3_UNORM_SRGB, "bc3-rgba-unorm-srgb"], [PixelFormat.PIXEL_FORMAT_BC4_UNORM, "bc4-r-unorm"], [PixelFormat.PIXEL_FORMAT_BC4_SNORM, "bc4-r-snorm"], [PixelFormat.PIXEL_FORMAT_BC5_UNORM, "bc5-rg-unorm"], [PixelFormat.PIXEL_FORMAT_BC5_SNORM, "bc5-rg-snorm"], [PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM, "bgra8unorm"],
|
|
42
47
|
// BGRX has no WebGPU format any more than a Metal one; Metal reads it as
|
|
43
48
|
// BGRA and ignores the fourth byte, and so does this.
|
|
44
49
|
[PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM, "bgra8unorm"], [PixelFormat.PIXEL_FORMAT_B8G8R8A8_TYPELESS, "bgra8unorm"], [PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, "bgra8unorm-srgb"], [PixelFormat.PIXEL_FORMAT_B8G8R8X8_TYPELESS, "bgra8unorm"], [PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, "bgra8unorm-srgb"], [PixelFormat.PIXEL_FORMAT_BC6H_UF16, "bc6h-rgb-ufloat"], [PixelFormat.PIXEL_FORMAT_BC6H_SF16, "bc6h-rgb-float"], [PixelFormat.PIXEL_FORMAT_BC7_UNORM, "bc7-rgba-unorm"], [PixelFormat.PIXEL_FORMAT_BC7_UNORM_SRGB, "bc7-rgba-unorm-srgb"]];
|
|
45
50
|
|
|
51
|
+
/**
|
|
52
|
+
* A 16-bit unorm texel stream as half floats, same size and layout. A half
|
|
53
|
+
* holds every unorm16 value in [0, 1] to within 2^-11.
|
|
54
|
+
*
|
|
55
|
+
* @param {Uint8Array} bytes The unorm16 data.
|
|
56
|
+
* @returns {Uint8Array} The same texels as binary16.
|
|
57
|
+
*/
|
|
58
|
+
function Unorm16ToHalf(bytes) {
|
|
59
|
+
const source = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
60
|
+
const out = new Uint8Array(bytes.byteLength);
|
|
61
|
+
const target = new DataView(out.buffer);
|
|
62
|
+
for (let at = 0; at + 1 < bytes.byteLength; at += 2) {
|
|
63
|
+
target.setUint16(at, num.toHalfFloat(source.getUint16(at, true) / 65535), true);
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Carbon pixel formats whose data is converted on upload, because the
|
|
70
|
+
* texture is created in a substitute format (PIXEL_FORMATS).
|
|
71
|
+
*/
|
|
72
|
+
const UPLOAD_CONVERSIONS = new Map([[PixelFormat.PIXEL_FORMAT_R16_UNORM, Unorm16ToHalf], [PixelFormat.PIXEL_FORMAT_R16G16B16A16_UNORM, Unorm16ToHalf]]);
|
|
73
|
+
|
|
46
74
|
/**
|
|
47
75
|
* The linear formats Metal makes an sRGB view of, and the view's format
|
|
48
76
|
* (`MetalContext.mm:342-357`, where Metal adds one to the format).
|
|
@@ -70,6 +98,30 @@ class CjsWebgpuUtils {
|
|
|
70
98
|
return pixelFormat >= 0 && pixelFormat < PIXEL_FORMAT_SENTINEL ? this._pixelFormatConversionTable[pixelFormat] : null;
|
|
71
99
|
}
|
|
72
100
|
|
|
101
|
+
/**
|
|
102
|
+
* How a Carbon pixel format's data is converted for its substitute texture
|
|
103
|
+
* format, or null when it uploads as it is. WebGPU-only: Metal has every
|
|
104
|
+
* format in its table natively.
|
|
105
|
+
*
|
|
106
|
+
* @param {number} pixelFormat A Carbon `PixelFormat`.
|
|
107
|
+
* @returns {Function|null} Bytes in, converted bytes out.
|
|
108
|
+
*/
|
|
109
|
+
GetUploadConversion(pixelFormat) {
|
|
110
|
+
return UPLOAD_CONVERSIONS.get(pixelFormat) ?? null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Whether a Carbon pixel format is a UNORM format stored in a float
|
|
115
|
+
* stand-in (PIXEL_FORMATS), so a pipeline rendering to it must store as
|
|
116
|
+
* UNORM does: clamped to [0, 1], NaN as 0. WebGPU-only, as the stand-ins are.
|
|
117
|
+
*
|
|
118
|
+
* @param {number} pixelFormat A Carbon `PixelFormat`.
|
|
119
|
+
* @returns {boolean} True for the 16-bit UNORM formats.
|
|
120
|
+
*/
|
|
121
|
+
IsUnormSubstitute(pixelFormat) {
|
|
122
|
+
return UPLOAD_CONVERSIONS.has(pixelFormat);
|
|
123
|
+
}
|
|
124
|
+
|
|
73
125
|
/**
|
|
74
126
|
* The format of a texture's sRGB view, the format half of
|
|
75
127
|
* `MetalContext::CreateSRGBViewOfMetalTexture` (`MetalContext.mm:342-357`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CjsWebgpuUtils.js","sources":["../../../../../src/trinityal/webgpu/core/CjsWebgpuUtils.js"],"sourcesContent":["// Source: trinity/trinityal/metal/MetalUtils.h\n// trinity/trinityal/metal/MetalUtils.mm:12-133, 353-357\n//\n// The WebGPU backend's translation tables, modelled on Metal's. Carbon's\n// Metal backend owns one `MetalUtils` on its context (`MetalContext.h:34`)\n// and reaches it as `metalContext->m_utils->GetMTLPixelFormat(...)`. Our\n// render context plays `MetalContext`'s part, so it owns this one as\n// `m_utils`. D3D needs no such table: Carbon's pixel format values are DXGI's.\n//\n// Only the pixel format table is ported so far. Metal's other translations\n// (vertex format, texture type, cull mode, blend, compare, stencil, colour\n// write) belong here as they are needed.\nimport { CjsSchema } from \"#schema\";\nimport { PixelFormat } from \"#consts/render-context\";\n\nconst { PIXEL_FORMAT_SENTINEL } = PixelFormat;\n\n/**\n * Carbon's pixel format to the `GPUTextureFormat` a texture is created with.\n *\n * Metal's table (`MetalUtils.mm:12-121`), entry for entry. Where Metal has a\n * format that core WebGPU does not (16-bit unorm/snorm, A8, the packed-stencil\n * depth format behind an optional feature), the entry is absent, which is\n * Metal's `MTLPixelFormatInvalid`: the texture is refused.\n *\n * R16G16B16A16_UNORM is the one such format substituted rather than refused,\n * because TAA renders into it; see its entry.\n *\n * One entry differs from Metal on purpose. Metal maps `D24_UNORM_S8_UINT` to\n * `Depth32Float` because Apple GPUs lack a 24-bit depth format; WebGPU has\n * `depth24plus-stencil8` in core, which keeps the stencil.\n */\nconst PIXEL_FORMATS = [\n [ PixelFormat.PIXEL_FORMAT_R32G32B32A32_FLOAT, \"rgba32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32B32A32_UINT, \"rgba32uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32B32A32_SINT, \"rgba32sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_FLOAT, \"rgba16float\" ],\n // DIVERGENCE: rgba16unorm is not core WebGPU (Metal has RGBA16Unorm). Carbon\n // renders TAA's accumulators in it (Tr2PostProcessRenderer.cpp:1450-1463);\n // rgba16float holds every 16-bit unorm value's range, a little less exactly\n // near 1. A render target only: 16-bit unorm pixel data uploaded into it\n // would be read as halves.\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_UNORM, \"rgba16float\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_UINT, \"rgba16uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_SINT, \"rgba16sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32_FLOAT, \"rg32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32_UINT, \"rg32uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32_SINT, \"rg32sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R10G10B10A2_UNORM, \"rgb10a2unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R10G10B10A2_UINT, \"rgb10a2uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R11G11B10_FLOAT, \"rg11b10ufloat\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_UNORM, \"rgba8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, \"rgba8unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_UINT, \"rgba8uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_SNORM, \"rgba8snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_SINT, \"rgba8sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16_FLOAT, \"rg16float\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16_UINT, \"rg16uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16_SINT, \"rg16sint\" ],\n [ PixelFormat.PIXEL_FORMAT_D32_FLOAT, \"depth32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32_FLOAT, \"r32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32_UINT, \"r32uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32_SINT, \"r32sint\" ],\n [ PixelFormat.PIXEL_FORMAT_D24_UNORM_S8_UINT, \"depth24plus-stencil8\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_UNORM, \"rg8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_UINT, \"rg8uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_SNORM, \"rg8snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_SINT, \"rg8sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16_FLOAT, \"r16float\" ],\n [ PixelFormat.PIXEL_FORMAT_D16_UNORM, \"depth16unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R16_UINT, \"r16uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16_SINT, \"r16sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_UNORM, \"r8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_UINT, \"r8uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_SNORM, \"r8snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_SINT, \"r8sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, \"rgb9e5ufloat\" ],\n [ PixelFormat.PIXEL_FORMAT_BC1_UNORM, \"bc1-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC1_UNORM_SRGB, \"bc1-rgba-unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC2_UNORM, \"bc2-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC2_UNORM_SRGB, \"bc2-rgba-unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC3_UNORM, \"bc3-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC3_UNORM_SRGB, \"bc3-rgba-unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC4_UNORM, \"bc4-r-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC4_SNORM, \"bc4-r-snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC5_UNORM, \"bc5-rg-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC5_SNORM, \"bc5-rg-snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM, \"bgra8unorm\" ],\n // BGRX has no WebGPU format any more than a Metal one; Metal reads it as\n // BGRA and ignores the fourth byte, and so does this.\n [ PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM, \"bgra8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8A8_TYPELESS, \"bgra8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, \"bgra8unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8X8_TYPELESS, \"bgra8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, \"bgra8unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC6H_UF16, \"bc6h-rgb-ufloat\" ],\n [ PixelFormat.PIXEL_FORMAT_BC6H_SF16, \"bc6h-rgb-float\" ],\n [ PixelFormat.PIXEL_FORMAT_BC7_UNORM, \"bc7-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC7_UNORM_SRGB, \"bc7-rgba-unorm-srgb\" ]\n];\n\n/**\n * The linear formats Metal makes an sRGB view of, and the view's format\n * (`MetalContext.mm:342-357`, where Metal adds one to the format).\n */\nconst SRGB_VIEW_FORMATS = new Map([\n [ \"rgba8unorm\", \"rgba8unorm-srgb\" ],\n [ \"bgra8unorm\", \"bgra8unorm-srgb\" ],\n [ \"bc1-rgba-unorm\", \"bc1-rgba-unorm-srgb\" ],\n [ \"bc2-rgba-unorm\", \"bc2-rgba-unorm-srgb\" ],\n [ \"bc3-rgba-unorm\", \"bc3-rgba-unorm-srgb\" ],\n [ \"bc7-rgba-unorm\", \"bc7-rgba-unorm-srgb\" ]\n]);\n\n/** The WebGPU backend's counterpart of Metal's `MetalUtils`. */\nexport class CjsWebgpuUtils\n{\n\n /** Carbon's pixel format to `GPUTextureFormat`, indexed by format; null is refused. */\n _pixelFormatConversionTable = new Array(PIXEL_FORMAT_SENTINEL).fill(null);\n\n /** Builds the tables, as `MetalUtils::MetalUtils` does (`MetalUtils.mm:353-357`). */\n constructor()\n {\n this.SetupPixelFormatConversionTable();\n }\n\n /**\n * The `GPUTextureFormat` for a Carbon pixel format, as\n * `MetalUtils::GetMTLPixelFormat` (`MetalUtils.mm:124-133`).\n *\n * @param {number} pixelFormat A Carbon `PixelFormat`.\n * @returns {string|null} The format, or null when WebGPU has none.\n */\n GetGPUTextureFormat(pixelFormat)\n {\n return pixelFormat >= 0 && pixelFormat < PIXEL_FORMAT_SENTINEL\n ? this._pixelFormatConversionTable[pixelFormat]\n : null;\n }\n\n /**\n * The format of a texture's sRGB view, the format half of\n * `MetalContext::CreateSRGBViewOfMetalTexture` (`MetalContext.mm:342-357`).\n * WebGPU must list a view format when the texture is created, so the format\n * is needed before any view exists.\n *\n * @param {string} format A linear `GPUTextureFormat`.\n * @returns {string|null} The sRGB view format, or null when there is none.\n */\n GetSRGBViewFormat(format)\n {\n return SRGB_VIEW_FORMATS.get(format) ?? null;\n }\n\n /** Fills the pixel format table (`MetalUtils.mm:12-121`). */\n SetupPixelFormatConversionTable()\n {\n this._pixelFormatConversionTable.fill(null);\n\n for (const [ pixelFormat, format ] of PIXEL_FORMATS)\n {\n this._pixelFormatConversionTable[pixelFormat] = format;\n }\n }\n\n}\n\n// Declared as a call, as the other AL classes are: the layer is imported\n// straight from source by its tests.\nCjsSchema.define(CjsWebgpuUtils, { className: \"CjsWebgpuUtils\", modelledOn: \"MetalUtils\" });\n"],"names":["PIXEL_FORMAT_SENTINEL","PixelFormat","PIXEL_FORMATS","PIXEL_FORMAT_R32G32B32A32_FLOAT","PIXEL_FORMAT_R32G32B32A32_UINT","PIXEL_FORMAT_R32G32B32A32_SINT","PIXEL_FORMAT_R16G16B16A16_FLOAT","PIXEL_FORMAT_R16G16B16A16_UNORM","PIXEL_FORMAT_R16G16B16A16_UINT","PIXEL_FORMAT_R16G16B16A16_SINT","PIXEL_FORMAT_R32G32_FLOAT","PIXEL_FORMAT_R32G32_UINT","PIXEL_FORMAT_R32G32_SINT","PIXEL_FORMAT_R10G10B10A2_UNORM","PIXEL_FORMAT_R10G10B10A2_UINT","PIXEL_FORMAT_R11G11B10_FLOAT","PIXEL_FORMAT_R8G8B8A8_UNORM","PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB","PIXEL_FORMAT_R8G8B8A8_UINT","PIXEL_FORMAT_R8G8B8A8_SNORM","PIXEL_FORMAT_R8G8B8A8_SINT","PIXEL_FORMAT_R16G16_FLOAT","PIXEL_FORMAT_R16G16_UINT","PIXEL_FORMAT_R16G16_SINT","PIXEL_FORMAT_D32_FLOAT","PIXEL_FORMAT_R32_FLOAT","PIXEL_FORMAT_R32_UINT","PIXEL_FORMAT_R32_SINT","PIXEL_FORMAT_D24_UNORM_S8_UINT","PIXEL_FORMAT_R8G8_UNORM","PIXEL_FORMAT_R8G8_UINT","PIXEL_FORMAT_R8G8_SNORM","PIXEL_FORMAT_R8G8_SINT","PIXEL_FORMAT_R16_FLOAT","PIXEL_FORMAT_D16_UNORM","PIXEL_FORMAT_R16_UINT","PIXEL_FORMAT_R16_SINT","PIXEL_FORMAT_R8_UNORM","PIXEL_FORMAT_R8_UINT","PIXEL_FORMAT_R8_SNORM","PIXEL_FORMAT_R8_SINT","PIXEL_FORMAT_R9G9B9E5_SHAREDEXP","PIXEL_FORMAT_BC1_UNORM","PIXEL_FORMAT_BC1_UNORM_SRGB","PIXEL_FORMAT_BC2_UNORM","PIXEL_FORMAT_BC2_UNORM_SRGB","PIXEL_FORMAT_BC3_UNORM","PIXEL_FORMAT_BC3_UNORM_SRGB","PIXEL_FORMAT_BC4_UNORM","PIXEL_FORMAT_BC4_SNORM","PIXEL_FORMAT_BC5_UNORM","PIXEL_FORMAT_BC5_SNORM","PIXEL_FORMAT_B8G8R8A8_UNORM","PIXEL_FORMAT_B8G8R8X8_UNORM","PIXEL_FORMAT_B8G8R8A8_TYPELESS","PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB","PIXEL_FORMAT_B8G8R8X8_TYPELESS","PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB","PIXEL_FORMAT_BC6H_UF16","PIXEL_FORMAT_BC6H_SF16","PIXEL_FORMAT_BC7_UNORM","PIXEL_FORMAT_BC7_UNORM_SRGB","SRGB_VIEW_FORMATS","Map","CjsWebgpuUtils","_pixelFormatConversionTable","Array","fill","constructor","SetupPixelFormatConversionTable","GetGPUTextureFormat","pixelFormat","GetSRGBViewFormat","format","get","CjsSchema","define","className","modelledOn"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAsB,CAAC,GAAGC,WAAW;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,CACpB,CAAED,WAAW,CAACE,+BAA+B,EAAE,aAAa,CAAE,EAC9D,CAAEF,WAAW,CAACG,8BAA8B,EAAE,YAAY,CAAE,EAC5D,CAAEH,WAAW,CAACI,8BAA8B,EAAE,YAAY,CAAE,EAC5D,CAAEJ,WAAW,CAACK,+BAA+B,EAAE,aAAa,CAAE;AAC9D;AACA;AACA;AACA;AACA;AACA,CAAEL,WAAW,CAACM,+BAA+B,EAAE,aAAa,CAAE,EAC9D,CAAEN,WAAW,CAACO,8BAA8B,EAAE,YAAY,CAAE,EAC5D,CAAEP,WAAW,CAACQ,8BAA8B,EAAE,YAAY,CAAE,EAC5D,CAAER,WAAW,CAACS,yBAAyB,EAAE,WAAW,CAAE,EACtD,CAAET,WAAW,CAACU,wBAAwB,EAAE,UAAU,CAAE,EACpD,CAAEV,WAAW,CAACW,wBAAwB,EAAE,UAAU,CAAE,EACpD,CAAEX,WAAW,CAACY,8BAA8B,EAAE,cAAc,CAAE,EAC9D,CAAEZ,WAAW,CAACa,6BAA6B,EAAE,aAAa,CAAE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C+D,2BAA2B,CAACM,WAAW,CAAC,GAAGE,MAAM;AACxD,IAAA;AACF,EAAA;AAEF;;AAEA;AACA;AACAE,SAAS,CAACC,MAAM,CAACZ,cAAc,EAAE;AAAEa,EAAAA,SAAS,EAAE,gBAAgB;AAAEC,EAAAA,UAAU,EAAE;AAAa,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"CjsWebgpuUtils.js","sources":["../../../../../src/trinityal/webgpu/core/CjsWebgpuUtils.js"],"sourcesContent":["// Source: trinity/trinityal/metal/MetalUtils.h\n// trinity/trinityal/metal/MetalUtils.mm:12-133, 353-357\n//\n// The WebGPU backend's translation tables, modelled on Metal's. Carbon's\n// Metal backend owns one `MetalUtils` on its context (`MetalContext.h:34`)\n// and reaches it as `metalContext->m_utils->GetMTLPixelFormat(...)`. Our\n// render context plays `MetalContext`'s part, so it owns this one as\n// `m_utils`. D3D needs no such table: Carbon's pixel format values are DXGI's.\n//\n// Only the pixel format table is ported so far. Metal's other translations\n// (vertex format, texture type, cull mode, blend, compare, stencil, colour\n// write) belong here as they are needed.\nimport { CjsSchema } from \"#schema\";\nimport { PixelFormat } from \"#consts/render-context\";\nimport { num } from \"#math/num\";\n\nconst { PIXEL_FORMAT_SENTINEL } = PixelFormat;\n\n/**\n * Carbon's pixel format to the `GPUTextureFormat` a texture is created with.\n *\n * Metal's table (`MetalUtils.mm:12-121`), entry for entry. Where Metal has a\n * format that core WebGPU does not (16-bit unorm/snorm, A8, the packed-stencil\n * depth format behind an optional feature), the entry is absent, which is\n * Metal's `MTLPixelFormatInvalid`: the texture is refused.\n *\n * The 16-bit unorm formats are substituted rather than refused: TAA renders\n * into R16G16B16A16_UNORM, and CORTAO's lookup table is R16_UNORM data\n * (`Tr2SSAO.cpp:108`). See their entries and `UPLOAD_CONVERSIONS`.\n *\n * One entry differs from Metal on purpose. Metal maps `D24_UNORM_S8_UINT` to\n * `Depth32Float` because Apple GPUs lack a 24-bit depth format; WebGPU has\n * `depth24plus-stencil8` in core, which keeps the stencil.\n */\nconst PIXEL_FORMATS = [\n [ PixelFormat.PIXEL_FORMAT_R32G32B32A32_FLOAT, \"rgba32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32B32A32_UINT, \"rgba32uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32B32A32_SINT, \"rgba32sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_FLOAT, \"rgba16float\" ],\n // DIVERGENCE: rgba16unorm is not core WebGPU (Metal has RGBA16Unorm). Carbon\n // renders TAA's accumulators in it (Tr2PostProcessRenderer.cpp:1450-1463);\n // rgba16float holds every 16-bit unorm value's range, a little less exactly\n // near 1. Pixel data uploaded into it is converted (UPLOAD_CONVERSIONS).\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_UNORM, \"rgba16float\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_UINT, \"rgba16uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_SINT, \"rgba16sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32_FLOAT, \"rg32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32_UINT, \"rg32uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32G32_SINT, \"rg32sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R10G10B10A2_UNORM, \"rgb10a2unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R10G10B10A2_UINT, \"rgb10a2uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R11G11B10_FLOAT, \"rg11b10ufloat\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_UNORM, \"rgba8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, \"rgba8unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_UINT, \"rgba8uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_SNORM, \"rgba8snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8B8A8_SINT, \"rgba8sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16_FLOAT, \"rg16float\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16_UINT, \"rg16uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16G16_SINT, \"rg16sint\" ],\n [ PixelFormat.PIXEL_FORMAT_D32_FLOAT, \"depth32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32_FLOAT, \"r32float\" ],\n [ PixelFormat.PIXEL_FORMAT_R32_UINT, \"r32uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R32_SINT, \"r32sint\" ],\n [ PixelFormat.PIXEL_FORMAT_D24_UNORM_S8_UINT, \"depth24plus-stencil8\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_UNORM, \"rg8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_UINT, \"rg8uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_SNORM, \"rg8snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8G8_SINT, \"rg8sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16_FLOAT, \"r16float\" ],\n // DIVERGENCE, as R16G16B16A16_UNORM: r16unorm needs texture-formats-tier1\n // and even then cannot be filtered, where D3D and Metal filter it and\n // CORTAO samples its lookup table linearly.\n [ PixelFormat.PIXEL_FORMAT_R16_UNORM, \"r16float\" ],\n [ PixelFormat.PIXEL_FORMAT_D16_UNORM, \"depth16unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R16_UINT, \"r16uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R16_SINT, \"r16sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_UNORM, \"r8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_UINT, \"r8uint\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_SNORM, \"r8snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_R8_SINT, \"r8sint\" ],\n [ PixelFormat.PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, \"rgb9e5ufloat\" ],\n [ PixelFormat.PIXEL_FORMAT_BC1_UNORM, \"bc1-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC1_UNORM_SRGB, \"bc1-rgba-unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC2_UNORM, \"bc2-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC2_UNORM_SRGB, \"bc2-rgba-unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC3_UNORM, \"bc3-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC3_UNORM_SRGB, \"bc3-rgba-unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC4_UNORM, \"bc4-r-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC4_SNORM, \"bc4-r-snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC5_UNORM, \"bc5-rg-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC5_SNORM, \"bc5-rg-snorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM, \"bgra8unorm\" ],\n // BGRX has no WebGPU format any more than a Metal one; Metal reads it as\n // BGRA and ignores the fourth byte, and so does this.\n [ PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM, \"bgra8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8A8_TYPELESS, \"bgra8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, \"bgra8unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8X8_TYPELESS, \"bgra8unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, \"bgra8unorm-srgb\" ],\n [ PixelFormat.PIXEL_FORMAT_BC6H_UF16, \"bc6h-rgb-ufloat\" ],\n [ PixelFormat.PIXEL_FORMAT_BC6H_SF16, \"bc6h-rgb-float\" ],\n [ PixelFormat.PIXEL_FORMAT_BC7_UNORM, \"bc7-rgba-unorm\" ],\n [ PixelFormat.PIXEL_FORMAT_BC7_UNORM_SRGB, \"bc7-rgba-unorm-srgb\" ]\n];\n\n/**\n * A 16-bit unorm texel stream as half floats, same size and layout. A half\n * holds every unorm16 value in [0, 1] to within 2^-11.\n *\n * @param {Uint8Array} bytes The unorm16 data.\n * @returns {Uint8Array} The same texels as binary16.\n */\nfunction Unorm16ToHalf(bytes)\n{\n const source = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const out = new Uint8Array(bytes.byteLength);\n const target = new DataView(out.buffer);\n\n for (let at = 0; at + 1 < bytes.byteLength; at += 2)\n {\n target.setUint16(at, num.toHalfFloat(source.getUint16(at, true) / 65535), true);\n }\n\n return out;\n}\n\n/**\n * Carbon pixel formats whose data is converted on upload, because the\n * texture is created in a substitute format (PIXEL_FORMATS).\n */\nconst UPLOAD_CONVERSIONS = new Map([\n [ PixelFormat.PIXEL_FORMAT_R16_UNORM, Unorm16ToHalf ],\n [ PixelFormat.PIXEL_FORMAT_R16G16B16A16_UNORM, Unorm16ToHalf ]\n]);\n\n/**\n * The linear formats Metal makes an sRGB view of, and the view's format\n * (`MetalContext.mm:342-357`, where Metal adds one to the format).\n */\nconst SRGB_VIEW_FORMATS = new Map([\n [ \"rgba8unorm\", \"rgba8unorm-srgb\" ],\n [ \"bgra8unorm\", \"bgra8unorm-srgb\" ],\n [ \"bc1-rgba-unorm\", \"bc1-rgba-unorm-srgb\" ],\n [ \"bc2-rgba-unorm\", \"bc2-rgba-unorm-srgb\" ],\n [ \"bc3-rgba-unorm\", \"bc3-rgba-unorm-srgb\" ],\n [ \"bc7-rgba-unorm\", \"bc7-rgba-unorm-srgb\" ]\n]);\n\n/** The WebGPU backend's counterpart of Metal's `MetalUtils`. */\nexport class CjsWebgpuUtils\n{\n\n /** Carbon's pixel format to `GPUTextureFormat`, indexed by format; null is refused. */\n _pixelFormatConversionTable = new Array(PIXEL_FORMAT_SENTINEL).fill(null);\n\n /** Builds the tables, as `MetalUtils::MetalUtils` does (`MetalUtils.mm:353-357`). */\n constructor()\n {\n this.SetupPixelFormatConversionTable();\n }\n\n /**\n * The `GPUTextureFormat` for a Carbon pixel format, as\n * `MetalUtils::GetMTLPixelFormat` (`MetalUtils.mm:124-133`).\n *\n * @param {number} pixelFormat A Carbon `PixelFormat`.\n * @returns {string|null} The format, or null when WebGPU has none.\n */\n GetGPUTextureFormat(pixelFormat)\n {\n return pixelFormat >= 0 && pixelFormat < PIXEL_FORMAT_SENTINEL\n ? this._pixelFormatConversionTable[pixelFormat]\n : null;\n }\n\n /**\n * How a Carbon pixel format's data is converted for its substitute texture\n * format, or null when it uploads as it is. WebGPU-only: Metal has every\n * format in its table natively.\n *\n * @param {number} pixelFormat A Carbon `PixelFormat`.\n * @returns {Function|null} Bytes in, converted bytes out.\n */\n GetUploadConversion(pixelFormat)\n {\n return UPLOAD_CONVERSIONS.get(pixelFormat) ?? null;\n }\n\n /**\n * Whether a Carbon pixel format is a UNORM format stored in a float\n * stand-in (PIXEL_FORMATS), so a pipeline rendering to it must store as\n * UNORM does: clamped to [0, 1], NaN as 0. WebGPU-only, as the stand-ins are.\n *\n * @param {number} pixelFormat A Carbon `PixelFormat`.\n * @returns {boolean} True for the 16-bit UNORM formats.\n */\n IsUnormSubstitute(pixelFormat)\n {\n return UPLOAD_CONVERSIONS.has(pixelFormat);\n }\n\n /**\n * The format of a texture's sRGB view, the format half of\n * `MetalContext::CreateSRGBViewOfMetalTexture` (`MetalContext.mm:342-357`).\n * WebGPU must list a view format when the texture is created, so the format\n * is needed before any view exists.\n *\n * @param {string} format A linear `GPUTextureFormat`.\n * @returns {string|null} The sRGB view format, or null when there is none.\n */\n GetSRGBViewFormat(format)\n {\n return SRGB_VIEW_FORMATS.get(format) ?? null;\n }\n\n /** Fills the pixel format table (`MetalUtils.mm:12-121`). */\n SetupPixelFormatConversionTable()\n {\n this._pixelFormatConversionTable.fill(null);\n\n for (const [ pixelFormat, format ] of PIXEL_FORMATS)\n {\n this._pixelFormatConversionTable[pixelFormat] = format;\n }\n }\n\n}\n\n// Declared as a call, as the other AL classes are: the layer is imported\n// straight from source by its tests.\nCjsSchema.define(CjsWebgpuUtils, { className: \"CjsWebgpuUtils\", modelledOn: \"MetalUtils\" });\n"],"names":["PIXEL_FORMAT_SENTINEL","PixelFormat","PIXEL_FORMATS","PIXEL_FORMAT_R32G32B32A32_FLOAT","PIXEL_FORMAT_R32G32B32A32_UINT","PIXEL_FORMAT_R32G32B32A32_SINT","PIXEL_FORMAT_R16G16B16A16_FLOAT","PIXEL_FORMAT_R16G16B16A16_UNORM","PIXEL_FORMAT_R16G16B16A16_UINT","PIXEL_FORMAT_R16G16B16A16_SINT","PIXEL_FORMAT_R32G32_FLOAT","PIXEL_FORMAT_R32G32_UINT","PIXEL_FORMAT_R32G32_SINT","PIXEL_FORMAT_R10G10B10A2_UNORM","PIXEL_FORMAT_R10G10B10A2_UINT","PIXEL_FORMAT_R11G11B10_FLOAT","PIXEL_FORMAT_R8G8B8A8_UNORM","PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB","PIXEL_FORMAT_R8G8B8A8_UINT","PIXEL_FORMAT_R8G8B8A8_SNORM","PIXEL_FORMAT_R8G8B8A8_SINT","PIXEL_FORMAT_R16G16_FLOAT","PIXEL_FORMAT_R16G16_UINT","PIXEL_FORMAT_R16G16_SINT","PIXEL_FORMAT_D32_FLOAT","PIXEL_FORMAT_R32_FLOAT","PIXEL_FORMAT_R32_UINT","PIXEL_FORMAT_R32_SINT","PIXEL_FORMAT_D24_UNORM_S8_UINT","PIXEL_FORMAT_R8G8_UNORM","PIXEL_FORMAT_R8G8_UINT","PIXEL_FORMAT_R8G8_SNORM","PIXEL_FORMAT_R8G8_SINT","PIXEL_FORMAT_R16_FLOAT","PIXEL_FORMAT_R16_UNORM","PIXEL_FORMAT_D16_UNORM","PIXEL_FORMAT_R16_UINT","PIXEL_FORMAT_R16_SINT","PIXEL_FORMAT_R8_UNORM","PIXEL_FORMAT_R8_UINT","PIXEL_FORMAT_R8_SNORM","PIXEL_FORMAT_R8_SINT","PIXEL_FORMAT_R9G9B9E5_SHAREDEXP","PIXEL_FORMAT_BC1_UNORM","PIXEL_FORMAT_BC1_UNORM_SRGB","PIXEL_FORMAT_BC2_UNORM","PIXEL_FORMAT_BC2_UNORM_SRGB","PIXEL_FORMAT_BC3_UNORM","PIXEL_FORMAT_BC3_UNORM_SRGB","PIXEL_FORMAT_BC4_UNORM","PIXEL_FORMAT_BC4_SNORM","PIXEL_FORMAT_BC5_UNORM","PIXEL_FORMAT_BC5_SNORM","PIXEL_FORMAT_B8G8R8A8_UNORM","PIXEL_FORMAT_B8G8R8X8_UNORM","PIXEL_FORMAT_B8G8R8A8_TYPELESS","PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB","PIXEL_FORMAT_B8G8R8X8_TYPELESS","PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB","PIXEL_FORMAT_BC6H_UF16","PIXEL_FORMAT_BC6H_SF16","PIXEL_FORMAT_BC7_UNORM","PIXEL_FORMAT_BC7_UNORM_SRGB","Unorm16ToHalf","bytes","source","DataView","buffer","byteOffset","byteLength","out","Uint8Array","target","at","setUint16","num","toHalfFloat","getUint16","UPLOAD_CONVERSIONS","Map","SRGB_VIEW_FORMATS","CjsWebgpuUtils","_pixelFormatConversionTable","Array","fill","constructor","SetupPixelFormatConversionTable","GetGPUTextureFormat","pixelFormat","GetUploadConversion","get","IsUnormSubstitute","has","GetSRGBViewFormat","format","CjsSchema","define","className","modelledOn"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA,MAAM;AAAEA,EAAAA;AAAsB,CAAC,GAAGC,WAAW;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAG,CAC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