This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Windows] Improve texture format logic #54329
Merged
auto-submit
merged 1 commit into
flutter:main
from
loic-sharma:issue_150546_bgra_format
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,19 +20,6 @@ struct FramebufferBackingStore { | |
| uint32_t texture_id; | ||
| }; | ||
|
|
||
| // Based off Skia's logic: | ||
| // https://github.com/google/skia/blob/4738ed711e03212aceec3cd502a4adb545f38e63/src/gpu/ganesh/gl/GrGLCaps.cpp#L1963-L2116 | ||
| int GetSupportedTextureFormat(const impeller::DescriptionGLES* description) { | ||
| if (description->HasExtension("GL_EXT_texture_format_BGRA8888")) { | ||
| return GL_BGRA8_EXT; | ||
| } else if (description->HasExtension("GL_APPLE_texture_format_BGRA8888") && | ||
| description->GetGlVersion().IsAtLeast(impeller::Version(3, 0))) { | ||
| return GL_BGRA8_EXT; | ||
| } else { | ||
| return GL_RGBA8; | ||
| } | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| CompositorOpenGL::CompositorOpenGL(FlutterWindowsEngine* engine, | ||
|
|
@@ -58,17 +45,18 @@ bool CompositorOpenGL::CreateBackingStore( | |
| gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||
| gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | ||
| gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||
| gl_->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, config.size.width, | ||
| config.size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); | ||
| gl_->TexImage2D(GL_TEXTURE_2D, 0, format_.general_format, config.size.width, | ||
| config.size.height, 0, format_.general_format, | ||
| GL_UNSIGNED_BYTE, nullptr); | ||
| gl_->BindTexture(GL_TEXTURE_2D, 0); | ||
|
|
||
| gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, | ||
|
Member
Author
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.
|
||
| GL_TEXTURE_2D, store->texture_id, 0); | ||
| gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | ||
| store->texture_id, 0); | ||
|
|
||
| result->type = kFlutterBackingStoreTypeOpenGL; | ||
| result->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer; | ||
| result->open_gl.framebuffer.name = store->framebuffer_id; | ||
| result->open_gl.framebuffer.target = format_; | ||
| result->open_gl.framebuffer.target = format_.sized_format; | ||
| result->open_gl.framebuffer.user_data = store.release(); | ||
| result->open_gl.framebuffer.destruction_callback = [](void* user_data) { | ||
| // Backing store destroyed in `CompositorOpenGL::CollectBackingStore`, set | ||
|
|
@@ -185,7 +173,14 @@ bool CompositorOpenGL::Initialize() { | |
| return false; | ||
| } | ||
|
|
||
| format_ = GetSupportedTextureFormat(gl_->GetDescription()); | ||
| if (gl_->GetDescription()->HasExtension("GL_EXT_texture_format_BGRA8888")) { | ||
| format_.sized_format = GL_BGRA8_EXT; | ||
| format_.general_format = GL_BGRA_EXT; | ||
| } else { | ||
| format_.sized_format = GL_RGBA8; | ||
| format_.general_format = GL_RGBA; | ||
| } | ||
|
|
||
| is_initialized_ = true; | ||
| return true; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
kN32_SkColorTypeis eitherBGRA8orRGBA8depending on the machine that builds the engine. This caused Skia to reject RGBA8 textures if the engine was built on a machine where BGRA8 is the native color format.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.
Oh wow - nice catch.