Quick Reference
render target은 "지금 쓰는 목적지"이고, framebuffer 또는 render pass attachment는 그 목적지를 묶어 GPU에 제시하는 방식입니다. 같은 texture도 한 pass에서는 attachment로 쓰고, 다음 pass에서는 sampled texture로 읽을 수 있습니다. 단, 같은 subresource를 같은 pass에서 읽기와 쓰기로 겹치게 두지 않습니다.
| attachment 또는 작업 | 저장하는 값 | 설정할 때 확인할 값 |
|---|---|---|
| Color attachment | scene color, G-buffer, object ID | format, sRGB 여부, blend, load/store |
| Depth / stencil attachment | depth compare와 stencil mask | depth format, clear value, compare, sample count |
| MRT | 여러 color 결과를 한 pass에서 기록 | 모든 attachment의 크기/sample count, bandwidth |
| MSAA target | pixel 안 여러 sample의 color/depth | sample count와 resolve target |
| Resolve | multi-sample 결과를 single-sample texture로 변환 | resolve 시점과 이후 pass의 읽기 방식 |
Attachment 계약
scene pass: HDR color + depth에 write
post-process: HDR color를 sample, post color에 write
final composite: post color를 sample, swapchain에 writecolor attachment는 fragment output을 저장하고, depth attachment는 depth test와 depth write의 기준이 됩니다. depth map처럼 다음 pass에서 shadow comparison에 읽을 depth는 sampling 또는 depth-read 용도로 만들 수 있는 format과 view가 필요합니다. 여러 color attachment를 동시에 쓰는 MRT는 G-buffer에 유용하지만, target 수와 precision이 늘수록 bandwidth도 늘어납니다.
load/clear/store는 pass 시작과 끝에 attachment 내용을 어떻게 다루는지 정합니다. 이전 결과가 필요 없으면 clear 또는 discard/load하지 않는 선택이 bandwidth를 줄일 수 있습니다. 반대로 다음 pass가 내용을 읽는데 store를 생략하면 결과가 보장되지 않습니다. 타일 기반 GPU에서는 이 선택이 특히 중요하지만, 실제 효과는 API와 hardware의 render-pass 구현에 따라 측정해야 합니다.
Format, sample, resolution
| 요구 | 자주 쓰는 선택 | 바꿀 때 생기는 변화 |
|---|---|---|
| HDR scene color | floating-point color format | bloom과 exposure에 1보다 큰 선형 값을 유지, 메모리 증가 |
| 일반 display color | sRGB 또는 output transform 대상 | texture decode와 render encode 규약을 맞춰야 함 |
| object picking | integer color attachment 또는 별도 ID target | blend와 color conversion을 쓰지 않아야 ID가 보존됨 |
| depth test | depth 또는 depth-stencil format | clear/compare와 normal/reversed Z 규약을 함께 바꿈 |
| anti-aliasing | multisample color/depth + resolve | sample memory와 resolve 비용 증가 |
| half-resolution effect | 작은 color target | bandwidth는 줄고 blur/edge detail은 낮아짐 |
MSAA attachment의 sample 값은 single-sample sampled texture와 다른 resource로 취급합니다. 후처리 shader가 한 색을 읽으려면 resolve target을 만들거나 API가 제공하는 multisample texture read 방식을 선택해야 합니다. resolve를 너무 일찍 하면 sample-level coverage 정보가 사라지고, 너무 늦게 하면 다음 pass가 읽을 수 있는 view와 비용이 복잡해집니다.
실패 신호
| 증상 | 점검 순서 |
|---|---|
| framebuffer 생성 또는 pass 시작 실패 | color/depth attachment의 width, height, layer, sample count, usage |
| 색이 두 번 감마 보정된 것처럼 보임 | target sRGB 설정, shader decode/encode, final output |
| depth test가 전부 통과/실패 | clear depth, compare op, projection depth range, reversed Z |
| 후처리 화면이 flicker하거나 이전 값이 섞임 | 같은 texture를 read/write하는 feedback loop, load/store, barrier |
| MSAA를 켰을 때만 흐리거나 검게 보임 | resolve target format/sample count와 pass 순서 |
full-resolution HDR target 여러 장은 shader 코드보다 메모리 read/write가 먼저 병목이 되기 쉽습니다. frame capture에서 attachment format, resolution, sample count, load/store, resolve 수를 함께 보고, 효과에 실제로 필요한 precision과 해상도만 남기십시오.
참고 링크
2 sources