add ComputeDispatch class
revoke glDispatch in PCProgram::useProgram update example
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
// This example can work only if GL version is 4.3 or greater
|
||||
|
||||
#include <osg/Texture2D>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/ComputeDispatch>
|
||||
#include <osg/Geode>
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
@@ -57,14 +57,12 @@ int main( int argc, char** argv )
|
||||
// The compute shader can't work with other kinds of shaders
|
||||
// It also requires the work group numbers. Setting them to 0 will disable the compute shader
|
||||
osg::ref_ptr<osg::Program> computeProg = new osg::Program;
|
||||
computeProg->setComputeGroups( 512/16, 512/16, 1 );
|
||||
computeProg->addShader( new osg::Shader(osg::Shader::COMPUTE, computeSrc) );
|
||||
|
||||
// Create a node for outputting to the texture.
|
||||
// It is OK to have just an empty node here, but seems inbuilt uniforms like osg_FrameTime won't work then.
|
||||
// TODO: maybe we can have a custom drawable which also will implement glMemoryBarrier?
|
||||
osg::ref_ptr<osg::Node> sourceNode = osgDB::readRefNodeFile("axes.osgt");
|
||||
if ( !sourceNode ) sourceNode = new osg::Node;
|
||||
osg::ref_ptr<osg::Node> sourceNode = new osg::ComputeDispatch(512/16, 512/16, 1 );
|
||||
sourceNode->setDataVariance( osg::Object::DYNAMIC );
|
||||
sourceNode->getOrCreateStateSet()->setAttributeAndModes( computeProg.get() );
|
||||
sourceNode->getOrCreateStateSet()->addUniform( new osg::Uniform("targetTex", (int)0) );
|
||||
|
||||
Reference in New Issue
Block a user