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.
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
종류 하나의 GPU 메모리. (원본 kindTable 의 { count, bytes })
GPU memory of one kind. (the { count, bytes } of the original kindTable)
use vanilla::GpuMemoryKindUsage;
let usage = GpuMemoryKindUsage::default();
assert_eq!(usage.count, 0);
assert_eq!(usage.bytes, 0);GpuMemoryOwnerUsagestruct traits Clone, PartialEq, Eq, Debug
주인 하나의 GPU 메모리. (원본 ownerList 의 칸)
GPU memory of one owner. (an entry of the original ownerList)
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);주인. (지은 호출 스택의 위쪽 세 칸을 " < " 로 이은 이름)
Owner. (the top three frames of the creating call stack joined with " < ")
반환ReturnsString
GpuMemoryUsagestruct traits Clone, PartialEq, Eq, Debug
지금 쓰는 GPU 메모리. (원본 readGpuMemoryUsage 가 주는 { totalBytes, canvasBytes, kindTable, ownerList })
The GPU memory in use now. (what the original readGpuMemoryUsage gives: { totalBytes, canvasBytes, kindTable, ownerList })
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);
}합. (캔버스 기본 프레임 버퍼 몫 포함)
Total. (including the canvas default framebuffer share)
반환Returnsu64
캔버스 기본 프레임 버퍼 몫. (색 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
종류별 몫. (세 종류 모두 칸이 있다)
Share by kind. (all three kinds have an entry)
반환ReturnsBTreeMap<GpuMemoryKind, GpuMemoryKindUsage>
주인별 몫. (큰 것부터)
Share by owner. (largest first)
반환ReturnsVec<GpuMemoryOwnerUsage>
GpuMemoryKindenum traits Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug
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) |
종류 이름. (원본 GpuMemoryKind 의 값 "texture", "renderbuffer", "buffer")
Kind name. (the value of the original GpuMemoryKind: "texture", "renderbuffer", "buffer")
반환Returns&'static str 이름 글.The name text.
use vanilla::GpuMemoryKind;
assert_eq!(GpuMemoryKind::Texture.get_name(), "texture");