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

@@ -70,6 +70,30 @@ static bool writeInternalFormat( osgDB::OutputStream& os, const osg::Texture& te
return true;
}
// _imageAttachment
static bool checkImageAttachment( const osg::Texture& attr )
{
return attr.getImageAttachment().access!=0;
}
static bool readImageAttachment( osgDB::InputStream& is, osg::Texture& attr )
{
osg::Texture::ImageAttachment attachment;
is >> attachment.unit >> attachment.level >> attachment.layered
>> attachment.layer >> attachment.access >> attachment.format;
attr.bindToImageUnit( attachment.unit, attachment.access, attachment.format,
attachment.level, attachment.layered!=GL_FALSE, attachment.layer );
return true;
}
static bool writeImageAttachment( osgDB::OutputStream& os, const osg::Texture& attr )
{
const osg::Texture::ImageAttachment& attachment = attr.getImageAttachment();
os << attachment.unit << attachment.level << attachment.layered
<< attachment.layer << attachment.access << attachment.format << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( Texture,
/*new osg::Texture*/NULL,
osg::Texture,
@@ -127,4 +151,9 @@ REGISTER_OBJECT_WRAPPER( Texture,
END_ENUM_SERIALIZER(); // _shadow_texture_mode
ADD_FLOAT_SERIALIZER( ShadowAmbient, 0.0f ); // _shadow_ambient
{
UPDATE_TO_VERSION_SCOPED( 95 )
ADD_USER_SERIALIZER( ImageAttachment ); // _imageAttachment
}
}