포스트

DirecX12 | Lecture 10. Root Signature (인프런)

DirectX12 강의 10. Root Signature를 정리한 글입니다.

DirecX12 | Lecture 10. Root Signature (인프런)

강의 정보 🎓


1. DirectXTex 라이브러리 연동

  • DirectXTex 다운로드
  • 자신의 환경에 맞는 Debug / Release 각각 솔루션 빌드 및 출력물 확인
  • 필요한 파일:
    • DirectXTex.lib , DirectXTex_debug.lib
    • DirectXTex.h, DirectXTex.inl

2. 디렉토리 설정

1
2
3
4
5
6
7
8
9
// EnginePch.h
#include <DirectXTex/DirectXTex.h>
#include <DirectXTex/DirectXTex.inl>

#ifdef _DEBUG
#pragma comment(lib, "DirectXTex\\DirectXTex_debug.lib")
#else
#pragma comment(lib, "DirectXTex\\DirectXTex.lib")
#endif

3. 포함/라이브러리 디렉토리 설정

  • Engine / Client 공통:
    • 포함 디렉토리: $(SolutionDir)Library\\Include
  • Client만:
    • 라이브러리 디렉토리: $(SolutionDir)Library\\Lib

4. Texture 클래스 구현

  • C++17 사용 (/std:c++17)
  • 주요 함수:
    • CreateTexture()
    • CreateView()

⚠️ std::byte 관련 모호성 문제 → using namespace std; 사용 주의


5. CommandQueue 리소스 전용 멤버

  • 리소스용 commandList 멤버 추가한다.
  • FlushResourceCommandQueue() 구현
    • 커맨드 리스트 실행 후 리셋하는 동작을 한다.
1
2
// 텍스처 로드 후 호출
FlushResourceCommandQueue(); 이렇게 사용해도 괜찮나? 너무 많아지지 않나?

6. RootSignature 및 Vertex 수정

  • SRV 등록용 Root Parameter**추가한다.
  • UV 좌표를 Vertex 구조체에 추가한다.
  • Default.hlsli 수정:
1
2
3
4
5
6
7
8
Texture2D tex_0 : register(t0);
SamplerState sam_0 : register(s0);
float2 uv : TEXCOORD;// VS_IN, VS_OUT 에 추가되어야 한다.

float4 PS_Main(VS_OUT input) : SV_Target {
    float4 color = tex_0.Sample(sam_0, input.uv);
    return color;
}

7. Shader, Mesh, Game 수정

  • Shader.cpp : UV 인풋 요소를 추가해야 한다.
  • RootSignature : 샘플러 파라미터 임시로 추가한다.
  • Game : 정점 데이터에 UV 좌표를 추가하고 Texture Init을 호출한다.

8. Mesh 클래스

  • Texture 멤버를 추가한다.
  • Render() 내부에서 SetSRV() 호출하여 Texture 정보를 설정해야 한다.

프로젝트 상태 💾

07Result.png

이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.