Commit f34d1db9 by Geoff Lang

Add table entries for almost all the remaining GL texture formats.

BUG=angleproject:884 BUG=angleproject:967 Change-Id: I113757dd9e1fae8fe0241a7286be979a90891b53 Reviewed-on: https://chromium-review.googlesource.com/270275Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/273135
parent 859dcb88
...@@ -1580,4 +1580,9 @@ void FunctionsGL::initialize() ...@@ -1580,4 +1580,9 @@ void FunctionsGL::initialize()
} }
} }
bool FunctionsGL::hasExtension(const std::string &ext) const
{
return std::find(extensions.begin(), extensions.end(), ext) != extensions.end();
}
} }
...@@ -31,6 +31,7 @@ class FunctionsGL ...@@ -31,6 +31,7 @@ class FunctionsGL
// Extensions // Extensions
std::vector<std::string> extensions; std::vector<std::string> extensions;
bool hasExtension(const std::string &ext) const;
// Entry Points // Entry Points
// 1.0 // 1.0
......
...@@ -21,17 +21,31 @@ namespace rx ...@@ -21,17 +21,31 @@ namespace rx
namespace nativegl namespace nativegl
{ {
struct SupportRequirement
{
SupportRequirement();
// Version that this format became supported without extensions
GLuint majorVersion;
GLuint minorVersion;
// Extensions that are required if the minimum version is not met
std::vector<std::string> versionExtensions;
// Extensions that are always required to support this format
std::vector<std::string> requiredExtensions;
};
struct InternalFormat struct InternalFormat
{ {
InternalFormat(); InternalFormat();
typedef bool(*SupportCheckFunction)(GLuint majorVersion, GLuint minorVersion, SupportRequirement texture;
const std::vector<std::string> &extensions); SupportRequirement filter;
SupportCheckFunction textureSupport; SupportRequirement renderbuffer;
SupportCheckFunction renderSupport; SupportRequirement framebufferAttachment;
SupportCheckFunction filterSupport;
}; };
const InternalFormat &GetInternalFormatInfo(GLenum internalFormat); const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, bool es);
} }
......
...@@ -25,14 +25,46 @@ namespace rx ...@@ -25,14 +25,46 @@ namespace rx
namespace nativegl_gl namespace nativegl_gl
{ {
static bool MeetsRequirements(const FunctionsGL *functions, const nativegl::SupportRequirement &requirements)
{
for (const std::string &extension : requirements.requiredExtensions)
{
if (!functions->hasExtension(extension))
{
return false;
}
}
if (functions->majorVersion > requirements.majorVersion ||
(functions->majorVersion == requirements.majorVersion && functions->minorVersion >= requirements.minorVersion))
{
return true;
}
else if (!requirements.versionExtensions.empty())
{
for (const std::string &extension : requirements.versionExtensions)
{
if (!functions->hasExtension(extension))
{
return false;
}
}
return true;
}
else
{
return false;
}
}
static gl::TextureCaps GenerateTextureFormatCaps(const FunctionsGL *functions, GLenum internalFormat) static gl::TextureCaps GenerateTextureFormatCaps(const FunctionsGL *functions, GLenum internalFormat)
{ {
gl::TextureCaps textureCaps; gl::TextureCaps textureCaps;
const nativegl::InternalFormat &formatInfo = nativegl::GetInternalFormatInfo(internalFormat); const nativegl::InternalFormat &formatInfo = nativegl::GetInternalFormatInfo(internalFormat, functions->openGLES);
textureCaps.texturable = formatInfo.textureSupport(functions->majorVersion, functions->minorVersion, functions->extensions); textureCaps.texturable = MeetsRequirements(functions, formatInfo.texture);
textureCaps.renderable = formatInfo.renderSupport(functions->majorVersion, functions->minorVersion, functions->extensions); textureCaps.filterable = textureCaps.texturable && MeetsRequirements(functions, formatInfo.filter);
textureCaps.filterable = formatInfo.filterSupport(functions->majorVersion, functions->minorVersion, functions->extensions); textureCaps.renderable = MeetsRequirements(functions, formatInfo.framebufferAttachment);
// glGetInternalformativ is not available until version 4.2 but may be available through the 3.0 // glGetInternalformativ is not available until version 4.2 but may be available through the 3.0
// extension GL_ARB_internalformat_query // extension GL_ARB_internalformat_query
......
...@@ -36,7 +36,7 @@ class BlendMinMaxTest : public ANGLETest ...@@ -36,7 +36,7 @@ class BlendMinMaxTest : public ANGLETest
return blendMin ? std::min<GLubyte>(curAsUbyte, prevColor) : std::max<GLubyte>(curAsUbyte, prevColor); return blendMin ? std::min<GLubyte>(curAsUbyte, prevColor) : std::max<GLubyte>(curAsUbyte, prevColor);
} }
void runTest() void runTest(GLenum colorFormat)
{ {
if (getClientVersion() < 3 && !extensionEnabled("GL_EXT_blend_minmax")) if (getClientVersion() < 3 && !extensionEnabled("GL_EXT_blend_minmax"))
{ {
...@@ -44,6 +44,8 @@ class BlendMinMaxTest : public ANGLETest ...@@ -44,6 +44,8 @@ class BlendMinMaxTest : public ANGLETest
return; return;
} }
SetUpFramebuffer(colorFormat);
const size_t colorCount = 1024; const size_t colorCount = 1024;
Color colors[colorCount]; Color colors[colorCount];
for (size_t i = 0; i < colorCount; i++) for (size_t i = 0; i < colorCount; i++)
...@@ -152,8 +154,7 @@ class BlendMinMaxTest : public ANGLETest ...@@ -152,8 +154,7 @@ class BlendMinMaxTest : public ANGLETest
TEST_P(BlendMinMaxTest, RGBA8) TEST_P(BlendMinMaxTest, RGBA8)
{ {
SetUpFramebuffer(GL_RGBA8); runTest(GL_RGBA8);
runTest();
} }
TEST_P(BlendMinMaxTest, RGBA32f) TEST_P(BlendMinMaxTest, RGBA32f)
...@@ -164,8 +165,7 @@ TEST_P(BlendMinMaxTest, RGBA32f) ...@@ -164,8 +165,7 @@ TEST_P(BlendMinMaxTest, RGBA32f)
return; return;
} }
SetUpFramebuffer(GL_RGBA32F); runTest(GL_RGBA32F);
runTest();
} }
TEST_P(BlendMinMaxTest, RGBA16F) TEST_P(BlendMinMaxTest, RGBA16F)
...@@ -176,8 +176,7 @@ TEST_P(BlendMinMaxTest, RGBA16F) ...@@ -176,8 +176,7 @@ TEST_P(BlendMinMaxTest, RGBA16F)
return; return;
} }
SetUpFramebuffer(GL_RGBA16F); runTest(GL_RGBA16F);
runTest();
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
......
...@@ -129,4 +129,4 @@ TEST_P(CubeMapTextureTest, RenderToFacesConsecutively) ...@@ -129,4 +129,4 @@ TEST_P(CubeMapTextureTest, RenderToFacesConsecutively)
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(CubeMapTextureTest, ES2_D3D11(), ES2_D3D11_FL9_3()); ANGLE_INSTANTIATE_TEST(CubeMapTextureTest, ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL(), ES3_OPENGL());
...@@ -174,9 +174,15 @@ TEST_P(DepthStencilFormatsTestES3, DrawWithDepthStencil) ...@@ -174,9 +174,15 @@ TEST_P(DepthStencilFormatsTestES3, DrawWithDepthStencil)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_NEAR(0, 0, 255, 0, 0, 255, 2.0); GLubyte pixel[4];
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel);
// Only require the red and alpha channels have the correct values, the depth texture extensions
// leave the green and blue channels undefined
ASSERT_NEAR(255, pixel[0], 2.0);
ASSERT_EQ(255, pixel[3]);
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(DepthStencilFormatsTest, ES2_D3D9(), ES2_D3D11()); ANGLE_INSTANTIATE_TEST(DepthStencilFormatsTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL());
ANGLE_INSTANTIATE_TEST(DepthStencilFormatsTestES3, ES3_D3D11()); ANGLE_INSTANTIATE_TEST(DepthStencilFormatsTestES3, ES3_D3D11(), ES3_OPENGL());
...@@ -142,16 +142,34 @@ TEST_P(FramebufferFormatsTest, RGB565) ...@@ -142,16 +142,34 @@ TEST_P(FramebufferFormatsTest, RGB565)
TEST_P(FramebufferFormatsTest, RGB8) TEST_P(FramebufferFormatsTest, RGB8)
{ {
if (getClientVersion() < 3 && !extensionEnabled("GL_OES_rgb8_rgba8"))
{
std::cout << "Test skipped due to missing ES3 or GL_OES_rgb8_rgba8." << std::endl;
return;
}
testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0); testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0);
} }
TEST_P(FramebufferFormatsTest, BGRA8) TEST_P(FramebufferFormatsTest, BGRA8)
{ {
if (!extensionEnabled("GL_EXT_texture_format_BGRA8888"))
{
std::cout << "Test skipped due to missing GL_EXT_texture_format_BGRA8888." << std::endl;
return;
}
testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8); testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8);
} }
TEST_P(FramebufferFormatsTest, RGBA8) TEST_P(FramebufferFormatsTest, RGBA8)
{ {
if (getClientVersion() < 3 && !extensionEnabled("GL_OES_rgb8_rgba8"))
{
std::cout << "Test skipped due to missing ES3 or GL_OES_rgb8_rgba8." << std::endl;
return;
}
testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8); testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8);
} }
...@@ -167,6 +185,12 @@ TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH24) ...@@ -167,6 +185,12 @@ TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH24)
TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH32F) TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH32F)
{ {
if (getClientVersion() < 3)
{
std::cout << "Test skipped due to missing ES3." << std::endl;
return;
}
testRenderbufferMultisampleFormat(3, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT32F); testRenderbufferMultisampleFormat(3, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT32F);
} }
...@@ -177,13 +201,26 @@ TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH24_STENCIL8) ...@@ -177,13 +201,26 @@ TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH24_STENCIL8)
TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH32F_STENCIL8) TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH32F_STENCIL8)
{ {
if (getClientVersion() < 3)
{
std::cout << "Test skipped due to missing ES3." << std::endl;
return;
}
testRenderbufferMultisampleFormat(3, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH32F_STENCIL8); testRenderbufferMultisampleFormat(3, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH32F_STENCIL8);
} }
TEST_P(FramebufferFormatsTest, RenderbufferMultisample_STENCIL_INDEX8) TEST_P(FramebufferFormatsTest, RenderbufferMultisample_STENCIL_INDEX8)
{ {
// TODO(geofflang): Figure out how to support GLSTENCIL_INDEX8 on desktop GL
if (GetParam().mEGLPlatformParameters.renderer == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
{
std::cout << "Test skipped on Desktop OpenGL." << std::endl;
return;
}
testRenderbufferMultisampleFormat(2, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8); testRenderbufferMultisampleFormat(2, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8);
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(FramebufferFormatsTest, ES2_D3D9(), ES2_D3D11(), ES3_D3D11()); ANGLE_INSTANTIATE_TEST(FramebufferFormatsTest, ES2_D3D9(), ES2_D3D11(), ES3_D3D11(), ES2_OPENGL(), ES3_OPENGL());
...@@ -163,4 +163,4 @@ TEST_P(IncompleteTextureTest, UpdateTexture) ...@@ -163,4 +163,4 @@ TEST_P(IncompleteTextureTest, UpdateTexture)
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(IncompleteTextureTest, ES2_D3D9(), ES2_D3D11()); ANGLE_INSTANTIATE_TEST(IncompleteTextureTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL());
...@@ -216,6 +216,6 @@ TEST_P(IndexedPointsTestUInt, UnsignedIntOffset3) ...@@ -216,6 +216,6 @@ TEST_P(IndexedPointsTestUInt, UnsignedIntOffset3)
runTest(3); runTest(3);
} }
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUByte, ES2_D3D11()); ANGLE_INSTANTIATE_TEST(IndexedPointsTestUByte, ES2_D3D11(), ES2_OPENGL());
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUShort, ES2_D3D11()); ANGLE_INSTANTIATE_TEST(IndexedPointsTestUShort, ES2_D3D11(), ES2_OPENGL());
ANGLE_INSTANTIATE_TEST(IndexedPointsTestUInt, ES2_D3D11()); ANGLE_INSTANTIATE_TEST(IndexedPointsTestUInt, ES2_D3D11(), ES2_OPENGL());
...@@ -28,20 +28,16 @@ class LineLoopTest : public ANGLETest ...@@ -28,20 +28,16 @@ class LineLoopTest : public ANGLETest
const std::string vsSource = SHADER_SOURCE const std::string vsSource = SHADER_SOURCE
( (
attribute highp vec4 position; attribute highp vec4 position;
attribute highp vec4 in_color;
varying highp vec4 color;
void main(void) void main(void)
{ {
gl_Position = position; gl_Position = position;
color = in_color;
} }
); );
const std::string fsSource = SHADER_SOURCE const std::string fsSource = SHADER_SOURCE
( (
varying highp vec4 color; uniform highp vec4 color;
void main(void) void main(void)
{ {
gl_FragColor = color; gl_FragColor = color;
...@@ -55,7 +51,7 @@ class LineLoopTest : public ANGLETest ...@@ -55,7 +51,7 @@ class LineLoopTest : public ANGLETest
} }
mPositionLocation = glGetAttribLocation(mProgram, "position"); mPositionLocation = glGetAttribLocation(mProgram, "position");
mColorLocation = glGetAttribLocation(mProgram, "in_color"); mColorLocation = glGetUniformLocation(mProgram, "in_color");
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND); glEnable(GL_BLEND);
...@@ -205,4 +201,4 @@ TEST_P(LineLoopTest, LineLoopUIntIndexBuffer) ...@@ -205,4 +201,4 @@ TEST_P(LineLoopTest, LineLoopUIntIndexBuffer)
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(LineLoopTest, ES2_D3D9(), ES2_D3D11()); ANGLE_INSTANTIATE_TEST(LineLoopTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL());
...@@ -274,6 +274,7 @@ TEST_P(SwizzleTest, CompressedDXT_2D) ...@@ -274,6 +274,7 @@ TEST_P(SwizzleTest, CompressedDXT_2D)
{ {
if (!extensionEnabled("GL_EXT_texture_compression_dxt1")) if (!extensionEnabled("GL_EXT_texture_compression_dxt1"))
{ {
std::cout << "Test skipped due to missing GL_EXT_texture_compression_dxt1." << std::endl;
return; return;
} }
...@@ -282,6 +283,6 @@ TEST_P(SwizzleTest, CompressedDXT_2D) ...@@ -282,6 +283,6 @@ TEST_P(SwizzleTest, CompressedDXT_2D)
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(SwizzleTest, ES3_D3D11()); ANGLE_INSTANTIATE_TEST(SwizzleTest, ES3_D3D11(), ES3_OPENGL());
} // namespace } // namespace
...@@ -610,6 +610,6 @@ TEST_P(TextureTest, TextureNPOT_GL_ALPHA_UBYTE) ...@@ -610,6 +610,6 @@ TEST_P(TextureTest, TextureNPOT_GL_ALPHA_UBYTE)
} }
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(TextureTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3()); ANGLE_INSTANTIATE_TEST(TextureTest, ES2_D3D9(), ES2_D3D11(), ES2_D3D11_FL9_3(), ES2_OPENGL());
} // namespace } // namespace
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