Use a priori knowledge about the number of stencil bits in Dawn, Metal and Vulkan backends
The goal here is to centralize more of the program key creation w/in GrProgramInfo. For Dawn,
Metal and Vulkan, afaict, the number of stencil bits is always 8. We can use this information
to stop passing the GrStencilSettings object around. For GL, the number of stencil bits is
variable but it is never part of the key.
Bug: skia:9455
Change-Id: I8fd2bea2422c5b9df69fc184d3a82013eef5407e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254177
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/dawn/GrDawnProgramBuilder.cpp b/src/gpu/dawn/GrDawnProgramBuilder.cpp
index 6b73b1a..c493d72 100644
--- a/src/gpu/dawn/GrDawnProgramBuilder.cpp
+++ b/src/gpu/dawn/GrDawnProgramBuilder.cpp
@@ -236,9 +236,11 @@
}
static wgpu::DepthStencilStateDescriptor create_depth_stencil_state(
- const GrStencilSettings& stencilSettings,
- wgpu::TextureFormat depthStencilFormat,
- GrSurfaceOrigin origin) {
+ const GrProgramInfo& programInfo,
+ wgpu::TextureFormat depthStencilFormat) {
+ GrStencilSettings stencilSettings = programInfo.nonGLStencilSettings();
+ GrSurfaceOrigin origin = programInfo.origin();
+
wgpu::DepthStencilStateDescriptor state;
state.format = depthStencilFormat;
if (!stencilSettings.isDisabled()) {
@@ -352,13 +354,13 @@
const GrPipeline& pipeline = programInfo.pipeline();
auto colorState = create_color_state(gpu, pipeline, colorFormat);
wgpu::DepthStencilStateDescriptor depthStencilState;
- GrStencilSettings stencil;
+
+#ifdef SK_DEBUG
if (pipeline.isStencilEnabled()) {
- int numStencilBits = renderTarget->renderTargetPriv().numStencilBits();
- stencil.reset(*pipeline.getUserStencil(), pipeline.hasStencilClip(), numStencilBits);
+ SkASSERT(renderTarget->renderTargetPriv().numStencilBits() == 8);
}
- depthStencilState = create_depth_stencil_state(stencil, depthStencilFormat,
- programInfo.origin());
+#endif
+ depthStencilState = create_depth_stencil_state(programInfo, depthStencilFormat);
std::vector<wgpu::VertexBufferLayoutDescriptor> inputs;