Revert "Further centralize computation of GrSurface VRAM consumption"
This reverts commit ccd3c8937f
.
Reason for revert: Blocking Chromium roll: https://codereview.chromium.org/2482643002/
Original change's description:
> Further centralize computation of GrSurface VRAM consumption
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4383
>
> Change-Id: I054b74f2cd15f904f8e05af0fda58d6e8a523eb9
> Reviewed-on: https://skia-review.googlesource.com/4383
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=662630
Change-Id: I186db2a41eb2bd789e6f681b3547e32d9ca374cf
Reviewed-on: https://skia-review.googlesource.com/4443
Commit-Queue: Ben Wagner <benjaminwagner@google.com>
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
This commit is contained in:
parent
ce4d04ae8e
commit
9c46b68d53
@ -146,9 +146,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {
|
||||||
if (!info.width() || !info.height()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return MakeRenderTarget(gr, b, info, 0, kBottomLeft_GrSurfaceOrigin, nullptr);
|
return MakeRenderTarget(gr, b, info, 0, kBottomLeft_GrSurfaceOrigin, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +119,8 @@ public:
|
|||||||
return (GrRenderTargetOpList*) this->getLastOpList();
|
return (GrRenderTargetOpList*) this->getLastOpList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t ComputeSize(const GrSurfaceDesc& desc, int colorValuesPerPixel);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum class Flags {
|
enum class Flags {
|
||||||
kNone = 0,
|
kNone = 0,
|
||||||
|
@ -126,12 +126,11 @@ public:
|
|||||||
fReleaseCtx = ctx;
|
fReleaseCtx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t WorstCaseSize(const GrSurfaceDesc& desc);
|
||||||
|
|
||||||
void setLastOpList(GrOpList* opList);
|
void setLastOpList(GrOpList* opList);
|
||||||
GrOpList* getLastOpList() { return fLastOpList; }
|
GrOpList* getLastOpList() { return fLastOpList; }
|
||||||
|
|
||||||
static size_t WorstCaseSize(const GrSurfaceDesc& desc);
|
|
||||||
static size_t ComputeSize(const GrSurfaceDesc& desc, int colorSamplesPerPixel, bool hasMIPMaps);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Methods made available via GrSurfacePriv
|
// Methods made available via GrSurfacePriv
|
||||||
bool savePixels(const char* filename);
|
bool savePixels(const char* filename);
|
||||||
|
@ -45,6 +45,8 @@ public:
|
|||||||
inline GrTexturePriv texturePriv();
|
inline GrTexturePriv texturePriv();
|
||||||
inline const GrTexturePriv texturePriv() const;
|
inline const GrTexturePriv texturePriv() const;
|
||||||
|
|
||||||
|
static size_t ComputeSize(const GrSurfaceDesc&, bool hasMipMaps);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType, bool wasMipMapDataProvided);
|
GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType, bool wasMipMapDataProvided);
|
||||||
|
|
||||||
|
@ -84,6 +84,17 @@ void GrRenderTarget::onAbandon() {
|
|||||||
INHERITED::onAbandon();
|
INHERITED::onAbandon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t GrRenderTarget::ComputeSize(const GrSurfaceDesc& desc, int colorValuesPerPixel) {
|
||||||
|
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
|
||||||
|
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
|
||||||
|
size_t colorBytes = GrBytesPerPixel(desc.fConfig);
|
||||||
|
SkASSERT(colorBytes > 0);
|
||||||
|
|
||||||
|
size_t rtSize = colorValuesPerPixel * desc.fWidth * desc.fHeight * colorBytes;
|
||||||
|
SkASSERT(rtSize <= WorstCaseSize(desc));
|
||||||
|
return rtSize;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) {
|
bool GrRenderTargetPriv::attachStencilAttachment(GrStencilAttachment* stencil) {
|
||||||
|
@ -82,7 +82,7 @@ size_t GrRenderTargetProxy::onGpuMemorySize() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: do we have enough information to improve this worst case estimate?
|
// TODO: do we have enough information to improve this worst case estimate?
|
||||||
return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, false);
|
return GrRenderTarget::ComputeSize(fDesc, fDesc.fSampleCnt+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps,
|
sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps,
|
||||||
|
@ -38,16 +38,15 @@ size_t GrSurface::WorstCaseSize(const GrSurfaceDesc& desc) {
|
|||||||
}
|
}
|
||||||
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
|
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
|
||||||
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
|
SkASSERT(!GrPixelConfigIsCompressed(desc.fConfig));
|
||||||
size_t colorBytes = desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
|
size_t colorBytes = GrBytesPerPixel(desc.fConfig);
|
||||||
SkASSERT(colorBytes > 0);
|
SkASSERT(colorBytes > 0);
|
||||||
|
|
||||||
size = colorValuesPerPixel * colorBytes;
|
size = (size_t) colorValuesPerPixel * desc.fWidth * desc.fHeight * colorBytes;
|
||||||
size += colorBytes/3; // in case we have to mipmap
|
|
||||||
} else {
|
} else {
|
||||||
if (GrPixelConfigIsCompressed(desc.fConfig)) {
|
if (GrPixelConfigIsCompressed(desc.fConfig)) {
|
||||||
size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
|
size = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
|
||||||
} else {
|
} else {
|
||||||
size = desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
|
size = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
size += size/3; // in case we have to mipmap
|
size += size/3; // in case we have to mipmap
|
||||||
@ -56,31 +55,6 @@ size_t GrSurface::WorstCaseSize(const GrSurfaceDesc& desc) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GrSurface::ComputeSize(const GrSurfaceDesc& desc,
|
|
||||||
int colorSamplesPerPixel,
|
|
||||||
bool hasMIPMaps) {
|
|
||||||
size_t colorSize;
|
|
||||||
|
|
||||||
SkASSERT(kUnknown_GrPixelConfig != desc.fConfig);
|
|
||||||
if (GrPixelConfigIsCompressed(desc.fConfig)) {
|
|
||||||
colorSize = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
|
|
||||||
} else {
|
|
||||||
colorSize = desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
|
|
||||||
}
|
|
||||||
SkASSERT(colorSize > 0);
|
|
||||||
|
|
||||||
size_t finalSize = colorSamplesPerPixel * colorSize;
|
|
||||||
|
|
||||||
if (hasMIPMaps) {
|
|
||||||
// We don't have to worry about the mipmaps being a different size than
|
|
||||||
// we'd expect because we never change fDesc.fWidth/fHeight.
|
|
||||||
finalSize += colorSize/3;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkASSERT(finalSize <= WorstCaseSize(desc));
|
|
||||||
return finalSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> static bool adjust_params(int surfaceWidth,
|
template<typename T> static bool adjust_params(int surfaceWidth,
|
||||||
int surfaceHeight,
|
int surfaceHeight,
|
||||||
size_t bpp,
|
size_t bpp,
|
||||||
|
@ -35,8 +35,29 @@ void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t GrTexture::ComputeSize(const GrSurfaceDesc& desc, bool hasMipMaps) {
|
||||||
|
size_t textureSize;
|
||||||
|
|
||||||
|
if (GrPixelConfigIsCompressed(desc.fConfig)) {
|
||||||
|
textureSize = GrCompressedFormatDataSize(desc.fConfig, desc.fWidth, desc.fHeight);
|
||||||
|
} else {
|
||||||
|
textureSize = (size_t) desc.fWidth * desc.fHeight * GrBytesPerPixel(desc.fConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasMipMaps) {
|
||||||
|
// We don't have to worry about the mipmaps being a different size than
|
||||||
|
// we'd expect because we never change fDesc.fWidth/fHeight.
|
||||||
|
textureSize += textureSize/3;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkASSERT(!SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag));
|
||||||
|
SkASSERT(textureSize <= WorstCaseSize(desc));
|
||||||
|
|
||||||
|
return textureSize;
|
||||||
|
}
|
||||||
|
|
||||||
size_t GrTexture::onGpuMemorySize() const {
|
size_t GrTexture::onGpuMemorySize() const {
|
||||||
return GrSurface::ComputeSize(fDesc, 1, this->texturePriv().hasMipMaps());
|
return ComputeSize(fDesc, this->texturePriv().hasMipMaps());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrTexture::validateDesc() const {
|
void GrTexture::validateDesc() const {
|
||||||
|
@ -46,7 +46,7 @@ size_t GrTextureProxy::onGpuMemorySize() const {
|
|||||||
|
|
||||||
static const bool kHasMipMaps = true;
|
static const bool kHasMipMaps = true;
|
||||||
// TODO: add tracking of mipmap state to improve the estimate
|
// TODO: add tracking of mipmap state to improve the estimate
|
||||||
return GrSurface::ComputeSize(fDesc, 1, kHasMipMaps);
|
return GrTexture::ComputeSize(fDesc, kHasMipMaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> GrTextureProxy::Make(GrTextureProvider* texProvider,
|
sk_sp<GrTextureProxy> GrTextureProxy::Make(GrTextureProvider* texProvider,
|
||||||
|
@ -1642,11 +1642,6 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
|
|||||||
return return_null_texture();
|
return return_null_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wasMipMapDataProvided = false;
|
|
||||||
if (texels.count() > 1) {
|
|
||||||
wasMipMapDataProvided = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
GrGLTexture* tex;
|
GrGLTexture* tex;
|
||||||
if (renderTarget) {
|
if (renderTarget) {
|
||||||
// unbind the texture from the texture unit before binding it to the frame buffer
|
// unbind the texture from the texture unit before binding it to the frame buffer
|
||||||
@ -1657,9 +1652,12 @@ GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
|
|||||||
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
|
GL_CALL(DeleteTextures(1, &idDesc.fInfo.fID));
|
||||||
return return_null_texture();
|
return return_null_texture();
|
||||||
}
|
}
|
||||||
tex = new GrGLTextureRenderTarget(this, budgeted, desc, idDesc, rtIDDesc,
|
tex = new GrGLTextureRenderTarget(this, budgeted, desc, idDesc, rtIDDesc);
|
||||||
wasMipMapDataProvided);
|
|
||||||
} else {
|
} else {
|
||||||
|
bool wasMipMapDataProvided = false;
|
||||||
|
if (texels.count() > 1) {
|
||||||
|
wasMipMapDataProvided = true;
|
||||||
|
}
|
||||||
tex = new GrGLTexture(this, budgeted, desc, idDesc, wasMipMapDataProvided);
|
tex = new GrGLTexture(this, budgeted, desc, idDesc, wasMipMapDataProvided);
|
||||||
}
|
}
|
||||||
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
|
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
|
||||||
|
@ -82,7 +82,7 @@ sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t GrGLRenderTarget::onGpuMemorySize() const {
|
size_t GrGLRenderTarget::onGpuMemorySize() const {
|
||||||
return GrSurface::ComputeSize(fDesc, fNumSamplesOwnedPerPixel, false);
|
return GrRenderTarget::ComputeSize(fDesc, fNumSamplesOwnedPerPixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrGLRenderTarget::completeStencilAttachment() {
|
bool GrGLRenderTarget::completeStencilAttachment() {
|
||||||
@ -183,7 +183,7 @@ void GrGLRenderTarget::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump)
|
|||||||
// Log any renderbuffer's contribution to memory. We only do this if we own the renderbuffer
|
// Log any renderbuffer's contribution to memory. We only do this if we own the renderbuffer
|
||||||
// (have a fMSColorRenderbufferID).
|
// (have a fMSColorRenderbufferID).
|
||||||
if (fMSColorRenderbufferID) {
|
if (fMSColorRenderbufferID) {
|
||||||
size_t size = GrSurface::ComputeSize(fDesc, this->msaaSamples(), false);
|
size_t size = GrRenderTarget::ComputeSize(fDesc, this->msaaSamples());
|
||||||
|
|
||||||
// Due to this resource having both a texture and a renderbuffer component, dump as
|
// Due to this resource having both a texture and a renderbuffer component, dump as
|
||||||
// skia/gpu_resources/resource_#/renderbuffer
|
// skia/gpu_resources/resource_#/renderbuffer
|
||||||
|
@ -77,7 +77,8 @@ protected:
|
|||||||
void onAbandon() override;
|
void onAbandon() override;
|
||||||
void onRelease() override;
|
void onRelease() override;
|
||||||
|
|
||||||
int numSamplesOwnedPerPixel() const { return fNumSamplesOwnedPerPixel; }
|
// In protected because subclass GrGLTextureRenderTarget calls this version.
|
||||||
|
size_t onGpuMemorySize() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constructor for instances wrapping backend objects.
|
// Constructor for instances wrapping backend objects.
|
||||||
@ -88,8 +89,6 @@ private:
|
|||||||
GrGLGpu* getGLGpu() const;
|
GrGLGpu* getGLGpu() const;
|
||||||
bool completeStencilAttachment() override;
|
bool completeStencilAttachment() override;
|
||||||
|
|
||||||
size_t onGpuMemorySize() const override;
|
|
||||||
|
|
||||||
int msaaSamples() const;
|
int msaaSamples() const;
|
||||||
// The number total number of samples, including both MSAA and resolve texture samples.
|
// The number total number of samples, including both MSAA and resolve texture samples.
|
||||||
int totalSamples() const;
|
int totalSamples() const;
|
||||||
|
@ -50,10 +50,9 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const
|
|||||||
this->registerWithCacheWrapped();
|
this->registerWithCacheWrapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
|
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc)
|
||||||
bool wasMipMapDataProvided)
|
|
||||||
: GrSurface(gpu, desc)
|
: GrSurface(gpu, desc)
|
||||||
, INHERITED(gpu, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
|
, INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
|
||||||
this->init(desc, idDesc);
|
this->init(desc, idDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
static sk_sp<GrGLTexture> MakeWrapped(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
|
static sk_sp<GrGLTexture> MakeWrapped(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
|
||||||
protected:
|
protected:
|
||||||
// Constructor for subclasses.
|
// Constructor for subclasses.
|
||||||
GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, bool wasMipMapDataProvided);
|
GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
|
||||||
|
|
||||||
enum Wrapped { kWrapped };
|
enum Wrapped { kWrapped };
|
||||||
// Constructor for instances wrapping backend objects.
|
// Constructor for instances wrapping backend objects.
|
||||||
|
@ -49,5 +49,5 @@ sk_sp<GrGLTextureRenderTarget> GrGLTextureRenderTarget::MakeWrapped(
|
|||||||
const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc)
|
const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc)
|
||||||
{
|
{
|
||||||
return sk_sp<GrGLTextureRenderTarget>(
|
return sk_sp<GrGLTextureRenderTarget>(
|
||||||
new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc, false));
|
new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc));
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "GrGLGpu.h"
|
#include "GrGLGpu.h"
|
||||||
#include "GrGLTexture.h"
|
#include "GrGLTexture.h"
|
||||||
#include "GrGLRenderTarget.h"
|
#include "GrGLRenderTarget.h"
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
|
|
||||||
class GrGLGpu;
|
class GrGLGpu;
|
||||||
|
|
||||||
@ -30,10 +29,9 @@ public:
|
|||||||
SkBudgeted budgeted,
|
SkBudgeted budgeted,
|
||||||
const GrSurfaceDesc& desc,
|
const GrSurfaceDesc& desc,
|
||||||
const GrGLTexture::IDDesc& texIDDesc,
|
const GrGLTexture::IDDesc& texIDDesc,
|
||||||
const GrGLRenderTarget::IDDesc& rtIDDesc,
|
const GrGLRenderTarget::IDDesc& rtIDDesc)
|
||||||
bool wasMipMapDataProvided)
|
|
||||||
: GrSurface(gpu, desc)
|
: GrSurface(gpu, desc)
|
||||||
, GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
|
, GrGLTexture(gpu, desc, texIDDesc)
|
||||||
, GrGLRenderTarget(gpu, desc, rtIDDesc) {
|
, GrGLRenderTarget(gpu, desc, rtIDDesc) {
|
||||||
this->registerWithCache(budgeted);
|
this->registerWithCache(budgeted);
|
||||||
}
|
}
|
||||||
@ -61,18 +59,16 @@ private:
|
|||||||
GrGLTextureRenderTarget(GrGLGpu* gpu,
|
GrGLTextureRenderTarget(GrGLGpu* gpu,
|
||||||
const GrSurfaceDesc& desc,
|
const GrSurfaceDesc& desc,
|
||||||
const GrGLTexture::IDDesc& texIDDesc,
|
const GrGLTexture::IDDesc& texIDDesc,
|
||||||
const GrGLRenderTarget::IDDesc& rtIDDesc,
|
const GrGLRenderTarget::IDDesc& rtIDDesc)
|
||||||
bool wasMipMapDataProvided)
|
|
||||||
: GrSurface(gpu, desc)
|
: GrSurface(gpu, desc)
|
||||||
, GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
|
, GrGLTexture(gpu, desc, texIDDesc)
|
||||||
, GrGLRenderTarget(gpu, desc, rtIDDesc) {
|
, GrGLRenderTarget(gpu, desc, rtIDDesc) {
|
||||||
this->registerWithCacheWrapped();
|
this->registerWithCacheWrapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
|
||||||
size_t onGpuMemorySize() const override {
|
size_t onGpuMemorySize() const override {
|
||||||
return GrSurface::ComputeSize(fDesc,
|
return GrGLRenderTarget::onGpuMemorySize();
|
||||||
this->numSamplesOwnedPerPixel(),
|
|
||||||
this->texturePriv().hasMipMaps());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -100,8 +100,7 @@ protected:
|
|||||||
// This accounts for the texture's memory and any MSAA renderbuffer's memory.
|
// This accounts for the texture's memory and any MSAA renderbuffer's memory.
|
||||||
size_t onGpuMemorySize() const override {
|
size_t onGpuMemorySize() const override {
|
||||||
// The plus 1 is to account for the resolve texture.
|
// The plus 1 is to account for the resolve texture.
|
||||||
// TODO: is this still correct?
|
return GrRenderTarget::ComputeSize(fDesc, fDesc.fSampleCnt+1); // TODO: this still correct?
|
||||||
return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createFramebuffer(GrVkGpu* gpu);
|
void createFramebuffer(GrVkGpu* gpu);
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
#include "GrVkRenderTarget.h"
|
#include "GrVkRenderTarget.h"
|
||||||
#include "GrVkGpu.h"
|
#include "GrVkGpu.h"
|
||||||
|
|
||||||
#include "GrTexturePriv.h"
|
|
||||||
|
|
||||||
#ifdef SK_BUILD_FOR_WIN
|
#ifdef SK_BUILD_FOR_WIN
|
||||||
// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
|
// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
@ -114,9 +112,7 @@ private:
|
|||||||
|
|
||||||
// GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
|
// GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
|
||||||
size_t onGpuMemorySize() const override {
|
size_t onGpuMemorySize() const override {
|
||||||
// The plus 1 is to account for the resolve texture.
|
return GrVkRenderTarget::onGpuMemorySize();
|
||||||
return GrSurface::ComputeSize(fDesc, fDesc.fSampleCnt+1, // TODO: this still correct?
|
|
||||||
this->texturePriv().hasMipMaps());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
#include "SkGr.h"
|
#include "SkGr.h"
|
||||||
#include "SkMessageBus.h"
|
#include "SkMessageBus.h"
|
||||||
#include "SkMipMap.h"
|
|
||||||
#include "SkSurface.h"
|
#include "SkSurface.h"
|
||||||
#include "Test.h"
|
#include "Test.h"
|
||||||
|
|
||||||
@ -1345,105 +1344,4 @@ DEF_GPUTEST(ResourceCacheMisc, reporter, factory) {
|
|||||||
test_abandoned(reporter);
|
test_abandoned(reporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
static sk_sp<GrTexture> make_normal_texture(GrTextureProvider* provider,
|
|
||||||
GrSurfaceFlags flags,
|
|
||||||
int width, int height,
|
|
||||||
int sampleCnt) {
|
|
||||||
GrSurfaceDesc desc;
|
|
||||||
desc.fFlags = flags;
|
|
||||||
desc.fWidth = width;
|
|
||||||
desc.fHeight = height;
|
|
||||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
||||||
desc.fSampleCnt = sampleCnt;
|
|
||||||
|
|
||||||
return sk_sp<GrTexture>(provider->createTexture(desc, SkBudgeted::kYes));
|
|
||||||
}
|
|
||||||
|
|
||||||
static sk_sp<GrTexture> make_mipmap_texture(GrTextureProvider* provider,
|
|
||||||
GrSurfaceFlags flags,
|
|
||||||
int width, int height,
|
|
||||||
int sampleCnt) {
|
|
||||||
SkBitmap bm;
|
|
||||||
|
|
||||||
bm.allocN32Pixels(width, height, true);
|
|
||||||
bm.eraseColor(SK_ColorBLUE);
|
|
||||||
|
|
||||||
SkAutoTUnref<SkMipMap> mipmaps(SkMipMap::Build(bm, SkSourceGammaTreatment::kIgnore, nullptr));
|
|
||||||
SkASSERT(mipmaps);
|
|
||||||
SkASSERT(mipmaps->countLevels() > 1);
|
|
||||||
|
|
||||||
int mipLevelCount = mipmaps->countLevels() + 1;
|
|
||||||
|
|
||||||
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
|
|
||||||
|
|
||||||
texels[0].fPixels = bm.getPixels();
|
|
||||||
texels[0].fRowBytes = bm.rowBytes();
|
|
||||||
|
|
||||||
for (int i = 1; i < mipLevelCount; ++i) {
|
|
||||||
SkMipMap::Level generatedMipLevel;
|
|
||||||
mipmaps->getLevel(i - 1, &generatedMipLevel);
|
|
||||||
texels[i].fPixels = generatedMipLevel.fPixmap.addr();
|
|
||||||
texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
|
||||||
desc.fFlags = flags;
|
|
||||||
desc.fWidth = width;
|
|
||||||
desc.fHeight = height;
|
|
||||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
||||||
desc.fSampleCnt = sampleCnt;
|
|
||||||
desc.fIsMipMapped = true;
|
|
||||||
|
|
||||||
return sk_sp<GrTexture>(provider->createMipMappedTexture(desc, SkBudgeted::kYes,
|
|
||||||
texels.get(), mipLevelCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exercise GrSurface::gpuMemorySize for different combos of MSAA, RT-only,
|
|
||||||
// Texture-only, both-RT-and-Texture and MIPmapped
|
|
||||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GPUMemorySize, reporter, ctxInfo) {
|
|
||||||
GrContext* context = ctxInfo.grContext();
|
|
||||||
GrTextureProvider* provider = context->textureProvider();
|
|
||||||
|
|
||||||
static const int kSize = 64;
|
|
||||||
|
|
||||||
sk_sp<GrTexture> tex;
|
|
||||||
|
|
||||||
// Normal versions
|
|
||||||
tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
|
|
||||||
size_t size = tex->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
|
|
||||||
|
|
||||||
if (context->caps()->maxSampleCount() >= 4) {
|
|
||||||
tex = make_normal_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
|
|
||||||
size = tex->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4 == size || // msaa4 failed
|
|
||||||
kSize*kSize*4*4 == size || // auto-resolving
|
|
||||||
kSize*kSize*4*5 == size); // explicit resolve buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
tex = make_normal_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
|
|
||||||
size = tex->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4 == size);
|
|
||||||
|
|
||||||
// Mipmapped versions
|
|
||||||
tex = make_mipmap_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 0);
|
|
||||||
size = tex->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
|
|
||||||
|
|
||||||
if (context->caps()->maxSampleCount() >= 4) {
|
|
||||||
tex = make_mipmap_texture(provider, kRenderTarget_GrSurfaceFlag, kSize, kSize, 4);
|
|
||||||
size = tex->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter,
|
|
||||||
kSize*kSize*4+(kSize*kSize*4)/3 == size || // msaa4 failed
|
|
||||||
kSize*kSize*4*4+(kSize*kSize*4)/3 == size || // auto-resolving
|
|
||||||
kSize*kSize*4*5+(kSize*kSize*4)/3 == size); // explicit resolve buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
tex = make_mipmap_texture(provider, kNone_GrSurfaceFlags, kSize, kSize, 0);
|
|
||||||
size = tex->gpuMemorySize();
|
|
||||||
REPORTER_ASSERT(reporter, kSize*kSize*4+(kSize*kSize*4)/3 == size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user