Commit 21061026 by Jamie Madill Committed by Commit Bot

Vulkan: Use angle::Result error handling.

Introduces a vk::Context class to contain an error handler and Renderer pointer. This abtracts the common code path for ContextVk + DisplayVk. Removes vk::Error in favor of the POD angle::Result class. There are a few remaining usages of gl::Error that will have to be cleaned up when we can change the front-end APIs. Bug: angleproject:2713 Change-Id: I5e68f223d595c6c561b59d6a85759e5738ed43c6 Reviewed-on: https://chromium-review.googlesource.com/1128924 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent 6b873dd7
...@@ -247,7 +247,7 @@ inline Error NoError() ...@@ -247,7 +247,7 @@ inline Error NoError()
} \ } \
ANGLE_EMPTY_STATEMENT ANGLE_EMPTY_STATEMENT
// TODO(jmadill): Introduce way to store errors to a const Context. // TODO(jmadill): Introduce way to store errors to a const Context. http://anglebug.com/2491
#define ANGLE_SWALLOW_ERR(EXPR) \ #define ANGLE_SWALLOW_ERR(EXPR) \
{ \ { \
auto ANGLE_LOCAL_VAR = EXPR; \ auto ANGLE_LOCAL_VAR = EXPR; \
......
...@@ -908,7 +908,7 @@ void Program::onDestroy(const Context *context) ...@@ -908,7 +908,7 @@ void Program::onDestroy(const Context *context)
} }
} }
// TODO(jmadill): Handle error in the Context. // TODO(jmadill): Handle error in the Context. http://anglebug.com/2491
ANGLE_SWALLOW_ERR(mProgram->destroy(context)); ANGLE_SWALLOW_ERR(mProgram->destroy(context));
ASSERT(!mState.hasAttachedShader()); ASSERT(!mState.hasAttachedShader());
......
...@@ -47,7 +47,6 @@ gl::Error BufferVk::setData(const gl::Context *context, ...@@ -47,7 +47,6 @@ gl::Error BufferVk::setData(const gl::Context *context,
gl::BufferUsage usage) gl::BufferUsage usage)
{ {
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
VkDevice device = contextVk->getDevice();
if (size > static_cast<size_t>(mState.getSize())) if (size > static_cast<size_t>(mState.getSize()))
{ {
...@@ -70,13 +69,13 @@ gl::Error BufferVk::setData(const gl::Context *context, ...@@ -70,13 +69,13 @@ gl::Error BufferVk::setData(const gl::Context *context,
createInfo.queueFamilyIndexCount = 0; createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = nullptr; createInfo.pQueueFamilyIndices = nullptr;
ANGLE_TRY(mBuffer.init(device, createInfo)); ANGLE_TRY(mBuffer.init(contextVk, createInfo));
// Assume host vislble/coherent memory available. // Assume host vislble/coherent memory available.
const VkMemoryPropertyFlags memoryPropertyFlags = const VkMemoryPropertyFlags memoryPropertyFlags =
(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
ANGLE_TRY(vk::AllocateBufferMemory(contextVk->getRenderer(), memoryPropertyFlags, &mBuffer, ANGLE_TRY(
&mBufferMemory)); vk::AllocateBufferMemory(contextVk, memoryPropertyFlags, &mBuffer, &mBufferMemory));
} }
if (data) if (data)
...@@ -117,14 +116,17 @@ gl::Error BufferVk::map(const gl::Context *context, GLenum access, void **mapPtr ...@@ -117,14 +116,17 @@ gl::Error BufferVk::map(const gl::Context *context, GLenum access, void **mapPtr
ASSERT(mBuffer.getHandle() != VK_NULL_HANDLE); ASSERT(mBuffer.getHandle() != VK_NULL_HANDLE);
ASSERT(mBufferMemory.getHandle() != VK_NULL_HANDLE); ASSERT(mBufferMemory.getHandle() != VK_NULL_HANDLE);
VkDevice device = vk::GetImpl(context)->getDevice(); ContextVk *contextVk = vk::GetImpl(context);
ANGLE_TRY(mapImpl(contextVk, mapPtr));
ANGLE_TRY(
mBufferMemory.map(device, 0, mState.getSize(), 0, reinterpret_cast<uint8_t **>(mapPtr)));
return gl::NoError(); return gl::NoError();
} }
angle::Result BufferVk::mapImpl(ContextVk *contextVk, void **mapPtr)
{
return mBufferMemory.map(contextVk, 0, mState.getSize(), 0,
reinterpret_cast<uint8_t **>(mapPtr));
}
GLint64 BufferVk::getSize() GLint64 BufferVk::getSize()
{ {
return mState.getSize(); return mState.getSize();
...@@ -139,9 +141,10 @@ gl::Error BufferVk::mapRange(const gl::Context *context, ...@@ -139,9 +141,10 @@ gl::Error BufferVk::mapRange(const gl::Context *context,
ASSERT(mBuffer.getHandle() != VK_NULL_HANDLE); ASSERT(mBuffer.getHandle() != VK_NULL_HANDLE);
ASSERT(mBufferMemory.getHandle() != VK_NULL_HANDLE); ASSERT(mBufferMemory.getHandle() != VK_NULL_HANDLE);
VkDevice device = vk::GetImpl(context)->getDevice(); ContextVk *contextVk = vk::GetImpl(context);
ANGLE_TRY(mBufferMemory.map(device, offset, length, 0, reinterpret_cast<uint8_t **>(mapPtr))); ANGLE_TRY(
mBufferMemory.map(contextVk, offset, length, 0, reinterpret_cast<uint8_t **>(mapPtr)));
return gl::NoError(); return gl::NoError();
} }
...@@ -165,7 +168,7 @@ gl::Error BufferVk::getIndexRange(const gl::Context *context, ...@@ -165,7 +168,7 @@ gl::Error BufferVk::getIndexRange(const gl::Context *context,
bool primitiveRestartEnabled, bool primitiveRestartEnabled,
gl::IndexRange *outRange) gl::IndexRange *outRange)
{ {
VkDevice device = vk::GetImpl(context)->getDevice(); ContextVk *contextVk = vk::GetImpl(context);
// TODO(jmadill): Consider keeping a shadow system memory copy in some cases. // TODO(jmadill): Consider keeping a shadow system memory copy in some cases.
ASSERT(mBuffer.valid()); ASSERT(mBuffer.valid());
...@@ -173,18 +176,18 @@ gl::Error BufferVk::getIndexRange(const gl::Context *context, ...@@ -173,18 +176,18 @@ gl::Error BufferVk::getIndexRange(const gl::Context *context,
const gl::Type &typeInfo = gl::GetTypeInfo(type); const gl::Type &typeInfo = gl::GetTypeInfo(type);
uint8_t *mapPointer = nullptr; uint8_t *mapPointer = nullptr;
ANGLE_TRY(mBufferMemory.map(device, offset, typeInfo.bytes * count, 0, &mapPointer)); ANGLE_TRY(mBufferMemory.map(contextVk, offset, typeInfo.bytes * count, 0, &mapPointer));
*outRange = gl::ComputeIndexRange(type, mapPointer, count, primitiveRestartEnabled); *outRange = gl::ComputeIndexRange(type, mapPointer, count, primitiveRestartEnabled);
mBufferMemory.unmap(device); mBufferMemory.unmap(contextVk->getDevice());
return gl::NoError(); return gl::NoError();
} }
vk::Error BufferVk::setDataImpl(ContextVk *contextVk, angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
const uint8_t *data, const uint8_t *data,
size_t size, size_t size,
size_t offset) size_t offset)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
VkDevice device = contextVk->getDevice(); VkDevice device = contextVk->getDevice();
...@@ -197,7 +200,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk, ...@@ -197,7 +200,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk,
vk::StagingUsage::Write)); vk::StagingUsage::Write));
uint8_t *mapPointer = nullptr; uint8_t *mapPointer = nullptr;
ANGLE_TRY(stagingBuffer.getDeviceMemory().map(device, 0, size, 0, &mapPointer)); ANGLE_TRY(stagingBuffer.getDeviceMemory().map(contextVk, 0, size, 0, &mapPointer));
ASSERT(mapPointer); ASSERT(mapPointer);
memcpy(mapPointer, data, size); memcpy(mapPointer, data, size);
...@@ -207,7 +210,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk, ...@@ -207,7 +210,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk,
// 'beginWriteResource' will stop any subsequent rendering from using the old buffer data, // 'beginWriteResource' will stop any subsequent rendering from using the old buffer data,
// by marking any current read operations / command buffers as 'finished'. // by marking any current read operations / command buffers as 'finished'.
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(beginWriteResource(renderer, &commandBuffer)); ANGLE_TRY(beginWriteResource(contextVk, &commandBuffer));
// Insert a barrier to ensure reads from the buffer are complete. // Insert a barrier to ensure reads from the buffer are complete.
// TODO(jmadill): Insert minimal barriers. // TODO(jmadill): Insert minimal barriers.
...@@ -256,7 +259,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk, ...@@ -256,7 +259,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk,
else else
{ {
uint8_t *mapPointer = nullptr; uint8_t *mapPointer = nullptr;
ANGLE_TRY(mBufferMemory.map(device, offset, size, 0, &mapPointer)); ANGLE_TRY(mBufferMemory.map(contextVk, offset, size, 0, &mapPointer));
ASSERT(mapPointer); ASSERT(mapPointer);
memcpy(mapPointer, data, size); memcpy(mapPointer, data, size);
...@@ -264,7 +267,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk, ...@@ -264,7 +267,7 @@ vk::Error BufferVk::setDataImpl(ContextVk *contextVk,
mBufferMemory.unmap(device); mBufferMemory.unmap(device);
} }
return vk::NoError(); return angle::Result::Continue();
} }
const vk::Buffer &BufferVk::getVkBuffer() const const vk::Buffer &BufferVk::getVkBuffer() const
......
...@@ -58,8 +58,13 @@ class BufferVk : public BufferImpl, public vk::CommandGraphResource ...@@ -58,8 +58,13 @@ class BufferVk : public BufferImpl, public vk::CommandGraphResource
const vk::Buffer &getVkBuffer() const; const vk::Buffer &getVkBuffer() const;
angle::Result mapImpl(ContextVk *contextVk, void **mapPtr);
private: private:
vk::Error setDataImpl(ContextVk *contextVk, const uint8_t *data, size_t size, size_t offset); angle::Result setDataImpl(ContextVk *contextVk,
const uint8_t *data,
size_t size,
size_t offset);
void release(RendererVk *renderer); void release(RendererVk *renderer);
vk::Buffer mBuffer; vk::Buffer mBuffer;
......
...@@ -43,7 +43,7 @@ class CommandGraphResource ...@@ -43,7 +43,7 @@ class CommandGraphResource
protected: protected:
// Allocates a write node via getNewWriteNode and returns a started command buffer. // Allocates a write node via getNewWriteNode and returns a started command buffer.
// The started command buffer will render outside of a RenderPass. // The started command buffer will render outside of a RenderPass.
Error beginWriteResource(RendererVk *renderer, CommandBuffer **commandBufferOut); angle::Result beginWriteResource(Context *context, CommandBuffer **commandBufferOut);
// Check if we have started writing outside a RenderPass. // Check if we have started writing outside a RenderPass.
bool hasStartedWriteResource() const; bool hasStartedWriteResource() const;
...@@ -51,16 +51,16 @@ class CommandGraphResource ...@@ -51,16 +51,16 @@ class CommandGraphResource
// Starts rendering to an existing command buffer for the resource. // Starts rendering to an existing command buffer for the resource.
// The started command buffer will render outside of a RenderPass. // The started command buffer will render outside of a RenderPass.
// Calls beginWriteResource if we have not yet started writing. // Calls beginWriteResource if we have not yet started writing.
Error appendWriteResource(RendererVk *renderer, CommandBuffer **commandBufferOut); angle::Result appendWriteResource(Context *context, CommandBuffer **commandBufferOut);
// Begins a command buffer on the current graph node for in-RenderPass rendering. // Begins a command buffer on the current graph node for in-RenderPass rendering.
// Currently only called from FramebufferVk::getCommandBufferForDraw. // Currently only called from FramebufferVk::getCommandBufferForDraw.
Error beginRenderPass(RendererVk *renderer, angle::Result beginRenderPass(Context *context,
const Framebuffer &framebuffer, const Framebuffer &framebuffer,
const gl::Rectangle &renderArea, const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc, const RenderPassDesc &renderPassDesc,
const std::vector<VkClearValue> &clearValues, const std::vector<VkClearValue> &clearValues,
CommandBuffer **commandBufferOut) const; CommandBuffer **commandBufferOut) const;
// Checks if we're in a RenderPass, returning true if so. Updates serial internally. // Checks if we're in a RenderPass, returning true if so. Updates serial internally.
// Returns the started command buffer in commandBufferOut. // Returns the started command buffer in commandBufferOut.
...@@ -132,11 +132,11 @@ class CommandGraph final : angle::NonCopyable ...@@ -132,11 +132,11 @@ class CommandGraph final : angle::NonCopyable
// to set up dependency relations. // to set up dependency relations.
CommandGraphNode *allocateNode(); CommandGraphNode *allocateNode();
Error submitCommands(VkDevice device, angle::Result submitCommands(Context *context,
Serial serial, Serial serial,
RenderPassCache *renderPassCache, RenderPassCache *renderPassCache,
CommandPool *commandPool, CommandPool *commandPool,
CommandBuffer *primaryCommandBufferOut); CommandBuffer *primaryCommandBufferOut);
bool empty() const; bool empty() const;
private: private:
......
...@@ -37,6 +37,19 @@ namespace rx ...@@ -37,6 +37,19 @@ namespace rx
namespace namespace
{ {
GLenum DefaultGLErrorCode(VkResult result)
{
switch (result)
{
case VK_ERROR_OUT_OF_HOST_MEMORY:
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
case VK_ERROR_TOO_MANY_OBJECTS:
return GL_OUT_OF_MEMORY;
default:
return GL_INVALID_OPERATION;
}
}
constexpr gl::Rectangle kMaxSizedScissor(0, constexpr gl::Rectangle kMaxSizedScissor(0,
0, 0,
std::numeric_limits<int>::max(), std::numeric_limits<int>::max(),
...@@ -49,7 +62,7 @@ constexpr VkColorComponentFlags kAllColorChannelsMask = ...@@ -49,7 +62,7 @@ constexpr VkColorComponentFlags kAllColorChannelsMask =
ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer) ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer)
: ContextImpl(state), : ContextImpl(state),
mRenderer(renderer), vk::Context(renderer),
mCurrentDrawMode(gl::PrimitiveMode::InvalidEnum), mCurrentDrawMode(gl::PrimitiveMode::InvalidEnum),
mTexturesDirty(false), mTexturesDirty(false),
mVertexArrayBindingHasChanged(false), mVertexArrayBindingHasChanged(false),
...@@ -94,19 +107,17 @@ gl::Error ContextVk::initialize() ...@@ -94,19 +107,17 @@ gl::Error ContextVk::initialize()
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
GetUniformBufferDescriptorCount() * vk::kDefaultDescriptorPoolMaxSets}; GetUniformBufferDescriptorCount() * vk::kDefaultDescriptorPoolMaxSets};
ANGLE_TRY( ANGLE_TRY(mDynamicDescriptorPools[kUniformsDescriptorSetIndex].init(this, uniformPoolSize));
mDynamicDescriptorPools[kUniformsDescriptorSetIndex].init(getDevice(), uniformPoolSize));
VkDescriptorPoolSize imageSamplerPoolSize = { VkDescriptorPoolSize imageSamplerPoolSize = {
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
mRenderer->getMaxActiveTextures() * vk::kDefaultDescriptorPoolMaxSets}; mRenderer->getMaxActiveTextures() * vk::kDefaultDescriptorPoolMaxSets};
ANGLE_TRY(mDynamicDescriptorPools[kTextureDescriptorSetIndex].init(getDevice(), ANGLE_TRY(mDynamicDescriptorPools[kTextureDescriptorSetIndex].init(this, imageSamplerPoolSize));
imageSamplerPoolSize));
VkDescriptorPoolSize driverUniformsPoolSize = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VkDescriptorPoolSize driverUniformsPoolSize = {VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
vk::kDefaultDescriptorPoolMaxSets}; vk::kDefaultDescriptorPoolMaxSets};
ANGLE_TRY(mDynamicDescriptorPools[kDriverUniformsDescriptorSetIndex].init( ANGLE_TRY(mDynamicDescriptorPools[kDriverUniformsDescriptorSetIndex].init(
getDevice(), driverUniformsPoolSize)); this, driverUniformsPoolSize));
mPipelineDesc.reset(new vk::PipelineDesc()); mPipelineDesc.reset(new vk::PipelineDesc());
mPipelineDesc->initDefaults(); mPipelineDesc->initDefaults();
...@@ -127,7 +138,7 @@ gl::Error ContextVk::flush(const gl::Context *context) ...@@ -127,7 +138,7 @@ gl::Error ContextVk::flush(const gl::Context *context)
gl::Error ContextVk::finish(const gl::Context *context) gl::Error ContextVk::finish(const gl::Context *context)
{ {
return mRenderer->finish(context); return mRenderer->finish(this);
} }
gl::Error ContextVk::initPipeline() gl::Error ContextVk::initPipeline()
...@@ -151,7 +162,7 @@ gl::Error ContextVk::initPipeline() ...@@ -151,7 +162,7 @@ gl::Error ContextVk::initPipeline()
mPipelineDesc->updateRenderPassDesc(framebufferVk->getRenderPassDesc()); mPipelineDesc->updateRenderPassDesc(framebufferVk->getRenderPassDesc());
// TODO(jmadill): Validate with ASSERT against physical device limits/caps? // TODO(jmadill): Validate with ASSERT against physical device limits/caps?
ANGLE_TRY(mRenderer->getAppPipeline(programVk, *mPipelineDesc, activeAttribLocationsMask, ANGLE_TRY(mRenderer->getAppPipeline(this, programVk, *mPipelineDesc, activeAttribLocationsMask,
&mCurrentPipeline)); &mCurrentPipeline));
return gl::NoError(); return gl::NoError();
...@@ -268,8 +279,8 @@ gl::Error ContextVk::drawArrays(const gl::Context *context, ...@@ -268,8 +279,8 @@ gl::Error ContextVk::drawArrays(const gl::Context *context,
const gl::VertexArray *vertexArray = context->getGLState().getVertexArray(); const gl::VertexArray *vertexArray = context->getGLState().getVertexArray();
VertexArrayVk *vertexArrayVk = vk::GetImpl(vertexArray); VertexArrayVk *vertexArrayVk = vk::GetImpl(vertexArray);
ANGLE_TRY(vertexArrayVk->drawArrays(context, mRenderer, drawCallParams, commandBuffer, ANGLE_TRY(
shouldApplyVertexArray)); vertexArrayVk->drawArrays(context, drawCallParams, commandBuffer, shouldApplyVertexArray));
return gl::NoError(); return gl::NoError();
} }
...@@ -298,7 +309,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context, ...@@ -298,7 +309,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context,
gl::VertexArray *vao = mState.getState().getVertexArray(); gl::VertexArray *vao = mState.getState().getVertexArray();
VertexArrayVk *vertexArrayVk = vk::GetImpl(vao); VertexArrayVk *vertexArrayVk = vk::GetImpl(vao);
ANGLE_TRY(vertexArrayVk->drawElements(context, mRenderer, drawCallParams, commandBuffer, ANGLE_TRY(vertexArrayVk->drawElements(context, drawCallParams, commandBuffer,
shouldApplyVertexArray)); shouldApplyVertexArray));
return gl::NoError(); return gl::NoError();
...@@ -846,7 +857,7 @@ const FeaturesVk &ContextVk::getFeatures() const ...@@ -846,7 +857,7 @@ const FeaturesVk &ContextVk::getFeatures() const
return mRenderer->getFeatures(); return mRenderer->getFeatures();
} }
vk::Error ContextVk::updateDriverUniforms() angle::Result ContextVk::updateDriverUniforms()
{ {
if (!mDriverUniformsBuffer.valid()) if (!mDriverUniformsBuffer.valid())
{ {
...@@ -865,8 +876,8 @@ vk::Error ContextVk::updateDriverUniforms() ...@@ -865,8 +876,8 @@ vk::Error ContextVk::updateDriverUniforms()
VkBuffer buffer = VK_NULL_HANDLE; VkBuffer buffer = VK_NULL_HANDLE;
uint32_t offset = 0; uint32_t offset = 0;
bool newBufferAllocated = false; bool newBufferAllocated = false;
ANGLE_TRY(mDriverUniformsBuffer.allocate(mRenderer, sizeof(DriverUniforms), &ptr, &buffer, ANGLE_TRY(mDriverUniformsBuffer.allocate(this, sizeof(DriverUniforms), &ptr, &buffer, &offset,
&offset, &newBufferAllocated)); &newBufferAllocated));
float scaleY = isViewportFlipEnabledForDrawFBO() ? 1.0f : -1.0f; float scaleY = isViewportFlipEnabledForDrawFBO() ? 1.0f : -1.0f;
// Copy and flush to the device. // Copy and flush to the device.
...@@ -876,7 +887,7 @@ vk::Error ContextVk::updateDriverUniforms() ...@@ -876,7 +887,7 @@ vk::Error ContextVk::updateDriverUniforms()
static_cast<float>(glViewport.width), static_cast<float>(glViewport.height)}, static_cast<float>(glViewport.width), static_cast<float>(glViewport.height)},
{1.0f, scaleY, 1.0f, 1.0f}}; {1.0f, scaleY, 1.0f, 1.0f}};
ANGLE_TRY(mDriverUniformsBuffer.flush(getDevice())); ANGLE_TRY(mDriverUniformsBuffer.flush(this));
// Get the descriptor set layout. // Get the descriptor set layout.
if (!mDriverUniformsSetLayout.valid()) if (!mDriverUniformsSetLayout.valid())
...@@ -884,7 +895,7 @@ vk::Error ContextVk::updateDriverUniforms() ...@@ -884,7 +895,7 @@ vk::Error ContextVk::updateDriverUniforms()
vk::DescriptorSetLayoutDesc desc; vk::DescriptorSetLayoutDesc desc;
desc.update(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1); desc.update(0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1);
ANGLE_TRY(mRenderer->getDescriptorSetLayout(desc, &mDriverUniformsSetLayout)); ANGLE_TRY(mRenderer->getDescriptorSetLayout(this, desc, &mDriverUniformsSetLayout));
} }
// Allocate a new descriptor set. // Allocate a new descriptor set.
...@@ -911,6 +922,17 @@ vk::Error ContextVk::updateDriverUniforms() ...@@ -911,6 +922,17 @@ vk::Error ContextVk::updateDriverUniforms()
vkUpdateDescriptorSets(getDevice(), 1, &writeInfo, 0, nullptr); vkUpdateDescriptorSets(getDevice(), 1, &writeInfo, 0, nullptr);
return vk::NoError(); return angle::Result::Continue();
}
void ContextVk::handleError(VkResult errorCode, const char *file, unsigned int line)
{
GLenum glErrorCode = DefaultGLErrorCode(errorCode);
std::stringstream errorStream;
errorStream << "Internal Vulkan error: " << VulkanResultString(errorCode) << ", in " << file
<< ", line " << line << ".";
mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str()));
} }
} // namespace rx } // namespace rx
...@@ -20,7 +20,7 @@ namespace rx ...@@ -20,7 +20,7 @@ namespace rx
struct FeaturesVk; struct FeaturesVk;
class RendererVk; class RendererVk;
class ContextVk : public ContextImpl class ContextVk : public ContextImpl, public vk::Context
{ {
public: public:
ContextVk(const gl::ContextState &state, RendererVk *renderer); ContextVk(const gl::ContextState &state, RendererVk *renderer);
...@@ -154,7 +154,6 @@ class ContextVk : public ContextImpl ...@@ -154,7 +154,6 @@ class ContextVk : public ContextImpl
gl::Error memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override; gl::Error memoryBarrierByRegion(const gl::Context *context, GLbitfield barriers) override;
VkDevice getDevice() const; VkDevice getDevice() const;
RendererVk *getRenderer() const { return mRenderer; }
const FeaturesVk &getFeatures() const; const FeaturesVk &getFeatures() const;
void invalidateCurrentPipeline(); void invalidateCurrentPipeline();
...@@ -170,6 +169,8 @@ class ContextVk : public ContextImpl ...@@ -170,6 +169,8 @@ class ContextVk : public ContextImpl
gl::Texture **textureOut); gl::Texture **textureOut);
void updateColorMask(const gl::BlendState &blendState); void updateColorMask(const gl::BlendState &blendState);
void handleError(VkResult errorCode, const char *file, unsigned int line) override;
private: private:
gl::Error initPipeline(); gl::Error initPipeline();
gl::Error setupDraw(const gl::Context *context, gl::Error setupDraw(const gl::Context *context,
...@@ -181,9 +182,8 @@ class ContextVk : public ContextImpl ...@@ -181,9 +182,8 @@ class ContextVk : public ContextImpl
void updateFlipViewportDrawFramebuffer(const gl::State &glState); void updateFlipViewportDrawFramebuffer(const gl::State &glState);
void updateFlipViewportReadFramebuffer(const gl::State &glState); void updateFlipViewportReadFramebuffer(const gl::State &glState);
vk::Error updateDriverUniforms(); angle::Result updateDriverUniforms();
RendererVk *mRenderer;
vk::PipelineAndSerial *mCurrentPipeline; vk::PipelineAndSerial *mCurrentPipeline;
gl::PrimitiveMode mCurrentDrawMode; gl::PrimitiveMode mCurrentDrawMode;
......
...@@ -19,25 +19,28 @@ ...@@ -19,25 +19,28 @@
namespace rx namespace rx
{ {
DisplayVk::DisplayVk(const egl::DisplayState &state) : DisplayImpl(state), mRenderer(nullptr) DisplayVk::DisplayVk(const egl::DisplayState &state)
: DisplayImpl(state), vk::Context(new RendererVk())
{ {
} }
DisplayVk::~DisplayVk() DisplayVk::~DisplayVk()
{ {
delete mRenderer;
} }
egl::Error DisplayVk::initialize(egl::Display *display) egl::Error DisplayVk::initialize(egl::Display *display)
{ {
ASSERT(!mRenderer && display != nullptr); ASSERT(mRenderer != nullptr && display != nullptr);
mRenderer.reset(new RendererVk()); angle::Result result = mRenderer->initialize(this, display->getAttributeMap(), getWSIName());
return mRenderer->initialize(display->getAttributeMap(), getWSIName()) ANGLE_TRY(angle::ToEGL(result, this, EGL_NOT_INITIALIZED));
.toEGL(EGL_NOT_INITIALIZED); return egl::NoError();
} }
void DisplayVk::terminate() void DisplayVk::terminate()
{ {
mRenderer.reset(nullptr); ASSERT(mRenderer);
mRenderer->onDestroy(this);
} }
egl::Error DisplayVk::makeCurrent(egl::Surface * /*drawSurface*/, egl::Error DisplayVk::makeCurrent(egl::Surface * /*drawSurface*/,
...@@ -82,7 +85,7 @@ egl::Error DisplayVk::waitClient(const gl::Context *context) ...@@ -82,7 +85,7 @@ egl::Error DisplayVk::waitClient(const gl::Context *context)
// http://anglebug.com/2504 // http://anglebug.com/2504
UNIMPLEMENTED(); UNIMPLEMENTED();
return mRenderer->finish(context); return angle::ToEGL(mRenderer->finish(this), this, EGL_BAD_ACCESS);
} }
egl::Error DisplayVk::waitNative(const gl::Context *context, EGLint engine) egl::Error DisplayVk::waitNative(const gl::Context *context, EGLint engine)
...@@ -142,7 +145,7 @@ ContextImpl *DisplayVk::createContext(const gl::ContextState &state, ...@@ -142,7 +145,7 @@ ContextImpl *DisplayVk::createContext(const gl::ContextState &state,
const gl::Context *shareContext, const gl::Context *shareContext,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
return new ContextVk(state, mRenderer.get()); return new ContextVk(state, mRenderer);
} }
StreamProducerImpl *DisplayVk::createStreamProducerD3DTexture( StreamProducerImpl *DisplayVk::createStreamProducerD3DTexture(
...@@ -169,4 +172,17 @@ void DisplayVk::generateCaps(egl::Caps *outCaps) const ...@@ -169,4 +172,17 @@ void DisplayVk::generateCaps(egl::Caps *outCaps) const
outCaps->textureNPOT = true; outCaps->textureNPOT = true;
} }
void DisplayVk::handleError(VkResult result, const char *file, unsigned int line)
{
std::stringstream errorStream;
errorStream << "Internal Vulkan error: " << VulkanResultString(result) << ", in " << file
<< ", line " << line << ".";
mStoredErrorString = errorStream.str();
}
// TODO(jmadill): Remove this. http://anglebug.com/2491
egl::Error DisplayVk::getEGLError(EGLint errorCode)
{
return egl::Error(errorCode, 0, std::move(mStoredErrorString));
}
} // namespace rx } // namespace rx
...@@ -11,12 +11,13 @@ ...@@ -11,12 +11,13 @@
#define LIBANGLE_RENDERER_VULKAN_DISPLAYVK_H_ #define LIBANGLE_RENDERER_VULKAN_DISPLAYVK_H_
#include "libANGLE/renderer/DisplayImpl.h" #include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/renderer/vulkan/vk_utils.h"
namespace rx namespace rx
{ {
class RendererVk; class RendererVk;
class DisplayVk : public DisplayImpl class DisplayVk : public DisplayImpl, public vk::Context
{ {
public: public:
DisplayVk(const egl::DisplayState &state); DisplayVk(const egl::DisplayState &state);
...@@ -65,8 +66,6 @@ class DisplayVk : public DisplayImpl ...@@ -65,8 +66,6 @@ class DisplayVk : public DisplayImpl
const egl::AttributeMap &attribs) override; const egl::AttributeMap &attribs) override;
gl::Version getMaxSupportedESVersion() const override; gl::Version getMaxSupportedESVersion() const override;
RendererVk *getRenderer() const { return mRenderer.get(); }
virtual const char *getWSIName() const = 0; virtual const char *getWSIName() const = 0;
// Determine if a config with given formats and sample counts is supported. This callback may // Determine if a config with given formats and sample counts is supported. This callback may
...@@ -74,6 +73,11 @@ class DisplayVk : public DisplayImpl ...@@ -74,6 +73,11 @@ class DisplayVk : public DisplayImpl
// returning a bool to indicate if the config should be supported. // returning a bool to indicate if the config should be supported.
virtual bool checkConfigSupport(egl::Config *config) = 0; virtual bool checkConfigSupport(egl::Config *config) = 0;
void handleError(VkResult result, const char *file, unsigned int line) override;
// TODO(jmadill): Remove this once refactor is done. http://anglebug.com/2491
egl::Error getEGLError(EGLint errorCode);
private: private:
virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window,
...@@ -82,7 +86,7 @@ class DisplayVk : public DisplayImpl ...@@ -82,7 +86,7 @@ class DisplayVk : public DisplayImpl
void generateExtensions(egl::DisplayExtensions *outExtensions) const override; void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override; void generateCaps(egl::Caps *outCaps) const override;
std::unique_ptr<RendererVk> mRenderer; std::string mStoredErrorString;
}; };
} // namespace rx } // namespace rx
......
...@@ -89,17 +89,17 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource ...@@ -89,17 +89,17 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
GLfloat *xy) const override; GLfloat *xy) const override;
RenderTargetVk *getDepthStencilRenderTarget() const; RenderTargetVk *getDepthStencilRenderTarget() const;
const vk::RenderPassDesc &getRenderPassDesc(); const vk::RenderPassDesc &getRenderPassDesc();
vk::Error getCommandBufferForDraw(ContextVk *contextVk, angle::Result getCommandBufferForDraw(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut, vk::CommandBuffer **commandBufferOut,
vk::RecordingMode *modeOut); vk::RecordingMode *modeOut);
// Internal helper function for readPixels operations. // Internal helper function for readPixels operations.
vk::Error readPixelsImpl(const gl::Context *context, angle::Result readPixelsImpl(ContextVk *contextVk,
const gl::Rectangle &area, const gl::Rectangle &area,
const PackPixelsParams &packPixelsParams, const PackPixelsParams &packPixelsParams,
const VkImageAspectFlags &copyAspectFlags, const VkImageAspectFlags &copyAspectFlags,
RenderTargetVk *renderTarget, RenderTargetVk *renderTarget,
void *pixels); void *pixels);
const gl::Extents &getReadImageExtents() const; const gl::Extents &getReadImageExtents() const;
...@@ -110,45 +110,44 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource ...@@ -110,45 +110,44 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
FramebufferVk(const gl::FramebufferState &state); FramebufferVk(const gl::FramebufferState &state);
FramebufferVk(const gl::FramebufferState &state, WindowSurfaceVk *backbuffer); FramebufferVk(const gl::FramebufferState &state, WindowSurfaceVk *backbuffer);
gl::Error blitUsingCopy(vk::CommandBuffer *commandBuffer, void blitUsingCopy(vk::CommandBuffer *commandBuffer,
const gl::Rectangle &readArea, const gl::Rectangle &readArea,
const gl::Rectangle &destArea, const gl::Rectangle &destArea,
RenderTargetVk *readRenderTarget,
RenderTargetVk *drawRenderTarget,
const gl::Rectangle *scissor,
bool blitDepthBuffer,
bool blitStencilBuffer);
gl::Error blitWithReadback(const gl::Context *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
bool blitDepthBuffer,
bool blitStencilBuffer,
vk::CommandBuffer *commandBuffer,
RenderTargetVk *readRenderTarget,
RenderTargetVk *drawRenderTarget);
vk::Error getFramebuffer(RendererVk *rendererVk, vk::Framebuffer **framebufferOut);
gl::Error clearWithClearAttachments(ContextVk *contextVk,
bool clearColor,
bool clearDepth,
bool clearStencil);
gl::Error clearWithDraw(const gl::Context *context, VkColorComponentFlags colorMaskFlags);
void updateActiveColorMasks(size_t colorIndex, bool r, bool g, bool b, bool a);
gl::Error blitImpl(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer,
const gl::Rectangle &readRectIn,
const gl::Rectangle &drawRectIn,
RenderTargetVk *readRenderTarget, RenderTargetVk *readRenderTarget,
RenderTargetVk *drawRenderTarget, RenderTargetVk *drawRenderTarget,
GLenum filter,
const gl::Rectangle *scissor, const gl::Rectangle *scissor,
bool colorBlit, bool blitDepthBuffer,
bool depthBlit, bool blitStencilBuffer);
bool stencilBlit, angle::Result blitWithReadback(ContextVk *contextVk,
bool flipSource, const gl::Rectangle &sourceArea,
bool flipDest); const gl::Rectangle &destArea,
bool blitDepthBuffer,
bool blitStencilBuffer,
vk::CommandBuffer *commandBuffer,
RenderTargetVk *readRenderTarget,
RenderTargetVk *drawRenderTarget);
angle::Result getFramebuffer(ContextVk *contextVk, vk::Framebuffer **framebufferOut);
angle::Result clearWithClearAttachments(ContextVk *contextVk,
bool clearColor,
bool clearDepth,
bool clearStencil);
angle::Result clearWithDraw(ContextVk *contextVk, VkColorComponentFlags colorMaskFlags);
void updateActiveColorMasks(size_t colorIndex, bool r, bool g, bool b, bool a);
void blitImpl(vk::CommandBuffer *commandBuffer,
const gl::Rectangle &readRectIn,
const gl::Rectangle &drawRectIn,
RenderTargetVk *readRenderTarget,
RenderTargetVk *drawRenderTarget,
GLenum filter,
const gl::Rectangle *scissor,
bool colorBlit,
bool depthBlit,
bool stencilBlit,
bool flipSource,
bool flipDest);
WindowSurfaceVk *mBackbuffer; WindowSurfaceVk *mBackbuffer;
......
...@@ -104,7 +104,7 @@ class ProgramVk : public ProgramImpl ...@@ -104,7 +104,7 @@ class ProgramVk : public ProgramImpl
const vk::ShaderModule &getLinkedFragmentModule() const; const vk::ShaderModule &getLinkedFragmentModule() const;
Serial getFragmentModuleSerial() const; Serial getFragmentModuleSerial() const;
vk::Error updateUniforms(ContextVk *contextVk); angle::Result updateUniforms(ContextVk *contextVk);
const std::vector<VkDescriptorSet> &getDescriptorSets() const; const std::vector<VkDescriptorSet> &getDescriptorSets() const;
const uint32_t *getDynamicOffsets(); const uint32_t *getDynamicOffsets();
...@@ -133,10 +133,10 @@ class ProgramVk : public ProgramImpl ...@@ -133,10 +133,10 @@ class ProgramVk : public ProgramImpl
GLboolean transpose, GLboolean transpose,
const GLfloat *value); const GLfloat *value);
vk::Error reset(ContextVk *contextVk); angle::Result reset(ContextVk *contextVk);
vk::Error allocateDescriptorSet(ContextVk *contextVk, uint32_t descriptorSetIndex); angle::Result allocateDescriptorSet(ContextVk *contextVk, uint32_t descriptorSetIndex);
gl::Error initDefaultUniformBlocks(const gl::Context *glContext); gl::Error initDefaultUniformBlocks(const gl::Context *glContext);
vk::Error updateDefaultUniformsDescriptorSet(ContextVk *contextVk); angle::Result updateDefaultUniformsDescriptorSet(ContextVk *contextVk);
template <class T> template <class T>
void getUniformImpl(GLint location, T *v, GLenum entryPointType) const; void getUniformImpl(GLint location, T *v, GLenum entryPointType) const;
......
...@@ -53,7 +53,6 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context, ...@@ -53,7 +53,6 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context,
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = contextVk->getRenderer();
const vk::Format &vkFormat = renderer->getFormat(internalformat); const vk::Format &vkFormat = renderer->getFormat(internalformat);
VkDevice device = renderer->getDevice();
if (mImage.valid()) if (mImage.valid())
{ {
...@@ -79,19 +78,19 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context, ...@@ -79,19 +78,19 @@ gl::Error RenderbufferVk::setStorage(const gl::Context *context,
(isDepthOrStencilFormat ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : 0); (isDepthOrStencilFormat ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : 0);
gl::Extents extents(static_cast<int>(width), static_cast<int>(height), 1); gl::Extents extents(static_cast<int>(width), static_cast<int>(height), 1);
ANGLE_TRY(mImage.init(device, gl::TextureType::_2D, extents, vkFormat, 1, usage, 1)); ANGLE_TRY(mImage.init(contextVk, gl::TextureType::_2D, extents, vkFormat, 1, usage, 1));
VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
ANGLE_TRY(mImage.initMemory(device, renderer->getMemoryProperties(), flags)); ANGLE_TRY(mImage.initMemory(contextVk, renderer->getMemoryProperties(), flags));
VkImageAspectFlags aspect = vk::GetFormatAspectFlags(textureFormat); VkImageAspectFlags aspect = vk::GetFormatAspectFlags(textureFormat);
ANGLE_TRY(mImage.initImageView(device, gl::TextureType::_2D, aspect, gl::SwizzleState(), ANGLE_TRY(mImage.initImageView(contextVk, gl::TextureType::_2D, aspect, gl::SwizzleState(),
&mImageView, 1)); &mImageView, 1));
// TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361 // TODO(jmadill): Fold this into the RenderPass load/store ops. http://anglebug.com/2361
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(beginWriteResource(renderer, &commandBuffer)); ANGLE_TRY(beginWriteResource(contextVk, &commandBuffer));
if (isDepthOrStencilFormat) if (isDepthOrStencilFormat)
{ {
......
...@@ -41,7 +41,10 @@ class RendererVk : angle::NonCopyable ...@@ -41,7 +41,10 @@ class RendererVk : angle::NonCopyable
RendererVk(); RendererVk();
~RendererVk(); ~RendererVk();
vk::Error initialize(const egl::AttributeMap &attribs, const char *wsiName); angle::Result initialize(vk::Context *context,
const egl::AttributeMap &attribs,
const char *wsiName);
void onDestroy(vk::Context *context);
std::string getVendorString() const; std::string getVendorString() const;
std::string getRendererDescription() const; std::string getRendererDescription() const;
...@@ -55,12 +58,14 @@ class RendererVk : angle::NonCopyable ...@@ -55,12 +58,14 @@ class RendererVk : angle::NonCopyable
VkQueue getQueue() const { return mQueue; } VkQueue getQueue() const { return mQueue; }
VkDevice getDevice() const { return mDevice; } VkDevice getDevice() const { return mDevice; }
vk::Error selectPresentQueueForSurface(VkSurfaceKHR surface, uint32_t *presentQueueOut); angle::Result selectPresentQueueForSurface(vk::Context *context,
VkSurfaceKHR surface,
uint32_t *presentQueueOut);
vk::Error finish(const gl::Context *context); angle::Result finish(vk::Context *context);
vk::Error flush(const gl::Context *context, angle::Result flush(vk::Context *context,
const vk::Semaphore &waitSemaphore, const vk::Semaphore &waitSemaphore,
const vk::Semaphore &signalSemaphore); const vk::Semaphore &signalSemaphore);
const vk::CommandPool &getCommandPool() const; const vk::CommandPool &getCommandPool() const;
...@@ -101,35 +106,41 @@ class RendererVk : angle::NonCopyable ...@@ -101,35 +106,41 @@ class RendererVk : angle::NonCopyable
const vk::Format &getFormat(angle::Format::ID formatID) const { return mFormatTable[formatID]; } const vk::Format &getFormat(angle::Format::ID formatID) const { return mFormatTable[formatID]; }
vk::Error getCompatibleRenderPass(const vk::RenderPassDesc &desc, angle::Result getCompatibleRenderPass(vk::Context *context,
vk::RenderPass **renderPassOut); const vk::RenderPassDesc &desc,
vk::Error getRenderPassWithOps(const vk::RenderPassDesc &desc, vk::RenderPass **renderPassOut);
const vk::AttachmentOpsArray &ops, angle::Result getRenderPassWithOps(vk::Context *context,
vk::RenderPass **renderPassOut); const vk::RenderPassDesc &desc,
const vk::AttachmentOpsArray &ops,
vk::RenderPass **renderPassOut);
// For getting a vk::Pipeline for the an application's draw call. RenderPassDesc is automatic. // For getting a vk::Pipeline for the an application's draw call. RenderPassDesc is automatic.
vk::Error getAppPipeline(const ProgramVk *programVk, angle::Result getAppPipeline(vk::Context *context,
const vk::PipelineDesc &desc, const ProgramVk *programVk,
const gl::AttributesMask &activeAttribLocationsMask, const vk::PipelineDesc &desc,
vk::PipelineAndSerial **pipelineOut); const gl::AttributesMask &activeAttribLocationsMask,
vk::PipelineAndSerial **pipelineOut);
// For getting a vk::Pipeline for an internal draw call. Use an explicit RenderPass. // For getting a vk::Pipeline for an internal draw call. Use an explicit RenderPass.
vk::Error getInternalPipeline(const vk::ShaderAndSerial &vertexShader, angle::Result getInternalPipeline(vk::Context *context,
const vk::ShaderAndSerial &fragmentShader, const vk::ShaderAndSerial &vertexShader,
const vk::PipelineLayout &pipelineLayout, const vk::ShaderAndSerial &fragmentShader,
const vk::PipelineDesc &pipelineDesc, const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const vk::PipelineDesc &pipelineDesc,
vk::PipelineAndSerial **pipelineOut); const gl::AttributesMask &activeAttribLocationsMask,
vk::PipelineAndSerial **pipelineOut);
// Queries the descriptor set layout cache. Creates the layout if not present. // Queries the descriptor set layout cache. Creates the layout if not present.
vk::Error getDescriptorSetLayout( angle::Result getDescriptorSetLayout(
vk::Context *context,
const vk::DescriptorSetLayoutDesc &desc, const vk::DescriptorSetLayoutDesc &desc,
vk::BindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut); vk::BindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut);
// Queries the pipeline layout cache. Creates the layout if not present. // Queries the pipeline layout cache. Creates the layout if not present.
vk::Error getPipelineLayout(const vk::PipelineLayoutDesc &desc, angle::Result getPipelineLayout(vk::Context *context,
const vk::DescriptorSetLayoutPointerArray &descriptorSetLayouts, const vk::PipelineLayoutDesc &desc,
vk::BindingPointer<vk::PipelineLayout> *pipelineLayoutOut); const vk::DescriptorSetLayoutPointerArray &descriptorSetLayouts,
vk::BindingPointer<vk::PipelineLayout> *pipelineLayoutOut);
// This should only be called from ResourceVk. // This should only be called from ResourceVk.
// TODO(jmadill): Keep in ContextVk to enable threaded rendering. // TODO(jmadill): Keep in ContextVk to enable threaded rendering.
...@@ -142,12 +153,14 @@ class RendererVk : angle::NonCopyable ...@@ -142,12 +153,14 @@ class RendererVk : angle::NonCopyable
const FeaturesVk &getFeatures() const { return mFeatures; } const FeaturesVk &getFeatures() const { return mFeatures; }
private: private:
vk::Error initializeDevice(uint32_t queueFamilyIndex); angle::Result initializeDevice(vk::Context *context, uint32_t queueFamilyIndex);
void ensureCapsInitialized() const; void ensureCapsInitialized() const;
vk::Error submitFrame(const VkSubmitInfo &submitInfo, vk::CommandBuffer &&commandBuffer); angle::Result submitFrame(vk::Context *context,
vk::Error checkInFlightCommands(); const VkSubmitInfo &submitInfo,
vk::CommandBuffer &&commandBuffer);
angle::Result checkInFlightCommands(vk::Context *context);
void freeAllInFlightResources(); void freeAllInFlightResources();
vk::Error flushCommandGraph(const gl::Context *context, vk::CommandBuffer *commandBatch); angle::Result flushCommandGraph(vk::Context *context, vk::CommandBuffer *commandBatch);
void initFeatures(); void initFeatures();
mutable bool mCapsInitialized; mutable bool mCapsInitialized;
......
...@@ -66,10 +66,10 @@ class OffscreenSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource ...@@ -66,10 +66,10 @@ class OffscreenSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource
AttachmentImage(vk::CommandGraphResource *commandGraphResource); AttachmentImage(vk::CommandGraphResource *commandGraphResource);
~AttachmentImage(); ~AttachmentImage();
egl::Error initialize(const egl::Display *display, angle::Result initialize(DisplayVk *displayVk,
EGLint width, EGLint width,
EGLint height, EGLint height,
const vk::Format &vkFormat); const vk::Format &vkFormat);
void destroy(const egl::Display *display, Serial storedQueueSerial); void destroy(const egl::Display *display, Serial storedQueueSerial);
vk::ImageHelper image; vk::ImageHelper image;
...@@ -77,6 +77,8 @@ class OffscreenSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource ...@@ -77,6 +77,8 @@ class OffscreenSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource
RenderTargetVk renderTarget; RenderTargetVk renderTarget;
}; };
angle::Result initializeImpl(DisplayVk *displayVk);
EGLint mWidth; EGLint mWidth;
EGLint mHeight; EGLint mHeight;
...@@ -127,9 +129,9 @@ class WindowSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource ...@@ -127,9 +129,9 @@ class WindowSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource
gl::Error initializeContents(const gl::Context *context, gl::Error initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex) override; const gl::ImageIndex &imageIndex) override;
vk::Error getCurrentFramebuffer(VkDevice device, angle::Result getCurrentFramebuffer(vk::Context *context,
const vk::RenderPass &compatibleRenderPass, const vk::RenderPass &compatibleRenderPass,
vk::Framebuffer **framebufferOut); vk::Framebuffer **framebufferOut);
protected: protected:
EGLNativeWindowType mNativeWindowType; EGLNativeWindowType mNativeWindowType;
...@@ -137,9 +139,10 @@ class WindowSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource ...@@ -137,9 +139,10 @@ class WindowSurfaceVk : public SurfaceImpl, public vk::CommandGraphResource
VkInstance mInstance; VkInstance mInstance;
private: private:
virtual vk::Error createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) = 0; virtual angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) = 0;
vk::Error initializeImpl(RendererVk *renderer); angle::Result initializeImpl(DisplayVk *displayVk);
vk::Error nextSwapchainImage(RendererVk *renderer); angle::Result nextSwapchainImage(DisplayVk *displayVk);
angle::Result swapImpl(DisplayVk *displayVk);
VkSwapchainKHR mSwapchain; VkSwapchainKHR mSwapchain;
......
...@@ -28,43 +28,43 @@ class PixelBuffer final : angle::NonCopyable ...@@ -28,43 +28,43 @@ class PixelBuffer final : angle::NonCopyable
void removeStagedUpdates(const gl::ImageIndex &index); void removeStagedUpdates(const gl::ImageIndex &index);
vk::Error stageSubresourceUpdate(ContextVk *contextVk, angle::Result 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,
const gl::InternalFormat &formatInfo, const gl::InternalFormat &formatInfo,
const gl::PixelUnpackState &unpack, const gl::PixelUnpackState &unpack,
GLenum type, GLenum type,
const uint8_t *pixels); const uint8_t *pixels);
vk::Error stageSubresourceUpdateAndGetData(RendererVk *renderer, angle::Result stageSubresourceUpdateAndGetData(ContextVk *contextVk,
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);
vk::Error stageSubresourceUpdateFromFramebuffer(const gl::Context *context, angle::Result 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,
const gl::Extents &dstExtent, const gl::Extents &dstExtent,
const gl::InternalFormat &formatInfo, const gl::InternalFormat &formatInfo,
FramebufferVk *framebufferVk); FramebufferVk *framebufferVk);
// 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.
vk::Error allocate(RendererVk *renderer, angle::Result allocate(ContextVk *contextVk,
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
uint32_t *offsetOut, uint32_t *offsetOut,
bool *newBufferAllocatedOut); bool *newBufferAllocatedOut);
vk::Error flushUpdatesToImage(RendererVk *renderer, angle::Result flushUpdatesToImage(ContextVk *contextVk,
uint32_t levelCount, uint32_t levelCount,
vk::ImageHelper *image, vk::ImageHelper *image,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
bool empty() const; bool empty() const;
...@@ -175,36 +175,37 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource ...@@ -175,36 +175,37 @@ class TextureVk : public TextureImpl, public vk::CommandGraphResource
const vk::ImageView &getImageView() const; const vk::ImageView &getImageView() const;
const vk::Sampler &getSampler() const; const vk::Sampler &getSampler() const;
vk::Error ensureImageInitialized(ContextVk *contextVk); angle::Result ensureImageInitialized(ContextVk *contextVk);
private: private:
vk::Error generateMipmapWithBlit(RendererVk *renderer); angle::Result generateMipmapWithBlit(ContextVk *contextVk);
vk::Error generateMipmapWithCPU(const gl::Context *context); angle::Result generateMipmapWithCPU(const gl::Context *context);
vk::Error generateMipmapLevelsWithCPU(ContextVk *contextVk, angle::Result generateMipmapLevelsWithCPU(ContextVk *contextVk,
const angle::Format &sourceFormat, const angle::Format &sourceFormat,
GLuint layer, GLuint layer,
GLuint firstMipLevel, GLuint firstMipLevel,
GLuint maxMipLevel, GLuint maxMipLevel,
size_t sourceWidth, size_t sourceWidth,
size_t sourceHeight, size_t sourceHeight,
size_t sourceRowPitch, size_t sourceRowPitch,
uint8_t *sourceData); uint8_t *sourceData);
gl::Error copySubImageImpl(const gl::Context *context, angle::Result copySubImageImpl(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
const gl::Offset &destOffset, const gl::Offset &destOffset,
const gl::Rectangle &sourceArea, const gl::Rectangle &sourceArea,
const gl::InternalFormat &internalFormat, const gl::InternalFormat &internalFormat,
gl::Framebuffer *source); gl::Framebuffer *source);
vk::Error initImage(ContextVk *contextVk, angle::Result initImage(ContextVk *contextVk,
const vk::Format &format, const vk::Format &format,
const gl::Extents &extents, const gl::Extents &extents,
const uint32_t levelCount, const uint32_t levelCount,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
void releaseImage(const gl::Context *context, RendererVk *renderer); void releaseImage(const gl::Context *context, RendererVk *renderer);
vk::Error getCommandBufferForWrite(RendererVk *renderer, vk::CommandBuffer **commandBufferOut); angle::Result getCommandBufferForWrite(ContextVk *contextVk,
vk::CommandBuffer **commandBufferOut);
uint32_t getLevelCount() const; uint32_t getLevelCount() const;
vk::ImageHelper mImage; vk::ImageHelper mImage;
......
...@@ -45,22 +45,14 @@ class VertexArrayVk : public VertexArrayImpl ...@@ -45,22 +45,14 @@ class VertexArrayVk : public VertexArrayImpl
const gl::AttribArray<VkBuffer> &getCurrentArrayBufferHandles() const; const gl::AttribArray<VkBuffer> &getCurrentArrayBufferHandles() const;
const gl::AttribArray<VkDeviceSize> &getCurrentArrayBufferOffsets() const; const gl::AttribArray<VkDeviceSize> &getCurrentArrayBufferOffsets() const;
void updateDrawDependencies(vk::CommandGraphResource *drawFramebuffer,
const gl::AttributesMask &activeAttribsMask,
vk::CommandGraphResource *elementArrayBufferOverride,
Serial serial,
bool isDrawElements);
void getPackedInputDescriptions(const RendererVk *rendererVk, vk::PipelineDesc *pipelineDesc); void getPackedInputDescriptions(const RendererVk *rendererVk, vk::PipelineDesc *pipelineDesc);
// Draw call handling. // Draw call handling.
gl::Error drawArrays(const gl::Context *context, gl::Error drawArrays(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
bool shouldApplyVertexArray); bool shouldApplyVertexArray);
gl::Error drawElements(const gl::Context *context, gl::Error drawElements(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
bool shouldApplyVertexArray); bool shouldApplyVertexArray);
...@@ -84,19 +76,17 @@ class VertexArrayVk : public VertexArrayImpl ...@@ -84,19 +76,17 @@ class VertexArrayVk : public VertexArrayImpl
void updateElementArrayBufferReadDependency(vk::CommandGraphResource *drawFramebuffer, void updateElementArrayBufferReadDependency(vk::CommandGraphResource *drawFramebuffer,
Serial serial); Serial serial);
gl::Error streamVertexData(RendererVk *renderer, angle::Result streamVertexData(ContextVk *contextVk,
const gl::AttributesMask &attribsToStream, const gl::AttributesMask &attribsToStream,
const gl::DrawCallParams &drawCallParams); const gl::DrawCallParams &drawCallParams);
gl::Error streamIndexData(RendererVk *renderer, const gl::DrawCallParams &drawCallParams); angle::Result streamIndexData(ContextVk *contextVk, const gl::DrawCallParams &drawCallParams);
gl::Error onDraw(const gl::Context *context, gl::Error onDraw(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
bool newCommandBuffer); bool newCommandBuffer);
gl::Error onIndexedDraw(const gl::Context *context, gl::Error onIndexedDraw(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer, vk::CommandBuffer *commandBuffer,
bool newCommandBuffer); bool newCommandBuffer);
......
...@@ -24,7 +24,7 @@ WindowSurfaceVkAndroid::WindowSurfaceVkAndroid(const egl::SurfaceState &surfaceS ...@@ -24,7 +24,7 @@ WindowSurfaceVkAndroid::WindowSurfaceVkAndroid(const egl::SurfaceState &surfaceS
{ {
} }
vk::Error WindowSurfaceVkAndroid::createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) angle::Result WindowSurfaceVkAndroid::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
{ {
VkAndroidSurfaceCreateInfoKHR createInfo; VkAndroidSurfaceCreateInfoKHR createInfo;
...@@ -32,15 +32,15 @@ vk::Error WindowSurfaceVkAndroid::createSurfaceVk(RendererVk *renderer, gl::Exte ...@@ -32,15 +32,15 @@ vk::Error WindowSurfaceVkAndroid::createSurfaceVk(RendererVk *renderer, gl::Exte
createInfo.pNext = nullptr; createInfo.pNext = nullptr;
createInfo.flags = 0; createInfo.flags = 0;
createInfo.window = mNativeWindowType; createInfo.window = mNativeWindowType;
ANGLE_VK_TRY( ANGLE_VK_TRY(context, vkCreateAndroidSurfaceKHR(context->getRenderer()->getInstance(),
vkCreateAndroidSurfaceKHR(renderer->getInstance(), &createInfo, nullptr, &mSurface)); &createInfo, nullptr, &mSurface));
int32_t width = ANativeWindow_getWidth(mNativeWindowType); int32_t width = ANativeWindow_getWidth(mNativeWindowType);
int32_t height = ANativeWindow_getHeight(mNativeWindowType); int32_t height = ANativeWindow_getHeight(mNativeWindowType);
ANGLE_VK_CHECK(width > 0 && height > 0, VK_ERROR_INITIALIZATION_FAILED); ANGLE_VK_CHECK(context, width > 0 && height > 0, VK_ERROR_INITIALIZATION_FAILED);
*extentsOut = gl::Extents(width, height, 0); *extentsOut = gl::Extents(width, height, 0);
return vk::NoError(); return angle::Result::Continue();
} }
} // namespace rx } // namespace rx
...@@ -24,7 +24,7 @@ class WindowSurfaceVkAndroid : public WindowSurfaceVk ...@@ -24,7 +24,7 @@ class WindowSurfaceVkAndroid : public WindowSurfaceVk
EGLint height); EGLint height);
private: private:
vk::Error createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) override; angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override;
}; };
} // namespace rx } // namespace rx
......
...@@ -342,13 +342,13 @@ class PipelineDesc final ...@@ -342,13 +342,13 @@ class PipelineDesc final
void initDefaults(); void initDefaults();
Error initializePipeline(VkDevice device, angle::Result initializePipeline(vk::Context *context,
const RenderPass &compatibleRenderPass, const RenderPass &compatibleRenderPass,
const PipelineLayout &pipelineLayout, const PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const ShaderModule &vertexModule, const ShaderModule &vertexModule,
const ShaderModule &fragmentModule, const ShaderModule &fragmentModule,
Pipeline *pipelineOut) const; Pipeline *pipelineOut) const;
void updateViewport(FramebufferVk *framebufferVk, void updateViewport(FramebufferVk *framebufferVk,
const gl::Rectangle &viewport, const gl::Rectangle &viewport,
...@@ -572,15 +572,15 @@ class RenderPassCache final : angle::NonCopyable ...@@ -572,15 +572,15 @@ class RenderPassCache final : angle::NonCopyable
void destroy(VkDevice device); void destroy(VkDevice device);
vk::Error getCompatibleRenderPass(VkDevice device, angle::Result getCompatibleRenderPass(vk::Context *context,
Serial serial, Serial serial,
const vk::RenderPassDesc &desc, const vk::RenderPassDesc &desc,
vk::RenderPass **renderPassOut); vk::RenderPass **renderPassOut);
vk::Error getRenderPassWithOps(VkDevice device, angle::Result getRenderPassWithOps(vk::Context *context,
Serial serial, Serial serial,
const vk::RenderPassDesc &desc, const vk::RenderPassDesc &desc,
const vk::AttachmentOpsArray &attachmentOps, const vk::AttachmentOpsArray &attachmentOps,
vk::RenderPass **renderPassOut); vk::RenderPass **renderPassOut);
private: private:
// Use a two-layer caching scheme. The top level matches the "compatible" RenderPass elements. // Use a two-layer caching scheme. The top level matches the "compatible" RenderPass elements.
...@@ -601,14 +601,14 @@ class PipelineCache final : angle::NonCopyable ...@@ -601,14 +601,14 @@ class PipelineCache final : angle::NonCopyable
void destroy(VkDevice device); void destroy(VkDevice device);
void populate(const vk::PipelineDesc &desc, vk::Pipeline &&pipeline); void populate(const vk::PipelineDesc &desc, vk::Pipeline &&pipeline);
vk::Error getPipeline(VkDevice device, angle::Result getPipeline(vk::Context *context,
const vk::RenderPass &compatibleRenderPass, const vk::RenderPass &compatibleRenderPass,
const vk::PipelineLayout &pipelineLayout, const vk::PipelineLayout &pipelineLayout,
const gl::AttributesMask &activeAttribLocationsMask, const gl::AttributesMask &activeAttribLocationsMask,
const vk::ShaderModule &vertexModule, const vk::ShaderModule &vertexModule,
const vk::ShaderModule &fragmentModule, const vk::ShaderModule &fragmentModule,
const vk::PipelineDesc &desc, const vk::PipelineDesc &desc,
vk::PipelineAndSerial **pipelineOut); vk::PipelineAndSerial **pipelineOut);
private: private:
std::unordered_map<vk::PipelineDesc, vk::PipelineAndSerial> mPayload; std::unordered_map<vk::PipelineDesc, vk::PipelineAndSerial> mPayload;
...@@ -622,8 +622,8 @@ class DescriptorSetLayoutCache final : angle::NonCopyable ...@@ -622,8 +622,8 @@ class DescriptorSetLayoutCache final : angle::NonCopyable
void destroy(VkDevice device); void destroy(VkDevice device);
vk::Error getDescriptorSetLayout( angle::Result getDescriptorSetLayout(
VkDevice device, vk::Context *context,
const vk::DescriptorSetLayoutDesc &desc, const vk::DescriptorSetLayoutDesc &desc,
vk::BindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut); vk::BindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut);
...@@ -639,10 +639,10 @@ class PipelineLayoutCache final : angle::NonCopyable ...@@ -639,10 +639,10 @@ class PipelineLayoutCache final : angle::NonCopyable
void destroy(VkDevice device); void destroy(VkDevice device);
vk::Error getPipelineLayout(VkDevice device, angle::Result getPipelineLayout(vk::Context *context,
const vk::PipelineLayoutDesc &desc, const vk::PipelineLayoutDesc &desc,
const vk::DescriptorSetLayoutPointerArray &descriptorSetLayouts, const vk::DescriptorSetLayoutPointerArray &descriptorSetLayouts,
vk::BindingPointer<vk::PipelineLayout> *pipelineLayoutOut); vk::BindingPointer<vk::PipelineLayout> *pipelineLayoutOut);
private: private:
std::unordered_map<vk::PipelineLayoutDesc, vk::SharedPipelineLayout> mPayload; std::unordered_map<vk::PipelineLayoutDesc, vk::SharedPipelineLayout> mPayload;
......
...@@ -42,18 +42,18 @@ class DynamicBuffer : angle::NonCopyable ...@@ -42,18 +42,18 @@ class DynamicBuffer : angle::NonCopyable
// This call will allocate a new region at the end of the buffer. It internally may trigger // This call will allocate a new region at the end of the buffer. It internally may trigger
// a new buffer to be created (which is returned in 'newBufferAllocatedOut'. This param may // a new buffer to be created (which is returned in 'newBufferAllocatedOut'. This param may
// be nullptr. // be nullptr.
Error allocate(RendererVk *renderer, angle::Result allocate(Context *context,
size_t sizeInBytes, size_t sizeInBytes,
uint8_t **ptrOut, uint8_t **ptrOut,
VkBuffer *handleOut, VkBuffer *handleOut,
uint32_t *offsetOut, uint32_t *offsetOut,
bool *newBufferAllocatedOut); bool *newBufferAllocatedOut);
// After a sequence of writes, call flush to ensure the data is visible to the device. // After a sequence of writes, call flush to ensure the data is visible to the device.
Error flush(VkDevice device); angle::Result flush(Context *context);
// After a sequence of writes, call invalidate to ensure the data is visible to the host. // After a sequence of writes, call invalidate to ensure the data is visible to the host.
Error invalidate(VkDevice device); angle::Result invalidate(Context *context);
// This releases resources when they might currently be in use. // This releases resources when they might currently be in use.
void release(RendererVk *renderer); void release(RendererVk *renderer);
...@@ -100,21 +100,21 @@ class DynamicDescriptorPool final : angle::NonCopyable ...@@ -100,21 +100,21 @@ class DynamicDescriptorPool final : angle::NonCopyable
~DynamicDescriptorPool(); ~DynamicDescriptorPool();
// The DynamicDescriptorPool only handles one pool size at at time. // The DynamicDescriptorPool only handles one pool size at at time.
Error init(VkDevice device, const VkDescriptorPoolSize &poolSize); angle::Result init(Context *context, const VkDescriptorPoolSize &poolSize);
void destroy(VkDevice device); void destroy(VkDevice device);
// We use the descriptor type to help count the number of free sets. // We use the descriptor type to help count the number of free sets.
// By convention, sets are indexed according to the constants in vk_cache_utils.h. // By convention, sets are indexed according to the constants in vk_cache_utils.h.
Error allocateSets(ContextVk *contextVk, angle::Result allocateSets(Context *context,
const VkDescriptorSetLayout *descriptorSetLayout, const VkDescriptorSetLayout *descriptorSetLayout,
uint32_t descriptorSetCount, uint32_t descriptorSetCount,
VkDescriptorSet *descriptorSetsOut); VkDescriptorSet *descriptorSetsOut);
// For testing only! // For testing only!
void setMaxSetsPerPoolForTesting(uint32_t maxSetsPerPool); void setMaxSetsPerPoolForTesting(uint32_t maxSetsPerPool);
private: private:
Error allocateNewPool(VkDevice device); angle::Result allocateNewPool(Context *context);
uint32_t mMaxSetsPerPool; uint32_t mMaxSetsPerPool;
uint32_t mCurrentSetsCount; uint32_t mCurrentSetsCount;
...@@ -136,21 +136,21 @@ class LineLoopHelper final : public vk::CommandGraphResource ...@@ -136,21 +136,21 @@ class LineLoopHelper final : public vk::CommandGraphResource
LineLoopHelper(RendererVk *renderer); LineLoopHelper(RendererVk *renderer);
~LineLoopHelper(); ~LineLoopHelper();
vk::Error getIndexBufferForDrawArrays(RendererVk *renderer, angle::Result getIndexBufferForDrawArrays(Context *context,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *offsetOut); VkDeviceSize *offsetOut);
vk::Error getIndexBufferForElementArrayBuffer(RendererVk *renderer, angle::Result getIndexBufferForElementArrayBuffer(Context *context,
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);
vk::Error getIndexBufferForClientElementArray(RendererVk *renderer, angle::Result getIndexBufferForClientElementArray(Context *context,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
VkBuffer *bufferHandleOut, VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut); VkDeviceSize *bufferOffsetOut);
void destroy(VkDevice device); void destroy(VkDevice device);
...@@ -169,27 +169,27 @@ class ImageHelper final : angle::NonCopyable ...@@ -169,27 +169,27 @@ class ImageHelper final : angle::NonCopyable
bool valid() const; bool valid() const;
Error init(VkDevice device, angle::Result init(Context *context,
gl::TextureType textureType, gl::TextureType textureType,
const gl::Extents &extents, const gl::Extents &extents,
const Format &format, const Format &format,
GLint samples, GLint samples,
VkImageUsageFlags usage, VkImageUsageFlags usage,
uint32_t mipLevels); uint32_t mipLevels);
Error initMemory(VkDevice device, angle::Result initMemory(Context *context,
const MemoryProperties &memoryProperties, const MemoryProperties &memoryProperties,
VkMemoryPropertyFlags flags); VkMemoryPropertyFlags flags);
Error initImageView(VkDevice device, angle::Result initImageView(Context *context,
gl::TextureType textureType, gl::TextureType textureType,
VkImageAspectFlags aspectMask, VkImageAspectFlags aspectMask,
const gl::SwizzleState &swizzleMap, const gl::SwizzleState &swizzleMap,
ImageView *imageViewOut, ImageView *imageViewOut,
uint32_t levelCount); uint32_t levelCount);
Error init2DStaging(VkDevice device, angle::Result init2DStaging(Context *context,
const MemoryProperties &memoryProperties, const MemoryProperties &memoryProperties,
const Format &format, const Format &format,
const gl::Extents &extent, const gl::Extents &extent,
StagingUsage usage); StagingUsage usage);
VkImageAspectFlags getAspectFlags() const; VkImageAspectFlags getAspectFlags() const;
void release(Serial serial, RendererVk *renderer); void release(Serial serial, RendererVk *renderer);
...@@ -208,7 +208,6 @@ class ImageHelper final : angle::NonCopyable ...@@ -208,7 +208,6 @@ class ImageHelper final : angle::NonCopyable
const gl::Extents &getExtents() const; const gl::Extents &getExtents() const;
const Format &getFormat() const; const Format &getFormat() const;
GLint getSamples() const; GLint getSamples() const;
size_t getAllocatedMemorySize() const;
VkImageLayout getCurrentLayout() const { return mCurrentLayout; } VkImageLayout getCurrentLayout() const { return mCurrentLayout; }
void updateLayout(VkImageLayout layout) { mCurrentLayout = layout; } void updateLayout(VkImageLayout layout) { mCurrentLayout = layout; }
......
...@@ -30,16 +30,16 @@ void ShaderLibrary::destroy(VkDevice device) ...@@ -30,16 +30,16 @@ void ShaderLibrary::destroy(VkDevice device)
} }
} }
Error ShaderLibrary::getShader(RendererVk *renderer, angle::Result ShaderLibrary::getShader(vk::Context *context,
InternalShaderID shaderID, InternalShaderID shaderID,
const ShaderAndSerial **shaderOut) const ShaderAndSerial **shaderOut)
{ {
ShaderAndSerial &shader = mShaders[shaderID]; ShaderAndSerial &shader = mShaders[shaderID];
*shaderOut = &shader; *shaderOut = &shader;
if (shader.get().valid()) if (shader.get().valid())
{ {
return NoError(); return angle::Result::Continue();
} }
const priv::ShaderBlob &shaderCode = priv::GetInternalShaderBlob(shaderID); const priv::ShaderBlob &shaderCode = priv::GetInternalShaderBlob(shaderID);
...@@ -52,9 +52,9 @@ Error ShaderLibrary::getShader(RendererVk *renderer, ...@@ -52,9 +52,9 @@ Error ShaderLibrary::getShader(RendererVk *renderer,
createInfo.codeSize = shaderCode.codeSize; createInfo.codeSize = shaderCode.codeSize;
createInfo.pCode = shaderCode.code; createInfo.pCode = shaderCode.code;
ANGLE_TRY(shader.get().init(renderer->getDevice(), createInfo)); ANGLE_TRY(shader.get().init(context, createInfo));
shader.updateSerial(renderer->issueShaderSerial()); shader.updateSerial(context->getRenderer()->issueShaderSerial());
return NoError(); return angle::Result::Continue();
} }
} // namespace vk } // namespace vk
} // namespace rx } // namespace rx
...@@ -23,9 +23,9 @@ class ShaderLibrary final : angle::NonCopyable ...@@ -23,9 +23,9 @@ class ShaderLibrary final : angle::NonCopyable
ShaderLibrary(); ShaderLibrary();
~ShaderLibrary(); ~ShaderLibrary();
Error getShader(RendererVk *renderer, angle::Result getShader(Context *context,
InternalShaderID shaderID, InternalShaderID shaderID,
const ShaderAndSerial **shaderOut); const ShaderAndSerial **shaderOut);
void destroy(VkDevice device); void destroy(VkDevice device);
private: private:
......
...@@ -22,7 +22,7 @@ WindowSurfaceVkWin32::WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState ...@@ -22,7 +22,7 @@ WindowSurfaceVkWin32::WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState
{ {
} }
vk::Error WindowSurfaceVkWin32::createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) angle::Result WindowSurfaceVkWin32::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
{ {
VkWin32SurfaceCreateInfoKHR createInfo; VkWin32SurfaceCreateInfoKHR createInfo;
...@@ -31,13 +31,15 @@ vk::Error WindowSurfaceVkWin32::createSurfaceVk(RendererVk *renderer, gl::Extent ...@@ -31,13 +31,15 @@ vk::Error WindowSurfaceVkWin32::createSurfaceVk(RendererVk *renderer, gl::Extent
createInfo.flags = 0; createInfo.flags = 0;
createInfo.hinstance = GetModuleHandle(nullptr); createInfo.hinstance = GetModuleHandle(nullptr);
createInfo.hwnd = mNativeWindowType; createInfo.hwnd = mNativeWindowType;
ANGLE_VK_TRY(vkCreateWin32SurfaceKHR(renderer->getInstance(), &createInfo, nullptr, &mSurface)); ANGLE_VK_TRY(context, vkCreateWin32SurfaceKHR(context->getRenderer()->getInstance(),
&createInfo, nullptr, &mSurface));
RECT rect; RECT rect;
ANGLE_VK_CHECK(GetClientRect(mNativeWindowType, &rect) == TRUE, VK_ERROR_INITIALIZATION_FAILED); ANGLE_VK_CHECK(context, GetClientRect(mNativeWindowType, &rect) == TRUE,
VK_ERROR_INITIALIZATION_FAILED);
*extentsOut = gl::Extents(rect.right - rect.left, rect.bottom - rect.top, 0); *extentsOut = gl::Extents(rect.right - rect.left, rect.bottom - rect.top, 0);
return vk::NoError(); return angle::Result::Continue();
} }
} // namespace rx } // namespace rx
...@@ -24,7 +24,7 @@ class WindowSurfaceVkWin32 : public WindowSurfaceVk ...@@ -24,7 +24,7 @@ class WindowSurfaceVkWin32 : public WindowSurfaceVk
EGLint height); EGLint height);
private: private:
vk::Error createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) override; angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override;
}; };
} // namespace rx } // namespace rx
......
...@@ -23,7 +23,7 @@ WindowSurfaceVkXcb::WindowSurfaceVkXcb(const egl::SurfaceState &surfaceState, ...@@ -23,7 +23,7 @@ WindowSurfaceVkXcb::WindowSurfaceVkXcb(const egl::SurfaceState &surfaceState,
{ {
} }
vk::Error WindowSurfaceVkXcb::createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) angle::Result WindowSurfaceVkXcb::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
{ {
VkXcbSurfaceCreateInfoKHR createInfo; VkXcbSurfaceCreateInfoKHR createInfo;
...@@ -32,7 +32,8 @@ vk::Error WindowSurfaceVkXcb::createSurfaceVk(RendererVk *renderer, gl::Extents ...@@ -32,7 +32,8 @@ vk::Error WindowSurfaceVkXcb::createSurfaceVk(RendererVk *renderer, gl::Extents
createInfo.flags = 0; createInfo.flags = 0;
createInfo.connection = mXcbConnection; createInfo.connection = mXcbConnection;
createInfo.window = mNativeWindowType; createInfo.window = mNativeWindowType;
ANGLE_VK_TRY(vkCreateXcbSurfaceKHR(renderer->getInstance(), &createInfo, nullptr, &mSurface)); ANGLE_VK_TRY(context, vkCreateXcbSurfaceKHR(context->getRenderer()->getInstance(), &createInfo,
nullptr, &mSurface));
xcb_get_geometry_cookie_t cookie = xcb_get_geometry(mXcbConnection, mNativeWindowType); xcb_get_geometry_cookie_t cookie = xcb_get_geometry(mXcbConnection, mNativeWindowType);
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(mXcbConnection, cookie, nullptr); xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(mXcbConnection, cookie, nullptr);
...@@ -40,7 +41,7 @@ vk::Error WindowSurfaceVkXcb::createSurfaceVk(RendererVk *renderer, gl::Extents ...@@ -40,7 +41,7 @@ vk::Error WindowSurfaceVkXcb::createSurfaceVk(RendererVk *renderer, gl::Extents
free(reply); free(reply);
*extentsOut = gl::Extents(reply->width, reply->height, 0); *extentsOut = gl::Extents(reply->width, reply->height, 0);
return vk::NoError(); return angle::Result::Continue();
} }
} // namespace rx } // namespace rx
...@@ -27,7 +27,7 @@ class WindowSurfaceVkXcb : public WindowSurfaceVk ...@@ -27,7 +27,7 @@ class WindowSurfaceVkXcb : public WindowSurfaceVk
xcb_connection_t *conn); xcb_connection_t *conn);
private: private:
vk::Error createSurfaceVk(RendererVk *renderer, gl::Extents *extentsOut) override; angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override;
xcb_connection_t *mXcbConnection; xcb_connection_t *mXcbConnection;
}; };
......
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