-
-
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
Update syntax of GlUniformBuffer to match that of GlUniformInput #1683 #1690
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c6db4fb
renderer: Update syntax of GlUniformBuffer to match that of GlUniform…
6256c66
renderer: Update syntax of GlUniformBuffer to match that of GlUniform…
EdvinLndh 623554e
Added syntax changes to GlUniformBufferInput class.
EdvinLndh 0c1a368
Merge branch 'uniform_syntax_change' of github.com:EdvinLndh/openage …
EdvinLndh de212cb
Changed uniforms attribute from unordered_map to vector
EdvinLndh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should not iterate through
this->uniforms_by_name
here and instead useglunif_in->used_uniforms
. Reasons for this are:UniformBufferInput
can be partial updates where only a few uniforms in the buffer are updated and not all. If you iterate onthis->uniforms_by_name
, this could then read some uninitialized data into the buffer.std::unordered_map
likethis->uniforms_by_name
will be very slow compared to iterating on astd::vector
(because of their memory layout). This is part of the reason why we want to "vectorize" these parameters: The vectors are much faster in our renderer.You can check out the update for the regular
UniformInput
in this code sample for inspiration:openage/libopenage/renderer/opengl/shader_program.cpp
Lines 352 to 365 in 380d2e9
The syntax of your code can be roughly the same I think :)
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 see, I think one of the reasons I went with that approach was in order to be able to lookup the
GlBlockInUniform
in the uniforms map. When iterating over the id's I'm not really sure how I should retrieve the correct value from the uniforms map. Do you think the uniforms attribute should be kept as astd::unordered_map
?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.
Yeah I think this might be a good opportunity to change the type of
GlUniformBuffer::uniforms
tostd::vector
. That's already something we do for the uniforms inshader_program.h
for uniforms outside of blocks:openage/libopenage/renderer/opengl/shader_program.h
Lines 184 to 189 in 380d2e9
The change should be pretty straight-forward I hope. Apart from the type of
uniforms
, you'll have to change the constructor ofGlUniformBuffer
and theRenderer::add_uniform_buffer
methods:openage/libopenage/renderer/opengl/renderer.cpp
Line 87 in 380d2e9
openage/libopenage/renderer/opengl/renderer.cpp
Line 115 in 380d2e9
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.
shader_data.h
also needs to be changed for theGlInBlockUniform
:openage/libopenage/renderer/opengl/shader_data.h
Lines 78 to 81 in 380d2e9
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 have now changed from
std::unordered_map
tostd::vector
. I did add a name attribute in theGlInBlockUniform
. the name is used instead of the the key that was stored with the map previously, mostly debugging and for creating the uniforms_by_name map. I'm not sure if this is how it should be, but I suppose some performance was gained, what do you think?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.
Great, I'll check it out now.