Commit 90cc64e6 authored by Sunny Sachanandani's avatar Sunny Sachanandani Committed by Commit Bot

Revert "Use shared images with DX11 video decoder"

This reverts commit 9d22b694.

Reason for revert: Broke non-overlay video playback: crbug.com/1119666

Original change's description:
> Use shared images with DX11 video decoder
>
> This change enables support for SkiaRenderer. In a future change,
> GLRenderer will also be supported.
>
> Change-Id: I760013fdd163dcec3e3fe5d888541f07849749c7
> Bug: 1011555
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250890
> Auto-Submit: Bryan Bernhart <bryan.bernhart@intel.com>
> Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
> Reviewed-by: Frank Liberato <liberato@chromium.org>
> Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#794763}

TBR=sunnyps@chromium.org,liberato@chromium.org,bryan.bernhart@intel.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1011555, 1119666, 1120094
Change-Id: Ie5fb291ea7093d3d695433181583302a36ecd88d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368240Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800420}
parent e4c22ace
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "gpu/command_buffer/service/gl_utils.h" #include "gpu/command_buffer/service/gl_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_context_state.h"
#include "gpu/command_buffer/service/shared_image_factory.h"
#include "gpu/command_buffer/service/texture_base.h" #include "gpu/command_buffer/service/texture_base.h"
#include "gpu/command_buffer/service/texture_manager.h" #include "gpu/command_buffer/service/texture_manager.h"
#include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/core/SkSurface.h"
...@@ -35,7 +34,6 @@ namespace viz { ...@@ -35,7 +34,6 @@ namespace viz {
SkiaOutputDeviceGL::SkiaOutputDeviceGL( SkiaOutputDeviceGL::SkiaOutputDeviceGL(
gpu::MailboxManager* mailbox_manager, gpu::MailboxManager* mailbox_manager,
gpu::SharedImageRepresentationFactory* representation_factory,
gpu::SharedContextState* context_state, gpu::SharedContextState* context_state,
scoped_refptr<gl::GLSurface> gl_surface, scoped_refptr<gl::GLSurface> gl_surface,
scoped_refptr<gpu::gles2::FeatureInfo> feature_info, scoped_refptr<gpu::gles2::FeatureInfo> feature_info,
...@@ -45,7 +43,6 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL( ...@@ -45,7 +43,6 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
memory_tracker, memory_tracker,
std::move(did_swap_buffer_complete_callback)), std::move(did_swap_buffer_complete_callback)),
mailbox_manager_(mailbox_manager), mailbox_manager_(mailbox_manager),
representation_factory_(representation_factory),
context_state_(context_state), context_state_(context_state),
gl_surface_(std::move(gl_surface)), gl_surface_(std::move(gl_surface)),
supports_async_swap_(gl_surface_->SupportsAsyncSwap()) { supports_async_swap_(gl_surface_->SupportsAsyncSwap()) {
...@@ -343,26 +340,11 @@ void SkiaOutputDeviceGL::EndPaint() {} ...@@ -343,26 +340,11 @@ void SkiaOutputDeviceGL::EndPaint() {}
scoped_refptr<gl::GLImage> SkiaOutputDeviceGL::GetGLImageForMailbox( scoped_refptr<gl::GLImage> SkiaOutputDeviceGL::GetGLImageForMailbox(
const gpu::Mailbox& mailbox) { const gpu::Mailbox& mailbox) {
// TODO(crbug.com/1005306): Remove ConsumeTexture here once // TODO(crbug.com/1005306): Use SharedImageManager to get textures here once
// all clients are using SharedImageInterface to create textures. // all clients are using SharedImageInterface to create textures.
// For example, the legacy mailbox still uses GL textures (no overlay)
// and is still used.
auto* texture_base = mailbox_manager_->ConsumeTexture(mailbox); auto* texture_base = mailbox_manager_->ConsumeTexture(mailbox);
if (!texture_base) { if (!texture_base)
auto overlay = representation_factory_->ProduceOverlay(mailbox); return nullptr;
if (!overlay)
return nullptr;
// Return GLImage since the ScopedReadAccess isn't being held by anyone.
// TODO(crbug.com/1011555): Have SkiaOutputSurfaceImplOnGpu hold on to the
// ScopedReadAccess for overlays like it does for PromiseImage based
// resources.
std::unique_ptr<gpu::SharedImageRepresentationOverlay::ScopedReadAccess>
scoped_overlay_read_access =
overlay->BeginScopedReadAccess(/*need_gl_image=*/true);
DCHECK(scoped_overlay_read_access);
return scoped_overlay_read_access->gl_image();
}
if (texture_base->GetType() == gpu::TextureBase::Type::kPassthrough) { if (texture_base->GetType() == gpu::TextureBase::Type::kPassthrough) {
gpu::gles2::TexturePassthrough* texture = gpu::gles2::TexturePassthrough* texture =
......
...@@ -22,7 +22,6 @@ class GLSurface; ...@@ -22,7 +22,6 @@ class GLSurface;
namespace gpu { namespace gpu {
class MailboxManager; class MailboxManager;
class SharedContextState; class SharedContextState;
class SharedImageRepresentationFactory;
namespace gles2 { namespace gles2 {
class FeatureInfo; class FeatureInfo;
...@@ -35,7 +34,6 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice { ...@@ -35,7 +34,6 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
public: public:
SkiaOutputDeviceGL( SkiaOutputDeviceGL(
gpu::MailboxManager* mailbox_manager, gpu::MailboxManager* mailbox_manager,
gpu::SharedImageRepresentationFactory* representation_factory,
gpu::SharedContextState* context_state, gpu::SharedContextState* context_state,
scoped_refptr<gl::GLSurface> gl_surface, scoped_refptr<gl::GLSurface> gl_surface,
scoped_refptr<gpu::gles2::FeatureInfo> feature_info, scoped_refptr<gpu::gles2::FeatureInfo> feature_info,
...@@ -76,7 +74,6 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice { ...@@ -76,7 +74,6 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
scoped_refptr<gl::GLImage> GetGLImageForMailbox(const gpu::Mailbox& mailbox); scoped_refptr<gl::GLImage> GetGLImageForMailbox(const gpu::Mailbox& mailbox);
gpu::MailboxManager* const mailbox_manager_; gpu::MailboxManager* const mailbox_manager_;
gpu::SharedImageRepresentationFactory* const representation_factory_;
gpu::SharedContextState* const context_state_; gpu::SharedContextState* const context_state_;
scoped_refptr<gl::GLSurface> gl_surface_; scoped_refptr<gl::GLSurface> gl_surface_;
......
...@@ -1077,8 +1077,7 @@ bool SkiaOutputSurfaceImplOnGpu::InitializeForGL() { ...@@ -1077,8 +1077,7 @@ bool SkiaOutputSurfaceImplOnGpu::InitializeForGL() {
GetDidSwapBuffersCompleteCallback()); GetDidSwapBuffersCompleteCallback());
} else { } else {
output_device_ = std::make_unique<SkiaOutputDeviceGL>( output_device_ = std::make_unique<SkiaOutputDeviceGL>(
dependency_->GetMailboxManager(), dependency_->GetMailboxManager(), context_state_.get(),
shared_image_representation_factory_.get(), context_state_.get(),
gl_surface_, feature_info_, memory_tracker_, gl_surface_, feature_info_, memory_tracker_,
GetDidSwapBuffersCompleteCallback()); GetDidSwapBuffersCompleteCallback());
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/trace_event/memory_dump_manager.h" #include "base/trace_event/memory_dump_manager.h"
#include "components/viz/common/resources/resource_format_utils.h" #include "components/viz/common/resources/resource_format_utils.h"
#include "components/viz/common/resources/resource_sizes.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/shared_image_representation_d3d.h" #include "gpu/command_buffer/service/shared_image_representation_d3d.h"
#include "gpu/command_buffer/service/shared_image_representation_skia_gl.h" #include "gpu/command_buffer/service/shared_image_representation_skia_gl.h"
...@@ -46,7 +45,7 @@ SharedImageBackingD3D::SharedImageBackingD3D( ...@@ -46,7 +45,7 @@ SharedImageBackingD3D::SharedImageBackingD3D(
uint32_t usage, uint32_t usage,
Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain, Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain,
scoped_refptr<gles2::TexturePassthrough> texture, scoped_refptr<gles2::TexturePassthrough> texture,
scoped_refptr<gl::GLImage> image, scoped_refptr<gl::GLImageD3D> image,
size_t buffer_index, size_t buffer_index,
Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture, Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture,
base::win::ScopedHandle shared_handle, base::win::ScopedHandle shared_handle,
...@@ -67,6 +66,7 @@ SharedImageBackingD3D::SharedImageBackingD3D( ...@@ -67,6 +66,7 @@ SharedImageBackingD3D::SharedImageBackingD3D(
d3d11_texture_(std::move(d3d11_texture)), d3d11_texture_(std::move(d3d11_texture)),
shared_handle_(std::move(shared_handle)), shared_handle_(std::move(shared_handle)),
dxgi_keyed_mutex_(std::move(dxgi_keyed_mutex)) { dxgi_keyed_mutex_(std::move(dxgi_keyed_mutex)) {
DCHECK(d3d11_texture_);
DCHECK(texture_); DCHECK(texture_);
} }
...@@ -171,10 +171,6 @@ HANDLE SharedImageBackingD3D::GetSharedHandle() const { ...@@ -171,10 +171,6 @@ HANDLE SharedImageBackingD3D::GetSharedHandle() const {
return shared_handle_.Get(); return shared_handle_.Get();
} }
gl::GLImage* SharedImageBackingD3D::GetGLImage() const {
return image_.get();
}
bool SharedImageBackingD3D::PresentSwapChain() { bool SharedImageBackingD3D::PresentSwapChain() {
TRACE_EVENT0("gpu", "SharedImageBackingD3D::PresentSwapChain"); TRACE_EVENT0("gpu", "SharedImageBackingD3D::PresentSwapChain");
if (buffer_index_ != 0) { if (buffer_index_ != 0) {
...@@ -199,7 +195,7 @@ bool SharedImageBackingD3D::PresentSwapChain() { ...@@ -199,7 +195,7 @@ bool SharedImageBackingD3D::PresentSwapChain() {
api->glBindTextureFn(GL_TEXTURE_2D, texture_->service_id()); api->glBindTextureFn(GL_TEXTURE_2D, texture_->service_id());
if (!image_->BindTexImage(GL_TEXTURE_2D)) { if (!image_->BindTexImage(GL_TEXTURE_2D)) {
DLOG(ERROR) << "GLImage::BindTexImage failed"; DLOG(ERROR) << "GLImageD3D::BindTexImage failed";
return false; return false;
} }
...@@ -227,12 +223,4 @@ SharedImageBackingD3D::ProduceSkia( ...@@ -227,12 +223,4 @@ SharedImageBackingD3D::ProduceSkia(
manager, this, tracker); manager, this, tracker);
} }
std::unique_ptr<SharedImageRepresentationOverlay>
SharedImageBackingD3D::ProduceOverlay(SharedImageManager* manager,
MemoryTypeTracker* tracker) {
TRACE_EVENT0("gpu", "SharedImageBackingD3D::ProduceOverlay");
return std::make_unique<SharedImageRepresentationOverlayD3D>(manager, this,
tracker);
}
} // namespace gpu } // namespace gpu
...@@ -32,8 +32,7 @@ struct Mailbox; ...@@ -32,8 +32,7 @@ struct Mailbox;
// Implementation of SharedImageBacking that holds buffer (front buffer/back // Implementation of SharedImageBacking that holds buffer (front buffer/back
// buffer of swap chain) texture (as gles2::Texture/gles2::TexturePassthrough) // buffer of swap chain) texture (as gles2::Texture/gles2::TexturePassthrough)
// and a reference to created swap chain. // and a reference to created swap chain.
class GPU_GLES2_EXPORT SharedImageBackingD3D class SharedImageBackingD3D : public ClearTrackingSharedImageBacking {
: public ClearTrackingSharedImageBacking {
public: public:
SharedImageBackingD3D( SharedImageBackingD3D(
const Mailbox& mailbox, const Mailbox& mailbox,
...@@ -45,7 +44,7 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D ...@@ -45,7 +44,7 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D
uint32_t usage, uint32_t usage,
Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain, Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain,
scoped_refptr<gles2::TexturePassthrough> texture, scoped_refptr<gles2::TexturePassthrough> texture,
scoped_refptr<gl::GLImage> image, scoped_refptr<gl::GLImageD3D> image,
size_t buffer_index, size_t buffer_index,
Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture, Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture,
base::win::ScopedHandle shared_handle, base::win::ScopedHandle shared_handle,
...@@ -74,7 +73,6 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D ...@@ -74,7 +73,6 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D
void EndAccessD3D11(); void EndAccessD3D11();
HANDLE GetSharedHandle() const; HANDLE GetSharedHandle() const;
gl::GLImage* GetGLImage() const;
bool PresentSwapChain() override; bool PresentSwapChain() override;
...@@ -83,10 +81,6 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D ...@@ -83,10 +81,6 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D
ProduceGLTexturePassthrough(SharedImageManager* manager, ProduceGLTexturePassthrough(SharedImageManager* manager,
MemoryTypeTracker* tracker) override; MemoryTypeTracker* tracker) override;
std::unique_ptr<SharedImageRepresentationOverlay> ProduceOverlay(
SharedImageManager* manager,
MemoryTypeTracker* tracker) override;
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia( std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
SharedImageManager* manager, SharedImageManager* manager,
MemoryTypeTracker* tracker, MemoryTypeTracker* tracker,
...@@ -95,10 +89,8 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D ...@@ -95,10 +89,8 @@ class GPU_GLES2_EXPORT SharedImageBackingD3D
private: private:
Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain_; Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain_;
scoped_refptr<gles2::TexturePassthrough> texture_; scoped_refptr<gles2::TexturePassthrough> texture_;
scoped_refptr<gl::GLImage> image_; scoped_refptr<gl::GLImageD3D> image_;
const size_t buffer_index_; const size_t buffer_index_;
// Texture could be nullptr if an empty backing is needed for testing.
Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture_; Microsoft::WRL::ComPtr<ID3D11Texture2D> d3d11_texture_;
// If d3d11_texture_ has a keyed mutex, it will be stored in // If d3d11_texture_ has a keyed mutex, it will be stored in
......
...@@ -132,22 +132,4 @@ void SharedImageRepresentationDawnD3D::EndAccess() { ...@@ -132,22 +132,4 @@ void SharedImageRepresentationDawnD3D::EndAccess() {
} }
#endif // BUILDFLAG(USE_DAWN) #endif // BUILDFLAG(USE_DAWN)
SharedImageRepresentationOverlayD3D::SharedImageRepresentationOverlayD3D(
SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker)
: SharedImageRepresentationOverlay(manager, backing, tracker) {}
bool SharedImageRepresentationOverlayD3D::BeginReadAccess() {
// Note: only the DX11 video decoder uses this overlay and does not need to
// synchronize read access from different devices.
return true;
}
void SharedImageRepresentationOverlayD3D::EndReadAccess() {}
gl::GLImage* SharedImageRepresentationOverlayD3D::GetGLImage() {
return static_cast<SharedImageBackingD3D*>(backing())->GetGLImage();
}
} // namespace gpu } // namespace gpu
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
namespace gpu { namespace gpu {
class SharedImageBackingD3D;
// Representation of a SharedImageBackingD3D as a GL TexturePassthrough. // Representation of a SharedImageBackingD3D as a GL TexturePassthrough.
class SharedImageRepresentationGLTexturePassthroughD3D class SharedImageRepresentationGLTexturePassthroughD3D
: public SharedImageRepresentationGLTexturePassthrough { : public SharedImageRepresentationGLTexturePassthrough {
...@@ -67,21 +65,5 @@ class SharedImageRepresentationDawnD3D : public SharedImageRepresentationDawn { ...@@ -67,21 +65,5 @@ class SharedImageRepresentationDawnD3D : public SharedImageRepresentationDawn {
}; };
#endif // BUILDFLAG(USE_DAWN) #endif // BUILDFLAG(USE_DAWN)
// Representation of a SharedImageBackingD3D as an overlay.
class SharedImageRepresentationOverlayD3D
: public SharedImageRepresentationOverlay {
public:
SharedImageRepresentationOverlayD3D(SharedImageManager* manager,
SharedImageBacking* backing,
MemoryTypeTracker* tracker);
~SharedImageRepresentationOverlayD3D() override = default;
private:
bool BeginReadAccess() override;
void EndReadAccess() override;
gl::GLImage* GetGLImage() override;
};
} // namespace gpu } // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_REPRESENTATION_D3D_H_ #endif // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_REPRESENTATION_D3D_H_
...@@ -14,12 +14,9 @@ ...@@ -14,12 +14,9 @@
#include "gpu/command_buffer/common/scheduling_priority.h" #include "gpu/command_buffer/common/scheduling_priority.h"
#include "gpu/command_buffer/service/decoder_context.h" #include "gpu/command_buffer/service/decoder_context.h"
#include "gpu/command_buffer/service/scheduler.h" #include "gpu/command_buffer/service/scheduler.h"
#include "gpu/command_buffer/service/shared_image_backing.h"
#include "gpu/command_buffer/service/shared_image_representation.h"
#include "gpu/command_buffer/service/sync_point_manager.h" #include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/ipc/service/command_buffer_stub.h" #include "gpu/ipc/service/command_buffer_stub.h"
#include "gpu/ipc/service/gpu_channel.h" #include "gpu/ipc/service/gpu_channel.h"
#include "gpu/ipc/service/gpu_channel_manager.h"
#include "media/gpu/gles2_decoder_helper.h" #include "media/gpu/gles2_decoder_helper.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
...@@ -48,8 +45,6 @@ class CommandBufferHelperImpl ...@@ -48,8 +45,6 @@ class CommandBufferHelperImpl
#endif // defined(OS_MAC) #endif // defined(OS_MAC)
); );
decoder_helper_ = GLES2DecoderHelper::Create(stub_->decoder_context()); decoder_helper_ = GLES2DecoderHelper::Create(stub_->decoder_context());
tracker_ =
std::make_unique<gpu::MemoryTypeTracker>(stub_->GetMemoryTracker());
} }
gl::GLContext* GetGLContext() override { gl::GLContext* GetGLContext() override {
...@@ -82,24 +77,6 @@ class CommandBufferHelperImpl ...@@ -82,24 +77,6 @@ class CommandBufferHelperImpl
return decoder_helper_ && decoder_helper_->MakeContextCurrent(); return decoder_helper_ && decoder_helper_->MakeContextCurrent();
} }
std::unique_ptr<gpu::SharedImageRepresentationFactoryRef> Register(
std::unique_ptr<gpu::SharedImageBacking> backing) override {
DVLOG(2) << __func__;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return stub_->channel()
->gpu_channel_manager()
->shared_image_manager()
->Register(std::move(backing), tracker_.get());
}
gpu::TextureBase* GetTexture(GLuint service_id) const override {
DVLOG(2) << __func__ << "(" << service_id << ")";
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(stub_->decoder_context()->GetGLContext()->IsCurrent(nullptr));
DCHECK(textures_.count(service_id));
return textures_.at(service_id)->GetTextureBase();
}
GLuint CreateTexture(GLenum target, GLuint CreateTexture(GLenum target,
GLenum internal_format, GLenum internal_format,
GLsizei width, GLsizei width,
...@@ -240,8 +217,6 @@ class CommandBufferHelperImpl ...@@ -240,8 +217,6 @@ class CommandBufferHelperImpl
WillDestroyStubCB will_destroy_stub_cb_; WillDestroyStubCB will_destroy_stub_cb_;
std::unique_ptr<gpu::MemoryTypeTracker> tracker_;
THREAD_CHECKER(thread_checker_); THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(CommandBufferHelperImpl); DISALLOW_COPY_AND_ASSIGN(CommandBufferHelperImpl);
}; };
......
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
namespace gpu { namespace gpu {
class CommandBufferStub; class CommandBufferStub;
class SharedImageBacking;
class SharedImageRepresentationFactoryRef;
class SharedImageStub; class SharedImageStub;
class TextureBase;
} // namespace gpu } // namespace gpu
namespace gl { namespace gl {
...@@ -62,12 +59,6 @@ class MEDIA_GPU_EXPORT CommandBufferHelper ...@@ -62,12 +59,6 @@ class MEDIA_GPU_EXPORT CommandBufferHelper
// Makes the GL context current. // Makes the GL context current.
virtual bool MakeContextCurrent() = 0; virtual bool MakeContextCurrent() = 0;
// Register a shared image backing
virtual std::unique_ptr<gpu::SharedImageRepresentationFactoryRef> Register(
std::unique_ptr<gpu::SharedImageBacking> backing) = 0;
virtual gpu::TextureBase* GetTexture(GLuint service_id) const = 0;
// Creates a texture and returns its |service_id|. // Creates a texture and returns its |service_id|.
// //
// See glTexImage2D() for argument definitions. // See glTexImage2D() for argument definitions.
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "media/gpu/test/fake_command_buffer_helper.h" #include "media/gpu/test/fake_command_buffer_helper.h"
#include "gpu/command_buffer/service/shared_image_backing.h"
#include "gpu/command_buffer/service/shared_image_representation.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -81,21 +79,6 @@ bool FakeCommandBufferHelper::MakeContextCurrent() { ...@@ -81,21 +79,6 @@ bool FakeCommandBufferHelper::MakeContextCurrent() {
return is_context_current_; return is_context_current_;
} }
std::unique_ptr<gpu::SharedImageRepresentationFactoryRef>
FakeCommandBufferHelper::Register(
std::unique_ptr<gpu::SharedImageBacking> backing) {
DVLOG(2) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread());
return nullptr;
}
gpu::TextureBase* FakeCommandBufferHelper::GetTexture(GLuint service_id) const {
DVLOG(2) << __func__ << "(" << service_id << ")";
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(service_ids_.count(service_id));
return nullptr;
}
GLuint FakeCommandBufferHelper::CreateTexture(GLenum target, GLuint FakeCommandBufferHelper::CreateTexture(GLenum target,
GLenum internal_format, GLenum internal_format,
GLsizei width, GLsizei width,
......
...@@ -42,9 +42,6 @@ class FakeCommandBufferHelper : public CommandBufferHelper { ...@@ -42,9 +42,6 @@ class FakeCommandBufferHelper : public CommandBufferHelper {
gpu::SharedImageStub* GetSharedImageStub() override; gpu::SharedImageStub* GetSharedImageStub() override;
bool HasStub() override; bool HasStub() override;
bool MakeContextCurrent() override; bool MakeContextCurrent() override;
std::unique_ptr<gpu::SharedImageRepresentationFactoryRef> Register(
std::unique_ptr<gpu::SharedImageBacking> backing) override;
gpu::TextureBase* GetTexture(GLuint service_id) const override;
GLuint CreateTexture(GLenum target, GLuint CreateTexture(GLenum target,
GLenum internal_format, GLenum internal_format,
GLsizei width, GLsizei width,
......
...@@ -30,6 +30,8 @@ CopyingTexture2DWrapper::CopyingTexture2DWrapper( ...@@ -30,6 +30,8 @@ CopyingTexture2DWrapper::CopyingTexture2DWrapper(
CopyingTexture2DWrapper::~CopyingTexture2DWrapper() = default; CopyingTexture2DWrapper::~CopyingTexture2DWrapper() = default;
Status CopyingTexture2DWrapper::ProcessTexture( Status CopyingTexture2DWrapper::ProcessTexture(
ComD3D11Texture2D texture,
size_t array_slice,
const gfx::ColorSpace& input_color_space, const gfx::ColorSpace& input_color_space,
MailboxHolderArray* mailbox_dest, MailboxHolderArray* mailbox_dest,
gfx::ColorSpace* output_color_space) { gfx::ColorSpace* output_color_space) {
...@@ -46,11 +48,11 @@ Status CopyingTexture2DWrapper::ProcessTexture( ...@@ -46,11 +48,11 @@ Status CopyingTexture2DWrapper::ProcessTexture(
D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC input_view_desc = {0}; D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC input_view_desc = {0};
input_view_desc.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D; input_view_desc.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D;
input_view_desc.Texture2D.ArraySlice = array_slice_; input_view_desc.Texture2D.ArraySlice = array_slice;
input_view_desc.Texture2D.MipSlice = 0; input_view_desc.Texture2D.MipSlice = 0;
ComD3D11VideoProcessorInputView input_view; ComD3D11VideoProcessorInputView input_view;
hr = video_processor_->CreateVideoProcessorInputView( hr = video_processor_->CreateVideoProcessorInputView(
texture_.Get(), &input_view_desc, &input_view); texture.Get(), &input_view_desc, &input_view);
if (!SUCCEEDED(hr)) { if (!SUCCEEDED(hr)) {
return Status(StatusCode::kCreateVideoProcessorInputViewFailed) return Status(StatusCode::kCreateVideoProcessorInputViewFailed)
.AddCause(HresultToStatus(hr)); .AddCause(HresultToStatus(hr));
...@@ -83,27 +85,19 @@ Status CopyingTexture2DWrapper::ProcessTexture( ...@@ -83,27 +85,19 @@ Status CopyingTexture2DWrapper::ProcessTexture(
.AddCause(HresultToStatus(hr)); .AddCause(HresultToStatus(hr));
} }
return output_texture_wrapper_->ProcessTexture(copy_color_space, mailbox_dest, return output_texture_wrapper_->ProcessTexture(
output_color_space); output_texture_, 0, copy_color_space, mailbox_dest, output_color_space);
} }
Status CopyingTexture2DWrapper::Init( Status CopyingTexture2DWrapper::Init(
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner, scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
GetCommandBufferHelperCB get_helper_cb, GetCommandBufferHelperCB get_helper_cb) {
ComD3D11Texture2D texture,
size_t array_slice) {
auto result = video_processor_->Init(size_.width(), size_.height()); auto result = video_processor_->Init(size_.width(), size_.height());
if (!result.is_ok()) if (!result.is_ok())
return std::move(result).AddHere(); return std::move(result).AddHere();
// Remember the texture + array_slice so later, ProcessTexture can still use
// it.
texture_ = texture;
array_slice_ = array_slice;
return output_texture_wrapper_->Init(std::move(gpu_task_runner), return output_texture_wrapper_->Init(std::move(gpu_task_runner),
std::move(get_helper_cb), std::move(get_helper_cb));
output_texture_, /*array_slice=*/0);
} }
void CopyingTexture2DWrapper::SetStreamHDRMetadata( void CopyingTexture2DWrapper::SetStreamHDRMetadata(
......
...@@ -31,14 +31,14 @@ class MEDIA_GPU_EXPORT CopyingTexture2DWrapper : public Texture2DWrapper { ...@@ -31,14 +31,14 @@ class MEDIA_GPU_EXPORT CopyingTexture2DWrapper : public Texture2DWrapper {
base::Optional<gfx::ColorSpace> output_color_space); base::Optional<gfx::ColorSpace> output_color_space);
~CopyingTexture2DWrapper() override; ~CopyingTexture2DWrapper() override;
Status ProcessTexture(const gfx::ColorSpace& input_color_space, Status ProcessTexture(ComD3D11Texture2D texture,
size_t array_slice,
const gfx::ColorSpace& input_color_space,
MailboxHolderArray* mailbox_dest, MailboxHolderArray* mailbox_dest,
gfx::ColorSpace* output_color_space) override; gfx::ColorSpace* output_color_space) override;
Status Init(scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner, Status Init(scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
GetCommandBufferHelperCB get_helper_cb, GetCommandBufferHelperCB get_helper_cb) override;
ComD3D11Texture2D texture,
size_t array_slice) override;
void SetStreamHDRMetadata(const HDRMetadata& stream_metadata) override; void SetStreamHDRMetadata(const HDRMetadata& stream_metadata) override;
void SetDisplayHDRMetadata( void SetDisplayHDRMetadata(
...@@ -54,9 +54,6 @@ class MEDIA_GPU_EXPORT CopyingTexture2DWrapper : public Texture2DWrapper { ...@@ -54,9 +54,6 @@ class MEDIA_GPU_EXPORT CopyingTexture2DWrapper : public Texture2DWrapper {
// If set, this is the color space that we last saw in ProcessTexture. // If set, this is the color space that we last saw in ProcessTexture.
base::Optional<gfx::ColorSpace> previous_input_color_space_; base::Optional<gfx::ColorSpace> previous_input_color_space_;
ComD3D11Texture2D texture_;
size_t array_slice_ = 0;
}; };
} // namespace media } // namespace media
......
...@@ -86,7 +86,9 @@ class MockTexture2DWrapper : public Texture2DWrapper { ...@@ -86,7 +86,9 @@ class MockTexture2DWrapper : public Texture2DWrapper {
public: public:
MockTexture2DWrapper() {} MockTexture2DWrapper() {}
Status ProcessTexture(const gfx::ColorSpace& input_color_space, Status ProcessTexture(ComD3D11Texture2D texture,
size_t array_slice,
const gfx::ColorSpace& input_color_space,
MailboxHolderArray* mailbox_dest, MailboxHolderArray* mailbox_dest,
gfx::ColorSpace* output_color_space) override { gfx::ColorSpace* output_color_space) override {
// Pretend we created an arbitrary color space, so that we're sure that it // Pretend we created an arbitrary color space, so that we're sure that it
...@@ -96,9 +98,7 @@ class MockTexture2DWrapper : public Texture2DWrapper { ...@@ -96,9 +98,7 @@ class MockTexture2DWrapper : public Texture2DWrapper {
} }
Status Init(scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner, Status Init(scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
GetCommandBufferHelperCB get_helper_cb, GetCommandBufferHelperCB get_helper_cb) override {
ComD3D11Texture2D in_texture,
size_t array_slice) override {
gpu_task_runner_ = std::move(gpu_task_runner); gpu_task_runner_ = std::move(gpu_task_runner);
return MockInit(); return MockInit();
} }
...@@ -222,19 +222,16 @@ TEST_P(D3D11CopyingTexture2DWrapperTest, ...@@ -222,19 +222,16 @@ TEST_P(D3D11CopyingTexture2DWrapperTest,
MailboxHolderArray mailboxes; MailboxHolderArray mailboxes;
gfx::ColorSpace input_color_space = gfx::ColorSpace::CreateSCRGBLinear(); gfx::ColorSpace input_color_space = gfx::ColorSpace::CreateSCRGBLinear();
gfx::ColorSpace output_color_space; gfx::ColorSpace output_color_space;
EXPECT_EQ(wrapper EXPECT_EQ(wrapper->Init(gpu_task_runner_, CreateMockHelperCB()).is_ok(),
->Init(gpu_task_runner_, CreateMockHelperCB(),
/*texture_d3d=*/nullptr, /*array_slice=*/0)
.is_ok(),
InitSucceeds()); InitSucceeds());
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
if (GetProcessorProxyInit()) if (GetProcessorProxyInit())
EXPECT_EQ(texture_wrapper_raw->gpu_task_runner_, gpu_task_runner_); EXPECT_EQ(texture_wrapper_raw->gpu_task_runner_, gpu_task_runner_);
EXPECT_EQ( EXPECT_EQ(wrapper
wrapper ->ProcessTexture(nullptr, 0, input_color_space, &mailboxes,
->ProcessTexture(input_color_space, &mailboxes, &output_color_space) &output_color_space)
.is_ok(), .is_ok(),
ProcessTextureSucceeds()); ProcessTextureSucceeds());
if (ProcessTextureSucceeds()) { if (ProcessTextureSucceeds()) {
// Regardless of what the input space is, the output should be provided by // Regardless of what the input space is, the output should be provided by
......
...@@ -52,9 +52,8 @@ Status D3D11PictureBuffer::Init( ...@@ -52,9 +52,8 @@ Status D3D11PictureBuffer::Init(
view_desc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D; view_desc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
view_desc.Texture2D.ArraySlice = array_slice_; view_desc.Texture2D.ArraySlice = array_slice_;
Status result = Status result = texture_wrapper_->Init(std::move(gpu_task_runner),
texture_wrapper_->Init(std::move(gpu_task_runner), std::move(get_helper_cb));
std::move(get_helper_cb), texture_, array_slice_);
if (!result.is_ok()) { if (!result.is_ok()) {
MEDIA_LOG(ERROR, media_log) << "Failed to Initialize the wrapper"; MEDIA_LOG(ERROR, media_log) << "Failed to Initialize the wrapper";
return result; return result;
...@@ -76,7 +75,8 @@ Status D3D11PictureBuffer::ProcessTexture( ...@@ -76,7 +75,8 @@ Status D3D11PictureBuffer::ProcessTexture(
const gfx::ColorSpace& input_color_space, const gfx::ColorSpace& input_color_space,
MailboxHolderArray* mailbox_dest, MailboxHolderArray* mailbox_dest,
gfx::ColorSpace* output_color_space) { gfx::ColorSpace* output_color_space) {
return texture_wrapper_->ProcessTexture(input_color_space, mailbox_dest, return texture_wrapper_->ProcessTexture(Texture(), array_slice_,
input_color_space, mailbox_dest,
output_color_space); output_color_space);
} }
......
This diff is collapsed.
...@@ -47,13 +47,13 @@ class MEDIA_GPU_EXPORT Texture2DWrapper { ...@@ -47,13 +47,13 @@ class MEDIA_GPU_EXPORT Texture2DWrapper {
// Initialize the wrapper. // Initialize the wrapper.
virtual Status Init( virtual Status Init(
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner, scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
GetCommandBufferHelperCB get_helper_cb, GetCommandBufferHelperCB get_helper_cb) = 0;
ComD3D11Texture2D texture,
size_t array_size) = 0;
// Import |texture|, |array_slice| and return the mailbox(es) that can be // Import |texture|, |array_slice| and return the mailbox(es) that can be
// used to refer to it. // used to refer to it.
virtual Status ProcessTexture(const gfx::ColorSpace& input_color_space, virtual Status ProcessTexture(ComD3D11Texture2D texture,
size_t array_slice,
const gfx::ColorSpace& input_color_space,
MailboxHolderArray* mailbox_dest_out, MailboxHolderArray* mailbox_dest_out,
gfx::ColorSpace* output_color_space) = 0; gfx::ColorSpace* output_color_space) = 0;
...@@ -77,11 +77,11 @@ class MEDIA_GPU_EXPORT DefaultTexture2DWrapper : public Texture2DWrapper { ...@@ -77,11 +77,11 @@ class MEDIA_GPU_EXPORT DefaultTexture2DWrapper : public Texture2DWrapper {
~DefaultTexture2DWrapper() override; ~DefaultTexture2DWrapper() override;
Status Init(scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner, Status Init(scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner,
GetCommandBufferHelperCB get_helper_cb, GetCommandBufferHelperCB get_helper_cb) override;
ComD3D11Texture2D in_texture,
size_t array_slice) override;
Status ProcessTexture(const gfx::ColorSpace& input_color_space, Status ProcessTexture(ComD3D11Texture2D texture,
size_t array_slice,
const gfx::ColorSpace& input_color_space,
MailboxHolderArray* mailbox_dest, MailboxHolderArray* mailbox_dest,
gfx::ColorSpace* output_color_space) override; gfx::ColorSpace* output_color_space) override;
...@@ -103,18 +103,14 @@ class MEDIA_GPU_EXPORT DefaultTexture2DWrapper : public Texture2DWrapper { ...@@ -103,18 +103,14 @@ class MEDIA_GPU_EXPORT DefaultTexture2DWrapper : public Texture2DWrapper {
const std::vector<gpu::Mailbox> mailboxes, const std::vector<gpu::Mailbox> mailboxes,
GLenum target, GLenum target,
gfx::Size size, gfx::Size size,
int textures_per_picture, int textures_per_picture);
viz::ResourceFormat format,
ComD3D11Texture2D texture, // Push a new |texture|, |array_slice| to |gl_image_|.
size_t array_slice); void PushNewTexture(ComD3D11Texture2D texture, size_t array_slice);
std::vector<uint32_t> service_ids_; std::vector<uint32_t> service_ids_;
private: private:
// Push a new |texture|, |array_slice| to |gl_image_|.
// Both |texture| and |array_slice| were set by Init.
void PushNewTexture();
// Notify our wrapper about |status|, if we haven't before. // Notify our wrapper about |status|, if we haven't before.
void NotifyError(Status status); void NotifyError(Status status);
...@@ -125,9 +121,6 @@ class MEDIA_GPU_EXPORT DefaultTexture2DWrapper : public Texture2DWrapper { ...@@ -125,9 +121,6 @@ class MEDIA_GPU_EXPORT DefaultTexture2DWrapper : public Texture2DWrapper {
scoped_refptr<gl::GLImageDXGI> gl_image_; scoped_refptr<gl::GLImageDXGI> gl_image_;
EGLStreamKHR stream_; EGLStreamKHR stream_;
std::vector<std::unique_ptr<gpu::SharedImageRepresentationFactoryRef>>
shared_images_;
DISALLOW_COPY_AND_ASSIGN(GpuResources); DISALLOW_COPY_AND_ASSIGN(GpuResources);
}; };
......
...@@ -90,8 +90,7 @@ TEST_F(D3D11TextureWrapperUnittest, NV12InitSucceeds) { ...@@ -90,8 +90,7 @@ TEST_F(D3D11TextureWrapperUnittest, NV12InitSucceeds) {
const DXGI_FORMAT dxgi_format = DXGI_FORMAT_NV12; const DXGI_FORMAT dxgi_format = DXGI_FORMAT_NV12;
auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format); auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format);
const Status init_result = wrapper->Init( const Status init_result = wrapper->Init(task_runner_, get_helper_cb_);
task_runner_, get_helper_cb_, /*texture_d3d=*/nullptr, /*array_slice=*/0);
EXPECT_TRUE(init_result.is_ok()); EXPECT_TRUE(init_result.is_ok());
// TODO: verify that ProcessTexture processes both textures. // TODO: verify that ProcessTexture processes both textures.
...@@ -102,8 +101,7 @@ TEST_F(D3D11TextureWrapperUnittest, BGRA8InitSucceeds) { ...@@ -102,8 +101,7 @@ TEST_F(D3D11TextureWrapperUnittest, BGRA8InitSucceeds) {
const DXGI_FORMAT dxgi_format = DXGI_FORMAT_B8G8R8A8_UNORM; const DXGI_FORMAT dxgi_format = DXGI_FORMAT_B8G8R8A8_UNORM;
auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format); auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format);
const Status init_result = wrapper->Init( const Status init_result = wrapper->Init(task_runner_, get_helper_cb_);
task_runner_, get_helper_cb_, /*texture_d3d=*/nullptr, /*array_slice=*/0);
EXPECT_TRUE(init_result.is_ok()); EXPECT_TRUE(init_result.is_ok());
} }
...@@ -112,8 +110,7 @@ TEST_F(D3D11TextureWrapperUnittest, FP16InitSucceeds) { ...@@ -112,8 +110,7 @@ TEST_F(D3D11TextureWrapperUnittest, FP16InitSucceeds) {
const DXGI_FORMAT dxgi_format = DXGI_FORMAT_R16G16B16A16_FLOAT; const DXGI_FORMAT dxgi_format = DXGI_FORMAT_R16G16B16A16_FLOAT;
auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format); auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format);
const Status init_result = wrapper->Init( const Status init_result = wrapper->Init(task_runner_, get_helper_cb_);
task_runner_, get_helper_cb_, /*texture_d3d=*/nullptr, /*array_slice=*/0);
EXPECT_TRUE(init_result.is_ok()); EXPECT_TRUE(init_result.is_ok());
} }
...@@ -122,19 +119,8 @@ TEST_F(D3D11TextureWrapperUnittest, P010InitSucceeds) { ...@@ -122,19 +119,8 @@ TEST_F(D3D11TextureWrapperUnittest, P010InitSucceeds) {
const DXGI_FORMAT dxgi_format = DXGI_FORMAT_P010; const DXGI_FORMAT dxgi_format = DXGI_FORMAT_P010;
auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format); auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format);
const Status init_result = wrapper->Init( const Status init_result = wrapper->Init(task_runner_, get_helper_cb_);
task_runner_, get_helper_cb_, /*texture_d3d=*/nullptr, /*array_slice=*/0);
EXPECT_TRUE(init_result.is_ok()); EXPECT_TRUE(init_result.is_ok());
} }
TEST_F(D3D11TextureWrapperUnittest, UnknownInitFails) {
STOP_IF_WIN7();
const DXGI_FORMAT dxgi_format = DXGI_FORMAT_UNKNOWN;
auto wrapper = std::make_unique<DefaultTexture2DWrapper>(size_, dxgi_format);
const Status init_result = wrapper->Init(
task_runner_, get_helper_cb_, /*texture_d3d=*/nullptr, /*array_slice=*/0);
EXPECT_FALSE(init_result.is_ok());
}
} // namespace media } // namespace media
\ No newline at end of file
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