Convert 11tex to 12resource, give it to dawn and dcomp [chromium/src : main]

0 views
Skip to first unread message

Rafael Cintron (Gerrit)

unread,
Aug 15, 2025, 5:00:02 PMAug 15
to Sahir Vellani, AyeAye, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Sahir Vellani

Rafael Cintron added 11 comments

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 86, Patchset 5 (Latest): d3d11on12_device->ReleaseWrappedResources(nullptr, 0);
Rafael Cintron . unresolved

Since you're passing nullptr to ReleaseWrappedResources, this call is a no-op.

Line 92, Patchset 5 (Latest): ID3D11DeviceContext* device_context;
Rafael Cintron . unresolved

Use a `ComPtr` for `device_context`.

Line 127, Patchset 5 (Latest): Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture) {
Rafael Cintron . unresolved

`ID3D11Texture2D` inherits from `ID3D11DeviceChild`. `ID3D11DeviceChild` has a `GetDevice` method you can use to get the D3D11 device which created it.

Line 152, Patchset 5 (Latest): d3d11on12_device2->ReturnUnderlyingResource(d3d11_texture.Get(), 1,
&fence_value, &fence_ptr);
Rafael Cintron . unresolved

The D3D12 command queue Dawn uses is the same as Chromium uses, correct? If so, there shouldn't be a need to pass fences here. You might be able to use ReleaseWrappedResource to accomplish the same thing and save yourself from having to pass fences.

Line 1531, Patchset 5 (Latest): d3d12_resource_ =
UnwrapUnderlyingResource(context_state_.get(), d3d11_texture_.Get());
Rafael Cintron . unresolved

This is very counterintuitive. If someone wants to `BeginAccessD3D11`, it means they want to use D3D11, not D3D12. Hence, we shouldn't unwrap to D3D12.

Since `BeginAccessD3D11` is paired with `EndAccessD3D11`, it means we call methods to wait on D3D11 objects while things are unwrapped to D3D12, further comingling things in surprising ways.

As part of your work, we should go back to the callers of `BeginAccessD3D11` and, if they need D3D11 for now, prepare the D3D11 texture and have a plan to move them to D3D12. For callers that support D3D12, we should add `BeginAccessD3D12` and call `UnwrapUnderlyingResource`

Line 1546, Patchset 5 (Latest): ? static_cast<IUnknown*>(d3d12_resource_.Get())
Rafael Cintron . unresolved

When you call `ReturnUnderlyingResource`, the next time you call `UnwrapUnderlyingResource`, you might get back a different D3D12 resource due to potential resource rename operations. Hence, we need to clear out the DComp texture on an unwrap operation ... or detect whether we get the same resource back as an optimization down the road.

Line 1661, Patchset 5 (Latest): Microsoft::WRL::ComPtr<ID3D12Device> d3d12_device;
Rafael Cintron . unresolved

(No longer relevant given my earlier comment about passing nullptr to `CreateFromD3D12Fence`)

`ID3D12Fence` inherits from `ID3D12DeviceChild`. `ID3D12DeviceChild` has a `GetDevice` method you can call to get the D3D12 device.

Line 1666, Patchset 5 (Latest): d3d12_device, std::move(d3d12_fence), fence_value);
Rafael Cintron . unresolved

Since the signaling device is the DComp device, Chromium's device, you need to pass nullptr for the first parameter of `CreateFromD3D12Fence` like we do on in the `CreateFromD3D11Fence` call below.

Line 1698, Patchset 5 (Latest): dcomp_texture_->Release();
Rafael Cintron . unresolved
```suggestion
dcomp_texture_->Reset();
```

Use Reset so that the ptr_ member variable is cleared.

Line 1870, Patchset 5 (Latest): d3d12_resource_->Release();
Rafael Cintron . unresolved
```suggestion
d3d12_resource_->Reset();
```
Use "Reset" so that the underlying `ptr_` inside of the ComPtr is set to nullptr.
File ui/gl/dc_layer_tree.cc
Line 1052, Patchset 5 (Latest): ::CloseHandle(fence_event);
Rafael Cintron . unresolved

This appears to be test code but in the future, use `base::win::ScopedHandle` to prevent memory leaks.

Open in Gerrit

Related details

Attention is currently required from:
  • Sahir Vellani
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 5
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Comment-Date: Fri, 15 Aug 2025 20:59:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Sep 2, 2025, 1:51:01 PMSep 2
to AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Rafael Cintron

Sahir Vellani added 19 comments

File gpu/command_buffer/service/dawn_context_provider.cc
Line 469, Patchset 4: d3d12_device.As(&d3d11_device);
Rafael Cintron . resolved

Please "CHECK_EQ(..., S_OK)" the return value of `As`.

Sahir Vellani

Done

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 421, Patchset 4: HANDLE d3d12_event_handle_;
Rafael Cintron . resolved

I know that `d3d12_event_handle_` is temporary and will not be checked in. For future reference, however, please use `base::win::ScopedHandle` to ensure handles do not get leaked.

Sahir Vellani

Acknowledged

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 86, Patchset 5: d3d11on12_device->ReleaseWrappedResources(nullptr, 0);
Rafael Cintron . resolved

Since you're passing nullptr to ReleaseWrappedResources, this call is a no-op.

Sahir Vellani

Acknowledged

Line 92, Patchset 5: ID3D11DeviceContext* device_context;
Rafael Cintron . resolved

Use a `ComPtr` for `device_context`.

Sahir Vellani

Done

Line 112, Patchset 4: }
Rafael Cintron . resolved

Please either early return from GetD3D11Device or use "else if"

Sahir Vellani

Done

Line 127, Patchset 5: Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture) {
Rafael Cintron . resolved

`ID3D11Texture2D` inherits from `ID3D11DeviceChild`. `ID3D11DeviceChild` has a `GetDevice` method you can use to get the D3D11 device which created it.

Sahir Vellani

Done

Line 128, Patchset 4: IUnknown* comp_texture_resource,
Rafael Cintron . resolved
```suggestion
IUnknown* d3d_resource,
```
Sahir Vellani

Done

Line 152, Patchset 5: d3d11on12_device2->ReturnUnderlyingResource(d3d11_texture.Get(), 1,
&fence_value, &fence_ptr);
Rafael Cintron . resolved

The D3D12 command queue Dawn uses is the same as Chromium uses, correct? If so, there shouldn't be a need to pass fences here. You might be able to use ReleaseWrappedResource to accomplish the same thing and save yourself from having to pass fences.

Sahir Vellani

Acknowledged

Line 561, Patchset 4: GetD3D11Device(context_state->dawn_context_provider()->GetDevice(),
Rafael Cintron . resolved

Why can this call context_state->GetD3D11Device()?

Sahir Vellani

Acknowledged

Line 1464, Patchset 4: if (d3d12_resource_ && base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDCompD3D12)) {
Rafael Cintron . resolved

Instead of checking flags, can we do the work in this if statement based on whether d3d12_resource is nullptr or not?

Sahir Vellani

Done

Line 1531, Patchset 5: d3d12_resource_ =
UnwrapUnderlyingResource(context_state_.get(), d3d11_texture_.Get());
Rafael Cintron . resolved

This is very counterintuitive. If someone wants to `BeginAccessD3D11`, it means they want to use D3D11, not D3D12. Hence, we shouldn't unwrap to D3D12.

Since `BeginAccessD3D11` is paired with `EndAccessD3D11`, it means we call methods to wait on D3D11 objects while things are unwrapped to D3D12, further comingling things in surprising ways.

As part of your work, we should go back to the callers of `BeginAccessD3D11` and, if they need D3D11 for now, prepare the D3D11 texture and have a plan to move them to D3D12. For callers that support D3D12, we should add `BeginAccessD3D12` and call `UnwrapUnderlyingResource`

Sahir Vellani

Done

Line 1546, Patchset 5: ? static_cast<IUnknown*>(d3d12_resource_.Get())
Rafael Cintron . resolved

When you call `ReturnUnderlyingResource`, the next time you call `UnwrapUnderlyingResource`, you might get back a different D3D12 resource due to potential resource rename operations. Hence, we need to clear out the DComp texture on an unwrap operation ... or detect whether we get the same resource back as an optimization down the road.

Sahir Vellani

Done

Line 1661, Patchset 5: Microsoft::WRL::ComPtr<ID3D12Device> d3d12_device;
Rafael Cintron . resolved

(No longer relevant given my earlier comment about passing nullptr to `CreateFromD3D12Fence`)

`ID3D12Fence` inherits from `ID3D12DeviceChild`. `ID3D12DeviceChild` has a `GetDevice` method you can call to get the D3D12 device.

Sahir Vellani

Acknowledged

Line 1666, Patchset 5: d3d12_device, std::move(d3d12_fence), fence_value);
Rafael Cintron . resolved

Since the signaling device is the DComp device, Chromium's device, you need to pass nullptr for the first parameter of `CreateFromD3D12Fence` like we do on in the `CreateFromD3D11Fence` call below.

Sahir Vellani

Acknowledged

Line 1698, Patchset 5: dcomp_texture_->Release();
Rafael Cintron . resolved
```suggestion
dcomp_texture_->Reset();
```

Use Reset so that the ptr_ member variable is cleared.

Sahir Vellani

Done

Line 1870, Patchset 5: d3d12_resource_->Release();
Rafael Cintron . resolved
```suggestion
d3d12_resource_->Reset();
```
Use "Reset" so that the underlying `ptr_` inside of the ComPtr is set to nullptr.
Sahir Vellani

Done

File gpu/command_buffer/service/shared_image/d3d_image_backing_factory.cc
Line 36, Patchset 4: ID3D11Texture2D* d3d11_texture) {
Rafael Cintron . resolved

ID3D11Texture2D objects have a GetDevice method they inherit from their base class. You should be able to QI that for the 11on12 device to then call UnwrapUnderlyingResource.

Sahir Vellani

Acknowledged

File ui/gl/dc_layer_tree.cc
Line 1052, Patchset 5: ::CloseHandle(fence_event);
Rafael Cintron . resolved

This appears to be test code but in the future, use `base::win::ScopedHandle` to prevent memory leaks.

Sahir Vellani

Done

File ui/gl/direct_composition_support.cc
Line 1192, Patchset 4 (Parent): if (SUCCEEDED(d3d11_device.As(&d3d11on12_device))) {
Rafael Cintron . resolved

Since we need ID3D11on12Device2, here is a good place to QI for that interface and return false if the QI fails.

Same goes for `D3DImageBackingFactory::IsD3DSharedImageSupported`.

Sahir Vellani

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 7
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Comment-Date: Tue, 02 Sep 2025 17:50:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Rafael Cintron (Gerrit)

unread,
Sep 4, 2025, 10:36:10 AMSep 4
to Sahir Vellani, AyeAye, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Sahir Vellani

Rafael Cintron added 14 comments

Patchset-level comments
File-level comment, Patchset 10 (Latest):
Rafael Cintron . resolved

Need to continue reviewing the L but here is what I have so far.

File cc/trees/layer_tree_host_impl.cc
Line 5538, Patchset 10 (Latest): "LayerTreeHostUIResourceSoftware"});
Rafael Cintron . unresolved

