Esempio n. 1
1
HRESULT DeviceResources::Initialize()
{
	HRESULT hr;

	D3D_FEATURE_LEVEL featureLevels[] =
	{
		D3D_FEATURE_LEVEL_11_0,
		D3D_FEATURE_LEVEL_10_1,
		D3D_FEATURE_LEVEL_10_0,
		D3D_FEATURE_LEVEL_9_3,
		D3D_FEATURE_LEVEL_9_2,
		D3D_FEATURE_LEVEL_9_1
	};

	UINT numFeatureLevels = ARRAYSIZE(featureLevels);

	UINT createDeviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;

#ifdef _DEBUG
	createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

	this->_d3dDriverType = D3D_DRIVER_TYPE_HARDWARE;

	hr = D3D11CreateDevice(nullptr, this->_d3dDriverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &this->_d3dDevice, &this->_d3dFeatureLevel, &this->_d3dDeviceContext);

	if (FAILED(hr))
	{
		this->_d3dDriverType = D3D_DRIVER_TYPE_WARP;

		hr = D3D11CreateDevice(nullptr, this->_d3dDriverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &this->_d3dDevice, &this->_d3dFeatureLevel, &this->_d3dDeviceContext);
	}

	this->CheckMultisamplingSupport();

	if (SUCCEEDED(hr))
	{
		hr = this->LoadMainResources();
	}

	if (SUCCEEDED(hr))
	{
		hr = this->LoadResources();
	}

	if (FAILED(hr))
	{
		static bool messageShown = false;

		if (!messageShown)
		{
			MessageBox(nullptr, _com_error(hr).ErrorMessage(), __FUNCTION__, MB_ICONERROR);
		}

		messageShown = true;
	}

	return hr;
}
Esempio n. 2
0
/*-------------------------------------------
	デバイスの作成
--------------------------------------------*/
HRESULT CreateDevice(void)
{
	HRESULT hr;

	// ハードウェア デバイスを試す
	hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0,
			g_pFeatureLevels, _countof(g_pFeatureLevels), D3D11_SDK_VERSION, &g_pD3DDevice,
			&g_FeatureLevelsSupported, &g_pImmediateContext);
	if (SUCCEEDED(hr)) {
		//「コンピュート シェーダ」「未処理バッファー」「構造化バッファ」のサポート調査
	    D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts;
	    g_pD3DDevice->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &hwopts, sizeof(hwopts));
	    if(hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) {
			wprintf_s(L"[D3D_DRIVER_TYPE_HARDWARE]\n");
			return hr;
		}
		SAFE_RELEASE(g_pImmediateContext);
		SAFE_RELEASE(g_pD3DDevice);
	}

	// WARPデバイスを試す
	hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, 0,
			g_pFeatureLevels, _countof(g_pFeatureLevels), D3D11_SDK_VERSION, &g_pD3DDevice,
			&g_FeatureLevelsSupported, &g_pImmediateContext);
	if (SUCCEEDED(hr)) {
		//「コンピュート シェーダ」「未処理バッファー」「構造化バッファ」のサポート調査
	    D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts;
	    g_pD3DDevice->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &hwopts, sizeof(hwopts));
	    if(hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) {
			wprintf_s(L"[D3D_DRIVER_TYPE_WARP]\n");
			return hr;
		}
		SAFE_RELEASE(g_pImmediateContext);
		SAFE_RELEASE(g_pD3DDevice);
	}

	// リファレンス デバイスを試す
	hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, 0,
			g_pFeatureLevels, _countof(g_pFeatureLevels), D3D11_SDK_VERSION, &g_pD3DDevice,
			&g_FeatureLevelsSupported, &g_pImmediateContext);
	if (SUCCEEDED(hr)) {
		//「コンピュート シェーダ」「未処理バッファー」「構造化バッファ」のサポート調査
	    D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts;
	    g_pD3DDevice->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &hwopts, sizeof(hwopts));
	    if(hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) {
			wprintf_s(L"[D3D_DRIVER_TYPE_REFERENCE]\n");
			return hr;
		}
		SAFE_RELEASE(g_pImmediateContext);
		SAFE_RELEASE(g_pD3DDevice);
	}

	// 失敗
	return DXTRACE_ERR(L"D3D11CreateDevice", hr);;
}
Esempio n. 3
0
bool Renderer::CreateDevice() {
	D3D_FEATURE_LEVEL SupportedLevel;
	if(D3D11CreateDevice(
		NULL,
		D3D_DRIVER_TYPE_HARDWARE, // we want hardware acceleration
		NULL, // pointer to software renderer. don't use that
		D3D11_CREATE_DEVICE_SINGLETHREADED,
		NULL,
		0,
		D3D11_SDK_VERSION,
		&D3DDevice,
		&SupportedLevel,
		&DeviceContext
	) != S_OK) {
		MessageBox(hwnd,"Error creating device","Error",MB_OK);
		return false;
	}
	
	// Exit if it's not supported
	if(SupportedLevel != D3D_FEATURE_LEVEL_11_0) {
		MessageBox(hwnd,"Your computer does not support DirectX 11","Error",MB_OK);
		return false;
	}
	
	return true;
}
Esempio n. 4
0
    KT_API D3D11Device::D3D11Device(
		kT::GraphicsDevice<kTD3D11DeviceTemplateListLineTypes>::ProcessingMethod processingMethod,
		bool debugFlag ):
     myDevice( 0 ),
     myProcessingMethod( processingMethod ),
     myImmediateContext( 0 )
    {
        D3D_DRIVER_TYPE driverTypes[] = {
            D3D_DRIVER_TYPE_HARDWARE,
            D3D_DRIVER_TYPE_WARP,
            D3D_DRIVER_TYPE_REFERENCE
        };

		UINT flags = debugFlag ? D3D11_CREATE_DEVICE_DEBUG : 0;
		ID3D11DeviceContext* imDev = 0;

		HRESULT hr = 0;
		for( size_t i = 0; i < 3; i++ )
		{
			D3D_FEATURE_LEVEL lvl;

			hr = D3D11CreateDevice( NULL, driverTypes[i], NULL, flags, NULL, 0, D3D11_SDK_VERSION, &myDevice, &lvl, &imDev );
			if( !FAILED(hr) )
				break;

			myFeatureLevel = lvl;
		}

        if( FAILED(hr) )
            kTLaunchException( kT::Exception, "Error while trying to create the D3D11 device" );

		myImmediateContext = new D3D11ImmediateContext( imDev );
    }
