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

Side by Side Diff: gpu/vulkan/vulkan_render_pass.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, 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_render_pass.h ('k') | gpu/vulkan/vulkan_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/vulkan/vulkan_render_pass.h" 5 #include "gpu/vulkan/vulkan_render_pass.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/vulkan/vulkan_command_buffer.h" 8 #include "gpu/vulkan/vulkan_command_buffer.h"
9 #include "gpu/vulkan/vulkan_device_queue.h"
9 #include "gpu/vulkan/vulkan_image_view.h" 10 #include "gpu/vulkan/vulkan_image_view.h"
10 #include "gpu/vulkan/vulkan_implementation.h" 11 #include "gpu/vulkan/vulkan_implementation.h"
11 #include "gpu/vulkan/vulkan_swap_chain.h" 12 #include "gpu/vulkan/vulkan_swap_chain.h"
12 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/geometry/size.h"
13 14
14 namespace gpu { 15 namespace gpu {
15 16
16 VkImageLayout ConvertImageLayout( 17 VkImageLayout ConvertImageLayout(
17 const VulkanImageView* image_view, 18 const VulkanImageView* image_view,
18 VulkanRenderPass::ImageLayoutType layout_type) { 19 VulkanRenderPass::ImageLayoutType layout_type) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 121 }
121 #endif 122 #endif
122 123
123 return true; 124 return true;
124 } 125 }
125 126
126 VulkanRenderPass::RenderPassData::RenderPassData() {} 127 VulkanRenderPass::RenderPassData::RenderPassData() {}
127 128
128 VulkanRenderPass::RenderPassData::~RenderPassData() {} 129 VulkanRenderPass::RenderPassData::~RenderPassData() {}
129 130
130 VulkanRenderPass::VulkanRenderPass() {} 131 VulkanRenderPass::VulkanRenderPass(VulkanDeviceQueue* device_queue)
132 : device_queue_(device_queue) {}
131 133
132 VulkanRenderPass::~VulkanRenderPass() { 134 VulkanRenderPass::~VulkanRenderPass() {
133 DCHECK_EQ(static_cast<VkRenderPass>(VK_NULL_HANDLE), render_pass_); 135 DCHECK_EQ(static_cast<VkRenderPass>(VK_NULL_HANDLE), render_pass_);
134 DCHECK(frame_buffers_.empty()); 136 DCHECK(frame_buffers_.empty());
135 } 137 }
136 138
137 bool VulkanRenderPass::RenderPassData::ValidateData( 139 bool VulkanRenderPass::RenderPassData::ValidateData(
138 const VulkanSwapChain* swap_chain) const { 140 const VulkanSwapChain* swap_chain) const {
139 #if DCHECK_IS_ON() 141 #if DCHECK_IS_ON()
140 for (const AttachmentData& attachment : attachments) { 142 for (const AttachmentData& attachment : attachments) {
(...skipping 10 matching lines...) Expand all
151 return true; 153 return true;
152 } 154 }
153 155
154 bool VulkanRenderPass::Initialize(const VulkanSwapChain* swap_chain, 156 bool VulkanRenderPass::Initialize(const VulkanSwapChain* swap_chain,
155 const RenderPassData& render_pass_data) { 157 const RenderPassData& render_pass_data) {
156 DCHECK(!executing_); 158 DCHECK(!executing_);
157 DCHECK_EQ(static_cast<VkRenderPass>(VK_NULL_HANDLE), render_pass_); 159 DCHECK_EQ(static_cast<VkRenderPass>(VK_NULL_HANDLE), render_pass_);
158 DCHECK(frame_buffers_.empty()); 160 DCHECK(frame_buffers_.empty());
159 DCHECK(render_pass_data.ValidateData(swap_chain)); 161 DCHECK(render_pass_data.ValidateData(swap_chain));
160 162
161 VkDevice device = GetVulkanDevice(); 163 VkDevice device = device_queue_->GetVulkanDevice();
162 VkResult result = VK_SUCCESS; 164 VkResult result = VK_SUCCESS;
163 165
164 swap_chain_ = swap_chain; 166 swap_chain_ = swap_chain;
165 num_sub_passes_ = render_pass_data.subpass_datas.size(); 167 num_sub_passes_ = render_pass_data.subpass_datas.size();
166 current_sub_pass_ = 0; 168 current_sub_pass_ = 0;
167 attachment_clear_values_.clear(); 169 attachment_clear_values_.clear();
168 attachment_clear_indexes_.clear(); 170 attachment_clear_indexes_.clear();
169 171
170 // Fill out attachment information. 172 // Fill out attachment information.
171 const uint32_t num_attachments = render_pass_data.attachments.size(); 173 const uint32_t num_attachments = render_pass_data.attachments.size();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 if (VK_SUCCESS != result) { 323 if (VK_SUCCESS != result) {
322 DLOG(ERROR) << "vkCreateFramebuffer() failed: " << result; 324 DLOG(ERROR) << "vkCreateFramebuffer() failed: " << result;
323 return false; 325 return false;
324 } 326 }
325 } 327 }
326 328
327 return true; 329 return true;
328 } 330 }
329 331
330 void VulkanRenderPass::Destroy() { 332 void VulkanRenderPass::Destroy() {
331 VkDevice device = GetVulkanDevice(); 333 VkDevice device = device_queue_->GetVulkanDevice();
332 334
333 for (VkFramebuffer frame_buffer : frame_buffers_) { 335 for (VkFramebuffer frame_buffer : frame_buffers_) {
334 vkDestroyFramebuffer(device, frame_buffer, nullptr); 336 vkDestroyFramebuffer(device, frame_buffer, nullptr);
335 } 337 }
336 frame_buffers_.clear(); 338 frame_buffers_.clear();
337 339
338 if (VK_NULL_HANDLE != render_pass_) { 340 if (VK_NULL_HANDLE != render_pass_) {
339 vkDestroyRenderPass(device, render_pass_, nullptr); 341 vkDestroyRenderPass(device, render_pass_, nullptr);
340 render_pass_ = VK_NULL_HANDLE; 342 render_pass_ = VK_NULL_HANDLE;
341 } 343 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 auto iter = 392 auto iter =
391 std::lower_bound(attachment_clear_indexes_.begin(), 393 std::lower_bound(attachment_clear_indexes_.begin(),
392 attachment_clear_indexes_.end(), attachment_index); 394 attachment_clear_indexes_.end(), attachment_index);
393 if (iter != attachment_clear_indexes_.end() && *iter == attachment_index) { 395 if (iter != attachment_clear_indexes_.end() && *iter == attachment_index) {
394 const uint32_t index = iter - attachment_clear_indexes_.begin(); 396 const uint32_t index = iter - attachment_clear_indexes_.begin();
395 attachment_clear_values_[index] = clear_value; 397 attachment_clear_values_[index] = clear_value;
396 } 398 }
397 } 399 }
398 400
399 } // namespace gpu 401 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/vulkan/vulkan_render_pass.h ('k') | gpu/vulkan/vulkan_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698