Fixes for OpenGL ES

This commit is contained in:
rdb 2014-07-03 22:24:34 +00:00
parent a3d80ae3eb
commit 0b8d9fd08e
3 changed files with 41 additions and 0 deletions

View File

@ -100,6 +100,20 @@ typedef char GLchar;
#define GL_RGBA16F GL_RGBA16F_EXT #define GL_RGBA16F GL_RGBA16F_EXT
#define GL_RGB32F GL_RGB32F_EXT #define GL_RGB32F GL_RGB32F_EXT
#define GL_RGBA32F GL_RGBA32F_EXT #define GL_RGBA32F GL_RGBA32F_EXT
#define GL_DEBUG_SEVERITY_HIGH GL_DEBUG_SEVERITY_HIGH_KHR
#define GL_DEBUG_SEVERITY_MEDIUM GL_DEBUG_SEVERITY_MEDIUM_KHR
#define GL_DEBUG_SEVERITY_LOW GL_DEBUG_SEVERITY_LOW_KHR
#define GL_DEBUG_SEVERITY_NOTIFICATION GL_DEBUG_SEVERITY_NOTIFICATION_KHR
#define GL_DEBUG_OUTPUT_SYNCHRONOUS GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR
#define GL_FRAMEBUFFER_SRGB GL_FRAMEBUFFER_SRGB_EXT
#define GL_SRGB GL_SRGB_EXT
#define GL_SRGB_ALPHA GL_SRGB_ALPHA_EXT
#define GL_SRGB8 GL_SRGB8_EXT
#define GL_SRGB8_ALPHA GL_SRGB8_ALPHA_EXT
#define GL_SLUMINANCE GL_SLUMINANCE_NV
#define GL_SLUMINANCE_ALPHA GL_SLUMINANCE_ALPHA_NV
#define GL_SLUMINANCE8 GL_SLUMINANCE8_NV
#define GL_SLUMINANCE8_ALPHA GL_SLUMINANCE8_ALPHA_NV
#undef SUPPORT_IMMEDIATE_MODE #undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY #define APIENTRY

View File

