-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DX11 Backend #861
DX11 Backend #861
Conversation
☔ The latest upstream changes (presumably #864) made this pull request unmergeable. Please resolve the merge conflicts. |
Check out |
Pretty much blocked now on the absence of |
Sorry about that, I'll go finish it up right now. 🐰 |
I've pushed some stuff to winapi just now. Could you use a cargo local override to test the latest git version of winapi and friends to ensure it works and has everything you need before I cargo publish it? |
@retep998 thank you! |
☔ The latest upstream changes (presumably #874) made this pull request unmergeable. Please resolve the merge conflicts. |
I've finished the first stage - implementing the basis we use for our examples, including shader reflection with d3dcompile. Now proceeding to the second stage - running the examples, debugging the errors, and fixing them. @retep998 First problem right away:
I'm using these dependencies for the d3d11-sys = "0.1"
d3dcompiler-sys = "0.0.1"
dxguid-sys = "0.0.1"
winapi = "0.2" |
Ah, you're using the |
Thanks @retep998 , this works! I hope it doesn't conflict with |
I've set up the build scripts such that they only use the bundled import libraries for |
@retep998 Now I'm trying to figure out why let mut reflection = ptr::null_mut();
d3dcompiler::D3DReflect(code.as_ptr() as *const winapi::VOID,
code.len() as winapi::SIZE_T, &dxguid::IID_ID3D11ShaderReflection, &mut reflection); I'm getting
Maybe the |
There seem to be D3D11Reflect in the docs, that would zero out the chance for improper IID, but it doesn't look like the current bindings provide it. |
@retep998 found something in PixarAnimationStudios/OpenSubdiv#775, makes me a sad panda:
|
Oh, there wasn't any |
I just compared the IID provided by 8, 8.1, and 10 of the Windows SDK headers to the IID in Also FORCEINLINE HRESULT
D3D11Reflect(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_Out_ ID3D11ShaderReflection** ppReflector)
{
return D3DReflect(pSrcData, SrcDataSize,
IID_ID3D11ShaderReflection, (void**)ppReflector);
} |
I have DX12 capable hardware so I'd be willing to test it to see if its just a feature level issue. What is a minimal example that I can build and run? |
Running the triangle example I get this error:
|
After I installed the optional windows feature "Graphical Tools" I got further!
|
Awesome, so we should be good by using |
@retep998 Now I'm puzzled. let hr = unsafe {
d3dcompiler::D3DReflect(code.as_ptr() as *const winapi::VOID,
code.len() as winapi::SIZE_T, &dxguid::IID_ID3D10ShaderReflection, &mut reflection)
}; Still getting |
Maybe it's something wrong with my binaries? After all, this error may be interpret as "your binary doesn't have this interface". I'm compiling the shader with this batch: set FXC="%DXSDK_DIR%\Utilities\bin\x64\fxc.exe"
mkdir data
%FXC% /T vs_4_0 /E Vertex /Fo data/vertex.fx triangle.hlsl
%FXC% /T ps_4_0 /E Pixel /Fo data/pixel.fx triangle.hlsl EDIT: ah, no, the binaries are fine since @retep998 was able to reflect them |
@sectopod Maybe you don't have something installed that is necessary to allow debugging and reflection? I'm on Windows 10 and I had to install the "Graphical Tools" optional system feature which I found out from http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx although not having it caused me to fail at creating the swap chain, not creating the reflection interface. It could possibly also be due to you using the |
It's certainly not the "Graphics Tools", since these are installed and only needed for debug runtime. DLL-wise, I don't have that many: As for MSVC toolchain, I'm trying this now. Getting something weird upon running the example:
On a side note, my cargo doesn't like |
I think I get it now, was misreading the documentation. Specifying this flag doesn't generate mipmaps automatically. It just enables the capability of calling |
|
@retep998 thank you! Will patch the appveyor now and see if it passes through. |
@retep998 don't you have to change the dependencies to "0.2" for these crates and publish the new |
|
Ok, we are green on windows msvc stable and linux stable/beta. Nightly is broken by #904 rustc regression. GNU build is failing on miniz-sys, which is just a dependency issue, and needs to be addressed on the appveyor script (or platform config) level rather than the code side. I believe we are ready to |
@@ -30,6 +30,6 @@ name = "gfx_device_dx11" | |||
log = "0.3" | |||
gfx_core = { path = "../../core", version = "0.2" } | |||
d3d11-sys = "0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated d3d11-sys
too, you know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed it. We'll update this at any point later, since it's not necessary and doesn't break the API.
Fails on nightly and the -gnu target (wrong setup on appveyor?), merging anyway! |
🎊 🎈 awesome job @sectopod |
🎉 🎉 🎉 |
Thank you everyone for the support! |
Now gfx can finally live up to its goal of being a a library that abstracts across multiple graphics APIs! |
Fixes #89, Fixes #849, Fixes #878, Fixes #882, Fixes #897, Fixes #902, Fixes #906
Breaking changes
TriangleFan
is removedR8_G8_B8
andR3_G3_B2
surface types are removed, and with them the oldSrgb8
shortcutFactory::update_*()
methods are removed in favor ofCommandBuffer
-based updates and providing the initial data for resource creation, which now supports multiple slices and mips.Bind
flag set that you'll need to pass for some of the object construction methodsUsage
enum has undergone a rewriteShaderSet
type that may need for the PSO (or shader program) constructionResourceDesc
,RenderDesc
, andDepthStencilDesc
SubmitInfo
is gone.Encoder
has a singleflush
method instead ofas_buffer
andreset
.Phantom
is renamed toTyped
gfx_constant_struct
requires the shader-visible names now, the same asgfx_vertex_struct
gfx_app
crate. Both core and render crates are now completely API-unaware.Notable non-breaking changes
gfx_device_dx11
andgfx_window_dxgi
crates. We also set up windows CI, which has GLFW stuff excluded.gfx_app
crate. It is now the only place that knows about all the windowing and API backends in this repository.Border
mode for samplersyour_pso::Bundle
and the constructoryour_pso::bundle()
are generated for you to contain the slice, PSO itself, and PSO run-time data objects.Examples update
launch_default
, which selects the default backends for the current platformcast_slice
- instead callingcreate_texture_const_u8
Why DX11?
It's the most established API for high-performance games and graphics application to date. It has the best all-around driver support, variety of powerful tools, and is not cluttered by the legacy (looking at you, OpenGL).
Implementation details
The backend supports both native deferred contexts and emulated (in the same way we do with OpenGL). Once you obtained a device instance with
gfx_window_dxgi::init
, you can transform it intogfx_device_dx11::Deferred
with a simpleinto()
call. The application launcher uses native DX11 contexts by default.Future work
winit
when it's ready (Integrate winit #907)