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

Method onLoad

Source/Samples/CudaInterop/CudaInterop.cpp:44–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42CudaInterop::~CudaInterop() {}
43
44void CudaInterop::onLoad(RenderContext* pRenderContext)
45{
46 // Initialize CUDA device
47 if (!getDevice()->initCudaDevice())
48 FALCOR_THROW("Failed to initialize CUDA device.");
49
50 // Create our input and output textures
51 mpInputTex = Texture::createFromFile(
52 getDevice(), AssetResolver::getDefaultResolver().resolvePath(kTexturePath), false, false, ResourceBindFlags::Shared
53 );
54 if (!mpInputTex)
55 FALCOR_THROW("Failed to load texture '{}'", kTexturePath);
56
57 mWidth = mpInputTex->getWidth();
58 mHeight = mpInputTex->getHeight();
59 mpOutputTex = getDevice()->createTexture2D(
60 mWidth, mHeight, mpInputTex->getFormat(), 1, 1, nullptr, ResourceBindFlags::Shared | ResourceBindFlags::ShaderResource
61 );
62
63 // Define our usage flags and then map the textures to CUDA surfaces. Surface values of 0
64 // indicate an error during mapping. We need to cache mInputSurf and mOutputSurf as
65 // mapTextureToSurface() can only be called once per resource.
66 uint32_t usageFlags = cudaArrayColorAttachment;
67
68 mInputSurf = cuda_utils::mapTextureToSurface(mpInputTex, usageFlags);
69 if (mInputSurf == 0)
70 FALCOR_THROW("Input texture to surface mapping failed");
71
72 mOutputSurf = cuda_utils::mapTextureToSurface(mpOutputTex, usageFlags);
73 if (mOutputSurf == 0)
74 FALCOR_THROW("Output texture to surface mapping failed");
75}
76
77void CudaInterop::onFrameRender(RenderContext* pRenderContext, const ref<Fbo>& pTargetFbo)
78{

Callers

nothing calls this directly

Calls 8

mapTextureToSurfaceFunction · 0.85
initCudaDeviceMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
createTexture2DMethod · 0.80
getFormatMethod · 0.80
getDeviceFunction · 0.50
resolvePathMethod · 0.45

Tested by

no test coverage detected