#include "tcuPlatform.hpp"
#include "tcuCommandLine.hpp"
#include "deStringUtil.hpp"
+#include "deSTLUtil.hpp"
namespace glu
{
}
}
+bool hasExtension (const glw::Functions& gl, ApiType apiType, const std::string& extension)
+{
+ std::vector<std::string> extensions(getExtensions(gl, apiType));
+
+ return de::contains(extensions.begin(), extensions.end(), extension);
+}
+
void initCoreFunctions (glw::Functions* dst, const glw::FunctionLoader* loader, ApiType apiType)
{
static const struct
void initFunctions (glw::Functions* dst, const glw::FunctionLoader* loader, ApiType apiType);
void initExtensionFunctions (glw::Functions* dst, const glw::FunctionLoader* loader, ApiType apiType);
+bool hasExtension (const glw::Functions& gl, ApiType apiType, const std::string& extension);
+
} // glu
#endif // _GLURENDERCONTEXT_HPP
TCU_THROW(NotSupportedError, "Required extensions not supported");
}
-bool hasExtension (const glw::Functions& gl, const char* extension)
-{
- std::istringstream stream((const char*)gl.getString(GL_EXTENSIONS));
- string ext;
-
- while (std::getline(stream, ext, ' '))
- {
- if (ext == extension)
- return true;
- }
-
- return false;
-}
-
bool checkVersionString (TestLog& log, const glw::Functions& gl, bool desktop, int major, int minor)
{
const char* const versionStr = (const char*)gl.getString(GL_VERSION);
{
if (majorVersion == 3 && minorVersion == 1)
{
- if (hasExtension(gl, "GL_ARB_compatibility"))
+ if (glu::hasExtension(gl, glu::ApiType::core(3, 1), "GL_ARB_compatibility"))
return true;
else
{
{
if (m_api == EGL_OPENGL_API)
{
- if (!hasExtension(gl, "GL_ARB_robustness"))
+ if (!glu::hasExtension(gl, glu::ApiType::core(majorVersion, minorVersion), "GL_ARB_robustness"))
{
log << TestLog::Message << "Created robustness context but it doesn't support GL_ARB_robustness." << TestLog::EndMessage;
isOk = false;
}
else if (m_api == EGL_OPENGL_ES_API)
{
- if (!hasExtension(gl, "GL_EXT_robustness"))
+ if (!glu::hasExtension(gl, glu::ApiType::es(majorVersion, minorVersion), "GL_EXT_robustness"))
{
log << TestLog::Message << "Created robustness context but it doesn't support GL_EXT_robustness." << TestLog::EndMessage;
isOk = false;
void ImageTests::addCreateTexture (const string& name, EGLenum source, GLenum format, GLenum type)
{
- m_createActions.add(name, MovePtr<Action>(new GLES2ImageApi::Create(createTextureImageSource(source, format, type))));
+ m_createActions.add(name, MovePtr<Action>(new GLES2ImageApi::Create(createTextureImageSource(source, format, format, type))));
}
void ImageTests::addCreateRenderbuffer (const string& name, GLenum format)
m_display = EGL_NO_DISPLAY;
}
+ bool isGLRedSupported (void)
+ {
+ return m_api.getMajorVersion() >= 3 || glu::hasExtension(m_gl, m_api, "GL_EXT_texture_rg");
+ }
+
protected:
glw::Functions m_gl;
ApiType m_api;
{
switch (storage)
{
+ case GL_RED: return "red";
+ case GL_RG: return "rg";
+ case GL_LUMINANCE: return "luminance";
+ case GL_LUMINANCE_ALPHA: return "luminance_alpha";
case GL_RGB: return "rgb";
case GL_RGBA: return "rgba";
case GL_DEPTH_COMPONENT16: return "depth_component_16";
}
}
- MovePtr<ImageSource> getImageSource (EGLint target, GLenum format, bool useTexLevel0)
+ MovePtr<ImageSource> getImageSource (EGLint target, GLenum format, bool useTexLevel0, GLenum internalFormat)
{
switch (target)
{
case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
- return createTextureImageSource(target, format, GL_UNSIGNED_BYTE, useTexLevel0);
+ return createTextureImageSource(target, internalFormat, format, GL_UNSIGNED_BYTE, useTexLevel0);
case EGL_GL_RENDERBUFFER_KHR:
return createRenderbufferImageSource(format);
case EGL_NATIVE_BUFFER_ANDROID:
}
}
- CreateImageGLES2 (EglTestContext& eglTestCtx, EGLint target, GLenum storage, bool useTexLevel0 = false)
- : ImageTestCase (eglTestCtx, ApiType::es(2, 0), string("create_image_gles2_") + getTargetName(target) + "_" + getStorageName(storage) + (useTexLevel0 ? "_level0_only" : ""), "Create EGLImage from GLES2 object")
- , m_source (getImageSource(target, storage, useTexLevel0))
+ CreateImageGLES2 (EglTestContext& eglTestCtx, EGLint target, GLenum storage, bool useTexLevel0 = false, GLenum internalFormat = GLenum(0))
+ : ImageTestCase (eglTestCtx, ApiType::es(2, 0), string("create_image_gles2_") + getTargetName(target) + "_" + getStorageName(storage) + (useTexLevel0 ? "_level0_only" : ""), "Create EGLImage from GLES2 object")
+ , m_source (getImageSource(target, storage, useTexLevel0, internalFormat))
+ , m_format (target)
{
}
Context context (m_eglTestCtx, dpy, contextType, 64, 64);
const EGLContext eglContext = context.getEglContext();
+ if ((m_format == GL_RED || m_format == GL_RG) && !isGLRedSupported())
+ TCU_THROW(NotSupportedError, "Unsupported extension: GL_EXT_texture_rg");
+
log << TestLog::Message << "Using EGL config " << eglu::getConfigID(egl, dpy, context.getConfig()) << TestLog::EndMessage;
UniquePtr<ClientBuffer> clientBuffer (m_source->createBuffer(context.gl()));
private:
UniquePtr<ImageSource> m_source;
+ GLenum m_format;
};
class ImageTargetGLES2 : public ImageTestCase
{
addChild(new Image::InvalidCreateImage(m_eglTestCtx));
+ addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RED, false, GL_R8));
+ addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RG, false, GL_RG8));
+
+ addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_LUMINANCE));
+ addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_LUMINANCE_ALPHA));
+
addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RGB));
addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RGBA));
addChild(new Image::CreateImageGLES2(m_eglTestCtx, EGL_GL_TEXTURE_2D_KHR, GL_RGBA, true));
class TextureImageSource : public GLImageSource
{
public:
- TextureImageSource (GLenum format, GLenum type, bool useTexLevel0) : m_format(format), m_type(type), m_useTexLevel0(useTexLevel0) {}
+ TextureImageSource (GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0) : m_internalFormat(internalFormat), m_format(format), m_type(type), m_useTexLevel0(useTexLevel0) {}
MovePtr<ClientBuffer> createBuffer (const glw::Functions& gl, Texture2D* reference) const;
GLenum getFormat (void) const { return m_format; }
+ GLenum getInternalFormat (void) const { return m_internalFormat; }
protected:
AttribMap getCreateAttribs (void) const;
virtual void initTexture (const glw::Functions& gl) const = 0;
virtual GLenum getGLTarget (void) const = 0;
+ GLenum m_internalFormat;
GLenum m_format;
GLenum m_type;
bool m_useTexLevel0;
GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
GLU_CHECK_GLW_CALL(gl, texParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
- GLU_CHECK_GLW_CALL(gl, texImage2D(imgTarget, 0, m_format, IMAGE_WIDTH, IMAGE_HEIGHT,
+ GLU_CHECK_GLW_CALL(gl, texImage2D(imgTarget, 0, m_internalFormat, IMAGE_WIDTH, IMAGE_HEIGHT,
0, m_format, m_type, ref->getLevel(0).getDataPtr()));
}
GLU_CHECK_GLW_CALL(gl, bindTexture(target, 0));
class Texture2DImageSource : public TextureImageSource
{
public:
- Texture2DImageSource (GLenum format, GLenum type, bool useTexLevel0) : TextureImageSource(format, type, useTexLevel0) {}
+ Texture2DImageSource (GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0) : TextureImageSource(internalFormat, format, type, useTexLevel0) {}
EGLenum getSource (void) const { return EGL_GL_TEXTURE_2D_KHR; }
string getRequiredExtension (void) const { return "EGL_KHR_gl_texture_2D_image"; }
GLenum getGLTarget (void) const { return GL_TEXTURE_2D; }
void Texture2DImageSource::initTexture (const glw::Functions& gl) const
{
// Specify mipmap level 0
- GLU_CHECK_CALL_ERROR(gl.texImage2D(GL_TEXTURE_2D, 0, m_format, IMAGE_WIDTH, IMAGE_HEIGHT, 0, m_format, m_type, DE_NULL),
+ GLU_CHECK_CALL_ERROR(gl.texImage2D(GL_TEXTURE_2D, 0, m_internalFormat, IMAGE_WIDTH, IMAGE_HEIGHT, 0, m_format, m_type, DE_NULL),
gl.getError());
}
class TextureCubeMapImageSource : public TextureImageSource
{
public:
- TextureCubeMapImageSource (EGLenum source, GLenum format, GLenum type, bool useTexLevel0) : TextureImageSource(format, type, useTexLevel0), m_source(source) {}
+ TextureCubeMapImageSource (GLenum internalFormat, EGLenum source, GLenum format, GLenum type, bool useTexLevel0) : TextureImageSource(internalFormat, format, type, useTexLevel0), m_source(source) {}
EGLenum getSource (void) const { return m_source; }
string getRequiredExtension (void) const { return "EGL_KHR_gl_texture_cubemap_image"; }
GLenum getGLTarget (void) const { return GL_TEXTURE_CUBE_MAP; }
};
for (int faceNdx = 0; faceNdx < DE_LENGTH_OF_ARRAY(faces); faceNdx++)
- GLU_CHECK_GLW_CALL(gl, texImage2D(faces[faceNdx], 0, m_format, IMAGE_WIDTH, IMAGE_HEIGHT, 0, m_format, m_type, DE_NULL));
+ GLU_CHECK_GLW_CALL(gl, texImage2D(faces[faceNdx], 0, m_internalFormat, IMAGE_WIDTH, IMAGE_HEIGHT, 0, m_format, m_type, DE_NULL));
}
class RenderbufferClientBuffer : public GLClientBuffer
return EGL_NO_IMAGE_KHR;
}
-MovePtr<ImageSource> createTextureImageSource (EGLenum source, GLenum format, GLenum type, bool useTexLevel0)
+MovePtr<ImageSource> createTextureImageSource (EGLenum source, GLenum internalFormat, GLenum format, GLenum type, bool useTexLevel0)
{
if (source == EGL_GL_TEXTURE_2D_KHR)
- return MovePtr<ImageSource>(new Texture2DImageSource(format, type, useTexLevel0));
+ return MovePtr<ImageSource>(new Texture2DImageSource(internalFormat, format, type, useTexLevel0));
else
- return MovePtr<ImageSource>(new TextureCubeMapImageSource(source, format, type, useTexLevel0));
+ return MovePtr<ImageSource>(new TextureCubeMapImageSource(source, internalFormat, format, type, useTexLevel0));
}
MovePtr<ImageSource> createRenderbufferImageSource (GLenum format)
virtual glw::GLenum getFormat (void) const = 0;
};
-de::MovePtr<ImageSource> createTextureImageSource (eglw::EGLenum source, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);
+de::MovePtr<ImageSource> createTextureImageSource (eglw::EGLenum source, glw::GLenum internalFormat, glw::GLenum format, glw::GLenum type, bool useTexLevel0 = false);
de::MovePtr<ImageSource> createRenderbufferImageSource (glw::GLenum format);
de::MovePtr<ImageSource> createUnsupportedImageSource (const std::string& message, glw::GLenum format);