Commit c1b8c724 authored by Rafael Cintron's avatar Rafael Cintron Committed by Commit Bot

Reland "Enable WebGPU on Skia Renderer""

This relands 5c675fd9

CreateSharedImage is not supported in Windows Server 2008 so we need to adjust the
test skipping logic.

> Enable WebGPU on Skia Renderer
>
> Implement SharedImageBackingD3D::ProduceSkia and supporting methods.
>
> Bug: 1021118,1002316
> Change-Id: Ia699bddfa08469b9e151018eca6c5206620cb731
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1938707
> Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
> Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#720722}

Bug: 1021118,1002316
Change-Id: I09f6a9f5a89f23dd7a0f7e07b94f5cedbae4f613
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1947637Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#721856}
parent f960fffd
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
#include "components/viz/common/resources/resource_format_utils.h" #include "components/viz/common/resources/resource_format_utils.h"
#include "gpu/command_buffer/common/shared_image_trace_utils.h" #include "gpu/command_buffer/common/shared_image_trace_utils.h"
#include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/shared_context_state.h"
#include "gpu/command_buffer/service/shared_image_backing.h" #include "gpu/command_buffer/service/shared_image_backing.h"
#include "gpu/command_buffer/service/shared_image_manager.h" #include "gpu/command_buffer/service/shared_image_manager.h"
#include "gpu/command_buffer/service/shared_image_representation.h" #include "gpu/command_buffer/service/shared_image_representation.h"
#include "gpu/command_buffer/service/shared_image_representation_skia_gl.h"
#include "gpu/command_buffer/service/texture_manager.h" #include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gfx/buffer_format_util.h" #include "ui/gfx/buffer_format_util.h"
#include "ui/gl/buildflags.h" #include "ui/gl/buildflags.h"
...@@ -405,6 +407,15 @@ class SharedImageBackingD3D : public SharedImageBacking { ...@@ -405,6 +407,15 @@ class SharedImageBackingD3D : public SharedImageBacking {
manager, this, tracker, texture_passthrough_); manager, this, tracker, texture_passthrough_);
} }
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) override {
return SharedImageRepresentationSkiaGL::CreateForPassthrough(
ProduceGLTexturePassthrough(manager, tracker), std::move(context_state),
manager, this, tracker);
}
private: private:
Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain_; Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain_;
gles2::Texture* texture_ = nullptr; gles2::Texture* texture_ = nullptr;
......
...@@ -212,6 +212,8 @@ class GPU_GLES2_EXPORT SharedImageRepresentationGLTexturePassthrough ...@@ -212,6 +212,8 @@ class GPU_GLES2_EXPORT SharedImageRepresentationGLTexturePassthrough
GetTexturePassthrough() = 0; GetTexturePassthrough() = 0;
protected: protected:
friend class SharedImageRepresentationSkiaGL;
// TODO(ericrk): Make these pure virtual and ensure real implementations // TODO(ericrk): Make these pure virtual and ensure real implementations
// exist. // exist.
virtual bool BeginAccess(GLenum mode); virtual bool BeginAccess(GLenum mode);
......
...@@ -53,6 +53,31 @@ SharedImageRepresentationSkiaGL::Create( ...@@ -53,6 +53,31 @@ SharedImageRepresentationSkiaGL::Create(
std::move(context_state), manager, backing, tracker)); std::move(context_state), manager, backing, tracker));
} }
std::unique_ptr<SharedImageRepresentationSkiaGL>
SharedImageRepresentationSkiaGL::CreateForPassthrough(
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
passthrough_representation,
scoped_refptr<SharedContextState> context_state,
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker) {
GrBackendTexture backend_texture;
if (!GetGrBackendTexture(
context_state->feature_info(),
passthrough_representation->GetTexturePassthrough()->target(),
backing->size(),
passthrough_representation->GetTexturePassthrough()->service_id(),
backing->format(), &backend_texture)) {
return nullptr;
}
auto promise_texture = SkPromiseImageTexture::Make(backend_texture);
if (!promise_texture)
return nullptr;
return base::WrapUnique(new SharedImageRepresentationSkiaGL(
std::move(passthrough_representation), std::move(promise_texture),
std::move(context_state), manager, backing, tracker));
}
SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL( SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL(
std::unique_ptr<SharedImageRepresentationGLTexture> gl_representation, std::unique_ptr<SharedImageRepresentationGLTexture> gl_representation,
sk_sp<SkPromiseImageTexture> promise_texture, sk_sp<SkPromiseImageTexture> promise_texture,
...@@ -64,6 +89,25 @@ SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL( ...@@ -64,6 +89,25 @@ SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL(
gl_representation_(std::move(gl_representation)), gl_representation_(std::move(gl_representation)),
promise_texture_(std::move(promise_texture)), promise_texture_(std::move(promise_texture)),
context_state_(std::move(context_state)) { context_state_(std::move(context_state)) {
DCHECK(gl_representation_);
#if DCHECK_IS_ON()
context_ = gl::GLContext::GetCurrent();
#endif
}
SharedImageRepresentationSkiaGL::SharedImageRepresentationSkiaGL(
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
passthrough_representation,
sk_sp<SkPromiseImageTexture> promise_texture,
scoped_refptr<SharedContextState> context_state,
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker)
: SharedImageRepresentationSkia(manager, backing, tracker),
passthrough_representation_(std::move(passthrough_representation)),
promise_texture_(std::move(promise_texture)),
context_state_(std::move(context_state)) {
DCHECK(passthrough_representation_);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
context_ = gl::GLContext::GetCurrent(); context_ = gl::GLContext::GetCurrent();
#endif #endif
...@@ -83,9 +127,14 @@ sk_sp<SkSurface> SharedImageRepresentationSkiaGL::BeginWriteAccess( ...@@ -83,9 +127,14 @@ sk_sp<SkSurface> SharedImageRepresentationSkiaGL::BeginWriteAccess(
DCHECK(!surface_); DCHECK(!surface_);
CheckContext(); CheckContext();
if (!gl_representation_->BeginAccess( if (gl_representation_ &&
!gl_representation_->BeginAccess(
GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM)) { GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM)) {
return nullptr; return nullptr;
} else if (passthrough_representation_ &&
!passthrough_representation_->BeginAccess(
GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM)) {
return nullptr;
} }
SkColorType sk_color_type = viz::ResourceFormatToClosestSkColorType( SkColorType sk_color_type = viz::ResourceFormatToClosestSkColorType(
...@@ -105,7 +154,11 @@ void SharedImageRepresentationSkiaGL::EndWriteAccess(sk_sp<SkSurface> surface) { ...@@ -105,7 +154,11 @@ void SharedImageRepresentationSkiaGL::EndWriteAccess(sk_sp<SkSurface> surface) {
DCHECK_EQ(surface.get(), surface_); DCHECK_EQ(surface.get(), surface_);
DCHECK(surface->unique()); DCHECK(surface->unique());
gl_representation_->EndAccess(); if (gl_representation_) {
gl_representation_->EndAccess();
} else {
passthrough_representation_->EndAccess();
}
mode_ = RepresentationAccessMode::kNone; mode_ = RepresentationAccessMode::kNone;
surface_ = nullptr; surface_ = nullptr;
} }
...@@ -116,9 +169,14 @@ sk_sp<SkPromiseImageTexture> SharedImageRepresentationSkiaGL::BeginReadAccess( ...@@ -116,9 +169,14 @@ sk_sp<SkPromiseImageTexture> SharedImageRepresentationSkiaGL::BeginReadAccess(
DCHECK_EQ(mode_, RepresentationAccessMode::kNone); DCHECK_EQ(mode_, RepresentationAccessMode::kNone);
CheckContext(); CheckContext();
if (!gl_representation_->BeginAccess( if (gl_representation_ && !gl_representation_->BeginAccess(
GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM)) GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM)) {
return nullptr;
} else if (passthrough_representation_ &&
!passthrough_representation_->BeginAccess(
GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM)) {
return nullptr; return nullptr;
}
mode_ = RepresentationAccessMode::kRead; mode_ = RepresentationAccessMode::kRead;
return promise_texture_; return promise_texture_;
} }
...@@ -127,7 +185,11 @@ void SharedImageRepresentationSkiaGL::EndReadAccess() { ...@@ -127,7 +185,11 @@ void SharedImageRepresentationSkiaGL::EndReadAccess() {
DCHECK_EQ(mode_, RepresentationAccessMode::kRead); DCHECK_EQ(mode_, RepresentationAccessMode::kRead);
CheckContext(); CheckContext();
gl_representation_->EndAccess(); if (gl_representation_) {
gl_representation_->EndAccess();
} else {
passthrough_representation_->EndAccess();
}
mode_ = RepresentationAccessMode::kNone; mode_ = RepresentationAccessMode::kNone;
surface_ = nullptr; surface_ = nullptr;
} }
...@@ -138,4 +200,4 @@ void SharedImageRepresentationSkiaGL::CheckContext() { ...@@ -138,4 +200,4 @@ void SharedImageRepresentationSkiaGL::CheckContext() {
#endif #endif
} }
} // namespace gpu } // namespace gpu
\ No newline at end of file
...@@ -24,6 +24,13 @@ class GPU_GLES2_EXPORT SharedImageRepresentationSkiaGL ...@@ -24,6 +24,13 @@ class GPU_GLES2_EXPORT SharedImageRepresentationSkiaGL
SharedImageManager* manager, SharedImageManager* manager,
SharedImageBacking* backing, SharedImageBacking* backing,
MemoryTypeTracker* tracker); MemoryTypeTracker* tracker);
static std::unique_ptr<SharedImageRepresentationSkiaGL> CreateForPassthrough(
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
passthrough_representation,
scoped_refptr<SharedContextState> context_state,
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker);
~SharedImageRepresentationSkiaGL() override; ~SharedImageRepresentationSkiaGL() override;
...@@ -46,9 +53,20 @@ class GPU_GLES2_EXPORT SharedImageRepresentationSkiaGL ...@@ -46,9 +53,20 @@ class GPU_GLES2_EXPORT SharedImageRepresentationSkiaGL
SharedImageManager* manager, SharedImageManager* manager,
SharedImageBacking* backing, SharedImageBacking* backing,
MemoryTypeTracker* tracker); MemoryTypeTracker* tracker);
SharedImageRepresentationSkiaGL(
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
passthrough_representation,
sk_sp<SkPromiseImageTexture> promise_texture,
scoped_refptr<SharedContextState> context_state,
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker);
void CheckContext(); void CheckContext();
std::unique_ptr<SharedImageRepresentationGLTexture> gl_representation_; std::unique_ptr<SharedImageRepresentationGLTexture> gl_representation_;
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
passthrough_representation_;
sk_sp<SkPromiseImageTexture> promise_texture_; sk_sp<SkPromiseImageTexture> promise_texture_;
scoped_refptr<SharedContextState> context_state_; scoped_refptr<SharedContextState> context_state_;
SkSurface* surface_ = nullptr; SkSurface* surface_ = nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment