Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mipgen succeeds but OpenGlDriver::setCompressedTextureData() fails on assert #1966

Closed
roxlu opened this issue Dec 11, 2019 · 12 comments · Fixed by #2943
Closed

mipgen succeeds but OpenGlDriver::setCompressedTextureData() fails on assert #1966

roxlu opened this issue Dec 11, 2019 · 12 comments · Fixed by #2943
Assignees
Labels
bug Something isn't working opengl Issue/request specific to OpenGL

Comments

@roxlu
Copy link
Contributor

roxlu commented Dec 11, 2019

I'm using mipgen to generate .ktx files using --compress=astc_fast_ldr_4x4 and for certain sizes e.g. 446 x 602 the mipgen succeeds but when loading the image data using OpenGDriver::setCompressedTextureData() an assert is triggered: assert(xoffset + width <= t->width >> level);.

This is probably caused because the width and height aren't multiples of 4?

Would it make sense to trigger an error in mipgen when this occurs?

And what would be an approriate way to deal with this?

Output of mipgen:

Reading image...
Generating miplevels...
Writing KTX file to disk...
Starting compression for stained oak hay1.png (446x602)
16912
Starting compression for stained oak hay1.png (223x301)
4256
Starting compression for stained oak hay1.png (111x150)
1064
Starting compression for stained oak hay1.png (55x75)
266
Starting compression for stained oak hay1.png (27x37)
70
Starting compression for stained oak hay1.png (13x18)
20
Starting compression for stained oak hay1.png (6x9)
6
Starting compression for stained oak hay1.png (3x4)
1
Starting compression for stained oak hay1.png (1x2)
1
Starting compression for stained oak hay1.png (1x1)
1
Done.

Values in OpenGLDriver::setCompressedTextureData()

Texture width: 446, width: 446, offset: 0, level: 0, assert: y, (446 < 446)
Texture width: 446, width: 223, offset: 0, level: 1, assert: y, (223 < 223)
Texture width: 446, width: 111, offset: 0, level: 2, assert: y, (111 < 111)
Texture width: 446, width: 55, offset: 0, level: 3, assert: y, (55 < 55)
Texture width: 446, width: 27, offset: 0, level: 4, assert: y, (27 < 27)
Texture width: 446, width: 13, offset: 0, level: 5, assert: y, (13 < 13)
Texture width: 446, width: 6, offset: 0, level: 6, assert: y, (6 < 6)
Texture width: 446, width: 3, offset: 0, level: 7, assert: y, (3 < 3)
Texture width: 446, width: 1, offset: 0, level: 8, assert: y, (1 < 1)
Texture width: 446, width: 1, offset: 0, level: 9, assert: n, (1 < 0)
@romainguy
Copy link
Collaborator

The assert might have been only for ETC textures, I don't remember if ASTC has the same size constraints.

@roxlu
Copy link
Contributor Author

roxlu commented Dec 12, 2019

Hmm even when the resolution is a multiple of 4 I'm running into this same issue:

Texture width: 508, width: 508, offset: 0, level: 0, assert: y, (508 < 508)
Texture width: 508, width: 254, offset: 0, level: 1, assert: y, (254 < 254)
Texture width: 508, width: 127, offset: 0, level: 2, assert: y, (127 < 127)
Texture width: 508, width: 63, offset: 0, level: 3, assert: y, (63 < 63)
Texture width: 508, width: 31, offset: 0, level: 4, assert: y, (31 < 31)
Texture width: 508, width: 15, offset: 0, level: 5, assert: y, (15 < 15)
Texture width: 508, width: 7, offset: 0, level: 6, assert: y, (7 < 7)
Texture width: 508, width: 3, offset: 0, level: 7, assert: y, (3 < 3)
Texture width: 508, width: 1, offset: 0, level: 8, assert: y, (1 < 1)
Texture width: 508, width: 1, offset: 0, level: 9, assert: n, (1 < 0)

I had a quick look at mipgen, and this might be related:

width = std::max(width >> 1u, 1u);
height = std::max(height >> 1u, 1u);

As quick test, I resized all my images to a multiple of 4 and made sure that the width and height were the same to make sure that it's not related to the resolution and/or alignment. After resizing it passes asserts in OpenGlDriver::setCompressedTextureData(), but then I ran into something more serious:

