ThreedClass.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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(context);
  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="updateFlags">Flags indicating which render targets should be updated and how</param>
  129. /// <param name="singleUse">If this is not -1, it indicates that only the given indexed target will be used.</param>
  130. public void UpdateRenderTargetState(RenderTargetUpdateFlags updateFlags, int singleUse = -1)
  131. {
  132. _stateUpdater.UpdateRenderTargetState(updateFlags, singleUse);
  133. }
  134. /// <summary>
  135. /// Updates scissor based on current render target state.
  136. /// </summary>
  137. public void UpdateScissorState()
  138. {
  139. _stateUpdater.UpdateScissorState();
  140. }
  141. /// <summary>
  142. /// Marks the entire state as dirty, forcing a full host state update before the next draw.
  143. /// </summary>
  144. public void ForceStateDirty()
  145. {
  146. _drawManager.ForceStateDirty();
  147. _stateUpdater.SetAllDirty();
  148. }
  149. /// <summary>
  150. /// Marks the specified register offset as dirty, forcing the associated state to update on the next draw.
  151. /// </summary>
  152. /// <param name="offset">Register offset</param>
  153. public void ForceStateDirty(int offset)
  154. {
  155. _stateUpdater.SetDirty(offset);
  156. }
  157. /// <summary>
  158. /// Forces the shaders to be rebound on the next draw.
  159. /// </summary>
  160. public void ForceShaderUpdate()
  161. {
  162. _stateUpdater.ForceShaderUpdate();
  163. }
  164. /// <summary>
  165. /// Create any syncs from WaitForIdle command that are currently pending.
  166. /// </summary>
  167. public void CreatePendingSyncs()
  168. {
  169. _fifoClass.CreatePendingSyncs();
  170. }
  171. /// <summary>
  172. /// Flushes any queued UBO updates.
  173. /// </summary>
  174. public void FlushUboDirty()
  175. {
  176. _cbUpdater.FlushUboDirty();
  177. }
  178. /// <summary>
  179. /// Perform any deferred draws.
  180. /// </summary>
  181. public void PerformDeferredDraws()
  182. {
  183. _drawManager.PerformDeferredDraws();
  184. }
  185. /// <summary>
  186. /// Updates the currently bound constant buffer.
  187. /// </summary>
  188. /// <param name="data">Data to be written to the buffer</param>
  189. public void ConstantBufferUpdate(ReadOnlySpan<int> data)
  190. {
  191. _cbUpdater.Update(data);
  192. }
  193. /// <summary>
  194. /// Launches the Inline-to-Memory DMA copy operation.
  195. /// </summary>
  196. /// <param name="argument">Method call argument</param>
  197. private void LaunchDma(int argument)
  198. {
  199. _i2mClass.LaunchDma(ref Unsafe.As<ThreedClassState, InlineToMemoryClassState>(ref _state.State), argument);
  200. }
  201. /// <summary>
  202. /// Pushes a block of data to the Inline-to-Memory engine.
  203. /// </summary>
  204. /// <param name="data">Data to push</param>
  205. public void LoadInlineData(ReadOnlySpan<int> data)
  206. {
  207. _i2mClass.LoadInlineData(data);
  208. }
  209. /// <summary>
  210. /// Pushes a word of data to the Inline-to-Memory engine.
  211. /// </summary>
  212. /// <param name="argument">Method call argument</param>
  213. private void LoadInlineData(int argument)
  214. {
  215. _i2mClass.LoadInlineData(argument);
  216. }
  217. /// <summary>
  218. /// Performs an incrementation on a syncpoint.
  219. /// </summary>
  220. /// <param name="argument">Method call argument</param>
  221. public void IncrementSyncpoint(int argument)
  222. {
  223. uint syncpointId = (uint)argument & 0xFFFF;
  224. _context.AdvanceSequence();
  225. _context.CreateHostSyncIfNeeded(true, true);
  226. _context.Renderer.UpdateCounters(); // Poll the query counters, the game may want an updated result.
  227. _context.Synchronization.IncrementSyncpoint(syncpointId);
  228. }
  229. /// <summary>
  230. /// Invalidates the cache with the sampler descriptors from the sampler pool.
  231. /// </summary>
  232. /// <param name="argument">Method call argument (unused)</param>
  233. private void InvalidateSamplerCacheNoWfi(int argument)
  234. {
  235. _context.AdvanceSequence();
  236. }
  237. /// <summary>
  238. /// Invalidates the cache with the texture descriptors from the texture pool.
  239. /// </summary>
  240. /// <param name="argument">Method call argument (unused)</param>
  241. private void InvalidateTextureHeaderCacheNoWfi(int argument)
  242. {
  243. _context.AdvanceSequence();
  244. }
  245. /// <summary>
  246. /// Issues a texture barrier.
  247. /// This waits until previous texture writes from the GPU to finish, before
  248. /// performing new operations with said textures.
  249. /// </summary>
  250. /// <param name="argument">Method call argument (unused)</param>
  251. private void TextureBarrier(int argument)
  252. {
  253. _context.Renderer.Pipeline.TextureBarrier();
  254. }
  255. /// <summary>
  256. /// Issues a texture barrier.
  257. /// This waits until previous texture writes from the GPU to finish, before
  258. /// performing new operations with said textures.
  259. /// This performs a per-tile wait, it is only valid if both the previous write
  260. /// and current access has the same access patterns.
  261. /// This may be faster than the regular barrier on tile-based rasterizers.
  262. /// </summary>
  263. /// <param name="argument">Method call argument (unused)</param>
  264. private void TextureBarrierTiled(int argument)
  265. {
  266. _context.Renderer.Pipeline.TextureBarrierTiled();
  267. }
  268. /// <summary>
  269. /// Draws a texture, without needing to specify shader programs.
  270. /// </summary>
  271. /// <param name="argument">Method call argument</param>
  272. private void DrawTexture(int argument)
  273. {
  274. _drawManager.DrawTexture(this, argument);
  275. }
  276. /// <summary>
  277. /// Performs a non-indexed draw with the specified topology, index and count.
  278. /// </summary>
  279. /// <param name="argument">Method call argument</param>
  280. private void DrawVertexArrayBeginEndInstanceFirst(int argument)
  281. {
  282. _drawManager.DrawVertexArrayBeginEndInstanceFirst(this, argument);
  283. }
  284. /// <summary>
  285. /// Performs a non-indexed draw with the specified topology, index and count,
  286. /// while incrementing the current instance.
  287. /// </summary>
  288. /// <param name="argument">Method call argument</param>
  289. private void DrawVertexArrayBeginEndInstanceSubsequent(int argument)
  290. {
  291. _drawManager.DrawVertexArrayBeginEndInstanceSubsequent(this, argument);
  292. }
  293. /// <summary>
  294. /// Pushes four 8-bit index buffer elements.
  295. /// </summary>
  296. /// <param name="argument">Method call argument</param>
  297. private void VbElementU8(int argument)
  298. {
  299. _drawManager.VbElementU8(argument);
  300. }
  301. /// <summary>
  302. /// Pushes two 16-bit index buffer elements.
  303. /// </summary>
  304. /// <param name="argument">Method call argument</param>
  305. private void VbElementU16(int argument)
  306. {
  307. _drawManager.VbElementU16(argument);
  308. }
  309. /// <summary>
  310. /// Pushes one 32-bit index buffer element.
  311. /// </summary>
  312. /// <param name="argument">Method call argument</param>
  313. private void VbElementU32(int argument)
  314. {
  315. _drawManager.VbElementU32(argument);
  316. }
  317. /// <summary>
  318. /// Resets the value of an internal GPU counter back to zero.
  319. /// </summary>
  320. /// <param name="argument">Method call argument</param>
  321. private void ResetCounter(int argument)
  322. {
  323. _semaphoreUpdater.ResetCounter(argument);
  324. }
  325. /// <summary>
  326. /// Finishes the draw call.
  327. /// This draws geometry on the bound buffers based on the current GPU state.
  328. /// </summary>
  329. /// <param name="argument">Method call argument</param>
  330. private void DrawEnd(int argument)
  331. {
  332. _drawManager.DrawEnd(this, argument);
  333. }
  334. /// <summary>
  335. /// Starts draw.
  336. /// This sets primitive type and instanced draw parameters.
  337. /// </summary>
  338. /// <param name="argument">Method call argument</param>
  339. private void DrawBegin(int argument)
  340. {
  341. _drawManager.DrawBegin(argument);
  342. }
  343. /// <summary>
  344. /// Sets the index buffer count.
  345. /// This also sets internal state that indicates that the next draw is an indexed draw.
  346. /// </summary>
  347. /// <param name="argument">Method call argument</param>
  348. private void SetIndexBufferCount(int argument)
  349. {
  350. _drawManager.SetIndexBufferCount(argument);
  351. }
  352. /// <summary>
  353. /// Performs a indexed draw with 8-bit index buffer elements.
  354. /// </summary>
  355. /// <param name="argument">Method call argument</param>
  356. private void DrawIndexBuffer8BeginEndInstanceFirst(int argument)
  357. {
  358. _drawManager.DrawIndexBuffer8BeginEndInstanceFirst(this, argument);
  359. }
  360. /// <summary>
  361. /// Performs a indexed draw with 16-bit index buffer elements.
  362. /// </summary>
  363. /// <param name="argument">Method call argument</param>
  364. private void DrawIndexBuffer16BeginEndInstanceFirst(int argument)
  365. {
  366. _drawManager.DrawIndexBuffer16BeginEndInstanceFirst(this, argument);
  367. }
  368. /// <summary>
  369. /// Performs a indexed draw with 32-bit index buffer elements.
  370. /// </summary>
  371. /// <param name="argument">Method call argument</param>
  372. private void DrawIndexBuffer32BeginEndInstanceFirst(int argument)
  373. {
  374. _drawManager.DrawIndexBuffer32BeginEndInstanceFirst(this, argument);
  375. }
  376. /// <summary>
  377. /// Performs a indexed draw with 8-bit index buffer elements,
  378. /// while also pre-incrementing the current instance value.
  379. /// </summary>
  380. /// <param name="argument">Method call argument</param>
  381. private void DrawIndexBuffer8BeginEndInstanceSubsequent(int argument)
  382. {
  383. _drawManager.DrawIndexBuffer8BeginEndInstanceSubsequent(this, argument);
  384. }
  385. /// <summary>
  386. /// Performs a indexed draw with 16-bit index buffer elements,
  387. /// while also pre-incrementing the current instance value.
  388. /// </summary>
  389. /// <param name="argument">Method call argument</param>
  390. private void DrawIndexBuffer16BeginEndInstanceSubsequent(int argument)
  391. {
  392. _drawManager.DrawIndexBuffer16BeginEndInstanceSubsequent(this, argument);
  393. }
  394. /// <summary>
  395. /// Performs a indexed draw with 32-bit index buffer elements,
  396. /// while also pre-incrementing the current instance value.
  397. /// </summary>
  398. /// <param name="argument">Method call argument</param>
  399. private void DrawIndexBuffer32BeginEndInstanceSubsequent(int argument)
  400. {
  401. _drawManager.DrawIndexBuffer32BeginEndInstanceSubsequent(this, argument);
  402. }
  403. /// <summary>
  404. /// Clears the current color and depth-stencil buffers.
  405. /// Which buffers should be cleared is also specified on the argument.
  406. /// </summary>
  407. /// <param name="argument">Method call argument</param>
  408. private void Clear(int argument)
  409. {
  410. _drawManager.Clear(this, argument);
  411. }
  412. /// <summary>
  413. /// Writes a GPU counter to guest memory.
  414. /// </summary>
  415. /// <param name="argument">Method call argument</param>
  416. private void Report(int argument)
  417. {
  418. _semaphoreUpdater.Report(argument);
  419. }
  420. /// <summary>
  421. /// Performs high-level emulation of Falcon microcode function number "4".
  422. /// </summary>
  423. /// <param name="argument">Method call argument</param>
  424. private void SetFalcon04(int argument)
  425. {
  426. _state.State.SetMmeShadowScratch[0] = 1;
  427. }
  428. /// <summary>
  429. /// Updates the uniform buffer data with inline data.
  430. /// </summary>
  431. /// <param name="argument">New uniform buffer data word</param>
  432. private void ConstantBufferUpdate(int argument)
  433. {
  434. _cbUpdater.Update(argument);
  435. }
  436. /// <summary>
  437. /// Binds a uniform buffer for the vertex shader stage.
  438. /// </summary>
  439. /// <param name="argument">Method call argument</param>
  440. private void ConstantBufferBindVertex(int argument)
  441. {
  442. _cbUpdater.BindVertex(argument);
  443. }
  444. /// <summary>
  445. /// Binds a uniform buffer for the tessellation control shader stage.
  446. /// </summary>
  447. /// <param name="argument">Method call argument</param>
  448. private void ConstantBufferBindTessControl(int argument)
  449. {
  450. _cbUpdater.BindTessControl(argument);
  451. }
  452. /// <summary>
  453. /// Binds a uniform buffer for the tessellation evaluation shader stage.
  454. /// </summary>
  455. /// <param name="argument">Method call argument</param>
  456. private void ConstantBufferBindTessEvaluation(int argument)
  457. {
  458. _cbUpdater.BindTessEvaluation(argument);
  459. }
  460. /// <summary>
  461. /// Binds a uniform buffer for the geometry shader stage.
  462. /// </summary>
  463. /// <param name="argument">Method call argument</param>
  464. private void ConstantBufferBindGeometry(int argument)
  465. {
  466. _cbUpdater.BindGeometry(argument);
  467. }
  468. /// <summary>
  469. /// Binds a uniform buffer for the fragment shader stage.
  470. /// </summary>
  471. /// <param name="argument">Method call argument</param>
  472. private void ConstantBufferBindFragment(int argument)
  473. {
  474. _cbUpdater.BindFragment(argument);
  475. }
  476. /// <summary>
  477. /// Generic register read function that just returns 0.
  478. /// </summary>
  479. /// <returns>Zero</returns>
  480. private static int Zero()
  481. {
  482. return 0;
  483. }
  484. /// <summary>
  485. /// Performs a indexed or non-indexed draw.
  486. /// </summary>
  487. /// <param name="topology">Primitive topology</param>
  488. /// <param name="count">Index count for indexed draws, vertex count for non-indexed draws</param>
  489. /// <param name="instanceCount">Instance count</param>
  490. /// <param name="firstIndex">First index on the index buffer for indexed draws, ignored for non-indexed draws</param>
  491. /// <param name="firstVertex">First vertex on the vertex buffer</param>
  492. /// <param name="firstInstance">First instance</param>
  493. /// <param name="indexed">True if the draw is indexed, false otherwise</param>
  494. public void Draw(
  495. PrimitiveTopology topology,
  496. int count,
  497. int instanceCount,
  498. int firstIndex,
  499. int firstVertex,
  500. int firstInstance,
  501. bool indexed)
  502. {
  503. _drawManager.Draw(this, topology, count, instanceCount, firstIndex, firstVertex, firstInstance, indexed);
  504. }
  505. /// <summary>
  506. /// Performs a indirect draw, with parameters from a GPU buffer.
  507. /// </summary>
  508. /// <param name="topology">Primitive topology</param>
  509. /// <param name="indirectBufferAddress">Address of the buffer with the draw parameters, such as count, first index, etc</param>
  510. /// <param name="parameterBufferAddress">Address of the buffer with the draw count</param>
  511. /// <param name="maxDrawCount">Maximum number of draws that can be made</param>
  512. /// <param name="stride">Distance in bytes between each entry on the data pointed to by <paramref name="indirectBufferAddress"/></param>
  513. /// <param name="indexCount">Maximum number of indices that the draw can consume</param>
  514. /// <param name="drawType">Type of the indirect draw, which can be indexed or non-indexed, with or without a draw count</param>
  515. public void DrawIndirect(
  516. PrimitiveTopology topology,
  517. ulong indirectBufferAddress,
  518. ulong parameterBufferAddress,
  519. int maxDrawCount,
  520. int stride,
  521. int indexCount,
  522. IndirectDrawType drawType)
  523. {
  524. _drawManager.DrawIndirect(this, topology, indirectBufferAddress, parameterBufferAddress, maxDrawCount, stride, indexCount, drawType);
  525. }
  526. /// <summary>
  527. /// Clears the current color and depth-stencil buffers.
  528. /// Which buffers should be cleared can also specified with the arguments.
  529. /// </summary>
  530. /// <param name="argument">Method call argument</param>
  531. /// <param name="layerCount">For array and 3D textures, indicates how many layers should be cleared</param>
  532. public void Clear(int argument, int layerCount)
  533. {
  534. _drawManager.Clear(this, argument, layerCount);
  535. }
  536. }
  537. }