vanilladocs
vanillapunch.com
API / core/gpumemorytracker

core/gpumemorytracker

GPU 메모리 셈. (원본 GpuMemoryTracker 의 짝)

  • 텍스처, 렌더버퍼, 버퍼를 짓고 크기를 정하는 GlContext 의 함수(tex_image_2d, tex_storage_2d, renderbuffer_storage_multisample, buffer_data_size 같은 것)가 이 파일의 길을 불러 객체마다 바이트를 적는다. 지우면 빼고, 컨텍스트를 잃으면 모두 비운다.
  • 바이트는 형식과 크기로 셈한 이름값이다. (드라이버가 맞추는 줄 정렬, 타일 메모리, 멀티샘플 압축은 모른다. 멀티샘플 렌더버퍼는 샘플 수를 곱한다)
  • 주인은 객체를 지은 호출 스택의 위쪽 세 칸이다. (데스크탑은 지을 때 스택 칸만 잡고 이름은 읽을 때 한 번 푼다. 웹(wasm)은 스택이 없어 지은 소스 자리로 대신한다)
  • 기본은 꺼 둔다. 꺼져 있으면 GlContext 의 짓기, 크기 정하기 함수는 깃발 하나만 보고 지나가고 프레임마다 드는 일은 0 이다. 켜는 길은 EngineConfiguration::track_gpu_memory, Graphic::enable_gpu_memory_tracking, Engine::enable_gpu_memory_tracking 이고 켠 뒤에 지은 것부터 센다.

GPU memory tracking. (counterpart of the original GpuMemoryTracker)

  • The GlContext functions that create resources and set their sizes (tex_image_2d, tex_storage_2d, renderbuffer_storage_multisample, buffer_data_size and the like) call into this file and record bytes per object. Deleting removes the entry, and losing the context clears everything.
  • Bytes are nominal values computed from format and size. (row alignment, tile memory and multisample compression chosen by the driver are not known; multisample renderbuffers multiply by the sample count)
  • The owner is the top three frames of the creating call stack. (desktop captures the frames at creation and resolves the names when read; the web (wasm) has no stack and uses the creating source location)
  • It is off by default. While off, the creation and sizing functions of GlContext only look at one flag and nothing runs per frame. It is turned on by EngineConfiguration::track_gpu_memory, Graphic::enable_gpu_memory_tracking or Engine::enable_gpu_memory_tracking, and counts what is created after that.
