Exemplo n.º 1
0
void  dxRenderDeviceRender::Reset( HWND hWnd, u32 &dwWidth, u32 &dwHeight, float &fWidth_2, float &fHeight_2)
{
#ifdef DEBUG
	_SHOW_REF("*ref -CRenderDevice::ResetTotal: DeviceREF:",HW.pDevice);
#endif // DEBUG	

	Resources->reset_begin	();
	Memory.mem_compact		();
	HW.Reset				(hWnd);

#ifdef	USE_DX10
	dwWidth					= HW.m_ChainDesc.BufferDesc.Width;
	dwHeight				= HW.m_ChainDesc.BufferDesc.Height;
#else	//	USE_DX10
	dwWidth					= HW.DevPP.BackBufferWidth;
	dwHeight				= HW.DevPP.BackBufferHeight;
#endif	//	USE_DX10

	fWidth_2				= float(dwWidth/2);
	fHeight_2				= float(dwHeight/2);
	Resources->reset_end	();

#ifdef DEBUG
	_SHOW_REF("*ref +CRenderDevice::ResetTotal: DeviceREF:",HW.pDevice);
#endif // DEBUG
}
void CRenderTarget::accum_omnip_geom_destroy()
{
#ifdef DEBUG
    _SHOW_REF("g_accum_omnip_ib",g_accum_omnip_ib);
#endif // DEBUG
    _RELEASE(g_accum_omnip_ib);
#ifdef DEBUG
    _SHOW_REF("g_accum_omnip_vb",g_accum_omnip_vb);
#endif // DEBUG
    _RELEASE(g_accum_omnip_vb);
}
void CRenderTarget::accum_spot_geom_destroy()
{
#ifdef DEBUG
	_SHOW_REF	("g_accum_spot_ib",g_accum_spot_ib);
#endif // DEBUG
	HW.stats_manager.decrement_stats_ib	(g_accum_spot_ib);
	_RELEASE	(g_accum_spot_ib);
#ifdef DEBUG
	_SHOW_REF	("g_accum_spot_vb",g_accum_spot_vb);
#endif // DEBUG
	HW.stats_manager.decrement_stats_vb	(g_accum_spot_vb);
	_RELEASE	(g_accum_spot_vb);
}
Exemplo n.º 4
0
CRenderTarget::~CRenderTarget	()
{
	// Textures
	t_material->surface_set		(NULL);

#ifdef DEBUG
	_SHOW_REF					("t_material_surf",t_material_surf);
#endif // DEBUG
	_RELEASE					(t_material_surf);

	t_LUM_src->surface_set		(NULL);
	t_LUM_dest->surface_set		(NULL);

#ifdef DEBUG
	_SHOW_REF("t_envmap_0 - #small",t_envmap_0->pSurface);
	_SHOW_REF("t_envmap_1 - #small",t_envmap_1->pSurface);
#endif // DEBUG
	t_envmap_0->surface_set		(NULL);
	t_envmap_1->surface_set		(NULL);
	t_envmap_0.destroy			();
	t_envmap_1.destroy			();

	_RELEASE					(rt_smap_ZB);

	// Jitter
	for (int it=0; it<TEX_jitter_count; it++)	{
		t_noise	[it]->surface_set	(NULL);
#ifdef DEBUG
		_SHOW_REF("t_noise_surf[it]",t_noise_surf[it]);
#endif // DEBUG
		_RELEASE					(t_noise_surf[it]);
	}

	// 
	accum_spot_geom_destroy		();
	accum_omnip_geom_destroy	();
	accum_point_geom_destroy	();

	// Blenders
	xr_delete					(b_combine				);
	xr_delete					(b_luminance			);
	xr_delete					(b_bloom				);
	xr_delete					(b_accum_reflected		);
	xr_delete					(b_accum_spot			);
	xr_delete					(b_accum_point			);
	xr_delete					(b_accum_direct			);
	xr_delete					(b_accum_mask			);
	xr_delete					(b_occq					);
}
Exemplo n.º 5
0
void CTexture::Unload	()
{
#ifdef DEBUG
	string_path				msg_buff;
	sprintf_s				(msg_buff,sizeof(msg_buff),"* Unloading texture [%s] pSurface RefCount=",cName.c_str());
#endif // DEBUG

//.	if (flags.bLoaded)		Msg		("* Unloaded: %s",cName.c_str());
	
	flags.bLoaded			= FALSE;
	if (!seqDATA.empty())	{
		for (u32 I=0; I<seqDATA.size(); I++)
		{
			_RELEASE	(seqDATA[I]);
		}
		seqDATA.clear();
		pSurface	= 0;
	}

#ifdef DEBUG
	_SHOW_REF		(msg_buff, pSurface);
#endif // DEBUG
	_RELEASE		(pSurface);

	xr_delete		(pAVI);
	xr_delete		(pTheora);

	bind			= fastdelegate::FastDelegate1<u32>(this,&CTexture::apply_load);
}
Exemplo n.º 6
0
void	CHW::DestroyDevice	()
{
    _SHOW_REF				("refCount:pBaseZB",pBaseZB);
    _RELEASE				(pBaseZB);

    _SHOW_REF				("refCount:pBaseRT",pBaseRT);
    _RELEASE				(pBaseRT);
#ifdef DEBUG
    _SHOW_REF				("refCount:dwDebugSB",dwDebugSB);
    _RELEASE				(dwDebugSB);
#endif
#ifdef _EDITOR
    _RELEASE				(HW.pDevice);
#else
    _SHOW_REF				("DeviceREF:",HW.pDevice);
    _RELEASE				(HW.pDevice);
#endif    
    DestroyD3D				();
    
#ifndef _EDITOR
    free_vid_mode_list		();
#endif
}
Exemplo n.º 7
0
CInput::~CInput(void)
{
#ifdef ENGINE_BUILD
	Device.seqFrame.Remove			(this);
	Device.seqAppDeactivate.Remove	(this);
	Device.seqAppActivate.Remove	(this);
#endif
	//_______________________

	// Unacquire and release the device's interfaces
	if( pMouse ){
		pMouse->Unacquire();
		_RELEASE	(pMouse);
	}

	if( pKeyboard ){
		pKeyboard->Unacquire();
		_RELEASE	(pKeyboard);
	}

	_SHOW_REF	("Input: ",pDI);
	_RELEASE	(pDI);
}
Exemplo n.º 8
0
void		CHW::CreateDevice		(HWND m_hWnd, bool move_window)
{
    m_move_window			= move_window;
    CreateD3D				();

    // General - select adapter and device
//#ifdef DEDICATED_SERVER
//	BOOL  bWindowed			= TRUE;
//#else
//	BOOL  bWindowed			= !psDeviceFlags.is(rsFullscreen);
//#endif

    BOOL  bWindowed			= TRUE;
    
#ifndef _EDITOR
    if (!g_dedicated_server)
        bWindowed			= !psDeviceFlags.is(rsFullscreen);
#else
    bWindowed				= 1;
#endif        

    DevAdapter				= D3DADAPTER_DEFAULT;
    DevT					= Caps.bForceGPU_REF?D3DDEVTYPE_REF:D3DDEVTYPE_HAL;

#ifndef	MASTER_GOLD
    // Look for 'NVIDIA NVPerfHUD' adapter
    // If it is present, override default settings
    for (UINT Adapter=0;Adapter<pD3D->GetAdapterCount();Adapter++)	{
        D3DADAPTER_IDENTIFIER9 Identifier;
        HRESULT Res=pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
        if (SUCCEEDED(Res) && (xr_strcmp(Identifier.Description,"NVIDIA PerfHUD")==0))
        {
            DevAdapter	=Adapter;
            DevT		=D3DDEVTYPE_REF;
            break;
        }
    }
#endif	//	MASTER_GOLD


    // Display the name of video board
    D3DADAPTER_IDENTIFIER9	adapterID;
    R_CHK	(pD3D->GetAdapterIdentifier(DevAdapter,0,&adapterID));
    Msg		("* GPU [vendor:%X]-[device:%X]: %s",adapterID.VendorId,adapterID.DeviceId,adapterID.Description);

    u16	drv_Product		= HIWORD(adapterID.DriverVersion.HighPart);
    u16	drv_Version		= LOWORD(adapterID.DriverVersion.HighPart);
    u16	drv_SubVersion	= HIWORD(adapterID.DriverVersion.LowPart);
    u16	drv_Build		= LOWORD(adapterID.DriverVersion.LowPart);
    Msg		("* GPU driver: %d.%d.%d.%d",u32(drv_Product),u32(drv_Version),u32(drv_SubVersion), u32(drv_Build));

    Caps.id_vendor	= adapterID.VendorId;
    Caps.id_device	= adapterID.DeviceId;

    // Retreive windowed mode
    D3DDISPLAYMODE mWindowed;
    R_CHK(pD3D->GetAdapterDisplayMode(DevAdapter, &mWindowed));

    // Select back-buffer & depth-stencil format
    D3DFORMAT&	fTarget	= Caps.fTarget;
    D3DFORMAT&	fDepth	= Caps.fDepth;
    if (bWindowed)
    {
        fTarget = mWindowed.Format;
        R_CHK(pD3D->CheckDeviceType	(DevAdapter,DevT,fTarget,fTarget,TRUE));
        fDepth  = selectDepthStencil(fTarget);
    } else {
        switch (psCurrentBPP) {
        case 32:
            fTarget = D3DFMT_X8R8G8B8;
            if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE)))
                break;
            fTarget = D3DFMT_A8R8G8B8;
            if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE)))
                break;
            fTarget = D3DFMT_R8G8B8;
            if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE)))
                break;
            fTarget = D3DFMT_UNKNOWN;
            break;
        case 16:
        default:
            fTarget = D3DFMT_R5G6B5;
            if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE)))
                break;
            fTarget = D3DFMT_X1R5G5B5;
            if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE)))
                break;
            fTarget = D3DFMT_X4R4G4B4;
            if (SUCCEEDED(pD3D->CheckDeviceType(DevAdapter,DevT,fTarget,fTarget,FALSE)))
                break;
            fTarget = D3DFMT_UNKNOWN;
            break;
        }
        fDepth  = selectDepthStencil(fTarget);
    }

    if ((D3DFMT_UNKNOWN==fTarget) || (D3DFMT_UNKNOWN==fTarget))	{
        Msg					("Failed to initialize graphics hardware.\n"
                             "Please try to restart the game.\n"
                             "Can not find matching format for back buffer."
                             );
        FlushLog			();
        MessageBox			(NULL,"Failed to initialize graphics hardware.\nPlease try to restart the game.","Error!",MB_OK|MB_ICONERROR);
        TerminateProcess	(GetCurrentProcess(),0);
    }


    // Set up the presentation parameters
    D3DPRESENT_PARAMETERS&	P	= DevPP;
    ZeroMemory				( &P, sizeof(P) );

