Commit 758b12fa by Jiacheng Lu Committed by Commit Bot

Filter out redundant depth&stencil state updates

1. Compare updating values with active ones at frontend when depth&stencil related gl call happens and do not set any unnecessary dirty bits. 2. Remove d3d and gl backends' checking of depth&stencil states when detect any dirty bits, as it is now being done at frontend. 3. Modification to graphics pipeline description update, make sure it syncs with gl::State initial value. 4. Change gl_vk::CullMode return type to VkCullModeFlagBits, as it only represents single value. Bug: angleproject:3700 Change-Id: Id3aa5186455ee3a10a9c147edad13944e3e41098 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1706903 Commit-Queue: Jiacheng Lu <lujc@google.com> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent c405776e
......@@ -4822,14 +4822,15 @@ void Context::scissor(GLint x, GLint y, GLsizei width, GLsizei height)
void Context::stencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
{
GLint clampedRef = gl::clamp(ref, 0, std::numeric_limits<uint8_t>::max());
if (face == GL_FRONT || face == GL_FRONT_AND_BACK)
{
mState.setStencilParams(func, ref, mask);
mState.setStencilParams(func, clampedRef, mask);
}
if (face == GL_BACK || face == GL_FRONT_AND_BACK)
{
mState.setStencilBackParams(func, ref, mask);
mState.setStencilBackParams(func, clampedRef, mask);
}
mStateCache.onStencilStateChange(this);
......
......@@ -623,8 +623,11 @@ void State::setColorMask(bool red, bool green, bool blue, bool alpha)
void State::setDepthMask(bool mask)
{
if (mDepthStencil.depthMask != mask)
{
mDepthStencil.depthMask = mask;
mDirtyBits.set(DIRTY_BIT_DEPTH_MASK);
}
}
void State::setRasterizerDiscard(bool enabled)
......@@ -653,14 +656,20 @@ void State::setFrontFace(GLenum front)
void State::setDepthTest(bool enabled)
{
if (mDepthStencil.depthTest != enabled)
{
mDepthStencil.depthTest = enabled;
mDirtyBits.set(DIRTY_BIT_DEPTH_TEST_ENABLED);
}
}
void State::setDepthFunc(GLenum depthFunc)
{
if (mDepthStencil.depthFunc != depthFunc)
{
mDepthStencil.depthFunc = depthFunc;
mDirtyBits.set(DIRTY_BIT_DEPTH_FUNC);
}
}
void State::setDepthRange(float zNear, float zFar)
......@@ -706,58 +715,85 @@ void State::setBlendEquation(GLenum rgbEquation, GLenum alphaEquation)
void State::setStencilTest(bool enabled)
{
if (mDepthStencil.stencilTest != enabled)
{
mDepthStencil.stencilTest = enabled;
mDirtyBits.set(DIRTY_BIT_STENCIL_TEST_ENABLED);
}
}
void State::setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask)
{
if (mDepthStencil.stencilFunc != stencilFunc || mStencilRef != stencilRef ||
mDepthStencil.stencilMask != stencilMask)
{
mDepthStencil.stencilFunc = stencilFunc;
mStencilRef = gl::clamp(stencilRef, 0, std::numeric_limits<uint8_t>::max());
mStencilRef = stencilRef;
mDepthStencil.stencilMask = stencilMask;
mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_FRONT);
}
}
void State::setStencilBackParams(GLenum stencilBackFunc,
GLint stencilBackRef,
GLuint stencilBackMask)
{
if (mDepthStencil.stencilBackFunc != stencilBackFunc || mStencilBackRef != stencilBackRef ||
mDepthStencil.stencilBackMask != stencilBackMask)
{
mDepthStencil.stencilBackFunc = stencilBackFunc;
mStencilBackRef = gl::clamp(stencilBackRef, 0, std::numeric_limits<uint8_t>::max());
mStencilBackRef = stencilBackRef;
mDepthStencil.stencilBackMask = stencilBackMask;
mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_BACK);
}
}
void State::setStencilWritemask(GLuint stencilWritemask)
{
if (mDepthStencil.stencilWritemask != stencilWritemask)
{
mDepthStencil.stencilWritemask = stencilWritemask;
mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_FRONT);
}
}
void State::setStencilBackWritemask(GLuint stencilBackWritemask)
{
if (mDepthStencil.stencilBackWritemask != stencilBackWritemask)
{
mDepthStencil.stencilBackWritemask = stencilBackWritemask;
mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_BACK);
}
}
void State::setStencilOperations(GLenum stencilFail,
GLenum stencilPassDepthFail,
GLenum stencilPassDepthPass)
{
if (mDepthStencil.stencilFail != stencilFail ||
mDepthStencil.stencilPassDepthFail != stencilPassDepthFail ||
mDepthStencil.stencilPassDepthPass != stencilPassDepthPass)
{
mDepthStencil.stencilFail = stencilFail;
mDepthStencil.stencilPassDepthFail = stencilPassDepthFail;
mDepthStencil.stencilPassDepthPass = stencilPassDepthPass;
mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_FRONT);
}
}
void State::setStencilBackOperations(GLenum stencilBackFail,
GLenum stencilBackPassDepthFail,
GLenum stencilBackPassDepthPass)
{
if (mDepthStencil.stencilBackFail != stencilBackFail ||
mDepthStencil.stencilBackPassDepthFail != stencilBackPassDepthFail ||
mDepthStencil.stencilBackPassDepthPass != stencilBackPassDepthPass)
{
mDepthStencil.stencilBackFail = stencilBackFail;
mDepthStencil.stencilBackPassDepthFail = stencilBackPassDepthFail;
mDepthStencil.stencilBackPassDepthPass = stencilBackPassDepthPass;
mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_BACK);
}
}
void State::setPolygonOffsetFill(bool enabled)
......
......@@ -1015,91 +1015,39 @@ void StateManager11::syncState(const gl::Context *context, const gl::State::Dirt
mInternalDirtyBits.set(DIRTY_BIT_BLEND_STATE);
}
break;
// Depth and stencil redundant state changes are guarded in the
// frontend so for related cases here just set the dirty bit.
case gl::State::DIRTY_BIT_DEPTH_MASK:
if (state.getDepthStencilState().depthMask != mCurDepthStencilState.depthMask)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED:
if (state.getDepthStencilState().depthTest != mCurDepthStencilState.depthTest)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
case gl::State::DIRTY_BIT_DEPTH_FUNC:
if (state.getDepthStencilState().depthFunc != mCurDepthStencilState.depthFunc)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
case gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED:
if (state.getDepthStencilState().stencilTest != mCurDepthStencilState.stencilTest)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
{
const gl::DepthStencilState &depthStencil = state.getDepthStencilState();
if (depthStencil.stencilFunc != mCurDepthStencilState.stencilFunc ||
depthStencil.stencilMask != mCurDepthStencilState.stencilMask ||
state.getStencilRef() != mCurStencilRef)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
}
case gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK:
{
const gl::DepthStencilState &depthStencil = state.getDepthStencilState();
if (depthStencil.stencilBackFunc != mCurDepthStencilState.stencilBackFunc ||
depthStencil.stencilBackMask != mCurDepthStencilState.stencilBackMask ||
state.getStencilBackRef() != mCurStencilBackRef)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
}
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT:
if (state.getDepthStencilState().stencilWritemask !=
mCurDepthStencilState.stencilWritemask)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK:
if (state.getDepthStencilState().stencilBackWritemask !=
mCurDepthStencilState.stencilBackWritemask)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
case gl::State::DIRTY_BIT_STENCIL_OPS_FRONT:
{
const gl::DepthStencilState &depthStencil = state.getDepthStencilState();
if (depthStencil.stencilFail != mCurDepthStencilState.stencilFail ||
depthStencil.stencilPassDepthFail !=
mCurDepthStencilState.stencilPassDepthFail ||
depthStencil.stencilPassDepthPass != mCurDepthStencilState.stencilPassDepthPass)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
}
case gl::State::DIRTY_BIT_STENCIL_OPS_BACK:
{
const gl::DepthStencilState &depthStencil = state.getDepthStencilState();
if (depthStencil.stencilBackFail != mCurDepthStencilState.stencilBackFail ||
depthStencil.stencilBackPassDepthFail !=
mCurDepthStencilState.stencilBackPassDepthFail ||
depthStencil.stencilBackPassDepthPass !=
mCurDepthStencilState.stencilBackPassDepthPass)
{
mInternalDirtyBits.set(DIRTY_BIT_DEPTH_STENCIL_STATE);
}
break;
}
case gl::State::DIRTY_BIT_CULL_FACE_ENABLED:
if (state.getRasterizerState().cullFace != mCurRasterState.cullFace)
{
......
......@@ -250,6 +250,8 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits
}
break;
}
// Depth and stencil redundant state changes are guarded in the
// frontend so for related cases here just set the dirty bit.
case gl::State::DIRTY_BIT_DEPTH_MASK:
if (state.getDepthStencilState().depthMask != mCurDepthStencilState.depthMask)
{
......@@ -257,20 +259,12 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits
}
break;
case gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED:
if (state.getDepthStencilState().depthTest != mCurDepthStencilState.depthTest)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_DEPTH_FUNC);
}
break;
case gl::State::DIRTY_BIT_DEPTH_FUNC:
if (state.getDepthStencilState().depthFunc != mCurDepthStencilState.depthFunc)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_DEPTH_FUNC);
}
break;
case gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED:
if (state.getDepthStencilState().stencilTest != mCurDepthStencilState.stencilTest)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_TEST_ENABLED);
// If we enable the stencil test, all of these must be set
mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_BACK);
......@@ -279,70 +273,25 @@ void StateManager9::syncState(const gl::State &state, const gl::State::DirtyBits
mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_BACK);
mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_FRONT);
mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_BACK);
}
break;
case gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT:
{
const gl::DepthStencilState &depthStencilState = state.getDepthStencilState();
if (depthStencilState.stencilFunc != mCurDepthStencilState.stencilFunc ||
depthStencilState.stencilMask != mCurDepthStencilState.stencilMask ||
state.getStencilRef() != mCurStencilRef)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_FRONT);
}
break;
}
case gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK:
{
const gl::DepthStencilState &depthStencilState = state.getDepthStencilState();
if (depthStencilState.stencilBackFunc != mCurDepthStencilState.stencilBackFunc ||
depthStencilState.stencilBackMask != mCurDepthStencilState.stencilBackMask ||
state.getStencilBackRef() != mCurStencilBackRef)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_FUNCS_BACK);
}
break;
}
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT:
if (state.getDepthStencilState().stencilWritemask !=
mCurDepthStencilState.stencilWritemask)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_FRONT);
}
break;
case gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK:
if (state.getDepthStencilState().stencilBackWritemask !=
mCurDepthStencilState.stencilBackWritemask)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_WRITEMASK_BACK);
}
break;
case gl::State::DIRTY_BIT_STENCIL_OPS_FRONT:
{
const gl::DepthStencilState &depthStencilState = state.getDepthStencilState();
if (depthStencilState.stencilFail != mCurDepthStencilState.stencilFail ||
depthStencilState.stencilPassDepthFail !=
mCurDepthStencilState.stencilPassDepthFail ||
depthStencilState.stencilPassDepthPass !=
mCurDepthStencilState.stencilPassDepthPass)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_FRONT);
}
break;
}
case gl::State::DIRTY_BIT_STENCIL_OPS_BACK:
{
const gl::DepthStencilState &depthStencilState = state.getDepthStencilState();
if (depthStencilState.stencilBackFail != mCurDepthStencilState.stencilBackFail ||
depthStencilState.stencilBackPassDepthFail !=
mCurDepthStencilState.stencilBackPassDepthFail ||
depthStencilState.stencilBackPassDepthPass !=
mCurDepthStencilState.stencilBackPassDepthPass)
{
mDirtyBits.set(DIRTY_BIT_STENCIL_OPS_BACK);
}
break;
}
case gl::State::DIRTY_BIT_SCISSOR_TEST_ENABLED:
if (state.isScissorTestEnabled() != mCurScissorEnabled)
{
......
......@@ -1192,10 +1192,11 @@ void StateManagerGL::setSampleMaski(GLuint maskNumber, GLbitfield mask)
}
}
// Depth and stencil redundant state changes are guarded in the
// frontend so for related cases here just set the dirty bit
// and update backend states.
void StateManagerGL::setDepthTestEnabled(bool enabled)
{
if (mDepthTestEnabled != enabled)
{
mDepthTestEnabled = enabled;
if (mDepthTestEnabled)
{
......@@ -1207,35 +1208,26 @@ void StateManagerGL::setDepthTestEnabled(bool enabled)
}
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_TEST_ENABLED);
}
}
void StateManagerGL::setDepthFunc(GLenum depthFunc)
{
if (mDepthFunc != depthFunc)
{
mDepthFunc = depthFunc;
mFunctions->depthFunc(mDepthFunc);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_FUNC);
}
}
void StateManagerGL::setDepthMask(bool mask)
{
if (mDepthMask != mask)
{
mDepthMask = mask;
mFunctions->depthMask(mDepthMask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_DEPTH_MASK);
}
}
void StateManagerGL::setStencilTestEnabled(bool enabled)
{
if (mStencilTestEnabled != enabled)
{
mStencilTestEnabled = enabled;
if (mStencilTestEnabled)
{
......@@ -1247,35 +1239,26 @@ void StateManagerGL::setStencilTestEnabled(bool enabled)
}
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_TEST_ENABLED);
}
}
void StateManagerGL::setStencilFrontWritemask(GLuint mask)
{
if (mStencilFrontWritemask != mask)
{
mStencilFrontWritemask = mask;
mFunctions->stencilMaskSeparate(GL_FRONT, mStencilFrontWritemask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_WRITEMASK_FRONT);
}
}
void StateManagerGL::setStencilBackWritemask(GLuint mask)
{
if (mStencilBackWritemask != mask)
{
mStencilBackWritemask = mask;
mFunctions->stencilMaskSeparate(GL_BACK, mStencilBackWritemask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_WRITEMASK_BACK);
}
}
void StateManagerGL::setStencilFrontFuncs(GLenum func, GLint ref, GLuint mask)
{
if (mStencilFrontFunc != func || mStencilFrontRef != ref || mStencilFrontValueMask != mask)
{
mStencilFrontFunc = func;
mStencilFrontRef = ref;
mStencilFrontValueMask = mask;
......@@ -1283,13 +1266,10 @@ void StateManagerGL::setStencilFrontFuncs(GLenum func, GLint ref, GLuint mask)
mStencilFrontValueMask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_FUNCS_FRONT);
}
}
void StateManagerGL::setStencilBackFuncs(GLenum func, GLint ref, GLuint mask)
{
if (mStencilBackFunc != func || mStencilBackRef != ref || mStencilBackValueMask != mask)
{
mStencilBackFunc = func;
mStencilBackRef = ref;
mStencilBackValueMask = mask;
......@@ -1297,14 +1277,10 @@ void StateManagerGL::setStencilBackFuncs(GLenum func, GLint ref, GLuint mask)
mStencilBackValueMask);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_FUNCS_BACK);
}
}
void StateManagerGL::setStencilFrontOps(GLenum sfail, GLenum dpfail, GLenum dppass)
{
if (mStencilFrontStencilFailOp != sfail || mStencilFrontStencilPassDepthFailOp != dpfail ||
mStencilFrontStencilPassDepthPassOp != dppass)
{
mStencilFrontStencilFailOp = sfail;
mStencilFrontStencilPassDepthFailOp = dpfail;
mStencilFrontStencilPassDepthPassOp = dppass;
......@@ -1313,14 +1289,10 @@ void StateManagerGL::setStencilFrontOps(GLenum sfail, GLenum dpfail, GLenum dppa
mStencilFrontStencilPassDepthPassOp);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_OPS_FRONT);
}
}
void StateManagerGL::setStencilBackOps(GLenum sfail, GLenum dpfail, GLenum dppass)
{
if (mStencilBackStencilFailOp != sfail || mStencilBackStencilPassDepthFailOp != dpfail ||
mStencilBackStencilPassDepthPassOp != dppass)
{
mStencilBackStencilFailOp = sfail;
mStencilBackStencilPassDepthFailOp = dpfail;
mStencilBackStencilPassDepthPassOp = dppass;
......@@ -1329,7 +1301,6 @@ void StateManagerGL::setStencilBackOps(GLenum sfail, GLenum dpfail, GLenum dppas
mStencilBackStencilPassDepthPassOp);
mLocalDirtyBits.set(gl::State::DIRTY_BIT_STENCIL_OPS_BACK);
}
}
void StateManagerGL::setCullFaceEnabled(bool enabled)
......
......@@ -824,6 +824,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
vk::GraphicsPipelineDesc pipelineDesc;
pipelineDesc.initDefaults();
pipelineDesc.setCullMode(VK_CULL_MODE_NONE);
pipelineDesc.setColorWriteMask(0, gl::DrawBufferMask());
pipelineDesc.setSingleColorWriteMask(params.colorAttachmentIndexGL, params.colorMaskFlags);
pipelineDesc.setRasterizationSamples(framebuffer->getSamples());
......@@ -1000,6 +1001,7 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
{
pipelineDesc.setColorWriteMask(0, gl::DrawBufferMask());
}
pipelineDesc.setCullMode(VK_CULL_MODE_NONE);
pipelineDesc.setRenderPassDesc(framebuffer->getRenderPassDesc());
pipelineDesc.setDepthTestEnabled(blitDepth);
pipelineDesc.setDepthWriteEnabled(blitDepth);
......@@ -1345,6 +1347,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
vk::GraphicsPipelineDesc pipelineDesc;
pipelineDesc.initDefaults();
pipelineDesc.setCullMode(VK_CULL_MODE_NONE);
pipelineDesc.setRenderPassDesc(renderPassDesc);
gl::Rectangle renderArea;
......
......@@ -488,13 +488,25 @@ bool GraphicsPipelineDesc::operator==(const GraphicsPipelineDesc &other) const
// TODO(jmadill): We should prefer using Packed GLenums. http://anglebug.com/2169
// Initialize PSO states, it is consistent with initial value of gl::State
void GraphicsPipelineDesc::initDefaults()
{
// Set all vertex input attributes to default, the default format is Float
angle::FormatID defaultFormat = GetCurrentValueFormatID(gl::VertexAttribType::Float);
for (PackedAttribDesc &packedAttrib : mVertexInputAttribs.attribs)
{
SetBitField(packedAttrib.stride, 0);
SetBitField(packedAttrib.divisor, 0);
SetBitField(packedAttrib.format, defaultFormat);
SetBitField(packedAttrib.offset, 0);
}
mRasterizationAndMultisampleStateInfo.bits.depthClampEnable = 0;
mRasterizationAndMultisampleStateInfo.bits.rasterizationDiscardEnable = 0;
SetBitField(mRasterizationAndMultisampleStateInfo.bits.polygonMode, VK_POLYGON_MODE_FILL);
SetBitField(mRasterizationAndMultisampleStateInfo.bits.cullMode, VK_CULL_MODE_NONE);
SetBitField(mRasterizationAndMultisampleStateInfo.bits.frontFace, VK_FRONT_FACE_CLOCKWISE);
SetBitField(mRasterizationAndMultisampleStateInfo.bits.cullMode, VK_CULL_MODE_BACK_BIT);
SetBitField(mRasterizationAndMultisampleStateInfo.bits.frontFace,
VK_FRONT_FACE_COUNTER_CLOCKWISE);
mRasterizationAndMultisampleStateInfo.bits.depthBiasEnable = 0;
mRasterizationAndMultisampleStateInfo.depthBiasConstantFactor = 0.0f;
mRasterizationAndMultisampleStateInfo.depthBiasClamp = 0.0f;
......@@ -553,10 +565,10 @@ void GraphicsPipelineDesc::initDefaults()
PackedColorBlendAttachmentState blendAttachmentState;
SetBitField(blendAttachmentState.srcColorBlendFactor, VK_BLEND_FACTOR_ONE);
SetBitField(blendAttachmentState.dstColorBlendFactor, VK_BLEND_FACTOR_ONE);
SetBitField(blendAttachmentState.dstColorBlendFactor, VK_BLEND_FACTOR_ZERO);
SetBitField(blendAttachmentState.colorBlendOp, VK_BLEND_OP_ADD);
SetBitField(blendAttachmentState.srcAlphaBlendFactor, VK_BLEND_FACTOR_ONE);
SetBitField(blendAttachmentState.dstAlphaBlendFactor, VK_BLEND_FACTOR_ONE);
SetBitField(blendAttachmentState.dstAlphaBlendFactor, VK_BLEND_FACTOR_ZERO);
SetBitField(blendAttachmentState.alphaBlendOp, VK_BLEND_OP_ADD);
std::fill(&inputAndBlend.attachments[0],
......@@ -565,6 +577,19 @@ void GraphicsPipelineDesc::initDefaults()
inputAndBlend.primitive.topology = static_cast<uint16_t>(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
inputAndBlend.primitive.restartEnable = 0;
// Viewport and scissor will be set to valid values when framebuffer being binded
mViewport.x = 0.0f;
mViewport.y = 0.0f;
mViewport.width = 0.0f;
mViewport.height = 0.0f;
mViewport.minDepth = 0.0f;
mViewport.maxDepth = 1.0f;
mScissor.offset.x = 0;
mScissor.offset.y = 0;
mScissor.extent.width = 0;
mScissor.extent.height = 0;
}
angle::Result GraphicsPipelineDesc::initializePipeline(
......@@ -876,11 +901,15 @@ void GraphicsPipelineDesc::updatePrimitiveRestartEnabled(GraphicsPipelineTransit
transition->set(ANGLE_GET_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo, primitive));
}
void GraphicsPipelineDesc::setCullMode(VkCullModeFlagBits cullMode)
{
SetBitField(mRasterizationAndMultisampleStateInfo.bits.cullMode, cullMode);
}
void GraphicsPipelineDesc::updateCullMode(GraphicsPipelineTransitionBits *transition,
const gl::RasterizerState &rasterState)
{
mRasterizationAndMultisampleStateInfo.bits.cullMode =
static_cast<uint16_t>(gl_vk::GetCullMode(rasterState));
setCullMode(gl_vk::GetCullMode(rasterState));
transition->set(ANGLE_GET_TRANSITION_BIT(mRasterizationAndMultisampleStateInfo, bits));
}
......
......@@ -380,6 +380,7 @@ class GraphicsPipelineDesc final
bool primitiveRestartEnabled);
// Raster states
void setCullMode(VkCullModeFlagBits cullMode);
void updateCullMode(GraphicsPipelineTransitionBits *transition,
const gl::RasterizerState &rasterState);
void updateFrontFace(GraphicsPipelineTransitionBits *transition,
......
......@@ -695,7 +695,7 @@ VkPrimitiveTopology GetPrimitiveTopology(gl::PrimitiveMode mode)
}
}
VkCullModeFlags GetCullMode(const gl::RasterizerState &rasterState)
VkCullModeFlagBits GetCullMode(const gl::RasterizerState &rasterState)
{
if (!rasterState.cullFace)
{
......
......@@ -575,7 +575,7 @@ VkFilter GetFilter(const GLenum filter);
VkSamplerMipmapMode GetSamplerMipmapMode(const GLenum filter);
VkSamplerAddressMode GetSamplerAddressMode(const GLenum wrap);
VkPrimitiveTopology GetPrimitiveTopology(gl::PrimitiveMode mode);
VkCullModeFlags GetCullMode(const gl::RasterizerState &rasterState);
VkCullModeFlagBits GetCullMode(const gl::RasterizerState &rasterState);
VkFrontFace GetFrontFace(GLenum frontFace, bool invertCullFace);
VkSampleCountFlagBits GetSamples(GLint sampleCount);
VkComponentSwizzle GetSwizzle(const GLenum swizzle);
......
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