1 #ifndef R300_SCREEN_BUFFER_H
2 #define R300_SCREEN_BUFFER_H
4 #include "pipe/p_compiler.h"
5 #include "pipe/p_state.h"
6 #include "r300_screen.h"
8 #include "r300_winsys.h"
9 #include "r300_context.h"
11 #define R300_BUFFER_MAGIC 0xabcd1234
13 struct r300_buffer_range {
17 #define R300_BUFFER_MAX_RANGES 32
21 struct pipe_buffer base;
25 struct r300_winsys_buffer *buf;
28 struct r300_buffer_range ranges[R300_BUFFER_MAX_RANGES];
34 static INLINE struct r300_buffer *
35 r300_buffer(struct pipe_buffer *buffer)
38 assert(((struct r300_buffer *)buffer)->magic == R300_BUFFER_MAGIC);
39 return (struct r300_buffer *)buffer;
45 r300_buffer_is_user_buffer(struct pipe_buffer *buffer)
47 return r300_buffer(buffer)->user_buffer ? true : false;
50 static INLINE boolean r300_add_buffer(struct r300_winsys_screen *rws,
51 struct pipe_buffer *buffer,
54 struct r300_buffer *buf = r300_buffer(buffer);
59 return rws->add_buffer(rws, buf->buf, rd, wr);
63 static INLINE boolean r300_add_texture(struct r300_winsys_screen *rws,
64 struct r300_texture *tex,
67 return rws->add_buffer(rws, tex->buffer, rd, wr);
70 void r300_screen_init_buffer_functions(struct r300_screen *r300screen);
72 static INLINE void r300_buffer_write_reloc(struct r300_winsys_screen *rws,
73 struct r300_buffer *buf,
74 uint32_t rd, uint32_t wd, uint32_t flags)
79 rws->write_cs_reloc(rws, buf->buf, rd, wd, flags);
82 static INLINE void r300_texture_write_reloc(struct r300_winsys_screen *rws,
83 struct r300_texture *texture,
84 uint32_t rd, uint32_t wd, uint32_t flags)
86 rws->write_cs_reloc(rws, texture->buffer, rd, wd, flags);
89 int r300_upload_user_buffers(struct r300_context *r300);
91 int r300_upload_index_buffer(struct r300_context *r300,
92 struct pipe_buffer **index_buffer,
97 boolean r300_buffer_is_referenced(struct r300_context *r300,
98 struct pipe_buffer *buf);