OLD | NEW |
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 Loading... |
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 |
OLD | NEW |