void ScanCode(u32 pc,CodeRegion* to) { to->start=pc; InitPipeline(); bool stop=false; u32 op_count=0; u32 SOM; while(stop==false) { op_count++; u32 opcode=IReadMem16(pc); StepPipeline(opcode); if (Scanner_FindSOM(opcode,pc,&SOM)) { //log("Scanner : SOM %d\n",SOM); pc+=SOM+2; op_count+=SOM>>1; known_pl_cycles+=SOM>>1; } else {
bool FRenderD3D11::Initialize(HWND hWindow) { // create a struct to hold information about the swap chain DXGI_SWAP_CHAIN_DESC scd; // clear out the struct for use ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); // fill the swap chain description struct scd.BufferCount = 1; // one back buffer scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color scd.BufferDesc.Width = FTL::WINDOW_DEFAULT_ROW_SIZE; // set the back buffer width scd.BufferDesc.Height = FTL::WINDOW_DEFAULT_COL_SIZE; // set the back buffer height scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used scd.OutputWindow = hWindow; // the window to be used scd.SampleDesc.Count = 4; // how many multisamples scd.Windowed = TRUE; // windowed/full-screen mode scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; // allow full-screen switching // create a device, device context and swap chain using the information in the scd struct D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &scd, &m_pSwapchain, &m_pDevice, NULL, &m_pDeviceContext); // get the address of the back buffer ID3D11Texture2D *pBackBuffer; m_pSwapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); // use the back buffer address to create the render target m_pDevice->CreateRenderTargetView(pBackBuffer, NULL, &m_pBackbuffer); pBackBuffer->Release(); // set the render target as the back buffer m_pDeviceContext->OMSetRenderTargets(1, &m_pBackbuffer, NULL); // Set the viewport D3D11_VIEWPORT viewport; ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT)); viewport.TopLeftX = 0; viewport.TopLeftY = 0; viewport.Width = FTL::WINDOW_DEFAULT_ROW_SIZE; viewport.Height = FTL::WINDOW_DEFAULT_COL_SIZE; m_pDeviceContext->RSSetViewports(1, &viewport); InitPipeline(); InitGraphics(); return true; }
//====================================================================== //====================================================================== bool NvUIGraphicFrameRenderVK::StaticInit() { //NvUIGraphicRenderVK::StaticInit(); if (!ms_staticCount) { ms_shader.Load(); VkPipelineColorBlendAttachmentState colorStateBlend = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; colorStateBlend.colorWriteMask = ~0; colorStateBlend.blendEnable = VK_TRUE; colorStateBlend.alphaBlendOp = VK_BLEND_OP_ADD; colorStateBlend.colorBlendOp = VK_BLEND_OP_ADD; colorStateBlend.srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; colorStateBlend.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; colorStateBlend.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; colorStateBlend.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; VkPipelineColorBlendStateCreateInfo colorInfoBlend = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; colorInfoBlend.logicOpEnable = VK_FALSE; colorInfoBlend.attachmentCount = 1; colorInfoBlend.pAttachments = &colorStateBlend; colorInfoBlend.blendConstants[0] = 1.0f; colorInfoBlend.blendConstants[1] = 1.0f; colorInfoBlend.blendConstants[2] = 1.0f; colorInfoBlend.blendConstants[3] = 1.0f; InitPipeline(ms_shader.mStageCount, ms_shader.mStages, &colorInfoBlend, &ms_pipelineAlpha); colorStateBlend.blendEnable = VK_FALSE; InitPipeline(ms_shader.mStageCount, ms_shader.mStages, &colorInfoBlend, &ms_pipelineOpaque); } ms_staticCount++; return true; }
void InitD3D( HWND hWnd, SFLOAT width, SFLOAT height ){ //initializing swap chain DXGI_SWAP_CHAIN_DESC swapChainDesc; ZeroMemory( &swapChainDesc, sizeof( DXGI_SWAP_CHAIN_DESC ) ); swapChainDesc.BufferCount = 1; // number of back buffers swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; //unsigned normalized values swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // draw graphics into back buffer swapChainDesc.OutputWindow = hWnd; // window to output to swapChainDesc.SampleDesc.Count = 4; // anti-aliasing that is done on the images swapChainDesc.Windowed = TRUE; D3D_FEATURE_LEVEL featureLevels[] = { //D3D_FEATURE_LEVEL_11_0 D3D_FEATURE_LEVEL_10_1, //D3D_FEATURE_LEVEL_10_0, }; HRESULT hr = D3D11CreateDeviceAndSwapChain( NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, //flags for singlethreading/multithreading etc. stuff featureLevels, 1, D3D11_SDK_VERSION, &swapChainDesc, &gSwapChain, &gDevice, NULL, &gDeviceContext ); //setting the render target to the back buffer //get address of back buffer into renderTargetLocation ID3D11Texture2D *renderTargetAddress; gSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (LPVOID*)&renderTargetAddress ); //using the back buffer address to create the render target gDevice->CreateRenderTargetView( renderTargetAddress, NULL, &gRenderTargetView ); renderTargetAddress->Release(); //set render target as the back buffer gDeviceContext->OMSetRenderTargets( 1, &gRenderTargetView, NULL ); InitViewport( width, height ); //InitRasterizer(); InitGraphics( width, height ); InitPipeline(); }
// this function initializes and prepares Direct3D for use void InitD3D(HWND hWnd) { // create a struct to hold information about the swap chain DXGI_SWAP_CHAIN_DESC scd; // clear out the struct for use ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); // fill the swap chain description struct scd.BufferCount = 1; // one back buffer scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32-bit color scd.BufferDesc.Width = SCREEN_WIDTH; // set the back buffer width scd.BufferDesc.Height = SCREEN_HEIGHT; // set the back buffer height scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how swap chain is to be used scd.OutputWindow = hWnd; // the window to be used scd.SampleDesc.Count = 4; // how many multisamples scd.Windowed = TRUE; // windowed/full-screen mode scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; // allow full-screen switching // create a device, device context and swap chain using the information in the scd struct D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &scd, &swapchain, &dev, NULL, &devcon); // create the depth buffer texture D3D11_TEXTURE2D_DESC texd; ZeroMemory(&texd, sizeof(texd)); texd.Width = SCREEN_WIDTH; texd.Height = SCREEN_HEIGHT; texd.ArraySize = 1; texd.MipLevels = 1; texd.SampleDesc.Count = 4; texd.Format = DXGI_FORMAT_D32_FLOAT; texd.BindFlags = D3D11_BIND_DEPTH_STENCIL; ID3D11Texture2D *pDepthBuffer; dev->CreateTexture2D(&texd, NULL, &pDepthBuffer); // create the depth buffer D3D11_DEPTH_STENCIL_VIEW_DESC dsvd; ZeroMemory(&dsvd, sizeof(dsvd)); dsvd.Format = DXGI_FORMAT_D32_FLOAT; dsvd.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; dev->CreateDepthStencilView(pDepthBuffer, &dsvd, &zbuffer); pDepthBuffer->Release(); // get the address of the back buffer ID3D11Texture2D *pBackBuffer; swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); // use the back buffer address to create the render target dev->CreateRenderTargetView(pBackBuffer, NULL, &backbuffer); pBackBuffer->Release(); // set the render target as the back buffer devcon->OMSetRenderTargets(1, &backbuffer, zbuffer); // Set the viewport D3D11_VIEWPORT viewport; ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT)); viewport.TopLeftX = 0; // set the left to 0 viewport.TopLeftY = 0; // set the top to 0 viewport.Width = SCREEN_WIDTH; // set the width to the window's width viewport.Height = SCREEN_HEIGHT; // set the height to the window's height viewport.MinDepth = 0; // the closest an object can be on the depth buffer is 0.0 viewport.MaxDepth = 1; // the farthest an object can be on the depth buffer is 1.0 devcon->RSSetViewports(1, &viewport); InitPipeline(); InitGraphics(); InitStates(); }
// this function initializes and prepares Direct3D for use void Game::Initialize() { // Define temporary pointers to a device and a device context ComPtr<ID3D11Device> dev11; ComPtr<ID3D11DeviceContext> devcon11; // Create the device and device context objects D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0, D3D11_SDK_VERSION, &dev11, nullptr, &devcon11); // Convert the pointers from the DirectX 11 versions to the DirectX 11.1 versions dev11.As(&dev); devcon11.As(&devcon); // obtain the DXGI factory ComPtr<IDXGIDevice1> dxgiDevice; dev.As(&dxgiDevice); ComPtr<IDXGIAdapter> dxgiAdapter; dxgiDevice->GetAdapter(&dxgiAdapter); ComPtr<IDXGIFactory2> dxgiFactory; dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory); // set up the swap chain description DXGI_SWAP_CHAIN_DESC1 scd = { 0 }; scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // how the swap chain should be used scd.BufferCount = 2; // a front buffer and a back buffer scd.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // the most common swap chain format scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // the recommended flip mode scd.SampleDesc.Count = 1; // disable anti-aliasing CoreWindow^ Window = CoreWindow::GetForCurrentThread(); // get the window pointer // create the swap chain dxgiFactory->CreateSwapChainForCoreWindow( dev.Get(), // address of the device reinterpret_cast<IUnknown*>(Window), // address of the window &scd, // address of the swap chain description nullptr, // advanced &swapchain); // address of the new swap chain pointer // get a pointer directly to the back buffer ComPtr<ID3D11Texture2D> backbuffer; swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), &backbuffer); // create a render target pointing to the back buffer dev->CreateRenderTargetView(backbuffer.Get(), nullptr, &rendertarget); // set the viewport D3D11_VIEWPORT viewport = { 0 }; viewport.TopLeftX = 0; viewport.TopLeftY = 0; viewport.Width = Window->Bounds.Width; viewport.Height = Window->Bounds.Height; devcon->RSSetViewports(1, &viewport); // initialize graphics and the pipeline InitGraphics(); InitPipeline(); }
// // FUNCTION: GraphicsDeviceInterface::Initialize() // // PURPOSE: Initializes Direct3D // bool GraphicsDeviceInterface::Initialize(HWND hWnd, WindowSize* wind) { HRESULT hResult; // Clear the struct ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC)); // Set the swap chain values scd.BufferCount = 1; // one back buffer scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // use 32 bit color scd.BufferDesc.Width = wind->getWidth(); // set width using windowSize object scd.BufferDesc.Height = wind->getHeight(); // set height using windowSize object scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; // swap chain is output scd.OutputWindow = hWnd; // window to render into scd.SampleDesc.Count = 4; // use 4 multisamples for antialiasing scd.Windowed = wind->getWindowed(); // Sets windowed mode scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; // Allow full-screen switching // Create the device, context, and swap chain hResult = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, //D3D_FEATURE_LEVEL_10_0, NULL, NULL, D3D11_SDK_VERSION, &scd, &m_Swapchain, &m_Device, NULL, &m_Context); if (hResult != S_OK) { return FALSE; } // Retrieves the IDXGIFactory that created "m_Device" IDXGIDevice *pDXGIDevice; m_Device->QueryInterface(__uuidof(IDXGIDevice), (void **)&pDXGIDevice); IDXGIAdapter *pDXGIAdapter; pDXGIDevice->GetParent(__uuidof(IDXGIAdapter), (void **)&pDXGIAdapter); IDXGIFactory *pDXGIFactory; pDXGIAdapter->GetParent(__uuidof(IDXGIFactory), (void **)&pDXGIFactory); // Disables the use of Alt-Enter to switch between fullscreen/windowed pDXGIFactory->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER); // Resized the target (window or screen resolution) and back buffers m_Swapchain->ResizeTarget(&scd.BufferDesc); m_Swapchain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, scd.Flags); // Get the back buffer address ID3D11Texture1D *pBackBuffer; m_Swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); // Use the back buffer address to create a render target m_Device->CreateRenderTargetView(pBackBuffer, NULL, &m_BackBuffer); pBackBuffer->Release(); D3D11_TEXTURE2D_DESC depthBufferDesc; D3D11_DEPTH_STENCIL_DESC depthStencilDesc; D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc; D3D11_RASTERIZER_DESC rasterDesc; ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc)); depthBufferDesc.Width = wind->getWidth(); depthBufferDesc.Height = wind->getHeight(); depthBufferDesc.MipLevels = 1; depthBufferDesc.ArraySize = 1; depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthBufferDesc.SampleDesc.Count = 4; depthBufferDesc.SampleDesc.Quality = 0; depthBufferDesc.Usage = D3D11_USAGE_DEFAULT; depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthBufferDesc.CPUAccessFlags = 0; depthBufferDesc.MiscFlags = 0; m_Device->CreateTexture2D(&depthBufferDesc, NULL, &m_DepthStencilBuffer); // Initialize the description of the stencil state. ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc)); // Set up the description of the stencil state. depthStencilDesc.DepthEnable = true; depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS; depthStencilDesc.StencilEnable = true; depthStencilDesc.StencilReadMask = 0xFF; depthStencilDesc.StencilWriteMask = 0xFF; // Stencil operations if pixel is front-facing. depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; // Stencil operations if pixel is back-facing. depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; m_Device->CreateDepthStencilState(&depthStencilDesc, &m_DepthStencilState); m_Context->OMSetDepthStencilState(m_DepthStencilState, 1); // Initailze the depth stencil view. ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc)); // Set up the depth stencil view description. depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; depthStencilViewDesc.Texture2D.MipSlice = 0; m_Device->CreateDepthStencilView(m_DepthStencilBuffer, NULL, &m_DepthStencilView); // set the render target as the back buffer m_Context->OMSetRenderTargets(1, &m_BackBuffer, m_DepthStencilView); // Set the viewport using windowSize object D3D11_VIEWPORT viewport; ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT)); viewport.TopLeftX = 0; viewport.TopLeftY = 0; viewport.MinDepth = 0.0f; viewport.MaxDepth = 1.0f; viewport.Width = (float)wind->getWidth(); viewport.Height = (float)wind->getHeight(); m_Context->RSSetViewports(1, &viewport); // Setup the projection matrix. float fieldOfView = (float)D3DX_PI / 4.0f; float screenAspect = (float)wind->getWidth() / (float)wind->getHeight(); // TODO: Make constants for screen depth and screen near. // Create the projection matrix for 3D rendering. D3DXMatrixPerspectiveFovLH(&m_projMatrix, fieldOfView, screenAspect, 0.1f, 1000.0f); InitPipeline(); InitGraphics(); return TRUE; }
avtDataRequest_p avtOriginatingSource::BalanceLoad(avtContract_p contract) { bool usesAllDomains =contract->GetDataRequest()->GetSIL().UsesAllDomains(); // // If it shouldn't use load balancing, then it has to do with auxiliary // data coming through our meta-data mechanism. Calling InitPipeline // would change the data attributes and it also causes an unnecessary // callback to our progress mechanism. // if (contract->ShouldUseLoadBalancing()) { InitPipeline(contract); } else if (contract->DoingOnDemandStreaming()) { GetOutput()->GetInfo().GetValidity().SetWhetherStreaming(true); } // // Allow the load balancer to split the load across processors. // bool dataReplicationOccurred = false; avtDataRequest_p rv = NULL; if (!UseLoadBalancer()) { debug5 << "This source should not load balance the data." << endl; rv = contract->GetDataRequest(); } else if (! contract->ShouldUseLoadBalancing()) { debug5 << "This pipeline has indicated that no load balancing should " << "be used." << endl; rv = contract->GetDataRequest(); } else if (loadBalanceFunction != NULL) { debug5 << "Using load balancer to reduce data." << endl; rv = loadBalanceFunction(loadBalanceFunctionArgs, contract); dataReplicationOccurred = contract->ReplicateSingleDomainOnAllProcessors(); } else { debug1 << "No load balancer exists to reduce data." << endl; rv = contract->GetDataRequest(); } // // Return the portion for this processor. // rv->SetUsesAllDomains(usesAllDomains); // // Tell the output if we are doing data replication. // if (dataReplicationOccurred) GetOutput()->GetInfo().GetAttributes().SetDataIsReplicatedOnAllProcessors(true); return rv; }