Permalink
Browse files

Revamped and simplified the interface. We now have a single MLAA.h fo…

…r DX9 and DX10
  • Loading branch information...
iryoku committed Aug 25, 2011
1 parent 74d98bd commit 34868de8f9fa10237251f5930021f3421af0adaa
Showing with 1,438 additions and 1,179 deletions.
  1. +15 −0 .gitignore
  2. BIN AreaTex.dds
  3. 0 {dx10 → Demo/DX10}/Code/Copy.cpp
  4. 0 {dx10 → Demo/DX10}/Code/Copy.h
  5. +69 −18 {dx10 → Demo/DX10}/Code/Demo.cpp
  6. +65 −44 {dx10 → Demo/DX10}/Code/MLAA.cpp
  7. +28 −47 {dx10 → Demo/DX10}/Code/MLAA.h
  8. 0 {dx10 → Demo/DX10}/Code/RenderTarget.cpp
  9. 0 {dx10 → Demo/DX10}/Code/RenderTarget.h
  10. +1 −1 {dx9 → Demo/DX10}/Code/Timer.cpp
  11. +2 −0 {dx10 → Demo/DX10}/Code/Timer.h
  12. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUT.cpp
  13. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUT.h
  14. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTCore_2005.sln
  15. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTCore_2005.vcproj
  16. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTCore_2008.sln
  17. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTCore_2008.vcproj
  18. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTenum.cpp
  19. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTenum.h
  20. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTmisc.cpp
  21. 0 {dx10 → Demo/DX10}/DXUT/Core/DXUTmisc.h
  22. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTLockFreePipe.h
  23. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTOptional_2005.sln
  24. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTOptional_2005.vcproj
  25. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTOptional_2008.sln
  26. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTOptional_2008.vcproj
  27. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTShapes.cpp
  28. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTShapes.h
  29. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTcamera.cpp
  30. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTcamera.h
  31. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTgui.cpp
  32. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTgui.h
  33. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTguiIME.cpp
  34. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTguiIME.h
  35. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTres.cpp
  36. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTres.h
  37. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTsettingsdlg.cpp
  38. 0 {dx10 → Demo/DX10}/DXUT/Optional/DXUTsettingsdlg.h
  39. 0 {dx10 → Demo/DX10}/DXUT/Optional/ImeUi.cpp
  40. 0 {dx10 → Demo/DX10}/DXUT/Optional/ImeUi.h
  41. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKmesh.cpp
  42. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKmesh.h
  43. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKmisc.cpp
  44. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKmisc.h
  45. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKsound.cpp
  46. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKsound.h
  47. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKwavefile.cpp
  48. 0 {dx10 → Demo/DX10}/DXUT/Optional/SDKwavefile.h
  49. BIN {dx10 → Demo/DX10}/DXUT/Optional/directx.ico
  50. 0 {dx10 → Demo/DX10}/Demo DX10.sln
  51. +4 −7 {dx10 → Demo/DX10}/Demo.rc
  52. +5 −2 {dx10 → Demo/DX10}/Demo.vcxproj
  53. +3 −0 {dx10 → Demo/DX10}/Demo.vcxproj.filters
  54. BIN {dx10 → Demo/DX10}/Icon.ico
  55. BIN {dx10 → Demo/DX10}/Media/Images/Unigine01.dds
  56. BIN {dx10 → Demo/DX10}/Media/Images/Unigine01.png
  57. BIN {dx10 → Demo/DX10}/Media/Images/Unigine02.dds
  58. BIN {dx10 → Demo/DX10}/Media/Images/Unigine02.png
  59. BIN {dx10 → Demo/DX10}/Media/Images/Unigine03.dds
  60. BIN {dx10 → Demo/DX10}/Media/Images/Unigine03.png
  61. BIN {dx10 → Demo/DX10}/Media/Images/Unigine04.dds
  62. BIN {dx10 → Demo/DX10}/Media/Images/Unigine04.png
  63. BIN {dx10 → Demo/DX10}/Media/Images/Unigine05.dds
  64. BIN {dx10 → Demo/DX10}/Media/Images/Unigine05.png
  65. BIN {dx10 → Demo/DX10}/Media/Images/Unigine06.dds
  66. BIN {dx10 → Demo/DX10}/Media/Images/Unigine06.png
  67. BIN {dx10 → Demo/DX10}/Media/Images/Unigine07.dds
  68. BIN {dx10 → Demo/DX10}/Media/Images/Unigine07.png
  69. 0 {dx10 → Demo/DX10}/README.txt
  70. +222 −0 Demo/DX10/Shaders/MLAA.fx
  71. +1 −1 {dx9 → Demo/DX9}/Code/Demo.cpp
  72. +56 −44 {dx9 → Demo/DX9}/Code/MLAA.cpp
  73. +26 −19 {dx9 → Demo/DX9}/Code/MLAA.h
  74. 0 {dx10 → Demo/DX9}/Code/Timer.cpp
  75. 0 {dx9 → Demo/DX9}/Code/Timer.h
  76. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT.cpp
  77. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT.h
  78. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT_2008.sln
  79. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT_2008.vcproj
  80. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT_2010.sln
  81. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT_2010.vcxproj
  82. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUT_2010.vcxproj.filters
  83. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUTenum.cpp
  84. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUTenum.h
  85. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUTmisc.cpp
  86. 0 {dx9 → Demo/DX9}/DXUT/Core/DXUTmisc.h
  87. 0 {dx9 → Demo/DX9}/DXUT/Core/dpiaware.manifest
  88. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTLockFreePipe.h
  89. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTOpt_2008.sln
  90. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTOpt_2008.vcproj
  91. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTOpt_2010.sln
  92. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTOpt_2010.vcxproj
  93. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTOpt_2010.vcxproj.filters
  94. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTShapes.cpp
  95. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTShapes.h
  96. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTcamera.cpp
  97. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTcamera.h
  98. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTgui.cpp
  99. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTgui.h
  100. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTguiIME.cpp
  101. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTguiIME.h
  102. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTres.cpp
  103. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTres.h
  104. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTsettingsdlg.cpp
  105. 0 {dx9 → Demo/DX9}/DXUT/Optional/DXUTsettingsdlg.h
  106. 0 {dx9 → Demo/DX9}/DXUT/Optional/ImeUi.cpp
  107. 0 {dx9 → Demo/DX9}/DXUT/Optional/ImeUi.h
  108. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKmesh.cpp
  109. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKmesh.h
  110. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKmisc.cpp
  111. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKmisc.h
  112. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKsound.cpp
  113. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKsound.h
  114. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKwavefile.cpp
  115. 0 {dx9 → Demo/DX9}/DXUT/Optional/SDKwavefile.h
  116. BIN {dx9 → Demo/DX9}/DXUT/Optional/directx.ico
  117. 0 {dx9 → Demo/DX9}/Demo DX9.sln
  118. +10 −0 Demo/DX9/Demo.rc
  119. +5 −2 {dx9 → Demo/DX9}/Demo.vcxproj
  120. +3 −0 {dx9 → Demo/DX9}/Demo.vcxproj.filters
  121. 0 {dx9 → Demo/DX9}/Demo.vcxproj.user
  122. BIN {dx9 → Demo/DX9}/Icon.ico
  123. BIN {dx9 → Demo/DX9}/Media/Images/Unigine01.dds
  124. BIN {dx9 → Demo/DX9}/Media/Images/Unigine01.png
  125. +253 −0 Demo/DX9/Shaders/MLAA.fx
  126. +9 −11 {dx9 → }/LICENSE.txt
  127. +606 −0 MLAA.h
  128. +55 −11 dx10/LICENSE.txt → README.md
  129. BIN dx10/Media/SearchLengthMap.dds → SearchTex.dds
  130. BIN dx10/Media/AreaMap129.dds
  131. BIN dx10/Media/AreaMap17.dds
  132. BIN dx10/Media/AreaMap33.dds
  133. BIN dx10/Media/AreaMap65.dds
  134. BIN dx10/Media/AreaMap9.dds
  135. +0 −438 dx10/Shaders/MLAA.fx
  136. +0 −14 dx9/Demo.rc
  137. BIN dx9/Media/AreaMap129.dds
  138. BIN dx9/Media/AreaMap17.dds
  139. BIN dx9/Media/AreaMap33.dds
  140. BIN dx9/Media/AreaMap65.dds
  141. BIN dx9/Media/AreaMap9.dds
  142. BIN dx9/Media/SearchLengthMap.dds
  143. +0 −520 dx9/Shaders/MLAA.fx
