microsoft / WPFDXInterop

Repo for WPF DX Interop support
MIT License
307 stars 98 forks source link

Multisampling support #14

Open PetrMahdalicek opened 8 years ago

PetrMahdalicek commented 8 years ago

Hello, can I somehow force D3D11Image to create its internal Texture2D with my sample description?

rrelyea commented 8 years ago

I don't think the current code supports that...but it sounds interesting. Can you describe your scenario more?

PetrMahdalicek commented 8 years ago

Well, currently we use D3D9 and if possible we create render target surface with antialisng to get better image quality. When using D3D11 image, we do not create render target surface, but we use surface created by this library. I did looked at the code, to me it looks like it should be possible. But I do not know if there are limitations when sharing surfaces betwen D3D9 and D3D11.

jasonjtyler commented 7 years ago

The surface created by this library is a shared resource, and with that come some restrictions. One of those restrictions is that the surface cannot be MSAA. From the ID3D11Device documentation ..

Textures being shared from D3D9 to D3D11 have the following restrictions. Textures must be 2D Only 1 mip level is allowed Texture must have default usage Texture must be write only MSAA textures are not allowed Bind flags must have SHADER_RESOURCE and RENDER_TARGET set Only R10G10B10A2_UNORM, R16G16B16A16_FLOAT and R8G8B8A8_UNORM formats are allowed

https://msdn.microsoft.com/en-us/library/windows/desktop/ff476531(v=vs.85).aspx

To achieve MSAA, you must instead create your own MSAA surface that is attached to your render target. Then, after rendering your scene, copy the results from your MSAA surface to the D3DImage surface provided by this library using ID3D11DeviceContext::ResolveSubresource.