[Solved][2.1] GPU -> CPU options

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
User avatar
mmixLinus
Silver Sponsor
Silver Sponsor
Posts: 199
Joined: Thu Apr 21, 2011 3:08 pm
Location: Lund, Sweden
x 12
Contact:

[Solved][2.1] GPU -> CPU options

Post by mmixLinus »

Hi, what are the current (Ogre 2.1) options to retrieve data from the GPU?

(FYI, I am using a couple of custom HlmUnlit, hlsl materials. One of the materials currently uses a Geometry Shader.)
  • I want to make a GPU mouse picker. The GPU will render my scene, and should collect the vertices that are within a certain radius from the mouse (ray). My vertex shader already shows which vertices fall inside this criterion (because I highlight them), but where and how do I write these to a buffer/target?.
One idea is to use MRT (Multiple Render Targets). I could output some data related to the selected vertices to a secondary, low resolution (non render window) target. Is that possible, or does this secondary target need to be the same format as my render window? If I "render" some data to a low-res rtt, it wouldn't be too much work for the CPU to scan it, to extract the information. Sounds a bit convoluted..

Or, should I be using:

Code: Select all

m_vao->readRequests(m_request);
m_vao->mapAsyncTickets(m_request);
based on a vertex buffer that I somehow update?

I currently set a couple of textures, the first is one I use for texturing. The second I am guessing I can read back

Code: Select all

	unsigned int w = 100;
	unsigned int h = 100;
	m_spMouseRTTTexture = Ogre::TextureManager::getSingleton().createManual("mouseRTT", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		Ogre::TEX_TYPE_2D, w, h, 0, Ogre::PF_R8G8B8A8, Ogre::TU_RENDERTARGET /*Ogre::TU_UAV_NOT_TEXTURE*/ );// , nullptr, false, AALevel);
	// ...
	// ...
	datablock->setTexture(0, 0, m_spStarsTexture);
	datablock->setTexture(0, 1, m_spMouseRTTTexture);
	Ogre::RenderTarget *mouseRT = m_spMouseRTTTexture->getBuffer()->getRenderTarget();

	// now what? What is the correct way to set mouseRT and make my Unlit material use it?
And reading back - I have seen examples of people using blitToMemory() in frameEnded - but this doesn't sound very 2.1.

Thanks! /mmixLinus
Last edited by mmixLinus on Tue Apr 25, 2017 3:19 pm, edited 1 time in total.
Powered by Ogre3D:
MMiX.Me 3D - 3D Music Player
Galaxy Navigator 3D - 2 million stars (ESA's Gaia satellite)
YouTube|Facebook
User avatar
mmixLinus
Silver Sponsor
Silver Sponsor
Posts: 199
Joined: Thu Apr 21, 2011 3:08 pm
Location: Lund, Sweden
x 12
Contact:

Re: [2.1] GPU -> CPU options

Post by mmixLinus »

I am using blitToMemory() in ::frameEnded() to copy a small texture from GPU to CPU.
Powered by Ogre3D:
MMiX.Me 3D - 3D Music Player
Galaxy Navigator 3D - 2 million stars (ESA's Gaia satellite)
YouTube|Facebook
Post Reply