test-filarsf-debug: /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/libs/utils/include/utils/Slice.h:207: T *utils::GrowingSlice<filament::details::RenderPass::Command, unsigned int>::grow(utils::GrowingSlice::size_type) [T = filament::details::RenderPass::Command, SIZE_TYPE = unsigned int]: Assertion `this->size() + count <= mCapOffset' failed.

Thread 1 "test-filarsf-de" received signal SIGABRT, Aborted.
0x00007ffff5d85f25 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff5d85f25 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff5d6f897 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff5d6f767 in __assert_fail_base.cold () from /usr/lib/libc.so.6
#3  0x00007ffff5d7e526 in __assert_fail () from /usr/lib/libc.so.6
#4  0x000055555614c2c0 in utils::GrowingSlice<filament::details::RenderPass::Command, unsigned int>::grow (this=0x7fffffffcd90, count=28446)
    at /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/libs/utils/include/utils/Slice.h:207
#5  0x000055555614a6be in filament::details::RenderPass::appendCommands (this=0x7fffffffcf20, commandTypeFlags=filament::details::RenderPass::COLOR_WITH_DEPTH_PREPASS)
    at /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/filament/src/RenderPass.cpp:104
#6  0x0000555556142663 in filament::details::FRenderer::renderJob (this=0x555557531bb0, arena=..., view=...)
    at /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/filament/src/Renderer.cpp:311
#7  0x0000555556141c76 in filament::details::FRenderer::render (this=0x555557531bb0, view=0x555557731db0)
    at /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/filament/src/Renderer.cpp:174
#8  0x0000555556143c32 in filament::Renderer::render (this=0x555557531bb0, view=0x555557731db0)
    at /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/filament/src/Renderer.cpp:681

Any ideas what might cause this?

Update
I'm trying to figure out when this happens and I notice that it seems to be related to the number of objects that I try to render. Maybe there is a limit? or growing a buffer fails? Maybe related to #1895. When toggling the objects that I export I sometimes run into:

CommandBufferQueue.cpp:75: void filament::backend::CommandBufferQueue::flush(): Assertion `used <= mFreeSpace' failed.

#4  0x0000555556250bea in filament::backend::CommandBufferQueue::flush (this=0x7fffee0fa830)
    at /home/app-main/build/build_unix.Debug/fila-prefix/src/fila/filament/backend/src/CommandBufferQueue.cpp:75

75	   assert(used <= mFreeSpace);

(gdb) print used
$1 = 1672336

(gdb) print mFreeSpace
$2 = 1617040

@prideout
Copy link
Contributor

Thanks for these bug reports, we like them, believe it or not. :)

I think the Command-related SIGABRT is quite distinct from the texture compression problem, do you mind filing a separate bug for that? Might be useful to let us know how many objects you're drawing too.

@romainguy romainguy added bug Something isn't working opengl Issue/request specific to OpenGL labels Dec 15, 2019
@roxlu
Copy link
Contributor Author

roxlu commented Feb 7, 2020

Just ran into a similar issue. Tested with both dxt5 and astc compression. How can I figure out what image is causing this issue, then I can share it.

#0  0x00007ffff6163f25 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff614d897 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff614d767 in __assert_fail_base.cold () from /usr/lib/libc.so.6
#3  0x00007ffff615c526 in __assert_fail () from /usr/lib/libc.so.6
#4  0x0000555555a20c77 in filament::OpenGLDriver::setCompressedTextureData (this=0x7fffe021efb0, t=0x7fffec203800, level=6, xoffset=0, yoffset=0, zoffset=0, width=1, height=7, depth=1, p=..., faceOffsets=0x0)
    at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/src/opengl/OpenGLDriver.cpp:1652
#5  0x0000555555a2c664 in filament::OpenGLDriver::update2DImage (this=0x7fffe021efb0, th=..., level=6, xoffset=0, yoffset=0, width=1, height=7, data=...) at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/src/opengl/OpenGLDriver.cpp:1514
#6  0x0000555555a44c2e in filament::backend::invoke<filament::OpenGLDriver, void (filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&), filament::OpenGLDriver&, filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor>(void (filament::OpenGLDriver::*)(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&), filament::OpenGLDriver&, filament::backend::Handle<filament::backend::HwTexture>&&, unsigned int&&, unsigned int&&, unsigned int&&, unsigned int&&, unsigned int&&, filament::backend::PixelBufferDescriptor&&) (m=
    (void (filament::OpenGLDriver::*)(filament::OpenGLDriver * const, filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor &&)) 0x555555a2c590 <filament::OpenGLDriver::update2DImage(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&)>, d=..., args=..., args=..., args=..., args=..., args=..., args=..., args=...)
    at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/include/private/backend/CommandStream.h:118
