VGF Python API Reference

The Python API is provided by the vgfpy extension module. It supports encoding VGF files and decoding their header, module, model-sequence, model-resource, and constant sections. Array data is accepted through the Python buffer protocol and decoded array data is returned as a memoryview.

Build and import the bindings

Build the bindings from a VGF Library source checkout:

python3 scripts/build.py --build-pylib

The extension is written to build/src by default. Add that directory to PYTHONPATH when running a Python application:

export PYTHONPATH="$PWD/build/src${PYTHONPATH:+:$PYTHONPATH}"

Then import the module:

import vgfpy as vgf

Python example

Create a minimal VGF file in memory, then inspect its header and module table:

import io

import vgfpy as vgf

encoder = vgf.CreateEncoder(vkHeaderVersion=0)
encoder.AddModule(vgf.ModuleType.Graph, "graph", "main")
encoder.Finish()

output = io.BytesIO()
encoder.WriteTo(output)
data = output.getbuffer()

header = vgf.CreateHeaderDecoder(data, vgf.HeaderSize(), len(data))
modules = vgf.CreateModuleTableDecoder(
    data[header.GetModuleTableOffset() :], header.GetModuleTableSize()
)
print(modules.getModuleName(0))

Python entry points

API

Purpose

CreateEncoder()

Create an encoder for constructing a VGF file.

CreateHeaderDecoder()

Validate a VGF header and inspect its version and sections.

CreateModuleTableDecoder()

Inspect the modules stored in a VGF file.

CreateModelSequenceTableDecoder()

Inspect segments, bindings, and model inputs and outputs.

CreateModelResourceTableDecoder()

Inspect model resources, tensor metadata, and sampler configuration.

CreateConstantDecoder()

Inspect constant metadata and data.

Encoder

vgfpy.CreateEncoder(vkHeaderVersion: SupportsInt | SupportsIndex) → vgfpy.Encoder

Create an encoder using the supplied Vulkan header version.

class vgfpy.Encoder

Construct and serialize a VGF file.

AddBindingSlot(self: vgfpy.Encoder, binding: SupportsInt | SupportsIndex, resource: vgfpy.ResourceRef) → vgfpy.BindingSlotRef

Add a binding slot associated with a model resource.

AddConstant(self: vgfpy.Encoder, resourceRef: vgfpy.ResourceRef, buffer: collections.abc.Buffer, sparsityDimension: SupportsInt | SupportsIndex = -1) → vgfpy.ConstantRef

Add buffer-protocol data for a constant model resource.

AddConstantResource(self: vgfpy.Encoder, vkFormat: SupportsInt | SupportsIndex, shape: collections.abc.Sequence[SupportsInt | SupportsIndex], strides: collections.abc.Sequence[SupportsInt | SupportsIndex]) → vgfpy.ResourceRef

Add a constant resource to the model resource table.

AddDescriptorSetInfo(self: vgfpy.Encoder, bindings: collections.abc.Sequence[vgfpy.BindingSlotRef] = [], setIndex: SupportsInt | SupportsIndex = 4294967295) → vgfpy.DescriptorSetInfoRef

Add descriptor-set information for binding slots.

AddInputResource(self: vgfpy.Encoder, vkDescriptorType: SupportsInt | SupportsIndex, vkFormat: SupportsInt | SupportsIndex, shape: collections.abc.Sequence[SupportsInt | SupportsIndex], strides: collections.abc.Sequence[SupportsInt | SupportsIndex], aliasGroupId: SupportsInt | SupportsIndex | None = None) → vgfpy.ResourceRef

Add an input to the model resource table.

AddIntermediateResource(self: vgfpy.Encoder, vkDescriptorType: SupportsInt | SupportsIndex, vkFormat: SupportsInt | SupportsIndex, shape: collections.abc.Sequence[SupportsInt | SupportsIndex], strides: collections.abc.Sequence[SupportsInt | SupportsIndex], aliasGroupId: SupportsInt | SupportsIndex | None = None) → vgfpy.ResourceRef

Add an intermediate value to the model resource table.

AddModelSequenceInputsOutputs(self: vgfpy.Encoder, inputs: collections.abc.Sequence[vgfpy.BindingSlotRef] = [], inputNames: collections.abc.Sequence[str] = [], outputs: collections.abc.Sequence[vgfpy.BindingSlotRef] = [], outputNames: collections.abc.Sequence[str] = []) → None

Set the model-level input and output binding slots and optional names.

AddModule()

Overloaded function.

1. AddModule(self: vgfpy.Encoder, type: vgfpy.ModuleType, name: str, entryPoint: str, code: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex] = []) -> vgfpy.ModuleRef

Add a SPIR-V module and return its reference.

2. AddModule(self: vgfpy.Encoder, type: vgfpy.ModuleType, name: str, entryPoint: str, shaderType: vgfpy.ShaderType, code: str = '') -> vgfpy.ModuleRef

Add a source-language shader module and return its reference.

AddOutputResource(self: vgfpy.Encoder, vkDescriptorType: SupportsInt | SupportsIndex, vkFormat: SupportsInt | SupportsIndex, shape: collections.abc.Sequence[SupportsInt | SupportsIndex], strides: collections.abc.Sequence[SupportsInt | SupportsIndex], aliasGroupId: SupportsInt | SupportsIndex | None = None) → vgfpy.ResourceRef

Add an output to the model resource table.

AddPlaceholderModule(self: vgfpy.Encoder, type: vgfpy.ModuleType, name: str, entryPoint: str) → vgfpy.ModuleRef

Deprecated: add a module without code. Use AddModule().

AddPushConstRange(self: vgfpy.Encoder, stageFlags: SupportsInt | SupportsIndex, offset: SupportsInt | SupportsIndex, size: SupportsInt | SupportsIndex) → vgfpy.PushConstRangeRef

Add a push-constant range to a segment.

AddSamplerConfig(self: vgfpy.Encoder, resource: vgfpy.ResourceRef, samplerMinFilter: SupportsInt | SupportsIndex, samplerMagFilter: SupportsInt | SupportsIndex, samplerAddressModeU: SupportsInt | SupportsIndex, samplerAddressModeV: SupportsInt | SupportsIndex, samplerBorderColor: SupportsInt | SupportsIndex) → None

Set sampler metadata for a model resource.

AddSegmentInfo()

Overloaded function.

1. AddSegmentInfo(self: vgfpy.Encoder, module: vgfpy.ModuleRef, name: str, descriptors: collections.abc.Sequence[vgfpy.DescriptorSetInfoRef] = [], inputs: collections.abc.Sequence[vgfpy.BindingSlotRef] = [], outputs: collections.abc.Sequence[vgfpy.BindingSlotRef] = [], constants: collections.abc.Sequence[vgfpy.ConstantRef] = [], dispatchShape: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"] = [0, 0, 0], pushConstRanges: collections.abc.Sequence[vgfpy.PushConstRangeRef] = []) -> vgfpy.SegmentInfoRef

Add a segment using legacy constant references.

2. AddSegmentInfo(self: vgfpy.Encoder, module: vgfpy.ModuleRef, name: str, descriptors: collections.abc.Sequence[vgfpy.DescriptorSetInfoRef], inputs: collections.abc.Sequence[vgfpy.BindingSlotRef], outputs: collections.abc.Sequence[vgfpy.BindingSlotRef], constantBindings: collections.abc.Sequence[vgfpy.GraphConstantBindingRef], dispatchShape: typing.Annotated[collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], "FixedSize(3)"] = [0, 0, 0], pushConstRanges: collections.abc.Sequence[vgfpy.PushConstRangeRef] = []) -> vgfpy.SegmentInfoRef

Add a segment using explicit graph constant bindings.

Finish(self: vgfpy.Encoder) → None

Finish encoding the VGF file before writing it.

SetAliasGroup(self: vgfpy.Encoder, resource: vgfpy.ResourceRef, aliasGroupId: SupportsInt | SupportsIndex) → None

Assign an alias group to a non-constant model resource.

