GpuService

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

ShotInstanceservicenot creatablecomingImages and GPU

Up and coming

Your program's line to the graphics card: make textures, load shaders and draw.

Write use GpuService. Every GpuTexture, ShaderProgram and MeshBatch it makes is its child, and each is freed at its Destroy and when the run ends, so a program that crashes leaves no GPU memory behind. TextureMemory says how many bytes your textures hold.

A service: write use GpuService.

Properties

NameTypeDefaultDescription
Backend"Python" | "Host"read-onlyRead-only: what the textures and shaders run on; Host is the coming native runtime's own OpenGL 3.3 context.
Connectedbooleanread-only
MaxTextureSizenumberread-onlyRead-only: the largest texture size, as the OpenGL context reports it.
TextureMemorynumberread-onlyRead-only: the bytes held by the textures this program made.

Methods

NameArgumentsReturnsDescription
CreateTextureAsync
yields
(size: Vector2, options: { Format: TextureFormat?, Filter: TextureFilter?, Fill: Color3? }?)(GpuTexture?, string?)Makes a texture as a child of GpuService, freed when the run ends; Format is RGBA32F unless you ask for RGBA8.
LoadTextureAsync
yields
(source: string | PathHandler | buffer)(GpuTexture?, string?)Loads a PNG or JPG, from a path or the file's bytes, into a new texture.
LoadShaderAsync
yields
(fragment: string | ShaderModule, vertex: (string | ShaderModule)?)(ShaderProgram?, string?)Compiles a program from a folder with Vertex.vert and Fragment.frag, a lone .frag over the built-in full-picture vertex shader, or ShaderModules.
CreateNoiseAsync
yields
(size: Vector2, kind: "White" | "Perlin", scale: number?, seed: number?)(GpuTexture?, string?)
CreateMeshBatchAsync
yields
(mesh: EditableMesh, texture: GpuTexture?)(MeshBatch?, string?)Makes a MeshBatch that draws many copies of one mesh, with an optional texture.

Events

NamePassesDescription
ConnectionChanged(boolean)Fires with whether the GPU link is up when it drops or returns; after a reconnect every object it made is gone.
From ShotInstance 33