Compiling Ogre with DirectX 9ex

Problems building or running the engine, queries about how to use features etc.
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43

Compiling Ogre with DirectX 9ex

Post by Oogst »

To be able to run my game Proun in a dome/planetarium, I have been asked if I could provide a version of Proun that is compiled with DirectX 9ex. I had never heard of that before, but apparently DirectX 9ex is normal DirectX 9c, but with some extra features from Windows Vista/7. So everything should be compatible and this sounds like in theory I could just swap the DirectX version and then recompile Ogre and Proun and it works.

However, I have no idea whether it really is as simple as that. I couldn't even find a download for the DirectX 9ex SDK on MSDN. Proun uses Ogre version 1.7.0 and I compiled it with the August 2007 DirectX SDK.

So my questions:
-It it really as simple as just recompiling with different include directories, or do I need to do more than that?
-What exactly do I need to change to make Ogre compile with a different DirectX version?
-Where can I download the DirectX 9ex SDK?
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: Compiling Ogre with DirectX 9ex

Post by Mind Calamity »

Well according to the last post here the person says that DirectX 9ex is just DirectX 10 for Windows Vista, and also from what I understood DirectX 9ex is also known as DirectX 9l (which I don't think is true).
Direct3D 9Ex (known internally during Windows Vista development as 9.0L or 9.L): allows full access to the new capabilities of WDDM (if WDDM drivers are installed) while maintaining compatibility for existing Direct3D applications. The Windows Aero user interface relies on D3D 9Ex.
Source: http://en.wikipedia.org/wiki/DirectX
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
Zonder
Ogre Magi
Posts: 1178
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 76

Re: Compiling Ogre with DirectX 9ex

Post by Zonder »

You shouldn't need to recompile it was supposed to be compatible with the normal version. Can you not try it?
There are 10 types of people in the world: Those who understand binary, and those who don't...
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43

Re: Compiling Ogre with DirectX 9ex

Post by Oogst »

Well, it is supposed to add some features to how the screen is output towards Windows, so shouldn't I at least link with a different lib?
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Compiling Ogre with DirectX 9ex

Post by bstone »

No, DirectX is developed around the concept of COM interfaces. The only stuff you link to in related libs is basically identifiers of the DirectX interfaces. You should be fine without any changes and recompilation as long as DX9ex is backward compatible with DX9c.
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43

Re: Compiling Ogre with DirectX 9ex

Post by Oogst »

So does that mean I don't have to do anything at all? If I run Proun in Windows 7 it automatically uses DirectX 9ex, and if I run it in Windows XP, it automatically uses DirectX 9c?
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
User avatar
Zonder
Ogre Magi
Posts: 1178
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 76

Re: Compiling Ogre with DirectX 9ex

Post by Zonder »

Yes that should be the case.
There are 10 types of people in the world: Those who understand binary, and those who don't...
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43

Re: Compiling Ogre with DirectX 9ex

Post by Oogst »

Okay, I'll tell the planetarium guy to just try the current version on Windows Vista/7 then. It might be that he just asked me for it and hadn't tried yet whether it works. Thanks for the quick replies! :)
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: Compiling Ogre with DirectX 9ex

Post by Mind Calamity »

If for some reason they need some DirectX 10 feature, you can try compiling and using the D3D11 render system, that should be backwards-compatible with DrectX 10/DirectX 9 ex
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 100

Re: Compiling Ogre with DirectX 9ex

Post by Wolfmanfx »

Hi,

First off there is a guy which already add d3d9ex support to ogre here is the repo -> https://bitbucket.org/JaredThirsk/ogre-d3d9ex/wiki/Home
but the port is not that clean (i mean its not in a state so it could be merged to the trunk).

Also you must make the impl dynamic -
Use Direct3DCreate9Ex on WinVista and later and use standard Direct3DCreate9 on winXP (there is an article in MSDN how todo this - its not hard)
Here the MSDN snippet:

Code: Select all

    HRESULT hr = S_OK;

    HMODULE hD3D = NULL;
    if (!m_pD3D)
    {
        hD3D = LoadLibrary(TEXT("d3d9.dll"));
        DIRECT3DCREATE9EXFUNCTION pfnCreate9Ex = (DIRECT3DCREATE9EXFUNCTION)GetProcAddress(hD3D, "Direct3DCreate9Ex");
        if (pfnCreate9Ex)
        {
            IFC((*pfnCreate9Ex)(D3D_SDK_VERSION, &m_pD3DEx));
            IFC(m_pD3DEx->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&m_pD3D)));
        }
        else
        {
            m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
            if (!m_pD3D) 
            {
                IFC(E_FAIL);
            }
        }

        m_cAdapters = m_pD3D->GetAdapterCount();
    }

Cleanup:
    if (hD3D)
    {
        FreeLibrary(hD3D);
    }

    return hr;
D3DPOOL_MANAGED is only valid with IDirect3DDevice9 but not with IDirect3DDevice9Ex. (So this also something the guy just changed)

But the main difference between the ordinary device and the ex device is the device lost behaviour. (http://msdn.microsoft.com/en-us/library ... 85%29.aspx)
Devices are now only lost under two circumstances; when the hardware is reset because it is hanging, and when the device driver is stopped. When hardware hangs, the device can be reset by calling ResetEx. If hardware hangs, texture memory is lost.
So this means when the hardware hangs we just need to recreate the textures on the device but not the hardwarebuffers / shaders and the other stuff.

hope it helps :)
Oogst
OGRE Expert User
OGRE Expert User
Posts: 1067
Joined: Mon Mar 29, 2004 8:49 pm
Location: the Netherlands
x 43

Re: Compiling Ogre with DirectX 9ex

Post by Oogst »

I got it to work, but only in windowed mode. However, the folks who need this are only going to run windowed anyway, so that is fine. :) They also sent me a little guideline and following that was enough to get it to work:
The initialization in D3D9 is done using the code:

IDirect3D9 *d3d9 = NULL;
IDirect3DDevice9 *d3d9Device = NULL;
HRESULT res = S_OK;
.
.
Direct3DCreate9(D3D_SDK_VERSION);
.
.
res = d3d9->CreateDevice(.........,&d3d9Device);

Please change it to:

IDirect3D9Ex *d3d9Ex = NULL;
IDirect3DDevice9Ex *d3d9DeviceEx = NULL;
HRESULT res = S_OK;

res = Direct3DCreate9Ex(D3D_SDK_VERSION,&d3d9Ex);
.
.
res = d3d9Ex->CreateDeviceEx(........,&d3d9DeviceEx);

Last step: Wherever the "flag" D#DPOOL_MANAGED exists replace it by D3DPOOL_DEFAULT

In CreateDeviceEx, there are other flags that if you need some help just let us know, but this last one is the important one.
There was one function that required a D3DDISPLAYMODEEX and I couldn't get that to work correctly for fullscreen, but in windowed mode it should be NULL, so just using NULL there worked fine. :)
My dev blog
Awesomenauts: platforming MOBA (PC/Mac/Linux/XBox360/X1/PS3/PS4)
Blightbound: coop online dungeon crawler (PC)
Swords & Soldiers: side-scrolling RTS (Switch/PS3/Wii/PC/Mac/Linux/iPhone/iPad/Android)
Proun: abstract racing game (PC)
Cello Fortress: mixing game and live cello performance
The Ageless Gate: cello album