Skip to content
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

Fix broken layerCount for some types of textures #8151

Merged
merged 4 commits into from
Sep 24, 2024
Merged

Conversation

z3moon
Copy link
Contributor

@z3moon z3moon commented Sep 24, 2024

Currently mLayerCount for RenderTarget is always updated to the number of depth for attachments, which incurs unintended behaviors for some types of textures. i.e., 2d array, cubemap array, and 3d textures.

Fix this by updating mLayerCount only for multiview use case.

BUGS=[369165616]

Currently mLayerCount for RenderTarget is always updated to the number
of depth for attachments, which incurs unintended behaviors for some
types of textures. i.e., 2d array, cubemap array, and 3d textures.

Fix this by updating mLayerCount only for multiview use case.
@z3moon z3moon added the internal Issue/PR does not affect clients label Sep 24, 2024
Comment on lines 125 to 137
if (attachment.layerCount) {
FILAMENT_CHECK_PRECONDITION(
attachment.texture->getTarget() == Texture::Sampler::SAMPLER_2D_ARRAY)
<< "Texture sampler must be of 2d array for multiview";
FILAMENT_CHECK_PRECONDITION(attachment.layer + attachment.layerCount <= d)
<< "For multiview, layer + layerCount cannot exceed the number of depth";
if (layerCountMultiview) {
FILAMENT_CHECK_PRECONDITION(layerCountMultiview == attachment.layerCount)
<< "layerCount for multiview should match";
} else {
layerCountMultiview = attachment.layerCount;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this, I would calculate the min and max layerCount and do the checks outside of the loop:

CHECK( min == max ) // all counts must match
CHECK( min > 1 && SAMPLER_2D || min <= 1 ) // multiview only with sampler 2D

The (attachment.layer + attachment.layerCount <= d) check can be always done (even when attachment.layerCount ==0).

@z3moon z3moon enabled auto-merge (squash) September 24, 2024 17:01
for (auto const& attachment : mImpl->mAttachments) {
if (attachment.texture) {
const uint32_t w = attachment.texture->getWidth(attachment.mipLevel);
const uint32_t h = attachment.texture->getHeight(attachment.mipLevel);
const uint32_t d = attachment.texture->getDepth(attachment.mipLevel);
const uint32_t l = attachment.layerCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically speaking, shouldn't we always have at least one layer? Should this be layer here instead of layerCount?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I disabled auto-merge while I still have this one question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layerCount here means the number of layers used for multiview. This variable indicates whether we use multiview . If this value is 0, then it means we don't use multiview for this attachment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just make it the same as mLayerCount in BuilderDetails so that > 1 means that multiview is enabled? So we don't have two different interpretations of the same variable name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original implementation. But the new interface .multiview(attachpoint, layerCount, startingLayer) requires each attachment point to have a layerCount.

@poweifeng poweifeng disabled auto-merge September 24, 2024 17:06
for (auto const& attachment : mImpl->mAttachments) {
if (attachment.texture) {
const uint32_t w = attachment.texture->getWidth(attachment.mipLevel);
const uint32_t h = attachment.texture->getHeight(attachment.mipLevel);
const uint32_t d = attachment.texture->getDepth(attachment.mipLevel);
const uint32_t l = attachment.layerCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just make it the same as mLayerCount in BuilderDetails so that > 1 means that multiview is enabled? So we don't have two different interpretations of the same variable name.

@z3moon z3moon merged commit 9d57ced into main Sep 24, 2024
11 checks passed
@z3moon z3moon deleted the zm/fix-broken-layercount branch September 24, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issue/PR does not affect clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants