зеркало из https://github.com/AvaloniaUI/angle.git
Enable desktop GLSL for desktop GL frontend
Bug: angleproject:7533 Change-Id: I91bd0c217880b05683b86449a9211b9844575ebc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3850471 Commit-Queue: Eddie Hatfield <eddiehatfield@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com>
This commit is contained in:
Родитель
f7274de21e
Коммит
5317b778e8
|
@ -204,7 +204,7 @@ declare_args() {
|
|||
angle_enable_vulkan && !is_android && !is_ggp && is_clang
|
||||
|
||||
# Translator frontend support:
|
||||
angle_enable_desktop_glsl = angle_enable_gl_desktop_backend
|
||||
angle_enable_desktop_glsl = angle_enable_gl_desktop_frontend
|
||||
|
||||
# Translator backend support:
|
||||
angle_enable_hlsl = angle_enable_d3d9 || angle_enable_d3d11
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("../../gni/angle.gni")
|
||||
|
||||
angle_unittests_sources = [
|
||||
"../../util/test_utils_unittest.cpp",
|
||||
"../../util/test_utils_unittest_helper.h",
|
||||
|
@ -159,7 +161,7 @@ angle_unittests_gl_sources =
|
|||
|
||||
angle_unittests_msl_sources = [ "../tests/compiler_tests/MSLOutput_test.cpp" ]
|
||||
|
||||
if (is_android) {
|
||||
if (!angle_enable_desktop_glsl) {
|
||||
angle_unittests_sources +=
|
||||
[ "compiler_tests/ImmutableString_test_ESSL_autogen.cpp" ]
|
||||
} else {
|
||||
|
|
|
@ -233,142 +233,4 @@ TEST_F(ShCompileTest, DecimalSepLocale)
|
|||
// Desktop GLSL support is not enabled on Android
|
||||
#if !defined(ANGLE_PLATFORM_ANDROID)
|
||||
|
||||
// For testing Desktop GL Shaders
|
||||
class ShCompileDesktopGLTest : public ShCompileTest
|
||||
{
|
||||
public:
|
||||
ShCompileDesktopGLTest() {}
|
||||
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
sh::InitBuiltInResources(&mResources);
|
||||
mCompiler = sh::ConstructCompiler(GL_FRAGMENT_SHADER, SH_GL_COMPATIBILITY_SPEC,
|
||||
SH_GLSL_330_CORE_OUTPUT, &mResources);
|
||||
ASSERT_TRUE(mCompiler != nullptr) << "Compiler could not be constructed.";
|
||||
}
|
||||
};
|
||||
|
||||
// Test calling sh::Compile with fragment shader source string
|
||||
TEST_F(ShCompileDesktopGLTest, DesktopGLString)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330
|
||||
void main()
|
||||
{
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, true);
|
||||
}
|
||||
|
||||
// Test calling sh::Compile with core version
|
||||
TEST_F(ShCompileDesktopGLTest, FragmentShaderCoreVersion)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, true);
|
||||
}
|
||||
|
||||
// Implicit conversions in basic operations
|
||||
TEST_F(ShCompileDesktopGLTest, ImplicitConversionBasicOperation)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
//float a = 1 + 1.5;
|
||||
//float b = 1 - 1.5;
|
||||
//float c = 1 * 1.5;
|
||||
//float d = 1 / 1.5;
|
||||
//float e = 1.5 + 1;
|
||||
//float f = 1.5 - 1;
|
||||
float g = 1.5 * 1;
|
||||
//float h = 1.5 / 1;
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, true);
|
||||
}
|
||||
|
||||
// Implicit conversions when assigning
|
||||
TEST_F(ShCompileDesktopGLTest, ImplicitConversionAssign)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
float a = 1;
|
||||
uint b = 2u;
|
||||
a = b;
|
||||
a += b;
|
||||
a -= b;
|
||||
a *= b;
|
||||
a /= b;
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, true);
|
||||
}
|
||||
|
||||
// Implicit conversions for vectors
|
||||
TEST_F(ShCompileDesktopGLTest, ImplicitConversionVector)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
vec3 a;
|
||||
ivec3 b = ivec3(1, 1, 1);
|
||||
a = b;
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, true);
|
||||
}
|
||||
|
||||
// Implicit conversions should not convert between ints and uints
|
||||
TEST_F(ShCompileDesktopGLTest, ImplicitConversionAssignFailed)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
int a = 1;
|
||||
uint b = 2;
|
||||
a = b;
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, false);
|
||||
}
|
||||
|
||||
// GL shaders use implicit conversions between types
|
||||
// Testing internal implicit conversions
|
||||
TEST_F(ShCompileDesktopGLTest, ImplicitConversionFunction)
|
||||
{
|
||||
constexpr char kFragmentShaderString[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
float cosTheta = clamp(0.5,0,1);
|
||||
float exp = pow(0.5,2);
|
||||
})";
|
||||
|
||||
const char *shaderStrings[] = {kFragmentShaderString};
|
||||
|
||||
testCompile(shaderStrings, 1, true);
|
||||
}
|
||||
|
||||
#endif // !defined(ANGLE_PLATFORM_ANDROID)
|
||||
|
|
|
@ -30,7 +30,7 @@ class DesktopGLSLTest : public ANGLETest<>
|
|||
// initializes.
|
||||
TEST_P(DesktopGLSLTest, BasicCompilation)
|
||||
{
|
||||
const char kVS[] = R"(#version 150
|
||||
constexpr char kVS[] = R"(#version 150
|
||||
in vec4 position;
|
||||
|
||||
void main()
|
||||
|
@ -38,7 +38,7 @@ void main()
|
|||
gl_Position = position;
|
||||
})";
|
||||
|
||||
const char kFS[] = R"(#version 150
|
||||
constexpr char kFS[] = R"(#version 150
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
|
@ -49,6 +49,114 @@ void main()
|
|||
ANGLE_GL_PROGRAM(testProgram, kVS, kFS);
|
||||
}
|
||||
|
||||
// Test calling sh::Compile with fragment shader source string
|
||||
TEST_P(DesktopGLSLTest, DesktopGLString)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330
|
||||
void main()
|
||||
{
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
// Test calling sh::Compile with core version
|
||||
TEST_P(DesktopGLSLTest, FragmentShaderCoreVersion)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
// Implicit conversions in basic operations
|
||||
TEST_P(DesktopGLSLTest, ImplicitConversionBasicOperation)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
//float a = 1 + 1.5;
|
||||
//float b = 1 - 1.5;
|
||||
//float c = 1 * 1.5;
|
||||
//float d = 1 / 1.5;
|
||||
//float e = 1.5 + 1;
|
||||
//float f = 1.5 - 1;
|
||||
float g = 1.5 * 1;
|
||||
//float h = 1.5 / 1;
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
// Implicit conversions when assigning
|
||||
TEST_P(DesktopGLSLTest, ImplicitConversionAssign)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
float a = 1;
|
||||
uint b = 2u;
|
||||
a = b;
|
||||
a += b;
|
||||
a -= b;
|
||||
a *= b;
|
||||
a /= b;
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
// Implicit conversions for vectors
|
||||
TEST_P(DesktopGLSLTest, ImplicitConversionVector)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
vec3 a;
|
||||
ivec3 b = ivec3(1, 1, 1);
|
||||
a = b;
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
// Implicit conversions should not convert between ints and uints
|
||||
TEST_P(DesktopGLSLTest, ImplicitConversionAssignFailed)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
int a = 1;
|
||||
uint b = 2;
|
||||
a = b;
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
// GL shaders use implicit conversions between types
|
||||
// Testing internal implicit conversions
|
||||
TEST_P(DesktopGLSLTest, ImplicitConversionFunction)
|
||||
{
|
||||
constexpr char kFS[] =
|
||||
R"(#version 330 core
|
||||
void main()
|
||||
{
|
||||
float cosTheta = clamp(0.5,0,1);
|
||||
float exp = pow(0.5,2);
|
||||
})";
|
||||
|
||||
ASSERT_NE(static_cast<unsigned int>(0), CompileShader(GL_FRAGMENT_SHADER, kFS));
|
||||
}
|
||||
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DesktopGLSLTest);
|
||||
ANGLE_INSTANTIATE_TEST_GL32_CORE(DesktopGLSLTest);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче