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, | 207 const GrPrimitiveProcessor& primProc, |
208 const GrCaps* caps, | 208 const GrCaps* caps, |
209 VkPipelineMultisampleStateCreateInfo* multisampleIn
fo) { | 209 VkPipelineMultisampleStateCreateInfo* multisampleIn
fo) { |
210 memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo)); | 210 memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo)); |
211 multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE
_INFO; | 211 multisampleInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE
_INFO; |
212 multisampleInfo->pNext = nullptr; | 212 multisampleInfo->pNext = nullptr; |
213 multisampleInfo->flags = 0; | 213 multisampleInfo->flags = 0; |
214 int numSamples = pipeline.getRenderTarget()->numColorSamples(); | 214 int numSamples = pipeline.getRenderTarget()->numColorSamples(); |
215 SkAssertResult(GrSampleCountToVkSampleCount(numSamples, | 215 SkAssertResult(GrSampleCountToVkSampleCount(numSamples, |
216 &multisampleInfo->rasterizationSamples)); | 216 &multisampleInfo->rasterizationSamples)); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 pipelineCreateInfo.pColorBlendState = &colorBlendInfo; | 462 pipelineCreateInfo.pColorBlendState = &colorBlendInfo; |
463 pipelineCreateInfo.pDynamicState = &dynamicInfo; | 463 pipelineCreateInfo.pDynamicState = &dynamicInfo; |
464 pipelineCreateInfo.layout = layout; | 464 pipelineCreateInfo.layout = layout; |
465 pipelineCreateInfo.renderPass = renderPass.vkRenderPass(); | 465 pipelineCreateInfo.renderPass = renderPass.vkRenderPass(); |
466 pipelineCreateInfo.subpass = 0; | 466 pipelineCreateInfo.subpass = 0; |
467 pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE; | 467 pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE; |
468 pipelineCreateInfo.basePipelineIndex = -1; | 468 pipelineCreateInfo.basePipelineIndex = -1; |
469 | 469 |
470 VkPipeline vkPipeline; | 470 VkPipeline vkPipeline; |
471 VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->d
evice(), | 471 VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->d
evice(), |
472 cache,
1, | 472 cache,
1, |
473 &pipel
ineCreateInfo, | 473 &pipel
ineCreateInfo, |
474 nullpt
r, &vkPipeline)); | 474 nullpt
r, &vkPipeline)); |
475 if (err) { | 475 if (err) { |
476 return nullptr; | 476 return nullptr; |
477 } | 477 } |
478 | 478 |
479 return new GrVkPipeline(vkPipeline); | 479 return new GrVkPipeline(vkPipeline); |
480 } | 480 } |
481 | 481 |
482 void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const { | 482 void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const { |
483 GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nul
lptr)); | 483 GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nul
lptr)); |
484 } | 484 } |
485 | 485 |
486 void set_dynamic_scissor_state(GrVkGpu* gpu, | 486 void set_dynamic_scissor_state(GrVkGpu* gpu, |
487 GrVkCommandBuffer* cmdBuffer, | 487 GrVkCommandBuffer* cmdBuffer, |
488 const GrPipeline& pipeline, | 488 const GrPipeline& pipeline, |
489 const GrRenderTarget& target) { | 489 const GrRenderTarget& target) { |
490 // We always use one scissor and if it is disabled we just make it the size
of the RT | 490 // We always use one scissor and if it is disabled we just make it the size
of the RT |
491 const GrScissorState& scissorState = pipeline.getScissorState(); | 491 const GrScissorState& scissorState = pipeline.getScissorState(); |
492 VkRect2D scissor; | 492 VkRect2D scissor; |
493 if (scissorState.enabled() && | 493 if (scissorState.enabled() && |
494 !scissorState.rect().contains(0, 0, target.width(), target.height())) { | 494 !scissorState.rect().contains(0, 0, target.width(), target.height())) { |
495 // This all assumes the scissorState has previously been clipped to the
device space render | 495 // This all assumes the scissorState has previously been clipped to the
device space render |
496 // target. | 496 // target. |
497 scissor.offset.x = scissorState.rect().fLeft; | 497 scissor.offset.x = scissorState.rect().fLeft; |
498 scissor.extent.width = scissorState.rect().width(); | 498 scissor.extent.width = scissorState.rect().width(); |
499 if (kTopLeft_GrSurfaceOrigin == target.origin()) { | 499 if (kTopLeft_GrSurfaceOrigin == target.origin()) { |
500 scissor.offset.y = scissorState.rect().fTop; | 500 scissor.offset.y = scissorState.rect().fTop; |
501 } else { | 501 } else { |
502 SkASSERT(kBottomLeft_GrSurfaceOrigin == target.origin()); | 502 SkASSERT(kBottomLeft_GrSurfaceOrigin == target.origin()); |
503 scissor.offset.y = target.height() - scissorState.rect().fBottom; | 503 scissor.offset.y = target.height() - scissorState.rect().fBottom; |
504 } | 504 } |
505 scissor.extent.height = scissorState.rect().height(); | 505 scissor.extent.height = scissorState.rect().height(); |
506 | 506 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 } | 548 } |
549 | 549 |
550 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, | 550 void GrVkPipeline::SetDynamicState(GrVkGpu* gpu, |
551 GrVkCommandBuffer* cmdBuffer, | 551 GrVkCommandBuffer* cmdBuffer, |
552 const GrPipeline& pipeline) { | 552 const GrPipeline& pipeline) { |
553 const GrRenderTarget& target = *pipeline.getRenderTarget(); | 553 const GrRenderTarget& target = *pipeline.getRenderTarget(); |
554 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); | 554 set_dynamic_scissor_state(gpu, cmdBuffer, pipeline, target); |
555 set_dynamic_viewport_state(gpu, cmdBuffer, target); | 555 set_dynamic_viewport_state(gpu, cmdBuffer, target); |
556 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); | 556 set_dynamic_blend_constant_state(gpu, cmdBuffer, pipeline); |
557 } | 557 } |
OLD | NEW |