Commit 896e7811 by Jamie Madill Committed by Commit Bot

Revert "Vulkan:Optimize SecondaryCommandBuffers"

This reverts commit 2219b18c. Reason for revert: Failing to compile on ASAN builders: https://ci.chromium.org/p/chromium/builders/try/linux-libfuzzer-asan-rel/134782 Currently blocking roll. Original change's description: > Vulkan:Optimize SecondaryCommandBuffers > > Optimize performance of SecondaryCommandBuffers and enable them as the > default build option. > To disable this set angle_enable_custom_vulkan_cmd_buffers=false in > your build args. > > This CL enhances the PoolAllocator to have a "fast" mode that can > be enabled at class creation. This mode uses an alignment of 1 byte and > enables a fastAllocation() call that avoids some bookkeeping overhead. > The SecondaryCommandBuffer uses this fastAllocation() function. > Furthermore the fast path of fast allocate, using the current page, > is inlined for maximum speed. > Jamie Madill also updated the SecondaryCommandBuffers to pre-allocate > blocks so that the commands occur linearly in memory. This speeds up > processing with improved cache coherency and minimizes overhead when > recording commands. > Also the core Draw functions and their state updates are all inlined > as well as the common functions to initialize commands and to copy > command pointer data. > > This change also includes some new, custom commands. One is > imageBarrier that is a specialized version of pipelineBarrier that only > performs a single image layout transition. > There are customized versions of various Draw commands to minimize > copying of parameters. > There are also specialized commands to bind[Graphics|Compute]Pipeline > that have the pipeline type built in to the command. > More custom commands and command data size optimizations will be made > in follow-on commits. > > Bug: angleproject:3136 > Change-Id: I35453cc2656bc8c51f0d84d1adef106900aca9a5 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1497418 > Commit-Queue: Tobin Ehlis <tobine@google.com> > Reviewed-by: Jamie Madill <jmadill@chromium.org> TBR=tobine@google.com,syoussefi@chromium.org,jmadill@chromium.org Change-Id: I1c0bfe864ff343eb8ea6c88556523f8715c981d5 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: angleproject:3136 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1535998Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 9e586a0f
...@@ -86,7 +86,7 @@ declare_args() { ...@@ -86,7 +86,7 @@ declare_args() {
angle_vulkan_conformant_configs_only = is_official_build angle_vulkan_conformant_configs_only = is_official_build
# Enable custom (cpu-side) secondary command buffers # Enable custom (cpu-side) secondary command buffers
angle_enable_custom_vulkan_cmd_buffers = true angle_enable_custom_vulkan_cmd_buffers = false
} }
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/mathutil.h"
#include "common/platform.h" #include "common/platform.h"
#include "common/tls.h" #include "common/tls.h"
...@@ -37,14 +36,6 @@ PoolAllocator::PoolAllocator(int growthIncrement, int allocationAlignment) ...@@ -37,14 +36,6 @@ PoolAllocator::PoolAllocator(int growthIncrement, int allocationAlignment)
#endif #endif
mLocked(false) mLocked(false)
{ {
if (mAlignment == 1)
{
// This is a special fast-path where fastAllocation() is enabled
mAlignmentMask = 0;
mHeaderSkip = sizeof(Header);
}
else
{
// //
// Adjust mAlignment to be at least pointer aligned and // Adjust mAlignment to be at least pointer aligned and
// power of 2. // power of 2.
...@@ -53,32 +44,35 @@ PoolAllocator::PoolAllocator(int growthIncrement, int allocationAlignment) ...@@ -53,32 +44,35 @@ PoolAllocator::PoolAllocator(int growthIncrement, int allocationAlignment)
mAlignment &= ~(minAlign - 1); mAlignment &= ~(minAlign - 1);
if (mAlignment < minAlign) if (mAlignment < minAlign)
mAlignment = minAlign; mAlignment = minAlign;
mAlignment = gl::ceilPow2(mAlignment); size_t a = 1;
mAlignmentMask = mAlignment - 1; while (a < mAlignment)
a <<= 1;
mAlignment = a;
mAlignmentMask = a - 1;
#if !defined(ANGLE_DISABLE_POOL_ALLOC) #if !defined(ANGLE_DISABLE_POOL_ALLOC)
// //
// Align header skip
//
mHeaderSkip = minAlign;
if (mHeaderSkip < sizeof(Header))
{
mHeaderSkip = rx::roundUp(sizeof(Header), mAlignment);
}
}
//
// Don't allow page sizes we know are smaller than all common // Don't allow page sizes we know are smaller than all common
// OS page sizes. // OS page sizes.
// //
if (mPageSize < 4 * 1024) if (mPageSize < 4 * 1024)
mPageSize = 4 * 1024; mPageSize = 4 * 1024;
// //
// A large mCurrentPageOffset indicates a new page needs to // A large mCurrentPageOffset indicates a new page needs to
// be obtained to allocate memory. // be obtained to allocate memory.
// //
mCurrentPageOffset = mPageSize; mCurrentPageOffset = mPageSize;
#else // !defined(ANGLE_DISABLE_POOL_ALLOC)
//
// Align header skip
//
mHeaderSkip = minAlign;
if (mHeaderSkip < sizeof(Header))
{
mHeaderSkip = (sizeof(Header) + mAlignmentMask) & ~mAlignmentMask;
} }
#else // !defined(ANGLE_DISABLE_POOL_ALLOC)
mStack.push_back({}); mStack.push_back({});
#endif #endif
} }
...@@ -268,21 +262,7 @@ void *PoolAllocator::allocate(size_t numBytes) ...@@ -268,21 +262,7 @@ void *PoolAllocator::allocate(size_t numBytes)
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(memory) + mHeaderSkip); reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(memory) + mHeaderSkip);
return std::align(mAlignment, numBytes, unalignedPtr, allocationSize); return std::align(mAlignment, numBytes, unalignedPtr, allocationSize);
} }
unsigned char *newPageAddr =
static_cast<unsigned char *>(allocateNewPage(numBytes, allocationSize));
return initializeAllocation(mInUseList, newPageAddr, numBytes);
#else // !defined(ANGLE_DISABLE_POOL_ALLOC)
void *alloc = malloc(numBytes + mAlignmentMask);
mStack.back().push_back(alloc);
intptr_t intAlloc = reinterpret_cast<intptr_t>(alloc);
intAlloc = rx::roundUp(intAlloc, mAlignment);
return reinterpret_cast<void *>(intAlloc);
#endif
}
void *PoolAllocator::allocateNewPage(size_t numBytes, size_t allocationSize)
{
// //
// Need a simple page to allocate from. // Need a simple page to allocate from.
// //
...@@ -298,13 +278,22 @@ void *PoolAllocator::allocateNewPage(size_t numBytes, size_t allocationSize) ...@@ -298,13 +278,22 @@ void *PoolAllocator::allocateNewPage(size_t numBytes, size_t allocationSize)
if (memory == 0) if (memory == 0)
return 0; return 0;
} }
// Use placement-new to initialize header // Use placement-new to initialize header
new (memory) Header(mInUseList, 1); new (memory) Header(mInUseList, 1);
mInUseList = memory; mInUseList = memory;
unsigned char *ret = reinterpret_cast<unsigned char *>(mInUseList) + mHeaderSkip; unsigned char *ret = reinterpret_cast<unsigned char *>(mInUseList) + mHeaderSkip;
mCurrentPageOffset = (mHeaderSkip + allocationSize + mAlignmentMask) & ~mAlignmentMask; mCurrentPageOffset = (mHeaderSkip + allocationSize + mAlignmentMask) & ~mAlignmentMask;
return ret; return initializeAllocation(mInUseList, ret, numBytes);
#else // !defined(ANGLE_DISABLE_POOL_ALLOC)
void *alloc = malloc(numBytes + mAlignmentMask);
mStack.back().push_back(alloc);
intptr_t intAlloc = reinterpret_cast<intptr_t>(alloc);
intAlloc = (intAlloc + mAlignmentMask) & ~mAlignmentMask;
return reinterpret_cast<void *>(intAlloc);
#endif
} }
void PoolAllocator::lock() void PoolAllocator::lock()
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <vector> #include <vector>
#include "angleutils.h" #include "angleutils.h"
#include "common/debug.h"
namespace angle namespace angle
{ {
...@@ -124,10 +123,6 @@ class PoolAllocator : angle::NonCopyable ...@@ -124,10 +123,6 @@ class PoolAllocator : angle::NonCopyable
{ {
public: public:
static const int kDefaultAlignment = 16; static const int kDefaultAlignment = 16;
//
// Create PoolAllocator. If alignment is be set to 1 byte then fastAllocate()
// function can be used to make allocations with less overhead.
//
PoolAllocator(int growthIncrement = 8 * 1024, int allocationAlignment = kDefaultAlignment); PoolAllocator(int growthIncrement = 8 * 1024, int allocationAlignment = kDefaultAlignment);
// //
...@@ -159,32 +154,6 @@ class PoolAllocator : angle::NonCopyable ...@@ -159,32 +154,6 @@ class PoolAllocator : angle::NonCopyable
void *allocate(size_t numBytes); void *allocate(size_t numBytes);
// //
// Call fastAllocate() for a faster allocate function that does minimal bookkeeping
// preCondition: Allocator must have been created w/ alignment of 1
ANGLE_INLINE uint8_t *fastAllocate(size_t numBytes)
{
#if defined(ANGLE_DISABLE_POOL_ALLOC)
return allocate(numBytes);
#endif
ASSERT(mAlignment == 1);
// No multi-page allocations
ASSERT(numBytes <= (mPageSize - mHeaderSkip));
//
// Do the allocation, most likely case inline first, for efficiency.
//
if (numBytes <= mPageSize - mCurrentPageOffset)
{
//
// Safe to allocate from mCurrentPageOffset.
//
uint8_t *memory = reinterpret_cast<uint8_t *>(mInUseList) + mCurrentPageOffset;
mCurrentPageOffset += numBytes;
return memory;
}
return reinterpret_cast<uint8_t *>(allocateNewPage(numBytes, numBytes));
}
//
// There is no deallocate. The point of this class is that // There is no deallocate. The point of this class is that
// deallocation can be skipped by the user of it, as the model // deallocation can be skipped by the user of it, as the model
// of use is to simultaneously deallocate everything at once // of use is to simultaneously deallocate everything at once
...@@ -236,8 +205,6 @@ class PoolAllocator : angle::NonCopyable ...@@ -236,8 +205,6 @@ class PoolAllocator : angle::NonCopyable
}; };
using AllocStack = std::vector<AllocState>; using AllocStack = std::vector<AllocState>;
// Slow path of allocation when we have to get a new page.
void *allocateNewPage(size_t numBytes, size_t allocationSize);
// Track allocations if and only if we're using guard blocks // Track allocations if and only if we're using guard blocks
void *initializeAllocation(Header *block, unsigned char *memory, size_t numBytes) void *initializeAllocation(Header *block, unsigned char *memory, size_t numBytes)
{ {
......
...@@ -139,9 +139,10 @@ void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT ...@@ -139,9 +139,10 @@ void MakeDebugUtilsLabel(GLenum source, const char *marker, VkDebugUtilsLabelEXT
} }
#if ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS #if ANGLE_USE_CUSTOM_VULKAN_CMD_BUFFERS
constexpr VkSubpassContents kRenderPassContents = VK_SUBPASS_CONTENTS_INLINE; static constexpr VkSubpassContents kRenderPassContents = VK_SUBPASS_CONTENTS_INLINE;
#else #else
constexpr VkSubpassContents kRenderPassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS; static constexpr VkSubpassContents kRenderPassContents =
VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
#endif #endif
// Helpers to unify executeCommands call based on underlying cmd buffer type // Helpers to unify executeCommands call based on underlying cmd buffer type
...@@ -302,6 +303,7 @@ CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function, ...@@ -302,6 +303,7 @@ CommandGraphNode::CommandGraphNode(CommandGraphNodeFunction function,
CommandGraphNode::~CommandGraphNode() CommandGraphNode::~CommandGraphNode()
{ {
mRenderPassFramebuffer.setHandle(VK_NULL_HANDLE); mRenderPassFramebuffer.setHandle(VK_NULL_HANDLE);
// Command buffers are managed by the command pool, so don't need to be freed. // Command buffers are managed by the command pool, so don't need to be freed.
mOutsideRenderPassCommands.releaseHandle(); mOutsideRenderPassCommands.releaseHandle();
mInsideRenderPassCommands.releaseHandle(); mInsideRenderPassCommands.releaseHandle();
...@@ -501,6 +503,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context, ...@@ -501,6 +503,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
RenderPass *renderPass = nullptr; RenderPass *renderPass = nullptr;
ANGLE_TRY(renderPassCache->getCompatibleRenderPass(context, serial, mRenderPassDesc, ANGLE_TRY(renderPassCache->getCompatibleRenderPass(context, serial, mRenderPassDesc,
&renderPass)); &renderPass));
ANGLE_VK_TRY(context, mInsideRenderPassCommands.end()); ANGLE_VK_TRY(context, mInsideRenderPassCommands.end());
VkRenderPassBeginInfo beginInfo = {}; VkRenderPassBeginInfo beginInfo = {};
...@@ -631,10 +634,7 @@ CommandGraph::CommandGraph(bool enableGraphDiagnostics, angle::PoolAllocator *po ...@@ -631,10 +634,7 @@ CommandGraph::CommandGraph(bool enableGraphDiagnostics, angle::PoolAllocator *po
: mEnableGraphDiagnostics(enableGraphDiagnostics), : mEnableGraphDiagnostics(enableGraphDiagnostics),
mPoolAllocator(poolAllocator), mPoolAllocator(poolAllocator),
mLastBarrierIndex(kInvalidNodeIndex) mLastBarrierIndex(kInvalidNodeIndex)
{ {}
// Push so that allocations made from here will be recycled in clear() below.
mPoolAllocator->push();
}
CommandGraph::~CommandGraph() CommandGraph::~CommandGraph()
{ {
...@@ -776,12 +776,6 @@ bool CommandGraph::empty() const ...@@ -776,12 +776,6 @@ bool CommandGraph::empty() const
void CommandGraph::clear() void CommandGraph::clear()
{ {
mLastBarrierIndex = kInvalidNodeIndex; mLastBarrierIndex = kInvalidNodeIndex;
// Release cmd graph pool memory now that cmds are submitted
// NOTE: This frees all memory since last push. Right now only the CommandGraph
// will push the allocator (at creation and below). If other people start
// pushing the allocator this (and/or the allocator) will need to be updated.
mPoolAllocator->pop();
mPoolAllocator->push();
// TODO(jmadill): Use pool allocator for performance. http://anglebug.com/2951 // TODO(jmadill): Use pool allocator for performance. http://anglebug.com/2951
for (CommandGraphNode *node : mNodes) for (CommandGraphNode *node : mNodes)
......
...@@ -24,7 +24,6 @@ namespace rx ...@@ -24,7 +24,6 @@ namespace rx
namespace vk namespace vk
{ {
enum class VisitedState enum class VisitedState
{ {
Unvisited, Unvisited,
...@@ -120,11 +119,9 @@ class CommandGraphNode final : angle::NonCopyable ...@@ -120,11 +119,9 @@ class CommandGraphNode final : angle::NonCopyable
static void SetHappensBeforeDependencies(CommandGraphNode **beforeNodes, static void SetHappensBeforeDependencies(CommandGraphNode **beforeNodes,
size_t beforeNodesCount, size_t beforeNodesCount,
CommandGraphNode *afterNode); CommandGraphNode *afterNode);
static void SetHappensBeforeDependencies(CommandGraphNode *beforeNode, static void SetHappensBeforeDependencies(CommandGraphNode *beforeNode,
CommandGraphNode **afterNodes, CommandGraphNode **afterNodes,
size_t afterNodesCount); size_t afterNodesCount);
bool hasParents() const; bool hasParents() const;
bool hasChildren() const { return mHasChildren; } bool hasChildren() const { return mHasChildren; }
......
...@@ -369,7 +369,9 @@ angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context, ...@@ -369,7 +369,9 @@ angle::Result ContextVk::handleDirtyPipeline(const gl::Context *context,
mGraphicsPipelineTransition.reset(); mGraphicsPipelineTransition.reset();
} }
commandBuffer->bindGraphicsPipeline(mCurrentPipeline->getPipeline());
commandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, mCurrentPipeline->getPipeline());
// Update the queue serial for the pipeline object. // Update the queue serial for the pipeline object.
ASSERT(mCurrentPipeline && mCurrentPipeline->valid()); ASSERT(mCurrentPipeline && mCurrentPipeline->valid());
mCurrentPipeline->updateSerial(mRenderer->getCurrentQueueSerial()); mCurrentPipeline->updateSerial(mRenderer->getCurrentQueueSerial());
...@@ -460,7 +462,7 @@ angle::Result ContextVk::drawArrays(const gl::Context *context, ...@@ -460,7 +462,7 @@ angle::Result ContextVk::drawArrays(const gl::Context *context,
{ {
ANGLE_TRY(setupDraw(context, mode, first, count, 1, gl::DrawElementsType::InvalidEnum, ANGLE_TRY(setupDraw(context, mode, first, count, 1, gl::DrawElementsType::InvalidEnum,
nullptr, mNonIndexedDirtyBitsMask, &commandBuffer)); nullptr, mNonIndexedDirtyBitsMask, &commandBuffer));
commandBuffer->draw(clampedVertexCount, first); commandBuffer->draw(clampedVertexCount, 1, first, 0);
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -482,7 +484,7 @@ angle::Result ContextVk::drawArraysInstanced(const gl::Context *context, ...@@ -482,7 +484,7 @@ angle::Result ContextVk::drawArraysInstanced(const gl::Context *context,
CommandBufferT *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(setupDraw(context, mode, first, count, instances, gl::DrawElementsType::InvalidEnum, ANGLE_TRY(setupDraw(context, mode, first, count, instances, gl::DrawElementsType::InvalidEnum,
nullptr, mNonIndexedDirtyBitsMask, &commandBuffer)); nullptr, mNonIndexedDirtyBitsMask, &commandBuffer));
commandBuffer->drawInstanced(gl::GetClampedVertexCount<uint32_t>(count), instances, first); commandBuffer->draw(gl::GetClampedVertexCount<uint32_t>(count), instances, first, 0);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -501,7 +503,7 @@ angle::Result ContextVk::drawElements(const gl::Context *context, ...@@ -501,7 +503,7 @@ angle::Result ContextVk::drawElements(const gl::Context *context,
else else
{ {
ANGLE_TRY(setupIndexedDraw(context, mode, count, 1, type, indices, &commandBuffer)); ANGLE_TRY(setupIndexedDraw(context, mode, count, 1, type, indices, &commandBuffer));
commandBuffer->drawIndexed(count); commandBuffer->drawIndexed(count, 1, 0, 0, 0);
} }
return angle::Result::Continue; return angle::Result::Continue;
...@@ -523,7 +525,7 @@ angle::Result ContextVk::drawElementsInstanced(const gl::Context *context, ...@@ -523,7 +525,7 @@ angle::Result ContextVk::drawElementsInstanced(const gl::Context *context,
CommandBufferT *commandBuffer = nullptr; CommandBufferT *commandBuffer = nullptr;
ANGLE_TRY(setupIndexedDraw(context, mode, count, instances, type, indices, &commandBuffer)); ANGLE_TRY(setupIndexedDraw(context, mode, count, instances, type, indices, &commandBuffer));
commandBuffer->drawIndexedInstanced(count, instances); commandBuffer->drawIndexed(count, instances, 0, 0, 0);
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -424,7 +424,7 @@ angle::Result FramebufferVk::blitWithCopy(ContextVk *contextVk, ...@@ -424,7 +424,7 @@ angle::Result FramebufferVk::blitWithCopy(ContextVk *contextVk,
VkImageAspectFlags aspectMask = VkImageAspectFlags aspectMask =
vk::GetDepthStencilAspectFlagsForCopy(blitDepthBuffer, blitStencilBuffer); vk::GetDepthStencilAspectFlagsForCopy(blitDepthBuffer, blitStencilBuffer);
CommandBufferT *commandBuffer = nullptr; CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(&mFramebuffer); vk::ImageHelper *writeImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
...@@ -509,7 +509,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk, ...@@ -509,7 +509,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
// Reinitialize the commandBuffer after a read pixels because it calls // Reinitialize the commandBuffer after a read pixels because it calls
// renderer->finish which makes command buffers obsolete. // renderer->finish which makes command buffers obsolete.
CommandBufferT *commandBuffer = nullptr; CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
// We read the bytes of the image in a buffer, now we have to copy them into the // We read the bytes of the image in a buffer, now we have to copy them into the
...@@ -669,7 +669,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk, ...@@ -669,7 +669,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer); vk::ImageHelper *dstImage = drawRenderTarget->getImageForWrite(&mFramebuffer);
CommandBufferT *commandBuffer = nullptr; CommandBufferT *commandBuffer;
ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mFramebuffer.recordCommands(contextVk, &commandBuffer));
const vk::Format &readImageFormat = readRenderTarget->getImageFormat(); const vk::Format &readImageFormat = readRenderTarget->getImageFormat();
......
...@@ -506,7 +506,7 @@ RendererVk::RendererVk() ...@@ -506,7 +506,7 @@ RendererVk::RendererVk()
mCurrentQueueSerial(mQueueSerialFactory.generate()), mCurrentQueueSerial(mQueueSerialFactory.generate()),
mDeviceLost(false), mDeviceLost(false),
mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod), mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod),
mPoolAllocator(kDefaultPoolAllocatorPageSize, 1), mPoolAllocator(kDefaultPoolAllocatorPageSize),
mCommandGraph(kEnableCommandGraphDiagnostics, &mPoolAllocator), mCommandGraph(kEnableCommandGraphDiagnostics, &mPoolAllocator),
mGpuEventsEnabled(false), mGpuEventsEnabled(false),
mGpuClockSync{std::numeric_limits<double>::max(), std::numeric_limits<double>::max()}, mGpuClockSync{std::numeric_limits<double>::max(), std::numeric_limits<double>::max()},
......
...@@ -14,6 +14,102 @@ namespace rx ...@@ -14,6 +14,102 @@ namespace rx
{ {
namespace vk namespace vk
{ {
// Allocate/initialize memory for the command and return pointer to Cmd Header
template <class StructType>
StructType *SecondaryCommandBuffer::initCommand(CommandID cmdID, size_t variableSize)
{
size_t paramSize = sizeof(StructType);
size_t completeSize = sizeof(CommandHeader) + paramSize + variableSize;
CommandHeader *header = static_cast<CommandHeader *>(mAllocator->allocate(completeSize));
// Update cmd ID in header
header->id = cmdID;
header->next = nullptr;
// Update mHead ptr
mHead = (mHead == nullptr) ? header : mHead;
// Update prev cmd's "next" ptr and mLast ptr
if (mLast)
{
mLast->next = header;
}
// Update mLast ptr
mLast = header;
uint8_t *fixedParamPtr = reinterpret_cast<uint8_t *>(header) + sizeof(CommandHeader);
mPtrCmdData = fixedParamPtr + sizeof(StructType);
return reinterpret_cast<StructType *>(fixedParamPtr);
}
template <class PtrType>
void SecondaryCommandBuffer::storePointerParameter(const PtrType *paramData,
const PtrType **writePtr,
size_t sizeInBytes)
{
*writePtr = reinterpret_cast<const PtrType *>(mPtrCmdData);
memcpy(mPtrCmdData, paramData, sizeInBytes);
mPtrCmdData += sizeInBytes;
}
void SecondaryCommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoint,
const PipelineLayout &layout,
uint32_t firstSet,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets,
uint32_t dynamicOffsetCount,
const uint32_t *dynamicOffsets)
{
size_t descSize = descriptorSetCount * sizeof(VkDescriptorSet);
size_t offsetSize = dynamicOffsetCount * sizeof(uint32_t);
size_t varSize = descSize + offsetSize;
BindDescriptorSetParams *paramStruct =
initCommand<BindDescriptorSetParams>(CommandID::BindDescriptorSets, varSize);
// Copy params into memory
paramStruct->bindPoint = bindPoint;
paramStruct->layout = layout.getHandle();
paramStruct->firstSet = firstSet;
paramStruct->descriptorSetCount = descriptorSetCount;
paramStruct->dynamicOffsetCount = dynamicOffsetCount;
// Copy variable sized data
storePointerParameter(descriptorSets, &paramStruct->descriptorSets, descSize);
storePointerParameter(dynamicOffsets, &paramStruct->dynamicOffsets, offsetSize);
}
void SecondaryCommandBuffer::bindIndexBuffer(const Buffer &buffer,
VkDeviceSize offset,
VkIndexType indexType)
{
BindIndexBufferParams *paramStruct =
initCommand<BindIndexBufferParams>(CommandID::BindIndexBuffer, 0);
paramStruct->buffer = buffer.getHandle();
paramStruct->offset = offset;
paramStruct->indexType = indexType;
}
void SecondaryCommandBuffer::bindPipeline(VkPipelineBindPoint pipelineBindPoint,
const Pipeline &pipeline)
{
BindPipelineParams *paramStruct = initCommand<BindPipelineParams>(CommandID::BindPipeline, 0);
paramStruct->pipelineBindPoint = pipelineBindPoint;
paramStruct->pipeline = pipeline.getHandle();
}
void SecondaryCommandBuffer::bindVertexBuffers(uint32_t firstBinding,
uint32_t bindingCount,
const VkBuffer *buffers,
const VkDeviceSize *offsets)
{
size_t buffSize = bindingCount * sizeof(VkBuffer);
size_t offsetSize = bindingCount * sizeof(VkDeviceSize);
BindVertexBuffersParams *paramStruct =
initCommand<BindVertexBuffersParams>(CommandID::BindVertexBuffers, buffSize + offsetSize);
// Copy params
paramStruct->firstBinding = firstBinding;
paramStruct->bindingCount = bindingCount;
// Copy variable sized data
storePointerParameter(buffers, &paramStruct->buffers, buffSize);
storePointerParameter(offsets, &paramStruct->offsets, offsetSize);
}
void SecondaryCommandBuffer::blitImage(const Image &srcImage, void SecondaryCommandBuffer::blitImage(const Image &srcImage,
VkImageLayout srcImageLayout, VkImageLayout srcImageLayout,
const Image &dstImage, const Image &dstImage,
...@@ -209,11 +305,37 @@ void SecondaryCommandBuffer::setScissor(uint32_t firstScissor, ...@@ -209,11 +305,37 @@ void SecondaryCommandBuffer::setScissor(uint32_t firstScissor,
storePointerParameter(scissors, &paramStruct->scissors, scissorSize); storePointerParameter(scissors, &paramStruct->scissors, scissorSize);
} }
void SecondaryCommandBuffer::draw(uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex,
uint32_t firstInstance)
{
DrawParams *paramStruct = initCommand<DrawParams>(CommandID::Draw, 0);
paramStruct->vertexCount = vertexCount;
paramStruct->instanceCount = instanceCount;
paramStruct->firstVertex = firstVertex;
paramStruct->firstInstance = firstInstance;
}
void SecondaryCommandBuffer::drawIndexed(uint32_t indexCount,
uint32_t instanceCount,
uint32_t firstIndex,
int32_t vertexOffset,
uint32_t firstInstance)
{
DrawIndexedParams *paramStruct = initCommand<DrawIndexedParams>(CommandID::DrawIndexed, 0);
paramStruct->indexCount = indexCount;
paramStruct->instanceCount = instanceCount;
paramStruct->firstIndex = firstIndex;
paramStruct->vertexOffset = vertexOffset;
paramStruct->firstInstance = firstInstance;
}
void SecondaryCommandBuffer::dispatch(uint32_t groupCountX, void SecondaryCommandBuffer::dispatch(uint32_t groupCountX,
uint32_t groupCountY, uint32_t groupCountY,
uint32_t groupCountZ) uint32_t groupCountZ)
{ {
DispatchParams *paramStruct = initCommand<DispatchParams>(CommandID::Dispatch); DispatchParams *paramStruct = initCommand<DispatchParams>(CommandID::Dispatch, 0);
paramStruct->groupCountX = groupCountX; paramStruct->groupCountX = groupCountX;
paramStruct->groupCountY = groupCountY; paramStruct->groupCountY = groupCountY;
paramStruct->groupCountZ = groupCountZ; paramStruct->groupCountZ = groupCountZ;
...@@ -233,10 +355,9 @@ void SecondaryCommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMask, ...@@ -233,10 +355,9 @@ void SecondaryCommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMask,
size_t buffBarrierSize = bufferMemoryBarrierCount * sizeof(VkBufferMemoryBarrier); size_t buffBarrierSize = bufferMemoryBarrierCount * sizeof(VkBufferMemoryBarrier);
size_t imgBarrierSize = imageMemoryBarrierCount * sizeof(VkImageMemoryBarrier); size_t imgBarrierSize = imageMemoryBarrierCount * sizeof(VkImageMemoryBarrier);
PipelineBarrierParams *paramStruct = initCommand<PipelineBarrierParams>( PipelineBarrierParams *paramStruct = initCommand<PipelineBarrierParams>(
CommandID::PipelineBarrier, memBarrierSize + buffBarrierSize + imgBarrierSize); CommandID::PipelinBarrier, memBarrierSize + buffBarrierSize + imgBarrierSize);
paramStruct->srcStageMask = srcStageMask; paramStruct->srcStageMask = srcStageMask;
paramStruct->dstStageMask = dstStageMask; paramStruct->dstStageMask = dstStageMask;
paramStruct->dependencyFlags = dependencyFlags;
paramStruct->memoryBarrierCount = memoryBarrierCount; paramStruct->memoryBarrierCount = memoryBarrierCount;
paramStruct->bufferMemoryBarrierCount = bufferMemoryBarrierCount; paramStruct->bufferMemoryBarrierCount = bufferMemoryBarrierCount;
paramStruct->imageMemoryBarrierCount = imageMemoryBarrierCount; paramStruct->imageMemoryBarrierCount = imageMemoryBarrierCount;
...@@ -247,26 +368,16 @@ void SecondaryCommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMask, ...@@ -247,26 +368,16 @@ void SecondaryCommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMask,
storePointerParameter(imageMemoryBarriers, &paramStruct->imageMemoryBarriers, imgBarrierSize); storePointerParameter(imageMemoryBarriers, &paramStruct->imageMemoryBarriers, imgBarrierSize);
} }
void SecondaryCommandBuffer::imageBarrier(VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
VkImageMemoryBarrier *imageMemoryBarrier)
{
ImageBarrierParams *paramStruct = initCommand<ImageBarrierParams>(CommandID::ImageBarrier);
paramStruct->srcStageMask = srcStageMask;
paramStruct->dstStageMask = dstStageMask;
paramStruct->imageMemoryBarrier = *imageMemoryBarrier;
}
void SecondaryCommandBuffer::setEvent(VkEvent event, VkPipelineStageFlags stageMask) void SecondaryCommandBuffer::setEvent(VkEvent event, VkPipelineStageFlags stageMask)
{ {
SetEventParams *paramStruct = initCommand<SetEventParams>(CommandID::SetEvent); SetEventParams *paramStruct = initCommand<SetEventParams>(CommandID::SetEvent, 0);
paramStruct->event = event; paramStruct->event = event;
paramStruct->stageMask = stageMask; paramStruct->stageMask = stageMask;
} }
void SecondaryCommandBuffer::resetEvent(VkEvent event, VkPipelineStageFlags stageMask) void SecondaryCommandBuffer::resetEvent(VkEvent event, VkPipelineStageFlags stageMask)
{ {
ResetEventParams *paramStruct = initCommand<ResetEventParams>(CommandID::ResetEvent); ResetEventParams *paramStruct = initCommand<ResetEventParams>(CommandID::ResetEvent, 0);
paramStruct->event = event; paramStruct->event = event;
paramStruct->stageMask = stageMask; paramStruct->stageMask = stageMask;
} }
...@@ -307,7 +418,7 @@ void SecondaryCommandBuffer::resetQueryPool(VkQueryPool queryPool, ...@@ -307,7 +418,7 @@ void SecondaryCommandBuffer::resetQueryPool(VkQueryPool queryPool,
uint32_t queryCount) uint32_t queryCount)
{ {
ResetQueryPoolParams *paramStruct = ResetQueryPoolParams *paramStruct =
initCommand<ResetQueryPoolParams>(CommandID::ResetQueryPool); initCommand<ResetQueryPoolParams>(CommandID::ResetQueryPool, 0);
paramStruct->queryPool = queryPool; paramStruct->queryPool = queryPool;
paramStruct->firstQuery = firstQuery; paramStruct->firstQuery = firstQuery;
paramStruct->queryCount = queryCount; paramStruct->queryCount = queryCount;
...@@ -317,7 +428,7 @@ void SecondaryCommandBuffer::beginQuery(VkQueryPool queryPool, ...@@ -317,7 +428,7 @@ void SecondaryCommandBuffer::beginQuery(VkQueryPool queryPool,
uint32_t query, uint32_t query,
VkQueryControlFlags flags) VkQueryControlFlags flags)
{ {
BeginQueryParams *paramStruct = initCommand<BeginQueryParams>(CommandID::BeginQuery); BeginQueryParams *paramStruct = initCommand<BeginQueryParams>(CommandID::BeginQuery, 0);
paramStruct->queryPool = queryPool; paramStruct->queryPool = queryPool;
paramStruct->query = query; paramStruct->query = query;
paramStruct->flags = flags; paramStruct->flags = flags;
...@@ -325,7 +436,7 @@ void SecondaryCommandBuffer::beginQuery(VkQueryPool queryPool, ...@@ -325,7 +436,7 @@ void SecondaryCommandBuffer::beginQuery(VkQueryPool queryPool,
void SecondaryCommandBuffer::endQuery(VkQueryPool queryPool, uint32_t query) void SecondaryCommandBuffer::endQuery(VkQueryPool queryPool, uint32_t query)
{ {
EndQueryParams *paramStruct = initCommand<EndQueryParams>(CommandID::EndQuery); EndQueryParams *paramStruct = initCommand<EndQueryParams>(CommandID::EndQuery, 0);
paramStruct->queryPool = queryPool; paramStruct->queryPool = queryPool;
paramStruct->query = query; paramStruct->query = query;
} }
...@@ -335,44 +446,23 @@ void SecondaryCommandBuffer::writeTimestamp(VkPipelineStageFlagBits pipelineStag ...@@ -335,44 +446,23 @@ void SecondaryCommandBuffer::writeTimestamp(VkPipelineStageFlagBits pipelineStag
uint32_t query) uint32_t query)
{ {
WriteTimestampParams *paramStruct = WriteTimestampParams *paramStruct =
initCommand<WriteTimestampParams>(CommandID::WriteTimestamp); initCommand<WriteTimestampParams>(CommandID::WriteTimestamp, 0);
paramStruct->pipelineStage = pipelineStage; paramStruct->pipelineStage = pipelineStage;
paramStruct->queryPool = queryPool; paramStruct->queryPool = queryPool;
paramStruct->query = query; paramStruct->query = query;
} }
ANGLE_INLINE const CommandHeader *NextCommand(const CommandHeader *command)
{
return reinterpret_cast<const CommandHeader *>(reinterpret_cast<const uint8_t *>(command) +
command->size);
}
// Parse the cmds in this cmd buffer into given primary cmd buffer // Parse the cmds in this cmd buffer into given primary cmd buffer
void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer) void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
{ {
for (const CommandHeader *command : mCommands) for (CommandHeader *currentCommand = mHead; currentCommand;
{ currentCommand = currentCommand->next)
for (const CommandHeader *currentCommand = command;
currentCommand->id != CommandID::Invalid; currentCommand = NextCommand(currentCommand))
{ {
switch (currentCommand->id) switch (currentCommand->id)
{ {
case CommandID::BeginQuery:
{
const BeginQueryParams *params = getParamPtr<BeginQueryParams>(currentCommand);
vkCmdBeginQuery(cmdBuffer, params->queryPool, params->query, params->flags);
break;
}
case CommandID::BindComputePipeline:
{
const BindPipelineParams *params =
getParamPtr<BindPipelineParams>(currentCommand);
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, params->pipeline);
break;
}
case CommandID::BindDescriptorSets: case CommandID::BindDescriptorSets:
{ {
const BindDescriptorSetParams *params = BindDescriptorSetParams *params =
getParamPtr<BindDescriptorSetParams>(currentCommand); getParamPtr<BindDescriptorSetParams>(currentCommand);
vkCmdBindDescriptorSets(cmdBuffer, params->bindPoint, params->layout, vkCmdBindDescriptorSets(cmdBuffer, params->bindPoint, params->layout,
params->firstSet, params->descriptorSetCount, params->firstSet, params->descriptorSetCount,
...@@ -380,75 +470,44 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer) ...@@ -380,75 +470,44 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
params->dynamicOffsets); params->dynamicOffsets);
break; break;
} }
case CommandID::BindGraphicsPipeline: case CommandID::BindIndexBuffer:
{ {
const BindPipelineParams *params = BindIndexBufferParams *params = getParamPtr<BindIndexBufferParams>(currentCommand);
getParamPtr<BindPipelineParams>(currentCommand); vkCmdBindIndexBuffer(cmdBuffer, params->buffer, params->offset, params->indexType);
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, params->pipeline);
break; break;
} }
case CommandID::BindIndexBuffer: case CommandID::BindPipeline:
{ {
const BindIndexBufferParams *params = BindPipelineParams *params = getParamPtr<BindPipelineParams>(currentCommand);
getParamPtr<BindIndexBufferParams>(currentCommand); vkCmdBindPipeline(cmdBuffer, params->pipelineBindPoint, params->pipeline);
vkCmdBindIndexBuffer(cmdBuffer, params->buffer, params->offset,
params->indexType);
break; break;
} }
case CommandID::BindVertexBuffers: case CommandID::BindVertexBuffers:
{ {
const BindVertexBuffersParams *params = BindVertexBuffersParams *params =
getParamPtr<BindVertexBuffersParams>(currentCommand); getParamPtr<BindVertexBuffersParams>(currentCommand);
const VkBuffer *buffers = vkCmdBindVertexBuffers(cmdBuffer, params->firstBinding, params->bindingCount,
Offset<VkBuffer>(params, sizeof(BindVertexBuffersParams)); params->buffers, params->offsets);
const VkDeviceSize *offsets =
Offset<VkDeviceSize>(buffers, sizeof(VkBuffer) * params->bindingCount);
vkCmdBindVertexBuffers(cmdBuffer, 0, params->bindingCount, buffers, offsets);
break; break;
} }
case CommandID::BlitImage: case CommandID::BlitImage:
{ {
const BlitImageParams *params = getParamPtr<BlitImageParams>(currentCommand); BlitImageParams *params = getParamPtr<BlitImageParams>(currentCommand);
vkCmdBlitImage(cmdBuffer, params->srcImage, params->srcImageLayout, vkCmdBlitImage(cmdBuffer, params->srcImage, params->srcImageLayout,
params->dstImage, params->dstImageLayout, params->regionCount, params->dstImage, params->dstImageLayout, params->regionCount,
params->pRegions, params->filter); params->pRegions, params->filter);
break; break;
} }
case CommandID::ClearAttachments:
{
const ClearAttachmentsParams *params =
getParamPtr<ClearAttachmentsParams>(currentCommand);
vkCmdClearAttachments(cmdBuffer, params->attachmentCount, params->attachments,
params->rectCount, params->rects);
break;
}
case CommandID::ClearColorImage:
{
const ClearColorImageParams *params =
getParamPtr<ClearColorImageParams>(currentCommand);
vkCmdClearColorImage(cmdBuffer, params->image, params->imageLayout,
&params->color, params->rangeCount, params->ranges);
break;
}
case CommandID::ClearDepthStencilImage:
{
const ClearDepthStencilImageParams *params =
getParamPtr<ClearDepthStencilImageParams>(currentCommand);
vkCmdClearDepthStencilImage(cmdBuffer, params->image, params->imageLayout,
&params->depthStencil, params->rangeCount,
params->ranges);
break;
}
case CommandID::CopyBuffer: case CommandID::CopyBuffer:
{ {
const CopyBufferParams *params = getParamPtr<CopyBufferParams>(currentCommand); CopyBufferParams *params = getParamPtr<CopyBufferParams>(currentCommand);
vkCmdCopyBuffer(cmdBuffer, params->srcBuffer, params->destBuffer, vkCmdCopyBuffer(cmdBuffer, params->srcBuffer, params->destBuffer,
params->regionCount, params->regions); params->regionCount, params->regions);
break; break;
} }
case CommandID::CopyBufferToImage: case CommandID::CopyBufferToImage:
{ {
const CopyBufferToImageParams *params = CopyBufferToImageParams *params =
getParamPtr<CopyBufferToImageParams>(currentCommand); getParamPtr<CopyBufferToImageParams>(currentCommand);
vkCmdCopyBufferToImage(cmdBuffer, params->srcBuffer, params->dstImage, vkCmdCopyBufferToImage(cmdBuffer, params->srcBuffer, params->dstImage,
params->dstImageLayout, params->regionCount, params->dstImageLayout, params->regionCount,
...@@ -457,7 +516,7 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer) ...@@ -457,7 +516,7 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
} }
case CommandID::CopyImage: case CommandID::CopyImage:
{ {
const CopyImageParams *params = getParamPtr<CopyImageParams>(currentCommand); CopyImageParams *params = getParamPtr<CopyImageParams>(currentCommand);
vkCmdCopyImage(cmdBuffer, params->srcImage, params->srcImageLayout, vkCmdCopyImage(cmdBuffer, params->srcImage, params->srcImageLayout,
params->dstImage, params->dstImageLayout, params->regionCount, params->dstImage, params->dstImageLayout, params->regionCount,
params->regions); params->regions);
...@@ -465,137 +524,139 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer) ...@@ -465,137 +524,139 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
} }
case CommandID::CopyImageToBuffer: case CommandID::CopyImageToBuffer:
{ {
const CopyImageToBufferParams *params = CopyImageToBufferParams *params =
getParamPtr<CopyImageToBufferParams>(currentCommand); getParamPtr<CopyImageToBufferParams>(currentCommand);
vkCmdCopyImageToBuffer(cmdBuffer, params->srcImage, params->srcImageLayout, vkCmdCopyImageToBuffer(cmdBuffer, params->srcImage, params->srcImageLayout,
params->dstBuffer, params->regionCount, params->regions); params->dstBuffer, params->regionCount, params->regions);
break; break;
} }
case CommandID::Dispatch: case CommandID::ClearAttachments:
{ {
const DispatchParams *params = getParamPtr<DispatchParams>(currentCommand); ClearAttachmentsParams *params =
vkCmdDispatch(cmdBuffer, params->groupCountX, params->groupCountY, getParamPtr<ClearAttachmentsParams>(currentCommand);
params->groupCountZ); vkCmdClearAttachments(cmdBuffer, params->attachmentCount, params->attachments,
params->rectCount, params->rects);
break; break;
} }
case CommandID::Draw: case CommandID::ClearColorImage:
{ {
const DrawParams *params = getParamPtr<DrawParams>(currentCommand); ClearColorImageParams *params = getParamPtr<ClearColorImageParams>(currentCommand);
vkCmdDraw(cmdBuffer, params->vertexCount, 1, params->firstVertex, 0); vkCmdClearColorImage(cmdBuffer, params->image, params->imageLayout, &params->color,
params->rangeCount, params->ranges);
break; break;
} }
case CommandID::DrawIndexed: case CommandID::ClearDepthStencilImage:
{ {
const DrawIndexedParams *params = ClearDepthStencilImageParams *params =
getParamPtr<DrawIndexedParams>(currentCommand); getParamPtr<ClearDepthStencilImageParams>(currentCommand);
vkCmdDrawIndexed(cmdBuffer, params->indexCount, 1, 0, 0, 0); vkCmdClearDepthStencilImage(cmdBuffer, params->image, params->imageLayout,
&params->depthStencil, params->rangeCount,
params->ranges);
break; break;
} }
case CommandID::DrawIndexedInstanced: case CommandID::UpdateBuffer:
{ {
const DrawIndexedInstancedParams *params = UpdateBufferParams *params = getParamPtr<UpdateBufferParams>(currentCommand);
getParamPtr<DrawIndexedInstancedParams>(currentCommand); vkCmdUpdateBuffer(cmdBuffer, params->buffer, params->dstOffset, params->dataSize,
vkCmdDrawIndexed(cmdBuffer, params->indexCount, params->instanceCount, 0, 0, 0); params->data);
break; break;
} }
case CommandID::DrawInstanced: case CommandID::PushConstants:
{ {
const DrawInstancedParams *params = PushConstantsParams *params = getParamPtr<PushConstantsParams>(currentCommand);
getParamPtr<DrawInstancedParams>(currentCommand); vkCmdPushConstants(cmdBuffer, params->layout, params->flag, params->offset,
vkCmdDraw(cmdBuffer, params->vertexCount, params->instanceCount, params->size, params->data);
params->firstVertex, 0);
break; break;
} }
case CommandID::EndQuery: case CommandID::SetViewport:
{ {
const EndQueryParams *params = getParamPtr<EndQueryParams>(currentCommand); SetViewportParams *params = getParamPtr<SetViewportParams>(currentCommand);
vkCmdEndQuery(cmdBuffer, params->queryPool, params->query); vkCmdSetViewport(cmdBuffer, params->firstViewport, params->viewportCount,
params->viewports);
break; break;
} }
case CommandID::ImageBarrier: case CommandID::SetScissor:
{ {
const ImageBarrierParams *params = SetScissorParams *params = getParamPtr<SetScissorParams>(currentCommand);
getParamPtr<ImageBarrierParams>(currentCommand); vkCmdSetScissor(cmdBuffer, params->firstScissor, params->scissorCount,
vkCmdPipelineBarrier(cmdBuffer, params->srcStageMask, params->dstStageMask, 0, params->scissors);
0, nullptr, 0, nullptr, 1, &params->imageMemoryBarrier);
break; break;
} }
case CommandID::PipelineBarrier: case CommandID::Draw:
{ {
const PipelineBarrierParams *params = DrawParams *params = getParamPtr<DrawParams>(currentCommand);
getParamPtr<PipelineBarrierParams>(currentCommand); vkCmdDraw(cmdBuffer, params->vertexCount, params->instanceCount,
vkCmdPipelineBarrier( params->firstVertex, params->firstInstance);
cmdBuffer, params->srcStageMask, params->dstStageMask,
params->dependencyFlags, params->memoryBarrierCount, params->memoryBarriers,
params->bufferMemoryBarrierCount, params->bufferMemoryBarriers,
params->imageMemoryBarrierCount, params->imageMemoryBarriers);
break; break;
} }
case CommandID::PushConstants: case CommandID::DrawIndexed:
{ {
const PushConstantsParams *params = DrawIndexedParams *params = getParamPtr<DrawIndexedParams>(currentCommand);
getParamPtr<PushConstantsParams>(currentCommand); vkCmdDrawIndexed(cmdBuffer, params->indexCount, params->instanceCount,
vkCmdPushConstants(cmdBuffer, params->layout, params->flag, params->offset, params->firstIndex, params->vertexOffset, params->firstInstance);
params->size, params->data);
break; break;
} }
case CommandID::ResetEvent: case CommandID::Dispatch:
{ {
const ResetEventParams *params = getParamPtr<ResetEventParams>(currentCommand); DispatchParams *params = getParamPtr<DispatchParams>(currentCommand);
vkCmdResetEvent(cmdBuffer, params->event, params->stageMask); vkCmdDispatch(cmdBuffer, params->groupCountX, params->groupCountY,
params->groupCountZ);
break; break;
} }
case CommandID::ResetQueryPool: case CommandID::PipelinBarrier:
{ {
const ResetQueryPoolParams *params = PipelineBarrierParams *params = getParamPtr<PipelineBarrierParams>(currentCommand);
getParamPtr<ResetQueryPoolParams>(currentCommand); vkCmdPipelineBarrier(cmdBuffer, params->srcStageMask, params->dstStageMask,
vkCmdResetQueryPool(cmdBuffer, params->queryPool, params->firstQuery, params->dependencyFlags, params->memoryBarrierCount,
params->queryCount); params->memoryBarriers, params->bufferMemoryBarrierCount,
params->bufferMemoryBarriers, params->imageMemoryBarrierCount,
params->imageMemoryBarriers);
break; break;
} }
case CommandID::SetEvent: case CommandID::SetEvent:
{ {
const SetEventParams *params = getParamPtr<SetEventParams>(currentCommand); SetEventParams *params = getParamPtr<SetEventParams>(currentCommand);
vkCmdSetEvent(cmdBuffer, params->event, params->stageMask); vkCmdSetEvent(cmdBuffer, params->event, params->stageMask);
break; break;
} }
case CommandID::SetScissor: case CommandID::ResetEvent:
{ {
const SetScissorParams *params = getParamPtr<SetScissorParams>(currentCommand); ResetEventParams *params = getParamPtr<ResetEventParams>(currentCommand);
vkCmdSetScissor(cmdBuffer, params->firstScissor, params->scissorCount, vkCmdResetEvent(cmdBuffer, params->event, params->stageMask);
params->scissors);
break; break;
} }
case CommandID::SetViewport: case CommandID::WaitEvents:
{ {
const SetViewportParams *params = WaitEventsParams *params = getParamPtr<WaitEventsParams>(currentCommand);
getParamPtr<SetViewportParams>(currentCommand); vkCmdWaitEvents(cmdBuffer, params->eventCount, params->events, params->srcStageMask,
vkCmdSetViewport(cmdBuffer, params->firstViewport, params->viewportCount, params->dstStageMask, params->memoryBarrierCount,
params->viewports); params->memoryBarriers, params->bufferMemoryBarrierCount,
params->bufferMemoryBarriers, params->imageMemoryBarrierCount,
params->imageMemoryBarriers);
break; break;
} }
case CommandID::UpdateBuffer: case CommandID::ResetQueryPool:
{ {
const UpdateBufferParams *params = ResetQueryPoolParams *params = getParamPtr<ResetQueryPoolParams>(currentCommand);
getParamPtr<UpdateBufferParams>(currentCommand); vkCmdResetQueryPool(cmdBuffer, params->queryPool, params->firstQuery,
vkCmdUpdateBuffer(cmdBuffer, params->buffer, params->dstOffset, params->queryCount);
params->dataSize, params->data);
break; break;
} }
case CommandID::WaitEvents: case CommandID::BeginQuery:
{
BeginQueryParams *params = getParamPtr<BeginQueryParams>(currentCommand);
vkCmdBeginQuery(cmdBuffer, params->queryPool, params->query, params->flags);
break;
}
case CommandID::EndQuery:
{ {
const WaitEventsParams *params = getParamPtr<WaitEventsParams>(currentCommand); EndQueryParams *params = getParamPtr<EndQueryParams>(currentCommand);
vkCmdWaitEvents(cmdBuffer, params->eventCount, params->events, vkCmdEndQuery(cmdBuffer, params->queryPool, params->query);
params->srcStageMask, params->dstStageMask,
params->memoryBarrierCount, params->memoryBarriers,
params->bufferMemoryBarrierCount, params->bufferMemoryBarriers,
params->imageMemoryBarrierCount, params->imageMemoryBarriers);
break; break;
} }
case CommandID::WriteTimestamp: case CommandID::WriteTimestamp:
{ {
const WriteTimestampParams *params = WriteTimestampParams *params = getParamPtr<WriteTimestampParams>(currentCommand);
getParamPtr<WriteTimestampParams>(currentCommand);
vkCmdWriteTimestamp(cmdBuffer, params->pipelineStage, params->queryPool, vkCmdWriteTimestamp(cmdBuffer, params->pipelineStage, params->queryPool,
params->query); params->query);
break; break;
...@@ -607,7 +668,6 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer) ...@@ -607,7 +668,6 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
} }
} }
} }
}
} }
} // namespace vk } // namespace vk
......
...@@ -22,46 +22,40 @@ namespace rx ...@@ -22,46 +22,40 @@ namespace rx
namespace vk namespace vk
{ {
enum class CommandID : uint16_t enum class CommandID
{ {
// Invalid cmd used to mark end of sequence of commands // State update cmds
Invalid = 0, BindDescriptorSets = 0,
BeginQuery, BindIndexBuffer = 1,
BindComputePipeline, BindPipeline = 2,
BindDescriptorSets, BindVertexBuffers = 3,
BindGraphicsPipeline, BlitImage = 4,
BindIndexBuffer, CopyBuffer = 5,
BindVertexBuffers, CopyBufferToImage = 6,
BlitImage, CopyImage = 7,
ClearAttachments, CopyImageToBuffer = 8,
ClearColorImage, ClearAttachments = 9,
ClearDepthStencilImage, ClearColorImage = 10,
CopyBuffer, ClearDepthStencilImage = 11,
CopyBufferToImage, UpdateBuffer = 12,
CopyImage, PushConstants = 13,
CopyImageToBuffer, SetViewport = 14,
Dispatch, SetScissor = 15,
Draw, // Draw/dispatch cmds
DrawIndexed, Draw = 16,
DrawIndexedInstanced, DrawIndexed = 17,
DrawInstanced, Dispatch = 18,
EndQuery, // Sync & Query cmds
ImageBarrier, PipelinBarrier = 19,
PipelineBarrier, ResetEvent = 20,
PushConstants, SetEvent = 21,
ResetEvent, WaitEvents = 22,
ResetQueryPool, ResetQueryPool = 23,
SetEvent, BeginQuery = 24,
SetScissor, EndQuery = 25,
SetViewport, WriteTimestamp = 26,
UpdateBuffer,
WaitEvents,
WriteTimestamp,
}; };
#define VERIFY_4_BYTE_ALIGNMENT(StructName) \
static_assert((sizeof(StructName) % 4) == 0, "Check StructName alignment");
// Structs to encapsulate parameters for different commands // Structs to encapsulate parameters for different commands
// This makes it easy to know the size of params & to copy params // This makes it easy to know the size of params & to copy params
// TODO: Could optimize the size of some of these structs through bit-packing // TODO: Could optimize the size of some of these structs through bit-packing
...@@ -76,7 +70,6 @@ struct BindDescriptorSetParams ...@@ -76,7 +70,6 @@ struct BindDescriptorSetParams
uint32_t dynamicOffsetCount; uint32_t dynamicOffsetCount;
const uint32_t *dynamicOffsets; const uint32_t *dynamicOffsets;
}; };
VERIFY_4_BYTE_ALIGNMENT(BindDescriptorSetParams)
struct BindIndexBufferParams struct BindIndexBufferParams
{ {
...@@ -84,20 +77,20 @@ struct BindIndexBufferParams ...@@ -84,20 +77,20 @@ struct BindIndexBufferParams
VkDeviceSize offset; VkDeviceSize offset;
VkIndexType indexType; VkIndexType indexType;
}; };
VERIFY_4_BYTE_ALIGNMENT(BindIndexBufferParams)
struct BindPipelineParams struct BindPipelineParams
{ {
VkPipelineBindPoint pipelineBindPoint;
VkPipeline pipeline; VkPipeline pipeline;
}; };
VERIFY_4_BYTE_ALIGNMENT(BindPipelineParams)
struct BindVertexBuffersParams struct BindVertexBuffersParams
{ {
// ANGLE always has firstBinding of 0 so not storing that currently uint32_t firstBinding;
uint32_t bindingCount; uint32_t bindingCount;
const VkBuffer *buffers;
const VkDeviceSize *offsets;
}; };
VERIFY_4_BYTE_ALIGNMENT(BindVertexBuffersParams)
struct BlitImageParams struct BlitImageParams
{ {
...@@ -109,7 +102,6 @@ struct BlitImageParams ...@@ -109,7 +102,6 @@ struct BlitImageParams
const VkImageBlit *pRegions; const VkImageBlit *pRegions;
VkFilter filter; VkFilter filter;
}; };
VERIFY_4_BYTE_ALIGNMENT(BlitImageParams)
struct CopyBufferParams struct CopyBufferParams
{ {
...@@ -118,7 +110,6 @@ struct CopyBufferParams ...@@ -118,7 +110,6 @@ struct CopyBufferParams
uint32_t regionCount; uint32_t regionCount;
const VkBufferCopy *regions; const VkBufferCopy *regions;
}; };
VERIFY_4_BYTE_ALIGNMENT(CopyBufferParams)
struct CopyBufferToImageParams struct CopyBufferToImageParams
{ {
...@@ -128,7 +119,6 @@ struct CopyBufferToImageParams ...@@ -128,7 +119,6 @@ struct CopyBufferToImageParams
uint32_t regionCount; uint32_t regionCount;
const VkBufferImageCopy *regions; const VkBufferImageCopy *regions;
}; };
VERIFY_4_BYTE_ALIGNMENT(CopyBufferToImageParams)
struct CopyImageParams struct CopyImageParams
{ {
...@@ -139,7 +129,6 @@ struct CopyImageParams ...@@ -139,7 +129,6 @@ struct CopyImageParams
uint32_t regionCount; uint32_t regionCount;
const VkImageCopy *regions; const VkImageCopy *regions;
}; };
VERIFY_4_BYTE_ALIGNMENT(CopyImageParams)
struct CopyImageToBufferParams struct CopyImageToBufferParams
{ {
...@@ -149,7 +138,6 @@ struct CopyImageToBufferParams ...@@ -149,7 +138,6 @@ struct CopyImageToBufferParams
uint32_t regionCount; uint32_t regionCount;
const VkBufferImageCopy *regions; const VkBufferImageCopy *regions;
}; };
VERIFY_4_BYTE_ALIGNMENT(CopyImageToBufferParams)
struct ClearAttachmentsParams struct ClearAttachmentsParams
{ {
...@@ -158,7 +146,6 @@ struct ClearAttachmentsParams ...@@ -158,7 +146,6 @@ struct ClearAttachmentsParams
uint32_t rectCount; uint32_t rectCount;
const VkClearRect *rects; const VkClearRect *rects;
}; };
VERIFY_4_BYTE_ALIGNMENT(ClearAttachmentsParams)
struct ClearColorImageParams struct ClearColorImageParams
{ {
...@@ -168,7 +155,6 @@ struct ClearColorImageParams ...@@ -168,7 +155,6 @@ struct ClearColorImageParams
uint32_t rangeCount; uint32_t rangeCount;
const VkImageSubresourceRange *ranges; const VkImageSubresourceRange *ranges;
}; };
VERIFY_4_BYTE_ALIGNMENT(ClearColorImageParams)
struct ClearDepthStencilImageParams struct ClearDepthStencilImageParams
{ {
...@@ -178,7 +164,6 @@ struct ClearDepthStencilImageParams ...@@ -178,7 +164,6 @@ struct ClearDepthStencilImageParams
uint32_t rangeCount; uint32_t rangeCount;
const VkImageSubresourceRange *ranges; const VkImageSubresourceRange *ranges;
}; };
VERIFY_4_BYTE_ALIGNMENT(ClearDepthStencilImageParams)
struct UpdateBufferParams struct UpdateBufferParams
{ {
...@@ -187,7 +172,6 @@ struct UpdateBufferParams ...@@ -187,7 +172,6 @@ struct UpdateBufferParams
VkDeviceSize dataSize; VkDeviceSize dataSize;
const void *data; const void *data;
}; };
VERIFY_4_BYTE_ALIGNMENT(UpdateBufferParams)
struct PushConstantsParams struct PushConstantsParams
{ {
...@@ -197,7 +181,6 @@ struct PushConstantsParams ...@@ -197,7 +181,6 @@ struct PushConstantsParams
uint32_t size; uint32_t size;
const void *data; const void *data;
}; };
VERIFY_4_BYTE_ALIGNMENT(PushConstantsParams)
struct SetViewportParams struct SetViewportParams
{ {
...@@ -205,7 +188,6 @@ struct SetViewportParams ...@@ -205,7 +188,6 @@ struct SetViewportParams
uint32_t viewportCount; uint32_t viewportCount;
const VkViewport *viewports; const VkViewport *viewports;
}; };
VERIFY_4_BYTE_ALIGNMENT(SetViewportParams)
struct SetScissorParams struct SetScissorParams
{ {
...@@ -213,35 +195,23 @@ struct SetScissorParams ...@@ -213,35 +195,23 @@ struct SetScissorParams
uint32_t scissorCount; uint32_t scissorCount;
const VkRect2D *scissors; const VkRect2D *scissors;
}; };
VERIFY_4_BYTE_ALIGNMENT(SetScissorParams)
struct DrawParams struct DrawParams
{ {
uint32_t vertexCount; uint32_t vertexCount;
uint32_t firstVertex;
};
VERIFY_4_BYTE_ALIGNMENT(DrawParams)
struct DrawInstancedParams
{
uint32_t vertexCount;
uint32_t instanceCount; uint32_t instanceCount;
uint32_t firstVertex; uint32_t firstVertex;
uint32_t firstInstance;
}; };
VERIFY_4_BYTE_ALIGNMENT(DrawInstancedParams)
struct DrawIndexedParams struct DrawIndexedParams
{ {
uint32_t indexCount; uint32_t indexCount;
};
VERIFY_4_BYTE_ALIGNMENT(DrawIndexedParams)
struct DrawIndexedInstancedParams
{
uint32_t indexCount;
uint32_t instanceCount; uint32_t instanceCount;
uint32_t firstIndex;
int32_t vertexOffset;
uint32_t firstInstance;
}; };
VERIFY_4_BYTE_ALIGNMENT(DrawIndexedInstancedParams)
struct DispatchParams struct DispatchParams
{ {
...@@ -249,7 +219,6 @@ struct DispatchParams ...@@ -249,7 +219,6 @@ struct DispatchParams
uint32_t groupCountY; uint32_t groupCountY;
uint32_t groupCountZ; uint32_t groupCountZ;
}; };
VERIFY_4_BYTE_ALIGNMENT(DispatchParams)
struct PipelineBarrierParams struct PipelineBarrierParams
{ {
...@@ -263,29 +232,18 @@ struct PipelineBarrierParams ...@@ -263,29 +232,18 @@ struct PipelineBarrierParams
uint32_t imageMemoryBarrierCount; uint32_t imageMemoryBarrierCount;
const VkImageMemoryBarrier *imageMemoryBarriers; const VkImageMemoryBarrier *imageMemoryBarriers;
}; };
VERIFY_4_BYTE_ALIGNMENT(PipelineBarrierParams)
struct ImageBarrierParams
{
VkPipelineStageFlags srcStageMask;
VkPipelineStageFlags dstStageMask;
VkImageMemoryBarrier imageMemoryBarrier;
};
VERIFY_4_BYTE_ALIGNMENT(ImageBarrierParams)
struct SetEventParams struct SetEventParams
{ {
VkEvent event; VkEvent event;
VkPipelineStageFlags stageMask; VkPipelineStageFlags stageMask;
}; };
VERIFY_4_BYTE_ALIGNMENT(SetEventParams)
struct ResetEventParams struct ResetEventParams
{ {
VkEvent event; VkEvent event;
VkPipelineStageFlags stageMask; VkPipelineStageFlags stageMask;
}; };
VERIFY_4_BYTE_ALIGNMENT(ResetEventParams)
struct WaitEventsParams struct WaitEventsParams
{ {
...@@ -300,7 +258,6 @@ struct WaitEventsParams ...@@ -300,7 +258,6 @@ struct WaitEventsParams
uint32_t imageMemoryBarrierCount; uint32_t imageMemoryBarrierCount;
const VkImageMemoryBarrier *imageMemoryBarriers; const VkImageMemoryBarrier *imageMemoryBarriers;
}; };
VERIFY_4_BYTE_ALIGNMENT(WaitEventsParams)
struct ResetQueryPoolParams struct ResetQueryPoolParams
{ {
...@@ -308,7 +265,6 @@ struct ResetQueryPoolParams ...@@ -308,7 +265,6 @@ struct ResetQueryPoolParams
uint32_t firstQuery; uint32_t firstQuery;
uint32_t queryCount; uint32_t queryCount;
}; };
VERIFY_4_BYTE_ALIGNMENT(ResetQueryPoolParams)
struct BeginQueryParams struct BeginQueryParams
{ {
...@@ -316,14 +272,12 @@ struct BeginQueryParams ...@@ -316,14 +272,12 @@ struct BeginQueryParams
uint32_t query; uint32_t query;
VkQueryControlFlags flags; VkQueryControlFlags flags;
}; };
VERIFY_4_BYTE_ALIGNMENT(BeginQueryParams)
struct EndQueryParams struct EndQueryParams
{ {
VkQueryPool queryPool; VkQueryPool queryPool;
uint32_t query; uint32_t query;
}; };
VERIFY_4_BYTE_ALIGNMENT(EndQueryParams)
struct WriteTimestampParams struct WriteTimestampParams
{ {
...@@ -331,34 +285,19 @@ struct WriteTimestampParams ...@@ -331,34 +285,19 @@ struct WriteTimestampParams
VkQueryPool queryPool; VkQueryPool queryPool;
uint32_t query; uint32_t query;
}; };
VERIFY_4_BYTE_ALIGNMENT(WriteTimestampParams)
// Header for every cmd in custom cmd buffer // Header for every cmd in custom cmd buffer
struct CommandHeader struct CommandHeader
{ {
CommandID id; CommandID id;
uint16_t size; CommandHeader *next;
}; };
static_assert(sizeof(CommandHeader) == 4, "Check CommandHeader size");
template <typename DestT, typename T>
ANGLE_INLINE DestT *Offset(T *ptr, size_t bytes)
{
return reinterpret_cast<DestT *>((reinterpret_cast<uint8_t *>(ptr) + bytes));
}
template <typename DestT, typename T>
ANGLE_INLINE const DestT *Offset(const T *ptr, size_t bytes)
{
return reinterpret_cast<const DestT *>((reinterpret_cast<const uint8_t *>(ptr) + bytes));
}
class SecondaryCommandBuffer final : angle::NonCopyable class SecondaryCommandBuffer final : angle::NonCopyable
{ {
public: public:
SecondaryCommandBuffer(); SecondaryCommandBuffer() : mHead(nullptr), mLast(nullptr), mAllocator(nullptr) {}
~SecondaryCommandBuffer(); ~SecondaryCommandBuffer() {}
// Add commands // Add commands
void bindDescriptorSets(VkPipelineBindPoint bindPoint, void bindDescriptorSets(VkPipelineBindPoint bindPoint,
...@@ -371,9 +310,7 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -371,9 +310,7 @@ class SecondaryCommandBuffer final : angle::NonCopyable
void bindIndexBuffer(const Buffer &buffer, VkDeviceSize offset, VkIndexType indexType); void bindIndexBuffer(const Buffer &buffer, VkDeviceSize offset, VkIndexType indexType);
void bindGraphicsPipeline(const Pipeline &pipeline); void bindPipeline(VkPipelineBindPoint pipelineBindPoint, const Pipeline &pipeline);
void bindComputePipeline(const Pipeline &pipeline);
void bindVertexBuffers(uint32_t firstBinding, void bindVertexBuffers(uint32_t firstBinding,
uint32_t bindingCount, uint32_t bindingCount,
...@@ -443,13 +380,16 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -443,13 +380,16 @@ class SecondaryCommandBuffer final : angle::NonCopyable
void setViewport(uint32_t firstViewport, uint32_t viewportCount, const VkViewport *viewports); void setViewport(uint32_t firstViewport, uint32_t viewportCount, const VkViewport *viewports);
void setScissor(uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *scissors); void setScissor(uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *scissors);
void draw(uint32_t vertexCount, uint32_t firstVertex); void draw(uint32_t vertexCount,
uint32_t instanceCount,
void drawInstanced(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex); uint32_t firstVertex,
uint32_t firstInstance);
void drawIndexed(uint32_t indexCount);
void drawIndexedInstanced(uint32_t indexCount, uint32_t instanceCount); void drawIndexed(uint32_t indexCount,
uint32_t instanceCount,
uint32_t firstIndex,
int32_t vertexOffset,
uint32_t firstInstance);
void dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); void dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
...@@ -463,10 +403,6 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -463,10 +403,6 @@ class SecondaryCommandBuffer final : angle::NonCopyable
uint32_t imageMemoryBarrierCount, uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier *imageMemoryBarriers); const VkImageMemoryBarrier *imageMemoryBarriers);
void imageBarrier(VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
VkImageMemoryBarrier *imageMemoryBarrier);
void setEvent(VkEvent event, VkPipelineStageFlags stageMask); void setEvent(VkEvent event, VkPipelineStageFlags stageMask);
void resetEvent(VkEvent event, VkPipelineStageFlags stageMask); void resetEvent(VkEvent event, VkPipelineStageFlags stageMask);
void waitEvents(uint32_t eventCount, void waitEvents(uint32_t eventCount,
...@@ -491,86 +427,24 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -491,86 +427,24 @@ class SecondaryCommandBuffer final : angle::NonCopyable
// Parse the cmds in this cmd buffer into given primary cmd buffer for execution // Parse the cmds in this cmd buffer into given primary cmd buffer for execution
void executeCommands(VkCommandBuffer cmdBuffer); void executeCommands(VkCommandBuffer cmdBuffer);
// Pool Alloc uses 16kB pages w/ 16byte header = 16368bytes. To minimize waste
// using a 16368/12 = 1364. Also better perf than 1024 due to fewer block allocations
static constexpr size_t kBlockSize = 1364;
// Make sure block size is 4-byte aligned to avoid Android errors
static_assert((kBlockSize % 4) == 0, "Check kBlockSize alignment");
// Initialize the SecondaryCommandBuffer by setting the allocator it will use // Initialize the SecondaryCommandBuffer by setting the allocator it will use
void initialize(angle::PoolAllocator *allocator) void initialize(angle::PoolAllocator *allocator) { mAllocator = allocator; }
{
ASSERT(allocator);
mAllocator = allocator;
allocateNewBlock();
// Set first command to Invalid to start
reinterpret_cast<CommandHeader *>(mCurrentWritePointer)->id = CommandID::Invalid;
}
// This will cause the SecondaryCommandBuffer to become invalid by clearing its allocator // This will cause the SecondaryCommandBuffer to become invalid by clearing its allocator
void releaseHandle() { mAllocator = nullptr; } void releaseHandle() { mAllocator = nullptr; }
// The SecondaryCommandBuffer is valid if it's been initialized // The SecondaryCommandBuffer is valid if it's been initialized
bool valid() { return mAllocator != nullptr; } bool valid() { return mAllocator != nullptr; }
private: private:
template <class StructType>
ANGLE_INLINE StructType *commonInit(CommandID cmdID, size_t allocationSize)
{
mCurrentBytesRemaining -= allocationSize;
CommandHeader *header = reinterpret_cast<CommandHeader *>(mCurrentWritePointer);
header->id = cmdID;
header->size = static_cast<uint16_t>(allocationSize);
ASSERT(allocationSize <= std::numeric_limits<uint16_t>::max());
mCurrentWritePointer += allocationSize;
// Set next cmd header to Invalid (0) so cmd sequence will be terminated
reinterpret_cast<CommandHeader *>(mCurrentWritePointer)->id = CommandID::Invalid;
return Offset<StructType>(header, sizeof(CommandHeader));
}
ANGLE_INLINE void allocateNewBlock()
{
ASSERT(mAllocator);
mCurrentWritePointer = mAllocator->fastAllocate(kBlockSize);
mCurrentBytesRemaining = kBlockSize;
mCommands.push_back(reinterpret_cast<CommandHeader *>(mCurrentWritePointer));
}
// Allocate and initialize memory for given commandID & variable param size // Allocate and initialize memory for given commandID & variable param size
// returning a pointer to the start of the commands parameter data and updating // returning a pointer to the start of the commands parameter data and updating
// mPtrCmdData to just past the fixed parameter data. // mPtrCmdData to just past the fixed parameter data.
template <class StructType> template <class StructType>
ANGLE_INLINE StructType *initCommand(CommandID cmdID, size_t variableSize) StructType *initCommand(CommandID cmdID, size_t variableSize);
{
constexpr size_t fixedAllocationSize = sizeof(StructType) + sizeof(CommandHeader);
const size_t allocationSize = fixedAllocationSize + variableSize;
// Make sure we have enough room to mark follow-on header "Invalid"
if (mCurrentBytesRemaining <= (allocationSize + sizeof(CommandHeader)))
{
allocateNewBlock();
}
mPtrCmdData = mCurrentWritePointer + fixedAllocationSize;
return commonInit<StructType>(cmdID, allocationSize);
}
// Initialize a command that doesn't have variable-sized ptr data
template <class StructType>
ANGLE_INLINE StructType *initCommand(CommandID cmdID)
{
constexpr size_t allocationSize = sizeof(StructType) + sizeof(CommandHeader);
// Make sure we have enough room to mark follow-on header "Invalid"
if (mCurrentBytesRemaining <= (allocationSize + sizeof(CommandHeader)))
{
allocateNewBlock();
}
return commonInit<StructType>(cmdID, allocationSize);
}
// Return a ptr to the parameter type // Return a ptr to the parameter type
template <class StructType> template <class StructType>
const StructType *getParamPtr(const CommandHeader *header) const StructType *getParamPtr(CommandHeader *header)
{ {
return reinterpret_cast<const StructType *>(reinterpret_cast<const uint8_t *>(header) + return reinterpret_cast<StructType *>(reinterpret_cast<char *>(header) +
sizeof(CommandHeader)); sizeof(CommandHeader));
} }
// Copy sizeInBytes data from paramData to mPtrCmdData and assign *writePtr // Copy sizeInBytes data from paramData to mPtrCmdData and assign *writePtr
...@@ -579,132 +453,18 @@ class SecondaryCommandBuffer final : angle::NonCopyable ...@@ -579,132 +453,18 @@ class SecondaryCommandBuffer final : angle::NonCopyable
template <class PtrType> template <class PtrType>
void storePointerParameter(const PtrType *paramData, void storePointerParameter(const PtrType *paramData,
const PtrType **writePtr, const PtrType **writePtr,
size_t sizeInBytes) size_t sizeInBytes);
{
if (sizeInBytes == 0)
return;
*writePtr = reinterpret_cast<const PtrType *>(mPtrCmdData);
memcpy(mPtrCmdData, paramData, sizeInBytes);
mPtrCmdData += sizeInBytes;
}
std::vector<CommandHeader *> mCommands;
// Allocator used by this class. If non-null then the class is valid. // Pointer to start of cmd buffer
CommandHeader *mHead;
// Last command inserted in cmd buffer
CommandHeader *mLast;
angle::PoolAllocator *mAllocator; angle::PoolAllocator *mAllocator;
uint8_t *mCurrentWritePointer;
size_t mCurrentBytesRemaining;
// Ptr to write variable ptr data section of cmd into. // Ptr to write variable ptr data section of cmd into.
// This is set to just past fixed parameter data when initCommand() is called // This is set to just past fixed parameter data when initCommand() is called
uint8_t *mPtrCmdData; uint8_t *mPtrCmdData;
}; };
ANGLE_INLINE SecondaryCommandBuffer::SecondaryCommandBuffer()
: mAllocator(nullptr), mCurrentWritePointer(nullptr), mCurrentBytesRemaining(0)
{}
ANGLE_INLINE SecondaryCommandBuffer::~SecondaryCommandBuffer() {}
ANGLE_INLINE void SecondaryCommandBuffer::bindDescriptorSets(VkPipelineBindPoint bindPoint,
const PipelineLayout &layout,
uint32_t firstSet,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets,
uint32_t dynamicOffsetCount,
const uint32_t *dynamicOffsets)
{
size_t descSize = descriptorSetCount * sizeof(VkDescriptorSet);
size_t offsetSize = dynamicOffsetCount * sizeof(uint32_t);
size_t varSize = descSize + offsetSize;
BindDescriptorSetParams *paramStruct =
initCommand<BindDescriptorSetParams>(CommandID::BindDescriptorSets, varSize);
// Copy params into memory
paramStruct->bindPoint = bindPoint;
paramStruct->layout = layout.getHandle();
paramStruct->firstSet = firstSet;
paramStruct->descriptorSetCount = descriptorSetCount;
paramStruct->dynamicOffsetCount = dynamicOffsetCount;
// Copy variable sized data
storePointerParameter(descriptorSets, &paramStruct->descriptorSets, descSize);
storePointerParameter(dynamicOffsets, &paramStruct->dynamicOffsets, offsetSize);
}
ANGLE_INLINE void SecondaryCommandBuffer::bindIndexBuffer(const Buffer &buffer,
VkDeviceSize offset,
VkIndexType indexType)
{
BindIndexBufferParams *paramStruct =
initCommand<BindIndexBufferParams>(CommandID::BindIndexBuffer);
paramStruct->buffer = buffer.getHandle();
paramStruct->offset = offset;
paramStruct->indexType = indexType;
}
ANGLE_INLINE void SecondaryCommandBuffer::bindGraphicsPipeline(const Pipeline &pipeline)
{
BindPipelineParams *paramStruct =
initCommand<BindPipelineParams>(CommandID::BindGraphicsPipeline);
paramStruct->pipeline = pipeline.getHandle();
}
ANGLE_INLINE void SecondaryCommandBuffer::bindComputePipeline(const Pipeline &pipeline)
{
BindPipelineParams *paramStruct =
initCommand<BindPipelineParams>(CommandID::BindComputePipeline);
paramStruct->pipeline = pipeline.getHandle();
}
ANGLE_INLINE void SecondaryCommandBuffer::bindVertexBuffers(uint32_t firstBinding,
uint32_t bindingCount,
const VkBuffer *buffers,
const VkDeviceSize *offsets)
{
ASSERT(firstBinding == 0);
size_t buffersSize = bindingCount * sizeof(VkBuffer);
size_t offsetsSize = bindingCount * sizeof(VkDeviceSize);
BindVertexBuffersParams *paramStruct = initCommand<BindVertexBuffersParams>(
CommandID::BindVertexBuffers, buffersSize + offsetsSize);
// Copy params
paramStruct->bindingCount = bindingCount;
uint8_t *writePointer = Offset<uint8_t>(paramStruct, sizeof(BindVertexBuffersParams));
memcpy(writePointer, buffers, buffersSize);
writePointer += buffersSize;
memcpy(writePointer, offsets, offsetsSize);
}
ANGLE_INLINE void SecondaryCommandBuffer::draw(uint32_t vertexCount, uint32_t firstVertex)
{
DrawParams *paramStruct = initCommand<DrawParams>(CommandID::Draw);
paramStruct->vertexCount = vertexCount;
paramStruct->firstVertex = firstVertex;
}
ANGLE_INLINE void SecondaryCommandBuffer::drawInstanced(uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex)
{
DrawInstancedParams *paramStruct = initCommand<DrawInstancedParams>(CommandID::DrawInstanced);
paramStruct->vertexCount = vertexCount;
paramStruct->instanceCount = instanceCount;
paramStruct->firstVertex = firstVertex;
}
ANGLE_INLINE void SecondaryCommandBuffer::drawIndexed(uint32_t indexCount)
{
DrawIndexedParams *paramStruct = initCommand<DrawIndexedParams>(CommandID::DrawIndexed);
paramStruct->indexCount = indexCount;
}
ANGLE_INLINE void SecondaryCommandBuffer::drawIndexedInstanced(uint32_t indexCount,
uint32_t instanceCount)
{
DrawIndexedInstancedParams *paramStruct =
initCommand<DrawIndexedInstancedParams>(CommandID::DrawIndexedInstanced);
paramStruct->indexCount = indexCount;
paramStruct->instanceCount = instanceCount;
}
} // namespace vk } // namespace vk
} // namespace rx } // namespace rx
......
...@@ -1004,7 +1004,7 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context) ...@@ -1004,7 +1004,7 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context)
sourceRowPitch, imageData + bufferOffset)); sourceRowPitch, imageData + bufferOffset));
} }
CommandBufferT *commandBuffer = nullptr; CommandBufferT *commandBuffer;
ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer)); ANGLE_TRY(mImage->recordCommands(contextVk, &commandBuffer));
return mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0), getLevelCount(), return mImage->flushStagedUpdates(contextVk, getNativeImageLevel(0), getLevelCount(),
commandBuffer); commandBuffer);
......
...@@ -335,7 +335,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context, ...@@ -335,7 +335,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context,
program->setShader(gl::ShaderType::Compute, fsCsShader); program->setShader(gl::ShaderType::Compute, fsCsShader);
ANGLE_TRY(program->getComputePipeline(context, pipelineLayout.get(), &pipelineAndSerial)); ANGLE_TRY(program->getComputePipeline(context, pipelineLayout.get(), &pipelineAndSerial));
pipelineAndSerial->updateSerial(serial); pipelineAndSerial->updateSerial(serial);
commandBuffer->bindComputePipeline(pipelineAndSerial->get()); commandBuffer->bindPipeline(bindPoint, pipelineAndSerial->get());
} }
else else
{ {
...@@ -350,7 +350,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context, ...@@ -350,7 +350,7 @@ angle::Result UtilsVk::setupProgram(vk::Context *context,
context, &renderer->getRenderPassCache(), renderer->getPipelineCache(), serial, context, &renderer->getRenderPassCache(), renderer->getPipelineCache(), serial,
pipelineLayout.get(), *pipelineDesc, gl::AttributesMask(), &descPtr, &helper)); pipelineLayout.get(), *pipelineDesc, gl::AttributesMask(), &descPtr, &helper));
helper->updateSerial(serial); helper->updateSerial(serial);
commandBuffer->bindGraphicsPipeline(helper->getPipeline()); commandBuffer->bindPipeline(bindPoint, helper->getPipeline());
} }
if (descriptorSet != VK_NULL_HANDLE) if (descriptorSet != VK_NULL_HANDLE)
...@@ -657,7 +657,9 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk, ...@@ -657,7 +657,9 @@ angle::Result UtilsVk::clearImage(ContextVk *contextVk,
ANGLE_TRY(setupProgram(contextVk, Function::ImageClear, fragmentShader, vertexShader, ANGLE_TRY(setupProgram(contextVk, Function::ImageClear, fragmentShader, vertexShader,
&mImageClearProgram, &pipelineDesc, VK_NULL_HANDLE, &shaderParams, &mImageClearProgram, &pipelineDesc, VK_NULL_HANDLE, &shaderParams,
sizeof(shaderParams), commandBuffer)); sizeof(shaderParams), commandBuffer));
commandBuffer->draw(6, 0);
commandBuffer->draw(6, 1, 0, 0);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -781,7 +783,9 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk, ...@@ -781,7 +783,9 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
ANGLE_TRY(setupProgram(contextVk, Function::ImageCopy, fragmentShader, vertexShader, ANGLE_TRY(setupProgram(contextVk, Function::ImageCopy, fragmentShader, vertexShader,
&mImageCopyPrograms[flags], &pipelineDesc, descriptorSet, &shaderParams, &mImageCopyPrograms[flags], &pipelineDesc, descriptorSet, &shaderParams,
sizeof(shaderParams), commandBuffer)); sizeof(shaderParams), commandBuffer));
commandBuffer->draw(6, 0);
commandBuffer->draw(6, 1, 0, 0);
descriptorPoolBinding.reset(); descriptorPoolBinding.reset();
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -1064,7 +1064,7 @@ void LineLoopHelper::Draw(uint32_t count, CommandBufferT *commandBuffer) ...@@ -1064,7 +1064,7 @@ void LineLoopHelper::Draw(uint32_t count, CommandBufferT *commandBuffer)
{ {
// Our first index is always 0 because that's how we set it up in createIndexBuffer*. // Our first index is always 0 because that's how we set it up in createIndexBuffer*.
// Note: this could theoretically overflow and wrap to zero. // Note: this could theoretically overflow and wrap to zero.
commandBuffer->drawIndexed(count + 1); commandBuffer->drawIndexed(count + 1, 1, 0, 0, 0);
} }
// BufferHelper implementation. // BufferHelper implementation.
...@@ -1603,8 +1603,9 @@ void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask, ...@@ -1603,8 +1603,9 @@ void ImageHelper::forceChangeLayoutAndQueue(VkImageAspectFlags aspectMask,
imageMemoryBarrier.subresourceRange.baseArrayLayer = 0; imageMemoryBarrier.subresourceRange.baseArrayLayer = 0;
imageMemoryBarrier.subresourceRange.layerCount = mLayerCount; imageMemoryBarrier.subresourceRange.layerCount = mLayerCount;
commandBuffer->imageBarrier(transitionFrom.srcStageMask, transitionTo.dstStageMask, commandBuffer->pipelineBarrier(transitionFrom.srcStageMask, transitionTo.dstStageMask, 0, 0,
&imageMemoryBarrier); nullptr, 0, nullptr, 1, &imageMemoryBarrier);
mCurrentLayout = newLayout; mCurrentLayout = newLayout;
mCurrentQueueFamilyIndex = newQueueFamilyIndex; mCurrentQueueFamilyIndex = newQueueFamilyIndex;
} }
...@@ -1613,6 +1614,7 @@ void ImageHelper::clearColor(const VkClearColorValue &color, ...@@ -1613,6 +1614,7 @@ void ImageHelper::clearColor(const VkClearColorValue &color,
uint32_t baseMipLevel, uint32_t baseMipLevel,
uint32_t levelCount, uint32_t levelCount,
CommandBufferT *commandBuffer) CommandBufferT *commandBuffer)
{ {
clearColorLayer(color, baseMipLevel, levelCount, 0, mLayerCount, commandBuffer); clearColorLayer(color, baseMipLevel, levelCount, 0, mLayerCount, commandBuffer);
} }
...@@ -1736,8 +1738,10 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint ...@@ -1736,8 +1738,10 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
// We can do it for all layers at once. // We can do it for all layers at once.
commandBuffer->imageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, commandBuffer->pipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1,
&barrier); &barrier);
VkImageBlit blit = {}; VkImageBlit blit = {};
blit.srcOffsets[0] = {0, 0, 0}; blit.srcOffsets[0] = {0, 0, 0};
blit.srcOffsets[1] = {mipWidth, mipHeight, 1}; blit.srcOffsets[1] = {mipWidth, mipHeight, 1};
...@@ -1766,8 +1770,9 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint ...@@ -1766,8 +1770,9 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
// We can do it for all layers at once. // We can do it for all layers at once.
commandBuffer->imageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, commandBuffer->pipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
&barrier); 0, 0, nullptr, 0, nullptr, 1, &barrier);
// This is just changing the internal state of the image helper so that the next call // This is just changing the internal state of the image helper so that the next call
// to changeLayout will use this layout as the "oldLayout" argument. // to changeLayout will use this layout as the "oldLayout" argument.
mCurrentLayout = ImageLayout::TransferSrc; mCurrentLayout = ImageLayout::TransferSrc;
......
...@@ -626,7 +626,6 @@ class ImageHelper final : public CommandGraphResource ...@@ -626,7 +626,6 @@ class ImageHelper final : public CommandGraphResource
VkImageAspectFlags clearAspectFlags, VkImageAspectFlags clearAspectFlags,
const VkClearDepthStencilValue &depthStencil, const VkClearDepthStencilValue &depthStencil,
CommandBufferT *commandBuffer); CommandBufferT *commandBuffer);
gl::Extents getSize(const gl::ImageIndex &index) const; gl::Extents getSize(const gl::ImageIndex &index) const;
static void Copy(ImageHelper *srcImage, static void Copy(ImageHelper *srcImage,
......
...@@ -180,9 +180,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer> ...@@ -180,9 +180,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
const VkBufferMemoryBarrier *bufferMemoryBarriers, const VkBufferMemoryBarrier *bufferMemoryBarriers,
uint32_t imageMemoryBarrierCount, uint32_t imageMemoryBarrierCount,
const VkImageMemoryBarrier *imageMemoryBarriers); const VkImageMemoryBarrier *imageMemoryBarriers);
void imageBarrier(VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
VkImageMemoryBarrier *imageMemoryBarrier);
void clearColorImage(const Image &image, void clearColorImage(const Image &image,
VkImageLayout imageLayout, VkImageLayout imageLayout,
const VkClearColorValue &color, const VkClearColorValue &color,
...@@ -228,21 +226,16 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer> ...@@ -228,21 +226,16 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
uint32_t instanceCount, uint32_t instanceCount,
uint32_t firstVertex, uint32_t firstVertex,
uint32_t firstInstance); uint32_t firstInstance);
void draw(uint32_t vertexCount, uint32_t firstVertex);
void drawInstanced(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex);
void drawIndexed(uint32_t indexCount, void drawIndexed(uint32_t indexCount,
uint32_t instanceCount, uint32_t instanceCount,
uint32_t firstIndex, uint32_t firstIndex,
int32_t vertexOffset, int32_t vertexOffset,
uint32_t firstInstance); uint32_t firstInstance);
void drawIndexed(uint32_t indexCount);
void drawIndexedInstanced(uint32_t indexCount, uint32_t instanceCount);
void dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); void dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
void bindPipeline(VkPipelineBindPoint pipelineBindPoint, const Pipeline &pipeline); void bindPipeline(VkPipelineBindPoint pipelineBindPoint, const Pipeline &pipeline);
void bindGraphicsPipeline(const Pipeline &pipeline);
void bindComputePipeline(const Pipeline &pipeline);
void bindVertexBuffers(uint32_t firstBinding, void bindVertexBuffers(uint32_t firstBinding,
uint32_t bindingCount, uint32_t bindingCount,
...@@ -580,15 +573,6 @@ ANGLE_INLINE void CommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMa ...@@ -580,15 +573,6 @@ ANGLE_INLINE void CommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMa
imageMemoryBarrierCount, imageMemoryBarriers); imageMemoryBarrierCount, imageMemoryBarriers);
} }
ANGLE_INLINE void CommandBuffer::imageBarrier(VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
VkImageMemoryBarrier *imageMemoryBarrier)
{
ASSERT(valid());
vkCmdPipelineBarrier(mHandle, srcStageMask, dstStageMask, 0, 0, nullptr, 0, nullptr, 1,
imageMemoryBarrier);
}
ANGLE_INLINE void CommandBuffer::destroy(VkDevice device) ANGLE_INLINE void CommandBuffer::destroy(VkDevice device)
{ {
releaseHandle(); releaseHandle();
...@@ -824,20 +808,6 @@ ANGLE_INLINE void CommandBuffer::draw(uint32_t vertexCount, ...@@ -824,20 +808,6 @@ ANGLE_INLINE void CommandBuffer::draw(uint32_t vertexCount,
vkCmdDraw(mHandle, vertexCount, instanceCount, firstVertex, firstInstance); vkCmdDraw(mHandle, vertexCount, instanceCount, firstVertex, firstInstance);
} }
ANGLE_INLINE void CommandBuffer::draw(uint32_t vertexCount, uint32_t firstVertex)
{
ASSERT(valid());
vkCmdDraw(mHandle, vertexCount, 1, firstVertex, 0);
}
ANGLE_INLINE void CommandBuffer::drawInstanced(uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex)
{
ASSERT(valid());
vkCmdDraw(mHandle, vertexCount, instanceCount, firstVertex, 0);
}
ANGLE_INLINE void CommandBuffer::drawIndexed(uint32_t indexCount, ANGLE_INLINE void CommandBuffer::drawIndexed(uint32_t indexCount,
uint32_t instanceCount, uint32_t instanceCount,
uint32_t firstIndex, uint32_t firstIndex,
...@@ -848,18 +818,6 @@ ANGLE_INLINE void CommandBuffer::drawIndexed(uint32_t indexCount, ...@@ -848,18 +818,6 @@ ANGLE_INLINE void CommandBuffer::drawIndexed(uint32_t indexCount,
vkCmdDrawIndexed(mHandle, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); vkCmdDrawIndexed(mHandle, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
} }
ANGLE_INLINE void CommandBuffer::drawIndexed(uint32_t indexCount)
{
ASSERT(valid());
vkCmdDrawIndexed(mHandle, indexCount, 1, 0, 0, 0);
}
ANGLE_INLINE void CommandBuffer::drawIndexedInstanced(uint32_t indexCount, uint32_t instanceCount)
{
ASSERT(valid());
vkCmdDrawIndexed(mHandle, indexCount, instanceCount, 0, 0, 0);
}
ANGLE_INLINE void CommandBuffer::dispatch(uint32_t groupCountX, ANGLE_INLINE void CommandBuffer::dispatch(uint32_t groupCountX,
uint32_t groupCountY, uint32_t groupCountY,
uint32_t groupCountZ) uint32_t groupCountZ)
...@@ -875,18 +833,6 @@ ANGLE_INLINE void CommandBuffer::bindPipeline(VkPipelineBindPoint pipelineBindPo ...@@ -875,18 +833,6 @@ ANGLE_INLINE void CommandBuffer::bindPipeline(VkPipelineBindPoint pipelineBindPo
vkCmdBindPipeline(mHandle, pipelineBindPoint, pipeline.getHandle()); vkCmdBindPipeline(mHandle, pipelineBindPoint, pipeline.getHandle());
} }
ANGLE_INLINE void CommandBuffer::bindGraphicsPipeline(const Pipeline &pipeline)
{
ASSERT(valid() && pipeline.valid());
vkCmdBindPipeline(mHandle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.getHandle());
}
ANGLE_INLINE void CommandBuffer::bindComputePipeline(const Pipeline &pipeline)
{
ASSERT(valid() && pipeline.valid());
vkCmdBindPipeline(mHandle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline.getHandle());
}
ANGLE_INLINE void CommandBuffer::bindVertexBuffers(uint32_t firstBinding, ANGLE_INLINE void CommandBuffer::bindVertexBuffers(uint32_t firstBinding,
uint32_t bindingCount, uint32_t bindingCount,
const VkBuffer *buffers, const VkBuffer *buffers,
......
...@@ -1404,8 +1404,6 @@ TEST_P(SimpleStateChangeTest, RedefineBufferInUse) ...@@ -1404,8 +1404,6 @@ TEST_P(SimpleStateChangeTest, RedefineBufferInUse)
// Tests updating a buffer's contents while in use, without redefining it. // Tests updating a buffer's contents while in use, without redefining it.
TEST_P(SimpleStateChangeTest, UpdateBufferInUse) TEST_P(SimpleStateChangeTest, UpdateBufferInUse)
{ {
// tobine: Started failing w/ custom cmd buffers. http://anglebug.com/3255
ANGLE_SKIP_TEST_IF(IsAMD() && IsWindows() && IsVulkan());
std::vector<GLColor> redColorData(6, GLColor::red); std::vector<GLColor> redColorData(6, GLColor::red);
GLBuffer buffer; GLBuffer buffer;
......
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