当前位置: 首页>>代码示例>>C++>>正文


C++ DevicePtr::reset方法代码示例

本文整理汇总了C++中DevicePtr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ DevicePtr::reset方法的具体用法?C++ DevicePtr::reset怎么用?C++ DevicePtr::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DevicePtr的用法示例。


在下文中一共展示了DevicePtr::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getGpu

//-----------------------------------------------------------------------------
GpuPtr Helper::getGpu(int index)
{
    // Check it against selection criteria.
    pair_int gpuBlock = selectDeviceAndBlock(index);
    if (-1 == gpuBlock.first) return GpuPtr();

    scoped_lock lock(mutex);

    // First check to see if this GPU device has been initialized.
    DevicePtr device;
    DevicelPtrMap::iterator dit = devPtrMap.find(gpuBlock.first);
    if (dit == devPtrMap.end())
    {
        device.reset(new Device(gpuBlock.first));
        // Double check to make sure our device is OK
        if (-1 == device->ID()) return GpuPtr();
        devPtrMap.insert(std::make_pair(gpuBlock.first, device));
    }
    else
    {
        device = dit->second;
        // Make sure we activate this per-thread.
        device->setDevice();
    }

    // Now that we have a device, get the block implementation handle.
    GpuPtr impl;
    GpuPtrMap::iterator it = gpuPtrMap.find(index);
    if (it == gpuPtrMap.end())
    {
        impl.reset(new Gpu(device));
        gpuPtrMap.insert(std::make_pair(index, impl));
    }
    else
    {
        impl = it->second;
    }

    if (!atExitRegistered)
    {
        atexit(Helper::destroy);
        atExitRegistered = true;
    }
    return impl;
}
开发者ID:chuckseberino,项目名称:CCT,代码行数:46,代码来源:CudaHelper.cpp

示例2: Create

	bool Create(HWND hWnd)
	{
		// デバイスとスワップチェーンの作成。
		RECT rectClient;
		GetClientRect(hWnd, &rectClient);

		DXGI_SWAP_CHAIN_DESC sd;
		ZeroMemory(&sd, sizeof(sd));
		sd.BufferCount = 1;
		sd.BufferDesc.Width = rectClient.right - rectClient.left;
		sd.BufferDesc.Height = rectClient.bottom - rectClient.top;
		sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
		sd.BufferDesc.RefreshRate.Numerator = 60;
		sd.BufferDesc.RefreshRate.Denominator = 1;
		sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
		sd.OutputWindow = hWnd;
		sd.SampleDesc.Count = 1;
		sd.SampleDesc.Quality = 0;//1;
		sd.Windowed = TRUE;
		sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
			
		D3D_FEATURE_LEVEL featureLevel;
		
		IDXGISwapChain* pSwapChainTmp;
		ID3D11Device* pDeviceTmp;
		ID3D11DeviceContext* pDeviceContextTmp;
		HRESULT hr = D3D11CreateDeviceAndSwapChain(NULL	// pAdapter
			, D3D_DRIVER_TYPE_HARDWARE	// DriverType
			, NULL	// Software
			, 0	// Flags
			, NULL	// pFeatureLevels
			, 0// FeatureLevels
			, D3D11_SDK_VERSION
			, &sd
			, &pSwapChainTmp
			, &pDeviceTmp
			, &featureLevel
			, &pDeviceContextTmp
			);
		if (FAILED(hr))
		{
			DebugTraceHresult(hr);
			return false;
		}
		_pSwapChain.reset(pSwapChainTmp, &SafeRelease<SwapChainPtr::element_type>);
		_pDevice.reset(pDeviceTmp, &SafeRelease<DevicePtr::element_type>);
		_pDeviceContext.reset(pDeviceContextTmp, &SafeRelease<DeviceContextPtr::element_type>);

		switch (featureLevel)
		{
		case D3D_FEATURE_LEVEL_11_0:	DebugTrace(_T("D3D_FEATURE_LEVEL_11_0")); break;
		case D3D_FEATURE_LEVEL_10_0:	DebugTrace(_T("D3D_FEATURE_LEVEL_10_0")); break;
		case D3D_FEATURE_LEVEL_10_1:	DebugTrace(_T("D3D_FEATURE_LEVEL_10_1")); break;
		case D3D_FEATURE_LEVEL_9_3:		DebugTrace(_T("D3D_FEATURE_LEVEL_9_3")); break;
		case D3D_FEATURE_LEVEL_9_2:		DebugTrace(_T("D3D_FEATURE_LEVEL_9_2")); break;
		case D3D_FEATURE_LEVEL_9_1:		DebugTrace(_T("D3D_FEATURE_LEVEL_9_1")); break;
		default:						DebugTrace(_T("Unknown")); break;
		}
		
		return true;
	}
开发者ID:erio-nk,项目名称:Graphics,代码行数:61,代码来源:GraphicsService.cpp


注:本文中的DevicePtr::reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。