GraphicsStateTracker.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Gr/BackendCommon/Common.h>
  7. #include <AnKi/Gr/ShaderProgram.h>
  8. namespace anki {
  9. /// @addtogroup graphics
  10. /// @{
  11. /// This is the way the command buffer sets the graphics state.
  12. class GraphicsStateTracker
  13. {
  14. friend class GraphicsPipelineFactory;
  15. public:
  16. void bindVertexBuffer(U32 binding, VertexStepRate stepRate
  17. #if ANKI_GR_BACKEND_VULKAN
  18. ,
  19. U32 stride
  20. #endif
  21. )
  22. {
  23. auto& vertState = m_staticState.m_vert;
  24. if(!vertState.m_bindingsSetMask.get(binding) || vertState.m_bindings[binding].m_stepRate != stepRate
  25. #if ANKI_GR_BACKEND_VULKAN
  26. || vertState.m_bindings[binding].m_stride != stride
  27. #endif
  28. )
  29. {
  30. vertState.m_bindingsSetMask.set(binding);
  31. #if ANKI_GR_BACKEND_VULKAN
  32. vertState.m_bindings[binding].m_stride = stride;
  33. #endif
  34. vertState.m_bindings[binding].m_stepRate = stepRate;
  35. m_hashes.m_vert = 0;
  36. }
  37. }
  38. void setVertexAttribute(VertexAttributeSemantic attribute, U32 buffBinding, Format fmt, U32 relativeOffset)
  39. {
  40. const VertexAttributeSemanticBit mask = VertexAttributeSemanticBit(1u << attribute);
  41. auto& attr = m_staticState.m_vert.m_attribs[attribute];
  42. if(!(m_staticState.m_vert.m_attribsSetMask & mask) || attr.m_fmt != fmt || attr.m_binding != buffBinding
  43. || attr.m_relativeOffset != relativeOffset)
  44. {
  45. attr.m_fmt = fmt;
  46. attr.m_binding = buffBinding;
  47. attr.m_relativeOffset = relativeOffset;
  48. m_staticState.m_vert.m_attribsSetMask |= mask;
  49. m_hashes.m_vert = 0;
  50. }
  51. }
  52. void setFillMode(FillMode mode)
  53. {
  54. ANKI_ASSERT(mode < FillMode::kCount);
  55. if(m_staticState.m_rast.m_fillMode != mode)
  56. {
  57. m_staticState.m_rast.m_fillMode = mode;
  58. m_hashes.m_rast = 0;
  59. }
  60. }
  61. void setCullMode(FaceSelectionBit mode)
  62. {
  63. if(m_staticState.m_rast.m_cullMode != mode)
  64. {
  65. m_staticState.m_rast.m_cullMode = mode;
  66. m_hashes.m_rast = 0;
  67. }
  68. }
  69. void setStencilOperations(FaceSelectionBit face, StencilOperation stencilFail, StencilOperation stencilPassDepthFail,
  70. StencilOperation stencilPassDepthPass)
  71. {
  72. ANKI_ASSERT(face != FaceSelectionBit::kNone);
  73. auto& front = m_staticState.m_stencil.m_face[0];
  74. if(!!(face & FaceSelectionBit::kFront)
  75. && (front.m_fail != stencilFail || front.m_stencilPassDepthFail != stencilPassDepthFail
  76. || front.m_stencilPassDepthPass != stencilPassDepthPass))
  77. {
  78. front.m_fail = stencilFail;
  79. front.m_stencilPassDepthFail = stencilPassDepthFail;
  80. front.m_stencilPassDepthPass = stencilPassDepthPass;
  81. m_hashes.m_depthStencil = 0;
  82. }
  83. auto& back = m_staticState.m_stencil.m_face[1];
  84. if(!!(face & FaceSelectionBit::kBack)
  85. && (back.m_fail != stencilFail || back.m_stencilPassDepthFail != stencilPassDepthFail
  86. || back.m_stencilPassDepthPass != stencilPassDepthPass))
  87. {
  88. back.m_fail = stencilFail;
  89. back.m_stencilPassDepthFail = stencilPassDepthFail;
  90. back.m_stencilPassDepthPass = stencilPassDepthPass;
  91. m_hashes.m_depthStencil = 0;
  92. }
  93. }
  94. void setStencilCompareOperation(FaceSelectionBit face, CompareOperation comp)
  95. {
  96. ANKI_ASSERT(face != FaceSelectionBit::kNone);
  97. if(!!(face & FaceSelectionBit::kFront) && m_staticState.m_stencil.m_face[0].m_compare != comp)
  98. {
  99. m_staticState.m_stencil.m_face[0].m_compare = comp;
  100. m_hashes.m_depthStencil = 0;
  101. }
  102. if(!!(face & FaceSelectionBit::kBack) && m_staticState.m_stencil.m_face[1].m_compare != comp)
  103. {
  104. m_staticState.m_stencil.m_face[1].m_compare = comp;
  105. m_hashes.m_depthStencil = 0;
  106. }
  107. }
  108. void setStencilCompareMask(FaceSelectionBit face, U32 mask)
  109. {
  110. ANKI_ASSERT(face != FaceSelectionBit::kNone);
  111. #if ANKI_GR_BACKEND_VULKAN
  112. if(!!(face & FaceSelectionBit::kFront) && m_dynState.m_stencilFaces[0].m_compareMask != mask)
  113. {
  114. m_dynState.m_stencilFaces[0].m_compareMask = mask;
  115. m_dynState.m_stencilCompareMaskDirty = true;
  116. }
  117. if(!!(face & FaceSelectionBit::kBack) && m_dynState.m_stencilFaces[1].m_compareMask != mask)
  118. {
  119. m_dynState.m_stencilFaces[1].m_compareMask = mask;
  120. m_dynState.m_stencilCompareMaskDirty = true;
  121. }
  122. #else
  123. if(!!(face & FaceSelectionBit::kFront) && m_staticState.m_stencil.m_face[0].m_compareMask != mask)
  124. {
  125. m_staticState.m_stencil.m_face[0].m_compareMask = mask;
  126. m_hashes.m_depthStencil = 0;
  127. }
  128. if(!!(face & FaceSelectionBit::kBack) && m_staticState.m_stencil.m_face[1].m_compareMask != mask)
  129. {
  130. m_staticState.m_stencil.m_face[1].m_compareMask = mask;
  131. m_hashes.m_depthStencil = 0;
  132. }
  133. #endif
  134. }
  135. void setStencilWriteMask(FaceSelectionBit face, U32 mask)
  136. {
  137. ANKI_ASSERT(face != FaceSelectionBit::kNone);
  138. #if ANKI_GR_BACKEND_VULKAN
  139. if(!!(face & FaceSelectionBit::kFront) && m_dynState.m_stencilFaces[0].m_writeMask != mask)
  140. {
  141. m_dynState.m_stencilFaces[0].m_writeMask = mask;
  142. m_dynState.m_stencilWriteMaskDirty = true;
  143. }
  144. if(!!(face & FaceSelectionBit::kBack) && m_dynState.m_stencilFaces[1].m_writeMask != mask)
  145. {
  146. m_dynState.m_stencilFaces[1].m_writeMask = mask;
  147. m_dynState.m_stencilWriteMaskDirty = true;
  148. }
  149. #else
  150. if(!!(face & FaceSelectionBit::kFront) && m_staticState.m_stencil.m_face[0].m_writeMask != mask)
  151. {
  152. m_staticState.m_stencil.m_face[0].m_writeMask = mask;
  153. m_hashes.m_depthStencil = 0;
  154. }
  155. if(!!(face & FaceSelectionBit::kBack) && m_staticState.m_stencil.m_face[1].m_writeMask != mask)
  156. {
  157. m_staticState.m_stencil.m_face[1].m_writeMask = mask;
  158. m_hashes.m_depthStencil = 0;
  159. }
  160. #endif
  161. }
  162. void setStencilReference(FaceSelectionBit face, U32 ref)
  163. {
  164. ANKI_ASSERT(face != FaceSelectionBit::kNone);
  165. ANKI_ASSERT((ANKI_GR_BACKEND_VULKAN || face == FaceSelectionBit::kFrontAndBack) && "D3D only supports a single value for both sides");
  166. if(!!(face & FaceSelectionBit::kFront) && m_dynState.m_stencilFaces[0].m_ref != ref)
  167. {
  168. m_dynState.m_stencilFaces[0].m_ref = ref;
  169. m_dynState.m_stencilRefDirty = true;
  170. }
  171. if(!!(face & FaceSelectionBit::kBack) && m_dynState.m_stencilFaces[1].m_ref != ref)
  172. {
  173. m_dynState.m_stencilFaces[1].m_ref = ref;
  174. m_dynState.m_stencilRefDirty = true;
  175. }
  176. }
  177. void setDepthWrite(Bool enable)
  178. {
  179. if(m_staticState.m_depth.m_writeEnabled != enable)
  180. {
  181. m_staticState.m_depth.m_writeEnabled = enable;
  182. m_hashes.m_depthStencil = 0;
  183. }
  184. }
  185. void setDepthCompareOperation(CompareOperation op)
  186. {
  187. ANKI_ASSERT(op < CompareOperation::kCount);
  188. if(m_staticState.m_depth.m_compare != op)
  189. {
  190. m_staticState.m_depth.m_compare = op;
  191. m_hashes.m_depthStencil = 0;
  192. }
  193. }
  194. void setPolygonOffset(F32 factor, F32 units)
  195. {
  196. #if ANKI_GR_BACKEND_VULKAN
  197. if(m_dynState.m_depthBiasConstantFactor != factor || m_dynState.m_depthBiasSlopeFactor != units)
  198. {
  199. m_dynState.m_depthBiasConstantFactor = factor;
  200. m_dynState.m_depthBiasSlopeFactor = units;
  201. m_dynState.m_depthBiasClamp = 0.0f;
  202. m_dynState.m_depthBiasDirty = true;
  203. m_staticState.m_rast.m_depthBiasEnabled = factor != 0.0f || units != 0.0f;
  204. }
  205. #else
  206. if(m_staticState.m_rast.m_depthBias != factor || m_staticState.m_rast.m_slopeScaledDepthBias != units)
  207. {
  208. m_staticState.m_rast.m_depthBias = factor;
  209. m_staticState.m_rast.m_slopeScaledDepthBias = units;
  210. m_staticState.m_rast.m_depthBiasClamp = 0.0f;
  211. m_hashes.m_rast = 0;
  212. }
  213. #endif
  214. }
  215. void setAlphaToCoverage(Bool enable)
  216. {
  217. if(m_staticState.m_blend.m_alphaToCoverage != enable)
  218. {
  219. m_staticState.m_blend.m_alphaToCoverage = enable;
  220. m_hashes.m_blend = 0;
  221. }
  222. }
  223. void setBlendFactors(U32 attachment, BlendFactor srcRgb, BlendFactor dstRgb, BlendFactor srcA, BlendFactor dstA)
  224. {
  225. auto& rt = m_staticState.m_blend.m_colorRts[attachment];
  226. if(rt.m_srcRgb != srcRgb || rt.m_srcA != srcA || rt.m_dstRgb != dstRgb || rt.m_dstA != dstA)
  227. {
  228. rt.m_srcRgb = srcRgb;
  229. rt.m_srcA = srcA;
  230. rt.m_dstRgb = dstRgb;
  231. rt.m_dstA = dstA;
  232. m_hashes.m_blend = 0;
  233. }
  234. }
  235. void setBlendOperation(U32 attachment, BlendOperation funcRgb, BlendOperation funcA)
  236. {
  237. auto& rt = m_staticState.m_blend.m_colorRts[attachment];
  238. if(rt.m_funcRgb != funcRgb || rt.m_funcA != funcA)
  239. {
  240. rt.m_funcRgb = funcRgb;
  241. rt.m_funcA = funcA;
  242. m_hashes.m_blend = 0;
  243. }
  244. }
  245. void beginRenderPass(ConstWeakArray<Format> colorFormats, Format depthStencilFormat, UVec2 rtsSize)
  246. {
  247. m_staticState.m_misc.m_colorRtFormats.fill(Format::kNone);
  248. m_staticState.m_misc.m_colorRtMask.unsetAll();
  249. for(U8 i = 0; i < colorFormats.getSize(); ++i)
  250. {
  251. ANKI_ASSERT(colorFormats[i] != Format::kNone);
  252. m_staticState.m_misc.m_colorRtFormats[i] = colorFormats[i];
  253. m_staticState.m_misc.m_colorRtMask.set(i);
  254. }
  255. m_staticState.m_misc.m_depthStencilFormat = depthStencilFormat;
  256. m_hashes.m_misc = 0; // Always mark it dirty because calling beginRenderPass is a rare occurance and we want to avoid extra checks
  257. if(m_rtsSize != rtsSize)
  258. {
  259. m_rtsSize = rtsSize;
  260. // Re-set the viewport and scissor because they depend on the size of the render targets
  261. m_dynState.m_scissorDirty = true;
  262. m_dynState.m_viewportDirty = true;
  263. }
  264. }
  265. void bindShaderProgram(ShaderProgram* prog)
  266. {
  267. ANKI_ASSERT(prog);
  268. if(prog != m_staticState.m_shaderProg)
  269. {
  270. const ShaderReflection& refl = prog->getReflection();
  271. if(m_staticState.m_vert.m_activeAttribs != refl.m_vertex.m_vertexAttributeMask)
  272. {
  273. m_staticState.m_vert.m_activeAttribs = refl.m_vertex.m_vertexAttributeMask;
  274. m_hashes.m_vert = 0;
  275. }
  276. #if ANKI_GR_BACKEND_VULKAN
  277. if(!!(prog->getShaderTypes() & ShaderTypeBit::kVertex) && !!refl.m_vertex.m_vertexAttributeMask)
  278. {
  279. if(m_staticState.m_shaderProg)
  280. {
  281. const Bool semanticsChanged = m_staticState.m_shaderProg->getReflection().m_vertex.m_vkVertexAttributeLocations
  282. != refl.m_vertex.m_vkVertexAttributeLocations;
  283. if(semanticsChanged)
  284. {
  285. m_hashes.m_vert = 0;
  286. }
  287. }
  288. for(VertexAttributeSemantic s : EnumIterable<VertexAttributeSemantic>())
  289. {
  290. m_staticState.m_vert.m_attribs[s].m_semanticToVertexAttributeLocation = refl.m_vertex.m_vkVertexAttributeLocations[s];
  291. }
  292. }
  293. #endif
  294. if(m_staticState.m_misc.m_colorRtMask != refl.m_pixel.m_colorRenderTargetWritemask)
  295. {
  296. m_staticState.m_misc.m_colorRtMask = refl.m_pixel.m_colorRenderTargetWritemask;
  297. m_hashes.m_misc = 0;
  298. }
  299. m_staticState.m_shaderProg = prog;
  300. m_hashes.m_shaderProg = 0;
  301. }
  302. }
  303. /// Used in D3D which doesn't have a separate binding point for compute and graphics.
  304. void unbindShaderProgram()
  305. {
  306. m_staticState.m_shaderProg = nullptr;
  307. m_globalHash = 0;
  308. }
  309. void setPrimitiveTopology(PrimitiveTopology topology)
  310. {
  311. if(m_staticState.m_ia.m_topology != topology)
  312. {
  313. m_staticState.m_ia.m_topology = topology;
  314. m_hashes.m_ia = 0;
  315. #if ANKI_GR_BACKEND_DIRECT3D
  316. m_dynState.m_topologyDirty = true;
  317. #endif
  318. }
  319. }
  320. void setViewport(U32 minx, U32 miny, U32 width, U32 height)
  321. {
  322. if(m_dynState.m_viewport[0] != minx || m_dynState.m_viewport[1] != miny || m_dynState.m_viewport[2] != width
  323. || m_dynState.m_viewport[3] != height)
  324. {
  325. m_dynState.m_viewport[0] = minx;
  326. m_dynState.m_viewport[1] = miny;
  327. m_dynState.m_viewport[2] = width;
  328. m_dynState.m_viewport[3] = height;
  329. m_dynState.m_viewportDirty = true;
  330. // Scissor needs to be re-adjusted if it's in its default size
  331. m_dynState.m_scissorDirty = true;
  332. }
  333. }
  334. void setScissor(U32 minx, U32 miny, U32 width, U32 height)
  335. {
  336. if(m_dynState.m_scissor[0] != minx || m_dynState.m_scissor[1] != miny || m_dynState.m_scissor[2] != width
  337. || m_dynState.m_scissor[3] != height)
  338. {
  339. m_dynState.m_scissor[0] = minx;
  340. m_dynState.m_scissor[1] = miny;
  341. m_dynState.m_scissor[2] = width;
  342. m_dynState.m_scissor[3] = height;
  343. m_dynState.m_scissorDirty = true;
  344. }
  345. }
  346. void setLineWidth(F32 width)
  347. {
  348. #if ANKI_GR_BACKEND_VULKAN
  349. if(m_dynState.m_lineWidth != width)
  350. {
  351. m_dynState.m_lineWidth = width;
  352. m_dynState.m_lineWidthDirty = true;
  353. }
  354. #else
  355. ANKI_ASSERT(width == 1.0f && "DX only accepts 1.0 line width");
  356. #endif
  357. }
  358. #if ANKI_GR_BACKEND_VULKAN
  359. void setEnablePipelineStatistics(Bool enable)
  360. {
  361. m_staticState.m_misc.m_pipelineStatisticsEnabled = enable;
  362. }
  363. #endif
  364. void setPrimitiveRestart(Bool enable)
  365. {
  366. if(m_staticState.m_ia.m_primitiveRestartEnabled != enable)
  367. {
  368. m_staticState.m_ia.m_primitiveRestartEnabled = enable;
  369. m_hashes.m_ia = 0;
  370. }
  371. }
  372. void setColorChannelWriteMask(U32 attachment, ColorBit mask)
  373. {
  374. if(m_staticState.m_blend.m_colorRts[attachment].m_channelWriteMask != mask)
  375. {
  376. m_staticState.m_blend.m_colorRts[attachment].m_channelWriteMask = mask;
  377. m_hashes.m_blend = 0;
  378. }
  379. }
  380. ShaderProgram& getShaderProgram()
  381. {
  382. ANKI_ASSERT(m_staticState.m_shaderProg);
  383. return *m_staticState.m_shaderProg;
  384. }
  385. private:
  386. ANKI_BEGIN_PACKED_STRUCT
  387. class StaticState
  388. {
  389. public:
  390. class Vertex
  391. {
  392. public:
  393. class Binding
  394. {
  395. public:
  396. #if ANKI_GR_BACKEND_VULKAN
  397. U32 m_stride;
  398. #endif
  399. VertexStepRate m_stepRate;
  400. Binding()
  401. {
  402. // No init for opt
  403. }
  404. };
  405. class Attribute
  406. {
  407. public:
  408. U32 m_relativeOffset;
  409. Format m_fmt;
  410. U32 m_binding;
  411. #if ANKI_GR_BACKEND_VULKAN
  412. U8 m_semanticToVertexAttributeLocation;
  413. #endif
  414. Attribute()
  415. {
  416. // No init for opt
  417. }
  418. };
  419. Array<Binding, U32(VertexAttributeSemantic::kCount)> m_bindings;
  420. Array<Attribute, U32(VertexAttributeSemantic::kCount)> m_attribs;
  421. VertexAttributeSemanticBit m_activeAttribs = VertexAttributeSemanticBit::kNone;
  422. BitSet<U32(VertexAttributeSemantic::kCount)> m_bindingsSetMask = {false};
  423. VertexAttributeSemanticBit m_attribsSetMask = VertexAttributeSemanticBit::kNone;
  424. } m_vert;
  425. class InputAssembler
  426. {
  427. public:
  428. PrimitiveTopology m_topology = PrimitiveTopology::kTriangles;
  429. Bool m_primitiveRestartEnabled = false;
  430. } m_ia;
  431. class Rast
  432. {
  433. public:
  434. FillMode m_fillMode = FillMode::kSolid;
  435. FaceSelectionBit m_cullMode = FaceSelectionBit::kBack;
  436. #if ANKI_GR_BACKEND_VULKAN
  437. Bool m_depthBiasEnabled = false;
  438. #else
  439. F32 m_depthBias = 0.0f;
  440. F32 m_depthBiasClamp = 0.0f;
  441. F32 m_slopeScaledDepthBias = 0.0f;
  442. #endif
  443. } m_rast;
  444. class
  445. {
  446. public:
  447. class StencilFace
  448. {
  449. public:
  450. StencilOperation m_fail = StencilOperation::kKeep;
  451. StencilOperation m_stencilPassDepthFail = StencilOperation::kKeep;
  452. StencilOperation m_stencilPassDepthPass = StencilOperation::kKeep;
  453. CompareOperation m_compare = CompareOperation::kAlways;
  454. #if ANKI_GR_BACKEND_DIRECT3D
  455. U32 m_compareMask = 0x5A5A5A5A; ///< Use a stupid number to initialize.
  456. U32 m_writeMask = 0x5A5A5A5A; ///< Use a stupid number to initialize.
  457. #endif
  458. };
  459. Array<StencilFace, 2> m_face;
  460. } m_stencil;
  461. class
  462. {
  463. public:
  464. CompareOperation m_compare = CompareOperation::kLess;
  465. Bool m_writeEnabled = true;
  466. } m_depth;
  467. class
  468. {
  469. public:
  470. class Rt
  471. {
  472. public:
  473. ColorBit m_channelWriteMask = ColorBit::kAll;
  474. BlendFactor m_srcRgb = BlendFactor::kOne;
  475. BlendFactor m_dstRgb = BlendFactor::kZero;
  476. BlendFactor m_srcA = BlendFactor::kOne;
  477. BlendFactor m_dstA = BlendFactor::kZero;
  478. BlendOperation m_funcRgb = BlendOperation::kAdd;
  479. BlendOperation m_funcA = BlendOperation::kAdd;
  480. };
  481. Array<Rt, kMaxColorRenderTargets> m_colorRts;
  482. Bool m_alphaToCoverage = false;
  483. } m_blend;
  484. class Misc
  485. {
  486. public:
  487. Array<Format, kMaxColorRenderTargets> m_colorRtFormats = {};
  488. Format m_depthStencilFormat = Format::kNone;
  489. BitSet<kMaxColorRenderTargets> m_colorRtMask = {false};
  490. #if ANKI_GR_BACKEND_VULKAN
  491. Bool m_pipelineStatisticsEnabled = false;
  492. #endif
  493. } m_misc;
  494. ShaderProgram* m_shaderProg = nullptr;
  495. } m_staticState;
  496. ANKI_END_PACKED_STRUCT
  497. class DynamicState
  498. {
  499. public:
  500. class StencilFace
  501. {
  502. public:
  503. #if ANKI_GR_BACKEND_VULKAN
  504. U32 m_compareMask = 0x5A5A5A5A; ///< Use a stupid number to initialize.
  505. U32 m_writeMask = 0x5A5A5A5A; ///< Use a stupid number to initialize.
  506. #endif
  507. U32 m_ref = 0x5A5A5A5A; ///< Use a stupid number to initialize.
  508. };
  509. Array<StencilFace, 2> m_stencilFaces;
  510. Array<U32, 4> m_viewport = {};
  511. Array<U32, 4> m_scissor = {0, 0, kMaxU32, kMaxU32};
  512. #if ANKI_GR_BACKEND_VULKAN
  513. F32 m_depthBiasConstantFactor = 0.0f;
  514. F32 m_depthBiasClamp = 0.0f;
  515. F32 m_depthBiasSlopeFactor = 0.0f;
  516. F32 m_lineWidth = 1.0f;
  517. #endif
  518. #if ANKI_GR_BACKEND_VULKAN
  519. Bool m_stencilCompareMaskDirty : 1 = true;
  520. Bool m_stencilWriteMaskDirty : 1 = true;
  521. Bool m_depthBiasDirty : 1 = true;
  522. Bool m_lineWidthDirty : 1 = true;
  523. #else
  524. Bool m_topologyDirty : 1 = true;
  525. #endif
  526. Bool m_stencilRefDirty : 1 = true;
  527. Bool m_viewportDirty : 1 = true;
  528. Bool m_scissorDirty : 1 = true;
  529. } m_dynState;
  530. class Hashes
  531. {
  532. public:
  533. U64 m_vert = 0;
  534. U64 m_rast = 0;
  535. U64 m_ia = 0;
  536. U64 m_depthStencil = 0;
  537. U64 m_blend = 0;
  538. U64 m_misc = 0;
  539. U64 m_shaderProg = 0;
  540. } m_hashes;
  541. U64 m_globalHash = 0;
  542. UVec2 m_rtsSize = UVec2(0u);
  543. Bool updateHashes();
  544. };
  545. /// @}
  546. } // end namespace anki