Remove OldSwapChain*

Bug: dawn:269
Change-Id: I5bc6f5f8b98a88c5d0bd69e0d2eaf1e4bbd12e2b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126422
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2023-04-05 10:13:01 +00:00 committed by Dawn LUCI CQ
parent 961f7eae70
commit 8a6ed63809
25 changed files with 35 additions and 555 deletions

View File

@ -631,8 +631,6 @@ source_set("sources") {
"opengl/SamplerGL.h", "opengl/SamplerGL.h",
"opengl/ShaderModuleGL.cpp", "opengl/ShaderModuleGL.cpp",
"opengl/ShaderModuleGL.h", "opengl/ShaderModuleGL.h",
"opengl/SwapChainGL.cpp",
"opengl/SwapChainGL.h",
"opengl/TextureGL.cpp", "opengl/TextureGL.cpp",
"opengl/TextureGL.h", "opengl/TextureGL.h",
"opengl/UtilsEGL.cpp", "opengl/UtilsEGL.cpp",

View File

@ -500,8 +500,6 @@ if (DAWN_ENABLE_OPENGL)
"opengl/SamplerGL.h" "opengl/SamplerGL.h"
"opengl/ShaderModuleGL.cpp" "opengl/ShaderModuleGL.cpp"
"opengl/ShaderModuleGL.h" "opengl/ShaderModuleGL.h"
"opengl/SwapChainGL.cpp"
"opengl/SwapChainGL.h"
"opengl/TextureGL.cpp" "opengl/TextureGL.cpp"
"opengl/TextureGL.h" "opengl/TextureGL.h"
"opengl/UtilsEGL.cpp" "opengl/UtilsEGL.cpp"

View File

@ -1746,12 +1746,6 @@ ResultOrError<Ref<SwapChainBase>> DeviceBase::CreateSwapChain(
descriptor); descriptor);
} }
// TODO(dawn:269): Remove this code path once implementation-based swapchains are removed.
if (surface == nullptr) {
return CreateSwapChainImpl(descriptor);
} else {
ASSERT(descriptor->implementation == 0);
NewSwapChainBase* previousSwapChain = surface->GetAttachedSwapChain(); NewSwapChainBase* previousSwapChain = surface->GetAttachedSwapChain();
ResultOrError<Ref<NewSwapChainBase>> maybeNewSwapChain = ResultOrError<Ref<NewSwapChainBase>> maybeNewSwapChain =
CreateSwapChainImpl(surface, previousSwapChain, descriptor); CreateSwapChainImpl(surface, previousSwapChain, descriptor);
@ -1767,7 +1761,6 @@ ResultOrError<Ref<SwapChainBase>> DeviceBase::CreateSwapChain(
surface->SetAttachedSwapChain(newSwapChain.Get()); surface->SetAttachedSwapChain(newSwapChain.Get());
return newSwapChain; return newSwapChain;
} }
}
ResultOrError<Ref<TextureBase>> DeviceBase::CreateTexture(const TextureDescriptor* descriptor) { ResultOrError<Ref<TextureBase>> DeviceBase::CreateTexture(const TextureDescriptor* descriptor) {
DAWN_TRY(ValidateIsAlive()); DAWN_TRY(ValidateIsAlive());

View File

@ -463,8 +463,6 @@ class DeviceBase : public RefCountedWithExternalCount {
const ShaderModuleDescriptor* descriptor, const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult, ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) = 0; OwnedCompilationMessages* compilationMessages) = 0;
virtual ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) = 0;
// Note that previousSwapChain may be nullptr, or come from a different backend. // Note that previousSwapChain may be nullptr, or come from a different backend.
virtual ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl( virtual ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
Surface* surface, Surface* surface,

View File

@ -53,19 +53,10 @@ class ErrorSwapChain final : public SwapChainBase {
MaybeError ValidateSwapChainDescriptor(const DeviceBase* device, MaybeError ValidateSwapChainDescriptor(const DeviceBase* device,
const Surface* surface, const Surface* surface,
const SwapChainDescriptor* descriptor) { const SwapChainDescriptor* descriptor) {
if (descriptor->implementation != 0) { DAWN_INVALID_IF(descriptor->implementation != 0,
DAWN_INVALID_IF(surface != nullptr, "Exactly one of surface or implementation must be set"); "Implementation-based swapchains are no longer supported.");
DawnSwapChainImplementation* impl = DAWN_INVALID_IF(surface == nullptr, "At least one of surface or implementation must be set");
reinterpret_cast<DawnSwapChainImplementation*>(descriptor->implementation);
DAWN_INVALID_IF(!impl->Init || !impl->Destroy || !impl->Configure ||
!impl->GetNextTexture || !impl->Present,
"Implementation is incomplete");
} else {
DAWN_INVALID_IF(surface == nullptr,
"At least one of surface or implementation must be set");
DAWN_INVALID_IF(surface->IsError(), "[Surface] is invalid."); DAWN_INVALID_IF(surface->IsError(), "[Surface] is invalid.");
DAWN_TRY(ValidatePresentMode(descriptor->presentMode)); DAWN_TRY(ValidatePresentMode(descriptor->presentMode));
@ -97,7 +88,6 @@ MaybeError ValidateSwapChainDescriptor(const DeviceBase* device,
"size (width: %u, height: %u).", "size (width: %u, height: %u).",
descriptor->width, descriptor->height, device->GetLimits().v1.maxTextureDimension2D, descriptor->width, descriptor->height, device->GetLimits().v1.maxTextureDimension2D,
device->GetLimits().v1.maxTextureDimension2D); device->GetLimits().v1.maxTextureDimension2D);
}
return {}; return {};
} }
@ -136,131 +126,6 @@ ObjectType SwapChainBase::GetType() const {
return ObjectType::SwapChain; return ObjectType::SwapChain;
} }
// OldSwapChainBase
OldSwapChainBase::OldSwapChainBase(DeviceBase* device, const SwapChainDescriptor* descriptor)
: SwapChainBase(device),
mImplementation(*reinterpret_cast<DawnSwapChainImplementation*>(descriptor->implementation)) {
}
OldSwapChainBase::~OldSwapChainBase() {
if (!IsError()) {
const auto& im = GetImplementation();
im.Destroy(im.userData);
}
}
void OldSwapChainBase::APIConfigure(wgpu::TextureFormat format,
wgpu::TextureUsage allowedUsage,
uint32_t width,
uint32_t height) {
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
return;
}
ASSERT(!IsError());
allowedUsage |= wgpu::TextureUsage::Present;
mFormat = format;
mAllowedUsage = allowedUsage;
mWidth = width;
mHeight = height;
mImplementation.Configure(mImplementation.userData, static_cast<WGPUTextureFormat>(format),
static_cast<WGPUTextureUsage>(allowedUsage), width, height);
}
TextureViewBase* OldSwapChainBase::APIGetCurrentTextureView() {
if (GetDevice()->ConsumedError(ValidateGetCurrentTextureView())) {
return TextureViewBase::MakeError(GetDevice());
}
ASSERT(!IsError());
// Return the same current texture view until Present is called.
if (mCurrentTextureView != nullptr) {
// Calling GetCurrentTextureView always returns a new reference so add it even when
// reuse the existing texture view.
mCurrentTextureView->Reference();
return mCurrentTextureView.Get();
}
// Create the backing texture and the view.
TextureDescriptor descriptor;
descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size.width = mWidth;
descriptor.size.height = mHeight;
descriptor.size.depthOrArrayLayers = 1;
descriptor.sampleCount = 1;
descriptor.format = mFormat;
descriptor.mipLevelCount = 1;
descriptor.usage = mAllowedUsage;
// Get the texture but remove the external refcount because it is never passed outside
// of dawn_native
mCurrentTexture = AcquireRef(GetNextTextureImpl(&descriptor));
mCurrentTextureView = mCurrentTexture->APICreateView();
return mCurrentTextureView.Get();
}
void OldSwapChainBase::APIPresent() {
if (GetDevice()->ConsumedError(ValidatePresent())) {
return;
}
ASSERT(!IsError());
if (GetDevice()->ConsumedError(OnBeforePresent(mCurrentTextureView.Get()))) {
return;
}
mImplementation.Present(mImplementation.userData);
mCurrentTexture = nullptr;
mCurrentTextureView = nullptr;
}
const DawnSwapChainImplementation& OldSwapChainBase::GetImplementation() {
ASSERT(!IsError());
return mImplementation;
}
MaybeError OldSwapChainBase::ValidateConfigure(wgpu::TextureFormat format,
wgpu::TextureUsage allowedUsage,
uint32_t width,
uint32_t height) const {
DAWN_TRY(GetDevice()->ValidateIsAlive());
DAWN_TRY(GetDevice()->ValidateObject(this));
DAWN_TRY(ValidateTextureUsage(allowedUsage));
DAWN_TRY(ValidateTextureFormat(format));
DAWN_INVALID_IF(width == 0 || height == 0,
"Configuration size (width: %u, height: %u) for %s is empty.", width, height,
this);
return {};
}
MaybeError OldSwapChainBase::ValidateGetCurrentTextureView() const {
DAWN_TRY(GetDevice()->ValidateIsAlive());
DAWN_TRY(GetDevice()->ValidateObject(this));
// If width is 0, it implies swap chain has never been configured
DAWN_INVALID_IF(mWidth == 0, "%s was not configured prior to calling GetNextTexture.", this);
return {};
}
MaybeError OldSwapChainBase::ValidatePresent() const {
DAWN_TRY(GetDevice()->ValidateIsAlive());
DAWN_TRY(GetDevice()->ValidateObject(this));
DAWN_INVALID_IF(
mCurrentTextureView == nullptr,
"GetCurrentTextureView was not called on %s this frame prior to calling Present.", this);
return {};
}
// Implementation of NewSwapChainBase // Implementation of NewSwapChainBase
NewSwapChainBase::NewSwapChainBase(DeviceBase* device, NewSwapChainBase::NewSwapChainBase(DeviceBase* device,

View File

@ -52,42 +52,6 @@ class SwapChainBase : public ApiObjectBase {
void DestroyImpl() override; void DestroyImpl() override;
}; };
// The base class for implementation-based SwapChains that are deprecated.
class OldSwapChainBase : public SwapChainBase {
public:
OldSwapChainBase(DeviceBase* device, const SwapChainDescriptor* descriptor);
// Dawn API
void APIConfigure(wgpu::TextureFormat format,
wgpu::TextureUsage allowedUsage,
uint32_t width,
uint32_t height) override;
TextureViewBase* APIGetCurrentTextureView() override;
void APIPresent() override;
protected:
~OldSwapChainBase() override;
const DawnSwapChainImplementation& GetImplementation();
virtual TextureBase* GetNextTextureImpl(const TextureDescriptor*) = 0;
virtual MaybeError OnBeforePresent(TextureViewBase* view) = 0;
private:
MaybeError ValidateConfigure(wgpu::TextureFormat format,
wgpu::TextureUsage allowedUsage,
uint32_t width,
uint32_t height) const;
MaybeError ValidateGetCurrentTextureView() const;
MaybeError ValidatePresent() const;
DawnSwapChainImplementation mImplementation = {};
wgpu::TextureFormat mFormat = {};
wgpu::TextureUsage mAllowedUsage;
uint32_t mWidth = 0;
uint32_t mHeight = 0;
Ref<TextureBase> mCurrentTexture;
Ref<TextureViewBase> mCurrentTextureView;
};
// The base class for surface-based SwapChains that aren't ready yet. // The base class for surface-based SwapChains that aren't ready yet.
class NewSwapChainBase : public SwapChainBase { class NewSwapChainBase : public SwapChainBase {
public: public:

View File

@ -440,10 +440,6 @@ ResultOrError<Ref<ShaderModuleBase>> Device::CreateShaderModuleImpl(
OwnedCompilationMessages* compilationMessages) { OwnedCompilationMessages* compilationMessages) {
return ShaderModule::Create(this, descriptor, parseResult, compilationMessages); return ShaderModule::Create(this, descriptor, parseResult, compilationMessages);
} }
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) {
return OldSwapChain::Create(this, descriptor);
}
ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -186,8 +186,6 @@ class Device final : public d3d::Device {
const ShaderModuleDescriptor* descriptor, const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult, ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) override; OwnedCompilationMessages* compilationMessages) override;
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) override;
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -74,64 +74,6 @@ DXGI_USAGE ToDXGIUsage(wgpu::TextureUsage usage) {
} // namespace } // namespace
// OldSwapChain
// static
Ref<OldSwapChain> OldSwapChain::Create(Device* device, const SwapChainDescriptor* descriptor) {
return AcquireRef(new OldSwapChain(device, descriptor));
}
OldSwapChain::OldSwapChain(Device* device, const SwapChainDescriptor* descriptor)
: OldSwapChainBase(device, descriptor) {
const auto& im = GetImplementation();
DawnWSIContextD3D12 wsiContext = {};
wsiContext.device = ToAPI(GetDevice());
im.Init(im.userData, &wsiContext);
ASSERT(im.textureUsage != WGPUTextureUsage_None);
mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
}
OldSwapChain::~OldSwapChain() = default;
TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
DeviceBase* device = GetDevice();
const auto& im = GetImplementation();
DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) {
device->HandleError(DAWN_INTERNAL_ERROR(error));
return nullptr;
}
ComPtr<ID3D12Resource> d3d12Texture = static_cast<ID3D12Resource*>(next.texture.ptr);
Ref<Texture> dawnTexture;
if (device->ConsumedError(
Texture::Create(ToBackend(GetDevice()), descriptor, std::move(d3d12Texture)),
&dawnTexture)) {
return nullptr;
}
return dawnTexture.Detach();
}
MaybeError OldSwapChain::OnBeforePresent(TextureViewBase* view) {
Device* device = ToBackend(GetDevice());
CommandRecordingContext* commandContext;
DAWN_TRY_ASSIGN(commandContext, device->GetPendingCommandContext());
// Perform the necessary transition for the texture to be presented.
ToBackend(view->GetTexture())
->TrackUsageAndTransitionNow(commandContext, mTextureUsage, view->GetSubresourceRange());
DAWN_TRY(device->ExecutePendingCommandContext());
return {};
}
// SwapChain
// static // static
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device, ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
Surface* surface, Surface* surface,

View File

@ -27,19 +27,6 @@ namespace dawn::native::d3d12 {
class Device; class Device;
class Texture; class Texture;
class OldSwapChain final : public OldSwapChainBase {
public:
static Ref<OldSwapChain> Create(Device* device, const SwapChainDescriptor* descriptor);
protected:
OldSwapChain(Device* device, const SwapChainDescriptor* descriptor);
~OldSwapChain() override;
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
MaybeError OnBeforePresent(TextureViewBase* view) override;
wgpu::TextureUsage mTextureUsage;
};
class SwapChain final : public NewSwapChainBase { class SwapChain final : public NewSwapChainBase {
public: public:
static ResultOrError<Ref<SwapChain>> Create(Device* device, static ResultOrError<Ref<SwapChain>> Create(Device* device,

View File

@ -111,8 +111,6 @@ class Device final : public DeviceBase {
const ShaderModuleDescriptor* descriptor, const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult, ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) override; OwnedCompilationMessages* compilationMessages) override;
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) override;
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -215,10 +215,6 @@ ResultOrError<Ref<ShaderModuleBase>> Device::CreateShaderModuleImpl(
OwnedCompilationMessages* compilationMessages) { OwnedCompilationMessages* compilationMessages) {
return ShaderModule::Create(this, descriptor, parseResult, compilationMessages); return ShaderModule::Create(this, descriptor, parseResult, compilationMessages);
} }
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) {
return OldSwapChain::Create(this, descriptor);
}
ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -27,17 +27,6 @@ namespace dawn::native::metal {
class Device; class Device;
class Texture; class Texture;
class OldSwapChain final : public OldSwapChainBase {
public:
static Ref<OldSwapChain> Create(Device* deivce, const SwapChainDescriptor* descriptor);
protected:
OldSwapChain(Device* device, const SwapChainDescriptor* descriptor);
~OldSwapChain() override;
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
MaybeError OnBeforePresent(TextureViewBase* view) override;
};
class SwapChain final : public NewSwapChainBase { class SwapChain final : public NewSwapChainBase {
public: public:
static ResultOrError<Ref<SwapChain>> Create(Device* device, static ResultOrError<Ref<SwapChain>> Create(Device* device,

View File

@ -24,44 +24,6 @@
namespace dawn::native::metal { namespace dawn::native::metal {
// OldSwapChain
// static
Ref<OldSwapChain> OldSwapChain::Create(Device* device, const SwapChainDescriptor* descriptor) {
return AcquireRef(new OldSwapChain(device, descriptor));
}
OldSwapChain::OldSwapChain(Device* device, const SwapChainDescriptor* descriptor)
: OldSwapChainBase(device, descriptor) {
const auto& im = GetImplementation();
DawnWSIContextMetal wsiContext = {};
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
wsiContext.queue = ToBackend(GetDevice())->GetMTLQueue();
im.Init(im.userData, &wsiContext);
}
OldSwapChain::~OldSwapChain() {}
TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
const auto& im = GetImplementation();
DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) {
GetDevice()->HandleError(DAWN_INTERNAL_ERROR(error));
return nullptr;
}
id<MTLTexture> nativeTexture = reinterpret_cast<id<MTLTexture>>(next.texture.ptr);
return Texture::CreateWrapping(ToBackend(GetDevice()), descriptor, nativeTexture).Detach();
}
MaybeError OldSwapChain::OnBeforePresent(TextureViewBase*) {
return {};
}
// SwapChain
// static // static
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device, ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
Surface* surface, Surface* surface,

View File

@ -173,10 +173,6 @@ ResultOrError<Ref<ShaderModuleBase>> Device::CreateShaderModuleImpl(
DAWN_TRY(module->Initialize(parseResult, compilationMessages)); DAWN_TRY(module->Initialize(parseResult, compilationMessages));
return module; return module;
} }
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) {
return AcquireRef(new OldSwapChain(this, descriptor));
}
ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,
@ -476,24 +472,6 @@ MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult,
return InitializeBase(parseResult, compilationMessages); return InitializeBase(parseResult, compilationMessages);
} }
// OldSwapChain
OldSwapChain::OldSwapChain(Device* device, const SwapChainDescriptor* descriptor)
: OldSwapChainBase(device, descriptor) {
const auto& im = GetImplementation();
im.Init(im.userData, nullptr);
}
OldSwapChain::~OldSwapChain() {}
TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
return GetDevice()->APICreateTexture(descriptor);
}
MaybeError OldSwapChain::OnBeforePresent(TextureViewBase*) {
return {};
}
uint32_t Device::GetOptimalBytesPerRowAlignment() const { uint32_t Device::GetOptimalBytesPerRowAlignment() const {
return 1; return 1;
} }

View File

@ -146,8 +146,6 @@ class Device final : public DeviceBase {
const ShaderModuleDescriptor* descriptor, const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult, ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) override; OwnedCompilationMessages* compilationMessages) override;
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) override;
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,
@ -312,16 +310,6 @@ class SwapChain final : public NewSwapChainBase {
void DetachFromSurfaceImpl() override; void DetachFromSurfaceImpl() override;
}; };
class OldSwapChain final : public OldSwapChainBase {
public:
OldSwapChain(Device* device, const SwapChainDescriptor* descriptor);
protected:
~OldSwapChain() override;
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
MaybeError OnBeforePresent(TextureViewBase*) override;
};
class Texture : public TextureBase { class Texture : public TextureBase {
public: public:
Texture(DeviceBase* device, const TextureDescriptor* descriptor, TextureState state); Texture(DeviceBase* device, const TextureDescriptor* descriptor, TextureState state);

View File

@ -31,7 +31,6 @@
#include "dawn/native/opengl/RenderPipelineGL.h" #include "dawn/native/opengl/RenderPipelineGL.h"
#include "dawn/native/opengl/SamplerGL.h" #include "dawn/native/opengl/SamplerGL.h"
#include "dawn/native/opengl/ShaderModuleGL.h" #include "dawn/native/opengl/ShaderModuleGL.h"
#include "dawn/native/opengl/SwapChainGL.h"
#include "dawn/native/opengl/TextureGL.h" #include "dawn/native/opengl/TextureGL.h"
namespace { namespace {
@ -239,10 +238,6 @@ ResultOrError<Ref<ShaderModuleBase>> Device::CreateShaderModuleImpl(
OwnedCompilationMessages* compilationMessages) { OwnedCompilationMessages* compilationMessages) {
return ShaderModule::Create(this, descriptor, parseResult, compilationMessages); return ShaderModule::Create(this, descriptor, parseResult, compilationMessages);
} }
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) {
return AcquireRef(new SwapChain(this, descriptor));
}
ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -112,8 +112,6 @@ class Device final : public DeviceBase {
const ShaderModuleDescriptor* descriptor, const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult, ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) override; OwnedCompilationMessages* compilationMessages) override;
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) override;
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -1,50 +0,0 @@
// Copyright 2017 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "dawn/native/opengl/SwapChainGL.h"
#include "dawn/native/opengl/DeviceGL.h"
#include "dawn/native/opengl/Forward.h"
#include "dawn/native/opengl/TextureGL.h"
#include "dawn/dawn_wsi.h"
namespace dawn::native::opengl {
SwapChain::SwapChain(Device* device, const SwapChainDescriptor* descriptor)
: OldSwapChainBase(device, descriptor) {
const auto& im = GetImplementation();
im.Init(im.userData, nullptr);
}
SwapChain::~SwapChain() {}
TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
const auto& im = GetImplementation();
DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) {
GetDevice()->HandleError(DAWN_INTERNAL_ERROR(error));
return nullptr;
}
GLuint nativeTexture = next.texture.u32;
return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture,
TextureBase::TextureState::OwnedExternal);
}
MaybeError SwapChain::OnBeforePresent(TextureViewBase*) {
return {};
}
} // namespace dawn::native::opengl

