| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // TODO: mask out any state we might want to set dynamically | 428 // TODO: mask out any state we might want to set dynamically |
| 429 dynamicInfo->dynamicStateCount = 0; | 429 dynamicInfo->dynamicStateCount = 0; |
| 430 } | 430 } |
| 431 | 431 |
| 432 GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, | 432 GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, |
| 433 const GrPrimitiveProcessor& primProc, | 433 const GrPrimitiveProcessor& primProc, |
| 434 VkPipelineShaderStageCreateInfo* shaderStageI
nfo, | 434 VkPipelineShaderStageCreateInfo* shaderStageI
nfo, |
| 435 int shaderStageCount, | 435 int shaderStageCount, |
| 436 GrPrimitiveType primitiveType, | 436 GrPrimitiveType primitiveType, |
| 437 const GrVkRenderPass& renderPass, | 437 const GrVkRenderPass& renderPass, |
| 438 VkPipelineLayout layout) { | 438 VkPipelineLayout layout, |
| 439 VkPipelineCache cache) { |
| 439 VkPipelineVertexInputStateCreateInfo vertexInputInfo; | 440 VkPipelineVertexInputStateCreateInfo vertexInputInfo; |
| 440 VkVertexInputBindingDescription bindingDesc; | 441 VkVertexInputBindingDescription bindingDesc; |
| 441 // TODO: allocate this based on VkPhysicalDeviceLimits::maxVertexInputAttrib
utes | 442 // TODO: allocate this based on VkPhysicalDeviceLimits::maxVertexInputAttrib
utes |
| 442 static const int kMaxVertexAttributes = 16; | 443 static const int kMaxVertexAttributes = 16; |
| 443 static VkVertexInputAttributeDescription attributeDesc[kMaxVertexAttributes]
; | 444 static VkVertexInputAttributeDescription attributeDesc[kMaxVertexAttributes]
; |
| 444 setup_vertex_input_state(primProc, &vertexInputInfo, &bindingDesc, 1, | 445 setup_vertex_input_state(primProc, &vertexInputInfo, &bindingDesc, 1, |
| 445 attributeDesc, kMaxVertexAttributes); | 446 attributeDesc, kMaxVertexAttributes); |
| 446 | 447 |
| 447 VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo; | 448 VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo; |
| 448 setup_input_assembly_state(primitiveType, &inputAssemblyInfo); | 449 setup_input_assembly_state(primitiveType, &inputAssemblyInfo); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 pipelineCreateInfo.pColorBlendState = &colorBlendInfo; | 489 pipelineCreateInfo.pColorBlendState = &colorBlendInfo; |
| 489 pipelineCreateInfo.pDynamicState = &dynamicInfo; | 490 pipelineCreateInfo.pDynamicState = &dynamicInfo; |
| 490 pipelineCreateInfo.layout = layout; | 491 pipelineCreateInfo.layout = layout; |
| 491 pipelineCreateInfo.renderPass = renderPass.vkRenderPass(); | 492 pipelineCreateInfo.renderPass = renderPass.vkRenderPass(); |
| 492 pipelineCreateInfo.subpass = 0; | 493 pipelineCreateInfo.subpass = 0; |
| 493 pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE; | 494 pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE; |
| 494 pipelineCreateInfo.basePipelineIndex = -1; | 495 pipelineCreateInfo.basePipelineIndex = -1; |
| 495 | 496 |
| 496 VkPipeline vkPipeline; | 497 VkPipeline vkPipeline; |
| 497 VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->d
evice(), | 498 VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateGraphicsPipelines(gpu->d
evice(), |
| 498 VK_NUL
L_HANDLE, 1, | 499 cache,
1, |
| 499 &pipel
ineCreateInfo, | 500 &pipel
ineCreateInfo, |
| 500 nullpt
r, &vkPipeline)); | 501 nullpt
r, &vkPipeline)); |
| 501 if (err) { | 502 if (err) { |
| 502 return nullptr; | 503 return nullptr; |
| 503 } | 504 } |
| 504 | 505 |
| 505 return new GrVkPipeline(vkPipeline); | 506 return new GrVkPipeline(vkPipeline); |
| 506 } | 507 } |
| 507 | 508 |
| 508 void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const { | 509 void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const { |
| 509 GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nul
lptr)); | 510 GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nul
lptr)); |
| 510 } | 511 } |
| 511 | 512 |
| 512 | 513 |
| OLD | NEW |