IDirect3DSurface9::QueryInterface

Started by
4 comments, last by 21st Century Moose 8 years, 2 months ago

Greetings.

Can someone explain why IDirect3DSurface9 do not support IDirect3DResource9? I mean the call to IDirect3DSurface9::QueryInterface for IDirect3DResource9 fails?

I go deep inside d3d9.dll and it looks like CSurface::QueryInterface (which is responsible for IDirect3DSurface9 afaik) succedded only for IID_IDirect3DSurface9 and IID_IUnknown.

Checked this on my Windows 8.1 with all latest updates, 32 bit dll (WoW) on 64 bit host platform.

According the MSDN IDirect3DSurface9 is inherits from IDirect3DResource9 and implement it.

I was curious and check WINE implementation of IDirect3DSurface9::QueryInterface - it supports querying of IDirect3DResource9.

Thanks in advance.

Advertisement
D3D often breaks the strict rules of COM...

D3D often breaks the strict rules of COM...

I never encounter something like this before, although i worked with Direct3d tightly :( This time it leads to a real problem. Nvidia implementation of OpenCL interop with Direct3D9 have some requirements (according to Khronos specs of cl_nv_d3d9_sharing). Surface (to be accessible in OpenCL) should be a valid IDirect3DSource9 and IDirect3DResource9... I debug the nvopencl.dll - they simply do two QueryInterface. One of them just fails...

Anyway, i will try to use texture instead of surface. Hope Nv will not QI on surface behind the texture interface. Or i just wrap IDirect3DSurface9 in my implementation and reimplement QueryInterface method...

Have you tried IDirect3DSurface9::GetContainer() (and then querying for ID3DResource9)?
I used it for a wrapper and it did the trick.

Have you tried IDirect3DSurface9::GetContainer() (and then querying for ID3DResource9)?
I used it for a wrapper and it did the trick.

Thanks for the idea. But looks like the problem was little deeper than i expected.

I try to fool underlying nv opencl implementation with IDirect3DSurface9 wrapper and reporting IDirect3DResource9 supported but still have an error while interop.

So i just switched to texture (with same dimenstions and format) and used corresponding interop function - that works ok.

According to Microsoft's own d3d9.h, IDirect3DSurface9 also inherits from IDirect3DResource9, so if there is something funny happening it must be happening in IDirect3DSurface9's implementation of QueryInterface.

As a general rule, in cases like this it's a fairly clear "you shouldn't be doing this" flag from Microsoft.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement