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

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

Issue 2653533002: Initialize memory for vulkan swapchain images.
Patch Set: Created 3 years, 11 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 | « no previous file | no next file » | 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_swap_chain.h" 5 #include "gpu/vulkan/vulkan_swap_chain.h"
6 6
7 #include "gpu/vulkan/vulkan_command_buffer.h" 7 #include "gpu/vulkan/vulkan_command_buffer.h"
8 #include "gpu/vulkan/vulkan_command_pool.h" 8 #include "gpu/vulkan/vulkan_command_pool.h"
9 #include "gpu/vulkan/vulkan_device_queue.h" 9 #include "gpu/vulkan/vulkan_device_queue.h"
10 #include "gpu/vulkan/vulkan_image_view.h" 10 #include "gpu/vulkan/vulkan_image_view.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 result = vkCreateSemaphore(device, &semaphore_create_info, nullptr, 196 result = vkCreateSemaphore(device, &semaphore_create_info, nullptr,
197 &image_data->present_semaphore); 197 &image_data->present_semaphore);
198 if (VK_SUCCESS != result) { 198 if (VK_SUCCESS != result) {
199 DLOG(ERROR) << "vkCreateSemaphore(present) failed: " << result; 199 DLOG(ERROR) << "vkCreateSemaphore(present) failed: " << result;
200 return false; 200 return false;
201 } 201 }
202 202
203 // Initialize the command buffer for this buffer data. 203 // Initialize the command buffer for this buffer data.
204 image_data->command_buffer = command_pool_->CreatePrimaryCommandBuffer(); 204 image_data->command_buffer = command_pool_->CreatePrimaryCommandBuffer();
205 205
206 // Setup the Image Layout as the first command that gets issued in each 206 {
207 // command buffer. 207 // Setup the Image Layout as the first command that gets issued in each
208 ScopedSingleUseCommandBufferRecorder recorder(*image_data->command_buffer); 208 // command buffer.
209 image_memory_barrier.image = images[i]; 209 ScopedSingleUseCommandBufferRecorder recorder(
210 vkCmdPipelineBarrier(recorder.handle(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 210 *image_data->command_buffer);
211 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0, 211 image_memory_barrier.image = images[i];
212 nullptr, 1, &image_memory_barrier); 212 vkCmdPipelineBarrier(recorder.handle(), VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
213 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0,
214 nullptr, 1, &image_memory_barrier);
215
216 VkClearColorValue clear_color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
217 vkCmdClearColorImage(recorder.handle(), images[i],
218 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
219 &clear_color, 1, &image_subresource_range);
220 }
221
222 // First submit to fill the image memory.
223 if (!image_data->command_buffer->Submit(0, VK_NULL_HANDLE,
224 1, &image_data->render_semaphore)) {
225 return false;
226 }
213 227
214 // Create the image view. 228 // Create the image view.
215 image_data->image_view.reset(new VulkanImageView(device_queue_)); 229 image_data->image_view.reset(new VulkanImageView(device_queue_));
216 if (!image_data->image_view->Initialize( 230 if (!image_data->image_view->Initialize(
217 images[i], VK_IMAGE_VIEW_TYPE_2D, VulkanImageView::IMAGE_TYPE_COLOR, 231 images[i], VK_IMAGE_VIEW_TYPE_2D, VulkanImageView::IMAGE_TYPE_COLOR,
218 surface_format.format, size_.width(), size_.height(), 0, 1, 0, 1)) { 232 surface_format.format, size_.width(), size_.height(), 0, 1, 0, 1)) {
219 return false; 233 return false;
220 } 234 }
221 } 235 }
222 236
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 command_pool_->Destroy(); 298 command_pool_->Destroy();
285 command_pool_.reset(); 299 command_pool_.reset();
286 } 300 }
287 } 301 }
288 302
289 VulkanSwapChain::ImageData::ImageData() {} 303 VulkanSwapChain::ImageData::ImageData() {}
290 304
291 VulkanSwapChain::ImageData::~ImageData() {} 305 VulkanSwapChain::ImageData::~ImageData() {}
292 306
293 } // namespace gpu 307 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698