Sign in to follow this  
theonlylawislove

IDirect3D9Ex::CreateDeviceEx fails with D3DERR_INVALIDCALL only on one OS

Recommended Posts

This works on an Windows 8 machine, but not on a Windows 7 Embedded machine.

 

Here are the values I am giving the presentation params.

 

AHAOz.png

The parameters to the method are as follows.

CreateDeviceEx(0, 
   D3DDEVTYPE_HAL, 
   displayWindow, 
   presentationParams, 
   D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE | D3DCREATE_HARDWARE_VERTEXPROCESSING, 
   NULL, 
   &device);

Does anyone have an idea as to why I am getting D3DERR_INVALIDCALL?

Share this post


Link to post
Share on other sites

UPDATE: The problem goes away when I use D3DMULTISAMPLE_NONE instead of D3DMULTISAMPLE_NONMASKABLE, but it the application. I'm not familiar with Direct3D to know why this is the case. Here is the code that renders pixels from a buffer.

HRESULT D3D9RenderImpl::CaptureDisplayFrame(BYTE* pBuffer, INT* width, INT* height, INT* stride)
{
    CComPtr<IDirect3DSurface9> pTargetSurface;  
    CComPtr<IDirect3DSurface9> pTempSurface;
    HR(m_pDevice->GetRenderTarget(0, &pTargetSurface)); 
    D3DSURFACE_DESC desc;       
    HR(pTargetSurface->GetDesc(&desc)); 
    if(!pBuffer)
    {
        *width = desc.Width;
        *height = desc.Height;
        *stride = desc.Width * 4; // Always ARGB32
        return S_OK;
    }
    HR(m_pDevice->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &pTempSurface, NULL));               
    HR(m_pDevice->GetRenderTargetData(pTargetSurface, pTempSurface));                    
    D3DLOCKED_RECT d3drect;
    HR(pTempSurface->LockRect(&d3drect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY));     
    BYTE* pFrame = (BYTE*)d3drect.pBits;
    memcpy(pBuffer, pFrame, desc.Height * d3drect.Pitch);
    return pTempSurface->UnlockRect();
}

Any help would be appreciated.

Share this post


Link to post
Share on other sites

I'm no D3D guru, but I should imagine there's a way to check the device caps to verify if your multisampling is supported. Then you can validate if the machine meets your minimum requirements and spit out a more descriptive error message if not.

there is a get device caps method, that return a flag with all available caps.

Doing a check with a & caps.whatneeded, you can know what you need.

Share this post


Link to post
Share on other sites

I'm no D3D guru, but I should imagine there's a way to check the device caps to verify if your multisampling is supported.

IDirect3D9::CheckDeviceMultiSampleType :)

However, unless you want everything to be MSAA'ed (including 2D HUD, post-processing, erx...), then you shouldn't create a multisampled back-buffer upon device creation. Instead, you can use IDirect3DDevice9::CreateRenderTarget to create an MSAA off-screen buffer, and then resolve it to the backbuffer (or another destination) with StretchRect.

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