aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLGpu.cpp29
-rw-r--r--src/gpu/gl/GrGLGpu.h6
-rw-r--r--src/gpu/gl/GrGLTexture.cpp13
-rw-r--r--src/gpu/gl/GrGLTexture.h5
-rw-r--r--src/gpu/gl/GrGLTextureRenderTarget.cpp12
-rw-r--r--src/gpu/gl/GrGLTextureRenderTarget.h6
6 files changed, 45 insertions, 26 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 159cec721f..bef1f1919f 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -1009,7 +1009,8 @@ void GrGLGpu::unbindCpuToGpuXferBuffer() {
bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight,
GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType,
int left, int top, int width, int height, GrPixelConfig dataConfig,
- const GrMipLevel texels[], int mipLevelCount) {
+ const GrMipLevel texels[], int mipLevelCount,
+ bool* wasFullMipMapDataProvided) {
SkASSERT(this->caps()->isConfigTexturable(texConfig));
SkDEBUGCODE(
SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height);
@@ -1075,6 +1076,11 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
// in case we need a temporary, trimmed copy of the src pixels
SkAutoSMalloc<128 * 128> tempStorage;
+ if (wasFullMipMapDataProvided) {
+ // Make sure this is initialized to true
+ *wasFullMipMapDataProvided = true;
+ }
+
// find the combined size of all the mip levels and the relative offset of
// each into the collective buffer
size_t combinedBufferSize = 0;
@@ -1088,6 +1094,9 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight
individualMipOffsets.push_back(combinedBufferSize);
combinedBufferSize += trimmedSize;
} else {
+ if (wasFullMipMapDataProvided) {
+ *wasFullMipMapDataProvided = false;
+ }
individualMipOffsets.push_back(0);
}
@@ -1407,15 +1416,16 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
GrGLTexture::IDDesc idDesc;
idDesc.fOwnership = GrBackendObjectOwnership::kOwned;
+ bool wasFullMipMapDataProvided = true;
GrGLTexture::TexParams initialTexParams;
if (!this->createTextureImpl(desc, &idDesc.fInfo, isRenderTarget, &initialTexParams,
- texels, mipLevelCount)) {
+ texels, mipLevelCount, &wasFullMipMapDataProvided)) {
return return_null_texture();
}
- bool wasMipMapDataProvided = false;
+ bool mipsAllocated = false;
if (mipLevelCount > 1) {
- wasMipMapDataProvided = true;
+ mipsAllocated = true;
}
sk_sp<GrGLTexture> tex;
@@ -1429,10 +1439,11 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
return return_null_texture();
}
tex = sk_make_sp<GrGLTextureRenderTarget>(this, budgeted, desc, idDesc, rtIDDesc,
- wasMipMapDataProvided);
+ mipsAllocated, wasFullMipMapDataProvided);
tex->baseLevelWasBoundToFBO();
} else {
- tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc, wasMipMapDataProvided);
+ tex = sk_make_sp<GrGLTexture>(this, budgeted, desc, idDesc,
+ mipsAllocated, wasFullMipMapDataProvided);
}
tex->setCachedTexParams(initialTexParams, this->getResetTimestamp());
#ifdef TRACE_TEXTURE_CREATION
@@ -1603,7 +1614,8 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
bool GrGLGpu::createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
bool renderTarget, GrGLTexture::TexParams* initialTexParams,
- const GrMipLevel texels[], int mipLevelCount) {
+ const GrMipLevel texels[], int mipLevelCount,
+ bool* wasFullMipMapDataProvided) {
info->fID = 0;
info->fTarget = GR_GL_TEXTURE_2D;
GL_CALL(GenTextures(1, &(info->fID)));
@@ -3165,6 +3177,9 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, bool allowSRGBInputs
return;
}
+ // Make sure we at least have some base layer to make mips from
+ SkASSERT(texture->texturePriv().mipMapsAreValid());
+
// If we created a rt/tex and rendered to it without using a texture and now we're texturing
// from the rt it will still be the last bound texture, but it needs resolving.
GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTarget());
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 000b56581d..20758c382c 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -224,7 +224,8 @@ private:
// The texture parameters are cached in |initialTexParams|.
bool createTextureImpl(const GrSurfaceDesc& desc, GrGLTextureInfo* info,
bool renderTarget, GrGLTexture::TexParams* initialTexParams,
- const GrMipLevel texels[], int mipLevelCount);
+ const GrMipLevel texels[], int mipLevelCount,
+ bool* wasFullMipMapDataProvided);
bool onIsACopyNeededForTextureParams(GrTextureProxy*, const GrSamplerState&,
GrTextureProducer::CopyParams*,
@@ -391,7 +392,8 @@ private:
bool uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight,
GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType, int left,
int top, int width, int height, GrPixelConfig dataConfig,
- const GrMipLevel texels[], int mipLevelCount);
+ const GrMipLevel texels[], int mipLevelCount,
+ bool* wasFullMipMapDataProvided = nullptr);
bool createRenderTargetObjects(const GrSurfaceDesc&, const GrGLTextureInfo& texInfo,
GrGLRenderTarget::IDDesc*);
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 0d71321ab0..789c0b756e 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -52,18 +52,19 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc&
const IDDesc& idDesc)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
- highest_filter_mode(idDesc, desc.fConfig), false) {
+ highest_filter_mode(idDesc, desc.fConfig), false, false) {
this->init(desc, idDesc);
this->registerWithCache(budgeted);
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
const IDDesc& idDesc,
- bool wasMipMapDataProvided)
+ bool mipsAllocated,
+ bool wasFullMipMapDataProvided)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
highest_filter_mode(idDesc, desc.fConfig),
- wasMipMapDataProvided) {
+ mipsAllocated, wasFullMipMapDataProvided) {
this->init(desc, idDesc);
this->registerWithCache(budgeted);
}
@@ -71,17 +72,17 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc&
GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const IDDesc& idDesc)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
- highest_filter_mode(idDesc, desc.fConfig), false) {
+ highest_filter_mode(idDesc, desc.fConfig), false, false) {
this->init(desc, idDesc);
this->registerWithCacheWrapped();
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
- bool wasMipMapDataProvided)
+ bool mipsAllocated, bool wasFullMipMapDataProvided)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
highest_filter_mode(idDesc, desc.fConfig),
- wasMipMapDataProvided) {
+ mipsAllocated, wasFullMipMapDataProvided) {
this->init(desc, idDesc);
}
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 85ada01c87..f2dc739f2d 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -34,7 +34,7 @@ public:
};
GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&);
GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&,
- bool wasMipMapDataProvided);
+ bool mipsAllocated, bool wasFullMipMapDataProvided);
~GrGLTexture() override {
// check that invokeReleaseProc has been called (if needed)
@@ -73,7 +73,8 @@ public:
protected:
// Constructor for subclasses.
- GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, bool wasMipMapDataProvided);
+ GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&,
+ bool mipsAllocated, bool wasMipMapDataProvided);
enum Wrapped { kWrapped };
// Constructor for instances wrapping backend objects.
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp
index ef401cdd06..b60d3c94ef 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.cpp
+++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp
@@ -17,9 +17,10 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu,
const GrSurfaceDesc& desc,
const GrGLTexture::IDDesc& texIDDesc,
const GrGLRenderTarget::IDDesc& rtIDDesc,
- bool wasMipMapDataProvided)
+ bool mipsAllocated,
+ bool wasFullMipMapDataProvided)
: GrSurface(gpu, desc)
- , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
+ , GrGLTexture(gpu, desc, texIDDesc, mipsAllocated, wasFullMipMapDataProvided)
, GrGLRenderTarget(gpu, desc, rtIDDesc) {
this->registerWithCache(budgeted);
}
@@ -27,10 +28,9 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu,
GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu,
const GrSurfaceDesc& desc,
const GrGLTexture::IDDesc& texIDDesc,
- const GrGLRenderTarget::IDDesc& rtIDDesc,
- bool wasMipMapDataProvided)
+ const GrGLRenderTarget::IDDesc& rtIDDesc)
: GrSurface(gpu, desc)
- , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
+ , GrGLTexture(gpu, desc, texIDDesc, false, false)
, GrGLRenderTarget(gpu, desc, rtIDDesc) {
this->registerWithCacheWrapped();
}
@@ -75,7 +75,7 @@ sk_sp<GrGLTextureRenderTarget> GrGLTextureRenderTarget::MakeWrapped(
const GrGLTexture::IDDesc& texIDDesc, const GrGLRenderTarget::IDDesc& rtIDDesc)
{
return sk_sp<GrGLTextureRenderTarget>(
- new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc, false));
+ new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc));
}
size_t GrGLTextureRenderTarget::onGpuMemorySize() const {
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.h b/src/gpu/gl/GrGLTextureRenderTarget.h
index e104e85b3f..2242933e0c 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.h
+++ b/src/gpu/gl/GrGLTextureRenderTarget.h
@@ -29,7 +29,8 @@ public:
const GrSurfaceDesc& desc,
const GrGLTexture::IDDesc& texIDDesc,
const GrGLRenderTarget::IDDesc& rtIDDesc,
- bool wasMipMapDataProvided);
+ bool mipsAllocated,
+ bool wasFullMipMapDataProvided);
bool canAttemptStencilAttachment() const override;
@@ -54,8 +55,7 @@ private:
GrGLTextureRenderTarget(GrGLGpu* gpu,
const GrSurfaceDesc& desc,
const GrGLTexture::IDDesc& texIDDesc,
- const GrGLRenderTarget::IDDesc& rtIDDesc,
- bool wasMipMapDataProvided);
+ const GrGLRenderTarget::IDDesc& rtIDDesc);
size_t onGpuMemorySize() const override;
};