Skip to content

Commit

Permalink
Vulkan: Fix querying support of prim restart patch
Browse files Browse the repository at this point in the history
* Added a cap to reflect support for primitive restart for patches.
  * primitiveRestartForPatchesSupported
  * In Vulkan, it is determined through the following component from
    the existing related device feature:
    * primitiveTopologyPatchListRestart

* Updated querying PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED via glGet().
  * Now it is only available on ES 3.2 or if tessellation shaders are
    supported. Otherwise, there will be a validation error.
  * It returns primitiveRestartForPatchesSupported.

* Added a unit test that queries this value and ensures that it remains
  the same regardless of whether primitive restart is enabled.

Bug: angleproject:349610458
Change-Id: If43a5326f0886cf10e38b4e73a868f46b1052533
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5661108
Reviewed-by: Shahbaz Youssefi <[email protected]>
Commit-Queue: Amirali Abdolrashidi <[email protected]>
Reviewed-by: Charlie Lao <[email protected]>
  • Loading branch information
aabdolrashidi authored and Angle LUCI CQ committed Jun 28, 2024
1 parent 3813e80 commit e86ba9a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libANGLE/Caps.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ struct Caps
GLint maxTessEvaluationInputComponents = 0;
GLint maxTessEvaluationOutputComponents = 0;

bool primitiveRestartForPatchesSupported = false;

GLuint subPixelBits = 4;

// GL_EXT_blend_func_extended
Expand Down
2 changes: 1 addition & 1 deletion src/libANGLE/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ void PrivateState::getBooleanv(GLenum pname, GLboolean *params) const
*params = mIsSampleShadingEnabled;
break;
case GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED:
*params = isPrimitiveRestartEnabled() && getExtensions().tessellationShaderAny();
*params = mCaps.primitiveRestartForPatchesSupported ? GL_TRUE : GL_FALSE;
break;
case GL_ROBUST_FRAGMENT_SHADER_OUTPUT_ANGLE:
*params = mExtensions.robustFragmentShaderOutputANGLE ? GL_TRUE : GL_FALSE;
Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,9 @@ void Renderer::ensureCapsInitialized() const
maxCombinedAtomicCounterBuffers;
}

mNativeCaps.primitiveRestartForPatchesSupported =
mPrimitiveTopologyListRestartFeatures.primitiveTopologyPatchListRestart == VK_TRUE;

// Reserve a uniform buffer binding for each tessellation stage
if (tessellationShaderEnabled)
{
Expand Down
9 changes: 9 additions & 0 deletions src/libANGLE/validationES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3117,6 +3117,15 @@ bool ValidateStateQuery(const Context *context,
}
break;

case GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED:
if (context->getClientVersion() < Version(3, 2) &&
!context->getExtensions().tessellationShaderAny())
{
ANGLE_VALIDATION_ERRORF(GL_INVALID_ENUM, kEnumNotSupported, pname);
return false;
}
break;

default:
break;
}
Expand Down
23 changes: 23 additions & 0 deletions src/tests/gl_tests/StateChangeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10047,6 +10047,29 @@ TEST_P(StateChangeTestES3, PrimitiveRestart)
ASSERT_GL_NO_ERROR();
}

// Tests that primitive restart for patches can be queried when tessellation shaders are available,
// and that its value is independent of whether primitive restart is enabled.
TEST_P(StateChangeTestES31, PrimitiveRestartForPatchQuery)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_tessellation_shader"));

glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
GLint primitiveRestartForPatchesWhenEnabled = -1;
glGetIntegerv(GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED,
&primitiveRestartForPatchesWhenEnabled);
ASSERT_GL_NO_ERROR();
EXPECT_GE(primitiveRestartForPatchesWhenEnabled, 0);

glDisable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
GLint primitiveRestartForPatchesWhenDisabled = -1;
glGetIntegerv(GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED,
&primitiveRestartForPatchesWhenDisabled);
ASSERT_GL_NO_ERROR();
EXPECT_GE(primitiveRestartForPatchesWhenDisabled, 0);

EXPECT_EQ(primitiveRestartForPatchesWhenEnabled, primitiveRestartForPatchesWhenDisabled);
}

// Tests state change for GL_COLOR_LOGIC_OP and glLogicOp.
TEST_P(StateChangeTestES3, LogicOp)
{
Expand Down

0 comments on commit e86ba9a

Please sign in to comment.