Sign in to follow this  
Deft

Using input layout in DirectX

Recommended Posts

Deft    226
Hello all again!

I'm interested in working with DirectX, but during researching this wonderful library I've got so much questions. At now first of questions is working with input layout and switching between different layouts for rendering difference game objects.
I can explain my question with example (very-very abstract example):[list=1]
[*]Let assume that I want to render player object at first pass. During player rendering I use shadows and lightning, and may be another graphics improvements;
[*]Then I want to render road with using of tessellation;
[*]After that I want to spawn game world NPCs.
[/list]
So, at first pass I use something like:
[source lang="cpp"]// Compiling shaders
context->IASetInputLayout(...); // Setting input layout with using custom vertex shader
// Rendering an object[/source]
Then I go to render road. And stop... Road isn't like a player. Let assume that I want to render it fast, without shadows and with tessellation. For doing such thing, I need to switch input layout - load and compile hull/domain shaders, change vertex shader and reset my input layout to new state for using new shader group.
After doing that I need return to shader from first pass to render NPCs. So, I call context->IASetInputLayout again... And so on, and so on.

Is it normal to switch between different input layouts during object rendering? Or may be I need to improve rendering sequence? Or I doing something wrong and input layout does not need to be switched during such rendering actions?

Hope for any answer [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] With regards.
// Sorry for my English.

Share this post


Link to post
Share on other sites
Ripiz    539
Everytime you switch there's some data validation going on, so it's best to do less switching to save CPU power.
I assume your player and other NPCs most likely use same shader (it's just skinning afterall), so render them all. Then change shader and render all roads, etc.

However, you shouldn't create input layout or shaders during rendering, it should be part of resource loading. Shader compilation takes a lot time, so better create them all when application starts, outside of mainloop.

Share this post


Link to post
Share on other sites
Deft    226
Thank you a lot. Now I understand what to do [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Deft

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