#7  0x0000555555a44a77 in filament::backend::trampoline<void (filament::OpenGLDriver::*)(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&), filament::OpenGLDriver&, std::__1::tuple<filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor>, 0ul, 1ul, 2ul, 3ul, 4ul, 5ul, 6ul> (m=
    @0x7fffe5ffaa58: (void (filament::OpenGLDriver::*)(filament::OpenGLDriver * const, filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor &&)) 0x555555a2c590 <filament::OpenGLDriver::update2DImage(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&)>, d=..., t=...)
    at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/include/private/backend/CommandStream.h:123
#8  0x0000555555a44907 in filament::backend::apply<void (filament::OpenGLDriver::*)(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&), filament::OpenGLDriver&, std::__1::tuple<filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor> > (m=
    @0x7fffe5ffaa58: (void (filament::OpenGLDriver::*)(filament::OpenGLDriver * const, filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor &&)) 0x555555a2c590 <filament::OpenGLDriver::update2DImage(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&)>, d=..., t=...)
    at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/include/private/backend/CommandStream.h:128
#9  0x0000555555a2c568 in filament::backend::CommandType<void (filament::backend::Driver::*)(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&)>::Command<&filament::backend::Driver::update2DImage>::execute<void (filament::OpenGLDriver::*)(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&), filament::OpenGLDriver&> (method=
    @0x7fffe5ffaa58: (void (filament::OpenGLDriver::*)(filament::OpenGLDriver * const, filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor &&)) 0x555555a2c590 <filament::OpenGLDriver::update2DImage(filament::backend::Handle<filament::backend::HwTexture>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, filament::backend::PixelBufferDescriptor&&)>, driver=..., base=0x7fffee0ee820, next=0x7fffe5ffaaa0)
    at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/include/private/backend/CommandStream.h:168
#10 0x0000555555a286a1 in filament::backend::ConcreteDispatcher<filament::OpenGLDriver>::update2DImage (driver=..., base=0x7fffee0ee820, next=0x7fffe5ffaaa0)
    at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/include/private/backend/DriverAPI.inc:258
#11 0x0000555555a149d5 in filament::backend::CommandBase::execute (this=0x7fffee0ee820, driver=...) at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/include/private/backend/CommandStream.h:102
#12 0x0000555555a14879 in filament::backend::CommandStream::execute(void*)::$_0::operator()() const (this=0x7fffe5ffacc8) at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/src/CommandStream.cpp:80
#13 0x0000555555a1480d in std::__1::__invoke<filament::backend::CommandStream::execute(void*)::$_0&> (__f=...) at /usr/bin/../include/c++/v1/type_traits:3530
#14 0x0000555555a147bd in std::__1::__invoke_void_return_wrapper<void>::__call<filament::backend::CommandStream::execute(void*)::$_0&>(filament::backend::CommandStream::execute(void*)::$_0&) (__args=...) at /usr/bin/../include/c++/v1/__functional_base:348
#15 0x0000555555a1478d in std::__1::__function::__alloc_func<filament::backend::CommandStream::execute(void*)::$_0, std::__1::allocator<filament::backend::CommandStream::execute(void*)::$_0>, void ()>::operator()() (this=0x7fffe5ffacc8) at /usr/bin/../include/c++/v1/functional:1533
#16 0x0000555555a136ee in std::__1::__function::__func<filament::backend::CommandStream::execute(void*)::$_0, std::__1::allocator<filament::backend::CommandStream::execute(void*)::$_0>, void ()>::operator()() (this=0x7fffe5ffacc0) at /usr/bin/../include/c++/v1/functional:1707
#17 0x0000555555769cf5 in std::__1::__function::__value_func<void ()>::operator()() const (this=0x7fffe5ffacc0) at /usr/bin/../include/c++/v1/functional:1860
#18 0x0000555555769cb5 in std::__1::function<void ()>::operator()() const (this=0x7fffe5ffacc0) at /usr/bin/../include/c++/v1/functional:2419
#19 0x0000555555a14e54 in filament::backend::Driver::execute(std::__1::function<void ()>) (this=0x7fffe021efb0, fn=...) at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/src/Driver.cpp:74
#20 0x0000555555a12f05 in filament::backend::CommandStream::execute (this=0x7fffee6ed898, buffer=0x7fffee0ee570) at build/build_unix.Debug/fila-prefix/src/fila/filament/backend/src/CommandStream.cpp:76
#21 0x0000555555748be5 in filament::details::FEngine::execute (this=0x7fffee6ed010) at build/build_unix.Debug/fila-prefix/src/fila/filament/src/Engine.cpp:792
#22 0x0000555555746e13 in filament::details::FEngine::loop (this=0x7fffee6ed010) at build/build_unix.Debug/fila-prefix/src/fila/filament/src/Engine.cpp:480
#23 0x000055555575a167 in std::__1::__invoke<int (filament::details::FEngine::*)(), filament::details::FEngine*, , void> (__f=@0x555556235fc8: (int (filament::details::FEngine::*)(filament::details::FEngine * const)) 0x555555746b30 <filament::details::FEngine::loop()>, __a0=@0x555556235fd8: 0x7fffee6ed010)
    at /usr/bin/../include/c++/v1/type_traits:3471
