From c8cbbd831d625fbf31dd7527ab65ac276e13fb4f Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 27 Nov 2016 18:14:52 +1000 Subject: [PATCH] GLExtensions: Seperate GL_ARB_compute_shader from GL 4.3 Allows the usage of glDispatchCompute from GLES (requires GLES 3.1). --- Source/Core/Common/Common.vcxproj | 1 + Source/Core/Common/Common.vcxproj.filters | 3 ++ .../GL/GLExtensions/ARB_compute_shader.h | 53 +++++++++++++++++++ .../Common/GL/GLExtensions/GLExtensions.cpp | 11 +++- .../Common/GL/GLExtensions/GLExtensions.h | 1 + Source/Core/Common/GL/GLExtensions/gl_4_3.h | 25 --------- 6 files changed, 67 insertions(+), 27 deletions(-) create mode 100644 Source/Core/Common/GL/GLExtensions/ARB_compute_shader.h diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 58528aca20..a00a8d488e 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -72,6 +72,7 @@ + diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters index d1f209f1c8..ff6b9ad7fc 100644 --- a/Source/Core/Common/Common.vcxproj.filters +++ b/Source/Core/Common/Common.vcxproj.filters @@ -245,6 +245,9 @@ GL\GLExtensions + + GL\GLExtensions + diff --git a/Source/Core/Common/GL/GLExtensions/ARB_compute_shader.h b/Source/Core/Common/GL/GLExtensions/ARB_compute_shader.h new file mode 100644 index 0000000000..b27b8091e4 --- /dev/null +++ b/Source/Core/Common/GL/GLExtensions/ARB_compute_shader.h @@ -0,0 +1,53 @@ +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#include "Common/GL/GLExtensions/gl_common.h" + +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 + +typedef void(APIENTRYP PFNDOLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, + GLuint num_groups_z); +typedef void(APIENTRYP PFNDOLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); + +extern PFNDOLDISPATCHCOMPUTEPROC dolDispatchCompute; +extern PFNDOLDISPATCHCOMPUTEINDIRECTPROC dolDispatchComputeIndirect; + +#define glDispatchCompute dolDispatchCompute +#define glDispatchComputeIndirect dolDispatchComputeIndirect diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp index ce9eb497a5..cba40b35dc 100644 --- a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp +++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp @@ -659,8 +659,6 @@ PFNDOLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC dolDrawTransformFeedbackStreamIns // gl_4_3 PFNDOLCLEARBUFFERDATAPROC dolClearBufferData; PFNDOLCLEARBUFFERSUBDATAPROC dolClearBufferSubData; -PFNDOLDISPATCHCOMPUTEPROC dolDispatchCompute; -PFNDOLDISPATCHCOMPUTEINDIRECTPROC dolDispatchComputeIndirect; PFNDOLFRAMEBUFFERPARAMETERIPROC dolFramebufferParameteri; PFNDOLGETFRAMEBUFFERPARAMETERIVPROC dolGetFramebufferParameteriv; PFNDOLGETINTERNALFORMATI64VPROC dolGetInternalformati64v; @@ -993,6 +991,10 @@ PFNDOLDEPTHBOUNDSDNVPROC dolDepthBoundsdNV; PFNDOLBINDIMAGETEXTUREPROC dolBindImageTexture; PFNDOLMEMORYBARRIERPROC dolMemoryBarrier; +// ARB_compute_shader +PFNDOLDISPATCHCOMPUTEPROC dolDispatchCompute; +PFNDOLDISPATCHCOMPUTEINDIRECTPROC dolDispatchComputeIndirect; + // Creates a GLFunc object that requires a feature #define GLFUNC_REQUIRES(x, y) \ { \ @@ -1863,6 +1865,11 @@ const GLFunc gl_function_array[] = { "GL_ARB_shader_image_load_store !VERSION_4_2 |VERSION_GLES_3_1"), GLFUNC_REQUIRES(glMemoryBarrier, "GL_ARB_shader_image_load_store !VERSION_4_2 |VERSION_GLES_3_1"), + + // ARB_compute_shader + GLFUNC_REQUIRES(glDispatchCompute, "GL_ARB_compute_shader !VERSION_4_3 |VERSION_GLES_3_1"), + GLFUNC_REQUIRES(glDispatchComputeIndirect, + "GL_ARB_compute_shader !VERSION_4_3 |VERSION_GLES_3_1"), }; namespace GLExtensions diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.h b/Source/Core/Common/GL/GLExtensions/GLExtensions.h index 92270d1b76..49e9fc282f 100644 --- a/Source/Core/Common/GL/GLExtensions/GLExtensions.h +++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.h @@ -12,6 +12,7 @@ #include "Common/GL/GLExtensions/ARB_blend_func_extended.h" #include "Common/GL/GLExtensions/ARB_buffer_storage.h" #include "Common/GL/GLExtensions/ARB_clip_control.h" +#include "Common/GL/GLExtensions/ARB_compute_shader.h" #include "Common/GL/GLExtensions/ARB_copy_image.h" #include "Common/GL/GLExtensions/ARB_debug_output.h" #include "Common/GL/GLExtensions/ARB_draw_elements_base_vertex.h" diff --git a/Source/Core/Common/GL/GLExtensions/gl_4_3.h b/Source/Core/Common/GL/GLExtensions/gl_4_3.h index e81b24e370..98b18ad246 100644 --- a/Source/Core/Common/GL/GLExtensions/gl_4_3.h +++ b/Source/Core/Common/GL/GLExtensions/gl_4_3.h @@ -38,24 +38,6 @@ #define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 #define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A #define GL_MAX_ELEMENT_INDEX 0x8D6B -#define GL_COMPUTE_SHADER 0x91B9 -#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB -#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF -#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_COMPUTE_SHADER_BIT 0x00000020 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 @@ -287,9 +269,6 @@ typedef void(APIENTRYP PFNDOLCLEARBUFFERDATAPROC)(GLenum target, GLenum internal typedef void(APIENTRYP PFNDOLCLEARBUFFERSUBDATAPROC)(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void* data); -typedef void(APIENTRYP PFNDOLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, - GLuint num_groups_z); -typedef void(APIENTRYP PFNDOLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect); typedef void(APIENTRYP PFNDOLFRAMEBUFFERPARAMETERIPROC)(GLenum target, GLenum pname, GLint param); typedef void(APIENTRYP PFNDOLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params); @@ -348,8 +327,6 @@ typedef void(APIENTRYP PFNDOLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLui extern PFNDOLCLEARBUFFERDATAPROC dolClearBufferData; extern PFNDOLCLEARBUFFERSUBDATAPROC dolClearBufferSubData; -extern PFNDOLDISPATCHCOMPUTEPROC dolDispatchCompute; -extern PFNDOLDISPATCHCOMPUTEINDIRECTPROC dolDispatchComputeIndirect; extern PFNDOLFRAMEBUFFERPARAMETERIPROC dolFramebufferParameteri; extern PFNDOLGETFRAMEBUFFERPARAMETERIVPROC dolGetFramebufferParameteriv; extern PFNDOLGETINTERNALFORMATI64VPROC dolGetInternalformati64v; @@ -378,8 +355,6 @@ extern PFNDOLVERTEXBINDINGDIVISORPROC dolVertexBindingDivisor; #define glClearBufferData dolClearBufferData #define glClearBufferSubData dolClearBufferSubData -#define glDispatchCompute dolDispatchCompute -#define glDispatchComputeIndirect dolDispatchComputeIndirect #define glFramebufferParameteri dolFramebufferParameteri #define glGetFramebufferParameteriv dolGetFramebufferParameteriv #define glGetInternalformati64v dolGetInternalformati64v