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)
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
delete commands;
commands->clear();
state = INITIAL;
}
VkResult CommandBuffer::begin(VkCommandBufferUsageFlags flags, const VkCommandBufferInheritanceInfo* pInheritanceInfo)
{
ASSERT((state != RECORDING) && (state != PENDING));
if((flags != VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) || pInheritanceInfo)
{
UNIMPLEMENTED();
}
if(!((flags == 0) || (flags == VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) || pInheritanceInfo)
{
UNIMPLEMENTED();
}
if(state != INITIAL)
{
// Implicit reset
resetState();
}
state = RECORDING;
return VK_SUCCESS;
......@@ -211,9 +219,7 @@ VkResult CommandBuffer::reset(VkCommandPoolResetFlags flags)
{
ASSERT(state != PENDING);
deleteCommands();
state = INITIAL;
resetState();
return VK_SUCCESS;
}
......@@ -223,9 +229,9 @@ void CommandBuffer::beginRenderPass(VkRenderPass renderPass, VkFramebuffer frame
{
ASSERT(state == RECORDING);
if(contents != VK_SUBPASS_CONTENTS_INLINE)
{
UNIMPLEMENTED();
if(contents != VK_SUBPASS_CONTENTS_INLINE)
{
UNIMPLEMENTED();
}
commands->push_back(std::make_unique<BeginRenderPass>(renderPass, framebuffer, renderArea, clearValueCount, clearValues));
......@@ -510,9 +516,9 @@ void CommandBuffer::waitEvents(uint32_t eventCount, const VkEvent* pEvents, VkPi
void CommandBuffer::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
{
if(instanceCount > 1 || firstVertex != 0 || firstInstance != 0)
{
UNIMPLEMENTED();
if(instanceCount > 1 || firstVertex != 0 || firstInstance != 0)
{
UNIMPLEMENTED();
}
commands->push_back(std::make_unique<Draw>(vertexCount));
......
......@@ -113,7 +113,7 @@ public:
class Command;
private:
void deleteCommands();
void resetState();
enum State { INITIAL, RECORDING, EXECUTABLE, PENDING, INVALID };
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