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

Unified Diff: gpu/vulkan/vulkan_swap_chain.cc

Issue 1829163003: Added initial implementation of the Vulkan Context Provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vk_surface_patch
Patch Set: Block off vulkan_cc with enable_vulkan (not relevant in future patch) 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_swap_chain.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/vulkan/vulkan_swap_chain.cc
diff --git a/gpu/vulkan/vulkan_swap_chain.cc b/gpu/vulkan/vulkan_swap_chain.cc
index 700832d25bd6466461fbecc5f9e82e45ab6706e9..c4e62295521e5e907e5a0fbfe3091a1fbd65c28b 100644
--- a/gpu/vulkan/vulkan_swap_chain.cc
+++ b/gpu/vulkan/vulkan_swap_chain.cc
@@ -6,6 +6,7 @@
#include "gpu/vulkan/vulkan_command_buffer.h"
#include "gpu/vulkan/vulkan_command_pool.h"
+#include "gpu/vulkan/vulkan_device_queue.h"
#include "gpu/vulkan/vulkan_image_view.h"
#include "gpu/vulkan/vulkan_implementation.h"
@@ -19,9 +20,12 @@ VulkanSwapChain::~VulkanSwapChain() {
DCHECK_EQ(static_cast<VkSemaphore>(VK_NULL_HANDLE), next_present_semaphore_);
}
-bool VulkanSwapChain::Initialize(VkSurfaceKHR surface,
+bool VulkanSwapChain::Initialize(VulkanDeviceQueue* device_queue,
+ VkSurfaceKHR surface,
const VkSurfaceCapabilitiesKHR& surface_caps,
const VkSurfaceFormatKHR& surface_format) {
+ DCHECK(device_queue);
+ device_queue_ = device_queue;
return InitializeSwapChain(surface, surface_caps, surface_format) &&
InitializeSwapImages(surface_caps, surface_format);
}
@@ -34,8 +38,8 @@ void VulkanSwapChain::Destroy() {
gfx::SwapResult VulkanSwapChain::SwapBuffers() {
VkResult result = VK_SUCCESS;
- VkDevice device = GetVulkanDevice();
- VkQueue queue = GetVulkanQueue();
+ VkDevice device = device_queue_->GetVulkanDevice();
+ VkQueue queue = device_queue_->GetVulkanQueue();
scoped_ptr<ImageData>& current_image_data = images_[current_image_];
@@ -49,7 +53,7 @@ gfx::SwapResult VulkanSwapChain::SwapBuffers() {
// Submit our command buffer for the current buffer.
if (!current_image_data->command_buffer->Submit(
- queue, 1, &current_image_data->present_semaphore, 1,
+ 1, &current_image_data->present_semaphore, 1,
&current_image_data->render_semaphore)) {
return gfx::SwapResult::SWAP_FAILED;
}
@@ -73,6 +77,7 @@ gfx::SwapResult VulkanSwapChain::SwapBuffers() {
next_present_semaphore_, VK_NULL_HANDLE,
&current_image_);
if (VK_SUCCESS != result) {
+ DLOG(ERROR) << "vkAcquireNextImageKHR() failed: " << result;
return gfx::SwapResult::SWAP_FAILED;
}
@@ -89,7 +94,7 @@ bool VulkanSwapChain::InitializeSwapChain(
VkSurfaceKHR surface,
const VkSurfaceCapabilitiesKHR& surface_caps,
const VkSurfaceFormatKHR& surface_format) {
- VkDevice device = GetVulkanDevice();
+ VkDevice device = device_queue_->GetVulkanDevice();
VkResult result = VK_SUCCESS;
VkSwapchainCreateInfoKHR swap_chain_create_info = {};
@@ -127,7 +132,7 @@ bool VulkanSwapChain::InitializeSwapChain(
}
void VulkanSwapChain::DestroySwapChain() {
- VkDevice device = GetVulkanDevice();
+ VkDevice device = device_queue_->GetVulkanDevice();
if (swap_chain_ != VK_NULL_HANDLE) {
vkDestroySwapchainKHR(device, swap_chain_, nullptr);
@@ -138,7 +143,7 @@ void VulkanSwapChain::DestroySwapChain() {
bool VulkanSwapChain::InitializeSwapImages(
const VkSurfaceCapabilitiesKHR& surface_caps,
const VkSurfaceFormatKHR& surface_format) {
- VkDevice device = GetVulkanDevice();
+ VkDevice device = device_queue_->GetVulkanDevice();
VkResult result = VK_SUCCESS;
uint32_t image_count = 0;
@@ -178,7 +183,7 @@ bool VulkanSwapChain::InitializeSwapImages(
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
image_memory_barrier.subresourceRange = image_subresource_range;
- command_pool_ = CreateCommandPool();
+ command_pool_ = device_queue_->CreateCommandPool();
if (!command_pool_)
return false;
@@ -215,7 +220,7 @@ bool VulkanSwapChain::InitializeSwapImages(
nullptr, 1, &image_memory_barrier);
// Create the image view.
- image_data->image_view.reset(new VulkanImageView);
+ image_data->image_view.reset(new VulkanImageView(device_queue_));
if (!image_data->image_view->Initialize(
images[i], VK_IMAGE_VIEW_TYPE_2D, VulkanImageView::IMAGE_TYPE_COLOR,
surface_format.format, size_.width(), size_.height(), 0, 1, 0, 1)) {
@@ -231,7 +236,7 @@ bool VulkanSwapChain::InitializeSwapImages(
}
// Acquire the initial buffer.
- result = vkAcquireNextImageKHR(GetVulkanDevice(), swap_chain_, UINT64_MAX,
+ result = vkAcquireNextImageKHR(device, swap_chain_, UINT64_MAX,
next_present_semaphore_, VK_NULL_HANDLE,
&current_image_);
if (VK_SUCCESS != result) {
@@ -246,7 +251,7 @@ bool VulkanSwapChain::InitializeSwapImages(
}
void VulkanSwapChain::DestroySwapImages() {
- VkDevice device = GetVulkanDevice();
+ VkDevice device = device_queue_->GetVulkanDevice();
if (VK_NULL_HANDLE != next_present_semaphore_) {
vkDestroySemaphore(device, next_present_semaphore_, nullptr);
« no previous file with comments | « gpu/vulkan/vulkan_swap_chain.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698