[//gpu] Have SIFactory create and own GMBFactory [chromium/src : main]

0 views
Skip to first unread message

Vasiliy Telezhnikov (Gerrit)

unread,
10:38 AM (6 hours ago) 10:38 AM
to Colin Blundell, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Colin Blundell

Vasiliy Telezhnikov added 2 comments

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Vasiliy Telezhnikov . resolved

Sorry for the delay on this, it's kinda tricky.

To keep this rolling, maybe we could:

  • Land the follow-up CL first (essentially inline creation into SharedImageManager
  • Do something wonky where we move GMBFactory to SIFactory only for non-windows
  • Merge non-windows factories out

It's not that clean, but kinda moves us in the right direction while we're sorting out windows part. Essentially we need to sort out copy-native-to-shmem. What do you think?

File gpu/command_buffer/service/shared_image/shared_image_factory.cc
Line 181, Patchset 5 (Latest): gpu_memory_buffer_factory_(gpu::GpuMemoryBufferFactory::CreateNativeType(
Vasiliy Telezhnikov . unresolved

The side effect of this is that we'd create new d3d device for each SharedImageFactory, which could be quite a bit, especially because we never destroy staging textures.

We might need to either add code to clean those up or to extract device/staging texture in a separate helper class that is shared across GMB factories. Or find a way to use main D3D device, but that's a bit complicated due to threads.

Open in Gerrit

Related details

Attention is currently required from:
  • Colin Blundell
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I2b4b62797ac5dda3c0476a7a12be524f116c8d1f
Gerrit-Change-Number: 6973471
Gerrit-PatchSet: 5
Gerrit-Owner: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Attention: Colin Blundell <blun...@chromium.org>
Gerrit-Comment-Date: Thu, 25 Sep 2025 14:38:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Colin Blundell (Gerrit)

unread,
12:10 PM (4 hours ago) 12:10 PM
to Colin Blundell, Vasiliy Telezhnikov, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Vasiliy Telezhnikov

Colin Blundell added 3 comments

Patchset-level comments
Colin Blundell . resolved

Thanks! I figured that you were wrestling with a nuance about the CL here, which is why I didn't invest in building further on it today :).

Vasiliy Telezhnikov . resolved

Sorry for the delay on this, it's kinda tricky.

To keep this rolling, maybe we could:

  • Land the follow-up CL first (essentially inline creation into SharedImageManager
  • Do something wonky where we move GMBFactory to SIFactory only for non-windows
  • Merge non-windows factories out

It's not that clean, but kinda moves us in the right direction while we're sorting out windows part. Essentially we need to sort out copy-native-to-shmem. What do you think?

Colin Blundell

Your point in the comment makes a ton of sense. I would add to it that as you're mentioning the non-Windows code is essentially trivial and IMO there's no real reason it needs to be abstracted through the backing factories via virtual methods (that kind of creates a misleading impression that there's some sort of dynamic choice going on, which is not actually what's happening). What if we did this, building on your suggestion:

  • Extracted the GMBFactoryNativePixmap and GMBFactoryIOSurface method bodies into static methods called by those factory methods
  • Added static methods on the respective SI backing factories that call those methods
  • Changed SIFactory to call those static methods and use GMBFactory only on Windows
  • Mutate GMBFactoryDXGI into a helper class that is still created/owned by SIManager (or alternatively a singleton internal to SIFactory) and have SIFactory delegate to that for implementing the GMBHandle-related methods on Windows?

I'm open to other suggestions.

File gpu/command_buffer/service/shared_image/shared_image_factory.cc
Line 181, Patchset 5 (Latest): gpu_memory_buffer_factory_(gpu::GpuMemoryBufferFactory::CreateNativeType(
Vasiliy Telezhnikov . unresolved

The side effect of this is that we'd create new d3d device for each SharedImageFactory, which could be quite a bit, especially because we never destroy staging textures.

We might need to either add code to clean those up or to extract device/staging texture in a separate helper class that is shared across GMB factories. Or find a way to use main D3D device, but that's a bit complicated due to threads.

Colin Blundell

Thanks, that makes a ton of sense and indeed I hadn't thought of that nuance.

Open in Gerrit

Related details

Attention is currently required from:
  • Vasiliy Telezhnikov
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I2b4b62797ac5dda3c0476a7a12be524f116c8d1f
Gerrit-Change-Number: 6973471
Gerrit-PatchSet: 5
Gerrit-Owner: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Attention: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Comment-Date: Thu, 25 Sep 2025 16:10:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Vasiliy Telezhnikov <vas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Vasiliy Telezhnikov (Gerrit)

unread,
1:24 PM (3 hours ago) 1:24 PM
to Colin Blundell, Chromium LUCI CQ, chromium...@chromium.org
Attention needed from Colin Blundell

Vasiliy Telezhnikov added 1 comment

Patchset-level comments
Vasiliy Telezhnikov . resolved

Sorry for the delay on this, it's kinda tricky.

To keep this rolling, maybe we could:

  • Land the follow-up CL first (essentially inline creation into SharedImageManager
  • Do something wonky where we move GMBFactory to SIFactory only for non-windows
  • Merge non-windows factories out

It's not that clean, but kinda moves us in the right direction while we're sorting out windows part. Essentially we need to sort out copy-native-to-shmem. What do you think?

Colin Blundell

Your point in the comment makes a ton of sense. I would add to it that as you're mentioning the non-Windows code is essentially trivial and IMO there's no real reason it needs to be abstracted through the backing factories via virtual methods (that kind of creates a misleading impression that there's some sort of dynamic choice going on, which is not actually what's happening). What if we did this, building on your suggestion:

  • Extracted the GMBFactoryNativePixmap and GMBFactoryIOSurface method bodies into static methods called by those factory methods
  • Added static methods on the respective SI backing factories that call those methods
  • Changed SIFactory to call those static methods and use GMBFactory only on Windows
  • Mutate GMBFactoryDXGI into a helper class that is still created/owned by SIManager (or alternatively a singleton internal to SIFactory) and have SIFactory delegate to that for implementing the GMBHandle-related methods on Windows?

I'm open to other suggestions.

Vasiliy Telezhnikov

Something like that sounds good to me.

We generally need a plan copy-native-to-shmem, especially as we're about to add it to android as it heavily intersects with CopyToGpuMemoryBuffer functionality on SII and with CompoundImageBacking.

As far as I know creating D3D textures is fine on any thread (D3D11Device is thread-safe in that manner unless created with SINGLETHREADED flag, which we do only for this GMB thingy), but doing copy would require access to ImmediateContext which is not thread-safe.

It's also debatable how much it makes sense to make a gpu readback on the IO-thread, as the thread is supposed to be never busy to handle IPC in a timely manner.

Open in Gerrit

Related details

Attention is currently required from:
  • Colin Blundell
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I2b4b62797ac5dda3c0476a7a12be524f116c8d1f
Gerrit-Change-Number: 6973471
Gerrit-PatchSet: 5
Gerrit-Owner: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Colin Blundell <blun...@chromium.org>
Gerrit-Reviewer: Vasiliy Telezhnikov <vas...@chromium.org>
Gerrit-Attention: Colin Blundell <blun...@chromium.org>
Gerrit-Comment-Date: Thu, 25 Sep 2025 17:24:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Colin Blundell <blun...@chromium.org>
Comment-In-Reply-To: Vasiliy Telezhnikov <vas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages