Commit 8141d7c5 by Alexis Hetu Committed by Alexis Hétu

Added utility function for OpenGL extension strings

The new glGetStringi() function needed to be unified with glGetString(), so I made a utility function to make future modifications easy. Change-Id: I6619d9f99b10d9fc43bd8783a1d50274e2b37a7b Reviewed-on: https://swiftshader-review.googlesource.com/2797Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 93ae1034
...@@ -1867,8 +1867,9 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1867,8 +1867,9 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
*params = 0; *params = 0;
break; break;
case GL_NUM_EXTENSIONS: // integer case GL_NUM_EXTENSIONS: // integer
UNIMPLEMENTED(); GLuint numExtensions;
*params = 0; getExtensions(0, &numExtensions);
*params = numExtensions;
break; break;
case GL_NUM_PROGRAM_BINARY_FORMATS: // integer, at least 0 case GL_NUM_PROGRAM_BINARY_FORMATS: // integer, at least 0
UNIMPLEMENTED(); UNIMPLEMENTED();
...@@ -3890,6 +3891,85 @@ Device *Context::getDevice() ...@@ -3890,6 +3891,85 @@ Device *Context::getDevice()
return device; return device;
} }
const GLubyte* Context::getExtensions(GLuint index, GLuint* numExt)
{
// Keep list sorted in following order:
// OES extensions
// EXT extensions
// Vendor extensions
static const GLubyte* extensions[] = {
(const GLubyte*)"GL_OES_compressed_ETC1_RGB8_texture",
(const GLubyte*)"GL_OES_depth_texture",
(const GLubyte*)"GL_OES_depth_texture_cube_map",
(const GLubyte*)"GL_OES_EGL_image",
(const GLubyte*)"GL_OES_EGL_image_external",
(const GLubyte*)"GL_OES_element_index_uint",
(const GLubyte*)"GL_OES_packed_depth_stencil",
(const GLubyte*)"GL_OES_rgb8_rgba8",
(const GLubyte*)"GL_OES_standard_derivatives",
(const GLubyte*)"GL_OES_texture_float",
(const GLubyte*)"GL_OES_texture_float_linear",
(const GLubyte*)"GL_OES_texture_half_float",
(const GLubyte*)"GL_OES_texture_half_float_linear",
(const GLubyte*)"GL_OES_texture_npot",
(const GLubyte*)"GL_OES_texture_3D",
(const GLubyte*)"GL_EXT_blend_minmax",
(const GLubyte*)"GL_EXT_occlusion_query_boolean",
(const GLubyte*)"GL_EXT_read_format_bgra",
#if (S3TC_SUPPORT)
(const GLubyte*)"GL_EXT_texture_compression_dxt1",
#endif
(const GLubyte*)"GL_EXT_texture_filter_anisotropic",
(const GLubyte*)"GL_EXT_texture_format_BGRA8888",
(const GLubyte*)"GL_ANGLE_framebuffer_blit",
(const GLubyte*)"GL_NV_framebuffer_blit",
(const GLubyte*)"GL_ANGLE_framebuffer_multisample",
#if (S3TC_SUPPORT)
(const GLubyte*)"GL_ANGLE_texture_compression_dxt3",
(const GLubyte*)"GL_ANGLE_texture_compression_dxt5",
#endif
(const GLubyte*)"GL_NV_fence"
};
static const GLuint numExtensions = sizeof(extensions) / sizeof(*extensions);
if(numExt)
{
*numExt = numExtensions;
return nullptr;
}
if(index == GL_INVALID_INDEX)
{
static GLubyte* extensionsCat = nullptr;
if((extensionsCat == nullptr) && (numExtensions > 0))
{
int totalLength = numExtensions; // 1 space between each extension name + terminating null
for(int i = 0; i < numExtensions; ++i)
{
totalLength += strlen(reinterpret_cast<const char*>(extensions[i]));
}
extensionsCat = new GLubyte[totalLength];
extensionsCat[0] = '\0';
for(int i = 0; i < numExtensions; ++i)
{
if(i != 0)
{
strcat(reinterpret_cast<char*>(extensionsCat), " ");
}
strcat(reinterpret_cast<char*>(extensionsCat), reinterpret_cast<const char*>(extensions[i]));
}
}
return extensionsCat;
}
if(index >= numExtensions)
{
return nullptr;
}
return extensions[index];
}
} }
// Exported functions for use by EGL // Exported functions for use by EGL
......
...@@ -560,6 +560,8 @@ public: ...@@ -560,6 +560,8 @@ public:
Device *getDevice(); Device *getDevice();
const GLubyte* getExtensions(GLuint index, GLuint* numExt = nullptr);
private: private:
virtual ~Context(); virtual ~Context();
......
...@@ -3104,7 +3104,7 @@ const GLubyte* GL_APIENTRY glGetString(GLenum name) ...@@ -3104,7 +3104,7 @@ const GLubyte* GL_APIENTRY glGetString(GLenum name)
switch(name) switch(name)
{ {
case GL_VENDOR: case GL_VENDOR:
return (GLubyte*)"TransGaming Inc."; return (GLubyte*)"Google Inc.";
case GL_RENDERER: case GL_RENDERER:
return (GLubyte*)"SwiftShader"; return (GLubyte*)"SwiftShader";
case GL_VERSION: case GL_VERSION:
...@@ -3112,42 +3112,10 @@ const GLubyte* GL_APIENTRY glGetString(GLenum name) ...@@ -3112,42 +3112,10 @@ const GLubyte* GL_APIENTRY glGetString(GLenum name)
case GL_SHADING_LANGUAGE_VERSION: case GL_SHADING_LANGUAGE_VERSION:
return (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader " VERSION_STRING; return (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader " VERSION_STRING;
case GL_EXTENSIONS: case GL_EXTENSIONS:
// Keep list sorted in following order: {
// OES extensions es2::Context *context = es2::getContext();
// EXT extensions return context ? context->getExtensions(GL_INVALID_INDEX) : (GLubyte*)NULL;
// Vendor extensions }
return (GLubyte*)
"GL_OES_compressed_ETC1_RGB8_texture "
"GL_OES_depth_texture "
"GL_OES_depth_texture_cube_map "
"GL_OES_EGL_image "
"GL_OES_EGL_image_external "
"GL_OES_element_index_uint "
"GL_OES_packed_depth_stencil "
"GL_OES_rgb8_rgba8 "
"GL_OES_standard_derivatives "
"GL_OES_texture_float "
"GL_OES_texture_float_linear "
"GL_OES_texture_half_float "
"GL_OES_texture_half_float_linear "
"GL_OES_texture_npot "
"GL_OES_texture_3D "
"GL_EXT_blend_minmax "
"GL_EXT_occlusion_query_boolean "
"GL_EXT_read_format_bgra "
#if (S3TC_SUPPORT)
"GL_EXT_texture_compression_dxt1 "
#endif
"GL_EXT_texture_filter_anisotropic "
"GL_EXT_texture_format_BGRA8888 "
"GL_ANGLE_framebuffer_blit "
"GL_NV_framebuffer_blit "
"GL_ANGLE_framebuffer_multisample "
#if (S3TC_SUPPORT)
"GL_ANGLE_texture_compression_dxt3 "
"GL_ANGLE_texture_compression_dxt5 "
#endif
"GL_NV_fence";
default: default:
return error(GL_INVALID_ENUM, (GLubyte*)NULL); return error(GL_INVALID_ENUM, (GLubyte*)NULL);
} }
......
...@@ -2257,8 +2257,27 @@ const GLubyte *GL_APIENTRY glGetStringi(GLenum name, GLuint index) ...@@ -2257,8 +2257,27 @@ const GLubyte *GL_APIENTRY glGetStringi(GLenum name, GLuint index)
{ {
TRACE("(GLenum name = 0x%X, GLuint index = %d)", name, index); TRACE("(GLenum name = 0x%X, GLuint index = %d)", name, index);
UNIMPLEMENTED(); es2::Context *context = es2::getContext();
return nullptr; if(context)
{
GLuint numExtensions;
context->getExtensions(0, &numExtensions);
if(index >= numExtensions)
{
return error(GL_INVALID_VALUE, (GLubyte*)NULL);
}
switch(name)
{
case GL_EXTENSIONS:
return context->getExtensions(index);
default:
return error(GL_INVALID_ENUM, (GLubyte*)NULL);
}
}
return (GLubyte*)NULL;
} }
void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) void GL_APIENTRY glCopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size)
......
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