1 #ifndef __NOUVEAU_STATEBUF_H__ 2 #define __NOUVEAU_STATEBUF_H__ 3 4 /* state buffers: lightweight state objects interface */ 5 /* relocations are not supported, but Gallium CSOs don't require them */ 6 7 struct nouveau_statebuf_builder 8 { 9 uint32_t* p; 10 #ifdef DEBUG 11 uint32_t* pend; 12 #endif 13 }; 14 15 #ifdef DEBUG 16 #define sb_init(var) {var, var + sizeof(var) / sizeof((var)[0])} 17 #define sb_data(sb, v) do {assert((sb).p != (sb).pend); *(sb).p++ = (v);} while(0) 18 #else 19 #define sb_init(var) {var} 20 #define sb_data(sb, v) *(sb).p++ = (v) 21 #endif 22 23 static INLINE uint32_t sb_header(unsigned subc, unsigned mthd, unsigned size) 24 { 25 return (size << 18) | (subc << 13) | mthd; 26 } 27 28 #define sb_method(sb, v, n) sb_data(sb, sb_header(SUBC_3D(v), n)); 29 30 #define sb_len(sb, var) ((sb).p - (var)) 31 #define sb_emit(push, sb_buf, sb_len) do {PUSH_SPACE((push), (sb_len)); PUSH_DATAp((push), (sb_buf), (sb_len)); } while(0) 32 #endif 33