Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 Nov 2009
Offline Last Active Feb 25 2014 04:31 AM

Topics I've Started

Resource Sharing between Directx11 and DirectX9

03 June 2013 - 03:59 AM


I am trying to share resource between directx9 and directx11,having some problems regarding this.

what i am doing is this :-

STEP1: created a shared texture with format D3DFMT_A8R8G8B8 in directx9 and get its shared handle.

STEP2: open the shared texture with directx11 device using the handle.

STEP3: create UAV of texture creating in step3.

but step 3 fails with error

D3D11: ERROR: ID3D11Device::CreateUnorderedAccessView: The format (0x57, B8G8R8A8_UNORM) cannot be used with a Typed Unordered Access View. [ STATE_CREATION ERROR #2097344: CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT ]
D3D11: ERROR: ID3D11Device::CreateUnorderedAccessView: A UnorderedAccessView cannot be created of a Resource that did not specify the D3D11_BIND_UNORDERED_ACCESS BindFlag. [ STATE_CREATION ERROR #2097342: CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE ]


please help me here that how can i create UAV of a shared texture which is created in directx9.

HRESULT hr = g_pd3dDevice9->CreateTexture( Width , Height , 1 , D3DUSAGE_RENDERTARGET , D3DFMT_A8R8G8B8 ,D3DPOOL_DEFAULT , &g_pTexture , &g_pSharedHandleTex9 );

hr = m_pDevice11->OpenSharedResource( g_pSharedHandleTex9 , __uuidof(ID3D11Texture2D) , (void**)&m_pTetxure); //success
hr = m_pDevice11->CreateUnorderedAccessView( m_pTetxure, NULL, &m_pTetxureUAV); //fails


so,instead of this, I tried to do 

STEP1: create a texture in directx11 format  DXGI_FORMAT_R8G8B8A8_UNORM (with UAV bind flag)

STEP2: created a shared texture with format D3DFMT_A8R8G8B8 in directx9 and get its shared handle.

STEP3: open the shared texture with directx11 device using the handle.

STEP4: CopyResource() from the texture created on step 1 to the shared texture. 


but the step4 failed,with error 

D3D11: ERROR: ID3D11DeviceContext::CopyResource: Cannot invoke CopyResource when the Formats of each Resource are not the same or at least castable to each other, unless one format is compressed (DXGI_FORMAT_R9G9B9E5_SHAREDEXP, or DXGI_FORMAT_BC[1,2,3,4,5]_* ) and the source format is similar to the dest according to: BC[1|4] ~= R16G16B16A16|R32G32, BC[2|3|5] ~= R32G32B32A32, R9G9B9E5_SHAREDEXP ~= R32. [ RESOURCE_MANIPULATION ERROR #284: COPYRESOURCE_INVALIDSOURCE ]



I thought that D3DFMT_A8R8G8B8 and DXGI_FORMAT_R8G8B8A8_UNORM should match , just like DXGI_FORMAT_R32_FLOAT and D3DFMT_R32F matches.please help me here.



HRESULT hr = g_pd3dDevice9->CreateTexture( Width , Height , 1 , D3DUSAGE_RENDERTARGET , D3DFMT_A8R8G8B8 ,D3DPOOL_DEFAULT , &g_pTexture , &g_pSharedHandleTex9 );

desc.Width              = width;
desc.Height             = height;
desc.Format             = DXGI_FORMAT_R8G8B8A8_UNORM;

hr = m_pDevice11->CreateTexture2D(&desc, NULL, &m_pTetxure); //success
hr = m_pDevice->OpenSharedResource( g_pSharedHandleTex9 , __uuidof(ID3D11Texture2D) , (void**)&m_pSTexture);
m_pDeviceContext11->CopyResource( m_pSTexture, m_pTetxure ); //fails


please help me.


A simple 3D car race game Source

12 February 2011 - 11:06 PM

i made a simple 3d car race game and put it to opensource.it is made in c++,OpenGL,havok physics.it is very basic and good for bigineers.may someone will be helped by it.
here is the link to get executable or source
let me know your suggestions on it.

point sprite problem

09 October 2010 - 09:21 PM

i am make a simple particle system using point sprite.every thing is fine but when i draw a mesh (or actally call drawsubset(x) for mesh drawing) ,particles shows very far from each other and fire system particles becomes like sky-stars.

my code for sprite drawing is

g_pd3dDevice->SetTransform(D3DTS_WORLD, stack->GetTop());

g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

g_pd3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, TRUE ); // Turn on point sprites
g_pd3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE, TRUE ); // Allow sprites to be scaled with distance
g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE, FtoDW( size ) ); // Float value that specifies the size to use for point size computation in cases where point size is not specified for each vertex.
g_pd3dDevice->SetRenderState( D3DRS_POINTSIZE_MIN, FtoDW(1.0f) ); // Float value that specifies the minimum size of point primitives. Point primitives are clamped to this size during rendering.
g_pd3dDevice->SetRenderState( D3DRS_POINTSCALE_A, FtoDW(0.0f) ); // Default 1.0
g_pd3dDevice->SetRenderState( D3DRS_POINTSCALE_B, FtoDW(1.0f) ); // Default 0.0
g_pd3dDevice->SetRenderState( D3DRS_POINTSCALE_C, FtoDW(0.0f) ); // Default 0.0


g_pd3dDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
g_pd3dDevice->SetRenderState( D3DRS_POINTSPRITEENABLE, FALSE );
g_pd3dDevice->SetRenderState( D3DRS_POINTSCALEENABLE, FALSE );

for mesh drawing,i am using MS sample mesh drawing code...


}stack->Pop();d3ddev->SetTransform(D3DTS_WORLD, stack->GetTop());

please help me.

setting up Weapon in FPS

29 September 2010 - 01:20 AM

i am making a simple FPS game in DirectX and c++.
i have a weapon mesh and want to show it as the camera rotate and move,i tried for many hours but can not succeed.

-I know the camera forward,up and right directions (in vector forms)
-I know the current position of camera.

so, how can i set up the rotations and translation of the weapon.

my code is..

D3DXMATRIX matWorld,temp;
g_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );
D3DXMatrixInverse(&matWorld, 0, &matView);


by this code not working well.
please help me.

sceneary along with the road

05 June 2010 - 09:26 PM

I want to make a car race game in opengl.I have a 3ds model of the road which is in zig-zagged shape,now i want to add scenery along with the both corners of the road....but i cant get any way to do it as i have to get all the corners vertics of the road to do that.
So,please tell the standard way,most game programmers do...