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:
parent
104b2dfc72
commit
a45c4c8f39
@ -181,18 +181,16 @@ struct IndirectTarget
|
|||||||
: maxTargetQuantity(0)
|
: maxTargetQuantity(0)
|
||||||
{
|
{
|
||||||
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
|
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
|
||||||
|
indirectCommands->getBufferObject()->setUsage(GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
IndirectTarget( AggregateGeometryVisitor* agv, osg::Program* program )
|
IndirectTarget( AggregateGeometryVisitor* agv, osg::Program* program )
|
||||||
: geometryAggregator(agv), drawProgram(program), maxTargetQuantity(0)
|
: geometryAggregator(agv), drawProgram(program), maxTargetQuantity(0)
|
||||||
{
|
{
|
||||||
indirectCommands = new osg::DefaultIndirectCommandDrawArrays;
|
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 )
|
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 = new osg::TextureBuffer(indirectCommands);
|
||||||
indirectCommandTextureBuffer->setInternalFormat( GL_R32I );
|
indirectCommandTextureBuffer->setInternalFormat( GL_R32I );
|
||||||
indirectCommandTextureBuffer->bindToImageUnit(index, osg::Texture::READ_WRITE);
|
indirectCommandTextureBuffer->bindToImageUnit(index, osg::Texture::READ_WRITE);
|
||||||
|
@ -25,7 +25,7 @@ namespace osg {
|
|||||||
class OSG_EXPORT IndirectCommandDrawArrays: public BufferData
|
class OSG_EXPORT IndirectCommandDrawArrays: public BufferData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IndirectCommandDrawArrays():BufferData(){}
|
IndirectCommandDrawArrays():BufferData(){setBufferObject(new DrawIndirectBufferObject());}
|
||||||
IndirectCommandDrawArrays(const IndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
|
IndirectCommandDrawArrays(const IndirectCommandDrawArrays& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
|
||||||
:BufferData(copy, copyop){ }
|
:BufferData(copy, copyop){ }
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
class OSG_EXPORT IndirectCommandDrawElements: public BufferData
|
class OSG_EXPORT IndirectCommandDrawElements: public BufferData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IndirectCommandDrawElements():BufferData(){}
|
IndirectCommandDrawElements():BufferData(){setBufferObject(new DrawIndirectBufferObject());}
|
||||||
IndirectCommandDrawElements(const IndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
|
IndirectCommandDrawElements(const IndirectCommandDrawElements& copy,const CopyOp& copyop/*=CopyOp::SHALLOW_COPY*/)
|
||||||
:BufferData(copy, copyop){}
|
:BufferData(copy, copyop){}
|
||||||
|
|
||||||
@ -147,8 +147,9 @@ public:
|
|||||||
/// set command array of this indirect primitive set
|
/// set command array of this indirect primitive set
|
||||||
inline void setIndirectCommandArray(IndirectCommandDrawElements*idc) {
|
inline void setIndirectCommandArray(IndirectCommandDrawElements*idc) {
|
||||||
_indirectCommandArray = idc;
|
_indirectCommandArray = idc;
|
||||||
if(!_indirectCommandArray->getBufferObject())
|
//ensure bo of idc is of the correct type
|
||||||
_indirectCommandArray->setBufferObject(new osg::DrawIndirectBufferObject());
|
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
|
||||||
|
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
|
||||||
}
|
}
|
||||||
/// get command array of this indirect primitive set
|
/// get command array of this indirect primitive set
|
||||||
inline IndirectCommandDrawElements* getIndirectCommandArray() { return _indirectCommandArray; }
|
inline IndirectCommandDrawElements* getIndirectCommandArray() { return _indirectCommandArray; }
|
||||||
@ -655,8 +656,9 @@ public:
|
|||||||
|
|
||||||
inline void setIndirectCommandArray(IndirectCommandDrawArrays*idc) {
|
inline void setIndirectCommandArray(IndirectCommandDrawArrays*idc) {
|
||||||
_indirectCommandArray = idc;
|
_indirectCommandArray = idc;
|
||||||
if(!_indirectCommandArray->getBufferObject())
|
//ensure bo of idc is of the correct type
|
||||||
_indirectCommandArray->setBufferObject(new osg::DrawIndirectBufferObject());
|
if(!dynamic_cast<DrawIndirectBufferObject* >(_indirectCommandArray->getBufferObject()))
|
||||||
|
_indirectCommandArray->setBufferObject(new DrawIndirectBufferObject());
|
||||||
}
|
}
|
||||||
inline const IndirectCommandDrawArrays* getIndirectCommandArray() const {
|
inline const IndirectCommandDrawArrays* getIndirectCommandArray() const {
|
||||||
return _indirectCommandArray;
|
return _indirectCommandArray;
|
||||||
|
Loading…
Reference in New Issue
Block a user