mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-09-14 06:28:17 +00:00
WebGPU: Fixed texture conversion pitch, and mip-gen array views. (#3776)
This commit is contained in:
committed by
GitHub
parent
ffcbac4ac0
commit
1e8e82b42e
@@ -4127,7 +4127,7 @@ WGPU_IMPORT
|
||||
rectPitch = (_rect.m_width / blockInfo.blockWidth) * blockInfo.blockSize;
|
||||
}
|
||||
|
||||
const uint32_t bytesPerRow = UINT16_MAX == _pitch ? rectPitch : _pitch;
|
||||
uint32_t bytesPerRow = UINT16_MAX == _pitch ? rectPitch : _pitch;
|
||||
const uint32_t slicePitch = rectPitch*_rect.m_height;
|
||||
|
||||
const bool convert = m_textureFormat != m_requestedFormat;
|
||||
@@ -4137,10 +4137,10 @@ WGPU_IMPORT
|
||||
|
||||
if (convert)
|
||||
{
|
||||
bytesPerRow = rectPitch;
|
||||
temp = (uint8_t*)bx::alloc(g_allocator, slicePitch);
|
||||
bimg::imageDecodeToBgra8(g_allocator, temp, srcData, _rect.m_width, _rect.m_height, bytesPerRow, bimg::TextureFormat::Enum(m_requestedFormat) );
|
||||
bimg::imageDecodeToBgra8(g_allocator, temp, srcData, _rect.m_width, _rect.m_height, rectPitch, bimg::TextureFormat::Enum(m_requestedFormat) );
|
||||
srcData = temp;
|
||||
|
||||
}
|
||||
|
||||
const uint32_t width = bx::min(bx::max(1u, bx::alignUp(m_width >> _mip, blockInfo.blockWidth ) ), _rect.m_width);
|
||||
@@ -4226,7 +4226,7 @@ WGPU_IMPORT
|
||||
return sampler;
|
||||
}
|
||||
|
||||
WGPUTextureView TextureWGPU::getTextureView(uint8_t _baseMipLevel, uint8_t _mipLevelCount, bool _storage, uint16_t _baseArrayLayer, uint16_t _arrayLayerCount) const
|
||||
WGPUTextureView TextureWGPU::getTextureView(uint8_t _baseMipLevel, uint8_t _mipLevelCount, bool _storage, uint16_t _baseArrayLayer, uint16_t _arrayLayerCount, bool _force2DArray) const
|
||||
{
|
||||
bx::HashMurmur3 murmur;
|
||||
murmur.begin();
|
||||
@@ -4236,6 +4236,7 @@ WGPU_IMPORT
|
||||
murmur.add(_storage);
|
||||
murmur.add(_baseArrayLayer);
|
||||
murmur.add(_arrayLayerCount);
|
||||
murmur.add(_force2DArray);
|
||||
const uint32_t hash = murmur.end();
|
||||
|
||||
WGPUTextureView textureView = s_renderWGPU->m_textureViewStateCache.find(hash);
|
||||
@@ -4256,6 +4257,11 @@ WGPU_IMPORT
|
||||
}
|
||||
}
|
||||
|
||||
if (_force2DArray)
|
||||
{
|
||||
tvd = WGPUTextureViewDimension_2DArray;
|
||||
}
|
||||
|
||||
WGPUTextureViewDescriptor textureViewDesc =
|
||||
{
|
||||
.nextInChain = NULL,
|
||||
@@ -5397,7 +5403,7 @@ m_resolution.formatColor = TextureFormat::BGRA8;
|
||||
WGPUTextureView view;
|
||||
if (ii < numMips)
|
||||
{
|
||||
view = _texture.getTextureView(uint8_t(topMip + 1 + ii), 1, true, true);
|
||||
view = _texture.getTextureView(uint8_t(topMip + 1 + ii), 1, true, 0, UINT16_MAX, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5429,7 +5435,7 @@ m_resolution.formatColor = TextureFormat::BGRA8;
|
||||
.offset = 0,
|
||||
.size = 0,
|
||||
.sampler = NULL,
|
||||
.textureView = _texture.getTextureView(uint8_t(topMip), 1, false, true),
|
||||
.textureView = _texture.getTextureView(uint8_t(topMip), 1, false, 0, UINT16_MAX, true),
|
||||
};
|
||||
|
||||
const uint32_t samplerFlags = 0
|
||||
|
||||
@@ -638,7 +638,7 @@ namespace wgpu {
|
||||
void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
|
||||
|
||||
WGPUSampler getSamplerState(uint32_t _samplerFlags) const;
|
||||
WGPUTextureView getTextureView(uint8_t _baseMipLevel, uint8_t _mipLevelCount, bool _storage, uint16_t _baseArrayLayer = 0, uint16_t _arrayLayerCount = UINT16_MAX) const;
|
||||
WGPUTextureView getTextureView(uint8_t _baseMipLevel, uint8_t _mipLevelCount, bool _storage, uint16_t _baseArrayLayer = 0, uint16_t _arrayLayerCount = UINT16_MAX, bool _force2DArray = false) const;
|
||||
|
||||
WGPUTexture m_texture;
|
||||
WGPUTexture m_textureResolve;
|
||||
|
||||
Reference in New Issue
Block a user