@ -345,6 +345,7 @@ CLP(GraphicsStateGuardian)::
// gl_debug has been enabled (and the driver supports // gl_debug has been enabled (and the driver supports
// the GL_ARB_debug_output extension). // the GL_ARB_debug_output extension).
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifndef OPENGLES_1
void CLP(GraphicsStateGuardian):: void CLP(GraphicsStateGuardian)::
debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) { debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) {
// Determine how to map the severity level. // Determine how to map the severity level.
@ -380,6 +381,7 @@ debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei l
} }
#endif #endif
} }
#endif // OPENGLES_1
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: GLGraphicsStateGuardian::reset // Function: GLGraphicsStateGuardian::reset
@ -437,6 +439,7 @@ reset() {
// Initialize OpenGL debugging output first, if enabled and supported. // Initialize OpenGL debugging output first, if enabled and supported.
_supports_debug = false; _supports_debug = false;
#ifndef OPENGLES_1
if (gl_debug) { if (gl_debug) {
PFNGLDEBUGMESSAGECALLBACKPROC _glDebugMessageCallback; PFNGLDEBUGMESSAGECALLBACKPROC _glDebugMessageCallback;
PFNGLDEBUGMESSAGECONTROLPROC _glDebugMessageControl; PFNGLDEBUGMESSAGECONTROLPROC _glDebugMessageControl;
@ -493,6 +496,7 @@ reset() {
|| has_extension("GL_KHR_debug") || has_extension("GL_KHR_debug")
|| has_extension("GL_ARB_debug_output"); || has_extension("GL_ARB_debug_output");
} }
#endif // OPENGLES_1
_supported_geom_rendering = _supported_geom_rendering =
Geom::GR_indexed_point | Geom::GR_indexed_point |
@ -744,7 +748,9 @@ reset() {
_supports_cube_map = _supports_cube_map =
has_extension("GL_ARB_texture_cube_map") || is_at_least_gl_version(1, 3) || has_extension("GL_ARB_texture_cube_map") || is_at_least_gl_version(1, 3) ||
has_extension("GL_OES_texture_cube_map"); has_extension("GL_OES_texture_cube_map");
#endif
#ifndef OPENGLES
if (_supports_cube_map && gl_cube_map_seamless) { if (_supports_cube_map && gl_cube_map_seamless) {
if (is_at_least_gl_version(3, 2) || has_extension("GL_ARB_seamless_cube_map")) { if (is_at_least_gl_version(3, 2) || has_extension("GL_ARB_seamless_cube_map")) {
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
@ -2373,9 +2379,11 @@ begin_frame(Thread *current_thread) {
} }
#endif // NDEBUG #endif // NDEBUG
#ifndef OPENGLES_1
if (_current_properties->get_srgb_color()) { if (_current_properties->get_srgb_color()) {
glEnable(GL_FRAMEBUFFER_SRGB); glEnable(GL_FRAMEBUFFER_SRGB);
} }
#endif
report_my_gl_errors(); report_my_gl_errors();
return true; return true;
@ -2429,9 +2437,11 @@ void CLP(GraphicsStateGuardian)::
end_frame(Thread *current_thread) { end_frame(Thread *current_thread) {
report_my_gl_errors(); report_my_gl_errors();
#ifndef OPENGLES_1
if (_current_properties->get_srgb_color()) { if (_current_properties->get_srgb_color()) {
glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_FRAMEBUFFER_SRGB);
} }
#endif
#ifdef DO_PSTATS #ifdef DO_PSTATS
// Check for textures, etc., that are no longer resident. These // Check for textures, etc., that are no longer resident. These
@ -4422,6 +4432,7 @@ end_occlusion_query() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CLP(GraphicsStateGuardian):: void CLP(GraphicsStateGuardian)::
dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) {
#ifndef OPENGLES
maybe_gl_finish(); maybe_gl_finish();
PStatTimer timer(_compute_dispatch_pcollector); PStatTimer timer(_compute_dispatch_pcollector);
@ -4430,6 +4441,7 @@ dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) {
_glDispatchCompute(num_groups_x, num_groups_y, num_groups_z); _glDispatchCompute(num_groups_x, num_groups_y, num_groups_z);
maybe_gl_finish(); maybe_gl_finish();
#endif
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -6769,8 +6781,11 @@ get_external_image_format(Texture *tex) const {
case Texture::F_luminance_alpha: case Texture::F_luminance_alpha:
case Texture::F_sluminance_alpha: case Texture::F_sluminance_alpha:
return GL_LUMINANCE_ALPHA; return GL_LUMINANCE_ALPHA;
#ifndef OPENGLES
case Texture::F_r32i: case Texture::F_r32i:
return GL_RED_INTEGER; return GL_RED_INTEGER;
#endif
} }
GLCAT.error() GLCAT.error()
<< "Invalid Texture::Format value in get_external_image_format(): " << "Invalid Texture::Format value in get_external_image_format(): "
@ -7159,6 +7174,7 @@ get_internal_image_format(Texture *tex) const {
case Texture::F_luminance_alphamask: case Texture::F_luminance_alphamask:
return GL_LUMINANCE_ALPHA; return GL_LUMINANCE_ALPHA;
#ifndef OPENGLES_1
case Texture::F_srgb: case Texture::F_srgb:
return GL_SRGB8; return GL_SRGB8;
case Texture::F_srgb_alpha: case Texture::F_srgb_alpha:
@ -7167,9 +7183,12 @@ get_internal_image_format(Texture *tex) const {
return GL_SLUMINANCE8; return GL_SLUMINANCE8;
case Texture::F_sluminance_alpha: case Texture::F_sluminance_alpha:
return GL_SLUMINANCE8_ALPHA8; return GL_SLUMINANCE8_ALPHA8;
#endif
#ifndef OPENGLES
case Texture::F_r32i: case Texture::F_r32i:
return GL_R32I; return GL_R32I;
#endif
default: default:
GLCAT.error() GLCAT.error()
@ -9089,10 +9108,12 @@ specify_texture(CLP(TextureContext) *gtc) {
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
get_texture_filter_type(magfilter, true)); get_texture_filter_type(magfilter, true));
#ifndef OPENGLES
if (!uses_mipmaps) { if (!uses_mipmaps) {
// NVIDIA drivers complain if we don't do this. // NVIDIA drivers complain if we don't do this.
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 0); glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 0);
} }
#endif
// Set anisotropic filtering. // Set anisotropic filtering.
if (_supports_anisotropy) { if (_supports_anisotropy) {
@ -10324,9 +10345,11 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
format = Texture::F_red; format = Texture::F_red;
break; break;
#endif #endif
#ifndef OPENGLES
case GL_R32I: case GL_R32I:
format = Texture::F_r32i; format = Texture::F_r32i;
break; break;
#endif
#ifndef OPENGLES #ifndef OPENGLES
case GL_RED: case GL_RED:
@ -10351,6 +10374,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
format = Texture::F_luminance_alpha; format = Texture::F_luminance_alpha;
break; break;
#ifndef OPENGLES_1
case GL_SRGB: case GL_SRGB:
format = Texture::F_srgb; format = Texture::F_srgb;
break; break;
@ -10363,6 +10387,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) {
case GL_SLUMINANCE_ALPHA: case GL_SLUMINANCE_ALPHA:
format = Texture::F_sluminance_alpha; format = Texture::F_sluminance_alpha;
break; break;
#endif
#ifndef OPENGLES #ifndef OPENGLES
case GL_COMPRESSED_RGB: case GL_COMPRESSED_RGB:

View File

@ -206,7 +206,9 @@ public:
virtual int get_driver_shader_version_major(); virtual int get_driver_shader_version_major();
virtual int get_driver_shader_version_minor(); virtual int get_driver_shader_version_minor();
#ifndef OPENGLES_1
static void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam); static void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam);
#endif
virtual void reset(); virtual void reset();