void Pyx::Graphics::Gui::ImGuiImpl::Initialize() { if (m_isInitialized) Shutdown(); auto& io = ImGui::GetIO(); io.IniFilename = nullptr; io.LogFilename = nullptr; SetupStyle(); auto* pRenderer = GraphicsContext::GetInstance().GetMainRenderer(); if (pRenderer) { switch (pRenderer->GetRendererType()) { case RendererType::D3D9: { auto* pD3D9Renderer = reinterpret_cast<Renderer::D3D9Renderer*>(pRenderer); auto* pDevice9 = pD3D9Renderer->GetDevice(); if (pDevice9) { ImGui_ImplDX9_Init(pD3D9Renderer->GetAttachedWindow(), pDevice9); if (!m_isResourcesCreated) CreateResources(); m_isInitialized = true; } break; } case RendererType::D3D11: { auto* pD3D11Renderer = reinterpret_cast<Renderer::D3D11Renderer*>(pRenderer); auto* pDevice11 = pD3D11Renderer->GetDevice(); ID3D11DeviceContext* pDevice11Context = nullptr; if (pDevice11) { pDevice11->GetImmediateContext(&pDevice11Context); ImGui_ImplDX11_Init(pD3D11Renderer->GetAttachedWindow(), pDevice11, pDevice11Context); pDevice11Context->Release(); if (!m_isResourcesCreated) CreateResources(); m_isInitialized = true; } break; } default: return; } } }
HRESULT D3D9RenderImpl::Initialize(HWND hDisplayWindow) { m_hDisplayWindow = hDisplayWindow; m_pD3D9 = Direct3DCreate9( D3D_SDK_VERSION ); if(!m_pD3D9) { return E_FAIL; } HR(m_pD3D9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &m_displayMode)); D3DCAPS9 deviceCaps; HR(m_pD3D9->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &deviceCaps)); DWORD dwBehaviorFlags = D3DCREATE_MULTITHREADED; if( deviceCaps.VertexProcessingCaps != 0 ) dwBehaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; else dwBehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING; HR(GetPresentParams(&m_presentParams, TRUE)); HR(m_pD3D9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hDisplayWindow, dwBehaviorFlags, &m_presentParams, &m_pDevice)); return CreateResources(); }
//******************************************************************************* void CBCGPTextGaugeImpl::OnDraw(CBCGPGraphicsManager* pGM, const CBCGPRect& /*rectClip*/, DWORD dwFlags) { ASSERT_VALID(pGM); if (m_rect.IsRectEmpty() || !m_bIsVisible || m_strText.IsEmpty()) { return; } if ((dwFlags & m_DefaultDrawFlags) == 0) { return; } CBCGPRect rect = m_rect; if (m_bIsSubGauge) { rect.OffsetRect(-m_ptScrollOffset); } pGM->FillRectangle(rect, GetFillBrush ()); const CBCGPBrush& br = m_bOff ? m_brTextLight : m_brText; CreateResources(CBCGPBrush(), FALSE); pGM->DrawText(m_strText, rect, m_textFormat, br); pGM->DrawRectangle(rect, GetOutlineBrush (), GetScaleRatioMid()); SetDirty(FALSE); }
//******************************************************************************* CBCGPSize CBCGPTextGaugeImpl::GetDefaultSize(CBCGPGraphicsManager* pGM, const CBCGPBaseVisualObject* /*pParentGauge*/) { ASSERT_VALID(pGM); CreateResources(CBCGPBrush(), FALSE); return pGM->GetTextSize(m_strText, m_textFormat); }
bool SetupGame(ResourceManager &resourceManager, const unsigned int lives) { Map map; CreateResources(resourceManager); return PlayGame(map, resourceManager, lives); }
void CPixelBufferView::OnDeviceReset() { CreateResources(); m_pixelBufferTexture = CreateTextureFromBitmap(m_pixelBufferBitmap); if(!m_checkerboardEffect.IsEmpty()) m_checkerboardEffect->OnResetDevice(); if(!m_pixelBufferViewEffect.IsEmpty()) m_pixelBufferViewEffect->OnResetDevice(); }
//----------------------------------------------------------------------------- void MySample::Create() { CreateResources(); ImGui_ImplDX11_Init(GetHWnd(), GetDevice(), GetContext()); CPUTWindowWin::SetWinProcOverride(MySample_WndProcCallback); int windowWidth, windowHeight; mpWindow->GetClientDimensions(&windowWidth, &windowHeight); SampleUtil_Init(); MenuGlob_Init(); MenuGlob_SetScreenDim(windowWidth, windowHeight); MenuController_Init(); std::string userDir = GetUserDataDirectory(); #ifndef DISABLE_RSSDK MenuController_PushMenu(gMenu_Scan); // go directly to the face mapping menu //std::string debugFace; //CPUTFileSystem::CombinePath(userDir, "joe.obj", &debugFace); //gMenu_FaceMapping->LoadFace(debugFace); //MenuController_PushMenu(gMenu_FaceMapping); // Go directly to the face scan preview menu //gMenu_FaceScanPreview->LoadFaceObj("", true); //gMenu_FaceScanPreview->SetFaceScanMode( FaceScanPreviewMode_ApproveScan ); //MenuController_PushMenu(gMenu_FaceScanPreview); #else std::string debugFace; CPUTFileSystem::CombinePath(userDir, "joe_sr300_1.obj", &debugFace); gMenu_FaceMapping->LoadFace( debugFace ); MenuController_PushMenu(gMenu_FaceMapping); // go directly to the face preview menu //gMenu_FaceScanPreview->LoadFaceObj("", true); //MenuController_PushMenu(gMenu_FaceScanPreview); // go to the edit landmark menu //static CFaceModel faceModel; //faceModel.LoadObjFilename(debugFace); //gMenu_LandmarkEdit->SetInput(&faceModel.Landmarks, &faceModel.Landmarks, NULL, &faceModel); //MenuController_PushMenu(gMenu_LandmarkEdit); #endif MenuGlob_GUI()->SetActivePanel(MENU_CPUT_PANEL_ID); }
//******************************************************************************* void CBCGPTextGaugeImpl::SetText(const CString& str, const CBCGPBrush& brText, BOOL bRedraw) { m_strText = str; CreateResources(brText, TRUE); SetDirty(); if (bRedraw) { Redraw(); } }
//******************************************************************************* void CBCGPTextGaugeImpl::SetText(const CString& str, const CBCGPColor& clrText, BOOL bRedraw) { m_strText = str; CreateResources(clrText == CBCGPColor() ? CBCGPBrush() : CBCGPBrush(clrText), FALSE); SetDirty(); if (bRedraw) { Redraw(); } }
void RenderAPI_D3D12::ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces) { switch (type) { case kUnityGfxDeviceEventInitialize: s_D3D12 = interfaces->Get<IUnityGraphicsD3D12v2>(); CreateResources(); break; case kUnityGfxDeviceEventShutdown: ReleaseResources(); break; } }
void game::Init(void) { if(g_isConsoleUpdater) { cmdLine_Init(); return; } //@gHwInfoPoster.Start(); -- DISABLED FOR NOW // set small icon ::SendMessage(win::hWnd, WM_SETICON, FALSE, (LPARAM)::LoadIcon(win::hInstance, MAKEINTRESOURCE(IDI_WARINC))); // make borderless window and subclass wndProc r3dWinStyleModify(win::hWnd, 0, WS_BORDER); r3dWinStyleModify(win::hWnd, 0, WS_CAPTION); SetWindowLong(win::hWnd, GWL_WNDPROC, (DWORD)&updApp_WndFunc); // ok, now r3drendered started using vars inside itself... RegisterAllVars(); const int Width = 785; const int Height = 650; HDC disp_dc = CreateIC("DISPLAY", NULL, NULL, NULL); int curDispWidth = GetDeviceCaps(disp_dc, HORZRES); int curDispHeight = GetDeviceCaps(disp_dc, VERTRES); int StartXPos = (curDispWidth - Width) / 2; int StartYPos = (curDispHeight - Height) / 2; SetWindowPos(win::hWnd, NULL, StartXPos, StartYPos, (int)Width, (int)Height, 0); r3dRenderer = new r3dRenderLayer; r3dRenderer->Init(win::hWnd, NULL); fake_SetMode(Width, Height); char title[512]; sprintf(title, "Infestation Thailand Updater %s (%s)", UPDATER_VERSION, UPDATER_BUILD); if(!UPDATER_UPDATER_ENABLED) strcat(title, "!!!!SELF_UPDATE_DISABLED!!!"); ::SetWindowText(win::hWnd, title); CreateResources(); ShowWindow(win::hWnd, SW_SHOW); ClipCursor(NULL); // release dinput classes becase we won't be using them Keyboard->ReleaseCapture(); Mouse->ReleaseCapture(); }
// This sample processes audio buffers during the render cycle of the application. // As long as the sample maintains a high-enough frame rate, this approach should // not glitch audio. In game code, it is best for audio buffers to be processed // on a separate thread that is not synced to the main render loop of the game. void Audio::Render() { if (m_engineExperiencedCriticalError) { ReleaseResources(); Initialize(); CreateResources(); Start(); if (m_engineExperiencedCriticalError) { return; } } }
bool cIpmiMcVendor::CreateRdrs( cIpmiDomain *domain, cIpmiMc *source_mc, cIpmiSdrs *sdrs ) { if ( CreateResources( domain, source_mc, sdrs ) == false ) return false; if ( CreateSensors( domain, source_mc, sdrs ) == false ) return false; if ( CreateControls( domain, source_mc, sdrs ) == false ) return false; if ( CreateSels( domain, source_mc, sdrs ) == false ) return false; if ( CreateInvs( domain, source_mc, sdrs ) == false ) return false; return true; }
// GDP = Graphical Data Processor. bool ImageDraw::GDP ( BYTE * image, unsigned long cbImage) { // Check for inforrectly sized image data. if ( cbImage < ((sourceHeight - 1) * sourceStride) + (sourceWidth * 4) ) { return false; } // create the resources for this device // they will be recreated if previously lost HRESULT hr = CreateResources(); if ( FAILED(hr) ) { return false; } // copy the image that was passed in into the direct2d bitmap hr = bitmap->CopyFromMemory( NULL, image, sourceStride); if ( FAILED(hr) ) { return false; } renderTarget->BeginDraw(); // Draw the bitmap streched to the size of the window. renderTarget->DrawBitmap( bitmap ); hr = renderTarget->EndDraw(); // Device lost, need to recreate the render target // We'll dispose it now and retry drawing. if ( hr == D2DERR_RECREATE_TARGET) { hr = S_OK; discardResources(); } return SUCCEEDED( hr ); }
/*func*------------------------------------------------------------------------ set color for screen or printer, handle the GDI resources in :bScreen - false: set color of printer element true : set color of screen element ColorType - desired element (COLOR_TYPE) ulCol - color value out:- -----------------------------------------------------------------------------*/ void GDIHelper::SetColor(bool bScreen, COLOR_TYPE ColorType, COLORREF ulCol) { bool bChanged; ASSERT((ColorType >= 0) || (ColorType < CO_LAST)); if (bScreen) { bChanged = ulColor[1][ColorType] != ulCol; ulColor[1][ColorType] = ulCol; } else { bChanged = ulColor[0][ColorType] != ulCol; ulColor[0][ColorType] = ulCol; } if (bChanged) { DeleteResources(); CreateResources(); } }
bool DX11::Initialise(int a_width, int a_height, bool a_vsync, HWND a_hwnd, bool a_fullscreen, float a_screenNear, float a_screenFar) { // Store common display settings m_width = a_width; m_height = a_height; m_vsync = a_vsync; m_fullscreen = a_fullscreen; // Initiate renderer bool device = CreateDevice(a_hwnd); bool resources = CreateResources(a_screenNear, a_screenFar); #if defined(_DEBUG) if (device && resources) { //m_pDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL); } #endif return device && resources; }
void Graphics::InitializeDirect3d() { HRESULT d3dresult; /* Set some global flags. */ if (config.useDirect3d9Ex) { logger->info("Using Direct3D9Ex mode"); d3dresult = D3DLOG(Direct3DCreate9Ex(D3D_SDK_VERSION, &mDirect3d9)); if (d3dresult != D3D_OK) { throw TempleException("Unable to create Direct3D9 interface."); } } else { logger->info("Using standard Direct3D9 mode"); mDirect3d9 = static_cast<IDirect3D9Ex*>(Direct3DCreate9(D3D_SDK_VERSION)); if (!mDirect3d9) { throw TempleException("Unable to create Direct3D9 interface."); } } /** START OF OLD WINDOWED INIT */ // At this point we only do a GetDisplayMode to check the resolution. We could also do this elsewhere D3DDISPLAYMODE displayMode; d3dresult = D3DLOG(mDirect3d9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode)); if (d3dresult != D3D_OK) { throw TempleException("Unable to query display mode for primary adapter."); } // We need at least 1024x768 if (displayMode.Width < 1024 || displayMode.Height < 768) { throw TempleException("You need at least a display resolution of 1024x768."); } auto presentParams = CreatePresentParams(); // presentParams.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; // presentParams.MultiSampleQuality = 0; // Nvidia drivers seriously barf on D3d9ex if we use software vertex processing here, as ToEE specifies. // I think we are safe with hardware vertex processing, since HW T&L has been standard for more than 10 years. if (config.useDirect3d9Ex) { logger->info("Creating Direct3D9Ex device."); d3dresult = D3DLOG(mDirect3d9->CreateDeviceEx( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mMainWindow.GetHwnd(), D3DCREATE_HARDWARE_VERTEXPROCESSING, &presentParams, nullptr, &mDevice)); } else { logger->info("Creating Direct3D9 device."); d3dresult = D3DLOG(mDirect3d9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mMainWindow.GetHwnd(), D3DCREATE_HARDWARE_VERTEXPROCESSING, &presentParams, reinterpret_cast<IDirect3DDevice9**>(&mDevice))); } if (d3dresult != D3D_OK) { throw TempleException("Unable to create Direct3D9 device!"); } // TODO: color bullshit is not yet done (tig_d3d_init_handleformat et al) // Get the device caps for real this time. ReadCaps(); SetDefaultRenderStates(); CreateResources(); }
//-------------------------------------------------------------------------------------- // Entry point to the program //-------------------------------------------------------------------------------------- int __cdecl wmain() { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // Generate a random list of numbers to sort // Not intended for production code srand( GetTickCount() ); std::generate( data.begin(), data.end(), SampleRand ); // Create the device HRESULT hr = InitDevice(); if ( FAILED (hr) ) { if ( hr == DXUTERR_NODIRECT3D11 ) { OSVERSIONINFOEX osv; memset( &osv, 0, sizeof(osv) ); osv.dwOSVersionInfoSize = sizeof(osv); GetVersionEx( (LPOSVERSIONINFO)&osv ); if ( ( osv.dwMajorVersion > 6 ) || ( osv.dwMajorVersion == 6 && osv.dwMinorVersion >= 1 ) || ( osv.dwMajorVersion == 6 && osv.dwMinorVersion == 0 && osv.dwBuildNumber > 6002 ) ) { MessageBox( 0, L"Direct3D 11 components were not found.", L"Error", MB_ICONEXCLAMATION ); // This should not happen, but is here for completeness as the system could be // corrupted or some future OS version could pull D3D11.DLL for some reason } else if ( osv.dwMajorVersion == 6 && osv.dwMinorVersion == 0 && osv.dwBuildNumber == 6002 ) { MessageBox( 0, L"Direct3D 11 components were not found, but are available for"\ L" this version of Windows.\n"\ L"For details see Microsoft Knowledge Base Article #971644\n"\ L"http://support.microsoft.com/default.aspx/kb/971644/", L"Error", MB_ICONEXCLAMATION ); } else if ( osv.dwMajorVersion == 6 && osv.dwMinorVersion == 0 ) { MessageBox( 0, L"Direct3D 11 components were not found. Please install the latest Service Pack.\n"\ L"For details see Microsoft Knowledge Base Article #935791\n"\ L" http://support.microsoft.com/default.aspx/kb/935791", L"Error", MB_ICONEXCLAMATION ); } else { MessageBox( 0, L"Direct3D 11 is not supported on this OS.", L"Error", MB_ICONEXCLAMATION ); } } printf( "Failed to create the device. Exiting.\n" ); return 1; } // Create the buffers and shaders if( FAILED( CreateResources() ) ) { printf( "Failed to create resources. Exiting.\n" ); return 1; } printf( "Sorting %u Elements\n", NUM_ELEMENTS ); // GPU Bitonic Sort printf( "Starting GPU Bitonic Sort...\n" ); GPUSort(); printf( "...GPU Bitonic Sort Finished\n" ); // Sort the data on the CPU to compare for correctness printf( "Starting CPU Sort...\n" ); CPUSort(); printf( "...CPU Sort Finished\n" ); // Compare the results for correctness bool bComparisonSucceeded = true; for( UINT i = 0 ; i < NUM_ELEMENTS ; ++i ) { if( data[i] != results[i] ) { bComparisonSucceeded = false; break; } } printf( "Comparison %s\n", (bComparisonSucceeded)? "Succeeded" : "FAILED" ); // Cleanup the resources SAFE_RELEASE( g_pReadBackBuffer ); SAFE_RELEASE( g_pBuffer2UAV ); SAFE_RELEASE( g_pBuffer1UAV ); SAFE_RELEASE( g_pBuffer2SRV ); SAFE_RELEASE( g_pBuffer1SRV ); SAFE_RELEASE( g_pBuffer2 ); SAFE_RELEASE( g_pBuffer1 ); SAFE_RELEASE( g_pCB ); SAFE_RELEASE( g_pComputeShaderTranspose ); SAFE_RELEASE( g_pComputeShaderBitonic ); SAFE_RELEASE( g_pd3dImmediateContext ); SAFE_RELEASE( g_pd3dDevice ); return 0; }
//******************************************************************************* void CBCGPTextGaugeImpl::SetTextColor(const CBCGPColor& color) { CreateResources(CBCGPBrush(color), FALSE); SetDirty(); }
void WinConsole::InitAppMode() { SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); m_instance = (HINSTANCE)GetModuleHandle(0); DWORD processId; GetWindowThreadProcessId(GetConsoleWindow(), &processId); if (GetCurrentProcessId() == processId && g_ArgumentCount == 1) { m_initialArguments = (char**)g_Arguments; m_initialArgumentCount = g_ArgumentCount; // make command line to start in server mode m_defaultArguments = (char**)malloc(sizeof(char*) * 3); m_defaultArguments[0] = (*g_Arguments)[0]; m_defaultArguments[1] = "-s"; m_defaultArguments[2] = nullptr; g_Arguments = (char*(*)[])m_defaultArguments; g_ArgumentCount = 2; m_appMode = true; } else if (GetCurrentProcessId() == processId && g_ArgumentCount > 1) { for (int i = 1; i < g_ArgumentCount; i++) { if (!strcmp((*g_Arguments)[i], "-D")) { break; } else if (!strcmp((*g_Arguments)[i], "-app")) { m_appMode = true; } else if (!strcmp((*g_Arguments)[i], "-auto")) { m_autoParam = true; } else if (!strcmp((*g_Arguments)[i], "-A")) { m_addParam = true; } } if (m_appMode || m_autoParam) { m_initialArguments = (char**)g_Arguments; m_initialArgumentCount = g_ArgumentCount; // remove "-app" from command line int argc = g_ArgumentCount - (m_appMode ? 1 : 0) - (m_autoParam ? 1 : 0); m_defaultArguments = (char**)malloc(sizeof(char*) * (argc + 2)); int p = 0; for (int i = 0; i < g_ArgumentCount; i++) { if (strcmp((*g_Arguments)[i], "-app") && strcmp((*g_Arguments)[i], "-auto")) { m_defaultArguments[p++] = (*g_Arguments)[i]; } } m_defaultArguments[p] = nullptr; g_Arguments = (char*(*)[])m_defaultArguments; g_ArgumentCount = p; } } if (m_addParam) { RunAnotherInstance(); return; } // m_appMode indicates whether the program was started as a standalone app // (not from a dos box window). In that case we hide the console window, // show the tray icon and start in server mode if (m_appMode) { CreateResources(); CheckRunning(); } }
//******************************************************************************* void CBCGPTextGaugeImpl::SetTextBrush(const CBCGPBrush& brush) { CreateResources(brush, TRUE); SetDirty(); }
void Pyx::Graphics::Gui::ImGuiImpl::OnFrame() { if (m_isInitialized) { if (!m_isResourcesCreated) CreateResources(); if (m_isResourcesCreated) { auto* pRenderer = GraphicsContext::GetInstance().GetMainRenderer(); if (pRenderer) { auto& io = ImGui::GetIO(); if (Input::InputContext::GetInstance().CursorIsVisible() && pRenderer->GetAttachedWindow() == GetForegroundWindow()) { auto cursorPos = Input::InputContext::GetInstance().GetCursorPosition(); ScreenToClient(pRenderer->GetAttachedWindow(), &cursorPos); io.MousePos.x = cursorPos.x; io.MousePos.y = cursorPos.y; io.MouseDown[0] = GetAsyncKeyState(VK_LBUTTON) != 0; io.MouseDown[1] = GetAsyncKeyState(VK_RBUTTON) != 0; io.MouseDown[2] = GetAsyncKeyState(VK_MBUTTON) != 0; io.KeyCtrl = GetAsyncKeyState(VK_CONTROL) != 0; io.KeyShift = GetAsyncKeyState(VK_SHIFT) != 0; io.KeyAlt = GetAsyncKeyState(VK_MENU) != 0; } switch (pRenderer->GetRendererType()) { case RendererType::D3D9: { ImGui_ImplDX9_NewFrame(); break; } case RendererType::D3D11: { ImGui_ImplDX11_NewFrame(); break; } default: return; } if (m_isVisible) { BuildMainMenuBar(); if (m_showConsole) BuildLogsWindow(); if (m_showDebugWindow) BuildDebugWindow(); GetOnRenderCallbacks().Run(this); Scripting::ScriptingContext::GetInstance().FireCallbacks(XorStringW(L"ImGui.OnRender")); ImGui::Render(); } } static int lastToggleVisibilityTick = 0; if (GetTickCount() - lastToggleVisibilityTick > 250) { bool shouldToggleGui = true; for (auto vKey : PyxContext::GetInstance().GetSettings().GuiToggleVisibilityHotkeys) { if (GetAsyncKeyState(vKey) == NULL) { shouldToggleGui = false; break; } } if (shouldToggleGui) { ToggleVisibility(!IsVisible()); lastToggleVisibilityTick = GetTickCount(); } } static int lastToggleConsoleVisibilityTick = 0; if (GetTickCount() - lastToggleConsoleVisibilityTick > 250) { bool shouldToggleConsole = true; for (auto vKey : PyxContext::GetInstance().GetSettings().ImGuiToggleConsoleHotkeys) { if (GetAsyncKeyState(vKey) == NULL) { shouldToggleConsole = false; break; } } if (shouldToggleConsole) { m_showConsole = !m_showConsole; lastToggleConsoleVisibilityTick = GetTickCount(); } } } } }
HRESULT GaussianMain::OnD3D11CreateDevice( ID3D11Device* pd3dDevice) { //HRESULT hr; ID3D11DeviceContext* pd3dImmediateContext; pd3dDevice->GetImmediateContext(&pd3dImmediateContext); // Load effect LoadEffectFromFile(pd3dDevice, L"gaussian_vs_ps.hlsl", &g_pFX_Render); // Layout for full screen quad rendering const D3D11_INPUT_ELEMENT_DESC quad_layout[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; D3DX11_PASS_DESC pass_desc; g_pFX_Render->GetTechniqueByName("Tech_ShowImage")->GetPassByName("Pass_ShowMonoImage")->GetDesc(&pass_desc); pd3dDevice->CreateInputLayout(quad_layout, 2, pass_desc.pIAInputSignature, pass_desc.IAInputSignatureSize, &g_pQuadLayout); // Vertex buffer for full screen quad rendering SCREEN_VERTEX svQuad[4]; svQuad[0].pos = D3DXVECTOR4( -1.0f, 1.0f, 0.5f, 1.0f ); svQuad[0].tex = D3DXVECTOR2( 0.0f, 0.0f ); svQuad[1].pos = D3DXVECTOR4( 1.0f, 1.0f, 0.5f, 1.0f ); svQuad[1].tex = D3DXVECTOR2( 1.0f, 0.0f ); svQuad[2].pos = D3DXVECTOR4( -1.0f, -1.0f, 0.5f, 1.0f ); svQuad[2].tex = D3DXVECTOR2( 0.0f, 1.0f ); svQuad[3].pos = D3DXVECTOR4( 1.0f, -1.0f, 0.5f, 1.0f ); svQuad[3].tex = D3DXVECTOR2( 1.0f, 1.0f ); D3D11_BUFFER_DESC vbdesc = { 4 * sizeof( SCREEN_VERTEX ), D3D11_USAGE_IMMUTABLE, D3D11_BIND_VERTEX_BUFFER, 0, 0 }; D3D11_SUBRESOURCE_DATA InitData; InitData.pSysMem = svQuad; InitData.SysMemPitch = 0; InitData.SysMemSlicePitch = 0; pd3dDevice->CreateBuffer( &vbdesc, &InitData, &g_pScreenQuadVB ); //--------------------------------- //resize swap chain //--------------------------------- CreateResources(pd3dDevice, &GetDXGIBackBufferSurfaceDesc()); // Save render target and viewport pd3dImmediateContext->OMGetRenderTargets(1, &g_pRTV_Default, &g_pDSV_Default); UINT nViewPorts = 1; pd3dImmediateContext->RSGetViewports(&nViewPorts, g_VP_Default); SAFE_RELEASE(pd3dImmediateContext); //---------------------------------- // frame move //---------------------------------- // Compile the shaders if haven't. SAFE_RELEASE(g_pFX_GaussianCol); SAFE_RELEASE(g_pFX_GaussianRow); CompileGaussianFilterEffects(pd3dDevice, &GetDXGIBackBufferSurfaceDesc()); return S_OK; }
//-------------------------------------------------------------------------------------- // Entry point to the program //-------------------------------------------------------------------------------------- int __cdecl wmain() { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif // Generate a random list of numbers to sort // Not intended for production code srand(GetTickCount()); std::generate(data.begin(), data.end(), SampleRand); // Create the device HRESULT hr = InitDevice(); if (FAILED(hr)) { if (hr == DXUTERR_NODIRECT3D) { MessageBox(0, L"Direct3D 11 components were not found.\n" L"For details see Microsoft Knowledge Base\n" L"https://support.microsoft.com/", L"Error", MB_ICONEXCLAMATION); } printf("Failed to create the device. Exiting.\n"); return 1; } // Create the buffers and shaders if (FAILED(CreateResources())) { printf("Failed to create resources. Exiting.\n"); return 1; } printf("Sorting %u Elements\n", NUM_ELEMENTS); // GPU Bitonic Sort printf("Starting GPU Bitonic Sort...\n"); GPUSort(); printf("...GPU Bitonic Sort Finished\n"); // Sort the data on the CPU to compare for correctness printf("Starting CPU Sort...\n"); CPUSort(); printf("...CPU Sort Finished\n"); // Compare the results for correctness bool bComparisonSucceeded = true; for (UINT i = 0; i < NUM_ELEMENTS; ++i) { if (data[i] != results[i]) { bComparisonSucceeded = false; break; } } printf("Comparison %s\n", (bComparisonSucceeded) ? "Succeeded" : "FAILED"); // Cleanup the resources SAFE_RELEASE(g_pReadBackBuffer); SAFE_RELEASE(g_pBuffer2UAV); SAFE_RELEASE(g_pBuffer1UAV); SAFE_RELEASE(g_pBuffer2SRV); SAFE_RELEASE(g_pBuffer1SRV); SAFE_RELEASE(g_pBuffer2); SAFE_RELEASE(g_pBuffer1); SAFE_RELEASE(g_pCB); SAFE_RELEASE(g_pComputeShaderTranspose); SAFE_RELEASE(g_pComputeShaderBitonic); SAFE_RELEASE(g_pd3dImmediateContext); SAFE_RELEASE(g_pd3dDevice); return 0; }
void CPixelBufferView::OnDeviceReset() { CreateResources(); CreateSelectedPixelBufferTexture(); }