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