Created
October 28, 2011 20:12
-
-
Save nyetwurk/1323422 to your computer and use it in GitHub Desktop.
Patch to kissaki's DX11 branch of mumble
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/overlay/d3d11.cpp b/overlay/d3d11.cpp | |
index af7f790..7c108ee 100644 | |
--- a/overlay/d3d11.cpp | |
+++ b/overlay/d3d11.cpp | |
@@ -29,8 +29,8 @@ | |
*/ | |
#include "lib.h" | |
-#include "overlay.hex" | |
-/*#include "Effects11/Inc/d3dx11effect.h"*/ | |
+#include "overlay11.hex" | |
+#include "Effects11/Inc/d3dx11effect.h" | |
#include <d3d11.h> | |
#include <d3dx10math.h> | |
#include <d3dx11.h> | |
@@ -70,6 +70,7 @@ class D11State: protected Pipe { | |
ID3D11Device *pDevice; | |
ID3D11DeviceContext *pDeviceContext; | |
+ bool bDeferredContext; | |
IDXGISwapChain *pSwapChain; | |
ID3D11RenderTargetView *pRTV; | |
@@ -80,7 +81,6 @@ class D11State: protected Pipe { | |
ID3D11Buffer *pVertexBuffer; | |
ID3D11Buffer *pIndexBuffer; | |
ID3D11BlendState *pBlendState; | |
- ID3D11CommandList *pCommandList; | |
ID3D11Texture2D *pTexture; | |
ID3D11ShaderResourceView *pSRView; | |
@@ -121,7 +121,6 @@ D11State::D11State(IDXGISwapChain *pSwapChain, ID3D11Device *pDevice) { | |
pTexture = NULL; | |
pSRView = NULL; | |
pDeviceContext = NULL; | |
- pCommandList = NULL; | |
timeT = clock(); | |
frameCount = 0; | |
@@ -256,8 +255,15 @@ void D11State::init() { | |
ID3D11Texture2D* pBackBuffer = NULL; | |
hr = pSwapChain->GetBuffer(0, __uuidof(*pBackBuffer), (LPVOID*)&pBackBuffer); | |
- //hr = pDevice->CreateDeferredContext(0, &pDeviceContext); | |
- pDevice->GetImmediateContext(&pDeviceContext); | |
+ hr = pDevice->CreateDeferredContext(0, &pDeviceContext); | |
+ | |
+ if (! SUCCEEDED(hr) || !pDeviceContext) { | |
+ ods("D3D11: Failed to create DeferredContext (0x%x). Getting ImmediateContext", hr); | |
+ pDevice->GetImmediateContext(&pDeviceContext); | |
+ bDeferredContext=false; | |
+ } else { | |
+ bDeferredContext=true; | |
+ } | |
D3D11_TEXTURE2D_DESC backBufferSurfaceDesc; | |
pBackBuffer->GetDesc(&backBufferSurfaceDesc); | |
@@ -290,7 +296,7 @@ void D11State::init() { | |
float bf[4]; | |
pDeviceContext->OMSetBlendState(pBlendState, bf, 0xffffffff); | |
- hr = D3DX11CreateEffectFromMemory((void *) g_main, sizeof(g_main), 0, pDevice, &pEffect); | |
+ hr = D3DX11CreateEffectFromMemory((void *) g_main11, sizeof(g_main11), 0, pDevice, &pEffect); | |
pTechnique = pEffect->GetTechniqueByName("Render"); | |
pDiffuseTexture = pEffect->GetVariableByName("txDiffuse")->AsShaderResource(); | |
@@ -357,8 +363,6 @@ D11State::~D11State() { | |
pTexture->Release(); | |
if (pSRView) | |
pSRView->Release(); | |
- if (pCommandList) | |
- pCommandList->Release(); | |
if (pDeviceContext) | |
pDeviceContext->Release(); | |
} | |
@@ -405,12 +409,16 @@ void D11State::draw() { | |
pDeviceContext->DrawIndexed(6, 0, 0); | |
} | |
- /*pDeviceContext->FinishCommandList(TRUE, &pCommandList); | |
- ID3D11DeviceContext *ctx = NULL; | |
- pDevice->GetImmediateContext(&ctx); | |
- ctx->ExecuteCommandList(pCommandList, TRUE); | |
- ctx->Release(); | |
- pCommandList->Release();*/ | |
+ if (bDeferredContext) { | |
+ ID3D11CommandList *pCommandList; | |
+ pDeviceContext->FinishCommandList(TRUE, &pCommandList); | |
+ ID3D11DeviceContext *ctx = NULL; | |
+ pDevice->GetImmediateContext(&ctx); | |
+ ctx->ExecuteCommandList(pCommandList, TRUE); | |
+ ctx->Release(); | |
+ pCommandList->Release(); | |
+ } | |
+ | |
/*TODO rm | |
pDeviceContext->FinishCommandList(TRUE, &pCommandList); | |
@@ -431,7 +439,7 @@ static HRESULT __stdcall myPresent(IDXGISwapChain *pSwapChain, UINT SyncInterval | |
ID3D11Device *pDevice = NULL; | |
- ods("DXGI11: DrawBegin"); | |
+ ods("DXGI11: myPresent"); | |
hr = pSwapChain->GetDevice(__uuidof(ID3D11Device), (void **) &pDevice); | |
if (pDevice) { | |
diff --git a/overlay/overlay.pro b/overlay/overlay.pro | |
index 36307ef..65d7465 100644 | |
--- a/overlay/overlay.pro | |
+++ b/overlay/overlay.pro | |
@@ -47,5 +47,10 @@ fxc.output = ${QMAKE_FILE_BASE}.hex | |
fxc.commands = fxc /Tfx_4_0 /O3 /Fh${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} | |
fxc.input = EFFECTS | |
fxc.CONFIG *= no_link target_predeps | |
-QMAKE_EXTRA_COMPILERS *= fxc | |
+ | |
+fxc11.output = ${QMAKE_FILE_BASE}11.hex | |
+fxc11.commands = fxc /Tfx_5_0 /Emain11 /Fh${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} | |
+fxc11.input = EFFECTS | |
+fxc11.CONFIG *= no_link target_predeps | |
+QMAKE_EXTRA_COMPILERS *= fxc fxc11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment