Hi
it is possible to bind d3d texture (512x512, D3DFMT_A8R8G8B8, POOL_DEFAULT, all mipmaps) as cuda 2d texture ?
All calls in code below return cudaSuccess, but the tex2D in cuda always return float4(0, 0, 0, 0) what is wrong ? is this kind of interopability possible ?
when i bind cuda2dArray to this texture all is fine and correct values are sampled in
kernel
texture <uchar4, 2, cudaReadModeNormalizedFloat> MAT_TextureRef_00;
// ...
const textureReference *texRef = NULL;
if (cudaGetTextureReference(&texRef, "MAT_TextureRef_00") != cudaSuccess)
freaked_error("Cuda failed to get refrence !");
D3D_BindInteropTexture2D_A8R8G8B8(texRef, d3dTexture);
// ...
void D3D_BindInteropTexture2D_A8R8G8B8(const textureReference *texRef, void *_texture)
{
cudaChannelFormatDesc desc;
desc.x = 8;
desc.y = 8;
desc.z = 8;
desc.w = 8;
desc.f = cudaChannelFormatKindUnsigned;
IDirect3DResource9 *texture = ((c_D3DTEXTURE*)_texture)->GetTexture();
if (texture == NULL)
return;
if (cudaD3D9RegisterResource(texture, cudaD3D9RegisterFlagsNone) != cudaSuccess)
freaked_error("Cuda failed to register !");
if (cudaD3D9ResourceSetMapFlags(texture, cudaD3D9MapFlagsReadOnly) != cudaSuccess)
freaked_error("Cuda failed to set flags !");
if (cudaD3D9MapResources(1, &texture) != cudaSuccess)
freaked_error("Cuda failed to map !");
void *TextureData;
size_t TextureSize;
if (cudaD3D9ResourceGetMappedPointer(&TextureData, texture, 0, 0) != cudaSuccess)
freaked_error("Cuda failed to get !");
if (cudaD3D9ResourceGetMappedSize(&TextureSize, texture, 0, 0) != cudaSuccess)
freaked_error("Cuda failed to get !");
((textureReference *)texRef)->addressMode[0] = cudaAddressModeWrap;
((textureReference *)texRef)->addressMode[1] = cudaAddressModeWrap;
((textureReference *)texRef)->filterMode = cudaFilterModeLinear;
((textureReference *)texRef)->normalized = true;
if (cudaBindTexture(NULL, texRef, TextureData, &desc, TextureSize) != cudaSuccess)
freaked_error("Cuda failed to bind !");
return;
}
thanks for any ansfers.