r600g: adapt to latest interfaces changes
[mesa.git] / src / gallium / drivers / r600 / r600_screen.h
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #ifndef R600_SCREEN_H
24 #define R600_SCREEN_H
25
26 #include <pipe/p_state.h>
27 #include <pipe/p_screen.h>
28 #include <pipebuffer/pb_buffer.h>
29 #include <xf86drm.h>
30 #include <radeon_drm.h>
31 #include "radeon.h"
32 #include "util/u_transfer.h"
33
34 #define r600_screen(s) ((struct r600_screen*)s)
35
36 /* Texture transfer. */
37 struct r600_transfer {
38 /* Base class. */
39 struct pipe_transfer transfer;
40 /* Buffer transfer. */
41 struct pipe_transfer *buffer_transfer;
42 unsigned offset;
43 };
44
45 struct r600_buffer {
46 struct u_resource b;
47 struct radeon_bo *bo;
48 u32 domain;
49 u32 flink;
50 struct pb_buffer *pb;
51 };
52
53 struct r600_screen {
54 struct pipe_screen screen;
55 struct radeon *rw;
56 };
57
58 /* Buffer functions. */
59 struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
60 const struct pipe_resource *templ);
61 struct pipe_resource *r600_user_buffer_create(struct pipe_screen *screen,
62 void *ptr, unsigned bytes,
63 unsigned bind);
64 unsigned r600_buffer_is_referenced_by_cs(struct pipe_context *context,
65 struct pipe_resource *buf,
66 unsigned face, unsigned level);
67 struct pipe_resource *r600_buffer_from_handle(struct pipe_screen *screen,
68 struct winsys_handle *whandle);
69
70 /* Texture transfer functions. */
71 struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
72 struct pipe_resource *texture,
73 struct pipe_subresource sr,
74 unsigned usage,
75 const struct pipe_box *box);
76 void r600_texture_transfer_destroy(struct pipe_context *ctx,
77 struct pipe_transfer *trans);
78 void* r600_texture_transfer_map(struct pipe_context *ctx,
79 struct pipe_transfer* transfer);
80 void r600_texture_transfer_unmap(struct pipe_context *ctx,
81 struct pipe_transfer* transfer);
82
83
84 /* Blit functions. */
85 void r600_clear(struct pipe_context *ctx,
86 unsigned buffers,
87 const float *rgba,
88 double depth,
89 unsigned stencil);
90 void r600_surface_copy(struct pipe_context *ctx,
91 struct pipe_surface *dst,
92 unsigned dstx, unsigned dsty,
93 struct pipe_surface *src,
94 unsigned srcx, unsigned srcy,
95 unsigned width, unsigned height);
96 void r600_surface_fill(struct pipe_context *ctx,
97 struct pipe_surface *dst,
98 unsigned dstx, unsigned dsty,
99 unsigned width, unsigned height,
100 unsigned value);
101
102 /* helpers */
103 int r600_conv_pipe_format(unsigned pformat, unsigned *format);
104 int r600_conv_pipe_prim(unsigned pprim, unsigned *prim);
105
106 union r600_float_to_u32_u {
107 u32 u;
108 float f;
109 };
110
111 static inline u32 r600_float_to_u32(float f)
112 {
113 union r600_float_to_u32_u c;
114
115 c.f = f;
116 return c.u;
117 }
118
119 #endif