void Shader::Close() { _RELEASE(m_pVertexShader); _RELEASE(m_pPixelShader); _RELEASE(m_pLayout); _RELEASE(m_pSampleState); _RELEASE(m_pTexture); }
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); }
void CDetailManager::hw_Unload() { // Destroy VS/VB/IB hw_Geom.destroy (); _RELEASE (hw_IB); _RELEASE (hw_VB); }
void SPrimitiveBuffer::Destroy() { if (pGeom){ _RELEASE (pGeom->vb); _RELEASE (pGeom->ib); pGeom.destroy (); } }
void CRTC::destroy () { pTexture->surface_set (0); pTexture = NULL; for (u32 face=0; face<6; face++) _RELEASE (pRT[face] ); _RELEASE (pSurface ); }
void CRT::destroy () { if (pTexture._get()) { pTexture->surface_set (0); pTexture = NULL; } _RELEASE (pRT ); _RELEASE (pSurface ); }
void CDetailManager::hw_Unload() { // Destroy VS/VB/IB hw_Geom.destroy (); HW.stats_manager.decrement_stats_vb ( hw_VB); HW.stats_manager.decrement_stats_ib ( hw_IB); _RELEASE (hw_IB); _RELEASE (hw_VB); }
void CHW::Reset (HWND hwnd) { #ifdef DEBUG _RELEASE (dwDebugSB); #endif _RELEASE (pBaseZB); _RELEASE (pBaseRT); #ifndef _EDITOR //#ifndef DEDICATED_SERVER // BOOL bWindowed = !psDeviceFlags.is (rsFullscreen); //#else // BOOL bWindowed = TRUE; //#endif BOOL bWindowed = TRUE; if (!g_dedicated_server) bWindowed = !psDeviceFlags.is (rsFullscreen); selectResolution (DevPP.BackBufferWidth, DevPP.BackBufferHeight, bWindowed); // Windoze DevPP.SwapEffect = bWindowed?D3DSWAPEFFECT_COPY:D3DSWAPEFFECT_DISCARD; DevPP.Windowed = bWindowed; //AVO: fucntional vsync by avbaula #ifdef VSYNC_FIX DevPP.PresentationInterval = selectPresentInterval(); // Vsync if(!bWindowed) // Refresh rate DevPP.FullScreen_RefreshRateInHz = selectRefresh(DevPP.BackBufferWidth,DevPP.BackBufferHeight,Caps.fTarget); else DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; #else //!VSYNC_FIX DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if( !bWindowed ) DevPP.FullScreen_RefreshRateInHz = selectRefresh (DevPP.BackBufferWidth,DevPP.BackBufferHeight,Caps.fTarget); else DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; #endif //-VSYNC_FIX //-AVO #endif //-_EDITOR while (TRUE) { HRESULT _hr = HW.pDevice->Reset (&DevPP); if (SUCCEEDED(_hr)) break; Msg ("! ERROR: [%dx%d]: %s",DevPP.BackBufferWidth,DevPP.BackBufferHeight,Debug.error2string(_hr)); Sleep (100); } R_CHK (pDevice->GetRenderTarget (0,&pBaseRT)); R_CHK (pDevice->GetDepthStencilSurface (&pBaseZB)); #ifdef DEBUG R_CHK (pDevice->CreateStateBlock (D3DSBT_ALL,&dwDebugSB)); #endif #ifndef _EDITOR updateWindowProps (hwnd); #endif }
void CRender::level_Unload() { if (0==g_pGameLevel) return; if (!b_loaded) return; u32 I; // HOM HOM.Unload (); //*** Details Details->Unload (); //*** Sectors // 1. xr_delete (rmPortals); pLastSector = 0; vLastCameraPos.set (0,0,0); // 2. for (I=0; I<Sectors.size(); I++) xr_delete(Sectors[I]); Sectors.clear (); // 3. Portals.clear (); //*** Lights // Glows.Unload (); Lights.Unload (); //*** Visuals for (I=0; I<Visuals.size(); I++) { Visuals[I]->Release(); xr_delete(Visuals[I]); } Visuals.clear (); //*** VB/IB for (I=0; I<nVB.size(); I++) _RELEASE(nVB[I]); for (I=0; I<xVB.size(); I++) _RELEASE(xVB[I]); nVB.clear(); xVB.clear(); for (I=0; I<nIB.size(); I++) _RELEASE(nIB[I]); for (I=0; I<xIB.size(); I++) _RELEASE(xIB[I]); nIB.clear(); xIB.clear(); nDC.clear(); xDC.clear(); //*** Components xr_delete (Details); xr_delete (Wallmarks); //*** Shaders Shaders.clear_and_free (); b_loaded = FALSE; }
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 CRender::destroy () { ::PortalTraverser.destroy (); _RELEASE (q_sync_point[1]); _RELEASE (q_sync_point[0]); HWOCC.occq_destroy (); xr_delete (Models); xr_delete (Target); PSLibrary.OnDestroy (); Device.seqFrame.Remove (this); }
ID3DTexture2D* TW_LoadTextureFromTexture ( ID3DTexture2D* t_from, D3DFORMAT& t_dest_fmt, int levels_2_skip, u32& w, u32& h ) { // Calculate levels & dimensions ID3DTexture2D* t_dest = NULL; D3DSURFACE_DESC t_from_desc0 ; R_CHK (t_from->GetLevelDesc (0,&t_from_desc0)); int levels_exist = t_from->GetLevelCount(); int top_width = t_from_desc0.Width; int top_height = t_from_desc0.Height; Reduce (top_width,top_height,levels_exist,levels_2_skip); // Create HW-surface if (D3DX_DEFAULT==t_dest_fmt) t_dest_fmt = t_from_desc0.Format; R_CHK (D3DXCreateTexture( HW.pDevice, top_width,top_height, levels_exist,0,t_dest_fmt, D3DPOOL_MANAGED,&t_dest )); // Copy surfaces & destroy temporary ID3DTexture2D* T_src= t_from; ID3DTexture2D* T_dst= t_dest; int L_src = T_src->GetLevelCount ()-1; int L_dst = T_dst->GetLevelCount ()-1; for (; L_dst>=0; L_src--,L_dst--) { // Get surfaces IDirect3DSurface9 *S_src, *S_dst; R_CHK (T_src->GetSurfaceLevel (L_src,&S_src)); R_CHK (T_dst->GetSurfaceLevel (L_dst,&S_dst)); // Copy R_CHK (D3DXLoadSurfaceFromSurface(S_dst,NULL,NULL,S_src,NULL,NULL,D3DX_FILTER_NONE,0)); // Release surfaces _RELEASE (S_src); _RELEASE (S_dst); } // OK w = top_width; h = top_height; return t_dest; }
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); }
void R_occlusion::occq_destroy ( ) { while (!used.empty()) { _RELEASE(used.back().Q); used.pop_back (); } while (!pool.empty()) { _RELEASE(pool.back().Q); pool.pop_back (); } used.clear (); pool.clear (); fids.clear (); }
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 ); }
void CRT::destroy () { if (pTexture._get()) { pTexture->surface_set (0); pTexture = NULL; } _RELEASE (pRT ); _RELEASE (pZRT ); HW.stats_manager.decrement_stats_rtarget( pSurface ); _RELEASE (pSurface ); #ifdef USE_DX11 _RELEASE (pUAView); #endif }
dx10ConstantBuffer::~dx10ConstantBuffer() { DEV->_DeleteConstantBuffer(this); // Flush(); _RELEASE(m_pBuffer); xr_free(m_pBufferData); }
void CTexture::surface_set (ID3DBaseTexture* surf ) { if (surf) surf->AddRef (); _RELEASE (pSurface); pSurface = surf; }
bool Shader::createShader(wchar_t* namevs, wchar_t* nameps, ID3D11Device* pDevice) { HRESULT hr = S_OK; ID3DBlob* vertexShaderBuffer = nullptr; hr = m_compileShaderFromFile(namevs, "VS", "vs_4_0", &vertexShaderBuffer); if(FAILED(hr)) { Log::get()->err("Не удалось загрузить вершинный шейдер %ls", namevs); return false; } ID3DBlob* pixelShaderBuffer = nullptr; hr = m_compileShaderFromFile(nameps, "PS", "ps_4_0", &pixelShaderBuffer); if(FAILED(hr)) { Log::get()->err("Не удалось загрузить пиксельный шейдер %ls", nameps); return false; } hr = pDevice->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_pVertexShader); if(FAILED(hr)) { Log::get()->err("Не удалось создать вершинный шейдер"); return false; } hr = pDevice->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pPixelShader); if(FAILED(hr)) { Log::get()->err("Не удалось создать пиксельный шейдер"); return false; } hr = pDevice->CreateInputLayout(m_pLayoutFormat, m_numLayout, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_pLayout); if(FAILED(hr)) { Log::get()->err("Не удалось создать формат ввода"); return false; } _DELETE_ARRAY(m_pLayoutFormat); _RELEASE(vertexShaderBuffer); _RELEASE(pixelShaderBuffer); return true; }
void dxEnvironmentRender::OnFrame(CEnvironment &env) { dxEnvDescriptorMixerRender &mixRen = *(dxEnvDescriptorMixerRender*)&*env.CurrentEnv->m_pDescriptorMixer; if (::Render->get_generation()==IRender_interface::GENERATION_R2){ //. very very ugly hack if (HW.Caps.raster_major >= 3 && HW.Caps.geometry.bVTF){ // tonemapping in VS mixRen.sky_r_textures.push_back (mk_pair(u32(D3DVERTEXTEXTURESAMPLER0),tonemap)); //. hack mixRen.sky_r_textures_env.push_back (mk_pair(u32(D3DVERTEXTEXTURESAMPLER0),tonemap)); //. hack mixRen.clouds_r_textures.push_back (mk_pair(u32(D3DVERTEXTEXTURESAMPLER0),tonemap)); //. hack } else { // tonemapping in PS mixRen.sky_r_textures.push_back (mk_pair(2,tonemap)); //. hack mixRen.sky_r_textures_env.push_back (mk_pair(2,tonemap)); //. hack mixRen.clouds_r_textures.push_back (mk_pair(2,tonemap)); //. hack } } //. Setup skybox textures, somewhat ugly ID3DBaseTexture* e0 = mixRen.sky_r_textures[0].second->surface_get(); ID3DBaseTexture* e1 = mixRen.sky_r_textures[1].second->surface_get(); tsky0->surface_set (e0); _RELEASE(e0); tsky1->surface_set (e1); _RELEASE(e1); // ******************** Environment params (setting) #ifdef USE_DX10 // TODO: DX10: Implement environment parameters setting for DX10 (if necessary) #else // USE_DX10 #if RENDER==R_R1 Fvector3 fog_color = env.CurrentEnv->fog_color; fog_color.mul(ps_r1_fog_luminance); #else // RENDER==R_R1 Fvector3 &fog_color = env.CurrentEnv->fog_color; #endif // RENDER==R_R1 CHK_DX(HW.pDevice->SetRenderState( D3DRS_FOGCOLOR, color_rgba_f(fog_color.x,fog_color.y,fog_color.z,0) )); CHK_DX(HW.pDevice->SetRenderState( D3DRS_FOGSTART, *(u32 *)(&env.CurrentEnv->fog_near) )); CHK_DX(HW.pDevice->SetRenderState( D3DRS_FOGEND, *(u32 *)(&env.CurrentEnv->fog_far) )); #endif // USE_DX10 }
void dx103DFluidRenderer::Destroy() { if (!m_bInited) return; //createJitterTexture(); m_JitterTexture = 0; m_HHGGTexture = 0; //createScreenQuad(); m_GeomQuadVertex = 0; _RELEASE(m_pQuadVertexBuffer); //createGridBox(); m_GeomGridBox = 0; _RELEASE(m_pGridBoxVertexBuffer); _RELEASE(m_pGridBoxIndexBuffer); DestroyShaders(); }
void r_pixel_calculator::end () { Device.End (); RCache.set_RT (HW.pBaseRT); RCache.set_ZB (HW.pBaseZB); _RELEASE (zb); rt = 0 ; }
void dx10StateCache<IDeviceState, StateDecs> ::ClearStateArray() { for (u32 i=0; i<m_StateArray.size(); ++i) { _RELEASE(m_StateArray[i].m_pState); } m_StateArray.clear_not_free(); }
CSoundStream::~CSoundStream ( ) { Stop ( ); FS.r_close (hf); xr_free (WaveSource); xr_free (WaveDest); xr_free (pwfx); xr_free (psrc); _RELEASE (pBuffer); }
void dx103DFluidRenderer::CreateJitterTexture() { BYTE data[256 * 256]; for (int i = 0; i < 256 * 256; i++) { data[i] = (unsigned char) (rand()/float(RAND_MAX)*256); } D3D10_TEXTURE2D_DESC desc; desc.Width = 256; desc.Height = 256; desc.MipLevels = 1; desc.ArraySize = 1; //desc.Format = DXGI_FORMAT_R8_TYPELESS; desc.Format = DXGI_FORMAT_R8_UNORM; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; //desc.Usage = D3D10_USAGE_IMMUTABLE; desc.Usage = D3D10_USAGE_DEFAULT; desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = 0; desc.MiscFlags = 0; D3D10_SUBRESOURCE_DATA dataDesc; dataDesc.pSysMem = data; dataDesc.SysMemPitch = 256; ID3D10Texture2D* NoiseTexture = NULL; //ID3D10ShaderResourceView* JitterTextureSRV = NULL; CHK_DX( HW.pDevice->CreateTexture2D(&desc, &dataDesc, &NoiseTexture)); //( m_pD3DDevice->CreateTexture2D(&desc, &dataDesc, &NoiseTexture) ); // Create the shader resource view for jittering //D3D10_SHADER_RESOURCE_VIEW_DESC descSRV; //ZeroMemory( &descSRV, sizeof(descSRV) ); //descSRV.Format = DXGI_FORMAT_R8_UNORM; //descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; //descSRV.Texture2D.MipLevels = 1; //descSRV.Texture2D.MostDetailedMip = 0; //V( m_pD3DDevice->CreateShaderResourceView( NoiseTexture, &descSRV, &JitterTextureSRV ) ); //pEffect->GetVariableByName("jitterTex")->AsShaderResource() -> SetResource (JitterTextureSRV); m_JitterTexture = dxRenderDeviceRender::Instance().Resources->_CreateTexture("$user$NVjitterTex"); m_JitterTexture->surface_set(NoiseTexture); _RELEASE(NoiseTexture); //SAFE_RELEASE(JitterTextureSRV); }
void Render::Shutdown() { Close(); if(m_pImmediateContext) m_pImmediateContext->ClearState(); _RELEASE(m_pRenderTargetView); m_pSwapChain->SetFullscreenState(false, NULL); _RELEASE(m_pSwapChain); _RELEASE(m_pDepthStencil); _RELEASE(m_pDepthStencilView); _RELEASE(m_pImmediateContext); // uncomment for debug purposes /* ID3D11Debug *debugDev = nullptr; hr = m_pd3dDevice->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&debugDev)); if (debugDev != nullptr) { debugDev->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL); debugDev = nullptr; }*/ _RELEASE(m_pd3dDevice); }
bool MyRender::Close() { _RELEASE(m_pVertexBuffer); _RELEASE(m_pVertexLayout); _RELEASE(m_pVertexShader); _RELEASE(m_pPixelShader); _RELEASE(m_pPixelShaderSolid); _RELEASE(m_pIndexBuffer); _RELEASE(m_pConstantBuffer); delete m_car; return true; }
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 }
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); }
void CRender::reset_begin() { // Update incremental shadowmap-visibility solver // BUG-ID: 10646 { u32 it=0; for (it=0; it<Lights_LastFrame.size(); it++) { if (0==Lights_LastFrame[it]) continue ; try { Lights_LastFrame[it]->svis.resetoccq () ; } catch (...) { Msg ("! Failed to flush-OCCq on light [%d] %X",it,*(u32*)(&Lights_LastFrame[it])); } } Lights_LastFrame.clear (); } xr_delete (Target); HWOCC.occq_destroy (); _RELEASE (q_sync_point[1]); _RELEASE (q_sync_point[0]); }