CmD3D11RenderSystem.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. #include "CmD3D11RenderSystem.h"
  2. #include "CmRenderSystem.h"
  3. #include "CmDebug.h"
  4. #include "CmException.h"
  5. namespace CamelotEngine
  6. {
  7. D3D11Device& D3D11RenderSystem::getPrimaryDevice()
  8. {
  9. CM_EXCEPT(NotImplementedException, "Not implemented");
  10. }
  11. void D3D11RenderSystem::determineFSAASettings(UINT32 fsaa, const String& fsaaHint, DXGI_FORMAT format, DXGI_SAMPLE_DESC* outFSAASettings)
  12. {
  13. CM_EXCEPT(NotImplementedException, "Not implemented");
  14. /*
  15. bool ok = false;
  16. bool qualityHint = fsaaHint.find("Quality") != String::npos;
  17. size_t origFSAA = fsaa;
  18. bool tryCSAA = false;
  19. // NVIDIA, prefer CSAA if available for 8+
  20. // it would be tempting to use getCapabilities()->getVendor() == GPU_NVIDIA but
  21. // if this is the first window, caps will not be initialised yet
  22. if (mActiveD3DDriver->getAdapterIdentifier().VendorId == 0x10DE &&
  23. fsaa >= 8)
  24. {
  25. tryCSAA = true;
  26. }
  27. while (!ok)
  28. {
  29. // Deal with special cases
  30. if (tryCSAA)
  31. {
  32. // see http://developer.nvidia.com/object/coverage-sampled-aa.html
  33. switch(fsaa)
  34. {
  35. case 8:
  36. if (qualityHint)
  37. {
  38. outFSAASettings->Count = 8;
  39. outFSAASettings->Quality = 8;
  40. }
  41. else
  42. {
  43. outFSAASettings->Count = 4;
  44. outFSAASettings->Quality = 8;
  45. }
  46. break;
  47. case 16:
  48. if (qualityHint)
  49. {
  50. outFSAASettings->Count = 8;
  51. outFSAASettings->Quality = 16;
  52. }
  53. else
  54. {
  55. outFSAASettings->Count = 4;
  56. outFSAASettings->Quality = 16;
  57. }
  58. break;
  59. }
  60. }
  61. else // !CSAA
  62. {
  63. outFSAASettings->Count = fsaa == 0 ? 1 : fsaa;
  64. outFSAASettings->Quality = 0;
  65. }
  66. HRESULT hr;
  67. UINT outQuality;
  68. hr = mDevice->CheckMultisampleQualityLevels(
  69. format,
  70. outFSAASettings->Count,
  71. &outQuality);
  72. if (SUCCEEDED(hr) && (!tryCSAA || outQuality > outFSAASettings->Quality))
  73. {
  74. ok = true;
  75. }
  76. else
  77. {
  78. // downgrade
  79. if (tryCSAA && fsaa == 8)
  80. {
  81. // for CSAA, we'll try downgrading with quality mode at all samples.
  82. // then try without quality, then drop CSAA
  83. if (qualityHint)
  84. {
  85. // drop quality first
  86. qualityHint = false;
  87. }
  88. else
  89. {
  90. // drop CSAA entirely
  91. tryCSAA = false;
  92. }
  93. // return to original requested samples
  94. fsaa = static_cast<UINT32>(origFSAA);
  95. }
  96. else
  97. {
  98. // drop samples
  99. --fsaa;
  100. if (fsaa == 1)
  101. {
  102. // ran out of options, no FSAA
  103. fsaa = 0;
  104. ok = true;
  105. }
  106. }
  107. }
  108. } // while !ok
  109. */
  110. }
  111. bool D3D11RenderSystem::checkTextureFilteringSupported(TextureType ttype, PixelFormat format, int usage)
  112. {
  113. return true;
  114. }
  115. const String& D3D11RenderSystem::getName() const
  116. {
  117. static String strName("D3D11RenderSystem");
  118. return strName;
  119. }
  120. void D3D11RenderSystem::setSamplerState(UINT16 texUnit, const SamplerState& samplerState)
  121. {
  122. throw std::exception("The method or operation is not implemented.");
  123. }
  124. void D3D11RenderSystem::setBlendState(const BlendState& blendState)
  125. {
  126. throw std::exception("The method or operation is not implemented.");
  127. }
  128. void D3D11RenderSystem::setRasterizerState(const RasterizerState& rasterizerState)
  129. {
  130. throw std::exception("The method or operation is not implemented.");
  131. }
  132. void D3D11RenderSystem::setDepthStencilState(const DepthStencilState& depthStencilState)
  133. {
  134. throw std::exception("The method or operation is not implemented.");
  135. }
  136. void D3D11RenderSystem::setStencilRefValue(UINT32 refValue)
  137. {
  138. throw std::exception("The method or operation is not implemented.");
  139. }
  140. void D3D11RenderSystem::setTexture(UINT16 unit, bool enabled, const TexturePtr &texPtr)
  141. {
  142. throw std::exception("The method or operation is not implemented.");
  143. }
  144. void D3D11RenderSystem::disableTextureUnit(UINT16 texUnit)
  145. {
  146. throw std::exception("The method or operation is not implemented.");
  147. }
  148. void D3D11RenderSystem::beginFrame()
  149. {
  150. throw std::exception("The method or operation is not implemented.");
  151. }
  152. void D3D11RenderSystem::endFrame()
  153. {
  154. throw std::exception("The method or operation is not implemented.");
  155. }
  156. void D3D11RenderSystem::setViewport(const Viewport& vp)
  157. {
  158. throw std::exception("The method or operation is not implemented.");
  159. }
  160. void D3D11RenderSystem::setVertexDeclaration(VertexDeclarationPtr decl)
  161. {
  162. throw std::exception("The method or operation is not implemented.");
  163. }
  164. void D3D11RenderSystem::setVertexBufferBinding(VertexBufferBinding* binding)
  165. {
  166. throw std::exception("The method or operation is not implemented.");
  167. }
  168. void D3D11RenderSystem::bindGpuProgram(GpuProgramHandle prg)
  169. {
  170. throw std::exception("The method or operation is not implemented.");
  171. }
  172. void D3D11RenderSystem::unbindGpuProgram(GpuProgramType gptype)
  173. {
  174. throw std::exception("The method or operation is not implemented.");
  175. }
  176. void D3D11RenderSystem::bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params, UINT16 variabilityMask)
  177. {
  178. throw std::exception("The method or operation is not implemented.");
  179. }
  180. void D3D11RenderSystem::setScissorRect(UINT32 left /*= 0*/, UINT32 top /*= 0*/, UINT32 right /*= 800*/, UINT32 bottom /*= 600 */)
  181. {
  182. throw std::exception("The method or operation is not implemented.");
  183. }
  184. void D3D11RenderSystem::clearFrameBuffer(unsigned int buffers, const Color& color /*= Color::Black*/, float depth /*= 1.0f*/, unsigned short stencil /*= 0 */)
  185. {
  186. throw std::exception("The method or operation is not implemented.");
  187. }
  188. void D3D11RenderSystem::setRenderTarget(RenderTarget* target)
  189. {
  190. throw std::exception("The method or operation is not implemented.");
  191. }
  192. void D3D11RenderSystem::setClipPlanesImpl(const PlaneList& clipPlanes)
  193. {
  194. LOGWRN("This call will be ignored. DX11 uses shaders for setting clip planes.");
  195. }
  196. RenderSystemCapabilities* D3D11RenderSystem::createRenderSystemCapabilities() const
  197. {
  198. throw std::exception("The method or operation is not implemented.");
  199. }
  200. void D3D11RenderSystem::initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps)
  201. {
  202. throw std::exception("The method or operation is not implemented.");
  203. }
  204. CamelotEngine::String D3D11RenderSystem::getErrorDescription(long errorNumber) const
  205. {
  206. throw std::exception("The method or operation is not implemented.");
  207. }
  208. CamelotEngine::VertexElementType D3D11RenderSystem::getColorVertexElementType() const
  209. {
  210. return VET_COLOR_ABGR;
  211. }
  212. void D3D11RenderSystem::convertProjectionMatrix(const Matrix4& matrix, Matrix4& dest, bool forGpuProgram /*= false */)
  213. {
  214. dest = matrix;
  215. // Convert depth range from [-1,+1] to [0,1]
  216. dest[2][0] = (dest[2][0] + dest[3][0]) / 2;
  217. dest[2][1] = (dest[2][1] + dest[3][1]) / 2;
  218. dest[2][2] = (dest[2][2] + dest[3][2]) / 2;
  219. dest[2][3] = (dest[2][3] + dest[3][3]) / 2;
  220. if (!forGpuProgram)
  221. {
  222. // Convert right-handed to left-handed
  223. dest[0][2] = -dest[0][2];
  224. dest[1][2] = -dest[1][2];
  225. dest[2][2] = -dest[2][2];
  226. dest[3][2] = -dest[3][2];
  227. }
  228. }
  229. float D3D11RenderSystem::getHorizontalTexelOffset()
  230. {
  231. return 0.0f;
  232. }
  233. float D3D11RenderSystem::getVerticalTexelOffset()
  234. {
  235. return 0.0f;
  236. }
  237. float D3D11RenderSystem::getMinimumDepthInputValue()
  238. {
  239. return 0.0f;
  240. }
  241. float D3D11RenderSystem::getMaximumDepthInputValue()
  242. {
  243. return -1.0f;
  244. }
  245. }