XRManet / Engine

2 stars 0 forks source link

RenderingStratagy -> RenderPass #6

Open sixzone11 opened 3 years ago

sixzone11 commented 3 years ago

RenderPass로 전환하면서 pipeline 단위에서 정리되어야 할 각종 state와 input (vertex input layout, resource binding, ...), output (framebuffer, subpass, ...) 도 같이 정리합니다.

렌더 패스

렌더 패스에 대한 개요적 정의는 Vulkan 명세에서 기술하는 내용을 따르도록 합니다. 간략히 소개하여, Render Pass는 verterx 같은 primitive를 입력받아 color/depth attachment 같은 render target들을 출력하는데 들어가는 모든 상태 기록을 담당합니다.

BeginRenderPass(PassA);
{
    BeginSubpass(Sub0);
    {
        // record draw commands
    }
    EndSubpass(Sub0);

    if (need to final screen capture)
    {
        BeginSubpass(SubRenderToImage);
            // 
        EndSubpass(SubRenderToImage);
    }

    BeginSubpass(SubRenderToBackBuffer);
    {
        // record draw commands
    }
    EndSubpass(SubRenderToBackBuffer);
}
EndRenderPass(PassA);

렌더 패스를 작성하는 건 즉시 draw call을 수행하는 요청보단 렌더링 명세서를 작성해서 들고 있는 것에 가깝습니다. 렌더 패스를 명세하는 동작을 함수로 묶어뒀다가, 원하는 draw 결과를 만들 수 있는 함수를 순서대로 호출하는 형식이 됩니다.

최종 형태는 아래 그림처럼 발전되어야 합니다. image

위 그림에서 주황색 부분이 렌더 패스 함수가 됩니다.

GL state object

Vulkan 명세와 함께, 실제 GL state도 확인해야 하는데, 전체적으로 가능한 GL에서의 state 목록은 GL 명세의 State Tables 챕터를 확인하셔야 합니다. (OpenGL 4.6 Compatibility Profile 기준, Chapter 23. State Tables)

단, 좀 더 범위를 좁혀, NVIDIA 확장인 NV_command_list의 state object만을 우선 고려할 경우는 체크할 항목이 유의미하게 줄어들 수도 있습니다. NV_command_list 확장 제안서의 Add a new subsection 10.X.2 (Drawing with Commands) 항목, Table 10.X.2 (Token values and command structure names) 참고.