floooh / oryol

A small, portable and extensible C++ 3D coding framework
MIT License
2k stars 200 forks source link

Dequeue error when adding lots of DrawStates #329

Closed danhambleton closed 5 years ago

danhambleton commented 5 years ago

I'm writing an app the has to render a lot of meshes. In the default Gfx config I can create up to 128 objects in the scene like this:

        DrawState ds;
        ds.Mesh[0] = Oryol::Gfx::CreateResource(*meshDisplayData.meshSetup.get());
        ds.Pipeline = sceneTransient->phongPipeline;

This creates a new DrawState for each object. However, after 128 of these I get an error in Queue.h:

template<class TYPE> TYPE
Queue<TYPE>::Dequeue() {
    o_assert_dbg(this->buffer.size() > 0);
    return std::move(this->buffer.popFront());
}

I can fix this by adjusting the DefaultResourcePoolSize in GfxConfig.h. Is there another way?

floooh commented 5 years ago

You can pass pool sizes for all resource types in the Gfx::Setup() call, for instance see the BlendTest sample, which increases the pool size for Pipeline objects to 512:

https://github.com/floooh/oryol/blob/255de118fc4744b937b40306fd771a33f49ffc62/code/Samples/BlendTest/BlendTest.cc#L29-L31