Esempio n. 5
0
	Dx11() {
		HRESULT hr;
		// D3D_FEATURE_LEVEL
		std::array<D3D_FEATURE_LEVEL, 1> FeatureLevel = {
			D3D_FEATURE_LEVEL_11_0
		};

#if defined(DEBUG) || defined(_DEBUG)
		UINT createDeviceFlag = D3D11_CREATE_DEVICE_DEBUG;
#else
		UINT createDeviceFlag = 0;
#endif
		D3D_FEATURE_LEVEL selected;

		hr = D3D11CreateDevice(
			nullptr,                  // 使用するアダプターを設定。NULLの場合はデフォルトのアダプター。
			D3D_DRIVER_TYPE_HARDWARE,    // D3D_DRIVER_TYPEのいずれか。ドライバーの種類。pAdapterが NULL 以外の場合は、D3D_DRIVER_TYPE_UNKNOWNを指定する。
			NULL,                       // ソフトウェアラスタライザを実装するDLLへのハンドル。D3D_DRIVER_TYPE を D3D_DRIVER_TYPE_SOFTWARE に設定している場合は NULL にできない。
			createDeviceFlag,           // D3D11_CREATE_DEVICE_FLAGの組み合わせ。デバイスを作成時に使用されるパラメータ。
			FeatureLevel.data(),               // D3D_FEATURE_LEVELのポインタ
			FeatureLevel.size(),                 // D3D_FEATURE_LEVEL配列の要素数
			D3D11_SDK_VERSION,          // DirectX SDKのバージョン。この値は固定。
			&d3d11device,               // 初期化されたデバイス
			&selected,              // 採用されたフィーチャーレベル
			&d3d11deviceContext         // 初期化されたデバイスコンテキスト
		);
		if (FAILED(hr)) {
			printf("failed to initialize dx11");
		}
	}
BOOL CALLBACK create_device(PINIT_ONCE ignored, void *ignored2,
    void **ignored3) {
  debug_log("creating device");
  HRESULT hr;
  hr = CreateDXGIFactory1(__uuidof(IDXGIFactory2), (void **)&dxgi_factory);
  assert(hr == S_OK);
  hr = dxgi_factory->EnumAdapters1(0, &dxgi_adapter);
  assert(hr == S_OK);
  hr = dxgi_adapter->EnumOutputs(0, &dxgi_output);
  assert(hr == S_OK);
  hr = dxgi_output->QueryInterface(__uuidof(IDXGIOutput1),
      (void **)&dxgi_output1);
  assert(hr == S_OK);
  const D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_0 };
  D3D_FEATURE_LEVEL out_level;
  UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifndef NDEBUG
  flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
  hr = D3D11CreateDevice(dxgi_adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, flags,
      levels, 1, D3D11_SDK_VERSION, &device, &out_level, &context);
  assert(hr == S_OK);
  hr = dxgi_output1->DuplicateOutput(device, &dxgi_output_duplication);
  assert(hr == S_OK);
  InitializeCriticalSection(&directx_critical_section);
  return TRUE;
}
bool InitializeD3D11()
{
    D3D_FEATURE_LEVEL feature_levels[] = {
        D3D_FEATURE_LEVEL_11_1,
        D3D_FEATURE_LEVEL_11_0,
    };
    D3D_FEATURE_LEVEL valid_feature_level;

    IDXGIAdapter *adapter = nullptr;
    ID3D11Device *dev = nullptr;
    ID3D11DeviceContext *ctx = nullptr;
    HRESULT hr = D3D11CreateDevice(
        adapter,
        D3D_DRIVER_TYPE_HARDWARE,
        nullptr,
        0,
        feature_levels,
        _countof(feature_levels),
        D3D11_SDK_VERSION,
        &dev,
        &valid_feature_level,
        &ctx);

    if (dev) {
        fcGfxInitializeD3D11(dev);
        return true;
    }
    else {
        return false;
    }
}
Esempio n. 8
0
    void initializeDevice()
    {
        if (!mInitialized)
        {
#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
            mD3d11Module = LoadLibrary(TEXT("d3d11.dll"));
            ASSERT(mD3d11Module);

            PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice");
            ASSERT(D3D11CreateDevice != NULL);
#endif // !ANGLE_ENABLE_WINDOWS_STORE

            ID3D11Device* device = NULL;
            ID3D11DeviceContext* context = NULL;

            HRESULT hr = E_FAIL;

            // Create a D3D_DRIVER_TYPE_NULL device, which is much cheaper than other types of device.
            hr =  D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &device, NULL, &context);
            ASSERT(SUCCEEDED(hr));

            hr = context->QueryInterface(__uuidof(mUserDefinedAnnotation), reinterpret_cast<void**>(&mUserDefinedAnnotation));
            ASSERT(SUCCEEDED(hr) && mUserDefinedAnnotation != NULL);

            SafeRelease(device);
            SafeRelease(context);

            mInitialized = true;
        }
    }
