-
Notifications
You must be signed in to change notification settings - Fork 2k
materials: introduce mutable spec constants #8795
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
Conversation
Addressed comments and also tested that it works on Android. |
@@ -208,6 +212,12 @@ class FMaterial : public Material { | |||
} | |||
size_t getParameters(ParameterInfo* parameters, size_t count) const noexcept; | |||
|
|||
size_t getMutableConstantCount() const noexcept { return mMaterialMutableConstants.size(); } | |||
std::optional<uint32_t> getMutableConstantId(std::string_view name) const noexcept; |
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.
uint8_t
here since there's a max of 8 mutable constants?
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 changed this to a uint32_t
to match the actual type of mMaterialMutableConstants.size()
. I figure it's probably best keep this value as CPU word size.
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.
minor comments
|:------|:------------------------------|:--------|-----------------| | ||
| int | A signed, 32 bit GLSL int | | no | | ||
| float | A single-precision GLSL float | 0.0 | no | | ||
| bool | A GLSL bool | false | yes | |
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.
mention default value for mutable
?
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.
actually, it should seem pretty obvious that it's false.
I know this was discussed in the doc, but maybe just use mutable_bool
as a type would be more explicit? Because there's really not a case where you'd want mutable: false
. And also mutable
only applies to bool.
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 mentioned this a little bit in the design doc, but in order to keep forwards compatibility in case we want to extend this feature to other types, we should keep the spec very similar to the existing immutable constants. Treating mutable constants as different types also complicates the implementation slightly.
Rationale & design of this feature has been discussed internally. The current implementation uses a `FixedCapacityVector` to store the new program handles, but I wouldn't object to replacing it with a hasmap as discussed offline. I have compiled but not tested this yet on Android, so I'm not certain that the API bindings are correctly wired up.
64d0a41
to
1e6708e
Compare
Rationale & design of this feature has been discussed internally.
The current implementation uses a
FixedCapacityVector
to store the new program handles, but I wouldn't object to replacing it with a hasmap as discussed offline.I have compiled but not tested this yet on Android, so I'm not certain that the API bindings are correctly wired up.