InstEmitSurface.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. using Ryujinx.Graphics.Shader.Decoders;
  2. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  3. using Ryujinx.Graphics.Shader.Translation;
  4. using System.Collections.Generic;
  5. using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper;
  6. using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
  7. namespace Ryujinx.Graphics.Shader.Instructions
  8. {
  9. static partial class InstEmit
  10. {
  11. public static void SuatomB(EmitterContext context)
  12. {
  13. InstSuatomB op = context.GetOp<InstSuatomB>();
  14. EmitSuatom(
  15. context,
  16. op.Dim,
  17. op.Op,
  18. op.Size,
  19. 0,
  20. op.SrcA,
  21. op.SrcB,
  22. op.SrcC,
  23. op.Dest,
  24. op.Ba,
  25. isBindless: true,
  26. compareAndSwap: false);
  27. }
  28. public static void Suatom(EmitterContext context)
  29. {
  30. InstSuatom op = context.GetOp<InstSuatom>();
  31. EmitSuatom(
  32. context,
  33. op.Dim,
  34. op.Op,
  35. op.Size,
  36. op.TidB,
  37. op.SrcA,
  38. op.SrcB,
  39. 0,
  40. op.Dest,
  41. op.Ba,
  42. isBindless: false,
  43. compareAndSwap: false);
  44. }
  45. public static void SuatomB2(EmitterContext context)
  46. {
  47. InstSuatomB2 op = context.GetOp<InstSuatomB2>();
  48. EmitSuatom(
  49. context,
  50. op.Dim,
  51. op.Op,
  52. op.Size,
  53. 0,
  54. op.SrcA,
  55. op.SrcB,
  56. op.SrcC,
  57. op.Dest,
  58. op.Ba,
  59. isBindless: true,
  60. compareAndSwap: false);
  61. }
  62. public static void SuatomCasB(EmitterContext context)
  63. {
  64. InstSuatomCasB op = context.GetOp<InstSuatomCasB>();
  65. EmitSuatom(
  66. context,
  67. op.Dim,
  68. 0,
  69. op.Size,
  70. 0,
  71. op.SrcA,
  72. op.SrcB,
  73. op.SrcC,
  74. op.Dest,
  75. op.Ba,
  76. isBindless: true,
  77. compareAndSwap: true);
  78. }
  79. public static void SuatomCas(EmitterContext context)
  80. {
  81. InstSuatomCas op = context.GetOp<InstSuatomCas>();
  82. EmitSuatom(
  83. context,
  84. op.Dim,
  85. 0,
  86. op.Size,
  87. op.TidB,
  88. op.SrcA,
  89. op.SrcB,
  90. 0,
  91. op.Dest,
  92. op.Ba,
  93. isBindless: false,
  94. compareAndSwap: true);
  95. }
  96. public static void SuldDB(EmitterContext context)
  97. {
  98. InstSuldDB op = context.GetOp<InstSuldDB>();
  99. EmitSuld(context, op.CacheOp, op.Dim, op.Size, 0, 0, op.SrcA, op.Dest, op.SrcC, useComponents: false, op.Ba, isBindless: true);
  100. }
  101. public static void SuldD(EmitterContext context)
  102. {
  103. InstSuldD op = context.GetOp<InstSuldD>();
  104. EmitSuld(context, op.CacheOp, op.Dim, op.Size, op.TidB, 0, op.SrcA, op.Dest, 0, useComponents: false, op.Ba, isBindless: false);
  105. }
  106. public static void SuldB(EmitterContext context)
  107. {
  108. InstSuldB op = context.GetOp<InstSuldB>();
  109. EmitSuld(context, op.CacheOp, op.Dim, 0, 0, op.Rgba, op.SrcA, op.Dest, 0, useComponents: true, false, isBindless: true);
  110. }
  111. public static void Suld(EmitterContext context)
  112. {
  113. InstSuld op = context.GetOp<InstSuld>();
  114. EmitSuld(context, op.CacheOp, op.Dim, 0, op.TidB, op.Rgba, op.SrcA, op.Dest, 0, useComponents: true, false, isBindless: false);
  115. }
  116. public static void SuredB(EmitterContext context)
  117. {
  118. InstSuredB op = context.GetOp<InstSuredB>();
  119. EmitSured(context, op.Dim, op.Op, op.Size, 0, op.SrcA, op.Dest, op.SrcC, op.Ba, isBindless: true);
  120. }
  121. public static void Sured(EmitterContext context)
  122. {
  123. InstSured op = context.GetOp<InstSured>();
  124. EmitSured(context, op.Dim, op.Op, op.Size, op.TidB, op.SrcA, op.Dest, 0, op.Ba, isBindless: false);
  125. }
  126. public static void SustDB(EmitterContext context)
  127. {
  128. InstSustDB op = context.GetOp<InstSustDB>();
  129. EmitSust(context, op.CacheOp, op.Dim, op.Size, 0, 0, op.SrcA, op.Dest, op.SrcC, useComponents: false, op.Ba, isBindless: true);
  130. }
  131. public static void SustD(EmitterContext context)
  132. {
  133. InstSustD op = context.GetOp<InstSustD>();
  134. EmitSust(context, op.CacheOp, op.Dim, op.Size, op.TidB, 0, op.SrcA, op.Dest, 0, useComponents: false, op.Ba, isBindless: false);
  135. }
  136. public static void SustB(EmitterContext context)
  137. {
  138. InstSustB op = context.GetOp<InstSustB>();
  139. EmitSust(context, op.CacheOp, op.Dim, 0, 0, op.Rgba, op.SrcA, op.Dest, op.SrcC, useComponents: true, false, isBindless: true);
  140. }
  141. public static void Sust(EmitterContext context)
  142. {
  143. InstSust op = context.GetOp<InstSust>();
  144. EmitSust(context, op.CacheOp, op.Dim, 0, op.TidB, op.Rgba, op.SrcA, op.Dest, 0, useComponents: true, false, isBindless: false);
  145. }
  146. private static void EmitSuatom(
  147. EmitterContext context,
  148. SuDim dimensions,
  149. SuatomOp atomicOp,
  150. SuatomSize size,
  151. int imm,
  152. int srcA,
  153. int srcB,
  154. int srcC,
  155. int dest,
  156. bool byteAddress,
  157. bool isBindless,
  158. bool compareAndSwap)
  159. {
  160. SamplerType type = ConvertSamplerType(dimensions);
  161. if (type == SamplerType.None)
  162. {
  163. context.Config.GpuAccessor.Log("Invalid image atomic sampler type.");
  164. return;
  165. }
  166. Operand Ra()
  167. {
  168. if (srcA > RegisterConsts.RegisterZeroIndex)
  169. {
  170. return Const(0);
  171. }
  172. return context.Copy(Register(srcA++, RegisterType.Gpr));
  173. }
  174. Operand Rb()
  175. {
  176. if (srcB > RegisterConsts.RegisterZeroIndex)
  177. {
  178. return Const(0);
  179. }
  180. return context.Copy(Register(srcB++, RegisterType.Gpr));
  181. }
  182. Operand GetDest()
  183. {
  184. if (dest >= RegisterConsts.RegisterZeroIndex)
  185. {
  186. return null;
  187. }
  188. return Register(dest++, RegisterType.Gpr);
  189. }
  190. List<Operand> sourcesList = new List<Operand>();
  191. if (isBindless)
  192. {
  193. sourcesList.Add(context.Copy(GetSrcReg(context, srcC)));
  194. }
  195. int coordsCount = type.GetDimensions();
  196. for (int index = 0; index < coordsCount; index++)
  197. {
  198. sourcesList.Add(Ra());
  199. }
  200. if (Sample1DAs2D && (type & SamplerType.Mask) == SamplerType.Texture1D)
  201. {
  202. sourcesList.Add(Const(0));
  203. type &= ~SamplerType.Mask;
  204. type |= SamplerType.Texture2D;
  205. }
  206. if (type.HasFlag(SamplerType.Array))
  207. {
  208. sourcesList.Add(Ra());
  209. type |= SamplerType.Array;
  210. }
  211. if (byteAddress)
  212. {
  213. int xIndex = isBindless ? 1 : 0;
  214. sourcesList[xIndex] = context.ShiftRightS32(sourcesList[xIndex], Const(GetComponentSizeInBytesLog2(size)));
  215. }
  216. // TODO: FP and 64-bit formats.
  217. TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64
  218. ? (isBindless ? TextureFormat.Unknown : context.Config.GetTextureFormatAtomic(imm))
  219. : GetTextureFormat(size);
  220. if (compareAndSwap)
  221. {
  222. sourcesList.Add(Rb());
  223. }
  224. sourcesList.Add(Rb());
  225. Operand[] sources = sourcesList.ToArray();
  226. TextureFlags flags = compareAndSwap ? TextureFlags.CAS : GetAtomicOpFlags(atomicOp);
  227. if (isBindless)
  228. {
  229. flags |= TextureFlags.Bindless;
  230. }
  231. TextureOperation operation = context.CreateTextureOperation(
  232. Instruction.ImageAtomic,
  233. type,
  234. format,
  235. flags,
  236. imm,
  237. 0,
  238. GetDest(),
  239. sources);
  240. context.Add(operation);
  241. }
  242. private static void EmitSuld(
  243. EmitterContext context,
  244. CacheOpLd cacheOp,
  245. SuDim dimensions,
  246. SuSize size,
  247. int imm,
  248. SuRgba componentMask,
  249. int srcA,
  250. int srcB,
  251. int srcC,
  252. bool useComponents,
  253. bool byteAddress,
  254. bool isBindless)
  255. {
  256. context.Config.SetUsedFeature(FeatureFlags.IntegerSampling);
  257. SamplerType type = ConvertSamplerType(dimensions);
  258. if (type == SamplerType.None)
  259. {
  260. context.Config.GpuAccessor.Log("Invalid image store sampler type.");
  261. return;
  262. }
  263. Operand Ra()
  264. {
  265. if (srcA > RegisterConsts.RegisterZeroIndex)
  266. {
  267. return Const(0);
  268. }
  269. return context.Copy(Register(srcA++, RegisterType.Gpr));
  270. }
  271. List<Operand> sourcesList = new List<Operand>();
  272. if (isBindless)
  273. {
  274. sourcesList.Add(context.Copy(Register(srcC, RegisterType.Gpr)));
  275. }
  276. int coordsCount = type.GetDimensions();
  277. for (int index = 0; index < coordsCount; index++)
  278. {
  279. sourcesList.Add(Ra());
  280. }
  281. if (Sample1DAs2D && (type & SamplerType.Mask) == SamplerType.Texture1D)
  282. {
  283. sourcesList.Add(Const(0));
  284. type &= ~SamplerType.Mask;
  285. type |= SamplerType.Texture2D;
  286. }
  287. if (type.HasFlag(SamplerType.Array))
  288. {
  289. sourcesList.Add(Ra());
  290. }
  291. Operand[] sources = sourcesList.ToArray();
  292. int handle = imm;
  293. TextureFlags flags = isBindless ? TextureFlags.Bindless : TextureFlags.None;
  294. if (cacheOp == CacheOpLd.Cg)
  295. {
  296. flags |= TextureFlags.Coherent;
  297. }
  298. if (useComponents)
  299. {
  300. for (int compMask = (int)componentMask, compIndex = 0; compMask != 0; compMask >>= 1, compIndex++)
  301. {
  302. if ((compMask & 1) == 0)
  303. {
  304. continue;
  305. }
  306. if (srcB == RegisterConsts.RegisterZeroIndex)
  307. {
  308. break;
  309. }
  310. Operand rd = Register(srcB++, RegisterType.Gpr);
  311. TextureOperation operation = context.CreateTextureOperation(
  312. Instruction.ImageLoad,
  313. type,
  314. flags,
  315. handle,
  316. compIndex,
  317. rd,
  318. sources);
  319. if (!isBindless)
  320. {
  321. operation.Format = context.Config.GetTextureFormat(handle);
  322. }
  323. context.Add(operation);
  324. }
  325. }
  326. else
  327. {
  328. if (byteAddress)
  329. {
  330. int xIndex = isBindless ? 1 : 0;
  331. sources[xIndex] = context.ShiftRightS32(sources[xIndex], Const(GetComponentSizeInBytesLog2(size)));
  332. }
  333. int components = GetComponents(size);
  334. for (int compIndex = 0; compIndex < components; compIndex++)
  335. {
  336. if (srcB == RegisterConsts.RegisterZeroIndex)
  337. {
  338. break;
  339. }
  340. Operand rd = Register(srcB++, RegisterType.Gpr);
  341. TextureOperation operation = context.CreateTextureOperation(
  342. Instruction.ImageLoad,
  343. type,
  344. GetTextureFormat(size),
  345. flags,
  346. handle,
  347. compIndex,
  348. rd,
  349. sources);
  350. context.Add(operation);
  351. switch (size)
  352. {
  353. case SuSize.U8: context.Copy(rd, ZeroExtendTo32(context, rd, 8)); break;
  354. case SuSize.U16: context.Copy(rd, ZeroExtendTo32(context, rd, 16)); break;
  355. case SuSize.S8: context.Copy(rd, SignExtendTo32(context, rd, 8)); break;
  356. case SuSize.S16: context.Copy(rd, SignExtendTo32(context, rd, 16)); break;
  357. }
  358. }
  359. }
  360. }
  361. private static void EmitSured(
  362. EmitterContext context,
  363. SuDim dimensions,
  364. RedOp atomicOp,
  365. SuatomSize size,
  366. int imm,
  367. int srcA,
  368. int srcB,
  369. int srcC,
  370. bool byteAddress,
  371. bool isBindless)
  372. {
  373. SamplerType type = ConvertSamplerType(dimensions);
  374. if (type == SamplerType.None)
  375. {
  376. context.Config.GpuAccessor.Log("Invalid image reduction sampler type.");
  377. return;
  378. }
  379. Operand Ra()
  380. {
  381. if (srcA > RegisterConsts.RegisterZeroIndex)
  382. {
  383. return Const(0);
  384. }
  385. return context.Copy(Register(srcA++, RegisterType.Gpr));
  386. }
  387. Operand Rb()
  388. {
  389. if (srcB > RegisterConsts.RegisterZeroIndex)
  390. {
  391. return Const(0);
  392. }
  393. return context.Copy(Register(srcB++, RegisterType.Gpr));
  394. }
  395. List<Operand> sourcesList = new List<Operand>();
  396. if (isBindless)
  397. {
  398. sourcesList.Add(context.Copy(GetSrcReg(context, srcC)));
  399. }
  400. int coordsCount = type.GetDimensions();
  401. for (int index = 0; index < coordsCount; index++)
  402. {
  403. sourcesList.Add(Ra());
  404. }
  405. if (Sample1DAs2D && (type & SamplerType.Mask) == SamplerType.Texture1D)
  406. {
  407. sourcesList.Add(Const(0));
  408. type &= ~SamplerType.Mask;
  409. type |= SamplerType.Texture2D;
  410. }
  411. if (type.HasFlag(SamplerType.Array))
  412. {
  413. sourcesList.Add(Ra());
  414. type |= SamplerType.Array;
  415. }
  416. if (byteAddress)
  417. {
  418. int xIndex = isBindless ? 1 : 0;
  419. sourcesList[xIndex] = context.ShiftRightS32(sourcesList[xIndex], Const(GetComponentSizeInBytesLog2(size)));
  420. }
  421. // TODO: FP and 64-bit formats.
  422. TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64
  423. ? (isBindless ? TextureFormat.Unknown : context.Config.GetTextureFormatAtomic(imm))
  424. : GetTextureFormat(size);
  425. sourcesList.Add(Rb());
  426. Operand[] sources = sourcesList.ToArray();
  427. TextureFlags flags = GetAtomicOpFlags((SuatomOp)atomicOp);
  428. if (isBindless)
  429. {
  430. flags |= TextureFlags.Bindless;
  431. }
  432. TextureOperation operation = context.CreateTextureOperation(
  433. Instruction.ImageAtomic,
  434. type,
  435. format,
  436. flags,
  437. imm,
  438. 0,
  439. null,
  440. sources);
  441. context.Add(operation);
  442. }
  443. private static void EmitSust(
  444. EmitterContext context,
  445. CacheOpSt cacheOp,
  446. SuDim dimensions,
  447. SuSize size,
  448. int imm,
  449. SuRgba componentMask,
  450. int srcA,
  451. int srcB,
  452. int srcC,
  453. bool useComponents,
  454. bool byteAddress,
  455. bool isBindless)
  456. {
  457. SamplerType type = ConvertSamplerType(dimensions);
  458. if (type == SamplerType.None)
  459. {
  460. context.Config.GpuAccessor.Log("Invalid image store sampler type.");
  461. return;
  462. }
  463. Operand Ra()
  464. {
  465. if (srcA > RegisterConsts.RegisterZeroIndex)
  466. {
  467. return Const(0);
  468. }
  469. return context.Copy(Register(srcA++, RegisterType.Gpr));
  470. }
  471. Operand Rb()
  472. {
  473. if (srcB > RegisterConsts.RegisterZeroIndex)
  474. {
  475. return Const(0);
  476. }
  477. return context.Copy(Register(srcB++, RegisterType.Gpr));
  478. }
  479. List<Operand> sourcesList = new List<Operand>();
  480. if (isBindless)
  481. {
  482. sourcesList.Add(context.Copy(Register(srcC, RegisterType.Gpr)));
  483. }
  484. int coordsCount = type.GetDimensions();
  485. for (int index = 0; index < coordsCount; index++)
  486. {
  487. sourcesList.Add(Ra());
  488. }
  489. if (Sample1DAs2D && (type & SamplerType.Mask) == SamplerType.Texture1D)
  490. {
  491. sourcesList.Add(Const(0));
  492. type &= ~SamplerType.Mask;
  493. type |= SamplerType.Texture2D;
  494. }
  495. if (type.HasFlag(SamplerType.Array))
  496. {
  497. sourcesList.Add(Ra());
  498. }
  499. TextureFormat format = TextureFormat.Unknown;
  500. if (useComponents)
  501. {
  502. for (int compMask = (int)componentMask, compIndex = 0; compMask != 0; compMask >>= 1, compIndex++)
  503. {
  504. if ((compMask & 1) != 0)
  505. {
  506. sourcesList.Add(Rb());
  507. }
  508. }
  509. if (!isBindless)
  510. {
  511. format = context.Config.GetTextureFormat(imm);
  512. }
  513. }
  514. else
  515. {
  516. if (byteAddress)
  517. {
  518. int xIndex = isBindless ? 1 : 0;
  519. sourcesList[xIndex] = context.ShiftRightS32(sourcesList[xIndex], Const(GetComponentSizeInBytesLog2(size)));
  520. }
  521. int components = GetComponents(size);
  522. for (int compIndex = 0; compIndex < components; compIndex++)
  523. {
  524. sourcesList.Add(Rb());
  525. }
  526. format = GetTextureFormat(size);
  527. }
  528. Operand[] sources = sourcesList.ToArray();
  529. int handle = imm;
  530. TextureFlags flags = isBindless ? TextureFlags.Bindless : TextureFlags.None;
  531. if (cacheOp == CacheOpSt.Cg)
  532. {
  533. flags |= TextureFlags.Coherent;
  534. }
  535. TextureOperation operation = context.CreateTextureOperation(
  536. Instruction.ImageStore,
  537. type,
  538. format,
  539. flags,
  540. handle,
  541. 0,
  542. null,
  543. sources);
  544. context.Add(operation);
  545. }
  546. private static int GetComponentSizeInBytesLog2(SuatomSize size)
  547. {
  548. return size switch
  549. {
  550. SuatomSize.U32 => 2,
  551. SuatomSize.S32 => 2,
  552. SuatomSize.U64 => 3,
  553. SuatomSize.F32FtzRn => 2,
  554. SuatomSize.F16x2FtzRn => 2,
  555. SuatomSize.S64 => 3,
  556. SuatomSize.Sd32 => 2,
  557. SuatomSize.Sd64 => 3,
  558. _ => 2
  559. };
  560. }
  561. private static TextureFormat GetTextureFormat(SuatomSize size)
  562. {
  563. return size switch
  564. {
  565. SuatomSize.U32 => TextureFormat.R32Uint,
  566. SuatomSize.S32 => TextureFormat.R32Sint,
  567. SuatomSize.U64 => TextureFormat.R32G32Uint,
  568. SuatomSize.F32FtzRn => TextureFormat.R32Float,
  569. SuatomSize.F16x2FtzRn => TextureFormat.R16G16Float,
  570. SuatomSize.S64 => TextureFormat.R32G32Uint,
  571. SuatomSize.Sd32 => TextureFormat.R32Uint,
  572. SuatomSize.Sd64 => TextureFormat.R32G32Uint,
  573. _ => TextureFormat.R32Uint
  574. };
  575. }
  576. private static TextureFlags GetAtomicOpFlags(SuatomOp op)
  577. {
  578. return op switch
  579. {
  580. SuatomOp.Add => TextureFlags.Add,
  581. SuatomOp.Min => TextureFlags.Minimum,
  582. SuatomOp.Max => TextureFlags.Maximum,
  583. SuatomOp.Inc => TextureFlags.Increment,
  584. SuatomOp.Dec => TextureFlags.Decrement,
  585. SuatomOp.And => TextureFlags.BitwiseAnd,
  586. SuatomOp.Or => TextureFlags.BitwiseOr,
  587. SuatomOp.Xor => TextureFlags.BitwiseXor,
  588. SuatomOp.Exch => TextureFlags.Swap,
  589. _ => TextureFlags.Add
  590. };
  591. }
  592. private static int GetComponents(SuSize size)
  593. {
  594. return size switch
  595. {
  596. SuSize.B64 => 2,
  597. SuSize.B128 => 4,
  598. SuSize.UB128 => 4,
  599. _ => 1
  600. };
  601. }
  602. private static int GetComponentSizeInBytesLog2(SuSize size)
  603. {
  604. return size switch
  605. {
  606. SuSize.U8 => 0,
  607. SuSize.S8 => 0,
  608. SuSize.U16 => 1,
  609. SuSize.S16 => 1,
  610. SuSize.B32 => 2,
  611. SuSize.B64 => 3,
  612. SuSize.B128 => 4,
  613. SuSize.UB128 => 4,
  614. _ => 2
  615. };
  616. }
  617. private static TextureFormat GetTextureFormat(SuSize size)
  618. {
  619. return size switch
  620. {
  621. SuSize.U8 => TextureFormat.R8Uint,
  622. SuSize.S8 => TextureFormat.R8Sint,
  623. SuSize.U16 => TextureFormat.R16Uint,
  624. SuSize.S16 => TextureFormat.R16Sint,
  625. SuSize.B32 => TextureFormat.R32Uint,
  626. SuSize.B64 => TextureFormat.R32G32Uint,
  627. SuSize.B128 => TextureFormat.R32G32B32A32Uint,
  628. SuSize.UB128 => TextureFormat.R32G32B32A32Uint,
  629. _ => TextureFormat.R32Uint
  630. };
  631. }
  632. private static SamplerType ConvertSamplerType(SuDim target)
  633. {
  634. return target switch
  635. {
  636. SuDim._1d => SamplerType.Texture1D,
  637. SuDim._1dBuffer => SamplerType.TextureBuffer,
  638. SuDim._1dArray => SamplerType.Texture1D | SamplerType.Array,
  639. SuDim._2d => SamplerType.Texture2D,
  640. SuDim._2dArray => SamplerType.Texture2D | SamplerType.Array,
  641. SuDim._3d => SamplerType.Texture3D,
  642. _ => SamplerType.None
  643. };
  644. }
  645. }
  646. }