Sign in to follow this  
simonferquel

Directx 9ex/10 Shared Textures problem

Recommended Posts

Hi there. I am working on a sample about interop between WPF and Directx 10 trought Directx9EX (as WPF only knows about IDirect3DSurface9 interface). So I am at a point where I am able to create a texture using a 9ex device, share it to my device 10, make a RenderTargetView from it, clear it with whatever color I want, and pass it back to WPF (using the old good 2 big triangles thing to transform the texture in a format supported by WPF D3DImage). Well, that's kind of great but the strange thing is that I am only able to clear the rtv, and not draw anything on it (it seems to do something, but the texture does not get modified). Anyone has an idea about it ? Thanks a lot, Simon Here are some extracts of my code Shared texture creation : HRESULT hr = m_deviceEx->CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET , D3DFMT_A16B16G16R16F, // Required for DirectX10 Interop // but does not work with WPF D3DImage. So we need to copy into an other // D3D9 texture with correct WPF format. For this we simply render a rect D3DPOOL_DEFAULT, &m_renderTexture, &shareHandle); assert(SUCCEEDED(hr)); // Getting the shared texture in DX10 and creating the rtv: ID3D10Resource* ptempResource = NULL; hr = m_device10->OpenSharedResource(shareHandle,__uuidof(ID3D10Resource), (void**)&ptempResource); assert(SUCCEEDED(hr)); ptempResource->QueryInterface(__uuidof(ID3D10Texture2D), (void**)&m_renterTexture10); SAFE_RELEASE(ptempResource); hr = m_device10->CreateRenderTargetView(m_renterTexture10, NULL, &m_rtv); assert(SUCCEEDED(hr)); m_device10->OMSetRenderTargets(1, &m_rtv, NULL); D3D10_VIEWPORT vp; vp.Height = height; vp.Width = width; vp.MinDepth = .0f; vp.MaxDepth = 1.0f; vp.TopLeftX = 0; vp.TopLeftY = 0; m_device10->RSSetViewports(1, &vp); // Clearing and drawing a triangle float clearColor[] = {0.0,0.0,0.0,1}; m_device10->ClearRenderTargetView(m_rtv, clearColor); m_device10->Draw(3,0); m_device10->Flush();

Share this post


Link to post
Share on other sites
That is the next thing I'm gonna try... But I am just drawing a white triangle for now (without transformation matrix and things that would put my vertices outer screenspace).
If the problem is located there I'm gonna dye my hair blue.

Share this post


Link to post
Share on other sites
Ok, I have modified my device creation to associate it with a swap chain and an external window, and my beautiful yellow triangle is succesfully drawn. So the problem lays in another place.

I thought about a synchronisation problem (the DX9Ex device would be fetching the texture before the async drawing process has completed on DX10), but I eliminated it by trying to draw my triangle without clearing the RTV in my render loop unsuccessfuly (the texture remains completely transparent).

So I'm thinking that maybe it is not possible to render in DX10 into a shared texture coming from DX9Ex. (or maybe it needs a very undocumented flag at dx10 device creation to work). Any idea? Do I need to push a mail to MS DX team ?

Share this post


Link to post
Share on other sites
After further investigation, I still have a bug, but not related to the Shared texture.

When I draw to my debugging Render Target View (created from a swap_chain in an external window), it works fine. However, when I draw to a RenderTargetView created from a texture, it renders nothing (I tried by disabling texture sharing and copying bits to a working dx9 dynamic texture for each frame). Once again it renders only the color from the ClearRenderTargetView call (with some color swaping because of the unmatching formats of my textures).

So my problem is somewhere else : I am unsuccessful at rendering into a texture...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this