Add memoryless parameter for MSAA attachment creation
Bug: skia:12086 Change-Id: I9ad293852850253a8c3b1ca6bac4cf86900daec5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449842 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
2816dcfc67
commit
8d59fe04b8
@ -152,6 +152,20 @@ enum class GrScissorTest : bool {
|
||||
kEnabled = true
|
||||
};
|
||||
|
||||
/*
|
||||
* Used to say whether texture is backed by memory.
|
||||
*/
|
||||
enum class GrMemoryless : bool {
|
||||
/**
|
||||
* The texture will be allocated normally and will affect memory budgets.
|
||||
*/
|
||||
kNo = false,
|
||||
/**
|
||||
* The texture will be not use GPU memory and will not affect memory budgets.
|
||||
*/
|
||||
kYes = true
|
||||
};
|
||||
|
||||
struct GrMipLevel {
|
||||
const void* fPixels = nullptr;
|
||||
size_t fRowBytes = 0;
|
||||
|
@ -629,7 +629,8 @@ public:
|
||||
virtual sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) = 0;
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) = 0;
|
||||
|
||||
void handleDirtyContext() {
|
||||
if (fResetBits) {
|
||||
|
@ -672,7 +672,8 @@ sk_sp<GrAttachment> GrResourceProvider::getDiscardableMSAAAttachment(SkISize dim
|
||||
if (msaaAttachment) {
|
||||
return msaaAttachment;
|
||||
}
|
||||
msaaAttachment = this->makeMSAAAttachment(dimensions, format, sampleCnt, isProtected);
|
||||
msaaAttachment = this->makeMSAAAttachment(dimensions, format, sampleCnt, isProtected,
|
||||
GrMemoryless::kNo);
|
||||
if (msaaAttachment) {
|
||||
this->assignUniqueKeyToResource(key, msaaAttachment.get());
|
||||
}
|
||||
@ -682,7 +683,8 @@ sk_sp<GrAttachment> GrResourceProvider::getDiscardableMSAAAttachment(SkISize dim
|
||||
sk_sp<GrAttachment> GrResourceProvider::makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int sampleCnt,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
SkASSERT(sampleCnt > 1);
|
||||
@ -705,7 +707,7 @@ sk_sp<GrAttachment> GrResourceProvider::makeMSAAAttachment(SkISize dimensions,
|
||||
return scratch;
|
||||
}
|
||||
|
||||
return fGpu->makeMSAAAttachment(dimensions, format, sampleCnt, isProtected);
|
||||
return fGpu->makeMSAAAttachment(dimensions, format, sampleCnt, isProtected, isMemoryless);
|
||||
}
|
||||
|
||||
sk_sp<GrAttachment> GrResourceProvider::refScratchMSAAAttachment(SkISize dimensions,
|
||||
|
@ -295,7 +295,8 @@ public:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int sampleCnt,
|
||||
GrProtected isProtected);
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless);
|
||||
|
||||
/**
|
||||
* Gets a GrAttachment that can be used for MSAA rendering. This attachment may be shared by
|
||||
|
@ -86,7 +86,8 @@ public:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) override {
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,8 @@ public:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) override {
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1721,7 +1721,9 @@ sk_sp<GrAttachment> GrGLGpu::makeStencilAttachment(const GrBackendFormat& colorF
|
||||
}
|
||||
|
||||
sk_sp<GrAttachment> GrGLGpu::makeMSAAAttachment(SkISize dimensions, const GrBackendFormat& format,
|
||||
int numSamples, GrProtected isProtected) {
|
||||
int numSamples, GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) {
|
||||
SkASSERT(isMemoryless == GrMemoryless::kNo);
|
||||
return GrGLAttachment::MakeMSAA(this, dimensions, numSamples, format.asGLFormat());
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,8 @@ public:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) override;
|
||||
GrProtected isProtected,
|
||||
GrMemoryless) override;
|
||||
|
||||
void deleteBackendTexture(const GrBackendTexture&) override;
|
||||
|
||||
|
@ -167,7 +167,8 @@ private:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) override {
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,8 @@ private:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) override;
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) override;
|
||||
|
||||
bool createMtlTextureForBackendSurface(MTLPixelFormat,
|
||||
SkISize dimensions,
|
||||
|
@ -529,7 +529,13 @@ sk_sp<GrAttachment> GrMtlGpu::makeStencilAttachment(const GrBackendFormat& /*col
|
||||
sk_sp<GrAttachment> GrMtlGpu::makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected /*isProtected*/) {
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) {
|
||||
// Metal doesn't support protected textures
|
||||
SkASSERT(isProtected == GrProtected::kNo);
|
||||
// TODO: add memoryless support
|
||||
SkASSERT(isMemoryless == GrMemoryless::kNo);
|
||||
|
||||
MTLPixelFormat pixelFormat = (MTLPixelFormat) format.asMtlFormat();
|
||||
SkASSERT(pixelFormat != MTLPixelFormatInvalid);
|
||||
SkASSERT(!GrMtlFormatIsCompressed(pixelFormat));
|
||||
|
@ -67,7 +67,8 @@ sk_sp<GrMtlRenderTarget> GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu* gp
|
||||
}
|
||||
auto rp = gpu->getContext()->priv().resourceProvider();
|
||||
sk_sp<GrAttachment> msaaAttachment = rp->makeMSAAAttachment(
|
||||
dimensions, GrBackendFormat::MakeMtl(format), sampleCnt, GrProtected::kNo);
|
||||
dimensions, GrBackendFormat::MakeMtl(format), sampleCnt, GrProtected::kNo,
|
||||
GrMemoryless::kNo);
|
||||
if (!msaaAttachment) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ bool create_rt_attachments(GrMtlGpu* gpu, SkISize dimensions, MTLPixelFormat for
|
||||
if (sampleCnt > 1) {
|
||||
auto rp = gpu->getContext()->priv().resourceProvider();
|
||||
sk_sp<GrAttachment> msaaAttachment = rp->makeMSAAAttachment(
|
||||
dimensions, GrBackendFormat::MakeMtl(format), sampleCnt, GrProtected::kNo);
|
||||
dimensions, GrBackendFormat::MakeMtl(format), sampleCnt, GrProtected::kNo,
|
||||
GrMemoryless::kNo);
|
||||
if (!msaaAttachment) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1486,7 +1486,11 @@ sk_sp<GrAttachment> GrVkGpu::makeStencilAttachment(const GrBackendFormat& /*colo
|
||||
sk_sp<GrAttachment> GrVkGpu::makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) {
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) {
|
||||
// TODO: add memoryless support
|
||||
SkASSERT(isMemoryless == GrMemoryless::kNo);
|
||||
|
||||
VkFormat pixelFormat;
|
||||
SkAssertResult(format.asVkFormat(&pixelFormat));
|
||||
SkASSERT(!GrVkFormatIsCompressed(pixelFormat));
|
||||
|
@ -118,7 +118,8 @@ public:
|
||||
sk_sp<GrAttachment> makeMSAAAttachment(SkISize dimensions,
|
||||
const GrBackendFormat& format,
|
||||
int numSamples,
|
||||
GrProtected isProtected) override;
|
||||
GrProtected isProtected,
|
||||
GrMemoryless isMemoryless) override;
|
||||
|
||||
void addBufferMemoryBarrier(const GrManagedResource*,
|
||||
VkPipelineStageFlags srcStageMask,
|
||||
|
@ -59,7 +59,8 @@ bool create_rt_attachments(GrVkGpu* gpu, SkISize dimensions, VkFormat format, in
|
||||
if (sampleCnt > 1) {
|
||||
auto rp = gpu->getContext()->priv().resourceProvider();
|
||||
sk_sp<GrAttachment> msaaAttachment = rp->makeMSAAAttachment(
|
||||
dimensions, GrBackendFormat::MakeVk(format), sampleCnt, isProtected);
|
||||
dimensions, GrBackendFormat::MakeVk(format), sampleCnt, isProtected,
|
||||
GrMemoryless::kNo);
|
||||
if (!msaaAttachment) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user