#ifndef _EDITOR
    selectResolution	(P.BackBufferWidth, P.BackBufferHeight, bWindowed);
#endif
// Back buffer
//.	P.BackBufferWidth		= dwWidth;
//. P.BackBufferHeight		= dwHeight;
    P.BackBufferFormat		= fTarget;
    P.BackBufferCount		= 1;

    // Multisample
    P.MultiSampleType		= D3DMULTISAMPLE_NONE;
    P.MultiSampleQuality	= 0;

    // Windoze
    P.SwapEffect			= bWindowed?D3DSWAPEFFECT_COPY:D3DSWAPEFFECT_DISCARD;
    P.hDeviceWindow			= m_hWnd;
    P.Windowed				= bWindowed;

    // Depth/stencil
    P.EnableAutoDepthStencil= TRUE;
    P.AutoDepthStencilFormat= fDepth;
    P.Flags					= 0;	//. D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;

    //AVO: functional vsync by avbaula
#ifdef VSYNC_FIX
    P.PresentationInterval = selectPresentInterval(); // Vsync
    if(!bWindowed)		
        P.FullScreen_RefreshRateInHz = selectRefresh(P.BackBufferWidth, P.BackBufferHeight,fTarget);
#else //!VSYNC_FIX
    // Refresh rate
    P.PresentationInterval	= D3DPRESENT_INTERVAL_IMMEDIATE;
    if( !bWindowed )		P.FullScreen_RefreshRateInHz	= selectRefresh	(P.BackBufferWidth, P.BackBufferHeight,fTarget);