View File

@ -1,38 +0,0 @@
// Copyright 2017 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SRC_DAWN_NATIVE_OPENGL_SWAPCHAINGL_H_
#define SRC_DAWN_NATIVE_OPENGL_SWAPCHAINGL_H_
#include "dawn/native/SwapChain.h"
#include "dawn/native/opengl/opengl_platform.h"
namespace dawn::native::opengl {
class Device;
class SwapChain final : public OldSwapChainBase {
public:
SwapChain(Device* device, const SwapChainDescriptor* descriptor);
protected:
~SwapChain() override;
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
MaybeError OnBeforePresent(TextureViewBase* view) override;
};
} // namespace dawn::native::opengl
#endif // SRC_DAWN_NATIVE_OPENGL_SWAPCHAINGL_H_

View File

@ -189,10 +189,6 @@ ResultOrError<Ref<ShaderModuleBase>> Device::CreateShaderModuleImpl(
OwnedCompilationMessages* compilationMessages) { OwnedCompilationMessages* compilationMessages) {
return ShaderModule::Create(this, descriptor, parseResult, compilationMessages); return ShaderModule::Create(this, descriptor, parseResult, compilationMessages);
} }
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) {
return OldSwapChain::Create(this, descriptor);
}
ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -135,8 +135,6 @@ class Device final : public DeviceBase {
const ShaderModuleDescriptor* descriptor, const ShaderModuleDescriptor* descriptor,
ShaderModuleParseResult* parseResult, ShaderModuleParseResult* parseResult,
OwnedCompilationMessages* compilationMessages) override; OwnedCompilationMessages* compilationMessages) override;
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
const SwapChainDescriptor* descriptor) override;
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl( ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,

View File

@ -34,56 +34,6 @@
namespace dawn::native::vulkan { namespace dawn::native::vulkan {
// OldSwapChain
// static
Ref<OldSwapChain> OldSwapChain::Create(Device* device, const SwapChainDescriptor* descriptor) {
return AcquireRef(new OldSwapChain(device, descriptor));
}
OldSwapChain::OldSwapChain(Device* device, const SwapChainDescriptor* descriptor)
: OldSwapChainBase(device, descriptor) {
const auto& im = GetImplementation();
DawnWSIContextVulkan wsiContext = {};
im.Init(im.userData, &wsiContext);
ASSERT(im.textureUsage != WGPUTextureUsage_None);
mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
}
OldSwapChain::~OldSwapChain() {}
TextureBase* OldSwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
const auto& im = GetImplementation();
DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) {
GetDevice()->HandleError(DAWN_INTERNAL_ERROR(error));
return nullptr;
}
::VkImage image = NativeNonDispatachableHandleFromU64<::VkImage>(next.texture.u64);
VkImage nativeTexture = VkImage::CreateFromHandle(image);
return Texture::CreateForSwapChain(ToBackend(GetDevice()), descriptor, nativeTexture).Detach();
}
MaybeError OldSwapChain::OnBeforePresent(TextureViewBase* view) {
Device* device = ToBackend(GetDevice());
// Perform the necessary pipeline barriers for the texture to be used with the usage
// requested by the implementation.
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
ToBackend(view->GetTexture())
->TransitionUsageNow(recordingContext, mTextureUsage, view->GetSubresourceRange());
DAWN_TRY(device->SubmitPendingCommands());
return {};
}
// SwapChain
namespace { namespace {
ResultOrError<VkSurfaceKHR> CreateVulkanSurface(Adapter* adapter, Surface* surface) { ResultOrError<VkSurfaceKHR> CreateVulkanSurface(Adapter* adapter, Surface* surface) {

View File

@ -27,21 +27,6 @@ class Device;
class Texture; class Texture;
struct VulkanSurfaceInfo; struct VulkanSurfaceInfo;
class OldSwapChain : public OldSwapChainBase {
public:
static Ref<OldSwapChain> Create(Device* device, const SwapChainDescriptor* descriptor);
protected:
OldSwapChain(Device* device, const SwapChainDescriptor* descriptor);
~OldSwapChain() override;
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
MaybeError OnBeforePresent(TextureViewBase* texture) override;
private:
wgpu::TextureUsage mTextureUsage;
};
class SwapChain : public NewSwapChainBase { class SwapChain : public NewSwapChainBase {
public: public:
static ResultOrError<Ref<SwapChain>> Create(Device* device, static ResultOrError<Ref<SwapChain>> Create(Device* device,

View File

@ -108,10 +108,6 @@ class DeviceMock : public DeviceBase {
ShaderModuleParseResult*, ShaderModuleParseResult*,
OwnedCompilationMessages*), OwnedCompilationMessages*),
(override)); (override));
MOCK_METHOD(ResultOrError<Ref<SwapChainBase>>,
CreateSwapChainImpl,
(const SwapChainDescriptor*),
(override));
MOCK_METHOD(ResultOrError<Ref<NewSwapChainBase>>, MOCK_METHOD(ResultOrError<Ref<NewSwapChainBase>>,
CreateSwapChainImpl, CreateSwapChainImpl,
(Surface*, NewSwapChainBase*, const SwapChainDescriptor*), (Surface*, NewSwapChainBase*, const SwapChainDescriptor*),