]> git.tdb.fi Git - libs/gl.git/commitdiff
Make extensions compatible with OpenGL ES
authorMikko Rasa <tdb@tdb.fi>
Mon, 4 Dec 2017 11:04:48 +0000 (13:04 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 4 Dec 2017 11:04:48 +0000 (13:04 +0200)
40 files changed:
extensions/arb_depth_buffer_float.glext [new file with mode: 0644]
extensions/arb_depth_texture.glext
extensions/arb_fragment_shader.glext
extensions/arb_geometry_shader4.glext
extensions/arb_multitexture.glext
extensions/arb_occlusion_query.glext
extensions/arb_shader_objects.glext
extensions/arb_shadow.glext
extensions/arb_texture_cube_map.glext
extensions/arb_texture_float.glext
extensions/arb_texture_rg.glext
extensions/arb_texture_storage.glext
extensions/arb_texture_swizzle.glext
extensions/arb_uniform_buffer_object.glext
extensions/arb_vertex_buffer_object.glext
extensions/arb_vertex_shader.glext
extensions/ext_blend_minmax.glext
extensions/ext_blend_subtract.glext
extensions/ext_framebuffer_object.glext
extensions/ext_gpu_shader4.glext
extensions/ext_texture3d.glext
extensions/ext_texture_array.glext
extensions/ext_texture_srgb.glext
extensions/msp_buffer_control.glext [new file with mode: 0644]
extensions/msp_draw_buffer.glext [deleted file]
extensions/msp_sized_internal_formats.glext [deleted file]
extensions/nv_fbo_color_attachments.glext [new file with mode: 0644]
extensions/oes_mapbuffer.glext [new file with mode: 0644]
extensions/oes_required_internalformat.glext [new file with mode: 0644]
extensions/oes_texture_stencil8.glext [new file with mode: 0644]
gl.fixes.xml
gl.msp.xml
scripts/extgen.py
source/buffer.cpp
source/buffer.h
source/framebuffer.cpp
source/framebuffer.h
source/pixelformat.cpp
source/pixelformat.h
source/texunit.cpp

diff --git a/extensions/arb_depth_buffer_float.glext b/extensions/arb_depth_buffer_float.glext
new file mode 100644 (file)
index 0000000..8bd7ac3
--- /dev/null
@@ -0,0 +1 @@
+extension ARB_depth_buffer_float
index 8b72d00399d414e0d60c707448d139caff942503..16366a03ba166838733632fe2e968d2c58a1b333 100644 (file)
@@ -1,3 +1,14 @@
 extension ARB_depth_texture
-# Deprecated and not particularly useful
+# We are ignoring most tokens in the extension and the remaining one was used
+# for other purposes in earlier versions
+gl:core_version 1.4
+gles2:core_version 3.0
+# Sized depth formats are better accessed through OES_required_internalformat
+ignore GL_DEPTH_COMPONENT16_ARB
+ignore GL_DEPTH_COMPONENT24_ARB
+ignore GL_DEPTH_COMPONENT32_ARB
+# Used to specify color channels to use when sampling depth textures where
+# color samples are expected; deprecated
 ignore GL_DEPTH_TEXTURE_MODE_ARB
+# Texture component size queries are not available on OpenGL ES until 3.1
+ignore GL_TEXTURE_DEPTH_SIZE_ARB
index e632db21d05706741bb9cd3110e074f4ad948abf..55b4d17be399752e4fe0dda1af3a202e0516083d 100644 (file)
@@ -1 +1,7 @@
 extension ARB_fragment_shader
+# Fragment derivative functions are not available on OpenGL ES until 3.0; they
+# should be accessed through OES_standard_derivatives if needed
+ignore GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB
+# Maximum uniform component count queries are not available on OpenGL ES until
+# 3.0; similar queries for vector counts are available in 2.0
+ignore GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
index bc5bc77b2a003136b10fb7cf1856000dd9700846..83109d87a4186e2bb6798a4061cecada09a92539 100644 (file)
@@ -1,13 +1,22 @@
 extension ARB_geometry_shader4
-# We use the version from EXT_texture_array
+# EXT_texture_array has an equivalent function and it more properly belongs
+# there
 ignore glFramebufferTextureLayerARB
-# Not promoted to core
+# Binding a single face of a cube map array texture was not promoted to core
+# even with EXT_texture_cube_map_array
 ignore glFramebufferTextureFaceARB
+# Stage-specific maximum varying component count queries were not promoted to
+# core; the more generic overall queries are deprecated too
 ignore GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB
 ignore GL_MAX_VERTEX_VARYING_COMPONENTS_ARB
-# Not promoted but required to support the extension flavor of geometry shaders
+# Program point size is always used in OpenGL ES
+optional GL_PROGRAM_POINT_SIZE_ARB
+# The core flavor allows different layer counts per attachment; keep the error
+# condition around in case we end up using the extension flavor
+optional GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB
+# In the core flavor input and output layouts are set in GLSL source; keep
+# these so we can support the extension flavor
 optional GL_GEOMETRY_INPUT_TYPE_ARB
 optional GL_GEOMETRY_OUTPUT_TYPE_ARB
 optional GL_GEOMETRY_VERTICES_OUT_ARB
 optional glProgramParameteriARB
-optional GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB
index 78e8d9bac5d5fdc4d68a3d825134fbb444106eab..7c5063c3a77efd37c8ff480a892d175026fb1e85 100644 (file)
@@ -1 +1,40 @@
 extension ARB_multitexture
+# OpenGL ES does not have fixed-function attributes
+ignore glMultiTexCoord1sARB
+ignore glMultiTexCoord1svARB
+ignore glMultiTexCoord1iARB
+ignore glMultiTexCoord1ivARB
+ignore glMultiTexCoord1fARB
+ignore glMultiTexCoord1fvARB
+ignore glMultiTexCoord1dARB
+ignore glMultiTexCoord1dvARB
+ignore glMultiTexCoord2sARB
+ignore glMultiTexCoord2svARB
+ignore glMultiTexCoord2iARB
+ignore glMultiTexCoord2ivARB
+ignore glMultiTexCoord2fARB
+ignore glMultiTexCoord2fvARB
+ignore glMultiTexCoord2dARB
+ignore glMultiTexCoord2dvARB
+ignore glMultiTexCoord3sARB
+ignore glMultiTexCoord3svARB
+ignore glMultiTexCoord3iARB
+ignore glMultiTexCoord3ivARB
+ignore glMultiTexCoord3fARB
+ignore glMultiTexCoord3fvARB
+ignore glMultiTexCoord3dARB
+ignore glMultiTexCoord3dvARB
+ignore glMultiTexCoord4sARB
+ignore glMultiTexCoord4svARB
+ignore glMultiTexCoord4iARB
+ignore glMultiTexCoord4ivARB
+ignore glMultiTexCoord4fARB
+ignore glMultiTexCoord4fvARB
+ignore glMultiTexCoord4dARB
+ignore glMultiTexCoord4dvARB
+# With shaders the newer GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is more
+# appropriate; keep the old constant for legacy support
+optional GL_MAX_TEXTURE_UNITS_ARB
+# Used to control legacy vertex arrays
+optional GL_CLIENT_ACTIVE_TEXTURE_ARB
+optional glClientActiveTextureARB
index 1f9d049af06723ffbf7570013c4d6c522d85c606..616146ac275981a93f02189c3cd7d6e482748dc5 100644 (file)
@@ -1 +1,8 @@
 extension ARB_occlusion_query
+# OpenGL ES only has the unsigned version
+ignore glGetQueryObjectivARB
+# OpenGL ES only has GL_ANY_SAMPLES_PASSED, but on desktop OpenGL it
+# additionally requires the ARB_occlusion_query2 extension
+optional GL_SAMPLES_PASSED_ARB
+# Counter resolution query is not available on OpenGL ES
+ignore GL_QUERY_COUNTER_BITS_ARB
index 96d3fc283d8ea5608cc09f1dce8e4c2496c2165a..47705493f72d1c991781c5937c918dfcddfe2579 100644 (file)
@@ -1,11 +1,23 @@
 extension ARB_shader_objects
-# Not promoted to core
+# In the core flavor the current program is queried through the standard
+# glGetIntegerv interface
 ignore glGetHandleARB
+# Only the integer version was promoted to core
 ignore glGetObjectParameterfvARB
+# Since the unified objects idea was not promoted to core, these enums related
+# to object type queries are obsolete
+ignore GL_OBJECT_TYPE_ARB
 ignore GL_PROGRAM_OBJECT_ARB
 ignore GL_SHADER_OBJECT_ARB
-ignore GL_OBJECT_TYPE_ARB
 ignore GL_OBJECT_SUBTYPE_ARB
-# Rectangular textures have their own extension
+# 1D textures are not available on OpenGL ES
+optional GL_SAMPLER_1D_ARB
+# Rectangular texture samplers additionally require ARB_texture_rectangle
 optional GL_SAMPLER_2D_RECT_ARB
+# 3D texture samplers additionally require EXT_texture3D
+optional GL_SAMPLER_3D_ARB
+# Shadows samplers require the ARB_shadow extension in addition to texture type
+# specific extensions
+optional GL_SAMPLER_1D_SHADOW_ARB
+optional GL_SAMPLER_2D_SHADOW_ARB
 optional GL_SAMPLER_2D_RECT_SHADOW_ARB
index 477b7ba786cbc24f7e405f36861a7bc44ed30fb9..2633a52815c938c8481e059b075215c61350cc70 100644 (file)
@@ -1,4 +1,5 @@
 extension ARB_shadow
-# The name got changed in OpenGL 3.0; mark as optional to circumvent the
-# deprecation
+# The name is different in OpenGL 3.0 and OpenGL ES but semantics are
+# essentially the same; keep using the old name for now because the aliasing
+# is a bit hairy
 optional GL_COMPARE_R_TO_TEXTURE_ARB
index 5423ecfe243017f451c4683513b623afcecc6c8f..22c6ac40f0782538f6d7ba6a6a95e4dd6682979a 100644 (file)
@@ -1,4 +1,6 @@
 extension ARB_texture_cube_map
-# Deprecated; related to texture coordinate generation which we don't use
+# Texture coordinate generation is deprecated
 ignore GL_NORMAL_MAP_ARB
 ignore GL_REFLECTION_MAP_ARB
+# Proxy textures are not available on OpenGL ES
+ignore GL_PROXY_TEXTURE_CUBE_MAP_ARB
index ddfb06e3e7f62db74bdb94e350abe068b8f2c046..bdbb8d0ecc195643bd8936023b9f60badbe1da44 100644 (file)
@@ -1,4 +1,10 @@
 extension ARB_texture_float
+# Source extensions can't be detected properly on OpenGL ES because of the
+# complex relationships between format enums and the functions where they are
+# used; this set allows sized float formats for glTextureStorage
+gles2:source gles2.EXT_texture_storage
+gles2:source gles2.OES_texture_float
+gles2:source gles2.OES_texture_half_float
 # Alpha, luminance and intensity formats were replaced with R and RG formats
 ignore GL_ALPHA16F_ARB
 ignore GL_LUMINANCE16F_ARB
@@ -10,3 +16,9 @@ ignore GL_LUMINANCE_ALPHA32F_ARB
 ignore GL_INTENSITY32F_ARB
 ignore GL_TEXTURE_LUMINANCE_TYPE_ARB
 ignore GL_TEXTURE_INTENSITY_TYPE_ARB
+# Texture component type queries are not available on OpenGL ES until 3.1
+ignore GL_TEXTURE_RED_TYPE_ARB
+ignore GL_TEXTURE_GREEN_TYPE_ARB
+ignore GL_TEXTURE_BLUE_TYPE_ARB
+ignore GL_TEXTURE_ALPHA_TYPE_ARB
+ignore GL_TEXTURE_DEPTH_TYPE_ARB
index 68495ec29c7afff041c4264ca049f6b4dda3ad6f..8612f557eb5df10246c67446eb614353078f6ce6 100644 (file)
@@ -1 +1,4 @@
 extension ARB_texture_rg
+# OpenGL ES doesn't have 16-bit fixed-point formats
+ignore GL_R16
+ignore GL_RG16
index c752633939945df1d0ef4cd7cefb755c4c31a4d9..491f36d1a9d1b57c183f6e56353e589d4106f5b4 100644 (file)
@@ -1 +1,3 @@
 extension ARB_texture_storage
+# 1D textures are not available on OpenGL ES
+optional glTexStorage1D
index 524965213a54e5e0734c48a234c833377e7bba19..d1b9b0deb28333841947fd5801f3ea706db83225 100644 (file)
@@ -1 +1,8 @@
 extension ARB_texture_swizzle
+# OpenGL ES can't set all swizzle values at once
+optional GL_TEXTURE_SWIZZLE_RGBA
+# Individual color enums are not available in any reasonable extension; they
+# were introduced to desktop OpenGL very early and to OpenGL ES in 3.0 together
+# with swizzling
+optional GL_GREEN
+optional GL_BLUE
index 1ceadce79a46f686228c29fa195dec1c47f6926c..7a3a5ca3372bcea51cec7c612a906ddbc0b2fbaa 100644 (file)
@@ -1 +1,12 @@
 extension ARB_uniform_buffer_object
+# For some reason it's not possible to query uniform block usage in geometry
+# shader on OpenGL ES even though similar queries are available for vertex and
+# fragment shaders
+ignore GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER
+# Querying just the uniform name is not available on OpenGL ES; fortunately
+# it's included in the information provided by glGetActiveUniform
+ignore glGetActiveUniformName
+# Queries related to geometry shaders additionally require the
+# ARB_geometry_shader4 extension
+optional GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS
+optional GL_MAX_GEOMETRY_UNIFORM_BLOCKS
index 16d804f3c806e8b16d415217923661f1d836e250..c08254cd959a7767c820ee05067f70c68f80f344 100644 (file)
@@ -1,5 +1,5 @@
 extension ARB_vertex_buffer_object
-# Fixed-function arrays are deprecated and we don't query the bindings
+# Queries for fixed-function array buffer bindings are deprecated
 ignore GL_COLOR_ARRAY_BUFFER_BINDING_ARB
 ignore GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB
 ignore GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB
@@ -9,3 +9,22 @@ ignore GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB
 ignore GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB
 ignore GL_VERTEX_ARRAY_BUFFER_BINDING_ARB
 ignore GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB
+# Buffer mapping has a separate extension on OpenGL ES; see OES_mapbuffer
+ignore glMapBufferARB
+ignore glUnmapBufferARB
+ignore GL_BUFFER_ACCESS_ARB
+ignore GL_BUFFER_MAPPED_ARB
+ignore GL_BUFFER_MAP_POINTER_ARB
+ignore glGetBufferPointervARB
+ignore GL_READ_ONLY_ARB
+ignore GL_WRITE_ONLY_ARB
+ignore GL_READ_WRITE_ARB
+# Buffer content readback is not supported on OpenGL ES
+ignore glGetBufferSubDataARB
+# OpenGL ES does not support copy and read usages before 3.0
+optional GL_DYNAMIC_COPY_ARB
+optional GL_DYNAMIC_READ_ARB
+optional GL_STATIC_COPY_ARB
+optional GL_STATIC_READ_ARB
+optional GL_STREAM_COPY_ARB
+optional GL_STREAM_READ_ARB
index efd91b834c45391f9ce5fdfe7f0b1b403162cf2b..b0fa52badefe8adfc7c27eec03447643d261658c 100644 (file)
@@ -1,4 +1,41 @@
 extension ARB_vertex_shader
-# Deprecated fixed-function interop tokens
+# Fixed-function interop enums are deprecated
 ignore GL_MAX_TEXTURE_COORDS_ARB
 ignore GL_VERTEX_PROGRAM_TWO_SIDE_ARB
+# OpenGL ES does not have the full range of data types
+ignore glVertexAttrib1sARB
+ignore glVertexAttrib1svARB
+ignore glVertexAttrib1dARB
+ignore glVertexAttrib1dvARB
+ignore glVertexAttrib2sARB
+ignore glVertexAttrib2svARB
+ignore glVertexAttrib2dARB
+ignore glVertexAttrib2dvARB
+ignore glVertexAttrib3sARB
+ignore glVertexAttrib3svARB
+ignore glVertexAttrib3dARB
+ignore glVertexAttrib3dvARB
+ignore glVertexAttrib4bvARB
+ignore glVertexAttrib4ubvARB
+ignore glVertexAttrib4sARB
+ignore glVertexAttrib4svARB
+ignore glVertexAttrib4usvARB
+ignore glVertexAttrib4ivARB
+ignore glVertexAttrib4uivARB
+ignore glVertexAttrib4dARB
+ignore glVertexAttrib4dvARB
+ignore glVertexAttrib4NbvARB
+ignore glVertexAttrib4NubARB
+ignore glVertexAttrib4NubvARB
+ignore glVertexAttrib4NivARB
+ignore glVertexAttrib4NsvARB
+ignore glVertexAttrib4NusvARB
+ignore glVertexAttrib4NivARB
+ignore glVertexAttrib4NuivARB
+ignore glGetVertexAttribdvARB
+# Program point size is always used in OpenGL ES
+optional GL_VERTEX_PROGRAM_POINT_SIZE_ARB
+# Queries for max varying component counts are deprecated
+ignore GL_MAX_VARYING_FLOATS_ARB
+# Maximum uniform component count queries were introduced to OpenGL ES in 3.0
+ignore GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
index 4a2d1026769b96c7388df4bc08a7d2e1e5b3741a..b8642003574634675f1bfa9cdeae88db57797c2c 100644 (file)
@@ -1,3 +1,6 @@
 extension EXT_blend_minmax
 # Prevent autodetection of ARB_imaging as backport extension
-backport none
+gl:backport none
+# The source extension gets misdetected as OES_draw_buffer_indexed because it
+# uses the same enums and has higher preference
+gles2:source EXT_blend_minmax
index bf6c282121bce0ff32911fc8315dad367e857de2..6505ca2d8cd08f83dc68a0832fccce3e8689e310 100644 (file)
@@ -1,3 +1,5 @@
 extension EXT_blend_subtract
 # Prevent autodetection of ARB_imaging as backport extension
-backport none
+gl:backport none
+# The source extension gets misdetected as OES_draw_buffer_indexed
+gles2:source none
index 88f41cb1bb23b73bd3e13e7a68963f51ea4b6767..06e9c37b3dfd836c14117f6b4e9872a5c63cf15f 100644 (file)
@@ -1,4 +1,39 @@
 extension EXT_framebuffer_object
-# Not promoted; keep them around for more accurate error checking
+# The core flavor allows attachments to have different sizes or formats; keep
+# these error codes around in case we encounter extension flavor framebuffers
 optional GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
 optional GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
+# Changing the draw or read buffer is not available on OpenGL ES before 3.0 so
+# these errors don't exist
+optional GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
+optional GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT
+# OpenGL ES has a more limited range of stencil formats
+ignore GL_STENCIL_INDEX1_EXT
+ignore GL_STENCIL_INDEX4_EXT
+ignore GL_STENCIL_INDEX16_EXT
+# 1D textures are not available on OpenGL ES
+optional glFramebufferTexture1DEXT
+# 2D array textures were introduced to OpenGL ES at the same time as 3D
+# textures, so the more generic glFramebufferTextureLayer should be used
+optional glFramebufferTexture3DEXT
+# Color attachments beyond 0 are not available on OpenGL ES before 3.0; access
+# through NV_fbo_color_attachments instead
+ignore GL_MAX_COLOR_ATTACHMENTS_EXT
+ignore GL_COLOR_ATTACHMENT1_EXT
+ignore GL_COLOR_ATTACHMENT2_EXT
+ignore GL_COLOR_ATTACHMENT3_EXT
+ignore GL_COLOR_ATTACHMENT4_EXT
+ignore GL_COLOR_ATTACHMENT5_EXT
+ignore GL_COLOR_ATTACHMENT6_EXT
+ignore GL_COLOR_ATTACHMENT7_EXT
+ignore GL_COLOR_ATTACHMENT8_EXT
+ignore GL_COLOR_ATTACHMENT9_EXT
+ignore GL_COLOR_ATTACHMENT10_EXT
+ignore GL_COLOR_ATTACHMENT11_EXT
+ignore GL_COLOR_ATTACHMENT12_EXT
+ignore GL_COLOR_ATTACHMENT13_EXT
+ignore GL_COLOR_ATTACHMENT14_EXT
+ignore GL_COLOR_ATTACHMENT15_EXT
+# The query for attached texture layer is not available on OpenGL ES before 3.0
+# due to the lack of appropriate texture types
+ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT
index 1587535996c56cef8aa4f09fbaa5c3c2e410ee39..96d8c3e15bf7122b02a8bb0f1f530ad73df17a9f 100644 (file)
@@ -1,8 +1,15 @@
 extension EXT_gpu_shader4
-# Buffer textures have their own extension
+# 1D textures are not available on OpenGL ES
+optional GL_SAMPLER_1D_ARRAY_EXT
+optional GL_SAMPLER_1D_ARRAY_SHADOW_EXT
+optional GL_INT_SAMPLER_1D_EXT
+optional GL_INT_SAMPLER_1D_ARRAY_EXT
+optional GL_UNSIGNED_INT_SAMPLER_1D_EXT
+optional GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT
+# Buffer texture samplers additionally require ARB_texture_buffer_object
 optional GL_SAMPLER_BUFFER_EXT
 optional GL_INT_SAMPLER_BUFFER_EXT
 optional GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT
-# Ditto for rectangular textures
+# Rectangular texture samplers additionally require ARB_texture_rectangle
 optional GL_INT_SAMPLER_2D_RECT_EXT
 optional GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT
index e9bc90bb5cb2931d44811fa2e612aefa5267570e..65cfe203f9d8abfd1c4a73b1da0b6fe200f72f52 100644 (file)
@@ -1 +1,8 @@
 extension EXT_texture3D
+# Packing into a 3D subimage is not supported on OpenGL ES
+ignore GL_PACK_IMAGE_HEIGHT_EXT
+ignore GL_PACK_SKIP_IMAGES_EXT
+# Proxy textures are not available on OpenGL ES
+ignore GL_PROXY_TEXTURE_3D_EXT
+# Queries for texture dimensions were not introduced to OpenGL ES until 3.1
+ignore GL_TEXTURE_DEPTH_EXT
index a70989aa47230256ebfee90b6031c0f7aedd5b35..d7f044bd8d4676afd17ada3ba5fc851937306953 100644 (file)
@@ -1,3 +1,9 @@
 extension EXT_texture_array
-# We use the version from ARB_shadow
+# ARB_shadow has an equivalent enum and was introduced earlier
 ignore GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT
+# 1D textures are not available on OpenGL ES
+optional GL_TEXTURE_1D_ARRAY_EXT
+optional GL_TEXTURE_BINDING_1D_ARRAY_EXT
+# Proxy textures are not available on OpenGL ES
+ignore GL_PROXY_TEXTURE_1D_ARRAY_EXT
+ignore GL_PROXY_TEXTURE_2D_ARRAY_EXT
index a592cdfa05da9190f2da55690c6752c43535304d..2bfbcf481e50d6c2ed57baf1ff3f6daf86ede0fc 100644 (file)
@@ -1,9 +1,19 @@
 extension EXT_texture_sRGB
+# The automatically detected source extensions are incorrect; EXT_sRGB provides
+# SRGB8_ALPHA8 only for renderbuffers while NV_sRGB_formats provides SRGB8 only
+# for immutable texture storage
+gles2:source none
+# Unsized sRGB internal formats are not available on OpenGL ES
+optional GL_SRGB_EXT
+optional GL_SRGB_ALPHA_EXT
 # Specific compressed formats were not promoted to core
 ignore GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
 ignore GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
 ignore GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
 ignore GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
+# Generic compressed formats are not available on OpenGL ES
+ignore GL_COMPRESSED_SRGB_EXT
+ignore GL_COMPRESSED_SRGB_ALPHA_EXT
 # Luminance formats are deprecated
 ignore GL_COMPRESSED_SLUMINANCE_EXT
 ignore GL_COMPRESSED_SLUMINANCE_ALPHA_EXT
diff --git a/extensions/msp_buffer_control.glext b/extensions/msp_buffer_control.glext
new file mode 100644 (file)
index 0000000..64d4fb5
--- /dev/null
@@ -0,0 +1,2 @@
+extension MSP_buffer_control
+optional glDrawBuffer
diff --git a/extensions/msp_draw_buffer.glext b/extensions/msp_draw_buffer.glext
deleted file mode 100644 (file)
index 1c52cfd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extension MSP_draw_buffer
diff --git a/extensions/msp_sized_internal_formats.glext b/extensions/msp_sized_internal_formats.glext
deleted file mode 100644 (file)
index 23438c7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-extension MSP_sized_internal_formats
diff --git a/extensions/nv_fbo_color_attachments.glext b/extensions/nv_fbo_color_attachments.glext
new file mode 100644 (file)
index 0000000..40b473f
--- /dev/null
@@ -0,0 +1 @@
+extension gles2.NV_fbo_color_attachments
diff --git a/extensions/oes_mapbuffer.glext b/extensions/oes_mapbuffer.glext
new file mode 100644 (file)
index 0000000..184af97
--- /dev/null
@@ -0,0 +1,9 @@
+extension gles2.OES_mapbuffer
+# Whole buffer mapping was not promoted to core in OpenGL ES
+optional glMapBufferOES
+# Because of the above, mapped access cannot be queried on OpenGL ES
+ignore GL_BUFFER_ACCESS_OES
+# Include the access mode enums for desktop OpenGL
+optional GL_READ_ONLY
+optional GL_WRITE_ONLY_OES
+optional GL_READ_WRITE
diff --git a/extensions/oes_required_internalformat.glext b/extensions/oes_required_internalformat.glext
new file mode 100644 (file)
index 0000000..bda4b00
--- /dev/null
@@ -0,0 +1,16 @@
+extension gles2.OES_required_internalformat
+# Some formats were not promoted to core in OpenGL ES
+ignore GL_ALPHA8_OES
+ignore GL_LUMINANCE4_ALPHA4_OES
+ignore GL_LUMINANCE8_ALPHA8_OES
+ignore GL_LUMINANCE8_OES
+ignore GL_RGB10_EXT
+# 32-bit fixed point depth was not promoted to core in OpenGL ES; prefer
+# GL_DEPTH_COMPONENT32F from ARB_depth_buffer_float
+optional GL_DEPTH_COMPONENT32_OES
+# 5/6/5-bit RGB internal format additionally requires ARB_ES2_compatibility on
+# desktop OpenGL
+optional GL_RGB565_OES
+# Combined depth/stencil format additionally requires EXT_packed_depth_stencil
+# on desktop OpenGL
+optional GL_DEPTH24_STENCIL8_OES
diff --git a/extensions/oes_texture_stencil8.glext b/extensions/oes_texture_stencil8.glext
new file mode 100644 (file)
index 0000000..54d986d
--- /dev/null
@@ -0,0 +1 @@
+extension gles2.OES_texture_stencil8
index e6e14b38e400a8b2aa5caed85ba62d5085e27932..8b84a4fb963725468e331f2c836c11f8b34c5951 100644 (file)
         <!-- The name got changed but as far as I can tell they mean the same
         thing. -->
         <enum value="0x8CD4" name="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT" alias="GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"/>
+
+        <!-- Add an alias to improve desktop OpenGL compatibility even though
+        this was not promoted to core in OpenGL ES. -->
+        <enum value="0x81A7" name="GL_DEPTH_COMPONENT32_OES" alias="GL_DEPTH_COMPONENT32"/>
     </enums>
 
     <feature api="gl" name="GL_VERSION_1_4" number="1.4">
         </require>
     </feature>
 
+    <feature api="gles2">
+        <require>
+            <!-- Annotate support for certain things in OpenGL ES.  Don't set
+            version because they are only available through extensions. -->
+            <enum name="GL_DEPTH_COMPONENT32"/>
+            <enum name="GL_BUFFER_ACCESS"/>
+            <command name="glBindFragDataLocation"/>
+            <command name="glMapBuffer"/>
+        </require>
+    </feature>
+
+    <feature api="gles2" name="GL_ES_VERSION_3_0" number="3.0">
+        <require>
+            <!-- These are found in the 3.0 spec. -->
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"/>
+            <enum name="GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"/>
+        </require>
+    </feature>
+
     <extensions>
-        <!-- Put GL_RED here for the benefit of OpenGL ES. -->
-        <extension name="GL_ARB_texture_rg" supported="gl|glcore">
+        <extension name="GL_ARB_depth_texture" supported="gl">
             <require>
-                <enum name="GL_RED"/>
+                <!-- The base GL_DEPTH_COMPONENT format was introduced for
+                other purposes before it could be used for textures. -->
+                <enum name="GL_DEPTH_COMPONENT"/>
             </require>
         </extension>
 
-        <!-- And the remaining color components here. -->
-        <extension name="GL_ARB_texture_swizzle" supported="gl|glcore">
+        <extension name="GL_ARB_texture_rg" supported="gl|glcore">
             <require>
-                <enum name="GL_GREEN"/>
-                <enum name="GL_BLUE"/>
-                <enum name="GL_ALPHA"/>
+                <!-- GL_RED is mentioned in the extension spec. -->
+                <enum name="GL_RED"/>
             </require>
         </extension>
     </extensions>
index cea6395bf9d5238a73464bd1acfb1e08682d37c4..1f7ef6259970f9c5d042e4aeeea5df44097df09b 100644 (file)
@@ -67,7 +67,7 @@
         </extension>
 
         <!-- OpenGL ES does not have glDrawBuffer. -->
-        <extension name="GL_MSP_draw_buffer" supported="gl">
+        <extension name="GL_MSP_buffer_control" supported="gl">
             <require>
                 <command name="glDrawBuffer" />
                 <command name="glReadBuffer" />
             </require>
         </extension>
 
-        <!-- Sized internal formats were introduced in OpenGL ES 3.0, but are
-        not available as an extension. -->
-        <extension name="GL_MSP_sized_internal_formats" supported="gl|gles2">
-            <require>
-                <enum name="GL_RGB8" />
-                <enum name="GL_RGBA8" />
-            </require>
-        </extension>
-
         <!-- 1D textures are not available in OpenGL ES, but could conceivably
         be added at a later date. -->
         <extension name="GL_MSP_texture1D" supported="gl">
index 1d9cad3e853050a764ddc8fee308f1d4e87cc6ce..ff40ec60eadd1f515336f78d4d82eec2e0cfdfff 100755 (executable)
@@ -427,8 +427,32 @@ def detect_source_extension(host_api, things, debug=False):
                print "Looking for %d things in %d extensions"%(len(things), len(things_by_ext))
 
        extensions = []
+       keep_exts = 0
+       base_version = None
+       recheck_base_version = True
        missing = set(things)
-       while missing and things_by_ext:
+       while 1:
+               if recheck_base_version:
+                       max_version = Version(1, 0)
+                       for t in missing:
+                               supp = t.api_support.get(host_api.name)
+                               if supp and supp.core_version and max_version:
+                                       max_version = max(max_version, supp.core_version)
+                               else:
+                                       max_version = None
+
+                       if max_version:
+                               if not base_version or max_version<base_version:
+                                       base_version = max_version
+                                       keep_exts = len(extensions)
+                       elif not base_version:
+                               keep_exts = len(extensions)
+
+                       recheck_base_version = False
+
+               if not missing or not things_by_ext:
+                       break
+
                largest_ext = None
                largest_count = 0
                for e, t in things_by_ext.iteritems():
@@ -445,8 +469,10 @@ def detect_source_extension(host_api, things, debug=False):
                extensions.append(largest_ext)
                for t in things_by_ext[largest_ext]:
                        missing.remove(t)
-               if not missing:
-                       break
+
+                       supp = t.api_support.get(host_api.name)
+                       if supp and supp.core_version==base_version:
+                               recheck_base_version = True
 
                del things_by_ext[largest_ext]
                for e in things_by_ext.keys():
@@ -456,14 +482,21 @@ def detect_source_extension(host_api, things, debug=False):
                        else:
                                del things_by_ext[e]
 
-       if missing:
+       if not missing:
+               return None, extensions
+       elif base_version:
+               if debug:
+                       print "Found remaining things in version %s"%base_version
+                       if keep_exts<len(extensions):
+                               print "Discarding %d extensions that do not improve base version"%(len(extensions)-keep_exts)
+               del extensions[keep_exts:]
+               return base_version, extensions
+       else:
                if debug:
                        print "%d things still missing:"%len(missing)
                        for t in missing:
                                print "  "+t.name
-               return None
-
-       return extensions
+               return None, None
 
 
 class SourceGenerator:
@@ -482,7 +515,9 @@ class SourceGenerator:
                self.core_version = detect_core_version(host_api, things, debug)
                self.deprecated_version = detect_deprecated_version(host_api, things, debug)
                self.backport_ext = detect_backport_extension(host_api, things);
-               self.source_exts = detect_source_extension(host_api, things, debug)
+               b, e = detect_source_extension(host_api, things, debug)
+               self.base_version = b
+               self.source_exts = e
 
                if not self.core_version and not self.backport_ext and not self.source_exts:
                        print "Warning: Not supportable on host API"
@@ -495,7 +530,10 @@ class SourceGenerator:
                if self.backport_ext:
                        print "Backport %s"%self.backport_ext.name
                if self.source_exts:
-                       print "Sources %s"%", ".join(e.name for e in self.source_exts)
+                       names = [e.name for e in self.source_exts]
+                       if self.base_version:
+                               names.insert(0, "Version %s"%self.base_version)
+                       print "Sources %s"%", ".join(names)
 
        def write_header_intro(self, out):
                out.write("#ifndef MSP_GL_%s_\n"%self.ext_name.upper())
@@ -585,30 +623,36 @@ namespace GL {
                                out.write(", %r"%self.deprecated_version)
                        out.write("))\n\t{\n")
                        for f in self.funcs:
-                               supp = f.api_support[self.host_api.name]
-                               gpa_suffix = ""
-                               if supp.core_version is not None and supp.core_version<=Version(1, 1):
-                                       gpa_suffix = "_1_1"
-                               out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS%s(%s));\n"%(f.name, self.func_typedefs[f.name], gpa_suffix, f.name))
+                               supp = f.api_support.get(self.host_api.name)
+                               if supp:
+                                       gpa_suffix = ""
+                                       if supp.core_version is not None and supp.core_version<=Version(1, 1):
+                                               gpa_suffix = "_1_1"
+                                       out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS%s(%s));\n"%(f.name, self.func_typedefs[f.name], gpa_suffix, f.name))
                        out.write("\t\treturn Extension::CORE;\n")
                        out.write("\t}\n")
                        out.write("#endif\n")
                if self.source_exts:
                        out.write("#if !defined(__APPLE__) || defined(GL_%s)\n"%self.ext_name)
