diff --git a/.gitignore b/.gitignore index 182a55a..dc51204 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,14 @@ Demo/DX10/Demo.vcxproj.user Scripts/*.pyc Scripts/*.tga + +*~ +*.d +*.o + +mingw/dxsdkver.h +mingw/d3d*.h +mingw/D3DX10math.inl +mingw/dxerr.h +mingw/xinput.h +mingw/*.exe diff --git a/Demo/DX10/Code/Demo.cpp b/Demo/DX10/Code/Demo.cpp index 686c59b..b1d24d5 100644 --- a/Demo/DX10/Code/Demo.cpp +++ b/Demo/DX10/Code/Demo.cpp @@ -25,7 +25,7 @@ #include "DXUT.h" #include "DXUTgui.h" -#include "DXUTsettingsDlg.h" +#include "DXUTsettingsdlg.h" #include "SDKmesh.h" #include "SDKmisc.h" @@ -490,12 +490,12 @@ void initSMAA(ID3D10Device *device, const DXGI_SURFACE_DESC *desc) { slider = hud.GetSlider(IDC_MAX_SEARCH_STEPS); slider->GetRange(min, max); scale = float(slider->GetValue()) / (max - min); - smaa->setMaxSearchSteps(int(round(112.0f * scale))); + smaa->setMaxSearchSteps(int(round(112.0 * scale))); slider = hud.GetSlider(IDC_MAX_SEARCH_STEPS_DIAG); slider->GetRange(min, max); scale = float(slider->GetValue()) / (max - min); - smaa->setMaxSearchStepsDiag(int(round(20.0f * scale))); + smaa->setMaxSearchStepsDiag(int(round(20.0 * scale))); slider = hud.GetSlider(IDC_CORNER_ROUNDING); slider->GetRange(min, max); @@ -1183,10 +1183,10 @@ void CALLBACK onGUIEvent(UINT event, int id, CDXUTControl *control, void *contex slider->GetRange(min, max); float scale = float(slider->GetValue()) / (max - min); - smaa->setMaxSearchSteps(int(round(scale * 112.0f))); + smaa->setMaxSearchSteps(int(round(scale * 112.0))); wstringstream s; - s << L"Max Search Steps: " << int(round(scale * 112.0f)); + s << L"Max Search Steps: " << int(round(scale * 112.0)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_LABEL)->SetText(s.str().c_str()); } break; @@ -1197,10 +1197,10 @@ void CALLBACK onGUIEvent(UINT event, int id, CDXUTControl *control, void *contex slider->GetRange(min, max); float scale = float(slider->GetValue()) / (max - min); - smaa->setMaxSearchStepsDiag(int(round(scale * 20.0f))); + smaa->setMaxSearchStepsDiag(int(round(scale * 20.0))); wstringstream s; - s << L"Max Diag. Search Steps: " << int(round(scale * 20.0f)); + s << L"Max Diag. Search Steps: " << int(round(scale * 20.0)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL)->SetText(s.str().c_str()); } break; @@ -1296,21 +1296,24 @@ void initApp() { hud.GetStatic(IDC_THRESHOLD_LABEL)->SetVisible(false); hud.GetSlider(IDC_THRESHOLD)->SetVisible(false); - s = wstringstream(); + s.clear(); + s.str(L""); s << L"Max Search Steps: " << commandlineOptions.searchSteps; hud.AddStatic(IDC_MAX_SEARCH_STEPS_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22); hud.AddSlider(IDC_MAX_SEARCH_STEPS, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.searchSteps / 112.0f)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_LABEL)->SetVisible(false); hud.GetSlider(IDC_MAX_SEARCH_STEPS)->SetVisible(false); - s = wstringstream(); + s.clear(); + s.str(L""); s << L"Max Diag. Search Steps: " << commandlineOptions.diagSearchSteps; hud.AddStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22); hud.AddSlider(IDC_MAX_SEARCH_STEPS_DIAG, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.diagSearchSteps / 20.0f)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL)->SetVisible(false); hud.GetSlider(IDC_MAX_SEARCH_STEPS_DIAG)->SetVisible(false); - s = wstringstream(); + s.clear(); + s.str(L""); s << L"Corner Rounding: " << commandlineOptions.cornerRounding; hud.AddStatic(IDC_CORNER_ROUNDING_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22); hud.AddSlider(IDC_CORNER_ROUNDING, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.cornerRounding / 100.0f)); diff --git a/Demo/DX10/Code/SMAA.h b/Demo/DX10/Code/SMAA.h index 7083c14..daa7354 100644 --- a/Demo/DX10/Code/SMAA.h +++ b/Demo/DX10/Code/SMAA.h @@ -44,7 +44,31 @@ class SMAA { public: - class ExternalStorage; + /** + * @EXTERNAL_STORAGE + * + * If you have one or two spare render targets of the same size as the + * backbuffer, you may want to pass them to SMAA::SMAA() using a + * ExternalStorage object. You may pass one or the two, depending on + * what you have available. + * + * A non-sRGB RG buffer (at least) is expected for storing edges. + * A non-sRGB RGBA buffer is expected for the blending weights. + */ + class ExternalStorage { + public: + ExternalStorage(ID3D10ShaderResourceView *edgesSRV=nullptr, + ID3D10RenderTargetView *edgesRTV=nullptr, + ID3D10ShaderResourceView *weightsSRV=nullptr, + ID3D10RenderTargetView *weightsRTV=nullptr) + : edgesSRV(edgesSRV), + edgesRTV(edgesRTV), + weightsSRV(weightsSRV), + weightsRTV(weightsRTV) {} + + ID3D10ShaderResourceView *edgesSRV, *weightsSRV; + ID3D10RenderTargetView *edgesRTV, *weightsRTV; + }; enum Mode { MODE_SMAA_1X, MODE_SMAA_T2X, MODE_SMAA_S2X, MODE_SMAA_4X, MODE_SMAA_COUNT=MODE_SMAA_4X }; enum Preset { PRESET_LOW, PRESET_MEDIUM, PRESET_HIGH, PRESET_ULTRA, PRESET_CUSTOM, PRESET_COUNT=PRESET_CUSTOM }; @@ -169,31 +193,6 @@ class SMAA { void nextFrame(); int getFrameIndex() const { return frameIndex; } - /** - * @EXTERNAL_STORAGE - * - * If you have one or two spare render targets of the same size as the - * backbuffer, you may want to pass them to SMAA::SMAA() using a - * ExternalStorage object. You may pass one or the two, depending on - * what you have available. - * - * A non-sRGB RG buffer (at least) is expected for storing edges. - * A non-sRGB RGBA buffer is expected for the blending weights. - */ - class ExternalStorage { - public: - ExternalStorage(ID3D10ShaderResourceView *edgesSRV=nullptr, - ID3D10RenderTargetView *edgesRTV=nullptr, - ID3D10ShaderResourceView *weightsSRV=nullptr, - ID3D10RenderTargetView *weightsRTV=nullptr) - : edgesSRV(edgesSRV), - edgesRTV(edgesRTV), - weightsSRV(weightsSRV), - weightsRTV(weightsRTV) {} - - ID3D10ShaderResourceView *edgesSRV, *weightsSRV; - ID3D10RenderTargetView *edgesRTV, *weightsRTV; - }; private: /** diff --git a/Demo/DX10/Code/module.mk b/Demo/DX10/Code/module.mk new file mode 100644 index 0000000..85d59a2 --- /dev/null +++ b/Demo/DX10/Code/module.mk @@ -0,0 +1,37 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + Demo.cpp \ + SMAA.cpp \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) + + + +dx10demo_MODULES:=dxut Support + + +ifeq ($(DX10),y) + +PROGRAMS+= \ + dx10demo \ + #empty line + +endif + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/DX10/Demo.rc b/Demo/DX10/Demo.rc index 90d36b0..834810b 100644 --- a/Demo/DX10/Demo.rc +++ b/Demo/DX10/Demo.rc @@ -1,29 +1,29 @@ 1 ICON "Icon.ico" -SMAA.fx RCDATA Shaders\SMAA.fx -SMAA.hlsl RCDATA "..\\..\\SMAA.hlsl" -Simple.fx RCDATA Shaders\Simple.fx +SMAA.fx RCDATA "Shaders/SMAA.fx" +SMAA.hlsl RCDATA "../../SMAA.hlsl" +Simple.fx RCDATA "Shaders/Simple.fx" -AreaTexDX10.dds RCDATA "..\\..\\Textures\\AreaTexDX10.dds" -SearchTex.dds RCDATA "..\\..\\Textures\\SearchTex.dds" +AreaTexDX10.dds RCDATA "../../Textures/AreaTexDX10.dds" +SearchTex.dds RCDATA "../../Textures/SearchTex.dds" -Unigine01.png RCDATA "..\\Media\\Unigine01.png" -Unigine02.png RCDATA "..\\Media\\Unigine02.png" -Unigine03.png RCDATA "..\\Media\\Unigine03.png" -Unigine04.png RCDATA "..\\Media\\Unigine04.png" -Unigine05.png RCDATA "..\\Media\\Unigine05.png" -Unigine06.png RCDATA "..\\Media\\Unigine06.png" -Unigine07.png RCDATA "..\\Media\\Unigine07.png" +Unigine01.png RCDATA "../Media/Unigine01.png" +Unigine02.png RCDATA "../Media/Unigine02.png" +Unigine03.png RCDATA "../Media/Unigine03.png" +Unigine04.png RCDATA "../Media/Unigine04.png" +Unigine05.png RCDATA "../Media/Unigine05.png" +Unigine06.png RCDATA "../Media/Unigine06.png" +Unigine07.png RCDATA "../Media/Unigine07.png" -Unigine01.dds RCDATA "..\\Media\\Unigine01.dds" -Unigine02.dds RCDATA "..\\Media\\Unigine02.dds" -Unigine03.dds RCDATA "..\\Media\\Unigine03.dds" -Unigine04.dds RCDATA "..\\Media\\Unigine04.dds" -Unigine05.dds RCDATA "..\\Media\\Unigine05.dds" -Unigine06.dds RCDATA "..\\Media\\Unigine06.dds" -Unigine07.dds RCDATA "..\\Media\\Unigine07.dds" +Unigine01.dds RCDATA "../Media/Unigine01.dds" +Unigine02.dds RCDATA "../Media/Unigine02.dds" +Unigine03.dds RCDATA "../Media/Unigine03.dds" +Unigine04.dds RCDATA "../Media/Unigine04.dds" +Unigine05.dds RCDATA "../Media/Unigine05.dds" +Unigine06.dds RCDATA "../Media/Unigine06.dds" +Unigine07.dds RCDATA "../Media/Unigine07.dds" -Fence.sdkmesh RCDATA "..\\Media\\Fence.sdkmesh" -DiffuseMap.dds RCDATA "..\\Media\\DiffuseMap.dds" -NormalMap.dds RCDATA "..\\Media\\NormalMap.dds" -EnvMap.dds RCDATA "..\\Media\\EnvMap.dds" +Fence.sdkmesh RCDATA "../Media/Fence.sdkmesh" +DiffuseMap.dds RCDATA "../Media/DiffuseMap.dds" +NormalMap.dds RCDATA "../Media/NormalMap.dds" +EnvMap.dds RCDATA "../Media/EnvMap.dds" diff --git a/Demo/DX10/module.mk b/Demo/DX10/module.mk new file mode 100644 index 0000000..e712b7c --- /dev/null +++ b/Demo/DX10/module.mk @@ -0,0 +1,23 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + Code \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) +dx10demo_SRC:=$(foreach directory, $(DIRS), $(SRC_$(directory)) ) $(d)/Demo.rc + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/DX9/Code/Demo.cpp b/Demo/DX9/Code/Demo.cpp index d5e255c..4c0e41e 100644 --- a/Demo/DX9/Code/Demo.cpp +++ b/Demo/DX9/Code/Demo.cpp @@ -29,7 +29,7 @@ #include "DXUT.h" #include "DXUTgui.h" #include "DXUTmisc.h" -#include "DXUTSettingsDlg.h" +#include "DXUTsettingsdlg.h" #include "SDKmisc.h" #include "SMAA.h" @@ -474,21 +474,24 @@ void initApp() { hud.GetStatic(IDC_THRESHOLD_LABEL)->SetVisible(false); hud.GetSlider(IDC_THRESHOLD)->SetVisible(false); - s = wstringstream(); + s.clear(); + s.str(L""); s << L"Max Search Steps: " << commandlineOptions.searchSteps; hud.AddStatic(IDC_MAX_SEARCH_STEPS_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22); hud.AddSlider(IDC_MAX_SEARCH_STEPS, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.searchSteps / 112.0f)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_LABEL)->SetVisible(false); hud.GetSlider(IDC_MAX_SEARCH_STEPS)->SetVisible(false); - s = wstringstream(); + s.clear(); + s.str(L""); s << L"Max Diag. Search Steps: " << commandlineOptions.diagSearchSteps; hud.AddStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22); hud.AddSlider(IDC_MAX_SEARCH_STEPS_DIAG, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.diagSearchSteps / 20.0f)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL)->SetVisible(false); hud.GetSlider(IDC_MAX_SEARCH_STEPS_DIAG)->SetVisible(false); - s = wstringstream(); + s.clear(); + s.str(L""); s << L"Corner Rounding: " << commandlineOptions.cornerRounding; hud.AddStatic(IDC_CORNER_ROUNDING_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22); hud.AddSlider(IDC_CORNER_ROUNDING, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.cornerRounding / 100.0f)); diff --git a/Demo/DX9/Code/SMAA.h b/Demo/DX9/Code/SMAA.h index 2706c1d..1d27e23 100644 --- a/Demo/DX9/Code/SMAA.h +++ b/Demo/DX9/Code/SMAA.h @@ -38,7 +38,23 @@ class SMAA { public: - class ExternalStorage; + /** + * This class allows to pass spare storage buffers to the SMAA class. + */ + class ExternalStorage { + public: + ExternalStorage(IDirect3DTexture9 *edgeTex=nullptr, + IDirect3DSurface9 *edgeSurface=nullptr, + IDirect3DTexture9 *blendTex=nullptr, + IDirect3DSurface9 *blendSurface=nullptr) + : edgeTex(edgeTex), + edgeSurface(edgeSurface), + blendTex(blendTex), + blendSurface(blendSurface) {} + + IDirect3DTexture9 *edgeTex, *blendTex; + IDirect3DSurface9 *edgeSurface, *blendSurface; + }; enum Preset { PRESET_LOW, PRESET_MEDIUM, PRESET_HIGH, PRESET_ULTRA, PRESET_CUSTOM }; enum Input { INPUT_LUMA, INPUT_COLOR, INPUT_DEPTH }; @@ -109,23 +125,6 @@ class SMAA { float getCornerRounding() const { return cornerRounding; } void setCornerRounding(float cornerRounding) { this->cornerRounding = cornerRounding; } - /** - * This class allows to pass spare storage buffers to the SMAA class. - */ - class ExternalStorage { - public: - ExternalStorage(IDirect3DTexture9 *edgeTex=nullptr, - IDirect3DSurface9 *edgeSurface=nullptr, - IDirect3DTexture9 *blendTex=nullptr, - IDirect3DSurface9 *blendSurface=nullptr) - : edgeTex(edgeTex), - edgeSurface(edgeSurface), - blendTex(blendTex), - blendSurface(blendSurface) {} - - IDirect3DTexture9 *edgeTex, *blendTex; - IDirect3DSurface9 *edgeSurface, *blendSurface; - }; private: void loadAreaTex(); diff --git a/Demo/DX9/Code/module.mk b/Demo/DX9/Code/module.mk new file mode 100644 index 0000000..8a3cfc4 --- /dev/null +++ b/Demo/DX9/Code/module.mk @@ -0,0 +1,37 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + Demo.cpp \ + SMAA.cpp \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) + + + +dx9demo_MODULES:=dxut Support + + +ifeq ($(DX9),y) + +PROGRAMS+= \ + dx9demo \ + #empty line + +endif + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/DX9/Demo.rc b/Demo/DX9/Demo.rc index 53d846c..fa661c8 100644 --- a/Demo/DX9/Demo.rc +++ b/Demo/DX9/Demo.rc @@ -1,10 +1,10 @@ 1 ICON "Icon.ico" -SMAA.fx RCDATA Shaders\SMAA.fx -SMAA.hlsl RCDATA "..\\..\\SMAA.hlsl" +SMAA.fx RCDATA "Shaders/SMAA.fx" +SMAA.hlsl RCDATA "../../SMAA.hlsl" -AreaTexDX9.dds RCDATA "..\\..\\Textures\\AreaTexDX9.dds" -SearchTex.dds RCDATA "..\\..\\Textures\\SearchTex.dds" +AreaTexDX9.dds RCDATA "../../Textures/AreaTexDX9.dds" +SearchTex.dds RCDATA "../../Textures/SearchTex.dds" -Unigine02.png RCDATA "..\\Media\\Unigine02.png" -Unigine02.dds RCDATA "..\\Media\\Unigine02.dds" +Unigine02.png RCDATA "../Media/Unigine02.png" +Unigine02.dds RCDATA "../Media/Unigine02.dds" diff --git a/Demo/DX9/module.mk b/Demo/DX9/module.mk new file mode 100644 index 0000000..e5fe4ed --- /dev/null +++ b/Demo/DX9/module.mk @@ -0,0 +1,23 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + Code \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) +dx9demo_SRC:=$(foreach directory, $(DIRS), $(SRC_$(directory)) ) $(d)/Demo.rc + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/DXUT/Core/DXUTmisc.cpp b/Demo/DXUT/Core/DXUTmisc.cpp index fe98d65..0e77a2c 100644 --- a/Demo/DXUT/Core/DXUTmisc.cpp +++ b/Demo/DXUT/Core/DXUTmisc.cpp @@ -5,7 +5,7 @@ // // Copyright (c) Microsoft Corporation. All rights reserved //-------------------------------------------------------------------------------------- -#include "dxut.h" +#include "DXUT.h" #include #define DXUT_GAMEPAD_TRIGGER_THRESHOLD 30 #undef min // use __min instead @@ -907,7 +907,7 @@ void WINAPI DXUTTraceDecl( D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE] ) DXUTOutputDebugString( L"decl[%d]=D3DDECL_END\n", iDecl ); } -#define TRACE_ID(iD) case iD: return L#iD; +#define TRACE_ID(iD) case iD: return L ## #iD; //-------------------------------------------------------------------------------------- WCHAR* WINAPI DXUTTraceWindowsMessage( UINT uMsg ) diff --git a/Demo/DXUT/Core/module.mk b/Demo/DXUT/Core/module.mk new file mode 100644 index 0000000..1a742d6 --- /dev/null +++ b/Demo/DXUT/Core/module.mk @@ -0,0 +1,25 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + DXUT.cpp \ + DXUTenum.cpp \ + DXUTmisc.cpp \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/DXUT/Optional/DXUTgui.cpp b/Demo/DXUT/Optional/DXUTgui.cpp index ab5f135..b275807 100644 --- a/Demo/DXUT/Optional/DXUTgui.cpp +++ b/Demo/DXUT/Optional/DXUTgui.cpp @@ -5,7 +5,7 @@ //-------------------------------------------------------------------------------------- #include "DXUT.h" #include "DXUTgui.h" -#include "DXUTsettingsDlg.h" +#include "DXUTsettingsdlg.h" #include "DXUTres.h" #undef min // use __min instead diff --git a/Demo/DXUT/Optional/DXUTguiIME.cpp b/Demo/DXUT/Optional/DXUTguiIME.cpp index 6c27c77..ec2fa2d 100644 --- a/Demo/DXUT/Optional/DXUTguiIME.cpp +++ b/Demo/DXUT/Optional/DXUTguiIME.cpp @@ -5,7 +5,7 @@ //-------------------------------------------------------------------------------------- #include "DXUT.h" #include "DXUTgui.h" -#include "DXUTsettingsDlg.h" +#include "DXUTsettingsdlg.h" #include "DXUTres.h" #include "DXUTgui.h" #include "DXUTguiIME.h" diff --git a/Demo/DXUT/Optional/DXUTsettingsdlg.cpp b/Demo/DXUT/Optional/DXUTsettingsdlg.cpp index 2ea56ae..3df7d59 100644 --- a/Demo/DXUT/Optional/DXUTsettingsdlg.cpp +++ b/Demo/DXUT/Optional/DXUTsettingsdlg.cpp @@ -7,7 +7,7 @@ //-------------------------------------------------------------------------------------- #include "DXUT.h" #include "DXUTgui.h" -#include "DXUTsettingsDlg.h" +#include "DXUTsettingsdlg.h" #undef min // use __min instead #undef max // use __max instead diff --git a/Demo/DXUT/Optional/ImeUi.cpp b/Demo/DXUT/Optional/ImeUi.cpp index 32fe902..068677c 100644 --- a/Demo/DXUT/Optional/ImeUi.cpp +++ b/Demo/DXUT/Optional/ImeUi.cpp @@ -3,7 +3,7 @@ // // Copyright (c) Microsoft Corporation. All rights reserved. //-------------------------------------------------------------------------------------- -#include "dxut.h" +#include "DXUT.h" #include "ImeUi.h" #include #include diff --git a/Demo/DXUT/Optional/SDKmesh.cpp b/Demo/DXUT/Optional/SDKmesh.cpp index 53ba038..0ae6542 100644 --- a/Demo/DXUT/Optional/SDKmesh.cpp +++ b/Demo/DXUT/Optional/SDKmesh.cpp @@ -9,8 +9,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. //-------------------------------------------------------------------------------------- #include "DXUT.h" -#include "SDKMesh.h" -#include "SDKMisc.h" +#include "SDKmesh.h" +#include "SDKmisc.h" //-------------------------------------------------------------------------------------- void CDXUTSDKMesh::LoadMaterials( ID3D10Device* pd3dDevice, SDKMESH_MATERIAL* pMaterials, UINT numMaterials, @@ -430,6 +430,16 @@ HRESULT CDXUTSDKMesh::CreateFromMemory( ID3D10Device* pDev10, m_pMeshArray[i].pFrameInfluences = ( UINT* )( m_pStaticMeshData + m_pMeshArray[i].FrameInfluenceOffset ); } + // Setup buffer data pointer + BYTE* pBufferData = pData + m_pMeshHeader->HeaderSize + m_pMeshHeader->NonBufferDataSize; + + // Get the start of the buffer data + UINT64 BufferDataStart = m_pMeshHeader->HeaderSize + m_pMeshHeader->NonBufferDataSize; + + SDKMESH_SUBSET* pSubset = NULL; + SDKMESH_MESH* currentMesh = &m_pMeshArray[0]; + int tris = 0; + // error condition if( m_pMeshHeader->Version != SDKMESH_FILE_VERSION ) { @@ -437,12 +447,6 @@ HRESULT CDXUTSDKMesh::CreateFromMemory( ID3D10Device* pDev10, goto Error; } - // Setup buffer data pointer - BYTE* pBufferData = pData + m_pMeshHeader->HeaderSize + m_pMeshHeader->NonBufferDataSize; - - // Get the start of the buffer data - UINT64 BufferDataStart = m_pMeshHeader->HeaderSize + m_pMeshHeader->NonBufferDataSize; - // Create Adjacency Indices if( pDev10 && bCreateAdjacencyIndices ) CreateAdjacencyIndices( pDev10, 0.001f, pBufferData - BufferDataStart ); @@ -495,12 +499,9 @@ HRESULT CDXUTSDKMesh::CreateFromMemory( ID3D10Device* pDev10, hr = S_OK; - SDKMESH_SUBSET* pSubset = NULL; D3D10_PRIMITIVE_TOPOLOGY PrimType; // update bounding volume - SDKMESH_MESH* currentMesh = &m_pMeshArray[0]; - int tris = 0; for (UINT meshi=0; meshi < m_pMeshHeader->NumMeshes; ++meshi) { lower.x = FLT_MAX; lower.y = FLT_MAX; lower.z = FLT_MAX; upper.x = -FLT_MAX; upper.y = -FLT_MAX; upper.z = -FLT_MAX; @@ -1195,6 +1196,7 @@ HRESULT CDXUTSDKMesh::LoadAnimation( WCHAR* szFileName ) ///////////////////////// // Header SDKANIMATION_FILE_HEADER fileheader; + UINT64 BaseOffset = sizeof( SDKANIMATION_FILE_HEADER ); if( !ReadFile( hFile, &fileheader, sizeof( SDKANIMATION_FILE_HEADER ), &dwBytesRead, NULL ) ) goto Error; @@ -1218,7 +1220,6 @@ HRESULT CDXUTSDKMesh::LoadAnimation( WCHAR* szFileName ) m_pAnimationHeader = ( SDKANIMATION_FILE_HEADER* )m_pAnimationData; m_pAnimationFrameData = ( SDKANIMATION_FRAME_DATA* )( m_pAnimationData + m_pAnimationHeader->AnimationDataOffset ); - UINT64 BaseOffset = sizeof( SDKANIMATION_FILE_HEADER ); for( UINT i = 0; i < m_pAnimationHeader->NumFrames; i++ ) { m_pAnimationFrameData[i].pAnimationData = ( SDKANIMATION_DATA* )( m_pAnimationData + diff --git a/Demo/DXUT/Optional/SDKmisc.cpp b/Demo/DXUT/Optional/SDKmisc.cpp index d95377f..5d9e9e8 100644 --- a/Demo/DXUT/Optional/SDKmisc.cpp +++ b/Demo/DXUT/Optional/SDKmisc.cpp @@ -5,7 +5,7 @@ // // Copyright (c) Microsoft Corporation. All rights reserved //-------------------------------------------------------------------------------------- -#include "dxut.h" +#include "DXUT.h" #include "SDKmisc.h" #include "DXUTres.h" #undef min // use __min instead diff --git a/Demo/DXUT/Optional/module.mk b/Demo/DXUT/Optional/module.mk new file mode 100644 index 0000000..cbc63e2 --- /dev/null +++ b/Demo/DXUT/Optional/module.mk @@ -0,0 +1,29 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + DXUTcamera.cpp \ + DXUTgui.cpp \ + DXUTres.cpp \ + DXUTsettingsdlg.cpp \ + DXUTShapes.cpp \ + SDKmesh.cpp \ + SDKmisc.cpp \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/DXUT/module.mk b/Demo/DXUT/module.mk new file mode 100644 index 0000000..89e258e --- /dev/null +++ b/Demo/DXUT/module.mk @@ -0,0 +1,26 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + Core \ + Optional \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) + +SRC_dxut:=$(foreach directory, $(DIRS), $(SRC_$(directory)) ) + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/Support/module.mk b/Demo/Support/module.mk new file mode 100644 index 0000000..152778e --- /dev/null +++ b/Demo/Support/module.mk @@ -0,0 +1,27 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + Camera.cpp \ + Copy.cpp \ + RenderTarget.cpp \ + Timer.cpp \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) +SRC_Support:=$(SRC_$(d)) + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/Demo/module.mk b/Demo/module.mk new file mode 100644 index 0000000..7e3aece --- /dev/null +++ b/Demo/module.mk @@ -0,0 +1,26 @@ +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) + + +SUBDIRS:= \ + DX9 \ + DX10 \ + DXUT \ + Support \ + # empty line + +DIRS:=$(addprefix $(d)/,$(SUBDIRS)) + +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +FILES:= \ + # empty line + + +SRC_$(d):=$(addprefix $(d)/,$(FILES)) + + +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/README.mingw b/README.mingw new file mode 100644 index 0000000..fad6261 --- /dev/null +++ b/README.mingw @@ -0,0 +1,28 @@ +MinGW build instructions +------------------------ + +Copy the following files from Microsoft DirectX SDK to /mingw + +d3d10.h +d3d10sdklayers.h +d3dx10async.h +d3dx10core.h +d3dx10.h +d3dx10math.h +D3DX10math.inl +d3dx10mesh.h +d3dx10tex.h +dxerr.h +dxsdkver.h +xinput.h + +If cross-compiling on Linux make sure case is correct. You might also have to edit some of the files to fix case in includes. + +To build: +cd mingw +make + +The build defaults to DX10 version. Copy /mingw/example.mk to /mingw/local.mk and edit that to make changes. You can override specific settings by including only the changed lines in local.mk. +If building natively on Windows (instead of cross-compiling) you need to set +CC:=gcc +CXX:=g++ diff --git a/mingw/Makefile b/mingw/Makefile new file mode 100644 index 0000000..802daa3 --- /dev/null +++ b/mingw/Makefile @@ -0,0 +1,12 @@ +## DO NOT TOUCH THIS FILE +# copy example.mk to local.mk and change that + +# load defaults +include example.mk + +# load customizations if exist +-include local.mk + + +VPATH=$(TOPDIR) +include $(TOPDIR)/module.mk diff --git a/mingw/example.mk b/mingw/example.mk new file mode 100644 index 0000000..0578c8a --- /dev/null +++ b/mingw/example.mk @@ -0,0 +1,56 @@ +# example of local configuration +# copy to local.mk + + +# location of source +TOPDIR:=.. + + +LTO:=n +ASAN:=n +TSAN:=n +UBSAN:=n + + +# pick one +DX9:=n +DX10:=y + + +# compiler options etc +CC:=i686-w64-mingw32-gcc +CXX:=i686-w64-mingw32-g++ +RC:=i686-w64-mingw32-windres +RCOUT:=-o + + +CFLAGS:=-I. +CFLAGS+=-fpermissive +CFLAGS+=-municode +CFLAGS+=-gstabs + +#CFLAGS+=-Wall -Wextra -Wshadow -Werror + +CFLAGS+=-w + +OPTFLAGS:=-O2 -mtune=generic + + +# lazy assignment because CFLAGS is changed later and to get TOPDIR right +CXXFLAGS=$(CFLAGS) -std=c++11 -I$(TOPDIR)/mingw -include $(TOPDIR)/mingw/mingw-dxfix.h + + +LDFLAGS:=-mwindows +LDFLAGS+=-municode +LDFLAGS+=-gstabs +LDFLAGS+=-static-libstdc++ -static-libgcc +LDLIBS:=-lcomctl32 -ld3d9 -ld3dx9 -ld3dx10 -ldxerr9 -ldxguid + + +LTOCFLAGS:=-flto +LTOLDFLAGS:=-flto + + +OBJSUFFIX:=.o +EXESUFFIX:=.exe +RESOURCESUFFIX:=.o diff --git a/mingw/mingw-dxfix.h b/mingw/mingw-dxfix.h new file mode 100644 index 0000000..c46617c --- /dev/null +++ b/mingw/mingw-dxfix.h @@ -0,0 +1,51 @@ +#ifndef DXFIX_H +#define DXFIX_H + + +// http://www.gamedev.net/topic/619239-directx-11-mingw-w64/ + + +#include +#include +#include + + +#define __in +#define __out +#define __inout +#define __in_bcount(x) +#define __out_bcount(x) +#define __in_ecount(x) +#define __out_ecount(x) +#define __in_ecount_opt(x) +#define __out_ecount_opt(x) +#define __in_bcount_opt(x) +#define __out_bcount_opt(x) +#define __in_opt +#define __inout_opt +#define __out_opt +#define __out_ecount_part_opt(x,y) +#define __deref_out +#define __deref_out_opt +#define __RPC__deref_out +#define __in_range(x, y) +#define __in_z +#define __in_z_opt +#define __noop {} +#define __reserved + + +#include +#include + + +typedef D3DXMATRIX D3DXMATRIXA16 __attribute__ ((aligned (16))); + + +__CRT_UUID_DECL(ID3D10Device,0x9B7E4C0F,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0xF6,0x89,0xF0); +__CRT_UUID_DECL(ID3D10ShaderResourceView,0x9B7E4C07,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0xF6,0x89,0xF0); +__CRT_UUID_DECL(ID3D10Texture2D,0x9B7E4C04,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0xF6,0x89,0xF0); +__CRT_UUID_DECL(ID3D10SwitchToRef,0x9B7E4E02,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0xF6,0x89,0xF0); + + +#endif // DXFIX_H diff --git a/module.mk b/module.mk new file mode 100644 index 0000000..b1b9482 --- /dev/null +++ b/module.mk @@ -0,0 +1,162 @@ +.PHONY: default all bindirs clean distclean + + +.SUFFIXES: + +#initialize these +PROGRAMS:= +ALLSRC:= +# directories which might contain object files +# used for both clean and bindirs +ALLDIRS:= + +default: all + + +ifeq ($(ASAN),y) + +OPTFLAGS+=-fsanitize=address +LDFLAGS_asan?=-fsanitize=address +LDFLAGS+=$(LDFLAGS_asan) + +endif + + +ifeq ($(TSAN),y) + +CFLAGS+=-DPIC +OPTFLAGS+=-fsanitize=thread -fpic +LDFLAGS_tsan?=-fsanitize=thread -pie +LDFLAGS+=$(LDFLAGS_tsan) + +endif + + +ifeq ($(UBSAN),y) + +OPTFLAGS+=-fsanitize=undefined -fno-sanitize-recover +LDFLAGS+=-fsanitize=undefined -fno-sanitize-recover +CXXFLAGS+=-frtti + +endif + + +ifeq ($(LTO),y) + +CFLAGS+=$(LTOCFLAGS) +LDFLAGS+=$(LTOLDFLAGS) $(OPTFLAGS) + +endif + + +ifeq ($(DX9),y) + +CFLAGS+=-DTIMER_DIRECTX_9 + +endif + + +CFLAGS+=-I$(TOPDIR)/Demo/DXUT/Core +CFLAGS+=-I$(TOPDIR)/Demo/DXUT/Optional +CFLAGS+=-I$(TOPDIR)/Demo/Support +CFLAGS+=-I$(TOPDIR)/Textures + +CFLAGS+=$(OPTFLAGS) + + +# (call directory-module, dirname) +define directory-module + +# save old +DIRS_$1:=$$(DIRS) + +dir:=$1 +include $(TOPDIR)/$1/module.mk + +ALLDIRS+=$1 + +ALLSRC+=$$(SRC_$1) + +# restore saved +DIRS:=$$(DIRS_$1) + +endef # directory-module + + +DIRS:= \ + Demo \ + # empty line +$(eval $(foreach directory, $(DIRS), $(call directory-module,$(directory)) )) + + +TARGETS:=$(foreach PROG,$(PROGRAMS),$(PROG)$(EXESUFFIX)) + +all: $(TARGETS) + + +# check if a directory needs to be created +# can't use targets with the same name as directory because unfortunate +# interaction with VPATH (targets always exists because source dir) +# $(call missingdir, progname) +define missingdir + +ifneq ($$(shell test -d $1 && echo n),n) +MISSINGDIRS+=$1 +endif + +endef # missingdir + +MISSINGDIRS:= +$(eval $(foreach d, $(ALLDIRS), $(call missingdir,$(d)) )) + + +# create directories which might contain object files +bindirs: +ifneq ($(MISSINGDIRS),) + mkdir -p $(MISSINGDIRS) +endif + + +clean: + rm -f $(TARGETS) $(foreach dir,$(ALLDIRS),$(dir)/*$(OBJSUFFIX)) + +distclean: clean + rm -f $(foreach dir,$(ALLDIRS),$(dir)/*.d) + -rmdir -p --ignore-fail-on-non-empty $(ALLDIRS) + + +# rules here + +%$(OBJSUFFIX): %.c | bindirs + $(CC) -c -MF $*.d -MP -MMD -std=gnu99 $(CFLAGS) -o $@ $< + + +%$(OBJSUFFIX): %.cpp | bindirs + $(CXX) -c -MF $*.d -MP -MMD $(CXXFLAGS) -o $@ $< + + +%$(RESOURCESUFFIX): %.rc | bindirs + $(RC) $(RCOUT)$@ $< + + +# $(call program-target, progname) +define program-target + +ALLSRC+=$$(filter %.c,$$($1_SRC)) +ALLSRC+=$$(filter %.cpp,$$($1_SRC)) + +$1_SRC+=$$(foreach module, $$($1_MODULES), $$(SRC_$$(module))) + +$1_OBJ:=$$($1_SRC:.c=$(OBJSUFFIX)) +$1_OBJ:=$$($1_OBJ:.cpp=$(OBJSUFFIX)) +$1_OBJ:=$$($1_OBJ:.rc=$(RESOURCESUFFIX)) +$1$(EXESUFFIX): $$($1_OBJ) | bindirs + $$(CXX) $(LDFLAGS) -o $$@ $$^ $$(foreach module, $$($1_MODULES), $$(LDLIBS_$$(module))) $$($1_LIBS) $(LDLIBS) + +endef # program-target + + +$(eval $(foreach PROGRAM,$(PROGRAMS), $(call program-target,$(PROGRAM)) ) ) + + +-include $(foreach FILE,$(ALLSRC),$(patsubst %.cpp,%.d,$(patsubst %.c,%.d,$(FILE)))) diff --git a/msvgcc/example.mk b/msvgcc/example.mk new file mode 100644 index 0000000..4bf3dae --- /dev/null +++ b/msvgcc/example.mk @@ -0,0 +1,66 @@ +# example of local configuration +# copy to local.mk + +TOPDIR:=.. + + +# default to debugging disabled +DEBUG:=n + +# pick one +DX9:=n +DX10:=y + +CXX:=msvgcc +CC:=msvgcc +RC:=i686-w64-mingw32-windres +RCOUT:=-o + +# /GR[-] enable C++ RTTI +# /WX treat warnings as errors +# /W set warning level (default n=1) +# /Wp64 enable 64 bit porting warnings ERROR: msvc includes not clean for this! +CFLAGS:=/WX +CFLAGS+=-I$(TOPDIR) +CFLAGS+=-D_CRT_SECURE_NO_DEPRECATE +CFLAGS+=-DUNICODE + + +# lazy assignment because CFLAGS is changed later +CXXFLAGS=$(CFLAGS) +CXXFLAGS+=/EHsc + + +LDFLAGS:=/nodefaultlib:libcmt.lib /subsystem:windows /WX +LDLIBS:=advapi32.lib comctl32.lib comdlg32.lib d3dx9.lib d3dx10.lib d3d9.lib +LDLIBS+=dsound.lib dxerr.lib gdi32.lib imm32.lib ole32.lib oleaut32.lib +LDLIBS+=user32.lib shell32.lib version.lib winmm.lib + +OBJSUFFIX:=.obj +EXESUFFIX:=.exe +RESOURCESUFFIX:=.res + + +# the fucker requires different libs for debugging... +ifeq ($(DEBUG),y) + +CFLAGS+=/MDd -D_DEBUG +# /RTC1 Enable fast checks (/RTCsu) +# /Z7 enable old-style debug info +OPTFLAGS+=/RTC1 /Z7 +LDFLAGS+=/nodefaultlib:msvcrt.lib +LDLIBS+=msvcrtd.lib + +else + +CFLAGS+=/MD -DNDEBUG +# /O2 maximize speed +# /Oi enable intrinsic functions +# /GA optimize for Windows Application +# /GF enable read-only string pooling +# /fp:fast "fast" floating-point model; results are less predictable +# /arch: +OPTFLAGS+=/O2 /Oi /GA /GF /fp:fast /arch:SSE2 +LDLIBS+=msvcrt.lib + +endif