Class GPUMeshBufferCache
Namespace: ValveResourceFormat.Renderer
Assembly: Renderer.dll
Caches GPU mesh buffers and vertex array objects for efficient mesh rendering.
public class GPUMeshBufferCacheInheritance
Constructors
GPUMeshBufferCache(RendererContext)
Initializes a new GPU mesh buffer cache.
public GPUMeshBufferCache(RendererContext rendererContext)Parameters
rendererContext RendererContext
The renderer context owning this cache.
Properties
EmptyVAO
Gets a lazily created empty vertex array object with no attributes, used for attributeless draws.
public int EmptyVAO { get; }Property Value
QuadIndices
Gets the shared quad index buffer used for rendering quad-based geometry as triangle pairs.
public QuadIndexBuffer QuadIndices { get; }Property Value
VectorOneVertexBuffer
Gets a lazily created vertex buffer containing a single (1, 1, 1, 1) float4, used as a default color attribute.
public int VectorOneVertexBuffer { get; }Property Value
VertexArrayObjectCount
Gets the number of distinct vertex array objects currently cached.
public int VertexArrayObjectCount { get; }Property Value
Methods
Clear()
Disposes any cached gpu buffers and frees gpu vertex arrays.
public void Clear()CreateVertexIndexBuffers(string, VBIB)
Returns cached GPU buffers for the named mesh, uploading them if not yet present.
public GPUMeshBuffers CreateVertexIndexBuffers(string meshName, VBIB vbib)Parameters
meshName string
Unique name identifying the mesh.
vbib VBIB
Vertex and index buffer data to upload on first use.
Returns
The GPU buffers for the mesh.
DeleteVertexIndexBuffers(string)
Deletes and removes the cached GPU buffers and vertex arrays for the specified mesh.
public void DeleteVertexIndexBuffers(string meshName)Parameters
meshName string
Unique name identifying the mesh to delete.
GetVertexArrayObject(VertexDrawBuffer[], VsInputSignature, int, string?)
Returns a cached VAO for the given buffers, creating it if necessary. Locations are canonical, so it is valid for every shader that draws these buffers. Keyed by what a VAO fundamentally is, so callers never need to invent a unique name to keep unrelated geometry from colliding, and identical layouts dedupe automatically.
public int GetVertexArrayObject(VertexDrawBuffer[] vertexBuffers, Material.VsInputSignature inputSignature, int idxIndex, string? debugLabel = null)Parameters
vertexBuffers VertexDrawBuffer[]
Vertex buffer bindings for the draw call.
inputSignature Material.VsInputSignature
Material input signature mapping buffer semantics to shader attribute names.
idxIndex int
OpenGL handle of the index buffer, or 0 for non-indexed geometry.
debugLabel string?
Optional label applied to the VAO in debug builds when newly created.
Returns
The OpenGL VAO handle.
InvalidateVertexArrayObjectsForFreedBuffers(params int[])
Deletes and removes the cached VAOs built from the given GPU buffer handles, which the caller is about to delete. Because OpenGL never assigns a handle to two live objects at once, a handle passed here can only match VAOs built from that exact buffer, so this is a precise invalidation. Skipping it would leave a stale cache entry that silently matches whatever unrelated buffer GL later reuses that handle for.
public void InvalidateVertexArrayObjectsForFreedBuffers(params int[] bufferHandles)Parameters
bufferHandles int[]
Vertex and/or index buffer handles about to be freed.
UploadBuffersAndCreateVertexArray(string, VBIB, VsInputSignature)
Uploads the mesh buffers (if not yet present) and returns a VAO for the first vertex/index buffer pair, without exposing the GPU buffer handles to the caller.
public int UploadBuffersAndCreateVertexArray(string meshName, VBIB vbib, Material.VsInputSignature inputSignature = default)Parameters
meshName string
Unique name identifying the mesh.
vbib VBIB
Vertex and index buffer data; the first vertex buffer's layout describes the attributes.
inputSignature Material.VsInputSignature
Optional material input signature mapping buffer semantics to shader attribute names.
Returns
The OpenGL VAO handle.

