DirectX 11 support for windows - #6457
Conversation
andydotxyz
left a comment
There was a problem hiding this comment.
It's completely amazing to see something as substantial as this being contributed.
However I have a few reservations or change requests and these probably need discussion.
- There is no support for the Shader GL rendering and instead adds a new platform specific shader langauge - which is not gated or built for specific platforms, so most apps here will simply show nothing when built for directx
- The whole directx driver and painter seem to be compiled for all windows builds rather than those specifically requesting directx? (only the app entry point is actually gating on the build tag - as far as I can see)
- There is a massive amount of code generated here, particularly the d3d11.go with no testing. I have not looked at the code coverage in generally but it feels problematic.
I worry also that we have either a lack in our testing setup or in this particular addition to be able to compare what is rendered in one driver vs another (i.e. definitive either GL or software). For example does every line rendering support stroke width or is every circle vs ellipse contract the same...
|
One other thing I forgot to note - a lot of the docs generated in the DirectX seem to compare it to the GL or other renderers, whereas docs should stand on their own as describing behavior not differences. |
|
Thanks for taking the time to go through something this large. All fair points!. I've pushed fixes for two of them and would like to align on the other two before writing more code. Build gating — fixed. Only the app entry point was gated; the packages themselves built for plain Every file in Shader support Every built-in canvas primitive is implemented in the D3D pipeline: rectangles with per-corner radii, strokes and shadows, circle/ellipse, arc, regular and arbitrary polygons, bezier, line, text, image, raster, both gradients, and blur. The one thing that can't render from GLSL is a user-supplied The PR follows the pattern If a third per-target source isn't acceptable, the alternatives I see are: Happy to go whichever way you prefer. d3d11.go / testing — it's hand-written rather than generated: minimal COM vtable bindings for exactly the slots the painter calls (~850 lines covering device, context, swap-chain and the shader compiler). The existing tests pin the CPU-side invariants that fail silently: the Go constant-buffer structs against the HLSL declarations, glyph-atlas packing overlap, uniform offset parsing, blend-state configuration, blur kernel weights, text windowing maths. The binding layer itself only gets meaningfully exercised with a device, so my proposal is a Windows CI job running Cross-driver comparison — agreed, and I'd say the gap exists between GL and software today as well. Concrete proposal: a conformance suite rendering one fixed scene per primitive family (lines at several stroke widths, circle vs ellipse in non-square bounds, per-corner radii, gradients, text) through To your specific examples: line stroke width is supported, and circle shares the ellipse shader with aspect correction, so that contract is identical — but I agree that should be proven by a test, not asserted in a comment. I'd prefer building the suite as a follow-up PR since it touches and benefits every driver, but can fold it into this one if you consider it a blocker. Docs — fair, and fixed. I've swept the driver, the painter and the HLSL sources; comments now describe behaviour on their own terms without referencing the GL or software renderers. |
|
Let's get others thoughts on the Shader situation |
I do think it makes sense to add an HLSL shader property to the |
|
Mixing OpenGL and Direct3D Same window, both APIs presenting Painful. On Windows an HWND's pixel format is set once and is permanent, and DXGI wants to own the swapchain for that HWND. You can hack around it (child windows, D3D rendering to an offscreen target then blitting), but there's no clean way to have both APIs alternately presenting to one surface. Shared GPU resources one API renders into a texture, the other consumes it, no round-trip through system memory.
The downside of this is of course you'd have dual graphics stacks running inside your fyne app and it would not be possible to build without CGO due to the requirement of GLFW Regarding the Shader type We could reuse the existing Source field on Shader rather than introducing a new mechanism. Cross-compiling users would then select the appropriate shader source through the standard Go build constraints — either filename suffixes, explicit //go:build tags, or a combination of the two. A typical layout: //go:build windows
package myapp
import _ "embed"
//go:embed myshader.hlsl
var myShaderSource []byte//go:build linux
package myapp
import _ "embed"
//go:embed myshader.frag
var myShaderSource []bytepackage myapp
var myShader = Shader{
Name: "myShader",
Source: myShaderSource,
}package myapp
var myShader = Shader{
Name: "myShader",
Source: myShaderSource,
}Advantages of this approach:
|
Nah, we already have the pattern of Source and SourceES, so adding SourceHLSL would be following that existing pattern. |
Description:
Adds Windows DirectX 11 support. build with -tags=directx
Implements #911
Checklist:
Where applicable: