Rewriter.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. using Ryujinx.Graphics.Shader.Decoders;
  2. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Numerics;
  7. using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
  8. using static Ryujinx.Graphics.Shader.Translation.GlobalMemory;
  9. namespace Ryujinx.Graphics.Shader.Translation
  10. {
  11. static class Rewriter
  12. {
  13. public static void RunPass(BasicBlock[] blocks, ShaderConfig config)
  14. {
  15. bool isVertexShader = config.Stage == ShaderStage.Vertex;
  16. bool hasConstantBufferDrawParameters = config.GpuAccessor.QueryHasConstantBufferDrawParameters();
  17. bool supportsSnormBufferTextureFormat = config.GpuAccessor.QueryHostSupportsSnormBufferTextureFormat();
  18. for (int blkIndex = 0; blkIndex < blocks.Length; blkIndex++)
  19. {
  20. BasicBlock block = blocks[blkIndex];
  21. for (LinkedListNode<INode> node = block.Operations.First; node != null;)
  22. {
  23. if (node.Value is not Operation operation)
  24. {
  25. node = node.Next;
  26. continue;
  27. }
  28. if (isVertexShader)
  29. {
  30. if (hasConstantBufferDrawParameters)
  31. {
  32. if (ReplaceConstantBufferWithDrawParameters(operation))
  33. {
  34. config.SetUsedFeature(FeatureFlags.DrawParameters);
  35. }
  36. }
  37. else if (HasConstantBufferDrawParameters(operation))
  38. {
  39. config.SetUsedFeature(FeatureFlags.DrawParameters);
  40. }
  41. }
  42. LinkedListNode<INode> nextNode = node.Next;
  43. if (operation is TextureOperation texOp)
  44. {
  45. if (texOp.Inst == Instruction.TextureSample)
  46. {
  47. node = RewriteTextureSample(node, config);
  48. if (texOp.Type == SamplerType.TextureBuffer && !supportsSnormBufferTextureFormat)
  49. {
  50. node = InsertSnormNormalization(node, config);
  51. }
  52. }
  53. nextNode = node.Next;
  54. }
  55. else if (UsesGlobalMemory(operation.Inst))
  56. {
  57. nextNode = RewriteGlobalAccess(node, config)?.Next ?? nextNode;
  58. }
  59. node = nextNode;
  60. }
  61. }
  62. }
  63. private static LinkedListNode<INode> RewriteGlobalAccess(LinkedListNode<INode> node, ShaderConfig config)
  64. {
  65. Operation operation = (Operation)node.Value;
  66. bool isAtomic = operation.Inst.IsAtomic();
  67. bool isStg16Or8 = operation.Inst == Instruction.StoreGlobal16 || operation.Inst == Instruction.StoreGlobal8;
  68. bool isWrite = isAtomic || operation.Inst == Instruction.StoreGlobal || isStg16Or8;
  69. Operation storageOp = null;
  70. Operand PrependOperation(Instruction inst, params Operand[] sources)
  71. {
  72. Operand local = Local();
  73. node.List.AddBefore(node, new Operation(inst, local, sources));
  74. return local;
  75. }
  76. Operand PrependExistingOperation(Operation operation)
  77. {
  78. Operand local = Local();
  79. operation.Dest = local;
  80. node.List.AddBefore(node, operation);
  81. return local;
  82. }
  83. Operand addrLow = operation.GetSource(0);
  84. Operand addrHigh = operation.GetSource(1);
  85. Operand sbBaseAddrLow = Const(0);
  86. Operand sbSlot = Const(0);
  87. Operand alignMask = Const(-config.GpuAccessor.QueryHostStorageBufferOffsetAlignment());
  88. Operand BindingRangeCheck(int cbOffset, out Operand baseAddrLow)
  89. {
  90. baseAddrLow = Cbuf(0, cbOffset);
  91. Operand baseAddrHigh = Cbuf(0, cbOffset + 1);
  92. Operand size = Cbuf(0, cbOffset + 2);
  93. Operand offset = PrependOperation(Instruction.Subtract, addrLow, baseAddrLow);
  94. Operand borrow = PrependOperation(Instruction.CompareLessU32, addrLow, baseAddrLow);
  95. Operand inRangeLow = PrependOperation(Instruction.CompareLessU32, offset, size);
  96. Operand addrHighBorrowed = PrependOperation(Instruction.Add, addrHigh, borrow);
  97. Operand inRangeHigh = PrependOperation(Instruction.CompareEqual, addrHighBorrowed, baseAddrHigh);
  98. return PrependOperation(Instruction.BitwiseAnd, inRangeLow, inRangeHigh);
  99. }
  100. int sbUseMask = config.AccessibleStorageBuffersMask;
  101. while (sbUseMask != 0)
  102. {
  103. int slot = BitOperations.TrailingZeroCount(sbUseMask);
  104. sbUseMask &= ~(1 << slot);
  105. config.SetUsedStorageBuffer(slot, isWrite);
  106. int cbOffset = GetStorageCbOffset(config.Stage, slot);
  107. Operand inRange = BindingRangeCheck(cbOffset, out Operand baseAddrLow);
  108. sbBaseAddrLow = PrependOperation(Instruction.ConditionalSelect, inRange, baseAddrLow, sbBaseAddrLow);
  109. sbSlot = PrependOperation(Instruction.ConditionalSelect, inRange, Const(slot), sbSlot);
  110. }
  111. if (config.AccessibleStorageBuffersMask != 0)
  112. {
  113. Operand baseAddrTrunc = PrependOperation(Instruction.BitwiseAnd, sbBaseAddrLow, alignMask);
  114. Operand byteOffset = PrependOperation(Instruction.Subtract, addrLow, baseAddrTrunc);
  115. Operand[] sources = new Operand[operation.SourcesCount];
  116. sources[0] = sbSlot;
  117. if (isStg16Or8)
  118. {
  119. sources[1] = byteOffset;
  120. }
  121. else
  122. {
  123. sources[1] = PrependOperation(Instruction.ShiftRightU32, byteOffset, Const(2));
  124. }
  125. for (int index = 2; index < operation.SourcesCount; index++)
  126. {
  127. sources[index] = operation.GetSource(index);
  128. }
  129. if (isAtomic)
  130. {
  131. Instruction inst = (operation.Inst & ~Instruction.MrMask) | Instruction.MrStorage;
  132. storageOp = new Operation(inst, operation.Dest, sources);
  133. }
  134. else if (operation.Inst == Instruction.LoadGlobal)
  135. {
  136. storageOp = new Operation(Instruction.LoadStorage, operation.Dest, sources);
  137. }
  138. else
  139. {
  140. Instruction storeInst = operation.Inst switch
  141. {
  142. Instruction.StoreGlobal16 => Instruction.StoreStorage16,
  143. Instruction.StoreGlobal8 => Instruction.StoreStorage8,
  144. _ => Instruction.StoreStorage
  145. };
  146. storageOp = new Operation(storeInst, null, sources);
  147. }
  148. }
  149. else if (operation.Dest != null)
  150. {
  151. storageOp = new Operation(Instruction.Copy, operation.Dest, Const(0));
  152. }
  153. if (operation.Inst == Instruction.LoadGlobal)
  154. {
  155. int cbeUseMask = config.AccessibleConstantBuffersMask;
  156. while (cbeUseMask != 0)
  157. {
  158. int slot = BitOperations.TrailingZeroCount(cbeUseMask);
  159. int cbSlot = UbeFirstCbuf + slot;
  160. cbeUseMask &= ~(1 << slot);
  161. config.SetUsedConstantBuffer(cbSlot);
  162. Operand previousResult = PrependExistingOperation(storageOp);
  163. int cbOffset = GetConstantUbeOffset(slot);
  164. Operand inRange = BindingRangeCheck(cbOffset, out Operand baseAddrLow);
  165. Operand baseAddrTruncConst = PrependOperation(Instruction.BitwiseAnd, baseAddrLow, alignMask);
  166. Operand byteOffsetConst = PrependOperation(Instruction.Subtract, addrLow, baseAddrTruncConst);
  167. Operand cbIndex = PrependOperation(Instruction.ShiftRightU32, byteOffsetConst, Const(2));
  168. Operand[] sourcesCb = new Operand[operation.SourcesCount];
  169. sourcesCb[0] = Const(cbSlot);
  170. sourcesCb[1] = cbIndex;
  171. for (int index = 2; index < operation.SourcesCount; index++)
  172. {
  173. sourcesCb[index] = operation.GetSource(index);
  174. }
  175. Operand ldcResult = PrependOperation(Instruction.LoadConstant, sourcesCb);
  176. storageOp = new Operation(Instruction.ConditionalSelect, operation.Dest, inRange, ldcResult, previousResult);
  177. }
  178. }
  179. for (int index = 0; index < operation.SourcesCount; index++)
  180. {
  181. operation.SetSource(index, null);
  182. }
  183. LinkedListNode<INode> oldNode = node;
  184. LinkedList<INode> oldNodeList = oldNode.List;
  185. if (storageOp != null)
  186. {
  187. node = node.List.AddBefore(node, storageOp);
  188. }
  189. else
  190. {
  191. node = null;
  192. }
  193. oldNodeList.Remove(oldNode);
  194. return node;
  195. }
  196. private static LinkedListNode<INode> RewriteTextureSample(LinkedListNode<INode> node, ShaderConfig config)
  197. {
  198. TextureOperation texOp = (TextureOperation)node.Value;
  199. bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0;
  200. bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0;
  201. bool hasInvalidOffset = (hasOffset || hasOffsets) && !config.GpuAccessor.QueryHostSupportsNonConstantTextureOffset();
  202. bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0;
  203. bool isCoordNormalized = isBindless || config.GpuAccessor.QueryTextureCoordNormalized(texOp.Handle, texOp.CbufSlot);
  204. if (!hasInvalidOffset && isCoordNormalized)
  205. {
  206. return node;
  207. }
  208. bool isGather = (texOp.Flags & TextureFlags.Gather) != 0;
  209. bool hasDerivatives = (texOp.Flags & TextureFlags.Derivatives) != 0;
  210. bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0;
  211. bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0;
  212. bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0;
  213. bool isArray = (texOp.Type & SamplerType.Array) != 0;
  214. bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0;
  215. bool isMultisample = (texOp.Type & SamplerType.Multisample) != 0;
  216. bool isShadow = (texOp.Type & SamplerType.Shadow) != 0;
  217. int coordsCount = texOp.Type.GetDimensions();
  218. int offsetsCount;
  219. if (hasOffsets)
  220. {
  221. offsetsCount = coordsCount * 4;
  222. }
  223. else if (hasOffset)
  224. {
  225. offsetsCount = coordsCount;
  226. }
  227. else
  228. {
  229. offsetsCount = 0;
  230. }
  231. Operand[] offsets = new Operand[offsetsCount];
  232. Operand[] sources = new Operand[texOp.SourcesCount - offsetsCount];
  233. int copyCount = 0;
  234. if (isBindless || isIndexed)
  235. {
  236. copyCount++;
  237. }
  238. Operand[] lodSources = new Operand[copyCount + coordsCount];
  239. for (int index = 0; index < lodSources.Length; index++)
  240. {
  241. lodSources[index] = texOp.GetSource(index);
  242. }
  243. copyCount += coordsCount;
  244. if (isArray)
  245. {
  246. copyCount++;
  247. }
  248. if (isShadow)
  249. {
  250. copyCount++;
  251. }
  252. if (hasDerivatives)
  253. {
  254. copyCount += coordsCount * 2;
  255. }
  256. if (isMultisample)
  257. {
  258. copyCount++;
  259. }
  260. else if (hasLodLevel)
  261. {
  262. copyCount++;
  263. }
  264. int srcIndex = 0;
  265. int dstIndex = 0;
  266. for (int index = 0; index < copyCount; index++)
  267. {
  268. sources[dstIndex++] = texOp.GetSource(srcIndex++);
  269. }
  270. bool areAllOffsetsConstant = true;
  271. for (int index = 0; index < offsetsCount; index++)
  272. {
  273. Operand offset = texOp.GetSource(srcIndex++);
  274. areAllOffsetsConstant &= offset.Type == OperandType.Constant;
  275. offsets[index] = offset;
  276. }
  277. hasInvalidOffset &= !areAllOffsetsConstant;
  278. if (!hasInvalidOffset && isCoordNormalized)
  279. {
  280. return node;
  281. }
  282. if (hasLodBias)
  283. {
  284. sources[dstIndex++] = texOp.GetSource(srcIndex++);
  285. }
  286. if (isGather && !isShadow)
  287. {
  288. sources[dstIndex++] = texOp.GetSource(srcIndex++);
  289. }
  290. int coordsIndex = isBindless || isIndexed ? 1 : 0;
  291. int componentIndex = texOp.Index;
  292. Operand Int(Operand value)
  293. {
  294. Operand res = Local();
  295. node.List.AddBefore(node, new Operation(Instruction.ConvertFP32ToS32, res, value));
  296. return res;
  297. }
  298. Operand Float(Operand value)
  299. {
  300. Operand res = Local();
  301. node.List.AddBefore(node, new Operation(Instruction.ConvertS32ToFP32, res, value));
  302. return res;
  303. }
  304. // Emulate non-normalized coordinates by normalizing the coordinates on the shader.
  305. // Without normalization, the coordinates are expected to the in the [0, W or H] range,
  306. // and otherwise, it is expected to be in the [0, 1] range.
  307. // We normalize by dividing the coords by the texture size.
  308. if (!isCoordNormalized && !intCoords)
  309. {
  310. config.SetUsedFeature(FeatureFlags.IntegerSampling);
  311. int normCoordsCount = (texOp.Type & SamplerType.Mask) == SamplerType.TextureCube ? 2 : coordsCount;
  312. for (int index = 0; index < normCoordsCount; index++)
  313. {
  314. Operand coordSize = Local();
  315. Operand[] texSizeSources;
  316. if (isBindless || isIndexed)
  317. {
  318. texSizeSources = new Operand[] { sources[0], Const(0) };
  319. }
  320. else
  321. {
  322. texSizeSources = new Operand[] { Const(0) };
  323. }
  324. node.List.AddBefore(node, new TextureOperation(
  325. Instruction.TextureSize,
  326. texOp.Type,
  327. texOp.Format,
  328. texOp.Flags,
  329. texOp.CbufSlot,
  330. texOp.Handle,
  331. index,
  332. coordSize,
  333. texSizeSources));
  334. config.SetUsedTexture(Instruction.TextureSize, texOp.Type, texOp.Format, texOp.Flags, texOp.CbufSlot, texOp.Handle);
  335. Operand source = sources[coordsIndex + index];
  336. Operand coordNormalized = Local();
  337. node.List.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Divide, coordNormalized, source, Float(coordSize)));
  338. sources[coordsIndex + index] = coordNormalized;
  339. }
  340. }
  341. // Technically, non-constant texture offsets are not allowed (according to the spec),
  342. // however some GPUs does support that.
  343. // For GPUs where it is not supported, we can replace the instruction with the following:
  344. // For texture*Offset, we replace it by texture*, and add the offset to the P coords.
  345. // The offset can be calculated as offset / textureSize(lod), where lod = textureQueryLod(coords).
  346. // For texelFetchOffset, we replace it by texelFetch and add the offset to the P coords directly.
  347. // For textureGatherOffset, we take advantage of the fact that the operation is already broken down
  348. // to read the 4 pixels separately, and just replace it with 4 textureGather with a different offset
  349. // for each pixel.
  350. if (hasInvalidOffset)
  351. {
  352. if (intCoords)
  353. {
  354. for (int index = 0; index < coordsCount; index++)
  355. {
  356. Operand source = sources[coordsIndex + index];
  357. Operand coordPlusOffset = Local();
  358. node.List.AddBefore(node, new Operation(Instruction.Add, coordPlusOffset, source, offsets[index]));
  359. sources[coordsIndex + index] = coordPlusOffset;
  360. }
  361. }
  362. else
  363. {
  364. config.SetUsedFeature(FeatureFlags.IntegerSampling);
  365. Operand lod = Local();
  366. node.List.AddBefore(node, new TextureOperation(
  367. Instruction.Lod,
  368. texOp.Type,
  369. texOp.Format,
  370. texOp.Flags,
  371. texOp.CbufSlot,
  372. texOp.Handle,
  373. 0,
  374. lod,
  375. lodSources));
  376. for (int index = 0; index < coordsCount; index++)
  377. {
  378. Operand coordSize = Local();
  379. Operand[] texSizeSources;
  380. if (isBindless || isIndexed)
  381. {
  382. texSizeSources = new Operand[] { sources[0], Int(lod) };
  383. }
  384. else
  385. {
  386. texSizeSources = new Operand[] { Int(lod) };
  387. }
  388. node.List.AddBefore(node, new TextureOperation(
  389. Instruction.TextureSize,
  390. texOp.Type,
  391. texOp.Format,
  392. texOp.Flags,
  393. texOp.CbufSlot,
  394. texOp.Handle,
  395. index,
  396. coordSize,
  397. texSizeSources));
  398. config.SetUsedTexture(Instruction.TextureSize, texOp.Type, texOp.Format, texOp.Flags, texOp.CbufSlot, texOp.Handle);
  399. Operand offset = Local();
  400. Operand intOffset = offsets[index + (hasOffsets ? texOp.Index * coordsCount : 0)];
  401. node.List.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Divide, offset, Float(intOffset), Float(coordSize)));
  402. Operand source = sources[coordsIndex + index];
  403. Operand coordPlusOffset = Local();
  404. node.List.AddBefore(node, new Operation(Instruction.FP32 | Instruction.Add, coordPlusOffset, source, offset));
  405. sources[coordsIndex + index] = coordPlusOffset;
  406. }
  407. }
  408. if (isGather && !isShadow)
  409. {
  410. Operand gatherComponent = sources[dstIndex - 1];
  411. Debug.Assert(gatherComponent.Type == OperandType.Constant);
  412. componentIndex = gatherComponent.Value;
  413. }
  414. }
  415. TextureOperation newTexOp = new TextureOperation(
  416. Instruction.TextureSample,
  417. texOp.Type,
  418. texOp.Format,
  419. texOp.Flags & ~(TextureFlags.Offset | TextureFlags.Offsets),
  420. texOp.CbufSlot,
  421. texOp.Handle,
  422. componentIndex,
  423. texOp.Dest,
  424. sources);
  425. for (int index = 0; index < texOp.SourcesCount; index++)
  426. {
  427. texOp.SetSource(index, null);
  428. }
  429. LinkedListNode<INode> oldNode = node;
  430. node = node.List.AddBefore(node, newTexOp);
  431. node.List.Remove(oldNode);
  432. return node;
  433. }
  434. private static LinkedListNode<INode> InsertSnormNormalization(LinkedListNode<INode> node, ShaderConfig config)
  435. {
  436. TextureOperation texOp = (TextureOperation)node.Value;
  437. // We can't query the format of a bindless texture,
  438. // because the handle is unknown, it can have any format.
  439. if (texOp.Flags.HasFlag(TextureFlags.Bindless))
  440. {
  441. return node;
  442. }
  443. TextureFormat format = config.GpuAccessor.QueryTextureFormat(texOp.Handle, texOp.CbufSlot);
  444. int maxPositive = format switch
  445. {
  446. TextureFormat.R8Snorm => sbyte.MaxValue,
  447. TextureFormat.R8G8Snorm => sbyte.MaxValue,
  448. TextureFormat.R8G8B8A8Snorm => sbyte.MaxValue,
  449. TextureFormat.R16Snorm => short.MaxValue,
  450. TextureFormat.R16G16Snorm => short.MaxValue,
  451. TextureFormat.R16G16B16A16Snorm => short.MaxValue,
  452. _ => 0
  453. };
  454. // The value being 0 means that the format is not a SNORM format,
  455. // so there's nothing to do here.
  456. if (maxPositive == 0)
  457. {
  458. return node;
  459. }
  460. // Do normalization. We assume SINT formats are being used
  461. // as replacement for SNORM (which is not supported).
  462. INode[] uses = texOp.Dest.UseOps.ToArray();
  463. Operation convOp = new Operation(Instruction.ConvertS32ToFP32, Local(), texOp.Dest);
  464. Operation normOp = new Operation(Instruction.FP32 | Instruction.Multiply, Local(), convOp.Dest, ConstF(1f / maxPositive));
  465. node = node.List.AddAfter(node, convOp);
  466. node = node.List.AddAfter(node, normOp);
  467. foreach (INode useOp in uses)
  468. {
  469. if (useOp is not Operation op)
  470. {
  471. continue;
  472. }
  473. // Replace all uses of the texture pixel value with the normalized value.
  474. for (int index = 0; index < op.SourcesCount; index++)
  475. {
  476. if (op.GetSource(index) == texOp.Dest)
  477. {
  478. op.SetSource(index, normOp.Dest);
  479. }
  480. }
  481. }
  482. return node;
  483. }
  484. private static bool ReplaceConstantBufferWithDrawParameters(Operation operation)
  485. {
  486. bool modified = false;
  487. for (int srcIndex = 0; srcIndex < operation.SourcesCount; srcIndex++)
  488. {
  489. Operand src = operation.GetSource(srcIndex);
  490. if (src.Type == OperandType.ConstantBuffer && src.GetCbufSlot() == 0)
  491. {
  492. switch (src.GetCbufOffset())
  493. {
  494. case Constants.NvnBaseVertexByteOffset / 4:
  495. operation.SetSource(srcIndex, Attribute(AttributeConsts.BaseVertex));
  496. modified = true;
  497. break;
  498. case Constants.NvnBaseInstanceByteOffset / 4:
  499. operation.SetSource(srcIndex, Attribute(AttributeConsts.BaseInstance));
  500. modified = true;
  501. break;
  502. case Constants.NvnDrawIndexByteOffset / 4:
  503. operation.SetSource(srcIndex, Attribute(AttributeConsts.DrawIndex));
  504. modified = true;
  505. break;
  506. }
  507. }
  508. }
  509. return modified;
  510. }
  511. private static bool HasConstantBufferDrawParameters(Operation operation)
  512. {
  513. for (int srcIndex = 0; srcIndex < operation.SourcesCount; srcIndex++)
  514. {
  515. Operand src = operation.GetSource(srcIndex);
  516. if (src.Type == OperandType.ConstantBuffer && src.GetCbufSlot() == 0)
  517. {
  518. switch (src.GetCbufOffset())
  519. {
  520. case Constants.NvnBaseVertexByteOffset / 4:
  521. case Constants.NvnBaseInstanceByteOffset / 4:
  522. case Constants.NvnDrawIndexByteOffset / 4:
  523. return true;
  524. }
  525. }
  526. }
  527. return false;
  528. }
  529. }
  530. }