ThreedClass.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. using Ryujinx.Graphics.Device;
  2. using Ryujinx.Graphics.GAL;
  3. using Ryujinx.Graphics.Gpu.Engine.GPFifo;
  4. using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Runtime.CompilerServices;
  8. namespace Ryujinx.Graphics.Gpu.Engine.Threed
  9. {
  10. /// <summary>
  11. /// Represents a 3D engine class.
  12. /// </summary>
  13. class ThreedClass : IDeviceState
  14. {
  15. private readonly GpuContext _context;
  16. private readonly GPFifoClass _fifoClass;
  17. private readonly DeviceStateWithShadow<ThreedClassState> _state;
  18. private readonly InlineToMemoryClass _i2mClass;
  19. private readonly DrawManager _drawManager;
  20. private readonly SemaphoreUpdater _semaphoreUpdater;
  21. private readonly ConstantBufferUpdater _cbUpdater;
  22. private readonly StateUpdater _stateUpdater;
  23. /// <summary>
  24. /// Creates a new instance of the 3D engine class.
  25. /// </summary>
  26. /// <param name="context">GPU context</param>
  27. /// <param name="channel">GPU channel</param>
  28. public ThreedClass(GpuContext context, GpuChannel channel, GPFifoClass fifoClass)
  29. {
  30. _context = context;
  31. _fifoClass = fifoClass;
  32. _state = new DeviceStateWithShadow<ThreedClassState>(new Dictionary<string, RwCallback>
  33. {
  34. { nameof(ThreedClassState.LaunchDma), new RwCallback(LaunchDma, null) },
  35. { nameof(ThreedClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
  36. { nameof(ThreedClassState.SyncpointAction), new RwCallback(IncrementSyncpoint, null) },
  37. { nameof(ThreedClassState.InvalidateSamplerCacheNoWfi), new RwCallback(InvalidateSamplerCacheNoWfi, null) },
  38. { nameof(ThreedClassState.InvalidateTextureHeaderCacheNoWfi), new RwCallback(InvalidateTextureHeaderCacheNoWfi, null) },
  39. { nameof(ThreedClassState.TextureBarrier), new RwCallback(TextureBarrier, null) },
  40. { nameof(ThreedClassState.TextureBarrierTiled), new RwCallback(TextureBarrierTiled, null) },
  41. { nameof(ThreedClassState.DrawTextureSrcY), new RwCallback(DrawTexture, null) },
  42. { nameof(ThreedClassState.DrawVertexArrayBeginEndInstanceFirst), new RwCallback(DrawVertexArrayBeginEndInstanceFirst, null) },
  43. { nameof(ThreedClassState.DrawVertexArrayBeginEndInstanceSubsequent), new RwCallback(DrawVertexArrayBeginEndInstanceSubsequent, null) },
  44. { nameof(ThreedClassState.VbElementU8), new RwCallback(VbElementU8, null) },
  45. { nameof(ThreedClassState.VbElementU16), new RwCallback(VbElementU16, null) },
  46. { nameof(ThreedClassState.VbElementU32), new RwCallback(VbElementU32, null) },
  47. { nameof(ThreedClassState.ResetCounter), new RwCallback(ResetCounter, null) },
  48. { nameof(ThreedClassState.RenderEnableCondition), new RwCallback(null, Zero) },
  49. { nameof(ThreedClassState.DrawEnd), new RwCallback(DrawEnd, null) },
  50. { nameof(ThreedClassState.DrawBegin), new RwCallback(DrawBegin, null) },
  51. { nameof(ThreedClassState.DrawIndexBuffer32BeginEndInstanceFirst), new RwCallback(DrawIndexBuffer32BeginEndInstanceFirst, null) },
  52. { nameof(ThreedClassState.DrawIndexBuffer16BeginEndInstanceFirst), new RwCallback(DrawIndexBuffer16BeginEndInstanceFirst, null) },
  53. { nameof(ThreedClassState.DrawIndexBuffer8BeginEndInstanceFirst), new RwCallback(DrawIndexBuffer8BeginEndInstanceFirst, null) },
  54. { nameof(ThreedClassState.DrawIndexBuffer32BeginEndInstanceSubsequent), new RwCallback(DrawIndexBuffer32BeginEndInstanceSubsequent, null) },
  55. { nameof(ThreedClassState.DrawIndexBuffer16BeginEndInstanceSubsequent), new RwCallback(DrawIndexBuffer16BeginEndInstanceSubsequent, null) },
  56. { nameof(ThreedClassState.DrawIndexBuffer8BeginEndInstanceSubsequent), new RwCallback(DrawIndexBuffer8BeginEndInstanceSubsequent, null) },
  57. { nameof(ThreedClassState.IndexBufferCount), new RwCallback(SetIndexBufferCount, null) },
  58. { nameof(ThreedClassState.Clear), new RwCallback(Clear, null) },
  59. { nameof(ThreedClassState.SemaphoreControl), new RwCallback(Report, null) },
  60. { nameof(ThreedClassState.SetFalcon04), new RwCallback(SetFalcon04, null) },
  61. { nameof(ThreedClassState.UniformBufferUpdateData), new RwCallback(ConstantBufferUpdate, null) },
  62. { nameof(ThreedClassState.UniformBufferBindVertex), new RwCallback(ConstantBufferBindVertex, null) },
  63. { nameof(ThreedClassState.UniformBufferBindTessControl), new RwCallback(ConstantBufferBindTessControl, null) },
  64. { nameof(ThreedClassState.UniformBufferBindTessEvaluation), new RwCallback(ConstantBufferBindTessEvaluation, null) },
  65. { nameof(ThreedClassState.UniformBufferBindGeometry), new RwCallback(ConstantBufferBindGeometry, null) },
  66. { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) }
  67. });
  68. _i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);
  69. var spec = new SpecializationStateUpdater();
  70. var drawState = new DrawState();
  71. _drawManager = new DrawManager(context, channel, _state, drawState, spec);
  72. _semaphoreUpdater = new SemaphoreUpdater(context, channel, _state);
  73. _cbUpdater = new ConstantBufferUpdater(channel, _state);
  74. _stateUpdater = new StateUpdater(context, channel, _state, drawState, spec);
  75. // This defaults to "always", even without any register write.
  76. // Reads just return 0, regardless of what was set there.
  77. _state.State.RenderEnableCondition = Condition.Always;
  78. }
  79. /// <summary>
  80. /// Reads data from the class registers.
  81. /// </summary>
  82. /// <param name="offset">Register byte offset</param>
  83. /// <returns>Data at the specified offset</returns>
  84. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  85. public int Read(int offset) => _state.Read(offset);
  86. /// <summary>
  87. /// Writes data to the class registers.
  88. /// </summary>
  89. /// <param name="offset">Register byte offset</param>
  90. /// <param name="data">Data to be written</param>
  91. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  92. public void Write(int offset, int data)
  93. {
  94. _state.WriteWithRedundancyCheck(offset, data, out bool valueChanged);
  95. if (valueChanged)
  96. {
  97. _stateUpdater.SetDirty(offset);
  98. }
  99. }
  100. /// <summary>
  101. /// Sets the shadow ram control value of all sub-channels.
  102. /// </summary>
  103. /// <param name="control">New shadow ram control value</param>
  104. public void SetShadowRamControl(int control)
  105. {
  106. _state.State.SetMmeShadowRamControl = (uint)control;
  107. }
  108. /// <summary>
  109. /// Updates current host state for all registers modified since the last call to this method.
  110. /// </summary>
  111. public void UpdateState()
  112. {
  113. _fifoClass.CreatePendingSyncs();
  114. _cbUpdater.FlushUboDirty();
  115. _stateUpdater.Update();
  116. }
  117. /// <summary>
  118. /// Updates current host state for all registers modified since the last call to this method.
  119. /// </summary>
  120. /// <param name="mask">Mask where each bit set indicates that the respective state group index should be checked</param>
  121. public void UpdateState(ulong mask)
  122. {
  123. _stateUpdater.Update(mask);
  124. }
  125. /// <summary>
  126. /// Updates render targets (color and depth-stencil buffers) based on current render target state.
  127. /// </summary>
  128. /// <param name="useControl">Use draw buffers information from render target control register</param>
  129. /// <param name="layered">Indicates if the texture is layered</param>
  130. /// <param name="singleUse">If this is not -1, it indicates that only the given indexed target will be used.</param>
  131. public void UpdateRenderTargetState(bool useControl, bool layered = false, int singleUse = -1)
  132. {
  133. _stateUpdater.UpdateRenderTargetState(useControl, layered, singleUse);
  134. }
  135. /// <summary>
  136. /// Updates scissor based on current render target state.
  137. /// </summary>
  138. public void UpdateScissorState()
  139. {
  140. _stateUpdater.UpdateScissorState();
  141. }
  142. /// <summary>
  143. /// Marks the entire state as dirty, forcing a full host state update before the next draw.
  144. /// </summary>
  145. public void ForceStateDirty()
  146. {
  147. _drawManager.ForceStateDirty();
  148. _stateUpdater.SetAllDirty();
  149. }
  150. /// <summary>
  151. /// Marks the specified register offset as dirty, forcing the associated state to update on the next draw.
  152. /// </summary>
  153. /// <param name="offset">Register offset</param>
  154. public void ForceStateDirty(int offset)
  155. {
  156. _stateUpdater.SetDirty(offset);
  157. }
  158. /// <summary>
  159. /// Forces the shaders to be rebound on the next draw.
  160. /// </summary>
  161. public void ForceShaderUpdate()
  162. {
  163. _stateUpdater.ForceShaderUpdate();
  164. }
  165. /// <summary>
  166. /// Create any syncs from WaitForIdle command that are currently pending.
  167. /// </summary>
  168. public void CreatePendingSyncs()
  169. {
  170. _fifoClass.CreatePendingSyncs();
  171. }
  172. /// <summary>
  173. /// Flushes any queued UBO updates.
  174. /// </summary>
  175. public void FlushUboDirty()
  176. {
  177. _cbUpdater.FlushUboDirty();
  178. }
  179. /// <summary>
  180. /// Perform any deferred draws.
  181. /// </summary>
  182. public void PerformDeferredDraws()
  183. {
  184. _drawManager.PerformDeferredDraws();
  185. }
  186. /// <summary>
  187. /// Updates the currently bound constant buffer.
  188. /// </summary>
  189. /// <param name="data">Data to be written to the buffer</param>
  190. public void ConstantBufferUpdate(ReadOnlySpan<int> data)
  191. {
  192. _cbUpdater.Update(data);
  193. }
  194. /// <summary>
  195. /// Launches the Inline-to-Memory DMA copy operation.
  196. /// </summary>
  197. /// <param name="argument">Method call argument</param>
  198. private void LaunchDma(int argument)
  199. {
  200. _i2mClass.LaunchDma(ref Unsafe.As<ThreedClassState, InlineToMemoryClassState>(ref _state.State), argument);
  201. }
  202. /// <summary>
  203. /// Pushes a block of data to the Inline-to-Memory engine.
  204. /// </summary>
  205. /// <param name="data">Data to push</param>
  206. public void LoadInlineData(ReadOnlySpan<int> data)
  207. {
  208. _i2mClass.LoadInlineData(data);
  209. }
  210. /// <summary>
  211. /// Pushes a word of data to the Inline-to-Memory engine.
  212. /// </summary>
  213. /// <param name="argument">Method call argument</param>
  214. private void LoadInlineData(int argument)
  215. {
  216. _i2mClass.LoadInlineData(argument);
  217. }
  218. /// <summary>
  219. /// Performs an incrementation on a syncpoint.
  220. /// </summary>
  221. /// <param name="argument">Method call argument</param>
  222. public void IncrementSyncpoint(int argument)
  223. {
  224. uint syncpointId = (uint)argument & 0xFFFF;
  225. _context.AdvanceSequence();
  226. _context.CreateHostSyncIfNeeded(true);
  227. _context.Renderer.UpdateCounters(); // Poll the query counters, the game may want an updated result.
  228. _context.Synchronization.IncrementSyncpoint(syncpointId);
  229. }
  230. /// <summary>
  231. /// Invalidates the cache with the sampler descriptors from the sampler pool.
  232. /// </summary>
  233. /// <param name="argument">Method call argument (unused)</param>
  234. private void InvalidateSamplerCacheNoWfi(int argument)
  235. {
  236. _context.AdvanceSequence();
  237. }
  238. /// <summary>
  239. /// Invalidates the cache with the texture descriptors from the texture pool.
  240. /// </summary>
  241. /// <param name="argument">Method call argument (unused)</param>
  242. private void InvalidateTextureHeaderCacheNoWfi(int argument)
  243. {
  244. _context.AdvanceSequence();
  245. }
  246. /// <summary>
  247. /// Issues a texture barrier.
  248. /// This waits until previous texture writes from the GPU to finish, before
  249. /// performing new operations with said textures.
  250. /// </summary>
  251. /// <param name="argument">Method call argument (unused)</param>
  252. private void TextureBarrier(int argument)
  253. {
  254. _context.Renderer.Pipeline.TextureBarrier();
  255. }
  256. /// <summary>
  257. /// Issues a texture barrier.
  258. /// This waits until previous texture writes from the GPU to finish, before
  259. /// performing new operations with said textures.
  260. /// This performs a per-tile wait, it is only valid if both the previous write
  261. /// and current access has the same access patterns.
  262. /// This may be faster than the regular barrier on tile-based rasterizers.
  263. /// </summary>
  264. /// <param name="argument">Method call argument (unused)</param>
  265. private void TextureBarrierTiled(int argument)
  266. {
  267. _context.Renderer.Pipeline.TextureBarrierTiled();
  268. }
  269. /// <summary>
  270. /// Draws a texture, without needing to specify shader programs.
  271. /// </summary>
  272. /// <param name="argument">Method call argument</param>
  273. private void DrawTexture(int argument)
  274. {
  275. _drawManager.DrawTexture(this, argument);
  276. }
  277. /// <summary>
  278. /// Performs a non-indexed draw with the specified topology, index and count.
  279. /// </summary>
  280. /// <param name="argument">Method call argument</param>
  281. private void DrawVertexArrayBeginEndInstanceFirst(int argument)
  282. {
  283. _drawManager.DrawVertexArrayBeginEndInstanceFirst(this, argument);
  284. }
  285. /// <summary>
  286. /// Performs a non-indexed draw with the specified topology, index and count,
  287. /// while incrementing the current instance.
  288. /// </summary>
  289. /// <param name="argument">Method call argument</param>
  290. private void DrawVertexArrayBeginEndInstanceSubsequent(int argument)
  291. {
  292. _drawManager.DrawVertexArrayBeginEndInstanceSubsequent(this, argument);
  293. }
  294. /// <summary>
  295. /// Pushes four 8-bit index buffer elements.
  296. /// </summary>
  297. /// <param name="argument">Method call argument</param>
  298. private void VbElementU8(int argument)
  299. {
  300. _drawManager.VbElementU8(argument);
  301. }
  302. /// <summary>
  303. /// Pushes two 16-bit index buffer elements.
  304. /// </summary>
  305. /// <param name="argument">Method call argument</param>
  306. private void VbElementU16(int argument)
  307. {
  308. _drawManager.VbElementU16(argument);
  309. }
  310. /// <summary>
  311. /// Pushes one 32-bit index buffer element.
  312. /// </summary>
  313. /// <param name="argument">Method call argument</param>
  314. private void VbElementU32(int argument)
  315. {
  316. _drawManager.VbElementU32(argument);
  317. }
  318. /// <summary>
  319. /// Resets the value of an internal GPU counter back to zero.
  320. /// </summary>
  321. /// <param name="argument">Method call argument</param>
  322. private void ResetCounter(int argument)
  323. {
  324. _semaphoreUpdater.ResetCounter(argument);
  325. }
  326. /// <summary>
  327. /// Finishes the draw call.
  328. /// This draws geometry on the bound buffers based on the current GPU state.
  329. /// </summary>
  330. /// <param name="argument">Method call argument</param>
  331. private void DrawEnd(int argument)
  332. {
  333. _drawManager.DrawEnd(this, argument);
  334. }
  335. /// <summary>
  336. /// Starts draw.
  337. /// This sets primitive type and instanced draw parameters.
  338. /// </summary>
  339. /// <param name="argument">Method call argument</param>
  340. private void DrawBegin(int argument)
  341. {
  342. _drawManager.DrawBegin(argument);
  343. }
  344. /// <summary>
  345. /// Sets the index buffer count.
  346. /// This also sets internal state that indicates that the next draw is an indexed draw.
  347. /// </summary>
  348. /// <param name="argument">Method call argument</param>
  349. private void SetIndexBufferCount(int argument)
  350. {
  351. _drawManager.SetIndexBufferCount(argument);
  352. }
  353. /// <summary>
  354. /// Performs a indexed draw with 8-bit index buffer elements.
  355. /// </summary>
  356. /// <param name="argument">Method call argument</param>
  357. private void DrawIndexBuffer8BeginEndInstanceFirst(int argument)
  358. {
  359. _drawManager.DrawIndexBuffer8BeginEndInstanceFirst(this, argument);
  360. }
  361. /// <summary>
  362. /// Performs a indexed draw with 16-bit index buffer elements.
  363. /// </summary>
  364. /// <param name="argument">Method call argument</param>
  365. private void DrawIndexBuffer16BeginEndInstanceFirst(int argument)
  366. {
  367. _drawManager.DrawIndexBuffer16BeginEndInstanceFirst(this, argument);
  368. }
  369. /// <summary>
  370. /// Performs a indexed draw with 32-bit index buffer elements.
  371. /// </summary>
  372. /// <param name="argument">Method call argument</param>
  373. private void DrawIndexBuffer32BeginEndInstanceFirst(int argument)
  374. {
  375. _drawManager.DrawIndexBuffer32BeginEndInstanceFirst(this, argument);
  376. }
  377. /// <summary>
  378. /// Performs a indexed draw with 8-bit index buffer elements,
  379. /// while also pre-incrementing the current instance value.
  380. /// </summary>
  381. /// <param name="argument">Method call argument</param>
  382. private void DrawIndexBuffer8BeginEndInstanceSubsequent(int argument)
  383. {
  384. _drawManager.DrawIndexBuffer8BeginEndInstanceSubsequent(this, argument);
  385. }
  386. /// <summary>
  387. /// Performs a indexed draw with 16-bit index buffer elements,
  388. /// while also pre-incrementing the current instance value.
  389. /// </summary>
  390. /// <param name="argument">Method call argument</param>
  391. private void DrawIndexBuffer16BeginEndInstanceSubsequent(int argument)
  392. {
  393. _drawManager.DrawIndexBuffer16BeginEndInstanceSubsequent(this, argument);
  394. }
  395. /// <summary>
  396. /// Performs a indexed draw with 32-bit index buffer elements,
  397. /// while also pre-incrementing the current instance value.
  398. /// </summary>
  399. /// <param name="argument">Method call argument</param>
  400. private void DrawIndexBuffer32BeginEndInstanceSubsequent(int argument)
  401. {
  402. _drawManager.DrawIndexBuffer32BeginEndInstanceSubsequent(this, argument);
  403. }
  404. /// <summary>
  405. /// Clears the current color and depth-stencil buffers.
  406. /// Which buffers should be cleared is also specified on the argument.
  407. /// </summary>
  408. /// <param name="argument">Method call argument</param>
  409. private void Clear(int argument)
  410. {
  411. _drawManager.Clear(this, argument);
  412. }
  413. /// <summary>
  414. /// Writes a GPU counter to guest memory.
  415. /// </summary>
  416. /// <param name="argument">Method call argument</param>
  417. private void Report(int argument)
  418. {
  419. _semaphoreUpdater.Report(argument);
  420. }
  421. /// <summary>
  422. /// Performs high-level emulation of Falcon microcode function number "4".
  423. /// </summary>
  424. /// <param name="argument">Method call argument</param>
  425. private void SetFalcon04(int argument)
  426. {
  427. _state.State.SetMmeShadowScratch[0] = 1;
  428. }
  429. /// <summary>
  430. /// Updates the uniform buffer data with inline data.
  431. /// </summary>
  432. /// <param name="argument">New uniform buffer data word</param>
  433. private void ConstantBufferUpdate(int argument)
  434. {
  435. _cbUpdater.Update(argument);
  436. }
  437. /// <summary>
  438. /// Binds a uniform buffer for the vertex shader stage.
  439. /// </summary>
  440. /// <param name="argument">Method call argument</param>
  441. private void ConstantBufferBindVertex(int argument)
  442. {
  443. _cbUpdater.BindVertex(argument);
  444. }
  445. /// <summary>
  446. /// Binds a uniform buffer for the tessellation control shader stage.
  447. /// </summary>
  448. /// <param name="argument">Method call argument</param>
  449. private void ConstantBufferBindTessControl(int argument)
  450. {
  451. _cbUpdater.BindTessControl(argument);
  452. }
  453. /// <summary>
  454. /// Binds a uniform buffer for the tessellation evaluation shader stage.
  455. /// </summary>
  456. /// <param name="argument">Method call argument</param>
  457. private void ConstantBufferBindTessEvaluation(int argument)
  458. {
  459. _cbUpdater.BindTessEvaluation(argument);
  460. }
  461. /// <summary>
  462. /// Binds a uniform buffer for the geometry shader stage.
  463. /// </summary>
  464. /// <param name="argument">Method call argument</param>
  465. private void ConstantBufferBindGeometry(int argument)
  466. {
  467. _cbUpdater.BindGeometry(argument);
  468. }
  469. /// <summary>
  470. /// Binds a uniform buffer for the fragment shader stage.
  471. /// </summary>
  472. /// <param name="argument">Method call argument</param>
  473. private void ConstantBufferBindFragment(int argument)
  474. {
  475. _cbUpdater.BindFragment(argument);
  476. }
  477. /// <summary>
  478. /// Generic register read function that just returns 0.
  479. /// </summary>
  480. /// <returns>Zero</returns>
  481. private static int Zero()
  482. {
  483. return 0;
  484. }
  485. /// <summary>
  486. /// Performs a indexed or non-indexed draw.
  487. /// </summary>
  488. /// <param name="topology">Primitive topology</param>
  489. /// <param name="count">Index count for indexed draws, vertex count for non-indexed draws</param>
  490. /// <param name="instanceCount">Instance count</param>
  491. /// <param name="firstIndex">First index on the index buffer for indexed draws, ignored for non-indexed draws</param>
  492. /// <param name="firstVertex">First vertex on the vertex buffer</param>
  493. /// <param name="firstInstance">First instance</param>
  494. /// <param name="indexed">True if the draw is indexed, false otherwise</param>
  495. public void Draw(
  496. PrimitiveTopology topology,
  497. int count,
  498. int instanceCount,
  499. int firstIndex,
  500. int firstVertex,
  501. int firstInstance,
  502. bool indexed)
  503. {
  504. _drawManager.Draw(this, topology, count, instanceCount, firstIndex, firstVertex, firstInstance, indexed);
  505. }
  506. /// <summary>
  507. /// Performs a indirect draw, with parameters from a GPU buffer.
  508. /// </summary>
  509. /// <param name="topology">Primitive topology</param>
  510. /// <param name="indirectBufferAddress">Address of the buffer with the draw parameters, such as count, first index, etc</param>
  511. /// <param name="parameterBufferAddress">Address of the buffer with the draw count</param>
  512. /// <param name="maxDrawCount">Maximum number of draws that can be made</param>
  513. /// <param name="stride">Distance in bytes between each entry on the data pointed to by <paramref name="indirectBufferAddress"/></param>
  514. /// <param name="indexCount">Maximum number of indices that the draw can consume</param>
  515. /// <param name="drawType">Type of the indirect draw, which can be indexed or non-indexed, with or without a draw count</param>
  516. public void DrawIndirect(
  517. PrimitiveTopology topology,
  518. ulong indirectBufferAddress,
  519. ulong parameterBufferAddress,
  520. int maxDrawCount,
  521. int stride,
  522. int indexCount,
  523. IndirectDrawType drawType)
  524. {
  525. _drawManager.DrawIndirect(this, topology, indirectBufferAddress, parameterBufferAddress, maxDrawCount, stride, indexCount, drawType);
  526. }
  527. /// <summary>
  528. /// Clears the current color and depth-stencil buffers.
  529. /// Which buffers should be cleared can also specified with the arguments.
  530. /// </summary>
  531. /// <param name="argument">Method call argument</param>
  532. /// <param name="layerCount">For array and 3D textures, indicates how many layers should be cleared</param>
  533. public void Clear(int argument, int layerCount)
  534. {
  535. _drawManager.Clear(this, argument, layerCount);
  536. }
  537. }
  538. }