diff options
Diffstat (limited to 'src/gpu/vk/GrVkGpu.cpp')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 7fbca9f9da..6969e06252 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -315,6 +315,10 @@ GrBuffer* GrVkGpu::onCreateBuffer(size_t size, GrBufferType type, GrAccessPatter bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, GrPixelConfig srcConfig, DrawPreference* drawPreference, WritePixelTempDrawInfo* tempDrawInfo) { + if (GrPixelConfigIsCompressed(dstSurface->config())) { + return false; + } + GrRenderTarget* renderTarget = dstSurface->asRenderTarget(); // Start off assuming no swizzling @@ -375,32 +379,43 @@ bool GrVkGpu::onWritePixels(GrSurface* surface, } bool success = false; - bool linearTiling = vkTex->isLinearTiled(); - if (linearTiling) { - if (texels.count() > 1) { - SkDebugf("Can't upload mipmap data to linear tiled texture"); - return false; - } - if (VK_IMAGE_LAYOUT_PREINITIALIZED != vkTex->currentLayout()) { - // Need to change the layout to general in order to perform a host write - vkTex->setImageLayout(this, - VK_IMAGE_LAYOUT_GENERAL, - VK_ACCESS_HOST_WRITE_BIT, - VK_PIPELINE_STAGE_HOST_BIT, - false); - this->submitCommandBuffer(kForce_SyncQueue); - } - success = this->uploadTexDataLinear(vkTex, left, top, width, height, config, - texels.begin()->fPixels, texels.begin()->fRowBytes); + if (GrPixelConfigIsCompressed(vkTex->config())) { + // We check that config == desc.fConfig in GrGpu::getWritePixelsInfo() + SkASSERT(config == vkTex->config()); + // TODO: add compressed texture support + // delete the following two lines and uncomment the two after that when ready + vkTex->unref(); + return false; + //success = this->uploadCompressedTexData(vkTex->desc(), buffer, false, left, top, width, + // height); } else { - int newMipLevels = texels.count(); - int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1; - if (newMipLevels > currentMipLevels) { - if (!vkTex->reallocForMipmap(this, newMipLevels)) { + bool linearTiling = vkTex->isLinearTiled(); + if (linearTiling) { + if (texels.count() > 1) { + SkDebugf("Can't upload mipmap data to linear tiled texture"); return false; } + if (VK_IMAGE_LAYOUT_PREINITIALIZED != vkTex->currentLayout()) { + // Need to change the layout to general in order to perform a host write + vkTex->setImageLayout(this, + VK_IMAGE_LAYOUT_GENERAL, + VK_ACCESS_HOST_WRITE_BIT, + VK_PIPELINE_STAGE_HOST_BIT, + false); + this->submitCommandBuffer(kForce_SyncQueue); + } + success = this->uploadTexDataLinear(vkTex, left, top, width, height, config, + texels.begin()->fPixels, texels.begin()->fRowBytes); + } else { + int newMipLevels = texels.count(); + int currentMipLevels = vkTex->texturePriv().maxMipMapLevel() + 1; + if (newMipLevels > currentMipLevels) { + if (!vkTex->reallocForMipmap(this, newMipLevels)) { + return false; + } + } + success = this->uploadTexDataOptimal(vkTex, left, top, width, height, config, texels); } - success = this->uploadTexDataOptimal(vkTex, left, top, width, height, config, texels); } return success; @@ -483,6 +498,9 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, SkASSERT(data); SkASSERT(tex->isLinearTiled()); + // If we're uploading compressed data then we should be using uploadCompressedTexData + SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); + size_t bpp = GrBytesPerPixel(dataConfig); if (!GrSurfacePriv::AdjustWritePixelParams(tex->width(), tex->height(), bpp, &left, &top, @@ -551,6 +569,9 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, // first. SkASSERT(1 == texels.count() || texels.count() == (tex->texturePriv().maxMipMapLevel() + 1)); + // If we're uploading compressed data then we should be using uploadCompressedTexData + SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); + if (width == 0 || height == 0) { return false; } |