MeshManager : option to avoid reading back from vram

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
ghoulsblade
Halfling
Posts: 86
Joined: Sun Mar 05, 2006 2:55 pm
Location: Germany
x 2

MeshManager : option to avoid reading back from vram

Post by ghoulsblade »

Hi !

Ogre::HardwareVertexBuffer and HardwareIndexBuffer have a "bool useShadowBuffer" in the constructor for better reading speed by keeping a copy of the vertexdata in main-ram as well, an option in the MeshManager to enable that by default when loading meshes from file would be nice.

read access to meshdata is often needed for batching and for things like mousepicking and physics as well, maybe even for mesh-animation.

edit : can the shadowbuffers be safely read from a thread ? this would allow collecting batch-data in a main-ram buffer in the background before sending it to the gpu.
User avatar
ghoulsblade
Halfling
Posts: 86
Joined: Sun Mar 05, 2006 2:55 pm
Location: Germany
x 2

Post by ghoulsblade »

i just ran into an interesting problem.
when meshes are only used to be assembled in batches, there is no real need to ever load the original mesh-data into vram, but there is currently no way to loading an ogre mesh to ram instead of vram, except for writing a custom mesh loader.
inheriting from the existing meshloader (Ogre::MeshSerializerImpl) is not possible for two reasons :
a) it is _OgrePrivate (class _OgrePrivate MeshSerializerImpl : public Serializer)
b) the file-format-logic isn't seperated from MeshBuffer allocation/writing

one solution i could imagine, is a special option for the HardwareBufferManager to not allocate anything in vram, and only keep it in CPU-ram.
The Ogre::HardwareBuffer constructor parameter "systemMemory" hints at this being at least partially implemented, but i couldn't find any docs or options for HardwareBufferManager or MeshManager to use this when loading, but i think it would be a nice addition for some cases.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Re: MeshManager : option to avoid reading back from vram

Post by xavier »

ghoulsblade wrote: edit : can the shadowbuffers be safely read from a thread ?
Shadowbuffers do not update from VRAM, so they are true read-only resources -- and anything that is read-only is 100% thread-safe.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

ghoulsblade wrote:i just ran into an interesting problem.
when meshes are only used to be assembled in batches, there is no real need to ever load the original mesh-data into vram, but there is currently no way to loading an ogre mesh to ram instead of vram, except for writing a custom mesh loader.
inheriting from the existing meshloader (Ogre::MeshSerializerImpl) is not possible for two reasons :
a) it is _OgrePrivate (class _OgrePrivate MeshSerializerImpl : public Serializer)
b) the file-format-logic isn't seperated from MeshBuffer allocation/writing

one solution i could imagine, is a special option for the HardwareBufferManager to not allocate anything in vram, and only keep it in CPU-ram.
The Ogre::HardwareBuffer constructor parameter "systemMemory" hints at this being at least partially implemented, but i couldn't find any docs or options for HardwareBufferManager or MeshManager to use this when loading, but i think it would be a nice addition for some cases.
http://www.ogre3d.org/docs/api/html/cla ... hManagera3

Load your meshes at your leisure, with the usage flags you need to put it into system RAM.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
ghoulsblade
Halfling
Posts: 86
Joined: Sun Mar 05, 2006 2:55 pm
Location: Germany
x 2

Post by ghoulsblade »

ah, cool, this solves the first problem i posted here, thanks =)

but the second one (avoiding allocation of vram) remains,

possible usage flags are

Code: Select all

HBU_STATIC 	HBU_DYNAMIC 	HBU_WRITE_ONLY 	HBU_DISCARDABLE 	HBU_STATIC_WRITE_ONLY 	HBU_DYNAMIC_WRITE_ONLY 	HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE 
but all of them are for VRAM, and

Code: Select all

		bool  	vertexBufferShadowed = true,
		bool  	indexBufferShadowed = true
only allows me to make a COPY of the data in RAM, but not to avoid loading it to vram.

i meant the Ogre::HardwareBuffer constructor parameter systemMemory

Code: Select all

Ogre::HardwareBuffer::HardwareBuffer  	(   	Usage   	 usage,
		bool  	systemMemory,
		bool  	useShadowBuffer
	)  
would be interesting for that, but they aren't meant to be constructed directly, and i couldn't find anything for that in the HardwareBufferManager...
Post Reply