static HRESULT find_output()
{
	CComPtr<IDXGIFactory1> pFactory;
	HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void **)(&pFactory));
	for (UINT i = 0; ; i++) {
		CComPtr<IDXGIAdapter1> pAdapter;
		if (S_OK != (hr = pFactory->EnumAdapters1(i, &pAdapter))) {
			break;
		}

		aslog::info(L"Found adapter %d", i);

		for (UINT j = 0; ; j++) {
			CComPtr<IDXGIOutput> pOutput;
			if (S_OK != (hr = pAdapter->EnumOutputs(j, &pOutput))) {
				break;
			}

			aslog::info(L"Found output %d-%d", i, j);
			DXGI_OUTPUT_DESC desc;
			pOutput->GetDesc(&desc);
			aslog::info(L"Output %d-%d name: %s", i, j, desc.DeviceName);
			aslog::info(L"Output %d-%d attached to desktop: %s", i, j, desc.AttachedToDesktop ? L"true" : L"false");

			g_pAdapter = pAdapter;
			g_pOutput = pOutput;
			hr = D3D11CreateDevice(pAdapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, &g_pDevice, NULL, &g_pContext);
			return hr;
		}
	}
	return hr;
}
Esempio n. 10
0
File: d3d11.c Progetto: xcution/wine
static ID3D11Device *create_device(D3D_FEATURE_LEVEL feature_level)
{
    ID3D11Device *device;

    if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION,
            &device, NULL, NULL)))
        return device;
    if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_WARP, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION,
            &device, NULL, NULL)))
        return device;
    if (SUCCEEDED(D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, 0, &feature_level, 1, D3D11_SDK_VERSION,
            &device, NULL, NULL)))
        return device;

    return NULL;
}
Esempio n. 11
0
static info_t get_info(int adapter_index, IDXGIAdapter* adapter)
{
	struct ctx_t
	{
		DXGI_ADAPTER_DESC adapter_desc;
		info_t adapter_info;
	};

	ctx_t ctx;
	adapter->GetDesc(&ctx.adapter_desc);
	
	// There's a new adapter called teh Basic Render Driver that is not a video driver, so 
	// it won't show up with enumerate_video_drivers, so handle it explicitly here.
	if (ctx.adapter_desc.VendorId == 0x1414 && ctx.adapter_desc.DeviceId == 0x8c) // Microsoft Basic Render Driver
	{
		ctx.adapter_info.description = "Microsoft Basic Render Driver";
		ctx.adapter_info.plugnplay_id = "Microsoft Basic Render Driver";
		ctx.adapter_info.version = version_t(1,0);
		ctx.adapter_info.vendor = vendor::microsoft;
		ctx.adapter_info.feature_level = version_t(11,1);
	}

	else
	{
		detail::enumerate_video_drivers([](const info_t& info, void* user)->bool
		{
			auto& ctx = *(ctx_t*)user;

			char vendor[128];
			char device[128];
			snprintf(vendor, "VEN_%X", ctx.adapter_desc.VendorId);
			snprintf(device, "DEV_%04X", ctx.adapter_desc.DeviceId);
			if (strstr(info.plugnplay_id, vendor) && strstr(info.plugnplay_id, device))
			{
				ctx.adapter_info = info;
				return false;
			}
			return true;
		}, &ctx);
	}

	*(int*)&ctx.adapter_info.id = adapter_index;

	D3D_FEATURE_LEVEL FeatureLevel;
	// Note that the out-device is null, thus this isn't that expensive a call
	if (SUCCEEDED(D3D11CreateDevice(
		adapter
		, D3D_DRIVER_TYPE_UNKNOWN
		, nullptr
		, 0 // D3D11_CREATE_DEVICE_DEBUG // squelches a _com_error warning
		, nullptr
		, 0
		, D3D11_SDK_VERSION
		, nullptr
		, &FeatureLevel
		, nullptr)))
		ctx.adapter_info.feature_level = version_t((FeatureLevel>>12) & 0xff, (FeatureLevel>>8) & 0xf);

	return ctx.adapter_info;
}
Esempio n. 12
0
void DesktopDuplication::init()
{
	IDXGIFactory1* dxgiFactory = nullptr;
	CHECKED(hr, CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&dxgiFactory)));

	IDXGIAdapter1* dxgiAdapter = nullptr;
	CHECKED(hr, dxgiFactory->EnumAdapters1(adapter, &dxgiAdapter));
	dxgiFactory->Release();

	CHECKED(hr, D3D11CreateDevice(dxgiAdapter,
		D3D_DRIVER_TYPE_UNKNOWN,
		NULL,
		NULL,
		NULL,
		NULL,
		D3D11_SDK_VERSION,
		&d3dDevice,
		NULL,
		&d3dContext));

	IDXGIOutput* dxgiOutput = nullptr;
	CHECKED(hr, dxgiAdapter->EnumOutputs(output, &dxgiOutput));
	dxgiAdapter->Release();

	IDXGIOutput1* dxgiOutput1 = nullptr;
	CHECKED(hr, dxgiOutput->QueryInterface(__uuidof(dxgiOutput1), reinterpret_cast<void**>(&dxgiOutput1)));
	dxgiOutput->Release();

	IDXGIDevice* dxgiDevice = nullptr;
	CHECKED(hr, d3dDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice)));

	CHECKED(hr, dxgiOutput1->DuplicateOutput(dxgiDevice, &outputDuplication));
	dxgiOutput1->Release();
	dxgiDevice->Release();
}
Esempio n. 13
0
    HRESULT DisplayerImpl::CreateD3D11Device(IDXGIAdapter* adapter, D3D_DRIVER_TYPE driverType, UINT flags,
                                             ID3D11Device** ppDevice, ID3D11DeviceContext** ppDevCtx, D3D_FEATURE_LEVEL* resultLevel) {
        HRESULT hr = S_OK;

        static const D3D_FEATURE_LEVEL featureLevels[] = {
            D3D_FEATURE_LEVEL_11_1,
            D3D_FEATURE_LEVEL_11_0,
            D3D_FEATURE_LEVEL_10_1,
            D3D_FEATURE_LEVEL_10_0,
            D3D_FEATURE_LEVEL_9_3,
            D3D_FEATURE_LEVEL_9_2,
            D3D_FEATURE_LEVEL_9_1
        };

        uint32_t arraySize = sizeof(featureLevels) / sizeof(featureLevels[0]);

        D3D_FEATURE_LEVEL result;
        ID3D11Device* device = nullptr;
        ID3D11DeviceContext* devctx = nullptr;

        hr = D3D11CreateDevice(adapter, driverType, 0, flags, featureLevels, arraySize, D3D11_SDK_VERSION, &device, &result, &devctx);
        if (FAILED(hr))
            return hr;

        if (resultLevel) {
            *resultLevel = result;
        }
        *ppDevice = device;
        *ppDevCtx = devctx;

        return hr;
    }
