CmDeferredGpuCommands.cpp 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. #include "CmDeferredGpuCommands.h"
  2. #include "CmRenderSystem.h"
  3. namespace CamelotEngine
  4. {
  5. DeferredGpuCommand::DeferredGpuCommand()
  6. { }
  7. DfrdRenderGpuCommand::DfrdRenderGpuCommand(RenderOperation& _renderOp)
  8. :renderOp(_renderOp)
  9. { }
  10. void DfrdRenderGpuCommand::submitCommand(RenderSystem* rs)
  11. {
  12. rs->render(renderOp);
  13. }
  14. DfrdBindGpuProgramCommand::DfrdBindGpuProgramCommand(GpuProgramPtr _gpuProgram)
  15. :gpuProgram(_gpuProgram)
  16. { }
  17. void DfrdBindGpuProgramCommand::submitCommand(RenderSystem* rs)
  18. {
  19. rs->bindGpuProgram(gpuProgram.get());
  20. }
  21. DfrdBindGpuParamsCommand::DfrdBindGpuParamsCommand(GpuProgramType _type, GpuProgramParametersPtr& _progParams)
  22. :type(_type), progParams(_progParams)
  23. { }
  24. void DfrdBindGpuParamsCommand::submitCommand(RenderSystem* rs)
  25. {
  26. rs->bindGpuProgramParameters(type, progParams, GPV_ALL);
  27. }
  28. DfrdInvVertWindingCommand::DfrdInvVertWindingCommand(bool _invert)
  29. :invert(_invert)
  30. { }
  31. void DfrdInvVertWindingCommand::submitCommand(RenderSystem* rs)
  32. {
  33. rs->setInvertVertexWinding(invert);
  34. }
  35. DfrdScissorTestCommand::DfrdScissorTestCommand(bool _enabled, size_t _left, size_t _top, size_t _right, size_t _bottom)
  36. :enabled(_enabled), left(_left), top(_top), right(_right), bottom(_bottom)
  37. { }
  38. void DfrdScissorTestCommand::submitCommand(RenderSystem* rs)
  39. {
  40. rs->setScissorTest(enabled, left, top, right, bottom);
  41. }
  42. DfrdStencilBufferParamsCommand::DfrdStencilBufferParamsCommand(CompareFunction _func, UINT32 _refValue, UINT32 _mask,
  43. StencilOperation _stencilFailOp, StencilOperation _depthFailOp,
  44. StencilOperation _passOp, bool _twoSidedOperation)
  45. :func(_func), refValue(_refValue), mask(_mask), stencilFailOp(_stencilFailOp), depthFailOp(_depthFailOp),
  46. passOp(_passOp), twoSidedOperation(_twoSidedOperation)
  47. { }
  48. void DfrdStencilBufferParamsCommand::submitCommand(RenderSystem* rs)
  49. {
  50. rs->setStencilBufferParams(func, refValue, mask, stencilFailOp, depthFailOp, passOp, twoSidedOperation);
  51. }
  52. // TODO !
  53. DfrdVertexDeclCommand::DfrdVertexDeclCommand()
  54. { }
  55. void DfrdVertexDeclCommand::submitCommand(RenderSystem* rs)
  56. {
  57. }
  58. // TODO !
  59. DfrdVertBufferBindCommand::DfrdVertBufferBindCommand()
  60. { }
  61. void DfrdVertBufferBindCommand::submitCommand(RenderSystem* rs)
  62. {
  63. }
  64. DfrdPolygonModeCommand::DfrdPolygonModeCommand(PolygonMode _mode)
  65. :mode(_mode)
  66. { }
  67. void DfrdPolygonModeCommand::submitCommand(RenderSystem* rs)
  68. {
  69. rs->setPolygonMode(mode);
  70. }
  71. DfrdStencilCheckCommand::DfrdStencilCheckCommand(bool _enabled)
  72. :enabled(_enabled)
  73. { }
  74. void DfrdStencilCheckCommand::submitCommand(RenderSystem* rs)
  75. {
  76. rs->setStencilCheckEnabled(enabled);
  77. }
  78. DfrdWaitForVerticalBlankCommand::DfrdWaitForVerticalBlankCommand(bool _enabled)
  79. :enabled(_enabled)
  80. { }
  81. void DfrdWaitForVerticalBlankCommand::submitCommand(RenderSystem* rs)
  82. {
  83. rs->setWaitForVerticalBlank(enabled);
  84. }
  85. DfrdTextureUnitSettingsCommand::DfrdTextureUnitSettingsCommand(size_t _texUnit, const TexturePtr& _tex,
  86. const SamplerState& _samplerState)
  87. :texUnit(_texUnit), tex(_tex), samplerState(_samplerState)
  88. { }
  89. void DfrdTextureUnitSettingsCommand::submitCommand(RenderSystem* rs)
  90. {
  91. rs->setTextureUnitSettings(texUnit, tex, samplerState);
  92. }
  93. DfrdPointParamsCommand::DfrdPointParamsCommand(float _size, bool _attenuationEnabled,
  94. float _constant, float _linear, float _quadratic, float _minSize, float _maxSize)
  95. :size(_size), attenuationEnabled(_attenuationEnabled), constant(_constant), linear(_linear),
  96. quadratic(_quadratic), minSize(_minSize), maxSize(_maxSize)
  97. { }
  98. void DfrdPointParamsCommand::submitCommand(RenderSystem* rs)
  99. {
  100. rs->setPointParameters(size, attenuationEnabled, constant, linear, quadratic, minSize, maxSize);
  101. }
  102. DfrdTextureCommand::DfrdTextureCommand(size_t _texUnit, bool _enabled, const TexturePtr& _tex)
  103. :texUnit(_texUnit), enabled(_enabled), tex(_tex)
  104. { }
  105. void DfrdTextureCommand::submitCommand(RenderSystem* rs)
  106. {
  107. rs->setTexture(texUnit, enabled, tex);
  108. }
  109. DfrdVertexTextureCommand::DfrdVertexTextureCommand(size_t _texUnit, const TexturePtr& _tex)
  110. :texUnit(_texUnit), tex(_tex)
  111. { }
  112. void DfrdVertexTextureCommand::submitCommand(RenderSystem* rs)
  113. {
  114. rs->setVertexTexture(texUnit, tex);
  115. }
  116. DfrdTextureFilteringCommand::DfrdTextureFilteringCommand(size_t _texUnit, FilterType _ftype, FilterOptions _filter)
  117. :texUnit(_texUnit), ftype(_ftype), filter(_filter)
  118. { }
  119. void DfrdTextureFilteringCommand::submitCommand(RenderSystem* rs)
  120. {
  121. rs->setTextureFiltering(texUnit, ftype, filter);
  122. }
  123. DfrdTextureAnisotropyCommand::DfrdTextureAnisotropyCommand(size_t _texUnit, unsigned int _maxAnisotropy)
  124. :texUnit(_texUnit), maxAnisotropy(_maxAnisotropy)
  125. { }
  126. void DfrdTextureAnisotropyCommand::submitCommand(RenderSystem* rs)
  127. {
  128. rs->setTextureAnisotropy(texUnit, maxAnisotropy);
  129. }
  130. DfrdTextureAddrModeCommand::DfrdTextureAddrModeCommand(size_t _texUnit, const SamplerState::UVWAddressingMode& _uvw)
  131. :texUnit(_texUnit), uvw(_uvw)
  132. { }
  133. void DfrdTextureAddrModeCommand::submitCommand(RenderSystem* rs)
  134. {
  135. rs->setTextureAddressingMode(texUnit, uvw);
  136. }
  137. DfrdTextureBorderColorCommand::DfrdTextureBorderColorCommand(size_t _texUnit, const Color& _color)
  138. :texUnit(_texUnit), color(_color)
  139. { }
  140. void DfrdTextureBorderColorCommand::submitCommand(RenderSystem* rs)
  141. {
  142. rs->setTextureBorderColor(texUnit, color);
  143. }
  144. DfrdTextureMipBiasCommand::DfrdTextureMipBiasCommand(size_t _texUnit, float _bias)
  145. :texUnit(_texUnit), bias(_bias)
  146. { }
  147. void DfrdTextureMipBiasCommand::submitCommand(RenderSystem* rs)
  148. {
  149. rs->setTextureMipmapBias(texUnit, bias);
  150. }
  151. DfrdSceneBlendingCommand::DfrdSceneBlendingCommand(SceneBlendFactor _sourceFactor,
  152. SceneBlendFactor _destFactor, SceneBlendOperation _op)
  153. :sourceFactor(_sourceFactor), destFactor(_destFactor), op(_op)
  154. { }
  155. void DfrdSceneBlendingCommand::submitCommand(RenderSystem* rs)
  156. {
  157. rs->setSceneBlending(sourceFactor, destFactor, op);
  158. }
  159. DfrdSeparateSceneBlendingCommand::DfrdSeparateSceneBlendingCommand(SceneBlendFactor _sourceFactor,
  160. SceneBlendFactor _destFactor, SceneBlendFactor _sourceFactorAlpha,
  161. SceneBlendFactor _destFactorAlpha, SceneBlendOperation _op,
  162. SceneBlendOperation _alphaOp)
  163. :sourceFactor(_sourceFactor), destFactor(_destFactor), sourceFactorAlpha(_sourceFactorAlpha),
  164. destFactorAlpha(_destFactorAlpha), op(_op), alphaOp(_alphaOp)
  165. { }
  166. void DfrdSeparateSceneBlendingCommand::submitCommand(RenderSystem* rs)
  167. {
  168. rs->setSeparateSceneBlending(sourceFactor, destFactor, sourceFactorAlpha, destFactorAlpha, op, alphaOp);
  169. }
  170. DfrdAlphaRejectParamsCommand::DfrdAlphaRejectParamsCommand(CompareFunction _func,
  171. unsigned char _value, bool _alphaToCoverage)
  172. :func(_func), value(_value), alphaToCoverage(_alphaToCoverage)
  173. { }
  174. void DfrdAlphaRejectParamsCommand::submitCommand(RenderSystem* rs)
  175. {
  176. rs->setAlphaRejectSettings(func, value, alphaToCoverage);
  177. }
  178. // TODO
  179. DfrdViewportCommand::DfrdViewportCommand()
  180. { }
  181. void DfrdViewportCommand::submitCommand(RenderSystem* rs)
  182. {
  183. }
  184. DfrdCullingCommand::DfrdCullingCommand(CullingMode _mode)
  185. :mode(_mode)
  186. { }
  187. void DfrdCullingCommand::submitCommand(RenderSystem* rs)
  188. {
  189. rs->setCullingMode(mode);
  190. }
  191. DfrdDepthBufferParamsCommand::DfrdDepthBufferParamsCommand(bool _depthTest, bool _depthWrite,
  192. CompareFunction _depthFunction)
  193. :depthTest(_depthTest)
  194. { }
  195. void DfrdDepthBufferParamsCommand::submitCommand(RenderSystem* rs)
  196. {
  197. rs->setDepthBufferParams(depthTest, depthWrite, depthFunction);
  198. }
  199. DfrdDepthBufferCheckCommand::DfrdDepthBufferCheckCommand(bool _enabled)
  200. :enabled(_enabled)
  201. { }
  202. void DfrdDepthBufferCheckCommand::submitCommand(RenderSystem* rs)
  203. {
  204. rs->setDepthBufferCheckEnabled(enabled);
  205. }
  206. DfrdDepthBufferWriteCommand::DfrdDepthBufferWriteCommand(bool _enabled)
  207. :enabled(_enabled)
  208. { }
  209. void DfrdDepthBufferWriteCommand::submitCommand(RenderSystem* rs)
  210. {
  211. rs->setDepthBufferWriteEnabled(enabled);
  212. }
  213. DfrdDepthBufferFuncCommand::DfrdDepthBufferFuncCommand(CompareFunction _func)
  214. :func(_func)
  215. { }
  216. void DfrdDepthBufferFuncCommand::submitCommand(RenderSystem* rs)
  217. {
  218. rs->setDepthBufferFunction(func);
  219. }
  220. DfrdDepthBiasCommand::DfrdDepthBiasCommand(float _constantBias, float _slopeScaleBias)
  221. :constantBias(_constantBias), slopeScaleBias(_slopeScaleBias)
  222. { }
  223. void DfrdDepthBiasCommand::submitCommand(RenderSystem* rs)
  224. {
  225. rs->setDepthBias(constantBias, slopeScaleBias);
  226. }
  227. DfrdColorBufferWriteCommand::DfrdColorBufferWriteCommand(bool _red, bool _green, bool _blue, bool _alpha)
  228. :red(_red), green(_green), blue(_blue), alpha(_alpha)
  229. { }
  230. void DfrdColorBufferWriteCommand::submitCommand(RenderSystem* rs)
  231. {
  232. rs->setColorBufferWriteEnabled(red, green, blue, alpha);
  233. }
  234. DfrdDisableTextureUnitCommand::DfrdDisableTextureUnitCommand(size_t _texUnit)
  235. :texUnit(_texUnit)
  236. { }
  237. void DfrdDisableTextureUnitCommand::submitCommand(RenderSystem* rs)
  238. {
  239. rs->disableTextureUnit(texUnit);
  240. }
  241. DfrdDisableTextureUnitsFromCommand::DfrdDisableTextureUnitsFromCommand(size_t _texUnit)
  242. :texUnit(_texUnit)
  243. { }
  244. void DfrdDisableTextureUnitsFromCommand::submitCommand(RenderSystem* rs)
  245. {
  246. rs->disableTextureUnitsFrom(texUnit);
  247. }
  248. DfrdBeginFrameCommand::DfrdBeginFrameCommand()
  249. { }
  250. void DfrdBeginFrameCommand::submitCommand(RenderSystem* rs)
  251. {
  252. rs->beginFrame();
  253. }
  254. DfrdEndFrameCommand::DfrdEndFrameCommand()
  255. { }
  256. void DfrdEndFrameCommand::submitCommand(RenderSystem* rs)
  257. {
  258. rs->endFrame();
  259. }
  260. DfrdClearFrameBufferCommand::DfrdClearFrameBufferCommand(unsigned int _buffers,
  261. const Color& _color, float _depth, unsigned short _stencil)
  262. :buffers(_buffers), color(_color), depth(_depth), stencil(_stencil)
  263. { }
  264. void DfrdClearFrameBufferCommand::submitCommand(RenderSystem* rs)
  265. {
  266. rs->clearFrameBuffer(buffers, color, depth, stencil);
  267. }
  268. }