Jump to content
  • Advertisement
Sign in to follow this  
freeworld

[HLSL] first time with MRT's

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

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
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]

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 [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]

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!