Quick Flow
Depth pass: writes depth
G-buffer pass: reads depth, writes albedo / normal
Lighting pass: reads depth / G-buffer, writes HDR color
Post pass: reads HDR color, writes camera color| 선언 | 그래프가 알아야 하는 이유 | 누락했을 때 |
|---|---|---|
| Pass가 읽는 resource | write가 끝난 뒤 실행해야 함 | 이전 frame 또는 미정의 데이터를 읽음 |
| Pass가 쓰는 resource | 뒤 pass의 순서와 state를 정함 | write-after-write 충돌 또는 누락된 barrier |
| transient / imported | lifetime과 외부 소유권이 다름 | texture 재사용 또는 동기화가 잘못됨 |
| subresource 범위 | mip, layer, buffer range가 다를 수 있음 | 필요한 부분까지 잘못 alias 또는 누락된 dependency |
| side effect | final image에 안 닿아도 실행해야 할 수 있음 | 유용한 pass가 cull됨 |
의존성을 선언하는 방법
render graph는 pass와 texture/buffer의 읽기·쓰기를 그래프로 표현합니다. producer가 resource를 쓰고 consumer가 읽으면 read-after-write dependency가 생깁니다. 같은 resource에 두 pass가 쓰면 write-after-write 순서가 필요하며, 먼저 읽고 나중에 쓰는 read-after-write도 명시적으로 구분해야 합니다.
create transient HDR color
add pass "Lighting": write HDR color
add pass "Bloom": read HDR color, write bloom texture
add pass "Composite": read HDR color + bloom texture, write camera color위 선언에서 Bloom이나 Composite가 HDR color를 몰래 직접 읽으면 그래프는 필요한 순서, resource state, lifetime을 계산할 근거를 잃습니다. Unity 6 URP의 Render Graph도 pass에서 쓰는 texture를 입력 또는 출력으로 선언하도록 요구하며, Viewer에서 pass와 resource 연결을 확인할 수 있습니다. API의 정확한 barrier/merge/aliasing 전략은 backend와 graph 구현에 따라 달라지지만, 올바른 read/write 선언이 먼저입니다.
Resource lifetime과 queue
| resource 종류 | 소유와 lifetime | 주의할 점 |
|---|---|---|
| Transient texture/buffer | 그래프 안에서 만들고 마지막 사용 뒤 재사용 가능 | graph 밖에 handle을 보관해 다음 frame에 읽으면 안 됨 |
| Imported resource | swapchain, persistent history, 외부 RT처럼 그래프 밖에서 소유 | 초기 state, 최종 state, 외부 동기화를 정해야 함 |
| History resource | TAA, denoise처럼 여러 frame을 건넘 | camera cut, resolution 변경에 reset 규칙 필요 |
| Async compute output | compute queue에서 쓰고 graphics queue가 읽음 | queue fence와 overlap 가능성을 모두 확인 |
pass culling은 최종 출력에 영향을 주지 않는 pass를 생략하는 최적화입니다. debug readback, global state 변경, 외부 plugin 호출처럼 그래프 밖 side effect가 있는 pass는 cull해도 되는지 별도로 표시해야 합니다. pass merge도 항상 이득인 규칙이 아니라 attachment load/store, render target 전환, shader 구조에 따라 backend가 선택하는 구현 세부입니다.
디버깅 기준
| 증상 | 먼저 보는 그래프 정보 |
|---|---|
| texture가 검거나 이전 frame 값 | producer가 write로 선언됐는지, pass 순서와 clear/load |
| 특정 camera에서만 effect 누락 | imported camera color, history와 camera별 resource 이름 |
| memory가 예상보다 큼 | transient resource의 lifetime, 해상도, format, aliasing 불가 원인 |
| async compute가 빨라지지 않음 | queue dependency fence와 graphics queue의 wait |
| pass가 실행되지 않음 | final output 경로, culling, side effect 선언 |
render graph가 모든 작업을 자동으로 안전하게 만드는 것은 아닙니다. graph 밖에서 같은 resource를 접근하거나, read/write를 잘못 선언하거나, frame을 넘는 history를 transient처럼 취급하면 dependency 분석이 깨집니다. Frame Debugger 또는 Render Graph Viewer에서 실제 pass와 resource 연결을 frame 단위로 확인하십시오.
참고 링크
2 sources