Roll dawn and adjust for new SwapChain API.
Split GrDawnImageInfo into GrDawnTextureInfo and GrDawnRenderTargetInfo.
The former holds only a wgpu::Texture, and the latter holds only a
wgpu::TextureView. This split is necessary because Dawn SwapChains now
vend TextureViews, not Textures.
The TextureView held by GrDawnRenderTargetInfo is always 1-mip, since
it's a requirement for rendering to a texture in Dawn.
Change-Id: Id6e99b5e4bf18f97e939170856a665e2038253ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254810
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/DEPS b/DEPS
index 2f3355c..ab4f097 100644
--- a/DEPS
+++ b/DEPS
@@ -8,7 +8,7 @@
"buildtools" : "https://chromium.googlesource.com/chromium/buildtools.git@505de88083136eefd056e5ee4ca0f01fe9b33de8",
"common" : "https://skia.googlesource.com/common.git@9737551d7a52c3db3262db5856e6bcd62c462b92",
"third_party/externals/angle2" : "https://chromium.googlesource.com/angle/angle.git@086aded3cb743b2fc405d8a11b12d7fc132ec181",
- "third_party/externals/dawn" : "https://dawn.googlesource.com/dawn.git@3c086a0c2e1dc3e2e14aaa3d78c052c7e07274b4",
+ "third_party/externals/dawn" : "https://dawn.googlesource.com/dawn.git@604072bc2ed01018eb03bcbbf9d94042f679af63",
"third_party/externals/dng_sdk" : "https://android.googlesource.com/platform/external/dng_sdk.git@c8d0c9b1d16bfda56f15165d39e0ffa360a11123",
"third_party/externals/egl-registry" : "https://skia.googlesource.com/external/github.com/KhronosGroup/EGL-Registry@a0bca08de07c7d7651047bedc0b653cfaaa4f2ae",
"third_party/externals/expat" : "https://android.googlesource.com/platform/external/expat.git@e5aa0a2cb0a5f759ef31c0819dc67d9b14246a4a",
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 8531340..748325d 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -206,7 +206,7 @@
#ifdef SK_DAWN
GrBackendTexture(int width,
int height,
- const GrDawnImageInfo& dawnInfo);
+ const GrDawnTextureInfo& dawnInfo);
#endif
GrBackendTexture(int width,
@@ -234,9 +234,9 @@
void glTextureParametersModified();
#ifdef SK_DAWN
- // If the backend API is Dawn, copies a snapshot of the GrDawnImageInfo struct into the passed
+ // If the backend API is Dawn, copies a snapshot of the GrDawnTextureInfo struct into the passed
// in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
- bool getDawnImageInfo(GrDawnImageInfo*) const;
+ bool getDawnTextureInfo(GrDawnTextureInfo*) const;
#endif
// If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
@@ -317,7 +317,7 @@
GrMtlTextureInfo fMtlInfo;
#endif
#ifdef SK_DAWN
- GrDawnImageInfo fDawnInfo;
+ GrDawnTextureInfo fDawnInfo;
#endif
};
@@ -338,7 +338,7 @@
int height,
int sampleCnt,
int stencilBits,
- const GrDawnImageInfo& dawnInfo);
+ const GrDawnRenderTargetInfo& dawnInfo);
#endif
/** Deprecated, use version that does not take stencil bits. */
@@ -379,9 +379,9 @@
bool getGLFramebufferInfo(GrGLFramebufferInfo*) const;
#ifdef SK_DAWN
- // If the backend API is Dawn, copies a snapshot of the GrDawnImageInfo struct into the passed
- // in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
- bool getDawnImageInfo(GrDawnImageInfo*) const;
+ // If the backend API is Dawn, copies a snapshot of the GrDawnRenderTargetInfo struct into the
+ // passed-in pointer and returns true. Otherwise returns false if the backend API is not Dawn.
+ bool getDawnRenderTargetInfo(GrDawnRenderTargetInfo*) const;
#endif
// If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo struct into the passed
@@ -449,7 +449,7 @@
GrMtlTextureInfo fMtlInfo;
#endif
#ifdef SK_DAWN
- GrDawnImageInfo fDawnInfo;
+ GrDawnRenderTargetInfo fDawnInfo;
#endif
};
diff --git a/include/gpu/dawn/GrDawnTypes.h b/include/gpu/dawn/GrDawnTypes.h
index 1b7bfe5..2bd923e 100644
--- a/include/gpu/dawn/GrDawnTypes.h
+++ b/include/gpu/dawn/GrDawnTypes.h
@@ -22,28 +22,64 @@
#endif
#include "dawn/webgpu_cpp.h"
-struct GrDawnImageInfo {
+struct GrDawnTextureInfo {
wgpu::Texture fTexture;
wgpu::TextureFormat fFormat;
uint32_t fLevelCount;
- GrDawnImageInfo() : fTexture(nullptr), fFormat(), fLevelCount(0) {
+ GrDawnTextureInfo() : fTexture(nullptr), fFormat(), fLevelCount(0) {
}
- GrDawnImageInfo(const GrDawnImageInfo& other)
+ GrDawnTextureInfo(const GrDawnTextureInfo& other)
: fTexture(other.fTexture)
, fFormat(other.fFormat)
, fLevelCount(other.fLevelCount) {
}
- GrDawnImageInfo& operator=(const GrDawnImageInfo& other) {
+ GrDawnTextureInfo& operator=(const GrDawnTextureInfo& other) {
fTexture = other.fTexture;
fFormat = other.fFormat;
fLevelCount = other.fLevelCount;
return *this;
}
- bool operator==(const GrDawnImageInfo& other) const {
+ bool operator==(const GrDawnTextureInfo& other) const {
return fTexture.Get() == other.fTexture.Get() &&
fFormat == other.fFormat &&
fLevelCount == other.fLevelCount;
}
};
+// GrDawnRenderTargetInfo holds a reference to a (1-mip) TextureView. This means that, for now,
+// GrDawnRenderTarget is suitable for rendering, but not readPixels() or writePixels(). Also,
+// backdrop filters and certain blend modes requiring copying the destination framebuffer
+// will not work.
+struct GrDawnRenderTargetInfo {
+ wgpu::TextureView fTextureView;
+ wgpu::TextureFormat fFormat;
+ uint32_t fLevelCount;
+ GrDawnRenderTargetInfo() : fTextureView(nullptr), fFormat(), fLevelCount(0) {
+ }
+ GrDawnRenderTargetInfo(const GrDawnRenderTargetInfo& other)
+ : fTextureView(other.fTextureView)
+ , fFormat(other.fFormat)
+ , fLevelCount(other.fLevelCount) {
+ }
+ explicit GrDawnRenderTargetInfo(const GrDawnTextureInfo& texInfo)
+ : fFormat(texInfo.fFormat)
+ , fLevelCount(1) {
+ wgpu::TextureViewDescriptor desc;
+ desc.format = texInfo.fFormat;
+ desc.mipLevelCount = 1;
+ fTextureView = texInfo.fTexture.CreateView(&desc);
+ }
+ GrDawnRenderTargetInfo& operator=(const GrDawnRenderTargetInfo& other) {
+ fTextureView = other.fTextureView;
+ fFormat = other.fFormat;
+ fLevelCount = other.fLevelCount;
+ return *this;
+ }
+ bool operator==(const GrDawnRenderTargetInfo& other) const {
+ return fTextureView.Get() == other.fTextureView.Get() &&
+ fFormat == other.fFormat &&
+ fLevelCount == other.fLevelCount;
+ }
+};
+
#endif
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index f45b457..fffad92 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -313,7 +313,7 @@
#ifdef SK_DAWN
GrBackendTexture::GrBackendTexture(int width,
int height,
- const GrDawnImageInfo& dawnInfo)
+ const GrDawnTextureInfo& dawnInfo)
: fIsValid(true)
, fWidth(width)
, fHeight(height)
@@ -466,7 +466,7 @@
}
#ifdef SK_DAWN
-bool GrBackendTexture::getDawnImageInfo(GrDawnImageInfo* outInfo) const {
+bool GrBackendTexture::getDawnTextureInfo(GrDawnTextureInfo* outInfo) const {
if (this->isValid() && GrBackendApi::kDawn == fBackend) {
*outInfo = fDawnInfo;
return true;
@@ -663,7 +663,7 @@
int height,
int sampleCnt,
int stencilBits,
- const GrDawnImageInfo& dawnInfo)
+ const GrDawnRenderTargetInfo& dawnInfo)
: fIsValid(true)
, fFramebufferOnly(true)
, fWidth(width)
@@ -816,7 +816,7 @@
}
#ifdef SK_DAWN
-bool GrBackendRenderTarget::getDawnImageInfo(GrDawnImageInfo* outInfo) const {
+bool GrBackendRenderTarget::getDawnRenderTargetInfo(GrDawnRenderTargetInfo* outInfo) const {
if (this->isValid() && GrBackendApi::kDawn == fBackend) {
*outInfo = fDawnInfo;
return true;
@@ -898,6 +898,13 @@
return GrBackendFormat::MakeMtl(GrGetMTLPixelFormatFromMtlTextureInfo(mtlInfo));
}
#endif
+#ifdef SK_DAWN
+ case GrBackendApi::kDawn: {
+ GrDawnRenderTargetInfo dawnInfo;
+ SkAssertResult(this->getDawnRenderTargetInfo(&dawnInfo));
+ return GrBackendFormat::MakeDawn(dawnInfo.fFormat);
+ }
+#endif
case GrBackendApi::kMock:
return fMockInfo.getBackendFormat();
default:
diff --git a/src/gpu/dawn/GrDawnGpu.cpp b/src/gpu/dawn/GrDawnGpu.cpp
index ec2c46b..66cb7e9 100644
--- a/src/gpu/dawn/GrDawnGpu.cpp
+++ b/src/gpu/dawn/GrDawnGpu.cpp
@@ -183,8 +183,8 @@
GrWrapOwnership ownership,
GrWrapCacheable cacheable,
GrIOType) {
- GrDawnImageInfo info;
- if (!backendTex.getDawnImageInfo(&info)) {
+ GrDawnTextureInfo info;
+ if (!backendTex.getDawnTextureInfo(&info)) {
return nullptr;
}
@@ -205,8 +205,8 @@
int sampleCnt, GrColorType colorType,
GrWrapOwnership,
GrWrapCacheable cacheable) {
- GrDawnImageInfo info;
- if (!tex.getDawnImageInfo(&info) || !info.fTexture) {
+ GrDawnTextureInfo info;
+ if (!tex.getDawnTextureInfo(&info) || !info.fTexture) {
return nullptr;
}
@@ -223,8 +223,8 @@
sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt,
GrColorType colorType) {
- GrDawnImageInfo info;
- if (!rt.getDawnImageInfo(&info) && !info.fTexture) {
+ GrDawnRenderTargetInfo info;
+ if (!rt.getDawnRenderTargetInfo(&info) || !info.fTextureView) {
return nullptr;
}
@@ -236,8 +236,8 @@
sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
int sampleCnt,
GrColorType colorType) {
- GrDawnImageInfo info;
- if (!tex.getDawnImageInfo(&info) || !info.fTexture) {
+ GrDawnTextureInfo textureInfo;
+ if (!tex.getDawnTextureInfo(&textureInfo) || !textureInfo.fTexture) {
return nullptr;
}
@@ -247,6 +247,7 @@
return nullptr;
}
+ GrDawnRenderTargetInfo info(textureInfo);
return GrDawnRenderTarget::MakeWrapped(this, dimensions, sampleCnt, info);
}
@@ -349,7 +350,7 @@
}
wgpu::CommandBuffer cmdBuf = copyEncoder.Finish();
fQueue.Submit(1, &cmdBuf);
- GrDawnImageInfo info;
+ GrDawnTextureInfo info;
info.fTexture = tex;
info.fFormat = desc.format;
info.fLevelCount = desc.mipLevelCount;
@@ -365,16 +366,16 @@
}
void GrDawnGpu::deleteBackendTexture(const GrBackendTexture& tex) {
- GrDawnImageInfo info;
- if (tex.getDawnImageInfo(&info)) {
+ GrDawnTextureInfo info;
+ if (tex.getDawnTextureInfo(&info)) {
info.fTexture = nullptr;
}
}
#if GR_TEST_UTILS
bool GrDawnGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
- GrDawnImageInfo info;
- if (!tex.getDawnImageInfo(&info)) {
+ GrDawnTextureInfo info;
+ if (!tex.getDawnTextureInfo(&info)) {
return false;
}
@@ -405,17 +406,17 @@
wgpu::Texture tex = this->device().CreateTexture(&desc);
- GrDawnImageInfo info;
- info.fTexture = tex;
+ GrDawnRenderTargetInfo info;
+ info.fTextureView = tex.CreateView();
info.fFormat = desc.format;
info.fLevelCount = desc.mipLevelCount;
return GrBackendRenderTarget(width, height, 1, 0, info);
}
void GrDawnGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& rt) {
- GrDawnImageInfo info;
- if (rt.getDawnImageInfo(&info)) {
- info.fTexture = nullptr;
+ GrDawnRenderTargetInfo info;
+ if (rt.getDawnRenderTargetInfo(&info)) {
+ info.fTextureView = nullptr;
}
}
@@ -442,9 +443,7 @@
}
static wgpu::Texture get_dawn_texture_from_surface(GrSurface* src) {
- if (auto rt = static_cast<GrDawnRenderTarget*>(src->asRenderTarget())) {
- return rt->texture();
- } else if (auto t = static_cast<GrDawnTexture*>(src->asTexture())) {
+ if (auto t = static_cast<GrDawnTexture*>(src->asTexture())) {
return t->texture();
} else {
return nullptr;
@@ -483,6 +482,7 @@
GrColorType surfaceColorType, GrColorType dstColorType, void* buffer,
size_t rowBytes) {
wgpu::Texture tex = get_dawn_texture_from_surface(surface);
+ SkASSERT(tex);
if (0 == rowBytes) {
return false;
diff --git a/src/gpu/dawn/GrDawnOpsRenderPass.cpp b/src/gpu/dawn/GrDawnOpsRenderPass.cpp
index 083df05..abfa19f 100644
--- a/src/gpu/dawn/GrDawnOpsRenderPass.cpp
+++ b/src/gpu/dawn/GrDawnOpsRenderPass.cpp
@@ -56,16 +56,12 @@
wgpu::RenderPassEncoder GrDawnOpsRenderPass::beginRenderPass(wgpu::LoadOp colorOp,
wgpu::LoadOp stencilOp) {
- wgpu::Texture texture = static_cast<GrDawnRenderTarget*>(fRenderTarget)->texture();
auto stencilAttachment = static_cast<GrDawnStencilAttachment*>(
fRenderTarget->renderTargetPriv().getStencilAttachment());
- wgpu::TextureViewDescriptor desc;
- desc.mipLevelCount = 1;
- wgpu::TextureView colorView = texture.CreateView(&desc);
const float *c = fColorInfo.fClearColor.vec();
wgpu::RenderPassColorAttachmentDescriptor colorAttachment;
- colorAttachment.attachment = colorView;
+ colorAttachment.attachment = static_cast<GrDawnRenderTarget*>(fRenderTarget)->textureView();
colorAttachment.resolveTarget = nullptr;
colorAttachment.clearColor = { c[0], c[1], c[2], c[3] };
colorAttachment.loadOp = colorOp;
diff --git a/src/gpu/dawn/GrDawnRenderTarget.cpp b/src/gpu/dawn/GrDawnRenderTarget.cpp
index 94709c5..341c9e5 100644
--- a/src/gpu/dawn/GrDawnRenderTarget.cpp
+++ b/src/gpu/dawn/GrDawnRenderTarget.cpp
@@ -14,7 +14,7 @@
GrDawnRenderTarget::GrDawnRenderTarget(GrDawnGpu* gpu,
SkISize dimensions,
int sampleCnt,
- const GrDawnImageInfo& info)
+ const GrDawnRenderTargetInfo& info)
: GrSurface(gpu, dimensions, GrProtected::kNo)
, GrRenderTarget(gpu, dimensions, sampleCnt, GrProtected::kNo)
, fInfo(info) {}
@@ -22,7 +22,7 @@
sk_sp<GrDawnRenderTarget> GrDawnRenderTarget::MakeWrapped(GrDawnGpu* gpu,
SkISize dimensions,
int sampleCnt,
- const GrDawnImageInfo& info) {
+ const GrDawnRenderTargetInfo& info) {
sk_sp<GrDawnRenderTarget> rt(new GrDawnRenderTarget(gpu, dimensions, sampleCnt, info));
rt->registerWithCacheWrapped(GrWrapCacheable::kNo);
return rt;
diff --git a/src/gpu/dawn/GrDawnRenderTarget.h b/src/gpu/dawn/GrDawnRenderTarget.h
index 5c7ed93..16d498d 100644
--- a/src/gpu/dawn/GrDawnRenderTarget.h
+++ b/src/gpu/dawn/GrDawnRenderTarget.h
@@ -18,7 +18,7 @@
static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*,
SkISize dimensions,
int sampleCnt,
- const GrDawnImageInfo&);
+ const GrDawnRenderTargetInfo&);
~GrDawnRenderTarget() override;
@@ -28,13 +28,13 @@
GrBackendRenderTarget getBackendRenderTarget() const override;
GrBackendFormat backendFormat() const override;
- wgpu::Texture texture() const { return fInfo.fTexture; }
+ wgpu::TextureView textureView() const { return fInfo.fTextureView; }
protected:
GrDawnRenderTarget(GrDawnGpu* gpu,
SkISize dimensions,
int sampleCnt,
- const GrDawnImageInfo& info);
+ const GrDawnRenderTargetInfo& info);
void onAbandon() override;
void onRelease() override;
@@ -44,10 +44,10 @@
size_t onGpuMemorySize() const override;
static GrDawnRenderTarget* Create(GrDawnGpu*, const GrSurfaceDesc&, int sampleCnt,
- const GrDawnImageInfo&);
+ const GrDawnRenderTargetInfo&);
bool completeStencilAttachment() override;
- GrDawnImageInfo fInfo;
+ GrDawnRenderTargetInfo fInfo;
typedef GrRenderTarget INHERITED;
};
diff --git a/src/gpu/dawn/GrDawnTexture.cpp b/src/gpu/dawn/GrDawnTexture.cpp
index 4bbd5c2..80e45fc 100644
--- a/src/gpu/dawn/GrDawnTexture.cpp
+++ b/src/gpu/dawn/GrDawnTexture.cpp
@@ -15,7 +15,7 @@
GrDawnTexture::GrDawnTexture(GrDawnGpu* gpu,
SkISize dimensions,
wgpu::TextureView textureView,
- const GrDawnImageInfo& info,
+ const GrDawnTextureInfo& info,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, dimensions, GrProtected::kNo)
, GrTexture(gpu, dimensions, GrProtected::kNo, GrTextureType::k2D, mipMapsStatus)
@@ -58,7 +58,7 @@
return nullptr;
}
- GrDawnImageInfo info;
+ GrDawnTextureInfo info;
info.fTexture = tex;
info.fFormat = textureDesc.format;
info.fLevelCount = mipLevels;
@@ -86,7 +86,7 @@
GrRenderable renderable,
int sampleCnt, GrMipMapsStatus status,
GrWrapCacheable cacheable,
- const GrDawnImageInfo& info) {
+ const GrDawnTextureInfo& info) {
wgpu::TextureView textureView = info.fTexture.CreateView();
if (!textureView) {
return nullptr;
diff --git a/src/gpu/dawn/GrDawnTexture.h b/src/gpu/dawn/GrDawnTexture.h
index 1f11411..2b3c6d2 100644
--- a/src/gpu/dawn/GrDawnTexture.h
+++ b/src/gpu/dawn/GrDawnTexture.h
@@ -12,7 +12,6 @@
#include "dawn/webgpu_cpp.h"
class GrDawnGpu;
-struct GrDawnImageInfo;
class GrDawnTexture : public GrTexture {
public:
@@ -23,7 +22,7 @@
static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, SkISize dimensions,
GrRenderable, int sampleCnt,
GrMipMapsStatus, GrWrapCacheable,
- const GrDawnImageInfo&);
+ const GrDawnTextureInfo&);
~GrDawnTexture() override;
@@ -40,8 +39,8 @@
wgpu::Texture texture() const { return fInfo.fTexture; }
wgpu::TextureView textureView() const { return fTextureView; }
protected:
- GrDawnTexture(GrDawnGpu*, SkISize dimensions, wgpu::TextureView, const GrDawnImageInfo&,
- GrMipMapsStatus);
+ GrDawnTexture(GrDawnGpu*, SkISize dimensions, wgpu::TextureView,
+ const GrDawnTextureInfo&, GrMipMapsStatus);
GrDawnGpu* getDawnGpu() const;
@@ -53,9 +52,9 @@
}
private:
- GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnImageInfo&, GrMipMapsStatus);
+ GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnTextureInfo&, GrMipMapsStatus);
- GrDawnImageInfo fInfo;
+ GrDawnTextureInfo fInfo;
wgpu::TextureView fTextureView;
typedef GrTexture INHERITED;
diff --git a/src/gpu/dawn/GrDawnTextureRenderTarget.cpp b/src/gpu/dawn/GrDawnTextureRenderTarget.cpp
index a70b05e..3d27d19 100644
--- a/src/gpu/dawn/GrDawnTextureRenderTarget.cpp
+++ b/src/gpu/dawn/GrDawnTextureRenderTarget.cpp
@@ -16,11 +16,12 @@
SkISize dimensions,
wgpu::TextureView textureView,
int sampleCnt,
- const GrDawnImageInfo& info,
+ const GrDawnTextureInfo& textureInfo,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, dimensions, GrProtected::kNo)
- , GrDawnTexture(gpu, dimensions, textureView, info, mipMapsStatus)
- , GrDawnRenderTarget(gpu, dimensions, sampleCnt, info) {}
+ , GrDawnTexture(gpu, dimensions, textureView, textureInfo, mipMapsStatus)
+ , GrDawnRenderTarget(gpu, dimensions, sampleCnt,
+ GrDawnRenderTargetInfo(textureInfo)) {}
bool GrDawnTextureRenderTarget::canAttemptStencilAttachment() const {
return true;
diff --git a/src/gpu/dawn/GrDawnTextureRenderTarget.h b/src/gpu/dawn/GrDawnTextureRenderTarget.h
index bc6dffc..d96e11d 100644
--- a/src/gpu/dawn/GrDawnTextureRenderTarget.h
+++ b/src/gpu/dawn/GrDawnTextureRenderTarget.h
@@ -25,7 +25,7 @@
SkISize dimensions,
const wgpu::TextureView textureView,
int sampleCnt,
- const GrDawnImageInfo& info,
+ const GrDawnTextureInfo& textureInfo,
GrMipMapsStatus mipMapsStatus);
bool canAttemptStencilAttachment() const override;
diff --git a/tools/sk_app/DawnWindowContext.cpp b/tools/sk_app/DawnWindowContext.cpp
index 4b66ce4..1001fc0 100644
--- a/tools/sk_app/DawnWindowContext.cpp
+++ b/tools/sk_app/DawnWindowContext.cpp
@@ -66,28 +66,23 @@
}
sk_sp<SkSurface> DawnWindowContext::getBackbufferSurface() {
- GrDawnImageInfo imageInfo;
- imageInfo.fTexture = fSwapChain.GetNextTexture();
- imageInfo.fFormat = fSwapChainFormat;
- imageInfo.fLevelCount = 1; // FIXME
- GrBackendTexture backendTexture(fWidth, fHeight, imageInfo);
- fSurface = SkSurface::MakeFromBackendTextureAsRenderTarget(fContext.get(),
- backendTexture,
- this->getRTOrigin(),
- fDisplayParams.fMSAASampleCount,
- fDisplayParams.fColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ GrDawnRenderTargetInfo rtInfo;
+ rtInfo.fTextureView = fSwapChain.GetCurrentTextureView();
+ rtInfo.fFormat = fSwapChainFormat;
+ rtInfo.fLevelCount = 1; // FIXME
+ GrBackendRenderTarget backendRenderTarget(fWidth, fHeight, fDisplayParams.fMSAASampleCount, 8,
+ rtInfo);
+ fSurface = SkSurface::MakeFromBackendRenderTarget(fContext.get(),
+ backendRenderTarget,
+ this->getRTOrigin(),
+ fDisplayParams.fColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
return fSurface;
}
void DawnWindowContext::swapBuffers() {
- GrBackendRenderTarget backendRT = fSurface->getBackendRenderTarget(
- SkSurface::kFlushRead_BackendHandleAccess);
- GrDawnImageInfo imageInfo;
- SkAssertResult(backendRT.getDawnImageInfo(&imageInfo));
-
- fSwapChain.Present(imageInfo.fTexture);
+ fSwapChain.Present();
this->onSwapBuffers();
}
diff --git a/tools/sk_app/mac/DawnMTLWindowContext_mac.mm b/tools/sk_app/mac/DawnMTLWindowContext_mac.mm
index 61c7f99..5697236 100644
--- a/tools/sk_app/mac/DawnMTLWindowContext_mac.mm
+++ b/tools/sk_app/mac/DawnMTLWindowContext_mac.mm
@@ -52,9 +52,9 @@
~SwapChainImplMTL() {}
- DawnSwapChainError Configure(DawnTextureFormat format, DawnTextureUsage,
+ DawnSwapChainError Configure(WGPUTextureFormat format, WGPUTextureUsage,
uint32_t width, uint32_t height) {
- if (format != DAWN_TEXTURE_FORMAT_RGBA8_UNORM) {
+ if (format != WGPUTextureFormat::WGPUTextureFormat_RGBA8Unorm) {
return "unsupported format";
}
SkASSERT(width > 0);