set DIBO of the drawcommandarray directly in their interface constructor

it makes osggpu use case lighter + drawcommandarray can't exist without a BO
This commit is contained in:
mp3butcher 2017-07-27 12:27:55 +02:00
parent 104b2dfc72
commit a45c4c8f39
2 changed files with 10 additions and 10 deletions

View File

@ -181,18 +181,16 @@ struct IndirectTarget
: maxTargetQuantity(0)
{
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW);
}
IndirectTarget( AggregateGeometryVisitor* agv, osg::Program* program )
: geometryAggregator(agv), drawProgram(program), maxTargetQuantity(0)
{
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW);
}
void endRegister(unsigned int index, unsigned int rowsPerInstance, GLenum pixelFormat, GLenum type, GLint internalFormat, bool useMultiDrawArraysIndirect )
{
osg::DrawIndirectBufferObject * indirectCommandbuffer = new osg::DrawIndirectBufferObject();
indirectCommandbuffer->setUsage(GL_DYNAMIC_DRAW);
indirectCommands->setBufferObject(indirectCommandbuffer);
indirectCommandTextureBuffer = new osg::TextureBuffer(indirectCommands);
indirectCommandTextureBuffer->setInternalFormat( GL_R32I );
indirectCommandTextureBuffer->bindToImageUnit(index, osg::Texture::READ_WRITE);

View File

@ -25,7 +25,7 @@ namespace osg {
class OSG_EXPORT IndirectCommandDrawArrays: public BufferData
{
public:
IndirectCommandDrawArrays():BufferData(){}
IndirectCommandDrawArrays():BufferData(){setBufferObject(new DrawIndirectBufferObject());}
IndirectCommandDrawArrays(const IndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
:BufferData(copy, copyop){ }
@ -40,7 +40,7 @@ public:
class OSG_EXPORT IndirectCommandDrawElements: public BufferData
{
public:
IndirectCommandDrawElements():BufferData(){}
IndirectCommandDrawElements():BufferData(){setBufferObject(new DrawIndirectBufferObject());}
IndirectCommandDrawElements(const IndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
:BufferData(copy, copyop){}
@ -147,8 +147,9 @@ public:
/// set command array of this indirect primitive set
inline void setIndirectCommandArray(IndirectCommandDrawElements*idc) {
_indirectCommandArray = idc;
if(!_indirectCommandArray->getBufferObject())
_indirectCommandArray->setBufferObject(new osg::DrawIndirectBufferObject());
//ensure bo of idc is of the correct type
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
}
/// get command array of this indirect primitive set
inline IndirectCommandDrawElements* getIndirectCommandArray() { return _indirectCommandArray; }
@ -655,8 +656,9 @@ public:
inline void setIndirectCommandArray(IndirectCommandDrawArrays*idc) {
_indirectCommandArray = idc;
if(!_indirectCommandArray->getBufferObject())
_indirectCommandArray->setBufferObject(new osg::DrawIndirectBufferObject());
//ensure bo of idc is of the correct type
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
}
inline const IndirectCommandDrawArrays* getIndirectCommandArray() const {
return _indirectCommandArray;