cpu

package module
v0.0.0-...-f1e9e8c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2022 License: MIT, Unlicense Imports: 3 Imported by: 6

README

Compile and run compute programs on CPU

This projects contains the compiler for turning Vulkan SPIR-V compute shaders into binaries for arm64, arm or amd64, using SwiftShader with a few modifications. A runtime implemented in C and Go is available for running the resulting binaries.

The primary use is to support a CPU-based rendering fallback for Gio. In particular, the gioui.org/shader/piet package contains arm, arm64, amd64 binaries for piet-gpu.

Compiling and running shaders

The init.sh script clones the modifed SwiftShader projects and builds it for 64-bit and 32-bit. SwiftShader is not designed to cross-compile which is why a 32-bit build is needed to compile shaders for arm.

The example/run.sh script demonstrates compiling and running a simple compute program.

Issues and contributions

See the Gio contribution guide.

Documentation

Index

Constants

View Source
const Supported = true

Variables

View Source
var ABIH []byte
View Source
var RuntimeH []byte

Functions

This section is empty.

Types

type BufferDescriptor

type BufferDescriptor = C.struct_buffer_descriptor

func NewBuffer

func NewBuffer(size int) BufferDescriptor

func (*BufferDescriptor) Data

func (d *BufferDescriptor) Data() []byte

func (*BufferDescriptor) Free

func (d *BufferDescriptor) Free()

type DispatchContext

type DispatchContext = C.struct_dispatch_context

func NewDispatchContext

func NewDispatchContext() *DispatchContext

func (*DispatchContext) Dispatch

func (c *DispatchContext) Dispatch(threadIdx int, ctx *ThreadContext)

func (*DispatchContext) Free

func (c *DispatchContext) Free()

func (*DispatchContext) Prepare

func (c *DispatchContext) Prepare(numThreads int, prog *ProgramInfo, descSet unsafe.Pointer, x, y, z int)

type ImageDescriptor

type ImageDescriptor = C.struct_image_descriptor

func NewImageRGBA

func NewImageRGBA(width, height int) ImageDescriptor

func (*ImageDescriptor) Data

func (d *ImageDescriptor) Data() []byte

func (*ImageDescriptor) Free

func (d *ImageDescriptor) Free()

type ProgramInfo

type ProgramInfo = C.struct_program_info

type ThreadContext

type ThreadContext = C.struct_thread_context

func NewThreadContext

func NewThreadContext() *ThreadContext

func (*ThreadContext) Free

func (c *ThreadContext) Free()

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL