1848b8605Smrg#ifndef __NOUVEAU_STATEBUF_H__ 2848b8605Smrg#define __NOUVEAU_STATEBUF_H__ 3848b8605Smrg 4848b8605Smrg/* state buffers: lightweight state objects interface */ 5848b8605Smrg/* relocations are not supported, but Gallium CSOs don't require them */ 6848b8605Smrg 7848b8605Smrgstruct nouveau_statebuf_builder 8848b8605Smrg{ 9b8e80941Smrg uint32_t* p; 10848b8605Smrg#ifdef DEBUG 11b8e80941Smrg uint32_t* pend; 12848b8605Smrg#endif 13848b8605Smrg}; 14848b8605Smrg 15848b8605Smrg#ifdef DEBUG 16848b8605Smrg#define sb_init(var) {var, var + sizeof(var) / sizeof((var)[0])} 17848b8605Smrg#define sb_data(sb, v) do {assert((sb).p != (sb).pend); *(sb).p++ = (v);} while(0) 18848b8605Smrg#else 19848b8605Smrg#define sb_init(var) {var} 20848b8605Smrg#define sb_data(sb, v) *(sb).p++ = (v) 21848b8605Smrg#endif 22848b8605Smrg 23b8e80941Smrgstatic inline uint32_t sb_header(unsigned subc, unsigned mthd, unsigned size) 24848b8605Smrg{ 25b8e80941Smrg return (size << 18) | (subc << 13) | mthd; 26848b8605Smrg} 27848b8605Smrg 28848b8605Smrg#define sb_method(sb, v, n) sb_data(sb, sb_header(SUBC_3D(v), n)); 29848b8605Smrg 30848b8605Smrg#define sb_len(sb, var) ((sb).p - (var)) 31848b8605Smrg#define sb_emit(push, sb_buf, sb_len) do {PUSH_SPACE((push), (sb_len)); PUSH_DATAp((push), (sb_buf), (sb_len)); } while(0) 32848b8605Smrg#endif 33