Sign in to follow this  

Viewing vertices transformed by DrawPrimitive

This topic is 2838 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

Is there a way to view the x,y,z values of a vertex in a vertex buffer after the vertex has been transformed by DrawPrimitive in DirectX9? My first thought is to Lock the vertex buffer after the DrawPrimitive call, and just look at the values in the vertex buffer, but unless I'm mistaken the values in the vertex buffer are not changed by the DrawPrimitive call. But that's the type of thing I'm trying to do. How do I look at the verts after the DrawPrimitive call? Or perhaps there is a method that simulates the transformations done by DrawPrimitive so I can see the resultant values of the the transformation pipeline?

Share this post


Link to post
Share on other sites
You can use PIX to ispect geometry before and after the transformations.

In D3D9, you can use ProcessVertices method to transform vertex data without drawing it (but in the CPU, not GPU). In D3D10 and up you could redirect the vertex shader's output to a "stream out buffer" (on GPU) which you can then reuse or download to the main memory.

You can of course also do the transformations yourself on the data. The DX SDK explains the innards of the fixed function pipeline transforms very thoroughly. In simplified terms:

v' = v * model * view * projection * viewport

where v' is the transformed vertex; v is the original vertex; model, view and projection are the transform matrices; and viewport transforms geometry from perspective space to screen space. The viewport transformation can easily be expressed as a matrix, even though it isn't actually set to the device in matrix form.

Share this post


Link to post
Share on other sites
You're correct, the vertex buffer values themselves are not changed by the DrawPrimitive call. The DrawPrimitive call results in the values being converted to screen locations and pixels by a vertex/pixel shader or the fixed function pipeline using the method described by Nik02, and then stored in the screen buffer for display.

You can "process" the vertices yourself to get those screen locations using the formula Nik02 mentions and examine v'.

If you're not sure about the process described, perhaps you can ask a more specific question. Or, if that's not what you're asking about, maybe you can be a bit more descriptive about what you mean by "inspect."

Share this post


Link to post
Share on other sites
Nik02 mentioned:
You can use PIX to [inspect] geometry before and after the transformations.

I am new to using the PIX tool. I checked it out and was able to generate a log of DirectX calls very easily. Yet having gone over all the options, I see no way to inspect the geometry (a vertex buffer) after a DrawPrimitive call.

By inspect I just mean look at the x,y,z values in the vertex buffer.

Share this post


Link to post
Share on other sites
Do a single frame capture, and click on the "render" tab on the right. That'd run all the rendering that's been done, and allow you to view device status, etc. The "mesh" tab IIRC (don't have it in front of me) will show you the vertices before and after transformation.

Share this post


Link to post
Share on other sites
PIX won't change the fact that the pipeline runs in one direction. The T/L pipe or shaders do not change the original geometry inside the vertex buffers. This is true even on D3D10 and up, even though newer APIs offer more flexible options of eventually looping back the geometry.

As Eyal said, PIX enables you to intercept your D3D calls so you see visually what the system does internally. As far as I remember, you cannot dump the intermediate transformed geometry to a file; however, I could be wrong, PIX evolves over time.

If you need the results as a raw data inside your own application, you need to either use the ProcessVertices method of the device object (so the device applies the same transforms as in drawing) or implement the transformation pipeline yourself (by multiplying the original vertices with the various transforms I listed on my first reply). Check the ProcessVertices documentation to see that it requires a separate destination vertex buffer that gets filled with the processed data.

Share this post


Link to post
Share on other sites

This topic is 2838 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this