hlsl

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: GPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	FillEntry     = "Fill"
	FillCountWord = 0
	FillValueWord = 1
	FillBaseWord  = 2
	FillConstants = 3
	FillWorkgroup = 64
)

The DX12 backend's fill kernel, which runs a fill: a compute list has no buffer fill command, and a UAV clear needs descriptor heaps the backend does not keep. The kernel is the backend's own, not a compute package entry, and the generator compiles it into the backend shader set under FillEntry. The device binds the buffer at the fill's first byte as the one root UAV and pushes the root constants at the positions below: the words to write, the value, and the first word of a piece of a split dispatch, since the device issues a fill wider than one dispatch in pieces as it does an index grid. FillLayout is the root signature the source declares.

View Source
const (
	RowThreadsWord = 5
	ThreadBaseWord = 6
	FixedWords     = 7
)

The root constants of every entry, a contract between the shell and the dx12 device alone: the dispatch record's five words, then two words the device fills for itself, then the module's length words. RowThreadsWord is a group entry's row thread count, which no built-in supplies (d_rowthreads). ThreadBaseWord is the first thread of a piece of a split index or span dispatch, zero for an unsplit one (d_base). FixedWords is the count of the words ahead of the lengths.

View Source
const FillSource = `` /* 339-byte string literal not displayed */

FillSource is the fill kernel.

View Source
const GroupWorkgroup = 128

GroupWorkgroup is a group entry's numthreads width, the unit the DX12 backend widens a group row in (GroupThreads).

View Source
const RootDwords = 64

RootDwords is the root signature's size limit in 32-bit words: a root descriptor costs two and a root constant one. No entry declares more constants than this, so a device's constant block of this size holds every entry's.

Variables

This section is empty.

Functions

func Lengths

func Lengths(m *compile.Module) int

Lengths is the module's length words: the most data buffers any entry with a variable-length buffer binds, or zero when none has one.

Types

type EntryPoint

type EntryPoint struct {
	Entry  int
	Func   string
	Source string
	Layout Layout
}

EntryPoint describes one emitted entry point: the entry's index, the entry's Go function name, which names its compiled blob, the source holding every function and this entry's shell, the root signature layout the shell declares, which carries the workgroup the host dispatches with. The shell's kernel function is named main in every source, so one compiler command serves every file.

type Layout

type Layout struct {
	Buffers   int
	Constants int
	Lengths   bool   // the entry binds a variable-length buffer, so the host fills the length words
	Dynamic   uint32 // the variable-length bindings, by bit
	Group     bool   // a group entry, so the host fills RowThreadsWord and never splits the grid
	Workgroup [2]int
}

Layout is an entry's root signature as the shell declares it and the device binds it: one root UAV descriptor per buffer, the data buffers in binding order then the params buffer when the entry takes one, and after them the 32-bit root constants, the FixedWords followed by the module's length words. Every entry of a module declares the same constant count, so the device pushes one block for every dispatch. The workgroup is the shell's numthreads, which the device rounds the grid to, so the blob and the device take it from this one rule.

func EntryLayout

func EntryLayout(m *compile.Module, i int) Layout

EntryLayout is entry i's layout.

func FillLayout

func FillLayout() Layout

FillLayout is the fill kernel's root signature as the device binds it: one root UAV and the FillConstants, at the fill's workgroup.

func (Layout) RootSignature

func (l Layout) RootSignature() string

RootSignature prints the layout in the root signature language: the descriptors at u0 upward, then the constants at b0.

type Output

type Output struct {
	Entries []EntryPoint
}

Output is one source per entry point.

func Emit

func Emit(m *compile.Module) (*Output, error)

Emit prints one HLSL source per entry point: the prelude, the structs and their params loaders, the tables, every function, and the entry's shell.

Jump to

Keyboard shortcuts

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