Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::webgpu Namespace Reference

Classes

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

Functions

BlendStateWGPU 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 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 toWGPUIndexFormat (GfxDataType type)
 Index type for drawElements' GfxDataType.
WGPUTextureFormat toWGPUTextureFormat (GfxPixelFormat fmt)
u32 wgpuBytesPerPixel (GfxPixelFormat fmt)
WGPUTextureFormat toWGPUCompressedFormat (GfxCompressedFormat fmt)
WGPUFeatureName compressionFeatureFor (GfxCompressedFormat fmt)
WGPUFilterMode toWGPUFilter (TextureFilter filter)
WGPUAddressMode toWGPUAddressMode (TextureWrap wrap)
WGPUBufferUsage toWGPUBufferUsage (GfxBufferUsage usage)
WGPUCompareFunction toWGPUCompare (GfxStencilFunc func)
WGPUStencilOperation toWGPUStencilOp (GfxStencilOp op)
WGPUStencilFaceState 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 toWGPUStencilWriteMask (GfxStencilMode mode)
 Stencil write mask per mode — the applyStencilMode table: Write fills all planes, Test reads without writing, Off never touches stencil.
WGPUDepthStencilState toWGPUDepthStencil (const PipelineDesc &desc, WGPUTextureFormat format)
 A pipeline's full depth-stencil state against a pass attachment format.
bool 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 toWGPULoadOp (bool clearRequested, bool scoped)
WGPUColor toWGPUClearColor (const RenderPassDesc &desc)
WGPUCullMode toWGPUCullMode (bool enabled, bool front)
 Cull state (PipelineDesc.cullEnabled/cullFront). Front face is CCW, matching the GL backend's default winding.
u64 scanWGSLTextureKindMask (const char *source, u32 group, const char *kind)
 Bit mask of the group's bindings whose declaration names the type kind.
u64 scanWGSLDepthTextureMask (const char *source, u32 group)
 Bit mask of the group's bindings a WGSL source declares as DEPTH textures.
u64 scanWGSLArrayTextureMask (const char *source, u32 group)
 Bit mask of the group's bindings a WGSL source declares as texture_2d_array.
u64 scanWGSLVolumeTextureMask (const char *source, u32 group)
 Bit mask of the group's bindings a WGSL source declares as texture_3d.
u32 alignedWriteSize (u32 size)
bool needsWriteStaging (u32 size)
bool writeFitsInBuffer (u32 offset, u32 size, u32 capacity)

Variables

constexpr WGPUVertexFormat 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 kGroup1TextureUnits = WGSL_MAX_TEXTURE_UNITS
 Texture units the group-1 convention spans — see WGSL_MAX_TEXTURE_UNITS.

Function Documentation

◆ alignedWriteSize()

u32 esengine::webgpu::alignedWriteSize ( u32 size)
inline

WriteBuffer's size (and offset) must be a 4-byte multiple; buffers are allocated rounded up so the slack exists. Callers supply exactly size bytes, so an unaligned size must be staged, never read up to alignedWriteSize in place.

Definition at line 445 of file WebGPUMappings.hpp.

◆ compressionFeatureFor()

WGPUFeatureName esengine::webgpu::compressionFeatureFor ( GfxCompressedFormat fmt)
inline

◆ hasStencilPlanes()

bool esengine::webgpu::hasStencilPlanes ( WGPUTextureFormat format)
inline

True when a depth-stencil format carries stencil planes (drives whether a pass may set stencil load/store ops — Depth24Plus alone must not).

Definition at line 347 of file WebGPUMappings.hpp.

Referenced by esengine::WebGPUDevice::clearStencil().

◆ needsWriteStaging()

bool esengine::webgpu::needsWriteStaging ( u32 size)
inline

Definition at line 446 of file WebGPUMappings.hpp.

Referenced by esengine::WebGPUDevice::backendUpdateBuffer().

◆ scanWGSLArrayTextureMask()

u64 esengine::webgpu::scanWGSLArrayTextureMask ( const char * source,
u32 group )
inline

Bit mask of the group's bindings a WGSL source declares as texture_2d_array.

Such a binding's layout entry is viewDimension = 2DArray, and only an array view binds under it.

