Documentation
¶
Overview ¶
package alignsl performs 16-byte alignment checking of struct fields and total size modulus checking of struct types to ensure WGSL (and GSL) compatibility.
Checks that struct sizes are an even multiple of 16 bytes (4 float32's), fields are 32 bit types: [U]Int32, Float32, and that fields that are other struct types are aligned at even 16 byte multiples.
Index ¶
- func CheckPackage(pkg *packages.Package, structTypes map[string]bool) error
- func CheckScope(cx *Context, sc *types.Scope, level int) bool
- func CheckStack(cx *Context) bool
- func CheckStruct(cx *Context, st *types.Struct, stName string) bool
- func CheckStructImpl(cx *Context, st *types.Struct, stName string) bool
- func TypeName(tp types.Type) string
- type Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPackage ¶
CheckPackage is main entry point for checking a package returns error string if any errors found. structTypes is a map of struct type names to check for alignment. any other struct types are purely internal not used for variables, so they don't need to be checked.
func CheckStack ¶
func CheckStruct ¶
CheckStruct is the top-level checker -- returns hasErr = true if there are any mis-aligned fields or total size of struct is not an even multiple of 16 bytes -- adds details to Errs. If struct is not on the cx.StructTypes list, it is skipped.
func CheckStructImpl ¶ added in v0.1.3
CheckStructImpl can be used for CheckStack -- doesn't check for top-level StructTypes membership.
Types ¶
type Context ¶
type Context struct {
Sizes types.Sizes // from package
Structs map[*types.Struct]string // structs that have been processed already -- value is name
Stack map[*types.Struct]string // structs to process in a second pass -- structs encountered during processing of other structs
StructTypes map[string]bool // top level list of struct types to examine -- skip anything at a top-level that is not in this list.
Errs []string // accumulating list of error strings -- empty if all good
}
Context for given package run