Merge branch 'ComputeDispatch' of https://github.com/mp3butcher/OpenSceneGraph into mp3butcher-ComputeDispatch
This commit is contained in:
@@ -55,6 +55,7 @@ SET(TARGET_H
|
||||
${HEADER_PATH}/ColorMaski
|
||||
${HEADER_PATH}/ColorMatrix
|
||||
${HEADER_PATH}/ComputeBoundsVisitor
|
||||
${HEADER_PATH}/ComputeDispatch
|
||||
${HEADER_PATH}/ContextData
|
||||
${HEADER_PATH}/ConvexPlanarOccluder
|
||||
${HEADER_PATH}/ConvexPlanarPolygon
|
||||
@@ -267,6 +268,7 @@ SET(TARGET_SRC
|
||||
ColorMaski.cpp
|
||||
ColorMatrix.cpp
|
||||
ComputeBoundsVisitor.cpp
|
||||
ComputeDispatch.cpp
|
||||
ContextData.cpp
|
||||
ConvexPlanarOccluder.cpp
|
||||
ConvexPlanarPolygon.cpp
|
||||
|
||||
16
src/osg/ComputeDispatch.cpp
Normal file
16
src/osg/ComputeDispatch.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <osg/ComputeDispatch>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
ComputeDispatch::ComputeDispatch(const ComputeDispatch&o,const osg::CopyOp& copyop):
|
||||
Drawable(o,copyop),
|
||||
_numGroupsX(o._numGroupsX),
|
||||
_numGroupsY(o._numGroupsY),
|
||||
_numGroupsZ(o._numGroupsZ)
|
||||
{
|
||||
}
|
||||
|
||||
void ComputeDispatch::drawImplementation(RenderInfo& renderInfo) const
|
||||
{
|
||||
renderInfo.getState()->get<GLExtensions>()->glDispatchCompute(_numGroupsX, _numGroupsY, _numGroupsZ);
|
||||
}
|
||||
@@ -92,8 +92,7 @@ void Program::ProgramBinary::assign(unsigned int size, const unsigned char* data
|
||||
|
||||
Program::Program() :
|
||||
_geometryVerticesOut(1), _geometryInputType(GL_TRIANGLES),
|
||||
_geometryOutputType(GL_TRIANGLE_STRIP),
|
||||
_numGroupsX(0), _numGroupsY(0), _numGroupsZ(0), _feedbackmode(GL_SEPARATE_ATTRIBS)
|
||||
_geometryOutputType(GL_TRIANGLE_STRIP), _feedbackmode(GL_SEPARATE_ATTRIBS)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -133,10 +132,6 @@ Program::Program(const Program& rhs, const osg::CopyOp& copyop):
|
||||
_geometryInputType = rhs._geometryInputType;
|
||||
_geometryOutputType = rhs._geometryOutputType;
|
||||
|
||||
_numGroupsX = rhs._numGroupsX;
|
||||
_numGroupsY = rhs._numGroupsY;
|
||||
_numGroupsZ = rhs._numGroupsZ;
|
||||
|
||||
_feedbackmode=rhs._feedbackmode;
|
||||
_feedbackout=rhs._feedbackout;
|
||||
}
|
||||
@@ -173,15 +168,6 @@ int Program::compare(const osg::StateAttribute& sa) const
|
||||
if( _geometryOutputType < rhs._geometryOutputType ) return -1;
|
||||
if( rhs._geometryOutputType < _geometryOutputType ) return 1;
|
||||
|
||||
if( _numGroupsX < rhs._numGroupsX ) return -1;
|
||||
if( rhs._numGroupsX < _numGroupsX ) return 1;
|
||||
|
||||
if( _numGroupsY < rhs._numGroupsY ) return -1;
|
||||
if( rhs._numGroupsY < _numGroupsY ) return 1;
|
||||
|
||||
if( _numGroupsZ < rhs._numGroupsZ ) return -1;
|
||||
if( rhs._numGroupsZ < _numGroupsZ ) return 1;
|
||||
|
||||
if(_feedbackout<rhs._feedbackout) return -1;
|
||||
if(_feedbackmode<rhs._feedbackmode) return -1;
|
||||
|
||||
@@ -386,20 +372,6 @@ GLint Program::getParameter( GLenum pname ) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Program::setComputeGroups( GLint numGroupsX, GLint numGroupsY, GLint numGroupsZ )
|
||||
{
|
||||
_numGroupsX = numGroupsX;
|
||||
_numGroupsY = numGroupsY;
|
||||
_numGroupsZ = numGroupsZ;
|
||||
}
|
||||
|
||||
void Program::getComputeGroups( GLint& numGroupsX, GLint& numGroupsY, GLint& numGroupsZ ) const
|
||||
{
|
||||
numGroupsX = _numGroupsX;
|
||||
numGroupsY = _numGroupsY;
|
||||
numGroupsZ = _numGroupsZ;
|
||||
}
|
||||
|
||||
void Program::addBindAttribLocation( const std::string& name, GLuint index )
|
||||
{
|
||||
_attribBindingList[name] = index;
|
||||
@@ -1108,8 +1080,4 @@ Program::ProgramBinary* Program::PerContextProgram::compileProgramBinary(osg::St
|
||||
void Program::PerContextProgram::useProgram() const
|
||||
{
|
||||
_extensions->glUseProgram( _glProgramHandle );
|
||||
if ( _program->_numGroupsX>0 && _program->_numGroupsY>0 && _program->_numGroupsZ>0 )
|
||||
{
|
||||
_extensions->glDispatchCompute( _program->_numGroupsX, _program->_numGroupsY, _program->_numGroupsZ );
|
||||
}
|
||||
}
|
||||
|
||||
36
src/osgWrappers/serializers/osg/ComputeDispatch.cpp
Normal file
36
src/osgWrappers/serializers/osg/ComputeDispatch.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <osg/ComputeDispatch>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
// _numGroupsX/Y/Z
|
||||
static bool checkComputeGroups( const osg::ComputeDispatch& 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::ComputeDispatch& 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::ComputeDispatch& attr )
|
||||
{
|
||||
GLint numX = 0, numY = 0, numZ = 0;
|
||||
attr.getComputeGroups( numX, numY, numZ );
|
||||
os << numX << numY << numZ << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( ComputeDispatch,
|
||||
new osg::ComputeDispatch,
|
||||
osg::ComputeDispatch,
|
||||
"osg::Object osg::Node osg::Drawable osg::ComputeDispatch" )
|
||||
{
|
||||
ADD_USER_SERIALIZER( ComputeGroups ); // _numGroupsX/Y/Z
|
||||
}
|
||||
@@ -121,29 +121,6 @@ static bool writeFeedBackMode( osgDB::OutputStream& os, const osg::Program& attr
|
||||
os << attr.getTransformFeedBackMode()<< std::endl;
|
||||
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;
|
||||
}
|
||||
|
||||
static bool checkBindUniformBlock( const osg::Program& node )
|
||||
{
|
||||
@@ -190,11 +167,6 @@ REGISTER_OBJECT_WRAPPER( Program,
|
||||
ADD_USER_SERIALIZER( GeometryInputType ); // _geometryInputType
|
||||
ADD_USER_SERIALIZER( GeometryOutputType ); // _geometryOutputType
|
||||
|
||||
{
|
||||
UPDATE_TO_VERSION_SCOPED( 95 )
|
||||
ADD_USER_SERIALIZER( ComputeGroups ); // _numGroupsX/Y/Z
|
||||
}
|
||||
|
||||
{
|
||||
UPDATE_TO_VERSION_SCOPED( 116 )
|
||||
ADD_USER_SERIALIZER( FeedBackVaryingsName );
|
||||
|
||||
Reference in New Issue
Block a user