Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: src/gpu/vk/GrVkPipeline.cpp

Issue 1962243002: Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/text/GrStencilAndCoverTextContext.cpp ('k') | src/gpu/vk/GrVkPipelineState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrVkPipeline.h" 8 #include "GrVkPipeline.h"
9 9
10 #include "GrGeometryProcessor.h" 10 #include "GrGeometryProcessor.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 inputAssemblyInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_C REATE_INFO; 93 inputAssemblyInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_C REATE_INFO;
94 inputAssemblyInfo->pNext = nullptr; 94 inputAssemblyInfo->pNext = nullptr;
95 inputAssemblyInfo->flags = 0; 95 inputAssemblyInfo->flags = 0;
96 inputAssemblyInfo->primitiveRestartEnable = false; 96 inputAssemblyInfo->primitiveRestartEnable = false;
97 inputAssemblyInfo->topology = gPrimitiveType2VkTopology[primitiveType]; 97 inputAssemblyInfo->topology = gPrimitiveType2VkTopology[primitiveType];
98 } 98 }
99 99
100 100
101 VkStencilOp stencil_op_to_vk_stencil_op(GrStencilOp op) { 101 VkStencilOp stencil_op_to_vk_stencil_op(GrStencilOp op) {
102 static const VkStencilOp gTable[] = { 102 static const VkStencilOp gTable[] = {
103 VK_STENCIL_OP_KEEP, // kKeep_StencilOp 103 VK_STENCIL_OP_KEEP, // kKeep
104 VK_STENCIL_OP_REPLACE, // kReplace_StencilOp 104 VK_STENCIL_OP_ZERO, // kZero
105 VK_STENCIL_OP_INCREMENT_AND_WRAP, // kIncWrap_StencilOp 105 VK_STENCIL_OP_REPLACE, // kReplace
106 VK_STENCIL_OP_INCREMENT_AND_CLAMP, // kIncClamp_StencilOp 106 VK_STENCIL_OP_INVERT, // kInvert
107 VK_STENCIL_OP_DECREMENT_AND_WRAP, // kDecWrap_StencilOp 107 VK_STENCIL_OP_INCREMENT_AND_WRAP, // kIncWrap
108 VK_STENCIL_OP_DECREMENT_AND_CLAMP, // kDecClamp_StencilOp 108 VK_STENCIL_OP_DECREMENT_AND_WRAP, // kDecWrap
109 VK_STENCIL_OP_ZERO, // kZero_StencilOp 109 VK_STENCIL_OP_INCREMENT_AND_CLAMP, // kIncClamp
110 VK_STENCIL_OP_INVERT, // kInvert_StencilOp 110 VK_STENCIL_OP_DECREMENT_AND_CLAMP, // kDecClamp
111 }; 111 };
112 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kStencilOpCnt); 112 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kGrStencilOpCount);
113 GR_STATIC_ASSERT(0 == kKeep_StencilOp); 113 GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep);
114 GR_STATIC_ASSERT(1 == kReplace_StencilOp); 114 GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero);
115 GR_STATIC_ASSERT(2 == kIncWrap_StencilOp); 115 GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace);
116 GR_STATIC_ASSERT(3 == kIncClamp_StencilOp); 116 GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert);
117 GR_STATIC_ASSERT(4 == kDecWrap_StencilOp); 117 GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap);
118 GR_STATIC_ASSERT(5 == kDecClamp_StencilOp); 118 GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap);
119 GR_STATIC_ASSERT(6 == kZero_StencilOp); 119 GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp);
120 GR_STATIC_ASSERT(7 == kInvert_StencilOp); 120 GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp);
121 SkASSERT((unsigned)op < kStencilOpCnt); 121 SkASSERT(op < (GrStencilOp)kGrStencilOpCount);
122 return gTable[op]; 122 return gTable[(int)op];
123 } 123 }
124 124
125 VkCompareOp stencil_func_to_vk_compare_op(GrStencilFunc basicFunc) { 125 VkCompareOp stencil_func_to_vk_compare_op(GrStencilTest test) {
126 static const VkCompareOp gTable[] = { 126 static const VkCompareOp gTable[] = {
127 VK_COMPARE_OP_ALWAYS, // kAlways_StencilFunc 127 VK_COMPARE_OP_ALWAYS, // kAlways
128 VK_COMPARE_OP_NEVER, // kNever_StencilFunc 128 VK_COMPARE_OP_NEVER, // kNever
129 VK_COMPARE_OP_GREATER, // kGreater_StencilFunc 129 VK_COMPARE_OP_GREATER, // kGreater
130 VK_COMPARE_OP_GREATER_OR_EQUAL, // kGEqual_StencilFunc 130 VK_COMPARE_OP_GREATER_OR_EQUAL, // kGEqual
131 VK_COMPARE_OP_LESS, // kLess_StencilFunc 131 VK_COMPARE_OP_LESS, // kLess
132 VK_COMPARE_OP_LESS_OR_EQUAL, // kLEqual_StencilFunc, 132 VK_COMPARE_OP_LESS_OR_EQUAL, // kLEqual
133 VK_COMPARE_OP_EQUAL, // kEqual_StencilFunc, 133 VK_COMPARE_OP_EQUAL, // kEqual
134 VK_COMPARE_OP_NOT_EQUAL, // kNotEqual_StencilFunc, 134 VK_COMPARE_OP_NOT_EQUAL, // kNotEqual
135 }; 135 };
136 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kBasicStencilFuncCnt); 136 GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kGrStencilTestCount);
137 GR_STATIC_ASSERT(0 == kAlways_StencilFunc); 137 GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways);
138 GR_STATIC_ASSERT(1 == kNever_StencilFunc); 138 GR_STATIC_ASSERT(1 == (int)GrStencilTest::kNever);
139 GR_STATIC_ASSERT(2 == kGreater_StencilFunc); 139 GR_STATIC_ASSERT(2 == (int)GrStencilTest::kGreater);
140 GR_STATIC_ASSERT(3 == kGEqual_StencilFunc); 140 GR_STATIC_ASSERT(3 == (int)GrStencilTest::kGEqual);
141 GR_STATIC_ASSERT(4 == kLess_StencilFunc); 141 GR_STATIC_ASSERT(4 == (int)GrStencilTest::kLess);
142 GR_STATIC_ASSERT(5 == kLEqual_StencilFunc); 142 GR_STATIC_ASSERT(5 == (int)GrStencilTest::kLEqual);
143 GR_STATIC_ASSERT(6 == kEqual_StencilFunc); 143 GR_STATIC_ASSERT(6 == (int)GrStencilTest::kEqual);
144 GR_STATIC_ASSERT(7 == kNotEqual_StencilFunc); 144 GR_STATIC_ASSERT(7 == (int)GrStencilTest::kNotEqual);
145 SkASSERT((unsigned)basicFunc < kBasicStencilFuncCnt); 145 SkASSERT(test < (GrStencilTest)kGrStencilTestCount);
146 146
147 return gTable[basicFunc]; 147 return gTable[(int)test];
148 } 148 }
149 149
150 void setup_depth_stencil_state(const GrVkGpu* gpu, 150 void setup_depth_stencil_state(const GrVkGpu* gpu,
151 const GrStencilSettings& stencilSettings, 151 const GrStencilSettings& stencilSettings,
152 VkPipelineDepthStencilStateCreateInfo* stencilInf o) { 152 VkPipelineDepthStencilStateCreateInfo* stencilInf o) {
153 memset(stencilInfo, 0, sizeof(VkPipelineDepthStencilStateCreateInfo)); 153 memset(stencilInfo, 0, sizeof(VkPipelineDepthStencilStateCreateInfo));
154 stencilInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_I NFO; 154 stencilInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_I NFO;
155 stencilInfo->pNext = nullptr; 155 stencilInfo->pNext = nullptr;
156 stencilInfo->flags = 0; 156 stencilInfo->flags = 0;
157 // set depth testing defaults 157 // set depth testing defaults
158 stencilInfo->depthTestEnable = VK_FALSE; 158 stencilInfo->depthTestEnable = VK_FALSE;
159 stencilInfo->depthWriteEnable = VK_FALSE; 159 stencilInfo->depthWriteEnable = VK_FALSE;
160 stencilInfo->depthCompareOp = VK_COMPARE_OP_ALWAYS; 160 stencilInfo->depthCompareOp = VK_COMPARE_OP_ALWAYS;
161 stencilInfo->depthBoundsTestEnable = VK_FALSE; 161 stencilInfo->depthBoundsTestEnable = VK_FALSE;
162 stencilInfo->stencilTestEnable = !stencilSettings.isDisabled(); 162 stencilInfo->stencilTestEnable = !stencilSettings.isDisabled();
163 if (!stencilSettings.isDisabled()) { 163 if (!stencilSettings.isDisabled()) {
164 // Set front face 164 // Set front face
165 GrStencilSettings::Face face = GrStencilSettings::kFront_Face; 165 const GrStencilSettings::Face& front = stencilSettings.front();
166 stencilInfo->front.failOp = stencil_op_to_vk_stencil_op(stencilSettings. failOp(face)); 166 stencilInfo->front.failOp = stencil_op_to_vk_stencil_op(front.fFailOp);
167 stencilInfo->front.passOp = stencil_op_to_vk_stencil_op(stencilSettings. passOp(face)); 167 stencilInfo->front.passOp = stencil_op_to_vk_stencil_op(front.fPassOp);
168 stencilInfo->front.depthFailOp = stencilInfo->front.failOp; 168 stencilInfo->front.depthFailOp = stencilInfo->front.failOp;
169 stencilInfo->front.compareOp = stencil_func_to_vk_compare_op(stencilSett ings.func(face)); 169 stencilInfo->front.compareOp = stencil_func_to_vk_compare_op(front.fTest );
170 stencilInfo->front.compareMask = stencilSettings.funcMask(face); 170 stencilInfo->front.compareMask = front.fTestMask;
171 stencilInfo->front.writeMask = stencilSettings.writeMask(face); 171 stencilInfo->front.writeMask = front.fWriteMask;
172 stencilInfo->front.reference = stencilSettings.funcRef(face); 172 stencilInfo->front.reference = front.fRef;
173 173
174 // Set back face 174 // Set back face
175 face = GrStencilSettings::kBack_Face; 175 if (!stencilSettings.isTwoSided()) {
176 stencilInfo->back.failOp = stencil_op_to_vk_stencil_op(stencilSettings.f ailOp(face)); 176 stencilInfo->back = stencilInfo->front;
177 stencilInfo->back.passOp = stencil_op_to_vk_stencil_op(stencilSettings.p assOp(face)); 177 } else {
178 stencilInfo->back.depthFailOp = stencilInfo->front.failOp; 178 const GrStencilSettings::Face& back = stencilSettings.back();
179 stencilInfo->back.compareOp = stencil_func_to_vk_compare_op(stencilSetti ngs.func(face)); 179 stencilInfo->back.failOp = stencil_op_to_vk_stencil_op(back.fFailOp) ;
180 stencilInfo->back.compareMask = stencilSettings.funcMask(face); 180 stencilInfo->back.passOp = stencil_op_to_vk_stencil_op(back.fPassOp) ;
181 stencilInfo->back.writeMask = stencilSettings.writeMask(face); 181 stencilInfo->back.depthFailOp = stencilInfo->front.failOp;
182 stencilInfo->back.reference = stencilSettings.funcRef(face); 182 stencilInfo->back.compareOp = stencil_func_to_vk_compare_op(back.fTe st);
183 stencilInfo->back.compareMask = back.fTestMask;
184 stencilInfo->back.writeMask = back.fWriteMask;
185 stencilInfo->back.reference = back.fRef;
186 }
183 } 187 }
184 stencilInfo->minDepthBounds = 0.0f; 188 stencilInfo->minDepthBounds = 0.0f;
185 stencilInfo->maxDepthBounds = 1.0f; 189 stencilInfo->maxDepthBounds = 1.0f;
186 } 190 }
187 191
188 void setup_viewport_scissor_state(const GrVkGpu* gpu, 192 void setup_viewport_scissor_state(const GrVkGpu* gpu,
189 const GrPipeline& pipeline, 193 const GrPipeline& pipeline,
190 const GrVkRenderTarget* vkRT, 194 const GrVkRenderTarget* vkRT,
191 VkPipelineViewportStateCreateInfo* viewportInf o) { 195 VkPipelineViewportStateCreateInfo* viewportInf o) {
192 memset(viewportInfo, 0, sizeof(VkPipelineViewportStateCreateInfo)); 196 memset(viewportInfo, 0, sizeof(VkPipelineViewportStateCreateInfo));
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 552 }
549 553
550 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, 554 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu,
551 GrVkCommandBuffer* cmdBuffer, 555 GrVkCommandBuffer* cmdBuffer,
552 const GrPipeline& pipeline) { 556 const GrPipeline& pipeline) {
553 const GrRenderTarget& target = *pipeline.getRenderTarget(); 557 const GrRenderTarget& target = *pipeline.getRenderTarget();
554 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); 558 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target);
555 set_dynamic_viewport_state(gpu, cmdBuffer, target); 559 set_dynamic_viewport_state(gpu, cmdBuffer, target);
556 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); 560 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline);
557 } 561 }
OLDNEW
« no previous file with comments | « src/gpu/text/GrStencilAndCoverTextContext.cpp ('k') | src/gpu/vk/GrVkPipelineState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698