bkaradzic/bgfx

Vulkan Backend - incorrect mipmap generation for cubemap frame buffers.

volcoma opened this issue · 4 comments

Hi, i've found a bug with the implementation of the mipmap generation in

void TextureVK::resolve function.

Currently it only generates mipmap for one of the faces of the cubemap as seen here. This works fine for dx11 and opengl backends
I have a frame buffer which is filled properly

for(int i = 0; i < 6; ++i)
{
gfx::frame_buffer::ptr output ...  per face

gfx::blit(pass.id,
             cubemap_fbo->get_texture()->native_handle(),
             0,
             0,
             0,
             uint16_t(face),
             output->get_texture()->native_handle());
} 

after that i use a pass to resolve the texture so it can force generate the mipmaps

            gfx::render_pass pass("cubemap_generate_mips");
            pass.bind(cubemap_fbo.get());
            pass.touch();

Screenshot 2024-01-01 154044

if i change the function a bit

            auto numLayers = _numLayers;
            if(m_type == VK_IMAGE_VIEW_TYPE_CUBE || VK_IMAGE_VIEW_TYPE_CUBE_ARRAY)
            {
                numLayers = 6;
            }

and use numLayers instead of _numLayers it fixes it.

Screenshot 2024-01-01 154001

I am not sure if it is the same for both VK_IMAGE_VIEW_TYPE_CUBE and VK_IMAGE_VIEW_TYPE_CUBE_ARRAY but i think it is.
Could not find much info about it.

The easiest fix would be to use the existing m_numSides, that would also work for layered cube maps, i.e. 6*N

Hi. Any idea when this fix would hit master? Seemed like a trivial fix, but like 5 months passed.

@volcoma You can test fix, and send PR.