Definition at line 430 of file WebGPUMappings.hpp.

References scanWGSLTextureKindMask().

Referenced by esengine::WebGPUDevice::backendCreateProgram().

◆ scanWGSLDepthTextureMask()

u64 esengine::webgpu::scanWGSLDepthTextureMask ( const char * source,
u32 group )
inline

Bit mask of the group's bindings a WGSL source declares as DEPTH textures.

A texture_depth_2d binding needs sampleType = Depth in its layout entry and a depth-aspect view under it; bound as an ordinary float texture WebGPU rejects the pipeline.

Definition at line 422 of file WebGPUMappings.hpp.

References scanWGSLTextureKindMask().

Referenced by esengine::WebGPUDevice::backendCreateProgram().

◆ scanWGSLTextureKindMask()

u64 esengine::webgpu::scanWGSLTextureKindMask ( const char * source,
u32 group,
const char * kind )
inline

Bit mask of the group's bindings whose declaration names the type kind.

Same source scan as scanWGSLBindingMask, reading the declaration that follows each binding.

Definition at line 391 of file WebGPUMappings.hpp.

Referenced by scanWGSLArrayTextureMask(), scanWGSLDepthTextureMask(), and scanWGSLVolumeTextureMask().

◆ scanWGSLVolumeTextureMask()

u64 esengine::webgpu::scanWGSLVolumeTextureMask ( const char * source,
u32 group )
inline

Bit mask of the group's bindings a WGSL source declares as texture_3d.

Such a binding's layout entry is viewDimension = 3D, and only a volume's view binds under it.

Definition at line 438 of file WebGPUMappings.hpp.

References scanWGSLTextureKindMask().

Referenced by esengine::WebGPUDevice::backendCreateProgram().

◆ toWGPUAddressMode()

WGPUAddressMode esengine::webgpu::toWGPUAddressMode ( TextureWrap wrap)
inline

◆ toWGPUBlend()

BlendStateWGPU esengine::webgpu::toWGPUBlend ( BlendMode mode,
bool layerAlpha = false )
inline

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).

Definition at line 48 of file WebGPUMappings.hpp.

References esengine::Additive, esengine::Darken, esengine::Lighten, esengine::Multiply, esengine::None, esengine::Normal, esengine::Overlay, esengine::PmaAdditive, esengine::PremultipliedAlpha, and esengine::Screen.

◆ toWGPUBufferUsage()

WGPUBufferUsage esengine::webgpu::toWGPUBufferUsage ( GfxBufferUsage usage)
inline

◆ toWGPUClearColor()

WGPUColor esengine::webgpu::toWGPUClearColor ( const RenderPassDesc & desc)
inline

Definition at line 365 of file WebGPUMappings.hpp.

References esengine::RenderPassDesc::clearColorValue.

◆ toWGPUCompare()

WGPUCompareFunction esengine::webgpu::toWGPUCompare ( GfxStencilFunc func)
inline

◆ toWGPUCompressedFormat()

◆ toWGPUCullMode()

WGPUCullMode esengine::webgpu::toWGPUCullMode ( bool enabled,
bool front )
inline

Cull state (PipelineDesc.cullEnabled/cullFront). Front face is CCW, matching the GL backend's default winding.

Definition at line 372 of file WebGPUMappings.hpp.

◆ toWGPUDepthStencil()

WGPUDepthStencilState esengine::webgpu::toWGPUDepthStencil ( const PipelineDesc & desc,
WGPUTextureFormat format )
inline

A pipeline's full depth-stencil state against a pass attachment format.

GL semantics carried over exactly: a disabled depth test neither compares NOR writes (glDepthMask only applies while GL_DEPTH_TEST is on); an enabled one compares with GL's default Less func. Stencil faces/masks come from the same tables applyStencilMode uses.

Definition at line 327 of file WebGPUMappings.hpp.

References esengine::PipelineDesc::depthBias, esengine::PipelineDesc::depthEqual, esengine::PipelineDesc::depthTest, esengine::PipelineDesc::depthWrite, esengine::PipelineDesc::stencil, toWGPUStencilFace(), and toWGPUStencilWriteMask().

