| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/vulkan/vulkan_shader_module.h" | 5 #include "gpu/vulkan/vulkan_shader_module.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <shaderc/shaderc.h> | 8 #include <shaderc/shaderc.h> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 if (padding < 4) { | 116 if (padding < 4) { |
| 117 for (int i = 0; i < padding; ++i) { | 117 for (int i = 0; i < padding; ++i) { |
| 118 source += ' '; | 118 source += ' '; |
| 119 } | 119 } |
| 120 } | 120 } |
| 121 | 121 |
| 122 VkShaderModuleCreateInfo shader_module_create_info = {}; | 122 VkShaderModuleCreateInfo shader_module_create_info = {}; |
| 123 shader_module_create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | 123 shader_module_create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 124 shader_module_create_info.pCode = | 124 shader_module_create_info.pCode = |
| 125 reinterpret_cast<const uint32_t*>(source.c_str()); | 125 reinterpret_cast<const uint32_t*>(source.c_str()); |
| 126 shader_module_create_info.codeSize = source.length() / 4; | 126 shader_module_create_info.codeSize = source.length(); |
| 127 | 127 |
| 128 VkShaderModule shader_module = VK_NULL_HANDLE; | 128 VkShaderModule shader_module = VK_NULL_HANDLE; |
| 129 VkResult result = | 129 VkResult result = |
| 130 vkCreateShaderModule(device_queue_->GetVulkanDevice(), | 130 vkCreateShaderModule(device_queue_->GetVulkanDevice(), |
| 131 &shader_module_create_info, nullptr, &shader_module); | 131 &shader_module_create_info, nullptr, &shader_module); |
| 132 if (VK_SUCCESS != result) { | 132 if (VK_SUCCESS != result) { |
| 133 std::stringstream ss; | 133 std::stringstream ss; |
| 134 ss << "vkCreateShaderModule() failed: " << result; | 134 ss << "vkCreateShaderModule() failed: " << result; |
| 135 error_messages_ = ss.str(); | 135 error_messages_ = ss.str(); |
| 136 DLOG(ERROR) << error_messages_; | 136 DLOG(ERROR) << error_messages_; |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 handle_ = shader_module; | 140 handle_ = shader_module; |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 | 143 |
| 144 void VulkanShaderModule::Destroy() { | 144 void VulkanShaderModule::Destroy() { |
| 145 if (handle_ != VK_NULL_HANDLE) { | 145 if (handle_ != VK_NULL_HANDLE) { |
| 146 vkDestroyShaderModule(device_queue_->GetVulkanDevice(), handle_, nullptr); | 146 vkDestroyShaderModule(device_queue_->GetVulkanDevice(), handle_, nullptr); |
| 147 handle_ = VK_NULL_HANDLE; | 147 handle_ = VK_NULL_HANDLE; |
| 148 } | 148 } |
| 149 | 149 |
| 150 entry_point_.clear(); | 150 entry_point_.clear(); |
| 151 error_messages_.clear(); | 151 error_messages_.clear(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace gpu | 154 } // namespace gpu |
| OLD | NEW |