DirectX 11 render system - work-in-progress

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

I fixed all swapchain resizing issues - all swapchain related resources (render target views and back buffer texture) must be released and reacquired after resize.
Also depth stencil is now destroyed and recreated. Did not test this on Win32, but on WinRT works like a charm.

I will continue to tweak render system - want to add the ability to work not only over HWND and CoreWindow, but in Direct3D+XAML scenarios too, as described here:
http://msdn.microsoft.com/en-us/library ... l/hh825871 ,
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf Raman wrote:Well, I don't have a windows 8 computer... I guess I can create a virtual machine for it or the sort...
Yeah, that work pretty well - I work on Win8 port in virtual machine hosted on Mac several months.

Here is the list of virtual machines known to work with win8:
http://blogs.msdn.com/b/b8/archive/2011 ... nment.aspx

Building process for OGRE_BUILD_PLATFORM_WINRT requires some manual steps and is described in BuildingOgreWinRT.txt,
here are some highlights from this file:

1. You need Windows 8 Consumer Preview (build 8250) or later.
(http://windows.microsoft.com/en-US/windows-8/iso)
Windows 8 Developer Preview (build 8102) is not supported.

2. You need patched CMake 2.8.7 from Feb 23 2012 or later for
VS_WINRT_EXTENSIONS and VS_WINRT_REFERENCES special target properties.
(http://www.cmake.org/files/dev/cmake-2. ... 32-x86.exe)

3. You need Visual Studio 11 Ultimate Beta or later.
(http://www.microsoft.com/download/en/de ... n&id=28975)
Visual Studio 11 Express Beta is not supported.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

Man, this seems like a lot of work... It will take me a while.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

Downloading the big iso files.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

Well, i spent some time creating the image and such.
It does seems like something that will take me some time to get working and do the merge.
Before doing that - can you explain more the need for it?
Windows 8 is not even out, and this seems a bit too soon, isn't?
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf Raman wrote:Well, i spent some time creating the image and such.
It does seems like something that will take me some time to get working and do the merge.
Before doing that - can you explain more the need for it?
Windows 8 is not even out, and this seems a bit too soon, isn't?
Well, I`m programmer on Live Interior 3D project, simple interior design program for Macs that uses Ogre as 3D engine. It`s distributed via Apple`s App Store, and this is really good business model. So when MS declared that Windows will have App Store too - it was the reason to consider porting our application to Windows. By the way, Windows market share is 20 times bigger than Apple`s.

In initial period only Metro Style applications would be allowed in the Store, and even later only Metro applications would be full featured citizens of the Store, with the ability of direct downloading, automatic updating, etc. AFAIK all other applications would have just parking page in the Store with redirect to developer`s site.

Metro applications are executed inside a sandbox, and can not use almost all Win32 APIs except carefully choosen subset - or application will not pass validation. Particularly, OpenGL and Direct3D9 are forbidden, and only Direct3D11.1 can be used among 3D APIs. Therefore, Direct3D11 becomes the only choice for all developers that want to sell their games and other programs via Windows Store.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

I see.
I will try then to help you out.
Where do I get the D3D11.1 SDK?
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf Raman wrote:Where do I get the D3D11.1 SDK?
No more such separate thing. Combined with Windows SDK and while available as standalone download also contained in Visual Studio 11. It is located in "C:\Program Files (x86)\Windows Kits\8.0" folder. Some libraries were lost in transition, such as D3DX and DXErr, therefore shaders should be compiled via D3DCompile() even for Win32. I tweaked CMake scripts so Ogre can be built in both Win32 and WinRT modes on Win8.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

I didn't see it there... Does it suppose to come with VS2011 preview?
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf Raman wrote:I didn't see it there... Does it suppose to come with VS2011 preview?
Yes.

Also, you need not just any VS preview but fresh VS beta, as they are targeting different incompatible Win8 builds (8102 and 8250). If you download it by my link - it`s OK.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

God help them... I will try to manage.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

BTW: What about a NaCl version for your product?
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf Raman wrote:BTW: What about a NaCl version for your product?
Not planned. Even iPad version is not yet planned.
Zero
Halfling
Posts: 50
Joined: Mon Mar 10, 2008 12:08 am
Location: Stuttgart|Germany
x 1
Contact:

Re: DirectX 11 render system - work-in-progress

Post by Zero »

I added another patch for DirectX11 https://sourceforge.net/tracker/index.p ... tid=302997

@Resizing DepthBuffer:
I already uploaded last year a patch with that functionality.

But now I have one problem with the renderer, when you have a rendertarget for render to texture and you minimize the renderwindow, you get an error.
OGRE EXCEPTION(3:RenderingAPIException): D3D11 device cannot set vertex shader
Error Description:ID3D11DeviceContext::PSSetShaderResources: Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL.
in D3D11RenderSystem::bindGpuProgram at ..\..\..\Ogre Trunk\RenderSystems\Direct3D11\src\OgreD3D11RenderSystem.cpp (line 2318)

I couldn't fix this in the renderer, so I have a workaround in my application, which sets the rendertargets deactive when the renderwindow is minimized. Maybe someone has an idea how to fix this.
Image
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Found one issue with Direct3D11 Render System in both Win32 and WinRT modes - on Samsung Slate 7 device (Windows 8 development machine from Microsoft) screen is just black without any visible errors on both hardware and reference devices. Videocard is from intel, drivers are WDDM 1.2 from MS, device is created without problem, obtained feature level 10.1, Ogre log is identical to log on NVidia machine, where everything works.
This machine can run without problem Direct3D11.1 samples from MS with hlsl 4 shaders.

Update:
At least swapchain is functional - if I clear backbuffer with color - I can see it.
But if I set mTrayMgr->showBackdrop("BaseWhite"); I can not see it - screen is still black.
Last edited by Eugene on Wed Mar 14, 2012 3:13 pm, edited 2 times in total.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

I don't see how I can help without having the device.
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf, I have a question - you added special hack to RTSS to pass color parameters to HLSL programs with vs_4_0 profile as uint - search by needToTranslateHlsl4Color variable. With this hack I got exceptions from D3DDevice about mismatched shader parameters, and on high ignorance levels all texts are not rendered (transparent). This happens on both Win32 (without cg plugin) and WinRT variants, and with disabled hack warning disappeared and text rendered OK also on both Win32 and WinRT variants.

Can you provide some more info about this hack and how can be checked is it still needed?
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

I think it turns out I didn't need the hack in the end.
Didn't I remove it?
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

Assaf Raman wrote:I think it turns out I didn't need the hack in the end.
Didn't I remove it?
Probably not if I found it :)
It`s in CG program writer, the same needs to be done for HLSL program writer too. Also parameter named colorParameter that was located near needToTranslateHlsl4Color was used only for this hack and can be removed from both CG and HLSL writeFunctionDeclaration() functions. I already did it in my fork, as well as cleanup and rebase all my WinRT related patches on top of Ogre`s head.

What do you think about WinRT compatibility patch as a whole?
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

My laptop is broken, so I didn't get to look at it yet.
windows 8 is still a long time from being released - so I can take my time.
I like the idea of your patch and I am sure we will merge most of after I will review it.
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

I work now on Direct3D/Xaml interoperability, as described here http://msdn.microsoft.com/en-us/library ... l/hh825871
To do this I refactored D3D11RenderWindow that was before conditionally compiled to work over HWND or CoreWindow^.
This is required as XAML controls are not windows with native handles as Win32 HWNDs.

Now hierarchy looks like this:

D3D11RenderWindowBase
  • D3D11RenderWindowSwapChainBased
    • D3D11RenderWindowHwnd
      D3D11RenderWindowCoreWindow
      D3D11RenderWindowComposition (not yet implemented)
    D3D11RenderWindowImageSource (not yet implemented, WIP)
    D3D11RenderWindowVirtualImageSource (not yet implemented)
I want to share this refactoring ASAP, as changes are numerous and would provoke merge conflicts if postponed.
Sources are here https://bitbucket.org/eugene_gff/ogre-winrt , both Win32 and WinRT versions were compiled and tested.

P.S.
I pushed yet another fix for Win32 version: switching to fullscreen using Alt-Enter does not work as during swapchain resizing not all swap chain size depended resources were released.
The same problem can be seen while resizing window with mouse: "DXGI ERROR: Swapchain cannot be resized unless all outstanding buffer references have been released. [ UNKNOWN ERROR #24: ]"
Just backported necessary code from WinRT to Win32 version.

P.P.S.
Yet another fix - driver version can be determined for Direct3D11 too, not directly but with high confidence level.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

While working on Direct3D on XAML I implemented D3D11RenderWindowImageSource using two SurfaceImageSource-s and one ImageBrush to emulate swapchain, so that UI thread would not be blocked while 3D scene is rendered in background thread.

But there are some issues:
1) SurfaceImageSource can return surface larger than requested, and active rectangle can be offset. For example, when I requested surface with size 800x600 I got 832x640 and update rectangle origin was located at (31,39). This would require Viewport tweaking before rendering with some amount of messy code.
2) As surface can be different each frame I should each time recreate render target view and recreate depth stencil and corresponded view if surface size is changed.
3) Probably resetting ImageBrush->ImageSource should be done via Dispatcher if rendering is done from another thread, and this would complicate the story further.

Therefore I decided that I don`t like this approach. I`ll implement another one - instead of two SurfaceImageSources there would be one and intermediate ID3DTexture2D with exactly required size thus avoiding messing up with viewports. As texture would be mine, depth stencil and both views would be reused. Swapping would be done via copying that texture into the SurfaceImageSource`s IDXGISurface using provided update rectangle.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Re: DirectX 11 render system - work-in-progress

Post by Assaf Raman »

Sounds like the normal MS things.
Keep up the good work.
Watch out for my OGRE related tweets here.
User avatar
Eugene
OGRE Team Member
OGRE Team Member
Posts: 185
Joined: Mon Mar 24, 2008 4:54 pm
Location: Kraków, Poland
x 41

Re: DirectX 11 render system - work-in-progress

Post by Eugene »

I did what I want, now Ogre can render 3D scenes over Xaml controls too. Sources are here http://bitbucket.org/eugene_gff/ogre-winrt and sample screenshot is in first post of this thread.

There are another test project, SampleBrowserWinRT.Xaml.vcxproj, that demonstrate this technique, custom build steps are the same as for SampleBrowserWinRT.vcxproj and are described in BuildingOgreWinRT.txt
Post Reply