Commit b90779eb by Jamie Madill Committed by Commit Bot

Vulkan: Pass fewer Context pointers around.

These weren't needed in many places. Also renames one FramebufferVk method. Bug: angleproject:2455 Change-Id: Idb641094fa3e180a85f357533d86bd0b19db4ec8 Reviewed-on: https://chromium-review.googlesource.com/1024826Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent bb3255b5
......@@ -96,7 +96,7 @@ gl::Error ContextVk::finish(const gl::Context *context)
return mRenderer->finish(context);
}
gl::Error ContextVk::initPipeline(const gl::Context *context)
gl::Error ContextVk::initPipeline()
{
ASSERT(!mCurrentPipeline);
......@@ -114,7 +114,7 @@ gl::Error ContextVk::initPipeline(const gl::Context *context)
vertexArrayVk->getPackedInputDescriptions(mPipelineDesc.get());
// Ensure that the RenderPass description is updated.
mPipelineDesc->updateRenderPassDesc(framebufferVk->getRenderPassDesc(context));
mPipelineDesc->updateRenderPassDesc(framebufferVk->getRenderPassDesc());
// TODO(jmadill): Validate with ASSERT against physical device limits/caps?
ANGLE_TRY(mRenderer->getPipeline(programVk, *mPipelineDesc, activeAttribLocationsMask,
......@@ -123,8 +123,7 @@ gl::Error ContextVk::initPipeline(const gl::Context *context)
return gl::NoError();
}
gl::Error ContextVk::setupDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
gl::Error ContextVk::setupDraw(const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode **drawNodeOut,
bool *newCommandBufferOut)
{
......@@ -136,7 +135,7 @@ gl::Error ContextVk::setupDraw(const gl::Context *context,
if (!mCurrentPipeline)
{
ANGLE_TRY(initPipeline(context));
ANGLE_TRY(initPipeline());
}
const auto &state = mState.getState();
......@@ -147,7 +146,7 @@ gl::Error ContextVk::setupDraw(const gl::Context *context,
Serial queueSerial = mRenderer->getCurrentQueueSerial();
vk::CommandGraphNode *graphNode = nullptr;
ANGLE_TRY(vkFBO->getCommandGraphNodeForDraw(context, &graphNode));
ANGLE_TRY(vkFBO->getCommandGraphNodeForDraw(this, &graphNode));
vk::CommandBuffer *commandBuffer = nullptr;
......@@ -224,7 +223,7 @@ gl::Error ContextVk::drawArrays(const gl::Context *context, GLenum mode, GLint f
vk::CommandGraphNode *drawNode = nullptr;
bool newCommands = false;
ANGLE_TRY(setupDraw(context, drawCallParams, &drawNode, &newCommands));
ANGLE_TRY(setupDraw(drawCallParams, &drawNode, &newCommands));
const gl::VertexArray *vertexArray = context->getGLState().getVertexArray();
VertexArrayVk *vertexArrayVk = vk::GetImpl(vertexArray);
......@@ -253,7 +252,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context,
vk::CommandGraphNode *drawNode = nullptr;
bool newCommands = false;
ANGLE_TRY(setupDraw(context, drawCallParams, &drawNode, &newCommands));
ANGLE_TRY(setupDraw(drawCallParams, &drawNode, &newCommands));
gl::VertexArray *vao = mState.getState().getVertexArray();
VertexArrayVk *vertexArrayVk = vk::GetImpl(vao);
......
......@@ -161,9 +161,8 @@ class ContextVk : public ContextImpl
const VkRect2D &getScissor() const { return mPipelineDesc->getScissor(); }
private:
gl::Error initPipeline(const gl::Context *context);
gl::Error setupDraw(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
gl::Error initPipeline();
gl::Error setupDraw(const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode **drawNodeOut,
bool *newCommandBufferOut);
......
......@@ -138,7 +138,7 @@ gl::Error FramebufferVk::clear(const gl::Context *context, GLbitfield mask)
// With scissor test enabled, we clear very differently and we don't need to access
// the image inside each attachment we can just use clearCmdAttachments with our
// scissor region instead.
ANGLE_TRY(clearAttachmentsWithScissorRegion(context, clearColor, clearDepth, clearStencil));
ANGLE_TRY(clearWithClearAttachments(contextVk, clearColor, clearDepth, clearStencil));
return gl::NoError();
}
......@@ -337,7 +337,7 @@ gl::Error FramebufferVk::syncState(const gl::Context *context,
return gl::NoError();
}
const vk::RenderPassDesc &FramebufferVk::getRenderPassDesc(const gl::Context *context)
const vk::RenderPassDesc &FramebufferVk::getRenderPassDesc()
{
if (mRenderPassDesc.valid())
{
......@@ -365,8 +365,7 @@ const vk::RenderPassDesc &FramebufferVk::getRenderPassDesc(const gl::Context *co
return mRenderPassDesc.value();
}
gl::ErrorOrResult<vk::Framebuffer *> FramebufferVk::getFramebuffer(const gl::Context *context,
RendererVk *rendererVk)
gl::ErrorOrResult<vk::Framebuffer *> FramebufferVk::getFramebuffer(RendererVk *rendererVk)
{
// If we've already created our cached Framebuffer, return it.
if (mFramebuffer.valid())
......@@ -374,7 +373,7 @@ gl::ErrorOrResult<vk::Framebuffer *> FramebufferVk::getFramebuffer(const gl::Con
return &mFramebuffer;
}
const vk::RenderPassDesc &desc = getRenderPassDesc(context);
const vk::RenderPassDesc &desc = getRenderPassDesc();
vk::RenderPass *renderPass = nullptr;
ANGLE_TRY(rendererVk->getCompatibleRenderPass(desc, &renderPass));
......@@ -432,19 +431,18 @@ gl::ErrorOrResult<vk::Framebuffer *> FramebufferVk::getFramebuffer(const gl::Con
return &mFramebuffer;
}
gl::Error FramebufferVk::clearAttachmentsWithScissorRegion(const gl::Context *context,
bool clearColor,
bool clearDepth,
bool clearStencil)
gl::Error FramebufferVk::clearWithClearAttachments(ContextVk *contextVk,
bool clearColor,
bool clearDepth,
bool clearStencil)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
// This command can only happen inside a render pass, so obtain one if its already happening
// or create a new one if not.
vk::CommandGraphNode *node = nullptr;
vk::CommandBuffer *commandBuffer = nullptr;
ANGLE_TRY(getCommandGraphNodeForDraw(context, &node));
ANGLE_TRY(getCommandGraphNodeForDraw(contextVk, &node));
if (node->getInsideRenderPassCommands()->valid())
{
commandBuffer = node->getInsideRenderPassCommands();
......@@ -532,10 +530,9 @@ gl::Error FramebufferVk::getSamplePosition(size_t index, GLfloat *xy) const
return gl::InternalError() << "getSamplePosition is unimplemented.";
}
gl::Error FramebufferVk::getCommandGraphNodeForDraw(const gl::Context *context,
gl::Error FramebufferVk::getCommandGraphNodeForDraw(ContextVk *contextVk,
vk::CommandGraphNode **nodeOut)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
Serial currentSerial = renderer->getCurrentQueueSerial();
......@@ -557,7 +554,7 @@ gl::Error FramebufferVk::getCommandGraphNodeForDraw(const gl::Context *context,
}
vk::Framebuffer *framebuffer = nullptr;
ANGLE_TRY_RESULT(getFramebuffer(context, renderer), framebuffer);
ANGLE_TRY_RESULT(getFramebuffer(renderer), framebuffer);
std::vector<VkClearValue> attachmentClearValues;
......
......@@ -86,21 +86,19 @@ class FramebufferVk : public FramebufferImpl, public vk::CommandGraphResource
gl::Error getSamplePosition(size_t index, GLfloat *xy) const override;
const vk::RenderPassDesc &getRenderPassDesc(const gl::Context *context);
gl::Error getCommandGraphNodeForDraw(const gl::Context *context,
vk::CommandGraphNode **nodeOut);
const vk::RenderPassDesc &getRenderPassDesc();
gl::Error getCommandGraphNodeForDraw(ContextVk *contextVk, vk::CommandGraphNode **nodeOut);
private:
FramebufferVk(const gl::FramebufferState &state);
FramebufferVk(const gl::FramebufferState &state, WindowSurfaceVk *backbuffer);
gl::ErrorOrResult<vk::Framebuffer *> getFramebuffer(const gl::Context *context,
RendererVk *rendererVk);
gl::ErrorOrResult<vk::Framebuffer *> getFramebuffer(RendererVk *rendererVk);
gl::Error clearAttachmentsWithScissorRegion(const gl::Context *context,
bool clearColor,
bool clearDepth,
bool clearStencil);
gl::Error clearWithClearAttachments(ContextVk *contextVk,
bool clearColor,
bool clearDepth,
bool clearStencil);
WindowSurfaceVk *mBackbuffer;
......
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