-                       out.write("\tif(%s)\n\t{\n"%" && ".join("is_supported(\"GL_%s\")"%s.name for s in self.source_exts))
+                       out.write("\tif(")
+                       if self.base_version:
+                               out.write("is_supported(%r) && "%self.base_version)
+                       out.write("%s)\n\t{\n"%" && ".join("is_supported(\"GL_%s\")"%s.name for s in self.source_exts))
                        for f in self.funcs:
-                               supp = f.api_support[self.host_api.name]
-                               if supp.sources:
-                                       src = None
-                                       for e in self.source_exts:
+                               supp = f.api_support.get(self.host_api.name)
+                               src = None
+                               for e in self.source_exts:
+                                       if f in e.things:
+                                               src = f
+                                       elif supp:
                                                for s in supp.sources:
                                                        if s.name in e.things:
                                                                src = s
                                                                break
-                                               if src:
-                                                       break
-                               else:
-                                       src = f
+                                       if src:
+                                               break
+                               if not src and supp and supp.core_version and self.base_version>=supp.core_version:
+                                       sec = f
 
                                if src:
                                        out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS(%s));\n"%(f.name, self.func_typedefs[f.name], src.name))
@@ -671,13 +715,14 @@ class ExtensionParser:
                self.core_version = None
                self.deprecated_version = None
                self.backport_ext = None
