MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / LoadPipeline

Method LoadPipeline

cpp/5_Domain_Specific/simpleD3D12/simpleD3D12.cpp:122–218  ·  view source on GitHub ↗

Load the rendering pipeline dependencies.

Source from the content-addressed store, hash-verified

120
121// Load the rendering pipeline dependencies.
122void DX12CudaInterop::LoadPipeline()
123{
124 UINT dxgiFactoryFlags = 0;
125
126#if defined(_DEBUG)
127 // Enable the debug layer (requires the Graphics Tools "optional feature").
128 // NOTE: Enabling the debug layer after device creation will invalidate the
129 // active device.
130 {
131 ComPtr<ID3D12Debug> debugController;
132 if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) {
133 debugController->EnableDebugLayer();
134
135 // Enable additional debug layers.
136 dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG;
137 }
138 }
139#endif
140
141 ComPtr<IDXGIFactory4> factory;
142 ThrowIfFailed(CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory)));
143
144 if (m_useWarpDevice) {
145 ComPtr<IDXGIAdapter> warpAdapter;
146 ThrowIfFailed(factory->EnumWarpAdapter(IID_PPV_ARGS(&warpAdapter)));
147
148 ThrowIfFailed(D3D12CreateDevice(warpAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device)));
149 }
150 else {
151 ComPtr<IDXGIAdapter1> hardwareAdapter;
152 GetHardwareAdapter(factory.Get(), &hardwareAdapter);
153
154 ThrowIfFailed(D3D12CreateDevice(hardwareAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device)));
155 DXGI_ADAPTER_DESC1 desc;
156 hardwareAdapter->GetDesc1(&desc);
157 m_dx12deviceluid = desc.AdapterLuid;
158 }
159
160 // Describe and create the command queue.
161 D3D12_COMMAND_QUEUE_DESC queueDesc = {};
162 queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
163 queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
164
165 ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_commandQueue)));
166
167 // Describe and create the swap chain.
168 DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
169 swapChainDesc.BufferCount = FrameCount;
170 swapChainDesc.Width = m_width;
171 swapChainDesc.Height = m_height;
172 swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
173 swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
174 swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
175 swapChainDesc.SampleDesc.Count = 1;
176
177 ComPtr<IDXGISwapChain1> swapChain;
178 ThrowIfFailed(factory->CreateSwapChainForHwnd(m_commandQueue.Get(), // Swap chain needs the queue so that it can
179 // force a flush on it.

Callers

nothing calls this directly

Calls 1

ThrowIfFailedFunction · 0.85

Tested by

no test coverage detected