Esempio n. 14
0
void DebugAnnotator11::initializeDevice()
{
    if (!mInitialized)
    {
#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
        mD3d11Module = LoadLibrary(TEXT("d3d11.dll"));
        ASSERT(mD3d11Module);

        PFN_D3D11_CREATE_DEVICE D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(mD3d11Module, "D3D11CreateDevice");
        ASSERT(D3D11CreateDevice != nullptr);
#endif // !ANGLE_ENABLE_WINDOWS_STORE

        ID3D11Device *device = nullptr;
        ID3D11DeviceContext *context = nullptr;

        HRESULT hr = E_FAIL;

        // Create a D3D_DRIVER_TYPE_NULL device, which is much cheaper than other types of device.
        hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, nullptr, 0, nullptr, 0, D3D11_SDK_VERSION, &device, nullptr, &context);
        ASSERT(SUCCEEDED(hr));
        if (SUCCEEDED(hr))
        {
            mUserDefinedAnnotation = d3d11::DynamicCastComObject<ID3DUserDefinedAnnotation>(context);
            ASSERT(mUserDefinedAnnotation != nullptr);
            mInitialized = true;
        }

        SafeRelease(device);
        SafeRelease(context);
    }
}
Esempio n. 15
0
int ContextD3D11::CreateDeviceResources() {
  UINT creationFlags = D3D11_CREATE_DEVICE_SINGLETHREADED;//D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef _DEBUG
  creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

  D3D_DRIVER_TYPE driverTypes[] =
  {
      D3D_DRIVER_TYPE_HARDWARE,
      D3D_DRIVER_TYPE_WARP,
      D3D_DRIVER_TYPE_REFERENCE,
  };
  UINT numDriverTypes = ARRAYSIZE( driverTypes );

  D3D_FEATURE_LEVEL featureLevels[] =
  {
    D3D_FEATURE_LEVEL_12_1,
    D3D_FEATURE_LEVEL_12_0,
    D3D_FEATURE_LEVEL_11_1,
    D3D_FEATURE_LEVEL_11_0,
    D3D_FEATURE_LEVEL_10_1,
    D3D_FEATURE_LEVEL_10_0,
  };
  UINT numFeatureLevels = ARRAYSIZE( featureLevels );
  D3D_FEATURE_LEVEL feature_level;
  ID3D11Device* device;
  ID3D11DeviceContext* devicecontext;

  auto hr = D3D11CreateDevice(adaptor_, D3D_DRIVER_TYPE_UNKNOWN, nullptr,	creationFlags, featureLevels, ARRAYSIZE(featureLevels),	D3D11_SDK_VERSION, &device, &feature_level, &devicecontext);
  if (FAILED(hr)) {
    OutputDebugString("ContextD3D11::CreateDeviceResources : D3D11CreateDevice Failed");
    return hr;
  }
  device_ = (ID3D11Device1*)device;
  device_context_ = (ID3D11DeviceContext1*)devicecontext;

  SafeRelease(&default_blend_state);
  D3D11_BLEND_DESC BlendStateDescription;
  ZeroMemory(&BlendStateDescription,sizeof(BlendStateDescription));
  BlendStateDescription.RenderTarget[0].BlendEnable           = true;
  BlendStateDescription.RenderTarget[0].SrcBlend              = D3D11_BLEND_SRC_ALPHA;        //D3D11_BLEND_SRC_COLOR;
  BlendStateDescription.RenderTarget[0].DestBlend             = D3D11_BLEND_INV_SRC_ALPHA;//D3D11_BLEND_DEST_COLOR;
  BlendStateDescription.RenderTarget[0].SrcBlendAlpha         = D3D11_BLEND_SRC_ALPHA;//D3D11_BLEND_SRC_ALPHA;
  BlendStateDescription.RenderTarget[0].DestBlendAlpha        = D3D11_BLEND_ZERO;//D3D11_BLEND_DEST_ALPHA;
  BlendStateDescription.RenderTarget[0].BlendOp               = D3D11_BLEND_OP_ADD;
  BlendStateDescription.RenderTarget[0].BlendOpAlpha          = D3D11_BLEND_OP_ADD;
  BlendStateDescription.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
    
  device_->CreateBlendState(&BlendStateDescription,&default_blend_state);
  float blendFactor[] = {1,1, 1, 1};
  UINT sampleMask   = 0xffffffff;
  device_context_->OMSetBlendState(default_blend_state,blendFactor,sampleMask);


  

  return S_OK;
}
Esempio n. 16
0
File: d3d11.c Progetto: xcution/wine
static void test_create_device(void)
{
    D3D_FEATURE_LEVEL feature_level, supported_feature_level;
    ID3D11DeviceContext *immediate_context = NULL;
    ID3D11Device *device;
    ULONG refcount;
    HRESULT hr;

    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, &device,
            NULL, NULL);
    if (FAILED(hr))
    {
        skip("Failed to create HAL device, skipping tests.\n");
        return;
    }

    supported_feature_level = ID3D11Device_GetFeatureLevel(device);
    ID3D11Device_Release(device);

    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);
    ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);

    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL,
            &feature_level, NULL);
    ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);
    ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n",
            feature_level, supported_feature_level);

    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, 0, D3D11_SDK_VERSION, NULL, NULL,
            &immediate_context);
    ok(SUCCEEDED(hr), "D3D11CreateDevice failed %#x.\n", hr);

    todo_wine ok(!!immediate_context, "Immediate context is NULL.\n");
    if (!immediate_context) return;

    refcount = get_refcount((IUnknown *)immediate_context);
    ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);

    ID3D11DeviceContext_GetDevice(immediate_context, &device);
    refcount = ID3D11Device_Release(device);
    ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);

    refcount = ID3D11DeviceContext_Release(immediate_context);
    ok(!refcount, "ID3D11DeviceContext has %u references left.\n", refcount);
}
Esempio n. 17
0
QtTestGui::QtTestGui(QWidget *parent)
	: QMainWindow(parent), trayIcon(this), stopD3d(false){
	ui.setupUi(this);

	this->trayIcon.setToolTip("Click me!");

	Qt::WindowFlags flags = this->windowFlags();
	this->setWindowFlags(flags | Qt::WindowStaysOnTopHint);
	this->setAttribute(Qt::WidgetAttribute::WA_PaintOnScreen);

	connect(&this->trayIcon, &QSystemTrayIcon::activated, this, &QtTestGui::TrayActivated);


	HRESULT hr = S_OK;
	D3D_FEATURE_LEVEL levels[] = {
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_1,
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_11_0,
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_10_1,
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_10_0,
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_9_3,
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_9_2,
		D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_9_1
	};

	Microsoft::WRL::ComPtr<ID3D11Device> d3dDevTmp;
	Microsoft::WRL::ComPtr<ID3D11DeviceContext> d3dCtxTmp;

	uint32_t dxDevFlags = D3D11_CREATE_DEVICE_FLAG::D3D11_CREATE_DEVICE_BGRA_SUPPORT;

#ifdef _DEBUG
	dxDevFlags |= D3D11_CREATE_DEVICE_FLAG::D3D11_CREATE_DEVICE_DEBUG;
#endif

	std::lock_guard<std::mutex> lk(this->d3dMtx);

	hr = D3D11CreateDevice(
		nullptr,
		D3D_DRIVER_TYPE::D3D_DRIVER_TYPE_HARDWARE,
		nullptr, dxDevFlags,
		levels, sizeof(levels) / sizeof(levels[0]),
		D3D11_SDK_VERSION,
		d3dDevTmp.GetAddressOf(), &this->d3dLevel, d3dCtxTmp.GetAddressOf());

	hr = d3dDevTmp.As(&this->d3dDev);
	hr = d3dCtxTmp.As(&this->d3dCtx);

	this->TestTextureTypes();
	this->CreateGeometry();
	this->CreateShaders();
	this->CreateSampler();

	this->UpdateProjection();

	this->d3dThread = std::thread([=](){
		this->RenderD3d();
	});
}
Esempio n. 18
0
	void D3DContext::InitD3D(HWND hWnd)
	{
		m_MSAAEnabled = true;

		HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, m_DebugLayerEnabled ? D3D11_CREATE_DEVICE_DEBUG : D3D11_CREATE_DEVICE_SINGLETHREADED, NULL, NULL, D3D11_SDK_VERSION, &dev, &m_D3DFeatureLevel, &devcon);
		dev->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &m_MSAAQuality);
		// assert(m_MSAAQuality > 0);

		DXGI_SWAP_CHAIN_DESC scd;
		ZeroMemory(&scd, sizeof(DXGI_SWAP_CHAIN_DESC));

		scd.BufferDesc.Width = m_Properties.width;
		scd.BufferDesc.Height = m_Properties.height;
		scd.BufferDesc.RefreshRate.Numerator = 60;
		scd.BufferDesc.RefreshRate.Denominator = 1;
		scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;

		scd.SampleDesc.Count = m_MSAAEnabled ? 4 : 1;
		scd.SampleDesc.Quality = m_MSAAEnabled ? (m_MSAAQuality - 1) : 0;

		scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
		scd.BufferCount = 3;
		scd.OutputWindow = hWnd;
		scd.Windowed = !m_Properties.fullscreen;
		scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
		scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

		IDXGIDevice* dxgiDevice = 0;
		IDXGIAdapter* dxgiAdapter = 0;
		IDXGIFactory* dxgiFactory = 0;

		dev->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
		dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter);
		dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory);
		dxgiFactory->CreateSwapChain(dev, &scd, &swapchain);

		dxgiFactory->Release();
		dxgiAdapter->Release();
		dxgiDevice->Release();

		if (m_DebugLayerEnabled)
		{
			dev->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_DebugLayer));
			m_DebugLayer->ReportLiveDeviceObjects(D3D11_RLDO_SUMMARY);

			ID3D11InfoQueue* infoQueue;
			dev->QueryInterface(__uuidof(ID3D11InfoQueue), reinterpret_cast<void**>(&infoQueue));
			D3D11_MESSAGE_ID hide[] = { D3D11_MESSAGE_ID_DEVICE_DRAW_SAMPLER_NOT_SET };
			D3D11_INFO_QUEUE_FILTER filter;
			memset(&filter, 0, sizeof(filter));
			filter.DenyList.NumIDs = 1;
			filter.DenyList.pIDList = hide;
			infoQueue->AddStorageFilterEntries(&filter);
		}

		Resize();
	}