◆ toWGPUFilter()

WGPUFilterMode esengine::webgpu::toWGPUFilter ( TextureFilter filter)
inline

Definition at line 212 of file WebGPUMappings.hpp.

References esengine::Nearest.

◆ toWGPUIndexFormat()

WGPUIndexFormat esengine::webgpu::toWGPUIndexFormat ( GfxDataType type)
inline

Index type for drawElements' GfxDataType.

Definition at line 147 of file WebGPUMappings.hpp.

References esengine::UnsignedInt, and esengine::UnsignedShort.

◆ toWGPULoadOp()

WGPULoadOp esengine::webgpu::toWGPULoadOp ( bool clearRequested,
bool scoped )
inline

Definition at line 359 of file WebGPUMappings.hpp.

◆ toWGPUStencilFace()

WGPUStencilFaceState esengine::webgpu::toWGPUStencilFace ( GfxStencilMode mode)
inline

The engine's two stencil modes as WebGPU face states (same table as GLDevice::applyPipeline: Write = Always/Replace + no color write, Test = Equal/Keep).

Definition at line 276 of file WebGPUMappings.hpp.

References esengine::Decrement, esengine::Increment, esengine::Off, esengine::Test, esengine::TestOutside, esengine::Write, and esengine::Zero.

Referenced by toWGPUDepthStencil().

◆ toWGPUStencilOp()

WGPUStencilOperation esengine::webgpu::toWGPUStencilOp ( GfxStencilOp op)
inline

◆ toWGPUStencilWriteMask()

u32 esengine::webgpu::toWGPUStencilWriteMask ( GfxStencilMode mode)
inline

Stencil write mask per mode — the applyStencilMode table: Write fills all planes, Test reads without writing, Off never touches stencil.

Definition at line 316 of file WebGPUMappings.hpp.

References esengine::writesStencil().

Referenced by toWGPUDepthStencil().

◆ toWGPUTextureFormat()

WGPUTextureFormat esengine::webgpu::toWGPUTextureFormat ( GfxPixelFormat fmt)
inline

◆ toWGPUVertexFormat()

WGPUVertexFormat esengine::webgpu::toWGPUVertexFormat ( u8 components,
GfxDataType type,
bool normalized )
inline

Maps one RHI attribute (components × type × normalized) to a WGPUVertexFormat, or kInvalidVertexFormat for combinations the engine never produces.

Definition at line 106 of file WebGPUMappings.hpp.

References esengine::Float, esengine::Int, kInvalidVertexFormat, esengine::UnsignedByte, esengine::UnsignedInt, and esengine::UnsignedShort.

Referenced by esengine::WebGPUDevice::backendAcceptsVertexLayout().

◆ wgpuBytesPerPixel()

u32 esengine::webgpu::wgpuBytesPerPixel ( GfxPixelFormat fmt)
inline

Bytes per pixel of an uncompressed upload in fmt (RGB8 expands to RGBA8).

Definition at line 175 of file WebGPUMappings.hpp.

References esengine::RGBA16F, and esengine::RGBA32F.

◆ writeFitsInBuffer()

bool esengine::webgpu::writeFitsInBuffer ( u32 offset,
u32 size,
u32 capacity )
inline

Whether a write lands inside a buffer. Subtraction, not addition: offset + size can wrap past UINT32_MAX and compare as in-range.

Definition at line 450 of file WebGPUMappings.hpp.

Referenced by esengine::WebGPUDevice::backendUpdateBuffer().

Variable Documentation

◆ kGroup1TextureUnits

u32 esengine::webgpu::kGroup1TextureUnits = WGSL_MAX_TEXTURE_UNITS
inlineconstexpr

Texture units the group-1 convention spans — see WGSL_MAX_TEXTURE_UNITS.

Definition at line 382 of file WebGPUMappings.hpp.

◆ kInvalidVertexFormat

WGPUVertexFormat esengine::webgpu::kInvalidVertexFormat = WGPUVertexFormat_Force32
inlineconstexpr

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.

Definition at line 101 of file WebGPUMappings.hpp.

Referenced by esengine::WebGPUDevice::backendAcceptsVertexLayout(), and toWGPUVertexFormat().