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

check max mipmap level for texture creation #16783

Closed

Conversation

jcyuan
Copy link
Contributor

@jcyuan jcyuan commented Mar 9, 2024

check max level count
actually there is already a function getLevelCount in the GFXTexture.cpp to calculate the max count, but i didn't move this function to somewhere for common use because not sure where should i put it.

Copy link

github-actions bot commented Mar 9, 2024

Interface Check Report

This pull request does not change any public interfaces !

@@ -104,7 +104,8 @@ void TextureValidator::doInit(const TextureInfo &info) {
}

if (hasFlag(info.flags, TextureFlagBit::GEN_MIPMAP)) {
CC_ASSERT(info.levelCount > 1);
auto maxLevelCount = std::floor(std::log2(std::max({ info.width, info.height, info.depth }))) + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think don't have to +1 for some situations, for example std::max({ info.width, info.height, info.depth }) == 8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check here:

uint32_t getLevelCount(uint32_t width, uint32_t height) {
return static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
}

and this method actually could be moved to somewhere for common use.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, I think it is better to use _actor->getLevelCount() to get the value. And we may fix the logic of _actor->getLevelCount() in future.

@minggo minggo deleted the branch cocos:v3.8.3 May 16, 2024 02:51
@minggo minggo closed this May 16, 2024
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.

2 participants