aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-09 12:02:32 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-09 17:26:50 +0000
commitafdc6b1ba9f5dba52916bd20b608f1f7c21c3160 (patch)
tree6edfa3a2d534c7edbbf3cc91a2f09e292bfda08d /src/gpu
parent32929e0614742d03e067b117c71999c7ab1c902e (diff)
Vulkan backend render targets don't allow client to specify stencil bits
We already always create the stencil buffer even for wrapped RTs. Make VulkanWindowContext use SkSurface::MakeFromBackendRenderTarget. Change-Id: I5df429d347331801954ec17cb9d75e323a7af345 Reviewed-on: https://skia-review.googlesource.com/113206 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrBackendSurface.cpp11
-rw-r--r--src/gpu/vk/GrVkGpu.cpp10
2 files changed, 16 insertions, 5 deletions
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 73135dc42c..6db618f717 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -153,10 +153,19 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
int sampleCnt,
int stencilBits,
const GrVkImageInfo& vkInfo)
+ : GrBackendRenderTarget(width, height, sampleCnt, vkInfo) {
+ // This is a deprecated constructor that takes a bogus stencil bits.
+ SkASSERT(0 == stencilBits);
+}
+
+GrBackendRenderTarget::GrBackendRenderTarget(int width,
+ int height,
+ int sampleCnt,
+ const GrVkImageInfo& vkInfo)
: fWidth(width)
, fHeight(height)
, fSampleCnt(SkTMax(1, sampleCnt))
- , fStencilBits(stencilBits)
+ , fStencilBits(0) // We always create stencil buffers internally for vulkan
, fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fBackend(kVulkan_GrBackend)
, fVkInfo(vkInfo) {}
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index b674185a00..1acbf02627 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -942,11 +942,13 @@ sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTa
desc.fSampleCnt = 1;
sk_sp<GrVkRenderTarget> tgt = GrVkRenderTarget::MakeWrappedRenderTarget(this, desc, info);
- if (tgt && backendRT.stencilBits()) {
- if (!createStencilAttachmentForRenderTarget(tgt.get(), desc.fWidth, desc.fHeight)) {
- return nullptr;
- }
+
+ // We don't allow the client to supply a premade stencil buffer. We always create one if needed.
+ SkASSERT(!backendRT.stencilBits());
+ if (tgt) {
+ SkASSERT(tgt->canAttemptStencilAttachment());
}
+
return tgt;
}