Class TextureStreamingHelper
Namespace: ValveResourceFormat.Renderer.Materials
Assembly: Renderer.dll
Reads texture mip data on background threads and gives it to the GPU over the frames that follow. A streamed texture starts out holding only its smallest mip. A texture materials draw then grows to the resolution the closest visible mesh drawing it needs, measured by TextureStreamingHelper.BeginDemandPass, and gives back mips when video memory runs out. A texture that no mesh draw call uses, such as one a particle draws, grows to its whole chain.
public sealed class TextureStreamingHelperInheritance
object ← TextureStreamingHelper
Constructors
TextureStreamingHelper(RendererContext)
Reads texture mip data on background threads and gives it to the GPU over the frames that follow. A streamed texture starts out holding only its smallest mip. A texture materials draw then grows to the resolution the closest visible mesh drawing it needs, measured by TextureStreamingHelper.BeginDemandPass, and gives back mips when video memory runs out. A texture that no mesh draw call uses, such as one a particle draws, grows to its whole chain.
public TextureStreamingHelper(RendererContext rendererContext)Parameters
rendererContext RendererContext
Properties
Mode
How textures load. Safe to change at any point; chains already under way finish either way.
public TextureStreamingMode Mode { get; set; }Property Value
Methods
CancelAllStreaming()
Throws away everything queued and hands its buffers back to the pool. Makes no GL calls, so it is safe during teardown with no current context.
public void CancelAllStreaming()CancelReads()
Stops reads from writing to the staging buffer and waits out the ones under way, so the buffer can go away with the GL context. Makes no GL calls.
public void CancelReads()DeleteStaging()
Deletes the staging buffer. Call with the GL context current, after the textures are deleted and streaming is cancelled.
public void DeleteStaging()DrainPendingLoads()
Waits for dispatched loads to land, so no thread is left reading a texture resource that the caller is about to dispose. Makes no GL calls. Never call this on the UI thread.
public void DrainPendingLoads()FinishAllStreaming(CancellationToken)
Blocks until every texture holds what it needs, to no budget. Must be called on a thread with a GL context, after TextureStreamingHelper.EndDemandPass.
public void FinishAllStreaming(CancellationToken cancellationToken = default)Parameters
cancellationToken CancellationToken
Stops early, leaving chains unfinished.
HasStorageToTrim()
Whether any idle texture holds storage past its smallest mip, which TextureStreamingHelper.TrimStorage() would free. Makes no GL calls.
public bool HasStorageToTrim()Returns
bool
Suspend()
Stops loading while nothing is drawing: drops the queued requests and the data waiting to be uploaded, and drops what reads still in flight deliver. The textures keep what they hold, and streaming resumes by itself with the next TextureStreamingHelper.Timeslice(float). Makes no GL calls.
public void Suspend()Timeslice(float)
Does one frame's worth of streaming: starts the loads it can, and gives the GPU whatever mip data has arrived since last time. Call once per frame, after TextureStreamingHelper.EndDemandPass, on a thread with a GL context.
public void Timeslice(float frameTime = 0.016666668)Parameters
frameTime float
Length of the previous frame in seconds. This call gets 20% of it, minus the time the previous call spent, so the cost of streaming cannot grow the budget.
TrimStorage()
Shrinks every idle texture to its smallest mip, the state it loaded in, so a viewer that is not drawn does not hold the finer ones. Must be called on a thread with the viewer's GL context.
public void TrimStorage()