WriteTo(self: vgfpy.Encoder, output: object) → bool

Write the finished VGF file to a binary Python IO stream.

Encoder references

Encoder methods return reference objects that identify entries while the VGF file is being constructed.

class vgfpy.ModuleRef(arg0: SupportsInt | SupportsIndex)

Reference to an encoded module.

property reference
Type:

int

Module-table index.

Read-only.

class vgfpy.ResourceRef(arg0: SupportsInt | SupportsIndex)

Reference to an encoded model resource.

property reference
Type:

int

Model-resource-table index.

Read-only.

class vgfpy.ConstantRef(arg0: SupportsInt | SupportsIndex)

Reference to encoded constant data.

property reference
Type:

int

Constant-table index.

Read-only.

class vgfpy.GraphConstantBindingRef(arg0: SupportsInt | SupportsIndex, arg1: vgfpy.ConstantRef)

Map a graph constant ID to encoded constant data.

property constant
Type:

vgfpy.ConstantRef

Encoded constant reference.

Read-only.

property graphConstantId
Type:

int

SPIR-V graph constant ID.

Writable.

class vgfpy.BindingSlotRef(arg0: SupportsInt | SupportsIndex)

Reference to an encoded binding slot.

property reference
Type:

int

Binding-slot index.

Read-only.

class vgfpy.DescriptorSetInfoRef(arg0: SupportsInt | SupportsIndex)

Reference to encoded descriptor-set information.

property reference
Type:

int

Descriptor-set information index.

Read-only.

class vgfpy.SegmentInfoRef(arg0: SupportsInt | SupportsIndex)

Reference to an encoded model segment.

property reference
Type:

int

Model-segment index.

Read-only.

class vgfpy.PushConstRangeRef(arg0: SupportsInt | SupportsIndex)

Reference to an encoded push-constant range.

property reference
Type:

int

Push-constant-range index.

Read-only.

Header decoder

Decoder factory functions retain a reference to their input buffer. Keep the buffer unchanged for the lifetime of the returned decoder.

vgfpy.HeaderSize() → int

Return the encoded VGF header size in bytes.

vgfpy.HeaderDecoderSize() → int

Return the native header decoder size in bytes.

vgfpy.CreateHeaderDecoder(data: collections.abc.Buffer, headerSize: SupportsInt | SupportsIndex, fileSize: SupportsInt | SupportsIndex) → vgfpy.HeaderDecoder

Create a header decoder over a buffer containing VGF file data.

class vgfpy.FormatVersion

Semantic version stored in a VGF header.

property major
Type:

int

Major version.

Writable.

property minor
Type:

int

Minor version.

Writable.

property patch
Type:

int

Patch version.

Writable.

class vgfpy.HeaderDecoder

Inspect and validate a VGF header.

CheckVersion(self: vgfpy.HeaderDecoder) → bool

Return whether the VGF format version is supported.

GetConstantsOffset(self: vgfpy.HeaderDecoder) → int

Return the constant-section byte offset.

GetConstantsSize(self: vgfpy.HeaderDecoder) → int

Return the constant-section size in bytes.

GetEncoderVulkanHeadersVersion(self: vgfpy.HeaderDecoder) → int

Return the Vulkan header version used by the encoder.

GetMajor(self: vgfpy.HeaderDecoder) → int

Return the VGF major version.

GetMinor(self: vgfpy.HeaderDecoder) → int

Return the VGF minor version.

GetModelResourceTableOffset(self: vgfpy.HeaderDecoder) → int

Return the model-resource-table byte offset.

GetModelResourceTableSize(self: vgfpy.HeaderDecoder) → int

Return the model-resource-table size in bytes.

GetModelSequenceTableOffset(self: vgfpy.HeaderDecoder) → int

Return the model-sequence-table byte offset.

GetModelSequenceTableSize(self: vgfpy.HeaderDecoder) → int

Return the model-sequence-table size in bytes.

GetModuleTableOffset(self: vgfpy.HeaderDecoder) → int

Return the module-table byte offset.

GetModuleTableSize(self: vgfpy.HeaderDecoder) → int

Return the module-table size in bytes.

GetPatch(self: vgfpy.HeaderDecoder) → int

Return the VGF patch version.

GetVersion(self: vgfpy.HeaderDecoder) → vgfpy.FormatVersion

Return the VGF format version.

IsLatestVersion(self: vgfpy.HeaderDecoder) → bool

Return whether the file uses the latest VGF version.

IsValid(self: vgfpy.HeaderDecoder) → bool

Return whether the VGF header magic value is valid.

Module-table decoder

vgfpy.ModuleTableDecoderSize() → int

Return the native module-table decoder size in bytes.

vgfpy.CreateModuleTableDecoder(data: collections.abc.Buffer, size: SupportsInt | SupportsIndex) → vgfpy.ModuleTableDecoder

Create a module-table decoder over an encoded section.

class vgfpy.ModuleTableDecoder

Inspect modules in a VGF module table.

getGLSLModuleCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → str

Return GLSL source, or an empty string.

getHLSLModuleCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → str

Return HLSL source, or an empty string.

getModuleCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → object

Deprecated: return SPIR-V code as a memoryview. Use getSPIRVModuleCode().

getModuleEntryPoint(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → str

Return the module entry point.

getModuleName(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → str

Return the module name.

getModuleType(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → vgfpy.ModuleType

Return the module type.

getSPIRVModuleCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → object

Return SPIR-V code as a memoryview, or None when absent.

hasGLSLCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether GLSL code is present.

hasHLSLCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether HLSL code is present.

hasSPIRV(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Deprecated: return whether the module contains SPIR-V. Use isSPIRV().

hasSPIRVCode(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether SPIR-V code is present.

isGLSL(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether the module uses GLSL.

isHLSL(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether the module uses HLSL.

isSPIRV(self: vgfpy.ModuleTableDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether the module uses SPIR-V.

size(self: vgfpy.ModuleTableDecoder) → int

Return the number of modules.

Model-sequence-table decoder

vgfpy.ModelSequenceTableDecoderSize() → int

Return the native model-sequence-table decoder size in bytes.

vgfpy.CreateModelSequenceTableDecoder(data: collections.abc.Buffer, size: SupportsInt | SupportsIndex) → vgfpy.ModelSequenceTableDecoder

Create a model-sequence-table decoder over an encoded section.

class vgfpy.GraphConstantBinding

Decoded mapping from a graph constant ID to a constant-table index.

property constantIndex
Type:

int

Constant-table index.

Writable.

property graphConstantId
Type:

int

SPIR-V graph constant ID.

Writable.

class vgfpy.ModelSequenceTableDecoder

Inspect segments and bindings in a VGF model-sequence table.

getBindingSlotBinding(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.BindingSlotArrayHandle_s, slotIdx: SupportsInt | SupportsIndex) → int

Return the Vulkan binding number for a binding slot.

getBindingSlotMrtIndex(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.BindingSlotArrayHandle_s, slotIdx: SupportsInt | SupportsIndex) → int

Return the model-resource-table index for a binding slot.

getBindingsSize(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.BindingSlotArrayHandle_s) → int

Return the number of binding slots in an opaque handle.

getDescriptorBindingSlotsHandle(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex, descIdx: SupportsInt | SupportsIndex) → vgfpy.BindingSlotArrayHandle_s

Return the binding slots for one descriptor set as an opaque handle.

getModelSequenceInputBindingSlotsHandle(self: vgfpy.ModelSequenceTableDecoder) → vgfpy.BindingSlotArrayHandle_s

Return model input binding slots as an opaque handle.

getModelSequenceInputNamesHandle(self: vgfpy.ModelSequenceTableDecoder) → vgfpy.NameArrayHandle_s

Return model input names as an opaque handle.

getModelSequenceOutputBindingSlotsHandle(self: vgfpy.ModelSequenceTableDecoder) → vgfpy.BindingSlotArrayHandle_s

Return model output binding slots as an opaque handle.

getModelSequenceOutputNamesHandle(self: vgfpy.ModelSequenceTableDecoder) → vgfpy.NameArrayHandle_s

Return model output names as an opaque handle.

getName(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.NameArrayHandle_s, nameIdx: SupportsInt | SupportsIndex) → str

Return a name from an opaque handle.

getNamesSize(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.NameArrayHandle_s) → int

Return the number of names in an opaque handle.

getPushConstRangeOffset(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.PushConstantRangeHandle_s, rangeIdx: SupportsInt | SupportsIndex) → int

Return the byte offset of a push-constant range.

getPushConstRangeSize(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.PushConstantRangeHandle_s, rangeIdx: SupportsInt | SupportsIndex) → int

Return the byte size of a push-constant range.

getPushConstRangeStageFlags(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.PushConstantRangeHandle_s, rangeIdx: SupportsInt | SupportsIndex) → int

Return the Vulkan stage flags for a push-constant range.

getPushConstRangesSize(self: vgfpy.ModelSequenceTableDecoder, handle: vgfpy.PushConstantRangeHandle_s) → int

Return the number of push-constant ranges in an opaque handle.

getSegmentConstantBindings(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → list

Return graph constant bindings for a segment.

getSegmentConstantIndexes(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → object

Return legacy constant-table indexes as a memoryview.

getSegmentDescriptorSetIndex(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex, descIdx: SupportsInt | SupportsIndex) → int

Return the explicit descriptor-set index.

getSegmentDescriptorSetInfosSize(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → int

Return the number of descriptor sets for a segment.

getSegmentDispatchShape(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → object

Return the three-dimensional dispatch shape as a memoryview.

getSegmentInputBindingSlotsHandle(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → vgfpy.BindingSlotArrayHandle_s

Return a segment’s input binding slots as an opaque handle.

getSegmentModuleIndex(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → int

Return the segment’s module-table index.

getSegmentName(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → str

Return the segment name.

getSegmentOutputBindingSlotsHandle(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → vgfpy.BindingSlotArrayHandle_s

Return a segment’s output binding slots as an opaque handle.

getSegmentPushConstRange(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → vgfpy.PushConstantRangeHandle_s

Return a segment’s push-constant ranges as an opaque handle.

getSegmentType(self: vgfpy.ModelSequenceTableDecoder, segmentIdx: SupportsInt | SupportsIndex) → vgfpy.ModuleType

Return the segment module type.

modelSequenceTableSize(self: vgfpy.ModelSequenceTableDecoder) → int

Return the number of model segments.

The binding-slot, name, and push-constant-range handle objects are opaque. Pass them unchanged to the corresponding methods on ModelSequenceTableDecoder.

class vgfpy.BindingSlotArrayHandle_s

Opaque binding-slot array handle.

class vgfpy.NameArrayHandle_s

Opaque name array handle.

class vgfpy.PushConstantRangeHandle_s

Opaque push-constant-range array handle.

Model-resource-table decoder

vgfpy.ModelResourceTableDecoderSize() → int

Return the native model-resource-table decoder size in bytes.

vgfpy.CreateModelResourceTableDecoder(data: collections.abc.Buffer, size: SupportsInt | SupportsIndex) → vgfpy.ModelResourceTableDecoder

Create a model-resource-table decoder over an encoded section.

class vgfpy.ModelResourceTableDecoder

Inspect resources and tensor metadata in a VGF model-resource table.

getAliasGroupId(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → int | None

Return the alias group ID, or None when absent.

getCategory(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → vgfpy.ResourceCategory

Return the resource usage category.

getDescriptorType(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → int | None

Return the Vulkan descriptor type, or None when absent.

getSamplerConfigAddressModeU(self: vgfpy.ModelResourceTableDecoder, handle: vgfpy.SamplerConfigHandle_s) → int

Return the Vulkan U-axis address mode.

getSamplerConfigAddressModeV(self: vgfpy.ModelResourceTableDecoder, handle: vgfpy.SamplerConfigHandle_s) → int

Return the Vulkan V-axis address mode.

getSamplerConfigBorderColor(self: vgfpy.ModelResourceTableDecoder, handle: vgfpy.SamplerConfigHandle_s) → int

Return the Vulkan border color value.

getSamplerConfigHandle(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → vgfpy.SamplerConfigHandle_s

Return sampler configuration as an opaque handle, or None when absent.

getSamplerConfigMagFilter(self: vgfpy.ModelResourceTableDecoder, handle: vgfpy.SamplerConfigHandle_s) → int

Return the Vulkan magnification filter value.

getSamplerConfigMinFilter(self: vgfpy.ModelResourceTableDecoder, handle: vgfpy.SamplerConfigHandle_s) → int

Return the Vulkan minimum filter value.

getTensorShape(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → object

Return the tensor shape as a memoryview, or None when absent.

getTensorStride(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → object

Return the tensor strides as a memoryview, or None when absent.

getVkFormat(self: vgfpy.ModelResourceTableDecoder, id: SupportsInt | SupportsIndex) → int

Return the Vulkan format.

size(self: vgfpy.ModelResourceTableDecoder) → int

Return the number of model resources.

Sampler configuration handles are opaque. Pass them unchanged to the sampler configuration accessors on ModelResourceTableDecoder.

class vgfpy.SamplerConfigHandle_s

Opaque sampler configuration handle.

Constant decoder

vgfpy.ConstantDecoderSize() → int

Return the native constant decoder size in bytes.

vgfpy.CreateConstantDecoder(data: collections.abc.Buffer, size: SupportsInt | SupportsIndex) → vgfpy.ConstantDecoder

Create a constant decoder over an encoded section.

class vgfpy.ConstantDecoder

Inspect constant metadata and data in a VGF constant section.

getConstant(self: vgfpy.ConstantDecoder, idx: SupportsInt | SupportsIndex) → object

Return constant bytes as a memoryview, or None when absent.

getConstantMrtIndex(self: vgfpy.ConstantDecoder, idx: SupportsInt | SupportsIndex) → int

Return the model-resource-table index associated with a constant.

getConstantSparsityDimension(self: vgfpy.ConstantDecoder, idx: SupportsInt | SupportsIndex) → int

Return the sparse dimension, or -1 for a non-sparse constant.

isSparseConstant(self: vgfpy.ConstantDecoder, idx: SupportsInt | SupportsIndex) → bool

Return whether a constant is sparse.

size(self: vgfpy.ConstantDecoder) → int

Return the number of constants.

Common types and functions

vgfpy.FourCC(a: str, b: str, c: str, d: str) → vgfpy.FourCCValue

Create a four-character code value.

class vgfpy.FourCCValue(arg0: str, arg1: str, arg2: str, arg3: str)

A four-character code value.

property a
Type:

str

First character.

Writable.

property b
Type:

str

Second character.

Writable.

property c
Type:

str

Third character.

Writable.

property d
Type:

str

Fourth character.

Writable.

vgfpy.UndefinedFormat() → int

Return the value representing an undefined Vulkan format.

Enumerations

The following reference is generated from the exported Python enumerations.

class vgfpy.ModuleType(value: SupportsInt | SupportsIndex)

Type of module stored in a VGF file.

Members:

Compute

Graph

Compute = <ModuleType.Compute: 0>
Graph = <ModuleType.Graph: 1>
property name
Type:

str

Read-only.

property value
Type:

int

Read-only.

class vgfpy.ShaderType(value: SupportsInt | SupportsIndex)

Source language used by a shader module.

Members:

Glsl

Hlsl

Glsl = <ShaderType.Glsl: 0>
Hlsl = <ShaderType.Hlsl: 1>
property name
Type:

str

Read-only.

property value
Type:

int

Read-only.

class vgfpy.ResourceCategory(value: SupportsInt | SupportsIndex)

Usage category of a model resource.

Members:

Input

Output

Intermediate

Constant

Constant = <ResourceCategory.Constant: 3>
Input = <ResourceCategory.Input: 0>
Intermediate = <ResourceCategory.Intermediate: 2>
Output = <ResourceCategory.Output: 1>
property name
Type:

str

Read-only.

property value
Type:

int

Read-only.

Header constants

The module exposes the following constants for inspecting the encoded header layout. Section constants are provided for the module, model-sequence, model-resource, and constant sections.

Category

Constants

Magic and version

HEADER_MAGIC_VALUE, HEADER_MAGIC_VALUE_OLD, HEADER_MAJOR_VERSION_VALUE, HEADER_MINOR_VERSION_VALUE, HEADER_PATCH_VERSION_VALUE

Header layout

HEADER_MAGIC_OFFSET, HEADER_VK_HEADER_VERSION_OFFSET, HEADER_VERSION_OFFSET, HEADER_HEADER_SIZE_VALUE, HEADER_FIRST_SECTION_OFFSET, HEADER_SECOND_SECTION_OFFSET, HEADER_THIRD_SECTION_OFFSET, HEADER_FOURTH_SECTION_OFFSET

Module section

HEADER_MODULE_SECTION_OFFSET, HEADER_MODULE_SECTION_OFFSET_OFFSET, HEADER_MODULE_SECTION_SIZE_OFFSET

Model-sequence section

HEADER_MODEL_SEQUENCE_SECTION_OFFSET, HEADER_MODEL_SEQUENCE_SECTION_OFFSET_OFFSET, HEADER_MODEL_SEQUENCE_SECTION_SIZE_OFFSET

Model-resource section

HEADER_MODEL_RESOURCE_SECTION_OFFSET, HEADER_MODEL_RESOURCE_SECTION_OFFSET_OFFSET, HEADER_MODEL_RESOURCE_SECTION_SIZE_OFFSET

Constant section

HEADER_CONSTANT_SECTION_OFFSET, HEADER_CONSTANT_SECTION_OFFSET_OFFSET, HEADER_CONSTANT_SECTION_SIZE_OFFSET

vgfpy.HEADER_MAGIC_VALUE_OLD = 4041331395
vgfpy.HEADER_MAGIC_VALUE = vgfpy.FourCCValue('V', 'G', 'F', '1')
vgfpy.HEADER_MAGIC_OFFSET = 0
vgfpy.HEADER_VK_HEADER_VERSION_OFFSET = 4
vgfpy.HEADER_VERSION_OFFSET = 8
vgfpy.HEADER_HEADER_SIZE_VALUE = 128
vgfpy.HEADER_FIRST_SECTION_OFFSET = 16
vgfpy.HEADER_SECOND_SECTION_OFFSET = 32
vgfpy.HEADER_THIRD_SECTION_OFFSET = 48
vgfpy.HEADER_FOURTH_SECTION_OFFSET = 64
vgfpy.HEADER_MODULE_SECTION_OFFSET = 16
vgfpy.HEADER_MODULE_SECTION_OFFSET_OFFSET = 16
vgfpy.HEADER_MODULE_SECTION_SIZE_OFFSET = 24
vgfpy.HEADER_MODEL_SEQUENCE_SECTION_OFFSET = 32
vgfpy.HEADER_MODEL_SEQUENCE_SECTION_OFFSET_OFFSET = 32
vgfpy.HEADER_MODEL_SEQUENCE_SECTION_SIZE_OFFSET = 40
vgfpy.HEADER_MODEL_RESOURCE_SECTION_OFFSET = 48
vgfpy.HEADER_MODEL_RESOURCE_SECTION_OFFSET_OFFSET = 48
vgfpy.HEADER_MODEL_RESOURCE_SECTION_SIZE_OFFSET = 56
vgfpy.HEADER_CONSTANT_SECTION_OFFSET = 64
vgfpy.HEADER_CONSTANT_SECTION_OFFSET_OFFSET = 64
vgfpy.HEADER_CONSTANT_SECTION_SIZE_OFFSET = 72
vgfpy.HEADER_MAJOR_VERSION_VALUE = 0
vgfpy.HEADER_MINOR_VERSION_VALUE = 5
vgfpy.HEADER_PATCH_VERSION_VALUE = 0