Commit ef6023ea by Jamie Madill Committed by Commit Bot

Vulkan: Make ContextVk driver uniforms a dirty bit.

This makes the update lazier and won't trigger as many times during state changes. It also makes a command buffer available during the update so we can use barriers if necessary. Bug: angleproject:2598 Bug: angleproject:2727 Change-Id: I23ac91c84f6b1f4bad14b3354d19402e5978791e Reviewed-on: https://chromium-review.googlesource.com/1211730Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent fb19e084
...@@ -144,6 +144,7 @@ ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer) ...@@ -144,6 +144,7 @@ ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer)
mDirtyBitHandlers[DIRTY_BIT_TEXTURES] = &ContextVk::handleDirtyTextures; mDirtyBitHandlers[DIRTY_BIT_TEXTURES] = &ContextVk::handleDirtyTextures;
mDirtyBitHandlers[DIRTY_BIT_VERTEX_BUFFERS] = &ContextVk::handleDirtyVertexBuffers; mDirtyBitHandlers[DIRTY_BIT_VERTEX_BUFFERS] = &ContextVk::handleDirtyVertexBuffers;
mDirtyBitHandlers[DIRTY_BIT_INDEX_BUFFER] = &ContextVk::handleDirtyIndexBuffer; mDirtyBitHandlers[DIRTY_BIT_INDEX_BUFFER] = &ContextVk::handleDirtyIndexBuffer;
mDirtyBitHandlers[DIRTY_BIT_DRIVER_UNIFORMS] = &ContextVk::handleDirtyDriverUniforms;
mDirtyBitHandlers[DIRTY_BIT_DESCRIPTOR_SETS] = &ContextVk::handleDirtyDescriptorSets; mDirtyBitHandlers[DIRTY_BIT_DESCRIPTOR_SETS] = &ContextVk::handleDirtyDescriptorSets;
} }
...@@ -662,12 +663,12 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -662,12 +663,12 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt
mPipelineDesc->updateViewport(framebufferVk, glState.getViewport(), mPipelineDesc->updateViewport(framebufferVk, glState.getViewport(),
glState.getNearPlane(), glState.getFarPlane(), glState.getNearPlane(), glState.getFarPlane(),
isViewportFlipEnabledForDrawFBO()); isViewportFlipEnabledForDrawFBO());
ANGLE_TRY(updateDriverUniforms(glState)); mDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
break; break;
} }
case gl::State::DIRTY_BIT_DEPTH_RANGE: case gl::State::DIRTY_BIT_DEPTH_RANGE:
mPipelineDesc->updateDepthRange(glState.getNearPlane(), glState.getFarPlane()); mPipelineDesc->updateDepthRange(glState.getNearPlane(), glState.getFarPlane());
ANGLE_TRY(updateDriverUniforms(glState)); mDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
break; break;
case gl::State::DIRTY_BIT_BLEND_ENABLED: case gl::State::DIRTY_BIT_BLEND_ENABLED:
mPipelineDesc->updateBlendEnabled(glState.isBlendEnabled()); mPipelineDesc->updateBlendEnabled(glState.isBlendEnabled());
...@@ -806,7 +807,7 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -806,7 +807,7 @@ gl::Error ContextVk::syncState(const gl::Context *context, const gl::State::Dirt
glState.getDrawFramebuffer()); glState.getDrawFramebuffer());
mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(), mPipelineDesc->updateStencilBackWriteMask(glState.getDepthStencilState(),
glState.getDrawFramebuffer()); glState.getDrawFramebuffer());
ANGLE_TRY(updateDriverUniforms(glState)); mDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
break; break;
} }
case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING: case gl::State::DIRTY_BIT_RENDERBUFFER_BINDING:
...@@ -899,7 +900,7 @@ gl::Error ContextVk::onMakeCurrent(const gl::Context *context) ...@@ -899,7 +900,7 @@ gl::Error ContextVk::onMakeCurrent(const gl::Context *context)
const gl::State &glState = context->getGLState(); const gl::State &glState = context->getGLState();
updateFlipViewportDrawFramebuffer(glState); updateFlipViewportDrawFramebuffer(glState);
updateFlipViewportReadFramebuffer(glState); updateFlipViewportReadFramebuffer(glState);
ANGLE_TRY(updateDriverUniforms(glState)); mDirtyBits.set(DIRTY_BIT_DRIVER_UNIFORMS);
return gl::NoError(); return gl::NoError();
} }
...@@ -1082,12 +1083,14 @@ const FeaturesVk &ContextVk::getFeatures() const ...@@ -1082,12 +1083,14 @@ const FeaturesVk &ContextVk::getFeatures() const
return mRenderer->getFeatures(); return mRenderer->getFeatures();
} }
angle::Result ContextVk::updateDriverUniforms(const gl::State &glState) angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer)
{ {
// Release any previously retained buffers. // Release any previously retained buffers.
mDriverUniformsBuffer.releaseRetainedBuffers(mRenderer); mDriverUniformsBuffer.releaseRetainedBuffers(mRenderer);
const gl::Rectangle &glViewport = glState.getViewport(); const gl::Rectangle &glViewport = mState.getState().getViewport();
// Allocate a new region in the dynamic buffer. // Allocate a new region in the dynamic buffer.
uint8_t *ptr = nullptr; uint8_t *ptr = nullptr;
...@@ -1098,8 +1101,8 @@ angle::Result ContextVk::updateDriverUniforms(const gl::State &glState) ...@@ -1098,8 +1101,8 @@ angle::Result ContextVk::updateDriverUniforms(const gl::State &glState)
&newBufferAllocated)); &newBufferAllocated));
float scaleY = isViewportFlipEnabledForDrawFBO() ? -1.0f : 1.0f; float scaleY = isViewportFlipEnabledForDrawFBO() ? -1.0f : 1.0f;
float depthRangeNear = glState.getNearPlane(); float depthRangeNear = mState.getState().getNearPlane();
float depthRangeFar = glState.getFarPlane(); float depthRangeFar = mState.getState().getFarPlane();
float depthRangeDiff = depthRangeFar - depthRangeNear; float depthRangeDiff = depthRangeFar - depthRangeNear;
// Copy and flush to the device. // Copy and flush to the device.
......
...@@ -185,6 +185,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -185,6 +185,7 @@ class ContextVk : public ContextImpl, public vk::Context
DIRTY_BIT_TEXTURES, DIRTY_BIT_TEXTURES,
DIRTY_BIT_VERTEX_BUFFERS, DIRTY_BIT_VERTEX_BUFFERS,
DIRTY_BIT_INDEX_BUFFER, DIRTY_BIT_INDEX_BUFFER,
DIRTY_BIT_DRIVER_UNIFORMS,
DIRTY_BIT_DESCRIPTOR_SETS, DIRTY_BIT_DESCRIPTOR_SETS,
DIRTY_BIT_MAX, DIRTY_BIT_MAX,
}; };
...@@ -213,7 +214,6 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -213,7 +214,6 @@ class ContextVk : public ContextImpl, public vk::Context
void updateFlipViewportDrawFramebuffer(const gl::State &glState); void updateFlipViewportDrawFramebuffer(const gl::State &glState);
void updateFlipViewportReadFramebuffer(const gl::State &glState); void updateFlipViewportReadFramebuffer(const gl::State &glState);
angle::Result updateDriverUniforms(const gl::State &glState);
angle::Result updateActiveTextures(const gl::Context *context); angle::Result updateActiveTextures(const gl::Context *context);
angle::Result updateDefaultAttribute(size_t attribIndex); angle::Result updateDefaultAttribute(size_t attribIndex);
...@@ -234,6 +234,9 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -234,6 +234,9 @@ class ContextVk : public ContextImpl, public vk::Context
angle::Result handleDirtyIndexBuffer(const gl::Context *context, angle::Result handleDirtyIndexBuffer(const gl::Context *context,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyDriverUniforms(const gl::Context *context,
const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyDescriptorSets(const gl::Context *context, angle::Result handleDirtyDescriptorSets(const gl::Context *context,
const gl::DrawCallParams &drawCallParams, const gl::DrawCallParams &drawCallParams,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
......
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