_indexCount=static_cast<uint32>(ibvs.size());uint32bufferSize=_indexCount*sizeof(Vertex);// 1. 버퍼생성D3D12_HEAP_PROPERTIESheapProperty=CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD);D3D12_RESOURCE_DESCdesc=CD3DX12_RESOURCE_DESC::Buffer(bufferSize);MyEngine->GetDevice()->GetDevice()->CreateCommittedResource(&heapProperty,D3D12_HEAP_FLAG_NONE,&desc,D3D12_RESOURCE_STATE_GENERIC_READ,nullptr,IID_PPV_ARGS(&_indexBuffer));// 2. CPU -> GPU 복사void*indexDataBuffer=nullptr;CD3DX12_RANGEreadRange(0,0);_indexBuffer->Map(0,&readRange,&indexDataBuffer);::memcpy(indexDataBuffer,&ibvs[0],bufferSize);_indexBuffer->Unmap(0,nullptr);// 3. indexBuffer를 사용하는 방법 묘사_indexBufferView.BufferLocation=_indexBuffer->GetGPUVirtualAddress();// GPU 주소_indexBufferView.Format=DXGI_FORMAT_R32_UINT;// 32bit 포맷_indexBufferView.SizeInBytes=bufferSize;// 버퍼 크기
2. IndexBuffer를 활용하여 물체 그리기
// 색인 버퍼를 입력조립기(IA)단계에 바인딩cmdList->IASetIndexBuffer(&_indexBufferView);...// 색인을 이용한 기본도형 그리기cmdList->DrawIndexedInstanced(_indexCount,1,0,0,0);// 실제로 그려짐
댓글남기기