From 414c650550654c0fdff8312d2cb79098d1af2ce4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 4 Mar 2026 22:00:50 +0100 Subject: [PATCH] Fixes for WebGPU --- Source/Engine/Graphics/PixelFormatExtensions.h | 2 +- Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp | 6 ++++++ .../Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Graphics/PixelFormatExtensions.h b/Source/Engine/Graphics/PixelFormatExtensions.h index bfe5ff692..27fc812ca 100644 --- a/Source/Engine/Graphics/PixelFormatExtensions.h +++ b/Source/Engine/Graphics/PixelFormatExtensions.h @@ -159,7 +159,7 @@ public: API_FUNCTION() static int32 ComputeComponentsCount(PixelFormat format); /// - /// Computes the amount of pixels per-axis stored in the a single block of the format (eg. 4 for BC-family). Returns 1 for uncompressed formats. + /// Computes the amount of pixels per-axis stored in a single block of the format (eg. 4 for BC-family). Returns 1 for uncompressed formats. /// /// The . /// The block pixels count. diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp index 367b939c8..5207cc772 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp @@ -616,6 +616,12 @@ void GPUContextWebGPU::UpdateTexture(GPUTexture* texture, int32 arrayIndex, int3 int32 mipWidth, mipHeight, mipDepth; texture->GetMipSize(mipIndex, mipWidth, mipHeight, mipDepth); + const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(textureWebGPU->Format()); + mipWidth = Math::Max(mipWidth, blockSize); + mipHeight = Math::Max(mipHeight, blockSize); + if (textureWebGPU->Dimensions() == TextureDimensions::VolumeTexture) + mipDepth = Math::Max(mipDepth, blockSize); + WGPUTexelCopyTextureInfo copyInfo = WGPU_TEXEL_COPY_TEXTURE_INFO_INIT; copyInfo.texture = textureWebGPU->Texture; copyInfo.mipLevel = mipIndex; diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp index 467a76ef3..fcae89cb5 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp @@ -325,6 +325,8 @@ WGPUComputePipeline GPUShaderProgramCSWebGPU::GetPipeline(WGPUDevice device, con #endif if (log) LOG(Info, "[WebGPU] GetPipeline: '{}'", String(_name)); +#else + const bool log = false; #endif // Create layout bind group @@ -635,6 +637,8 @@ void GPUPipelineStateWebGPU::InitLayout(const GPUContextBindingsWebGPU& bindings #else const bool log = true; #endif +#else + const bool log = false; #endif // Count the biggest bind group entries (for all shaders) to allocate reused memory