Commit 95663914 by Geoff Lang

Add stubs for GL_OES_fbo_render_mipmap.

BUG=angle:905 Change-Id: Idd4964bd2d9d07cd98137770e1cc57397f1dd3a6 Reviewed-on: https://chromium-review.googlesource.com/263762Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent dab84368
...@@ -133,6 +133,7 @@ Extensions::Extensions() ...@@ -133,6 +133,7 @@ Extensions::Extensions()
fragDepth(false), fragDepth(false),
textureUsage(false), textureUsage(false),
translatedShaderSource(false), translatedShaderSource(false),
fboRenderMipmap(false),
colorBufferFloat(false) colorBufferFloat(false)
{ {
} }
...@@ -182,6 +183,7 @@ std::vector<std::string> Extensions::getStrings() const ...@@ -182,6 +183,7 @@ std::vector<std::string> Extensions::getStrings() const
InsertExtensionString("GL_EXT_frag_depth", fragDepth, &extensionStrings); InsertExtensionString("GL_EXT_frag_depth", fragDepth, &extensionStrings);
InsertExtensionString("GL_ANGLE_texture_usage", textureUsage, &extensionStrings); InsertExtensionString("GL_ANGLE_texture_usage", textureUsage, &extensionStrings);
InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings); InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings);
InsertExtensionString("GL_OES_fbo_render_mipmap", fboRenderMipmap, &extensionStrings);
InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings); InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings);
return extensionStrings; return extensionStrings;
......
...@@ -209,6 +209,9 @@ struct Extensions ...@@ -209,6 +209,9 @@ struct Extensions
// GL_ANGLE_translated_shader_source // GL_ANGLE_translated_shader_source
bool translatedShaderSource; bool translatedShaderSource;
// GL_OES_fbo_render_mipmap
bool fboRenderMipmap;
// ES3 Extension support // ES3 Extension support
// GL_EXT_color_buffer_float // GL_EXT_color_buffer_float
......
...@@ -1115,6 +1115,7 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, gl:: ...@@ -1115,6 +1115,7 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, gl::
extensions->fragDepth = true; extensions->fragDepth = true;
extensions->textureUsage = true; // This could be false since it has no effect in D3D11 extensions->textureUsage = true; // This could be false since it has no effect in D3D11
extensions->translatedShaderSource = true; extensions->translatedShaderSource = true;
extensions->fboRenderMipmap = false;
} }
} }
......
...@@ -536,6 +536,7 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT ...@@ -536,6 +536,7 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT
extensions->fragDepth = true; extensions->fragDepth = true;
extensions->textureUsage = true; extensions->textureUsage = true;
extensions->translatedShaderSource = true; extensions->translatedShaderSource = true;
extensions->fboRenderMipmap = false;
extensions->colorBufferFloat = false; extensions->colorBufferFloat = false;
} }
......
...@@ -1735,8 +1735,8 @@ bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum atta ...@@ -1735,8 +1735,8 @@ bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum atta
bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTexture2D(Context *context, GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level) GLenum textarget, GLuint texture, GLint level)
{ {
// Attachments are required to be bound to level 0 in ES2 // Attachments are required to be bound to level 0 without ES3 or the GL_OES_fbo_render_mipmap extension
if (context->getClientVersion() < 3 && level != 0) if (context->getClientVersion() < 3 && !context->getExtensions().fboRenderMipmap && level != 0)
{ {
context->recordError(Error(GL_INVALID_VALUE)); context->recordError(Error(GL_INVALID_VALUE));
return false; return false;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
'<(angle_path)/src/tests/end2end_tests/DepthStencilFormatsTest.cpp', '<(angle_path)/src/tests/end2end_tests/DepthStencilFormatsTest.cpp',
'<(angle_path)/src/tests/end2end_tests/DrawBuffersTest.cpp', '<(angle_path)/src/tests/end2end_tests/DrawBuffersTest.cpp',
'<(angle_path)/src/tests/end2end_tests/FramebufferFormatsTest.cpp', '<(angle_path)/src/tests/end2end_tests/FramebufferFormatsTest.cpp',
'<(angle_path)/src/tests/end2end_tests/FramebufferRenderMipmapTest.cpp',
'<(angle_path)/src/tests/end2end_tests/GLSLTest.cpp', '<(angle_path)/src/tests/end2end_tests/GLSLTest.cpp',
'<(angle_path)/src/tests/end2end_tests/IncompleteTextureTest.cpp', '<(angle_path)/src/tests/end2end_tests/IncompleteTextureTest.cpp',
'<(angle_path)/src/tests/end2end_tests/IndexedPointsTest.cpp', '<(angle_path)/src/tests/end2end_tests/IndexedPointsTest.cpp',
......
#include "ANGLETest.h"
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_TYPED_TEST_CASE(FramebufferRenderMipmapTest, ES2_D3D9, ES2_D3D11, ES3_D3D11);
template<typename T>
class FramebufferRenderMipmapTest : public ANGLETest
{
protected:
FramebufferRenderMipmapTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetPlatform())
{
setWindowWidth(256);
setWindowHeight(256);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
virtual void SetUp()
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
const std::string fsSource = SHADER_SOURCE
(
uniform highp vec4 color;
void main(void)
{
gl_FragColor = color;
}
);
mProgram = CompileProgram(vsSource, fsSource);
if (mProgram == 0)
{
FAIL() << "shader compilation failed.";
}
mColorLocation = glGetUniformLocation(mProgram, "color");
glUseProgram(mProgram);
glClearColor(0, 0, 0, 0);
glClearDepthf(0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
ASSERT_GL_NO_ERROR();
}
virtual void TearDown()
{
glDeleteProgram(mProgram);
ANGLETest::TearDown();
}
GLuint mProgram;
GLint mColorLocation;
};
// Validate that if we are in ES3 or GL_OES_fbo_render_mipmap exists, there are no validation errors
// when using a non-zero level in glFramebufferTexture2D.
TYPED_TEST(FramebufferRenderMipmapTest, Validation)
{
bool renderToMipmapSupported = extensionEnabled("GL_OES_fbo_render_mipmap") || getClientVersion() > 2;
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
const size_t levels = 5;
for (size_t i = 0; i < levels; i++)
{
size_t size = 1 << ((levels - 1) - i);
glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
EXPECT_GL_NO_ERROR();
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
EXPECT_GL_NO_ERROR();
for (size_t i = 0; i < levels; i++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
if (i > 0 && !renderToMipmapSupported)
{
EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
else
{
EXPECT_GL_NO_ERROR();
EXPECT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GLenum(GL_FRAMEBUFFER_COMPLETE));
}
}
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
}
// Render to various levels of a texture and check that they have the correct color data via ReadPixels
TYPED_TEST(FramebufferRenderMipmapTest, RenderToMipmap)
{
bool renderToMipmapSupported = extensionEnabled("GL_OES_fbo_render_mipmap") || getClientVersion() > 2;
if (!renderToMipmapSupported)
{
std::cout << "Test skipped because GL_OES_fbo_render_mipmap or ES3 is not available." << std::endl;
return;
}
const GLfloat levelColors[] =
{
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
};
const size_t testLevels = ArraySize(levelColors) / 4;
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
for (size_t i = 0; i < testLevels; i++)
{
size_t size = 1 << ((testLevels - 1) - i);
glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
EXPECT_GL_NO_ERROR();
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
EXPECT_GL_NO_ERROR();
// Render to the levels of the texture with different colors
for (size_t i = 0; i < testLevels; i++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
EXPECT_GL_NO_ERROR();
glUseProgram(mProgram);
glUniform4fv(mColorLocation, 1, levelColors + (i * 4));
drawQuad(mProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
}
// Test that the levels of the texture are correct
for (size_t i = 0; i < testLevels; i++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
EXPECT_GL_NO_ERROR();
const GLfloat *color = levelColors + (i * 4);
EXPECT_PIXEL_EQ(0, 0, color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255);
}
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
EXPECT_GL_NO_ERROR();
}
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