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

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

Issue 1955803002: Added Validation to Vulkan CommandBuffer API's. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved declaration to initialization Created 4 years, 7 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 | « AUTHORS ('k') | 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_command_buffer.h" 5 #include "gpu/vulkan/vulkan_command_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.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_implementation.h" 10 #include "gpu/vulkan/vulkan_implementation.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 } 142 }
143 143
144 void VulkanCommandBuffer::ResetIfDirty() { 144 void VulkanCommandBuffer::ResetIfDirty() {
145 DCHECK(!recording_); 145 DCHECK(!recording_);
146 if (record_type_ == RECORD_TYPE_DIRTY) { 146 if (record_type_ == RECORD_TYPE_DIRTY) {
147 // Block if command buffer is still in use. This can be externally avoided 147 // Block if command buffer is still in use. This can be externally avoided
148 // using the asynchronous SubmissionFinished() function. 148 // using the asynchronous SubmissionFinished() function.
149 VkDevice device = device_queue_->GetVulkanDevice(); 149 VkDevice device = device_queue_->GetVulkanDevice();
150 vkWaitForFences(device, 1, &submission_fence_, true, UINT64_MAX); 150 vkWaitForFences(device, 1, &submission_fence_, true, UINT64_MAX);
151 151 VkResult result = vkResetCommandBuffer(command_buffer_, 0);
152 vkResetCommandBuffer(command_buffer_, 0); 152 if (VK_SUCCESS != result) {
153 record_type_ = RECORD_TYPE_EMPTY; 153 DLOG(ERROR) << "vkResetCommandBuffer() failed: " << result;
154 } else {
155 record_type_ = RECORD_TYPE_EMPTY;
156 }
154 } 157 }
155 } 158 }
156 159
157 CommandBufferRecorderBase::~CommandBufferRecorderBase() { 160 CommandBufferRecorderBase::~CommandBufferRecorderBase() {
158 vkEndCommandBuffer(handle_); 161 VkResult result = vkEndCommandBuffer(handle_);
162 if (VK_SUCCESS != result) {
163 DLOG(ERROR) << "vkEndCommandBuffer() failed: " << result;
164 }
159 }; 165 };
160 166
161 ScopedMultiUseCommandBufferRecorder::ScopedMultiUseCommandBufferRecorder( 167 ScopedMultiUseCommandBufferRecorder::ScopedMultiUseCommandBufferRecorder(
162 VulkanCommandBuffer& command_buffer) 168 VulkanCommandBuffer& command_buffer)
163 : CommandBufferRecorderBase(command_buffer) { 169 : CommandBufferRecorderBase(command_buffer) {
164 ValidateMultiUse(command_buffer); 170 ValidateMultiUse(command_buffer);
165 VkCommandBufferBeginInfo begin_info = {}; 171 VkCommandBufferBeginInfo begin_info = {};
166 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; 172 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
167 vkBeginCommandBuffer(handle_, &begin_info); 173 VkResult result = vkBeginCommandBuffer(handle_, &begin_info);
174
175 if (VK_SUCCESS != result) {
176 DLOG(ERROR) << "vkBeginCommandBuffer() failed: " << result;
177 }
168 } 178 }
169 179
170 ScopedSingleUseCommandBufferRecorder::ScopedSingleUseCommandBufferRecorder( 180 ScopedSingleUseCommandBufferRecorder::ScopedSingleUseCommandBufferRecorder(
171 VulkanCommandBuffer& command_buffer) 181 VulkanCommandBuffer& command_buffer)
172 : CommandBufferRecorderBase(command_buffer) { 182 : CommandBufferRecorderBase(command_buffer) {
173 ValidateSingleUse(command_buffer); 183 ValidateSingleUse(command_buffer);
174 VkCommandBufferBeginInfo begin_info = {}; 184 VkCommandBufferBeginInfo begin_info = {};
175 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; 185 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
176 begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; 186 begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
177 vkBeginCommandBuffer(handle_, &begin_info); 187 VkResult result = vkBeginCommandBuffer(handle_, &begin_info);
188
189 if (VK_SUCCESS != result) {
190 DLOG(ERROR) << "vkBeginCommandBuffer() failed: " << result;
191 }
178 } 192 }
179 193
180 } // namespace gpu 194 } // namespace gpu
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698