cudaD3D9RegisterResource(IDirect3DResource9* pResource, unsigned int Flags)
説明
CUDAでアクセスするDirect3Dリソースを登録する。
cudaD3D9UnregisterResourceで登録解除するまでmap/unmapすることができる。
pResourceの内部の参照カウントが増え、cudaD3D9UnregisterResourceで減る。
この関数は潜在的に重いからフレームごとに読んじゃだめ。
pResourceは以下の型のいずれかでないとだめ
- IDirect3DVertexBuffer9
- IDirect3DIndexBuffer9
- IDirect3DSurface9
- IDirect3DBaseTexture9
FlagsにはCUDAがDirect3Dリソースにアクセスするメカニズムを指定する。
以下の値ならおk
- cudaD3D9RegisterFlagsNone
CUDAがvoid*型でこのリソースにアクセスすることを示す。
cudaD3D9ResourceGetMappedpointer,
cudaD3D9ResourceGetMappedSize,
cudaD3D9ResourceGetMappedPitch
によってこのリソースにアクセスされるかもしれない。
このオプションはすべてのリソースタイプについて有効である。
上記すべてのDirect3DリソースがCUDAでうまく動くわけではない。
以下がその制限。
- The primary rendertarget may not be registered with CUDA.
- 共有として確保されたリソースはCUDAに登録されないかもしれない
Reousrces allocated as shared may not be registered with CUDA. - D3DPOOL_SYSTEMMEMの中に確保されたリソースはCUDAに登録されないかもしれない
- Textures which are not of a format which is 1, 2, or 4 channels of 8, 16, or 32-bit integer or floating-point data cannnot be shared.
- Surfaces of depth or stencil formats cannot be shared.
pResourceが間違った型だったり、すでに登録済みならcudaErrorInvalidHandleが戻る。
登録できなかったらcudaErrorUnknownが戻る。
戻り値
cudaSuccess
cudaErrorInvalidValue
cudaErrorInvalidHandle
cudaErrorUnknown