Crash when rendering

#1

Error of my part sorry, problem explained on the next post.

#2

Hi! I’m trying to use some mesa extensions to use modern opengl features but I got a crash while rendering : ../src/gallium/drivers/r600/evergreend_state.c:4933: evergreen_atimic_buffer_setup: Assertion 'resource' failed.

Here is the source code I’m trying to make it simple because I’m starting with those new functionnalities, si I simply want to increment the counter each time a fragment is draw and write the value to texture.

So, here is the code

I created the atomic buffers first

            GLuint atomicsBuffer;
            glGenBuffers(1, &atomicsBuffer);
            // bind the buffer and define its initial storage capacity
            glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicsBuffer);
            glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), NULL, GL_DYNAMIC_DRAW);
            // unbind the buffer
            glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0);

Then I clear the buffer at each draw call

                glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, atomicsBuffer);
                GLuint a[1] = {0};
                glBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0 , sizeof(GLuint), a);
                glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, 0);

and finally I draw the scene

                currentStates.shader = &countNbLayers;
                std::map<physic::BoundingBox, std::pair<unsigned int, std::vector<Instance>>>::iterator it;
                for (it = m_newInstances.begin(); it != m_newInstances.end(); it++) {
                    for (unsigned int i = 0; i < it->second.second.size(); i++) {
                        nbLayersCount.draw(it->second.second[i].getAllVertices(),currentStates);
                    }
                }
                nbLayersCount.display();

Why does it crash ?

#3

FYI: If you want to add more to a post, you can just edit the post and add more to it. You shouldn’t make posts in sequence like this just to add more details. The edit button is the pencil icon in the ... menu.

Also, you can use fenced ``` back-ticks to put code inside code-blocks. That would make your code a lot more legible.

All that being said, there’s really not enough of your code to know why it crashes.

#4

I tried the edit button but it didn’t worked.

and how to put code inside blocks ?

I tried to bind the atomic counter buffer location but it didn’t solved the crash, if you want more source code, I can upload it on git because there is a lot of code.

It seems that, when the atomicCounterIncrement function is called in the fragment shader, the uniform variable passed to the function is null, so, the binding is not set in the shader, so, the resource (the buffer) is null.
Even if I bind the buffer here with this function
glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, atomicsBuffer);

PS : I have a question, bindings needs to create a VAO or not ?

#5

Er, actually, when I create the atomic buffer in the constructor, the buffer size is one, but when I want to use it in the render loop its size is 0.
And I use several openGL context. (one by FBO)
Uh, the atomic buffer is not shared between different opengl contexts or what?

#6

It’s good I resolved the crash in fact I initialized the buffer to 0 in the constructor and not in the rendering function, it looks like the counter resets itself and the buffer this empty so …

#7

Edited your code with code tags. Please checkout our Forum Posting Guidelines for more information.

1 Like
#8

Ha but mashed I’m stupid I removed the identifier of the buffer, in the manufacturer and not in the class so necessarily at the end of the constructor it is destroyed.

#9

@laurent7601, to increase the chance of your getting useful feedback, please post your comments in English.

For details, see section 5 in the OpenGL 4.6 Spec (linked to OpenGL Registry). In particular, the mention of atomics and how changes to shared objects are propagated betweeen contexts.

Also, for useful background info, see the ARB_shader_atomic_counters extension and mentions of shared contexts. For example, in the Q&A: