diff --git a/Source/Engine/Graphics/RenderBuffers.cpp b/Source/Engine/Graphics/RenderBuffers.cpp index 28b19fd51..b660b5564 100644 --- a/Source/Engine/Graphics/RenderBuffers.cpp +++ b/Source/Engine/Graphics/RenderBuffers.cpp @@ -143,6 +143,10 @@ GPUTexture* RenderBuffers::RequestHiZ(GPUContext* context, bool fullRes, int32 m { HiZ = RenderTargetPool::Get(desc); RENDER_TARGET_POOL_SET_NAME(HiZ, "HiZ"); +#if PLATFORM_WEB + // Hack to fix WebGPU limitation that requires to specify different sampler type manually to load 32-bit float texture + SetWebGPUTextureViewSampler(HiZ->View(), GPU_WEBGPU_SAMPLER_TYPE_UNFILTERABLE_FLOAT); +#endif } // Downscale diff --git a/Source/Engine/Renderer/RendererPass.h b/Source/Engine/Renderer/RendererPass.h index 8475001a2..f337b6b0e 100644 --- a/Source/Engine/Renderer/RendererPass.h +++ b/Source/Engine/Renderer/RendererPass.h @@ -103,3 +103,10 @@ class RendererPass : public Singleton, public RendererPassBase #define REPORT_INVALID_SHADER_PASS_CB_SIZE(shader, index, dataType) LOG(Fatal, "Shader {0} has incorrect constant buffer {1} size: {2} bytes. Expected: {3} bytes", shader->ToString(), index, shader->GetCB(index)->GetSize(), sizeof(dataType)); #define CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, index, dataType) ASSERT(shader && shader->GetCB(index)); if (shader->GetCB(index)->GetSize() != sizeof(dataType) && shader->GetCB(index)->GetSize() != 0) { REPORT_INVALID_SHADER_PASS_CB_SIZE(shader, index, dataType); return true; } + +#if PLATFORM_WEB +// Hack to fix WebGPU limitation that requires to specify different sampler type manually (eg. to sample depth texture without filtering) +void SetWebGPUTextureViewSampler(GPUTextureView* view, uint32 samplerType); +#define GPU_WEBGPU_SAMPLER_TYPE_UNFILTERABLE_FLOAT 0x00000003 // WGPUTextureSampleType_UnfilterableFloat +#define GPU_WEBGPU_SAMPLER_TYPE_DEPTH 0x00000004 // WGPUTextureSampleType_Depth +#endif diff --git a/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp b/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp index be8970e7b..1aa5d7a18 100644 --- a/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp +++ b/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp @@ -275,15 +275,13 @@ GPUTexture* ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPU context->UpdateCB(cb, &data); context->BindCB(0, cb); - // Bind GBuffer inputs - context->BindSR(0, buffers->GBuffer0); - context->BindSR(1, buffers->GBuffer1); - context->BindSR(2, buffers->GBuffer2); - context->BindSR(3, depthBufferTrace); - // Combine pass { PROFILE_GPU("Combine"); + context->BindSR(0, buffers->GBuffer0); + context->BindSR(1, buffers->GBuffer1); + context->BindSR(2, buffers->GBuffer2); + context->BindSR(3, buffers->DepthBuffer); context->BindSR(TEXTURE0, lightBuffer); context->BindSR(TEXTURE1, reflectionsRT); context->BindSR(TEXTURE2, _preIntegratedGF->GetTexture()); @@ -328,6 +326,7 @@ GPUTexture* ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPU PROFILE_GPU("RayTrace"); context->SetViewportAndScissors((float)traceWidth, (float)traceHeight); context->SetRenderTarget(*traceBuffer); + context->BindSR(3, depthBufferTrace); context->BindSR(TEXTURE0, colorBuffer0->View()); if (useGlobalSurfaceAtlas) { diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 18bf57ea8..1404b8525 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -1177,8 +1177,7 @@ void ShadowsPass::SetupShadows(RenderContext& renderContext, RenderContextBatch& } #if PLATFORM_WEB // Hack to fix WebGPU limitation that requires to specify different sampler type manually to sample depth texture - void SetWebGPUTextureViewSampler(GPUTextureView * view, uint32 samplerType); - SetWebGPUTextureViewSampler(shadows.ShadowMapAtlas->View(), 0x00000004); // WGPUTextureSampleType_Depth + SetWebGPUTextureViewSampler(shadows.ShadowMapAtlas->View(), GPU_WEBGPU_SAMPLER_TYPE_DEPTH); #endif shadows.ClearShadowMapAtlas = true; shadows.Resolution = atlasResolution;