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>
This commit is contained in:
parent
6aa65053d9
commit
f03c116021
2
DEPS
2
DEPS
@ -8,7 +8,7 @@ deps = {
|
||||
"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",
|
||||
|
@ -206,7 +206,7 @@ public:
|
||||
#ifdef SK_DAWN
|
||||
GrBackendTexture(int width,
|
||||
int height,
|
||||
const GrDawnImageInfo& dawnInfo);
|
||||
const GrDawnTextureInfo& dawnInfo);
|
||||
#endif
|
||||
|
||||
GrBackendTexture(int width,
|
||||
@ -234,9 +234,9 @@ public:
|
||||
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 @@ private:
|
||||
GrMtlTextureInfo fMtlInfo;
|
||||
#endif
|
||||
#ifdef SK_DAWN
|
||||
GrDawnImageInfo fDawnInfo;
|
||||
GrDawnTextureInfo fDawnInfo;
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -338,7 +338,7 @@ public:
|
||||
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 @@ public:
|
||||
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 @@ private:
|
||||
GrMtlTextureInfo fMtlInfo;
|
||||
#endif
|
||||
#ifdef SK_DAWN
|
||||
GrDawnImageInfo fDawnInfo;
|
||||
GrDawnRenderTargetInfo fDawnInfo;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -22,28 +22,64 @@ static constexpr int None = 0L;
|
||||
#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
|
||||
|
@ -313,7 +313,7 @@ SkString GrBackendFormat::toStr() const {
|
||||
#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 @@ GrBackendTexture& GrBackendTexture::operator=(const GrBackendTexture& that) {
|
||||
}
|
||||
|
||||
#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 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
|
||||
int height,
|
||||
int sampleCnt,
|
||||
int stencilBits,
|
||||
const GrDawnImageInfo& dawnInfo)
|
||||
const GrDawnRenderTargetInfo& dawnInfo)
|
||||
: fIsValid(true)
|
||||
, fFramebufferOnly(true)
|
||||
, fWidth(width)
|
||||
@ -816,7 +816,7 @@ GrBackendRenderTarget& GrBackendRenderTarget::operator=(const GrBackendRenderTar
|
||||
}
|
||||
|
||||
#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;
|
||||
@ -897,6 +897,13 @@ GrBackendFormat GrBackendRenderTarget::getBackendFormat() const {
|
||||
SkAssertResult(this->getMtlTextureInfo(&mtlInfo));
|
||||
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();
|
||||
|
@ -183,8 +183,8 @@ sk_sp<GrTexture> GrDawnGpu::onWrapBackendTexture(const GrBackendTexture& backend
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
GrIOType) {
|
||||
GrDawnImageInfo info;
|
||||
if (!backendTex.getDawnImageInfo(&info)) {
|
||||
GrDawnTextureInfo info;
|
||||
if (!backendTex.getDawnTextureInfo(&info)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -205,8 +205,8 @@ sk_sp<GrTexture> GrDawnGpu::onWrapRenderableBackendTexture(const GrBackendTextur
|
||||
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<GrTexture> GrDawnGpu::onWrapRenderableBackendTexture(const GrBackendTextur
|
||||
|
||||
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::onWrapBackendRenderTarget(const GrBackendRender
|
||||
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 @@ sk_sp<GrRenderTarget> GrDawnGpu::onWrapBackendTextureAsRenderTarget(const GrBack
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrDawnRenderTargetInfo info(textureInfo);
|
||||
return GrDawnRenderTarget::MakeWrapped(this, dimensions, sampleCnt, info);
|
||||
}
|
||||
|
||||
@ -349,7 +350,7 @@ GrBackendTexture GrDawnGpu::onCreateBackendTexture(SkISize dimensions,
|
||||
}
|
||||
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 @@ GrBackendTexture GrDawnGpu::onCreateCompressedBackendTexture(SkISize dimensions,
|
||||
}
|
||||
|
||||
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 @@ GrBackendRenderTarget GrDawnGpu::createTestingOnlyBackendRenderTarget(int width,
|
||||
|
||||
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 @@ bool GrDawnGpu::onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfac
|
||||
}
|
||||
|
||||
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 @@ bool GrDawnGpu::onReadPixels(GrSurface* surface, int left, int top, int width, i
|
||||
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;
|
||||
|
@ -56,16 +56,12 @@ GrDawnOpsRenderPass::GrDawnOpsRenderPass(GrDawnGpu* gpu, GrRenderTarget* rt, GrS
|
||||
|
||||
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;
|
||||
|
@ -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 @@ GrDawnRenderTarget::GrDawnRenderTarget(GrDawnGpu* gpu,
|
||||
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;
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*,
|
||||
SkISize dimensions,
|
||||
int sampleCnt,
|
||||
const GrDawnImageInfo&);
|
||||
const GrDawnRenderTargetInfo&);
|
||||
|
||||
~GrDawnRenderTarget() override;
|
||||
|
||||
@ -28,13 +28,13 @@ public:
|
||||
|
||||
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 @@ protected:
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -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 @@ sk_sp<GrDawnTexture> GrDawnTexture::Make(GrDawnGpu* gpu, SkISize dimensions,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrDawnImageInfo info;
|
||||
GrDawnTextureInfo info;
|
||||
info.fTexture = tex;
|
||||
info.fFormat = textureDesc.format;
|
||||
info.fLevelCount = mipLevels;
|
||||
@ -86,7 +86,7 @@ sk_sp<GrDawnTexture> GrDawnTexture::MakeWrapped(GrDawnGpu* gpu, SkISize dimensio
|
||||
GrRenderable renderable,
|
||||
int sampleCnt, GrMipMapsStatus status,
|
||||
GrWrapCacheable cacheable,
|
||||
const GrDawnImageInfo& info) {
|
||||
const GrDawnTextureInfo& info) {
|
||||
wgpu::TextureView textureView = info.fTexture.CreateView();
|
||||
if (!textureView) {
|
||||
return nullptr;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "dawn/webgpu_cpp.h"
|
||||
|
||||
class GrDawnGpu;
|
||||
struct GrDawnImageInfo;
|
||||
|
||||
class GrDawnTexture : public GrTexture {
|
||||
public:
|
||||
@ -23,7 +22,7 @@ public:
|
||||
static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, SkISize dimensions,
|
||||
GrRenderable, int sampleCnt,
|
||||
GrMipMapsStatus, GrWrapCacheable,
|
||||
const GrDawnImageInfo&);
|
||||
const GrDawnTextureInfo&);
|
||||
|
||||
~GrDawnTexture() override;
|
||||
|
||||
@ -40,8 +39,8 @@ public:
|
||||
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 @@ protected:
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -16,11 +16,12 @@ GrDawnTextureRenderTarget::GrDawnTextureRenderTarget(GrDawnGpu* gpu,
|
||||
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;
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
SkISize dimensions,
|
||||
const wgpu::TextureView textureView,
|
||||
int sampleCnt,
|
||||
const GrDawnImageInfo& info,
|
||||
const GrDawnTextureInfo& textureInfo,
|
||||
GrMipMapsStatus mipMapsStatus);
|
||||
|
||||
bool canAttemptStencilAttachment() const override;
|
||||
|
@ -66,28 +66,23 @@ void DawnWindowContext::destroyContext() {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,9 @@ public:
|
||||
|
||||
~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);
|
||||
|
Loading…
Reference in New Issue
Block a user