0

Revert "Use DawnAHardwareBufferImageRepresentation for all dawn backends"

This reverts commit f5334a65d6.

Reason for revert: caused failures on Android (see https://crbug.com/381386757).

Original change's description:
> Use DawnAHardwareBufferImageRepresentation for all dawn backends
>
> Dawn now supports direct AHardwareBuffer import on all Android
> backends.
>
> Bug: 42241435
> Change-Id: I14e98bf78ba687294ad101e5401850ca4f175b74
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6019930
> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
> Commit-Queue: Geoff Lang <geofflang@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1388986}

Bug: 42241435, 381386757
Change-Id: I278ab553c8a40637c17b0d7bec6c1000bacf8595
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6054214
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Boris Sazonov <bsazonov@chromium.org>
Auto-Submit: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1389340}
This commit is contained in:
Boris Sazonov
2024-11-28 12:19:00 +00:00
committed by Chromium LUCI CQ
parent 20a953ec52
commit d95f6c3dbd
4 changed files with 29 additions and 23 deletions

@@ -39,6 +39,7 @@
#include "gpu/command_buffer/service/shared_context_state.h" #include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image/android_image_backing.h" #include "gpu/command_buffer/service/shared_image/android_image_backing.h"
#include "gpu/command_buffer/service/shared_image/dawn_ahardwarebuffer_image_representation.h" #include "gpu/command_buffer/service/shared_image/dawn_ahardwarebuffer_image_representation.h"
#include "gpu/command_buffer/service/shared_image/dawn_egl_image_representation.h"
#include "gpu/command_buffer/service/shared_image/gl_texture_android_image_representation.h" #include "gpu/command_buffer/service/shared_image/gl_texture_android_image_representation.h"
#include "gpu/command_buffer/service/shared_image/gl_texture_passthrough_android_image_representation.h" #include "gpu/command_buffer/service/shared_image/gl_texture_passthrough_android_image_representation.h"
#include "gpu/command_buffer/service/shared_image/shared_image_backing.h" #include "gpu/command_buffer/service/shared_image/shared_image_backing.h"
@@ -608,6 +609,26 @@ AHardwareBufferImageBacking::ProduceDawn(
// backing. // backing.
DCHECK(hardware_buffer_handle_.is_valid()); DCHECK(hardware_buffer_handle_.is_valid());
#if BUILDFLAG(USE_DAWN) && BUILDFLAG(DAWN_ENABLE_BACKEND_OPENGLES)
if (backend_type == wgpu::BackendType::OpenGLES) {
std::unique_ptr<GLTextureImageRepresentationBase> gl_representation;
if (use_passthrough_) {
gl_representation = ProduceGLTexturePassthrough(manager, tracker);
} else {
gl_representation = ProduceGLTexture(manager, tracker);
}
gl::ScopedEGLImage egl_image =
CreateEGLImageFromAHardwareBuffer(hardware_buffer_handle_.get());
auto result = std::make_unique<DawnEGLImageRepresentation>(
std::move(gl_representation), std::move(egl_image), manager, this,
tracker, device, std::move(view_formats));
return result;
}
#endif
DCHECK_EQ(backend_type, wgpu::BackendType::Vulkan);
wgpu::TextureFormat webgpu_format = ToDawnFormat(format()); wgpu::TextureFormat webgpu_format = ToDawnFormat(format());
if (webgpu_format == wgpu::TextureFormat::Undefined) { if (webgpu_format == wgpu::TextureFormat::Undefined) {
LOG(ERROR) << "Unable to fine a suitable WebGPU format."; LOG(ERROR) << "Unable to fine a suitable WebGPU format.";
@@ -615,7 +636,7 @@ AHardwareBufferImageBacking::ProduceDawn(
} }
return std::make_unique<DawnAHardwareBufferImageRepresentation>( return std::make_unique<DawnAHardwareBufferImageRepresentation>(
manager, this, tracker, wgpu::Device(device), backend_type, webgpu_format, manager, this, tracker, wgpu::Device(device), webgpu_format,
std::move(view_formats), hardware_buffer_handle_.get()); std::move(view_formats), hardware_buffer_handle_.get());
#else #else
return nullptr; return nullptr;

@@ -253,18 +253,11 @@ TEST_P(AHardwareBufferImageBackingFactoryTest, ProduceDawnOpenGLES) {
wgpu::DeviceDescriptor device_descriptor; wgpu::DeviceDescriptor device_descriptor;
constexpr wgpu::FeatureName kOptionalFeatures[] = { // We need to request internal usage to be able to do operations with
// We need to request internal usage to be able to do operations with // internal methods that would need specific usages.
// internal methods that would need specific usages. wgpu::FeatureName dawn_internal_usage = wgpu::FeatureName::DawnInternalUsages;
wgpu::FeatureName::DawnInternalUsages, device_descriptor.requiredFeatureCount = 1;
device_descriptor.requiredFeatures = &dawn_internal_usage;
// AHardwareBuffers are imported directly into Dawn and SyncFDs are used
// to synchronize them.
wgpu::FeatureName::SharedTextureMemoryAHardwareBuffer,
wgpu::FeatureName::SharedFenceSyncFD,
};
device_descriptor.requiredFeatureCount = std::size(kOptionalFeatures);
device_descriptor.requiredFeatures = kOptionalFeatures;
wgpu::Device device = adapter.CreateDevice(&device_descriptor); wgpu::Device device = adapter.CreateDevice(&device_descriptor);

@@ -17,13 +17,11 @@ DawnAHardwareBufferImageRepresentation::DawnAHardwareBufferImageRepresentation(
AndroidImageBacking* backing, AndroidImageBacking* backing,
MemoryTypeTracker* tracker, MemoryTypeTracker* tracker,
wgpu::Device device, wgpu::Device device,
wgpu::BackendType backend_type,
wgpu::TextureFormat format, wgpu::TextureFormat format,
std::vector<wgpu::TextureFormat> view_formats, std::vector<wgpu::TextureFormat> view_formats,
AHardwareBuffer* buffer) AHardwareBuffer* buffer)
: DawnImageRepresentation(manager, backing, tracker), : DawnImageRepresentation(manager, backing, tracker),
device_(std::move(device)), device_(std::move(device)),
backend_type_(backend_type),
format_(format), format_(format),
view_formats_(std::move(view_formats)) { view_formats_(std::move(view_formats)) {
DCHECK(device_); DCHECK(device_);
@@ -83,9 +81,7 @@ wgpu::Texture DawnAHardwareBufferImageRepresentation::BeginAccess(
// TODO(crbug.com/327111284): Track layouts correctly. // TODO(crbug.com/327111284): Track layouts correctly.
begin_layout.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; begin_layout.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
begin_layout.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; begin_layout.newLayout = VK_IMAGE_LAYOUT_UNDEFINED;
if (backend_type_ == wgpu::BackendType::Vulkan) { begin_access_desc.nextInChain = &begin_layout;
begin_access_desc.nextInChain = &begin_layout;
}
wgpu::SharedFence shared_fence; wgpu::SharedFence shared_fence;
// Pass 1 as the signaled value for the binary semaphore // Pass 1 as the signaled value for the binary semaphore
@@ -162,9 +158,7 @@ void DawnAHardwareBufferImageRepresentation::EndAccess() {
wgpu::SharedTextureMemoryEndAccessState end_access_desc = {}; wgpu::SharedTextureMemoryEndAccessState end_access_desc = {};
wgpu::SharedTextureMemoryVkImageLayoutEndState end_layout{}; wgpu::SharedTextureMemoryVkImageLayoutEndState end_layout{};
if (backend_type_ == wgpu::BackendType::Vulkan) { end_access_desc.nextInChain = &end_layout;
end_access_desc.nextInChain = &end_layout;
}
if (shared_texture_memory_.EndAccess(texture_, &end_access_desc) != if (shared_texture_memory_.EndAccess(texture_, &end_access_desc) !=
wgpu::Status::Success) { wgpu::Status::Success) {

@@ -23,7 +23,6 @@ class DawnAHardwareBufferImageRepresentation : public DawnImageRepresentation {
AndroidImageBacking* backing, AndroidImageBacking* backing,
MemoryTypeTracker* tracker, MemoryTypeTracker* tracker,
wgpu::Device device, wgpu::Device device,
wgpu::BackendType backend_type,
wgpu::TextureFormat format, wgpu::TextureFormat format,
std::vector<wgpu::TextureFormat> view_formats, std::vector<wgpu::TextureFormat> view_formats,
AHardwareBuffer* buffer); AHardwareBuffer* buffer);
@@ -41,7 +40,6 @@ class DawnAHardwareBufferImageRepresentation : public DawnImageRepresentation {
base::android::ScopedHardwareBufferHandle handle_; base::android::ScopedHardwareBufferHandle handle_;
wgpu::Texture texture_; wgpu::Texture texture_;
wgpu::Device device_; wgpu::Device device_;
wgpu::BackendType backend_type_;
wgpu::TextureFormat format_; wgpu::TextureFormat format_;
std::vector<wgpu::TextureFormat> view_formats_; std::vector<wgpu::TextureFormat> view_formats_;
// There is a SharedTextureMemory per representation with how this works // There is a SharedTextureMemory per representation with how this works