From Wang Rui, "In the attached files I've added the Compute Shader support for OSG, as well as serializer updates and a new osgcomputeshaders example. My submission also include a setComputeGroups() function in Program for setting compute-shader work groups, and a bindToImageUnit() function in Texture for binding textures as image variables in shaders.
All code are tested on Windows 7 + NVIDIA GFX 570 with the latest GeForce 310.70 Driver (BETA), which could support OpenGL 4.3. Compute shader information can be found at "http://www.opengl.org/registry/specs/ARB/compute_shader.txt" "
This commit is contained in:
@@ -442,6 +442,28 @@ typedef char GLchar;
|
||||
#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
|
||||
#endif
|
||||
|
||||
// ARB_compute_shader
|
||||
#ifndef GL_ARB_compute_shader
|
||||
#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_LOCAL_INVOCATIONS 0x90EB
|
||||
#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
|
||||
#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
|
||||
#define GL_COMPUTE_LOCAL_WORK_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
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_depth_clamp
|
||||
#define GL_DEPTH_CLAMP 0x864F
|
||||
#endif
|
||||
@@ -689,6 +711,8 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
||||
// ARB_shader_atomic_counters
|
||||
void glGetActiveAtomicCounterBufferiv( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params ) const;
|
||||
|
||||
// ARB_compute_shader
|
||||
void glDispatchCompute( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ ) const;
|
||||
|
||||
protected:
|
||||
~GL2Extensions() {}
|
||||
@@ -855,6 +879,7 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
||||
typedef void (GL_APIENTRY * UniformMatrix3x4dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
|
||||
typedef void (GL_APIENTRY * UniformMatrix4x3dvProc)( GLint location, GLsizei count, GLboolean transpose, const GLdouble* value );
|
||||
typedef void (GL_APIENTRY * GetActiveAtomicCounterBufferivProc)( GLuint program, GLuint bufferIndex, GLenum pname, GLint* params );
|
||||
typedef void (GL_APIENTRY * DispatchComputeProc)( GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ );
|
||||
|
||||
BlendEquationSeparateProc _glBlendEquationSeparate;
|
||||
DrawBuffersProc _glDrawBuffers;
|
||||
@@ -1020,6 +1045,9 @@ class OSG_EXPORT GL2Extensions : public osg::Referenced
|
||||
|
||||
// ARB_shader_atomic_counters
|
||||
GetActiveAtomicCounterBufferivProc _glGetActiveAtomicCounterBufferiv;
|
||||
|
||||
// ARB_compute_shader
|
||||
DispatchComputeProc _glDispatchCompute;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user