Commit 27780295 by Yuly Novikov Committed by Commit Bot

Vulkan: refactor WrappedObject descendants

Methods receive VkDevice instead of Context and return VkResult instead of angle::Result now. Bug: angleproject:2657 Change-Id: I3eca8692ad0b3b6e96e31fd433ed14e04384990e Reviewed-on: https://chromium-review.googlesource.com/c/1330105Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
parent 0864a7ac
......@@ -116,8 +116,10 @@ angle::Result BufferVk::map(const gl::Context *context, GLenum access, void **ma
angle::Result BufferVk::mapImpl(ContextVk *contextVk, void **mapPtr)
{
return mBuffer.getDeviceMemory().map(contextVk, 0, mState.getSize(), 0,
reinterpret_cast<uint8_t **>(mapPtr));
ANGLE_VK_TRY(contextVk,
mBuffer.getDeviceMemory().map(contextVk->getDevice(), 0, mState.getSize(), 0,
reinterpret_cast<uint8_t **>(mapPtr)));
return angle::Result::Continue();
}
GLint64 BufferVk::getSize()
......@@ -135,8 +137,9 @@ angle::Result BufferVk::mapRange(const gl::Context *context,
ContextVk *contextVk = vk::GetImpl(context);
return mBuffer.getDeviceMemory().map(contextVk, offset, length, 0,
reinterpret_cast<uint8_t **>(mapPtr));
ANGLE_VK_TRY(contextVk, mBuffer.getDeviceMemory().map(contextVk->getDevice(), offset, length, 0,
reinterpret_cast<uint8_t **>(mapPtr)));
return angle::Result::Continue();
}
angle::Result BufferVk::unmap(const gl::Context *context, GLboolean *result)
......@@ -181,8 +184,8 @@ angle::Result BufferVk::getIndexRange(const gl::Context *context,
const gl::Type &typeInfo = gl::GetTypeInfo(type);
uint8_t *mapPointer = nullptr;
ANGLE_TRY(
mBuffer.getDeviceMemory().map(contextVk, offset, typeInfo.bytes * count, 0, &mapPointer));
ANGLE_VK_TRY(contextVk, mBuffer.getDeviceMemory().map(contextVk->getDevice(), offset,
typeInfo.bytes * count, 0, &mapPointer));
*outRange = gl::ComputeIndexRange(type, mapPointer, count, primitiveRestartEnabled);
......@@ -206,7 +209,8 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
vk::StagingUsage::Write));
uint8_t *mapPointer = nullptr;
ANGLE_TRY(stagingBuffer.getDeviceMemory().map(contextVk, 0, size, 0, &mapPointer));
ANGLE_VK_TRY(contextVk,
stagingBuffer.getDeviceMemory().map(device, 0, size, 0, &mapPointer));
ASSERT(mapPointer);
memcpy(mapPointer, data, size);
......@@ -222,7 +226,8 @@ angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
else
{
uint8_t *mapPointer = nullptr;
ANGLE_TRY(mBuffer.getDeviceMemory().map(contextVk, offset, size, 0, &mapPointer));
ANGLE_VK_TRY(contextVk,
mBuffer.getDeviceMemory().map(device, offset, size, 0, &mapPointer));
ASSERT(mapPointer);
memcpy(mapPointer, data, size);
......
......@@ -38,14 +38,14 @@ angle::Result InitAndBeginCommandBuffer(vk::Context *context,
createInfo.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY;
createInfo.commandBufferCount = 1;
ANGLE_TRY(commandBuffer->init(context, createInfo));
ANGLE_VK_TRY(context, commandBuffer->init(context->getDevice(), createInfo));
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = flags | VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
beginInfo.pInheritanceInfo = &inheritanceInfo;
ANGLE_TRY(commandBuffer->begin(context, beginInfo));
ANGLE_VK_TRY(context, commandBuffer->begin(beginInfo));
return angle::Result::Continue();
}
......@@ -505,7 +505,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
if (mOutsideRenderPassCommands.valid())
{
ANGLE_TRY(mOutsideRenderPassCommands.end(context));
ANGLE_VK_TRY(context, mOutsideRenderPassCommands.end());
primaryCommandBuffer->executeCommands(1, &mOutsideRenderPassCommands);
}
......@@ -517,7 +517,7 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context,
ANGLE_TRY(renderPassCache->getCompatibleRenderPass(context, serial, mRenderPassDesc,
&renderPass));
ANGLE_TRY(mInsideRenderPassCommands.end(context));
ANGLE_VK_TRY(context, mInsideRenderPassCommands.end());
VkRenderPassBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
......@@ -658,7 +658,7 @@ angle::Result CommandGraph::submitCommands(Context *context,
primaryInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
primaryInfo.commandBufferCount = 1;
ANGLE_TRY(primaryCommandBufferOut->init(context, primaryInfo));
ANGLE_VK_TRY(context, primaryCommandBufferOut->init(context->getDevice(), primaryInfo));
if (mEnableGraphDiagnostics)
{
......@@ -672,7 +672,7 @@ angle::Result CommandGraph::submitCommands(Context *context,
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
beginInfo.pInheritanceInfo = nullptr;
ANGLE_TRY(primaryCommandBufferOut->begin(context, beginInfo));
ANGLE_VK_TRY(context, primaryCommandBufferOut->begin(beginInfo));
ANGLE_TRY(context->getRenderer()->traceGpuEvent(
context, primaryCommandBufferOut, TRACE_EVENT_PHASE_BEGIN, "Primary Command Buffer"));
......@@ -713,7 +713,7 @@ angle::Result CommandGraph::submitCommands(Context *context,
ANGLE_TRY(context->getRenderer()->traceGpuEvent(
context, primaryCommandBufferOut, TRACE_EVENT_PHASE_END, "Primary Command Buffer"));
ANGLE_TRY(primaryCommandBufferOut->end(context));
ANGLE_VK_TRY(context, primaryCommandBufferOut->end());
// TODO(jmadill): Use pool allocation so we don't need to deallocate command graph.
for (CommandGraphNode *node : mNodes)
......
......@@ -445,7 +445,8 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
uniformBufferInfo.queueFamilyIndexCount = 0;
uniformBufferInfo.pQueueFamilyIndices = nullptr;
ANGLE_TRY(mEmptyUniformBlockStorage.buffer.init(contextVk, uniformBufferInfo));
ANGLE_VK_TRY(contextVk, mEmptyUniformBlockStorage.buffer.init(contextVk->getDevice(),
uniformBufferInfo));
// Assume host visible/coherent memory available.
VkMemoryPropertyFlags flags =
......
......@@ -135,18 +135,17 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
VkQueryResultFlags flags = (wait ? VK_QUERY_RESULT_WAIT_BIT : 0) | VK_QUERY_RESULT_64_BIT;
angle::Result result = mQueryHelper.getQueryPool()->getResults(
contextVk, mQueryHelper.getQuery(), 1, sizeof(mCachedResult), &mCachedResult,
VkResult result = mQueryHelper.getQueryPool()->getResults(
contextVk->getDevice(), mQueryHelper.getQuery(), 1, sizeof(mCachedResult), &mCachedResult,
sizeof(mCachedResult), flags);
ANGLE_TRY(result);
// If the results are not ready, do nothing. mCachedResultValid remains false.
if (result == angle::Result::Incomplete())
if (result == VK_NOT_READY)
{
// If VK_QUERY_RESULT_WAIT_BIT was given, Incomplete() cannot have been returned.
// If VK_QUERY_RESULT_WAIT_BIT was given, VK_NOT_READY cannot have been returned.
ASSERT(!wait);
return angle::Result::Continue();
}
ANGLE_VK_TRY(contextVk, result);
// Fix up the results to what OpenGL expects.
switch (getType())
......@@ -163,13 +162,12 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
uint64_t timeElapsedEnd = mCachedResult;
result = mQueryHelperTimeElapsedBegin.getQueryPool()->getResults(
contextVk, mQueryHelperTimeElapsedBegin.getQuery(), 1, sizeof(mCachedResult),
&mCachedResult, sizeof(mCachedResult), flags);
ANGLE_TRY(result);
contextVk->getDevice(), mQueryHelperTimeElapsedBegin.getQuery(), 1,
sizeof(mCachedResult), &mCachedResult, sizeof(mCachedResult), flags);
// Since the result of the end query of time-elapsed is already available, the
// result of begin query must be available too.
ASSERT(result != angle::Result::Incomplete());
ASSERT(result != VK_NOT_READY);
ANGLE_VK_TRY(contextVk, result);
mCachedResult = timeElapsedEnd - mCachedResult;
break;
......
......@@ -621,7 +621,7 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF
commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
commandPoolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex;
ANGLE_TRY(mCommandPool.init(displayVk, commandPoolInfo));
ANGLE_VK_TRY(displayVk, mCommandPool.init(mDevice, commandPoolInfo));
// Initialize the vulkan pipeline cache.
ANGLE_TRY(initPipelineCacheVk(displayVk));
......@@ -790,7 +790,7 @@ angle::Result RendererVk::initPipelineCacheVk(DisplayVk *display)
pipelineCacheCreateInfo.initialDataSize = success ? initialData.size() : 0;
pipelineCacheCreateInfo.pInitialData = success ? initialData.data() : nullptr;
ANGLE_TRY(mPipelineCacheVk.init(display, pipelineCacheCreateInfo));
ANGLE_VK_TRY(display, mPipelineCacheVk.init(mDevice, pipelineCacheCreateInfo));
return angle::Result::Continue();
}
......@@ -940,10 +940,12 @@ angle::Result RendererVk::checkCompletedCommands(vk::Context *context)
for (CommandBatch &batch : mInFlightCommands)
{
angle::Result result = batch.fence.getStatus(context);
ANGLE_TRY(result);
if (result == angle::Result::Incomplete())
VkResult result = batch.fence.getStatus(mDevice);
if (result == VK_NOT_READY)
{
break;
}
ANGLE_VK_TRY(context, result);
ASSERT(batch.serial > mLastCompletedQueueSerial);
mLastCompletedQueueSerial = batch.serial;
......@@ -981,7 +983,7 @@ angle::Result RendererVk::submitFrame(vk::Context *context,
vk::Scoped<CommandBatch> scopedBatch(mDevice);
CommandBatch &batch = scopedBatch.get();
ANGLE_TRY(batch.fence.init(context, fenceInfo));
ANGLE_VK_TRY(context, batch.fence.init(mDevice, fenceInfo));
ANGLE_VK_TRY(context, vkQueueSubmit(mQueue, 1, &submitInfo, batch.fence.getHandle()));
......@@ -1018,7 +1020,8 @@ angle::Result RendererVk::submitFrame(vk::Context *context,
poolInfo.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
poolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex;
return mCommandPool.init(context, poolInfo);
ANGLE_VK_TRY(context, mCommandPool.init(mDevice, poolInfo));
return angle::Result::Continue();
}
bool RendererVk::isSerialInUse(Serial serial) const
......@@ -1048,13 +1051,8 @@ angle::Result RendererVk::finishToSerial(vk::Context *context, Serial serial)
// Wait for it finish
constexpr uint64_t kMaxFenceWaitTimeNs = 10'000'000'000llu;
angle::Result result = batch.fence.wait(context, kMaxFenceWaitTimeNs);
if (result == angle::Result::Incomplete())
{
// Wait a maximum of 10s. If that times out, we declare it a failure.
result = angle::Result::Stop();
}
ANGLE_TRY(result);
// Wait a maximum of 10s. If that times out, we declare it a failure.
ANGLE_VK_TRY(context, batch.fence.wait(mDevice, kMaxFenceWaitTimeNs));
// Clean up finished batches.
return checkCompletedCommands(context);
......@@ -1182,21 +1180,23 @@ angle::Result RendererVk::syncPipelineCacheVk(DisplayVk *displayVk)
// Get the size of the cache.
size_t pipelineCacheSize = 0;
ANGLE_TRY(mPipelineCacheVk.getCacheData(displayVk, &pipelineCacheSize, nullptr));
VkResult result = mPipelineCacheVk.getCacheData(mDevice, &pipelineCacheSize, nullptr);
if (result != VK_INCOMPLETE)
{
ANGLE_VK_TRY(displayVk, result);
}
angle::MemoryBuffer *pipelineCacheData = nullptr;
ANGLE_VK_CHECK_ALLOC(displayVk,
displayVk->getScratchBuffer(pipelineCacheSize, &pipelineCacheData));
size_t originalPipelineCacheSize = pipelineCacheSize;
angle::Result result =
mPipelineCacheVk.getCacheData(displayVk, &pipelineCacheSize, pipelineCacheData->data());
ANGLE_TRY(result);
result = mPipelineCacheVk.getCacheData(mDevice, &pipelineCacheSize, pipelineCacheData->data());
// Note: currently we don't accept incomplete as we don't expect it (the full size of cache
// was determined just above), so receiving it hints at an implementation bug we would want
// to know about early.
ASSERT(result != angle::Result::Incomplete());
ASSERT(result != VK_INCOMPLETE);
ANGLE_VK_TRY(displayVk, result);
// If vkGetPipelineCacheData ends up writing fewer bytes than requested, zero out the rest of
// the buffer to avoid leaking garbage memory.
......@@ -1282,14 +1282,14 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
commandBufferInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
commandBufferInfo.commandBufferCount = 1;
ANGLE_TRY(commandBuffer.init(context, commandBufferInfo));
ANGLE_VK_TRY(context, commandBuffer.init(mDevice, commandBufferInfo));
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = 0;
beginInfo.pInheritanceInfo = nullptr;
ANGLE_TRY(commandBuffer.begin(context, beginInfo));
ANGLE_VK_TRY(context, commandBuffer.begin(beginInfo));
commandBuffer.resetQueryPool(timestampQuery.getQueryPool()->getHandle(),
timestampQuery.getQuery(), 1);
......@@ -1297,7 +1297,7 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
timestampQuery.getQueryPool()->getHandle(),
timestampQuery.getQuery());
ANGLE_TRY(commandBuffer.end(context));
ANGLE_VK_TRY(context, commandBuffer.end());
// Create fence for the submission
VkFenceCreateInfo fenceInfo = {};
......@@ -1305,7 +1305,7 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
fenceInfo.flags = 0;
vk::Scoped<vk::Fence> fence(mDevice);
ANGLE_TRY(fence.get().init(context, fenceInfo));
ANGLE_VK_TRY(context, fence.get().init(mDevice, fenceInfo));
// Submit the command buffer
VkSubmitInfo submitInfo = {};
......@@ -1322,21 +1322,16 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
// Wait for the submission to finish. Given no semaphores, there is hope that it would execute
// in parallel with what's already running on the GPU.
// Declare it a failure if it times out.
constexpr uint64_t kMaxFenceWaitTimeNs = 10'000'000'000llu;
angle::Result result = fence.get().wait(context, kMaxFenceWaitTimeNs);
if (result == angle::Result::Incomplete())
{
// Declare it a failure if it times out.
result = angle::Result::Stop();
}
ANGLE_TRY(result);
ANGLE_VK_TRY(context, fence.get().wait(mDevice, kMaxFenceWaitTimeNs));
// Get the query results
constexpr VkQueryResultFlags queryFlags = VK_QUERY_RESULT_WAIT_BIT | VK_QUERY_RESULT_64_BIT;
ANGLE_TRY(timestampQuery.getQueryPool()->getResults(context, timestampQuery.getQuery(), 1,
sizeof(*timestampOut), timestampOut,
sizeof(*timestampOut), queryFlags));
ANGLE_VK_TRY(context, timestampQuery.getQueryPool()->getResults(
mDevice, timestampQuery.getQuery(), 1, sizeof(*timestampOut),
timestampOut, sizeof(*timestampOut), queryFlags));
timestampQueryPool.get().freeQuery(context, &timestampQuery);
......@@ -1430,9 +1425,9 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
eventCreateInfo.flags = 0;
vk::Scoped<vk::Event> cpuReady(mDevice), gpuReady(mDevice), gpuDone(mDevice);
ANGLE_TRY(cpuReady.get().init(context, eventCreateInfo));
ANGLE_TRY(gpuReady.get().init(context, eventCreateInfo));
ANGLE_TRY(gpuDone.get().init(context, eventCreateInfo));
ANGLE_VK_TRY(context, cpuReady.get().init(mDevice, eventCreateInfo));
ANGLE_VK_TRY(context, gpuReady.get().init(mDevice, eventCreateInfo));
ANGLE_VK_TRY(context, gpuDone.get().init(mDevice, eventCreateInfo));
constexpr uint32_t kRetries = 10;
......@@ -1443,9 +1438,9 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
for (uint32_t i = 0; i < kRetries; ++i)
{
// Reset the events
ANGLE_TRY(cpuReady.get().reset(context));
ANGLE_TRY(gpuReady.get().reset(context));
ANGLE_TRY(gpuDone.get().reset(context));
ANGLE_VK_TRY(context, cpuReady.get().reset(mDevice));
ANGLE_VK_TRY(context, gpuReady.get().reset(mDevice));
ANGLE_VK_TRY(context, gpuDone.get().reset(mDevice));
// Record the command buffer
vk::Scoped<vk::CommandBuffer> commandBatch(mDevice);
......@@ -1457,14 +1452,14 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
commandBufferInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
commandBufferInfo.commandBufferCount = 1;
ANGLE_TRY(commandBuffer.init(context, commandBufferInfo));
ANGLE_VK_TRY(context, commandBuffer.init(mDevice, commandBufferInfo));
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = 0;
beginInfo.pInheritanceInfo = nullptr;
ANGLE_TRY(commandBuffer.begin(context, beginInfo));
ANGLE_VK_TRY(context, commandBuffer.begin(beginInfo));
commandBuffer.setEvent(gpuReady.get(), VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT);
commandBuffer.waitEvents(1, cpuReady.get().ptr(), VK_PIPELINE_STAGE_HOST_BIT,
......@@ -1479,7 +1474,7 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
commandBuffer.setEvent(gpuDone.get(), VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT);
ANGLE_TRY(commandBuffer.end(context));
ANGLE_VK_TRY(context, commandBuffer.end());
// Submit the command buffer
angle::FixedVector<VkSemaphore, kMaxWaitSemaphores> waitSemaphores;
......@@ -1499,25 +1494,31 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
ANGLE_TRY(submitFrame(context, submitInfo, std::move(commandBuffer)));
// Wait for GPU to be ready. This is a short busy wait.
angle::Result result = angle::Result::Incomplete();
VkResult result = VK_EVENT_RESET;
do
{
result = gpuReady.get().getStatus(context);
ANGLE_TRY(result);
} while (result == angle::Result::Incomplete());
result = gpuReady.get().getStatus(mDevice);
if (result != VK_EVENT_SET && result != VK_EVENT_RESET)
{
ANGLE_VK_TRY(context, result);
}
} while (result == VK_EVENT_RESET);
double TsS = platform->monotonicallyIncreasingTime(platform);
// Tell the GPU to go ahead with the timestamp query.
ANGLE_TRY(cpuReady.get().set(context));
ANGLE_VK_TRY(context, cpuReady.get().set(mDevice));
double cpuTimestampS = platform->monotonicallyIncreasingTime(platform);
// Wait for GPU to be done. Another short busy wait.
do
{
result = gpuDone.get().getStatus(context);
ANGLE_TRY(result);
} while (result == angle::Result::Incomplete());
result = gpuDone.get().getStatus(mDevice);
if (result != VK_EVENT_SET && result != VK_EVENT_RESET)
{
ANGLE_VK_TRY(context, result);
}
} while (result == VK_EVENT_RESET);
double TeS = platform->monotonicallyIncreasingTime(platform);
......@@ -1527,9 +1528,9 @@ angle::Result RendererVk::synchronizeCpuGpuTime(vk::Context *context)
constexpr VkQueryResultFlags queryFlags = VK_QUERY_RESULT_WAIT_BIT | VK_QUERY_RESULT_64_BIT;
uint64_t gpuTimestampCycles = 0;
ANGLE_TRY(timestampQuery.getQueryPool()->getResults(
context, timestampQuery.getQuery(), 1, sizeof(gpuTimestampCycles), &gpuTimestampCycles,
sizeof(gpuTimestampCycles), queryFlags));
ANGLE_VK_TRY(context, timestampQuery.getQueryPool()->getResults(
mDevice, timestampQuery.getQuery(), 1, sizeof(gpuTimestampCycles),
&gpuTimestampCycles, sizeof(gpuTimestampCycles), queryFlags));
// Use the first timestamp queried as origin.
if (mGpuEventTimestampOrigin == 0)
......@@ -1607,16 +1608,15 @@ angle::Result RendererVk::checkCompletedGpuEvents(vk::Context *context)
// See if the results are available.
uint64_t gpuTimestampCycles = 0;
angle::Result result = mGpuEventQueryPool.getQueryPool(eventQuery.queryPoolIndex)
->getResults(context, eventQuery.queryIndex, 1,
sizeof(gpuTimestampCycles), &gpuTimestampCycles,
sizeof(gpuTimestampCycles), VK_QUERY_RESULT_64_BIT);
ANGLE_TRY(result);
if (result == angle::Result::Incomplete())
VkResult result = mGpuEventQueryPool.getQueryPool(eventQuery.queryPoolIndex)
->getResults(mDevice, eventQuery.queryIndex, 1,
sizeof(gpuTimestampCycles), &gpuTimestampCycles,
sizeof(gpuTimestampCycles), VK_QUERY_RESULT_64_BIT);
if (result == VK_NOT_READY)
{
break;
}
ANGLE_VK_TRY(context, result);
mGpuEventQueryPool.freeQuery(context, eventQuery.queryPoolIndex, eventQuery.queryIndex);
......
......@@ -751,7 +751,8 @@ angle::Result WindowSurfaceVk::getCurrentFramebuffer(vk::Context *context,
for (SwapchainImage &swapchainImage : mSwapchainImages)
{
imageViews[0] = swapchainImage.imageView.getHandle();
ANGLE_TRY(swapchainImage.framebuffer.init(context, framebufferInfo));
ANGLE_VK_TRY(context,
swapchainImage.framebuffer.init(context->getDevice(), framebufferInfo));
}
ASSERT(currentFramebuffer.valid());
......
......@@ -996,7 +996,8 @@ angle::Result TextureVk::syncState(const gl::Context *context,
samplerInfo.borderColor = VK_BORDER_COLOR_INT_TRANSPARENT_BLACK;
samplerInfo.unnormalizedCoordinates = VK_FALSE;
return mSampler.init(contextVk, samplerInfo);
ANGLE_VK_TRY(contextVk, mSampler.init(contextVk->getDevice(), samplerInfo));
return angle::Result::Continue();
}
gl::Error TextureVk::setStorageMultisample(const gl::Context *context,
......
......@@ -238,7 +238,7 @@ angle::Result InitializeRenderPassFromDesc(vk::Context *context,
createInfo.dependencyCount = 0;
createInfo.pDependencies = nullptr;
ANGLE_TRY(renderPass->init(context, createInfo));
ANGLE_VK_TRY(context, renderPass->init(context->getDevice(), createInfo));
return angle::Result::Continue();
}
......@@ -666,8 +666,8 @@ angle::Result PipelineDesc::initializePipeline(vk::Context *context,
createInfo.basePipelineHandle = VK_NULL_HANDLE;
createInfo.basePipelineIndex = 0;
ANGLE_TRY(pipelineOut->initGraphics(context, createInfo, pipelineCacheVk));
ANGLE_VK_TRY(context,
pipelineOut->initGraphics(context->getDevice(), createInfo, pipelineCacheVk));
return angle::Result::Continue();
}
......@@ -1235,7 +1235,7 @@ angle::Result DescriptorSetLayoutCache::getDescriptorSetLayout(
createInfo.pBindings = bindings.data();
vk::DescriptorSetLayout newLayout;
ANGLE_TRY(newLayout.init(context, createInfo));
ANGLE_VK_TRY(context, newLayout.init(context->getDevice(), createInfo));
auto insertedItem = mPayload.emplace(desc, vk::SharedDescriptorSetLayout(std::move(newLayout)));
vk::SharedDescriptorSetLayout &insertedLayout = insertedItem.first->second;
......@@ -1319,7 +1319,7 @@ angle::Result PipelineLayoutCache::getPipelineLayout(
createInfo.pPushConstantRanges = pushConstantRanges.data();
vk::PipelineLayout newLayout;
ANGLE_TRY(newLayout.init(context, createInfo));
ANGLE_VK_TRY(context, newLayout.init(context->getDevice(), createInfo));
auto insertedItem = mPayload.emplace(desc, vk::SharedPipelineLayout(std::move(newLayout)));
vk::SharedPipelineLayout &insertedLayout = insertedItem.first->second;
......
......@@ -146,7 +146,7 @@ angle::Result DynamicBuffer::allocate(Context *context,
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = nullptr;
ANGLE_TRY(mBuffer.init(context, createInfo));
ANGLE_VK_TRY(context, mBuffer.init(context->getDevice(), createInfo));
VkMemoryPropertyFlags actualMemoryPropertyFlags = 0;
ANGLE_TRY(AllocateBufferMemory(context, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
......@@ -154,7 +154,7 @@ angle::Result DynamicBuffer::allocate(Context *context,
mHostCoherent = (VK_MEMORY_PROPERTY_HOST_COHERENT_BIT ==
(VK_MEMORY_PROPERTY_HOST_COHERENT_BIT & actualMemoryPropertyFlags));
ANGLE_TRY(mMemory.map(context, 0, mSize, 0, &mMappedMemory));
ANGLE_VK_TRY(context, mMemory.map(context->getDevice(), 0, mSize, 0, &mMappedMemory));
mNextAllocationOffset = 0;
mLastFlushOrInvalidateOffset = 0;
......@@ -315,7 +315,8 @@ angle::Result DescriptorPoolHelper::init(Context *context,
mFreeDescriptorSets = maxSets;
return mDescriptorPool.init(context, descriptorPoolInfo);
ANGLE_VK_TRY(context, mDescriptorPool.init(context->getDevice(), descriptorPoolInfo));
return angle::Result::Continue();
}
void DescriptorPoolHelper::destroy(VkDevice device)
......@@ -337,7 +338,9 @@ angle::Result DescriptorPoolHelper::allocateSets(Context *context,
ASSERT(mFreeDescriptorSets >= descriptorSetCount);
mFreeDescriptorSets -= descriptorSetCount;
return mDescriptorPool.allocateDescriptorSets(context, allocInfo, descriptorSetsOut);
ANGLE_VK_TRY(context, mDescriptorPool.allocateDescriptorSets(context->getDevice(), allocInfo,
descriptorSetsOut));
return angle::Result::Continue();
}
// DynamicDescriptorPool implementation.
......@@ -599,7 +602,7 @@ angle::Result DynamicQueryPool::allocateNewPool(Context *context)
vk::QueryPool queryPool;
ANGLE_TRY(queryPool.init(context, queryPoolInfo));
ANGLE_VK_TRY(context, queryPool.init(context->getDevice(), queryPoolInfo));
return allocateNewEntryPool(context, std::move(queryPool));
}
......@@ -691,7 +694,7 @@ angle::Result DynamicSemaphorePool::allocateNewPool(Context *context)
for (Semaphore &semaphore : newPool)
{
ANGLE_TRY(semaphore.init(context));
ANGLE_VK_TRY(context, semaphore.init(context->getDevice()));
}
// This code is safe as long as the growth of the outer vector in vector<vector<T>> is done by
......@@ -900,7 +903,7 @@ angle::Result BufferHelper::init(ContextVk *contextVk,
const VkBufferCreateInfo &createInfo,
VkMemoryPropertyFlags memoryPropertyFlags)
{
ANGLE_TRY(mBuffer.init(contextVk, createInfo));
ANGLE_VK_TRY(contextVk, mBuffer.init(contextVk->getDevice(), createInfo));
return vk::AllocateBufferMemory(contextVk, memoryPropertyFlags, &mMemoryPropertyFlags, &mBuffer,
&mDeviceMemory);
}
......@@ -1016,7 +1019,7 @@ angle::Result ImageHelper::init(Context *context,
mCurrentLayout = VK_IMAGE_LAYOUT_UNDEFINED;
ANGLE_TRY(mImage.init(context, imageInfo));
ANGLE_VK_TRY(context, mImage.init(context->getDevice(), imageInfo));
return angle::Result::Continue();
}
......@@ -1086,7 +1089,7 @@ angle::Result ImageHelper::initLayerImageView(Context *context,
viewInfo.subresourceRange.baseArrayLayer = baseArrayLayer;
viewInfo.subresourceRange.layerCount = layerCount;
ANGLE_TRY(imageViewOut->init(context, viewInfo));
ANGLE_VK_TRY(context, imageViewOut->init(context->getDevice(), viewInfo));
return angle::Result::Continue();
}
......@@ -1149,7 +1152,7 @@ angle::Result ImageHelper::init2DStaging(Context *context,
imageInfo.pQueueFamilyIndices = nullptr;
imageInfo.initialLayout = mCurrentLayout;
ANGLE_TRY(mImage.init(context, imageInfo));
ANGLE_VK_TRY(context, mImage.init(context->getDevice(), imageInfo));
// Allocate and bind host visible and coherent Image memory.
// TODO(ynovikov): better approach would be to request just visible memory,
......@@ -1455,7 +1458,8 @@ FramebufferHelper::~FramebufferHelper() = default;
angle::Result FramebufferHelper::init(ContextVk *contextVk,
const VkFramebufferCreateInfo &createInfo)
{
return mFramebuffer.init(contextVk, createInfo);
ANGLE_VK_TRY(contextVk, mFramebuffer.init(contextVk->getDevice(), createInfo));
return angle::Result::Continue();
}
void FramebufferHelper::release(RendererVk *renderer)
......
......@@ -114,7 +114,7 @@ angle::Result FindAndAllocateCompatibleMemory(vk::Context *context,
allocInfo.memoryTypeIndex = memoryTypeIndex;
allocInfo.allocationSize = memoryRequirements.size;
ANGLE_TRY(deviceMemoryOut->allocate(context, allocInfo));
ANGLE_VK_TRY(context, deviceMemoryOut->allocate(context->getDevice(), allocInfo));
return angle::Result::Continue();
}
......@@ -134,8 +134,7 @@ angle::Result AllocateBufferOrImageMemory(vk::Context *context,
ANGLE_TRY(FindAndAllocateCompatibleMemory(context, memoryProperties,
requestedMemoryPropertyFlags, memoryPropertyFlagsOut,
memoryRequirements, deviceMemoryOut));
ANGLE_TRY(bufferOrImage->bindMemory(context, *deviceMemoryOut));
ANGLE_VK_TRY(context, bufferOrImage->bindMemory(context->getDevice(), *deviceMemoryOut));
return angle::Result::Continue();
}
......@@ -318,11 +317,10 @@ void CommandPool::destroy(VkDevice device)
}
}
angle::Result CommandPool::init(Context *context, const VkCommandPoolCreateInfo &createInfo)
VkResult CommandPool::init(VkDevice device, const VkCommandPoolCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateCommandPool(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateCommandPool(device, &createInfo, nullptr, &mHandle);
}
// CommandBuffer implementation.
......@@ -337,11 +335,10 @@ VkCommandBuffer CommandBuffer::releaseHandle()
return handle;
}
angle::Result CommandBuffer::init(Context *context, const VkCommandBufferAllocateInfo &createInfo)
VkResult CommandBuffer::init(VkDevice device, const VkCommandBufferAllocateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkAllocateCommandBuffers(context->getDevice(), &createInfo, &mHandle));
return vkAllocateCommandBuffers(device, &createInfo, &mHandle);
}
void CommandBuffer::blitImage(const Image &srcImage,
......@@ -357,22 +354,22 @@ void CommandBuffer::blitImage(const Image &srcImage,
dstImageLayout, regionCount, pRegions, filter);
}
angle::Result CommandBuffer::begin(Context *context, const VkCommandBufferBeginInfo &info)
VkResult CommandBuffer::begin(const VkCommandBufferBeginInfo &info)
{
ASSERT(valid());
ANGLE_VK_TRY_RETURN(context, vkBeginCommandBuffer(mHandle, &info));
return vkBeginCommandBuffer(mHandle, &info);
}
angle::Result CommandBuffer::end(Context *context)
VkResult CommandBuffer::end()
{
ASSERT(valid());
ANGLE_VK_TRY_RETURN(context, vkEndCommandBuffer(mHandle));
return vkEndCommandBuffer(mHandle);
}
angle::Result CommandBuffer::reset(Context *context)
VkResult CommandBuffer::reset()
{
ASSERT(valid());
ANGLE_VK_TRY_RETURN(context, vkResetCommandBuffer(mHandle, 0));
return vkResetCommandBuffer(mHandle, 0);
}
void CommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMask,
......@@ -665,11 +662,10 @@ void Image::destroy(VkDevice device)
}
}
angle::Result Image::init(Context *context, const VkImageCreateInfo &createInfo)
VkResult Image::init(VkDevice device, const VkImageCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateImage(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateImage(device, &createInfo, nullptr, &mHandle);
}
void Image::getMemoryRequirements(VkDevice device, VkMemoryRequirements *requirementsOut) const
......@@ -678,11 +674,10 @@ void Image::getMemoryRequirements(VkDevice device, VkMemoryRequirements *require
vkGetImageMemoryRequirements(device, mHandle, requirementsOut);
}
angle::Result Image::bindMemory(Context *context, const vk::DeviceMemory &deviceMemory)
VkResult Image::bindMemory(VkDevice device, const vk::DeviceMemory &deviceMemory)
{
ASSERT(valid() && deviceMemory.valid());
ANGLE_VK_TRY_RETURN(
context, vkBindImageMemory(context->getDevice(), mHandle, deviceMemory.getHandle(), 0));
return vkBindImageMemory(device, mHandle, deviceMemory.getHandle(), 0);
}
void Image::getSubresourceLayout(VkDevice device,
......@@ -713,10 +708,9 @@ void ImageView::destroy(VkDevice device)
}
}
angle::Result ImageView::init(Context *context, const VkImageViewCreateInfo &createInfo)
VkResult ImageView::init(VkDevice device, const VkImageViewCreateInfo &createInfo)
{
ANGLE_VK_TRY_RETURN(context,
vkCreateImageView(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateImageView(device, &createInfo, nullptr, &mHandle);
}
// Semaphore implementation.
......@@ -733,7 +727,7 @@ void Semaphore::destroy(VkDevice device)
}
}
angle::Result Semaphore::init(Context *context)
VkResult Semaphore::init(VkDevice device)
{
ASSERT(!valid());
......@@ -741,8 +735,7 @@ angle::Result Semaphore::init(Context *context)
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
semaphoreInfo.flags = 0;
ANGLE_VK_TRY_RETURN(context,
vkCreateSemaphore(context->getDevice(), &semaphoreInfo, nullptr, &mHandle));
return vkCreateSemaphore(device, &semaphoreInfo, nullptr, &mHandle);
}
// Framebuffer implementation.
......@@ -759,11 +752,10 @@ void Framebuffer::destroy(VkDevice device)
}
}
angle::Result Framebuffer::init(Context *context, const VkFramebufferCreateInfo &createInfo)
VkResult Framebuffer::init(VkDevice device, const VkFramebufferCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateFramebuffer(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateFramebuffer(device, &createInfo, nullptr, &mHandle);
}
void Framebuffer::setHandle(VkFramebuffer handle)
......@@ -785,22 +777,20 @@ void DeviceMemory::destroy(VkDevice device)
}
}
angle::Result DeviceMemory::allocate(Context *context, const VkMemoryAllocateInfo &allocInfo)
VkResult DeviceMemory::allocate(VkDevice device, const VkMemoryAllocateInfo &allocInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkAllocateMemory(context->getDevice(), &allocInfo, nullptr, &mHandle));
return vkAllocateMemory(device, &allocInfo, nullptr, &mHandle);
}
angle::Result DeviceMemory::map(Context *context,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
uint8_t **mapPointer) const
VkResult DeviceMemory::map(VkDevice device,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
uint8_t **mapPointer) const
{
ASSERT(valid());
ANGLE_VK_TRY_RETURN(context, vkMapMemory(context->getDevice(), mHandle, offset, size, flags,
reinterpret_cast<void **>(mapPointer)));
return vkMapMemory(device, mHandle, offset, size, flags, reinterpret_cast<void **>(mapPointer));
}
void DeviceMemory::unmap(VkDevice device) const
......@@ -823,11 +813,10 @@ void RenderPass::destroy(VkDevice device)
}
}
angle::Result RenderPass::init(Context *context, const VkRenderPassCreateInfo &createInfo)
VkResult RenderPass::init(VkDevice device, const VkRenderPassCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateRenderPass(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateRenderPass(device, &createInfo, nullptr, &mHandle);
}
// Buffer implementation.
......@@ -844,18 +833,16 @@ void Buffer::destroy(VkDevice device)
}
}
angle::Result Buffer::init(Context *context, const VkBufferCreateInfo &createInfo)
VkResult Buffer::init(VkDevice device, const VkBufferCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateBuffer(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateBuffer(device, &createInfo, nullptr, &mHandle);
}
angle::Result Buffer::bindMemory(Context *context, const DeviceMemory &deviceMemory)
VkResult Buffer::bindMemory(VkDevice device, const DeviceMemory &deviceMemory)
{
ASSERT(valid() && deviceMemory.valid());
ANGLE_VK_TRY_RETURN(
context, vkBindBufferMemory(context->getDevice(), mHandle, deviceMemory.getHandle(), 0));
return vkBindBufferMemory(device, mHandle, deviceMemory.getHandle(), 0);
}
void Buffer::getMemoryRequirements(VkDevice device, VkMemoryRequirements *memoryRequirementsOut)
......@@ -878,11 +865,10 @@ void ShaderModule::destroy(VkDevice device)
}
}
angle::Result ShaderModule::init(Context *context, const VkShaderModuleCreateInfo &createInfo)
VkResult ShaderModule::init(VkDevice device, const VkShaderModuleCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateShaderModule(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateShaderModule(device, &createInfo, nullptr, &mHandle);
}
// PipelineLayout implementation.
......@@ -899,11 +885,10 @@ void PipelineLayout::destroy(VkDevice device)
}
}
angle::Result PipelineLayout::init(Context *context, const VkPipelineLayoutCreateInfo &createInfo)
VkResult PipelineLayout::init(VkDevice device, const VkPipelineLayoutCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(
context, vkCreatePipelineLayout(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreatePipelineLayout(device, &createInfo, nullptr, &mHandle);
}
// PipelineCache implementation.
......@@ -920,16 +905,15 @@ void PipelineCache::destroy(VkDevice device)
}
}
angle::Result PipelineCache::init(Context *context, const VkPipelineCacheCreateInfo &createInfo)
VkResult PipelineCache::init(VkDevice device, const VkPipelineCacheCreateInfo &createInfo)
{
ASSERT(!valid());
// Note: if we are concerned with memory usage of this cache, we should give it custom
// allocators. Also, failure of this function is of little importance.
ANGLE_VK_TRY_RETURN(
context, vkCreatePipelineCache(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreatePipelineCache(device, &createInfo, nullptr, &mHandle);
}
angle::Result PipelineCache::getCacheData(Context *context, size_t *cacheSize, void *cacheData)
VkResult PipelineCache::getCacheData(VkDevice device, size_t *cacheSize, void *cacheData)
{
ASSERT(valid());
......@@ -939,8 +923,7 @@ angle::Result PipelineCache::getCacheData(Context *context, size_t *cacheSize, v
// VK_INCOMPLETE in the first case is an expected output. In the second case, VK_INCOMPLETE is
// also acceptable and the resulting buffer will contain valid value by spec. Angle currently
// ensures *cacheSize to be either 0 or of enough size, therefore VK_INCOMPLETE is not expected.
ANGLE_VK_TRY_RETURN_ALLOW_INCOMPLETE(
context, vkGetPipelineCacheData(context->getDevice(), mHandle, cacheSize, cacheData));
return vkGetPipelineCacheData(device, mHandle, cacheSize, cacheData);
}
// Pipeline implementation.
......@@ -957,14 +940,13 @@ void Pipeline::destroy(VkDevice device)
}
}
angle::Result Pipeline::initGraphics(Context *context,
const VkGraphicsPipelineCreateInfo &createInfo,
const PipelineCache &pipelineCacheVk)
VkResult Pipeline::initGraphics(VkDevice device,
const VkGraphicsPipelineCreateInfo &createInfo,
const PipelineCache &pipelineCacheVk)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(
context, vkCreateGraphicsPipelines(context->getDevice(), pipelineCacheVk.getHandle(), 1,
&createInfo, nullptr, &mHandle));
return vkCreateGraphicsPipelines(device, pipelineCacheVk.getHandle(), 1, &createInfo, nullptr,
&mHandle);
}
// DescriptorSetLayout implementation.
......@@ -981,12 +963,11 @@ void DescriptorSetLayout::destroy(VkDevice device)
}
}
angle::Result DescriptorSetLayout::init(Context *context,
const VkDescriptorSetLayoutCreateInfo &createInfo)
VkResult DescriptorSetLayout::init(VkDevice device,
const VkDescriptorSetLayoutCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(
context, vkCreateDescriptorSetLayout(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateDescriptorSetLayout(device, &createInfo, nullptr, &mHandle);
}
// DescriptorPool implementation.
......@@ -1003,30 +984,27 @@ void DescriptorPool::destroy(VkDevice device)
}
}
angle::Result DescriptorPool::init(Context *context, const VkDescriptorPoolCreateInfo &createInfo)
VkResult DescriptorPool::init(VkDevice device, const VkDescriptorPoolCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(
context, vkCreateDescriptorPool(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateDescriptorPool(device, &createInfo, nullptr, &mHandle);
}
angle::Result DescriptorPool::allocateDescriptorSets(Context *context,
const VkDescriptorSetAllocateInfo &allocInfo,
VkDescriptorSet *descriptorSetsOut)
VkResult DescriptorPool::allocateDescriptorSets(VkDevice device,
const VkDescriptorSetAllocateInfo &allocInfo,
VkDescriptorSet *descriptorSetsOut)
{
ASSERT(valid());
ANGLE_VK_TRY_RETURN(
context, vkAllocateDescriptorSets(context->getDevice(), &allocInfo, descriptorSetsOut));
return vkAllocateDescriptorSets(device, &allocInfo, descriptorSetsOut);
}
angle::Result DescriptorPool::freeDescriptorSets(Context *context,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets)
VkResult DescriptorPool::freeDescriptorSets(VkDevice device,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets)
{
ASSERT(valid());
ASSERT(descriptorSetCount > 0);
ANGLE_VK_TRY_RETURN(context, vkFreeDescriptorSets(context->getDevice(), mHandle,
descriptorSetCount, descriptorSets));
return vkFreeDescriptorSets(device, mHandle, descriptorSetCount, descriptorSets);
}
// Sampler implementation.
......@@ -1043,11 +1021,10 @@ void Sampler::destroy(VkDevice device)
}
}
angle::Result Sampler::init(Context *context, const VkSamplerCreateInfo &createInfo)
VkResult Sampler::init(VkDevice device, const VkSamplerCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateSampler(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateSampler(device, &createInfo, nullptr, &mHandle);
}
// Event implementation.
......@@ -1064,26 +1041,25 @@ void Event::destroy(VkDevice device)
}
}
angle::Result Event::init(Context *context, const VkEventCreateInfo &createInfo)
VkResult Event::init(VkDevice device, const VkEventCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateEvent(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateEvent(device, &createInfo, nullptr, &mHandle);
}
angle::Result Event::getStatus(Context *context) const
VkResult Event::getStatus(VkDevice device) const
{
ANGLE_VK_TRY_RETURN_EVENT_STATUS(context, vkGetEventStatus(context->getDevice(), mHandle));
return vkGetEventStatus(device, mHandle);
}
angle::Result Event::set(Context *context) const
VkResult Event::set(VkDevice device) const
{
ANGLE_VK_TRY_RETURN(context, vkSetEvent(context->getDevice(), mHandle));
return vkSetEvent(device, mHandle);
}
angle::Result Event::reset(Context *context) const
VkResult Event::reset(VkDevice device) const
{
ANGLE_VK_TRY_RETURN(context, vkResetEvent(context->getDevice(), mHandle));
return vkResetEvent(device, mHandle);
}
// Fence implementation.
......@@ -1100,22 +1076,20 @@ void Fence::destroy(VkDevice device)
}
}
angle::Result Fence::init(Context *context, const VkFenceCreateInfo &createInfo)
VkResult Fence::init(VkDevice device, const VkFenceCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateFence(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateFence(device, &createInfo, nullptr, &mHandle);
}
angle::Result Fence::getStatus(Context *context) const
VkResult Fence::getStatus(VkDevice device) const
{
ANGLE_VK_TRY_RETURN_ALLOW_NOT_READY(context, vkGetFenceStatus(context->getDevice(), mHandle));
return vkGetFenceStatus(device, mHandle);
}
angle::Result Fence::wait(Context *context, uint64_t timeout) const
VkResult Fence::wait(VkDevice device, uint64_t timeout) const
{
ANGLE_VK_TRY_RETURN_ALLOW_TIMEOUT(
context, vkWaitForFences(context->getDevice(), 1, &mHandle, true, timeout));
return vkWaitForFences(device, 1, &mHandle, true, timeout);
}
// MemoryProperties implementation.
......@@ -1192,7 +1166,7 @@ angle::Result StagingBuffer::init(Context *context, VkDeviceSize size, StagingUs
VkMemoryPropertyFlags flags =
(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
ANGLE_TRY(mBuffer.init(context, createInfo));
ANGLE_VK_TRY(context, mBuffer.init(context->getDevice(), createInfo));
VkMemoryPropertyFlags flagsOut = 0;
ANGLE_TRY(AllocateBufferMemory(context, flags, &flagsOut, &mBuffer, &mDeviceMemory));
mSize = static_cast<size_t>(size);
......@@ -1219,24 +1193,22 @@ void QueryPool::destroy(VkDevice device)
}
}
angle::Result QueryPool::init(Context *context, const VkQueryPoolCreateInfo &createInfo)
VkResult QueryPool::init(VkDevice device, const VkQueryPoolCreateInfo &createInfo)
{
ASSERT(!valid());
ANGLE_VK_TRY_RETURN(context,
vkCreateQueryPool(context->getDevice(), &createInfo, nullptr, &mHandle));
return vkCreateQueryPool(device, &createInfo, nullptr, &mHandle);
}
angle::Result QueryPool::getResults(Context *context,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
void *data,
VkDeviceSize stride,
VkQueryResultFlags flags) const
VkResult QueryPool::getResults(VkDevice device,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
void *data,
VkDeviceSize stride,
VkQueryResultFlags flags) const
{
ANGLE_VK_TRY_RETURN_ALLOW_NOT_READY(
context, vkGetQueryPoolResults(context->getDevice(), mHandle, firstQuery, queryCount,
dataSize, data, stride, flags));
return vkGetQueryPoolResults(device, mHandle, firstQuery, queryCount, dataSize, data, stride,
flags);
}
angle::Result AllocateBufferMemory(vk::Context *context,
......@@ -1270,7 +1242,7 @@ angle::Result InitShaderAndSerial(Context *context,
createInfo.codeSize = shaderCodeSize;
createInfo.pCode = shaderCode;
ANGLE_TRY(shaderAndSerial->get().init(context, createInfo));
ANGLE_VK_TRY(context, shaderAndSerial->get().init(context->getDevice(), createInfo));
shaderAndSerial->updateSerial(context->getRenderer()->issueShaderSerial());
return angle::Result::Continue();
}
......
......@@ -290,7 +290,7 @@ class CommandPool final : public WrappedObject<CommandPool, VkCommandPool>
void destroy(VkDevice device);
angle::Result init(Context *context, const VkCommandPoolCreateInfo &createInfo);
VkResult init(VkDevice device, const VkCommandPoolCreateInfo &createInfo);
};
// Helper class that wraps a Vulkan command buffer.
......@@ -307,7 +307,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
// This is used in conjunction with VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT.
void destroy(VkDevice device, const CommandPool &commandPool);
angle::Result init(Context *context, const VkCommandBufferAllocateInfo &createInfo);
VkResult init(VkDevice device, const VkCommandBufferAllocateInfo &createInfo);
void blitImage(const Image &srcImage,
VkImageLayout srcImageLayout,
const Image &dstImage,
......@@ -317,10 +317,10 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
VkFilter filter);
using WrappedObject::operator=;
angle::Result begin(Context *context, const VkCommandBufferBeginInfo &info);
VkResult begin(const VkCommandBufferBeginInfo &info);
angle::Result end(Context *context);
angle::Result reset(Context *context);
VkResult end();
VkResult reset();
void pipelineBarrier(VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
......@@ -461,10 +461,10 @@ class Image final : public WrappedObject<Image, VkImage>
// Called on shutdown when the helper class *does* own the handle to the image resource.
void destroy(VkDevice device);
angle::Result init(Context *context, const VkImageCreateInfo &createInfo);
VkResult init(VkDevice device, const VkImageCreateInfo &createInfo);
void getMemoryRequirements(VkDevice device, VkMemoryRequirements *requirementsOut) const;
angle::Result bindMemory(Context *context, const DeviceMemory &deviceMemory);
VkResult bindMemory(VkDevice device, const DeviceMemory &deviceMemory);
void getSubresourceLayout(VkDevice device,
VkImageAspectFlagBits aspectMask,
......@@ -479,7 +479,7 @@ class ImageView final : public WrappedObject<ImageView, VkImageView>
ImageView();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkImageViewCreateInfo &createInfo);
VkResult init(VkDevice device, const VkImageViewCreateInfo &createInfo);
};
class Semaphore final : public WrappedObject<Semaphore, VkSemaphore>
......@@ -488,7 +488,7 @@ class Semaphore final : public WrappedObject<Semaphore, VkSemaphore>
Semaphore();
void destroy(VkDevice device);
angle::Result init(Context *context);
VkResult init(VkDevice device);
};
class Framebuffer final : public WrappedObject<Framebuffer, VkFramebuffer>
......@@ -500,7 +500,7 @@ class Framebuffer final : public WrappedObject<Framebuffer, VkFramebuffer>
// Use this method only in necessary cases. (RenderPass)
void setHandle(VkFramebuffer handle);
angle::Result init(Context *context, const VkFramebufferCreateInfo &createInfo);
VkResult init(VkDevice device, const VkFramebufferCreateInfo &createInfo);
};
class DeviceMemory final : public WrappedObject<DeviceMemory, VkDeviceMemory>
......@@ -509,12 +509,12 @@ class DeviceMemory final : public WrappedObject<DeviceMemory, VkDeviceMemory>
DeviceMemory();
void destroy(VkDevice device);
angle::Result allocate(Context *context, const VkMemoryAllocateInfo &allocInfo);
angle::Result map(Context *context,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
uint8_t **mapPointer) const;
VkResult allocate(VkDevice device, const VkMemoryAllocateInfo &allocInfo);
VkResult map(VkDevice device,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
uint8_t **mapPointer) const;
void unmap(VkDevice device) const;
};
......@@ -524,7 +524,7 @@ class RenderPass final : public WrappedObject<RenderPass, VkRenderPass>
RenderPass();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkRenderPassCreateInfo &createInfo);
VkResult init(VkDevice device, const VkRenderPassCreateInfo &createInfo);
};
enum class StagingUsage
......@@ -540,8 +540,8 @@ class Buffer final : public WrappedObject<Buffer, VkBuffer>
Buffer();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkBufferCreateInfo &createInfo);
angle::Result bindMemory(Context *context, const DeviceMemory &deviceMemory);
VkResult init(VkDevice device, const VkBufferCreateInfo &createInfo);
VkResult bindMemory(VkDevice device, const DeviceMemory &deviceMemory);
void getMemoryRequirements(VkDevice device, VkMemoryRequirements *memoryRequirementsOut);
};
......@@ -551,7 +551,7 @@ class ShaderModule final : public WrappedObject<ShaderModule, VkShaderModule>
ShaderModule();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkShaderModuleCreateInfo &createInfo);
VkResult init(VkDevice device, const VkShaderModuleCreateInfo &createInfo);
};
class PipelineLayout final : public WrappedObject<PipelineLayout, VkPipelineLayout>
......@@ -560,7 +560,7 @@ class PipelineLayout final : public WrappedObject<PipelineLayout, VkPipelineLayo
PipelineLayout();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkPipelineLayoutCreateInfo &createInfo);
VkResult init(VkDevice device, const VkPipelineLayoutCreateInfo &createInfo);
};
class PipelineCache final : public WrappedObject<PipelineCache, VkPipelineCache>
......@@ -569,8 +569,8 @@ class PipelineCache final : public WrappedObject<PipelineCache, VkPipelineCache>
PipelineCache();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkPipelineCacheCreateInfo &createInfo);
angle::Result getCacheData(Context *context, size_t *cacheSize, void *cacheData);
VkResult init(VkDevice device, const VkPipelineCacheCreateInfo &createInfo);
VkResult getCacheData(VkDevice device, size_t *cacheSize, void *cacheData);
};
class Pipeline final : public WrappedObject<Pipeline, VkPipeline>
......@@ -579,9 +579,9 @@ class Pipeline final : public WrappedObject<Pipeline, VkPipeline>
Pipeline();
void destroy(VkDevice device);
angle::Result initGraphics(Context *context,
const VkGraphicsPipelineCreateInfo &createInfo,
const PipelineCache &pipelineCacheVk);
VkResult initGraphics(VkDevice device,
const VkGraphicsPipelineCreateInfo &createInfo,
const PipelineCache &pipelineCacheVk);
};
class DescriptorSetLayout final : public WrappedObject<DescriptorSetLayout, VkDescriptorSetLayout>
......@@ -590,7 +590,7 @@ class DescriptorSetLayout final : public WrappedObject<DescriptorSetLayout, VkDe
DescriptorSetLayout();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkDescriptorSetLayoutCreateInfo &createInfo);
VkResult init(VkDevice device, const VkDescriptorSetLayoutCreateInfo &createInfo);
};
class DescriptorPool final : public WrappedObject<DescriptorPool, VkDescriptorPool>
......@@ -599,14 +599,14 @@ class DescriptorPool final : public WrappedObject<DescriptorPool, VkDescriptorPo
DescriptorPool();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkDescriptorPoolCreateInfo &createInfo);
VkResult init(VkDevice device, const VkDescriptorPoolCreateInfo &createInfo);
angle::Result allocateDescriptorSets(Context *context,
const VkDescriptorSetAllocateInfo &allocInfo,
VkDescriptorSet *descriptorSetsOut);
angle::Result freeDescriptorSets(Context *context,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets);
VkResult allocateDescriptorSets(VkDevice device,
const VkDescriptorSetAllocateInfo &allocInfo,
VkDescriptorSet *descriptorSetsOut);
VkResult freeDescriptorSets(VkDevice device,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets);
};
class Sampler final : public WrappedObject<Sampler, VkSampler>
......@@ -614,32 +614,32 @@ class Sampler final : public WrappedObject<Sampler, VkSampler>
public:
Sampler();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkSamplerCreateInfo &createInfo);
VkResult init(VkDevice device, const VkSamplerCreateInfo &createInfo);
};
class Event final : public WrappedObject<Event, VkEvent>
{
public:
Event();
void destroy(VkDevice fence);
void destroy(VkDevice device);
using WrappedObject::operator=;
angle::Result init(Context *context, const VkEventCreateInfo &createInfo);
angle::Result getStatus(Context *context) const;
angle::Result set(Context *context) const;
angle::Result reset(Context *context) const;
VkResult init(VkDevice device, const VkEventCreateInfo &createInfo);
VkResult getStatus(VkDevice device) const;
VkResult set(VkDevice device) const;
VkResult reset(VkDevice device) const;
};
class Fence final : public WrappedObject<Fence, VkFence>
{
public:
Fence();
void destroy(VkDevice fence);
void destroy(VkDevice device);
using WrappedObject::operator=;
angle::Result init(Context *context, const VkFenceCreateInfo &createInfo);
angle::Result getStatus(Context *context) const;
angle::Result wait(Context *context, uint64_t timeout) const;
VkResult init(VkDevice device, const VkFenceCreateInfo &createInfo);
VkResult getStatus(VkDevice device) const;
VkResult wait(VkDevice device, uint64_t timeout) const;
};
// Similar to StagingImage, for Buffers.
......@@ -671,14 +671,14 @@ class QueryPool final : public WrappedObject<QueryPool, VkQueryPool>
QueryPool();
void destroy(VkDevice device);
angle::Result init(Context *context, const VkQueryPoolCreateInfo &createInfo);
angle::Result getResults(Context *context,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
void *data,
VkDeviceSize stride,
VkQueryResultFlags flags) const;
VkResult init(VkDevice device, const VkQueryPoolCreateInfo &createInfo);
VkResult getResults(VkDevice device,
uint32_t firstQuery,
uint32_t queryCount,
size_t dataSize,
void *data,
VkDeviceSize stride,
VkQueryResultFlags flags) const;
};
template <typename ObjT>
......@@ -919,40 +919,6 @@ void GetScissor(const gl::State &glState,
#define ANGLE_VK_CHECK_ALLOC(context, result) \
ANGLE_VK_CHECK(context, result, VK_ERROR_OUT_OF_HOST_MEMORY)
// Macros specifically made for vulkan wrappers (in vk_utils.h) that execute the call and return
// appropriately.
#define ANGLE_VK_TRY_RETURN(context, command) \
do \
{ \
ANGLE_VK_TRY(context, command); \
return angle::Result::Continue(); \
} while (0)
#define ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, success, incomplete) \
do \
{ \
auto ANGLE_LOCAL_VAR = command; \
if (ANGLE_UNLIKELY(ANGLE_LOCAL_VAR != success && ANGLE_LOCAL_VAR != incomplete)) \
{ \
context->handleError(ANGLE_LOCAL_VAR, __FILE__, __LINE__); \
return angle::Result::Stop(); \
} \
return ANGLE_LOCAL_VAR == success ? angle::Result::Continue() \
: angle::Result::Incomplete(); \
} while (0)
#define ANGLE_VK_TRY_RETURN_ALLOW_INCOMPLETE(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_SUCCESS, VK_INCOMPLETE)
#define ANGLE_VK_TRY_RETURN_ALLOW_NOT_READY(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_SUCCESS, VK_NOT_READY)
#define ANGLE_VK_TRY_RETURN_ALLOW_TIMEOUT(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_SUCCESS, VK_TIMEOUT)
#define ANGLE_VK_TRY_RETURN_EVENT_STATUS(context, command) \
ANGLE_VK_TRY_RETURN_ALLOW_OTHER(context, command, VK_EVENT_SET, VK_EVENT_RESET)
#define ANGLE_VK_UNREACHABLE(context) \
UNREACHABLE(); \
ANGLE_VK_CHECK(context, false, VK_ERROR_FEATURE_NOT_PRESENT)
......
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