OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/vulkan/vulkan_descriptor_layout.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "gpu/vulkan/vulkan_descriptor_pool.h" |
| 9 #include "gpu/vulkan/vulkan_device_queue.h" |
| 10 |
| 11 namespace gpu { |
| 12 |
| 13 VulkanDescriptorLayout::VulkanDescriptorLayout(VulkanDeviceQueue* device_queue) |
| 14 : device_queue_(device_queue) {} |
| 15 |
| 16 VulkanDescriptorLayout::~VulkanDescriptorLayout() { |
| 17 DCHECK_EQ(static_cast<VkDescriptorSetLayout>(VK_NULL_HANDLE), handle_); |
| 18 } |
| 19 |
| 20 bool VulkanDescriptorLayout::Initialize( |
| 21 const std::vector<VkDescriptorSetLayoutBinding>& layout) { |
| 22 VkResult result = VK_SUCCESS; |
| 23 VkDevice device = device_queue_->GetVulkanDevice(); |
| 24 |
| 25 VkDescriptorSetLayoutCreateInfo layout_create_info = {}; |
| 26 layout_create_info.sType = |
| 27 VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 28 layout_create_info.bindingCount = static_cast<uint32_t>(layout.size()); |
| 29 layout_create_info.pBindings = layout.data(); |
| 30 |
| 31 result = vkCreateDescriptorSetLayout(device, &layout_create_info, nullptr, |
| 32 &handle_); |
| 33 if (VK_SUCCESS != result) { |
| 34 DLOG(ERROR) << "vkCreateDescriptorSetLayout() failed: " << result; |
| 35 return false; |
| 36 } |
| 37 |
| 38 return true; |
| 39 } |
| 40 |
| 41 void VulkanDescriptorLayout::Destroy() { |
| 42 if (VK_NULL_HANDLE != handle_) { |
| 43 vkDestroyDescriptorSetLayout( |
| 44 device_queue_->GetVulkanDevice(), handle_, nullptr); |
| 45 handle_ = VK_NULL_HANDLE; |
| 46 } |
| 47 } |
| 48 |
| 49 } // namespace gpu |
OLD | NEW |