-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Bind empty VAO to bufferless quad rendering #1734
Conversation
Hey thanks a lot! I read through this while on the train today, so I have not tried the code out yet. But here are my thoughts on the approach: Defining Making the VAO
This ensures that a VAO is always bound during rendering and should also be much more storage/runtime efficient. |
This is normal btw ;) OpenGL does not raise errors because they happen on the GPU. Hence, we only learn about them during validity checks when we explicitly request the error state. You can also see the error in "real time" in the logs if you enable OpenGL debug output (by starting with the |
Got it, thanks! Working on the updates now. |
@@ -67,6 +68,8 @@ class GlRenderer final : public Renderer { | |||
|
|||
/// The main screen surface as a render target. | |||
std::shared_ptr<GlRenderTarget> display; | |||
|
|||
std::shared_ptr<GlVertexArray> shared_quad_vao; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make this member a unique_ptr
I think, since it's only used by the GlRenderer class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to use unique_ptr
, but encountered an issue since it requires the complete type definition. When I moved the include to the header file to replace forward declaration, it led to circular include dependencies. Did I do something wrong, or should I dive into the dependency cycle to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you are right. I think you can change it back to shared_ptr
.
I think the problem here is that unique_ptr
only allows incomplete types under specific circumstances. I also didn't know the specifics for that :'D
std::unique_ptr may be constructed for an incomplete type T, such as to facilitate the use as a handle in the pImpl idiom. If the default deleter is used, T must be complete at the point in code where the deleter is invoked, which happens in the destructor, move assignment operator, and reset member function of std::unique_ptr. (In contrast, std::shared_ptr can't be constructed from a raw pointer to incomplete type, but can be destroyed where T is incomplete). Note that if T is a class template specialization, use of unique_ptr as an operand, e.g. !p requires T's parameters to be complete due to ADL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will change it back
a8ac514
to
1bd9f28
Compare
1bd9f28
to
21fbaa9
Compare
Very good! |
Bind empty VAO for bufferless quad rendering
Hey! 👋 resolve #1659
I've made some initial fixes for the bufferless quad VAO issue, but wanted to get some advice before finalizing:
I tested my current code and noticed the VAO error was still there but occurred during shader validation in
GlShaderProgram::use()
.This happens during
program->update_uniforms(in);
beforegeom->draw()
; inGlRenderer::render()
.My current fix is binding the empty VAO in
geometry.cpp
, but I'm wondering:GlShaderProgram::use()
?appreciate your thoughts on the best approach!