Files
Elias Naur 8999747ad2 app,gpu,internal/vk: add Vulkan port for Wayland, X11, Android
This change implements a Vulkan port for the two renderers, old and
compute. Run with GIORENDERER=forcecompute to test the compute renderer.

To shake out bugs faster, it is also made the default on systems that
support it. To disable Vulkan and force the use of OpenGL, use the
`novulkan` tag:

$ go run -tags novulkan gioui.org/example/kitchen

Don't forget to file an issue describing the issue that prompted the use
of the tag.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-21 18:40:05 +02:00

46 lines
810 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
package headless
import (
"unsafe"
"gioui.org/gpu"
"gioui.org/internal/d3d11"
)
type d3d11Context struct {
dev *d3d11.Device
}
func init() {
newContextPrimary = func() (context, error) {
dev, ctx, _, err := d3d11.CreateDevice(
d3d11.DRIVER_TYPE_HARDWARE,
0,
)
if err != nil {
return nil, err
}
// Don't need it.
d3d11.IUnknownRelease(unsafe.Pointer(ctx), ctx.Vtbl.Release)
return &d3d11Context{dev: dev}, nil
}
}
func (c *d3d11Context) API() gpu.API {
return gpu.Direct3D11{Device: unsafe.Pointer(c.dev)}
}
func (c *d3d11Context) MakeCurrent() error {
return nil
}
func (c *d3d11Context) ReleaseCurrent() {
}
func (c *d3d11Context) Release() {
d3d11.IUnknownRelease(unsafe.Pointer(c.dev), c.dev.Vtbl.Release)
c.dev = nil
}