Grender Architecture
1. Layer Position
grender는 Grap 시스템에서 Rendering API Layer를 제공하는 라이브러리이다.
이 모듈은 렌더링 장치 구현과 애플리케이션 사이의 렌더링 인터페이스 계층을 구성한다.
grender는 다음 요소를 정의한다.
- 렌더링 장치 인터페이스
- 렌더링 명령 구조
- 렌더링 데이터 타입
- 렌더링 리소스 핸들
- 렌더링 열거형
grender는 렌더링 구현을 포함하지 않는다.
렌더링 구현은 별도의 backend에서 수행된다.
시스템 레이어 구조
Application
▲
│
grender
(Render API Layer)
▲
│
Rendering Backend
(CPU / GPU Renderer)
레이어 역할
| Layer | Responsibility |
|---|---|
| Application | 애플리케이션 로직 |
| grender | 렌더링 API 인터페이스 |
| Rendering Backend | 실제 렌더링 구현 |
2. Internal Modules
grender는 다음 서브시스템으로 구성된다.
grender
├─ common
├─ id
├─ enums
├─ types
└─ device
각 모듈은 렌더링 API를 구성하는 특정 역할을 담당한다.
common
- 라이브러리 설정 정보 제공
- Result 타입 정의
- assertion 유틸리티 제공
id
- 렌더링 리소스 식별 타입 정의
- Handle 기반 리소스 식별 구조 제공
enums
- 렌더링 관련 열거형 정의
- PrimitiveType
- Format
- Flags
types
- 렌더링 데이터 구조 정의
- FrameDesc
- DrawCmd
- VertexFormat
- ResourceDesc
device
- 렌더링 장치 인터페이스 정의
- IRenderDevice 인터페이스 제공
3. Dependency Structure
grender 내부 모듈은 다음 의존 구조를 따른다.
common
▲
│
id
▲
│
enums
▲
│
types
▲
│
device
의존 규칙
common은 최하위 모듈id는common에 의존 가능enums는common에 의존 가능types는id,enums,common에 의존 가능device는types에 의존 가능- 순환 의존성 금지
4. Header Architecture
grender는 Public Header 구조를 제공한다.
모든 Public API는 <grender/...> 경로로 접근할 수 있다.
예
#include <grender/types/frame_desc.hpp>
#include <grender/types/draw_cmd.hpp>
#include <grender/device/render_device.hpp>
grender는 umbrella header를 제공한다.
#include <grender/grender.hpp>
이 헤더는 grender의 Public API 전체를 포함한다.
5. Directory Layout
grender 디렉토리 구조
grender/
├─ grender.hpp
│
├─ common/
│ ├─ config.hpp
│ ├─ result.hpp
│ └─ assert.hpp
│
├─ id/
│ ├─ ids.hpp
│ └─ handle.hpp
│
├─ enums/
│ ├─ primitive.hpp
│ ├─ format.hpp
│ └─ flags.hpp
│
├─ types/
│ ├─ frame_desc.hpp
│ ├─ draw_cmd.hpp
│ ├─ vertex_format.hpp
│ └─ resource_desc.hpp
│
├─ device/
│ ├─ render_device.hpp
│ └─ render_device.cpp
│
└─ tests/
└─ smoke.cpp
6. Design Principles
grender 시스템은 다음 설계 원칙을 따른다.
Backend Independence
grender는 특정 렌더링 구현에 의존하지 않는다.
렌더링 구현은 IRenderDevice 인터페이스를 통해 연결된다.
Interface Based Design
렌더링 장치는 인터페이스 기반 구조를 사용한다.
예
IRenderDevice
렌더러 구현은 해당 인터페이스를 구현해야 한다.
Command Based Rendering
렌더링은 명령 기반 모델을 사용한다.
렌더링 흐름
begin_frame()
draw()
end_frame()
present()
렌더 명령은 DrawCmd 구조체를 통해 전달된다.
Handle Based Resource System
렌더링 리소스는 핸들 기반 식별 시스템을 사용한다.
예
VertexBufferHandle
IndexBufferHandle
TextureHandle
PipelineHandle
핸들은 리소스의 실제 메모리를 관리하지 않는다.
Minimal API Surface
grender는 최소한의 렌더링 API만 제공한다.
제공 기능
- RenderDevice 인터페이스
- Render command 구조
- Frame configuration
- Resource handle
7. Rendering Flow
렌더링 데이터 흐름
Frame 시작
Application
│
▼
IRenderDevice::begin_frame(FrameDesc)
Draw Command 제출
Application
│
▼
IRenderDevice::draw(DrawCmd)
Frame 종료
IRenderDevice::end_frame()
Frame 출력
IRenderDevice::present()
8. System Interaction
렌더링 API 호출 흐름
Application
│
▼
DrawCmd 생성
│
▼
IRenderDevice::draw
│
▼
Rendering Backend
(CPU Renderer / GPU Renderer)
9. Summary
grender는 Grap 시스템에서 Rendering API Layer를 제공하는 라이브러리이다.
주요 기능
- 렌더링 장치 인터페이스 정의
- 렌더링 명령 구조 정의
- 렌더링 데이터 타입 정의
- 렌더링 리소스 핸들 시스템 제공
grender는 실제 렌더링 구현을 포함하지 않으며
렌더링 backend와 애플리케이션 사이의 API 인터페이스 계층을 제공한다.