Esempio n. 19
0
// Create DX11 device
ID3D11Device* spoutDirectX::CreateDX11device()
{
	ID3D11Device* pd3dDevice = NULL;
	HRESULT hr = S_OK;
	UINT createDeviceFlags = 0;

	// GL/DX interop Spec
	// ID3D11Device can only be used on WDDM operating systems : Must be multithreaded
	// D3D11_CREATE_DEVICE_FLAG createDeviceFlags
	// malcolm - derivative reported possible NVIDIA memory leak bug unless D3D11_CREATE_DEVICE_SINGLETHREADED is set
	// but the spec requires multithreaded
	D3D_DRIVER_TYPE driverTypes[] =	{
		D3D_DRIVER_TYPE_HARDWARE,
		D3D_DRIVER_TYPE_WARP,
		D3D_DRIVER_TYPE_REFERENCE,
	};

	UINT numDriverTypes = ARRAYSIZE( driverTypes );

	D3D_FEATURE_LEVEL featureLevels[] =	{
		D3D_FEATURE_LEVEL_11_0,
		D3D_FEATURE_LEVEL_10_1,
		D3D_FEATURE_LEVEL_10_0,
	};

	UINT numFeatureLevels = ARRAYSIZE( featureLevels );

	for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) {
		g_driverType = driverTypes[driverTypeIndex];

		// Createdevice only method, not the full swap chain
		hr = D3D11CreateDevice(	NULL,
								g_driverType,
								NULL,
								createDeviceFlags,
								featureLevels,
								numFeatureLevels,
								D3D11_SDK_VERSION, 
								&pd3dDevice,
								&g_featureLevel,
								&g_pImmediateContext);
		
		// Break as soon as something passes
		if(SUCCEEDED(hr))
			break;

	}
	
	// Quit if nothing worked
	if( FAILED(hr))
		return NULL;

	// All OK
	return pd3dDevice;

} // end CreateDX11device
Esempio n. 20
0
	// Constructor. Creates a Direct3D device.
	D3D() : _Device(NULL), _ImmediateContext(NULL)
	{
		IDXGIFactory* factory;
		if (FAILED(CreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory))) return;
		
		HRESULT hr = S_OK;

		UINT createDeviceFlags = 0;