#endif //-VSYNC_FIX
    //-AVO
    else					P.FullScreen_RefreshRateInHz	= D3DPRESENT_RATE_DEFAULT;

    // Create the device
    u32 GPU		= selectGPU();	
    HRESULT R	= HW.pD3D->CreateDevice(DevAdapter,
                                        DevT,
                                        m_hWnd,
                                        GPU | D3DCREATE_MULTITHREADED,	//. ? locks at present
                                        &P,
                                        &pDevice );
    
    if (FAILED(R))	{
        R	= HW.pD3D->CreateDevice(	DevAdapter,
                                        DevT,
                                        m_hWnd,
                                        GPU | D3DCREATE_MULTITHREADED,	//. ? locks at present
                                        &P,
                                        &pDevice );
    }
    if (D3DERR_DEVICELOST==R)	{
        // Fatal error! Cannot create rendering device AT STARTUP !!!
        Msg					("Failed to initialize graphics hardware.\n"
                             "Please try to restart the game.\n"
                             "CreateDevice returned 0x%08x(D3DERR_DEVICELOST)", R);
        FlushLog			();
        MessageBox			(NULL,"Failed to initialize graphics hardware.\nPlease try to restart the game.","Error!",MB_OK|MB_ICONERROR);
        TerminateProcess	(GetCurrentProcess(),0);
    };
    R_CHK		(R);

    _SHOW_REF	("* CREATE: DeviceREF:",HW.pDevice);
    switch (GPU)
    {
    case D3DCREATE_SOFTWARE_VERTEXPROCESSING:
        Log	("* Vertex Processor: SOFTWARE");
        break;
    case D3DCREATE_MIXED_VERTEXPROCESSING:
        Log	("* Vertex Processor: MIXED");
        break;
    case D3DCREATE_HARDWARE_VERTEXPROCESSING:
        Log	("* Vertex Processor: HARDWARE");
        break;
    case D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE:
        Log	("* Vertex Processor: PURE HARDWARE");
        break;
    }

    // Capture misc data
