Commit 64b5b3d3 by Tim Van Patten Committed by Commit Bot

Vulkan: Further restrict enabling LINE_RASTERIZATION_MODE_BRESENHAM

The app "Car Parking Multiplayer" enables GL_SAMPLE_ALPHA_TO_COVERAGE, which leads to a VVL error when LINE_RASTERIZATION_MODE_BRESENHAM is also enabled: VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766: The Vulkan spec states: If the lineRasterizationMode member of a VkPipelineRasterizationLineStateCreateInfoEXT structure included in the pNext chain of pRasterizationState is VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT or VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT and if rasterization is enabled, then the alphaToCoverageEnable, alphaToOneEnable, and sampleShadingEnable members of pMultisampleState must all be VK_FALSE. This CL adds the additional checking to GraphicsPipelineDesc::initializePipeline() to ensure those conditions are met before setting lineRasterizationMode to VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT. Bug: angleproject:5613 Test: StateChangeTest.AlphaToCoverageEnable Change-Id: Ie2286078f6916c01a19ae6f932321a86619bd4e1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2694094Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 0fa6c307
...@@ -1846,8 +1846,18 @@ angle::Result GraphicsPipelineDesc::initializePipeline( ...@@ -1846,8 +1846,18 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
VkPipelineRasterizationLineStateCreateInfoEXT rasterLineState = {}; VkPipelineRasterizationLineStateCreateInfoEXT rasterLineState = {};
rasterLineState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT; rasterLineState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT;
// Enable Bresenham line rasterization if available and not multisampling. // Enable Bresenham line rasterization if available and the following conditions are met:
// 1.) not multisampling
// 2.) VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766:
// The Vulkan spec states: If the lineRasterizationMode member of a
// VkPipelineRasterizationLineStateCreateInfoEXT structure included in the pNext chain of
// pRasterizationState is VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT or
// VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT and if rasterization is enabled, then the
// alphaToCoverageEnable, alphaToOneEnable, and sampleShadingEnable members of pMultisampleState
// must all be VK_FALSE.
if (rasterAndMS.bits.rasterizationSamples <= 1 && if (rasterAndMS.bits.rasterizationSamples <= 1 &&
!rasterAndMS.bits.rasterizationDiscardEnable && !rasterAndMS.bits.alphaToCoverageEnable &&
!rasterAndMS.bits.alphaToOneEnable && !rasterAndMS.bits.sampleShadingEnable &&
contextVk->getFeatures().bresenhamLineRasterization.enabled) contextVk->getFeatures().bresenhamLineRasterization.enabled)
{ {
rasterLineState.lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT; rasterLineState.lineRasterizationMode = VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT;
......
...@@ -271,6 +271,30 @@ TEST_P(StateChangeTestES3, FramebufferIncompleteDepthStencilAttachment) ...@@ -271,6 +271,30 @@ TEST_P(StateChangeTestES3, FramebufferIncompleteDepthStencilAttachment)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test that enabling GL_SAMPLE_ALPHA_TO_COVERAGE doesn't generate errors.
TEST_P(StateChangeTest, AlphaToCoverageEnable)
{
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
glBindTexture(GL_TEXTURE_2D, mTextures[0]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextures[0], 0);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
ANGLE_GL_PROGRAM(greenProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green());
// We don't actually care that this does anything, just that it can be enabled without causing
// an error.
glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
glUseProgram(greenProgram);
drawQuad(greenProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
}
const char kSimpleAttributeVS[] = R"(attribute vec2 position; const char kSimpleAttributeVS[] = R"(attribute vec2 position;
attribute vec4 testAttrib; attribute vec4 testAttrib;
varying vec4 testVarying; varying vec4 testVarying;
......
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