[HLSL] first time with MRT's

Started by
2 comments, last by Tordin 12 years, 8 months ago
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?
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Advertisement

Hello Freeworld,

[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?[/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.
[color=#1C2837][size=2]

[color=#1C2837][size=2]

[color=#1C2837][size=2]
[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?[color=#1C2837][size=2][/quote]
[color=#1C2837][size=2]

[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.
[color=#1C2837][size=2]

[color=#1C2837][size=2]

[color=#1C2837][size=2]
[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? [color=#1C2837][size=2][/quote]
[color=#1C2837][size=2]

[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.
[color=#1C2837][size=2]

[color=#1C2837][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=#1C2837][size=2]

[color=#1C2837][size=2]

[color=#1C2837][size=2]
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 [font=Consolas, Courier, monospace][size=2]DXGI_FORMAT_R8G8B8A8_UNORM surface would result in (1,1,1,1) being stored.[/font]
[font=Consolas, Courier, monospace][size=2]
[/font]
[font=Consolas, Courier, monospace][size=2]Cheers![/font]
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.
"There will be major features. none to be thought of yet"

This topic is closed to new replies.

Advertisement