diff options
author | Robert Phillips <robertphillips@google.com> | 2023-12-08 12:40:54 -0500 |
---|---|---|
committer | SkCQ <skcq-be@skia-corp.google.com.iam.gserviceaccount.com> | 2023-12-12 14:07:58 +0000 |
commit | e1b4c6d9bc8d3e3b58a15099b68408a7a02e01ca (patch) | |
tree | b40b48d4169cd85ea596c82f88b6e38edf82abfe | |
parent | fe04635b125f29a98ac8a15decef3f6bf3eb9aa3 (diff) | |
download | skia-e1b4c6d9bc8d3e3b58a15099b68408a7a02e01ca.tar.gz |
[graphite] Propagate Protectedness throughout Vulkan backend
Bug: b/237108194
Change-Id: I45704064beed128b862c42d69831d7ce043ec32a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/787438
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Nicolette Prevost <nicolettep@google.com>
-rw-r--r-- | src/gpu/graphite/AtlasProvider.cpp | 2 | ||||
-rw-r--r-- | src/gpu/graphite/DrawAtlas.cpp | 2 | ||||
-rw-r--r-- | src/gpu/graphite/RecorderPriv.h | 4 | ||||
-rw-r--r-- | src/gpu/graphite/TextureUtils.cpp | 6 | ||||
-rw-r--r-- | tools/window/GraphiteVulkanWindowContext.cpp | 12 |
5 files changed, 20 insertions, 6 deletions
diff --git a/src/gpu/graphite/AtlasProvider.cpp b/src/gpu/graphite/AtlasProvider.cpp index 389308d2c7..ca9bb1b2df 100644 --- a/src/gpu/graphite/AtlasProvider.cpp +++ b/src/gpu/graphite/AtlasProvider.cpp @@ -73,7 +73,7 @@ sk_sp<TextureProxy> AtlasProvider::getAtlasTexture(Recorder* recorder, SkISize::Make(int32_t(width), int32_t(height)), colorType, skgpu::Mipmapped::kNo, - skgpu::Protected::kNo, + recorder->priv().isProtected(), skgpu::Renderable::kNo, skgpu::Budgeted::kYes); } diff --git a/src/gpu/graphite/DrawAtlas.cpp b/src/gpu/graphite/DrawAtlas.cpp index 52092be989..90cd2f68ca 100644 --- a/src/gpu/graphite/DrawAtlas.cpp +++ b/src/gpu/graphite/DrawAtlas.cpp @@ -476,7 +476,7 @@ bool DrawAtlas::activateNewPage(Recorder* recorder) { const Caps* caps = recorder->priv().caps(); auto textureInfo = caps->getDefaultSampledTextureInfo(fColorType, /*mipmapped=*/Mipmapped::kNo, - Protected::kNo, + recorder->priv().isProtected(), Renderable::kNo); fProxies[fNumActivePages] = TextureProxy::Make( caps, {fTextureWidth, fTextureHeight}, textureInfo, skgpu::Budgeted::kYes); diff --git a/src/gpu/graphite/RecorderPriv.h b/src/gpu/graphite/RecorderPriv.h index 820e0d7586..a7eb7e12da 100644 --- a/src/gpu/graphite/RecorderPriv.h +++ b/src/gpu/graphite/RecorderPriv.h @@ -49,6 +49,10 @@ public: return fRecorder->fSharedContext->rendererProvider(); } + Protected isProtected() const { + return fRecorder->fSharedContext->isProtected(); + } + UniformDataCache* uniformDataCache() { return fRecorder->fUniformDataCache.get(); } TextureDataCache* textureDataCache() { return fRecorder->fTextureDataCache.get(); } DrawBufferManager* drawBufferManager() { return fRecorder->fDrawBufferManager.get(); } diff --git a/src/gpu/graphite/TextureUtils.cpp b/src/gpu/graphite/TextureUtils.cpp index 8b6d9a8cad..aeb439b369 100644 --- a/src/gpu/graphite/TextureUtils.cpp +++ b/src/gpu/graphite/TextureUtils.cpp @@ -95,6 +95,7 @@ sk_sp<SkSpecialImage> eval_blur(skgpu::graphite::Recorder* recorder, const SkSurfaceProps& outProps) { SkImageInfo outII = SkImageInfo::Make({dstRect.width(), dstRect.height()}, colorType, kPremul_SkAlphaType, std::move(outCS)); + // Protected-ness is pulled off of the recorder auto device = skgpu::graphite::Device::Make(recorder, outII, skgpu::Budgeted::kYes, @@ -313,11 +314,12 @@ std::tuple<TextureProxyView, SkColorType> MakeBitmapProxyView(Recorder* recorder mipmapped = Mipmapped::kNo; } - auto textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, Protected::kNo, + Protected isProtected = recorder->priv().isProtected(); + auto textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, isProtected, Renderable::kNo); if (!textureInfo.isValid()) { ct = kRGBA_8888_SkColorType; - textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, Protected::kNo, + textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, isProtected, Renderable::kNo); } SkASSERT(textureInfo.isValid()); diff --git a/tools/window/GraphiteVulkanWindowContext.cpp b/tools/window/GraphiteVulkanWindowContext.cpp index 2a8f99fcba..72ba8820f8 100644 --- a/tools/window/GraphiteVulkanWindowContext.cpp +++ b/tools/window/GraphiteVulkanWindowContext.cpp @@ -67,7 +67,8 @@ void GraphiteVulkanWindowContext::initializeContext() { VkPhysicalDeviceFeatures2 features; if (!sk_gpu_test::CreateVkBackendContext(getInstanceProc, &backendContext, &extensions, &features, &fDebugCallback, &fPresentQueueIndex, - fCanPresentFn)) { + fCanPresentFn, + fDisplayParams.fCreateProtectedNativeBackend)) { sk_gpu_test::FreeVulkanFeaturesStructs(&features); return; } @@ -293,6 +294,9 @@ bool GraphiteVulkanWindowContext::createSwapchain(int width, int height, VkSwapchainCreateInfoKHR swapchainCreateInfo; memset(&swapchainCreateInfo, 0, sizeof(VkSwapchainCreateInfoKHR)); swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; + swapchainCreateInfo.flags = fDisplayParams.fCreateProtectedNativeBackend + ? VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR + : 0; swapchainCreateInfo.surface = fSurface; swapchainCreateInfo.minImageCount = imageCount; swapchainCreateInfo.imageFormat = surfaceFormat; @@ -346,7 +350,8 @@ bool GraphiteVulkanWindowContext::createSwapchain(int width, int height, return true; } -bool GraphiteVulkanWindowContext::createBuffers(VkFormat format, VkImageUsageFlags usageFlags, +bool GraphiteVulkanWindowContext::createBuffers(VkFormat format, + VkImageUsageFlags usageFlags, SkColorType colorType, VkSharingMode sharingMode) { fGetSwapchainImagesKHR(fDevice, fSwapchain, &fImageCount, nullptr); @@ -365,6 +370,8 @@ bool GraphiteVulkanWindowContext::createBuffers(VkFormat format, VkImageUsageFla info.fFormat = format; info.fImageUsageFlags = usageFlags; info.fSharingMode = sharingMode; + info.fFlags = fDisplayParams.fCreateProtectedNativeBackend ? VK_IMAGE_CREATE_PROTECTED_BIT + : 0; skgpu::graphite::BackendTexture backendTex(this->dimensions(), info, @@ -372,6 +379,7 @@ bool GraphiteVulkanWindowContext::createBuffers(VkFormat format, VkImageUsageFla fPresentQueueIndex, fImages[i], skgpu::VulkanAlloc()); + fSurfaces[i] = SkSurfaces::WrapBackendTexture(this->graphiteRecorder(), backendTex, colorType, |