Module Sarek_push_constants

Sarek_push_constants - the push-constant block layout of a kernel signature.

One function decides where each field of the block sits, and both sides use it: the Vulkan backend to write the block at launch time, and the launch window to size a fused kernel's block before building it, so the two cannot drift. The block follows Sarek_ir_glsl.gen_push_constants: the length of every vector parameter first (one 4-byte int each, in declaration order), then every scalar parameter in declaration order, each field aligned to its own size (std430).

type width =
  1. | W4
  2. | W8

Size and alignment of one field: 4 bytes (int, float) or 8 bytes (int64_t, double).

val bytes_of_width : width -> int
val width_of_elttype : Sarek_ir_types.elttype -> width

The width of a scalar kernel parameter of this type: 8 bytes for TInt64 and TFloat64, 4 for the other primitive scalars (TInt32, TFloat32, TBool). Record, variant and array types are not push-constant scalars (the Vulkan launch path accepts only int32, int64, float32 and float64 scalar arguments) and are counted as 4 bytes here; a launch with such a parameter is refused by the backend, not sized by the window.

val vulkan_block_limit : int

The block size Vulkan guarantees (maxPushConstantsSize is at least this), and the range the Vulkan backend declares in its pipeline layouts.

val place : width list -> int list * int

place fields is the byte offset of each field, in order, and the size of the block (the end of the last field; 0 for no fields).

val fields_of_params : Sarek_ir_types.decl list -> width list

The fields of a kernel signature: W4 per vector parameter, then the width of each scalar parameter, in declaration order.

val block_bytes : Sarek_ir_types.decl list -> int

Size in bytes of the block of the signature params.

val fused_block_bytes : Sarek_ir_types.decl list list -> int

Size in bytes of the block of the kernel that horizontal fusion (Fusion_horizontal.fuse) builds from kernels with these parameter lists: every member's parameters in member order, then an (offset, size) pair of int32 scalars per member.