Jump to content

  • Log In with Google      Sign In   
  • Create Account


Using input layout in DirectX


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Deft   Members   -  Reputation: 218

Like
0Likes
Like

Posted 29 August 2012 - 04:28 PM

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):
  • 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.
So, at first pass I use something like:
[source lang="cpp"]// Compiling shaderscontext->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 Posted Image With regards.
// Sorry for my English.

Sponsor:

#2 Ripiz   Members   -  Reputation: 529

Like
1Likes
Like

Posted 30 August 2012 - 01:57 AM

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.

#3 Deft   Members   -  Reputation: 218

Like
0Likes
Like

Posted 30 August 2012 - 09:31 AM

Thank you a lot. Now I understand what to do Posted Image

Edited by Deft, 30 August 2012 - 09:31 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS