Commit 8273e006 by Geoff Lang

Add new GLSL target versions.

Test the emulated GLSL functions against multiple GL versions. BUG=angleproject:1044 Change-Id: I1e12523301042f0d541ab2f4e73f02319d1584ef Reviewed-on: https://chromium-review.googlesource.com/277702Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 83ab236f
......@@ -90,8 +90,15 @@ typedef enum {
//Note: GL introduced core profiles in 1.5. However, for compatiblity with Chromium, we treat SH_GLSL_CORE_OUTPUT as GLSL_130_OUTPUT.
//TODO: Remove SH_GLSL_CORE_OUTPUT
SH_GLSL_130_OUTPUT = 0x8B47,
SH_GLSL_140_OUTPUT = 0x8B80,
SH_GLSL_150_CORE_OUTPUT = 0x8B81,
SH_GLSL_330_CORE_OUTPUT = 0x8B82,
SH_GLSL_400_CORE_OUTPUT = 0x8B83,
SH_GLSL_410_CORE_OUTPUT = 0x8B84,
SH_GLSL_420_CORE_OUTPUT = 0x8B85,
SH_GLSL_430_CORE_OUTPUT = 0x8B86,
SH_GLSL_440_CORE_OUTPUT = 0x8B87,
SH_GLSL_450_CORE_OUTPUT = 0x8B88,
// HLSL output only supported in some configurations.
SH_HLSL_OUTPUT = 0x8B48,
......
......@@ -41,7 +41,9 @@ void InitBuiltInFunctionEmulatorForGLSLWorkarounds(BuiltInFunctionEmulator *emu,
void InitBuiltInFunctionEmulatorForGLSLMissingFunctions(BuiltInFunctionEmulator *emu, sh::GLenum shaderType,
int targetGLSLVersion)
{
if (targetGLSLVersion == GLSL_VERSION_410)
// Emulate packSnorm2x16, packHalf2x16, unpackSnorm2x16, and unpackHalf2x16 (GLSL 4.20)
// by using floatBitsToInt, floatBitsToUint, intBitsToFloat, and uintBitsToFloat (GLSL 3.30).
if (targetGLSLVersion >= GLSL_VERSION_330 && targetGLSLVersion < GLSL_VERSION_420)
{
TType *float2 = new TType(EbtFloat, 2);
TType *uint1 = new TType(EbtUInt);
......
......@@ -22,8 +22,15 @@ TCompiler* ConstructCompiler(
case SH_ESSL_OUTPUT:
return new TranslatorESSL(type, spec);
case SH_GLSL_130_OUTPUT:
case SH_GLSL_140_OUTPUT:
case SH_GLSL_150_CORE_OUTPUT:
case SH_GLSL_330_CORE_OUTPUT:
case SH_GLSL_400_CORE_OUTPUT:
case SH_GLSL_410_CORE_OUTPUT:
case SH_GLSL_420_CORE_OUTPUT:
case SH_GLSL_430_CORE_OUTPUT:
case SH_GLSL_440_CORE_OUTPUT:
case SH_GLSL_450_CORE_OUTPUT:
case SH_GLSL_COMPATIBILITY_OUTPUT:
return new TranslatorGLSL(type, spec, output);
case SH_HLSL9_OUTPUT:
......
......@@ -38,8 +38,15 @@ bool IsWebGLBasedSpec(ShShaderSpec spec)
bool IsGLSL130OrNewer(ShShaderOutput output)
{
return (output == SH_GLSL_130_OUTPUT ||
output == SH_GLSL_140_OUTPUT ||
output == SH_GLSL_150_CORE_OUTPUT ||
output == SH_GLSL_330_CORE_OUTPUT ||
output == SH_GLSL_400_CORE_OUTPUT ||
output == SH_GLSL_410_CORE_OUTPUT ||
output == SH_GLSL_420_CORE_OUTPUT);
output == SH_GLSL_420_CORE_OUTPUT ||
output == SH_GLSL_430_CORE_OUTPUT ||
output == SH_GLSL_440_CORE_OUTPUT ||
output == SH_GLSL_450_CORE_OUTPUT);
}
size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
......
......@@ -11,8 +11,15 @@ int ShaderOutputTypeToGLSLVersion(ShShaderOutput output)
switch (output)
{
case SH_GLSL_130_OUTPUT: return GLSL_VERSION_130;
case SH_GLSL_140_OUTPUT: return GLSL_VERSION_140;
case SH_GLSL_150_CORE_OUTPUT: return GLSL_VERSION_150;
case SH_GLSL_330_CORE_OUTPUT: return GLSL_VERSION_330;
case SH_GLSL_400_CORE_OUTPUT: return GLSL_VERSION_400;
case SH_GLSL_410_CORE_OUTPUT: return GLSL_VERSION_410;
case SH_GLSL_420_CORE_OUTPUT: return GLSL_VERSION_420;
case SH_GLSL_430_CORE_OUTPUT: return GLSL_VERSION_430;
case SH_GLSL_440_CORE_OUTPUT: return GLSL_VERSION_440;
case SH_GLSL_450_CORE_OUTPUT: return GLSL_VERSION_450;
case SH_GLSL_COMPATIBILITY_OUTPUT: return GLSL_VERSION_110;
default: UNREACHABLE(); return 0;
}
......
......@@ -14,8 +14,15 @@
static const int GLSL_VERSION_110 = 110;
static const int GLSL_VERSION_120 = 120;
static const int GLSL_VERSION_130 = 130;
static const int GLSL_VERSION_140 = 140;
static const int GLSL_VERSION_150 = 150;
static const int GLSL_VERSION_330 = 330;
static const int GLSL_VERSION_400 = 400;
static const int GLSL_VERSION_410 = 410;
static const int GLSL_VERSION_420 = 420;
static const int GLSL_VERSION_430 = 430;
static const int GLSL_VERSION_440 = 440;
static const int GLSL_VERSION_450 = 450;
int ShaderOutputTypeToGLSLVersion(ShShaderOutput output);
......
......@@ -11,6 +11,7 @@
#include "common/debug.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Data.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
namespace rx
{
......@@ -18,10 +19,74 @@ namespace rx
// Global count of active shader compiler handles. Needed to know when to call ShInitialize and ShFinalize.
static size_t activeCompilerHandles = 0;
CompilerGL::CompilerGL(const gl::Data &data)
static ShShaderOutput GetShaderOutputType(const FunctionsGL *functions)
{
ASSERT(functions);
if (functions->standard == STANDARD_GL_DESKTOP)
{
// GLSL outputs
if (functions->isAtLeastGL(gl::Version(4, 5)))
{
return SH_GLSL_450_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(4, 4)))
{
return SH_GLSL_440_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(4, 3)))
{
return SH_GLSL_430_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(4, 2)))
{
return SH_GLSL_420_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(4, 1)))
{
return SH_GLSL_410_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(4, 0)))
{
return SH_GLSL_400_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(3, 3)))
{
return SH_GLSL_330_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(3, 2)))
{
return SH_GLSL_150_CORE_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(3, 1)))
{
return SH_GLSL_140_OUTPUT;
}
else if (functions->isAtLeastGL(gl::Version(3, 0)))
{
return SH_GLSL_130_OUTPUT;
}
else
{
return SH_GLSL_COMPATIBILITY_OUTPUT;
}
}
else if (functions->standard == STANDARD_GL_ES)
{
// ESSL outputs
return SH_ESSL_OUTPUT;
}
else
{
UNREACHABLE();
return ShShaderOutput(0);
}
}
CompilerGL::CompilerGL(const gl::Data &data, const FunctionsGL *functions)
: CompilerImpl(),
mSpec(data.clientVersion > 2 ? SH_GLES3_SPEC : SH_GLES2_SPEC),
mOutputType(data.clientVersion > 2 ? SH_GLSL_410_CORE_OUTPUT : SH_GLSL_OUTPUT),
mOutputType(GetShaderOutputType(functions)),
mResources(),
mFragmentCompiler(nullptr),
mVertexCompiler(nullptr)
......
......@@ -21,10 +21,12 @@ struct Data;
namespace rx
{
class FunctionsGL;
class CompilerGL : public CompilerImpl
{
public:
CompilerGL(const gl::Data &data);
CompilerGL(const gl::Data &data, const FunctionsGL *functions);
~CompilerGL() override;
gl::Error release() override;
......
......@@ -167,7 +167,7 @@ gl::Error RendererGL::drawElements(const gl::Data &data, GLenum mode, GLsizei co
CompilerImpl *RendererGL::createCompiler(const gl::Data &data)
{
return new CompilerGL(data);
return new CompilerGL(data, mFunctions);
}
ShaderImpl *RendererGL::createShader(GLenum type)
......
......@@ -218,6 +218,7 @@ TEST_P(PackUnpackTest, PackUnpackHalfOverflow)
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(PackUnpackTest, ES3_OPENGL());
ANGLE_INSTANTIATE_TEST(PackUnpackTest, ES3_OPENGL(3, 3), ES3_OPENGL(4, 0), ES3_OPENGL(4, 1), ES3_OPENGL(4, 2),
ES3_OPENGL(4, 3), ES3_OPENGL(4, 4), ES3_OPENGL(4, 5));
}
......@@ -310,6 +310,15 @@ EGLPlatformParameters OPENGL()
return EGLPlatformParameters(EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE);
}
EGLPlatformParameters OPENGL(EGLint major, EGLint minor)
{
return EGLPlatformParameters(
EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
major, minor,
EGL_DONT_CARE);
}
EGLPlatformParameters OPENGL_NULL()
{
return EGLPlatformParameters(
......@@ -501,9 +510,19 @@ PlatformParameters ES2_OPENGL()
return PlatformParameters(2, 0, egl_platform::OPENGL());
}
PlatformParameters ES2_OPENGL(EGLint major, EGLint minor)
{
return PlatformParameters(2, 0, egl_platform::OPENGL(major, minor));
}
PlatformParameters ES3_OPENGL()
{
return PlatformParameters(3, 0, egl_platform::OPENGL());
}
PlatformParameters ES3_OPENGL(EGLint major, EGLint minor)
{
return PlatformParameters(3, 0, egl_platform::OPENGL(major, minor));
}
} // namespace angle
......@@ -68,6 +68,7 @@ EGLPlatformParameters D3D11_FL10_0_REFERENCE();
EGLPlatformParameters D3D11_FL9_3_REFERENCE();
EGLPlatformParameters OPENGL();
EGLPlatformParameters OPENGL(EGLint major, EGLint minor);
EGLPlatformParameters OPENGL_NULL();
EGLPlatformParameters OPENGLES();
......@@ -115,7 +116,9 @@ PlatformParameters ES3_D3D11_FL10_1_REFERENCE();
PlatformParameters ES3_D3D11_FL10_0_REFERENCE();
PlatformParameters ES2_OPENGL();
PlatformParameters ES2_OPENGL(EGLint major, EGLint minor);
PlatformParameters ES3_OPENGL();
PlatformParameters ES3_OPENGL(EGLint major, EGLint minor);
PlatformParameters ES2_OPENGLES();
PlatformParameters ES3_OPENGLES();
......
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