-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] use sync fence for image uploads. #56609
Conversation
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.
Overall design LGTM
return handle; | ||
case HandleType::kFence: | ||
return GLHandle{.sync = gl.FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)}; | ||
break; |
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.
The break
can be deleted
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.
Done
@@ -117,18 +123,44 @@ const ProcTableGLES& ReactorGLES::GetProcTable() const { | |||
} | |||
|
|||
std::optional<GLuint> ReactorGLES::GetGLHandle(const HandleGLES& handle) const { | |||
if (handle.type == HandleType::kFence) { |
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.
The locking and the lookup in the handles_
map can be extracted out into a separate method in order to reduce the duplication between ReactorGLES::GetGLHandle
and GetGLFence
.
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.
Done
@@ -378,6 +377,8 @@ ImageDecoderImpeller::UnsafeUploadTextureToPrivate( | |||
} | |||
blit_pass->EncodeCommands(context->GetResourceAllocator()); | |||
|
|||
bool did_add_fence = context->AddTrackingFence(result_texture); |
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.
Create the fence after the call to CommandQueue::Submit
.
glFenceSync
should be called after issuing all of the GL commands that write to the texture. In theory that may not happen until after Submit
returns successfully.
(In practice the ReactorGLES::AddOperation
calls done during encoding will probably be able to call React
, which will call the GL APIs)
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.
Done
@@ -346,6 +348,8 @@ static bool ResourceIsLive(const ProcTableGLES& gl, | |||
return gl.IsRenderbuffer(name); | |||
case DebugResourceType::kFrameBuffer: | |||
return gl.IsFramebuffer(name); | |||
case DebugResourceType::kFence: | |||
return true; |
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.
GLES3 has a glIsSync
API that can be used here
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.
This is only used for debug labeling which I don't believe can be done to the sync fence APIs
@@ -121,10 +122,22 @@ class TextureGLES final : public Texture, | |||
|
|||
bool IsSliceInitialized(size_t slice) const; | |||
|
|||
//---------------------------------------------------------------------------- | |||
/// @brief Attach a sync fence to this texture that will be waited on | |||
/// before encoding a rendering operatio that references it. |
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.
typo: "operation"
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.
Done
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.
Stating the obvious; this should land after #56596 to get the gles3 context.
This is looking good. The test is looking good, the approach is looking right. I don't think we should introduce GLHandle when we have HandleGLES, it seems like we can merge those concepts, use HandleGLES when you need to potentially represent a fence.
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.
lgtm modulo any remaining of jason's feedback!
@jonahwilliams my PR that brings in an opengles3 context landed. This should be good to merge as far as I know. |
…159118) flutter/engine@878f593...c1b0e18 2024-11-19 [email protected] [Impeller] use sync fence for image uploads. (flutter/engine#56609) 2024-11-18 [email protected] Update emulator definitions version to latest available from chrome infra (flutter/engine#56313) 2024-11-18 [email protected] Roll Dart SDK from 625e0a9cb67a to 05d58364e92f (1 revision) (flutter/engine#56688) 2024-11-18 [email protected] iOS: Eliminate unguarded-availability opt-out (flutter/engine#56689) 2024-11-18 [email protected] [skwasm] Use `displayWidth`/`displayHeight` instead of `codedWidth`/`codedHeight` (flutter/engine#56686) 2024-11-18 [email protected] Extract TestGLContext to separate translation unit (flutter/engine#56647) 2024-11-18 [email protected] Roll Skia from b79e71223284 to 492e8347d7a4 (2 revisions) (flutter/engine#56687) 2024-11-18 [email protected] Update the Skia build scripts for a refactoring of the Fontconfig font manager (flutter/engine#56684) 2024-11-18 [email protected] iOS,macOS: Enable ARC in flutter_cflags_objc[c] (flutter/engine#56685) 2024-11-18 [email protected] Re-land "Remove `android_jit_release_x86`." (flutter/engine#56681) 2024-11-18 [email protected] Roll Skia from 0d24bd3268ef to b79e71223284 (1 revision) (flutter/engine#56683) 2024-11-18 [email protected] Flutter views can gain focus (flutter/engine#54985) 2024-11-18 [email protected] Roll Skia from 0b74d5c3eb4f to 0d24bd3268ef (1 revision) (flutter/engine#56680) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes flutter#158963 If the GLES version is at least 3, then we can attach a sync fence to the texture gles object. If this operation succeeds, then we can use gl.Flush instad of gl.Finish. Then, when binding the texture - if a sync fence is present we wait and then remove the fence.
Fixes flutter/flutter#158963
If the GLES version is at least 3, then we can attach a sync fence to the texture gles object. If this operation succeeds, then we can use gl.Flush instad of gl.Finish. Then, when binding the texture - if a sync fence is present we wait and then remove the fence.