Sign in to follow this  
freeworld

[HLSL] first time with MRT's

Recommended Posts

Need just a quick clarification on a few things.

1: When setting multiple render targets, do they reset after calling draw primitive. Or do I have to call something like SetRenderTarget(index, NULL) ? to get rid of any extra render targets?

2: In the pixel shader, do you have to output the same amount of values as the amount of render targets you set?

ie you set three render targets but only output 2 float4's, will that cause problems, or even if you output 4 float4's but only 2 render targets?

3: does the hlsl compiler, for lack of better words, normalize values that must be within a certain range... ie if output float4(655, 577, 878, 900) as a color value, will they retain they're value?

Share this post


Link to post
Share on other sites

Hello Freeworld,

[quote][color=#1C2837][size=2]When setting multiple render targets, do they reset after calling draw primitive. Or do I have to call something like SetRenderTarget(index, NULL) ? to get rid of any extra render targets?[/size][/color][/quote]


No, any draw call won't change the state of the device, so all your render targets remain bound in the way they were until you call [color=#1C2837][size=2]SetRenderTarget(index, NULL) or a device state reset/change.[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2][quote][/size][/color][color=#1C2837][size=2]2: In the pixel shader, do you have to output the same amount of values as the amount of render targets you set?[/size][/color][color=#1C2837][size=2][/quote][/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]I think not writing not every SV_Target# register that is bound should work, the device might store a warning in its message queue, but the draw call will probably succeed. However the SV_Target registers that aren't getting written, will remain unchanged (pertain their values). If you write to more SV_Target registers than are bound, should work aswell, but again with a warning.[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2][quote][/size][/color][color=#1C2837][size=2]3: does the hlsl compiler, for lack of better words, normalize values that must be within a certain range... ie if output float4(655, 577, 878, 900) as a color value, will they retain they're value? [/size][/color][color=#1C2837][size=2][/quote][/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]No, fxc.exe will not do that for you, because it doesn't know what the format is of render target that is ought to be bound to the device. The DeviceContext will probably clamp the values the fall beyond the domain.[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[size="2"][color="#1c2837"]BTW, you can always profile your own application with PIX for example (use a debug-flagged device though) and see what happens. It also allows you to see the state of the entire device between each draw call for example[/color][/size]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]
[/size][/color]

Share this post


Link to post
Share on other sites
2 - I haven't had problems or messages from not writing to bound render target
3 - values will be clamped automatically to fit in the render target format. Ie. [color=#1C2837][size=2] float4(655, 577, 878, 900) on [/size][/color][font=Consolas, Courier, monospace][size=2]DXGI_FORMAT_R8G8B8A8_UNORM surface would result in (1,1,1,1) being stored.[/size][/font]
[font=Consolas, Courier, monospace][size=2]
[/size][/font]
[font=Consolas, Courier, monospace][size=2]Cheers![/size][/font]

Share this post


Link to post
Share on other sites
Question 2:

You can only write to SV_TARGET0->7 and you can write to them without bounding any RT´s from the cpu.
You will only get a warningmessage if you have the debugger on.

Share this post


Link to post
Share on other sites

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