TextureBindingsManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.Graphics.GAL;
  3. using Ryujinx.Graphics.Gpu.Engine.Types;
  4. using Ryujinx.Graphics.Shader;
  5. using System;
  6. namespace Ryujinx.Graphics.Gpu.Image
  7. {
  8. /// <summary>
  9. /// Texture bindings manager.
  10. /// </summary>
  11. class TextureBindingsManager : IDisposable
  12. {
  13. private const int InitialTextureStateSize = 32;
  14. private const int InitialImageStateSize = 8;
  15. private readonly GpuContext _context;
  16. private readonly bool _isCompute;
  17. private SamplerPool _samplerPool;
  18. private SamplerIndex _samplerIndex;
  19. private ulong _texturePoolAddress;
  20. private int _texturePoolMaximumId;
  21. private readonly GpuChannel _channel;
  22. private readonly TexturePoolCache _texturePoolCache;
  23. private readonly TextureBindingInfo[][] _textureBindings;
  24. private readonly TextureBindingInfo[][] _imageBindings;
  25. private struct TextureStatePerStage
  26. {
  27. public ITexture Texture;
  28. public ISampler Sampler;
  29. }
  30. private readonly TextureStatePerStage[][] _textureState;
  31. private readonly TextureStatePerStage[][] _imageState;
  32. private int[] _textureBindingsCount;
  33. private int[] _imageBindingsCount;
  34. private int _textureBufferIndex;
  35. private bool _rebind;
  36. private readonly float[] _scales;
  37. private bool _scaleChanged;
  38. private int _lastFragmentTotal;
  39. /// <summary>
  40. /// Constructs a new instance of the texture bindings manager.
  41. /// </summary>
  42. /// <param name="context">The GPU context that the texture bindings manager belongs to</param>
  43. /// <param name="channel">The GPU channel that the texture bindings manager belongs to</param>
  44. /// <param name="poolCache">Texture pools cache used to get texture pools from</param>
  45. /// <param name="scales">Array where the scales for the currently bound textures are stored</param>
  46. /// <param name="isCompute">True if the bindings manager is used for the compute engine</param>
  47. public TextureBindingsManager(GpuContext context, GpuChannel channel, TexturePoolCache poolCache, float[] scales, bool isCompute)
  48. {
  49. _context = context;
  50. _channel = channel;
  51. _texturePoolCache = poolCache;
  52. _scales = scales;
  53. _isCompute = isCompute;
  54. int stages = isCompute ? 1 : Constants.ShaderStages;
  55. _textureBindings = new TextureBindingInfo[stages][];
  56. _imageBindings = new TextureBindingInfo[stages][];
  57. _textureState = new TextureStatePerStage[stages][];
  58. _imageState = new TextureStatePerStage[stages][];
  59. _textureBindingsCount = new int[stages];
  60. _imageBindingsCount = new int[stages];
  61. for (int stage = 0; stage < stages; stage++)
  62. {
  63. _textureBindings[stage] = new TextureBindingInfo[InitialTextureStateSize];
  64. _imageBindings[stage] = new TextureBindingInfo[InitialImageStateSize];
  65. _textureState[stage] = new TextureStatePerStage[InitialTextureStateSize];
  66. _imageState[stage] = new TextureStatePerStage[InitialImageStateSize];
  67. }
  68. }
  69. /// <summary>
  70. /// Rents the texture bindings array for a given stage, so that they can be modified.
  71. /// </summary>
  72. /// <param name="stage">Shader stage number, or 0 for compute shaders</param>
  73. /// <param name="count">The number of bindings needed</param>
  74. /// <returns>The texture bindings array</returns>
  75. public TextureBindingInfo[] RentTextureBindings(int stage, int count)
  76. {
  77. if (count > _textureBindings[stage].Length)
  78. {
  79. Array.Resize(ref _textureBindings[stage], count);
  80. Array.Resize(ref _textureState[stage], count);
  81. }
  82. int toClear = Math.Max(_textureBindingsCount[stage], count);
  83. TextureStatePerStage[] state = _textureState[stage];
  84. for (int i = 0; i < toClear; i++)
  85. {
  86. state[i] = new TextureStatePerStage();
  87. }
  88. _textureBindingsCount[stage] = count;
  89. return _textureBindings[stage];
  90. }
  91. /// <summary>
  92. /// Rents the image bindings array for a given stage, so that they can be modified.
  93. /// </summary>
  94. /// <param name="stage">Shader stage number, or 0 for compute shaders</param>
  95. /// <param name="count">The number of bindings needed</param>
  96. /// <returns>The image bindings array</returns>
  97. public TextureBindingInfo[] RentImageBindings(int stage, int count)
  98. {
  99. if (count > _imageBindings[stage].Length)
  100. {
  101. Array.Resize(ref _imageBindings[stage], count);
  102. Array.Resize(ref _imageState[stage], count);
  103. }
  104. int toClear = Math.Max(_imageBindingsCount[stage], count);
  105. TextureStatePerStage[] state = _imageState[stage];
  106. for (int i = 0; i < toClear; i++)
  107. {
  108. state[i] = new TextureStatePerStage();
  109. }
  110. _imageBindingsCount[stage] = count;
  111. return _imageBindings[stage];
  112. }
  113. /// <summary>
  114. /// Sets the textures constant buffer index.
  115. /// The constant buffer specified holds the texture handles.
  116. /// </summary>
  117. /// <param name="index">Constant buffer index</param>
  118. public void SetTextureBufferIndex(int index)
  119. {
  120. _textureBufferIndex = index;
  121. }
  122. /// <summary>
  123. /// Sets the current texture sampler pool to be used.
  124. /// </summary>
  125. /// <param name="gpuVa">Start GPU virtual address of the pool</param>
  126. /// <param name="maximumId">Maximum ID of the pool (total count minus one)</param>
  127. /// <param name="samplerIndex">Type of the sampler pool indexing used for bound samplers</param>
  128. public void SetSamplerPool(ulong gpuVa, int maximumId, SamplerIndex samplerIndex)
  129. {
  130. if (gpuVa != 0)
  131. {
  132. ulong address = _channel.MemoryManager.Translate(gpuVa);
  133. if (_samplerPool != null && _samplerPool.Address == address && _samplerPool.MaximumId >= maximumId)
  134. {
  135. return;
  136. }
  137. _samplerPool?.Dispose();
  138. _samplerPool = new SamplerPool(_context, _channel.MemoryManager.Physical, address, maximumId);
  139. }
  140. else
  141. {
  142. _samplerPool?.Dispose();
  143. _samplerPool = null;
  144. }
  145. _samplerIndex = samplerIndex;
  146. }
  147. /// <summary>
  148. /// Sets the current texture pool to be used.
  149. /// </summary>
  150. /// <param name="gpuVa">Start GPU virtual address of the pool</param>
  151. /// <param name="maximumId">Maximum ID of the pool (total count minus one)</param>
  152. public void SetTexturePool(ulong gpuVa, int maximumId)
  153. {
  154. if (gpuVa != 0)
  155. {
  156. ulong address = _channel.MemoryManager.Translate(gpuVa);
  157. _texturePoolAddress = address;
  158. _texturePoolMaximumId = maximumId;
  159. }
  160. else
  161. {
  162. _texturePoolAddress = 0;
  163. _texturePoolMaximumId = 0;
  164. }
  165. }
  166. /// <summary>
  167. /// Gets a texture and a sampler from their respective pools from a texture ID and a sampler ID.
  168. /// </summary>
  169. /// <param name="textureId">ID of the texture</param>
  170. /// <param name="samplerId">ID of the sampler</param>
  171. public (Texture, Sampler) GetTextureAndSampler(int textureId, int samplerId)
  172. {
  173. ulong texturePoolAddress = _texturePoolAddress;
  174. TexturePool texturePool = texturePoolAddress != 0
  175. ? _texturePoolCache.FindOrCreate(_channel, texturePoolAddress, _texturePoolMaximumId)
  176. : null;
  177. return (texturePool.Get(textureId), _samplerPool.Get(samplerId));
  178. }
  179. /// <summary>
  180. /// Updates the texture scale for a given texture or image.
  181. /// </summary>
  182. /// <param name="texture">Start GPU virtual address of the pool</param>
  183. /// <param name="binding">The related texture binding</param>
  184. /// <param name="index">The texture/image binding index</param>
  185. /// <param name="stage">The active shader stage</param>
  186. /// <returns>True if the given texture has become blacklisted, indicating that its host texture may have changed.</returns>
  187. private bool UpdateScale(Texture texture, TextureBindingInfo binding, int index, ShaderStage stage)
  188. {
  189. float result = 1f;
  190. bool changed = false;
  191. if ((binding.Flags & TextureUsageFlags.NeedsScaleValue) != 0 && texture != null)
  192. {
  193. if ((binding.Flags & TextureUsageFlags.ResScaleUnsupported) != 0)
  194. {
  195. changed = texture.ScaleMode != TextureScaleMode.Blacklisted;
  196. texture.BlacklistScale();
  197. }
  198. else
  199. {
  200. switch (stage)
  201. {
  202. case ShaderStage.Fragment:
  203. float scale = texture.ScaleFactor;
  204. if (scale != 1)
  205. {
  206. Texture activeTarget = _channel.TextureManager.GetAnyRenderTarget();
  207. if (activeTarget != null && (activeTarget.Info.Width / (float)texture.Info.Width) == (activeTarget.Info.Height / (float)texture.Info.Height))
  208. {
  209. // If the texture's size is a multiple of the sampler size, enable interpolation using gl_FragCoord. (helps "invent" new integer values between scaled pixels)
  210. result = -scale;
  211. break;
  212. }
  213. }
  214. result = scale;
  215. break;
  216. case ShaderStage.Vertex:
  217. int fragmentIndex = (int)ShaderStage.Fragment - 1;
  218. index += _textureBindingsCount[fragmentIndex] + _imageBindingsCount[fragmentIndex];
  219. result = texture.ScaleFactor;
  220. break;
  221. case ShaderStage.Compute:
  222. result = texture.ScaleFactor;
  223. break;
  224. }
  225. }
  226. }
  227. if (result != _scales[index])
  228. {
  229. _scaleChanged = true;
  230. _scales[index] = result;
  231. }
  232. return changed;
  233. }
  234. /// <summary>
  235. /// Uploads texture and image scales to the backend when they are used.
  236. /// </summary>
  237. private void CommitRenderScale()
  238. {
  239. // Stage 0 total: Compute or Vertex.
  240. int total = _textureBindingsCount[0] + _imageBindingsCount[0];
  241. int fragmentIndex = (int)ShaderStage.Fragment - 1;
  242. int fragmentTotal = _isCompute ? 0 : (_textureBindingsCount[fragmentIndex] + _imageBindingsCount[fragmentIndex]);
  243. if (total != 0 && fragmentTotal != _lastFragmentTotal)
  244. {
  245. // Must update scales in the support buffer if:
  246. // - Vertex stage has bindings.
  247. // - Fragment stage binding count has been updated since last render scale update.
  248. _scaleChanged = true;
  249. }
  250. if (_scaleChanged)
  251. {
  252. if (!_isCompute)
  253. {
  254. total += fragmentTotal; // Add the fragment bindings to the total.
  255. }
  256. _lastFragmentTotal = fragmentTotal;
  257. _context.Renderer.Pipeline.UpdateRenderScale(_scales, total, fragmentTotal);
  258. _scaleChanged = false;
  259. }
  260. }
  261. /// <summary>
  262. /// Ensures that the bindings are visible to the host GPU.
  263. /// Note: this actually performs the binding using the host graphics API.
  264. /// </summary>
  265. public void CommitBindings()
  266. {
  267. ulong texturePoolAddress = _texturePoolAddress;
  268. TexturePool texturePool = texturePoolAddress != 0
  269. ? _texturePoolCache.FindOrCreate(_channel, texturePoolAddress, _texturePoolMaximumId)
  270. : null;
  271. if (_isCompute)
  272. {
  273. CommitTextureBindings(texturePool, ShaderStage.Compute, 0);
  274. CommitImageBindings (texturePool, ShaderStage.Compute, 0);
  275. }
  276. else
  277. {
  278. for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++)
  279. {
  280. int stageIndex = (int)stage - 1;
  281. CommitTextureBindings(texturePool, stage, stageIndex);
  282. CommitImageBindings (texturePool, stage, stageIndex);
  283. }
  284. }
  285. CommitRenderScale();
  286. _rebind = false;
  287. }
  288. /// <summary>
  289. /// Ensures that the texture bindings are visible to the host GPU.
  290. /// Note: this actually performs the binding using the host graphics API.
  291. /// </summary>
  292. /// <param name="pool">The current texture pool</param>
  293. /// <param name="stage">The shader stage using the textures to be bound</param>
  294. /// <param name="stageIndex">The stage number of the specified shader stage</param>
  295. private void CommitTextureBindings(TexturePool pool, ShaderStage stage, int stageIndex)
  296. {
  297. int textureCount = _textureBindingsCount[stageIndex];
  298. if (textureCount == 0)
  299. {
  300. return;
  301. }
  302. var samplerPool = _samplerPool;
  303. if (pool == null)
  304. {
  305. Logger.Error?.Print(LogClass.Gpu, $"Shader stage \"{stage}\" uses textures, but texture pool was not set.");
  306. return;
  307. }
  308. for (int index = 0; index < textureCount; index++)
  309. {
  310. TextureBindingInfo bindingInfo = _textureBindings[stageIndex][index];
  311. (int textureBufferIndex, int samplerBufferIndex) = TextureHandle.UnpackSlots(bindingInfo.CbufSlot, _textureBufferIndex);
  312. int packedId = ReadPackedId(stageIndex, bindingInfo.Handle, textureBufferIndex, samplerBufferIndex);
  313. int textureId = UnpackTextureId(packedId);
  314. int samplerId;
  315. if (_samplerIndex == SamplerIndex.ViaHeaderIndex)
  316. {
  317. samplerId = textureId;
  318. }
  319. else
  320. {
  321. samplerId = UnpackSamplerId(packedId);
  322. }
  323. Texture texture = pool.Get(textureId);
  324. ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
  325. if (hostTexture != null && texture.Target == Target.TextureBuffer)
  326. {
  327. // Ensure that the buffer texture is using the correct buffer as storage.
  328. // Buffers are frequently re-created to accomodate larger data, so we need to re-bind
  329. // to ensure we're not using a old buffer that was already deleted.
  330. _channel.BufferManager.SetBufferTextureStorage(hostTexture, texture.Range.GetSubRange(0).Address, texture.Size, bindingInfo, bindingInfo.Format, false);
  331. }
  332. else
  333. {
  334. if (_textureState[stageIndex][index].Texture != hostTexture || _rebind)
  335. {
  336. if (UpdateScale(texture, bindingInfo, index, stage))
  337. {
  338. hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
  339. }
  340. _textureState[stageIndex][index].Texture = hostTexture;
  341. _context.Renderer.Pipeline.SetTexture(bindingInfo.Binding, hostTexture);
  342. }
  343. Sampler sampler = samplerPool?.Get(samplerId);
  344. ISampler hostSampler = sampler?.GetHostSampler(texture);
  345. if (_textureState[stageIndex][index].Sampler != hostSampler || _rebind)
  346. {
  347. _textureState[stageIndex][index].Sampler = hostSampler;
  348. _context.Renderer.Pipeline.SetSampler(bindingInfo.Binding, hostSampler);
  349. }
  350. }
  351. }
  352. }
  353. /// <summary>
  354. /// Ensures that the image bindings are visible to the host GPU.
  355. /// Note: this actually performs the binding using the host graphics API.
  356. /// </summary>
  357. /// <param name="pool">The current texture pool</param>
  358. /// <param name="stage">The shader stage using the textures to be bound</param>
  359. /// <param name="stageIndex">The stage number of the specified shader stage</param>
  360. private void CommitImageBindings(TexturePool pool, ShaderStage stage, int stageIndex)
  361. {
  362. int imageCount = _imageBindingsCount[stageIndex];
  363. if (imageCount == 0)
  364. {
  365. return;
  366. }
  367. if (pool == null)
  368. {
  369. Logger.Error?.Print(LogClass.Gpu, $"Shader stage \"{stage}\" uses images, but texture pool was not set.");
  370. return;
  371. }
  372. // Scales for images appear after the texture ones.
  373. int baseScaleIndex = _textureBindingsCount[stageIndex];
  374. for (int index = 0; index < imageCount; index++)
  375. {
  376. TextureBindingInfo bindingInfo = _imageBindings[stageIndex][index];
  377. (int textureBufferIndex, int samplerBufferIndex) = TextureHandle.UnpackSlots(bindingInfo.CbufSlot, _textureBufferIndex);
  378. int packedId = ReadPackedId(stageIndex, bindingInfo.Handle, textureBufferIndex, samplerBufferIndex);
  379. int textureId = UnpackTextureId(packedId);
  380. Texture texture = pool.Get(textureId);
  381. ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
  382. bool isStore = bindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
  383. if (hostTexture != null && texture.Target == Target.TextureBuffer)
  384. {
  385. // Ensure that the buffer texture is using the correct buffer as storage.
  386. // Buffers are frequently re-created to accomodate larger data, so we need to re-bind
  387. // to ensure we're not using a old buffer that was already deleted.
  388. Format format = bindingInfo.Format;
  389. if (format == 0 && texture != null)
  390. {
  391. format = texture.Format;
  392. }
  393. _channel.BufferManager.SetBufferTextureStorage(hostTexture, texture.Range.GetSubRange(0).Address, texture.Size, bindingInfo, format, true);
  394. }
  395. else
  396. {
  397. if (isStore)
  398. {
  399. texture?.SignalModified();
  400. }
  401. if (_imageState[stageIndex][index].Texture != hostTexture || _rebind)
  402. {
  403. if (UpdateScale(texture, bindingInfo, baseScaleIndex + index, stage))
  404. {
  405. hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
  406. }
  407. _imageState[stageIndex][index].Texture = hostTexture;
  408. Format format = bindingInfo.Format;
  409. if (format == 0 && texture != null)
  410. {
  411. format = texture.Format;
  412. }
  413. _context.Renderer.Pipeline.SetImage(bindingInfo.Binding, hostTexture, format);
  414. }
  415. }
  416. }
  417. }
  418. /// <summary>
  419. /// Gets the texture descriptor for a given texture handle.
  420. /// </summary>
  421. /// <param name="poolGpuVa">GPU virtual address of the texture pool</param>
  422. /// <param name="bufferIndex">Index of the constant buffer with texture handles</param>
  423. /// <param name="maximumId">Maximum ID of the texture pool</param>
  424. /// <param name="stageIndex">The stage number where the texture is bound</param>
  425. /// <param name="handle">The texture handle</param>
  426. /// <param name="cbufSlot">The texture handle's constant buffer slot</param>
  427. /// <returns>The texture descriptor for the specified texture</returns>
  428. public TextureDescriptor GetTextureDescriptor(
  429. ulong poolGpuVa,
  430. int bufferIndex,
  431. int maximumId,
  432. int stageIndex,
  433. int handle,
  434. int cbufSlot)
  435. {
  436. (int textureBufferIndex, int samplerBufferIndex) = TextureHandle.UnpackSlots(cbufSlot, bufferIndex);
  437. int packedId = ReadPackedId(stageIndex, handle, textureBufferIndex, samplerBufferIndex);
  438. int textureId = UnpackTextureId(packedId);
  439. ulong poolAddress = _channel.MemoryManager.Translate(poolGpuVa);
  440. TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, poolAddress, maximumId);
  441. return texturePool.GetDescriptor(textureId);
  442. }
  443. /// <summary>
  444. /// Reads a packed texture and sampler ID (basically, the real texture handle)
  445. /// from the texture constant buffer.
  446. /// </summary>
  447. /// <param name="stageIndex">The number of the shader stage where the texture is bound</param>
  448. /// <param name="wordOffset">A word offset of the handle on the buffer (the "fake" shader handle)</param>
  449. /// <param name="textureBufferIndex">Index of the constant buffer holding the texture handles</param>
  450. /// <param name="samplerBufferIndex">Index of the constant buffer holding the sampler handles</param>
  451. /// <returns>The packed texture and sampler ID (the real texture handle)</returns>
  452. private int ReadPackedId(int stageIndex, int wordOffset, int textureBufferIndex, int samplerBufferIndex)
  453. {
  454. (int textureWordOffset, int samplerWordOffset, TextureHandleType handleType) = TextureHandle.UnpackOffsets(wordOffset);
  455. ulong textureBufferAddress = _isCompute
  456. ? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex)
  457. : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex);
  458. int handle = _channel.MemoryManager.Physical.Read<int>(textureBufferAddress + (uint)textureWordOffset * 4);
  459. // The "wordOffset" (which is really the immediate value used on texture instructions on the shader)
  460. // is a 13-bit value. However, in order to also support separate samplers and textures (which uses
  461. // bindless textures on the shader), we extend it with another value on the higher 16 bits with
  462. // another offset for the sampler.
  463. // The shader translator has code to detect separate texture and sampler uses with a bindless texture,
  464. // turn that into a regular texture access and produce those special handles with values on the higher 16 bits.
  465. if (handleType != TextureHandleType.CombinedSampler)
  466. {
  467. ulong samplerBufferAddress = _isCompute
  468. ? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex)
  469. : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex);
  470. int samplerHandle = _channel.MemoryManager.Physical.Read<int>(samplerBufferAddress + (uint)samplerWordOffset * 4);
  471. if (handleType == TextureHandleType.SeparateSamplerId)
  472. {
  473. samplerHandle <<= 20;
  474. }
  475. handle |= samplerHandle;
  476. }
  477. return handle;
  478. }
  479. /// <summary>
  480. /// Unpacks the texture ID from the real texture handle.
  481. /// </summary>
  482. /// <param name="packedId">The real texture handle</param>
  483. /// <returns>The texture ID</returns>
  484. private static int UnpackTextureId(int packedId)
  485. {
  486. return (packedId >> 0) & 0xfffff;
  487. }
  488. /// <summary>
  489. /// Unpacks the sampler ID from the real texture handle.
  490. /// </summary>
  491. /// <param name="packedId">The real texture handle</param>
  492. /// <returns>The sampler ID</returns>
  493. private static int UnpackSamplerId(int packedId)
  494. {
  495. return (packedId >> 20) & 0xfff;
  496. }
  497. /// <summary>
  498. /// Force all bound textures and images to be rebound the next time CommitBindings is called.
  499. /// </summary>
  500. public void Rebind()
  501. {
  502. _rebind = true;
  503. }
  504. /// <summary>
  505. /// Disposes all textures and samplers in the cache.
  506. /// </summary>
  507. public void Dispose()
  508. {
  509. _samplerPool?.Dispose();
  510. }
  511. }
  512. }