Files
2nd/10_Wiki/Topic_Programming/DevOps_and_Security/Draw Call.md
T
Antigravity Agent 9148c358d0 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 폴더 제거.
2026-07-05 00:33:48 +09:00

4.7 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-draw-call Draw Call 10_Wiki/Topics verified self
Drawcall
GPU Submit
Render Command
none A 0.9 applied
graphics
gpu
performance
rendering
2026-05-10 pending
language framework
C++/Rust Vulkan/Metal/D3D12/WebGPU

Draw Call

매 한 줄

"매 CPU 가 GPU 에게 매 한 batch 를 그리라고 매 instructing 하는 single command". 1990s OpenGL glDrawArrays 시대의 매 ms-cost overhead 가 매 modern explicit API (Vulkan/D3D12/Metal/WebGPU) + bindless + GPU-driven rendering 으로 매 micro-second 수준으로 떨어짐. 매 2026 — vkCmdDrawIndexedIndirectCount + mesh shader 가 매 norm.

매 핵심

매 anatomy

  • Set pipeline (shader, blend, depth state).
  • Bind resources (vertex/index buffer, uniform, texture).
  • Issue draw (drawIndexed, dispatch).
  • Submit to queue.

매 cost source

  • Driver validation: legacy GL 의 매 main bottleneck.
  • State change: pipeline / RT / descriptor switch.
  • CPU↔GPU sync: fence wait, map/unmap.
  • Command recording: 매 modern API 에서 매 thread 분산 가능.

매 응용

  1. Draw call 수 줄임 → frame time 직접 감소.
  2. Batching (instancing, atlas, indirect).
  3. GPU-driven culling (compute → indirect).

💻 패턴

Vulkan minimal draw

vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
VkBuffer vbs[] = {vertexBuf}; VkDeviceSize off[] = {0};
vkCmdBindVertexBuffers(cmd, 0, 1, vbs, off);
vkCmdBindIndexBuffer(cmd, indexBuf, 0, VK_INDEX_TYPE_UINT32);
vkCmdBindDescriptorSets(cmd, ..., 0, 1, &set, 0, nullptr);
vkCmdDrawIndexed(cmd, indexCount, instanceCount, 0, 0, 0);

Instancing (1 call → N objects)

// vertex shader
layout(location = 0) in vec3 pos;
layout(location = 4) in mat4 modelMatrix;  // per-instance
void main() { gl_Position = vp * modelMatrix * vec4(pos, 1); }
// CPU side
vkCmdDrawIndexed(cmd, idxCount, 10000, 0, 0, 0);  // 10k objects, 1 draw

Indirect draw (GPU-driven)

struct VkDrawIndexedIndirectCommand {
    uint32_t indexCount, instanceCount, firstIndex;
    int32_t  vertexOffset; uint32_t firstInstance;
};
// Compute shader culls & writes commands + count to GPU buffer.
// CPU just calls:
vkCmdDrawIndexedIndirectCount(cmd, drawBuf, 0, countBuf, 0, MAX_DRAWS, sizeof(Cmd));

Bindless (descriptor indexing)

#extension GL_EXT_nonuniform_qualifier : require
layout(set=0, binding=0) uniform sampler2D textures[];
layout(push_constant) uniform PC { uint texIndex; };
void main() { color = texture(textures[nonuniformEXT(texIndex)], uv); }

Mesh shader (DX12 / Vulkan)

#version 460
#extension GL_EXT_mesh_shader : require
layout(local_size_x = 32) in;
layout(triangles, max_vertices = 64, max_primitives = 124) out;
void main() {
    SetMeshOutputsEXT(vertCount, primCount);
    // amplify / cull per meshlet, no IA stage
}

Multi-thread command recording (Vulkan)

// 1 secondary CB per thread
parallel_for(0, N, [&](int i) {
    VkCommandBuffer sec = secondaryCBs[threadId];
    vkBeginCommandBuffer(sec, ...);
    record_draws_for_chunk(sec, chunk[i]);
    vkEndCommandBuffer(sec);
});
vkCmdExecuteCommands(primaryCB, N, secondaryCBs.data());

매 결정 기준

상황 Approach
同 mesh 수천 개 Instancing
Diverse mesh, frustum cullable GPU-driven indirect + compute culling
Many materials Bindless texture + uber-shader
Highly detailed geometry Mesh shader + meshlet
Legacy GL/GLES Atlas + state sort + minimize binds

기본값: Modern → indirect + bindless. Legacy → batch by state.

🔗 Graph

🤖 LLM 활용

언제: Renderer architecture, perf budget 분석, profiling 결과 해석. 언제 X: Game design / art direction.

안티패턴

  • One draw per object: legacy 패턴 — instancing/indirect 사용.
  • Excessive state changes: shader/pipeline 매 frame 수천 번 swap.
  • CPU-side culling 만: GPU 보내서 매 compute 로 culling.
  • Map/unmap loop: persistent mapped buffer + ring 사용.
  • Single thread record: secondary CB + parallel_for.

🧪 검증 / 중복

  • Verified (Vulkan/D3D12 spec, Khronos best practices, GPU Zen).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — draw call cost + indirect/bindless/mesh shader