Commit eebe2190 by Jamie Madill Committed by Commit Bot

Vulkan: Clean up Error usage.

* Adds a nodiscard to the Error class. * Fixes the places where Error was discard. * Uses more vk::Error instead of gl::Error. This enables the Vulkan back-end Error refactoring. Bug: angleproject:2713 Change-Id: I09606d965e8b7cfd341ad7fb95cf029b9d694ef4 Reviewed-on: https://chromium-review.googlesource.com/1128922 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent 12222070
...@@ -459,7 +459,7 @@ Error CommandGraphNode::visitAndExecute(VkDevice device, ...@@ -459,7 +459,7 @@ Error CommandGraphNode::visitAndExecute(VkDevice device,
{ {
if (mOutsideRenderPassCommands.valid()) if (mOutsideRenderPassCommands.valid())
{ {
mOutsideRenderPassCommands.end(); ANGLE_TRY(mOutsideRenderPassCommands.end());
primaryCommandBuffer->executeCommands(1, &mOutsideRenderPassCommands); primaryCommandBuffer->executeCommands(1, &mOutsideRenderPassCommands);
} }
...@@ -471,7 +471,7 @@ Error CommandGraphNode::visitAndExecute(VkDevice device, ...@@ -471,7 +471,7 @@ Error CommandGraphNode::visitAndExecute(VkDevice device,
ANGLE_TRY( ANGLE_TRY(
renderPassCache->getCompatibleRenderPass(device, serial, mRenderPassDesc, &renderPass)); renderPassCache->getCompatibleRenderPass(device, serial, mRenderPassDesc, &renderPass));
mInsideRenderPassCommands.end(); ANGLE_TRY(mInsideRenderPassCommands.end());
VkRenderPassBeginInfo beginInfo; VkRenderPassBeginInfo beginInfo;
beginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; beginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
......
...@@ -1052,7 +1052,7 @@ gl::DrawBufferMask FramebufferVk::getEmulatedAlphaAttachmentMask() ...@@ -1052,7 +1052,7 @@ gl::DrawBufferMask FramebufferVk::getEmulatedAlphaAttachmentMask()
return mEmulatedAlphaAttachmentMask; return mEmulatedAlphaAttachmentMask;
} }
gl::Error FramebufferVk::readPixelsImpl(const gl::Context *context, vk::Error FramebufferVk::readPixelsImpl(const gl::Context *context,
const gl::Rectangle &area, const gl::Rectangle &area,
const PackPixelsParams &packPixelsParams, const PackPixelsParams &packPixelsParams,
void *pixels) void *pixels)
...@@ -1082,8 +1082,8 @@ gl::Error FramebufferVk::readPixelsImpl(const gl::Context *context, ...@@ -1082,8 +1082,8 @@ gl::Error FramebufferVk::readPixelsImpl(const gl::Context *context,
uint32_t stagingOffset = 0; uint32_t stagingOffset = 0;
size_t allocationSize = area.width * angleFormat.pixelBytes * area.height; size_t allocationSize = area.width * angleFormat.pixelBytes * area.height;
mReadPixelsBuffer.allocate(renderer, allocationSize, &readPixelBuffer, &bufferHandle, ANGLE_TRY(mReadPixelsBuffer.allocate(renderer, allocationSize, &readPixelBuffer, &bufferHandle,
&stagingOffset, &newBufferAllocated); &stagingOffset, &newBufferAllocated));
VkBufferImageCopy region; VkBufferImageCopy region;
region.bufferImageHeight = area.height; region.bufferImageHeight = area.height;
......
...@@ -94,7 +94,7 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource ...@@ -94,7 +94,7 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
vk::RecordingMode *modeOut); vk::RecordingMode *modeOut);
// Internal helper function for readPixels operations. // Internal helper function for readPixels operations.
gl::Error readPixelsImpl(const gl::Context *context, vk::Error readPixelsImpl(const gl::Context *context,
const gl::Rectangle &area, const gl::Rectangle &area,
const PackPixelsParams &packPixelsParams, const PackPixelsParams &packPixelsParams,
void *pixels); void *pixels);
......
...@@ -816,7 +816,7 @@ vk::Error RendererVk::submitFrame(const VkSubmitInfo &submitInfo, vk::CommandBuf ...@@ -816,7 +816,7 @@ vk::Error RendererVk::submitFrame(const VkSubmitInfo &submitInfo, vk::CommandBuf
poolInfo.flags = 0; poolInfo.flags = 0;
poolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex; poolInfo.queueFamilyIndex = mCurrentQueueFamilyIndex;
mCommandPool.init(mDevice, poolInfo); ANGLE_TRY(mCommandPool.init(mDevice, poolInfo));
return vk::NoError(); return vk::NoError();
} }
......
...@@ -282,7 +282,7 @@ void WindowSurfaceVk::destroy(const egl::Display *display) ...@@ -282,7 +282,7 @@ void WindowSurfaceVk::destroy(const egl::Display *display)
VkInstance instance = renderer->getInstance(); VkInstance instance = renderer->getInstance();
// We might not need to flush the pipe here. // We might not need to flush the pipe here.
renderer->finish(display->getProxyContext()); ANGLE_SWALLOW_ERR(renderer->finish(display->getProxyContext()));
mAcquireNextImageSemaphore.destroy(device); mAcquireNextImageSemaphore.destroy(device);
...@@ -483,8 +483,9 @@ vk::Error WindowSurfaceVk::initializeImpl(RendererVk *renderer) ...@@ -483,8 +483,9 @@ vk::Error WindowSurfaceVk::initializeImpl(RendererVk *renderer)
{ {
SwapchainImage &member = mSwapchainImages[imageIndex]; SwapchainImage &member = mSwapchainImages[imageIndex];
member.image.init2DWeakReference(swapchainImages[imageIndex], extents, format, 1); member.image.init2DWeakReference(swapchainImages[imageIndex], extents, format, 1);
member.image.initImageView(device, gl::TextureType::_2D, VK_IMAGE_ASPECT_COLOR_BIT, ANGLE_TRY(member.image.initImageView(device, gl::TextureType::_2D,
gl::SwizzleState(), &member.imageView, 1); VK_IMAGE_ASPECT_COLOR_BIT, gl::SwizzleState(),
&member.imageView, 1));
// Set transfer dest layout, and clear the image to black. // Set transfer dest layout, and clear the image to black.
member.image.clearColor(transparentBlack, 0, 1, commandBuffer); member.image.clearColor(transparentBlack, 0, 1, commandBuffer);
......
...@@ -91,7 +91,7 @@ void PixelBuffer::removeStagedUpdates(const gl::ImageIndex &index) ...@@ -91,7 +91,7 @@ void PixelBuffer::removeStagedUpdates(const gl::ImageIndex &index)
mSubresourceUpdates.end()); mSubresourceUpdates.end());
} }
gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk, vk::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Extents &extents, const gl::Extents &extents,
const gl::Offset &offset, const gl::Offset &offset,
...@@ -101,19 +101,19 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk, ...@@ -101,19 +101,19 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
const uint8_t *pixels) const uint8_t *pixels)
{ {
GLuint inputRowPitch = 0; GLuint inputRowPitch = 0;
ANGLE_TRY_CHECKED_MATH(formatInfo.computeRowPitch(type, extents.width, unpack.alignment, ANGLE_TRY_VK_CHECKED_MATH(formatInfo.computeRowPitch(type, extents.width, unpack.alignment,
unpack.rowLength, &inputRowPitch)); unpack.rowLength, &inputRowPitch));
GLuint inputDepthPitch = 0; GLuint inputDepthPitch = 0;
ANGLE_TRY_CHECKED_MATH(formatInfo.computeDepthPitch(extents.height, unpack.imageHeight, ANGLE_TRY_VK_CHECKED_MATH(formatInfo.computeDepthPitch(extents.height, unpack.imageHeight,
inputRowPitch, &inputDepthPitch)); inputRowPitch, &inputDepthPitch));
// TODO(jmadill): skip images for 3D Textures. // TODO(jmadill): skip images for 3D Textures.
bool applySkipImages = false; bool applySkipImages = false;
GLuint inputSkipBytes = 0; GLuint inputSkipBytes = 0;
ANGLE_TRY_CHECKED_MATH(formatInfo.computeSkipBytes(type, inputRowPitch, inputDepthPitch, unpack, ANGLE_TRY_VK_CHECKED_MATH(formatInfo.computeSkipBytes(
applySkipImages, &inputSkipBytes)); type, inputRowPitch, inputDepthPitch, unpack, applySkipImages, &inputSkipBytes));
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
...@@ -129,8 +129,8 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk, ...@@ -129,8 +129,8 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
bool newBufferAllocated = false; bool newBufferAllocated = false;
uint32_t stagingOffset = 0; uint32_t stagingOffset = 0;
size_t allocationSize = outputDepthPitch * extents.depth; size_t allocationSize = outputDepthPitch * extents.depth;
mStagingBuffer.allocate(renderer, allocationSize, &stagingPointer, &bufferHandle, ANGLE_TRY(mStagingBuffer.allocate(renderer, allocationSize, &stagingPointer, &bufferHandle,
&stagingOffset, &newBufferAllocated); &stagingOffset, &newBufferAllocated));
const uint8_t *source = pixels + inputSkipBytes; const uint8_t *source = pixels + inputSkipBytes;
...@@ -154,10 +154,10 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk, ...@@ -154,10 +154,10 @@ gl::Error PixelBuffer::stageSubresourceUpdate(ContextVk *contextVk,
mSubresourceUpdates.emplace_back(bufferHandle, copy); mSubresourceUpdates.emplace_back(bufferHandle, copy);
return gl::NoError(); return vk::NoError();
} }
gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context *context, vk::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
const gl::Offset &dstOffset, const gl::Offset &dstOffset,
...@@ -174,7 +174,7 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context * ...@@ -174,7 +174,7 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context *
&clippedRectangle)) &clippedRectangle))
{ {
// Empty source area, nothing to do. // Empty source area, nothing to do.
return gl::NoError(); return vk::NoError();
} }
bool isViewportFlipEnabled = contextVk->isViewportFlipEnabledForDrawFBO(); bool isViewportFlipEnabled = contextVk->isViewportFlipEnabledForDrawFBO();
...@@ -201,8 +201,8 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context * ...@@ -201,8 +201,8 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context *
// The destination is only one layer deep. // The destination is only one layer deep.
size_t allocationSize = outputDepthPitch; size_t allocationSize = outputDepthPitch;
mStagingBuffer.allocate(renderer, allocationSize, &stagingPointer, &bufferHandle, ANGLE_TRY(mStagingBuffer.allocate(renderer, allocationSize, &stagingPointer, &bufferHandle,
&stagingOffset, &newBufferAllocated); &stagingOffset, &newBufferAllocated));
gl::PixelPackState pixelPackState = gl::PixelPackState(); gl::PixelPackState pixelPackState = gl::PixelPackState();
// TODO(lucferron): The pixel pack state alignment should probably be 1 instead of 4. // TODO(lucferron): The pixel pack state alignment should probably be 1 instead of 4.
...@@ -229,7 +229,7 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context * ...@@ -229,7 +229,7 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context *
size_t bufferSize = size_t bufferSize =
storageFormat.pixelBytes * clippedRectangle.width * clippedRectangle.height; storageFormat.pixelBytes * clippedRectangle.width * clippedRectangle.height;
angle::MemoryBuffer *memoryBuffer = nullptr; angle::MemoryBuffer *memoryBuffer = nullptr;
ANGLE_TRY_ALLOCATION(context->getScratchBuffer(bufferSize, &memoryBuffer)); ANGLE_TRY_VK_ALLOCATION(context->getScratchBuffer(bufferSize, &memoryBuffer));
// Read into the scratch buffer // Read into the scratch buffer
ANGLE_TRY( ANGLE_TRY(
...@@ -260,10 +260,10 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context * ...@@ -260,10 +260,10 @@ gl::Error PixelBuffer::stageSubresourceUpdateFromFramebuffer(const gl::Context *
// 3- enqueue the destination image subresource update // 3- enqueue the destination image subresource update
mSubresourceUpdates.emplace_back(bufferHandle, copyToImage); mSubresourceUpdates.emplace_back(bufferHandle, copyToImage);
return gl::NoError(); return vk::NoError();
} }
gl::Error PixelBuffer::allocate(RendererVk *renderer, vk::Error PixelBuffer::allocate(RendererVk *renderer,
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
...@@ -335,7 +335,7 @@ bool PixelBuffer::empty() const ...@@ -335,7 +335,7 @@ bool PixelBuffer::empty() const
return mSubresourceUpdates.empty(); return mSubresourceUpdates.empty();
} }
gl::Error PixelBuffer::stageSubresourceUpdateAndGetData(RendererVk *renderer, vk::Error PixelBuffer::stageSubresourceUpdateAndGetData(RendererVk *renderer,
size_t allocationSize, size_t allocationSize,
const gl::ImageIndex &imageIndex, const gl::ImageIndex &imageIndex,
const gl::Extents &extents, const gl::Extents &extents,
...@@ -362,10 +362,10 @@ gl::Error PixelBuffer::stageSubresourceUpdateAndGetData(RendererVk *renderer, ...@@ -362,10 +362,10 @@ gl::Error PixelBuffer::stageSubresourceUpdateAndGetData(RendererVk *renderer,
mSubresourceUpdates.emplace_back(bufferHandle, copy); mSubresourceUpdates.emplace_back(bufferHandle, copy);
return gl::NoError(); return vk::NoError();
} }
gl::Error TextureVk::generateMipmapLevelsWithCPU(ContextVk *contextVk, vk::Error TextureVk::generateMipmapLevelsWithCPU(ContextVk *contextVk,
const angle::Format &sourceFormat, const angle::Format &sourceFormat,
GLuint layer, GLuint layer,
GLuint firstMipLevel, GLuint firstMipLevel,
...@@ -412,7 +412,7 @@ gl::Error TextureVk::generateMipmapLevelsWithCPU(ContextVk *contextVk, ...@@ -412,7 +412,7 @@ gl::Error TextureVk::generateMipmapLevelsWithCPU(ContextVk *contextVk,
previousLevelRowPitch = destRowPitch; previousLevelRowPitch = destRowPitch;
} }
return gl::NoError(); return vk::NoError();
} }
PixelBuffer::SubresourceUpdate::SubresourceUpdate() : bufferHandle(VK_NULL_HANDLE) PixelBuffer::SubresourceUpdate::SubresourceUpdate() : bufferHandle(VK_NULL_HANDLE)
...@@ -644,12 +644,12 @@ gl::Error TextureVk::setImageExternal(const gl::Context *context, ...@@ -644,12 +644,12 @@ gl::Error TextureVk::setImageExternal(const gl::Context *context,
return gl::InternalError(); return gl::InternalError();
} }
void TextureVk::generateMipmapWithBlit(RendererVk *renderer) vk::Error TextureVk::generateMipmapWithBlit(RendererVk *renderer)
{ {
uint32_t imageLayerCount = GetImageLayerCount(mState.getType()); uint32_t imageLayerCount = GetImageLayerCount(mState.getType());
const gl::Extents baseLevelExtents = mImage.getExtents(); const gl::Extents baseLevelExtents = mImage.getExtents();
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
getCommandBufferForWrite(renderer, &commandBuffer); ANGLE_TRY(getCommandBufferForWrite(renderer, &commandBuffer));
// We are able to use blitImage since the image format we are using supports it. This // We are able to use blitImage since the image format we are using supports it. This
// is a faster way we can generate the mips. // is a faster way we can generate the mips.
...@@ -719,9 +719,11 @@ void TextureVk::generateMipmapWithBlit(RendererVk *renderer) ...@@ -719,9 +719,11 @@ void TextureVk::generateMipmapWithBlit(RendererVk *renderer)
// 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 changeLayoutWithStages will use this layout as the "oldLayout" argument. // to changeLayoutWithStages will use this layout as the "oldLayout" argument.
mImage.updateLayout(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); mImage.updateLayout(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
return vk::NoError();
} }
gl::Error TextureVk::generateMipmapWithCPU(const gl::Context *context) vk::Error TextureVk::generateMipmapWithCPU(const gl::Context *context)
{ {
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
...@@ -734,7 +736,7 @@ gl::Error TextureVk::generateMipmapWithCPU(const gl::Context *context) ...@@ -734,7 +736,7 @@ gl::Error TextureVk::generateMipmapWithCPU(const gl::Context *context)
size_t baseLevelAllocationSize = sourceRowPitch * baseLevelExtents.height; size_t baseLevelAllocationSize = sourceRowPitch * baseLevelExtents.height;
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
getCommandBufferForWrite(renderer, &commandBuffer); ANGLE_TRY(getCommandBufferForWrite(renderer, &commandBuffer));
// Requirement of the copyImageToBuffer, the source image must be in SRC_OPTIMAL layout. // Requirement of the copyImageToBuffer, the source image must be in SRC_OPTIMAL layout.
mImage.changeLayoutWithStages(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mImage.changeLayoutWithStages(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
...@@ -788,8 +790,7 @@ gl::Error TextureVk::generateMipmapWithCPU(const gl::Context *context) ...@@ -788,8 +790,7 @@ gl::Error TextureVk::generateMipmapWithCPU(const gl::Context *context)
sourceRowPitch, baseLevelBuffers + bufferOffset)); sourceRowPitch, baseLevelBuffers + bufferOffset));
} }
mPixelBuffer.flushUpdatesToImage(renderer, levelCount, &mImage, commandBuffer); return mPixelBuffer.flushUpdatesToImage(renderer, levelCount, &mImage, commandBuffer);
return gl::NoError();
} }
gl::Error TextureVk::generateMipmap(const gl::Context *context) gl::Error TextureVk::generateMipmap(const gl::Context *context)
...@@ -821,7 +822,7 @@ gl::Error TextureVk::generateMipmap(const gl::Context *context) ...@@ -821,7 +822,7 @@ gl::Error TextureVk::generateMipmap(const gl::Context *context)
// only. // only.
if (IsMaskFlagSet(kBlitFeatureFlags, imageProperties.linearTilingFeatures)) if (IsMaskFlagSet(kBlitFeatureFlags, imageProperties.linearTilingFeatures))
{ {
generateMipmapWithBlit(renderer); ANGLE_TRY(generateMipmapWithBlit(renderer));
} }
else else
{ {
......
...@@ -28,7 +28,7 @@ class PixelBuffer final : angle::NonCopyable ...@@ -28,7 +28,7 @@ class PixelBuffer final : angle::NonCopyable
void removeStagedUpdates(const gl::ImageIndex &index); void removeStagedUpdates(const gl::ImageIndex &index);
gl::Error stageSubresourceUpdate(ContextVk *contextVk, vk::Error stageSubresourceUpdate(ContextVk *contextVk,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Extents &extents, const gl::Extents &extents,
const gl::Offset &offset, const gl::Offset &offset,
...@@ -37,14 +37,14 @@ class PixelBuffer final : angle::NonCopyable ...@@ -37,14 +37,14 @@ class PixelBuffer final : angle::NonCopyable
GLenum type, GLenum type,
const uint8_t *pixels); const uint8_t *pixels);
gl::Error stageSubresourceUpdateAndGetData(RendererVk *renderer, vk::Error stageSubresourceUpdateAndGetData(RendererVk *renderer,
size_t allocationSize, size_t allocationSize,
const gl::ImageIndex &imageIndex, const gl::ImageIndex &imageIndex,
const gl::Extents &extents, const gl::Extents &extents,
const gl::Offset &offset, const gl::Offset &offset,
uint8_t **destData); uint8_t **destData);
gl::Error stageSubresourceUpdateFromFramebuffer(const gl::Context *context, vk::Error stageSubresourceUpdateFromFramebuffer(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
const gl::Offset &dstOffset, const gl::Offset &dstOffset,
...@@ -54,7 +54,7 @@ class PixelBuffer final : angle::NonCopyable ...@@ -54,7 +54,7 @@ class PixelBuffer final : angle::NonCopyable
// This will use the underlying dynamic buffer to allocate some memory to be used as a src or // This will use the underlying dynamic buffer to allocate some memory to be used as a src or
// dst. // dst.
gl::Error allocate(RendererVk *renderer, vk::Error allocate(RendererVk *renderer,
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
...@@ -178,11 +178,11 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -178,11 +178,11 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
vk::Error ensureImageInitialized(ContextVk *contextVk); vk::Error ensureImageInitialized(ContextVk *contextVk);
private: private:
void generateMipmapWithBlit(RendererVk *renderer); vk::Error generateMipmapWithBlit(RendererVk *renderer);
gl::Error generateMipmapWithCPU(const gl::Context *context); vk::Error generateMipmapWithCPU(const gl::Context *context);
gl::Error generateMipmapLevelsWithCPU(ContextVk *contextVk, vk::Error generateMipmapLevelsWithCPU(ContextVk *contextVk,
const angle::Format &sourceFormat, const angle::Format &sourceFormat,
GLuint layer, GLuint layer,
GLuint firstMipLevel, GLuint firstMipLevel,
......
...@@ -529,9 +529,9 @@ gl::Error VertexArrayVk::onIndexedDraw(const gl::Context *context, ...@@ -529,9 +529,9 @@ gl::Error VertexArrayVk::onIndexedDraw(const gl::Context *context,
uint8_t *allocatedData = nullptr; uint8_t *allocatedData = nullptr;
bool newBufferAllocated = false; bool newBufferAllocated = false;
uint32_t expandedDataOffset = 0; uint32_t expandedDataOffset = 0;
mTranslatedByteIndexData.allocate( ANGLE_TRY(mTranslatedByteIndexData.allocate(
renderer, static_cast<size_t>(bufferVk->getSize()) * 2, &allocatedData, renderer, static_cast<size_t>(bufferVk->getSize()) * 2, &allocatedData,
&mCurrentElementArrayBufferHandle, &expandedDataOffset, &newBufferAllocated); &mCurrentElementArrayBufferHandle, &expandedDataOffset, &newBufferAllocated));
mCurrentElementArrayBufferOffset = static_cast<VkDeviceSize>(expandedDataOffset); mCurrentElementArrayBufferOffset = static_cast<VkDeviceSize>(expandedDataOffset);
// Expand the source into the destination // Expand the source into the destination
...@@ -543,7 +543,7 @@ gl::Error VertexArrayVk::onIndexedDraw(const gl::Context *context, ...@@ -543,7 +543,7 @@ gl::Error VertexArrayVk::onIndexedDraw(const gl::Context *context,
} }
// Make sure our writes are available. // Make sure our writes are available.
mTranslatedByteIndexData.flush(renderer->getDevice()); ANGLE_TRY(mTranslatedByteIndexData.flush(renderer->getDevice()));
GLboolean result = false; GLboolean result = false;
ANGLE_TRY(bufferVk->unmap(context, &result)); ANGLE_TRY(bufferVk->unmap(context, &result));
......
...@@ -359,7 +359,7 @@ LineLoopHelper::LineLoopHelper(RendererVk *renderer) ...@@ -359,7 +359,7 @@ LineLoopHelper::LineLoopHelper(RendererVk *renderer)
LineLoopHelper::~LineLoopHelper() = default; LineLoopHelper::~LineLoopHelper() = default;
gl::Error LineLoopHelper::getIndexBufferForDrawArrays(RendererVk *renderer, vk::Error LineLoopHelper::getIndexBufferForDrawArrays(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut) VkDeviceSize *offsetOut)
...@@ -390,10 +390,10 @@ gl::Error LineLoopHelper::getIndexBufferForDrawArrays(RendererVk *renderer, ...@@ -390,10 +390,10 @@ gl::Error LineLoopHelper::getIndexBufferForDrawArrays(RendererVk *renderer,
// writing. // writing.
ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice())); ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice()));
return gl::NoError(); return vk::NoError();
} }
gl::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *renderer, vk::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *renderer,
BufferVk *elementArrayBufferVk, BufferVk *elementArrayBufferVk,
VkIndexType indexType, VkIndexType indexType,
int indexCount, int indexCount,
...@@ -422,17 +422,17 @@ gl::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *render ...@@ -422,17 +422,17 @@ gl::Error LineLoopHelper::getIndexBufferForElementArrayBuffer(RendererVk *render
std::array<VkBufferCopy, 2> copies = {{copy1, copy2}}; std::array<VkBufferCopy, 2> copies = {{copy1, copy2}};
vk::CommandBuffer *commandBuffer; vk::CommandBuffer *commandBuffer;
beginWriteResource(renderer, &commandBuffer); ANGLE_TRY(beginWriteResource(renderer, &commandBuffer));
elementArrayBufferVk->addReadDependency(this); elementArrayBufferVk->addReadDependency(this);
commandBuffer->copyBuffer(elementArrayBufferVk->getVkBuffer().getHandle(), *bufferHandleOut, 2, commandBuffer->copyBuffer(elementArrayBufferVk->getVkBuffer().getHandle(), *bufferHandleOut, 2,
copies.data()); copies.data());
ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice())); ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice()));
return gl::NoError(); return vk::NoError();
} }
gl::Error LineLoopHelper::getIndexBufferForClientElementArray( vk::Error LineLoopHelper::getIndexBufferForClientElementArray(
RendererVk *renderer, RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
...@@ -471,7 +471,7 @@ gl::Error LineLoopHelper::getIndexBufferForClientElementArray( ...@@ -471,7 +471,7 @@ gl::Error LineLoopHelper::getIndexBufferForClientElementArray(
} }
ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice())); ANGLE_TRY(mDynamicIndexBuffer.flush(renderer->getDevice()));
return gl::NoError(); return vk::NoError();
} }
void LineLoopHelper::destroy(VkDevice device) void LineLoopHelper::destroy(VkDevice device)
......
...@@ -136,18 +136,18 @@ class LineLoopHelper final : public vk::CommandGraphResource ...@@ -136,18 +136,18 @@ class LineLoopHelper final : public vk::CommandGraphResource
LineLoopHelper(RendererVk *renderer); LineLoopHelper(RendererVk *renderer);
~LineLoopHelper(); ~LineLoopHelper();
gl::Error getIndexBufferForDrawArrays(RendererVk *renderer, vk::Error getIndexBufferForDrawArrays(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut); VkDeviceSize *offsetOut);
gl::Error getIndexBufferForElementArrayBuffer(RendererVk *renderer, vk::Error getIndexBufferForElementArrayBuffer(RendererVk *renderer,
BufferVk *elementArrayBufferVk, BufferVk *elementArrayBufferVk,
VkIndexType indexType, VkIndexType indexType,
int indexCount, int indexCount,
intptr_t elementArrayOffset, intptr_t elementArrayOffset,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut); VkDeviceSize *bufferOffsetOut);
gl::Error getIndexBufferForClientElementArray(RendererVk *renderer, vk::Error getIndexBufferForClientElementArray(RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut); VkDeviceSize *bufferOffsetOut);
......
...@@ -118,7 +118,7 @@ GetImplType<T> *GetImpl(const T *glObject) ...@@ -118,7 +118,7 @@ GetImplType<T> *GetImpl(const T *glObject)
return GetImplAs<GetImplType<T>>(glObject); return GetImplAs<GetImplType<T>>(glObject);
} }
class Error final class ANGLE_NO_DISCARD Error final
{ {
public: public:
Error(VkResult result); Error(VkResult result);
...@@ -156,6 +156,18 @@ inline Error NoError() ...@@ -156,6 +156,18 @@ inline Error NoError()
return Error(VK_SUCCESS); return Error(VK_SUCCESS);
} }
#define ANGLE_TRY_VK_CHECKED_MATH(result) \
if (!result) \
{ \
return vk::Error(VK_ERROR_VALIDATION_FAILED_EXT); \
}
#define ANGLE_TRY_VK_ALLOCATION(result) \
if (!result) \
{ \
return vk::Error(VK_ERROR_OUT_OF_HOST_MEMORY); \
}
// Unimplemented handle types: // Unimplemented handle types:
// Instance // Instance
// PhysicalDevice // PhysicalDevice
......
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