StoreStorageSmallInt.glsl 810 B

1234567891011121314151617181920212223
  1. void Helper_StoreStorage16(int index, int offset, uint value)
  2. {
  3. int wordOffset = offset >> 2;
  4. int bitOffset = (offset & 3) * 8;
  5. uint oldValue, newValue;
  6. do
  7. {
  8. oldValue = $STORAGE_MEM$[index].data[wordOffset];
  9. newValue = bitfieldInsert(oldValue, value, bitOffset, 16);
  10. } while (atomicCompSwap($STORAGE_MEM$[index].data[wordOffset], oldValue, newValue) != oldValue);
  11. }
  12. void Helper_StoreStorage8(int index, int offset, uint value)
  13. {
  14. int wordOffset = offset >> 2;
  15. int bitOffset = (offset & 3) * 8;
  16. uint oldValue, newValue;
  17. do
  18. {
  19. oldValue = $STORAGE_MEM$[index].data[wordOffset];
  20. newValue = bitfieldInsert(oldValue, value, bitOffset, 8);
  21. } while (atomicCompSwap($STORAGE_MEM$[index].data[wordOffset], oldValue, newValue) != oldValue);
  22. }