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:
Robert Osfield
2013-01-25 11:54:03 +00:00
parent f6450a1123
commit 26a8f63212
16 changed files with 397 additions and 4 deletions

View File

@@ -77,6 +77,30 @@ static bool writeShaders( osgDB::OutputStream& os, const osg::Program& attr )
return true;
}
// _numGroupsX/Y/Z
static bool checkComputeGroups( const osg::Program& attr )
{
GLint numX = 0, numY = 0, numZ = 0;
attr.getComputeGroups( numX, numY, numZ );
return numX>0 && numY>0 && numZ>0;
}
static bool readComputeGroups( osgDB::InputStream& is, osg::Program& attr )
{
GLint numX = 0, numY = 0, numZ = 0;
is >> numX >> numY >> numZ;
attr.setComputeGroups( numX, numY, numZ );
return true;
}
static bool writeComputeGroups( osgDB::OutputStream& os, const osg::Program& attr )
{
GLint numX = 0, numY = 0, numZ = 0;
attr.getComputeGroups( numX, numY, numZ );
os << numX << numY << numZ << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( Program,
new osg::Program,
osg::Program,
@@ -88,4 +112,8 @@ REGISTER_OBJECT_WRAPPER( Program,
ADD_USER_SERIALIZER( GeometryVerticesOut ); // _geometryVerticesOut
ADD_USER_SERIALIZER( GeometryInputType ); // _geometryInputType
ADD_USER_SERIALIZER( GeometryOutputType ); // _geometryOutputType
{
UPDATE_TO_VERSION_SCOPED( 95 )
ADD_USER_SERIALIZER( ComputeGroups ); // _numGroupsX/Y/Z
}
}