mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 08:21:56 +09:00
[Feat] (GL): advertise the 4.x-core extension batch and ARB_tessellation_shader where the device has tessellation
This commit is contained in:
@@ -1244,6 +1244,78 @@ TEST(CorePlumbingAdvertisement, IsUnconditionalAndIdenticalOnBothBackends) {
|
||||
}
|
||||
}
|
||||
|
||||
// Strings for functionality that is core in the 4.x versions MobileGL claims, named so contexts of
|
||||
// an older requested version (the conformance suite's GL 3.x runs gate on the string alone) reach
|
||||
// the same surface. Unconditional on both backends; only the tessellation string follows a probed
|
||||
// device capability.
|
||||
TEST(CoreSurfaceAdvertisement, BatchIsUnconditionalAndTessellationFollowsTheDevice) {
|
||||
const auto contains = [](const MobileGL::Vector<MobileGL::GLExtension>& extensions,
|
||||
MobileGL::GLExtension wanted) {
|
||||
return std::find(extensions.begin(), extensions.end(), wanted) != extensions.end();
|
||||
};
|
||||
const MobileGL::GLExtension expected[] = {
|
||||
MobileGL::E_GL_ARB_transform_feedback2, MobileGL::E_GL_ARB_transform_feedback3,
|
||||
MobileGL::E_GL_ARB_texture_rgb10_a2ui, MobileGL::E_GL_EXT_texture_shared_exponent,
|
||||
MobileGL::E_GL_EXT_texture_integer, MobileGL::E_GL_ARB_pipeline_statistics_query,
|
||||
MobileGL::E_GL_EXT_shader_integer_mix};
|
||||
|
||||
const auto es = MobileGL::MG_Backend::DirectGLES::BuildAdvertisedExtensions(false, false, false, false, false,
|
||||
false);
|
||||
const auto vk = MobileGL::MG_Backend::DirectVulkan::BuildAdvertisedExtensions(false, false, false, false, false);
|
||||
for (const auto extension : expected) {
|
||||
EXPECT_TRUE(contains(es, extension)) << "DirectGLES does not advertise extension " << extension;
|
||||
EXPECT_TRUE(contains(vk, extension)) << "DirectVulkan does not advertise extension " << extension;
|
||||
}
|
||||
// Withheld until shaders can actually use the gl_FragCoord layout qualifiers it adds.
|
||||
EXPECT_FALSE(contains(es, MobileGL::E_GL_ARB_fragment_coord_conventions));
|
||||
EXPECT_FALSE(contains(vk, MobileGL::E_GL_ARB_fragment_coord_conventions));
|
||||
|
||||
EXPECT_FALSE(contains(es, MobileGL::E_GL_ARB_tessellation_shader));
|
||||
EXPECT_FALSE(contains(vk, MobileGL::E_GL_ARB_tessellation_shader));
|
||||
const MobileGL::MG_Backend::AdvertisedFeatureSupport tessellation{.TessellationShader = true};
|
||||
EXPECT_TRUE(contains(MobileGL::MG_Backend::DirectGLES::BuildAdvertisedExtensions(false, false, false, false,
|
||||
false, false, tessellation),
|
||||
MobileGL::E_GL_ARB_tessellation_shader));
|
||||
EXPECT_TRUE(contains(MobileGL::MG_Backend::DirectVulkan::BuildAdvertisedExtensions(false, false, false, false,
|
||||
false, tessellation),
|
||||
MobileGL::E_GL_ARB_tessellation_shader));
|
||||
}
|
||||
|
||||
// ES 3.2 has tessellation in core; ES 3.1 only through GL_EXT_tessellation_shader. Either way the
|
||||
// patch-size entry point has to have resolved.
|
||||
TEST(TessellationCapabilities, FollowTheVersionOrTheExtension) {
|
||||
const auto funcs = MakeFakeGLESFunctions();
|
||||
auto withPatch = funcs;
|
||||
withPatch.glPatchParameteri = [](GLenum, GLint) {};
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
MobileGL::MG_External::GLESCapabilities es31;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(es31, withPatch));
|
||||
EXPECT_FALSE(es31.SupportsTessellationShader);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.extensions.emplace_back("GL_EXT_tessellation_shader");
|
||||
MobileGL::MG_External::GLESCapabilities es31Ext;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(es31Ext, withPatch));
|
||||
EXPECT_TRUE(es31Ext.SupportsTessellationShader);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.glesMinorVersion = 2;
|
||||
MobileGL::MG_External::GLESCapabilities es32NoEntryPoint;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(es32NoEntryPoint, funcs));
|
||||
EXPECT_FALSE(es32NoEntryPoint.SupportsTessellationShader);
|
||||
|
||||
ResetFakeDriver();
|
||||
g_fake.maxVertexSsboBlocks = 0;
|
||||
g_fake.glesMinorVersion = 2;
|
||||
MobileGL::MG_External::GLESCapabilities es32;
|
||||
ASSERT_TRUE(MobileGL::MG_Util::BackendLoader::FillInGLESCapabilities(es32, withPatch));
|
||||
EXPECT_TRUE(es32.SupportsTessellationShader);
|
||||
}
|
||||
|
||||
// Minecraft 26.3 checks ARB_draw_indirect before it considers the already-advertised
|
||||
// ARB_multi_draw_indirect, then separately requires ARB_base_instance before enabling its terrain
|
||||
// indirect path. Pin both strings and, just as importantly, the non-zero firstInstance gate.
|
||||
|
||||
@@ -1571,6 +1571,57 @@ void main() { mgColor = vec4(float(gl_MaxCullDistances)); }
|
||||
MG_State::pGLContext = Move(previousContext);
|
||||
}
|
||||
|
||||
// GL_EXT_shader_integer_mix (KHR-GL4x.shader_integer_mix.*): a 3.30 shader that requires the
|
||||
// extension must see its macro and must be able to mix integer and boolean vectors under a
|
||||
// boolean selector. Both backends carry the result: SPIR-V lowers the call to OpSelect, which
|
||||
// ESSL 3.10+ and GLSL 4.50 print back as a core boolean mix.
|
||||
TEST(ShaderCompilerSanity, ExtShaderIntegerMixIsUsableAt330) {
|
||||
using namespace MobileGL;
|
||||
|
||||
auto previousContext = MG_State::pGLContext.Take();
|
||||
auto previousBackend = Move(MG_Backend::pActiveBackendObject);
|
||||
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
|
||||
MG_Backend::pActiveBackendObject = MakeUnique<DynamicParameterBackend>(MG_Backend::DynamicBackendParameters{});
|
||||
const auto env = MG_Util::ShaderTranspiler::CaptureCompileEnv();
|
||||
|
||||
const auto compile = [&env](GLenum stage, const String& source) {
|
||||
return MG_Util::ShaderTranspiler::ShaderCompiler::CompileShader({
|
||||
.shaderType = stage,
|
||||
.sourceStr = source,
|
||||
.env = env.get(),
|
||||
});
|
||||
};
|
||||
|
||||
const String defineProbe = R"(#version 330
|
||||
#extension GL_EXT_shader_integer_mix: require
|
||||
#if !defined GL_EXT_shader_integer_mix
|
||||
# error GL_EXT_shader_integer_mix is not defined
|
||||
#elif GL_EXT_shader_integer_mix != 1
|
||||
# error GL_EXT_shader_integer_mix is not equal to 1
|
||||
#endif
|
||||
void main(void) { gl_Position = vec4(0); }
|
||||
)";
|
||||
auto define = compile(GL_VERTEX_SHADER, defineProbe);
|
||||
EXPECT_TRUE(define) << (define ? String() : define.error().log);
|
||||
|
||||
const String mixes = R"(#version 330
|
||||
#extension GL_EXT_shader_integer_mix: enable
|
||||
uniform ivec4 a; uniform ivec4 b; uniform uvec4 c; uniform uvec4 d; uniform bvec4 sel;
|
||||
flat out ivec4 i; flat out uvec4 u; flat out ivec4 bo;
|
||||
void main(void) {
|
||||
i = mix(a, b, sel);
|
||||
u = mix(c, d, sel);
|
||||
bo = ivec4(mix(bvec4(a), bvec4(b), sel));
|
||||
gl_Position = vec4(0);
|
||||
}
|
||||
)";
|
||||
auto mixed = compile(GL_VERTEX_SHADER, mixes);
|
||||
EXPECT_TRUE(mixed) << (mixed ? String() : mixed.error().log);
|
||||
|
||||
MG_Backend::pActiveBackendObject = Move(previousBackend);
|
||||
MG_State::pGLContext = Move(previousContext);
|
||||
}
|
||||
|
||||
TEST(GetterSanity, ReportsKhrSubgroupDynamicParameters) {
|
||||
using namespace MobileGL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user