Commit 1505c750 by Luc Ferron Committed by Commit Bot

Vulkan: Fix issue in blending factor conversions

The blend factor were not converted correctly from GL enum types to their VK equivalents. I found this by running many dEQP tests related to blending. Bug:angleproject:2346 Change-Id: I3c332bb5e5c44d2bec4ff9d62e0df2421507e136 Reviewed-on: https://chromium-review.googlesource.com/956241 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5b772312
...@@ -41,6 +41,46 @@ uint8_t PackGLBlendOp(GLenum blendOp) ...@@ -41,6 +41,46 @@ uint8_t PackGLBlendOp(GLenum blendOp)
} }
} }
uint8_t PackGLBlendFactor(GLenum blendFactor)
{
switch (blendFactor)
{
case GL_ZERO:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ZERO);
case GL_ONE:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE);
case GL_SRC_COLOR:
return static_cast<uint8_t>(VK_BLEND_FACTOR_SRC_COLOR);
case GL_DST_COLOR:
return static_cast<uint8_t>(VK_BLEND_FACTOR_DST_COLOR);
case GL_ONE_MINUS_SRC_COLOR:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR);
case GL_SRC_ALPHA:
return static_cast<uint8_t>(VK_BLEND_FACTOR_SRC_ALPHA);
case GL_ONE_MINUS_SRC_ALPHA:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
case GL_DST_ALPHA:
return static_cast<uint8_t>(VK_BLEND_FACTOR_DST_ALPHA);
case GL_ONE_MINUS_DST_ALPHA:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA);
case GL_ONE_MINUS_DST_COLOR:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR);
case GL_SRC_ALPHA_SATURATE:
return static_cast<uint8_t>(VK_BLEND_FACTOR_SRC_ALPHA_SATURATE);
case GL_CONSTANT_COLOR:
return static_cast<uint8_t>(VK_BLEND_FACTOR_CONSTANT_COLOR);
case GL_CONSTANT_ALPHA:
return static_cast<uint8_t>(VK_BLEND_FACTOR_CONSTANT_ALPHA);
case GL_ONE_MINUS_CONSTANT_COLOR:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR);
case GL_ONE_MINUS_CONSTANT_ALPHA:
return static_cast<uint8_t>(VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA);
default:
UNREACHABLE();
return 0;
}
}
VkSampleCountFlagBits ConvertSamples(GLint sampleCount) VkSampleCountFlagBits ConvertSamples(GLint sampleCount)
{ {
switch (sampleCount) switch (sampleCount)
...@@ -647,11 +687,10 @@ void PipelineDesc::updateBlendFuncs(const gl::BlendState &blendState) ...@@ -647,11 +687,10 @@ void PipelineDesc::updateBlendFuncs(const gl::BlendState &blendState)
{ {
for (auto &blendAttachmentState : mColorBlendStateInfo.attachments) for (auto &blendAttachmentState : mColorBlendStateInfo.attachments)
{ {
blendAttachmentState.srcColorBlendFactor = static_cast<uint8_t>(blendState.sourceBlendRGB); blendAttachmentState.srcColorBlendFactor = PackGLBlendFactor(blendState.sourceBlendRGB);
blendAttachmentState.dstColorBlendFactor = static_cast<uint8_t>(blendState.destBlendRGB); blendAttachmentState.dstColorBlendFactor = PackGLBlendFactor(blendState.destBlendRGB);
blendAttachmentState.srcAlphaBlendFactor = blendAttachmentState.srcAlphaBlendFactor = PackGLBlendFactor(blendState.sourceBlendAlpha);
static_cast<uint8_t>(blendState.sourceBlendAlpha); blendAttachmentState.dstAlphaBlendFactor = PackGLBlendFactor(blendState.destBlendAlpha);
blendAttachmentState.dstAlphaBlendFactor = static_cast<uint8_t>(blendState.destBlendAlpha);
} }
} }
......
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