github.com/cybriq/giocore@v0.0.7-0.20210703034601-cfb9cb5f3900/gpu/shaders/state.h (about) 1 // SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense 2 3 // Code auto-generated by piet-gpu-derive 4 5 struct StateRef { 6 uint offset; 7 }; 8 9 struct State { 10 vec4 mat; 11 vec2 translate; 12 vec4 bbox; 13 float linewidth; 14 uint flags; 15 uint path_count; 16 uint pathseg_count; 17 uint trans_count; 18 }; 19 20 #define State_size 60 21 22 StateRef State_index(StateRef ref, uint index) { 23 return StateRef(ref.offset + index * State_size); 24 } 25 26 State State_read(StateRef ref) { 27 uint ix = ref.offset >> 2; 28 uint raw0 = state[ix + 0]; 29 uint raw1 = state[ix + 1]; 30 uint raw2 = state[ix + 2]; 31 uint raw3 = state[ix + 3]; 32 uint raw4 = state[ix + 4]; 33 uint raw5 = state[ix + 5]; 34 uint raw6 = state[ix + 6]; 35 uint raw7 = state[ix + 7]; 36 uint raw8 = state[ix + 8]; 37 uint raw9 = state[ix + 9]; 38 uint raw10 = state[ix + 10]; 39 uint raw11 = state[ix + 11]; 40 uint raw12 = state[ix + 12]; 41 uint raw13 = state[ix + 13]; 42 uint raw14 = state[ix + 14]; 43 State s; 44 s.mat = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); 45 s.translate = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); 46 s.bbox = vec4(uintBitsToFloat(raw6), uintBitsToFloat(raw7), uintBitsToFloat(raw8), uintBitsToFloat(raw9)); 47 s.linewidth = uintBitsToFloat(raw10); 48 s.flags = raw11; 49 s.path_count = raw12; 50 s.pathseg_count = raw13; 51 s.trans_count = raw14; 52 return s; 53 } 54 55 void State_write(StateRef ref, State s) { 56 uint ix = ref.offset >> 2; 57 state[ix + 0] = floatBitsToUint(s.mat.x); 58 state[ix + 1] = floatBitsToUint(s.mat.y); 59 state[ix + 2] = floatBitsToUint(s.mat.z); 60 state[ix + 3] = floatBitsToUint(s.mat.w); 61 state[ix + 4] = floatBitsToUint(s.translate.x); 62 state[ix + 5] = floatBitsToUint(s.translate.y); 63 state[ix + 6] = floatBitsToUint(s.bbox.x); 64 state[ix + 7] = floatBitsToUint(s.bbox.y); 65 state[ix + 8] = floatBitsToUint(s.bbox.z); 66 state[ix + 9] = floatBitsToUint(s.bbox.w); 67 state[ix + 10] = floatBitsToUint(s.linewidth); 68 state[ix + 11] = s.flags; 69 state[ix + 12] = s.path_count; 70 state[ix + 13] = s.pathseg_count; 71 state[ix + 14] = s.trans_count; 72 } 73