#ifdef _DEBUG
		createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

		D3D_DRIVER_TYPE driverTypes[] =
		{
			D3D_DRIVER_TYPE_UNKNOWN,
		};
		UINT numDriverTypes = sizeof(driverTypes) / sizeof(driverTypes[0]);

		D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0 };
		unsigned int numFeatureLevels = 1;
		D3D_FEATURE_LEVEL usedFeatureLevel = D3D_FEATURE_LEVEL_11_0;

		// iterate the display adapters and look for a DirectX 11 capable device.
		for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
		{
			D3D_DRIVER_TYPE driverType = driverTypes[driverTypeIndex];

			IDXGIAdapter* adapter;
			for (UINT i = 0;
				factory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND;
				++i)
			{
				DXGI_ADAPTER_DESC desc;
				adapter->GetDesc(&desc);

				std::wstring adapterDesc(desc.Description);
				hr = D3D11CreateDevice(adapter, driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, &_Device, &usedFeatureLevel, &_ImmediateContext);
				if (SUCCEEDED(hr))
				{
					wprintf(L"D3D is using: %s\n", adapterDesc.c_str());
					break;
				}
			}

			if (!_Device) {
				printf("Couldn't create DirectX device.\nMaybe DirectX 11 is not supported on your machine?\n");
				exit(-1);
			}

			if (adapter) adapter->Release();

			if (SUCCEEDED(hr))
				break;
		}
		factory->Release();
	}
