Add more checks for extensions being present, for future use

This commit is contained in:
baldurk
2017-01-11 21:32:06 +00:00
parent 4a80a744c3
commit c66dd62a2e
5 changed files with 42 additions and 35 deletions
+8 -2
View File
@@ -28,7 +28,7 @@
#include "serialise/string_utils.h"
#include "gl_driver.h"
bool ExtensionSupported[ExtensionSupported_Count];
bool ExtensionSupported[GLExt_Count];
bool VendorCheck[VendorCheck_Count];
int GLCoreVersion = 0;
@@ -71,7 +71,7 @@ void DoVendorChecks(const GLHookSet &gl, GLWindowingData context)
#define EXT_CHECK(extname) \
if(!strcmp(ext, STRINGIZE(extname))) \
ExtensionSupported[CONCAT(ExtensionSupported_, extname)] = true;
ExtensionSupported[CONCAT(GLExt_, extname)] = true;
EXT_CHECK(ARB_clip_control);
EXT_CHECK(ARB_enhanced_layouts);
@@ -80,6 +80,12 @@ void DoVendorChecks(const GLHookSet &gl, GLWindowingData context)
EXT_CHECK(EXT_raster_multisample);
EXT_CHECK(ARB_indirect_parameters);
EXT_CHECK(EXT_depth_bounds_test);
EXT_CHECK(ARB_compute_shader);
EXT_CHECK(ARB_program_interface_query);
EXT_CHECK(ARB_image_load_store);
EXT_CHECK(ARB_copy_image);
EXT_CHECK(ARB_shader_atomic_counters);
EXT_CHECK(ARB_shader_storage_buffer_object);
#undef EXT_CHECK
}
+15 -9
View File
@@ -190,16 +190,22 @@ extern bool GLIsCore;
// extensions we know we want to check for are precached, indexd by this enum
enum ExtensionCheckEnum
{
ExtensionSupported_ARB_enhanced_layouts = 0,
ExtensionSupported_ARB_clip_control,
ExtensionSupported_EXT_polygon_offset_clamp,
ExtensionSupported_KHR_blend_equation_advanced_coherent,
ExtensionSupported_EXT_raster_multisample,
ExtensionSupported_ARB_indirect_parameters,
ExtensionSupported_EXT_depth_bounds_test,
ExtensionSupported_Count,
GLExt_ARB_enhanced_layouts = 0,
GLExt_ARB_clip_control,
GLExt_EXT_polygon_offset_clamp,
GLExt_KHR_blend_equation_advanced_coherent,
GLExt_EXT_raster_multisample,
GLExt_ARB_indirect_parameters,
GLExt_EXT_depth_bounds_test,
GLExt_ARB_compute_shader,
GLExt_ARB_program_interface_query,
GLExt_ARB_image_load_store,
GLExt_ARB_copy_image,
GLExt_ARB_shader_atomic_counters,
GLExt_ARB_shader_storage_buffer_object,
GLExt_Count,
};
extern bool ExtensionSupported[ExtensionSupported_Count];
extern bool ExtensionSupported[GLExt_Count];
// for some things we need to know how a specific implementation behaves to work around it
// or adjust things. We centralise that here (similar to extensions)
+3 -3
View File
@@ -1476,7 +1476,7 @@ struct RenderTextState
enableBits[7] = gl.glIsEnabled(eGL_ALPHA_TEST) != 0;
}
if(modern && (GLCoreVersion >= 45 || ExtensionSupported[ExtensionSupported_ARB_clip_control]))
if(modern && (GLCoreVersion >= 45 || ExtensionSupported[GLExt_ARB_clip_control]))
{
gl.glGetIntegerv(eGL_CLIP_ORIGIN, (GLint *)&ClipOrigin);
gl.glGetIntegerv(eGL_CLIP_DEPTH_MODE, (GLint *)&ClipDepth);
@@ -1611,7 +1611,7 @@ struct RenderTextState
if(modern && gl.glClipControl &&
(GLCoreVersion >= 45 ||
ExtensionSupported[ExtensionSupported_ARB_clip_control])) // only available in 4.5+
ExtensionSupported[GLExt_ARB_clip_control])) // only available in 4.5+
gl.glClipControl(ClipOrigin, ClipDepth);
if(modern)
@@ -1786,7 +1786,7 @@ void WrappedOpenGL::RenderOverlayStr(float x, float y, const char *text)
if(gl.glClipControl &&
(GLCoreVersion >= 45 ||
ExtensionSupported[ExtensionSupported_ARB_clip_control])) // only available in 4.5+
ExtensionSupported[GLExt_ARB_clip_control])) // only available in 4.5+
gl.glClipControl(eGL_LOWER_LEFT, eGL_NEGATIVE_ONE_TO_ONE);
// bind UBOs
+15 -20
View File
@@ -553,21 +553,19 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
for(GLuint i = 0; i < eEnabled_Count; i++)
{
if(pnames[i] == eGL_BLEND_ADVANCED_COHERENT_KHR &&
!ExtensionSupported[ExtensionSupported_KHR_blend_equation_advanced_coherent])
!ExtensionSupported[GLExt_KHR_blend_equation_advanced_coherent])
{
Enabled[i] = true;
continue;
}
if(pnames[i] == eGL_RASTER_MULTISAMPLE_EXT &&
!ExtensionSupported[ExtensionSupported_EXT_raster_multisample])
if(pnames[i] == eGL_RASTER_MULTISAMPLE_EXT && !ExtensionSupported[GLExt_EXT_raster_multisample])
{
Enabled[i] = false;
continue;
}
if(pnames[i] == eGL_DEPTH_BOUNDS_TEST_EXT &&
!ExtensionSupported[ExtensionSupported_EXT_depth_bounds_test])
if(pnames[i] == eGL_DEPTH_BOUNDS_TEST_EXT && !ExtensionSupported[GLExt_EXT_depth_bounds_test])
{
Enabled[i] = false;
continue;
@@ -640,7 +638,7 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
m_Real->glGetFloatv(eGL_POINT_SIZE, &PointSize);
m_Real->glGetIntegerv(eGL_PRIMITIVE_RESTART_INDEX, (GLint *)&PrimitiveRestartIndex);
if(GLCoreVersion >= 45 || ExtensionSupported[ExtensionSupported_ARB_clip_control])
if(GLCoreVersion >= 45 || ExtensionSupported[GLExt_ARB_clip_control])
{
m_Real->glGetIntegerv(eGL_CLIP_ORIGIN, (GLint *)&ClipOrigin);
m_Real->glGetIntegerv(eGL_CLIP_DEPTH_MODE, (GLint *)&ClipDepth);
@@ -694,7 +692,7 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
(GLint *)&BufferBindings[eBufIdx_Pixel_Unpack]);
m_Real->glGetIntegerv(eGL_QUERY_BUFFER_BINDING, (GLint *)&BufferBindings[eBufIdx_Query]);
m_Real->glGetIntegerv(eGL_TEXTURE_BUFFER_BINDING, (GLint *)&BufferBindings[eBufIdx_Texture]);
if(ExtensionSupported[ExtensionSupported_ARB_indirect_parameters])
if(ExtensionSupported[GLExt_ARB_indirect_parameters])
m_Real->glGetIntegerv(eGL_PARAMETER_BUFFER_BINDING_ARB,
(GLint *)&BufferBindings[eBufIdx_Parameter]);
@@ -791,7 +789,7 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
for(GLuint i = 0; i < (GLuint)ARRAY_COUNT(DepthRanges); i++)
m_Real->glGetDoublei_v(eGL_DEPTH_RANGE, i, &DepthRanges[i].nearZ);
if(ExtensionSupported[ExtensionSupported_EXT_depth_bounds_test])
if(ExtensionSupported[GLExt_EXT_depth_bounds_test])
{
m_Real->glGetDoublev(eGL_DEPTH_BOUNDS_TEST_EXT, &DepthBounds.nearZ);
}
@@ -840,12 +838,12 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
SampleCoverageInvert = (boolread != 0);
m_Real->glGetFloatv(eGL_MIN_SAMPLE_SHADING_VALUE, &MinSampleShading);
if(ExtensionSupported[ExtensionSupported_EXT_raster_multisample])
if(ExtensionSupported[GLExt_EXT_raster_multisample])
m_Real->glGetIntegerv(eGL_RASTER_SAMPLES_EXT, (GLint *)&RasterSamples);
else
RasterSamples = 0;
if(ExtensionSupported[ExtensionSupported_EXT_raster_multisample])
if(ExtensionSupported[GLExt_EXT_raster_multisample])
m_Real->glGetIntegerv(eGL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT, (GLint *)&RasterFixed);
else
RasterFixed = false;
@@ -876,7 +874,7 @@ void GLRenderState::FetchState(void *ctx, WrappedOpenGL *gl)
m_Real->glGetFloatv(eGL_POLYGON_OFFSET_FACTOR, &PolygonOffset[0]);
m_Real->glGetFloatv(eGL_POLYGON_OFFSET_UNITS, &PolygonOffset[1]);
if(ExtensionSupported[ExtensionSupported_EXT_polygon_offset_clamp])
if(ExtensionSupported[GLExt_EXT_polygon_offset_clamp])
m_Real->glGetFloatv(eGL_POLYGON_OFFSET_CLAMP_EXT, &PolygonOffset[2]);
else
PolygonOffset[2] = 0.0f;
@@ -937,15 +935,13 @@ void GLRenderState::ApplyState(void *ctx, WrappedOpenGL *gl)
for(GLuint i = 0; i < eEnabled_Count; i++)
{
if(pnames[i] == eGL_BLEND_ADVANCED_COHERENT_KHR &&
!ExtensionSupported[ExtensionSupported_KHR_blend_equation_advanced_coherent])
!ExtensionSupported[GLExt_KHR_blend_equation_advanced_coherent])
continue;
if(pnames[i] == eGL_RASTER_MULTISAMPLE_EXT &&
!ExtensionSupported[ExtensionSupported_EXT_raster_multisample])
if(pnames[i] == eGL_RASTER_MULTISAMPLE_EXT && !ExtensionSupported[GLExt_EXT_raster_multisample])
continue;
if(pnames[i] == eGL_DEPTH_BOUNDS_TEST_EXT &&
!ExtensionSupported[ExtensionSupported_EXT_depth_bounds_test])
if(pnames[i] == eGL_DEPTH_BOUNDS_TEST_EXT && !ExtensionSupported[GLExt_EXT_depth_bounds_test])
continue;
if(Enabled[i])
@@ -1025,7 +1021,7 @@ void GLRenderState::ApplyState(void *ctx, WrappedOpenGL *gl)
m_Real->glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, BufferBindings[eBufIdx_Pixel_Unpack]);
m_Real->glBindBuffer(eGL_QUERY_BUFFER, BufferBindings[eBufIdx_Query]);
m_Real->glBindBuffer(eGL_TEXTURE_BUFFER, BufferBindings[eBufIdx_Texture]);
if(ExtensionSupported[ExtensionSupported_ARB_indirect_parameters])
if(ExtensionSupported[GLExt_ARB_indirect_parameters])
m_Real->glBindBuffer(eGL_PARAMETER_BUFFER_ARB, BufferBindings[eBufIdx_Parameter]);
struct
@@ -1186,7 +1182,7 @@ void GLRenderState::ApplyState(void *ctx, WrappedOpenGL *gl)
m_Real->glSampleCoverage(SampleCoverage, SampleCoverageInvert ? GL_TRUE : GL_FALSE);
m_Real->glMinSampleShading(MinSampleShading);
if(ExtensionSupported[ExtensionSupported_EXT_raster_multisample] && m_Real->glRasterSamplesEXT)
if(ExtensionSupported[GLExt_EXT_raster_multisample] && m_Real->glRasterSamplesEXT)
m_Real->glRasterSamplesEXT(RasterSamples, RasterFixed);
m_Real->glLogicOp(LogicOp);
@@ -1199,8 +1195,7 @@ void GLRenderState::ApplyState(void *ctx, WrappedOpenGL *gl)
m_Real->glPatchParameterfv(eGL_PATCH_DEFAULT_OUTER_LEVEL, PatchParams.defaultOuterLevel);
m_Real->glPolygonMode(eGL_FRONT_AND_BACK, PolygonMode);
if(ExtensionSupported[ExtensionSupported_EXT_polygon_offset_clamp] &&
m_Real->glPolygonOffsetClampEXT)
if(ExtensionSupported[GLExt_EXT_polygon_offset_clamp] && m_Real->glPolygonOffsetClampEXT)
m_Real->glPolygonOffsetClampEXT(PolygonOffset[0], PolygonOffset[1], PolygonOffset[2]);
else
m_Real->glPolygonOffset(PolygonOffset[0], PolygonOffset[1]);
+1 -1
View File
@@ -1687,7 +1687,7 @@ void MakeShaderReflection(const GLHookSet &gl, GLenum shadType, GLuint sepProg,
GLsizei numSigProps = (GLsizei)ARRAY_COUNT(props);
// GL_LOCATION_COMPONENT not supported on core <4.4 (or without GL_ARB_enhanced_layouts)
if(!ExtensionSupported[ExtensionSupported_ARB_enhanced_layouts] && GLCoreVersion < 44)
if(!ExtensionSupported[GLExt_ARB_enhanced_layouts] && GLCoreVersion < 44)
numSigProps--;
gl.glGetProgramResourceiv(sepProg, sigEnum, i, numSigProps, props, numSigProps, NULL, values);