DispatchCompute 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
  2. * Copyright (C) 2017 Julien Valentin
  3. *
  4. * This library is open source and may be redistributed and/or modified under
  5. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  6. * (at your option) any later version. The full license is in LICENSE file
  7. * included with this distribution, and on the openscenegraph.org website.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * OpenSceneGraph Public License for more details.
  13. */
  14. #ifndef OSG_DispatchCompute
  15. #define OSG_DispatchCompute 1
  16. #include <osg/Export>
  17. #include <osg/Geometry>
  18. namespace osg
  19. {
  20. /** Wrapper around glDispatchCompute.*/
  21. class OSG_EXPORT DispatchCompute : public osg::Drawable
  22. {
  23. public:
  24. DispatchCompute(GLint numGroupsX=0, GLint numGroupsY=0, GLint numGroupsZ=0):
  25. Drawable(),
  26. _numGroupsX(numGroupsX),
  27. _numGroupsY(numGroupsY),
  28. _numGroupsZ(numGroupsZ)
  29. {}
  30. DispatchCompute(const DispatchCompute&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  31. META_Node(osg, DispatchCompute);
  32. virtual void compileGLObjects(RenderInfo&) const {}
  33. virtual VertexArrayState* createVertexArrayStateImplememtation(RenderInfo&) const { return 0; }
  34. virtual void drawImplementation(RenderInfo& renderInfo) const;
  35. /** Set compute shader work groups */
  36. void setComputeGroups( GLint numGroupsX, GLint numGroupsY, GLint numGroupsZ ) { _numGroupsX=numGroupsX; _numGroupsY=numGroupsY; _numGroupsZ=numGroupsZ; }
  37. /** Get compute shader work groups */
  38. void getComputeGroups( GLint& numGroupsX, GLint& numGroupsY, GLint& numGroupsZ ) const{ numGroupsX=_numGroupsX; numGroupsY=_numGroupsY; numGroupsZ=_numGroupsZ; }
  39. protected:
  40. GLint _numGroupsX, _numGroupsY, _numGroupsZ;
  41. };
  42. }
  43. #endif