8000 materials: introduce mutable spec constants by elizagamedev · Pull Request #8795 · google/filament · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Jun 6, 2025
Merged

Conversation

elizagamedev
Copy link
Contributor

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.

@elizagamedev
Copy link
Contributor Author

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;
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor
@poweifeng poweifeng left a 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 |
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.
@elizagamedev elizagamedev force-pushed the exv/mutable-constants branch from 64d0a41 to 1e6708e Compare June 6, 2025 03:39
@elizagamedev elizagamedev enabled auto-merge (squash) June 6, 2025 03:40
@elizagamedev elizagamedev merged commit 8a1a0b0 into main Jun 6, 2025
16 checks passed
@elizagamedev elizagamedev deleted the exv/mutable-constants branch June 6, 2025 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0