Skip to main content
gamedev.net
🔒 Locked

Render to Vertex Buffer

Started by 51mon 5 replies 3.4k views
Original Post
51mon
51mon
I’m doing some hardware instancing and the data that constitute the auxiliary stream is already in GPU memory. For the moment I solve this by first rendering the wanted data to textures, sending it to system memory, creating the auxiliary stream and sending it back to GPU memory again. I was thinking that there might be some better method. I have looked at the IDirect3DDevice9::ProcessVertices method but as I can understand, it only operates in software? I also found R2VB but it only works on ATI cards, right (I got nVidia)? In DX10 this would have been a simple task but I’m using DX9. So is there any hacks, can I render to vertex buffer in DX9 with nVidia cards? I have had small thoughts about using textures as stream sources? I was thinking there might be some way since a D3DFMT_A32B32G32R32F texture and a D3DXVECTOR4 stream has the same structure of there data. Is there some dirty trick, or has MS put a lock on these kinds of operations? Thanks
Sc4Freak
Sc4Freak
I think what you might be looking for is Vertex Texture Fetch (VTF). It allows a vertex shader to do texture lookups. However, current ATI cards don't support this feature (which is why you'd use R2VB on ATI cards to simulate VTF).
51mon
51mon
Quote:
Original post by Sc4Freak
I think what you might be looking for is Vertex Texture Fetch (VTF). It allows a vertex shader to do texture lookups. However, current ATI cards don't support this feature (which is why you'd use R2VB on ATI cards to simulate VTF).


Yeah I have been thinking about that. But in this case I need to do 3 Tex2Dlod for every instance, send these values to the pixel shader and also do several operations on the data to obtain a matrix which I transform the mesh with. With VTF I have to do this process once for every vertex instead of now when I only do it once per instance, am I right about this? So I don't think I gain from it.
ET3D
ET3D
I think there was a mention of NVIDIA drivers supporting R2BV. On Vista, maybe? I hope I didn't just imagine this. Maybe someone with a better memory can comment.
51mon
51mon
One thing that made me think that it was possible to do R2VB on nVidia was these 2 publications.

Publication 1

Publication 2

Maybe they are just talking about VTF?

[Edited by - 51mon on January 29, 2007 4:23:22 AM]
remigius
remigius
In the GeoClipMapping article in GPU Gems 2 there also was some mention of 'using Render-to-Vertex-Array'. It's an NVidia book and I also recall seeing that technique mentioned in other NVidia sources, so it might indicate they obscurely support it. On the other hand, this specific article was written by MS folks, so they just might be pointing out alternatives.

Some form of R2VB will be supported by all Vista (SM4) hardware though, at least that's what I've been told when I asked a similar question. D3D10/SM4 supports stream rerouting to and from various resources, so you can set up your shader pipeline to do something equivalent to both VTF and R2VB. I hope the R2VB-equivalent is feasible on SM4 hardware; from what I've heard VTF is quite slow, plus VTF is applied every frame while R2VB offers more control.
jollyjeffers
jollyjeffers
From what I've seen, I don't think there are any easy ways of doing this with D3D9, at least not without falling to device-dependent features...

You might want to look into the GPGPU side of things for this sort of job - they tend to "hack" general purpose computations on top of the D3D/OGL API's (until CUDA/CTM appeared) and might have some nifty tricks for uploading arbitrary data and pulling it back again...

Quote:
Original post by remigius
In the GeoClipMapping article in GPU Gems 2 there also was some mention of 'using Render-to-Vertex-Array'.
I could be wrong, but I think the 'Render to vertex array' feature is the OpenGL equivalent of VTF/R2VB...

Quote:
Original post by remigius
Some form of R2VB will be supported by all Vista (SM4) hardware though, at least that's what I've been told when I asked a similar question. D3D10/SM4 supports stream rerouting to and from various resources, so you can set up your shader pipeline to do something equivalent to both VTF and R2VB.
VTF is supported as a basic feature in D3D10 - simply because you can bind a texture as an input to any of the three programmable stages.

Strem re-routing is via the GS with SO but it has its limitations - iirc it only allows for 1024 4xFP32 values to be written out, which may not be enough for complex models. The GS can be used with RT arrays to implement a form of scatter-writing which could get you close to R2VB - but I've not tried that or R2VB (don't use ATI hw) so I could be wrong.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.