+               self.source_exts = []
                self.ignore_things = []
                self.optional_things = []
 
        def parse(self, fn):
                for line in open(fn):
                        line = line.strip()
-                       if line.startswith("#"):
+                       if not line or line.startswith("#"):
                                continue
 
                        parts = line.split()
@@ -697,6 +742,8 @@ class ExtensionParser:
                                self.deprecated_version = Version(*map(int, parts[1].split('.')))
                        elif keyword=="backport":
                                self.backport_ext = parts[1]
+                       elif keyword=="source":
+                               self.source_exts.append(parts[1])
                        elif keyword=="ignore":
                                self.ignore_things.append(parts[1])
                        elif keyword=="optional":
@@ -804,6 +851,12 @@ replaced with cpp and h."""
                        generator.backport_ext = None
                else:
                        generator.backport_ext = get_extension(xml_parser.apis, ext_parser.backport_ext)
+       if ext_parser.source_exts:
+               generator.base_version = None
+               if len(ext_parser.source_exts)==1 and ext_parser.source_exts[0]=="none":
+                       generator.source_exts = []
+               else:
+                       generator.source_exts = map((lambda e: get_extension(xml_parser.apis, e)), ext_parser.source_exts)
        if debug:
                generator.dump_info()
        generator.write_header(out_base+".h")
index 100e4b2ea40a08b4858b41abf043f7b4d84c11eb..38a690287b96d3bcc506b81bc184700fa9b35521 100644 (file)
@@ -98,11 +98,13 @@ void *Buffer::map(BufferAccess access)
        }
        else if(ARB_direct_state_access)
                return glMapNamedBuffer(id, access);
-       else
+       else if(OES_mapbuffer)
        {
                BindRestore _bind(this, type);
                return glMapBuffer(type, access);
        }
+       else
+               throw invalid_operation("Buffer::map");
 }
 
 bool Buffer::unmap()
index c473d7edc918202e9c7f3cfff2d23f77badebcaa..39e88cd1ce7647b74ea5f7f6b75cba575ea0d403 100644 (file)
@@ -6,6 +6,7 @@
 #include <msp/gl/extensions/arb_pixel_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_buffer_object.h>
 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
+#include <msp/gl/extensions/oes_mapbuffer.h>
 
 namespace Msp {
 namespace GL {
index c3639b8bb378848f4c9dda1e27f7654109c75af6..237f417a9b45db982ffe54e8a59e0bf9a8895e8f 100644 (file)
@@ -4,7 +4,7 @@
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/ext_texture_array.h>
 #include <msp/gl/extensions/ext_texture3d.h>
-#include <msp/gl/extensions/msp_draw_buffer.h>
+#include <msp/gl/extensions/msp_buffer_control.h>
 #include "error.h"
 #include "framebuffer.h"
 #include "misc.h"
@@ -159,10 +159,10 @@ void Framebuffer::update_attachment(unsigned mask) const
        {
                if(ARB_draw_buffers)
                        glDrawBuffers(color_bufs.size(), &color_bufs[0]);
-               else if(MSP_draw_buffer)
+               else if(MSP_buffer_control)
                        glDrawBuffer(first_buffer);
 
-               if(MSP_draw_buffer)
+               if(MSP_buffer_control)
                        glReadBuffer(first_buffer);
        }
 }
index 4fcfa9002c734ca6c05e1332a5775aea1e512633..5a9993dae202421f1c6434ebe5bb4bd006c5569f 100644 (file)
@@ -7,6 +7,7 @@
 #include "texturecube.h"
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/msp_stereo_rendering.h>
+#include <msp/gl/extensions/nv_fbo_color_attachments.h>
 
 namespace Msp {
 namespace GL {
index d866bcf8094b9f9d677ccea8c00bf36db8842cd7..e915e92fa61160908f8639828ffac60c89b893a7 100644 (file)
@@ -113,7 +113,8 @@ PixelFormat get_unsized_pixelformat(PixelFormat pf)
        case SLUMINANCE8_ALPHA8: return SLUMINANCE_ALPHA;
        case DEPTH_COMPONENT16:
        case DEPTH_COMPONENT24:
-       case DEPTH_COMPONENT32: return DEPTH_COMPONENT;
+       case DEPTH_COMPONENT32:
+       case DEPTH_COMPONENT32F: return DEPTH_COMPONENT;
        default: return pf;
        }
 }
@@ -171,7 +172,7 @@ PixelFormat get_sized_pixelformat(PixelFormat pf, unsigned size)
                case RG: return RG32F;
                case RGB: return RGB32F;
                case RGBA: return RGBA32F;
-               case DEPTH_COMPONENT: return DEPTH_COMPONENT32;
+               case DEPTH_COMPONENT: return ARB_depth_buffer_float ? DEPTH_COMPONENT32F : DEPTH_COMPONENT32;
                default: throw invalid_argument("get_sized_pixelformat");
                }
        default:
@@ -248,6 +249,7 @@ unsigned get_component_size(PixelFormat pf)
        case RGB32F:
        case RGBA32F:
        case DEPTH_COMPONENT32:
+       case DEPTH_COMPONENT32F:
                return 4;
        default:
                return 0;
@@ -261,8 +263,17 @@ unsigned get_pixel_size(PixelFormat pf)
 
 void require_pixelformat(PixelFormat pf)
 {
+       /* TODO These checks are only accurate for textures.  On OpenGL ES some
+       formats are allowed for render buffers earlier than textures.  In particular
+       it's possible to create a 16-bit depth renderbuffer on OpenGL ES 2.0 but
+       depth textures are only available with 3.0 or the OES_depth_texture
+       extension.*/
        switch(pf)
        {
+       case RGB8:
+       case RGBA8:
+               { static Require _req(OES_required_internalformat); }
+               break;
        case RED:
        case R8:
        case RG:
@@ -297,10 +308,19 @@ void require_pixelformat(PixelFormat pf)
                { static Require _req(EXT_bgra); }
                break;
        case DEPTH_COMPONENT:
+               { static Require _req(ARB_depth_texture); }
+               break;
        case DEPTH_COMPONENT16:
        case DEPTH_COMPONENT24:
        case DEPTH_COMPONENT32:
                { static Require _req(ARB_depth_texture); }
+               { static Require _req(OES_required_internalformat); }
+               break;
+       case DEPTH_COMPONENT32F:
+               { static Require _req(ARB_depth_buffer_float); }
+               break;
+       case STENCIL_INDEX:
+               { static Require _req(OES_texture_stencil8); }
                break;
        default:
                break;
index 14ca580e5fc7e9cbdb22ebc9f5ce6f2725312f0b..5d59c255ea2c40e42aa2a9e20240e47607c22201 100644 (file)
@@ -4,13 +4,15 @@
 #include <msp/graphics/pixelformat.h>
 #include <msp/strings/lexicalcast.h>
 #include "gl.h"
+#include <msp/gl/extensions/arb_depth_buffer_float.h>
 #include <msp/gl/extensions/arb_depth_texture.h>
 #include <msp/gl/extensions/arb_texture_float.h>
 #include <msp/gl/extensions/arb_texture_rg.h>
 #include <msp/gl/extensions/ext_bgra.h>
 #include <msp/gl/extensions/ext_texture_srgb.h>
 #include <msp/gl/extensions/msp_legacy_features.h>
-#include <msp/gl/extensions/msp_sized_internal_formats.h>
+#include <msp/gl/extensions/oes_required_internalformat.h>
+#include <msp/gl/extensions/oes_texture_stencil8.h>
 
 namespace Msp {
 namespace GL {
@@ -22,6 +24,7 @@ enum PixelFormat
        DEPTH_COMPONENT16 = GL_DEPTH_COMPONENT16,
        DEPTH_COMPONENT24 = GL_DEPTH_COMPONENT24,
        DEPTH_COMPONENT32 = GL_DEPTH_COMPONENT32,
+       DEPTH_COMPONENT32F = GL_DEPTH_COMPONENT32F,
        RED             = GL_RED,
        RG              = GL_RG,
        RGB             = GL_RGB,
index 74a23246b368ac6ad3b6b3d69765c5f6d4bbd82e..31c90777aad10eccd5a4e9d110de2a0846809f26 100644 (file)
@@ -39,7 +39,7 @@ unsigned TexUnit::get_n_units()
        if(count<0)
        {
                if(ARB_vertex_shader)
-                       count = get_i(GL_MAX_TEXTURE_IMAGE_UNITS);
+                       count = get_i(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS);
                else if(ARB_multitexture)
                        count = get_i(GL_MAX_TEXTURE_UNITS);
                else