Esempio n. 21
0
void testCache(IDXGIAdapter* adapter)
{
	ID3D11Device* device = 0;
	ID3D11DeviceContext* context = 0;
	D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, 0, 0, 0, 0, D3D11_SDK_VERSION, &device, 0, &context);

	setupShaders(device, context);

	inspectCache([&](const unsigned int* indices, size_t index_count) { return queryVSInvocations(device, context, indices, index_count); });
}
Esempio n. 22
0
void Window::Initialize()
{
	D3D_FEATURE_LEVEL level;

	HRESULT hr = D3D11CreateDevice(0, D3D_DRIVER_TYPE_HARDWARE, 0, 0, 0, 0, D3D11_SDK_VERSION, &_d3dDevice, &level, &_d3dDeviceContext);

	Resize();

	InitializeVertexBuffer();
	InitializeShaders();
}
Esempio n. 23
0
inline ComPtr<ID3D11Device> CreateD3D11Device()
{
	// NOTE: This is mandatory in order to allow direct3d to work with direct2d
	UINT flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef DEBUG
	flags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
	ComPtr<ID3D11Device> d3dDevice;
	// We don't need to direct3d device context for direct2d since we will be using the direct2d device context
	HR(D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, flags, nullptr, 0, D3D11_SDK_VERSION, d3dDevice.GetAddressOf(), nullptr, nullptr));
	return d3dDevice;
}
Esempio n. 24
0
IUnknown* DX11Engine::createNativeDevice() const {
    ID3D11Device* pDeivce = nullptr;
    unsigned int flag = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#ifdef _DEBUG
    flag |= D3D11_CREATE_DEVICE_DEBUG;
#endif
    D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_0 };
    D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr,
                      flag, levels, _countof(levels), D3D11_SDK_VERSION, &pDeivce, nullptr, nullptr);
        
    return pDeivce;
}
Esempio n. 25
0
HRESULT GraphicsDevice::Initialize(const ComPtr<IDXGIFactory2>& factory, const ComPtr<IDXGIAdapter>& adapter, bool createDebug)
{
    Factory = factory;
    Adapter = adapter;

    uint32_t flags = 0;
    if (createDebug)
    {
        flags |= D3D11_CREATE_DEVICE_DEBUG;
    }

    D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;

    HRESULT hr = D3D11CreateDevice(Adapter.Get(), Adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE,
        nullptr, flags, &featureLevel, 1, D3D11_SDK_VERSION, &Device, nullptr, &Context);
    CHECKHR(hr);

    // create common states
    D3D11_SAMPLER_DESC sd{};
    sd.AddressU = sd.AddressV = sd.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    sd.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    sd.MaxLOD = D3D11_FLOAT32_MAX;
    hr = Device->CreateSamplerState(&sd, &LinearWrapSampler);
    CHECKHR(hr);

    sd.AddressU = sd.AddressV = sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
    sd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
    hr = Device->CreateSamplerState(&sd, &PointClampSampler);
    CHECKHR(hr);

    sd.AddressU = sd.AddressV = sd.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    sd.Filter = D3D11_FILTER_ANISOTROPIC;
    sd.MaxAnisotropy = 8;
    hr = Device->CreateSamplerState(&sd, &AnisoWrapSampler);
    CHECKHR(hr);

    D3D11_DEPTH_STENCIL_DESC dsd{};
    dsd.DepthEnable = TRUE;
    dsd.DepthFunc = D3D11_COMPARISON_LESS;
    dsd.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
    hr = Device->CreateDepthStencilState(&dsd, &DepthWriteState);
    CHECKHR(hr);

    dsd.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
    dsd.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
    hr = Device->CreateDepthStencilState(&dsd, &DepthReadState);
    CHECKHR(hr);

    return hr;
}
Esempio n. 26
0
void RenderDevice::init()
{
	ComResult hr;

	hr = D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_DEBUG,
		nullptr, 0, D3D11_SDK_VERSION, &this->pDevice3, nullptr, &this->pDeviceContext3);
	hr = this->pDevice3.As(&this->pxDevice);

	hr = D2D1CreateDevice(this->pxDevice.Get(), D2D1::CreationProperties(
		D2D1_THREADING_MODE_MULTI_THREADED, D2D1_DEBUG_LEVEL_ERROR, D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS),
		&this->pDevice2);

	hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), &this->pdwFactory);
	hr = this->pdwFactory->GetSystemFontCollection(&this->pSystemFontCollection);
}
BOOL TRenderDevice::CreateRenderDevice(){
	HRESULT  hr;
	RenderSize = new TD3DRenderSize();
	
	if(RenderWindow!=0){
		RenderWindow->CreateNativeWindow();
		SetWindowLong(RenderWindow->GetHWnd(), GWL_USERDATA, (LONG)this);
		RenderWindow->SetWindowSize(RenderSize->GetRenderWidth(),RenderSize->GetRenderHeight());
	}
	
#if defined(DEBUG) || defined(_DEBUG)
	m_CreateFlags|=D3D10_CREATE_DEVICE_DEBUG;
#endif
	D3D_FEATURE_LEVEL pFeatureLevels[] = {
				D3D_FEATURE_LEVEL_11_0,
				D3D_FEATURE_LEVEL_10_1,
				D3D_FEATURE_LEVEL_10_0,
				D3D_FEATURE_LEVEL_9_3,
				D3D_FEATURE_LEVEL_9_2,
				D3D_FEATURE_LEVEL_9_1,
			};
	
	hr = D3D11CreateDevice(0,D3D_DRIVER_TYPE_HARDWARE,0,m_CreateFlags,
						pFeatureLevels,
						6,
						D3D11_SDK_VERSION,
						&Device,
						&m_OutFeatureLevel,
						&DeviceContext);
	if(FAILED(hr)){
		MessageBox(0,L"创建设备失败",0,0);
		return S_FALSE;
	}
	if(m_OutFeatureLevel!=D3D_FEATURE_LEVEL_11_0){
		MessageBox(0,L"m_OutFeatureLevel!=D3D_FEATURE_LEVEL_11_0",0,0);
	}
	
	Device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 4, &MsaaQuality);
	assert(MsaaQuality>0);
	
	CreateSwapChain();
	
	RenderTarget = new TRenderTarget(this);
	ViewPort = new TViewPort(this);
	ViewPort->ApplyViewPort();
	
	return S_OK;
}
Esempio n. 28
0
    bool SystemCheck::CheckVRAMSize()
    {
        HRESULT hr;
        D3D_FEATURE_LEVEL FeatureLevel;

        CComPtr<IDXGIFactory1> DXGIFactory;

        hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&DXGIFactory);
        if(SUCCEEDED(hr))
        {
            CComPtr<IDXGIAdapter1> Adapter;

            hr = DXGIFactory->EnumAdapters1(0, &Adapter);
            if(SUCCEEDED(hr))
            {
                CComPtr<ID3D11Device> Device;
                CComPtr<ID3D11DeviceContext> DeviceContext;

                hr = D3D11CreateDevice(Adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
                    D3D11_CREATE_DEVICE_BGRA_SUPPORT, nullptr, 0, D3D11_SDK_VERSION,
                    &Device, &FeatureLevel, &DeviceContext);

                if(SUCCEEDED(hr))
                {
                    DXGI_ADAPTER_DESC adapterDesc;
                    Adapter->GetDesc(&adapterDesc);

                    std::wstring Description = adapterDesc.Description;
                    INT64 VideoRam = adapterDesc.DedicatedVideoMemory;
                    INT64 SystemRam = adapterDesc.DedicatedSystemMemory;
                    INT64 SharedRam = adapterDesc.SharedSystemMemory;

                    std::wcout << "***************** GRAPHICS ADAPTER DETAILS ***********************" << endl;;
                    std::wcout << "Adapter Description: " << Description << endl;
                    std::wcout << "Dedicated Video RAM: " << VideoRam << endl;
                    std::wcout << "Dedicated System RAM: " << SystemRam << endl;
                    std::wcout << "Shared System RAM: " << SharedRam << endl;
                    std::wcout << "PCI ID: " << Description << endl;
                    std::wcout << "Feature Level: " << FeatureLevel << endl;
                }
            }
        }    

        return true;
    }
