I recently took the plunge and upgraded to Windows 8, primarily so that I can develop an App for the soon-to-be-launched Windows Store. I’m going to be using C++/CX and DirectX 11 (and probably XAML) with Visual Studio 2012 as my development environment.
While I’m at it I thought it might be useful to keep a log of problems (relating to DX11, C++/CX, WinRT, etc.) that I hit along the way. At the very least I hope to solidify my own understanding through elucidation, but maybe there’ll be some useful titbits for other developers as well.
I’ll continue to update this post over the coming weeks.
DirectX 11 – Tessellation
Problem: Vertex shader won’t compile alongside hull and domain shaders. Specifically, attempting to compile results in: “error X4541: vertex shader must minimally write all four components of POSITION”
Solution: The vertex shader was being compiled against an old Shader Model.
Prior to the introduction of domain shaders, a vertex shader had to (as a bare minimum) output 2D screen coordinates (and depth values) for all 3D vertex positions it was fed. In DirectX 11, however, the domain shader can fulfil that responsibility for applications making use of tessellation (which occurs after the vertex shader phase in the graphics pipeline).
Visual Studio 2012 now compiles shaders as part of its regular build process (very cool), but it must be told which Shader Model to compile against. Using tessellation with DirectX 11 requires that the .hlsl files (including the vertex shader) be compiled against Shader Model 5.
The HLSL compiler settings can be set at the project and/or individual .hlsl file level. In either case it’s achieved by right-clicking on said item in the Solution Explorer and hitting Properties -> HLSL Compiler.
Problem: “E_ACCESSDENIED General access denied error” upon making Direct3D calls while a domain shader is active.
Solution: This was a bug in my C++ code. Tessellation shaders work on control point patches rather than more traditional primitives (such as triangles). The Direct3D context must be informed of such with a call to IASetPrimitiveTopology like so:[c++]d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST);[/c++]