Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1082 from mumble-voip/olay-11
Overlay: Add Direct3D 11 support
- Loading branch information
Showing
13 changed files
with
1,142 additions
and
39 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
include(../../compiler.pri) | ||
|
||
BUILDDIR=$$basename(PWD) | ||
SOURCEDIR=$$replace(BUILDDIR,-build,-src) | ||
|
||
!exists(../$$SOURCEDIR/Effect.h) { | ||
message("The $$SOURCEDIR/ directory was not found. You need to do one of the following:") | ||
message("") | ||
message("git submodule init") | ||
message("git submodule update") | ||
message("") | ||
error("Aborting configuration") | ||
} | ||
|
||
TEMPLATE = lib | ||
CONFIG *= debug_and_release warn_on | ||
CONFIG *= staticlib | ||
VPATH = ../$$SOURCEDIR | ||
TARGET = effects11 | ||
SOURCES = EffectAPI.cpp \ | ||
EffectLoad.cpp \ | ||
EffectNonRuntime.cpp \ | ||
EffectReflection.cpp \ | ||
EffectRuntime.cpp \ | ||
d3dxGlobal.cpp | ||
HEADERS = pchfx.h \ | ||
Inc/d3dx11effect.h \ | ||
Inc/d3dxglobal.h \ | ||
Binary/EffectBinaryFormat.h \ | ||
Binary/EffectStateBase11.h \ | ||
Binary/EffectStates11.h \ | ||
Binary/SOParser.h \ | ||
Effect.h \ | ||
EffectLoad.h \ | ||
IUnknownImp.h | ||
|
||
DEFINES += WIN32 PROFILE _WINDOWS _LIB D3DXFX_LARGEADDRESS_HANDLE | ||
|
||
QMAKE_CXXFLAGS_RELEASE -= -MD | ||
QMAKE_CXXFLAGS_DEBUG -= -MDd | ||
|
||
QMAKE_CXXFLAGS_RELEASE *= -MT | ||
QMAKE_CXXFLAGS_DEBUG *= -MTd | ||
|
||
INCLUDEPATH *= ../$$SOURCEDIR/Inc ../$$SOURCEDIR/Binary | ||
INCLUDEPATH *= $(DXSDK_DIR)Include | ||
|
||
CONFIG(release, debug|release) { | ||
DEFINES *= NDEBUG | ||
} | ||
|
||
CONFIG(debug, debug|release) { | ||
DEFINES *= DEBUG _DEBUG | ||
} |
Submodule fx11-src
added at
7606b7
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* Copyright (C) 2011-2013, Nye Liu <nyet@nyet.org> | ||
Copyright (C) 2011-2013, Kissaki <kissaki@gmx.de> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
- Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
- Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
- Neither the name of the Mumble Developers nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "D11StateBlock.h" | ||
|
||
void D11CreateStateBlock(ID3D11DeviceContext *pDeviceContext, D11StateBlock **ppStateBlock) | ||
{ | ||
*ppStateBlock = new D11StateBlock(pDeviceContext); | ||
} | ||
|
||
D11StateBlock::D11StateBlock(ID3D11DeviceContext *pDC) | ||
: pRasterizerState(0), uiSampleMask(0) | ||
, Format(DXGI_FORMAT_UNKNOWN), Topology(D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) | ||
, pBlendState(0), pIndexBuffer(0), pInputLayout(0), uiOffset(0) | ||
, pDepthStencilView(0) { | ||
uiNumViewports = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; | ||
ZeroMemory(pViewports, sizeof(pViewports)); | ||
ZeroMemory(pRenderTargetViews, sizeof (pRenderTargetViews)); | ||
ZeroMemory(fBlendFactor, sizeof (fBlendFactor)); | ||
ZeroMemory(pVertexBuffers, sizeof (pVertexBuffers)); | ||
ZeroMemory(uiStrides, sizeof (uiStrides)); | ||
ZeroMemory(uiOffsets, sizeof (uiOffsets)); | ||
|
||
pDeviceContext = pDC; | ||
pDeviceContext->AddRef(); | ||
} | ||
|
||
D11StateBlock::~D11StateBlock() { | ||
ReleaseObjects(); | ||
pDeviceContext->Release(); | ||
} | ||
|
||
void D11StateBlock::Capture() | ||
{ | ||
// Release potential references to make sure we have no leaks. | ||
ReleaseObjects(); | ||
|
||
pDeviceContext->RSGetState(&pRasterizerState); | ||
uiNumViewports = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; | ||
pDeviceContext->RSGetViewports(&uiNumViewports, pViewports); | ||
pDeviceContext->OMGetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, pRenderTargetViews, &pDepthStencilView); | ||
pDeviceContext->OMGetBlendState(&pBlendState, fBlendFactor, &uiSampleMask); | ||
pDeviceContext->IAGetInputLayout(&pInputLayout); | ||
pDeviceContext->IAGetIndexBuffer(&pIndexBuffer, &Format, &uiOffset); | ||
pDeviceContext->IAGetPrimitiveTopology(&Topology); | ||
pDeviceContext->IAGetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, pVertexBuffers, uiStrides, uiOffsets); | ||
} | ||
|
||
void D11StateBlock::Apply() | ||
{ | ||
pDeviceContext->RSSetState(pRasterizerState); | ||
pDeviceContext->RSSetViewports(uiNumViewports, pViewports); | ||
pDeviceContext->OMSetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, pRenderTargetViews, pDepthStencilView); | ||
pDeviceContext->OMSetBlendState(pBlendState, fBlendFactor, uiSampleMask); | ||
pDeviceContext->IASetInputLayout(pInputLayout); | ||
pDeviceContext->IASetIndexBuffer(pIndexBuffer, Format, uiOffset); | ||
pDeviceContext->IASetPrimitiveTopology(Topology); | ||
pDeviceContext->IASetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, pVertexBuffers, uiStrides, uiOffsets); | ||
ReleaseObjects(); | ||
} | ||
|
||
/// Release state information | ||
void D11StateBlock::ReleaseObjects() | ||
{ | ||
if (pRasterizerState) { | ||
pRasterizerState->Release(); | ||
pRasterizerState = NULL; | ||
} | ||
|
||
for (int i=0; i<D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++) | ||
if (pRenderTargetViews[i]) { | ||
pRenderTargetViews[i]->Release(); | ||
pRenderTargetViews[i] = NULL; | ||
} | ||
|
||
|
||
if (pDepthStencilView) { | ||
pDepthStencilView->Release(); | ||
pDepthStencilView = NULL; | ||
} | ||
|
||
if (pBlendState) { | ||
pBlendState->Release(); | ||
pBlendState = NULL; | ||
} | ||
|
||
if (pInputLayout) { | ||
pInputLayout->Release(); | ||
pInputLayout = NULL; | ||
} | ||
|
||
if (pIndexBuffer) { | ||
pIndexBuffer->Release(); | ||
pIndexBuffer = NULL; | ||
} | ||
|
||
for (int i=0; i<D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) | ||
if (pVertexBuffers[i]) { | ||
pVertexBuffers[i]->Release(); | ||
pVertexBuffers[i] = NULL; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* Copyright (C) 2011-2013, Nye Liu <nyet@nyet.org> | ||
Copyright (C) 2011-2013, Kissaki <kissaki@gmx.de> | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
- Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
- Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
- Neither the name of the Mumble Developers nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef MUMBLE_D11STATEBLOCK_H_ | ||
#define MUMBLE_D11STATEBLOCK_H_ | ||
|
||
// File contains the D11StateBlock class and a function D11CreateStateBlock. | ||
|
||
#include <d3d11.h> | ||
#include <d3dx10math.h> | ||
#include <d3dx11.h> | ||
|
||
class D11StateBlock; | ||
|
||
void D11CreateStateBlock(ID3D11DeviceContext *, D11StateBlock **); | ||
|
||
class D11StateBlock { | ||
public: | ||
D11StateBlock(ID3D11DeviceContext *); | ||
~D11StateBlock(); | ||
|
||
void Capture(); | ||
void Apply(); | ||
void ReleaseObjects(); | ||
void ReleaseAllDeviceObjects(); | ||
|
||
private: | ||
ID3D11DeviceContext *pDeviceContext; | ||
|
||
ID3D11RasterizerState *pRasterizerState; | ||
UINT uiNumViewports; | ||
D3D11_VIEWPORT pViewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; | ||
|
||
ID3D11RenderTargetView *pRenderTargetViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT]; | ||
ID3D11DepthStencilView *pDepthStencilView; | ||
|
||
ID3D11BlendState *pBlendState; | ||
float fBlendFactor[4]; | ||
UINT32 uiSampleMask; | ||
|
||
ID3D11InputLayout *pInputLayout; | ||
|
||
ID3D11Buffer *pIndexBuffer; | ||
DXGI_FORMAT Format; | ||
UINT uiOffset; | ||
|
||
D3D11_PRIMITIVE_TOPOLOGY Topology; | ||
|
||
ID3D11Buffer *pVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; | ||
UINT uiStrides[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; | ||
UINT uiOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; | ||
}; | ||
|
||
#endif /* !D11STATEBLOCK_H_ */ |
Oops, something went wrong.