Skip to content

Commit

Permalink
Improve OpenGL ES support, add OpenGL ES 3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
rdb committed Apr 4, 2016
1 parent 6ddfb0a commit e73a897
Show file tree
Hide file tree
Showing 12 changed files with 643 additions and 357 deletions.
99 changes: 99 additions & 0 deletions panda/src/gles2gsg/gles2gsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef char GLchar;
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT GL_FRAMEBUFFER_INCOMPLETE_FORMATS
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define GL_COLOR_ATTACHMENT1_EXT (GL_COLOR_ATTACHMENT0 + 1)
#define GL_STENCIL_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT
#define GL_DEPTH_STENCIL GL_DEPTH_STENCIL_OES
#define GL_DEPTH_STENCIL_EXT GL_DEPTH_STENCIL_OES
Expand Down Expand Up @@ -123,6 +124,104 @@ typedef char GLchar;
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE

// For GLES 3 compat - need a better solution for this
#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x1
#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x2
#define GL_UNIFORM_BARRIER_BIT 0x4
#define GL_TEXTURE_FETCH_BARRIER_BIT 0x8
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x20
#define GL_COMMAND_BARRIER_BIT 0x40
#define GL_PIXEL_BUFFER_BARRIER_BIT 0x80
#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x100
#define GL_BUFFER_UPDATE_BARRIER_BIT 0x200
#define GL_FRAMEBUFFER_BARRIER_BIT 0x400
#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x800
#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x1000
#define GL_HALF_FLOAT 0x140B
#define GL_COLOR 0x1800
#define GL_DEPTH 0x1801
#define GL_STENCIL 0x1802
#define GL_RGB10_A2 0x8059
#define GL_TEXTURE_WRAP_R 0x8072
#define GL_TEXTURE_MIN_LOD 0x813A
#define GL_TEXTURE_MAX_LOD 0x813B
#define GL_TEXTURE_MAX_LEVEL 0x813D
#define GL_NUM_EXTENSIONS 0x821D
#define GL_RG_INTEGER 0x8228
#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
#define GL_PROGRAM_BINARY_LENGTH 0x8741
#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
#define GL_PROGRAM_BINARY_FORMATS 0x87FF
#define GL_READ_ONLY 0x88B8
#define GL_WRITE_ONLY 0x88B9
#define GL_READ_WRITE 0x88BA
#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
#define GL_UNIFORM_TYPE 0x8A37
#define GL_UNIFORM_SIZE 0x8A38
#define GL_UNIFORM_NAME_LENGTH 0x8A39
#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
#define GL_UNIFORM_OFFSET 0x8A3B
#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
#define GL_FLOAT_MAT2x3 0x8B65
#define GL_FLOAT_MAT2x4 0x8B66
#define GL_FLOAT_MAT3x2 0x8B67
#define GL_FLOAT_MAT3x4 0x8B68
#define GL_FLOAT_MAT4x2 0x8B69
#define GL_FLOAT_MAT4x3 0x8B6A
#define GL_TEXTURE_2D_ARRAY 0x8C1A
#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
#define GL_R11F_G11F_B10F 0x8C3A
#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
#define GL_RGB9_E5 0x8C3D
#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
#define GL_RED_INTEGER 0x8D94
#define GL_RGB_INTEGER 0x8D98
#define GL_RGBA_INTEGER 0x8D99
#define GL_SAMPLER_2D_ARRAY 0x8DC1
#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
#define GL_UNSIGNED_INT_VEC2 0x8DC6
#define GL_UNSIGNED_INT_VEC3 0x8DC7
#define GL_UNSIGNED_INT_VEC4 0x8DC8
#define GL_INT_SAMPLER_2D 0x8DCA
#define GL_INT_SAMPLER_3D 0x8DCB
#define GL_INT_SAMPLER_CUBE 0x8DCC
#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
#define GL_MAX_IMAGE_UNITS 0x8F38
#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
#define GL_IMAGE_2D 0x904D
#define GL_IMAGE_3D 0x904E
#define GL_IMAGE_CUBE 0x9050
#define GL_IMAGE_2D_ARRAY 0x9053
#define GL_INT_IMAGE_2D 0x9058
#define GL_INT_IMAGE_3D 0x9059
#define GL_INT_IMAGE_CUBE 0x905B
#define GL_INT_IMAGE_2D_ARRAY 0x905E
#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
#define GL_COMPUTE_SHADER 0x91B9
#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310
#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311
#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313
#define GL_ALL_BARRIER_BITS 0xFFFFFFFF

#undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY
#define APIENTRYP *
Expand Down
12 changes: 12 additions & 0 deletions panda/src/glesgsg/glesgsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#define GL_RENDERBUFFER_ALPHA_SIZE_EXT GL_RENDERBUFFER_ALPHA_SIZE_OES
#define GL_RENDERBUFFER_DEPTH_SIZE_EXT GL_RENDERBUFFER_DEPTH_SIZE_OES
#define GL_RENDERBUFFER_STENCIL_SIZE_EXT GL_RENDERBUFFER_STENCIL_SIZE_OES
#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
#define GL_DRAW_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
#define GL_READ_FRAMEBUFFER_EXT GL_FRAMEBUFFER_OES
Expand Down Expand Up @@ -119,6 +120,17 @@
#define GL_LUMINANCE8 GL_LUMINANCE8_EXT
#define GL_LUMINANCE8_ALPHA8 GL_LUMINANCE8_ALPHA8_EXT
#define GL_MAX_VERTEX_UNITS_ARB GL_MAX_VERTEX_UNITS_OES
#define GL_TEXTURE_MAX_LEVEL GL_TEXTURE_MAX_LEVEL_APPLE

// These aren't technically part of OpenGL ES 1.0, but some implementations
// nonetheless implement it.
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
#define GL_DEBUG_SEVERITY_HIGH 0x9146
#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
#define GL_DEBUG_SEVERITY_LOW 0x9148
#define GL_DEBUG_OUTPUT 0x92E0

#undef SUPPORT_IMMEDIATE_MODE
#define APIENTRY
Expand Down
16 changes: 5 additions & 11 deletions panda/src/glstuff/glGraphicsBuffer_src.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ begin_frame(FrameMode mode, Thread *current_thread) {

// In case of multisample rendering, we don't need to issue the barrier
// until we call glBlitFramebuffer.
#ifndef OPENGLES
#ifndef OPENGLES_1
if (gl_enable_memory_barriers && _fbo_multisample == 0) {
CLP(GraphicsStateGuardian) *glgsg;
DCAST_INTO_R(glgsg, _gsg, false);
Expand Down Expand Up @@ -526,7 +526,6 @@ rebuild_bitplanes() {
}
glgsg->bind_fbo(_fbo[layer]);

#ifndef OPENGLES
if (glgsg->_use_object_labels) {
// Assign a label for OpenGL to use when displaying debug messages.
if (num_fbos > 1) {
Expand All @@ -538,7 +537,6 @@ rebuild_bitplanes() {
glgsg->_glObjectLabel(GL_FRAMEBUFFER, _fbo[layer], _name.size(), _name.data());
}
}
#endif

// For all slots, update the slot.
if (_use_depth_stencil) {
Expand Down Expand Up @@ -591,7 +589,7 @@ rebuild_bitplanes() {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
#ifndef OPENGLES
#ifndef OPENGLES_1
} else if (glgsg->_supports_empty_framebuffer) {
// Set the "default" width and height, which is required to have an FBO
// without any attachments.
Expand Down Expand Up @@ -751,12 +749,10 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
_fb_properties.setup_color_texture(tex);
}

#ifndef OPENGLES
GLenum target = glgsg->get_texture_target(tex->get_texture_type());
if (target == GL_TEXTURE_CUBE_MAP) {
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
}
#endif

if (attachpoint == GL_DEPTH_ATTACHMENT_EXT) {
GLCAT.debug() << "Binding texture " << *tex << " to depth attachment.\n";
Expand Down Expand Up @@ -815,7 +811,7 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot,
GLuint gl_format = GL_RGBA4;
switch (slot) {
case RTP_depth_stencil:
gl_format = GL_DEPTH_STENCIL_OES;
gl_format = GL_DEPTH24_STENCIL8_OES;
break;
case RTP_depth:
if (_fb_properties.get_depth_bits() > 24 && glgsg->_supports_depth32) {
Expand Down Expand Up @@ -1191,9 +1187,7 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) {
glgsg->_glFramebufferTexture3D(GL_FRAMEBUFFER_EXT, attachpoint,
target, gtc->_index, 0, layer);
break;
#endif
#ifndef OPENGLES
case GL_TEXTURE_2D_ARRAY_EXT:
case GL_TEXTURE_2D_ARRAY:
glgsg->_glFramebufferTextureLayer(GL_FRAMEBUFFER_EXT, attachpoint,
gtc->_index, 0, layer);
break;
Expand Down Expand Up @@ -1729,7 +1723,7 @@ resolve_multisamples() {

PStatGPUTimer timer(glgsg, _resolve_multisample_pcollector);

#ifndef OPENGLES
#ifndef OPENGLES_1
if (gl_enable_memory_barriers) {
// Issue memory barriers as necessary to make sure that the texture memory
// is synchronized before we blit to it.
Expand Down
2 changes: 2 additions & 0 deletions panda/src/glstuff/glGraphicsStateGuardian_src.I
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ INLINE bool CLP(GraphicsStateGuardian)::
is_at_least_gles_version(int major_version, int minor_version) const {
#ifndef OPENGLES
return false;
#elif defined(OPENGLES_1)
return major_version == 1 && _gl_version_minor >= minor_version;
#else
if (_gl_version_major < major_version) {
return false;
Expand Down

0 comments on commit e73a897

Please sign in to comment.