CmDeferredGpuCommands.cpp 11 KB

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