Jump to content
  • Advertisement
Sign in to follow this  

Using input layout in DirectX

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

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):

  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;
  2. Then I want to render road with using of tessellation;
  3. After that I want to spawn game world NPCs.

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 smile.png With regards.
// Sorry for my English.

Share this post

Link to post
Share on other sites
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
Thank you a lot. Now I understand what to do smile.png Edited by Deft

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!