#24 0x000055555575a0ae in std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, int (filament::details::FEngine::*)(), filament::details::FEngine*, 2ul> (__t=...) at /usr/bin/../include/c++/v1/thread:277
#25 0x0000555555759dc3 in std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, int (filament::details::FEngine::*)(), filament::details::FEngine*> > (__vp=0x555556235fc0) at /usr/bin/../include/c++/v1/thread:287
#26 0x00007ffff7f7d4cf in start_thread () from /usr/lib/libpthread.so.0


# f 4

# info args
this = 0x7fffe021efb0
t = 0x7fffec203800
level = 6
xoffset = 0
yoffset = 0
zoffset = 0
width = 1
height = 7
depth = 1
p = @0x7fffee0ee840: {<filament::backend::BufferDescriptor> = {buffer = 0x5555563b54f0, size = 32, callback = 0x555555643250 <image::ktx::createTexture(filament::Engine*, image::KtxBundle const&, bool, void (*)(void*), void*)::{lambda(void*, unsigned long, void*)#1}::__invoke(void*, unsigned long, void*)>, 
    user = 0x5555567f8a40}, left = 0, top = 0, {{stride = 32, format = 18}, {imageSize = 32, compressedFormat = filament::backend::CompressedPixelDataType::RGBA_ASTC_4x4}}, type = -8, alignment = 1 '\001'}
faceOffsets = 0x0

@roxlu
Copy link
Contributor Author

roxlu commented Feb 7, 2020

Thanks for these bug reports, we like them, believe it or not. :)

I think the Command-related SIGABRT is quite distinct from the texture compression problem, do you mind filing a separate bug for that? Might be useful to let us know how many objects you're drawing too.

See #2057

@romainguy
Copy link
Collaborator

You're triggering an assert so it could be you're asking to use an unsupported compression format (astc on desktop?).

@roxlu
Copy link
Contributor Author

roxlu commented Feb 7, 2020

You're triggering an assert so it could be you're asking to use an unsupported compression format (astc on desktop?).

I tested both astc and dxt5 and both triggered the same assert.

@romainguy
Copy link
Collaborator

Here are the assertions in that code path:

    assert(xoffset + width <= t->width >> level);
    assert(yoffset + height <= t->height >> level);
    assert(zoffset + depth <= t->depth);
    assert(t->samples <= 1);

Could be an issue with the dimensions or offsets or mip levels you pass?

@roxlu
Copy link
Contributor Author

roxlu commented Feb 8, 2020

I looked into this a bit more closely and I found two things that are maybe related to this issue.

1. Multiples of 4

When using DXT5 we are limited to image resolutions that are multiples of 4 or at least some compressors seem to be limited to this. The image that I was testing with has a resolution of 160x90. I used mipgen to compress with DXT5 and didn't see any error messages which might tell us that it's OK to use image resolutions which are not a multipe of 4. Maybe the image is resized internally.

The output I got when using mipgen:

    Writing KTX file to disk...
    Starting compression for darkgrey.png (160x90)
    Starting compression for darkgrey.png (80x45)
    Starting compression for darkgrey.png (40x22)
    Starting compression for darkgrey.png (20x11)
    Starting compression for darkgrey.png (10x5)
    Starting compression for darkgrey.png (5x2)
    Starting compression for darkgrey.png (2x1)
    Starting compression for darkgrey.png (1x1)

2. Mipmap Count

The other thing that might cause this is because the getMipmapCount() will return the maximum mipmap that would be possible for either the width OR the height. In my case the maximum mipmap for the width is 7 and the height is 6 until we reach an image of 1x1 pix. I created this test case to log some info, see below.

Output of the test:

