Merge NewSwapChainBase in SwapChainBase
Bug: dawn:269 Change-Id: I514c210f88e2bf1f501e2d814f8ab931c5ed724f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126423 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
4299bd0ac9
commit
1226684b09
|
@ -1778,15 +1778,15 @@ ResultOrError<Ref<SwapChainBase>> DeviceBase::CreateSwapChain(
|
||||||
descriptor);
|
descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
NewSwapChainBase* previousSwapChain = surface->GetAttachedSwapChain();
|
SwapChainBase* previousSwapChain = surface->GetAttachedSwapChain();
|
||||||
ResultOrError<Ref<NewSwapChainBase>> maybeNewSwapChain =
|
ResultOrError<Ref<SwapChainBase>> maybeNewSwapChain =
|
||||||
CreateSwapChainImpl(surface, previousSwapChain, descriptor);
|
CreateSwapChainImpl(surface, previousSwapChain, descriptor);
|
||||||
|
|
||||||
if (previousSwapChain != nullptr) {
|
if (previousSwapChain != nullptr) {
|
||||||
previousSwapChain->DetachFromSurface();
|
previousSwapChain->DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<NewSwapChainBase> newSwapChain;
|
Ref<SwapChainBase> newSwapChain;
|
||||||
DAWN_TRY_ASSIGN(newSwapChain, std::move(maybeNewSwapChain));
|
DAWN_TRY_ASSIGN(newSwapChain, std::move(maybeNewSwapChain));
|
||||||
|
|
||||||
newSwapChain->SetIsAttached();
|
newSwapChain->SetIsAttached();
|
||||||
|
|
|
@ -471,9 +471,9 @@ class DeviceBase : public RefCountedWithExternalCount {
|
||||||
ShaderModuleParseResult* parseResult,
|
ShaderModuleParseResult* parseResult,
|
||||||
OwnedCompilationMessages* compilationMessages) = 0;
|
OwnedCompilationMessages* compilationMessages) = 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<SwapChainBase>> CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) = 0;
|
const SwapChainDescriptor* descriptor) = 0;
|
||||||
virtual ResultOrError<Ref<TextureBase>> CreateTextureImpl(
|
virtual ResultOrError<Ref<TextureBase>> CreateTextureImpl(
|
||||||
const TextureDescriptor* descriptor) = 0;
|
const TextureDescriptor* descriptor) = 0;
|
||||||
|
|
|
@ -48,7 +48,6 @@ class SamplerBase;
|
||||||
class Surface;
|
class Surface;
|
||||||
class ShaderModuleBase;
|
class ShaderModuleBase;
|
||||||
class SwapChainBase;
|
class SwapChainBase;
|
||||||
class NewSwapChainBase;
|
|
||||||
class TextureBase;
|
class TextureBase;
|
||||||
class TextureViewBase;
|
class TextureViewBase;
|
||||||
|
|
||||||
|
|
|
@ -230,12 +230,12 @@ Surface::~Surface() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NewSwapChainBase* Surface::GetAttachedSwapChain() {
|
SwapChainBase* Surface::GetAttachedSwapChain() {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
return mSwapChain.Get();
|
return mSwapChain.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Surface::SetAttachedSwapChain(NewSwapChainBase* swapChain) {
|
void Surface::SetAttachedSwapChain(SwapChainBase* swapChain) {
|
||||||
ASSERT(!IsError());
|
ASSERT(!IsError());
|
||||||
mSwapChain = swapChain;
|
mSwapChain = swapChain;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ class Surface final : public ErrorMonad {
|
||||||
|
|
||||||
Surface(InstanceBase* instance, const SurfaceDescriptor* descriptor);
|
Surface(InstanceBase* instance, const SurfaceDescriptor* descriptor);
|
||||||
|
|
||||||
void SetAttachedSwapChain(NewSwapChainBase* swapChain);
|
void SetAttachedSwapChain(SwapChainBase* swapChain);
|
||||||
NewSwapChainBase* GetAttachedSwapChain();
|
SwapChainBase* GetAttachedSwapChain();
|
||||||
|
|
||||||
// These are valid to call on all Surfaces.
|
// These are valid to call on all Surfaces.
|
||||||
enum class Type {
|
enum class Type {
|
||||||
|
@ -96,7 +96,7 @@ class Surface final : public ErrorMonad {
|
||||||
Type mType;
|
Type mType;
|
||||||
|
|
||||||
// The swapchain will set this to null when it is destroyed.
|
// The swapchain will set this to null when it is destroyed.
|
||||||
Ref<NewSwapChainBase> mSwapChain;
|
Ref<SwapChainBase> mSwapChain;
|
||||||
|
|
||||||
// MetalLayer
|
// MetalLayer
|
||||||
void* mMetalLayer = nullptr;
|
void* mMetalLayer = nullptr;
|
||||||
|
|
|
@ -31,21 +31,9 @@ class ErrorSwapChain final : public SwapChainBase {
|
||||||
explicit ErrorSwapChain(DeviceBase* device) : SwapChainBase(device, ObjectBase::kError) {}
|
explicit ErrorSwapChain(DeviceBase* device) : SwapChainBase(device, ObjectBase::kError) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void APIConfigure(wgpu::TextureFormat format,
|
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewImpl() override { UNREACHABLE(); }
|
||||||
wgpu::TextureUsage allowedUsage,
|
MaybeError PresentImpl() override { UNREACHABLE(); }
|
||||||
uint32_t width,
|
void DetachFromSurfaceImpl() override { UNREACHABLE(); }
|
||||||
uint32_t height) override {
|
|
||||||
GetDevice()->HandleError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this));
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureViewBase* APIGetCurrentTextureView() override {
|
|
||||||
GetDevice()->HandleError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this));
|
|
||||||
return TextureViewBase::MakeError(GetDevice());
|
|
||||||
}
|
|
||||||
|
|
||||||
void APIPresent() override {
|
|
||||||
GetDevice()->HandleError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@ -92,7 +80,7 @@ MaybeError ValidateSwapChainDescriptor(const DeviceBase* device,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureDescriptor GetSwapChainBaseTextureDescriptor(NewSwapChainBase* swapChain) {
|
TextureDescriptor GetSwapChainBaseTextureDescriptor(SwapChainBase* swapChain) {
|
||||||
TextureDescriptor desc;
|
TextureDescriptor desc;
|
||||||
desc.usage = swapChain->GetUsage();
|
desc.usage = swapChain->GetUsage();
|
||||||
desc.dimension = wgpu::TextureDimension::e2D;
|
desc.dimension = wgpu::TextureDimension::e2D;
|
||||||
|
@ -104,43 +92,20 @@ TextureDescriptor GetSwapChainBaseTextureDescriptor(NewSwapChainBase* swapChain)
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SwapChainBase
|
SwapChainBase::SwapChainBase(DeviceBase* device,
|
||||||
|
Surface* surface,
|
||||||
SwapChainBase::SwapChainBase(DeviceBase* device) : ApiObjectBase(device, kLabelNotImplemented) {
|
const SwapChainDescriptor* descriptor)
|
||||||
GetObjectTrackingList()->Track(this);
|
: ApiObjectBase(device, kLabelNotImplemented),
|
||||||
}
|
|
||||||
|
|
||||||
SwapChainBase::SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
|
||||||
: ApiObjectBase(device, tag) {}
|
|
||||||
|
|
||||||
SwapChainBase::~SwapChainBase() {}
|
|
||||||
|
|
||||||
void SwapChainBase::DestroyImpl() {}
|
|
||||||
|
|
||||||
// static
|
|
||||||
SwapChainBase* SwapChainBase::MakeError(DeviceBase* device) {
|
|
||||||
return new ErrorSwapChain(device);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectType SwapChainBase::GetType() const {
|
|
||||||
return ObjectType::SwapChain;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Implementation of NewSwapChainBase
|
|
||||||
|
|
||||||
NewSwapChainBase::NewSwapChainBase(DeviceBase* device,
|
|
||||||
Surface* surface,
|
|
||||||
const SwapChainDescriptor* descriptor)
|
|
||||||
: SwapChainBase(device),
|
|
||||||
mAttached(false),
|
|
||||||
mWidth(descriptor->width),
|
mWidth(descriptor->width),
|
||||||
mHeight(descriptor->height),
|
mHeight(descriptor->height),
|
||||||
mFormat(descriptor->format),
|
mFormat(descriptor->format),
|
||||||
mUsage(descriptor->usage),
|
mUsage(descriptor->usage),
|
||||||
mPresentMode(descriptor->presentMode),
|
mPresentMode(descriptor->presentMode),
|
||||||
mSurface(surface) {}
|
mSurface(surface) {
|
||||||
|
GetObjectTrackingList()->Track(this);
|
||||||
|
}
|
||||||
|
|
||||||
NewSwapChainBase::~NewSwapChainBase() {
|
SwapChainBase::~SwapChainBase() {
|
||||||
if (mCurrentTextureView != nullptr) {
|
if (mCurrentTextureView != nullptr) {
|
||||||
ASSERT(mCurrentTextureView->GetTexture()->GetTextureState() ==
|
ASSERT(mCurrentTextureView->GetTexture()->GetTextureState() ==
|
||||||
TextureBase::TextureState::Destroyed);
|
TextureBase::TextureState::Destroyed);
|
||||||
|
@ -149,7 +114,21 @@ NewSwapChainBase::~NewSwapChainBase() {
|
||||||
ASSERT(!mAttached);
|
ASSERT(!mAttached);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSwapChainBase::DetachFromSurface() {
|
SwapChainBase::SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||||
|
: ApiObjectBase(device, tag) {}
|
||||||
|
|
||||||
|
// static
|
||||||
|
SwapChainBase* SwapChainBase::MakeError(DeviceBase* device) {
|
||||||
|
return new ErrorSwapChain(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwapChainBase::DestroyImpl() {}
|
||||||
|
|
||||||
|
ObjectType SwapChainBase::GetType() const {
|
||||||
|
return ObjectType::SwapChain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwapChainBase::DetachFromSurface() {
|
||||||
if (mAttached) {
|
if (mAttached) {
|
||||||
DetachFromSurfaceImpl();
|
DetachFromSurfaceImpl();
|
||||||
mSurface = nullptr;
|
mSurface = nullptr;
|
||||||
|
@ -157,19 +136,19 @@ void NewSwapChainBase::DetachFromSurface() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSwapChainBase::SetIsAttached() {
|
void SwapChainBase::SetIsAttached() {
|
||||||
mAttached = true;
|
mAttached = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSwapChainBase::APIConfigure(wgpu::TextureFormat format,
|
void SwapChainBase::APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
GetDevice()->HandleError(
|
GetDevice()->HandleError(
|
||||||
DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains."));
|
DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains."));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() {
|
TextureViewBase* SwapChainBase::APIGetCurrentTextureView() {
|
||||||
Ref<TextureViewBase> result;
|
Ref<TextureViewBase> result;
|
||||||
if (GetDevice()->ConsumedError(GetCurrentTextureView(), &result,
|
if (GetDevice()->ConsumedError(GetCurrentTextureView(), &result,
|
||||||
"calling %s.GetCurrentTextureView()", this)) {
|
"calling %s.GetCurrentTextureView()", this)) {
|
||||||
|
@ -178,7 +157,7 @@ TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() {
|
||||||
return result.Detach();
|
return result.Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<Ref<TextureViewBase>> NewSwapChainBase::GetCurrentTextureView() {
|
ResultOrError<Ref<TextureViewBase>> SwapChainBase::GetCurrentTextureView() {
|
||||||
DAWN_TRY(ValidateGetCurrentTextureView());
|
DAWN_TRY(ValidateGetCurrentTextureView());
|
||||||
|
|
||||||
if (mCurrentTextureView != nullptr) {
|
if (mCurrentTextureView != nullptr) {
|
||||||
|
@ -204,7 +183,7 @@ ResultOrError<Ref<TextureViewBase>> NewSwapChainBase::GetCurrentTextureView() {
|
||||||
return mCurrentTextureView;
|
return mCurrentTextureView;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewSwapChainBase::APIPresent() {
|
void SwapChainBase::APIPresent() {
|
||||||
if (GetDevice()->ConsumedError(ValidatePresent())) {
|
if (GetDevice()->ConsumedError(ValidatePresent())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -218,39 +197,39 @@ void NewSwapChainBase::APIPresent() {
|
||||||
mCurrentTextureView = nullptr;
|
mCurrentTextureView = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t NewSwapChainBase::GetWidth() const {
|
uint32_t SwapChainBase::GetWidth() const {
|
||||||
return mWidth;
|
return mWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t NewSwapChainBase::GetHeight() const {
|
uint32_t SwapChainBase::GetHeight() const {
|
||||||
return mHeight;
|
return mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::TextureFormat NewSwapChainBase::GetFormat() const {
|
wgpu::TextureFormat SwapChainBase::GetFormat() const {
|
||||||
return mFormat;
|
return mFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::TextureUsage NewSwapChainBase::GetUsage() const {
|
wgpu::TextureUsage SwapChainBase::GetUsage() const {
|
||||||
return mUsage;
|
return mUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::PresentMode NewSwapChainBase::GetPresentMode() const {
|
wgpu::PresentMode SwapChainBase::GetPresentMode() const {
|
||||||
return mPresentMode;
|
return mPresentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface* NewSwapChainBase::GetSurface() const {
|
Surface* SwapChainBase::GetSurface() const {
|
||||||
return mSurface;
|
return mSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewSwapChainBase::IsAttached() const {
|
bool SwapChainBase::IsAttached() const {
|
||||||
return mAttached;
|
return mAttached;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::BackendType NewSwapChainBase::GetBackendType() const {
|
wgpu::BackendType SwapChainBase::GetBackendType() const {
|
||||||
return GetDevice()->GetAdapter()->GetBackendType();
|
return GetDevice()->GetAdapter()->GetBackendType();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError NewSwapChainBase::ValidatePresent() const {
|
MaybeError SwapChainBase::ValidatePresent() const {
|
||||||
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
|
@ -263,7 +242,7 @@ MaybeError NewSwapChainBase::ValidatePresent() const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError NewSwapChainBase::ValidateGetCurrentTextureView() const {
|
MaybeError SwapChainBase::ValidateGetCurrentTextureView() const {
|
||||||
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
||||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||||
|
|
||||||
|
|
|
@ -28,35 +28,15 @@ MaybeError ValidateSwapChainDescriptor(const DeviceBase* device,
|
||||||
const Surface* surface,
|
const Surface* surface,
|
||||||
const SwapChainDescriptor* descriptor);
|
const SwapChainDescriptor* descriptor);
|
||||||
|
|
||||||
TextureDescriptor GetSwapChainBaseTextureDescriptor(NewSwapChainBase* swapChain);
|
TextureDescriptor GetSwapChainBaseTextureDescriptor(SwapChainBase* swapChain);
|
||||||
|
|
||||||
class SwapChainBase : public ApiObjectBase {
|
class SwapChainBase : public ApiObjectBase {
|
||||||
public:
|
public:
|
||||||
explicit SwapChainBase(DeviceBase* device);
|
SwapChainBase(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor);
|
||||||
|
|
||||||
static SwapChainBase* MakeError(DeviceBase* device);
|
static SwapChainBase* MakeError(DeviceBase* device);
|
||||||
|
|
||||||
ObjectType GetType() const override;
|
ObjectType GetType() const override;
|
||||||
|
|
||||||
// Dawn API
|
|
||||||
virtual void APIConfigure(wgpu::TextureFormat format,
|
|
||||||
wgpu::TextureUsage allowedUsage,
|
|
||||||
uint32_t width,
|
|
||||||
uint32_t height) = 0;
|
|
||||||
virtual TextureViewBase* APIGetCurrentTextureView() = 0;
|
|
||||||
virtual void APIPresent() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
|
||||||
~SwapChainBase() override;
|
|
||||||
void DestroyImpl() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
// The base class for surface-based SwapChains that aren't ready yet.
|
|
||||||
class NewSwapChainBase : public SwapChainBase {
|
|
||||||
public:
|
|
||||||
NewSwapChainBase(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor);
|
|
||||||
|
|
||||||
// This is called when the swapchain is detached when one of the following happens:
|
// This is called when the swapchain is detached when one of the following happens:
|
||||||
//
|
//
|
||||||
// - The surface it is attached to is being destroyed.
|
// - The surface it is attached to is being destroyed.
|
||||||
|
@ -80,9 +60,9 @@ class NewSwapChainBase : public SwapChainBase {
|
||||||
void APIConfigure(wgpu::TextureFormat format,
|
void APIConfigure(wgpu::TextureFormat format,
|
||||||
wgpu::TextureUsage allowedUsage,
|
wgpu::TextureUsage allowedUsage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) override;
|
uint32_t height);
|
||||||
TextureViewBase* APIGetCurrentTextureView() override;
|
TextureViewBase* APIGetCurrentTextureView();
|
||||||
void APIPresent() override;
|
void APIPresent();
|
||||||
|
|
||||||
uint32_t GetWidth() const;
|
uint32_t GetWidth() const;
|
||||||
uint32_t GetHeight() const;
|
uint32_t GetHeight() const;
|
||||||
|
@ -94,10 +74,12 @@ class NewSwapChainBase : public SwapChainBase {
|
||||||
wgpu::BackendType GetBackendType() const;
|
wgpu::BackendType GetBackendType() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~NewSwapChainBase() override;
|
SwapChainBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||||
|
~SwapChainBase() override;
|
||||||
|
void DestroyImpl() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool mAttached;
|
bool mAttached = false;
|
||||||
uint32_t mWidth;
|
uint32_t mWidth;
|
||||||
uint32_t mHeight;
|
uint32_t mHeight;
|
||||||
wgpu::TextureFormat mFormat;
|
wgpu::TextureFormat mFormat;
|
||||||
|
|
|
@ -440,9 +440,9 @@ 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<NewSwapChainBase>> Device::CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,9 +186,9 @@ class Device final : public d3d::Device {
|
||||||
const ShaderModuleDescriptor* descriptor,
|
const ShaderModuleDescriptor* descriptor,
|
||||||
ShaderModuleParseResult* parseResult,
|
ShaderModuleParseResult* parseResult,
|
||||||
OwnedCompilationMessages* compilationMessages) override;
|
OwnedCompilationMessages* compilationMessages) override;
|
||||||
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) override;
|
const SwapChainDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
|
|
|
@ -77,7 +77,7 @@ DXGI_USAGE ToDXGIUsage(wgpu::TextureUsage usage) {
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
||||||
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
||||||
|
@ -94,7 +94,7 @@ void SwapChain::DestroyImpl() {
|
||||||
// Initializes the swapchain on the surface. Note that `previousSwapChain` may or may not be
|
// Initializes the swapchain on the surface. Note that `previousSwapChain` may or may not be
|
||||||
// nullptr. If it is not nullptr it means that it is the swapchain previously in use on the
|
// nullptr. If it is not nullptr it means that it is the swapchain previously in use on the
|
||||||
// surface and that we have a chance to reuse it's underlying IDXGISwapChain and "buffers".
|
// surface and that we have a chance to reuse it's underlying IDXGISwapChain and "buffers".
|
||||||
MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
MaybeError SwapChain::Initialize(SwapChainBase* previousSwapChain) {
|
||||||
ASSERT(GetSurface()->GetType() == Surface::Type::WindowsHWND);
|
ASSERT(GetSurface()->GetType() == Surface::Type::WindowsHWND);
|
||||||
|
|
||||||
// Precompute the configuration parameters we want for the DXGI swapchain.
|
// Precompute the configuration parameters we want for the DXGI swapchain.
|
||||||
|
@ -116,8 +116,7 @@ MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
||||||
"D3D12 SwapChain cannot switch backend types from %s to %s.",
|
"D3D12 SwapChain cannot switch backend types from %s to %s.",
|
||||||
previousSwapChain->GetBackendType(), wgpu::BackendType::D3D12);
|
previousSwapChain->GetBackendType(), wgpu::BackendType::D3D12);
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/269): use ToBackend once OldSwapChainBase is removed.
|
SwapChain* previousD3D12SwapChain = ToBackend(previousSwapChain);
|
||||||
SwapChain* previousD3D12SwapChain = static_cast<SwapChain*>(previousSwapChain);
|
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/269): Figure out switching an HWND between devices, it might
|
// TODO(crbug.com/dawn/269): Figure out switching an HWND between devices, it might
|
||||||
// require just losing the reference to the swapchain, but might also need to wait for
|
// require just losing the reference to the swapchain, but might also need to wait for
|
||||||
|
|
|
@ -27,11 +27,11 @@ namespace dawn::native::d3d12 {
|
||||||
class Device;
|
class Device;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
class SwapChain final : public NewSwapChainBase {
|
class SwapChain final : public SwapChainBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor);
|
const SwapChainDescriptor* descriptor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -39,8 +39,8 @@ class SwapChain final : public NewSwapChainBase {
|
||||||
|
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using SwapChainBase::SwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(SwapChainBase* previousSwapChain);
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
// Information that's passed to the D3D12 swapchain creation call.
|
// Information that's passed to the D3D12 swapchain creation call.
|
||||||
|
@ -50,7 +50,7 @@ class SwapChain final : public NewSwapChainBase {
|
||||||
DXGI_USAGE usage;
|
DXGI_USAGE usage;
|
||||||
};
|
};
|
||||||
|
|
||||||
// NewSwapChainBase implementation
|
// SwapChainBase implementation
|
||||||
MaybeError PresentImpl() override;
|
MaybeError PresentImpl() override;
|
||||||
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewImpl() override;
|
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewImpl() override;
|
||||||
void DetachFromSurfaceImpl() override;
|
void DetachFromSurfaceImpl() override;
|
||||||
|
|
|
@ -111,9 +111,9 @@ class Device final : public DeviceBase {
|
||||||
const ShaderModuleDescriptor* descriptor,
|
const ShaderModuleDescriptor* descriptor,
|
||||||
ShaderModuleParseResult* parseResult,
|
ShaderModuleParseResult* parseResult,
|
||||||
OwnedCompilationMessages* compilationMessages) override;
|
OwnedCompilationMessages* compilationMessages) override;
|
||||||
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) override;
|
const SwapChainDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
|
|
|
@ -215,9 +215,9 @@ 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<NewSwapChainBase>> Device::CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ namespace dawn::native::metal {
|
||||||
class Device;
|
class Device;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
class SwapChain final : public NewSwapChainBase {
|
class SwapChain final : public SwapChainBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor);
|
const SwapChainDescriptor* descriptor);
|
||||||
|
|
||||||
SwapChain(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor);
|
SwapChain(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor);
|
||||||
|
@ -40,8 +40,8 @@ class SwapChain final : public NewSwapChainBase {
|
||||||
private:
|
private:
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using SwapChainBase::SwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(SwapChainBase* previousSwapChain);
|
||||||
|
|
||||||
NSRef<CAMetalLayer> mLayer;
|
NSRef<CAMetalLayer> mLayer;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace dawn::native::metal {
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
||||||
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
||||||
|
@ -35,7 +35,7 @@ ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapChain::SwapChain(DeviceBase* dev, Surface* sur, const SwapChainDescriptor* desc)
|
SwapChain::SwapChain(DeviceBase* dev, Surface* sur, const SwapChainDescriptor* desc)
|
||||||
: NewSwapChainBase(dev, sur, desc) {}
|
: SwapChainBase(dev, sur, desc) {}
|
||||||
|
|
||||||
SwapChain::~SwapChain() = default;
|
SwapChain::~SwapChain() = default;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void SwapChain::DestroyImpl() {
|
||||||
DetachFromSurface();
|
DetachFromSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
MaybeError SwapChain::Initialize(SwapChainBase* previousSwapChain) {
|
||||||
ASSERT(GetSurface()->GetType() == Surface::Type::MetalLayer);
|
ASSERT(GetSurface()->GetType() == Surface::Type::MetalLayer);
|
||||||
|
|
||||||
if (previousSwapChain != nullptr) {
|
if (previousSwapChain != nullptr) {
|
||||||
|
|
|
@ -173,9 +173,9 @@ ResultOrError<Ref<ShaderModuleBase>> Device::CreateShaderModuleImpl(
|
||||||
DAWN_TRY(module->Initialize(parseResult, compilationMessages));
|
DAWN_TRY(module->Initialize(parseResult, compilationMessages));
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
||||||
}
|
}
|
||||||
|
@ -424,14 +424,14 @@ MaybeError RenderPipeline::Initialize() {
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
||||||
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
||||||
return swapchain;
|
return swapchain;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
MaybeError SwapChain::Initialize(SwapChainBase* previousSwapChain) {
|
||||||
if (previousSwapChain != nullptr) {
|
if (previousSwapChain != nullptr) {
|
||||||
// TODO(crbug.com/dawn/269): figure out what should happen when surfaces are used by
|
// TODO(crbug.com/dawn/269): figure out what should happen when surfaces are used by
|
||||||
// multiple backends one after the other. It probably needs to block until the backend
|
// multiple backends one after the other. It probably needs to block until the backend
|
||||||
|
|
|
@ -146,9 +146,9 @@ class Device final : public DeviceBase {
|
||||||
const ShaderModuleDescriptor* descriptor,
|
const ShaderModuleDescriptor* descriptor,
|
||||||
ShaderModuleParseResult* parseResult,
|
ShaderModuleParseResult* parseResult,
|
||||||
OwnedCompilationMessages* compilationMessages) override;
|
OwnedCompilationMessages* compilationMessages) override;
|
||||||
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) override;
|
const SwapChainDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
|
@ -291,17 +291,17 @@ class ShaderModule final : public ShaderModuleBase {
|
||||||
OwnedCompilationMessages* compilationMessages);
|
OwnedCompilationMessages* compilationMessages);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SwapChain final : public NewSwapChainBase {
|
class SwapChain final : public SwapChainBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor);
|
const SwapChainDescriptor* descriptor);
|
||||||
~SwapChain() override;
|
~SwapChain() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using SwapChainBase::SwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(SwapChainBase* previousSwapChain);
|
||||||
|
|
||||||
Ref<Texture> mTexture;
|
Ref<Texture> mTexture;
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,9 @@ 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<NewSwapChainBase>> Device::CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
return DAWN_VALIDATION_ERROR("New swapchains not implemented.");
|
return DAWN_VALIDATION_ERROR("New swapchains not implemented.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,9 +112,9 @@ class Device final : public DeviceBase {
|
||||||
const ShaderModuleDescriptor* descriptor,
|
const ShaderModuleDescriptor* descriptor,
|
||||||
ShaderModuleParseResult* parseResult,
|
ShaderModuleParseResult* parseResult,
|
||||||
OwnedCompilationMessages* compilationMessages) override;
|
OwnedCompilationMessages* compilationMessages) override;
|
||||||
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) override;
|
const SwapChainDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
|
|
|
@ -189,9 +189,9 @@ 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<NewSwapChainBase>> Device::CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> Device::CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
return SwapChain::Create(this, surface, previousSwapChain, descriptor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,9 +135,9 @@ class Device final : public DeviceBase {
|
||||||
const ShaderModuleDescriptor* descriptor,
|
const ShaderModuleDescriptor* descriptor,
|
||||||
ShaderModuleParseResult* parseResult,
|
ShaderModuleParseResult* parseResult,
|
||||||
OwnedCompilationMessages* compilationMessages) override;
|
OwnedCompilationMessages* compilationMessages) override;
|
||||||
ResultOrError<Ref<NewSwapChainBase>> CreateSwapChainImpl(
|
ResultOrError<Ref<SwapChainBase>> CreateSwapChainImpl(
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) override;
|
const SwapChainDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
ResultOrError<Ref<TextureBase>> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
|
|
|
@ -208,7 +208,7 @@ uint32_t MinImageCountForPresentMode(VkPresentModeKHR mode) {
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
ResultOrError<Ref<SwapChain>> SwapChain::Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor) {
|
const SwapChainDescriptor* descriptor) {
|
||||||
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
Ref<SwapChain> swapchain = AcquireRef(new SwapChain(device, surface, descriptor));
|
||||||
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
DAWN_TRY(swapchain->Initialize(previousSwapChain));
|
||||||
|
@ -224,7 +224,7 @@ void SwapChain::DestroyImpl() {
|
||||||
|
|
||||||
// Note that when we need to re-create the swapchain because it is out of date,
|
// Note that when we need to re-create the swapchain because it is out of date,
|
||||||
// previousSwapChain can be set to `this`.
|
// previousSwapChain can be set to `this`.
|
||||||
MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
MaybeError SwapChain::Initialize(SwapChainBase* previousSwapChain) {
|
||||||
Device* device = ToBackend(GetDevice());
|
Device* device = ToBackend(GetDevice());
|
||||||
Adapter* adapter = ToBackend(GetDevice()->GetAdapter());
|
Adapter* adapter = ToBackend(GetDevice()->GetAdapter());
|
||||||
|
|
||||||
|
@ -241,8 +241,7 @@ MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
|
||||||
"Vulkan SwapChain cannot switch backend types from %s to %s.",
|
"Vulkan SwapChain cannot switch backend types from %s to %s.",
|
||||||
previousSwapChain->GetBackendType(), wgpu::BackendType::Vulkan);
|
previousSwapChain->GetBackendType(), wgpu::BackendType::Vulkan);
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/269): use ToBackend once OldSwapChainBase is removed.
|
SwapChain* previousVulkanSwapChain = ToBackend(previousSwapChain);
|
||||||
SwapChain* previousVulkanSwapChain = static_cast<SwapChain*>(previousSwapChain);
|
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/269): Figure out switching a single surface between multiple
|
// TODO(crbug.com/dawn/269): Figure out switching a single surface between multiple
|
||||||
// Vulkan devices on different VkInstances. Probably needs to block too!
|
// Vulkan devices on different VkInstances. Probably needs to block too!
|
||||||
|
|
|
@ -27,17 +27,17 @@ class Device;
|
||||||
class Texture;
|
class Texture;
|
||||||
struct VulkanSurfaceInfo;
|
struct VulkanSurfaceInfo;
|
||||||
|
|
||||||
class SwapChain : public NewSwapChainBase {
|
class SwapChain : public SwapChainBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
static ResultOrError<Ref<SwapChain>> Create(Device* device,
|
||||||
Surface* surface,
|
Surface* surface,
|
||||||
NewSwapChainBase* previousSwapChain,
|
SwapChainBase* previousSwapChain,
|
||||||
const SwapChainDescriptor* descriptor);
|
const SwapChainDescriptor* descriptor);
|
||||||
~SwapChain() override;
|
~SwapChain() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using NewSwapChainBase::NewSwapChainBase;
|
using SwapChainBase::SwapChainBase;
|
||||||
MaybeError Initialize(NewSwapChainBase* previousSwapChain);
|
MaybeError Initialize(SwapChainBase* previousSwapChain);
|
||||||
void DestroyImpl() override;
|
void DestroyImpl() override;
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
|
@ -62,7 +62,7 @@ class SwapChain : public NewSwapChainBase {
|
||||||
ResultOrError<Config> ChooseConfig(const VulkanSurfaceInfo& surfaceInfo) const;
|
ResultOrError<Config> ChooseConfig(const VulkanSurfaceInfo& surfaceInfo) const;
|
||||||
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewInternal(bool isReentrant = false);
|
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewInternal(bool isReentrant = false);
|
||||||
|
|
||||||
// NewSwapChainBase implementation
|
// SwapChainBase implementation
|
||||||
MaybeError PresentImpl() override;
|
MaybeError PresentImpl() override;
|
||||||
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewImpl() override;
|
ResultOrError<Ref<TextureViewBase>> GetCurrentTextureViewImpl() override;
|
||||||
void DetachFromSurfaceImpl() override;
|
void DetachFromSurfaceImpl() override;
|
||||||
|
|
|
@ -200,13 +200,9 @@ TEST_P(DeviceLostTest, CreateShaderModuleFails) {
|
||||||
})"));
|
})"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that CreateSwapChain fails when device is lost
|
// Note that no device lost tests are done for swapchain because it is awkward to create a
|
||||||
TEST_P(DeviceLostTest, CreateSwapChainFails) {
|
// wgpu::Surface in this file. SwapChainValidationTests.CreateSwapChainFailsAfterDevLost covers
|
||||||
LoseDeviceForTesting();
|
// this validation.
|
||||||
|
|
||||||
wgpu::SwapChainDescriptor descriptor = {};
|
|
||||||
ASSERT_DEVICE_ERROR(device.CreateSwapChain(nullptr, &descriptor));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tests that CreateTexture fails when device is lost
|
// Tests that CreateTexture fails when device is lost
|
||||||
TEST_P(DeviceLostTest, CreateTextureFails) {
|
TEST_P(DeviceLostTest, CreateTextureFails) {
|
||||||
|
|
|
@ -166,13 +166,6 @@ TEST_P(SwapChainValidationTests, InvalidCreationFormat) {
|
||||||
ASSERT_DEVICE_ERROR(device.CreateSwapChain(surface, &desc));
|
ASSERT_DEVICE_ERROR(device.CreateSwapChain(surface, &desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks that the implementation must be zero.
|
|
||||||
TEST_P(SwapChainValidationTests, InvalidWithImplementation) {
|
|
||||||
wgpu::SwapChainDescriptor desc = goodDescriptor;
|
|
||||||
desc.implementation = 1;
|
|
||||||
ASSERT_DEVICE_ERROR(device.CreateSwapChain(surface, &desc));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check swapchain operations with an error swapchain are errors
|
// Check swapchain operations with an error swapchain are errors
|
||||||
TEST_P(SwapChainValidationTests, OperationsOnErrorSwapChain) {
|
TEST_P(SwapChainValidationTests, OperationsOnErrorSwapChain) {
|
||||||
wgpu::SwapChain swapchain;
|
wgpu::SwapChain swapchain;
|
||||||
|
@ -322,7 +315,7 @@ TEST_P(SwapChainValidationTests, SwapChainIsInvalidAfterSurfaceDestruction_After
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that new swap chain present fails after device is lost
|
// Test that new swap chain present fails after device is lost
|
||||||
TEST_P(SwapChainValidationTests, NewSwapChainPresentFailsAfterDeviceLost) {
|
TEST_P(SwapChainValidationTests, SwapChainPresentFailsAfterDeviceLost) {
|
||||||
wgpu::SwapChain swapchain = device.CreateSwapChain(surface, &goodDescriptor);
|
wgpu::SwapChain swapchain = device.CreateSwapChain(surface, &goodDescriptor);
|
||||||
wgpu::TextureView view = swapchain.GetCurrentTextureView();
|
wgpu::TextureView view = swapchain.GetCurrentTextureView();
|
||||||
|
|
||||||
|
@ -331,7 +324,7 @@ TEST_P(SwapChainValidationTests, NewSwapChainPresentFailsAfterDeviceLost) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that new swap chain get current texture view fails after device is lost
|
// Test that new swap chain get current texture view fails after device is lost
|
||||||
TEST_P(SwapChainValidationTests, NewSwapChainGetCurrentTextureViewFailsAfterDevLost) {
|
TEST_P(SwapChainValidationTests, SwapChainGetCurrentTextureViewFailsAfterDevLost) {
|
||||||
wgpu::SwapChain swapchain = device.CreateSwapChain(surface, &goodDescriptor);
|
wgpu::SwapChain swapchain = device.CreateSwapChain(surface, &goodDescriptor);
|
||||||
|
|
||||||
LoseDeviceForTesting();
|
LoseDeviceForTesting();
|
||||||
|
@ -339,7 +332,7 @@ TEST_P(SwapChainValidationTests, NewSwapChainGetCurrentTextureViewFailsAfterDevL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that creation of a new swapchain fails after device is lost
|
// Test that creation of a new swapchain fails after device is lost
|
||||||
TEST_P(SwapChainValidationTests, CreateNewSwapChainFailsAfterDevLost) {
|
TEST_P(SwapChainValidationTests, CreateSwapChainFailsAfterDevLost) {
|
||||||
LoseDeviceForTesting();
|
LoseDeviceForTesting();
|
||||||
ASSERT_DEVICE_ERROR(device.CreateSwapChain(surface, &goodDescriptor));
|
ASSERT_DEVICE_ERROR(device.CreateSwapChain(surface, &goodDescriptor));
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,9 @@ class DeviceMock : public DeviceBase {
|
||||||
ShaderModuleParseResult*,
|
ShaderModuleParseResult*,
|
||||||
OwnedCompilationMessages*),
|
OwnedCompilationMessages*),
|
||||||
(override));
|
(override));
|
||||||
MOCK_METHOD(ResultOrError<Ref<NewSwapChainBase>>,
|
MOCK_METHOD(ResultOrError<Ref<SwapChainBase>>,
|
||||||
CreateSwapChainImpl,
|
CreateSwapChainImpl,
|
||||||
(Surface*, NewSwapChainBase*, const SwapChainDescriptor*),
|
(Surface*, SwapChainBase*, const SwapChainDescriptor*),
|
||||||
(override));
|
(override));
|
||||||
MOCK_METHOD(ResultOrError<Ref<TextureBase>>,
|
MOCK_METHOD(ResultOrError<Ref<TextureBase>>,
|
||||||
CreateTextureImpl,
|
CreateTextureImpl,
|
||||||
|
|
|
@ -16,7 +16,10 @@
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
SwapChainMock::SwapChainMock(DeviceBase* device) : SwapChainBase(device) {
|
SwapChainMock::SwapChainMock(DeviceBase* device,
|
||||||
|
Surface* surface,
|
||||||
|
const SwapChainDescriptor* descriptor)
|
||||||
|
: SwapChainBase(device, surface, descriptor) {
|
||||||
ON_CALL(*this, DestroyImpl).WillByDefault([this]() { this->SwapChainBase::DestroyImpl(); });
|
ON_CALL(*this, DestroyImpl).WillByDefault([this]() { this->SwapChainBase::DestroyImpl(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,17 +24,14 @@ namespace dawn::native {
|
||||||
|
|
||||||
class SwapChainMock : public SwapChainBase {
|
class SwapChainMock : public SwapChainBase {
|
||||||
public:
|
public:
|
||||||
explicit SwapChainMock(DeviceBase* device);
|
SwapChainMock(DeviceBase* device, Surface* surface, const SwapChainDescriptor* descriptor);
|
||||||
~SwapChainMock() override;
|
~SwapChainMock() override;
|
||||||
|
|
||||||
MOCK_METHOD(void, DestroyImpl, (), (override));
|
MOCK_METHOD(void, DestroyImpl, (), (override));
|
||||||
|
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(ResultOrError<Ref<TextureViewBase>>, GetCurrentTextureViewImpl, (), (override));
|
||||||
APIConfigure,
|
MOCK_METHOD(MaybeError, PresentImpl, (), (override));
|
||||||
(wgpu::TextureFormat, wgpu::TextureUsage, uint32_t, uint32_t),
|
MOCK_METHOD(void, DetachFromSurfaceImpl, (), (override));
|
||||||
(override));
|
|
||||||
MOCK_METHOD(TextureViewBase*, APIGetCurrentTextureView, (), (override));
|
|
||||||
MOCK_METHOD(void, APIPresent, (), (override));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn::native
|
} // namespace dawn::native
|
||||||
|
|
Loading…
Reference in New Issue