Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Side by Side Diff: gpu/vulkan/vulkan_command_pool.cc

Issue 1776453003: Added initial implementation of Vulkan Render Passes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn_vulkan
Patch Set: Adding logging/macros headers Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/vulkan/vulkan_command_pool.h ('k') | gpu/vulkan/vulkan_image_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_command_pool.h"
6
7 #include "base/logging.h"
8 #include "gpu/vulkan/vulkan_command_buffer.h"
9 #include "gpu/vulkan/vulkan_implementation.h"
10
11 namespace gpu {
12
13 VulkanCommandPool::VulkanCommandPool(VkDevice device, uint32_t queue_index)
14 : device_(device), queue_index_(queue_index) {}
15
16 VulkanCommandPool::~VulkanCommandPool() {
17 DCHECK_EQ(0u, command_buffer_count_);
18 DCHECK_EQ(static_cast<VkCommandPool>(VK_NULL_HANDLE), handle_);
19 }
20
21 bool VulkanCommandPool::Initialize() {
22 VkCommandPoolCreateInfo command_pool_create_info = {};
23 command_pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
24 command_pool_create_info.flags =
25 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
26 command_pool_create_info.queueFamilyIndex = queue_index_;
27
28 VkResult result = vkCreateCommandPool(device_, &command_pool_create_info,
29 nullptr, &handle_);
30 if (VK_SUCCESS != result) {
31 DLOG(ERROR) << "vkCreateCommandPool() failed: " << result;
32 return false;
33 }
34
35 return true;
36 }
37
38 void VulkanCommandPool::Destroy() {
39 DCHECK_EQ(0u, command_buffer_count_);
40 if (VK_NULL_HANDLE != handle_) {
41 vkDestroyCommandPool(device_, handle_, nullptr);
42 handle_ = VK_NULL_HANDLE;
43 }
44 }
45
46 scoped_ptr<VulkanCommandBuffer>
47 VulkanCommandPool::CreatePrimaryCommandBuffer() {
48 scoped_ptr<VulkanCommandBuffer> command_buffer(
49 new VulkanCommandBuffer(this, true));
50 if (!command_buffer->Initialize())
51 return nullptr;
52
53 return command_buffer;
54 }
55
56 scoped_ptr<VulkanCommandBuffer>
57 VulkanCommandPool::CreateSecondaryCommandBuffer() {
58 scoped_ptr<VulkanCommandBuffer> command_buffer(
59 new VulkanCommandBuffer(this, false));
60 if (!command_buffer->Initialize())
61 return nullptr;
62
63 return command_buffer;
64 }
65
66 void VulkanCommandPool::IncrementCommandBufferCount() {
67 command_buffer_count_++;
68 }
69
70 void VulkanCommandPool::DecrementCommandBufferCount() {
71 DCHECK_LT(0u, command_buffer_count_);
72 command_buffer_count_--;
73 }
74
75 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/vulkan/vulkan_command_pool.h ('k') | gpu/vulkan/vulkan_image_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698