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

Unified 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, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/vulkan/vulkan_command_pool.cc
diff --git a/gpu/vulkan/vulkan_command_pool.cc b/gpu/vulkan/vulkan_command_pool.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c771dbd6b9e9617f2e16edc0984fb97970d8e14f
--- /dev/null
+++ b/gpu/vulkan/vulkan_command_pool.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/vulkan/vulkan_command_pool.h"
+
+#include "base/logging.h"
+#include "gpu/vulkan/vulkan_command_buffer.h"
+#include "gpu/vulkan/vulkan_implementation.h"
+
+namespace gpu {
+
+VulkanCommandPool::VulkanCommandPool(VkDevice device, uint32_t queue_index)
+ : device_(device), queue_index_(queue_index) {}
+
+VulkanCommandPool::~VulkanCommandPool() {
+ DCHECK_EQ(0u, command_buffer_count_);
+ DCHECK_EQ(static_cast<VkCommandPool>(VK_NULL_HANDLE), handle_);
+}
+
+bool VulkanCommandPool::Initialize() {
+ VkCommandPoolCreateInfo command_pool_create_info = {};
+ command_pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ command_pool_create_info.flags =
+ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
+ command_pool_create_info.queueFamilyIndex = queue_index_;
+
+ VkResult result = vkCreateCommandPool(device_, &command_pool_create_info,
+ nullptr, &handle_);
+ if (VK_SUCCESS != result) {
+ DLOG(ERROR) << "vkCreateCommandPool() failed: " << result;
+ return false;
+ }
+
+ return true;
+}
+
+void VulkanCommandPool::Destroy() {
+ DCHECK_EQ(0u, command_buffer_count_);
+ if (VK_NULL_HANDLE != handle_) {
+ vkDestroyCommandPool(device_, handle_, nullptr);
+ handle_ = VK_NULL_HANDLE;
+ }
+}
+
+scoped_ptr<VulkanCommandBuffer>
+VulkanCommandPool::CreatePrimaryCommandBuffer() {
+ scoped_ptr<VulkanCommandBuffer> command_buffer(
+ new VulkanCommandBuffer(this, true));
+ if (!command_buffer->Initialize())
+ return nullptr;
+
+ return command_buffer;
+}
+
+scoped_ptr<VulkanCommandBuffer>
+VulkanCommandPool::CreateSecondaryCommandBuffer() {
+ scoped_ptr<VulkanCommandBuffer> command_buffer(
+ new VulkanCommandBuffer(this, false));
+ if (!command_buffer->Initialize())
+ return nullptr;
+
+ return command_buffer;
+}
+
+void VulkanCommandPool::IncrementCommandBufferCount() {
+ command_buffer_count_++;
+}
+
+void VulkanCommandPool::DecrementCommandBufferCount() {
+ DCHECK_LT(0u, command_buffer_count_);
+ command_buffer_count_--;
+}
+
+} // namespace gpu
« 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