Commit d2791c20 by Alexis Hetu Committed by Alexis Hétu

Fixed command buffer reset and added implicit reset

A call to vkBeginCommandBuffer implicitly resets the command buffer. Bug b/118619338 Change-Id: I020a2d15915cbb309dbcd012b2dbbf34ca2f63c6 Reviewed-on: https://swiftshader-review.googlesource.com/c/23148Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com>
parent a233ceae
...@@ -175,24 +175,32 @@ CommandBuffer::CommandBuffer(VkCommandBufferLevel pLevel) : level(pLevel) ...@@ -175,24 +175,32 @@ CommandBuffer::CommandBuffer(VkCommandBufferLevel pLevel) : level(pLevel)
void CommandBuffer::destroy(const VkAllocationCallbacks* pAllocator) void CommandBuffer::destroy(const VkAllocationCallbacks* pAllocator)
{ {
deleteCommands(); delete commands;
} }
void CommandBuffer::deleteCommands() void CommandBuffer::resetState()
{ {
// FIXME (b/119409619): replace this vector by an allocator so we can control all memory allocations // FIXME (b/119409619): replace this vector by an allocator so we can control all memory allocations
delete commands; commands->clear();
state = INITIAL;
} }
VkResult CommandBuffer::begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo* pInheritanceInfo) VkResult CommandBuffer::begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo* pInheritanceInfo)
{ {
ASSERT((state != RECORDING) && (state != PENDING)); ASSERT((state != RECORDING) && (state != PENDING));
if((flags != VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) || pInheritanceInfo) if(!((flags == 0) || (flags == VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) || pInheritanceInfo)
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
if(state != INITIAL)
{
// Implicit reset
resetState();
}
state = RECORDING; state = RECORDING;
return VK_SUCCESS; return VK_SUCCESS;
...@@ -211,9 +219,7 @@ VkResult CommandBuffer::reset(VkCommandPoolResetFlags flags) ...@@ -211,9 +219,7 @@ VkResult CommandBuffer::reset(VkCommandPoolResetFlags flags)
{ {
ASSERT(state != PENDING); ASSERT(state != PENDING);
deleteCommands(); resetState();
state = INITIAL;
return VK_SUCCESS; return VK_SUCCESS;
} }
......
...@@ -113,7 +113,7 @@ public: ...@@ -113,7 +113,7 @@ public:
class Command; class Command;
private: private:
void deleteCommands(); void resetState();
enum State { INITIAL, RECORDING, EXECUTABLE, PENDING, INVALID }; enum State { INITIAL, RECORDING, EXECUTABLE, PENDING, INVALID };
State state = INITIAL; State state = INITIAL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment