   Z-buffer problem
  I have problem with order of drawing objects in d3d9 in x64 application, I guess that problem iz in z-buffer but I can't find mistake. Parts of my code::ZeroMemory(&d3dpp,sizeof(d3dpp));d3dpp.BackBufferCount = 1;d3dpp.BackBufferHeight = m_size.cy;d3dpp.BackBufferWidth = m_size.cx;d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.MultiSampleType = (D3DMULTISAMPLE_TYPE)m_multisampling_type;d3dpp.MultiSampleQuality = m_multisampling_quality;d3dpp.hDeviceWindow = m_hWnd;d3dpp.Windowed = TRUE;d3dpp.EnableAutoDepthStencil = TRUE;d3dpp.AutoDepthStencilFormat = D3DFMT_D16;HRESULT hr = m_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);IS_OK(SUCCEEDED(hr));m_pEngine->BeginDraw(m_bSkipMargins, rcInsideRect, m_bVirtualScreenMode, m_totalsize.cx, m_totalsize.cy);hr = m_device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, TRUE);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_ZENABLE, TRUE);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);IS_OK(SUCCEEDED(hr));hr = m_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); IS_OK(SUCCEEDED(hr));m_blit_render3d_state.Release();hr = m_device->CreateStateBlock(D3DSBT_ALL, &m_blit_render3d_state);IS_OK(SUCCEEDED(hr));
  Any ideas?Solved. Clearing Z-Buffer didn't work, so somehow I found the problem on other place in code. The problem was in 5. parameter (DepthStencil) which was set to FALSEHRESULT hr = D3DXCreateRenderToSurface(m_device, m_totalsize.cx, m_totalsize.cy, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D16, &m_pRTS);Later was called m_pRTS->beginScene()... and because of this m_device deattached z-buffer.   