OLD | NEW |
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 viewportInfo->viewportCount = 1; | 197 viewportInfo->viewportCount = 1; |
198 viewportInfo->pViewports = nullptr; // This is set dynamically | 198 viewportInfo->pViewports = nullptr; // This is set dynamically |
199 | 199 |
200 viewportInfo->scissorCount = 1; | 200 viewportInfo->scissorCount = 1; |
201 viewportInfo->pScissors = nullptr; // This is set dynamically | 201 viewportInfo->pScissors = nullptr; // This is set dynamically |
202 | 202 |
203 SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount); | 203 SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount); |
204 } | 204 } |
205 | 205 |
206 void setup_multisample_state(const GrPipeline& pipeline, | 206 void setup_multisample_state(const GrPipeline& pipeline, |
| 207 const GrPrimitiveProcessor& primProc, |
| 208 const GrCaps* caps, |
207 VkPipelineMultisampleStateCreateInfo* multisampleIn
fo) { | 209 VkPipelineMultisampleStateCreateInfo* multisampleIn
fo) { |
208 memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo)); | 210 memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo)); |
209 multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE
_INFO; | 211 multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE
_INFO; |
210 multisampleInfo->pNext = nullptr; | 212 multisampleInfo->pNext = nullptr; |
211 multisampleInfo->flags = 0; | 213 multisampleInfo->flags = 0; |
212 int numSamples = pipeline.getRenderTarget()->numColorSamples(); | 214 int numSamples = pipeline.getRenderTarget()->numColorSamples(); |
213 SkAssertResult(GrSampleCountToVkSampleCount(numSamples, | 215 SkAssertResult(GrSampleCountToVkSampleCount(numSamples, |
214 &multisampleInfo->rasterizationSamples)); | 216 &multisampleInfo->rasterizationSamples)); |
215 multisampleInfo->sampleShadingEnable = VK_FALSE; | 217 float sampleShading = primProc.getSampleShading(); |
216 multisampleInfo->minSampleShading = 0; | 218 SkASSERT(sampleShading == 0.0f || caps->sampleShadingSupport()); |
| 219 multisampleInfo->sampleShadingEnable = sampleShading > 0.0f; |
| 220 multisampleInfo->minSampleShading = sampleShading; |
217 multisampleInfo->pSampleMask = nullptr; | 221 multisampleInfo->pSampleMask = nullptr; |
218 multisampleInfo->alphaToCoverageEnable = VK_FALSE; | 222 multisampleInfo->alphaToCoverageEnable = VK_FALSE; |
219 multisampleInfo->alphaToOneEnable = VK_FALSE; | 223 multisampleInfo->alphaToOneEnable = VK_FALSE; |
220 } | 224 } |
221 | 225 |
222 static VkBlendFactor blend_coeff_to_vk_blend(GrBlendCoeff coeff) { | 226 static VkBlendFactor blend_coeff_to_vk_blend(GrBlendCoeff coeff) { |
223 static const VkBlendFactor gTable[] = { | 227 static const VkBlendFactor gTable[] = { |
224 VK_BLEND_FACTOR_ZERO, // kZero_GrBlendCoeff | 228 VK_BLEND_FACTOR_ZERO, // kZero_GrBlendCoeff |
225 VK_BLEND_FACTOR_ONE, // kOne_GrBlendCoeff | 229 VK_BLEND_FACTOR_ONE, // kOne_GrBlendCoeff |
226 VK_BLEND_FACTOR_SRC_COLOR, // kSC_GrBlendCoeff | 230 VK_BLEND_FACTOR_SRC_COLOR, // kSC_GrBlendCoeff |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 424 |
421 VkPipelineDepthStencilStateCreateInfo depthStencilInfo; | 425 VkPipelineDepthStencilStateCreateInfo depthStencilInfo; |
422 setup_depth_stencil_state(gpu, pipeline.getStencil(), &depthStencilInfo); | 426 setup_depth_stencil_state(gpu, pipeline.getStencil(), &depthStencilInfo); |
423 | 427 |
424 GrRenderTarget* rt = pipeline.getRenderTarget(); | 428 GrRenderTarget* rt = pipeline.getRenderTarget(); |
425 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(rt); | 429 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(rt); |
426 VkPipelineViewportStateCreateInfo viewportInfo; | 430 VkPipelineViewportStateCreateInfo viewportInfo; |
427 setup_viewport_scissor_state(gpu, pipeline, vkRT, &viewportInfo); | 431 setup_viewport_scissor_state(gpu, pipeline, vkRT, &viewportInfo); |
428 | 432 |
429 VkPipelineMultisampleStateCreateInfo multisampleInfo; | 433 VkPipelineMultisampleStateCreateInfo multisampleInfo; |
430 setup_multisample_state(pipeline, &multisampleInfo); | 434 setup_multisample_state(pipeline, primProc, gpu->caps(), &multisampleInfo); |
431 | 435 |
432 // We will only have one color attachment per pipeline. | 436 // We will only have one color attachment per pipeline. |
433 VkPipelineColorBlendAttachmentState attachmentStates[1]; | 437 VkPipelineColorBlendAttachmentState attachmentStates[1]; |
434 VkPipelineColorBlendStateCreateInfo colorBlendInfo; | 438 VkPipelineColorBlendStateCreateInfo colorBlendInfo; |
435 setup_color_blend_state(gpu, pipeline, &colorBlendInfo, attachmentStates); | 439 setup_color_blend_state(gpu, pipeline, &colorBlendInfo, attachmentStates); |
436 | 440 |
437 VkPipelineRasterizationStateCreateInfo rasterInfo; | 441 VkPipelineRasterizationStateCreateInfo rasterInfo; |
438 setup_raster_state(gpu, pipeline, &rasterInfo); | 442 setup_raster_state(gpu, pipeline, &rasterInfo); |
439 | 443 |
440 VkDynamicState dynamicStates[3]; | 444 VkDynamicState dynamicStates[3]; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 548 } |
545 | 549 |
546 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, | 550 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, |
547 GrVkCommandBuffer* cmdBuffer, | 551 GrVkCommandBuffer* cmdBuffer, |
548 const GrPipeline& pipeline) { | 552 const GrPipeline& pipeline) { |
549 const GrRenderTarget& target = *pipeline.getRenderTarget(); | 553 const GrRenderTarget& target = *pipeline.getRenderTarget(); |
550 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); | 554 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); |
551 set_dynamic_viewport_state(gpu, cmdBuffer, target); | 555 set_dynamic_viewport_state(gpu, cmdBuffer, target); |
552 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); | 556 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); |
553 } | 557 } |
OLD | NEW |