The improvements to the existing labels should be upstreamed as a separate CL.

File gpu/command_buffer/service/dawn_context_provider.cc
Line 471, Patchset 10 (Latest): switches::kDCompD3D12)) {
Rafael Cintron . unresolved

To aid in running experiments, please make this be its own feature flag or add it as a parameter of the existing SkiaGraphite feature flag.

Line 475, Patchset 10 (Latest): dawn::native::d3d12::GetD3D11On12Device(device_.Get());
Rafael Cintron . unresolved

ID3D11On12Device1 does not exist on all versions of Windows that Chromium supports. We need to limit our support of the feature to only those where the QI for ID3D11On12Device1 returns S_OK. For all others, we need to gracefully fallback to single swap chain like we have today.

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 20, Patchset 10 (Latest):#include "base/containers/span.h"
Rafael Cintron . unresolved

Unless I am missing something, we shouldn't need this include of span in `d3d_image_backing.h`

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 101, Patchset 10 (Latest): hr = d3d12_device->CreateCommandQueue(&command_queue_desc,
Rafael Cintron . unresolved

Creating a command queue every time we call PrepareTextureForD3D12 will be costly. Please cache the queue in the context.

Line 699, Patchset 10 (Latest): texture_d3d11_device_ = GetD3D11Device(
Rafael Cintron . unresolved

The device to use should come from the passed in texture not from a global place.

Line 992, Patchset 10 (Latest): d3d12_event_handle_ = CreateEventHandle();
Rafael Cintron . unresolved

I opened a previous issue about needing to get rid of this event handle. Please do so.

If you need it for prototyping purposes while you make progress, please manage its lifetime a bit better. I see multiple places where the handle is unconditionally assigned to and never cleaned up, thus leaking the handle and bloating the process handle table.

Line 1817, Patchset 10 (Latest): hr = d3d12_fence->SetEventOnCompletion(fence_value, d3d12_event_handle_);
CHECK_EQ(hr, S_OK);
::WaitForSingleObject(d3d12_event_handle_, 10000);
Rafael Cintron . unresolved

Can you please see what it would take to remove this hack? We should be able to go down the same path for fences that we do for D3D11.

Line 2101, Patchset 10 (Latest): dcomp_texture_.Reset();
Rafael Cintron . unresolved

Creating and destroying DComp textures repeatedly is a known source of performance regressions. Please find a way to only release/re-create it when the underlying DirectX resource actually needs to be changed.

File gpu/command_buffer/service/shared_image/d3d_image_representation.cc
Line 334, Patchset 10 (Latest): if (!d3d_image_backing->BeginAccessD3D(d3d11_device_,
Rafael Cintron . unresolved

Why does D3D12VideoImageRepresentation need to exist? Is this for the case where we use D3D12 to do video? Or where Video is on a separate D3D11 device from the rest of Chromium? The answers to these questions will guide whether this class should call BeginAccessD3D11 or BeginAccessD3D12.

File ui/gl/dc_layer_tree.cc
Line 1036, Patchset 10 (Latest): Microsoft::WRL::ComPtr<EXPERIMENTAL_IDCompositionDevice6> dcomp_device6;
HRESULT hr = dc_layer_tree_->dcomp_device_.As(&dcomp_device6);
Rafael Cintron . unresolved

Please have `DCLayerTree` store the `IDCompositionDevice6` as a member variable and set it in its Initialize method if the QI succeeds. No need to check the command line switch in `DClayerTree.`

File ui/gl/dcomp_presenter.cc
Line 7, Patchset 10 (Latest):#include <dawn/native/D3D12Backend.h>
Rafael Cintron . unresolved

Does `dcomp_presenter.cc` still need to `include dawn/native/D3D12Backend.h`?

File ui/gl/direct_composition_support.cc
Line 1145, Patchset 10 (Latest): // if (g_direct_composition_texture_supported.has_value()) {
// return g_direct_composition_texture_supported.value();
// }
Rafael Cintron . unresolved

Placeholder issue to uncomment this code and implement `DirectCompositionTextureSupported` correctly.

Open in Gerrit

Related details

Attention is currently required from:
  • Sahir Vellani
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 10
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Comment-Date: Thu, 04 Sep 2025 14:36:00 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Rafael Cintron (Gerrit)

unread,
Sep 4, 2025, 6:30:50 PMSep 4
to Sahir Vellani, AyeAye, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Sahir Vellani

Rafael Cintron added 3 comments

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 442, Patchset 10 (Latest): SkAlphaType alpha_type_;
Rafael Cintron . unresolved
```suggestion
const SkAlphaType alpha_type_;
```
Line 439, Patchset 10 (Latest): bool want_dcomp_texture_;
Rafael Cintron . unresolved
```suggestion
const bool want_dcomp_texture_;
```
File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 680, Patchset 10 (Latest): context_state_(std::move(context_state)),
Rafael Cintron . unresolved

What would it take to avoid passing context state to `D3DImageBacking` and, instead, determine what to do based on whether the device of `d3d11_texture` is an 11on12 device?

Open in Gerrit

Related details

Attention is currently required from:
  • Sahir Vellani
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 10
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Comment-Date: Thu, 04 Sep 2025 22:30:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Tang (Gerrit)

unread,
Sep 5, 2025, 5:41:47 PMSep 5
to Sahir Vellani, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Sahir Vellani

Michael Tang added 16 comments

Patchset-level comments
Michael Tang . resolved

I've left some comments, as with Rafael, I will continue to review this. Apologies for any dupe comments w/ rafael.

Please split out unrelated changes (logging, etc) to make this easier to review!

File components/viz/service/display_embedder/skia_output_device_dcomp.cc
Line 63, Patchset 9: if (Microsoft::WRL::ComPtr<PREVIEW_IDCompositionDevice5> dcomp_device5;
SUCCEEDED(dcomp_device.As(&dcomp_device5))) {
return OutputSurface::DCSupportLevel::kDCompDynamicTexture;
}
Michael Tang . unresolved
```suggestion
if (Microsoft::WRL::ComPtr<PREVIEW_IDCompositionDevice6> dcomp_device6;
SUCCEEDED(dcomp_device.As(&dcomp_device6))) {
return OutputSurface::DCSupportLevel::kDCompTextureD3D12;
}
    if (Microsoft::WRL::ComPtr<PREVIEW_IDCompositionDevice5> dcomp_device5;
SUCCEEDED(dcomp_device.As(&dcomp_device5))) {
return OutputSurface::DCSupportLevel::kDCompDynamicTexture;
}
```

When you clean up this CL, this will be useful to gate your feature on API support. This can possibly replace `kDCompD3D12`.

Line 203, Patchset 4: presenter_->SetCommandQueue(std::move(command_queue));
Michael Tang . unresolved

In practice, can the command queue change frame to frame? It not, we should initialize `DCLayerTree` with the command queue instead of passing it down every frame.

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 466, Patchset 10 (Latest): // Used to track D3D12 fence completion. Only a bandaid solution to get the
// prototype working.
Michael Tang . unresolved

What is the intended solution?

Line 441, Patchset 10 (Latest): const gfx::ColorSpace color_space_;
SkAlphaType alpha_type_;
Line 439, Patchset 10 (Latest): bool want_dcomp_texture_;
Michael Tang . unresolved
```suggestion
const bool want_dcomp_texture_;
```
Line 303, Patchset 10 (Latest): return dcomp_texture_ || (dxgi_shared_handle_state_ &&
Michael Tang . unresolved

Is this only needed for dx12 comp textures?

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 244, Patchset 9: LOG(INFO) << "GLTextureHolder::GLTextureHolder";
Michael Tang . unresolved

If these logs are useful for posterity, we can do something like to check it in.

```suggestion
DVLOG(3) << "GLTextureHolder::GLTextureHolder"; // or __func__ << " " << this;
```
Line 679, Patchset 9: context_state_(std::move(context_state)),
Michael Tang . unresolved

Can we extract the D3D11 device and simply bail (e.g. `want_dcomp_texture = false`) if the backend type is not correct?

I recall being told that we want to avoid passing the `SharedContextState` around, preferring to extract the specific stuff we need from it (since it's kind of an "everything" object that adds unnessecary dependencies).

Line 699, Patchset 10 (Latest): texture_d3d11_device_ = GetD3D11Device(
Rafael Cintron . unresolved

The device to use should come from the passed in texture not from a global place.

Michael Tang

Is this not already set a couple lines up?

Line 1190, Patchset 10 (Latest): if (context_state_->dawn_context_provider()->backend_type() ==
Michael Tang . unresolved

Do you know why `ProduceDawn` is provided with a `backend_type` instead of reading it off the `shared_context_state_` like you are here? I wonder if `ProduceVideo` isn't supposed to know about this detail-- if not, is there another signal for us to branch on here?

Line 2101, Patchset 10 (Latest): dcomp_texture_.Reset();
Rafael Cintron . unresolved

Creating and destroying DComp textures repeatedly is a known source of performance regressions. Please find a way to only release/re-create it when the underlying DirectX resource actually needs to be changed.

Michael Tang

I believe the dcomp texture also needs to stay alive

File gpu/command_buffer/service/shared_image/d3d_image_representation.cc
Line 320, Patchset 10 (Latest):D3D12VideoImageRepresentation::D3D12VideoImageRepresentation(
Michael Tang . unresolved

This seems to be pretty similar to `D3D11VideoImageRepresentation`, should the latter just be renamed to `D3DVideoImageRepresentation`?

File gpu/command_buffer/service/shared_image/wrapped_sk_image_backing_factory.cc
Line 55, Patchset 10 (Parent): case wgpu::BackendType::D3D12:
Michael Tang . unresolved

Will this still be needed when we don't support dcomp textures, but want d3d12?

File ui/gl/dcomp_presenter.h
Line 145, Patchset 10 (Latest): Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue_;
Michael Tang . unresolved

if we can initialize DCompPresenter with the command queue, then we can just have this field live on DCLayerTree.

File ui/gl/direct_composition_support.cc
Line 1196, Patchset 10 (Latest): if (FAILED(d3d11_device.As(&d3d11on12_device))) {
Michael Tang . unresolved

This needs to be something like "if SUCCEEDED(qi to 11on12) AND we do not support dx12 comp textures"

Open in Gerrit

Related details

Attention is currently required from:
  • Sahir Vellani
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 10
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Comment-Date: Fri, 05 Sep 2025 21:41:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Sep 5, 2025, 6:08:52 PMSep 5
to Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 13 comments

File gpu/command_buffer/service/dawn_context_provider.cc
Line 471, Patchset 10: switches::kDCompD3D12)) {
Rafael Cintron . resolved

To aid in running experiments, please make this be its own feature flag or add it as a parameter of the existing SkiaGraphite feature flag.

Sahir Vellani

Done

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 442, Patchset 10: SkAlphaType alpha_type_;
Rafael Cintron . resolved
```suggestion
const SkAlphaType alpha_type_;
```
Sahir Vellani

Done

Line 439, Patchset 10: bool want_dcomp_texture_;
Rafael Cintron . resolved
```suggestion
const bool want_dcomp_texture_;
```
Sahir Vellani

Done

Line 20, Patchset 10:#include "base/containers/span.h"
Rafael Cintron . resolved

Unless I am missing something, we shouldn't need this include of span in `d3d_image_backing.h`

Sahir Vellani

Relic of some experimentation.

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 101, Patchset 10: hr = d3d12_device->CreateCommandQueue(&command_queue_desc,
Rafael Cintron . resolved

Creating a command queue every time we call PrepareTextureForD3D12 will be costly. Please cache the queue in the context.

Sahir Vellani

Done

Line 699, Patchset 10: texture_d3d11_device_ = GetD3D11Device(
Rafael Cintron . resolved

The device to use should come from the passed in texture not from a global place.

Sahir Vellani

Done

Line 992, Patchset 10: d3d12_event_handle_ = CreateEventHandle();
Rafael Cintron . resolved

I opened a previous issue about needing to get rid of this event handle. Please do so.

If you need it for prototyping purposes while you make progress, please manage its lifetime a bit better. I see multiple places where the handle is unconditionally assigned to and never cleaned up, thus leaking the handle and bloating the process handle table.

Sahir Vellani

Done

Line 1817, Patchset 10: hr = d3d12_fence->SetEventOnCompletion(fence_value, d3d12_event_handle_);
CHECK_EQ(hr, S_OK);
::WaitForSingleObject(d3d12_event_handle_, 10000);
Rafael Cintron . resolved

Can you please see what it would take to remove this hack? We should be able to go down the same path for fences that we do for D3D11.

Sahir Vellani

Done

Line 2101, Patchset 10: dcomp_texture_.Reset();
Rafael Cintron . resolved

Creating and destroying DComp textures repeatedly is a known source of performance regressions. Please find a way to only release/re-create it when the underlying DirectX resource actually needs to be changed.

Sahir Vellani

Done

File gpu/command_buffer/service/shared_image/d3d_image_representation.cc
Line 334, Patchset 10: if (!d3d_image_backing->BeginAccessD3D(d3d11_device_,
Rafael Cintron . resolved

Why does D3D12VideoImageRepresentation need to exist? Is this for the case where we use D3D12 to do video? Or where Video is on a separate D3D11 device from the rest of Chromium? The answers to these questions will guide whether this class should call BeginAccessD3D11 or BeginAccessD3D12.

Sahir Vellani

Oversight on my part. We don't need both image representations, whether we use 11 or 12 can be an implementation detail of BeginAccessD3D. Actually, we don't really need the D3D11VideoImageRepresentation at all when the backend type is D3D12. The D3D11 texture is currently used in situations that allow for it to be unwrapped.

File ui/gl/dc_layer_tree.cc
Line 1036, Patchset 10: Microsoft::WRL::ComPtr<EXPERIMENTAL_IDCompositionDevice6> dcomp_device6;

HRESULT hr = dc_layer_tree_->dcomp_device_.As(&dcomp_device6);
Rafael Cintron . resolved

Please have `DCLayerTree` store the `IDCompositionDevice6` as a member variable and set it in its Initialize method if the QI succeeds. No need to check the command line switch in `DClayerTree.`

Sahir Vellani

Done

File ui/gl/dcomp_presenter.cc
Line 7, Patchset 10:#include <dawn/native/D3D12Backend.h>
Rafael Cintron . resolved

Does `dcomp_presenter.cc` still need to `include dawn/native/D3D12Backend.h`?

Sahir Vellani

Done

Line 106, Patchset 4:void DCompPresenter::SetCommandQueue(
Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue) {
command_queue_ = std::move(command_queue);
}
Rafael Cintron . resolved

Instead of adhoc ways of passing objects around, let's have the presenter get the command queue at construction time so that it is available.

When gpu_init.cc calls gl::InitializeDirectComposition, it should pass it the command queue to use for presentation.

Sahir Vellani

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 11
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Comment-Date: Fri, 05 Sep 2025 22:08:41 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Sep 8, 2025, 7:32:43 PMSep 8
to Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 12 comments

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 466, Patchset 10: // Used to track D3D12 fence completion. Only a bandaid solution to get the
// prototype working.
Michael Tang . resolved

What is the intended solution?

Sahir Vellani

Add the d3d12 fence to read/write fence sets and let the currently existing logic do its thing. Would've just been harder to debug that way.

Line 441, Patchset 10: const gfx::ColorSpace color_space_;
SkAlphaType alpha_type_;
Michael Tang . resolved
Sahir Vellani

I missed that, thanks.

Line 439, Patchset 10: bool want_dcomp_texture_;
Michael Tang . resolved
```suggestion
const bool want_dcomp_texture_;
```
Sahir Vellani

Done

Line 303, Patchset 10: return dcomp_texture_ || (dxgi_shared_handle_state_ &&
Michael Tang . unresolved

Is this only needed for dx12 comp textures?

Sahir Vellani

Yes

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 244, Patchset 9: LOG(INFO) << "GLTextureHolder::GLTextureHolder";
Michael Tang . resolved

If these logs are useful for posterity, we can do something like to check it in.

```suggestion
DVLOG(3) << "GLTextureHolder::GLTextureHolder"; // or __func__ << " " << this;
```
Sahir Vellani

Good idea, acknowledged.

Line 679, Patchset 9: context_state_(std::move(context_state)),
Michael Tang . resolved

Can we extract the D3D11 device and simply bail (e.g. `want_dcomp_texture = false`) if the backend type is not correct?

I recall being told that we want to avoid passing the `SharedContextState` around, preferring to extract the specific stuff we need from it (since it's kind of an "everything" object that adds unnessecary dependencies).

Sahir Vellani

Removed context_state_.

Line 680, Patchset 10: context_state_(std::move(context_state)),
Rafael Cintron . resolved

What would it take to avoid passing context state to `D3DImageBacking` and, instead, determine what to do based on whether the device of `d3d11_texture` is an 11on12 device?

Sahir Vellani

Not much, apparently.

Line 1190, Patchset 10: if (context_state_->dawn_context_provider()->backend_type() ==
Michael Tang . resolved

Do you know why `ProduceDawn` is provided with a `backend_type` instead of reading it off the `shared_context_state_` like you are here? I wonder if `ProduceVideo` isn't supposed to know about this detail-- if not, is there another signal for us to branch on here?

Sahir Vellani

Acknowledged

File gpu/command_buffer/service/shared_image/d3d_image_representation.cc
Line 320, Patchset 10:D3D12VideoImageRepresentation::D3D12VideoImageRepresentation(
Michael Tang . resolved

This seems to be pretty similar to `D3D11VideoImageRepresentation`, should the latter just be renamed to `D3DVideoImageRepresentation`?

Sahir Vellani

Done

File gpu/command_buffer/service/shared_image/wrapped_sk_image_backing_factory.cc
Line 55, Patchset 10 (Parent): case wgpu::BackendType::D3D12:
Michael Tang . resolved

Will this still be needed when we don't support dcomp textures, but want d3d12?

Sahir Vellani

Yes, nice catch.

File ui/gl/dcomp_presenter.h
Line 145, Patchset 10: Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue_;
Michael Tang . resolved

if we can initialize DCompPresenter with the command queue, then we can just have this field live on DCLayerTree.

Sahir Vellani

Done

File ui/gl/direct_composition_support.cc
Line 1196, Patchset 10: if (FAILED(d3d11_device.As(&d3d11on12_device))) {
Michael Tang . resolved

This needs to be something like "if SUCCEEDED(qi to 11on12) AND we do not support dx12 comp textures"

Sahir Vellani

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 13
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Comment-Date: Mon, 08 Sep 2025 23:32:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Michael Tang <ta...@microsoft.com>
Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Sep 9, 2025, 2:31:23 PMSep 9
to Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 2 comments

File cc/trees/layer_tree_host_impl.cc
Line 5538, Patchset 10: "LayerTreeHostUIResourceSoftware"});
Rafael Cintron . resolved

The improvements to the existing labels should be upstreamed as a separate CL.

Sahir Vellani

Acknowledged

File components/viz/service/display_embedder/skia_output_device_dcomp.cc
Line 203, Patchset 4: presenter_->SetCommandQueue(std::move(command_queue));
Michael Tang . resolved

In practice, can the command queue change frame to frame? It not, we should initialize `DCLayerTree` with the command queue instead of passing it down every frame.

Sahir Vellani

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 14
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Comment-Date: Tue, 09 Sep 2025 18:31:12 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Sep 9, 2025, 3:28:53 PMSep 9
to Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 2 comments

File gpu/command_buffer/service/dawn_context_provider.cc
Line 475, Patchset 10: dawn::native::d3d12::GetD3D11On12Device(device_.Get());
Rafael Cintron . resolved

ID3D11On12Device1 does not exist on all versions of Windows that Chromium supports. We need to limit our support of the feature to only those where the QI for ID3D11On12Device1 returns S_OK. For all others, we need to gracefully fallback to single swap chain like we have today.

Sahir Vellani

Done

File ui/gl/direct_composition_support.cc
Line 1145, Patchset 10: // if (g_direct_composition_texture_supported.has_value()) {
// return g_direct_composition_texture_supported.value();
// }
Rafael Cintron . resolved

Placeholder issue to uncomment this code and implement `DirectCompositionTextureSupported` correctly.

Sahir Vellani

Done

Gerrit-Comment-Date: Tue, 09 Sep 2025 19:28:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Rafael Cintron (Gerrit)

unread,
Sep 9, 2025, 10:23:48 PMSep 9
to Sahir Vellani, Chromium LUCI CQ, Michael Tang, AyeAye, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Sahir Vellani

Rafael Cintron added 14 comments

Patchset-level comments
File-level comment, Patchset 15:
Rafael Cintron . resolved

Have not finished with current review but posting what I have so far.

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 461, Patchset 15: bool is_texture_unwrapped_ GUARDED_BY(lock_) = false;
Rafael Cintron . unresolved

Please add a comment to `is_texture_unwrapped_` like the other members in this class have.

Line 439, Patchset 15: const bool want_dcomp_texture_;
Rafael Cintron . unresolved

Please add a comment to `want_dcomp_texture_` like the other members in this class have.

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 79, Patchset 15: LOG(ERROR) << "D3D12 command queue is null";
Rafael Cintron . unresolved

Will the caller ever pass a nullptr command queue. If not, we should just dereference it unconditionally like we already do with `d3d11_texture`.

Line 93, Patchset 15: d3d11on12_device->ReleaseWrappedResources(&d3d11_texture, 1);
Rafael Cintron . unresolved

Might be better to encapsulate this logcin by having the BeginAccessD3D12 and EndAccessD3D12 methods be more explicit about releasing the wrapped resource or unwrapping it based on which one is called. With your current approach, I think you're calling ReleaseWrappedResource when you don't need to.

Did you test the case where media is on a separate device than Chromium?

Line 2286, Patchset 15:D3DImageBacking::GetCommandQueueFor11On12() {
Rafael Cintron . unresolved

Please write a detailed commend why this "11on12" command queue exists.

Line 2286, Patchset 15:D3DImageBacking::GetCommandQueueFor11On12() {
Rafael Cintron . unresolved

```suggestion
D3DImageBacking::GetOrCreateCommandQueueFor11On12() {
```

Line 2287, Patchset 15: if (d3d12_command_queue_) {
Rafael Cintron . unresolved

Please disambiguate the member variable. When I first read the code, I thought this was the command queue where actual work was being being submitted. We should call it (and the accessor) something like "d3d12_none_command_queue."

File ui/gl/dc_layer_tree.h
Line 592, Patchset 15: Microsoft::WRL::ComPtr<EXPERIMENTAL_IDCompositionDevice6> dcomp_device_6_;

Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue_;
Rafael Cintron . unresolved

Please add a comment for these members like the other ones in this class have.

File ui/gl/dc_layer_tree.cc
Line 342, Patchset 15: dcomp_device_6_ = std::move(dcomp_device6);
Rafael Cintron . unresolved

Later in the file, we check for `dcomp_device_6_` and unconditionally dereference `command_queue_` when we call `PresentCompositionTextures`.

If we're running on a machine with `IDCompositionDevice6` but D3D12 mode is disabled or the machine has no D3D12 drivers, you'll get a crash in `BuildTree`.

We should fix this by first calling `GetDirectCompositionD3D12CommandQueue`. If it returns a non-nullptr queue, only then do we set `dcomp_device_6_`. This way both variables are either nullptr or non-nullptr.

File ui/gl/direct_composition_support.h
Line 59, Patchset 15:// Retrieves the global d3d12 command queue used by direct composition.
Rafael Cintron . unresolved

```suggestion
// Retrieves the global d3d12 command queue created by Dawn used by SharedImage code to queue work when it runs in D3D12 mode.
```

File ui/gl/direct_composition_support.cc
Line 150, Patchset 15:// Global d3d12 command queue used by direct composition.
Rafael Cintron . unresolved

```suggestion
// Global d3d12 command queue created by Dawn used by SharedImage code to queue work when it runs in D3D12 mode.
```

Line 766, Patchset 15: if (d3d12_command_queue) {
Rafael Cintron . unresolved

If check of d3d12_command_queue is unnecessary.

File ui/gl/presenter.h
Line 35, Patchset 15:#include <d3d12.h>
#include <wrl/client.h>
Rafael Cintron . unresolved

Are these header files needed in presenter.h?

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Sahir Vellani
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 15
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Comment-Date: Wed, 10 Sep 2025 02:23:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Sep 10, 2025, 2:23:24 PMSep 10
to Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 13 comments

File gpu/command_buffer/service/shared_image/d3d_image_backing.h
Line 461, Patchset 15: bool is_texture_unwrapped_ GUARDED_BY(lock_) = false;
Rafael Cintron . resolved

Please add a comment to `is_texture_unwrapped_` like the other members in this class have.

Sahir Vellani

Done

Line 439, Patchset 15: const bool want_dcomp_texture_;
Rafael Cintron . resolved

Please add a comment to `want_dcomp_texture_` like the other members in this class have.

Sahir Vellani

Done

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 79, Patchset 15: LOG(ERROR) << "D3D12 command queue is null";
Rafael Cintron . resolved

Will the caller ever pass a nullptr command queue. If not, we should just dereference it unconditionally like we already do with `d3d11_texture`.

Sahir Vellani

Yes a null command queue can be passed in.

Line 93, Patchset 15: d3d11on12_device->ReleaseWrappedResources(&d3d11_texture, 1);
Rafael Cintron . unresolved

Might be better to encapsulate this logcin by having the BeginAccessD3D12 and EndAccessD3D12 methods be more explicit about releasing the wrapped resource or unwrapping it based on which one is called. With your current approach, I think you're calling ReleaseWrappedResource when you don't need to.

Did you test the case where media is on a separate device than Chromium?

Sahir Vellani

I think you're right that I'm releasing when I don't have to. We check whether the texture is unwrapped prior to unwrapping anyway.

Line 2286, Patchset 15:D3DImageBacking::GetCommandQueueFor11On12() {
Rafael Cintron . resolved

```suggestion
D3DImageBacking::GetOrCreateCommandQueueFor11On12() {
```

Sahir Vellani

Done

Line 2286, Patchset 15:D3DImageBacking::GetCommandQueueFor11On12() {
Rafael Cintron . resolved

Please write a detailed commend why this "11on12" command queue exists.

Sahir Vellani

Done

Line 2287, Patchset 15: if (d3d12_command_queue_) {
Rafael Cintron . resolved

Please disambiguate the member variable. When I first read the code, I thought this was the command queue where actual work was being being submitted. We should call it (and the accessor) something like "d3d12_none_command_queue."

Sahir Vellani

Done

File ui/gl/dc_layer_tree.h
Line 592, Patchset 15: Microsoft::WRL::ComPtr<EXPERIMENTAL_IDCompositionDevice6> dcomp_device_6_;
Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue_;
Rafael Cintron . resolved

Please add a comment for these members like the other ones in this class have.

Sahir Vellani

Done

File ui/gl/dc_layer_tree.cc
Line 342, Patchset 15: dcomp_device_6_ = std::move(dcomp_device6);
Rafael Cintron . resolved

Later in the file, we check for `dcomp_device_6_` and unconditionally dereference `command_queue_` when we call `PresentCompositionTextures`.

If we're running on a machine with `IDCompositionDevice6` but D3D12 mode is disabled or the machine has no D3D12 drivers, you'll get a crash in `BuildTree`.

We should fix this by first calling `GetDirectCompositionD3D12CommandQueue`. If it returns a non-nullptr queue, only then do we set `dcomp_device_6_`. This way both variables are either nullptr or non-nullptr.

Sahir Vellani

Done

File ui/gl/direct_composition_support.h
Line 59, Patchset 15:// Retrieves the global d3d12 command queue used by direct composition.
Rafael Cintron . resolved

```suggestion
// Retrieves the global d3d12 command queue created by Dawn used by SharedImage code to queue work when it runs in D3D12 mode.
```

Sahir Vellani

Done

File ui/gl/direct_composition_support.cc
Line 150, Patchset 15:// Global d3d12 command queue used by direct composition.
Rafael Cintron . resolved

```suggestion
// Global d3d12 command queue created by Dawn used by SharedImage code to queue work when it runs in D3D12 mode.
```

Sahir Vellani

Done

Line 766, Patchset 15: if (d3d12_command_queue) {
Rafael Cintron . resolved

If check of d3d12_command_queue is unnecessary.

Sahir Vellani

Done

File ui/gl/presenter.h
Line 35, Patchset 15:#include <d3d12.h>
#include <wrl/client.h>
Rafael Cintron . resolved

Are these header files needed in presenter.h?

Sahir Vellani

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 17
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Comment-Date: Wed, 10 Sep 2025 18:23:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Oct 1, 2025, 6:52:48 PMOct 1
to Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 1 comment

Patchset-level comments
Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Rafael Cintron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 22
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Comment-Date: Wed, 01 Oct 2025 22:52:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Rafael Cintron (Gerrit)

unread,
Oct 1, 2025, 9:58:36 PMOct 1
to Sahir Vellani, Chromium LUCI CQ, Michael Tang, AyeAye, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Sahir Vellani

Rafael Cintron added 16 comments

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 73, Patchset 22 (Latest): return SUCCEEDED(hr) && !(d3d11_texture_desc.MiscFlags &
D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX);
Rafael Cintron . unresolved

Nit: Please provide a comment why keyed mutexes are excluded.

Line 79, Patchset 22 (Latest): Microsoft::WRL::ComPtr<ID3D11Resource> d3d11_texture,
Microsoft::WRL::ComPtr<ID3D12CommandQueue> d3d12_command_queue) {
Rafael Cintron . unresolved

Since PrepareTextureForD3D12 does not take ownership of its parameters, please pass these by bald pointer.

Line 85, Patchset 22 (Latest): Microsoft::WRL::ComPtr<ID3D12Resource> d3d12_resource;
Rafael Cintron . unresolved

Nit: Please declare d3d12_resource closer to where it is used.

Line 90, Patchset 22 (Latest): if (FAILED(hr)) {
LOG(ERROR) << "Failed to get D3D11On12Device2: "
<< logging::SystemErrorCodeToString(hr);
return nullptr;
}
Rafael Cintron . unresolved

Per earlier checks, this QI for ID3D11On12Device2 should always succeed.

Line 107, Patchset 22 (Latest): // Flushing operations.
Rafael Cintron . unresolved

Nit: Please replace this "flushing operations" comment with a comment that describes why we need to flush. Include a link to the MSDN page that talks about why: https://learn.microsoft.com/en-us/windows/win32/api/d3d11on12/nf-d3d11on12-id3d11on12device2-unwrapunderlyingresource

Line 118, Patchset 22 (Latest):void PrepareTextureForD3D11(
Rafael Cintron . unresolved

Since PrepareTextureForD3D11 does not take ownership of its parameters, please pass these by bald pointer.

Line 948, Patchset 22 (Latest): if (!dcomp_texture_) {
dcomp_texture_ =
want_dcomp_texture_ && (d3d11_texture_ || d3d12_resource_)
? CreateDCompTexture(
d3d12_resource_
? static_cast<IUnknown*>(d3d12_resource_.Get())
: static_cast<IUnknown*>(d3d11_texture_.Get()),
alpha_type(), color_space())
: nullptr;
}
Rafael Cintron . unresolved

Why does "ProduceDawn" need to create DComp textures?

Line 1554, Patchset 22 (Latest): ? CreateDCompTexture(static_cast<IUnknown*>(d3d11_texture_.Get()),
Rafael Cintron . unresolved

D3D11 textures inherit from IUnknown. Unless I am missing something, this static cast should not be necessary.

Line 1600, Patchset 22 (Latest): is_texture_unwrapped_
Rafael Cintron . unresolved

If `BeginAccessD3D12` sets `is_texture_unwrapped` to true below and `EndAccessD3D12` always sets it to false, when will it be true here on line 1600?

Line 1604, Patchset 22 (Latest): if (d3d12_resource && d3d12_resource != d3d12_resource_) {
Rafael Cintron . unresolved

If `EndAccessCommon` always clears out `d3d12_resource_`, why are we assuming it is non-nullptr here? Is the `EndAccessCommon` code which clears the D3D resource not necessary?

Line 1604, Patchset 22 (Latest): if (d3d12_resource && d3d12_resource != d3d12_resource_) {
Rafael Cintron . unresolved

If `d3d12_resource` is nullptr, we should clear out `d3d12_resource_` and return false.

Line 1606, Patchset 22 (Latest): d3d12_resource_ = d3d12_resource;
Rafael Cintron . unresolved
```suggestion
d3d12_resource_ = std::move(d3d12_resource);
```
Line 1616, Patchset 22 (Latest): ? CreateDCompTexture(static_cast<IUnknown*>(d3d12_resource_.Get()),
Rafael Cintron . unresolved

Similarly here, D3D12 resources derive from IUnknown so this cast shouldn't be necessary.

Line 1655, Patchset 22 (Latest): d3d11_signal_fence = gfx::D3DSharedFence::CreateForD3D11(d3d11_device);
Rafael Cintron . unresolved

Why can't we rely on existing code in GetPendingWaitFences to add signaled fences to `d3d11_signaled_fence_map_` when needed? Is there a bug in GetPendingWaitFences?

Line 2253, Patchset 22 (Latest): if (FAILED(hr)) {
LOG(ERROR) << "Failed to get D3D11On12Device2: "
<< logging::SystemErrorCodeToString(hr);
return nullptr;
}
Rafael Cintron . unresolved

Per if checks which run earlier, shouldn't this QI for ID3D11on12Device2 always succeed?

Line 2270, Patchset 22 (Latest): CHECK_EQ(hr, S_OK) << ", CreateCommandQueue failed: "
<< logging::SystemErrorCodeToString(hr);
Rafael Cintron . unresolved

CreateCommandQueue, on the other hand, is something we should handle gracefully and not CHECK. If the device has become removed, it will fail.

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Sahir Vellani
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not 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: I323c85586daa2687de59c97d0d27f4f0e443fb69
Gerrit-Change-Number: 6733314
Gerrit-PatchSet: 22
Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
Gerrit-CC: Michael Tang <ta...@microsoft.com>
Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
Gerrit-Attention: Michael Tang <ta...@microsoft.com>
Gerrit-Comment-Date: Thu, 02 Oct 2025 01:58:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Sahir Vellani (Gerrit)

unread,
Oct 2, 2025, 6:50:16 PMOct 2
to Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
Attention needed from Michael Tang and Rafael Cintron

Sahir Vellani added 16 comments

File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
Line 73, Patchset 22: return SUCCEEDED(hr) && !(d3d11_texture_desc.MiscFlags &
D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX);
Rafael Cintron . resolved

Nit: Please provide a comment why keyed mutexes are excluded.

Sahir Vellani

Done

Line 79, Patchset 22: Microsoft::WRL::ComPtr<ID3D11Resource> d3d11_texture,

Microsoft::WRL::ComPtr<ID3D12CommandQueue> d3d12_command_queue) {
Rafael Cintron . resolved

Since PrepareTextureForD3D12 does not take ownership of its parameters, please pass these by bald pointer.

Sahir Vellani

Done

Line 85, Patchset 22: Microsoft::WRL::ComPtr<ID3D12Resource> d3d12_resource;
Rafael Cintron . resolved

Nit: Please declare d3d12_resource closer to where it is used.

Sahir Vellani

Done

Line 90, Patchset 22: if (FAILED(hr)) {

LOG(ERROR) << "Failed to get D3D11On12Device2: "
<< logging::SystemErrorCodeToString(hr);
return nullptr;
}
Rafael Cintron . resolved

Per earlier checks, this QI for ID3D11On12Device2 should always succeed.

Sahir Vellani

Done

Line 107, Patchset 22: // Flushing operations.
Rafael Cintron . resolved

Nit: Please replace this "flushing operations" comment with a comment that describes why we need to flush. Include a link to the MSDN page that talks about why: https://learn.microsoft.com/en-us/windows/win32/api/d3d11on12/nf-d3d11on12-id3d11on12device2-unwrapunderlyingresource

Sahir Vellani

Done

Line 118, Patchset 22:void PrepareTextureForD3D11(
Rafael Cintron . resolved

Since PrepareTextureForD3D11 does not take ownership of its parameters, please pass these by bald pointer.

Sahir Vellani

Done

Line 948, Patchset 22: if (!dcomp_texture_) {

dcomp_texture_ =
want_dcomp_texture_ && (d3d11_texture_ || d3d12_resource_)
? CreateDCompTexture(
d3d12_resource_
? static_cast<IUnknown*>(d3d12_resource_.Get())
: static_cast<IUnknown*>(d3d11_texture_.Get()),
alpha_type(), color_space())
: nullptr;
}
Rafael Cintron . resolved

Why does "ProduceDawn" need to create DComp textures?

Sahir Vellani

Don't think it does. Thanks for the catch.

Line 1554, Patchset 22: ? CreateDCompTexture(static_cast<IUnknown*>(d3d11_texture_.Get()),
Rafael Cintron . resolved

D3D11 textures inherit from IUnknown. Unless I am missing something, this static cast should not be necessary.

Sahir Vellani

Done

Line 1600, Patchset 22: is_texture_unwrapped_
Rafael Cintron . resolved

If `BeginAccessD3D12` sets `is_texture_unwrapped` to true below and `EndAccessD3D12` always sets it to false, when will it be true here on line 1600?

Sahir Vellani

Done

Line 1604, Patchset 22: if (d3d12_resource && d3d12_resource != d3d12_resource_) {
Rafael Cintron . resolved

If `d3d12_resource` is nullptr, we should clear out `d3d12_resource_` and return false.

Sahir Vellani

Done

Line 1604, Patchset 22: if (d3d12_resource && d3d12_resource != d3d12_resource_) {
Rafael Cintron . resolved

If `EndAccessCommon` always clears out `d3d12_resource_`, why are we assuming it is non-nullptr here? Is the `EndAccessCommon` code which clears the D3D resource not necessary?

Sahir Vellani

Done

Line 1606, Patchset 22: d3d12_resource_ = d3d12_resource;
Rafael Cintron . resolved
```suggestion
d3d12_resource_ = std::move(d3d12_resource);
```
Sahir Vellani

Done

Line 1616, Patchset 22: ? CreateDCompTexture(static_cast<IUnknown*>(d3d12_resource_.Get()),
Rafael Cintron . resolved

Similarly here, D3D12 resources derive from IUnknown so this cast shouldn't be necessary.

Sahir Vellani

Done

Line 1655, Patchset 22: d3d11_signal_fence = gfx::D3DSharedFence::CreateForD3D11(d3d11_device);
Rafael Cintron . unresolved

Why can't we rely on existing code in GetPendingWaitFences to add signaled fences to `d3d11_signaled_fence_map_` when needed? Is there a bug in GetPendingWaitFences?

Sahir Vellani

GetPendingWaitFences only creates a fence on the texture's device. When there is WebGL on the page, that fence's value is current because work is being done on the ANGLE device. Here, we create a fence on the device that is being used for the current D3D11 access. I think it could be a bug, but I haven't yet looked into why there are no problems in regular D3D11 mode.

Line 2253, Patchset 22: if (FAILED(hr)) {

LOG(ERROR) << "Failed to get D3D11On12Device2: "
<< logging::SystemErrorCodeToString(hr);
return nullptr;
}
Rafael Cintron . resolved

Per if checks which run earlier, shouldn't this QI for ID3D11on12Device2 always succeed?

Sahir Vellani

No, actually GetOrCreateCommandQueueFor11On12 is called regardless of the mode we're in.

Line 2270, Patchset 22: CHECK_EQ(hr, S_OK) << ", CreateCommandQueue failed: "
<< logging::SystemErrorCodeToString(hr);
Rafael Cintron . resolved

CreateCommandQueue, on the other hand, is something we should handle gracefully and not CHECK. If the device has become removed, it will fail.

Sahir Vellani

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Tang
  • Rafael Cintron
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I323c85586daa2687de59c97d0d27f4f0e443fb69
    Gerrit-Change-Number: 6733314
    Gerrit-PatchSet: 24
    Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-CC: Michael Tang <ta...@microsoft.com>
    Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Attention: Michael Tang <ta...@microsoft.com>
    Gerrit-Comment-Date: Thu, 02 Oct 2025 22:50:07 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Rafael Cintron (Gerrit)

    unread,
    Nov 4, 2025, 10:01:53 PM (8 days ago) Nov 4
    to Sahir Vellani, Chromium LUCI CQ, Michael Tang, AyeAye, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
    Attention needed from Michael Tang and Sahir Vellani

    Rafael Cintron added 16 comments

    File gpu/command_buffer/service/shared_image/d3d_image_backing.h
    Line 144, Patchset 27 (Latest): bool BeginAccessD3D12(Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
    bool write_access,
    bool is_overlay_access = false);
    void EndAccessD3D12(Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
    bool is_overlay_access = false);
    Rafael Cintron . unresolved

    Will Begin/EndAccessD3D12 ever be called from outside of D3DImageBacking? If not, can we make them private to the class?

    File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
    Line 69, Patchset 27 (Latest):bool ShouldUseD3D12(Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
    Rafael Cintron . unresolved

    ```suggestion
    bool ShouldUseD3D12(ID3D11Device* d3d11_device,
    ```

    Line 70, Patchset 27 (Latest): D3D11_TEXTURE2D_DESC d3d11_texture_desc) {
    Rafael Cintron . unresolved
    ```suggestion
    const D3D11_TEXTURE2D_DESC& d3d11_texture_desc) {
    ```
    Line 929, Patchset 27 (Latest): // TODO(savella) Look into why dawn_d3d11_device == texture_d3d11_device_ if
    // the resource has a keyed mutex flag. This happens during copy scenarios
    Rafael Cintron . unresolved

    What were the results of your investigation?

    Line 934, Patchset 27 (Latest): // ProduceDawn can be called during D3D12 access. Therefore if the texture
    // is already unwrapped, use the underlying resource to create shared
    Rafael Cintron . unresolved

    Unless I am missing something, this comment doesn't appear to match what the code is doing. The comment says "use the underlying resource" but the code sets d3d12_resource to nullptr.

    Line 1007, Patchset 27 (Latest): // texture memory for the D3D12 resource. Since it was not already in an
    // unwrapped state, return the resource back to the 11On12 translation
    // layer.
    Rafael Cintron . unresolved

    This code seems counterintuitive to me. Since the purpose of "ProduceDawn" is to prepare to render to the texture (with Dawn) with D3D12, we shouldn't need to give the resource back to 11on12. We just called PrepareTextureForD3D12 earlier in this same function.

    Line 1602, Patchset 27 (Latest): return false;
    Rafael Cintron . unresolved

    Please LOG(ERROR) for this false condition so we can troubleshoot bad rendering with users.

    Line 1597, Patchset 27 (Latest): if (d3d12_resource && d3d12_resource != d3d12_resource_) {
    dcomp_texture_.Reset();
    d3d12_resource_ = std::move(d3d12_resource);
    } else if (!d3d12_resource) {
    d3d12_resource_.Reset();
    return false;
    }
    Rafael Cintron . unresolved
    ```suggestion
    if (d3d12_resource) {
    if (d3d12_resource != d3d12_resource_) {
    dcomp_texture_.Reset();
    d3d12_resource_ = std::move(d3d12_resource);
    }
    } else {
    d3d12_resource_.Reset();
    return false;
    }
    ```
    Line 1639, Patchset 27 (Latest): if (d3d11_signal_fence) {
    if (d3d11_signal_fence->IncrementAndSignalD3D11()) {
    signaled_fence.insert(d3d11_signal_fence);
    } else {
    LOG(ERROR) << "Failed to signal D3D11 device fence on EndAccess";
    }
    } else if (!is_texture_device && in_write_access_) {
    Rafael Cintron . unresolved

    Since the code seems necessary, we should be able to reuse the IncrementAndSignal code instead of copy/pasting it.

    Line 1655, Patchset 22: d3d11_signal_fence = gfx::D3DSharedFence::CreateForD3D11(d3d11_device);
    Rafael Cintron . resolved

    Why can't we rely on existing code in GetPendingWaitFences to add signaled fences to `d3d11_signaled_fence_map_` when needed? Is there a bug in GetPendingWaitFences?

    Sahir Vellani

    GetPendingWaitFences only creates a fence on the texture's device. When there is WebGL on the page, that fence's value is current because work is being done on the ANGLE device. Here, we create a fence on the device that is being used for the current D3D11 access. I think it could be a bug, but I haven't yet looked into why there are no problems in regular D3D11 mode.

    Rafael Cintron

    Acknowledged

    Line 1691, Patchset 27 (Latest): if (d3d11_signal_fence->IncrementAndSignalD3D11()) {
    Rafael Cintron . unresolved

    Does this code (now) need the same treatment you added to EndAccessD3D11 with regard to calling IncrementAndSignal when we're in write access and the devices do not match? Why or why not?

    Line 2023, Patchset 27 (Latest): if (is_texture_unwrapped_) {
    PrepareTextureForD3D11(d3d11_texture_.Get());
    is_texture_unwrapped_ = false;
    }
    Rafael Cintron . unresolved

    Please add a comment that describes why we're not clearing out `d3d12_resource_` after we've prepared for D3D11.

    File ui/gl/dc_layer_tree.cc
    Line 343, Patchset 27 (Latest): dcomp_device_6_ = std::move(dcomp_device6);
    Rafael Cintron . unresolved

    Please improve the code so that we don't end up in a partially initialized state. Suggest that g_d3d12_command_queue is only set when we have IDCompositionDevice6. Then, we can CHECK_EQ(..., S_OK) the QI here.

    Line 1044, Patchset 27 (Latest): CHECK_EQ(hr, S_OK) << "Failed to present composition textures."
    Rafael Cintron . unresolved

    Similar to Commit, PresentCompositionTextures can fail if the device has been removed or we have presentation loss. We want those cases to be handled in the caller. Please add a new "CommitError::Reason" for PresentCompositionTextures.

    Line 1052, Patchset 27 (Latest): CHECK_EQ(hr, S_OK) << "Commit failed with error 0x" << std::hex << hr;
    Rafael Cintron . unresolved

    Since we do FAILED(hr) right above, hr will never be S_OK to satisfy this CHECK.

    Commit can fail if the device has been removed or we have presentation loss. We want those cases to be handled in the caller.

    File ui/gl/direct_composition_support.cc
    Line 794, Patchset 27 (Latest): }
    if (g_d3d12_command_queue) {
    g_d3d12_command_queue->Release();
    g_d3d12_command_queue = nullptr;
    }
    Rafael Cintron . unresolved
    ```suggestion
    if (g_d3d12_command_queue) {
    g_d3d12_command_queue->Release();
    g_d3d12_command_queue = nullptr;
    }
    }
    ```
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Tang
    • Sahir Vellani
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I323c85586daa2687de59c97d0d27f4f0e443fb69
    Gerrit-Change-Number: 6733314
    Gerrit-PatchSet: 27
    Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-CC: Michael Tang <ta...@microsoft.com>
    Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Attention: Michael Tang <ta...@microsoft.com>
    Gerrit-Comment-Date: Wed, 05 Nov 2025 03:01:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Sahir Vellani <sahir....@microsoft.com>
    Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Michael Tang (Gerrit)

    unread,
    Nov 7, 2025, 6:28:50 PM (5 days ago) Nov 7
    to Sahir Vellani, Chromium LUCI CQ, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
    Attention needed from Sahir Vellani

    Michael Tang added 22 comments

    Patchset-level comments
    File-level comment, Patchset 28 (Latest):
    Michael Tang . unresolved

    Do you anticipate that D3D12+DComp support will be something that we need to query for? Or is it something that we want to just happen automatically when supported without our knowledge? If the former, please add a `OutputSurface::DCSupportLevel::kDCompTextureD3D12` and set it [in SkiaOutputDeviceDComp](https://source.chromium.org/chromium/chromium/src/+/main:components/viz/service/display_embedder/skia_output_device_dcomp.cc;l=54-68;drc=75786f4af376776d0078a6d500a7134172922e59).

    File gpu/command_buffer/service/shared_image/d3d_image_backing.h
    Line 459, Patchset 28 (Latest): // True if the backing's texture has been unwrapped for use as a D3D12
    // resource. Used to prevent unwraps of already unwrapped texture.

    bool is_texture_unwrapped_ GUARDED_BY(lock_) = false;
    Michael Tang . unresolved

    Can we add a note that this is referring to `d3d11_texture_` and if `is_texture_unwrapped_ = true` means that the texture _cannot_ be used by D3D11?

    Maybe theres a better name for that that is higher level than the 11on12 terminology?

    Line 360, Patchset 28 (Parent): const Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture_;
    Michael Tang . unresolved

    Can this be made `const` again? I don't see any places that reset it.

    File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
    Line 78, Patchset 28 (Latest):// Unwraps a D3D11 texture to its underlying D3D12 resource.
    Michael Tang . unresolved

    Given the usage, it seems like `UnwrapUnderlyingResource` can return different results on the same input texture. Please add a note in this comment if that's so.

    Line 80, Patchset 28 (Latest): ID3D11Resource* d3d11_texture,
    Michael Tang . unresolved

    Does this texture have to have been created on 11on12? What happens if I call this without D3D12 initialized (or from a non-11on12 texture)?

    Line 89, Patchset 28 (Latest): HRESULT hr = d3d11_device.As(&d3d11on12_device);
    Michael Tang . unresolved

    We're dropping errors from `hr` here.

    Line 102, Patchset 28 (Latest): // UnwrapUnderlyingResource doesn't flush, and it may schedule GPU work. We
    // should therefore flush the D3D11 device context here. See:
    // https://learn.microsoft.com/en-us/windows/win32/api/d3d11on12/nf-d3d11on12-id3d11on12device2-unwrapunderlyingresource
    Michael Tang . unresolved

    Is the reason we need to flush is to ensure that any fence signals get realized _now_?

    Line 173, Patchset 28 (Latest): LOG(ERROR) << "Failed to get D3D11 device from D3D12 device. hr="
    << std::hex << hr;
    Michael Tang . unresolved
    ```suggestion
    LOG(ERROR) << "Failed to get D3D11 device from D3D12 device: "
    << logging::SystemErrorCodeToString(hr);
    ```
    Line 177, Patchset 28 (Latest): }
    Michael Tang . unresolved
    ```suggestion
    } else {
    NOTREACHED();
    }
    ```
    Should we guard against unexpected backend types? Or rename this to something like `TryGetDawnDeviceAsD3D11Device`?
    Line 909, Patchset 28 (Latest): auto d3d12_resource =
    is_texture_unwrapped_
    ? nullptr
    : PrepareTextureForD3D12(d3d11_texture_.Get(),
    GetOrCreateCommandQueueFor11On12());
    Michael Tang . unresolved

    Is there ever a time when `d3d11_texture_` and `d3d12_resource_` are both valid to use at the same time? Could we (reasonably) replace `is_texture_unwrapped_` with a `std::optional<ID3D12Resource>` (or `std::variant`?) to ensure safety in that case?

    Line 928, Patchset 28 (Latest): } else {
    Michael Tang . unresolved

    Should we guard against unexpected dawn backend types?

    Line 1128, Patchset 28 (Parent): CHECK(dawn_d3d11_device);
    Michael Tang . unresolved

    Not sure if intentional, but we are dropping this check. Should it be in `GetD3D11Device`?

    Line 1503, Patchset 28 (Latest): CHECK(!is_texture_unwrapped_) << "Texture is unwrapped";
    Michael Tang . unresolved

    Maybe something with a bit more context: "11on12 texture is unwrapped for D3D12 access"? I'm imagining what it would be like to see this crash message after forgetting about this change 😊

    Line 1548, Patchset 28 (Latest): AutoLock auto_lock(this);

    FlushGraphiteCommandsIfNeeded();

    if (!ValidateBeginAccess(write_access)) {
    return false;
    }

    // Defer clearing fences until later to handle failure to synchronize.
    std::vector<scoped_refptr<gfx::D3DSharedFence>> wait_fences =
    GetPendingWaitFences(d3d11_device, /*dawn_device=*/nullptr, write_access);
    for (auto& wait_fence : wait_fences) {
    if (!wait_fence->WaitD3D11(d3d11_device)) {
    LOG(ERROR) << "Failed to wait for fence";
    return false;
    }
    }
    Michael Tang . unresolved

    Can this be hoisted up into `BeginAccessD3D`?

    Line 1581, Patchset 28 (Latest): if (!dcomp_texture_) {
    CHECK(is_texture_unwrapped_);
    dcomp_texture_ = want_dcomp_texture_
    ? CreateDCompTexture(d3d12_resource_.Get(),
    alpha_type(), color_space())
    : nullptr;
    }

    if (is_overlay_access && dcomp_texture_) {
    CHECK(!write_access);
    BeginDCompTextureAccess();
    }

    // Clear fences and update state iff D3D12 BeginAccess succeeds.
    BeginAccessCommon(write_access);
    return true;
    Michael Tang . unresolved

    Can this be hoisted up into `BeginAccessD3D`?

    Line 1613, Patchset 28 (Latest): // If the accessing device is not the texture's original device, create
    Michael Tang . unresolved

    nit: wording, since the access has finished at this point?

    ```suggestion
    // If the accessing device was not the texture's original device, create
    ```
    Line 1616, Patchset 28 (Latest): if (!d3d11_signal_fence && (!is_texture_device && in_write_access_)) {
    Michael Tang . unresolved

    Could/should we find a way to put the accessing device into `d3d11_signaled_fence_map_` on begin access instead of special casing it here? This map seems to be the general place to sychronize "after D3D11 access".

    Line 1665, Patchset 28 (Latest): if (is_overlay_access && dcomp_texture_) {
    EndDCompTextureAccess();
    }

    if (in_write_access_) {
    NotifyGraphiteAboutInitializedStatus();
    }

    EndAccessCommon(signaled_fence);
    Michael Tang . unresolved

    Can this be hoisted up into `EndAccessD3D`?

    Line 1707, Patchset 28 (Latest): Microsoft::WRL::ComPtr<ID3D12Fence> d3d12_fence;
    if (ShouldUseD3D12(texture_d3d11_device_.Get(), d3d11_texture_desc_)) {
    uint64_t fence_value = 0;
    HRESULT hr = dcomp_texture_->GetAvailableFence(&fence_value,
    IID_PPV_ARGS(&d3d12_fence));
    CHECK_EQ(hr, S_OK) << ", GetAvailableFence failed: "
    << logging::SystemErrorCodeToString(hr);
    CHECK(d3d12_fence) << "Overlay access is still in use by DWM.";

    // If the fence is already passed the wait value, we don't need to wait on
    // it.
    if (d3d12_fence->GetCompletedValue() >= fence_value) {
    return;
    }
    dcomp_texture_available_fence_ = gfx::D3DSharedFence::CreateFromD3D12Fence(
    std::move(d3d12_fence), fence_value);
    return;
    }
    Michael Tang . unresolved

    Theres a lot of duplicated code here vs the D3D11 version-- is there a way to deduplicate, so both versions to have to stay as much in sync? Maybe store off `ShouldUseD3D12` and interleave checks to it?

    File ui/gl/dc_layer_tree.h
    Line 592, Patchset 19: // An extension of composition device interface that enables support of d3d12
    // for composition textures.

    Microsoft::WRL::ComPtr<EXPERIMENTAL_IDCompositionDevice6> dcomp_device_6_;
    // A d3d12 command queue from Dawn that is used to present composition
    // textures prior to DComp commit.

    Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue_;
    Michael Tang . unresolved

    nit: Can we group this with the other `d3d11_device_`, `dcomp_device_`, etc above?

    File ui/gl/dc_layer_tree.cc
    Line 1039, Patchset 13: IUnknown* command_queue_unk = dc_layer_tree_->command_queue_.Get();
    Michael Tang . unresolved

    q: Does this need to be `IUnknown*`? Can it be `ID3D12CommandQueue*` which is converted at the `PresentCompositionTextures` callsite?

    File ui/gl/direct_composition_support.h
    Line 40, Patchset 13:// Initialize direct composition with the given d3d11 device and d3d12 command
    // queue.
    Michael Tang . unresolved

    nit: Can we note that this can be null?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Sahir Vellani
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I323c85586daa2687de59c97d0d27f4f0e443fb69
    Gerrit-Change-Number: 6733314
    Gerrit-PatchSet: 28
    Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-CC: Michael Tang <ta...@microsoft.com>
    Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Comment-Date: Fri, 07 Nov 2025 23:28:41 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Sahir Vellani (Gerrit)

    unread,
    Nov 11, 2025, 2:18:31 PM (2 days ago) Nov 11
    to Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
    Attention needed from Michael Tang, Rafael Cintron and Sahir Vellani

    Sahir Vellani voted and added 38 comments

    Votes added by Sahir Vellani

    Commit-Queue+1

    38 comments

    File gpu/command_buffer/service/shared_image/d3d_image_backing.h
    Line 459, Patchset 28: // True if the backing's texture has been unwrapped for use as a D3D12

    // resource. Used to prevent unwraps of already unwrapped texture.
    bool is_texture_unwrapped_ GUARDED_BY(lock_) = false;
    Michael Tang . resolved

    Can we add a note that this is referring to `d3d11_texture_` and if `is_texture_unwrapped_ = true` means that the texture _cannot_ be used by D3D11?

    Maybe theres a better name for that that is higher level than the 11on12 terminology?

    Sahir Vellani

    Done

    Line 360, Patchset 28 (Parent): const Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture_;
    Michael Tang . resolved

    Can this be made `const` again? I don't see any places that reset it.

    Sahir Vellani

    Done

    Line 144, Patchset 27: bool BeginAccessD3D12(Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,

    bool write_access,
    bool is_overlay_access = false);
    void EndAccessD3D12(Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
    bool is_overlay_access = false);
    Rafael Cintron . resolved

    Will Begin/EndAccessD3D12 ever be called from outside of D3DImageBacking? If not, can we make them private to the class?

    Sahir Vellani

    We can make them private for now.

    Line 303, Patchset 10: return dcomp_texture_ || (dxgi_shared_handle_state_ &&
    Michael Tang . resolved

    Is this only needed for dx12 comp textures?

    Sahir Vellani

    Yes

    Sahir Vellani

    Done

    File gpu/command_buffer/service/shared_image/d3d_image_backing.cc
    Line 69, Patchset 27:bool ShouldUseD3D12(Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device,
    Rafael Cintron . resolved

    ```suggestion
    bool ShouldUseD3D12(ID3D11Device* d3d11_device,
    ```

    Sahir Vellani

    Done

    Line 70, Patchset 27: D3D11_TEXTURE2D_DESC d3d11_texture_desc) {
    Rafael Cintron . resolved
    ```suggestion
    const D3D11_TEXTURE2D_DESC& d3d11_texture_desc) {
    ```
    Sahir Vellani

    Done

    Line 78, Patchset 28:// Unwraps a D3D11 texture to its underlying D3D12 resource.
    Michael Tang . resolved

    Given the usage, it seems like `UnwrapUnderlyingResource` can return different results on the same input texture. Please add a note in this comment if that's so.

    Sahir Vellani

    Done

    Line 80, Patchset 28: ID3D11Resource* d3d11_texture,
    Michael Tang . resolved

    Does this texture have to have been created on 11on12? What happens if I call this without D3D12 initialized (or from a non-11on12 texture)?

    Sahir Vellani

    No the texture does not need to be created on 11on12. If this is called without D3D12 initialized, it would be a no-op as the command queue would be null.

    Line 89, Patchset 28: HRESULT hr = d3d11_device.As(&d3d11on12_device);
    Michael Tang . resolved

    We're dropping errors from `hr` here.

    Sahir Vellani

    Done

    Line 93, Patchset 15: d3d11on12_device->ReleaseWrappedResources(&d3d11_texture, 1);
    Rafael Cintron . resolved

    Might be better to encapsulate this logcin by having the BeginAccessD3D12 and EndAccessD3D12 methods be more explicit about releasing the wrapped resource or unwrapping it based on which one is called. With your current approach, I think you're calling ReleaseWrappedResource when you don't need to.

    Did you test the case where media is on a separate device than Chromium?

    Sahir Vellani

    I think you're right that I'm releasing when I don't have to. We check whether the texture is unwrapped prior to unwrapping anyway.

    Sahir Vellani

    Done

    Line 102, Patchset 28: // UnwrapUnderlyingResource doesn't flush, and it may schedule GPU work. We
    Michael Tang . resolved

    Is the reason we need to flush is to ensure that any fence signals get realized _now_?

    Sahir Vellani

    Yes, as UnwrapUnderlyingResource can queue work in the D3D11 context IIUC.

    Line 173, Patchset 28: LOG(ERROR) << "Failed to get D3D11 device from D3D12 device. hr="
    << std::hex << hr;
    Michael Tang . resolved
    ```suggestion
    LOG(ERROR) << "Failed to get D3D11 device from D3D12 device: "
    << logging::SystemErrorCodeToString(hr);
    ```
    Sahir Vellani

    Done

    Line 177, Patchset 28: }
    Michael Tang . resolved
    ```suggestion
    } else {
    NOTREACHED();
    }
    ```
    Should we guard against unexpected backend types? Or rename this to something like `TryGetDawnDeviceAsD3D11Device`?
    Sahir Vellani

    Done

    Line 909, Patchset 28: auto d3d12_resource =

    is_texture_unwrapped_
    ? nullptr
    : PrepareTextureForD3D12(d3d11_texture_.Get(),
    GetOrCreateCommandQueueFor11On12());
    Michael Tang . resolved

    Is there ever a time when `d3d11_texture_` and `d3d12_resource_` are both valid to use at the same time? Could we (reasonably) replace `is_texture_unwrapped_` with a `std::optional<ID3D12Resource>` (or `std::variant`?) to ensure safety in that case?

    Sahir Vellani

    I purposefully don't clear out the D3D12 resource when returning it back to the 11On12 translation layer because I would need to re-create Dawn's shared texture memory. So I'd rather not use an optional for this case.

    Line 928, Patchset 28: } else {
    Michael Tang . resolved

    Should we guard against unexpected dawn backend types?

    Sahir Vellani

    I don't think it's necessary. There's a check earlier in this function.

    Line 929, Patchset 27: // TODO(savella) Look into why dawn_d3d11_device == texture_d3d11_device_ if

    // the resource has a keyed mutex flag. This happens during copy scenarios
    Rafael Cintron . resolved

    What were the results of your investigation?

    Sahir Vellani

    Device that opens the shared handle is the one that is returned by `GetDevice`.

    Line 934, Patchset 27: // ProduceDawn can be called during D3D12 access. Therefore if the texture

    // is already unwrapped, use the underlying resource to create shared
    Rafael Cintron . resolved

    Unless I am missing something, this comment doesn't appear to match what the code is doing. The comment says "use the underlying resource" but the code sets d3d12_resource to nullptr.

    Sahir Vellani

    Done

    Line 1007, Patchset 27: // texture memory for the D3D12 resource. Since it was not already in an

    // unwrapped state, return the resource back to the 11On12 translation
    // layer.
    Rafael Cintron . unresolved

    This code seems counterintuitive to me. Since the purpose of "ProduceDawn" is to prepare to render to the texture (with Dawn) with D3D12, we shouldn't need to give the resource back to 11on12. We just called PrepareTextureForD3D12 earlier in this same function.

    Sahir Vellani

    We PrepareTextureForD3D12 to get the resource for creating a SharedTextureMemory. My opinion is that we only unwrap when we definitely want to use the resource; and we know that only happens between Begin/End Access. Returning the resource back to D3D11On12 here keeps it in a predictable state.

    Line 1128, Patchset 28 (Parent): CHECK(dawn_d3d11_device);
    Michael Tang . resolved

    Not sure if intentional, but we are dropping this check. Should it be in `GetD3D11Device`?

    Sahir Vellani

    Done

    Line 1503, Patchset 28: CHECK(!is_texture_unwrapped_) << "Texture is unwrapped";
    Michael Tang . resolved

    Maybe something with a bit more context: "11on12 texture is unwrapped for D3D12 access"? I'm imagining what it would be like to see this crash message after forgetting about this change 😊

    Sahir Vellani

    Done

    Line 1548, Patchset 28: AutoLock auto_lock(this);


    FlushGraphiteCommandsIfNeeded();

    if (!ValidateBeginAccess(write_access)) {
    return false;
    }

    // Defer clearing fences until later to handle failure to synchronize.
    std::vector<scoped_refptr<gfx::D3DSharedFence>> wait_fences =
    GetPendingWaitFences(d3d11_device, /*dawn_device=*/nullptr, write_access);
    for (auto& wait_fence : wait_fences) {
    if (!wait_fence->WaitD3D11(d3d11_device)) {
    LOG(ERROR) << "Failed to wait for fence";
    return false;
    }
    }
    Michael Tang . resolved

    Can this be hoisted up into `BeginAccessD3D`?

    Sahir Vellani

    I can do this as a follow-up once I get PersistentDawnAccess working, as we need to invalidate persistent access in D3D11 mode before validating begin access and dealing with the fences.

    Line 1581, Patchset 28: if (!dcomp_texture_) {

    CHECK(is_texture_unwrapped_);
    dcomp_texture_ = want_dcomp_texture_
    ? CreateDCompTexture(d3d12_resource_.Get(),
    alpha_type(), color_space())
    : nullptr;
    }

    if (is_overlay_access && dcomp_texture_) {
    CHECK(!write_access);
    BeginDCompTextureAccess();
    }

    // Clear fences and update state iff D3D12 BeginAccess succeeds.
    BeginAccessCommon(write_access);
    return true;
    Michael Tang . resolved

    Can this be hoisted up into `BeginAccessD3D`?

    Sahir Vellani

    Done

    Line 1602, Patchset 27: return false;
    Rafael Cintron . resolved

    Please LOG(ERROR) for this false condition so we can troubleshoot bad rendering with users.

    Sahir Vellani

    Done

    Line 1597, Patchset 27: if (d3d12_resource && d3d12_resource != d3d12_resource_) {

    dcomp_texture_.Reset();
    d3d12_resource_ = std::move(d3d12_resource);
    } else if (!d3d12_resource) {
    d3d12_resource_.Reset();
    return false;
    }
    Rafael Cintron . resolved
    ```suggestion
    if (d3d12_resource) {
    if (d3d12_resource != d3d12_resource_) {
    dcomp_texture_.Reset();
    d3d12_resource_ = std::move(d3d12_resource);
    }
    } else {
    d3d12_resource_.Reset();
    return false;
    }
    ```
    Sahir Vellani

    Done

    Line 1613, Patchset 28: // If the accessing device is not the texture's original device, create
    Michael Tang . resolved

    nit: wording, since the access has finished at this point?

    ```suggestion
    // If the accessing device was not the texture's original device, create
    ```
    Sahir Vellani

    Done

    Line 1616, Patchset 28: if (!d3d11_signal_fence && (!is_texture_device && in_write_access_)) {
    Michael Tang . resolved

    Could/should we find a way to put the accessing device into `d3d11_signaled_fence_map_` on begin access instead of special casing it here? This map seems to be the general place to sychronize "after D3D11 access".

    Sahir Vellani

    Done

    Line 1639, Patchset 27: if (d3d11_signal_fence) {

    if (d3d11_signal_fence->IncrementAndSignalD3D11()) {
    signaled_fence.insert(d3d11_signal_fence);
    } else {
    LOG(ERROR) << "Failed to signal D3D11 device fence on EndAccess";
    }
    } else if (!is_texture_device && in_write_access_) {
    Rafael Cintron . resolved

    Since the code seems necessary, we should be able to reuse the IncrementAndSignal code instead of copy/pasting it.

    Sahir Vellani

    Done

    Line 1665, Patchset 28: if (is_overlay_access && dcomp_texture_) {

    EndDCompTextureAccess();
    }

    if (in_write_access_) {
    NotifyGraphiteAboutInitializedStatus();
    }

    EndAccessCommon(signaled_fence);
    Michael Tang . resolved

    Can this be hoisted up into `EndAccessD3D`?

    Sahir Vellani

    Done

    Line 1691, Patchset 27: if (d3d11_signal_fence->IncrementAndSignalD3D11()) {
    Rafael Cintron . unresolved

    Does this code (now) need the same treatment you added to EndAccessD3D11 with regard to calling IncrementAndSignal when we're in write access and the devices do not match? Why or why not?

    Sahir Vellani

    I'm not aware of a use case that would require us to wait on the d3d11_device here. The existing application of GetPendingWaitFences() seems sufficient.

    Line 1707, Patchset 28: Microsoft::WRL::ComPtr<ID3D12Fence> d3d12_fence;

    if (ShouldUseD3D12(texture_d3d11_device_.Get(), d3d11_texture_desc_)) {
    uint64_t fence_value = 0;
    HRESULT hr = dcomp_texture_->GetAvailableFence(&fence_value,
    IID_PPV_ARGS(&d3d12_fence));
    CHECK_EQ(hr, S_OK) << ", GetAvailableFence failed: "
    << logging::SystemErrorCodeToString(hr);
    CHECK(d3d12_fence) << "Overlay access is still in use by DWM.";

    // If the fence is already passed the wait value, we don't need to wait on
    // it.
    if (d3d12_fence->GetCompletedValue() >= fence_value) {
    return;
    }
    dcomp_texture_available_fence_ = gfx::D3DSharedFence::CreateFromD3D12Fence(
    std::move(d3d12_fence), fence_value);
    return;
    }
    Michael Tang . resolved

    Theres a lot of duplicated code here vs the D3D11 version-- is there a way to deduplicate, so both versions to have to stay as much in sync? Maybe store off `ShouldUseD3D12` and interleave checks to it?

    Sahir Vellani

    It's a different fence data structure for each version, so we would still have the same amount of code right? My thought is that with the separate block it is easier to read.

    Line 2023, Patchset 27: if (is_texture_unwrapped_) {
    PrepareTextureForD3D11(d3d11_texture_.Get());
    is_texture_unwrapped_ = false;
    }
    Rafael Cintron . resolved

    Please add a comment that describes why we're not clearing out `d3d12_resource_` after we've prepared for D3D11.

    Sahir Vellani

    Done

    File ui/gl/dc_layer_tree.h
    Line 592, Patchset 19: // An extension of composition device interface that enables support of d3d12
    // for composition textures.
    Microsoft::WRL::ComPtr<EXPERIMENTAL_IDCompositionDevice6> dcomp_device_6_;
    // A d3d12 command queue from Dawn that is used to present composition
    // textures prior to DComp commit.
    Microsoft::WRL::ComPtr<ID3D12CommandQueue> command_queue_;
    Michael Tang . resolved

    nit: Can we group this with the other `d3d11_device_`, `dcomp_device_`, etc above?

    Sahir Vellani

    Done

    File ui/gl/dc_layer_tree.cc
    Line 343, Patchset 27: dcomp_device_6_ = std::move(dcomp_device6);
    Rafael Cintron . resolved

    Please improve the code so that we don't end up in a partially initialized state. Suggest that g_d3d12_command_queue is only set when we have IDCompositionDevice6. Then, we can CHECK_EQ(..., S_OK) the QI here.

    Sahir Vellani

    Done

    Line 1039, Patchset 13: IUnknown* command_queue_unk = dc_layer_tree_->command_queue_.Get();
    Michael Tang . resolved

    q: Does this need to be `IUnknown*`? Can it be `ID3D12CommandQueue*` which is converted at the `PresentCompositionTextures` callsite?

    Sahir Vellani

    Yeah it has to be null. The code fails to compile if an ID3D12CommandQueue* is supplied to PresetCompositionTextures.

    Line 1044, Patchset 27: CHECK_EQ(hr, S_OK) << "Failed to present composition textures."
    Rafael Cintron . resolved

    Similar to Commit, PresentCompositionTextures can fail if the device has been removed or we have presentation loss. We want those cases to be handled in the caller. Please add a new "CommitError::Reason" for PresentCompositionTextures.

    Sahir Vellani

    Done

    Line 1052, Patchset 27: CHECK_EQ(hr, S_OK) << "Commit failed with error 0x" << std::hex << hr;
    Rafael Cintron . resolved

    Since we do FAILED(hr) right above, hr will never be S_OK to satisfy this CHECK.

    Commit can fail if the device has been removed or we have presentation loss. We want those cases to be handled in the caller.

    Sahir Vellani

    This was from a debugging exercise, missed it.

    File ui/gl/direct_composition_support.h
    Line 40, Patchset 13:// Initialize direct composition with the given d3d11 device and d3d12 command
    // queue.
    Michael Tang . resolved

    nit: Can we note that this can be null?

    Sahir Vellani

    Done

    File ui/gl/direct_composition_support.cc

    if (g_d3d12_command_queue) {
    g_d3d12_command_queue->Release();
    g_d3d12_command_queue = nullptr;
    }
    Rafael Cintron . resolved
    ```suggestion
    if (g_d3d12_command_queue) {
    g_d3d12_command_queue->Release();
    g_d3d12_command_queue = nullptr;
    }
    }
    ```
    Sahir Vellani

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Tang
    • Rafael Cintron
    • Sahir Vellani
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I323c85586daa2687de59c97d0d27f4f0e443fb69
    Gerrit-Change-Number: 6733314
    Gerrit-PatchSet: 30
    Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-CC: Michael Tang <ta...@microsoft.com>
    Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Attention: Michael Tang <ta...@microsoft.com>
    Gerrit-Comment-Date: Tue, 11 Nov 2025 19:18:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Rafael Cintron <rafael....@microsoft.com>
    Comment-In-Reply-To: Sahir Vellani <sahir....@microsoft.com>
    Comment-In-Reply-To: Michael Tang <ta...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    chromeperf@appspot.gserviceaccount.com (Gerrit)

    unread,
    Nov 12, 2025, 7:33:23 PM (10 hours ago) Nov 12
    to Sahir Vellani, Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
    Attention needed from Michael Tang, Rafael Cintron and Sahir Vellani

    Message from chrom...@appspot.gserviceaccount.com

    😿 Job win-11-perf/motionmark1.3.1.crossbench failed.

    See results at: https://pinpoint-dot-chromeperf.appspot.com/job/13c92f68310000

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Michael Tang
    • Rafael Cintron
    • Sahir Vellani
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    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: I323c85586daa2687de59c97d0d27f4f0e443fb69
    Gerrit-Change-Number: 6733314
    Gerrit-PatchSet: 32
    Gerrit-Owner: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Reviewer: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Reviewer: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-CC: Michael Tang <ta...@microsoft.com>
    Gerrit-Attention: Sahir Vellani <sahir....@microsoft.com>
    Gerrit-Attention: Rafael Cintron <rafael....@microsoft.com>
    Gerrit-Attention: Michael Tang <ta...@microsoft.com>
    Gerrit-Comment-Date: Thu, 13 Nov 2025 00:33:13 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    chromeperf@appspot.gserviceaccount.com (Gerrit)

    unread,
    Nov 12, 2025, 7:49:42 PM (10 hours ago) Nov 12
    to Sahir Vellani, Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
    Attention needed from Michael Tang, Rafael Cintron and Sahir Vellani

    Message from chrom...@appspot.gserviceaccount.com

    📍 Job win-11-perf/motionmark1.3.1.crossbench complete.

    See results at: https://pinpoint-dot-chromeperf.appspot.com/job/11bff6b0310000

    Gerrit-Comment-Date: Thu, 13 Nov 2025 00:49:32 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    chromeperf@appspot.gserviceaccount.com (Gerrit)

    unread,
    Nov 12, 2025, 8:54:36 PM (9 hours ago) Nov 12
    to Sahir Vellani, Chromium LUCI CQ, Michael Tang, AyeAye, Rafael Cintron, chromium...@chromium.org, feature-me...@chromium.org, media-cro...@chromium.org, chromeos-gfx-...@google.com, media-wi...@chromium.org, cc-...@chromium.org, penghu...@chromium.org
    Attention needed from Michael Tang, Rafael Cintron and Sahir Vellani

    Message from chrom...@appspot.gserviceaccount.com

    😿 Job win-11-perf/rendering.desktop failed.

    See results at: https://pinpoint-dot-chromeperf.appspot.com/job/105e32dfd10000

    Gerrit-Comment-Date: Thu, 13 Nov 2025 01:54:25 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages