Commit d5fa6ea9 by Alexey Knyazev Committed by Commit Bot

Vulkan: Implement OES_draw_buffers_indexed

Bug: angleproject:4394 Change-Id: I7db9c695c233b2daf740acc654b1b2e546a8b681 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2172739 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 385fb40f
...@@ -647,7 +647,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk ...@@ -647,7 +647,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mCurrentDrawElementsType(gl::DrawElementsType::InvalidEnum), mCurrentDrawElementsType(gl::DrawElementsType::InvalidEnum),
mXfbBaseVertex(0), mXfbBaseVertex(0),
mXfbVertexCountPerInstance(0), mXfbVertexCountPerInstance(0),
mClearColorMask(kAllColorChannelsMask),
mFlipYForCurrentSurface(false), mFlipYForCurrentSurface(false),
mIsAnyHostVisibleBufferWritten(false), mIsAnyHostVisibleBufferWritten(false),
mEmulateSeamfulCubeMapSampling(false), mEmulateSeamfulCubeMapSampling(false),
...@@ -669,6 +668,10 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk ...@@ -669,6 +668,10 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
memset(&mClearColorValue, 0, sizeof(mClearColorValue)); memset(&mClearColorValue, 0, sizeof(mClearColorValue));
memset(&mClearDepthStencilValue, 0, sizeof(mClearDepthStencilValue)); memset(&mClearDepthStencilValue, 0, sizeof(mClearDepthStencilValue));
mClearColorMasks = gl::BlendStateExt::ColorMaskStorage::GetReplicatedValue(
kAllColorChannelsMask,
gl::BlendStateExt::ColorMaskStorage::GetMask(getCaps().maxDrawBuffers));
mNonIndexedDirtyBitsMask.set(); mNonIndexedDirtyBitsMask.set();
mNonIndexedDirtyBitsMask.reset(DIRTY_BIT_INDEX_BUFFER); mNonIndexedDirtyBitsMask.reset(DIRTY_BIT_INDEX_BUFFER);
...@@ -2706,15 +2709,14 @@ SurfaceRotation ContextVk::getRotationReadFramebuffer() const ...@@ -2706,15 +2709,14 @@ SurfaceRotation ContextVk::getRotationReadFramebuffer() const
return mCurrentRotationReadFramebuffer; return mCurrentRotationReadFramebuffer;
} }
void ContextVk::updateColorMask(const gl::BlendState &blendState) void ContextVk::updateColorMasks(const gl::BlendStateExt &blendStateExt)
{ {
mClearColorMask = mClearColorMasks = blendStateExt.mColorMask;
gl_vk::GetColorComponentFlags(blendState.colorMaskRed, blendState.colorMaskGreen,
blendState.colorMaskBlue, blendState.colorMaskAlpha);
FramebufferVk *framebufferVk = vk::GetImpl(mState.getDrawFramebuffer()); FramebufferVk *framebufferVk = vk::GetImpl(mState.getDrawFramebuffer());
mGraphicsPipelineDesc->updateColorWriteMask(&mGraphicsPipelineTransition, mClearColorMask, mGraphicsPipelineDesc->updateColorWriteMasks(&mGraphicsPipelineTransition, mClearColorMasks,
framebufferVk->getEmulatedAlphaAttachmentMask(), framebufferVk->getEmulatedAlphaAttachmentMask(),
framebufferVk->getState().getEnabledDrawBuffers()); framebufferVk->getState().getEnabledDrawBuffers());
} }
void ContextVk::updateSampleMask(const gl::State &glState) void ContextVk::updateSampleMask(const gl::State &glState)
...@@ -2937,7 +2939,7 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2937,7 +2939,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
break; break;
case gl::State::DIRTY_BIT_BLEND_ENABLED: case gl::State::DIRTY_BIT_BLEND_ENABLED:
mGraphicsPipelineDesc->updateBlendEnabled(&mGraphicsPipelineTransition, mGraphicsPipelineDesc->updateBlendEnabled(&mGraphicsPipelineTransition,
glState.isBlendEnabled()); glState.getBlendStateExt().mEnabledMask);
break; break;
case gl::State::DIRTY_BIT_BLEND_COLOR: case gl::State::DIRTY_BIT_BLEND_COLOR:
mGraphicsPipelineDesc->updateBlendColor(&mGraphicsPipelineTransition, mGraphicsPipelineDesc->updateBlendColor(&mGraphicsPipelineTransition,
...@@ -2945,14 +2947,14 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -2945,14 +2947,14 @@ angle::Result ContextVk::syncState(const gl::Context *context,
break; break;
case gl::State::DIRTY_BIT_BLEND_FUNCS: case gl::State::DIRTY_BIT_BLEND_FUNCS:
mGraphicsPipelineDesc->updateBlendFuncs(&mGraphicsPipelineTransition, mGraphicsPipelineDesc->updateBlendFuncs(&mGraphicsPipelineTransition,
glState.getBlendState()); glState.getBlendStateExt());
break; break;
case gl::State::DIRTY_BIT_BLEND_EQUATIONS: case gl::State::DIRTY_BIT_BLEND_EQUATIONS:
mGraphicsPipelineDesc->updateBlendEquations(&mGraphicsPipelineTransition, mGraphicsPipelineDesc->updateBlendEquations(&mGraphicsPipelineTransition,
glState.getBlendState()); glState.getBlendStateExt());
break; break;
case gl::State::DIRTY_BIT_COLOR_MASK: case gl::State::DIRTY_BIT_COLOR_MASK:
updateColorMask(glState.getBlendState()); updateColorMasks(glState.getBlendStateExt());
break; break;
case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED: case gl::State::DIRTY_BIT_SAMPLE_ALPHA_TO_COVERAGE_ENABLED:
mGraphicsPipelineDesc->updateAlphaToCoverageEnable( mGraphicsPipelineDesc->updateAlphaToCoverageEnable(
...@@ -3107,7 +3109,7 @@ angle::Result ContextVk::syncState(const gl::Context *context, ...@@ -3107,7 +3109,7 @@ angle::Result ContextVk::syncState(const gl::Context *context,
updateSurfaceRotationDrawFramebuffer(glState); updateSurfaceRotationDrawFramebuffer(glState);
updateViewport(mDrawFramebuffer, glState.getViewport(), glState.getNearPlane(), updateViewport(mDrawFramebuffer, glState.getViewport(), glState.getNearPlane(),
glState.getFarPlane(), isViewportFlipEnabledForDrawFBO()); glState.getFarPlane(), isViewportFlipEnabledForDrawFBO());
updateColorMask(glState.getBlendState()); updateColorMasks(glState.getBlendStateExt());
updateSampleMask(glState); updateSampleMask(glState);
mGraphicsPipelineDesc->updateRasterizationSamples(&mGraphicsPipelineTransition, mGraphicsPipelineDesc->updateRasterizationSamples(&mGraphicsPipelineTransition,
mDrawFramebuffer->getSamples()); mDrawFramebuffer->getSamples());
...@@ -3739,9 +3741,9 @@ const VkClearValue &ContextVk::getClearDepthStencilValue() const ...@@ -3739,9 +3741,9 @@ const VkClearValue &ContextVk::getClearDepthStencilValue() const
return mClearDepthStencilValue; return mClearDepthStencilValue;
} }
VkColorComponentFlags ContextVk::getClearColorMask() const gl::BlendStateExt::ColorMaskStorage::Type ContextVk::getClearColorMasks() const
{ {
return mClearColorMask; return mClearColorMasks;
} }
void ContextVk::writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOut, void ContextVk::writeAtomicCounterBufferDriverUniformOffsets(uint32_t *offsetsOut,
......
...@@ -382,11 +382,11 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -382,11 +382,11 @@ class ContextVk : public ContextImpl, public vk::Context
const VkClearValue &getClearColorValue() const; const VkClearValue &getClearColorValue() const;
const VkClearValue &getClearDepthStencilValue() const; const VkClearValue &getClearDepthStencilValue() const;
VkColorComponentFlags getClearColorMask() const; gl::BlendStateExt::ColorMaskStorage::Type getClearColorMasks() const;
angle::Result getIncompleteTexture(const gl::Context *context, angle::Result getIncompleteTexture(const gl::Context *context,
gl::TextureType type, gl::TextureType type,
gl::Texture **textureOut); gl::Texture **textureOut);
void updateColorMask(const gl::BlendState &blendState); void updateColorMasks(const gl::BlendStateExt &blendStateExt);
void updateSampleMask(const gl::State &glState); void updateSampleMask(const gl::State &glState);
void handleError(VkResult errorCode, void handleError(VkResult errorCode,
...@@ -1021,7 +1021,7 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -1021,7 +1021,7 @@ class ContextVk : public ContextImpl, public vk::Context
// Cached clear value/mask for color and depth/stencil. // Cached clear value/mask for color and depth/stencil.
VkClearValue mClearColorValue; VkClearValue mClearColorValue;
VkClearValue mClearDepthStencilValue; VkClearValue mClearDepthStencilValue;
VkColorComponentFlags mClearColorMask; gl::BlendStateExt::ColorMaskStorage::Type mClearColorMasks;
IncompleteTextureSet mIncompleteTextures; IncompleteTextureSet mIncompleteTextures;
......
...@@ -308,7 +308,7 @@ FramebufferVk::FramebufferVk(RendererVk *renderer, ...@@ -308,7 +308,7 @@ FramebufferVk::FramebufferVk(RendererVk *renderer,
: FramebufferImpl(state), : FramebufferImpl(state),
mBackbuffer(backbuffer), mBackbuffer(backbuffer),
mFramebuffer(nullptr), mFramebuffer(nullptr),
mActiveColorComponents(0), mActiveColorComponentMasksForClear(0),
mReadOnlyDepthFeedbackLoopMode(false) mReadOnlyDepthFeedbackLoopMode(false)
{ {
mReadPixelBuffer.init(renderer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, kReadPixelsBufferAlignment, mReadPixelBuffer.init(renderer, VK_BUFFER_USAGE_TRANSFER_DST_BIT, kReadPixelsBufferAlignment,
...@@ -433,8 +433,8 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -433,8 +433,8 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
// Adjust clear behavior based on whether the respective attachments are present; if asked to // Adjust clear behavior based on whether the respective attachments are present; if asked to
// clear a non-existent attachment, don't attempt to clear it. // clear a non-existent attachment, don't attempt to clear it.
VkColorComponentFlags colorMaskFlags = contextVk->getClearColorMask(); gl::BlendStateExt::ColorMaskStorage::Type colorMasks = contextVk->getClearColorMasks();
bool clearColor = clearColorBuffers.any(); bool clearColor = clearColorBuffers.any();
const gl::FramebufferAttachment *depthAttachment = mState.getDepthAttachment(); const gl::FramebufferAttachment *depthAttachment = mState.getDepthAttachment();
clearDepth = clearDepth && depthAttachment; clearDepth = clearDepth && depthAttachment;
...@@ -448,7 +448,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -448,7 +448,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
static_cast<uint8_t>(contextVk->getState().getDepthStencilState().stencilWritemask); static_cast<uint8_t>(contextVk->getState().getDepthStencilState().stencilWritemask);
// The front-end should ensure we don't attempt to clear color if all channels are masked. // The front-end should ensure we don't attempt to clear color if all channels are masked.
ASSERT(!clearColor || colorMaskFlags != 0); ASSERT(!clearColor || colorMasks != 0);
// The front-end should ensure we don't attempt to clear depth if depth write is disabled. // The front-end should ensure we don't attempt to clear depth if depth write is disabled.
ASSERT(!clearDepth || contextVk->getState().getDepthStencilState().depthMask); ASSERT(!clearDepth || contextVk->getState().getDepthStencilState().depthMask);
// The front-end should ensure we don't attempt to clear stencil if all bits are masked. // The front-end should ensure we don't attempt to clear stencil if all bits are masked.
...@@ -465,8 +465,8 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -465,8 +465,8 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
// We can use render pass load ops if clearing depth, unmasked color or unmasked stencil. If // We can use render pass load ops if clearing depth, unmasked color or unmasked stencil. If
// there's a depth mask, depth clearing is already disabled. // there's a depth mask, depth clearing is already disabled.
bool maskedClearColor = bool maskedClearColor = clearColor && (mActiveColorComponentMasksForClear & colorMasks) !=
clearColor && (mActiveColorComponents & colorMaskFlags) != mActiveColorComponents; mActiveColorComponentMasksForClear;
bool maskedClearStencil = clearStencil && stencilMask != 0xFF; bool maskedClearStencil = clearStencil && stencilMask != 0xFF;
bool clearColorWithRenderPassLoadOp = clearColor && !maskedClearColor && !scissoredClear; bool clearColorWithRenderPassLoadOp = clearColor && !maskedClearColor && !scissoredClear;
...@@ -559,7 +559,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context, ...@@ -559,7 +559,7 @@ angle::Result FramebufferVk::clearImpl(const gl::Context *context,
// The most costly clear mode is when we need to mask out specific color channels or stencil // The most costly clear mode is when we need to mask out specific color channels or stencil
// bits. This can only be done with a draw call. // bits. This can only be done with a draw call.
return clearWithDraw(contextVk, scissoredRenderArea, clearColorBuffers, clearDepth, return clearWithDraw(contextVk, scissoredRenderArea, clearColorBuffers, clearDepth,
clearStencil, colorMaskFlags, stencilMask, clearColorValue, clearStencil, colorMasks, stencilMask, clearColorValue,
clearDepthStencilValue); clearDepthStencilValue);
} }
...@@ -1551,7 +1551,7 @@ angle::Result FramebufferVk::updateColorAttachment(const gl::Context *context, ...@@ -1551,7 +1551,7 @@ angle::Result FramebufferVk::updateColorAttachment(const gl::Context *context,
mEmulatedAlphaAttachmentMask.set(colorIndexGL, mEmulatedAlphaAttachmentMask.set(colorIndexGL,
sourceFormat.alphaBits == 0 && actualFormat.alphaBits > 0); sourceFormat.alphaBits == 0 && actualFormat.alphaBits > 0);
contextVk->updateColorMask(context->getState().getBlendState()); contextVk->updateColorMasks(context->getState().getBlendStateExt());
if (deferClears && mState.getEnabledDrawBuffers().test(colorIndexGL)) if (deferClears && mState.getEnabledDrawBuffers().test(colorIndexGL))
{ {
...@@ -1722,7 +1722,7 @@ angle::Result FramebufferVk::syncState(const gl::Context *context, ...@@ -1722,7 +1722,7 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
if (shouldUpdateColorMask) if (shouldUpdateColorMask)
{ {
contextVk->updateColorMask(context->getState().getBlendState()); contextVk->updateColorMasks(context->getState().getBlendStateExt());
} }
// In some cases we'll need to force a flush of deferred clears. When we're syncing the read // In some cases we'll need to force a flush of deferred clears. When we're syncing the read
...@@ -1752,10 +1752,6 @@ angle::Result FramebufferVk::syncState(const gl::Context *context, ...@@ -1752,10 +1752,6 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
const gl::State &glState = context->getState(); const gl::State &glState = context->getState();
ANGLE_TRY(contextVk->updateScissor(glState)); ANGLE_TRY(contextVk->updateScissor(glState));
mActiveColorComponents = gl_vk::GetColorComponentFlags(
mActiveColorComponentMasksForClear[0].any(), mActiveColorComponentMasksForClear[1].any(),
mActiveColorComponentMasksForClear[2].any(), mActiveColorComponentMasksForClear[3].any());
if (command != gl::Command::Blit) if (command != gl::Command::Blit)
{ {
// Don't end the render pass when handling a blit to resolve, since we may be able to // Don't end the render pass when handling a blit to resolve, since we may be able to
...@@ -2011,7 +2007,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -2011,7 +2007,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
gl::DrawBufferMask clearColorBuffers, gl::DrawBufferMask clearColorBuffers,
bool clearDepth, bool clearDepth,
bool clearStencil, bool clearStencil,
VkColorComponentFlags colorMaskFlags, gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
uint8_t stencilMask, uint8_t stencilMask,
const VkClearColorValue &clearColorValue, const VkClearColorValue &clearColorValue,
const VkClearDepthStencilValue &clearDepthStencilValue) const VkClearDepthStencilValue &clearDepthStencilValue)
...@@ -2048,7 +2044,8 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk, ...@@ -2048,7 +2044,8 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
params.colorFormat = params.colorFormat =
&colorRenderTarget->getImageForRenderPass().getFormat().actualImageFormat(); &colorRenderTarget->getImageForRenderPass().getFormat().actualImageFormat();
params.colorAttachmentIndexGL = static_cast<uint32_t>(colorIndexGL); params.colorAttachmentIndexGL = static_cast<uint32_t>(colorIndexGL);
params.colorMaskFlags = colorMaskFlags; params.colorMaskFlags =
gl::BlendStateExt::ColorMaskStorage::GetValueIndexed(colorIndexGL, colorMasks);
if (mEmulatedAlphaAttachmentMask[colorIndexGL]) if (mEmulatedAlphaAttachmentMask[colorIndexGL])
{ {
params.colorMaskFlags &= ~VK_COLOR_COMPONENT_A_BIT; params.colorMaskFlags &= ~VK_COLOR_COMPONENT_A_BIT;
...@@ -2535,10 +2532,9 @@ void FramebufferVk::restoreDepthStencilDefinedContents() ...@@ -2535,10 +2532,9 @@ void FramebufferVk::restoreDepthStencilDefinedContents()
void FramebufferVk::updateActiveColorMasks(size_t colorIndexGL, bool r, bool g, bool b, bool a) void FramebufferVk::updateActiveColorMasks(size_t colorIndexGL, bool r, bool g, bool b, bool a)
{ {
mActiveColorComponentMasksForClear[0].set(colorIndexGL, r); gl::BlendStateExt::ColorMaskStorage::SetValueIndexed(
mActiveColorComponentMasksForClear[1].set(colorIndexGL, g); colorIndexGL, gl::BlendStateExt::PackColorMask(r, g, b, a),
mActiveColorComponentMasksForClear[2].set(colorIndexGL, b); &mActiveColorComponentMasksForClear);
mActiveColorComponentMasksForClear[3].set(colorIndexGL, a);
} }
const gl::DrawBufferMask &FramebufferVk::getEmulatedAlphaAttachmentMask() const const gl::DrawBufferMask &FramebufferVk::getEmulatedAlphaAttachmentMask() const
......
...@@ -187,7 +187,7 @@ class FramebufferVk : public FramebufferImpl ...@@ -187,7 +187,7 @@ class FramebufferVk : public FramebufferImpl
gl::DrawBufferMask clearColorBuffers, gl::DrawBufferMask clearColorBuffers,
bool clearDepth, bool clearDepth,
bool clearStencil, bool clearStencil,
VkColorComponentFlags colorMaskFlags, gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
uint8_t stencilMask, uint8_t stencilMask,
const VkClearColorValue &clearColorValue, const VkClearColorValue &clearColorValue,
const VkClearDepthStencilValue &clearDepthStencilValue); const VkClearDepthStencilValue &clearDepthStencilValue);
...@@ -235,11 +235,10 @@ class FramebufferVk : public FramebufferImpl ...@@ -235,11 +235,10 @@ class FramebufferVk : public FramebufferImpl
vk::FramebufferHelper *mFramebuffer; vk::FramebufferHelper *mFramebuffer;
RenderTargetCache<RenderTargetVk> mRenderTargetCache; RenderTargetCache<RenderTargetVk> mRenderTargetCache;
// These two variables are used to quickly compute if we need to do a masked clear. If a color // This variable is used to quickly compute if we need to do a masked clear. If a color
// channel is masked out, we check against the Framebuffer Attachments (RenderTargets) to see // channel is masked out, we check against the Framebuffer Attachments (RenderTargets) to see
// if the masked out channel is present in any of the attachments. // if the masked out channel is present in any of the attachments.
VkColorComponentFlags mActiveColorComponents; gl::BlendStateExt::ColorMaskStorage::Type mActiveColorComponentMasksForClear;
gl::DrawBufferMask mActiveColorComponentMasksForClear[4];
vk::DynamicBuffer mReadPixelBuffer; vk::DynamicBuffer mReadPixelBuffer;
// When we draw to the framebuffer, and the real format has an alpha channel but the format of // When we draw to the framebuffer, and the real format has an alpha channel but the format of
......
...@@ -1422,7 +1422,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk, ...@@ -1422,7 +1422,7 @@ angle::Result UtilsVk::clearFramebuffer(ContextVk *contextVk,
vk::GraphicsPipelineDesc pipelineDesc; vk::GraphicsPipelineDesc pipelineDesc;
pipelineDesc.initDefaults(); pipelineDesc.initDefaults();
pipelineDesc.setCullMode(VK_CULL_MODE_NONE); pipelineDesc.setCullMode(VK_CULL_MODE_NONE);
pipelineDesc.setColorWriteMask(0, gl::DrawBufferMask(), gl::DrawBufferMask()); pipelineDesc.setColorWriteMasks(0, gl::DrawBufferMask(), gl::DrawBufferMask());
pipelineDesc.setSingleColorWriteMask(params.colorAttachmentIndexGL, params.colorMaskFlags); pipelineDesc.setSingleColorWriteMask(params.colorAttachmentIndexGL, params.colorMaskFlags);
pipelineDesc.setRasterizationSamples(framebuffer->getSamples()); pipelineDesc.setRasterizationSamples(framebuffer->getSamples());
pipelineDesc.setRenderPassDesc(framebuffer->getRenderPassDesc()); pipelineDesc.setRenderPassDesc(framebuffer->getRenderPassDesc());
...@@ -1639,13 +1639,15 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk, ...@@ -1639,13 +1639,15 @@ angle::Result UtilsVk::blitResolveImpl(ContextVk *contextVk,
pipelineDesc.initDefaults(); pipelineDesc.initDefaults();
if (blitColor) if (blitColor)
{ {
pipelineDesc.setColorWriteMask(kAllColorComponents, pipelineDesc.setColorWriteMasks(
framebuffer->getEmulatedAlphaAttachmentMask(), gl::BlendStateExt::ColorMaskStorage::GetReplicatedValue(
~gl::DrawBufferMask()); kAllColorComponents, gl::BlendStateExt::ColorMaskStorage::GetMask(
framebuffer->getRenderPassDesc().colorAttachmentRange())),
framebuffer->getEmulatedAlphaAttachmentMask(), ~gl::DrawBufferMask());
} }
else else
{ {
pipelineDesc.setColorWriteMask(0, gl::DrawBufferMask(), gl::DrawBufferMask()); pipelineDesc.setColorWriteMasks(0, gl::DrawBufferMask(), gl::DrawBufferMask());
} }
pipelineDesc.setCullMode(VK_CULL_MODE_NONE); pipelineDesc.setCullMode(VK_CULL_MODE_NONE);
pipelineDesc.setRenderPassDesc(framebuffer->getRenderPassDesc()); pipelineDesc.setRenderPassDesc(framebuffer->getRenderPassDesc());
......
...@@ -1903,62 +1903,67 @@ void GraphicsPipelineDesc::updateBlendColor(GraphicsPipelineTransitionBits *tran ...@@ -1903,62 +1903,67 @@ void GraphicsPipelineDesc::updateBlendColor(GraphicsPipelineTransitionBits *tran
} }
void GraphicsPipelineDesc::updateBlendEnabled(GraphicsPipelineTransitionBits *transition, void GraphicsPipelineDesc::updateBlendEnabled(GraphicsPipelineTransitionBits *transition,
bool isBlendEnabled) gl::DrawBufferMask blendEnabledMask)
{ {
gl::DrawBufferMask blendEnabled;
if (isBlendEnabled)
blendEnabled.set();
mInputAssemblyAndColorBlendStateInfo.blendEnableMask = mInputAssemblyAndColorBlendStateInfo.blendEnableMask =
static_cast<uint8_t>(blendEnabled.bits()); static_cast<uint8_t>(blendEnabledMask.bits());
transition->set( transition->set(
ANGLE_GET_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo, blendEnableMask)); ANGLE_GET_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo, blendEnableMask));
} }
void GraphicsPipelineDesc::updateBlendEquations(GraphicsPipelineTransitionBits *transition, void GraphicsPipelineDesc::updateBlendEquations(GraphicsPipelineTransitionBits *transition,
const gl::BlendState &blendState) const gl::BlendStateExt &blendStateExt)
{ {
constexpr size_t kSize = sizeof(PackedColorBlendAttachmentState) * 8; constexpr size_t kSize = sizeof(PackedColorBlendAttachmentState) * 8;
for (size_t attachmentIndex = 0; attachmentIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; for (size_t attachmentIndex = 0; attachmentIndex < blendStateExt.mMaxDrawBuffers;
++attachmentIndex) ++attachmentIndex)
{ {
PackedColorBlendAttachmentState &blendAttachmentState = PackedColorBlendAttachmentState &blendAttachmentState =
mInputAssemblyAndColorBlendStateInfo.attachments[attachmentIndex]; mInputAssemblyAndColorBlendStateInfo.attachments[attachmentIndex];
blendAttachmentState.colorBlendOp = PackGLBlendOp(blendState.blendEquationRGB); blendAttachmentState.colorBlendOp =
blendAttachmentState.alphaBlendOp = PackGLBlendOp(blendState.blendEquationAlpha); PackGLBlendOp(blendStateExt.getEquationColorIndexed(attachmentIndex));
blendAttachmentState.alphaBlendOp =
PackGLBlendOp(blendStateExt.getEquationAlphaIndexed(attachmentIndex));
transition->set(ANGLE_GET_INDEXED_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo, transition->set(ANGLE_GET_INDEXED_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo,
attachments, attachmentIndex, kSize)); attachments, attachmentIndex, kSize));
} }
} }
void GraphicsPipelineDesc::updateBlendFuncs(GraphicsPipelineTransitionBits *transition, void GraphicsPipelineDesc::updateBlendFuncs(GraphicsPipelineTransitionBits *transition,
const gl::BlendState &blendState) const gl::BlendStateExt &blendStateExt)
{ {
constexpr size_t kSize = sizeof(PackedColorBlendAttachmentState) * 8; constexpr size_t kSize = sizeof(PackedColorBlendAttachmentState) * 8;
for (size_t attachmentIndex = 0; attachmentIndex < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; for (size_t attachmentIndex = 0; attachmentIndex < blendStateExt.mMaxDrawBuffers;
++attachmentIndex) ++attachmentIndex)
{ {
PackedColorBlendAttachmentState &blendAttachmentState = PackedColorBlendAttachmentState &blendAttachmentState =
mInputAssemblyAndColorBlendStateInfo.attachments[attachmentIndex]; mInputAssemblyAndColorBlendStateInfo.attachments[attachmentIndex];
blendAttachmentState.srcColorBlendFactor = PackGLBlendFactor(blendState.sourceBlendRGB); blendAttachmentState.srcColorBlendFactor =
blendAttachmentState.dstColorBlendFactor = PackGLBlendFactor(blendState.destBlendRGB); PackGLBlendFactor(blendStateExt.getSrcColorIndexed(attachmentIndex));
blendAttachmentState.srcAlphaBlendFactor = PackGLBlendFactor(blendState.sourceBlendAlpha); blendAttachmentState.dstColorBlendFactor =
blendAttachmentState.dstAlphaBlendFactor = PackGLBlendFactor(blendState.destBlendAlpha); PackGLBlendFactor(blendStateExt.getDstColorIndexed(attachmentIndex));
blendAttachmentState.srcAlphaBlendFactor =
PackGLBlendFactor(blendStateExt.getSrcAlphaIndexed(attachmentIndex));
blendAttachmentState.dstAlphaBlendFactor =
PackGLBlendFactor(blendStateExt.getDstAlphaIndexed(attachmentIndex));
transition->set(ANGLE_GET_INDEXED_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo, transition->set(ANGLE_GET_INDEXED_TRANSITION_BIT(mInputAssemblyAndColorBlendStateInfo,
attachments, attachmentIndex, kSize)); attachments, attachmentIndex, kSize));
} }
} }
void GraphicsPipelineDesc::setColorWriteMask(VkColorComponentFlags colorComponentFlags, void GraphicsPipelineDesc::setColorWriteMasks(gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
const gl::DrawBufferMask &alphaMask, const gl::DrawBufferMask &alphaMask,
const gl::DrawBufferMask &enabledDrawBuffers) const gl::DrawBufferMask &enabledDrawBuffers)
{ {
PackedInputAssemblyAndColorBlendStateInfo &inputAndBlend = mInputAssemblyAndColorBlendStateInfo; PackedInputAssemblyAndColorBlendStateInfo &inputAndBlend = mInputAssemblyAndColorBlendStateInfo;
uint8_t colorMask = static_cast<uint8_t>(colorComponentFlags);
for (uint32_t colorIndexGL = 0; colorIndexGL < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; for (uint32_t colorIndexGL = 0; colorIndexGL < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS;
colorIndexGL++) colorIndexGL++)
{ {
uint8_t colorMask =
gl::BlendStateExt::ColorMaskStorage::GetValueIndexed(colorIndexGL, colorMasks);
uint8_t mask = 0; uint8_t mask = 0;
if (enabledDrawBuffers.test(colorIndexGL)) if (enabledDrawBuffers.test(colorIndexGL))
{ {
...@@ -1976,12 +1981,13 @@ void GraphicsPipelineDesc::setSingleColorWriteMask(uint32_t colorIndexGL, ...@@ -1976,12 +1981,13 @@ void GraphicsPipelineDesc::setSingleColorWriteMask(uint32_t colorIndexGL,
Int4Array_Set(inputAndBlend.colorWriteMaskBits, colorIndexGL, colorMask); Int4Array_Set(inputAndBlend.colorWriteMaskBits, colorIndexGL, colorMask);
} }
void GraphicsPipelineDesc::updateColorWriteMask(GraphicsPipelineTransitionBits *transition, void GraphicsPipelineDesc::updateColorWriteMasks(
VkColorComponentFlags colorComponentFlags, GraphicsPipelineTransitionBits *transition,
const gl::DrawBufferMask &alphaMask, gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
const gl::DrawBufferMask &enabledDrawBuffers) const gl::DrawBufferMask &alphaMask,
const gl::DrawBufferMask &enabledDrawBuffers)
{ {
setColorWriteMask(colorComponentFlags, alphaMask, enabledDrawBuffers); setColorWriteMasks(colorMasks, alphaMask, enabledDrawBuffers);
for (size_t colorIndexGL = 0; colorIndexGL < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS; for (size_t colorIndexGL = 0; colorIndexGL < gl::IMPLEMENTATION_MAX_DRAW_BUFFERS;
colorIndexGL++) colorIndexGL++)
......
...@@ -604,20 +604,21 @@ class GraphicsPipelineDesc final ...@@ -604,20 +604,21 @@ class GraphicsPipelineDesc final
const RenderPassDesc &renderPassDesc); const RenderPassDesc &renderPassDesc);
// Blend states // Blend states
void updateBlendEnabled(GraphicsPipelineTransitionBits *transition, bool isBlendEnabled); void updateBlendEnabled(GraphicsPipelineTransitionBits *transition,
gl::DrawBufferMask blendEnabledMask);
void updateBlendColor(GraphicsPipelineTransitionBits *transition, const gl::ColorF &color); void updateBlendColor(GraphicsPipelineTransitionBits *transition, const gl::ColorF &color);
void updateBlendFuncs(GraphicsPipelineTransitionBits *transition, void updateBlendFuncs(GraphicsPipelineTransitionBits *transition,
const gl::BlendState &blendState); const gl::BlendStateExt &blendStateExt);
void updateBlendEquations(GraphicsPipelineTransitionBits *transition, void updateBlendEquations(GraphicsPipelineTransitionBits *transition,
const gl::BlendState &blendState); const gl::BlendStateExt &blendStateExt);
void setColorWriteMask(VkColorComponentFlags colorComponentFlags, void setColorWriteMasks(gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
const gl::DrawBufferMask &alphaMask, const gl::DrawBufferMask &alphaMask,
const gl::DrawBufferMask &enabledDrawBuffers); const gl::DrawBufferMask &enabledDrawBuffers);
void setSingleColorWriteMask(uint32_t colorIndexGL, VkColorComponentFlags colorComponentFlags); void setSingleColorWriteMask(uint32_t colorIndexGL, VkColorComponentFlags colorComponentFlags);
void updateColorWriteMask(GraphicsPipelineTransitionBits *transition, void updateColorWriteMasks(GraphicsPipelineTransitionBits *transition,
VkColorComponentFlags colorComponentFlags, gl::BlendStateExt::ColorMaskStorage::Type colorMasks,
const gl::DrawBufferMask &alphaMask, const gl::DrawBufferMask &alphaMask,
const gl::DrawBufferMask &enabledDrawBuffers); const gl::DrawBufferMask &enabledDrawBuffers);
// Depth/stencil states. // Depth/stencil states.
void setDepthTestEnabled(bool enabled); void setDepthTestEnabled(bool enabled);
......
...@@ -116,6 +116,10 @@ void RendererVk::ensureCapsInitialized() const ...@@ -116,6 +116,10 @@ void RendererVk::ensureCapsInitialized() const
// Enable EXT_blend_minmax // Enable EXT_blend_minmax
mNativeExtensions.blendMinMax = true; mNativeExtensions.blendMinMax = true;
// Enable OES/EXT_draw_buffers_indexed
mNativeExtensions.drawBuffersIndexedOES = mPhysicalDeviceFeatures.independentBlend == VK_TRUE;
mNativeExtensions.drawBuffersIndexedEXT = mNativeExtensions.drawBuffersIndexedOES;
mNativeExtensions.eglImageOES = true; mNativeExtensions.eglImageOES = true;
mNativeExtensions.eglImageExternalOES = true; mNativeExtensions.eglImageExternalOES = true;
mNativeExtensions.eglImageExternalWrapModesEXT = true; mNativeExtensions.eglImageExternalWrapModesEXT = true;
......
...@@ -243,3 +243,21 @@ ...@@ -243,3 +243,21 @@
4371 VULKAN ANDROID : dEQP-GLES31.functional.shaders.implicit_conversions.es31.arithmetic.input_before_literal.add.int_to_vec3_vertex = FAIL 4371 VULKAN ANDROID : dEQP-GLES31.functional.shaders.implicit_conversions.es31.arithmetic.input_before_literal.add.int_to_vec3_vertex = FAIL
4371 VULKAN ANDROID : dEQP-GLES31.functional.shaders.implicit_conversions.es31.arithmetic.input_before_literal.add.int_to_uvec3_vertex = FAIL 4371 VULKAN ANDROID : dEQP-GLES31.functional.shaders.implicit_conversions.es31.arithmetic.input_before_literal.add.int_to_uvec3_vertex = FAIL
4371 SWIFTSHADER : dEQP-GLES31.functional.shaders.implicit_conversions.* = FAIL 4371 SWIFTSHADER : dEQP-GLES31.functional.shaders.implicit_conversions.* = FAIL
// Unexpected crashes on Android 64-bit, some also fail on Android 32-bit
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.1 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.3 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.5 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.9 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.10 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.12 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.13 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.14 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.15 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.17 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffers.18 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_required_draw_buffers.0 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_required_draw_buffers.2 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_required_draw_buffers.10 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_required_draw_buffers.11 = SKIP
4822 VULKAN ANDROID : dEQP-GLES31.functional.draw_buffers_indexed.random.max_required_draw_buffers.17 = SKIP
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