Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
WebGPUMappings.hpp File Reference

Pure RHI-enum → WebGPU translations (REARCH_WGSL Phase 2). More...

#include "../../core/Types.hpp"
#include "../rhi/GfxEnums.hpp"
#include "../draw/BlendMode.hpp"
#include "../rhi/PipelineState.hpp"
#include "../rhi/WgslBindings.hpp"
#include <webgpu/webgpu.h>
#include <cstdlib>
#include <cstring>
Include dependency graph for WebGPUMappings.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  esengine::webgpu::BlendStateWGPU
 One RHI blend mode as a full WebGPU blend state (color + alpha). More...

Namespaces

namespace  esengine
namespace  esengine::webgpu

Functions

BlendStateWGPU esengine::webgpu::toWGPUBlend (BlendMode mode, bool layerAlpha=false)
 Maps BlendMode to its WebGPU blend components — mirrors GLDevice's setBlendMode table (Overlay renders as Normal there too; the real overlay math lives in shaders).
WGPUVertexFormat esengine::webgpu::toWGPUVertexFormat (u8 components, GfxDataType type, bool normalized)
 Maps one RHI attribute (components × type × normalized) to a WGPUVertexFormat, or kInvalidVertexFormat for combinations the engine never produces.
WGPUIndexFormat esengine::webgpu::toWGPUIndexFormat (GfxDataType type)
 Index type for drawElements' GfxDataType.
WGPUTextureFormat esengine::webgpu::toWGPUTextureFormat (GfxPixelFormat fmt)
u32 esengine::webgpu::wgpuBytesPerPixel (GfxPixelFormat fmt)
WGPUTextureFormat esengine::webgpu::toWGPUCompressedFormat (GfxCompressedFormat fmt)
WGPUFeatureName esengine::webgpu::compressionFeatureFor (GfxCompressedFormat fmt)
WGPUFilterMode esengine::webgpu::toWGPUFilter (TextureFilter filter)
WGPUAddressMode esengine::webgpu::toWGPUAddressMode (TextureWrap wrap)
WGPUBufferUsage esengine::webgpu::toWGPUBufferUsage (GfxBufferUsage usage)
WGPUCompareFunction esengine::webgpu::toWGPUCompare (GfxStencilFunc func)
WGPUStencilOperation esengine::webgpu::toWGPUStencilOp (GfxStencilOp op)
WGPUStencilFaceState esengine::webgpu::toWGPUStencilFace (GfxStencilMode mode)
 The engine's two stencil modes as WebGPU face states (same table as GLDevice::applyPipeline: Write = Always/Replace + no color write, Test = Equal/Keep).
u32 esengine::webgpu::toWGPUStencilWriteMask (GfxStencilMode mode)
 Stencil write mask per mode — the applyStencilMode table: Write fills all planes, Test reads without writing, Off never touches stencil.
WGPUDepthStencilState esengine::webgpu::toWGPUDepthStencil (const PipelineDesc &desc, WGPUTextureFormat format)
 A pipeline's full depth-stencil state against a pass attachment format.
bool esengine::webgpu::hasStencilPlanes (WGPUTextureFormat format)
 True when a depth-stencil format carries stencil planes (drives whether a pass may set stencil load/store ops — Depth24Plus alone must not).
WGPULoadOp esengine::webgpu::toWGPULoadOp (bool clearRequested, bool scoped)
WGPUColor esengine::webgpu::toWGPUClearColor (const RenderPassDesc &desc)
WGPUCullMode esengine::webgpu::toWGPUCullMode (bool enabled, bool front)
 Cull state (PipelineDesc.cullEnabled/cullFront). Front face is CCW, matching the GL backend's default winding.
u64 esengine::webgpu::scanWGSLTextureKindMask (const char *source, u32 group, const char *kind)
 Bit mask of the group's bindings whose declaration names the type kind.
u64 esengine::webgpu::scanWGSLDepthTextureMask (const char *source, u32 group)
 Bit mask of the group's bindings a WGSL source declares as DEPTH textures.
u64 esengine::webgpu::scanWGSLArrayTextureMask (const char *source, u32 group)
 Bit mask of the group's bindings a WGSL source declares as texture_2d_array.
u64 esengine::webgpu::scanWGSLVolumeTextureMask (const char *source, u32 group)
 Bit mask of the group's bindings a WGSL source declares as texture_3d.
u32 esengine::webgpu::alignedWriteSize (u32 size)
bool esengine::webgpu::needsWriteStaging (u32 size)
bool esengine::webgpu::writeFitsInBuffer (u32 offset, u32 size, u32 capacity)

Variables

constexpr WGPUVertexFormat esengine::webgpu::kInvalidVertexFormat = WGPUVertexFormat_Force32
 Sentinel for "no WGPU spelling": the header defines no Undefined vertex format, so the enum's non-value stands in. Callers treat it as a hard error.
constexpr u32 esengine::webgpu::kGroup1TextureUnits = WGSL_MAX_TEXTURE_UNITS
 Texture units the group-1 convention spans — see WGSL_MAX_TEXTURE_UNITS.

Detailed Description

Pure RHI-enum → WebGPU translations (REARCH_WGSL Phase 2).

Every GfxEnums/PipelineState concept the GL backend consumes has its WebGPU spelling here, as free functions with no device dependency — so the mapping layer is unit-testable long before a live adapter exists, and WebGPUDevice stays a thin orchestration shell over these.

Compiled only under ES_ENABLE_WEBGPU (emdawnwebgpu port supplies <webgpu/webgpu.h>); never part of the GL build.

Author
ESEngine Team
Date
2026

Definition in file WebGPUMappings.hpp.