Пример #1
0
    std::vector<GPU_DEVICE> RenderContext::enumGpuDevicesNV(HGPUNV gpu) const
    {
      std::vector<GPU_DEVICE> devices;

      if(WGLEW_NV_gpu_affinity)
      {
        GPU_DEVICE device;
        for (UINT deviceIndex = 0;wglEnumGpuDevicesNV(gpu, deviceIndex, &device);++deviceIndex)
        {
          devices.push_back(device);
        }
      }
      
      return devices;
    }
Пример #2
0
int main( const int argc, char** argv )
{
    if( !initWGLEW( ))
        std::cerr << "WGL extension query failed" << std::endl;
    else if( !WGLEW_NV_gpu_affinity )
        std::cerr << "WGL_NV_gpu_affinity unsupported" << std::endl;
    else for( UINT gpu = 0; true; ++gpu )
    {
        HGPUNV hGPU = 0;
        if( !wglEnumGpusNV( gpu, &hGPU ))
            break;

        GPU_DEVICE gpuDevice;
        gpuDevice.cb = sizeof( gpuDevice );
        const bool found = wglEnumGpuDevicesNV( hGPU, 0, &gpuDevice );
        assert( found );

        std::cout << "GPU " << gpu << ": " << gpuDevice.DeviceString;
 
        if( gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP )
        {
            const RECT& rect = gpuDevice.rcVirtualScreen;
            std::cout << " used on [" << rect.left << ' ' << rect.top << ' '
                      << rect.right  - rect.left << ' ' 
                      << rect.bottom - rect.top << ']';
        }
        else
            std::cout << " offline";

        std::cout << std::endl;
    }

    std::cout << "Press Enter to exit..." << std::endl;
    
    char foo[256];
    std::cin.getline( foo, 256 );
    return EXIT_SUCCESS;
}
Пример #3
0
//---------------------------------------------------------------------------
// WGL init
//---------------------------------------------------------------------------
bool Pipe::configInit()
{
    if ( !_configInitWGLEW() )
        return false;

    PixelViewport pvp = getPipe()->getPixelViewport();
    if( pvp.isValid( ))
        return true;

    // setup pvp
    // ...using gpu affinity API
    HGPUNV hGPU = 0;
    if( !_getGPUHandle( hGPU ))
        return false;

    if( hGPU != 0 )
    {
        GPU_DEVICE gpuDevice;
        gpuDevice.cb = sizeof( gpuDevice );
        const bool found = wglEnumGpuDevicesNV( hGPU, 0, &gpuDevice );
        EQASSERT( found );

        if( gpuDevice.Flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP )
        {
            const RECT& rect = gpuDevice.rcVirtualScreen;
            pvp.x = rect.left;
            pvp.y = rect.top;
            pvp.w = rect.right  - rect.left;
            pvp.h = rect.bottom - rect.top; 
        }
        else
        {
            pvp.x = 0;
            pvp.y = 0;
            pvp.w = 4096;
            pvp.h = 4096;
        }
    }
    else // ... using Win32 API
    {
        HDC dc = createWGLDisplayDC();

        pvp.x = 0;
        pvp.y = 0;
        if( dc )
        {
            pvp.w = GetDeviceCaps( dc, HORZRES );
            pvp.h = GetDeviceCaps( dc, VERTRES );
            DeleteDC( dc );
        }
        else
        {
            EQWARN << "Can't create display dc query pipe resolution: "
                   << co::base::sysError << std::endl;
            pvp.w = 2048;
            pvp.h = 2048;
        }
    }

    getPipe()->setPixelViewport( pvp );
    EQINFO << "Pipe pixel viewport " << pvp << std::endl;
    return true;
}