MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / gfxResourceFromNativeHandle

Function gfxResourceFromNativeHandle

Source/Falcor/Core/API/Buffer.cpp:208–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208inline Slang::ComPtr<gfx::IBufferResource> gfxResourceFromNativeHandle(
209 Device* pDevice,
210 NativeHandle handle,
211 size_t size,
212 ResourceBindFlags bindFlags,
213 MemoryType memoryType
214)
215{
216 gfx::IBufferResource::Desc bufDesc = {};
217 prepareGFXBufferDesc(bufDesc, size, 0, ResourceFormat::Unknown, bindFlags, memoryType);
218
219 gfx::InteropHandle gfxNativeHandle = {};
220#if FALCOR_HAS_D3D12
221 if (pDevice->getType() == Device::Type::D3D12 && handle.getType() == NativeHandleType::ID3D12Resource)
222 {
223 gfxNativeHandle.api = gfx::InteropHandleAPI::D3D12;
224 gfxNativeHandle.handleValue = reinterpret_cast<uint64_t>(handle.as<ID3D12Resource*>());
225 }
226#endif
227#if FALCOR_HAS_VULKAN
228 if (pDevice->getType() == Device::Type::Vulkan && handle.getType() == NativeHandleType::VkBuffer)
229 {
230 gfxNativeHandle.api = gfx::InteropHandleAPI::Vulkan;
231 gfxNativeHandle.handleValue = reinterpret_cast<uint64_t>(handle.as<VkBuffer>());
232 }
233#endif
234
235 if (gfxNativeHandle.api == gfx::InteropHandleAPI::Unknown)
236 FALCOR_THROW("Unknown native handle type");
237
238 Slang::ComPtr<gfx::IBufferResource> gfxBuffer;
239 FALCOR_GFX_CALL(pDevice->getGfxDevice()->createBufferFromNativeHandle(gfxNativeHandle, bufDesc, gfxBuffer.writeRef()));
240
241 return gfxBuffer;
242}
243
244Buffer::Buffer(ref<Device> pDevice, NativeHandle handle, size_t size, ResourceBindFlags bindFlags, MemoryType memoryType)
245 : Buffer(pDevice, gfxResourceFromNativeHandle(pDevice.get(), handle, size, bindFlags, memoryType), size, bindFlags, memoryType)

Callers 1

BufferMethod · 0.85

Calls 4

prepareGFXBufferDescFunction · 0.85
writeRefMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected