| 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" |
| 11 #include "GrPipeline.h" | 11 #include "GrPipeline.h" |
| 12 | 12 |
| 13 #include "GrVkGpu.h" | 13 #include "GrVkGpu.h" |
| 14 #include "GrVkProgramDesc.h" | 14 #include "GrVkProgramDesc.h" |
| 15 #include "GrVkRenderTarget.h" | 15 #include "GrVkRenderTarget.h" |
| 16 #include "GrVkUtil.h" | 16 #include "GrVkUtil.h" |
| 17 | 17 |
| 18 static inline const VkFormat& attrib_type_to_vkformat(GrVertexAttribType type) { | 18 static inline const VkFormat& attrib_type_to_vkformat(GrVertexAttribType type) { |
| 19 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); | 19 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| 20 static const VkFormat kFormats[kGrVertexAttribTypeCount] = { | 20 static const VkFormat kFormats[kGrVertexAttribTypeCount] = { |
| 21 VK_FORMAT_R32_SFLOAT, // kFloat_GrVertexAttribType | 21 VK_FORMAT_R32_SFLOAT, // kFloat_GrVertexAttribType |
| 22 VK_FORMAT_R32G32_SFLOAT, // kVec2f_GrVertexAttribType | 22 VK_FORMAT_R32G32_SFLOAT, // kVec2f_GrVertexAttribType |
| 23 VK_FORMAT_R32G32B32_SFLOAT, // kVec3f_GrVertexAttribType | 23 VK_FORMAT_R32G32B32_SFLOAT, // kVec3f_GrVertexAttribType |
| 24 VK_FORMAT_R32G32B32A32_SFLOAT, // kVec4f_GrVertexAttribType | 24 VK_FORMAT_R32G32B32A32_SFLOAT, // kVec4f_GrVertexAttribType |
| 25 VK_FORMAT_R8_UNORM, // kUByte_GrVertexAttribType | 25 VK_FORMAT_R8_UNORM, // kUByte_GrVertexAttribType |
| 26 VK_FORMAT_R8G8B8A8_UNORM, // kVec4ub_GrVertexAttribType | 26 VK_FORMAT_R8G8B8A8_UNORM, // kVec4ub_GrVertexAttribType |
| 27 VK_FORMAT_R16G16_SSCALED, // kVec2s_GrVertexAttribType | 27 VK_FORMAT_R16G16_UNORM, // kVec2us_GrVertexAttribType |
| 28 }; | 28 }; |
| 29 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); | 29 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| 30 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); | 30 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); |
| 31 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); | 31 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); |
| 32 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); | 32 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); |
| 33 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); | 33 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| 34 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); | 34 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| 35 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); | 35 GR_STATIC_ASSERT(6 == kVec2us_GrVertexAttribType); |
| 36 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFormats) == kGrVertexAttribTypeCount); | 36 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFormats) == kGrVertexAttribTypeCount); |
| 37 return kFormats[type]; | 37 return kFormats[type]; |
| 38 } | 38 } |
| 39 | 39 |
| 40 static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc, | 40 static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc, |
| 41 VkPipelineVertexInputStateCreateInfo* verte
xInputInfo, | 41 VkPipelineVertexInputStateCreateInfo* verte
xInputInfo, |
| 42 VkVertexInputBindingDescription* bindingDes
c, | 42 VkVertexInputBindingDescription* bindingDes
c, |
| 43 int maxBindingDescCount, | 43 int maxBindingDescCount, |
| 44 VkVertexInputAttributeDescription* attribut
eDesc, | 44 VkVertexInputAttributeDescription* attribut
eDesc, |
| 45 int maxAttributeDescCount) { | 45 int maxAttributeDescCount) { |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 498 } |
| 499 | 499 |
| 500 return new GrVkPipeline(vkPipeline); | 500 return new GrVkPipeline(vkPipeline); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const { | 503 void GrVkPipeline::freeGPUData(const GrVkGpu* gpu) const { |
| 504 GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nul
lptr)); | 504 GR_VK_CALL(gpu->vkInterface(), DestroyPipeline(gpu->device(), fPipeline, nul
lptr)); |
| 505 } | 505 } |
| 506 | 506 |
| 507 | 507 |
| OLD | NEW |