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:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,147 @@
---
id: wiki-2026-0508-render-state
title: Render State
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [GPU Render State, Pipeline State, Graphics State]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [graphics, gpu, rendering, pipeline]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: hlsl/glsl
framework: vulkan/d3d12
---
# Render State
## 매 한 줄
> **"매 GPU 명령마다 어떤 컨텍스트에서 그릴지 결정하는 파라미터 묶음"**. 매 blend mode, depth test, rasterizer setup, shader binding 의 collection. 매 modern Vulkan/D3D12 에서는 PSO (Pipeline State Object) 의 immutable bake — state change cost 의 minimization.
## 매 핵심
### 매 구성 요소
- **Rasterizer state**: cull mode, fill mode, depth bias.
- **Depth-stencil state**: depth test, stencil ops, write masks.
- **Blend state**: src/dst factors, blend op, write mask.
- **Input layout**: vertex attribute format.
- **Shader stages**: VS / PS / GS / HS / DS / CS bindings.
- **Descriptor sets / root signature**: resource bindings.
### 매 진화
- **OpenGL/D3D9-11**: per-state setter — `glEnable(GL_DEPTH_TEST)` style. Driver 의 lazy validation cost 큼.
- **D3D12 / Vulkan / Metal**: PSO bake at create time. Runtime change = bind 1 PSO.
- **WebGPU 2025**: Vulkan style PSO + 동일 abstractions.
### 매 응용
1. Forward / deferred 의 pass 별 PSO 분리.
2. Shadow pass 의 depth-only PSO.
3. UI overlay 의 alpha-blend PSO.
## 💻 패턴
### Vulkan PSO 생성
```cpp
VkGraphicsPipelineCreateInfo info{};
info.stageCount = 2;
info.pStages = stages; // VS + PS
info.pVertexInputState = &vi;
info.pInputAssemblyState = &ia;
info.pRasterizationState = &rs; // cull, fill
info.pDepthStencilState = &ds; // test, write
info.pColorBlendState = &cb; // alpha blend
info.layout = pipelineLayout;
info.renderPass = rp;
vkCreateGraphicsPipelines(dev, cache, 1, &info, nullptr, &pso);
```
### State sort 의 draw call batching
```cpp
std::sort(drawables.begin(), drawables.end(), [](auto& a, auto& b){
if (a.psoHash != b.psoHash) return a.psoHash < b.psoHash;
if (a.materialHash != b.materialHash) return a.materialHash < b.materialHash;
return a.depth < b.depth;
});
for (auto& d : drawables) {
if (d.psoHash != lastPso) cmd.bindPipeline(d.pso);
if (d.materialHash != lastMat) cmd.bindDescriptorSets(...);
cmd.draw(...);
}
```
### Dynamic state subset
```cpp
VkPipelineDynamicStateCreateInfo dyn{};
VkDynamicState ds[] = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR};
dyn.dynamicStateCount = 2;
dyn.pDynamicStates = ds;
// PSO 는 viewport/scissor 없이 bake → runtime 에서 cmd.setViewport()
```
### D3D12 root signature + PSO
```cpp
CD3DX12_PIPELINE_STATE_STREAM_DESC desc;
desc.pRootSignature = rootSig;
desc.VS = {vsBlob, vsSize};
desc.PS = {psBlob, psSize};
desc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
desc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
desc.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
device->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
```
### Shader hot-reload + PSO cache
```cpp
auto hash = HashShaders(vs, ps) ^ HashState(rs, ds, cb);
if (auto it = cache.find(hash); it != cache.end()) return it->second;
auto pso = CreatePso(...);
cache[hash] = pso;
return pso;
```
### Bindless descriptor + PSO 단순화
```cpp
// Descriptor heap 1개 + bindless indexing → PSO 변경 거의 없음
ConstantBuffer<uint> meshIdx;
Texture2D<float4> textures[] : register(t0, space0);
float4 color = textures[NonUniformResourceIndex(materialId)].Sample(...);
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| AAA 엔진, 수만 draw call | PSO + sort by state hash |
| Indie, simple 2D | Dynamic state OK, PSO 1-2개 |
| Shader 자주 바뀜 (dev) | PSO cache + hot-reload |
| Mobile (tile-based) | Render pass 단위 minimization |
**기본값**: PSO bake at level load + state-sorted draw queue.
## 🔗 Graph
- 부모: [[Graphics Pipeline]] · [[GPU]]
- 응용: [[Deferred Rendering]]
- Adjacent: [[Vulkan]] · [[WebGPU]]
## 🤖 LLM 활용
**언제**: state-sort 알고리즘 작성, PSO cache 설계, Vulkan boilerplate 생성.
**언제 X**: GPU vendor 별 micro-optimization (driver 의 black-box).
## ❌ 안티패턴
- **Per-draw PSO recreation**: stutter 발생. Cache + warmup 필수.
- **State leak**: legacy GL 코드 의 `glEnable` 후 disable 누락 → 다음 frame corruption.
- **Over-granular PSO**: 1만 PSO → memory + driver overhead.
## 🧪 검증 / 중복
- Verified (Vulkan spec, D3D12 docs, GPU Gems).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Render state full coverage |