#ifdef DEBUG
    R_CHK	(pDevice->CreateStateBlock			(D3DSBT_ALL,&dwDebugSB));
#endif
    R_CHK	(pDevice->GetRenderTarget			(0,&pBaseRT));
    R_CHK	(pDevice->GetDepthStencilSurface	(&pBaseZB));
    u32	memory									= pDevice->GetAvailableTextureMem	();
    Msg		("*     Texture memory: %d M",		memory/(1024*1024));
    Msg		("*          DDI-level: %2.1f",		float(D3DXGetDriverLevel(pDevice))/100.f);
#ifndef _EDITOR
    updateWindowProps							(m_hWnd);
    fill_vid_mode_list							(this);
#endif
}
Exemplo n.º 9
0
CRenderTarget::~CRenderTarget	()
{
    _RELEASE					(t_ss_async);

    // Textures
    t_material->surface_set		(NULL);

#ifdef DEBUG
    _SHOW_REF					("t_material_surf",t_material_surf);
#endif // DEBUG
    _RELEASE					(t_material_surf);

    t_LUM_src->surface_set		(NULL);
    t_LUM_dest->surface_set		(NULL);

#ifdef DEBUG
    ID3DBaseTexture*	pSurf = 0;

    pSurf = t_envmap_0->surface_get();
    if (pSurf) pSurf->Release();
    _SHOW_REF("t_envmap_0 - #small",pSurf);

    pSurf = t_envmap_1->surface_get();
    if (pSurf) pSurf->Release();
    _SHOW_REF("t_envmap_1 - #small",pSurf);
    //_SHOW_REF("t_envmap_0 - #small",t_envmap_0->pSurface);
    //_SHOW_REF("t_envmap_1 - #small",t_envmap_1->pSurface);
#endif // DEBUG
    t_envmap_0->surface_set		(NULL);
    t_envmap_1->surface_set		(NULL);
    t_envmap_0.destroy			();
    t_envmap_1.destroy			();

    //	TODO: DX10: Check if we need old style SMAPs
//	_RELEASE					(rt_smap_ZB);

    // Jitter
    for (int it=0; it<TEX_jitter_count; it++)	{
        t_noise	[it]->surface_set	(NULL);
#ifdef DEBUG
        _SHOW_REF("t_noise_surf[it]",t_noise_surf[it]);
#endif // DEBUG
        _RELEASE					(t_noise_surf[it]);
    }

    t_noise_mipped->surface_set	(NULL);
#ifdef DEBUG
    _SHOW_REF("t_noise_surf_mipped",t_noise_surf_mipped);
#endif // DEBUG
    _RELEASE					(t_noise_surf_mipped);

    //
    accum_spot_geom_destroy		();
    accum_omnip_geom_destroy	();
    accum_point_geom_destroy	();
    accum_volumetric_geom_destroy();

    // Blenders
    xr_delete					(b_combine				);
    xr_delete					(b_luminance			);
    xr_delete					(b_bloom				);
    xr_delete					(b_accum_reflected		);
    xr_delete					(b_accum_spot			);
    xr_delete					(b_accum_point			);
    xr_delete					(b_accum_direct			);
    xr_delete					(b_ssao					);

    if( RImplementation.o.dx10_msaa )
    {
        int bound = RImplementation.o.dx10_msaa_samples;

        if( RImplementation.o.dx10_msaa_opt )
            bound = 1;

        for( int i = 0; i < bound; ++i )
        {
            xr_delete					(b_combine_msaa[i]);
            xr_delete					(b_accum_direct_msaa[i]);
            xr_delete					(b_accum_mask_msaa[i]);
            xr_delete					(b_accum_direct_volumetric_msaa[i]);
            //xr_delete					(b_accum_direct_volumetric_sun_msaa[i]);
            xr_delete					(b_accum_spot_msaa[i]);
            xr_delete					(b_accum_volumetric_msaa[i]);
            xr_delete					(b_accum_point_msaa[i]);
            xr_delete					(b_accum_reflected_msaa[i]);
            xr_delete					(b_ssao_msaa[i]);
        }
    }
    xr_delete					(b_accum_mask			);
    xr_delete					(b_occq					);
}