KhronosGroup / VK-GL-CTS

Khronos Vulkan, OpenGL, and OpenGL ES Conformance Tests
https://www.khronos.org/
Apache License 2.0
525 stars 293 forks source link

Why does it use "opengl 3.1 ctx + GLX_CONTEXT_PROFILE_MASK_ARB" to create core profile? #380

Open Daylight-Peng opened 1 year ago

Daylight-Peng commented 1 year ago

In "KHR-GL31.texture_size_promotion.functional" test case, it use "opengl 3.1 ctx + GLX_CONTEXT_PROFILE_MASK_ARB" to create core profile to test.

But from the spec https://registry.khronos.org/OpenGL/extensions/ARB/GLX_ARB_create_context.txt: If the requested OpenGL version is less than 3.2, GLX_CONTEXT_PROFILE_MASK_ARB is ignored

It may actually get the 3.1 compatibility ctx if the driver supports "GL_ARB_compatibility" extension. So it may meet below issue:

1) The "KHR-GL31.texture_size_promotion.functional" test case "GL_DEPTH* " relevent code test will fail:

The log:
#beginTestCaseResult KHR-GL31.texture_size_promotion.functional
<?xml version="1.0" encoding="UTF-8"?>
<TestCaseResult Version="0.3.4" CasePath="KHR-GL31.texture_size_promotion.functional" CaseType="SelfValidate">
 <Text>Promotion from internal format GL_DEPTH_COMPONENT16 have failed during functional test of green channel with target GL_TEXTURE_1D. Expected value = 0 read value = 0.125002.</Text>
 <Text>Promotion from internal format GL_DEPTH_COMPONENT16 have failed during functional test of blue channel with target GL_TEXTURE_1D. Expected value = 0 read value = 0.125002.</Text>
 <Text>Promotion from internal format GL_DEPTH_COMPONENT16 have failed during functional test of green channel with target GL_TEXTURE_2D. Expected value = 0 read value = 0.125002.</Text>
 <Text>Promotion from internal format GL_DEPTH_COMPONENT16 have failed during functional test of blue channel with target GL_TEXTURE_2D. Expected value = 0 read value = 0.125002.</Text>
 <Text>Promotion from internal format GL_DEPTH_COMPONENT16 have failed during functional test of green channel with target GL_TEXTURE_1D_ARRAY. Expected value = 0 read value = 0.125002.</Text
...
 <Text>Promotion from internal format GL_DEPTH32F_STENCIL8 have failed during functional test of green channel with target GL_TEXTURE_RECTANGLE. Expected value = 0 read value = 0.125.</Text>
 <Text>Promotion from internal format GL_DEPTH32F_STENCIL8 have failed during functional test of blue channel with target GL_TEXTURE_RECTANGLE. Expected value = 0 read value = 0.125.</Text>
 <Text>Promotion from internal format GL_DEPTH32F_STENCIL8 have failed during functional test of green channel with target GL_TEXTURE_2D_ARRAY. Expected value = 0 read value = 0.125.</Text>
 <Text>Promotion from internal format GL_DEPTH32F_STENCIL8 have failed during functional test of blue channel with target GL_TEXTURE_2D_ARRAY. Expected value = 0 read value = 0.125.</Text>
 <Text>Texture Size Promotion Test have failed.</Text>
 <Number Name="TestDuration" Description="Test case duration in microseconds" Tag="Time" Unit="us">4692530</Number>
 <Result StatusCode="Fail">Fail</Result>

2) The logic that causes the failure: from the spec https://registry.khronos.org/OpenGL/specs/gl/glspec31undep.pdf The initial state for depth and depth/stencil textures treats them as LUMINANCE textures except in a forward-compatible context, where the initial state instead treats them as RED textures.

The "KHR-GL31.texture_size_promotion.functional" test case "GL_DEPTH* " relevent code thinks the driver set GL_DEPTH_TEXTURE_MODE to GL_RED in core profile, but the driver actully set GL_DEPTH_TEXTURE_MODE to GL_LUMINANCE in compatibility profile.

Daylight-Peng commented 1 year ago

Could you please help to have a check?

AlexGalazin-IMG commented 1 year ago

@pdaniell-nv

pdaniell-nv commented 1 year ago

It sounds like the CTS code is designed for "core profile", which isn't available when the OpenGL version is less than 3.2. I think the solution would be to make modifications to the CTS at the points where there is a difference between core and compatibility, like the examples you listed above, and do the right thing based on the context profile. You can use the isContextTypeGLCompatibility() function to know when the compatibility profile is being used.

Daylight-Peng commented 1 year ago

spec: https://registry.khronos.org/OpenGL/extensions/ARB/GLX_ARB_create_context.txt

For the OGL 3.0 and 3.1 context, if we want to use the "core profile", we need to config the "GLX_CONTEXT_FLAGS_ARB" to " GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB".

With below patch, I can get the 3.1 core profile and pass the CTS:

diff --git a/external/openglcts/modules/gl/gl3cTestPackages.hpp b/external/openglcts/modules/gl/gl3cTestPackages.hpp
index f1a3c255e..57db89447 100644
--- a/external/openglcts/modules/gl/gl3cTestPackages.hpp
+++ b/external/openglcts/modules/gl/gl3cTestPackages.hpp
@@ -53,7 +53,7 @@ class GL31TestPackage : public GL30TestPackage
 public:
        GL31TestPackage(tcu::TestContext& testCtx, const char* packageName,
                                        const char*              description       = "OpenGL 3.1 Conformance Tests",
-                                       glu::ContextType renderContextType = glu::ContextType(3, 1, glu::PROFILE_CORE));
+                                       glu::ContextType renderContextType = glu::ContextType(3, 1, glu::PROFILE_CORE,glu::CONTEXT_FORWARD_COMPATIBLE));
pdaniell-nv commented 1 year ago

That change seems reasonable. Are you planning to create a push request?

Daylight-Peng commented 1 year ago

That change seems reasonable. Are you planning to create a push request?

The PR: https://github.com/KhronosGroup/VK-GL-CTS/pull/385

Could you please help to review?