diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index e0af1e45d..a50a52986 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -5555,7 +5555,12 @@ namespace bgfx { namespace d3d11 { ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx; - const bool needResolve = NULL != m_rt; + const bx::EncodingType::Enum encoding = bx::EncodingType::Enum(bimg::getBlockInfo(bimg::TextureFormat::Enum(m_textureFormat) ).encoding); + const bool resolvable = bx::EncodingType::Int != encoding + && bx::EncodingType::Uint != encoding + ; + + const bool needResolve = NULL != m_rt && resolvable; if (needResolve) { const DXGI_FORMAT resolveFormat = bimg::isDepth(bimg::TextureFormat::Enum(m_textureFormat) ) diff --git a/src/renderer_webgpu.cpp b/src/renderer_webgpu.cpp index 29dcb308e..fbb111a98 100644 --- a/src/renderer_webgpu.cpp +++ b/src/renderer_webgpu.cpp @@ -3454,7 +3454,7 @@ WGPU_IMPORT if (NULL != depthStencilTextureView) { - setDepthStencilState(depthStencilState, formatDepthStencil, _state, _stencil, _depthBias, _slopeScale, _biasClamp); + setDepthStencilState(depthStencilState, formatDepthStencil, _state, _stencil, fb.m_readOnlyDepth, fb.m_readOnlyStencil, _depthBias, _slopeScale, _biasClamp); } else { @@ -3840,9 +3840,11 @@ WGPU_IMPORT _murmur.add(NULL != _fb.m_depthStencilView); _murmur.add(_fb.m_formatDepthStencil); + _murmur.add(_fb.m_readOnlyDepth); + _murmur.add(_fb.m_readOnlyStencil); } - void setDepthStencilState(WGPUDepthStencilState& _outDepthStencilState, TextureFormat::Enum _format, uint64_t _state, uint64_t _stencil, int32_t _depthBias = 0, float _slopeScale = 0.0f, float _biasClamp = 0.0f) + void setDepthStencilState(WGPUDepthStencilState& _outDepthStencilState, TextureFormat::Enum _format, uint64_t _state, uint64_t _stencil, bool _readOnlyDepth, bool _readOnlyStencil, int32_t _depthBias = 0, float _slopeScale = 0.0f, float _biasClamp = 0.0f) { if (!hasStencil(_format) ) { @@ -3851,7 +3853,7 @@ WGPU_IMPORT _stencil = !stencilEnabled(_stencil) ? kStencilDisabled : _stencil; - const uint8_t writeMask = unpackStencilWriteMask(_stencil); + const uint8_t writeMask = _readOnlyStencil ? 0 : unpackStencilWriteMask(_stencil); const uint32_t fstencil = unpackStencil(0, _stencil); const uint32_t frontAndBack = stencilFrontAndBack(_stencil); uint32_t bstencil = frontAndBack ? unpackStencil(1, _stencil) : fstencil; @@ -3864,7 +3866,7 @@ WGPU_IMPORT { .nextInChain = NULL, .format = s_textureFormat[_format].m_fmt, - .depthWriteEnabled = WGPUOptionalBool(depthRw && !!(BGFX_STATE_WRITE_Z & _state) ), + .depthWriteEnabled = WGPUOptionalBool(depthRw && !_readOnlyDepth && !!(BGFX_STATE_WRITE_Z & _state) ), .depthCompare = depthRw ? s_cmpFunc[func] : WGPUCompareFunction_Always, .stencilFront = { diff --git a/src/renderer_webgpu.h b/src/renderer_webgpu.h index feb8d83a1..edb688de1 100644 --- a/src/renderer_webgpu.h +++ b/src/renderer_webgpu.h @@ -724,8 +724,11 @@ namespace wgpu { , m_denseIdx(kInvalidHandle) , m_numColorAttachments(0) , m_numAttachments(0) + , m_width(0) + , m_height(0) , m_msaaCount(1) , m_needPresent(false) + , m_needResolve(false) { }