Esempio n. 29
0
void Direct3D11::create_device()
{
	D3D_FEATURE_LEVEL feature_levels[] = {
		D3D_FEATURE_LEVEL_11_0,
		D3D_FEATURE_LEVEL_10_1,
		D3D_FEATURE_LEVEL_10_0
	};

	D3D_FEATURE_LEVEL feature_level = feature_levels[ 0 ];

#ifdef _DEBUG
    UINT d3d11_create_device_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_DEBUG;
#else
    UINT d3d11_create_device_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#endif

	DIRECT_X_FAIL_CHECK( D3D11CreateDevice( dxgi_adapter_.get(), D3D_DRIVER_TYPE_UNKNOWN, 0, d3d11_create_device_flags, feature_levels, ARRAYSIZE( feature_levels ), D3D11_SDK_VERSION, & device_, & feature_level, & immediate_context_ ) );
}
Esempio n. 30
0
Graphics::Graphics()
{
	comptr<IDXGIDevice> dxgi_device;
	comptr<ID3D11Device> d3d_device;

	HRESULT hr = D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT,
		nullptr, 0, D3D11_SDK_VERSION, d3d_device.GetAddressOf(), nullptr, nullptr );
	assert( SUCCEEDED( hr ) );

	hr = d3d_device.As( &dxgi_device );
	assert( SUCCEEDED( hr ) );

	hr = D2D1CreateDevice( dxgi_device.Get(), D2D1_CREATION_PROPERTIES{}, device.GetAddressOf() );
	assert( SUCCEEDED( hr ) );

	hr = device->CreateDeviceContext( D2D1_DEVICE_CONTEXT_OPTIONS{}, context.GetAddressOf() );
	assert( SUCCEEDED( hr ) );
}