• Advertisement
Sign in to follow this  

Render to Vertex Buffer

This topic is 4038 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement