lpw

D3D9 interoperability extension

Discussion created by lpw on Sep 22, 2008
Latest reply on Dec 13, 2008 by gaurav.garg

Hi,

What is the status of the D3D9 interoperability extension? As mentioned in another thread, I'm hoping to use this extension to run occlusion queries on CAL kernels.

I tried the calD3D9Associate function, but this results in epic Fail. Calling the function promptly reboots my computer. A short program that reproduces the problem is included below.

I am using DXUT to create the device, perhaps that's the problem? If so, could someone post the parameters I should use to create the device manually? A short working program would be great.

Perhaps the problem is that I'm using a Radeon HD 3870 X2, which is exposed as two CAL devices yet a single D3D9 adapter? Still, a system reboot seems rather drastic.

My system:

- Radeon HD 3870 X2

- XP Pro (32 bit)

- CAL 1.2.0 beta

- DirectX 9c (February 2007)

- Tried Catalyst 8.6, 8.8, and 8.9 with same results

The code:

#include "DXUT/Core/DXUT.h"
#include <cal_ext.h>
#include <cal_ext_d3d9.h>


HRESULT WINAPI OnD3D9DeviceCreated(IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext);

LPDIRECT3DDEVICE9 g_pd3dDevice = 0;


int main()
{
//
// CAL setup
//
if (calInit() != CAL_RESULT_OK) {
fprintf(stderr, "Failed to initialize CAL\n");
exit(1);
}
if (calExtSupported(CAL_EXT_D3D9) != CAL_RESULT_OK) {
fprintf(stderr, "CAL_EXT_D3D9 not supported\n");
exit(1);
}
CALdevice dev = 0;
if (calDeviceOpen(&dev, 0) != CAL_RESULT_OK) {
fprintf(stderr, "Failed to open CAL device 0\n");
exit(1);
}

//
// DX setup
//
DXUTSetCallbackD3D9DeviceCreated(OnD3D9DeviceCreated);
if (FAILED(DXUTInit(true, true, 0, true))) {
fprintf(stderr, "Failed to initialize DXUT\n");
exit(1);
}
if (FAILED(DXUTCreateWindow(L"Bogus D3D Window"))) {
fprintf(stderr, "Failed to create window\n");
exit(1);
}
if (FAILED(DXUTCreateDevice())) {
fprintf(stderr, "Failed to create device\n");
exit(1);
}
if (!g_pd3dDevice) {
fprintf(stderr, "No d3d9 device\n");
exit(1);
}

//
// Associate
//
PFNCALD3D9ASSOCIATE pfnCalD3D9Associate = 0;
if (calExtGetProc((CALextproc*)&pfnCalD3D9Associate, CAL_EXT_D3D9, "calD3D9Associate") != CAL_RESULT_OK) {
fprintf(stderr, "Failed to obtain pointer to calD3D9Associate\n");
exit(1);
}
if (!pfnCalD3D9Associate) {
fprintf(stderr, "No calD3D9Associate\n");
exit(1);
}
printf("calD3D9Associate lives at 0x%p\n", pfnCalD3D9Associate); // OK
if (pfnCalD3D9Associate(dev, g_pd3dDevice) != CAL_RESULT_OK) {
fprintf(stderr, "Failed to associate devices\n");
exit(1);
}
printf("I'm alive\n"); // never get here
}


HRESULT WINAPI OnD3D9DeviceCreated(IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext)
{
g_pd3dDevice = pd3dDevice;
return S_OK;
}

Outcomes