예제Example추적을 켜고 쓰는 GPU 메모리 합 읽기Reading the GPU memory total with tracking turned on
use vanilla::{Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
engine.enable_gpu_memory_tracking();
if let Some(usage) = engine.read_gpu_memory_usage() {
	assert!(usage.total_bytes >= usage.canvas_bytes);
}

GpuMemoryKindUsagestruct traits Clone, Copy, PartialEq, Eq, Default, Debug

소스source

종류 하나의 GPU 메모리. (원본 kindTable 의 { count, bytes })

GPU memory of one kind. (the { count, bytes } of the original kindTable)

예제Example종류 칸의 기본값은 0 개 0 바이트The default of the kind slot is 0 items and 0 bytes
use vanilla::GpuMemoryKindUsage;

let usage = GpuMemoryKindUsage::default();
assert_eq!(usage.count, 0);
assert_eq!(usage.bytes, 0);
필드fieldpub count: u64#0.4.0 부터since 0.4.0소스source

살아 있는 객체 수.

Number of live objects.

반환Returnsu64

필드fieldpub bytes: u64#0.4.0 부터since 0.4.0소스source

바이트.

Bytes.

반환Returnsu64

GpuMemoryOwnerUsagestruct traits Clone, PartialEq, Eq, Debug

소스source

주인 하나의 GPU 메모리. (원본 ownerList 의 칸)

GPU memory of one owner. (an entry of the original ownerList)

예제Example주인 칸 하나 만들기Creating one owner slot
use vanilla::{GpuMemoryKind, GpuMemoryOwnerUsage};

let usage = GpuMemoryOwnerUsage {
	owner: String::from("Graphic::new"),
	kind: GpuMemoryKind::Texture,
	count: 2,
	bytes: 4096,
};
assert_eq!(usage.kind, GpuMemoryKind::Texture);
assert_eq!(usage.bytes, 4096);
필드fieldpub owner: String#0.4.0 부터since 0.4.0소스source

주인. (지은 호출 스택의 위쪽 세 칸을 " < " 로 이은 이름)

Owner. (the top three frames of the creating call stack joined with " < ")

반환ReturnsString

필드fieldpub kind: GpuMemoryKind#0.4.0 부터since 0.4.0소스source

종류.

Kind.

반환ReturnsGpuMemoryKind

필드fieldpub count: u64#0.4.0 부터since 0.4.0소스source

객체 수.

Object count.

반환Returnsu64

필드fieldpub bytes: u64#0.4.0 부터since 0.4.0소스source

바이트.

Bytes.

반환Returnsu64

GpuMemoryUsagestruct traits Clone, PartialEq, Eq, Debug

소스source

지금 쓰는 GPU 메모리. (원본 readGpuMemoryUsage 가 주는 { totalBytes, canvasBytes, kindTable, ownerList })

The GPU memory in use now. (what the original readGpuMemoryUsage gives: { totalBytes, canvasBytes, kindTable, ownerList })

예제Example엔진이 그래픽을 가졌으면 합을 읽는다Read the total if the engine has graphics
use vanilla::{Engine, EngineConfiguration};

let engine = Engine::new(EngineConfiguration::new());
if let Some(usage) = engine.read_gpu_memory_usage() {
	assert!(usage.total_bytes >= usage.canvas_bytes);
}
필드fieldpub total_bytes: u64#0.4.0 부터since 0.4.0소스source

합. (캔버스 기본 프레임 버퍼 몫 포함)

Total. (including the canvas default framebuffer share)

반환Returnsu64

필드fieldpub canvas_bytes: u64#0.4.0 부터since 0.4.0소스source

캔버스 기본 프레임 버퍼 몫. (색 4 바이트 + 깊이와 스텐실 4 바이트, 멀티샘플이면 샘플 수 4 를 곱하고 풀어 낸 색 한 장을 더한다)

Share of the canvas default framebuffer. (4 bytes color + 4 bytes depth and stencil; when multisampled, multiplied by the sample count 4 plus one resolved color image)

반환Returnsu64

필드fieldpub kind_table: BTreeMap<GpuMemoryKind, GpuMemoryKindUsage>#0.4.0 부터since 0.4.0소스source

종류별 몫. (세 종류 모두 칸이 있다)

Share by kind. (all three kinds have an entry)

반환ReturnsBTreeMap<GpuMemoryKind, GpuMemoryKindUsage>

필드fieldpub owner_list: Vec<GpuMemoryOwnerUsage>#0.4.0 부터since 0.4.0소스source

주인별 몫. (큰 것부터)

Share by owner. (largest first)

반환ReturnsVec<GpuMemoryOwnerUsage>

GpuMemoryKindenum traits Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug

짝Counterpart: vanilla.js GpuMemoryKind소스source

GPU 메모리 종류. (원본 GpuMemoryKind)

GPU memory kind. (original GpuMemoryKind)

이름Name설명Description
Texture텍스처.Texture.
Renderbuffer렌더버퍼. (멀티샘플 렌더 타겟의 색, 깊이)Renderbuffer. (color and depth of a multisample render target)
Buffer버퍼. (정점, 인덱스, 인스턴스, 유니폼)Buffer. (vertex, index, instance, uniform)
메서드methodpub fn get_name(self) -> &'static str#0.4.0 부터since 0.4.0소스source

종류 이름. (원본 GpuMemoryKind 의 값 "texture", "renderbuffer", "buffer")

Kind name. (the value of the original GpuMemoryKind: "texture", "renderbuffer", "buffer")

반환Returns&'static str 이름 글.The name text.

예제Example종류 이름 읽기Read the kind name
use vanilla::GpuMemoryKind;

assert_eq!(GpuMemoryKind::Texture.get_name(), "texture");