From b5eec85631f420a04daccd650cc21a801279eee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 22 Jan 2019 18:34:56 -0800 Subject: [PATCH] D3D11: Fixed skip mip for 3D textures. --- src/renderer_d3d11.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 04334051a..fdf839485 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -4095,18 +4095,19 @@ namespace bgfx { namespace d3d11 if (bimg::imageParse(imageContainer, _mem->data, _mem->size) ) { uint8_t numMips = imageContainer.m_numMips; - const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) ); + const uint8_t startLod = bx::min(_skip, numMips-1); numMips -= startLod; const bimg::ImageBlockInfo& blockInfo = bimg::getBlockInfo(bimg::TextureFormat::Enum(imageContainer.m_format) ); - const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod); - const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod); + const uint32_t textureWidth = bx::max(blockInfo.blockWidth, imageContainer.m_width >>startLod); + const uint32_t textureHeight = bx::max(blockInfo.blockHeight, imageContainer.m_height>>startLod); + const uint32_t textureDepth = bx::max(1, imageContainer.m_depth >>startLod); const uint16_t numLayers = imageContainer.m_numLayers; m_flags = _flags; m_width = textureWidth; m_height = textureHeight; m_depth = 1 < imageContainer.m_depth - ? imageContainer.m_depth + ? textureDepth : imageContainer.m_numLayers ; m_requestedFormat = uint8_t(imageContainer.m_format); @@ -4345,8 +4346,8 @@ namespace bgfx { namespace d3d11 D3D11_TEXTURE3D_DESC desc = {}; desc.Width = textureWidth; desc.Height = textureHeight; - desc.Depth = imageContainer.m_depth; - desc.MipLevels = imageContainer.m_numMips; + desc.Depth = textureDepth; + desc.MipLevels = numMips; desc.Format = format; desc.Usage = kk == 0 || blit ? D3D11_USAGE_DEFAULT : D3D11_USAGE_IMMUTABLE; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;