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

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: 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 record_type_ = RECORD_TYPE_DIRTY; 137 record_type_ = RECORD_TYPE_DIRTY;
138 } else if (record_type_ == RECORD_TYPE_MULTI_USE) { 138 } else if (record_type_ == RECORD_TYPE_MULTI_USE) {
139 // Can no longer record new items unless marked as clear. 139 // Can no longer record new items unless marked as clear.
140 record_type_ = RECORD_TYPE_RECORDED; 140 record_type_ = RECORD_TYPE_RECORDED;
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 VkResult result = VK_SUCCESS;
piman 2016/05/12 23:20:43 nit: move declaration to initialization (l. 153)
ssami 2016/05/13 08:45:46 Done.
147 // Block if command buffer is still in use. This can be externally avoided 148 // Block if command buffer is still in use. This can be externally avoided
148 // using the asynchronous SubmissionFinished() function. 149 // using the asynchronous SubmissionFinished() function.
149 VkDevice device = device_queue_->GetVulkanDevice(); 150 VkDevice device = device_queue_->GetVulkanDevice();
150 vkWaitForFences(device, 1, &submission_fence_, true, UINT64_MAX); 151 vkWaitForFences(device, 1, &submission_fence_, true, UINT64_MAX);
151 152
152 vkResetCommandBuffer(command_buffer_, 0); 153 result = vkResetCommandBuffer(command_buffer_, 0);
piman 2016/05/12 23:20:43 nit: VkResult result = vkResetCommandBuffer(comman
ssami 2016/05/13 08:45:46 Done.
153 record_type_ = RECORD_TYPE_EMPTY; 154 if (VK_SUCCESS != result) {
155 DLOG(ERROR) << "vkResetCommandBuffer() failed: " << result;
156 } else {
157 record_type_ = RECORD_TYPE_EMPTY;
158 }
154 } 159 }
155 } 160 }
156 161
157 CommandBufferRecorderBase::~CommandBufferRecorderBase() { 162 CommandBufferRecorderBase::~CommandBufferRecorderBase() {
158 vkEndCommandBuffer(handle_); 163 VkResult result = VK_SUCCESS;
164 result = vkEndCommandBuffer(handle_);
piman 2016/05/12 23:20:43 nit: VkResult result = vkEndCommandBuffer(handle_)
ssami 2016/05/13 08:45:46 Done.
165
166 if (VK_SUCCESS != result) {
167 DLOG(ERROR) << "vkEndCommandBuffer() failed: " << result;
168 }
159 }; 169 };
160 170
161 ScopedMultiUseCommandBufferRecorder::ScopedMultiUseCommandBufferRecorder( 171 ScopedMultiUseCommandBufferRecorder::ScopedMultiUseCommandBufferRecorder(
162 VulkanCommandBuffer& command_buffer) 172 VulkanCommandBuffer& command_buffer)
163 : CommandBufferRecorderBase(command_buffer) { 173 : CommandBufferRecorderBase(command_buffer) {
174 VkResult result = VK_SUCCESS;
164 ValidateMultiUse(command_buffer); 175 ValidateMultiUse(command_buffer);
165 VkCommandBufferBeginInfo begin_info = {}; 176 VkCommandBufferBeginInfo begin_info = {};
166 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; 177 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
167 vkBeginCommandBuffer(handle_, &begin_info); 178 result = vkBeginCommandBuffer(handle_, &begin_info);
piman 2016/05/12 23:20:43 nit: VkResult result = vkBeginCommandBuffer(handle
ssami 2016/05/13 08:45:46 Done.
179
180 if (VK_SUCCESS != result) {
181 DLOG(ERROR) << "vkBeginCommandBuffer() failed: " << result;
182 }
168 } 183 }
169 184
170 ScopedSingleUseCommandBufferRecorder::ScopedSingleUseCommandBufferRecorder( 185 ScopedSingleUseCommandBufferRecorder::ScopedSingleUseCommandBufferRecorder(
171 VulkanCommandBuffer& command_buffer) 186 VulkanCommandBuffer& command_buffer)
172 : CommandBufferRecorderBase(command_buffer) { 187 : CommandBufferRecorderBase(command_buffer) {
188 VkResult result = VK_SUCCESS;
173 ValidateSingleUse(command_buffer); 189 ValidateSingleUse(command_buffer);
174 VkCommandBufferBeginInfo begin_info = {}; 190 VkCommandBufferBeginInfo begin_info = {};
175 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; 191 begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
176 begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; 192 begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
177 vkBeginCommandBuffer(handle_, &begin_info); 193 result = vkBeginCommandBuffer(handle_, &begin_info);
piman 2016/05/12 23:20:43 nit: VkResult result = vkBeginCommandBuffer(handle
ssami 2016/05/13 08:45:46 Done.
194
195 if (VK_SUCCESS != result) {
196 DLOG(ERROR) << "vkBeginCommandBuffer() failed: " << result;
197 }
178 } 198 }
179 199
180 } // namespace gpu 200 } // 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