View
@@ -0,0 +1,15 @@
+Demo/DX9/Debug/
+Demo/DX9/Release/
+Demo/DX9/ipch/
+Demo/DX9/Demo/
+Demo/DX9/Demo DX9.opensdf
+Demo/DX9/Demo DX9.sdf
+Demo/DX9/Demo DX9.suo
+
+Demo/DX10/Debug/
+Demo/DX10/Release/
+Demo/DX10/ipch/
+Demo/DX10/Demo DX10.opensdf
+Demo/DX10/Demo DX10.sdf
+Demo/DX10/Demo DX10.suo
+Demo/DX10/Demo.vcxproj.user
View
Binary file not shown.
File renamed without changes.
File renamed without changes.
@@ -35,7 +35,9 @@
#include "SDKmisc.h"
#include <sstream>
+#include <fstream>
#include <iomanip>
+#include <cmath>
#include "Timer.h"
#include "RenderTarget.h"
@@ -68,6 +70,9 @@ ID3D10ShaderResourceView *testDepthView = NULL;
bool showHud = true;
+bool benchmark = false;
+fstream benchmarkFile;
+
struct {
float threshold;
int distance;
@@ -90,6 +95,11 @@ struct {
#define IDC_THRESHOLD 12
+float round(float n) {
+ return floor(n + 0.5f);
+}
+
+
bool CALLBACK isDeviceAcceptable(UINT adapter, UINT output, D3D10_DRIVER_TYPE deviceType, DXGI_FORMAT format, bool windowed, void *context) {
return true;
}
@@ -142,9 +152,13 @@ void loadImage() {
}
}
- hud.GetComboBox(IDC_DETECTIONMODE)->SetEnabled(testDepthView != NULL);
- if (testDepthView == NULL)
- hud.GetComboBox(IDC_DETECTIONMODE)->SetSelectedByIndex(0);
+ int selectedIndex = hud.GetComboBox(IDC_DETECTIONMODE)->GetSelectedIndex();
+ hud.GetComboBox(IDC_DETECTIONMODE)->RemoveAllItems();
+ hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Luma edge det.", (LPVOID) 0);
+ hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Color edge det.", (LPVOID) 1);
+ if (testDepthView != NULL)
+ hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Depth edge det.", (LPVOID) 2);
+ hud.GetComboBox(IDC_DETECTIONMODE)->SetSelectedByIndex(selectedIndex);
}
@@ -180,9 +194,6 @@ HRESULT CALLBACK onCreateDevice(ID3D10Device *device, const DXGI_SURFACE_DESC *d
loadImage();
- if (testDepthView != NULL)
- hud.GetComboBox(IDC_DETECTIONMODE)->SetSelectedByIndex(1);
-
return S_OK;
}
@@ -212,7 +223,7 @@ void initMLAA() {
CDXUTSlider *slider = hud.GetSlider(IDC_MAXSEARCHSTEPS);
slider->GetRange(min, max);
scale = float(slider->GetValue()) / (max - min);
- mlaa->setMaxSearchSteps(int(scale * 16.0f));
+ mlaa->setMaxSearchSteps(int(round(scale * 98.0f)));
slider = hud.GetSlider(IDC_THRESHOLD);
slider->GetRange(min, max);
@@ -266,7 +277,7 @@ void drawHud(ID3D10Device *device, float elapsedTime) {
if (timer->isEnabled()) {
wstringstream s;
- s << setprecision(5) << std::fixed;
+ s << setprecision(2) << std::fixed;
s << *timer;
txtHelper->DrawTextLine(s.str().c_str());
}
@@ -285,6 +296,23 @@ void saveBackbuffer(ID3D10Device *device) {
}
+void doBenchmark() {
+ benchmarkFile << timer->getSection(L"MLAA") << endl;
+
+ int next = hud.GetComboBox(IDC_INPUT)->GetSelectedIndex() + 1;
+ int n = hud.GetComboBox(IDC_INPUT)->GetNumItems();
+ hud.GetComboBox(IDC_INPUT)->SetSelectedByIndex(next < n? next : n);
+ loadImage();
+
+ timer->reset();
+
+ if (next == n) {
+ benchmark = false;
+ benchmarkFile.close();
+ }
+}
+
+
void drawTextures(ID3D10Device *device) {
switch (int(hud.GetComboBox(IDC_VIEWMODE)->GetSelectedData())) {
case 1:
@@ -316,15 +344,20 @@ void CALLBACK onFrameRender(ID3D10Device *device, double time, float elapsedTime
// Run MLAA
if (hud.GetCheckBox(IDC_ANTIALIASING)->GetChecked()) {
- bool useDepth = int(hud.GetComboBox(IDC_DETECTIONMODE)->GetSelectedData()) == 1;
+ MLAA::Input input = MLAA::Input(int(hud.GetComboBox(IDC_DETECTIONMODE)->GetSelectedData()));
int n = hud.GetCheckBox(IDC_PROFILE)->GetChecked()? timer->getRepetitionsCount() : 1;
timer->start();
for (int i = 0; i < n; i++) { // This loop is just for profiling.
- if (useDepth)
- mlaa->goDepth(*depthBufferRenderTarget, *finalRenderTargetSRGB, *backbufferRenderTarget, *depthStencil);
- else
- mlaa->goColor(*finalRenderTarget, *finalRenderTargetSRGB, *backbufferRenderTarget, *depthStencil);
+ switch (input) {
+ case MLAA::INPUT_LUMA:
+ case MLAA::INPUT_COLOR:
+ mlaa->go(*finalRenderTarget, *finalRenderTargetSRGB, *backbufferRenderTarget, *depthStencil, input);
+ break;
+ case MLAA::INPUT_DEPTH:
+ mlaa->go(*depthBufferRenderTarget, *finalRenderTargetSRGB, *backbufferRenderTarget, *depthStencil, input);
+ break;
+ }
}
timer->clock(L"MLAA");
} else {
@@ -336,6 +369,9 @@ void CALLBACK onFrameRender(ID3D10Device *device, double time, float elapsedTime
exit(0);
}
+ if (benchmark)
+ doBenchmark();
+
DXUT_BeginPerfEvent(DXUT_PERFEVENTCOLOR, L"HUD / Stats"); // These events are to help PIX identify what the code is doing
drawTextures(device);
drawHud(device, elapsedTime);
@@ -362,6 +398,7 @@ LRESULT CALLBACK msgProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, bool
void CALLBACK keyboardProc(UINT nchar, bool keyDown, bool altDown, void *context) {
+ if (keyDown)
switch (nchar) {
case VK_TAB: {
if (keyDown)
@@ -385,6 +422,19 @@ void CALLBACK keyboardProc(UINT nchar, bool keyDown, bool altDown, void *context
}
break;
}
+ case 'X':
+ hud.GetCheckBox(IDC_PROFILE)->SetChecked(!hud.GetCheckBox(IDC_PROFILE)->GetChecked());
+ timer->setEnabled(hud.GetCheckBox(IDC_PROFILE)->GetChecked());
+ break;
+ case 'Z':
+ hud.GetCheckBox(IDC_ANTIALIASING)->SetChecked(!hud.GetCheckBox(IDC_ANTIALIASING)->GetChecked());
+ break;
+ case 'P':
+ hud.GetCheckBox(IDC_PROFILE)->SetChecked(true);
+ timer->setEnabled(true);
+ benchmark = true;
+ benchmarkFile.open("Benchmark.txt", ios_base::out);
+ break;
}
}
@@ -529,10 +579,10 @@ void CALLBACK onGUIEvent(UINT event, int id, CDXUTControl *control, void *contex
slider->GetRange(min, max);
float scale = float(slider->GetValue()) / (max - min);
- mlaa->setMaxSearchSteps(int(scale * 16.0f));
+ mlaa->setMaxSearchSteps(int(round(scale * 98.0f)));
wstringstream s;
- s << L"Max Search Steps: " << int(scale * 16.0f);
+ s << L"Max Search Steps: " << int(round(scale * 98.0f));
hud.GetStatic(IDC_MAXSEARCHSTEPS_LABEL)->SetText(s.str().c_str());
}
break;
@@ -568,8 +618,9 @@ void initApp() {
hud.AddButton(IDC_LOADIMAGE, L"Load image", 35, iY += 24, HUD_WIDTH, 22);
hud.AddComboBox(IDC_DETECTIONMODE, 35, iY += 24, HUD_WIDTH, 22, 0, false);
- hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Color edge det.", (LPVOID) 0);
- hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Depth edge det.", (LPVOID) 1);
+ hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Luma edge det.", (LPVOID) 0);
+ hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Color edge det.", (LPVOID) 1);
+ hud.GetComboBox(IDC_DETECTIONMODE)->AddItem(L"Depth edge det.", (LPVOID) 2);
hud.AddComboBox(IDC_VIEWMODE, 35, iY += 24, HUD_WIDTH, 22, 0, false);
hud.GetComboBox(IDC_VIEWMODE)->AddItem(L"View image", (LPVOID) 0);
@@ -589,7 +640,7 @@ void initApp() {
wstringstream s;
s << L"Max Search Steps: " << commandlineOptions.distance;
hud.AddStatic(IDC_MAXSEARCHSTEPS_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22);
- hud.AddSlider(IDC_MAXSEARCHSTEPS, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.distance / 16.0f));
+ hud.AddSlider(IDC_MAXSEARCHSTEPS, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.distance / 98.0f));
s = wstringstream();
s << L"Threshold: " << commandlineOptions.threshold;
Oops, something went wrong.

0 comments on commit 34868de

Please sign in to comment.