-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Separate linear and sRGB uniform buffers in RD rendering backends #92444
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,8 +100,8 @@ class MaterialStorage : public RendererMaterialStorage { | |
HashMap<StringName, uint64_t> used_global_textures; | ||
|
||
//internally by update_parameters_uniform_set | ||
Vector<uint8_t> ubo_data; | ||
RID uniform_buffer; | ||
Vector<uint8_t> ubo_data[2]; // 0: linear buffer; 1: sRGB buffer. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would use an enum for the buffer, its just clearer why we have two. Might be over kill. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you clarify where the Enum would go? Do you mean you would create an enum just to establish the size of the Array? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe what he means is making it clearer that 0 is Linear and 1 is sRGB through an Enum. Declared at the top of material.h like this:
Used as such (without the need of comments):
I don't find it overkill, might save some headache for someone trying to guess which one is which in a later feature. But I think this ship has sailed since it has already been merged. @clayjohn if this is welcome, let me know if I should make another PR with this minor change. It might be a good start for me to get used with contributions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it would be beneficial. Using enums hides what is actually happening. For example, your code will fail to compile (an array of size 0 doesn't work for the UBO array, the array needs to have 2 elements). Also, the uniform buffer RID array is also wrong since it also needs two elements. It's really easy to make this kind of mistake when you hide the important values behind an enum. That being said, enums can be really handy when you use them both to initialize the array and to index into the array. Doing something like:
But in this case we index into the array with a boolean. So enums won't help. IMO using enums here adds more complexity for no gain |
||
RID uniform_buffer[2]; // 0: linear buffer; 1: sRGB buffer. | ||
Vector<RID> texture_cache; | ||
}; | ||
|
||
|
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.
@clayjohn I know the feature works because you reproduced so I'm just trying to learn here.
If
ubo_data[0]
is linear andubo_data[1]
is sRGB, why is the booleanp_use_linear_color
used like this? When it's true, it evaluates to 1 and accesses the sRGB data. Which seems counter-intuitive given the name of the variable.