티스토리 뷰

Game/Mini Engine

Mini engine porting (3)

newpolaris 2017. 5. 27. 19:24

몇시간 째 verte buffer creation 중이다

그 쉬운걸 왜케 오래 걸리냐고?

DX11와 DX12 가 사맛디 아니할세 내가 돌겠다.

DX12에서 Buffer는 GPU의 자원으로서

특히 Vertex와 Index는 D3D12_VERTEX_BUFFER_VIEW 라는 struct 로 setting 이 가능하다.

말이 Buffer 지 내부는 m_GpuVirtualAddress 라는 pointer 이다.

그 때문에 Mini Engine 에서는

m_UsageState = D3D12_RESOURCE_STATE_COMMON;

D3D12_HEAP_PROPERTIES HeapProps;
HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT;
HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
HeapProps.CreationNodeMask = 1;
HeapProps.VisibleNodeMask = 1;

위와 같이 usage 를 common 으로 생성한 후

StructuredBuffer m_VertexBuffer;
ByteAddressBuffer m_IndexBuffer;

위와 같이 사용한다.

usage 에도 Index 있고, Vertex 도 존재하지만 최적화의 의미지 DX11 처럼 땡강은 부리지 않는다.

그 덕분에 Linear alloc 이라는 공통 buffer를 잡아서 text 와 같이 vertex 변하는 것을 거기에 추가하고 offset이랑 size를 세팅한다

DX11는 반면 정말 친절하다

그냥 vertex는 SRV 생성하면 안됨 이라고 안알려주고

차근차근 예러 메시지를 뿝는다.

Buffers created with D3D11_RESOURCE_MISC_BUFFER_STRUCTURED cannot specify any of the following listed bind flags. The following BindFlags bits (0x8a) are set: D3D11_BIND_VERTEX_BUFFER (0), D3D11_BIND_INDEX_BUFFER (1), D3D11_BIND_CONSTANT_BUFFER (0), D3D11_BIND_STREAM_OUTPUT (0), D3D11_BIND_RENDER_TARGET (0), or D3D11_BIND_DEPTH_STENCIL (0). [ STATE_CREATION ERROR #68: CREATEBUFFER_INVALIDMISCFLAGS]

그리면 저걸 빼면, SRV 에서 DXGI_FORMAT_UNKNOWN 이란거 쓰지 못한다고 한다.

혹시나 Index buffer에서는 되나 테스트해보니 Index는 넘어가진다

그냥 Vertex Flag를 빼면 이래된다.

:IASetVertexBuffers: A Buffer trying to be bound to slot 0 did not have the appropriate bind flag set at creation time to allow the Buffer to be bound as a VertexBuffer. [ STATE_SETTING ERROR #238: IASETVERTEXBUFFERS_INVALIDBUFFER]

그래도 돌아는 가는데, 워낙 가벼운 테스트 프로그램이 이상이 먼가 있는지는 모르겠다.

딱히 생각해보니 CS 빼곤 vertex buffer를 받을만한 곳은 없고

CS는 buffer로 copy 해서 쓰더라

그래서 Practical 책에서는 SRV는 필요 없고,

// Select the appropriate binding locations based on the passed in flags
if ( streamout )
    desc.BindFlags = D3D11_BIND_VERTEX_BUFFER | D3D11_BIND_STREAM_0UTPUT;
else
    desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; 

에휴

'Game > Mini Engine' 카테고리의 다른 글

Mini engine porting (6) - FXAA  (0) 2017.06.02
Mini engine porting to DX11 (5) - Gamma correction  (0) 2017.06.02
Mini engine porting to DX11 (4) - Up sampler  (0) 2017.05.31
Mini Engine porting (2)  (0) 2017.05.27
Mini Engine porting (1)  (0) 2017.05.22
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크