gallium: add target-helpers/wrap_screen.c to C_SOURCES
[mesa/mesa-lb.git] / src / gallium / drivers / r300 / r300_screen_buffer.h
blob0cf349c25cdc7a6ccc6d74a4c7513bca47d1650c
1 #ifndef R300_SCREEN_BUFFER_H
2 #define R300_SCREEN_BUFFER_H
3 #include <stdio.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 {
14 uint32_t start;
15 uint32_t end;
17 #define R300_BUFFER_MAX_RANGES 32
19 struct r300_buffer
21 struct pipe_buffer base;
23 uint32_t magic;
25 struct r300_winsys_buffer *buf;
27 void *user_buffer;
28 struct r300_buffer_range ranges[R300_BUFFER_MAX_RANGES];
29 unsigned num_ranges;
31 void *map;
34 static INLINE struct r300_buffer *
35 r300_buffer(struct pipe_buffer *buffer)
37 if (buffer) {
38 assert(((struct r300_buffer *)buffer)->magic == R300_BUFFER_MAGIC);
39 return (struct r300_buffer *)buffer;
41 return NULL;
44 static INLINE boolean
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,
52 int rd, int wr)
54 struct r300_buffer *buf = r300_buffer(buffer);
56 if (!buf->buf)
57 return true;
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,
65 int rd, int wr)
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)
76 if (!buf->buf)
77 return;
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,
93 unsigned index_size,
94 unsigned start,
95 unsigned count);
97 boolean r300_buffer_is_referenced(struct r300_context *r300,
98 struct pipe_buffer *buf);
99 #endif