<p>I have a noobish question for any graphics programmer.</p>

<p>I am confused how some games (like Crysis) can support both DirectX 9 (in XP) and 10 (in Vista)?</p>

<p>What I understand so far is that if you write a DX10 app, then it can only runs in Vista.</p>

<p>Maybe they have 2 code bases -- one written in DX9 and another in DX10? But isn't that an overkill?</p>

[{'answer_id': 66029, 'author': 'Yann Ramin', 'author_id': 9167, 'author_profile': 'https://Stackoverflow.com/users/9167', 'pm_score': 4, 'selected': True, 'text': '<p>They have two rendering pipelines, one using DX9 calls and one using DX10 calls. The APIs are not compatible, though a majority of any game engine can be reused for either. If you want some Open Source examples of how different rendering pipelines are done, look at something like Ogre3d, which supports OpenGL, DX9, and (soon)DX10 rendering.</p>\n'}, {'answer_id': 66045, 'author': 'Ray Hayes', 'author_id': 7093, 'author_profile': 'https://Stackoverflow.com/users/7093', 'pm_score': 1, 'selected': False, 'text': '<p>It is likely that they have an abstraction layer and they develop against that.  At run-time they instantiate the DX9 or DX10 wrapping concrete engines.</p>\n\n<p>I imagine their abstraction is positioned very close to the DirectX layer and simply provides DX9 with sensible manual implementations of DX10 functions or enhances DX9 logic when running on DX10.</p>\n'}, {'answer_id': 66549, 'author': 'user9844', 'author_id': 9844, 'author_profile': 'https://Stackoverflow.com/users/9844', 'pm_score': 2, 'selected': False, 'text': "<p>The rendering layer of games is usually a fairly well isolated/abstracted part of the whole application. As far as the game engine is concerned, each frame you are simply building up a list of conceptual objects (trees, characters, etc.). If the game engine chooses to render a particular object, then it's up to the rendering layer how to actually translate that intent into DX draw calls. A DX10 rendering will generate a different set of draw calls to a DX9 layer, but conceptually they are still performing the same action - 'render this tree'.</p>\n\n<p>Rendering is nicely abstracted because it's rare that you want to get any information back from the rendering layer, once the 'render this tree' action is performed, the game engine will just assume that the rendering looks correct. There is little need to handle different potential results from DX9/DX10 rendering calls because 99.9% of the information is going from the engine to the graphics system, and the 0.1% that comes back likely takes the same form between the two APIs.</p>\n\n<p>The application setup is a little more icky, because you've got to ask the system whether or not DX10 is supported and gracefully fall back on DX9 otherwise, but this is standard fare for application setup (in the same way that the game has to pick a resolution, refresh rate, input device, etc.).</p>\n"}]
['https://Stackoverflow.com/questions/65998', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5196/']