Remove special handling of stencil formats and just use GrBackendFormts.
Before this change each backend had its own special stencil format
struct that contained information like the actual format, stencil bits,
etc. This change removes all of that and instead reliess on static
helper functions that can return all this information based on the
backend format.
Besides being cleaner, this change helps move towards being able to
combine all surface attachment classes into a unified class.
Bug: skia:10727
Change-Id: I26003e44f55ce32293e9092bafce5baef6f938d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/322958
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 00b6164..5fe7a42 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -9,6 +9,7 @@
#include "src/gpu/GrRenderTarget.h"
#include "src/core/SkRectPriv.h"
+#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrSamplePatternDictionary.h"
@@ -68,7 +69,7 @@
int GrRenderTarget::numStencilBits() const {
SkASSERT(this->getStencilAttachment());
- return this->getStencilAttachment()->bits();
+ return GrBackendFormatStencilBits(this->getStencilAttachment()->backendFormat());
}
int GrRenderTarget::getSamplePatternKey() {
diff --git a/src/gpu/GrStencilAttachment.h b/src/gpu/GrStencilAttachment.h
index e0cf5a0..6d4d77e 100644
--- a/src/gpu/GrStencilAttachment.h
+++ b/src/gpu/GrStencilAttachment.h
@@ -21,7 +21,6 @@
// TODO: allow SB to be purged and detach itself from rts
}
- int bits() const { return fBits; }
int numSamples() const { return fSampleCnt; }
bool hasPerformedInitialClear() const { return fHasPerformedInitialClear; }
@@ -33,17 +32,14 @@
GrUniqueKey* key);
protected:
- GrStencilAttachment(GrGpu* gpu, SkISize dimensions, int bits, int sampleCnt,
- GrProtected isProtected)
+ GrStencilAttachment(GrGpu* gpu, SkISize dimensions, int sampleCnt, GrProtected isProtected)
: INHERITED(gpu, dimensions, isProtected)
- , fBits(bits)
, fSampleCnt(sampleCnt) {
}
private:
const char* getResourceType() const override { return "Stencil"; }
- int fBits;
int fSampleCnt;
bool fHasPerformedInitialClear = false;
diff --git a/src/gpu/d3d/GrD3DCaps.cpp b/src/gpu/d3d/GrD3DCaps.cpp
index faec7f4..4ebed3a 100644
--- a/src/gpu/d3d/GrD3DCaps.cpp
+++ b/src/gpu/d3d/GrD3DCaps.cpp
@@ -268,18 +268,11 @@
}
void GrD3DCaps::initStencilFormat(ID3D12Device* device) {
- // List of legal stencil formats (though perhaps not supported on
- // the particular gpu/driver) from most preferred to least.
- static const StencilFormat
- // internal Format stencil bits
- gD24S8 = { DXGI_FORMAT_D24_UNORM_S8_UINT, 8 },
- gD32S8 = { DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 8 };
-
if (stencil_format_supported(device, DXGI_FORMAT_D24_UNORM_S8_UINT)) {
- fPreferredStencilFormat = gD24S8;
+ fPreferredStencilFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
} else {
SkASSERT(stencil_format_supported(device, DXGI_FORMAT_D32_FLOAT_S8X24_UINT));
- fPreferredStencilFormat = gD32S8;
+ fPreferredStencilFormat = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
}
}
diff --git a/src/gpu/d3d/GrD3DCaps.h b/src/gpu/d3d/GrD3DCaps.h
index 1d16cb5..ec11d6f 100644
--- a/src/gpu/d3d/GrD3DCaps.h
+++ b/src/gpu/d3d/GrD3DCaps.h
@@ -20,8 +20,6 @@
*/
class GrD3DCaps : public GrCaps {
public:
- typedef GrD3DStencilAttachment::Format StencilFormat;
-
/**
* Creates a GrD3DCaps that is set such that nothing is supported. The init function should
* be called to fill out the caps.
@@ -57,7 +55,7 @@
/**
* Returns both a supported and most preferred stencil format to use in draws.
*/
- const StencilFormat& preferredStencilFormat() const {
+ DXGI_FORMAT preferredStencilFormat() const {
return fPreferredStencilFormat;
}
static int GetStencilFormatTotalBitCount(DXGI_FORMAT format) {
@@ -201,7 +199,7 @@
int fMaxPerStageShaderResourceViews;
int fMaxPerStageUnorderedAccessViews;
- StencilFormat fPreferredStencilFormat;
+ DXGI_FORMAT fPreferredStencilFormat;
using INHERITED = GrCaps;
};
diff --git a/src/gpu/d3d/GrD3DGpu.cpp b/src/gpu/d3d/GrD3DGpu.cpp
index a418496..87b6974 100644
--- a/src/gpu/d3d/GrD3DGpu.cpp
+++ b/src/gpu/d3d/GrD3DGpu.cpp
@@ -970,7 +970,7 @@
SkASSERT(dimensions.width() >= rt->width());
SkASSERT(dimensions.height() >= rt->height());
- const GrD3DCaps::StencilFormat& sFmt = this->d3dCaps().preferredStencilFormat();
+ DXGI_FORMAT sFmt = this->d3dCaps().preferredStencilFormat();
GrD3DStencilAttachment* stencil(GrD3DStencilAttachment::Make(this,
dimensions,
diff --git a/src/gpu/d3d/GrD3DOpsRenderPass.cpp b/src/gpu/d3d/GrD3DOpsRenderPass.cpp
index 2d9a7d3..c089f6c 100644
--- a/src/gpu/d3d/GrD3DOpsRenderPass.cpp
+++ b/src/gpu/d3d/GrD3DOpsRenderPass.cpp
@@ -7,6 +7,7 @@
#include "src/gpu/d3d/GrD3DOpsRenderPass.h"
+#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrProgramDesc.h"
#include "src/gpu/GrRenderTarget.h"
@@ -325,7 +326,7 @@
// this should only be called internally when we know we have a
// stencil buffer.
SkASSERT(sb);
- int stencilBitCount = sb->bits();
+ int stencilBitCount = GrBackendFormatStencilBits(sb->backendFormat());
// The contract with the callers does not guarantee that we preserve all bits in the stencil
// during this clear. Thus we will clear the entire stencil to the desired value.
diff --git a/src/gpu/d3d/GrD3DStencilAttachment.cpp b/src/gpu/d3d/GrD3DStencilAttachment.cpp
index 246154d..fec6187 100644
--- a/src/gpu/d3d/GrD3DStencilAttachment.cpp
+++ b/src/gpu/d3d/GrD3DStencilAttachment.cpp
@@ -11,23 +11,22 @@
GrD3DStencilAttachment::GrD3DStencilAttachment(GrD3DGpu* gpu,
SkISize dimensions,
- const Format& format,
+ DXGI_FORMAT format,
const D3D12_RESOURCE_DESC& desc,
const GrD3DTextureResourceInfo& info,
sk_sp<GrD3DResourceState> state,
const GrD3DDescriptorHeap::CPUHandle& view)
- : GrStencilAttachment(gpu, dimensions, format.fStencilBits,
- desc.SampleDesc.Count, GrProtected::kNo)
+ : GrStencilAttachment(gpu, dimensions, desc.SampleDesc.Count, GrProtected::kNo)
, GrD3DTextureResource(info, state)
, fView(view)
- , fFormat(format.fInternalFormat) {
+ , fFormat(format) {
this->registerWithCache(SkBudgeted::kYes);
}
GrD3DStencilAttachment* GrD3DStencilAttachment::Make(GrD3DGpu* gpu,
SkISize dimensions,
int sampleCnt,
- const Format& format) {
+ DXGI_FORMAT format) {
D3D12_RESOURCE_DESC resourceDesc = {};
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
resourceDesc.Alignment = 0; // default alignment
@@ -35,14 +34,14 @@
resourceDesc.Height = dimensions.height();
resourceDesc.DepthOrArraySize = 1;
resourceDesc.MipLevels = 1;
- resourceDesc.Format = format.fInternalFormat;
+ resourceDesc.Format = format;
resourceDesc.SampleDesc.Count = sampleCnt;
resourceDesc.SampleDesc.Quality = DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN;
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; // use driver-selected swizzle
resourceDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
D3D12_CLEAR_VALUE clearValue = {};
- clearValue.Format = format.fInternalFormat;
+ clearValue.Format = format;
clearValue.DepthStencil.Depth = 0;
clearValue.DepthStencil.Stencil = 0;
diff --git a/src/gpu/d3d/GrD3DStencilAttachment.h b/src/gpu/d3d/GrD3DStencilAttachment.h
index 69ee45b..2534ec7 100644
--- a/src/gpu/d3d/GrD3DStencilAttachment.h
+++ b/src/gpu/d3d/GrD3DStencilAttachment.h
@@ -18,13 +18,8 @@
class GrD3DStencilAttachment : public GrStencilAttachment, public GrD3DTextureResource {
public:
- struct Format {
- DXGI_FORMAT fInternalFormat;
- int fStencilBits;
- };
-
static GrD3DStencilAttachment* Make(GrD3DGpu* gpu, SkISize dimensions, int sampleCnt,
- const Format& format);
+ DXGI_FORMAT format);
~GrD3DStencilAttachment() override {}
@@ -43,7 +38,7 @@
GrD3DStencilAttachment(GrD3DGpu* gpu,
SkISize dimensions,
- const Format& format,
+ DXGI_FORMAT format,
const D3D12_RESOURCE_DESC&,
const GrD3DTextureResourceInfo&,
sk_sp<GrD3DResourceState>,
diff --git a/src/gpu/dawn/GrDawnStencilAttachment.cpp b/src/gpu/dawn/GrDawnStencilAttachment.cpp
index eb42770..ee18c15 100644
--- a/src/gpu/dawn/GrDawnStencilAttachment.cpp
+++ b/src/gpu/dawn/GrDawnStencilAttachment.cpp
@@ -14,11 +14,10 @@
GrDawnStencilAttachment::GrDawnStencilAttachment(GrDawnGpu* gpu,
SkISize dimensions,
- int bits,
int samples,
wgpu::Texture texture,
wgpu::TextureView view)
- : INHERITED(gpu, dimensions, bits, samples, GrProtected::kNo)
+ : INHERITED(gpu, dimensions, samples, GrProtected::kNo)
, fTexture(texture)
, fView(view) {
this->registerWithCache(SkBudgeted::kYes);
@@ -41,7 +40,7 @@
if (!view) {
return nullptr;
}
- return new GrDawnStencilAttachment(gpu, dimensions, 8, sampleCnt, texture, view);
+ return new GrDawnStencilAttachment(gpu, dimensions, sampleCnt, texture, view);
}
GrDawnStencilAttachment::~GrDawnStencilAttachment() {
diff --git a/src/gpu/dawn/GrDawnStencilAttachment.h b/src/gpu/dawn/GrDawnStencilAttachment.h
index efa5cd4..6bf4a60 100644
--- a/src/gpu/dawn/GrDawnStencilAttachment.h
+++ b/src/gpu/dawn/GrDawnStencilAttachment.h
@@ -31,7 +31,7 @@
private:
size_t onGpuMemorySize() const override;
- GrDawnStencilAttachment(GrDawnGpu* gpu, SkISize dimensions, int bits, int samples,
+ GrDawnStencilAttachment(GrDawnGpu* gpu, SkISize dimensions, int samples,
wgpu::Texture texture, wgpu::TextureView view);
GrDawnGpu* getDawnGpu() const;
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 381ffe2..4c2f402 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -1098,14 +1098,8 @@
// Build up list of legal stencil formats (though perhaps not supported on
// the particular gpu/driver) from most preferred to least.
- // these consts are in order of most preferred to least preferred
- // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8
-
- static const StencilFormat
- // internal Format stencil bits total bits packed?
- gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false},
- gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false},
- gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true };
+ // We push back stencil formats onto the fStencilFormats array in order of most preferred to
+ // least preferred.
if (GR_IS_GR_GL(ctxInfo.standard())) {
bool supportsPackedDS =
@@ -1116,24 +1110,24 @@
// S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we
// require FBO support we can expect these are legal formats and don't
// check.
- fStencilFormats.push_back() = gS8;
- fStencilFormats.push_back() = gS16;
+ fStencilFormats.push_back() = GrGLFormat::kSTENCIL_INDEX8;
+ fStencilFormats.push_back() = GrGLFormat::kSTENCIL_INDEX16;
if (supportsPackedDS) {
- fStencilFormats.push_back() = gD24S8;
+ fStencilFormats.push_back() = GrGLFormat::kDEPTH24_STENCIL8;
}
} else if (GR_IS_GR_GL_ES(ctxInfo.standard())) {
// ES2 has STENCIL_INDEX8 without extensions but requires extensions
// for other formats.
- fStencilFormats.push_back() = gS8;
+ fStencilFormats.push_back() = GrGLFormat::kSTENCIL_INDEX8;
if (ctxInfo.version() >= GR_GL_VER(3,0) ||
ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) {
- fStencilFormats.push_back() = gD24S8;
+ fStencilFormats.push_back() = GrGLFormat::kDEPTH24_STENCIL8;
}
} else if (GR_IS_GR_WEBGL(ctxInfo.standard())) {
- fStencilFormats.push_back() = gS8;
+ fStencilFormats.push_back() = GrGLFormat::kSTENCIL_INDEX8;
if (ctxInfo.version() >= GR_GL_VER(2,0)) {
- fStencilFormats.push_back() = gD24S8;
+ fStencilFormats.push_back() = GrGLFormat::kDEPTH24_STENCIL8;
}
}
}
@@ -1149,8 +1143,8 @@
for (int i = 0; i < fStencilFormats.count(); ++i) {
writer->beginObject(nullptr, false);
- writer->appendS32("stencil bits", fStencilFormats[i].fStencilBits);
- writer->appendS32("total bits", fStencilFormats[i].fTotalBits);
+ writer->appendS32("stencil bits", GrGLFormatStencilBits(fStencilFormats[i]));
+ writer->appendS32("total bytes", GrGLFormatBytesPerBlock(fStencilFormats[i]));
writer->endObject();
}
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 05bfe10..936be05 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -29,8 +29,6 @@
*/
class GrGLCaps : public GrCaps {
public:
- typedef GrGLStencilAttachment::Format StencilFormat;
-
/**
* The type of MSAA for FBOs supported. Different extensions have different
* semantics of how / when a resolve is performed.
@@ -187,7 +185,7 @@
* to be supported by the driver but are legal GLenum names given the GL
* version and extensions supported.
*/
- const SkTArray<StencilFormat, true>& stencilFormats() const {
+ const SkTArray<GrGLFormat, true>& stencilFormats() const {
return fStencilFormats;
}
@@ -519,7 +517,7 @@
GrGLStandard fStandard = kNone_GrGLStandard;
- SkTArray<StencilFormat, true> fStencilFormats;
+ SkTArray<GrGLFormat, true> fStencilFormats;
int fMaxFragmentUniformVectors = 0;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index a766cac..1cb4c52 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1567,14 +1567,14 @@
if (sbRBID) {
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbRBID));
for (int i = 0; i < stencilFmtCnt && sbRBID; ++i) {
- const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[i];
+ GrGLFormat sFmt = this->glCaps().stencilFormats()[i];
GrGLenum error = GL_ALLOC_CALL(RenderbufferStorage(
- GR_GL_RENDERBUFFER, sFmt.fInternalFormat, kSize, kSize));
+ GR_GL_RENDERBUFFER, GrGLFormatToEnum(sFmt), kSize, kSize));
if (error == GR_GL_NO_ERROR) {
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
GR_GL_RENDERBUFFER, sbRBID));
- if (sFmt.fPacked) {
+ if (GrGLFormatIsPackedDepthStencil(sFmt)) {
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_DEPTH_ATTACHMENT,
GR_GL_RENDERBUFFER, sbRBID));
@@ -1592,7 +1592,7 @@
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
GR_GL_RENDERBUFFER, 0));
- if (sFmt.fPacked) {
+ if (GrGLFormatIsPackedDepthStencil(sFmt)) {
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_DEPTH_ATTACHMENT,
GR_GL_RENDERBUFFER, 0));
@@ -1712,17 +1712,18 @@
return nullptr;
}
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID));
- const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[sIdx];
+ GrGLFormat sFmt = this->glCaps().stencilFormats()[sIdx];
+ GrGLenum glFmt = GrGLFormatToEnum(sFmt);
// we do this "if" so that we don't call the multisample
// version on a GL that doesn't have an MSAA extension.
if (numStencilSamples > 1) {
- if (!this->renderbufferStorageMSAA(*fGLContext, numStencilSamples, sFmt.fInternalFormat,
+ if (!this->renderbufferStorageMSAA(*fGLContext, numStencilSamples, glFmt,
dimensions.width(), dimensions.height())) {
GL_CALL(DeleteRenderbuffers(1, &sbDesc.fRenderbufferID));
return nullptr;
}
} else {
- GrGLenum error = GL_ALLOC_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, sFmt.fInternalFormat,
+ GrGLenum error = GL_ALLOC_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, glFmt,
dimensions.width(),
dimensions.height()));
if (error != GR_GL_NO_ERROR) {
@@ -2044,7 +2045,7 @@
return;
}
- GrGLint stencilBitCount = sb->bits();
+ GrGLint stencilBitCount = GrBackendFormatStencilBits(sb->backendFormat());
#if 0
SkASSERT(stencilBitCount > 0);
GrGLint clipStencilMask = (1 << (stencilBitCount - 1));
@@ -3809,12 +3810,13 @@
GR_GL_RENDERBUFFER, colorID));
}
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, stencilID));
- auto stencilBufferFormat = this->glCaps().stencilFormats()[sFormatIdx].fInternalFormat;
+ auto stencilBufferFormat = this->glCaps().stencilFormats()[sFormatIdx];
if (sampleCnt == 1) {
- GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, stencilBufferFormat, dimensions.width(),
- dimensions.height()));
+ GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, GrGLFormatToEnum(stencilBufferFormat),
+ dimensions.width(), dimensions.height()));
} else {
- if (!this->renderbufferStorageMSAA(this->glContext(), sampleCnt, stencilBufferFormat,
+ if (!this->renderbufferStorageMSAA(this->glContext(), sampleCnt,
+ GrGLFormatToEnum(stencilBufferFormat),
dimensions.width(), dimensions.height())) {
deleteIDs();
return {};
@@ -3822,7 +3824,7 @@
}
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, GR_GL_STENCIL_ATTACHMENT, GR_GL_RENDERBUFFER,
stencilID));
- if (this->glCaps().stencilFormats()[sFormatIdx].fPacked) {
+ if (GrGLFormatIsPackedDepthStencil(this->glCaps().stencilFormats()[sFormatIdx])) {
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, GR_GL_DEPTH_ATTACHMENT,
GR_GL_RENDERBUFFER, stencilID));
}
@@ -3842,7 +3844,7 @@
return {};
}
- auto stencilBits = SkToInt(this->glCaps().stencilFormats()[sFormatIdx].fStencilBits);
+ auto stencilBits = SkToInt(GrGLFormatStencilBits(this->glCaps().stencilFormats()[sFormatIdx]));
GrBackendRenderTarget beRT = GrBackendRenderTarget(dimensions.width(), dimensions.height(),
sampleCnt, stencilBits, info);
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index 0c7ea1c..184f1db 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -9,6 +9,7 @@
#include "include/core/SkTraceMemoryDump.h"
#include "include/gpu/GrDirectContext.h"
+#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpuResourcePriv.h"
#include "src/gpu/gl/GrGLGpu.h"
@@ -58,6 +59,22 @@
fNumSamplesOwnedPerPixel = this->totalSamples();
}
+GrGLFormat stencil_bits_to_format(int stencilBits) {
+ SkASSERT(stencilBits);
+ switch (stencilBits) {
+ case 8:
+ // We pick the packed format here so when we query total size we are at least not
+ // underestimating the total size of the stencil buffer. However, in reality this
+ // rarely matters since we usually don't care about the size of wrapped objects.
+ return GrGLFormat::kDEPTH24_STENCIL8;
+ case 16:
+ return GrGLFormat::kSTENCIL_INDEX16;
+ default:
+ SkASSERT(false);
+ return GrGLFormat::kUnknown;
+ }
+}
+
sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
const SkISize& dimensions,
GrGLFormat format,
@@ -67,13 +84,15 @@
GrGLStencilAttachment* sb = nullptr;
if (stencilBits) {
GrGLStencilAttachment::IDDesc sbDesc;
- GrGLStencilAttachment::Format format;
- format.fInternalFormat = GrGLStencilAttachment::kUnknownInternalFormat;
- format.fPacked = false;
- format.fStencilBits = stencilBits;
- format.fTotalBits = stencilBits;
+ // We pick a "fake" actual format that matches the number of stencil bits. When wrapping
+ // an FBO with some number of stencil bits all we care about in the future is that we have
+ // a format with the same number of stencil bits. We don't even directly use the format or
+ // any other properties. Thus it is fine for us to just assign an arbitrary format that
+ // matches the stencil bit count.
+ GrGLFormat sFmt = stencil_bits_to_format(stencilBits);
+
// Ownership of sb is passed to the GrRenderTarget so doesn't need to be deleted
- sb = new GrGLStencilAttachment(gpu, sbDesc, dimensions, sampleCount, format);
+ sb = new GrGLStencilAttachment(gpu, sbDesc, dimensions, sampleCount, sFmt);
}
return sk_sp<GrGLRenderTarget>(
new GrGLRenderTarget(gpu, dimensions, format, sampleCount, idDesc, sb));
@@ -85,7 +104,7 @@
fbi.fFormat = GrGLFormatToEnum(this->format());
int numStencilBits = 0;
if (GrStencilAttachment* stencil = this->getStencilAttachment()) {
- numStencilBits = stencil->bits();
+ numStencilBits = GrBackendFormatStencilBits(stencil->backendFormat());
}
return GrBackendRenderTarget(
@@ -133,7 +152,7 @@
GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
GR_GL_RENDERBUFFER, rb));
- if (glStencil->format().fPacked) {
+ if (GrGLFormatIsPackedDepthStencil(glStencil->format())) {
GR_GL_CALL(interface, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_DEPTH_ATTACHMENT,
GR_GL_RENDERBUFFER, rb));
diff --git a/src/gpu/gl/GrGLStencilAttachment.cpp b/src/gpu/gl/GrGLStencilAttachment.cpp
index c98d866..c56fb9c 100644
--- a/src/gpu/gl/GrGLStencilAttachment.cpp
+++ b/src/gpu/gl/GrGLStencilAttachment.cpp
@@ -13,9 +13,9 @@
size_t GrGLStencilAttachment::onGpuMemorySize() const {
uint64_t size = this->width();
size *= this->height();
- size *= fFormat.fTotalBits;
+ size *= GrGLFormatBytesPerBlock(fFormat);
size *= this->numSamples();
- return static_cast<size_t>(size / 8);
+ return static_cast<size_t>(size);
}
void GrGLStencilAttachment::onRelease() {
@@ -36,7 +36,7 @@
}
GrBackendFormat GrGLStencilAttachment::backendFormat() const {
- return GrBackendFormat::MakeGL(fFormat.fInternalFormat, GR_GL_TEXTURE_NONE);
+ return GrBackendFormat::MakeGL(GrGLFormatToEnum(fFormat), GR_GL_TEXTURE_NONE);
}
void GrGLStencilAttachment::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
diff --git a/src/gpu/gl/GrGLStencilAttachment.h b/src/gpu/gl/GrGLStencilAttachment.h
index b6c3a67..a65f507 100644
--- a/src/gpu/gl/GrGLStencilAttachment.h
+++ b/src/gpu/gl/GrGLStencilAttachment.h
@@ -14,14 +14,6 @@
class GrGLStencilAttachment : public GrStencilAttachment {
public:
- static const GrGLenum kUnknownInternalFormat = ~0U;
- struct Format {
- GrGLenum fInternalFormat;
- GrGLuint fStencilBits;
- GrGLuint fTotalBits;
- bool fPacked;
- };
-
struct IDDesc {
IDDesc() : fRenderbufferID(0) {}
GrGLuint fRenderbufferID;
@@ -31,8 +23,8 @@
const IDDesc& idDesc,
SkISize dimensions,
int sampleCnt,
- const Format& format)
- : GrStencilAttachment(gpu, dimensions, format.fStencilBits, sampleCnt, GrProtected::kNo)
+ GrGLFormat format)
+ : GrStencilAttachment(gpu, dimensions, sampleCnt, GrProtected::kNo)
, fFormat(format)
, fRenderbufferID(idDesc.fRenderbufferID) {
this->registerWithCache(SkBudgeted::kYes);
@@ -44,7 +36,7 @@
return fRenderbufferID;
}
- const Format& format() const { return fFormat; }
+ GrGLFormat format() const { return fFormat; }
protected:
// overrides of GrResource
@@ -56,7 +48,8 @@
private:
size_t onGpuMemorySize() const override;
- Format fFormat;
+ GrGLFormat fFormat;
+
// may be zero for external SBs associated with external RTs
// (we don't require the client to give us the id, just tell
// us how many bits of stencil there are).
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index c7724c4..104ee5d 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -269,9 +269,8 @@
GrStencilAttachment* GrMockGpu::createStencilAttachmentForRenderTarget(
const GrRenderTarget* rt, SkISize dimensions, int numStencilSamples) {
SkASSERT(numStencilSamples == rt->numSamples());
- static constexpr int kBits = 8;
fStats.incStencilAttachmentCreates();
- return new GrMockStencilAttachment(this, dimensions, kBits, rt->numSamples());
+ return new GrMockStencilAttachment(this, dimensions, rt->numSamples());
}
GrBackendTexture GrMockGpu::onCreateBackendTexture(SkISize dimensions,
diff --git a/src/gpu/mock/GrMockStencilAttachment.h b/src/gpu/mock/GrMockStencilAttachment.h
index 9d25307..1d0d476 100644
--- a/src/gpu/mock/GrMockStencilAttachment.h
+++ b/src/gpu/mock/GrMockStencilAttachment.h
@@ -8,21 +8,26 @@
#ifndef GrMockStencilAttachment_DEFINED
#define GrMockStencilAttachment_DEFINED
+#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrStencilAttachment.h"
#include "src/gpu/mock/GrMockGpu.h"
class GrMockStencilAttachment : public GrStencilAttachment {
public:
- GrMockStencilAttachment(GrMockGpu* gpu, SkISize dimensions, int bits, int sampleCnt)
- : INHERITED(gpu, dimensions, bits, sampleCnt, GrProtected::kNo) {
+ GrMockStencilAttachment(GrMockGpu* gpu, SkISize dimensions, int sampleCnt)
+ : INHERITED(gpu, dimensions, sampleCnt, GrProtected::kNo) {
this->registerWithCache(SkBudgeted::kYes);
}
- GrBackendFormat backendFormat() const override { return GrBackendFormat(); }
+ GrBackendFormat backendFormat() const override {
+ return GrBackendFormat::MakeMock(GrColorType::kUnknown, SkImage::CompressionType::kNone,
+ /*isStencilFormat*/ true);
+ }
private:
size_t onGpuMemorySize() const override {
- return std::max(1, (int)(this->bits() / sizeof(char))) * this->width() * this->height();
+ int bpp = GrBackendFormatBytesPerBlock(this->backendFormat());
+ return std::max(1, (int)(bpp)) * this->width() * this->height();
}
using INHERITED = GrStencilAttachment;
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index 135ab99..b99a02b 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -116,7 +116,7 @@
GrBackendRenderTarget getBackendRenderTarget() const override {
int numStencilBits = 0;
if (GrStencilAttachment* stencil = this->getStencilAttachment()) {
- numStencilBits = stencil->bits();
+ numStencilBits = GrBackendFormatStencilBits(stencil->backendFormat());
}
return {this->width(), this->height(), this->numSamples(), numStencilBits, fInfo};
}
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 9ecfc02..7b46242 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -21,8 +21,6 @@
*/
class GrMtlCaps : public GrCaps {
public:
- typedef GrMtlStencilAttachment::Format StencilFormat;
-
GrMtlCaps(const GrContextOptions& contextOptions, id<MTLDevice> device,
MTLFeatureSet featureSet);
@@ -56,7 +54,7 @@
/**
* Returns both a supported and most prefered stencil format to use in draws.
*/
- const StencilFormat& preferredStencilFormat() const {
+ MTLPixelFormat preferredStencilFormat() const {
return fPreferredStencilFormat;
}
@@ -189,7 +187,7 @@
SkTDArray<int> fSampleCounts;
- StencilFormat fPreferredStencilFormat;
+ MTLPixelFormat fPreferredStencilFormat;
using INHERITED = GrCaps;
};
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 5b744f2..962f9b9 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -892,7 +892,7 @@
}
void GrMtlCaps::initStencilFormat(id<MTLDevice> physDev) {
- fPreferredStencilFormat = StencilFormat{ MTLPixelFormatStencil8, 8, 8, true };
+ fPreferredStencilFormat = MTLPixelFormatStencil8;
}
bool GrMtlCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const {
@@ -1089,7 +1089,7 @@
}
#endif
- b.add32(rt && rt->getStencilAttachment() ? this->preferredStencilFormat().fInternalFormat
+ b.add32(rt && rt->getStencilAttachment() ? this->preferredStencilFormat()
: MTLPixelFormatInvalid);
b.add32((uint32_t)programInfo.isStencilEnabled());
// Stencil samples don't seem to be tracked in the MTLRenderPipeline
@@ -1147,8 +1147,8 @@
writer->beginObject("Metal caps");
writer->beginObject("Preferred Stencil Format");
- writer->appendS32("stencil bits", fPreferredStencilFormat.fStencilBits);
- writer->appendS32("total bits", fPreferredStencilFormat.fTotalBits);
+ writer->appendS32("stencil bits", GrMtlFormatStencilBits(fPreferredStencilFormat));
+ writer->appendS32("total bytes", GrMtlFormatBytesPerBlock(fPreferredStencilFormat));
writer->endObject();
switch (fPlatform) {
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index 2b7ec88..e380671 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -505,7 +505,7 @@
int samples = rt->numSamples();
- const GrMtlCaps::StencilFormat& sFmt = this->mtlCaps().preferredStencilFormat();
+ MTLPixelFormat sFmt = this->mtlCaps().preferredStencilFormat();
GrMtlStencilAttachment* stencil(GrMtlStencilAttachment::Create(this,
dimensions,
diff --git a/src/gpu/mtl/GrMtlOpsRenderPass.mm b/src/gpu/mtl/GrMtlOpsRenderPass.mm
index e066d99..afe1af7 100644
--- a/src/gpu/mtl/GrMtlOpsRenderPass.mm
+++ b/src/gpu/mtl/GrMtlOpsRenderPass.mm
@@ -7,6 +7,7 @@
#include "src/gpu/mtl/GrMtlOpsRenderPass.h"
+#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrColor.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/mtl/GrMtlCommandBuffer.h"
@@ -145,7 +146,7 @@
// this should only be called internally when we know we have a
// stencil buffer.
SkASSERT(sb);
- int stencilBitCount = sb->bits();
+ int stencilBitCount = GrBackendFormatStencilBits(sb->backendFormat());
// The contract with the callers does not guarantee that we preserve all bits in the stencil
// during this clear. Thus we will clear the entire stencil to the desired value.
diff --git a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
index e603cdf..5ce964f 100644
--- a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
+++ b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
@@ -499,8 +499,7 @@
bool hasStencilAttachment = SkToBool(renderTarget->getStencilAttachment());
GrMtlCaps* mtlCaps = (GrMtlCaps*)this->caps();
pipelineDescriptor.stencilAttachmentPixelFormat =
- hasStencilAttachment ? mtlCaps->preferredStencilFormat().fInternalFormat
- : MTLPixelFormatInvalid;
+ hasStencilAttachment ? mtlCaps->preferredStencilFormat() : MTLPixelFormatInvalid;
SkASSERT(pipelineDescriptor.vertexFunction);
SkASSERT(pipelineDescriptor.fragmentFunction);
diff --git a/src/gpu/mtl/GrMtlStencilAttachment.h b/src/gpu/mtl/GrMtlStencilAttachment.h
index 9d78b22..35887c9 100644
--- a/src/gpu/mtl/GrMtlStencilAttachment.h
+++ b/src/gpu/mtl/GrMtlStencilAttachment.h
@@ -17,15 +17,8 @@
class GrMtlStencilAttachment : public GrStencilAttachment {
public:
- struct Format {
- MTLPixelFormat fInternalFormat;
- int fStencilBits;
- int fTotalBits;
- bool fPacked;
- };
-
static GrMtlStencilAttachment* Create(GrMtlGpu* gpu, SkISize dimensions,
- int sampleCnt, const Format& format);
+ int sampleCnt, MTLPixelFormat format);
~GrMtlStencilAttachment() override;
@@ -33,7 +26,7 @@
return GrBackendFormat::MakeMtl(fStencilView.pixelFormat);
}
- MTLPixelFormat mtlFormat() const { return fFormat.fInternalFormat; }
+ MTLPixelFormat mtlFormat() const { return fStencilView.pixelFormat; }
id<MTLTexture> stencilView() const { return fStencilView; }
@@ -46,13 +39,10 @@
GrMtlStencilAttachment(GrMtlGpu* gpu,
SkISize dimensions,
- const Format& format,
const id<MTLTexture> stencilView);
GrMtlGpu* getMtlGpu() const;
- Format fFormat;
-
id<MTLTexture> fStencilView;
};
diff --git a/src/gpu/mtl/GrMtlStencilAttachment.mm b/src/gpu/mtl/GrMtlStencilAttachment.mm
index 8ade63e..5abea33 100644
--- a/src/gpu/mtl/GrMtlStencilAttachment.mm
+++ b/src/gpu/mtl/GrMtlStencilAttachment.mm
@@ -14,11 +14,8 @@
GrMtlStencilAttachment::GrMtlStencilAttachment(GrMtlGpu* gpu,
SkISize dimensions,
- const Format& format,
const id<MTLTexture> stencilView)
- : GrStencilAttachment(gpu, dimensions, format.fStencilBits,
- stencilView.sampleCount, GrProtected::kNo)
- , fFormat(format)
+ : GrStencilAttachment(gpu, dimensions, stencilView.sampleCount, GrProtected::kNo)
, fStencilView(stencilView) {
this->registerWithCache(SkBudgeted::kYes);
}
@@ -26,9 +23,9 @@
GrMtlStencilAttachment* GrMtlStencilAttachment::Create(GrMtlGpu* gpu,
SkISize dimensions,
int sampleCnt,
- const Format& format) {
+ MTLPixelFormat format) {
MTLTextureDescriptor* desc =
- [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format.fInternalFormat
+ [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:format
width:dimensions.width()
height:dimensions.height()
mipmapped:NO];
@@ -40,7 +37,7 @@
if (sampleCnt > 1) {
desc.textureType = MTLTextureType2DMultisample;
}
- return new GrMtlStencilAttachment(gpu, dimensions, format,
+ return new GrMtlStencilAttachment(gpu, dimensions,
[gpu->device() newTextureWithDescriptor:desc]);
}
@@ -52,9 +49,9 @@
size_t GrMtlStencilAttachment::onGpuMemorySize() const {
uint64_t size = this->width();
size *= this->height();
- size *= fFormat.fTotalBits;
+ size *= GrMtlFormatBytesPerBlock(this->mtlFormat());
size *= this->numSamples();
- return static_cast<size_t>(size / 8);
+ return static_cast<size_t>(size);
}
void GrMtlStencilAttachment::onRelease() {
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 2c8d4aa..70acc3c 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -681,22 +681,13 @@
}
void GrVkCaps::initStencilFormat(const GrVkInterface* interface, VkPhysicalDevice physDev) {
- // List of legal stencil formats (though perhaps not supported on
- // the particular gpu/driver) from most preferred to least. We are guaranteed to have either
- // VK_FORMAT_D24_UNORM_S8_UINT or VK_FORMAT_D32_SFLOAT_S8_UINT.
- static const StencilFormat
- // internal Format stencil bits
- gS8 = { VK_FORMAT_S8_UINT, 8 },
- gD24S8 = { VK_FORMAT_D24_UNORM_S8_UINT, 8 },
- gD32S8 = { VK_FORMAT_D32_SFLOAT_S8_UINT, 8 };
-
if (stencil_format_supported(interface, physDev, VK_FORMAT_S8_UINT)) {
- fPreferredStencilFormat = gS8;
+ fPreferredStencilFormat = VK_FORMAT_S8_UINT;
} else if (stencil_format_supported(interface, physDev, VK_FORMAT_D24_UNORM_S8_UINT)) {
- fPreferredStencilFormat = gD24S8;
+ fPreferredStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
} else {
SkASSERT(stencil_format_supported(interface, physDev, VK_FORMAT_D32_SFLOAT_S8_UINT));
- fPreferredStencilFormat = gD32S8;
+ fPreferredStencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
}
}
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index 80e7948..96e3b52 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -21,8 +21,6 @@
*/
class GrVkCaps : public GrCaps {
public:
- typedef GrVkStencilAttachment::Format StencilFormat;
-
/**
* Creates a GrVkCaps that is set such that nothing is supported. The init function should
* be called to fill out the caps.
@@ -92,7 +90,7 @@
/**
* Returns both a supported and most preferred stencil format to use in draws.
*/
- const StencilFormat& preferredStencilFormat() const {
+ VkFormat preferredStencilFormat() const {
return fPreferredStencilFormat;
}
@@ -304,7 +302,7 @@
VkFormat fColorTypeToFormatTable[kGrColorTypeCnt];
void setColorType(GrColorType, std::initializer_list<VkFormat> formats);
- StencilFormat fPreferredStencilFormat;
+ VkFormat fPreferredStencilFormat;
SkSTArray<1, GrVkYcbcrConversionInfo> fYcbcrInfos;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index d77c019..5b274c2 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1546,7 +1546,7 @@
SkASSERT(dimensions.width() >= rt->width());
SkASSERT(dimensions.height() >= rt->height());
- const GrVkCaps::StencilFormat& sFmt = this->vkCaps().preferredStencilFormat();
+ VkFormat sFmt = this->vkCaps().preferredStencilFormat();
GrVkStencilAttachment* stencil(GrVkStencilAttachment::Create(this,
dimensions,
diff --git a/src/gpu/vk/GrVkOpsRenderPass.cpp b/src/gpu/vk/GrVkOpsRenderPass.cpp
index 188fe24..379c683 100644
--- a/src/gpu/vk/GrVkOpsRenderPass.cpp
+++ b/src/gpu/vk/GrVkOpsRenderPass.cpp
@@ -11,6 +11,7 @@
#include "include/core/SkRect.h"
#include "include/gpu/GrBackendDrawableInfo.h"
#include "include/gpu/GrDirectContext.h"
+#include "src/gpu/GrBackendUtils.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrOpFlushState.h"
#include "src/gpu/GrPipeline.h"
@@ -306,7 +307,7 @@
// this should only be called internally when we know we have a
// stencil buffer.
SkASSERT(sb);
- int stencilBitCount = sb->bits();
+ int stencilBitCount = GrBackendFormatStencilBits(sb->backendFormat());
// The contract with the callers does not guarantee that we preserve all bits in the stencil
// during this clear. Thus we will clear the entire stencil to the desired value.
diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp
index 29e7d68..1cbc2af 100644
--- a/src/gpu/vk/GrVkRenderTarget.cpp
+++ b/src/gpu/vk/GrVkRenderTarget.cpp
@@ -406,8 +406,8 @@
SkASSERT(!programInfo.isStencilEnabled() || programInfo.numStencilSamples());
if (programInfo.numStencilSamples()) {
- const GrVkCaps::StencilFormat& stencilFormat = vkCaps.preferredStencilFormat();
- desc->fStencil.fFormat = stencilFormat.fInternalFormat;
+ VkFormat stencilFormat = vkCaps.preferredStencilFormat();
+ desc->fStencil.fFormat = stencilFormat;
desc->fStencil.fSamples = programInfo.numStencilSamples();
#ifdef SK_DEBUG
if (vkCaps.mixedSamplesSupport()) {
diff --git a/src/gpu/vk/GrVkStencilAttachment.cpp b/src/gpu/vk/GrVkStencilAttachment.cpp
index 553c5e5..eec276b 100644
--- a/src/gpu/vk/GrVkStencilAttachment.cpp
+++ b/src/gpu/vk/GrVkStencilAttachment.cpp
@@ -15,12 +15,12 @@
GrVkStencilAttachment::GrVkStencilAttachment(GrVkGpu* gpu,
SkISize dimensions,
- const Format& format,
+ VkFormat format,
const GrVkImage::ImageDesc& desc,
const GrVkImageInfo& info,
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState,
sk_sp<const GrVkImageView> stencilView)
- : GrStencilAttachment(gpu, dimensions, format.fStencilBits, desc.fSamples, info.fProtected)
+ : GrStencilAttachment(gpu, dimensions, desc.fSamples, info.fProtected)
, GrVkImage(gpu, info, std::move(mutableState), GrBackendObjectOwnership::kOwned)
, fStencilView(std::move(stencilView)) {
this->registerWithCache(SkBudgeted::kYes);
@@ -29,10 +29,10 @@
GrVkStencilAttachment* GrVkStencilAttachment::Create(GrVkGpu* gpu,
SkISize dimensions,
int sampleCnt,
- const Format& format) {
+ VkFormat format) {
GrVkImage::ImageDesc imageDesc;
imageDesc.fImageType = VK_IMAGE_TYPE_2D;
- imageDesc.fFormat = format.fInternalFormat;
+ imageDesc.fFormat = format;
imageDesc.fWidth = dimensions.width();
imageDesc.fHeight = dimensions.height();
imageDesc.fLevels = 1;
@@ -47,8 +47,7 @@
return nullptr;
}
- sk_sp<const GrVkImageView> imageView = GrVkImageView::Make(gpu, info.fImage,
- format.fInternalFormat,
+ sk_sp<const GrVkImageView> imageView = GrVkImageView::Make(gpu, info.fImage, format,
GrVkImageView::kStencil_Type, 1,
GrVkYcbcrConversionInfo());
if (!imageView) {
diff --git a/src/gpu/vk/GrVkStencilAttachment.h b/src/gpu/vk/GrVkStencilAttachment.h
index 660e549..9a4d116 100644
--- a/src/gpu/vk/GrVkStencilAttachment.h
+++ b/src/gpu/vk/GrVkStencilAttachment.h
@@ -17,13 +17,8 @@
class GrVkStencilAttachment : public GrStencilAttachment, public GrVkImage {
public:
- struct Format {
- VkFormat fInternalFormat;
- int fStencilBits;
- };
-
static GrVkStencilAttachment* Create(GrVkGpu* gpu, SkISize dimensions, int sampleCnt,
- const Format& format);
+ VkFormat format);
~GrVkStencilAttachment() override;
@@ -41,7 +36,7 @@
GrVkStencilAttachment(GrVkGpu* gpu,
SkISize dimensions,
- const Format& format,
+ VkFormat format,
const GrVkImage::ImageDesc&,
const GrVkImageInfo&,
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState,