엔진

DX9와 DX11의 차이

알쿠미 2016. 8. 19. 15:48

DX9와 달리 DX11은 Device와 DeviceContext로 나누어져 있음


Device는 주로 resource 생성을 담당

- thread-safe

DeviceContext는 주로 rendering 을 담당

- thread-unsafe


* constant buffer 

cbuffer 키워드 안에 변수를 묶어서 정의

CreateBuffer로 constant buffer용 버퍼 생성

UpdateSubresource(Map)로 버퍼의 내용을 update

 - 이때 update를 하면 cbuffer의 내용 전부를 덮어씌운다.

( 그렇기 때문에 변수를 나누어서 cbuffer을 만들고 필요한 부분만 update를 효율적으로 하는게 중요하다.)


XXSetconstantBuffers로 레지스터에 바인드

 - VSSetConstantBuffers, PSsetConstantBuffer 등


VertextInputLayout - 버텍스 버퍼에 대한 정보를 GPU에 알려주기 위해서 사용한다.

CreateInputLayout을 이용해서 생성할 때 vertex shader와 매칭이 이루어지는데 

D3D11_INPUT_ELEMENT_DESC와 vertex shader semantic과 일치하면 success 불일치 하면 fail.


Shader reflection?

vertex shader를 reflection하여 semantic과 일치하는 VertexInputLayout을 미리생성

Shader semantic 기준으로 VertexInputLayout를 생성


MultiThread

immedidate context 

rendering 명령을 실행하는 오브젝트

1개만 생성가능 thread unsafe


deferred context

각 thread에서 모든 rendering 명령의 실행이 끝난 후에 FinishCommandList를 호출하여 command list를 얻어옴. 이후 command list를 immediate context 에서 실행


1. 생성

ID3D11DeviceContext* pImmediateContext;

ID3D11DeviceContext* pDeferredContext;


pDevice->CreateDeferredContext( 0, &pDeferredContext );


2. 각 Thread 마지막에 실행

pDeferredContext->FinishCommandList( FALSE, &pCommandList );


3. pImmediateContext->ExecuteCommandList( pCommandList, FALSE );




[참고]

http://www.slideshare.net/ssuserf07a43/kgc2014-dx9dx11-41292758?from_m_app=android