getMipmapCount, shifted height: 45, width: 80, count: 1.
getMipmapCount, shifted height: 22, width: 40, count: 2.
getMipmapCount, shifted height: 11, width: 20, count: 3.
getMipmapCount, shifted height: 5, width: 10, count: 4.
getMipmapCount, shifted height: 2, width: 5, count: 5.
getMipmapCount, shifted height: 1, width: 2, count: 6.
getMipmapCount, shifted height: 0, width: 1, count: 7.
texture_width: 160
texture_height: 90
height_shifted_level: 0
width_shifted_level: 1.
mipmap count: 7

Code used to produce the above output:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <algorithm>

/* -------------------------------------------------------------------------------------- */

/*
  Copied `getMipmapCount()` and changed it a bit that allows us
  to pass a width and height instead of a `LinearImage` so that
  we can create this standalone test case.

  Original version:

    https://github.com/google/filament/blob/master/libs/image/src/ImageSampler.cpp#L351
 */
static uint32_t getMipmapCount(uint32_t width, uint32_t height);

/* -------------------------------------------------------------------------------------- */

int main(int argc, char* argv[]) {

  printf("\nmipgen crash test\n");

  /* 
     The asserts in OpenGLDriver.cpp, setCompressedTextureData() are:

       assert(xoffset + width <= t->width >> level);
       assert(yoffset + height <= t->height >> level);
       assert(zoffset + depth <= t->depth);
       assert(t->samples <= 1);

     The one that fails is: 

        assert(yoffset + height <= t->height >> level);

     When the values are:

       yoffset = 0
       height = 1
       t->height = 90
       level = 7
  */
  
  uint32_t texture_width = 160;
  uint32_t texture_height = 90;
  uint32_t level = 7;
  uint32_t height = 1;
  uint32_t height_shifted_level = (texture_height >> level);
  uint32_t width_shifted_level = (texture_width >> level);
  uint32_t mipmap_count = getMipmapCount(texture_width, texture_height);

  printf("texture_width: %u\n", texture_width);
  printf("texture_height: %u\n", texture_height);
  printf("height_shifted_level: %u\n", height_shifted_level);
  printf("width_shifted_level: %u.\n", width_shifted_level);
  printf("mipmap count: %u\n", mipmap_count);
  printf("\n");
  
  return 0;
}

/* -------------------------------------------------------------------------------------- */

static uint32_t getMipmapCount(uint32_t width, uint32_t height){
  
  uint32_t count = 0;
  
  while (width > 1 || height > 1) {
    
    ++count;

    printf("getMipmapCount, shifted height: %u, width: %u, count: %u.\n", (height >> 1), (width >> 1), count);
      
    width = std::max(width >> 1u, 1u);
    height = std::max(height >> 1u, 1u);
  }
  
  return count;
}

/* -------------------------------------------------------------------------------------- */

@roxlu
Copy link
Contributor Author

roxlu commented Feb 8, 2020

I just resized all my assets so that both width and height fit into the same mipmap level. When I debug my app I'm not running into that assert anymore.

@roxlu
Copy link
Contributor Author

roxlu commented Jul 13, 2020

@pixelflinger, @romainguy running into this issue again; can we remove the assert in question? See my comment above where I created a test app which shows that the check is wrong.

I just ran into this when using an 512 x 2048 image.

mipgen:

$ mipgen --compress=s3tc_rgba_dxt5 img/trees-bark-diffuse.png

Generating miplevels...
Writing KTX file to disk...
Starting compression for trees-bark-diffuse.png (512x2048)
Starting compression for trees-bark-diffuse.png (256x1024)
Starting compression for trees-bark-diffuse.png (128x512)
Starting compression for trees-bark-diffuse.png (64x256)
Starting compression for trees-bark-diffuse.png (32x128)
Starting compression for trees-bark-diffuse.png (16x64)
Starting compression for trees-bark-diffuse.png (8x32)
Starting compression for trees-bark-diffuse.png (4x16)
Starting compression for trees-bark-diffuse.png (2x8)
Starting compression for trees-bark-diffuse.png (1x4)
Starting compression for trees-bark-diffuse.png (1x2)
Starting compression for trees-bark-diffuse.png (1x1)

This fails:

assert(xoffset + width <= t->width >> level);
// checks: assert(0 + 1 <= 512 >> 10)

GDB values:

   this = 0x7fffe4395870
   t = 0x7fffe8af9800
   t->width = 512
   level = 10
   xoffset = 0
   yoffset = 0
   zoffset = 0
   width = 1
   height = 2
   depth = 1

@pixelflinger
Copy link
Collaborator

I think the assert() is wrong. Will get to it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working opengl Issue/request specific to OpenGL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants