# [D3D10] Render to Texture

## Recommended Posts

##### Share on other sites
I'm not sure if this is what you want, but look up

"Using the Input-Assembler Stage without Buffers"

in the documentation index.

##### Share on other sites
Hmmm... I just looked up your reference. It is on the right path, but I notice that they still use a vertex shader to render triangles.

The reason why I'm asking this question in the first place is because I have some D3D9/SM3 code that I'm trying to convert to D3D10/SM4. I'll show you some important parts of the D3D9/SM3 code.

Firstly, there is the vertex declaration, which you can see describes a pre-transformed vertex with a single texture coordinate.

struct 2dvertex{	D3DXVECTOR4 xyzw;	D3DXVECTOR2 uv;};
In D3D9, the code uses DrawPrimitiveUp to render the quad. D3D10 doesn't have this, so instead I just build a small vertex and index buffer to render the quad using an indexed draw call. Seems like a total overkill, but not sure of any other way to do it at this stage.

The D3D9 pixel shader uses the following code.

struct pixelinput {	float4 pos : POSITION;	float2 t0 : TEXCOORD0;};float4 ps(pixelinput in) : COLOR{    return float4(0, 0, 1, 1);}technique render {	pass 0	{	 		ZEnable = false;		ZWriteEnable = false;		AlphaBlendEnable = false;    		FVF = XYZRHW | TEX1;    		PixelShader = compile ps_3_0 ps();	}		}
As you can see, there is no vertex shader there. I can't seem to reproduce this in D3D10/SM4.

##### Share on other sites
Your DX9 code is using the fixed function pipeline for vertices. That's why there's no vertex shader. The line in your technique that says "FVF = XYZRHW | TEX1;" is what gives this away. FVF stands for Flexible Vertex Format and is used for the fixed function pipeline. XYZRHW means that the vertices have already been transformed and therefor the code doesn't need to set the associated matrices.

DX10 does not have a fixed function pipeline. You have to include at least a minimal vertex shader. Now, this shader can just be a pass-through if you're using transformed vertices. Your shader could output just the position and texture coordinates exactly as it receives them.

neneboricua

##### Share on other sites
My understanding is that neneboricua19 is correct. Here are a couple of further comments which might help.

I found a comment about 2D drawing at the end of the FixedFuncEMU sample docs. You might want to take a look at it.

You don't need to create an index buffer for a quad. Use a triangle strip representation.

##### Share on other sites
Thank you neneboricua19. I know all about the lack of a FFP in D3D10, I just can't believe I overlooked that. Thanks for pointing that out.

ET3D, you have raised a good point about using a triangle strip. I'll do that and get rid of the index buffer. However, I couldn't find the reference you were speaking of. I looked up the FixedFuncEMU sample documentation and had a read through it, but couldn't find what you may have been referring to. Were you just referring to the triangle strip here? If not, can you provide some more details on the information you refer to. Thanks.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627662
• Total Posts
2978519

• 10
• 10
• 12
• 22
• 13