Exemplo n.º 1
0
static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3D9 *d3d9, D3DDEVTYPE deviceType,
        UINT adapter, D3DFORMAT adapterFormat)
{
    gl::TextureCaps textureCaps;

    const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(internalFormat);
    const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
    if (formatInfo.depthBits > 0 || formatInfo.stencilBits > 0)
    {
        textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
    }
    else
    {
        textureCaps.texturable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat)) &&
                                 SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, 0, D3DRTYPE_CUBETEXTURE, d3dFormatInfo.texFormat));
    }

    textureCaps.filterable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, d3dFormatInfo.texFormat));
    textureCaps.renderable = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat)) ||
                             SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, d3dFormatInfo.renderFormat));

    textureCaps.sampleCounts.insert(1);
    for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
    {
        D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_TYPE(i);

        HRESULT result = d3d9->CheckDeviceMultiSampleType(adapter, deviceType, d3dFormatInfo.renderFormat, TRUE, multisampleType, NULL);
        if (SUCCEEDED(result))
        {
            textureCaps.sampleCounts.insert(i);
        }
    }

    return textureCaps;
}
Exemplo n.º 2
0
static gl::TextureCaps GenerateTextureFormatCaps(GLenum internalFormat, IDirect3D9 *d3d9, D3DDEVTYPE deviceType,
                                                 UINT adapter, D3DFORMAT adapterFormat)
{
    gl::TextureCaps textureCaps;

    D3DFORMAT textureFormat = gl_d3d9::GetTextureFormat(internalFormat);
    D3DFORMAT renderFormat = gl_d3d9::GetRenderFormat(internalFormat);

    textureCaps.texture2D = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                              0, D3DRTYPE_TEXTURE, textureFormat));

    textureCaps.textureCubeMap = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                   0, D3DRTYPE_CUBETEXTURE, textureFormat));

    // D3D9 Renderer doesn't support 3D textures
    //textureCaps.setTexture3DSupport(SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format,
    //                                                                  0, D3DRTYPE_VOLUMETEXTURE, textureFormat)));
    textureCaps.texture3D = false;

    // D3D9 doesn't support 2D array textures
    textureCaps.texture2DArray = false;

    textureCaps.filtering = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                              D3DUSAGE_QUERY_FILTER, D3DRTYPE_TEXTURE, textureFormat));

    textureCaps.colorRendering = SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                   D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, textureFormat)) ||
                                 SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                   D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, renderFormat));

    textureCaps.depthRendering = gl::GetDepthBits(internalFormat) > 0 &&
                                 (SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                    D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat)) ||
                                  SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                    D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, renderFormat)));

    textureCaps.stencilRendering = gl::GetStencilBits(internalFormat) > 0 &&
                                   (SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                      D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, textureFormat)) ||
                                    SUCCEEDED(d3d9->CheckDeviceFormat(adapter, deviceType, adapterFormat,
                                                                      D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, renderFormat)));

    textureCaps.sampleCounts.insert(1);
    for (size_t i = D3DMULTISAMPLE_2_SAMPLES; i <= D3DMULTISAMPLE_16_SAMPLES; i++)
    {
        D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_TYPE(i);

        HRESULT result = d3d9->CheckDeviceMultiSampleType(adapter, deviceType, renderFormat, TRUE, multisampleType, NULL);
        if (SUCCEEDED(result))
        {
            textureCaps.sampleCounts.insert(i);
        }
    }

    return textureCaps;
}
Exemplo n.º 3
0
HRESULT					xrIDirect3DTexture9::GetLevelDesc			( UINT Level,D3DSURFACE_DESC *pDesc)
{
    APIDEBUG("xrIDirect3DTexture9::GetLevelDesc");

    pDesc->Format	= Format;
    pDesc->Type		= D3DRTYPE_TEXTURE;
    pDesc->Usage	= Usage;
    pDesc->Pool		= Pool;

    pDesc->MultiSampleType	= D3DMULTISAMPLE_TYPE(0);
    pDesc->MultiSampleQuality = 0;
    pDesc->Width	= Width;
    pDesc->Height	= Height;

    return HRESULT_Proc(S_OK);
};
Exemplo n.º 4
0
HRESULT					xrIDirect3DTexture9::GetSurfaceLevel		( UINT Level,IDirect3DSurface9** ppSurfaceLevel)
{
    APIDEBUG("xrIDirect3DTexture9::GetSurfaceLevel");

    *ppSurfaceLevel = NULL;
    xrIDirect3DSurface9* I = new xrIDirect3DSurface9(m_pIDirect3DDevice9, Width,Height,Format,D3DMULTISAMPLE_TYPE(0),0);
    *ppSurfaceLevel = I;

    return HRESULT_Proc(S_OK);
};
Exemplo n.º 5
0
// This is a static function, will be called when the plugin DLL is initialized
void CDXGraphicsContext::InitDeviceParameters()
{
	SetWindowText(m_hWndStatus, "Initialize DirectX Device");

	// Create Direct3D object
	LPDIRECT3D9 pD3D;
	pD3D = Direct3DCreate9( D3D_SDK_VERSION );
	if( pD3D == NULL )
	{
        DisplayD3DErrorMsg( D3DAPPERR_NODIRECT3D, MSGERR_APPMUSTEXIT );
		return;
	}

	//Get display mode for default adapter
	pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &m_displayMode);

	// Get device caps
	pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_d3dCaps);

	// Determine the maximum FSAA
	for( m_maxFSAA = 16; m_maxFSAA >= 2; m_maxFSAA-- )
	{
		if (SUCCEEDED(pD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, FALSE, D3DMULTISAMPLE_TYPE(D3DMULTISAMPLE_NONE + m_maxFSAA), NULL)))
		{
			if (m_maxFSAA < 2)
				m_maxFSAA = 0;
			break;
		}
		else
		{
			continue;
		}
	}

	if( options.DirectXMaxFSAA != m_maxFSAA )
	{
		options.DirectXMaxFSAA = m_maxFSAA;
		WriteConfiguration();
	}

	// Check Anisotropy Filtering maximum
	m_maxAnisotropy = m_d3dCaps.MaxAnisotropy;

	if( options.DirectXMaxAnisotropy != m_maxAnisotropy )
	{
		options.DirectXMaxAnisotropy = m_maxAnisotropy;
		WriteConfiguration();
	}


	// Release the Direct3D object
	pD3D->Release();
}
Exemplo n.º 6
0
HRESULT					xrIDirect3DCubeTexture9::GetCubeMapSurface( D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface)
{ 
	APIDEBUG("xrIDirect3DCubeTexture9::GetCubeMapSurface"); 

	*ppCubeMapSurface = NULL;
	xrIDirect3DSurface9* I = new xrIDirect3DSurface9(m_pIDirect3DDevice9, Width,Height,Format,D3DMULTISAMPLE_TYPE(0),0);
	*ppCubeMapSurface = I;

	return HRESULT_Proc(S_OK); 
};