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;
......
......@@ -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)
......
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