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:
@@ -1226,6 +1226,16 @@ void Texture::setMaxAnisotropy(float anis)
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::bindToImageUnit(unsigned int unit, GLenum access, GLenum format, int level, bool layered, int layer)
|
||||
{
|
||||
_imageAttachment.unit = unit;
|
||||
_imageAttachment.level = level;
|
||||
_imageAttachment.layered = layered ? GL_TRUE : GL_FALSE;
|
||||
_imageAttachment.layer = layer;
|
||||
_imageAttachment.access = access;
|
||||
_imageAttachment.format = format;
|
||||
dirtyTextureParameters();
|
||||
}
|
||||
|
||||
/** Force a recompile on next apply() of associated OpenGL texture objects.*/
|
||||
void Texture::dirtyTextureObject()
|
||||
@@ -1741,6 +1751,19 @@ void Texture::applyTexParameters(GLenum target, State& state) const
|
||||
}
|
||||
}
|
||||
|
||||
// Apply image load/store attributes
|
||||
if (extensions->isBindImageTextureSupported() && _imageAttachment.access!=0)
|
||||
{
|
||||
TextureObject* tobj = getTextureObject(contextID);
|
||||
if (tobj)
|
||||
{
|
||||
extensions->glBindImageTexture(
|
||||
_imageAttachment.unit, tobj->id(), _imageAttachment.level,
|
||||
_imageAttachment.layered, _imageAttachment.layer, _imageAttachment.access,
|
||||
_imageAttachment.format!=0 ? _imageAttachment.format : _internalFormat);
|
||||
}
|
||||
}
|
||||
|
||||
getTextureParameterDirty(state.getContextID()) = false;
|
||||
|
||||
}
|
||||
@@ -2590,6 +2613,8 @@ Texture::Extensions::Extensions(unsigned int contextID)
|
||||
if (_glTexParameterIiv == NULL) setGLExtensionFuncPtr(_glTexParameterIiv, "glTexParameterIivEXT");
|
||||
if (_glTexParameterIuiv == NULL) setGLExtensionFuncPtr(_glTexParameterIuiv, "glTexParameterIuivEXT");
|
||||
|
||||
setGLExtensionFuncPtr(_glBindImageTexture, "glBindImageTexture", "glBindImageTextureARB");
|
||||
|
||||
_isTextureMaxLevelSupported = ( getGLVersionNumber() >= 1.2f );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user