docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
---
|
||||
id: wiki-2026-0508-gpu-resources
|
||||
title: GPU Resources
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [GPU Buffer, GPU Texture, Render Target, WebGPU Resources]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [gpu, webgpu, graphics, rendering]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: webgpu
|
||||
---
|
||||
|
||||
# GPU Resources
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 GPU 는 매 buffer + texture + sampler + binding 의 매 4 primitive 위에서 매 모든 것을 그린다."**. Buffer 는 매 raw memory, texture 는 매 sampled grid, render target 은 매 write 가능한 texture. 매 2026 WebGPU / Vulkan / Metal 모두 매 같은 model.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 Buffer 종류
|
||||
- **Vertex buffer**: 매 vertex attribute (position, normal, uv).
|
||||
- **Index buffer**: 매 triangle index.
|
||||
- **Uniform buffer (UBO)**: 매 small constant data — 매 16KB 권장.
|
||||
- **Storage buffer (SSBO)**: 매 large read/write — 매 compute shader.
|
||||
- **Staging buffer**: 매 CPU→GPU upload 의 매 intermediate.
|
||||
|
||||
### 매 Texture 종류
|
||||
- **Sampled texture**: 매 shader 에서 매 sample.
|
||||
- **Storage texture**: 매 compute write.
|
||||
- **Depth/Stencil**: 매 depth test.
|
||||
- **Cube map / 3D / Array**: 매 special layout.
|
||||
- **Format**: rgba8unorm, rgba16float, bgra8unorm-srgb, depth32float, etc.
|
||||
|
||||
### 매 Render Target
|
||||
- 매 texture + 매 RENDER_ATTACHMENT usage. 매 framebuffer 의 매 color/depth attachment.
|
||||
- 매 swap chain texture 는 매 surface 가 매 제공 (acquireNextImage / getCurrentTexture).
|
||||
|
||||
### 매 Binding model
|
||||
- **WebGPU/Vulkan**: bind group / descriptor set — 매 group of resources.
|
||||
- **Layout**: 매 shader 와 매 CPU 가 매 합의한 schema.
|
||||
|
||||
### 매 응용
|
||||
1. PBR renderer — 매 g-buffer (multiple render target).
|
||||
2. Post-processing — 매 ping-pong render target.
|
||||
3. Compute particles — 매 storage buffer + indirect draw.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### WebGPU buffer create + write
|
||||
```typescript
|
||||
const buf = device.createBuffer({
|
||||
size: 256,
|
||||
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
||||
});
|
||||
device.queue.writeBuffer(buf, 0, new Float32Array([1, 2, 3, 4]));
|
||||
```
|
||||
|
||||
### Vertex buffer + draw
|
||||
```typescript
|
||||
const verts = new Float32Array([0, 0.5, 0, -0.5, -0.5, 0, 0.5, -0.5, 0]);
|
||||
const vb = device.createBuffer({
|
||||
size: verts.byteLength,
|
||||
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
||||
});
|
||||
device.queue.writeBuffer(vb, 0, verts);
|
||||
|
||||
pass.setVertexBuffer(0, vb);
|
||||
pass.draw(3);
|
||||
```
|
||||
|
||||
### Texture upload
|
||||
```typescript
|
||||
const img = await createImageBitmap(blob);
|
||||
const tex = device.createTexture({
|
||||
size: [img.width, img.height, 1],
|
||||
format: 'rgba8unorm',
|
||||
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT,
|
||||
});
|
||||
device.queue.copyExternalImageToTexture(
|
||||
{ source: img },
|
||||
{ texture: tex },
|
||||
[img.width, img.height],
|
||||
);
|
||||
```
|
||||
|
||||
### Render target (offscreen)
|
||||
```typescript
|
||||
const colorTex = device.createTexture({
|
||||
size: [w, h, 1],
|
||||
format: 'rgba16float',
|
||||
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
||||
});
|
||||
const depthTex = device.createTexture({
|
||||
size: [w, h, 1],
|
||||
format: 'depth24plus',
|
||||
usage: GPUTextureUsage.RENDER_ATTACHMENT,
|
||||
});
|
||||
|
||||
const enc = device.createCommandEncoder();
|
||||
const pass = enc.beginRenderPass({
|
||||
colorAttachments: [{
|
||||
view: colorTex.createView(),
|
||||
clearValue: { r: 0, g: 0, b: 0, a: 1 },
|
||||
loadOp: 'clear',
|
||||
storeOp: 'store',
|
||||
}],
|
||||
depthStencilAttachment: {
|
||||
view: depthTex.createView(),
|
||||
depthClearValue: 1.0,
|
||||
depthLoadOp: 'clear',
|
||||
depthStoreOp: 'store',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Bind group + sampler
|
||||
```typescript
|
||||
const sampler = device.createSampler({ magFilter: 'linear', minFilter: 'linear' });
|
||||
|
||||
const layout = device.createBindGroupLayout({
|
||||
entries: [
|
||||
{ binding: 0, visibility: GPUShaderStage.FRAGMENT, sampler: {} },
|
||||
{ binding: 1, visibility: GPUShaderStage.FRAGMENT, texture: {} },
|
||||
{ binding: 2, visibility: GPUShaderStage.VERTEX, buffer: { type: 'uniform' } },
|
||||
],
|
||||
});
|
||||
|
||||
const group = device.createBindGroup({
|
||||
layout,
|
||||
entries: [
|
||||
{ binding: 0, resource: sampler },
|
||||
{ binding: 1, resource: tex.createView() },
|
||||
{ binding: 2, resource: { buffer: ubo } },
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Compute shader with storage buffer
|
||||
```typescript
|
||||
const ssbo = device.createBuffer({
|
||||
size: 1024 * 1024,
|
||||
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
|
||||
});
|
||||
const pipe = device.createComputePipeline({
|
||||
layout: 'auto',
|
||||
compute: { module: device.createShaderModule({ code: wgsl }), entryPoint: 'main' },
|
||||
});
|
||||
const enc = device.createCommandEncoder();
|
||||
const cp = enc.beginComputePass();
|
||||
cp.setPipeline(pipe);
|
||||
cp.setBindGroup(0, bindGroup);
|
||||
cp.dispatchWorkgroups(1024);
|
||||
cp.end();
|
||||
```
|
||||
|
||||
### Resource lifecycle
|
||||
```typescript
|
||||
buffer.destroy(); // explicit free — required for large resources
|
||||
texture.destroy();
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Resource |
|
||||
|---|---|
|
||||
| 매 small constants per draw | Uniform buffer |
|
||||
| 매 large read-only data | Storage buffer (read) |
|
||||
| 매 read/write GPGPU | Storage buffer |
|
||||
| 매 sampled image | Texture (2D/3D/Cube) |
|
||||
| 매 framebuffer attachment | Texture w/ RENDER_ATTACHMENT |
|
||||
| 매 CPU↔GPU stream | Staging buffer + queue.writeBuffer |
|
||||
|
||||
**기본값**: WebGPU + bind group layout 명시. 매 destroy() 호출 잊지 X.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[WebGPU]] · [[Computer Graphics]]
|
||||
- 응용: [[Post Processing]] · [[Compute Shader]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 GPU pipeline 설계, 매 memory budget, 매 binding layout debug.
|
||||
**언제 X**: 매 high-level engine (Three.js, Babylon) 사용 시 — 매 abstraction 위.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **매 frame buffer create**: 매 alloc 폭증. 매 reuse / pool.
|
||||
- **UBO 에 매 large data**: 매 16KB cap. 매 SSBO 사용.
|
||||
- **destroy() 누락**: 매 GPU OOM.
|
||||
- **Bind group layout mismatch**: 매 shader / CPU schema drift.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (WebGPU spec, Vulkan spec).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — 매 WebGPU buffer/texture/RT 패턴 |
|
||||
Reference in New Issue
Block a user