From e19309340e90ee881e9cb2f8b7c33a5b89681aa6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 4 Dec 2017 13:04:48 +0200 Subject: [PATCH] Make extensions compatible with OpenGL ES --- extensions/arb_depth_buffer_float.glext | 1 + extensions/arb_depth_texture.glext | 13 ++- extensions/arb_fragment_shader.glext | 6 ++ extensions/arb_geometry_shader4.glext | 17 +++- extensions/arb_multitexture.glext | 39 +++++++ extensions/arb_occlusion_query.glext | 7 ++ extensions/arb_shader_objects.glext | 18 +++- extensions/arb_shadow.glext | 5 +- extensions/arb_texture_cube_map.glext | 4 +- extensions/arb_texture_float.glext | 12 +++ extensions/arb_texture_rg.glext | 3 + extensions/arb_texture_storage.glext | 2 + extensions/arb_texture_swizzle.glext | 7 ++ extensions/arb_uniform_buffer_object.glext | 11 ++ extensions/arb_vertex_buffer_object.glext | 21 +++- extensions/arb_vertex_shader.glext | 39 ++++++- extensions/ext_blend_minmax.glext | 5 +- extensions/ext_blend_subtract.glext | 4 +- extensions/ext_framebuffer_object.glext | 37 ++++++- extensions/ext_gpu_shader4.glext | 11 +- extensions/ext_texture3d.glext | 7 ++ extensions/ext_texture_array.glext | 8 +- extensions/ext_texture_srgb.glext | 10 ++ extensions/msp_buffer_control.glext | 2 + extensions/msp_draw_buffer.glext | 1 - extensions/msp_sized_internal_formats.glext | 1 - extensions/nv_fbo_color_attachments.glext | 1 + extensions/oes_mapbuffer.glext | 9 ++ extensions/oes_required_internalformat.glext | 16 +++ extensions/oes_texture_stencil8.glext | 1 + gl.fixes.xml | 38 +++++-- gl.msp.xml | 11 +- scripts/extgen.py | 101 ++++++++++++++----- source/buffer.cpp | 4 +- source/buffer.h | 1 + source/framebuffer.cpp | 6 +- source/framebuffer.h | 1 + source/pixelformat.cpp | 24 ++++- source/pixelformat.h | 5 +- source/texunit.cpp | 2 +- 40 files changed, 440 insertions(+), 71 deletions(-) create mode 100644 extensions/arb_depth_buffer_float.glext create mode 100644 extensions/msp_buffer_control.glext delete mode 100644 extensions/msp_draw_buffer.glext delete mode 100644 extensions/msp_sized_internal_formats.glext create mode 100644 extensions/nv_fbo_color_attachments.glext create mode 100644 extensions/oes_mapbuffer.glext create mode 100644 extensions/oes_required_internalformat.glext create mode 100644 extensions/oes_texture_stencil8.glext diff --git a/extensions/arb_depth_buffer_float.glext b/extensions/arb_depth_buffer_float.glext new file mode 100644 index 00000000..8bd7ac3a --- /dev/null +++ b/extensions/arb_depth_buffer_float.glext @@ -0,0 +1 @@ +extension ARB_depth_buffer_float diff --git a/extensions/arb_depth_texture.glext b/extensions/arb_depth_texture.glext index 8b72d003..16366a03 100644 --- a/extensions/arb_depth_texture.glext +++ b/extensions/arb_depth_texture.glext @@ -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 diff --git a/extensions/arb_fragment_shader.glext b/extensions/arb_fragment_shader.glext index e632db21..55b4d17b 100644 --- a/extensions/arb_fragment_shader.glext +++ b/extensions/arb_fragment_shader.glext @@ -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 diff --git a/extensions/arb_geometry_shader4.glext b/extensions/arb_geometry_shader4.glext index bc5bc77b..83109d87 100644 --- a/extensions/arb_geometry_shader4.glext +++ b/extensions/arb_geometry_shader4.glext @@ -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 diff --git a/extensions/arb_multitexture.glext b/extensions/arb_multitexture.glext index 78e8d9ba..7c5063c3 100644 --- a/extensions/arb_multitexture.glext +++ b/extensions/arb_multitexture.glext @@ -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 diff --git a/extensions/arb_occlusion_query.glext b/extensions/arb_occlusion_query.glext index 1f9d049a..616146ac 100644 --- a/extensions/arb_occlusion_query.glext +++ b/extensions/arb_occlusion_query.glext @@ -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 diff --git a/extensions/arb_shader_objects.glext b/extensions/arb_shader_objects.glext index 96d3fc28..47705493 100644 --- a/extensions/arb_shader_objects.glext +++ b/extensions/arb_shader_objects.glext @@ -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 diff --git a/extensions/arb_shadow.glext b/extensions/arb_shadow.glext index 477b7ba7..2633a528 100644 --- a/extensions/arb_shadow.glext +++ b/extensions/arb_shadow.glext @@ -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 diff --git a/extensions/arb_texture_cube_map.glext b/extensions/arb_texture_cube_map.glext index 5423ecfe..22c6ac40 100644 --- a/extensions/arb_texture_cube_map.glext +++ b/extensions/arb_texture_cube_map.glext @@ -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 diff --git a/extensions/arb_texture_float.glext b/extensions/arb_texture_float.glext index ddfb06e3..bdbb8d0e 100644 --- a/extensions/arb_texture_float.glext +++ b/extensions/arb_texture_float.glext @@ -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 diff --git a/extensions/arb_texture_rg.glext b/extensions/arb_texture_rg.glext index 68495ec2..8612f557 100644 --- a/extensions/arb_texture_rg.glext +++ b/extensions/arb_texture_rg.glext @@ -1 +1,4 @@ extension ARB_texture_rg +# OpenGL ES doesn't have 16-bit fixed-point formats +ignore GL_R16 +ignore GL_RG16 diff --git a/extensions/arb_texture_storage.glext b/extensions/arb_texture_storage.glext index c7526339..491f36d1 100644 --- a/extensions/arb_texture_storage.glext +++ b/extensions/arb_texture_storage.glext @@ -1 +1,3 @@ extension ARB_texture_storage +# 1D textures are not available on OpenGL ES +optional glTexStorage1D diff --git a/extensions/arb_texture_swizzle.glext b/extensions/arb_texture_swizzle.glext index 52496521..d1b9b0de 100644 --- a/extensions/arb_texture_swizzle.glext +++ b/extensions/arb_texture_swizzle.glext @@ -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 diff --git a/extensions/arb_uniform_buffer_object.glext b/extensions/arb_uniform_buffer_object.glext index 1ceadce7..7a3a5ca3 100644 --- a/extensions/arb_uniform_buffer_object.glext +++ b/extensions/arb_uniform_buffer_object.glext @@ -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 diff --git a/extensions/arb_vertex_buffer_object.glext b/extensions/arb_vertex_buffer_object.glext index 16d804f3..c08254cd 100644 --- a/extensions/arb_vertex_buffer_object.glext +++ b/extensions/arb_vertex_buffer_object.glext @@ -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 diff --git a/extensions/arb_vertex_shader.glext b/extensions/arb_vertex_shader.glext index efd91b83..b0fa52ba 100644 --- a/extensions/arb_vertex_shader.glext +++ b/extensions/arb_vertex_shader.glext @@ -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 diff --git a/extensions/ext_blend_minmax.glext b/extensions/ext_blend_minmax.glext index 4a2d1026..b8642003 100644 --- a/extensions/ext_blend_minmax.glext +++ b/extensions/ext_blend_minmax.glext @@ -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 diff --git a/extensions/ext_blend_subtract.glext b/extensions/ext_blend_subtract.glext index bf6c2821..6505ca2d 100644 --- a/extensions/ext_blend_subtract.glext +++ b/extensions/ext_blend_subtract.glext @@ -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 diff --git a/extensions/ext_framebuffer_object.glext b/extensions/ext_framebuffer_object.glext index 88f41cb1..06e9c37b 100644 --- a/extensions/ext_framebuffer_object.glext +++ b/extensions/ext_framebuffer_object.glext @@ -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 diff --git a/extensions/ext_gpu_shader4.glext b/extensions/ext_gpu_shader4.glext index 15875359..96d8c3e1 100644 --- a/extensions/ext_gpu_shader4.glext +++ b/extensions/ext_gpu_shader4.glext @@ -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 diff --git a/extensions/ext_texture3d.glext b/extensions/ext_texture3d.glext index e9bc90bb..65cfe203 100644 --- a/extensions/ext_texture3d.glext +++ b/extensions/ext_texture3d.glext @@ -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 diff --git a/extensions/ext_texture_array.glext b/extensions/ext_texture_array.glext index a70989aa..d7f044bd 100644 --- a/extensions/ext_texture_array.glext +++ b/extensions/ext_texture_array.glext @@ -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 diff --git a/extensions/ext_texture_srgb.glext b/extensions/ext_texture_srgb.glext index a592cdfa..2bfbcf48 100644 --- a/extensions/ext_texture_srgb.glext +++ b/extensions/ext_texture_srgb.glext @@ -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 index 00000000..64d4fb5f --- /dev/null +++ b/extensions/msp_buffer_control.glext @@ -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 index 1c52cfdb..00000000 --- a/extensions/msp_draw_buffer.glext +++ /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 index 23438c77..00000000 --- a/extensions/msp_sized_internal_formats.glext +++ /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 index 00000000..40b473f0 --- /dev/null +++ b/extensions/nv_fbo_color_attachments.glext @@ -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 index 00000000..184af979 --- /dev/null +++ b/extensions/oes_mapbuffer.glext @@ -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 index 00000000..bda4b008 --- /dev/null +++ b/extensions/oes_required_internalformat.glext @@ -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 index 00000000..54d986d2 --- /dev/null +++ b/extensions/oes_texture_stencil8.glext @@ -0,0 +1 @@ +extension gles2.OES_texture_stencil8 diff --git a/gl.fixes.xml b/gl.fixes.xml index e6e14b38..8b84a4fb 100644 --- a/gl.fixes.xml +++ b/gl.fixes.xml @@ -67,6 +67,10 @@ + + + @@ -77,20 +81,38 @@ + + + + + + + + + + + + + + + + + + - - + - + + - - + - - - + + diff --git a/gl.msp.xml b/gl.msp.xml index cea6395b..1f7ef625 100644 --- a/gl.msp.xml +++ b/gl.msp.xml @@ -67,7 +67,7 @@ - + @@ -100,15 +100,6 @@ - - - - - - - - diff --git a/scripts/extgen.py b/scripts/extgen.py index 1d9cad3e..ff40ec60 100755 --- a/scripts/extgen.py +++ b/scripts/extgen.py @@ -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(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") diff --git a/source/buffer.cpp b/source/buffer.cpp index 100e4b2e..38a69028 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -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() diff --git a/source/buffer.h b/source/buffer.h index c473d7ed..39e88cd1 100644 --- a/source/buffer.h +++ b/source/buffer.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace Msp { namespace GL { diff --git a/source/framebuffer.cpp b/source/framebuffer.cpp index c3639b8b..237f417a 100644 --- a/source/framebuffer.cpp +++ b/source/framebuffer.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #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); } } diff --git a/source/framebuffer.h b/source/framebuffer.h index 4fcfa900..5a9993da 100644 --- a/source/framebuffer.h +++ b/source/framebuffer.h @@ -7,6 +7,7 @@ #include "texturecube.h" #include #include +#include namespace Msp { namespace GL { diff --git a/source/pixelformat.cpp b/source/pixelformat.cpp index d866bcf8..e915e92f 100644 --- a/source/pixelformat.cpp +++ b/source/pixelformat.cpp @@ -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; diff --git a/source/pixelformat.h b/source/pixelformat.h index 14ca580e..5d59c255 100644 --- a/source/pixelformat.h +++ b/source/pixelformat.h @@ -4,13 +4,15 @@ #include #include #include "gl.h" +#include #include #include #include #include #include #include -#include +#include +#include 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, diff --git a/source/texunit.cpp b/source/texunit.cpp index 74a23246..31c90777 100644 --- a/source/texunit.cpp +++ b/source/texunit.cpp @@ -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 -- 2.43.0