• Advertisement
Sign in to follow this  

rendering to 3DTexture performance question

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

This is the first time i am rendering to a 3Dtexture, from what i read I can only render to one 2D slice of the 3DTexture with a quad.

I want to render to all the texels so I have to clone those quads and each one renders to a different layer of the 3d texture, so i have this question.

 

When rendering to all the texels of that texture what is faster

- Using drawIndexedInstanced so every intance draws quad to each layer of the 3Dtexture

-Make the geometry shader clone the quads and each one render to different layer

 

the 3Dtexture is 100X100X100

Edited by lomateron

Share this post


Link to post
Share on other sites
Advertisement

Hi!

 

Since you have to specify which slice you want to render into in a geometry shader by using the semantic SV_RenderTargetArrayIndex, I'd suggest to use the geometry shader approach.

I would render 100 vertices as a point list, without actually binding a vertex buffer (so that you get 100 vertex shader invocations).

The vertex shader does nothing.

In the geometry shader you can take the SV_PrimitiveID (in 0..99) to specify the target slice to render into. Expand then a quad (as a triangle strip) with the coordinates (-1,-1,0) (-1,1,0) (1,-1,0) (1,1,0).

The pixel shader receives with SV_Position the texel coordinate in the slice. (Additionally you can pass the SV_PrimitiveID from the geometry shader to the pixel shader, if you need the slice id.)

Be careful, though, because SV_Position comes in as float, so better cast it to int.

 

You can also use a compute shader, if you want to avoid the rasterization pipeline. (Hard to tell, whether it will be faster, since you'd need to switch from the rasterization pipeline to the compute pipeline and back. If I recall correctly, I heard in a talk at gamefest someone mentioning that frequent switches are to avoid.)

 

Cheers!

Share this post


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

  • Advertisement