diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrBackendSurface.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 8 | ||||
-rw-r--r-- | src/gpu/gl/GrGLRenderTarget.cpp | 12 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 35 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.h | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 10 | ||||
-rw-r--r-- | src/gpu/vk/GrVkRenderTarget.cpp | 12 | ||||
-rw-r--r-- | src/gpu/vk/GrVkTexture.cpp | 9 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUtil.cpp | 34 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUtil.h | 5 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 7 |
12 files changed, 94 insertions, 58 deletions
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp index 49a8c5f762..fa2582a18e 100644 --- a/src/gpu/GrBackendSurface.cpp +++ b/src/gpu/GrBackendSurface.cpp @@ -69,7 +69,7 @@ GrBackendTexture::GrBackendTexture(int width, const GrVkImageInfo& vkInfo) : fWidth(width) , fHeight(height) - , fConfig(kUnknown_GrPixelConfig) + , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat)) , fMipMapped(GrMipMapped(vkInfo.fLevelCount > 1)) , fBackend(kVulkan_GrBackend) , fVkInfo(vkInfo) {} @@ -99,7 +99,7 @@ GrBackendTexture::GrBackendTexture(int width, const GrGLTextureInfo& glInfo) : fWidth(width) , fHeight(height) - , fConfig(kUnknown_GrPixelConfig) + , fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat)) , fMipMapped(mipMapped) , fBackend(kOpenGL_GrBackend) , fGLInfo(glInfo) {} @@ -159,7 +159,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fHeight(height) , fSampleCnt(SkTMax(1, sampleCnt)) , fStencilBits(0) // We always create stencil buffers internally for vulkan - , fConfig(kUnknown_GrPixelConfig) + , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat)) , fBackend(kVulkan_GrBackend) , fVkInfo(vkInfo) {} #endif @@ -187,7 +187,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fHeight(height) , fSampleCnt(SkTMax(1, sampleCnt)) , fStencilBits(stencilBits) - , fConfig(kUnknown_GrPixelConfig) + , fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat)) , fBackend(kOpenGL_GrBackend) , fGLInfo(glInfo) {} diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 9a9f90c04e..4e88f7dde2 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4411,9 +4411,7 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in // unbind the texture from the texture unit to avoid asserts GL_CALL(BindTexture(info.fTarget, 0)); - GrBackendTexture beTex = GrBackendTexture(w, h, mipMapped, info); - beTex.setPixelConfig(config); - return beTex; + return GrBackendTexture(w, h, mipMapped, info); } bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { @@ -4503,9 +4501,7 @@ GrBackendRenderTarget GrGLGpu::createTestingOnlyBackendRenderTarget(int w, int h return {}; } auto stencilBits = SkToInt(this->glCaps().stencilFormats()[sFormatIdx].fStencilBits); - GrBackendRenderTarget beRT = {w, h, 1, stencilBits, info}; - beRT.setPixelConfig(config); - return beRT; + return {w, h, 1, stencilBits, config, info}; } void GrGLGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& backendRT) { diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index 73c5fdf4b3..de7399bd92 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -91,16 +91,8 @@ GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget() const { numStencilBits = stencil->bits(); } - GrBackendRenderTarget beRT = GrBackendRenderTarget(this->width(), this->height(), - this->numColorSamples(), numStencilBits, - fbi); -#if GR_TEST_UTILS - // We shouldn't have to set this since the client can't access it and we will handle the config - // correctly if we go through our public SkSurface APIs. However, some of our tests bypass the - // public APIs so we need to set this manually here. - beRT.setPixelConfig(this->config()); -#endif - return beRT; + return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(), + numStencilBits, fbi); } size_t GrGLRenderTarget::onGpuMemorySize() const { diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 771006919b..0f36dd0f32 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -98,15 +98,7 @@ GrBackendObject GrGLTexture::getTextureHandle() const { } GrBackendTexture GrGLTexture::getBackendTexture() const { - GrBackendTexture beTex = GrBackendTexture(this->width(), this->height(), - this->texturePriv().mipMapped(), fInfo); -#if GR_TEST_UTILS - // We shouldn't have to set this since the client can't access it and we will handle the config - // correctly if we go through our public SkSurface and SkImage APIs. However, some of our tests - // bypass the public APIs so we need to set this manually here. - beTex.setPixelConfig(this->config()); -#endif - return beTex; + return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), fInfo); } void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index a268827e23..6b44402c1b 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -486,3 +486,38 @@ GrGLenum GrToGLStencilFunc(GrStencilTest test) { return gTable[(int)test]; } +GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat) { + switch (sizedFormat) { + case GR_GL_R8: + return kAlpha_8_as_Red_GrPixelConfig; + case GR_GL_ALPHA8: + return kAlpha_8_as_Alpha_GrPixelConfig; + case GR_GL_RGBA8: + return kRGBA_8888_GrPixelConfig; + case GR_GL_BGRA8: + return kBGRA_8888_GrPixelConfig; + case GR_GL_SRGB8_ALPHA8: + return kSRGBA_8888_GrPixelConfig; + case GR_GL_RGB565: + return kRGB_565_GrPixelConfig; + case GR_GL_RGB5: + return kRGB_565_GrPixelConfig; + case GR_GL_RGBA4: + return kRGBA_4444_GrPixelConfig; + case GR_GL_RGB10_A2: + return kRGBA_1010102_GrPixelConfig; + case GR_GL_LUMINANCE8: + return kGray_8_GrPixelConfig; + case GR_GL_RGBA32F: + return kRGBA_float_GrPixelConfig; + case GR_GL_RG32F: + return kRG_float_GrPixelConfig; + case GR_GL_R16F: + return kAlpha_half_as_Red_GrPixelConfig; + case GR_GL_RGBA16F: + return kRGBA_half_GrPixelConfig; + default: + return kUnknown_GrPixelConfig; + } +} + diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 88e8901047..9905d75ef1 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -248,4 +248,6 @@ void GrGLClearErr(const GrGLInterface* gl); GrGLenum GrToGLStencilFunc(GrStencilTest test); +GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat); + #endif diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 5469b0e981..6c16a17416 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1422,6 +1422,7 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrier.image = image; barrier.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, mipLevels, 0, 1}; + initialLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; VK_CALL(CmdPipelineBarrier(cmdBuffer, GrVkMemory::LayoutToPipelineStageFlags(initialLayout), VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, @@ -1429,7 +1430,6 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool 0, nullptr, 0, nullptr, 1, &barrier)); - initialLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } // End CommandBuffer @@ -1499,9 +1499,7 @@ GrBackendTexture GrVkGpu::createTestingOnlyBackendTexture(const void* srcData, i &info)) { return {}; } - GrBackendTexture beTex = GrBackendTexture(w, h, info); - beTex.setPixelConfig(config); - return beTex; + return GrBackendTexture(w, h, info); } bool GrVkGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { @@ -1545,9 +1543,7 @@ GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h &info)) { return {}; } - GrBackendRenderTarget beRT = {w, h, 1, 0, info}; - beRT.setPixelConfig(config); - return beRT; + return {w, h, 1, 0, info}; } void GrVkGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& rt) { diff --git a/src/gpu/vk/GrVkRenderTarget.cpp b/src/gpu/vk/GrVkRenderTarget.cpp index 9c57ec01bd..99b6b7632c 100644 --- a/src/gpu/vk/GrVkRenderTarget.cpp +++ b/src/gpu/vk/GrVkRenderTarget.cpp @@ -352,16 +352,8 @@ GrBackendRenderTarget GrVkRenderTarget::getBackendRenderTarget() const { if (GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment()) { numStencilBits = stencil->bits(); } - GrBackendRenderTarget beRT = GrBackendRenderTarget(this->width(), this->height(), - this->numColorSamples(), numStencilBits, - fInfo); -#if GR_TEST_UTILS - // We shouldn't have to set this since the client can't access it and we will handle the config - // correctly if we go through our public SkSurface APIs. However, some of our tests bypass the - // public APIs so we need to set this manually here. - beRT.setPixelConfig(this->config()); -#endif - return beRT; + return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(), + numStencilBits, fInfo); } const GrVkResource* GrVkRenderTarget::stencilImageResource() const { diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp index 6668b8f4c1..109b10638d 100644 --- a/src/gpu/vk/GrVkTexture.cpp +++ b/src/gpu/vk/GrVkTexture.cpp @@ -162,14 +162,7 @@ GrBackendObject GrVkTexture::getTextureHandle() const { } GrBackendTexture GrVkTexture::getBackendTexture() const { - GrBackendTexture beTex = GrBackendTexture(this->width(), this->height(), fInfo); -#if GR_TEST_UTILS - // We shouldn't have to set this since the client can't access it and we will handle the config - // correctly if we go through our public SkSurface and SkImage APIs. However, some of our tests - // bypass the public APIs so we need to set this manually here. - beTex.setPixelConfig(this->config()); -#endif - return beTex; + return GrBackendTexture(this->width(), this->height(), fInfo); } GrVkGpu* GrVkTexture::getVkGpu() const { diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp index 5edb2e3818..4f0acdb8f4 100644 --- a/src/gpu/vk/GrVkUtil.cpp +++ b/src/gpu/vk/GrVkUtil.cpp @@ -72,6 +72,40 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) { return false; } +GrPixelConfig GrVkFormatToPixelConfig(VkFormat format) { + switch (format) { + case VK_FORMAT_R8G8B8A8_UNORM: + return kRGBA_8888_GrPixelConfig; + case VK_FORMAT_B8G8R8A8_UNORM: + return kBGRA_8888_GrPixelConfig; + case VK_FORMAT_R8G8B8A8_SRGB: + return kSRGBA_8888_GrPixelConfig; + case VK_FORMAT_B8G8R8A8_SRGB: + return kSBGRA_8888_GrPixelConfig; + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: + return kRGBA_1010102_GrPixelConfig; + case VK_FORMAT_R5G6B5_UNORM_PACK16: + return kRGB_565_GrPixelConfig; + break; + case VK_FORMAT_B4G4R4A4_UNORM_PACK16: + // R4G4B4A4 is not required to be supported so we actually + // store RGBA_4444 data as B4G4R4A4. + return kRGBA_4444_GrPixelConfig; + case VK_FORMAT_R8_UNORM: + return kAlpha_8_GrPixelConfig; + case VK_FORMAT_R32G32B32A32_SFLOAT: + return kRGBA_float_GrPixelConfig; + case VK_FORMAT_R32G32_SFLOAT: + return kRG_float_GrPixelConfig; + case VK_FORMAT_R16G16B16A16_SFLOAT: + return kRGBA_half_GrPixelConfig; + case VK_FORMAT_R16_SFLOAT: + return kAlpha_half_GrPixelConfig; + default: + return kUnknown_GrPixelConfig; + } +} + bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) { switch (format) { case VK_FORMAT_R8G8B8A8_UNORM: diff --git a/src/gpu/vk/GrVkUtil.h b/src/gpu/vk/GrVkUtil.h index b0d118adb5..01688c8486 100644 --- a/src/gpu/vk/GrVkUtil.h +++ b/src/gpu/vk/GrVkUtil.h @@ -32,6 +32,11 @@ class GrVkGpu; */ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format); +/** +* Returns the GrPixelConfig for the given vulkan texture format +*/ +GrPixelConfig GrVkFormatToPixelConfig(VkFormat format); + bool GrVkFormatIsSupported(VkFormat); /** diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 45906009f8..7c842f69c0 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -589,7 +589,7 @@ public: this->resetReleaseHelper(); } - sk_sp<GrTexture> getTexture(GrResourceProvider* resourceProvider, GrPixelConfig config) { + sk_sp<GrTexture> getTexture(GrResourceProvider* resourceProvider) { // Releases the promise helper if there are no outstanding hard refs. This means that we // don't have any ReleaseProcs waiting to be called so we will need to do a fulfill. if (fReleaseHelper && fReleaseHelper->weak_expired()) { @@ -599,7 +599,6 @@ public: sk_sp<GrTexture> tex; if (!fReleaseHelper) { fFulfillProc(fContext, &fBackendTex); - fBackendTex.fConfig = config; if (!fBackendTex.isValid()) { // Even though the GrBackendTexture is not valid, we must call the release // proc to keep our contract of always calling Fulfill and Release in pairs. @@ -701,13 +700,13 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context, PromiseImageHelper promiseHelper(textureFulfillProc, textureReleaseProc, textureContext); sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy( - [promiseHelper, config] (GrResourceProvider* resourceProvider) mutable { + [promiseHelper] (GrResourceProvider* resourceProvider) mutable { if (!resourceProvider) { promiseHelper.reset(); return sk_sp<GrTexture>(); } - return promiseHelper.getTexture(resourceProvider, config); + return promiseHelper.getTexture(resourceProvider); }, desc, origin, mipMapped, GrRenderTargetFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo, GrSurfaceProxy::LazyInstantiationType::kUninstantiate); |