radeon/r200/r300: merge span code into single shared file
[mesa.git] / src / mesa / drivers / dri / radeon / common_misc.h
1 #ifndef COMMON_MISC_H
2 #define COMMON_MISC_H
3
4 #include "common_context.h"
5 #include "radeon_buffer.h"
6 void radeonRecalcScissorRects(radeonContextPtr radeon);
7 void radeonSetCliprects(radeonContextPtr radeon);
8 void radeonUpdateScissor( GLcontext *ctx );
9
10 void radeonWaitForIdleLocked(radeonContextPtr radeon);
11 extern uint32_t radeonGetAge(radeonContextPtr radeon);
12 void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
13 const drm_clip_rect_t *rect);
14 void radeonPageFlip( __DRIdrawablePrivate *dPriv );
15 void radeon_common_finish(GLcontext * ctx);
16 void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
17 void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
18 int x, int y, int w, int h );
19
20 void radeonUpdatePageFlipping(radeonContextPtr rmesa);
21
22 GLboolean radeonInitContext(radeonContextPtr radeon,
23 struct dd_function_table* functions,
24 const __GLcontextModes * glVisual,
25 __DRIcontextPrivate * driContextPriv,
26 void *sharedContextPrivate);
27
28 void radeonCleanupContext(radeonContextPtr radeon);
29 void radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable);
30 GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
31 __DRIdrawablePrivate * driDrawPriv,
32 __DRIdrawablePrivate * driReadPriv);
33
34 void radeonEmitVec8(uint32_t *out, GLvoid * data, int stride, int count);
35 void radeonEmitVec12(uint32_t *out, GLvoid * data, int stride, int count);
36
37 void rcommon_emit_vector(GLcontext * ctx, struct radeon_aos *aos,
38 GLvoid * data, int size, int stride, int count);
39 void radeon_print_state_atom( struct radeon_state_atom *state );
40
41 struct gl_texture_image *radeonNewTextureImage(GLcontext *ctx);
42 void radeonFreeTexImageData(GLcontext *ctx, struct gl_texture_image *timage);
43
44 void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable);
45 void radeon_teximage_unmap(radeon_texture_image *image);
46 void radeonMapTexture(GLcontext *ctx, struct gl_texture_object *texObj);
47 void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj);
48 void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj);
49 int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj);
50 GLuint radeon_face_for_target(GLenum target);
51 const struct gl_texture_format *radeonChooseTextureFormat(GLcontext * ctx,
52 GLint internalFormat,
53 GLenum format,
54 GLenum type);
55
56 void radeonTexImage1D(GLcontext * ctx, GLenum target, GLint level,
57 GLint internalFormat,
58 GLint width, GLint border,
59 GLenum format, GLenum type, const GLvoid * pixels,
60 const struct gl_pixelstore_attrib *packing,
61 struct gl_texture_object *texObj,
62 struct gl_texture_image *texImage);
63 void radeonTexImage2D(GLcontext * ctx, GLenum target, GLint level,
64 GLint internalFormat,
65 GLint width, GLint height, GLint border,
66 GLenum format, GLenum type, const GLvoid * pixels,
67 const struct gl_pixelstore_attrib *packing,
68 struct gl_texture_object *texObj,
69 struct gl_texture_image *texImage);
70 void radeonCompressedTexImage2D(GLcontext * ctx, GLenum target,
71 GLint level, GLint internalFormat,
72 GLint width, GLint height, GLint border,
73 GLsizei imageSize, const GLvoid * data,
74 struct gl_texture_object *texObj,
75 struct gl_texture_image *texImage);
76 void radeonTexImage3D(GLcontext * ctx, GLenum target, GLint level,
77 GLint internalFormat,
78 GLint width, GLint height, GLint depth,
79 GLint border,
80 GLenum format, GLenum type, const GLvoid * pixels,
81 const struct gl_pixelstore_attrib *packing,
82 struct gl_texture_object *texObj,
83 struct gl_texture_image *texImage);
84 void radeonTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
85 GLint xoffset,
86 GLsizei width,
87 GLenum format, GLenum type,
88 const GLvoid * pixels,
89 const struct gl_pixelstore_attrib *packing,
90 struct gl_texture_object *texObj,
91 struct gl_texture_image *texImage);
92 void radeonTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
93 GLint xoffset, GLint yoffset,
94 GLsizei width, GLsizei height,
95 GLenum format, GLenum type,
96 const GLvoid * pixels,
97 const struct gl_pixelstore_attrib *packing,
98 struct gl_texture_object *texObj,
99 struct gl_texture_image *texImage);
100 void radeonCompressedTexSubImage2D(GLcontext * ctx, GLenum target,
101 GLint level, GLint xoffset,
102 GLint yoffset, GLsizei width,
103 GLsizei height, GLenum format,
104 GLsizei imageSize, const GLvoid * data,
105 struct gl_texture_object *texObj,
106 struct gl_texture_image *texImage);
107
108 void radeonTexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
109 GLint xoffset, GLint yoffset, GLint zoffset,
110 GLsizei width, GLsizei height, GLsizei depth,
111 GLenum format, GLenum type,
112 const GLvoid * pixels,
113 const struct gl_pixelstore_attrib *packing,
114 struct gl_texture_object *texObj,
115 struct gl_texture_image *texImage);
116
117 void radeonSpanRenderStart(GLcontext * ctx);
118 void radeonSpanRenderFinish(GLcontext * ctx);
119 GLubyte *radeon_ptr(const struct radeon_renderbuffer * rrb,
120 GLint x, GLint y);
121 GLubyte *radeon_ptr16(const struct radeon_renderbuffer * rrb,
122 GLint x, GLint y);
123 GLubyte *radeon_ptr32(const struct radeon_renderbuffer * rrb,
124 GLint x, GLint y);
125 void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size);
126 void radeonAllocDmaRegion(radeonContextPtr rmesa,
127 struct radeon_bo **pbo, int *poffset,
128 int bytes, int alignment);
129 void radeonReleaseDmaRegion(radeonContextPtr rmesa);
130
131 void rcommon_flush_last_swtcl_prim(GLcontext *ctx);
132
133 void *rcommonAllocDmaLowVerts(radeonContextPtr rmesa, int nverts, int vsize);
134
135
136 static inline struct radeon_renderbuffer *radeon_get_depthbuffer(radeonContextPtr rmesa)
137 {
138 struct radeon_renderbuffer *rrb;
139 rrb = rmesa->state.depth.rrb;
140 if (!rrb)
141 return NULL;
142
143 return rrb;
144 }
145
146 static inline struct radeon_renderbuffer *radeon_get_colorbuffer(radeonContextPtr rmesa)
147 {
148 struct radeon_renderbuffer *rrb;
149 GLframebuffer *fb = rmesa->dri.drawable->driverPrivate;
150
151 rrb = rmesa->state.color.rrb;
152 if (rmesa->radeonScreen->driScreen->dri2.enabled) {
153 rrb = (struct radeon_renderbuffer *)fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
154 }
155 if (!rrb)
156 return NULL;
157 return rrb;
158 }
159
160
161 #endif