From 0ec6a91477bdfd7070451f6ca273adb5a94b9d72 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 14 Jun 2010 22:38:47 +0000 Subject: [PATCH] Fail initializing if the D3D11 runtime is installed but no at least D3D 10.0 capable video card is used. Remove some superfluous checks in the shader caches. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5702 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_VideoDX11/Src/D3DBase.cpp | 14 +++++++-- .../Plugin_VideoDX11/Src/PixelShaderCache.cpp | 30 ++++++------------- .../Src/VertexShaderCache.cpp | 30 ++++++------------- 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp index 543ce23743..e3a6ffaca0 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp @@ -38,6 +38,13 @@ D3D_FEATURE_LEVEL featlevel; D3DTexture2D* backbuf = NULL; HWND hWnd; +#define NUM_SUPPORTED_FEATURE_LEVELS 3 +const D3D_FEATURE_LEVEL supported_feature_levels[NUM_SUPPORTED_FEATURE_LEVELS] = { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0 +}; + unsigned int xres, yres; bool bFrameInProgress = false; @@ -327,10 +334,13 @@ HRESULT Create(HWND wnd) #else D3D11_CREATE_DEVICE_FLAG device_flags = D3D11_CREATE_DEVICE_SINGLETHREADED; #endif - hr = D3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, device_flags, NULL, 0, D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device, &featlevel, &context); + hr = D3D11CreateDeviceAndSwapChain(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, device_flags, + supported_feature_levels, NUM_SUPPORTED_FEATURE_LEVELS, + D3D11_SDK_VERSION, &swap_chain_desc, &swapchain, &device, + &featlevel, &context); if (FAILED(hr) || !device || !context || !swapchain) { - MessageBox(wnd, _T("Failed to initialize Direct3D."), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR); + MessageBox(wnd, _T("Failed to initialize Direct3D.\nMake sure your video card supports at least D3D 10.0"), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR); SAFE_RELEASE(device); SAFE_RELEASE(context); SAFE_RELEASE(swapchain); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp index 0b5c9adc83..60d1813105 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp @@ -128,35 +128,23 @@ unsigned int ps_constant_offset_table[] = { }; void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if(D3D::gfxstate->psconstants[ps_constant_offset_table[const_number] ] != f1 - || D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+1] != f2 - || D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+2] != f3 - || D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+3] != f4) - { - D3D::gfxstate->psconstants[ps_constant_offset_table[const_number] ] = f1; - D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+1] = f2; - D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+2] = f3; - D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+3] = f4; - D3D::gfxstate->pscbufchanged = true; - } + D3D::gfxstate->psconstants[ps_constant_offset_table[const_number] ] = f1; + D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+1] = f2; + D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+2] = f3; + D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+3] = f4; + D3D::gfxstate->pscbufchanged = true; } void SetPSConstant4fv(unsigned int const_number, const float* f) { - if(memcmp(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4)) - { - memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4); - D3D::gfxstate->pscbufchanged = true; - } + memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4); + D3D::gfxstate->pscbufchanged = true; } void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float* f) { - if(memcmp(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count)) - { - memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count); - D3D::gfxstate->pscbufchanged = true; - } + memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count); + D3D::gfxstate->pscbufchanged = true; } // this class will load the precompiled shaders into our cache diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp index 9de7bb6939..96ed2ecd1d 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp @@ -51,26 +51,17 @@ ID3D11InputLayout* VertexShaderCache::GetClearInputLayout() { return ClearLayout unsigned int vs_constant_offset_table[238]; void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { - if(D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] != f1 - || D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+1] != f2 - || D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+2] != f3 - || D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+3] != f4) - { - D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] = f1; - D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+1] = f2; - D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+2] = f3; - D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+3] = f4; - D3D::gfxstate->vscbufchanged = true; - } + D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] = f1; + D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+1] = f2; + D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+2] = f3; + D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+3] = f4; + D3D::gfxstate->vscbufchanged = true; } void SetVSConstant4fv(unsigned int const_number, const float* f) { - if(memcmp(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4)) - { - memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4); - D3D::gfxstate->vscbufchanged = true; - } + memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4); + D3D::gfxstate->vscbufchanged = true; } void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float* f) @@ -85,11 +76,8 @@ void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float* f) { - if(memcmp(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count)) - { - memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count); - D3D::gfxstate->vscbufchanged = true; - } + memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count); + D3D::gfxstate->vscbufchanged = true; } // this class will load the precompiled shaders into our cache