22 Pipeline

gksrudtlr
|2025. 1. 12. 18:30
  • Rasterizer

  • SamplerState

  • BlendState

  • Game

    void Game::Init(HWND hWnd)
    {
      ...
      sampler = make_shared<SamplerState>(graphics->GetDevice());
      ...
      rs = make_shared<Rasterizer>(graphics->GetDevice());
      ...
      blend = make_shared<BlendState>(graphics->GetDevice());
    
      rs->Create();
      ...
      sampler->Create();
      ...
      //CreateBlendState
      blend->Create();
      ...
    }
    ...
    void Game::Render()
    {
      ...
      //RS
      deviceContext->RSSetState(rs->GetComPtr().Get());
    
      //PS
      ...
      deviceContext->PSSetSamplers(0, 1, sampler->GetComPtr().GetAddressOf());
    
      //OM
      deviceContext->OMSetBlendState(blend->GetComPtr().Get(), blend->GetBlendFactor(),  blend->GetSampleMask());
      ...
    }
    

```

  • Class로 나눈 Rasterizer, SamplerState, BlendState를 Game클래스에 객체로 만들어 적용시킨다
  • Pipeline
    • 지금까지 class 별로 나눈 것들은 새로운 리소스를 만들 때 사용되었지만 지금 만드는 Pipeline 클래스는 DeviceContext가 렌더링 파이프 라인과 나머지 리소스들을 묶어주는 자원을 맵핑해주는 역할을 할 것이다
    • Game의 Render함수에서 하는 것을 Pipeline에 묶어 더 알아보기 쉽고 사용하기 편하게 클래스로 묶어서 사용하게 될 것이다.
    • Update 함수에서는 Pipeline에서 필수적인 리소스들을 DeviceContext에 셋팅해줄 것이다
    • 부가적으로 필요한 것들은 각각의 함수들을 통해 콜할 수 있게 만들어 주었다
    • 이때 ConstantBuffer는 어떤 값이 들어올지 모르기 때문에 Templayte로 만들어 범용적으로 사용 가능하게 하였고, scope를 통해 enum으로 만들었던 값들과 비트연산을 통해 Vs인지 Ps인지 판단하여 ConstantBuffer를 설정할 수 있게 해주었다
    • Render에 있던 내용을 각각에 알맞은 부분에 넣어주었다
    • 이때 Draw와 DrawIndexed를 이용해 IndexBuffer가 있고 없을때 그리는 방법이 다르기 때문에 각각 알맞은 함수를 콜하여 그림을 그릴 수 있게 해주었다

'DirectX' 카테고리의 다른 글

24 Transform  (0) 2025.01.12
23 GameObject  (0) 2025.01.12
21 Shader  (1) 2025.01.12
20 Geometry  (0) 2025.01.12
19 InputAssembler  (0) 2025.01.12