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

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: added fence to command buffer 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
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 "gpu/vulkan/vulkan_command_buffer.h"
8 #include "gpu/vulkan/vulkan_implementation.h"
9
10 namespace gpu {
11
12 VulkanCommandPool::VulkanCommandPool(VkDevice device, uint32_t queue_index)
13 : device_(device), queue_index_(queue_index) {}
14
15 VulkanCommandPool::~VulkanCommandPool() {
16 DCHECK_EQ(0u, command_buffer_count_);
17 DCHECK_EQ(static_cast<VkCommandPool>(VK_NULL_HANDLE), handle_);
18 }
19
20 bool VulkanCommandPool::Initialize() {
21 VkCommandPoolCreateInfo command_pool_create_info = {};
22 command_pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
23 command_pool_create_info.flags =
24 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
25 command_pool_create_info.queueFamilyIndex = queue_index_;
26
27 VkResult result = vkCreateCommandPool(device_, &command_pool_create_info,
28 nullptr, &handle_);
29 if (VK_SUCCESS != result) {
30 DLOG(ERROR) << "vkCreateCommandPool() failed: " << result;
31 return false;
32 }
33
34 return true;
35 }
36
37 void VulkanCommandPool::Destroy() {
38 DCHECK_EQ(0u, command_buffer_count_);
39 if (VK_NULL_HANDLE != handle_) {
40 vkDestroyCommandPool(device_, handle_, nullptr);
41 handle_ = VK_NULL_HANDLE;
42 }
43 }
44
45 scoped_ptr<VulkanCommandBuffer>
46 VulkanCommandPool::CreatePrimaryCommandBuffer() {
47 scoped_ptr<VulkanCommandBuffer> command_buffer(
48 new VulkanCommandBuffer(this, true));
49 if (!command_buffer->Initialize())
50 return nullptr;
51
52 return command_buffer;
53 }
54
55 scoped_ptr<VulkanCommandBuffer>
56 VulkanCommandPool::CreateSecondaryCommandBuffer() {
57 scoped_ptr<VulkanCommandBuffer> command_buffer(
58 new VulkanCommandBuffer(this, false));
59 if (!command_buffer->Initialize())
60 return nullptr;
61
62 return command_buffer;
63 }
64
65 void VulkanCommandPool::IncrementCommandBufferCount() {
66 command_buffer_count_++;
67 }
68
69 void VulkanCommandPool::DecrementCommandBufferCount() {
70 DCHECK_LT(0u, command_buffer_count_);
71 command_buffer_count_--;
72 }
73
74 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698