From c7ac486261ad30ef654f6d0b1608da4e8483cd40 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 18 Feb 2010 23:50:59 -0800 Subject: Remove _mesa_memcpy in favor of plain memcpy. This may break the SUNOS4 build, but it's no longer relevant. --- src/mesa/drivers/dri/r600/r700_render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_render.c b/src/mesa/drivers/dri/r600/r700_render.c index 8f14af7472..fdd02fac23 100644 --- a/src/mesa/drivers/dri/r600/r700_render.c +++ b/src/mesa/drivers/dri/r600/r700_render.c @@ -594,7 +594,7 @@ static void r700AlignDataToDword(GLcontext *ctx, for (i = 0; i < count; ++i) { - _mesa_memcpy(dst_ptr, src_ptr, input->StrideB); + memcpy(dst_ptr, src_ptr, input->StrideB); src_ptr += input->StrideB; dst_ptr += dst_stride; } @@ -855,7 +855,7 @@ static void r700SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer assert(context->ind_buf.bo->ptr != NULL); dst_ptr = ADD_POINTERS(context->ind_buf.bo->ptr, context->ind_buf.bo_offset); - _mesa_memcpy(dst_ptr, src_ptr, size); + memcpy(dst_ptr, src_ptr, size); radeon_bo_unmap(context->ind_buf.bo); context->ind_buf.is_32bit = (mesa_ind_buf->type == GL_UNSIGNED_INT); -- cgit v1.2.3 From 32f2fd1c5d6088692551c80352b7d6fa35b0cd09 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 19 Feb 2010 11:58:49 -0500 Subject: Replace _mesa_malloc, _mesa_calloc and _mesa_free with plain libc versions --- src/egl/drivers/dri/egldri.c | 2 +- src/gallium/state_trackers/glx/xlib/glx_api.c | 18 ++-- src/gallium/state_trackers/glx/xlib/xm_api.c | 14 +-- src/glx/glcontextmodes.c | 35 +------- src/glx/glcontextmodes.h | 2 - src/mesa/drivers/common/meta.c | 34 +++---- src/mesa/drivers/dri/common/dri_util.c | 34 +++---- src/mesa/drivers/dri/common/drirenderbuffer.c | 4 +- src/mesa/drivers/dri/common/utils.c | 12 +-- src/mesa/drivers/dri/fb/fb_dri.c | 12 +-- src/mesa/drivers/dri/i965/brw_curbe.c | 6 +- src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 +- src/mesa/drivers/dri/i965/brw_eu.c | 4 +- src/mesa/drivers/dri/i965/brw_queryobj.c | 4 +- src/mesa/drivers/dri/i965/brw_state_batch.c | 6 +- src/mesa/drivers/dri/i965/brw_state_cache.c | 10 +-- src/mesa/drivers/dri/i965/brw_vtbl.c | 10 +-- src/mesa/drivers/dri/i965/brw_wm.c | 8 +- src/mesa/drivers/dri/intel/intel_buffer_objects.c | 12 +-- src/mesa/drivers/dri/intel/intel_fbo.c | 8 +- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 4 +- src/mesa/drivers/dri/intel/intel_pixel_draw.c | 4 +- src/mesa/drivers/dri/intel/intel_span.c | 2 +- src/mesa/drivers/dri/intel/intel_syncobj.c | 4 +- src/mesa/drivers/dri/r300/r300_fragprog_common.c | 2 +- src/mesa/drivers/dri/r300/r300_shader.c | 4 +- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- src/mesa/drivers/dri/r600/r700_oglprog.c | 2 +- src/mesa/drivers/dri/r600/r700_vertprog.c | 2 +- .../drivers/dri/radeon/radeon_buffer_objects.c | 2 +- src/mesa/drivers/dri/radeon/radeon_fbo.c | 4 +- src/mesa/drivers/dri/radeon/radeon_queryobj.c | 4 +- src/mesa/drivers/dri/radeon/radeon_texture.c | 4 +- src/mesa/drivers/dri/savage/savage_xmesa.c | 16 ++-- src/mesa/drivers/dri/savage/savagetex.c | 4 +- src/mesa/drivers/dri/swrast/swrast.c | 24 ++--- src/mesa/drivers/dri/unichrome/via_fb.c | 6 +- src/mesa/drivers/fbdev/glfbdev.c | 22 ++--- src/mesa/drivers/glide/fxdd.c | 4 +- src/mesa/drivers/glide/fxddtex.c | 6 +- src/mesa/drivers/glide/fxsetup.c | 4 +- src/mesa/drivers/glslcompiler/glslcompiler.c | 4 +- src/mesa/drivers/osmesa/osmesa.c | 12 +-- src/mesa/drivers/windows/gdi/mesa.def | 2 - src/mesa/drivers/windows/gdi/wmesa.c | 8 +- src/mesa/drivers/windows/icd/mesa.def | 3 - src/mesa/drivers/x11/fakeglx.c | 18 ++-- src/mesa/drivers/x11/xm_api.c | 26 +++--- src/mesa/drivers/x11/xm_buffer.c | 6 +- src/mesa/es/main/specials_es1.c | 2 +- src/mesa/es/main/specials_es2.c | 2 +- src/mesa/glapi/mesadef.py | 3 - src/mesa/main/arrayobj.c | 2 +- src/mesa/main/attrib.c | 4 +- src/mesa/main/bufferobj.c | 4 +- src/mesa/main/colortab.c | 8 +- src/mesa/main/context.c | 24 ++--- src/mesa/main/cpuinfo.c | 4 +- src/mesa/main/debug.c | 28 +++--- src/mesa/main/depthstencil.c | 4 +- src/mesa/main/dlist.c | 100 ++++++++++----------- src/mesa/main/execmem.c | 4 +- src/mesa/main/extensions.c | 6 +- src/mesa/main/framebuffer.c | 2 +- src/mesa/main/hash.c | 8 +- src/mesa/main/image.c | 8 +- src/mesa/main/imports.c | 39 ++------ src/mesa/main/imports.h | 19 ++-- src/mesa/main/light.c | 4 +- src/mesa/main/mipmap.c | 10 +-- src/mesa/main/mm.c | 16 ++-- src/mesa/main/queryobj.c | 2 +- src/mesa/main/renderbuffer.c | 14 +-- src/mesa/main/shaders.c | 12 +-- src/mesa/main/shared.c | 2 +- src/mesa/main/syncobj.c | 2 +- src/mesa/main/texcompress_fxt1.c | 12 +-- src/mesa/main/texcompress_s3tc.c | 8 +- src/mesa/main/teximage.c | 10 +-- src/mesa/main/texobj.c | 2 +- src/mesa/main/texrender.c | 2 +- src/mesa/main/texstore.c | 62 ++++++------- src/mesa/main/version.c | 2 +- src/mesa/shader/arbprogparse.c | 8 +- src/mesa/shader/atifragshader.c | 16 ++-- src/mesa/shader/hash_table.c | 8 +- src/mesa/shader/nvfragparse.c | 6 +- src/mesa/shader/nvvertparse.c | 10 +-- src/mesa/shader/prog_cache.c | 18 ++-- src/mesa/shader/prog_instruction.c | 8 +- src/mesa/shader/prog_optimize.c | 8 +- src/mesa/shader/prog_parameter.c | 14 +-- src/mesa/shader/prog_print.c | 2 +- src/mesa/shader/prog_statevars.c | 2 +- src/mesa/shader/prog_uniform.c | 6 +- src/mesa/shader/program.c | 16 ++-- src/mesa/shader/program_parse.tab.c | 22 ++--- src/mesa/shader/program_parse.y | 22 ++--- src/mesa/shader/shader_api.c | 24 ++--- src/mesa/shader/slang/slang_codegen.c | 6 +- src/mesa/shader/slang/slang_compile.c | 2 +- src/mesa/shader/slang/slang_compile_variable.c | 2 +- src/mesa/shader/slang/slang_emit.c | 6 +- src/mesa/shader/slang/slang_label.c | 2 +- src/mesa/shader/slang/slang_link.c | 26 +++--- src/mesa/shader/slang/slang_log.c | 4 +- src/mesa/shader/slang/slang_mem.c | 14 +-- src/mesa/shader/slang/slang_utility.c | 2 +- src/mesa/shader/symbol_table.c | 2 +- src/mesa/state_tracker/st_cb_accum.c | 12 +-- src/mesa/state_tracker/st_cb_bitmap.c | 2 +- src/mesa/state_tracker/st_cb_bufferobjects.c | 2 +- src/mesa/state_tracker/st_cb_drawpixels.c | 12 +-- src/mesa/state_tracker/st_cb_fbo.c | 10 +-- src/mesa/state_tracker/st_cb_queryobj.c | 2 +- src/mesa/state_tracker/st_cb_rasterpos.c | 2 +- src/mesa/state_tracker/st_cb_texture.c | 4 +- src/mesa/state_tracker/st_context.c | 4 +- src/mesa/state_tracker/st_context.h | 2 +- src/mesa/state_tracker/st_mesa_to_tgsi.c | 2 +- src/mesa/swrast/s_blit.c | 32 +++---- src/mesa/swrast/s_copypix.c | 36 ++++---- src/mesa/swrast/s_drawpix.c | 10 +-- src/mesa/swrast/s_readpix.c | 10 +-- src/mesa/tnl/t_draw.c | 4 +- src/mesa/tnl/t_vb_normals.c | 4 +- src/mesa/tnl/t_vb_points.c | 4 +- src/mesa/tnl/t_vertex.c | 2 +- src/mesa/vbo/vbo_exec_array.c | 4 +- src/mesa/vbo/vbo_rebase.c | 8 +- src/mesa/vbo/vbo_split_copy.c | 14 +-- src/mesa/vf/vf.c | 2 +- 132 files changed, 624 insertions(+), 691 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c index ca6821dad0..6a8bf89985 100644 --- a/src/egl/drivers/dri/egldri.c +++ b/src/egl/drivers/dri/egldri.c @@ -812,7 +812,7 @@ __eglGetDrawableInfo(__DRInativeDisplay * ndpy, int screen, __DRIid drawable, return GL_FALSE; } - cliprect = (drm_clip_rect_t*) _mesa_malloc(sizeof(drm_clip_rect_t)); + cliprect = (drm_clip_rect_t*) malloc(sizeof(drm_clip_rect_t)); cliprect->x1 = drawable->x; cliprect->y1 = drawable->y; cliprect->x2 = drawable->x + drawable->w; diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 9093a0eae9..0932569bd3 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -1018,7 +1018,7 @@ glXChooseVisual( Display *dpy, int screen, int *list ) xmvis = choose_visual(dpy, screen, list, GL_FALSE); if (xmvis) { /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); + xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -1055,7 +1055,7 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo, xmvis = create_glx_visual( dpy, visinfo ); if (!xmvis) { /* unusable visual */ - _mesa_free(glxCtx); + free(glxCtx); return NULL; } } @@ -1063,7 +1063,7 @@ glXCreateContext( Display *dpy, XVisualInfo *visinfo, glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); if (!glxCtx->xmesaContext) { - _mesa_free(glxCtx); + free(glxCtx); return NULL; } @@ -1336,7 +1336,7 @@ glXDestroyContext( Display *dpy, GLXContext ctx ) MakeCurrent_PrevReadBuffer = 0; XMesaDestroyContext( glxCtx->xmesaContext ); XMesaGarbageCollect(); - _mesa_free(glxCtx); + free(glxCtx); } @@ -1755,7 +1755,7 @@ glXGetFBConfigs( Display *dpy, int screen, int *nelements ) visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); if (*nelements > 0) { XMesaVisual *results; - results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual)); + results = (XMesaVisual *) malloc(*nelements * sizeof(XMesaVisual)); if (!results) { *nelements = 0; return NULL; @@ -1782,7 +1782,7 @@ glXChooseFBConfig( Display *dpy, int screen, xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); if (xmvis) { - GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual)); + GLXFBConfig *config = (GLXFBConfig *) malloc(sizeof(XMesaVisual)); if (!config) { *nitems = 0; return NULL; @@ -1807,7 +1807,7 @@ glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); + xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -2112,7 +2112,7 @@ glXCreateNewContext( Display *dpy, GLXFBConfig config, glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); if (!glxCtx->xmesaContext) { - _mesa_free(glxCtx); + free(glxCtx); return NULL; } @@ -2332,7 +2332,7 @@ glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_ glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); if (!glxCtx->xmesaContext) { - _mesa_free(glxCtx); + free(glxCtx); return NULL; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 2e678c8f1e..61af663436 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -175,7 +175,7 @@ bits_per_pixel( XMesaVisual xmv ) /* grab the bits/pixel value */ bitsPerPixel = img->bits_per_pixel; /* free the XImage */ - _mesa_free( img->data ); + free( img->data ); img->data = NULL; XDestroyImage( img ); return bitsPerPixel; @@ -669,13 +669,13 @@ XMesaVisual XMesaCreateVisual( Display *display, v->display = display; - /* Save a copy of the XVisualInfo struct because the user may X_mesa_free() + /* Save a copy of the XVisualInfo struct because the user may Xfree() * the struct but we may need some of the information contained in it * at a later time. */ v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo)); if (!v->visinfo) { - _mesa_free(v); + free(v); return NULL; } memcpy(v->visinfo, visinfo, sizeof(*visinfo)); @@ -743,8 +743,8 @@ XMesaVisual XMesaCreateVisual( Display *display, PUBLIC void XMesaDestroyVisual( XMesaVisual v ) { - _mesa_free(v->visinfo); - _mesa_free(v); + free(v->visinfo); + free(v); } @@ -811,7 +811,7 @@ fail: else if (pipe) pipe->destroy(pipe); - _mesa_free(c); + free(c); return NULL; } @@ -828,7 +828,7 @@ void XMesaDestroyContext( XMesaContext c ) screen->destroy(screen); */ - _mesa_free(c); + free(c); } diff --git a/src/glx/glcontextmodes.c b/src/glx/glcontextmodes.c index 257087a802..eb9037907f 100644 --- a/src/glx/glcontextmodes.c +++ b/src/glx/glcontextmodes.c @@ -31,39 +31,13 @@ * \author Ian Romanick */ -#if defined(IN_MINI_GLX) -#include -#else -#if defined(HAVE_DIX_CONFIG_H) -# include -#endif -#include #include #include "GL/glxint.h" -#endif - -/* Memory macros */ -#if defined(IN_MINI_GLX) -# include -# include -# define _mesa_malloc(b) malloc(b) -# define _mesa_free(m) free(m) -#else -# ifdef XFree86Server -# include -# include -# define _mesa_malloc(b) xalloc(b) -# define _mesa_free(m) xfree(m) -# else -# include -# define _mesa_malloc(b) Xmalloc(b) -# define _mesa_free(m) Xfree(m) -# endif /* XFree86Server */ -#endif /* !defined(IN_MINI_GLX) */ +#include +#include #include "glcontextmodes.h" -#if !defined(IN_MINI_GLX) #define NUM_VISUAL_TYPES 6 /** @@ -352,7 +326,6 @@ _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, return GLX_BAD_ATTRIBUTE; } } -#endif /* !defined(IN_MINI_GLX) */ /** @@ -392,7 +365,7 @@ _gl_context_modes_create(unsigned count, size_t minimum_size) next = &base; for (i = 0; i < count; i++) { - *next = (__GLcontextModes *) _mesa_malloc(size); + *next = (__GLcontextModes *) malloc(size); if (*next == NULL) { _gl_context_modes_destroy(base); base = NULL; @@ -438,7 +411,7 @@ _gl_context_modes_destroy(__GLcontextModes * modes) while (modes != NULL) { __GLcontextModes *const next = modes->next; - _mesa_free(modes); + free(modes); modes = next; } } diff --git a/src/glx/glcontextmodes.h b/src/glx/glcontextmodes.h index 6676ae306c..ecf0280cba 100644 --- a/src/glx/glcontextmodes.h +++ b/src/glx/glcontextmodes.h @@ -32,14 +32,12 @@ #include "GL/internal/glcore.h" -#if !defined(IN_MINI_GLX) extern GLint _gl_convert_from_x_visual_type(int visualType); extern GLint _gl_convert_to_x_visual_type(int visualType); extern void _gl_copy_visual_to_context_mode(__GLcontextModes * mode, const __GLXvisualConfig * config); extern int _gl_get_context_mode_data(const __GLcontextModes * mode, int attribute, int *value_return); -#endif /* !defined(IN_MINI_GLX) */ extern __GLcontextModes *_gl_context_modes_create(unsigned count, size_t minimum_size); diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 4dd2293b24..42ab7d4ed6 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -307,7 +307,7 @@ _mesa_meta_free(GLcontext *ctx) * freed by the normal context destruction code. But this would be * the place to free other meta data someday. */ - _mesa_free(ctx->Meta); + free(ctx->Meta); ctx->Meta = NULL; } @@ -1304,7 +1304,7 @@ _mesa_meta_BlitFramebuffer(GLcontext *ctx, } if (mask & GL_DEPTH_BUFFER_BIT) { - GLuint *tmp = (GLuint *) _mesa_malloc(srcW * srcH * sizeof(GLuint)); + GLuint *tmp = (GLuint *) malloc(srcW * srcH * sizeof(GLuint)); if (tmp) { if (!blit->DepthFP) init_blit_depth_pixels(ctx); @@ -1328,7 +1328,7 @@ _mesa_meta_BlitFramebuffer(GLcontext *ctx, _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); mask &= ~GL_DEPTH_BUFFER_BIT; - _mesa_free(tmp); + free(tmp); } } @@ -2065,7 +2065,7 @@ _mesa_meta_Bitmap(GLcontext *ctx, if (!bitmap1) return; - bitmap8 = (GLubyte *) _mesa_calloc(width * height); + bitmap8 = (GLubyte *) calloc(1, width * height); if (bitmap8) { _mesa_expand_bitmap(width, height, &unpackSave, bitmap1, bitmap8, width, 0xff); @@ -2082,7 +2082,7 @@ _mesa_meta_Bitmap(GLcontext *ctx, _mesa_set_enable(ctx, tex->Target, GL_FALSE); - _mesa_free(bitmap8); + free(bitmap8); } _mesa_unmap_pbo_source(ctx, &unpackSave); @@ -2531,7 +2531,7 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, /* * Alloc image buffer (XXX could use a PBO) */ - buf = _mesa_malloc(width * height * bpp); + buf = malloc(width * height * bpp); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims); return; @@ -2592,7 +2592,7 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, _mesa_lock_texture(ctx, texObj); /* re-lock */ - _mesa_free(buf); + free(buf); } @@ -2647,7 +2647,7 @@ copy_tex_sub_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, /* * Alloc image buffer (XXX could use a PBO) */ - buf = _mesa_malloc(width * height * bpp); + buf = malloc(width * height * bpp); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage%uD", dims); return; @@ -2688,7 +2688,7 @@ copy_tex_sub_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, _mesa_lock_texture(ctx, texObj); /* re-lock */ - _mesa_free(buf); + free(buf); } @@ -2731,7 +2731,7 @@ _mesa_meta_CopyColorTable(GLcontext *ctx, { GLfloat *buf; - buf = (GLfloat *) _mesa_malloc(width * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyColorTable"); return; @@ -2748,7 +2748,7 @@ _mesa_meta_CopyColorTable(GLcontext *ctx, _mesa_meta_end(ctx); - _mesa_free(buf); + free(buf); } @@ -2758,7 +2758,7 @@ _mesa_meta_CopyColorSubTable(GLcontext *ctx,GLenum target, GLsizei start, { GLfloat *buf; - buf = (GLfloat *) _mesa_malloc(width * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyColorSubTable"); return; @@ -2775,7 +2775,7 @@ _mesa_meta_CopyColorSubTable(GLcontext *ctx,GLenum target, GLsizei start, _mesa_meta_end(ctx); - _mesa_free(buf); + free(buf); } @@ -2786,7 +2786,7 @@ _mesa_meta_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, { GLfloat *buf; - buf = (GLfloat *) _mesa_malloc(width * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * 4 * sizeof(GLfloat)); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyConvolutionFilter2D"); return; @@ -2805,7 +2805,7 @@ _mesa_meta_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, _mesa_meta_end(ctx); - _mesa_free(buf); + free(buf); } @@ -2816,7 +2816,7 @@ _mesa_meta_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, { GLfloat *buf; - buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!buf) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyConvolutionFilter2D"); return; @@ -2836,5 +2836,5 @@ _mesa_meta_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, _mesa_meta_end(ctx); - _mesa_free(buf); + free(buf); } diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 58a94b5868..9142dd72f5 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -242,12 +242,12 @@ __driUtilUpdateDrawableInfo(__DRIdrawable *pdp) } if (pdp->pClipRects) { - _mesa_free(pdp->pClipRects); + free(pdp->pClipRects); pdp->pClipRects = NULL; } if (pdp->pBackClipRects) { - _mesa_free(pdp->pBackClipRects); + free(pdp->pBackClipRects); pdp->pBackClipRects = NULL; } @@ -324,7 +324,7 @@ static void driSwapBuffers(__DRIdrawable *dPriv) if (!dPriv->numClipRects) return; - rects = _mesa_malloc(sizeof(*rects) * dPriv->numClipRects); + rects = malloc(sizeof(*rects) * dPriv->numClipRects); if (!rects) return; @@ -337,7 +337,7 @@ static void driSwapBuffers(__DRIdrawable *dPriv) } driReportDamage(dPriv, rects, dPriv->numClipRects); - _mesa_free(rects); + free(rects); } static int driDrawableGetMSC( __DRIscreen *sPriv, __DRIdrawable *dPriv, @@ -430,7 +430,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, */ (void) attrs; - pdp = _mesa_malloc(sizeof *pdp); + pdp = malloc(sizeof *pdp); if (!pdp) { return NULL; } @@ -457,7 +457,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes, renderType == GLX_PIXMAP_BIT)) { - _mesa_free(pdp); + free(pdp); return NULL; } @@ -510,14 +510,14 @@ static void dri_put_drawable(__DRIdrawable *pdp) psp = pdp->driScreenPriv; (*psp->DriverAPI.DestroyBuffer)(pdp); if (pdp->pClipRects && pdp->pClipRects != &pdp->dri2.clipRect) { - _mesa_free(pdp->pClipRects); + free(pdp->pClipRects); pdp->pClipRects = NULL; } if (pdp->pBackClipRects && pdp->pClipRects != &pdp->dri2.clipRect) { - _mesa_free(pdp->pBackClipRects); + free(pdp->pBackClipRects); pdp->pBackClipRects = NULL; } - _mesa_free(pdp); + free(pdp); } } @@ -547,7 +547,7 @@ driDestroyContext(__DRIcontext *pcp) { if (pcp) { (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp); - _mesa_free(pcp); + free(pcp); } } @@ -577,7 +577,7 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, __DRIcontext *pcp; void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; - pcp = _mesa_malloc(sizeof *pcp); + pcp = malloc(sizeof *pcp); if (!pcp) return NULL; @@ -602,7 +602,7 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, pcp->hHWContext = hwContext; if ( !(*psp->DriverAPI.CreateContext)(&config->modes, pcp, shareCtx) ) { - _mesa_free(pcp); + free(pcp); return NULL; } @@ -656,7 +656,7 @@ static void driDestroyScreen(__DRIscreen *psp) (void)drmCloseOnce(psp->fd); } - _mesa_free(psp); + free(psp); } } @@ -718,7 +718,7 @@ driCreateNewScreen(int scrn, static const __DRIextension *emptyExtensionList[] = { NULL }; __DRIscreen *psp; - psp = _mesa_calloc(sizeof *psp); + psp = calloc(1, sizeof *psp); if (!psp) return NULL; @@ -763,7 +763,7 @@ driCreateNewScreen(int scrn, *driver_modes = driDriverAPI.InitScreen(psp); if (*driver_modes == NULL) { - _mesa_free(psp); + free(psp); return NULL; } @@ -785,7 +785,7 @@ dri2CreateNewScreen(int scrn, int fd, if (driDriverAPI.InitScreen2 == NULL) return NULL; - psp = _mesa_calloc(sizeof(*psp)); + psp = calloc(1, sizeof(*psp)); if (!psp) return NULL; @@ -807,7 +807,7 @@ dri2CreateNewScreen(int scrn, int fd, psp->DriverAPI = driDriverAPI; *driver_configs = driDriverAPI.InitScreen2(psp); if (*driver_configs == NULL) { - _mesa_free(psp); + free(psp); return NULL; } diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.c b/src/mesa/drivers/dri/common/drirenderbuffer.c index fe38f608a9..48a2c66229 100644 --- a/src/mesa/drivers/dri/common/drirenderbuffer.c +++ b/src/mesa/drivers/dri/common/drirenderbuffer.c @@ -32,7 +32,7 @@ driDeleteRenderbuffer(struct gl_renderbuffer *rb) /* don't free rb->Data Chances are it's a memory mapped region for * the dri drivers. */ - _mesa_free(rb); + free(rb); } @@ -70,7 +70,7 @@ driNewRenderbuffer(gl_format format, GLvoid *addr, assert(cpp > 0); assert(pitch > 0); - drb = _mesa_calloc(sizeof(driRenderbuffer)); + drb = calloc(1, sizeof(driRenderbuffer)); if (drb) { const GLuint name = 0; diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index 833f9ad232..8c15cbbf73 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -108,7 +108,7 @@ driGetRendererString( char * buffer, const char * hardware_name, cpu = _mesa_get_cpu_string(); if (cpu) { offset += sprintf(buffer + offset, " %s", cpu); - _mesa_free(cpu); + free(cpu); } return offset; @@ -559,7 +559,7 @@ driCreateConfigs(GLenum fb_format, GLenum fb_type, } num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * num_msaa_modes; - configs = _mesa_calloc((num_modes + 1) * sizeof *configs); + configs = calloc(1, (num_modes + 1) * sizeof *configs); if (configs == NULL) return NULL; @@ -568,7 +568,7 @@ driCreateConfigs(GLenum fb_format, GLenum fb_type, for ( i = 0 ; i < num_db_modes ; i++ ) { for ( h = 0 ; h < num_msaa_modes; h++ ) { for ( j = 0 ; j < num_accum_bits ; j++ ) { - *c = _mesa_malloc (sizeof **c); + *c = malloc (sizeof **c); modes = &(*c)->modes; c++; @@ -653,7 +653,7 @@ __DRIconfig **driConcatConfigs(__DRIconfig **a, while (b[j] != NULL) j++; - all = _mesa_malloc((i + j + 1) * sizeof *all); + all = malloc((i + j + 1) * sizeof *all); index = 0; for (i = 0; a[i] != NULL; i++) all[index++] = a[i]; @@ -661,8 +661,8 @@ __DRIconfig **driConcatConfigs(__DRIconfig **a, all[index++] = b[j]; all[index++] = NULL; - _mesa_free(a); - _mesa_free(b); + free(a); + free(b); return all; } diff --git a/src/mesa/drivers/dri/fb/fb_dri.c b/src/mesa/drivers/dri/fb/fb_dri.c index 0675bb9894..ac07e57db1 100644 --- a/src/mesa/drivers/dri/fb/fb_dri.c +++ b/src/mesa/drivers/dri/fb/fb_dri.c @@ -340,7 +340,7 @@ fbCreateContext( const __GLcontextModes *glVisual, assert(driContextPriv); /* Allocate the Fb context */ - fbmesa = (fbContextPtr) _mesa_calloc( sizeof(*fbmesa) ); + fbmesa = (fbContextPtr) calloc(1, sizeof(*fbmesa) ); if ( !fbmesa ) return GL_FALSE; @@ -358,7 +358,7 @@ fbCreateContext( const __GLcontextModes *glVisual, ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions, (void *) fbmesa); if (!fbmesa->glCtx) { - _mesa_free(fbmesa); + free(fbmesa); return GL_FALSE; } driContextPriv->driverPrivate = fbmesa; @@ -406,7 +406,7 @@ fbDestroyContext( __DRIcontext *driContextPriv ) fbmesa->glCtx->DriverCtx = NULL; _mesa_destroy_context( fbmesa->glCtx ); - _mesa_free( fbmesa ); + free( fbmesa ); } } @@ -449,7 +449,7 @@ fbCreateBuffer( __DRIscreen *driScrnPriv, } if (mesaVis->doubleBufferMode) { /* XXX what are the correct origin/stride values? */ - GLvoid *backBuf = _mesa_malloc(driScrnPriv->fbStride + GLvoid *backBuf = malloc(driScrnPriv->fbStride * driScrnPriv->fbHeight); driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, backBuf, @@ -503,7 +503,7 @@ fbSwapBuffers( __DRIdrawable *dPriv ) if (ctx->Visual.doubleBufferMode) { int i; int offset = 0; - char *tmp = _mesa_malloc(currentPitch); + char *tmp = malloc(currentPitch); _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ @@ -516,7 +516,7 @@ fbSwapBuffers( __DRIdrawable *dPriv ) offset += currentPitch; } - _mesa_free(tmp); + free(tmp); } } else { diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c index 6cb8edb611..cb9cd836a0 100644 --- a/src/mesa/drivers/dri/i965/brw_curbe.c +++ b/src/mesa/drivers/dri/i965/brw_curbe.c @@ -199,7 +199,7 @@ static void prepare_constant_buffer(struct brw_context *brw) return; } - buf = (GLfloat *) _mesa_calloc(bufsz); + buf = (GLfloat *) calloc(1, bufsz); /* fragment shader constants */ if (brw->curbe.wm_size) { @@ -294,12 +294,12 @@ static void prepare_constant_buffer(struct brw_context *brw) bufsz == brw->curbe.last_bufsz && memcmp(buf, brw->curbe.last_buf, bufsz) == 0) { /* constants have not changed */ - _mesa_free(buf); + free(buf); } else { /* constants have changed */ if (brw->curbe.last_buf) - _mesa_free(brw->curbe.last_buf); + free(brw->curbe.last_buf); brw->curbe.last_buf = buf; brw->curbe.last_bufsz = bufsz; diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index c46b9ba89c..ceaeb923b0 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -320,7 +320,7 @@ copy_array_to_vbo_array( struct brw_context *brw, } else { void *data; - data = _mesa_malloc(dst_stride * element->count); + data = malloc(dst_stride * element->count); dest = data; for (i = 0; i < element->count; i++) { memcpy(dest, src, dst_stride); @@ -333,7 +333,7 @@ copy_array_to_vbo_array( struct brw_context *brw, size, data); - _mesa_free(data); + free(data); } } } diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c index 1df561386e..4e7c1226ad 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.c +++ b/src/mesa/drivers/dri/i965/brw_eu.c @@ -237,7 +237,7 @@ brw_resolve_cals(struct brw_compile *c) struct brw_glsl_call *call, *next; for (call = c->first_call; call; call = next) { next = call->next; - _mesa_free(call); + free(call); } c->first_call = NULL; } @@ -247,7 +247,7 @@ brw_resolve_cals(struct brw_compile *c) struct brw_glsl_label *label, *next; for (label = c->first_label; label; label = next) { next = label->next; - _mesa_free(label); + free(label); } c->first_label = NULL; } diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index 5399a74244..6cce7e5089 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -73,7 +73,7 @@ brw_new_query_object(GLcontext *ctx, GLuint id) { struct brw_query_object *query; - query = _mesa_calloc(sizeof(struct brw_query_object)); + query = calloc(1, sizeof(struct brw_query_object)); query->Base.Id = id; query->Base.Result = 0; @@ -89,7 +89,7 @@ brw_delete_query(GLcontext *ctx, struct gl_query_object *q) struct brw_query_object *query = (struct brw_query_object *)q; dri_bo_unreference(query->bo); - _mesa_free(query); + free(query); } static void diff --git a/src/mesa/drivers/dri/i965/brw_state_batch.c b/src/mesa/drivers/dri/i965/brw_state_batch.c index ed8120d617..39019412fd 100644 --- a/src/mesa/drivers/dri/i965/brw_state_batch.c +++ b/src/mesa/drivers/dri/i965/brw_state_batch.c @@ -57,8 +57,8 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw, if (item->sz == sz && memcmp(item->header, newheader, sz) == 0) return GL_FALSE; if (item->sz != sz) { - _mesa_free(item->header); - item->header = _mesa_malloc(sz); + free(item->header); + item->header = malloc(sz); item->sz = sz; } goto emit; @@ -68,7 +68,7 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw, assert(!item); item = CALLOC_STRUCT(brw_cached_batch_item); - item->header = _mesa_malloc(sz); + item->header = malloc(sz); item->sz = sz; item->next = brw->cached_batch_items; brw->cached_batch_items = item; diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index 1369d97e21..dd9894d681 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -150,7 +150,7 @@ rehash(struct brw_cache *cache) GLuint size, i; size = cache->size * 3; - items = (struct brw_cache_item**) _mesa_calloc(size * sizeof(*items)); + items = (struct brw_cache_item**) calloc(1, size * sizeof(*items)); for (i = 0; i < cache->size; i++) for (c = cache->items[i]; c; c = next) { @@ -237,7 +237,7 @@ brw_upload_cache_with_auxdata(struct brw_cache *cache, /* Set up the memory containing the key, aux_data, and reloc_bufs */ - tmp = _mesa_malloc(key_size + aux_size + relocs_size); + tmp = malloc(key_size + aux_size + relocs_size); memcpy(tmp, key, key_size); memcpy(tmp + key_size, aux, aux_size); @@ -366,7 +366,7 @@ brw_init_non_surface_cache(struct brw_context *brw) cache->size = 7; cache->n_items = 0; cache->items = (struct brw_cache_item **) - _mesa_calloc(cache->size * sizeof(struct brw_cache_item)); + calloc(1, cache->size * sizeof(struct brw_cache_item)); brw_init_cache_id(cache, "CC_VP", BRW_CC_VP); brw_init_cache_id(cache, "CC_UNIT", BRW_CC_UNIT); @@ -403,7 +403,7 @@ brw_init_surface_cache(struct brw_context *brw) cache->size = 7; cache->n_items = 0; cache->items = (struct brw_cache_item **) - _mesa_calloc(cache->size * sizeof(struct brw_cache_item)); + calloc(1, cache->size * sizeof(struct brw_cache_item)); brw_init_cache_id(cache, "SS_SURFACE", BRW_SS_SURFACE); brw_init_cache_id(cache, "SS_SURF_BIND", BRW_SS_SURF_BIND); @@ -444,7 +444,7 @@ brw_clear_cache(struct brw_context *brw, struct brw_cache *cache) cache->n_items = 0; if (brw->curbe.last_buf) { - _mesa_free(brw->curbe.last_buf); + free(brw->curbe.last_buf); brw->curbe.last_buf = NULL; } diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 681319dedf..0b0be02dd2 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -67,11 +67,11 @@ static void brw_destroy_context( struct intel_context *intel ) brw_draw_destroy( brw ); brw_clear_validated_bos(brw); if (brw->wm.compile_data) { - _mesa_free(brw->wm.compile_data->instruction); - _mesa_free(brw->wm.compile_data->vreg); - _mesa_free(brw->wm.compile_data->refs); - _mesa_free(brw->wm.compile_data->prog_instructions); - _mesa_free(brw->wm.compile_data); + free(brw->wm.compile_data->instruction); + free(brw->wm.compile_data->vreg); + free(brw->wm.compile_data->refs); + free(brw->wm.compile_data->prog_instructions); + free(brw->wm.compile_data); } for (i = 0; i < brw->state.nr_color_regions; i++) diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 9191c81755..991e1b964b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -151,11 +151,11 @@ static void do_wm_prog( struct brw_context *brw, */ return; } - c->instruction = _mesa_calloc(BRW_WM_MAX_INSN * sizeof(*c->instruction)); - c->prog_instructions = _mesa_calloc(BRW_WM_MAX_INSN * + c->instruction = calloc(1, BRW_WM_MAX_INSN * sizeof(*c->instruction)); + c->prog_instructions = calloc(1, BRW_WM_MAX_INSN * sizeof(*c->prog_instructions)); - c->vreg = _mesa_calloc(BRW_WM_MAX_VREG * sizeof(*c->vreg)); - c->refs = _mesa_calloc(BRW_WM_MAX_REF * sizeof(*c->refs)); + c->vreg = calloc(1, BRW_WM_MAX_VREG * sizeof(*c->vreg)); + c->refs = calloc(1, BRW_WM_MAX_REF * sizeof(*c->refs)); } else { void *instruction = c->instruction; void *prog_instructions = c->prog_instructions; diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c index 3b7015b5ad..312866d865 100644 --- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c +++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c @@ -113,7 +113,7 @@ intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj) if (obj->Pointer) intel_bufferobj_unmap(ctx, 0, obj); - _mesa_free(intel_obj->sys_buffer); + free(intel_obj->sys_buffer); if (intel_obj->region) { intel_bufferobj_release_region(intel, intel_obj); } @@ -121,7 +121,7 @@ intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj) dri_bo_unreference(intel_obj->buffer); } - _mesa_free(intel_obj); + free(intel_obj); } @@ -155,7 +155,7 @@ intel_bufferobj_data(GLcontext * ctx, dri_bo_unreference(intel_obj->buffer); intel_obj->buffer = NULL; } - _mesa_free(intel_obj->sys_buffer); + free(intel_obj->sys_buffer); intel_obj->sys_buffer = NULL; if (size != 0) { @@ -164,7 +164,7 @@ intel_bufferobj_data(GLcontext * ctx, * with their contents anyway. */ if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) { - intel_obj->sys_buffer = _mesa_malloc(size); + intel_obj->sys_buffer = malloc(size); if (intel_obj->sys_buffer != NULL) { if (data != NULL) memcpy(intel_obj->sys_buffer, data, size); @@ -373,7 +373,7 @@ intel_bufferobj_map_range(GLcontext * ctx, if ((access & GL_MAP_INVALIDATE_RANGE_BIT) && drm_intel_bo_busy(intel_obj->buffer)) { if (access & GL_MAP_FLUSH_EXPLICIT_BIT) { - intel_obj->range_map_buffer = _mesa_malloc(length); + intel_obj->range_map_buffer = malloc(length); obj->Pointer = intel_obj->range_map_buffer; } else { intel_obj->range_map_bo = drm_intel_bo_alloc(intel->bufmgr, @@ -523,7 +523,7 @@ intel_bufferobj_buffer(struct intel_context *intel, intel_obj->Base.Size, sys_buffer, &intel_obj->Base); - _mesa_free(sys_buffer); + free(sys_buffer); intel_obj->sys_buffer = NULL; } diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index d58ffd95fa..40b867971d 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -71,13 +71,13 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb) ASSERT(irb); if (irb->span_cache != NULL) - _mesa_free(irb->span_cache); + free(irb->span_cache); if (intel && irb->region) { intel_region_release(&irb->region); } - _mesa_free(irb); + free(irb); } @@ -316,7 +316,7 @@ intel_create_renderbuffer(gl_format format) default: _mesa_problem(NULL, "Unexpected intFormat in intel_create_renderbuffer"); - _mesa_free(irb); + free(irb); return NULL; } @@ -468,7 +468,7 @@ intel_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage) irb->Base.ClassID = INTEL_RB_CLASS; if (!intel_update_wrapper(ctx, irb, texImage)) { - _mesa_free(irb); + free(irb); return NULL; } diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index eabfbf4af9..54998a63f6 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -395,7 +395,7 @@ intel_texture_bitmap(GLcontext * ctx, } /* Convert the A1 bitmap to an A8 format suitable for glTexImage */ - a8_bitmap = _mesa_calloc(width * height); + a8_bitmap = calloc(1, width * height); _mesa_expand_bitmap(width, height, unpack, bitmap, a8_bitmap, width, 0xff); if (_mesa_is_bufferobj(unpack->BufferObj)) { @@ -430,7 +430,7 @@ intel_texture_bitmap(GLcontext * ctx, _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, 1); _mesa_TexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, a8_bitmap); - _mesa_free(a8_bitmap); + free(a8_bitmap); meta_set_fragment_program(&intel->meta, &intel->meta.bitmap_fp, fp); _mesa_ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0, diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 10177228bd..bd1dd13fb7 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -147,7 +147,7 @@ intel_stencil_drawpixels(GLcontext * ctx, /* Unpack the supplied stencil values into a ubyte buffer. */ assert(sizeof(GLstencil) == sizeof(GLubyte)); - stencil_pixels = _mesa_malloc(width * height * sizeof(GLstencil)); + stencil_pixels = malloc(width * height * sizeof(GLstencil)); for (row = 0; row < height; row++) { GLvoid *source = _mesa_image_address2d(unpack, pixels, width, height, @@ -201,7 +201,7 @@ intel_stencil_drawpixels(GLcontext * ctx, _mesa_TexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, width, height, 0, GL_RED, GL_UNSIGNED_BYTE, stencil_pixels); ctx->Unpack = old_unpack; - _mesa_free(stencil_pixels); + free(stencil_pixels); meta_set_passthrough_transform(&intel->meta); diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 97bb97265f..0072bb15fc 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -49,7 +49,7 @@ static void get_span_cache(struct intel_renderbuffer *irb, uint32_t offset) { if (irb->span_cache == NULL) { - irb->span_cache = _mesa_malloc(SPAN_CACHE_SIZE); + irb->span_cache = malloc(SPAN_CACHE_SIZE); irb->span_cache_offset = -1; } diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c index 0d7889d3c2..d67f0cb4a6 100644 --- a/src/mesa/drivers/dri/intel/intel_syncobj.c +++ b/src/mesa/drivers/dri/intel/intel_syncobj.c @@ -50,7 +50,7 @@ intel_new_sync_object(GLcontext *ctx, GLuint id) { struct intel_sync_object *sync; - sync = _mesa_calloc(sizeof(struct intel_sync_object)); + sync = calloc(1, sizeof(struct intel_sync_object)); return &sync->Base; } @@ -61,7 +61,7 @@ intel_delete_sync_object(GLcontext *ctx, struct gl_sync_object *s) struct intel_sync_object *sync = (struct intel_sync_object *)s; drm_intel_bo_unreference(sync->bo); - _mesa_free(sync); + free(sync); } static void diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c index acc66e0ae0..a5810ee500 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c @@ -277,7 +277,7 @@ struct r300_fragment_program *r300SelectAndTranslateFragmentShader(GLcontext *ct fp = fp->next; } - fp = _mesa_calloc(sizeof(struct r300_fragment_program)); + fp = calloc(1, sizeof(struct r300_fragment_program)); fp->state = state; diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c index 3638010e48..9c24166ec5 100644 --- a/src/mesa/drivers/dri/r300/r300_shader.c +++ b/src/mesa/drivers/dri/r300/r300_shader.c @@ -39,7 +39,7 @@ static void freeFragProgCache(GLcontext *ctx, struct r300_fragment_program_cont while (fp) { tmp = fp->next; rc_constants_destroy(&fp->code.constants); - _mesa_free(fp); + free(fp); fp = tmp; } } @@ -52,7 +52,7 @@ static void freeVertProgCache(GLcontext *ctx, struct r300_vertex_program_cont *c tmp = vp->next; rc_constants_destroy(&vp->code.constants); _mesa_reference_vertprog(ctx, &vp->Base, NULL); - _mesa_free(vp); + free(vp); vp = tmp; } } diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index a74b7001dd..6a366b438b 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -233,7 +233,7 @@ static struct r300_vertex_program *build_program(GLcontext *ctx, struct r300_vertex_program *vp; struct r300_vertex_program_compiler compiler; - vp = _mesa_calloc(sizeof(*vp)); + vp = calloc(1, sizeof(*vp)); vp->Base = _mesa_clone_vertex_program(ctx, mesa_vp); memcpy(&vp->key, wanted_key, sizeof(vp->key)); diff --git a/src/mesa/drivers/dri/r600/r700_oglprog.c b/src/mesa/drivers/dri/r600/r700_oglprog.c index 2a50361199..b7124e644a 100644 --- a/src/mesa/drivers/dri/r600/r700_oglprog.c +++ b/src/mesa/drivers/dri/r600/r700_oglprog.c @@ -53,7 +53,7 @@ static void freeVertProgCache(GLcontext *ctx, struct r700_vertex_program_cont *c Clean_Up_Shader(&(vp->r700Shader)); _mesa_reference_vertprog(ctx, &vp->mesa_program, NULL); - _mesa_free(vp); + free(vp); vp = tmp; } } diff --git a/src/mesa/drivers/dri/r600/r700_vertprog.c b/src/mesa/drivers/dri/r600/r700_vertprog.c index 46481cdff4..07e0adc890 100644 --- a/src/mesa/drivers/dri/r600/r700_vertprog.c +++ b/src/mesa/drivers/dri/r600/r700_vertprog.c @@ -307,7 +307,7 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx, struct r700_vertex_program *vp; unsigned int i; - vp = _mesa_calloc(sizeof(*vp)); + vp = calloc(1, sizeof(*vp)); vp->mesa_program = _mesa_clone_vertex_program(ctx, mesa_vp); if (mesa_vp->IsPositionInvariant) diff --git a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c index bc5915d3e4..0897dafbd8 100644 --- a/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c +++ b/src/mesa/drivers/dri/radeon/radeon_buffer_objects.c @@ -70,7 +70,7 @@ radeonDeleteBufferObject(GLcontext * ctx, radeon_bo_unref(radeon_obj->bo); } - _mesa_free(radeon_obj); + free(radeon_obj); } diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c index 56dcc50785..a8931e8478 100644 --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c @@ -66,7 +66,7 @@ radeon_delete_renderbuffer(struct gl_renderbuffer *rb) if (rrb && rrb->bo) { radeon_bo_unref(rrb->bo); } - _mesa_free(rrb); + free(rrb); } static void * @@ -511,7 +511,7 @@ radeon_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage) rrb->base.ClassID = RADEON_RB_CLASS; if (!radeon_update_wrapper(ctx, rrb, texImage)) { - _mesa_free(rrb); + free(rrb); return NULL; } diff --git a/src/mesa/drivers/dri/radeon/radeon_queryobj.c b/src/mesa/drivers/dri/radeon/radeon_queryobj.c index d0dcf0e431..04ce12493e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_queryobj.c +++ b/src/mesa/drivers/dri/radeon/radeon_queryobj.c @@ -81,7 +81,7 @@ static struct gl_query_object * radeonNewQueryObject(GLcontext *ctx, GLuint id) { struct radeon_query_object *query; - query = _mesa_calloc(sizeof(struct radeon_query_object)); + query = calloc(1, sizeof(struct radeon_query_object)); query->Base.Id = id; query->Base.Result = 0; @@ -103,7 +103,7 @@ static void radeonDeleteQuery(GLcontext *ctx, struct gl_query_object *q) radeon_bo_unref(query->bo); } - _mesa_free(query); + free(query); } static void radeonWaitQuery(GLcontext *ctx, struct gl_query_object *q) diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 9b9d90bdd0..ff37fd3e86 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -637,7 +637,7 @@ static GLuint * allocate_image_offsets(GLcontext *ctx, int i; GLuint *offsets; - offsets = _mesa_malloc(depth * sizeof(GLuint)) ; + offsets = malloc(depth * sizeof(GLuint)) ; if (!offsets) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex[Sub]Image"); return NULL; @@ -736,7 +736,7 @@ static void radeon_store_teximage(GLcontext* ctx, int dims, } if (dims == 3) { - _mesa_free(dstImageOffsets); + free(dstImageOffsets); } radeon_teximage_unmap(image); diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index 74a001b789..6f07ac275e 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -179,7 +179,7 @@ savageInitDriver(__DRIscreen *sPriv) } /* Allocate the private area */ - savageScreen = (savageScreenPrivate *)_mesa_malloc(sizeof(savageScreenPrivate)); + savageScreen = (savageScreenPrivate *)malloc(sizeof(savageScreenPrivate)); if (!savageScreen) return GL_FALSE; @@ -226,7 +226,7 @@ savageInitDriver(__DRIscreen *sPriv) savageScreen->agpTextures.handle, savageScreen->agpTextures.size, (drmAddress *)&(savageScreen->agpTextures.map)) != 0) { - _mesa_free(savageScreen); + free(savageScreen); sPriv->private = NULL; return GL_FALSE; } @@ -246,7 +246,7 @@ savageInitDriver(__DRIscreen *sPriv) savageScreen->aperture.size, (drmAddress *)&savageScreen->aperture.map) != 0) { - _mesa_free(savageScreen); + free(savageScreen); sPriv->private = NULL; return GL_FALSE; } @@ -282,7 +282,7 @@ savageDestroyScreen(__DRIscreen *sPriv) /* free all option information */ driDestroyOptionInfo (&savageScreen->optionCache); - _mesa_free(savageScreen); + free(savageScreen); sPriv->private = NULL; } @@ -300,7 +300,7 @@ savageCreateContext( const __GLcontextModes *mesaVis, savageScreen->sarea_priv_offset); int textureSize[SAVAGE_NR_TEX_HEAPS]; int i; - imesa = (savageContextPtr)_mesa_calloc(sizeof(savageContext)); + imesa = (savageContextPtr)calloc(1, sizeof(savageContext)); if (!imesa) { return GL_FALSE; } @@ -317,7 +317,7 @@ savageCreateContext( const __GLcontextModes *mesaVis, shareCtx = NULL; ctx = _mesa_create_context(mesaVis, shareCtx, &functions, imesa); if (!ctx) { - _mesa_free(imesa); + free(imesa); return GL_FALSE; } driContextPriv->driverPrivate = imesa; @@ -436,7 +436,7 @@ savageCreateContext( const __GLcontextModes *mesaVis, if (ctx->Const.MaxTextureLevels <= 6) { /*spec requires at least 64x64*/ __driUtilMessage("Not enough texture memory. " "Falling back to indirect rendering."); - _mesa_free(imesa); + free(imesa); return GL_FALSE; } @@ -574,7 +574,7 @@ savageDestroyContext(__DRIcontext *driContextPriv) _mesa_destroy_context(imesa->glCtx); /* no longer use vertex_dma_buf*/ - _mesa_free(imesa); + free(imesa); } } diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c index 394be44eac..1a748ee126 100644 --- a/src/mesa/drivers/dri/savage/savagetex.c +++ b/src/mesa/drivers/dri/savage/savagetex.c @@ -603,7 +603,7 @@ _savage_texstore_a1114444(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); return GL_TRUE; } @@ -643,7 +643,7 @@ _savage_texstore_a1118888(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 40535b03b9..b2e7df34e8 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -155,7 +155,7 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions, TRACE; - psp = _mesa_calloc(sizeof(*psp)); + psp = calloc(1, sizeof(*psp)); if (!psp) return NULL; @@ -184,7 +184,7 @@ static void driDestroyScreen(__DRIscreen *psp) TRACE; if (psp) { - _mesa_free(psp); + free(psp); } } @@ -241,8 +241,8 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) { TRACE; - _mesa_free(rb->Data); - _mesa_free(rb); + free(rb->Data); + free(rb); } static GLboolean @@ -272,11 +272,11 @@ swrast_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, TRACE; - _mesa_free(rb->Data); + free(rb->Data); swrast_alloc_front_storage(ctx, rb, internalFormat, width, height); - rb->Data = _mesa_malloc(height * xrb->pitch); + rb->Data = malloc(height * xrb->pitch); return GL_TRUE; } @@ -284,7 +284,7 @@ swrast_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb, static struct swrast_renderbuffer * swrast_new_renderbuffer(const GLvisual *visual, GLboolean front) { - struct swrast_renderbuffer *xrb = _mesa_calloc(sizeof *xrb); + struct swrast_renderbuffer *xrb = calloc(1, sizeof *xrb); GLuint pixel_format; TRACE; @@ -358,7 +358,7 @@ driCreateNewDrawable(__DRIscreen *screen, TRACE; - buf = _mesa_calloc(sizeof *buf); + buf = calloc(1, sizeof *buf); if (!buf) return NULL; @@ -366,7 +366,7 @@ driCreateNewDrawable(__DRIscreen *screen, buf->driScreenPriv = screen; - buf->row = _mesa_malloc(MAX_WIDTH * 4); + buf->row = malloc(MAX_WIDTH * 4); /* basic framebuffer setup */ _mesa_initialize_window_framebuffer(&buf->Base, &config->modes); @@ -401,7 +401,7 @@ driDestroyDrawable(__DRIdrawable *buf) if (buf) { struct gl_framebuffer *fb = &buf->Base; - _mesa_free(buf->row); + free(buf->row); fb->DeletePending = GL_TRUE; _mesa_reference_framebuffer(&fb, NULL); @@ -525,7 +525,7 @@ driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config, TRACE; - ctx = _mesa_calloc(sizeof *ctx); + ctx = calloc(1, sizeof *ctx); if (!ctx) return NULL; @@ -540,7 +540,7 @@ driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config, if (!_mesa_initialize_context(&ctx->Base, &config->modes, shared ? &shared->Base : NULL, &functions, (void *) ctx)) { - _mesa_free(ctx); + free(ctx); return NULL; } diff --git a/src/mesa/drivers/dri/unichrome/via_fb.c b/src/mesa/drivers/dri/unichrome/via_fb.c index e4fb29f6c6..bebf0619d0 100644 --- a/src/mesa/drivers/dri/unichrome/via_fb.c +++ b/src/mesa/drivers/dri/unichrome/via_fb.c @@ -156,7 +156,7 @@ via_alloc_texture(struct via_context *vmesa, } else if (t->memType == VIA_MEM_SYSTEM) { - t->bufAddr = _mesa_malloc(t->size); + t->bufAddr = malloc(t->size); if (!t->bufAddr) goto cleanup; @@ -226,8 +226,8 @@ via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t) else if (t->memType == VIA_MEM_SYSTEM) { remove_from_list(t); vmesa->total_alloc[t->memType] -= t->size; - _mesa_free(t->bufAddr); - _mesa_free(t); + free(t->bufAddr); + free(t); } else if (t->index && viaCheckBreadcrumb(vmesa, t->lastUsed)) { via_do_free_texture( vmesa, t ); diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c index 49002512aa..4e369ceac4 100644 --- a/src/mesa/drivers/fbdev/glfbdev.c +++ b/src/mesa/drivers/fbdev/glfbdev.c @@ -392,7 +392,7 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, break; default: /* unexpected token */ - _mesa_free(vis); + free(vis); return NULL; } } @@ -431,7 +431,7 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, } else { _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n"); - _mesa_free(vis); + free(vis); return NULL; } } @@ -445,7 +445,7 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, } else { _mesa_problem(NULL, "Unsupported fbdev CI visual/bitdepth!\n"); - _mesa_free(vis); + free(vis); return NULL; } } @@ -457,7 +457,7 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, accumBlueBits, accumAlphaBits, numSamples)) { /* something was invalid */ - _mesa_free(vis); + free(vis); return NULL; } @@ -469,7 +469,7 @@ void glFBDevDestroyVisual( GLFBDevVisualPtr visual ) { if (visual) - _mesa_free(visual); + free(visual); } @@ -488,9 +488,9 @@ delete_renderbuffer(struct gl_renderbuffer *rb) { struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb; if (frb->mallocedBuffer) { - _mesa_free(frb->Base.Data); + free(frb->Base.Data); } - _mesa_free(frb); + free(frb); } @@ -636,10 +636,10 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo, const int malloced = !backBuffer; if (malloced) { /* malloc a back buffer */ - backBuffer = _mesa_malloc(size); + backBuffer = malloc(size); if (!backBuffer) { _mesa_free_framebuffer_data(&buf->glframebuffer); - _mesa_free(buf); + free(buf); return NULL; } } @@ -769,7 +769,7 @@ glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share ) if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual, share ? &share->glcontext : NULL, &functions, (void *) ctx)) { - _mesa_free(ctx); + free(ctx); return NULL; } @@ -818,7 +818,7 @@ glFBDevDestroyContext( GLFBDevContextPtr context ) _mesa_make_current(NULL, NULL, NULL); } _mesa_free_context_data(&context->glcontext); - _mesa_free(context); + free(context); } } diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index d94bf08a88..b78b101240 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1628,7 +1628,7 @@ fxDDGetString(GLcontext * ctx, GLenum name) if (ctx->Extensions.String == NULL) { GLubyte *ext = _mesa_make_extension_string(ctx); if (ext != NULL) { - ctx->Extensions.String = _mesa_malloc(strlen((char *)ext) + 256); + ctx->Extensions.String = malloc(strlen((char *)ext) + 256); if (ctx->Extensions.String != NULL) { strcpy((char *)ctx->Extensions.String, (char *)ext); /* put any additional extension names here */ @@ -1641,7 +1641,7 @@ fxDDGetString(GLcontext * ctx, GLenum name) strcat((char *)ctx->Extensions.String, " WGL_EXT_extensions_string WGL_ARB_extensions_string"); #endif /* put any additional extension names here */ - _mesa_free(ext); + free(ext); } else { ctx->Extensions.String = ext; } diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index a87a28ac3e..b35874fffc 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -1397,10 +1397,10 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level, mml->width, mml->height, 1); dstRowStride = _mesa_format_row_stride(texImage->TexFormat, mml->width); - texImage->Data = _mesa_malloc(texImage->CompressedSize); + texImage->Data = malloc(texImage->CompressedSize); } else { dstRowStride = mml->width * texelBytes; - texImage->Data = _mesa_malloc(mml->width * mml->height * texelBytes); + texImage->Data = malloc(mml->width * mml->height * texelBytes); } if (!texImage->Data) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); @@ -1654,7 +1654,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target, texImage->CompressedSize = _mesa_format_image_size(texImage->TexFormat, mml->width, mml->height, 1); - texImage->Data = _mesa_malloc(texImage->CompressedSize); + texImage->Data = malloc(texImage->CompressedSize); if (!texImage->Data) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D"); return; diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c index 9bf37967cd..9bb352fcb8 100644 --- a/src/mesa/drivers/glide/fxsetup.c +++ b/src/mesa/drivers/glide/fxsetup.c @@ -107,14 +107,14 @@ fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj) &(mml->wScale), &(mml->hScale)); _w *= mml->wScale; _h *= mml->hScale; - texImage->Data = _mesa_malloc(_w * _h * texelBytes); + texImage->Data = malloc(_w * _h * texelBytes); _mesa_rescale_teximage2d(texelBytes, mml->width, _w * texelBytes, /* dst stride */ mml->width, mml->height, /* src */ _w, _h, /* dst */ texImage_Data /*src*/, texImage->Data /*dst*/ ); - _mesa_free(texImage_Data); + free(texImage_Data); mml->width = _w; mml->height = _h; /* (!) ... and set mml->wScale = _w / texImage->Width */ diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c index e4527abdec..448029dace 100644 --- a/src/mesa/drivers/glslcompiler/glslcompiler.c +++ b/src/mesa/drivers/glslcompiler/glslcompiler.c @@ -119,7 +119,7 @@ CreateContext(void) 0, 0, 0, 0, 1); /* accum */ buf = _mesa_create_framebuffer(vis); - cc = _mesa_calloc(sizeof(*cc)); + cc = calloc(1, sizeof(*cc)); if (!vis || !buf || !cc) { if (vis) _mesa_destroy_visual(vis); @@ -143,7 +143,7 @@ CreateContext(void) !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(vis); _mesa_free_context_data(ctx); - _mesa_free(cc); + free(cc); return GL_FALSE; } TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 1c469b15bf..f9672d888e 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -818,7 +818,7 @@ compute_row_addresses( OSMesaContext osmesa ) static void osmesa_delete_renderbuffer(struct gl_renderbuffer *rb) { - _mesa_free(rb); + free(rb); } @@ -1189,7 +1189,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, 1 /* num samples */ ); if (!osmesa->gl_visual) { - _mesa_free(osmesa); + free(osmesa); return NULL; } @@ -1206,7 +1206,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, : (GLcontext *) NULL, &functions, (void *) osmesa)) { _mesa_destroy_visual( osmesa->gl_visual ); - _mesa_free(osmesa); + free(osmesa); return NULL; } @@ -1221,7 +1221,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, if (!osmesa->gl_buffer) { _mesa_destroy_visual( osmesa->gl_visual ); _mesa_free_context_data( &osmesa->mesa ); - _mesa_free(osmesa); + free(osmesa); return NULL; } @@ -1260,7 +1260,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, !_swsetup_CreateContext( ctx )) { _mesa_destroy_visual(osmesa->gl_visual); _mesa_free_context_data(ctx); - _mesa_free(osmesa); + free(osmesa); return NULL; } @@ -1305,7 +1305,7 @@ OSMesaDestroyContext( OSMesaContext osmesa ) _mesa_reference_framebuffer( &osmesa->gl_buffer, NULL ); _mesa_free_context_data( &osmesa->mesa ); - _mesa_free( osmesa ); + free( osmesa ); } } diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def index d7d6cfa4e2..baa592f136 100644 --- a/src/mesa/drivers/windows/gdi/mesa.def +++ b/src/mesa/drivers/windows/gdi/mesa.def @@ -868,7 +868,6 @@ EXPORTS _mesa_add_soft_renderbuffers _mesa_add_renderbuffer _mesa_bzero - _mesa_calloc _mesa_check_conditional_render _mesa_choose_tex_format _mesa_create_framebuffer @@ -887,7 +886,6 @@ EXPORTS _mesa_error _mesa_finish_render_texture _mesa_framebuffer_renderbuffer - _mesa_free _mesa_free_context_data _mesa_free_texture_image_data _mesa_generate_mipmap diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index b24b758cfb..2fdcb387be 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -1245,7 +1245,7 @@ static void read_rgba_pixels_16(const GLcontext *ctx, static void wmesa_delete_renderbuffer(struct gl_renderbuffer *rb) { - _mesa_free(rb); + free(rb); } @@ -1474,7 +1474,7 @@ WMesaContext WMesaCreateContext(HDC hDC, 1); /* num samples */ if (!visual) { - _mesa_free(c); + free(c); return NULL; } @@ -1512,7 +1512,7 @@ WMesaContext WMesaCreateContext(HDC hDC, !_tnl_CreateContext(ctx) || !_swsetup_CreateContext(ctx)) { _mesa_free_context_data(ctx); - _mesa_free(c); + free(c); return NULL; } _swsetup_Wakeup(ctx); @@ -1557,7 +1557,7 @@ void WMesaDestroyContext( WMesaContext pwc ) _swrast_DestroyContext(ctx); _mesa_free_context_data(ctx); - _mesa_free(pwc); + free(pwc); } diff --git a/src/mesa/drivers/windows/icd/mesa.def b/src/mesa/drivers/windows/icd/mesa.def index f6bd2aa68b..6f33d170ff 100644 --- a/src/mesa/drivers/windows/icd/mesa.def +++ b/src/mesa/drivers/windows/icd/mesa.def @@ -32,8 +32,6 @@ EXPORTS _mesa_buffer_data _mesa_buffer_map _mesa_buffer_subdata - _mesa_bzero - _mesa_calloc _mesa_choose_tex_format _mesa_compressed_texture_size _mesa_create_framebuffer @@ -47,7 +45,6 @@ EXPORTS _mesa_enable_1_5_extensions _mesa_enable_sw_extensions _mesa_error - _mesa_free _mesa_free_context_data _mesa_get_current_context _mesa_init_default_imports diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 291e90c822..f097d93a71 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1381,7 +1381,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); + xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -1438,7 +1438,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, xmvis = create_glx_visual( dpy, visinfo ); if (!xmvis) { /* unusable visual */ - _mesa_free(glxCtx); + free(glxCtx); return NULL; } } @@ -1446,7 +1446,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); if (!glxCtx->xmesaContext) { - _mesa_free(glxCtx); + free(glxCtx); return NULL; } @@ -1671,7 +1671,7 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) MakeCurrent_PrevReadBuffer = 0; XMesaDestroyContext( glxCtx->xmesaContext ); XMesaGarbageCollect(); - _mesa_free(glxCtx); + free(glxCtx); } @@ -2108,7 +2108,7 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); if (*nelements > 0) { XMesaVisual *results; - results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual)); + results = (XMesaVisual *) malloc(*nelements * sizeof(XMesaVisual)); if (!results) { *nelements = 0; return NULL; @@ -2135,7 +2135,7 @@ Fake_glXChooseFBConfig( Display *dpy, int screen, xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); if (xmvis) { - GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual)); + GLXFBConfig *config = (GLXFBConfig *) malloc(sizeof(XMesaVisual)); if (!config) { *nitems = 0; return NULL; @@ -2160,7 +2160,7 @@ Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo)); + xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -2469,7 +2469,7 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config, glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); if (!glxCtx->xmesaContext) { - _mesa_free(glxCtx); + free(glxCtx); return NULL; } @@ -2687,7 +2687,7 @@ Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int re glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); if (!glxCtx->xmesaContext) { - _mesa_free(glxCtx); + free(glxCtx); return NULL; } diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 98ce6c5831..ed945023cf 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -253,7 +253,7 @@ bits_per_pixel( XMesaVisual xmv ) /* grab the bits/pixel value */ bitsPerPixel = img->bits_per_pixel; /* free the XImage */ - _mesa_free( img->data ); + free( img->data ); img->data = NULL; XMesaDestroyImage( img ); return bitsPerPixel; @@ -383,7 +383,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, */ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE); if (!b->frontxrb) { - _mesa_free(b); + free(b); return NULL; } b->frontxrb->Parent = b; @@ -399,7 +399,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type, b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE); if (!b->backxrb) { /* XXX free front xrb too */ - _mesa_free(b); + free(b); return NULL; } b->backxrb->Parent = b; @@ -596,7 +596,7 @@ noFaultXAllocColor( int client, || prevCmapSize != cmapSize || !ctable) { /* free previously cached color table */ if (ctable) - _mesa_free(ctable); + free(ctable); /* Get the color table from X */ ctable = (XMesaColor *) MALLOC(cmapSize * sizeof(XMesaColor)); assert(ctable); @@ -652,8 +652,8 @@ noFaultXAllocColor( int client, *alloced = 0; } #ifdef XFree86Server - _mesa_free(ppixIn); - _mesa_free(ctable); + free(ppixIn); + free(ctable); #else /* don't free table, save it for next time */ #endif @@ -1366,14 +1366,14 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, v->display = display; - /* Save a copy of the XVisualInfo struct because the user may X_mesa_free() + /* Save a copy of the XVisualInfo struct because the user may Xfree() * the struct but we may need some of the information contained in it * at a later time. */ #ifndef XFree86Server v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo)); if(!v->visinfo) { - _mesa_free(v); + free(v); return NULL; } memcpy(v->visinfo, visinfo, sizeof(*visinfo)); @@ -1473,9 +1473,9 @@ PUBLIC void XMesaDestroyVisual( XMesaVisual v ) { #ifndef XFree86Server - _mesa_free(v->visinfo); + free(v->visinfo); #endif - _mesa_free(v); + free(v); } @@ -1514,7 +1514,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual, share_list ? &(share_list->mesa) : (GLcontext *) NULL, &functions, (void *) c)) { - _mesa_free(c); + free(c); return NULL; } @@ -1564,7 +1564,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) !_tnl_CreateContext( mesaCtx ) || !_swsetup_CreateContext( mesaCtx )) { _mesa_free_context_data(&c->mesa); - _mesa_free(c); + free(c); return NULL; } @@ -1598,7 +1598,7 @@ void XMesaDestroyContext( XMesaContext c ) _tnl_DestroyContext( mesaCtx ); _vbo_DestroyContext( mesaCtx ); _mesa_free_context_data( mesaCtx ); - _mesa_free( c ); + free( c ); } diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index bf38629289..5ffe110484 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -242,7 +242,7 @@ xmesa_delete_renderbuffer(struct gl_renderbuffer *rb) * should probably get freed here, but that's currently done in * XMesaDestroyBuffer(). */ - _mesa_free(rb); + free(rb); } @@ -412,11 +412,11 @@ xmesa_delete_framebuffer(struct gl_framebuffer *fb) } if (b->rowimage) { - _mesa_free( b->rowimage->data ); + free( b->rowimage->data ); b->rowimage->data = NULL; XMesaDestroyImage( b->rowimage ); } _mesa_free_framebuffer_data(fb); - _mesa_free(fb); + free(fb); } diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index a4f14490f3..c842007c22 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -167,7 +167,7 @@ compute_es_extensions(void) unsigned int len; len = make_extension_string(ctx, NULL); - s = (char *) _mesa_malloc(len + 1); + s = (char *) malloc(len + 1); if (!s) return NULL; make_extension_string(ctx, s); diff --git a/src/mesa/es/main/specials_es2.c b/src/mesa/es/main/specials_es2.c index e11ade9b94..10b4f25e0f 100644 --- a/src/mesa/es/main/specials_es2.c +++ b/src/mesa/es/main/specials_es2.c @@ -138,7 +138,7 @@ compute_es_extensions(void) unsigned int len; len = make_extension_string(ctx, NULL); - s = (char *) _mesa_malloc(len + 1); + s = (char *) malloc(len + 1); if (!s) return NULL; make_extension_string(ctx, s); diff --git a/src/mesa/glapi/mesadef.py b/src/mesa/glapi/mesadef.py index 59cea59ac2..38b0246ba5 100644 --- a/src/mesa/glapi/mesadef.py +++ b/src/mesa/glapi/mesadef.py @@ -113,8 +113,6 @@ def PrintTail(): print '\t_mesa_buffer_data' print '\t_mesa_buffer_map' print '\t_mesa_buffer_subdata' - print '\t_mesa_bzero' - print '\t_mesa_calloc' print '\t_mesa_choose_tex_format' print '\t_mesa_compressed_texture_size' print '\t_mesa_create_framebuffer' @@ -128,7 +126,6 @@ def PrintTail(): print '\t_mesa_enable_1_5_extensions' print '\t_mesa_enable_sw_extensions' print '\t_mesa_error' - print '\t_mesa_free' print '\t_mesa_free_context_data' print '\t_mesa_get_current_context' print '\t_mesa_init_default_imports' diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index e36137d378..3a1fd37324 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -130,7 +130,7 @@ _mesa_delete_array_object( GLcontext *ctx, struct gl_array_object *obj ) (void) ctx; unbind_array_object_vbos(ctx, obj); _glthread_DESTROY_MUTEX(obj->Mutex); - _mesa_free(obj); + free(obj); } diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 44dc3b871e..9a32bc335d 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1559,8 +1559,8 @@ _mesa_free_attrib_data(GLcontext *ctx) } next = attr->next; - _mesa_free(attr->data); - _mesa_free(attr); + free(attr->data); + free(attr); attr = next; } } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 2e9793ea0e..816465cea1 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -208,14 +208,14 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) (void) ctx; if (bufObj->Data) - _mesa_free(bufObj->Data); + free(bufObj->Data); /* assign strange values here to help w/ debugging */ bufObj->RefCount = -1000; bufObj->Name = ~0; _glthread_DESTROY_MUTEX(bufObj->Mutex); - _mesa_free(bufObj); + free(bufObj); } diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 1c12fb00fa..785813166c 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -407,8 +407,8 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, _mesa_free_colortable_data(table); if (width > 0) { - table->TableF = (GLfloat *) _mesa_malloc(comps * width * sizeof(GLfloat)); - table->TableUB = (GLubyte *) _mesa_malloc(comps * width * sizeof(GLubyte)); + table->TableF = (GLfloat *) malloc(comps * width * sizeof(GLfloat)); + table->TableUB = (GLubyte *) malloc(comps * width * sizeof(GLubyte)); if (!table->TableF || !table->TableUB) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); @@ -1095,11 +1095,11 @@ void _mesa_free_colortable_data( struct gl_color_table *p ) { if (p->TableF) { - _mesa_free(p->TableF); + free(p->TableF); p->TableF = NULL; } if (p->TableUB) { - _mesa_free(p->TableUB); + free(p->TableUB); p->TableUB = NULL; } } diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index f315f0b212..4ecbb5ecf6 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -222,7 +222,7 @@ _mesa_create_visual( GLboolean rgbFlag, GLint accumAlphaBits, GLint numSamples ) { - GLvisual *vis = (GLvisual *) _mesa_calloc(sizeof(GLvisual)); + GLvisual *vis = (GLvisual *) calloc(1, sizeof(GLvisual)); if (vis) { if (!_mesa_initialize_visual(vis, rgbFlag, dbFlag, stereoFlag, redBits, greenBits, blueBits, alphaBits, @@ -230,7 +230,7 @@ _mesa_create_visual( GLboolean rgbFlag, accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits, numSamples)) { - _mesa_free(vis); + free(vis); return NULL; } } @@ -320,7 +320,7 @@ _mesa_initialize_visual( GLvisual *vis, void _mesa_destroy_visual( GLvisual *vis ) { - _mesa_free(vis); + free(vis); } /*@}*/ @@ -755,7 +755,7 @@ alloc_dispatch_table(void) GLint numEntries = MAX2(_glapi_get_dispatch_table_size(), sizeof(struct _glapi_table) / sizeof(_glapi_proc)); struct _glapi_table *table = - (struct _glapi_table *) _mesa_malloc(numEntries * sizeof(_glapi_proc)); + (struct _glapi_table *) malloc(numEntries * sizeof(_glapi_proc)); if (table) { _glapi_proc *entry = (_glapi_proc *) table; GLint i; @@ -850,7 +850,7 @@ _mesa_initialize_context(GLcontext *ctx, if (!ctx->Exec || !ctx->Save) { _mesa_release_shared_state(ctx, ctx->Shared); if (ctx->Exec) - _mesa_free(ctx->Exec); + free(ctx->Exec); return GL_FALSE; } #if FEATURE_dispatch @@ -913,7 +913,7 @@ _mesa_create_context(const GLvisual *visual, ASSERT(visual); /*ASSERT(driverContext);*/ - ctx = (GLcontext *) _mesa_calloc(sizeof(GLcontext)); + ctx = (GLcontext *) calloc(1, sizeof(GLcontext)); if (!ctx) return NULL; @@ -922,7 +922,7 @@ _mesa_create_context(const GLvisual *visual, return ctx; } else { - _mesa_free(ctx); + free(ctx); return NULL; } } @@ -989,8 +989,8 @@ _mesa_free_context_data( GLcontext *ctx ) #endif /* free dispatch tables */ - _mesa_free(ctx->Exec); - _mesa_free(ctx->Save); + free(ctx->Exec); + free(ctx->Save); /* Shared context state (display lists, textures, etc) */ _mesa_release_shared_state( ctx, ctx->Shared ); @@ -999,10 +999,10 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_display_list_data(ctx); if (ctx->Extensions.String) - _mesa_free((void *) ctx->Extensions.String); + free((void *) ctx->Extensions.String); if (ctx->VersionString) - _mesa_free(ctx->VersionString); + free(ctx->VersionString); /* unbind the context if it's currently bound */ if (ctx == _mesa_get_current_context()) { @@ -1023,7 +1023,7 @@ _mesa_destroy_context( GLcontext *ctx ) { if (ctx) { _mesa_free_context_data(ctx); - _mesa_free( (void *) ctx ); + free( (void *) ctx ); } } diff --git a/src/mesa/main/cpuinfo.c b/src/mesa/main/cpuinfo.c index 79fcbc71c2..35de69b180 100644 --- a/src/mesa/main/cpuinfo.c +++ b/src/mesa/main/cpuinfo.c @@ -43,7 +43,7 @@ _mesa_get_cpu_features(void) /** * Return a string describing the CPU architexture and extensions that * Mesa is using (such as SSE or Altivec). - * \return information string, free it with _mesa_free() + * \return information string, free it with free() */ char * _mesa_get_cpu_string(void) @@ -51,7 +51,7 @@ _mesa_get_cpu_string(void) #define MAX_STRING 50 char *buffer; - buffer = (char *) _mesa_malloc(MAX_STRING); + buffer = (char *) malloc(MAX_STRING); if (!buffer) return NULL; diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index f2182c0577..79b63e940f 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -303,7 +303,7 @@ write_texture_image(struct gl_texture_object *texObj, GLubyte *buffer; char s[100]; - buffer = (GLubyte *) _mesa_malloc(img->Width * img->Height + buffer = (GLubyte *) malloc(img->Width * img->Height * img->Depth * 4); store = ctx->Pack; /* save */ @@ -321,7 +321,7 @@ write_texture_image(struct gl_texture_object *texObj, ctx->Pack = store; /* restore */ - _mesa_free(buffer); + free(buffer); } } @@ -350,7 +350,7 @@ write_renderbuffer_image(const struct gl_renderbuffer *rb) return; } - buffer = (GLubyte *) _mesa_malloc(rb->Width * rb->Height * 4); + buffer = (GLubyte *) malloc(rb->Width * rb->Height * 4); ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height, format, type, &ctx->DefaultPacking, buffer); @@ -361,7 +361,7 @@ write_renderbuffer_image(const struct gl_renderbuffer *rb) _mesa_printf(" Writing renderbuffer image to %s\n", s); write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE); - _mesa_free(buffer); + free(buffer); } @@ -481,7 +481,7 @@ _mesa_dump_color_buffer(const char *filename) const GLuint h = ctx->DrawBuffer->Height; GLubyte *buf; - buf = (GLubyte *) _mesa_malloc(w * h * 4); + buf = (GLubyte *) malloc(w * h * 4); _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); @@ -499,7 +499,7 @@ _mesa_dump_color_buffer(const char *filename) _mesa_PopClientAttrib(); - _mesa_free(buf); + free(buf); } @@ -513,8 +513,8 @@ _mesa_dump_depth_buffer(const char *filename) GLubyte *buf2; GLuint i; - buf = (GLuint *) _mesa_malloc(w * h * 4); /* 4 bpp */ - buf2 = (GLubyte *) _mesa_malloc(w * h * 3); /* 3 bpp */ + buf = (GLuint *) malloc(w * h * 4); /* 4 bpp */ + buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */ _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); @@ -534,8 +534,8 @@ _mesa_dump_depth_buffer(const char *filename) _mesa_PopClientAttrib(); - _mesa_free(buf); - _mesa_free(buf2); + free(buf); + free(buf2); } @@ -549,8 +549,8 @@ _mesa_dump_stencil_buffer(const char *filename) GLubyte *buf2; GLuint i; - buf = (GLubyte *) _mesa_malloc(w * h); /* 1 bpp */ - buf2 = (GLubyte *) _mesa_malloc(w * h * 3); /* 3 bpp */ + buf = (GLubyte *) malloc(w * h); /* 1 bpp */ + buf2 = (GLubyte *) malloc(w * h * 3); /* 3 bpp */ _mesa_PushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); _mesa_PixelStorei(GL_PACK_ALIGNMENT, 1); @@ -569,8 +569,8 @@ _mesa_dump_stencil_buffer(const char *filename) _mesa_PopClientAttrib(); - _mesa_free(buf); - _mesa_free(buf2); + free(buf); + free(buf2); } diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c index 49946a6506..892520b695 100644 --- a/src/mesa/main/depthstencil.c +++ b/src/mesa/main/depthstencil.c @@ -65,7 +65,7 @@ delete_wrapper(struct gl_renderbuffer *rb) ASSERT(rb->Format == MESA_FORMAT_Z24_S8 || rb->Format == MESA_FORMAT_S8_Z24); _mesa_reference_renderbuffer(&rb->Wrapped, NULL); - _mesa_free(rb); + free(rb); } @@ -818,5 +818,5 @@ _mesa_promote_stencil(GLcontext *ctx, struct gl_renderbuffer *stencilRb) } stencilRb->PutRow(ctx, stencilRb, width, 0, i, depthStencil, NULL); } - _mesa_free(data); + free(data); } diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 740ebfe17a..87b8ddacc2 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -472,7 +472,7 @@ make_list(GLuint name, GLuint count) { struct gl_display_list *dlist = CALLOC_STRUCT(gl_display_list); dlist->Name = name; - dlist->Head = (Node *) _mesa_malloc(sizeof(Node) * count); + dlist->Head = (Node *) malloc(sizeof(Node) * count); dlist->Head[0].opcode = OPCODE_END_OF_LIST; return dlist; } @@ -557,108 +557,108 @@ _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) switch (opcode) { /* for some commands, we need to free malloc'd memory */ case OPCODE_MAP1: - _mesa_free(n[6].data); + free(n[6].data); n += InstSize[n[0].opcode]; break; case OPCODE_MAP2: - _mesa_free(n[10].data); + free(n[10].data); n += InstSize[n[0].opcode]; break; case OPCODE_DRAW_PIXELS: - _mesa_free(n[5].data); + free(n[5].data); n += InstSize[n[0].opcode]; break; case OPCODE_BITMAP: - _mesa_free(n[7].data); + free(n[7].data); n += InstSize[n[0].opcode]; break; case OPCODE_COLOR_TABLE: - _mesa_free(n[6].data); + free(n[6].data); n += InstSize[n[0].opcode]; break; case OPCODE_COLOR_SUB_TABLE: - _mesa_free(n[6].data); + free(n[6].data); n += InstSize[n[0].opcode]; break; case OPCODE_CONVOLUTION_FILTER_1D: - _mesa_free(n[6].data); + free(n[6].data); n += InstSize[n[0].opcode]; break; case OPCODE_CONVOLUTION_FILTER_2D: - _mesa_free(n[7].data); + free(n[7].data); n += InstSize[n[0].opcode]; break; case OPCODE_POLYGON_STIPPLE: - _mesa_free(n[1].data); + free(n[1].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE1D: - _mesa_free(n[8].data); + free(n[8].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE2D: - _mesa_free(n[9].data); + free(n[9].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_IMAGE3D: - _mesa_free(n[10].data); + free(n[10].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE1D: - _mesa_free(n[7].data); + free(n[7].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE2D: - _mesa_free(n[9].data); + free(n[9].data); n += InstSize[n[0].opcode]; break; case OPCODE_TEX_SUB_IMAGE3D: - _mesa_free(n[11].data); + free(n[11].data); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_IMAGE_1D: - _mesa_free(n[7].data); + free(n[7].data); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_IMAGE_2D: - _mesa_free(n[8].data); + free(n[8].data); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_IMAGE_3D: - _mesa_free(n[9].data); + free(n[9].data); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: - _mesa_free(n[7].data); + free(n[7].data); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: - _mesa_free(n[9].data); + free(n[9].data); n += InstSize[n[0].opcode]; break; case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: - _mesa_free(n[11].data); + free(n[11].data); n += InstSize[n[0].opcode]; break; #if FEATURE_NV_vertex_program case OPCODE_LOAD_PROGRAM_NV: - _mesa_free(n[4].data); /* program string */ + free(n[4].data); /* program string */ n += InstSize[n[0].opcode]; break; case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - _mesa_free(n[2].data); /* array of program ids */ + free(n[2].data); /* array of program ids */ n += InstSize[n[0].opcode]; break; #endif #if FEATURE_NV_fragment_program case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - _mesa_free(n[3].data); /* parameter name */ + free(n[3].data); /* parameter name */ n += InstSize[n[0].opcode]; break; #endif #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program case OPCODE_PROGRAM_STRING_ARB: - _mesa_free(n[4].data); /* program string */ + free(n[4].data); /* program string */ n += InstSize[n[0].opcode]; break; #endif @@ -670,7 +670,7 @@ _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) case OPCODE_UNIFORM_2IV: case OPCODE_UNIFORM_3IV: case OPCODE_UNIFORM_4IV: - _mesa_free(n[3].data); + free(n[3].data); n += InstSize[n[0].opcode]; break; case OPCODE_UNIFORM_MATRIX22: @@ -682,17 +682,17 @@ _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) case OPCODE_UNIFORM_MATRIX32: case OPCODE_UNIFORM_MATRIX34: case OPCODE_UNIFORM_MATRIX43: - _mesa_free(n[4].data); + free(n[4].data); n += InstSize[n[0].opcode]; break; case OPCODE_CONTINUE: n = (Node *) n[1].next; - _mesa_free(block); + free(block); block = n; break; case OPCODE_END_OF_LIST: - _mesa_free(block); + free(block); done = GL_TRUE; break; default: @@ -703,7 +703,7 @@ _mesa_delete_list(GLcontext *ctx, struct gl_display_list *dlist) } } - _mesa_free(dlist); + free(dlist); } @@ -869,7 +869,7 @@ dlist_alloc(GLcontext *ctx, OpCode opcode, GLuint bytes) Node *newblock; n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos; n[0].opcode = OPCODE_CONTINUE; - newblock = (Node *) _mesa_malloc(sizeof(Node) * BLOCK_SIZE); + newblock = (Node *) malloc(sizeof(Node) * BLOCK_SIZE); if (!newblock) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "Building display list"); return NULL; @@ -2912,7 +2912,7 @@ save_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values) if (n) { n[1].e = map; n[2].i = mapsize; - n[3].data = (void *) _mesa_malloc(mapsize * sizeof(GLfloat)); + n[3].data = (void *) malloc(mapsize * sizeof(GLfloat)); memcpy(n[3].data, (void *) values, mapsize * sizeof(GLfloat)); } if (ctx->ExecuteFlag) { @@ -4360,7 +4360,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level, GLvoid *image; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); /* make copy of image */ - image = _mesa_malloc(imageSize); + image = malloc(imageSize); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); return; @@ -4377,7 +4377,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level, n[7].data = image; } else if (image) { - _mesa_free(image); + free(image); } if (ctx->ExecuteFlag) { CALL_CompressedTexImage1DARB(ctx->Exec, @@ -4406,7 +4406,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level, GLvoid *image; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); /* make copy of image */ - image = _mesa_malloc(imageSize); + image = malloc(imageSize); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); return; @@ -4424,7 +4424,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level, n[8].data = image; } else if (image) { - _mesa_free(image); + free(image); } if (ctx->ExecuteFlag) { CALL_CompressedTexImage2DARB(ctx->Exec, @@ -4453,7 +4453,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level, GLvoid *image; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); /* make copy of image */ - image = _mesa_malloc(imageSize); + image = malloc(imageSize); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); return; @@ -4472,7 +4472,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level, n[9].data = image; } else if (image) { - _mesa_free(image); + free(image); } if (ctx->ExecuteFlag) { CALL_CompressedTexImage3DARB(ctx->Exec, @@ -4496,7 +4496,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); /* make copy of image */ - image = _mesa_malloc(imageSize); + image = malloc(imageSize); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); return; @@ -4513,7 +4513,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, n[7].data = image; } else if (image) { - _mesa_free(image); + free(image); } if (ctx->ExecuteFlag) { CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset, @@ -4536,7 +4536,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); /* make copy of image */ - image = _mesa_malloc(imageSize); + image = malloc(imageSize); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); return; @@ -4555,7 +4555,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, n[9].data = image; } else if (image) { - _mesa_free(image); + free(image); } if (ctx->ExecuteFlag) { CALL_CompressedTexSubImage2DARB(ctx->Exec, @@ -4578,7 +4578,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); /* make copy of image */ - image = _mesa_malloc(imageSize); + image = malloc(imageSize); if (!image) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); return; @@ -4599,7 +4599,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, n[11].data = image; } else if (image) { - _mesa_free(image); + free(image); } if (ctx->ExecuteFlag) { CALL_CompressedTexSubImage3DARB(ctx->Exec, @@ -4788,7 +4788,7 @@ save_LoadProgramNV(GLenum target, GLuint id, GLsizei len, n = alloc_instruction(ctx, OPCODE_LOAD_PROGRAM_NV, 4); if (n) { - GLubyte *programCopy = (GLubyte *) _mesa_malloc(len); + GLubyte *programCopy = (GLubyte *) malloc(len); if (!programCopy) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); return; @@ -4815,7 +4815,7 @@ save_RequestResidentProgramsNV(GLsizei num, const GLuint * ids) n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 2); if (n) { - GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint)); + GLuint *idCopy = (GLuint *) malloc(num * sizeof(GLuint)); if (!idCopy) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV"); return; @@ -4986,7 +4986,7 @@ save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, n = alloc_instruction(ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6); if (n) { - GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len); + GLubyte *nameCopy = (GLubyte *) malloc(len); if (!nameCopy) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV"); return; @@ -5085,7 +5085,7 @@ save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, n = alloc_instruction(ctx, OPCODE_PROGRAM_STRING_ARB, 4); if (n) { - GLubyte *programCopy = (GLubyte *) _mesa_malloc(len); + GLubyte *programCopy = (GLubyte *) malloc(len); if (!programCopy) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); return; @@ -6199,7 +6199,7 @@ save_Uniform4fARB(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) static void * memdup(const void *src, GLsizei bytes) { - void *b = bytes >= 0 ? _mesa_malloc(bytes) : NULL; + void *b = bytes >= 0 ? malloc(bytes) : NULL; if (b) memcpy(b, src, bytes); return b; diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c index 4c6139985f..07a7f9fed8 100644 --- a/src/mesa/main/execmem.c +++ b/src/mesa/main/execmem.c @@ -140,14 +140,14 @@ _mesa_exec_free(void *addr) void * _mesa_exec_malloc(GLuint size) { - return _mesa_malloc( size ); + return malloc( size ); } void _mesa_exec_free(void *addr) { - _mesa_free(addr); + free(addr); } diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index f24baf5acd..2c1120e19f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -576,7 +576,7 @@ append(const char *a, const char *b) { const GLuint aLen = a ? strlen(a) : 0; const GLuint bLen = b ? strlen(b) : 0; - char *s = _mesa_calloc(aLen + bLen + 1); + char *s = calloc(1, aLen + bLen + 1); if (s) { if (a) memcpy(s, a, aLen); @@ -585,7 +585,7 @@ append(const char *a, const char *b) s[aLen + bLen] = '\0'; } if (a) - _mesa_free((void *) a); + free((void *) a); return s; } @@ -685,7 +685,7 @@ _mesa_make_extension_string( GLcontext *ctx ) extStrLen += strlen(extraExt) + 1; /* +1 for space */ /* allocate the extension string */ - s = (char *) _mesa_malloc(extStrLen); + s = (char *) malloc(extStrLen); if (!s) return NULL; diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 41b5420943..065e25fd33 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -192,7 +192,7 @@ _mesa_destroy_framebuffer(struct gl_framebuffer *fb) { if (fb) { _mesa_free_framebuffer_data(fb); - _mesa_free(fb); + free(fb); } } diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index fdfbe6b4f4..975775469d 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -108,13 +108,13 @@ _mesa_DeleteHashTable(struct _mesa_HashTable *table) _mesa_problem(NULL, "In _mesa_DeleteHashTable, found non-freed data"); } - _mesa_free(entry); + free(entry); entry = next; } } _glthread_DESTROY_MUTEX(table->Mutex); _glthread_DESTROY_MUTEX(table->WalkMutex); - _mesa_free(table); + free(table); } @@ -245,7 +245,7 @@ _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key) else { table->Table[pos] = entry->Next; } - _mesa_free(entry); + free(entry); _glthread_UNLOCK_MUTEX(table->Mutex); return; } @@ -282,7 +282,7 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, for (entry = table->Table[pos]; entry; entry = next) { callback(entry->Key, entry->Data, userData); next = entry->Next; - _mesa_free(entry); + free(entry); } table->Table[pos] = NULL; } diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index bd03217e2a..dc8d97728b 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1038,7 +1038,7 @@ _mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], | (p[3] ); p += 4; } - _mesa_free(ptrn); + free(ptrn); } } @@ -1083,7 +1083,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, /* Alloc dest storage */ bytes = ((width + 7) / 8 * height); - buffer = (GLubyte *) _mesa_malloc( bytes ); + buffer = (GLubyte *) malloc( bytes ); if (!buffer) return NULL; @@ -1094,7 +1094,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, _mesa_image_address2d(packing, pixels, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); if (!src) { - _mesa_free(buffer); + free(buffer); return NULL; } @@ -5232,7 +5232,7 @@ _mesa_unpack_image( GLuint dimensions, { GLubyte *destBuffer - = (GLubyte *) _mesa_malloc(bytesPerRow * height * depth); + = (GLubyte *) malloc(bytesPerRow * height * depth); GLubyte *dst; GLint img, row; if (!destBuffer) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 5c2c863f97..10224f7888 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -71,27 +71,6 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); /** \name Memory */ /*@{*/ -/** Wrapper around malloc() */ -void * -_mesa_malloc(size_t bytes) -{ - return malloc(bytes); -} - -/** Wrapper around calloc() */ -void * -_mesa_calloc(size_t bytes) -{ - return calloc(1, bytes); -} - -/** Wrapper around free() */ -void -_mesa_free(void *ptr) -{ - free(ptr); -} - /** * Allocate aligned memory. * @@ -118,7 +97,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment) ASSERT( alignment > 0 ); - ptr = (uintptr_t) _mesa_malloc(bytes + alignment + sizeof(void *)); + ptr = (uintptr_t) malloc(bytes + alignment + sizeof(void *)); if (!ptr) return NULL; @@ -138,8 +117,8 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment) } /** - * Same as _mesa_align_malloc(), but using _mesa_calloc() instead of - * _mesa_malloc() + * Same as _mesa_align_malloc(), but using calloc(1, ) instead of + * malloc() */ void * _mesa_align_calloc(size_t bytes, unsigned long alignment) @@ -167,7 +146,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment) ASSERT( alignment > 0 ); - ptr = (uintptr_t) _mesa_calloc(bytes + alignment + sizeof(void *)); + ptr = (uintptr_t) calloc(1, bytes + alignment + sizeof(void *)); if (!ptr) return NULL; @@ -203,7 +182,7 @@ _mesa_align_free(void *ptr) #else void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); void *realAddr = *cubbyHole; - _mesa_free(realAddr); + free(realAddr); #endif /* defined(HAVE_POSIX_MEMALIGN) */ } @@ -236,11 +215,11 @@ void * _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) { const size_t copySize = (oldSize < newSize) ? oldSize : newSize; - void *newBuffer = _mesa_malloc(newSize); + void *newBuffer = malloc(newSize); if (newBuffer && oldBuffer && copySize > 0) memcpy(newBuffer, oldBuffer, copySize); if (oldBuffer) - _mesa_free(oldBuffer); + free(oldBuffer); return newBuffer; } @@ -798,7 +777,7 @@ _mesa_getenv( const char *var ) /*@{*/ /** - * Implemented using _mesa_malloc() and strcpy. + * Implemented using malloc() and strcpy. * Note that NULL is handled accordingly. */ char * @@ -806,7 +785,7 @@ _mesa_strdup( const char *s ) { if (s) { size_t l = strlen(s); - char *s2 = (char *) _mesa_malloc(l + 1); + char *s2 = (char *) malloc(l + 1); if (s2) strcpy(s2, s); return s2; diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 106dd021a1..4eabdfdb0d 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -50,15 +50,15 @@ extern "C" { /*@{*/ /** Allocate \p BYTES bytes */ -#define MALLOC(BYTES) _mesa_malloc(BYTES) +#define MALLOC(BYTES) malloc(BYTES) /** Allocate and zero \p BYTES bytes */ -#define CALLOC(BYTES) _mesa_calloc(BYTES) +#define CALLOC(BYTES) calloc(1, BYTES) /** Allocate a structure of type \p T */ -#define MALLOC_STRUCT(T) (struct T *) _mesa_malloc(sizeof(struct T)) +#define MALLOC_STRUCT(T) (struct T *) malloc(sizeof(struct T)) /** Allocate and zero a structure of type \p T */ -#define CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T)) +#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) /** Free memory */ -#define FREE(PTR) _mesa_free(PTR) +#define FREE(PTR) free(PTR) /** Allocate \p BYTES aligned at \p N bytes */ #define ALIGN_MALLOC(BYTES, N) _mesa_align_malloc(BYTES, N) @@ -507,15 +507,6 @@ _mesa_little_endian(void) * Functions */ -extern void * -_mesa_malloc( size_t bytes ); - -extern void * -_mesa_calloc( size_t bytes ); - -extern void -_mesa_free( void *ptr ); - extern void * _mesa_align_malloc( size_t bytes, unsigned long alignment ); diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 654faa5c77..6899ed0ddf 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1433,7 +1433,7 @@ _mesa_free_lighting_data( GLcontext *ctx ) /* Free lighting shininess exponentiation table */ foreach_s( s, tmps, ctx->_ShineTabList ) { - _mesa_free( s ); + free( s ); } - _mesa_free( ctx->_ShineTabList ); + free( ctx->_ShineTabList ); } diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 1da576337f..415abcdfa1 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1537,15 +1537,15 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, size = _mesa_bytes_per_pixel(srcImage->_BaseFormat, CHAN_TYPE) * srcImage->Width * srcImage->Height * srcImage->Depth + 20; /* 20 extra bytes, just be safe when calling last FetchTexel */ - srcData = (GLubyte *) _mesa_malloc(size); + srcData = (GLubyte *) malloc(size); if (!srcData) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps"); return; } - dstData = (GLubyte *) _mesa_malloc(size / 2); /* 1/4 would probably be OK */ + dstData = (GLubyte *) malloc(size / 2); /* 1/4 would probably be OK */ if (!dstData) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps"); - _mesa_free((void *) srcData); + free((void *) srcData); return; } @@ -1590,8 +1590,8 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, if (!nextLevel) { /* all done */ if (_mesa_is_format_compressed(srcImage->TexFormat)) { - _mesa_free((void *) srcData); - _mesa_free(dstData); + free((void *) srcData); + free(dstData); } return; } diff --git a/src/mesa/main/mm.c b/src/mesa/main/mm.c index d430bcdb84..3ef38e94be 100644 --- a/src/mesa/main/mm.c +++ b/src/mesa/main/mm.c @@ -60,13 +60,13 @@ mmInit(unsigned ofs, unsigned size) if (!size) return NULL; - heap = (struct mem_block *) _mesa_calloc(sizeof(struct mem_block)); + heap = (struct mem_block *) calloc(1, sizeof(struct mem_block)); if (!heap) return NULL; - block = (struct mem_block *) _mesa_calloc(sizeof(struct mem_block)); + block = (struct mem_block *) calloc(1, sizeof(struct mem_block)); if (!block) { - _mesa_free(heap); + free(heap); return NULL; } @@ -98,7 +98,7 @@ SliceBlock(struct mem_block *p, /* break left [p, newblock, p->next], then p = newblock */ if (startofs > p->ofs) { - newblock = (struct mem_block*) _mesa_calloc(sizeof(struct mem_block)); + newblock = (struct mem_block*) calloc(1, sizeof(struct mem_block)); if (!newblock) return NULL; newblock->ofs = startofs; @@ -122,7 +122,7 @@ SliceBlock(struct mem_block *p, /* break right, also [p, newblock, p->next] */ if (size < p->size) { - newblock = (struct mem_block*) _mesa_calloc(sizeof(struct mem_block)); + newblock = (struct mem_block*) calloc(1, sizeof(struct mem_block)); if (!newblock) return NULL; newblock->ofs = startofs + size; @@ -225,7 +225,7 @@ Join2Blocks(struct mem_block *p) q->next_free->prev_free = q->prev_free; q->prev_free->next_free = q->next_free; - _mesa_free(q); + free(q); return 1; } return 0; @@ -270,9 +270,9 @@ mmDestroy(struct mem_block *heap) for (p = heap->next; p != heap; ) { struct mem_block *next = p->next; - _mesa_free(p); + free(p); p = next; } - _mesa_free(heap); + free(heap); } diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 387a82fc9d..471352f472 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -114,7 +114,7 @@ _mesa_check_query(GLcontext *ctx, struct gl_query_object *q) static void _mesa_delete_query(GLcontext *ctx, struct gl_query_object *q) { - _mesa_free(q); + free(q); } diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index aec22d9d14..c44db255d6 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1122,7 +1122,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, /* free old buffer storage */ if (rb->Data) { - _mesa_free(rb->Data); + free(rb->Data); rb->Data = NULL; } @@ -1179,10 +1179,10 @@ alloc_storage_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, /* next, resize my alpha buffer */ if (arb->Data) { - _mesa_free(arb->Data); + free(arb->Data); } - arb->Data = _mesa_malloc(width * height * sizeof(GLubyte)); + arb->Data = malloc(width * height * sizeof(GLubyte)); if (arb->Data == NULL) { arb->Width = 0; arb->Height = 0; @@ -1204,13 +1204,13 @@ static void delete_renderbuffer_alpha8(struct gl_renderbuffer *arb) { if (arb->Data) { - _mesa_free(arb->Data); + free(arb->Data); } ASSERT(arb->Wrapped); ASSERT(arb != arb->Wrapped); arb->Wrapped->Delete(arb->Wrapped); arb->Wrapped = NULL; - _mesa_free(arb); + free(arb); } @@ -1460,9 +1460,9 @@ void _mesa_delete_renderbuffer(struct gl_renderbuffer *rb) { if (rb->Data) { - _mesa_free(rb->Data); + free(rb->Data); } - _mesa_free(rb); + free(rb); } diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index 91f2a7a7bf..e6f6add768 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -434,7 +434,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, * This array holds offsets of where the appropriate string ends, thus the * last element will be set to the total length of the source code. */ - offsets = (GLint *) _mesa_malloc(count * sizeof(GLint)); + offsets = (GLint *) malloc(count * sizeof(GLint)); if (offsets == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); return; @@ -442,7 +442,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, for (i = 0; i < count; i++) { if (string[i] == NULL) { - _mesa_free((GLvoid *) offsets); + free((GLvoid *) offsets); _mesa_error(ctx, GL_INVALID_OPERATION, "glShaderSourceARB(null string)"); return; } @@ -460,9 +460,9 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, * valgrind warnings in the parser/grammer code. */ totalLength = offsets[count - 1] + 2; - source = (GLcharARB *) _mesa_malloc(totalLength * sizeof(GLcharARB)); + source = (GLcharARB *) malloc(totalLength * sizeof(GLcharARB)); if (source == NULL) { - _mesa_free((GLvoid *) offsets); + free((GLvoid *) offsets); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB"); return; } @@ -491,7 +491,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, if (newSource) { _mesa_fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", shaderObj, checksum, filename); - _mesa_free(source); + free(source); source = newSource; } } @@ -504,7 +504,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, sh->SourceChecksum = checksum; /* save original checksum */ } - _mesa_free(offsets); + free(offsets); } diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index b889364f0d..e364e24048 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -362,7 +362,7 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) _glthread_DESTROY_MUTEX(shared->Mutex); _glthread_DESTROY_MUTEX(shared->TexMutex); - _mesa_free(shared); + free(shared); } diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index 36b48fd9f2..1bff308177 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -78,7 +78,7 @@ static void _mesa_delete_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) { (void) ctx; - _mesa_free(syncObj); + free(syncObj); } diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 73a31a17ec..71e40dd3e9 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -105,7 +105,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS) dst, dstRowStride); if (tempImage) - _mesa_free((void*) tempImage); + free((void*) tempImage); return GL_TRUE; } @@ -162,7 +162,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS) dst, dstRowStride); if (tempImage) - _mesa_free((void*) tempImage); + free((void*) tempImage); return GL_TRUE; } @@ -1305,7 +1305,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps, if ((width & 7) | (height & 3)) { GLint newWidth = (width + 7) & ~7; GLint newHeight = (height + 3) & ~3; - newSource = _mesa_malloc(comps * newWidth * newHeight * sizeof(GLchan)); + newSource = malloc(comps * newWidth * newHeight * sizeof(GLchan)); if (!newSource) { GET_CURRENT_CONTEXT(ctx); _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture compression"); @@ -1324,7 +1324,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps, if (CHAN_TYPE != GL_UNSIGNED_BYTE) { const GLuint n = width * height * comps; const GLchan *src = (const GLchan *) source; - GLubyte *dest = (GLubyte *) _mesa_malloc(n * sizeof(GLubyte)); + GLubyte *dest = (GLubyte *) malloc(n * sizeof(GLubyte)); GLuint i; if (!dest) { GET_CURRENT_CONTEXT(ctx); @@ -1335,7 +1335,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps, dest[i] = CHAN_TO_UBYTE(src[i]); } if (newSource != NULL) { - _mesa_free(newSource); + free(newSource); } newSource = dest; /* we'll free this buffer before returning */ source = dest; /* the new, GLubyte incoming image */ @@ -1361,7 +1361,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps, cleanUp: if (newSource != NULL) { - _mesa_free(newSource); + free(newSource); } } diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index b271a539a7..fcd28a4b4e 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -213,7 +213,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) } if (tempImage) - _mesa_free((void *) tempImage); + free((void *) tempImage); return GL_TRUE; } @@ -275,7 +275,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) } if (tempImage) - _mesa_free((void*) tempImage); + free((void*) tempImage); return GL_TRUE; } @@ -336,7 +336,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) } if (tempImage) - _mesa_free((void *) tempImage); + free((void *) tempImage); return GL_TRUE; } @@ -397,7 +397,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) } if (tempImage) - _mesa_free((void *) tempImage); + free((void *) tempImage); return GL_TRUE; } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index da3c6f9841..11e37dc34e 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -488,8 +488,8 @@ _mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *texImage ) ASSERT(texImage->Data == NULL); if (texImage->ImageOffsets) - _mesa_free(texImage->ImageOffsets); - _mesa_free(texImage); + free(texImage->ImageOffsets); + free(texImage); } @@ -843,7 +843,7 @@ clear_teximage_fields(struct gl_texture_image *img) img->Depth = 0; img->RowStride = 0; if (img->ImageOffsets) { - _mesa_free(img->ImageOffsets); + free(img->ImageOffsets); img->ImageOffsets = NULL; } img->Width2 = 0; @@ -932,8 +932,8 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target, * case code in the texstore routines. */ if (img->ImageOffsets) - _mesa_free(img->ImageOffsets); - img->ImageOffsets = (GLuint *) _mesa_malloc(depth * sizeof(GLuint)); + free(img->ImageOffsets); + img->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint)); for (i = 0; i < depth; i++) { img->ImageOffsets[i] = i * width * height; } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 649f3587cb..feba6e95b6 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -207,7 +207,7 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) _glthread_DESTROY_MUTEX(texObj->Mutex); /* free this object */ - _mesa_free(texObj); + free(texObj); } diff --git a/src/mesa/main/texrender.c b/src/mesa/main/texrender.c index cf603d46d8..dbed51a77f 100644 --- a/src/mesa/main/texrender.c +++ b/src/mesa/main/texrender.c @@ -414,7 +414,7 @@ static void delete_texture_wrapper(struct gl_renderbuffer *rb) { ASSERT(rb->RefCount == 0); - _mesa_free(rb); + free(rb); } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index ab572a13ed..bd63c77a39 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -347,16 +347,16 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, GLfloat *convImage; /* pre-convolution image buffer (3D) */ - tempImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth + tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth * 4 * sizeof(GLfloat)); if (!tempImage) return NULL; /* post-convolution image buffer (2D) */ - convImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight + convImage = (GLfloat *) malloc(srcWidth * srcHeight * 4 * sizeof(GLfloat)); if (!convImage) { - _mesa_free(tempImage); + free(tempImage); return NULL; } @@ -419,7 +419,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, } } /* loop over 3D image slices */ - _mesa_free(convImage); + free(convImage); /* might need these below */ srcWidth = convWidth; @@ -433,7 +433,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, GLfloat *dst; GLint img, row; - tempImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth + tempImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth * components * sizeof(GLfloat)); if (!tempImage) return NULL; @@ -472,10 +472,10 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, */ ASSERT(texComponents >= logComponents); - newImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth + newImage = (GLfloat *) malloc(srcWidth * srcHeight * srcDepth * texComponents * sizeof(GLfloat)); if (!newImage) { - _mesa_free(tempImage); + free(tempImage); return NULL; } @@ -495,7 +495,7 @@ make_temp_float_image(GLcontext *ctx, GLuint dims, } } - _mesa_free(tempImage); + free(tempImage); tempImage = newImage; } @@ -582,11 +582,11 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, #endif /* unpack and transfer the source image */ - tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth + tempImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth * components * sizeof(GLchan)); if (!tempImage) { if (freeSrcImage) { - _mesa_free((void *) srcAddr); + free((void *) srcAddr); } return NULL; } @@ -611,7 +611,7 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, /* If we made a temporary image for convolution, free it here */ if (freeSrcImage) { - _mesa_free((void *) srcAddr); + free((void *) srcAddr); } if (logicalBaseFormat != textureBaseFormat) { @@ -631,10 +631,10 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, */ ASSERT(texComponents >= logComponents); - newImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth + newImage = (GLchan *) malloc(srcWidth * srcHeight * srcDepth * texComponents * sizeof(GLchan)); if (!newImage) { - _mesa_free(tempImage); + free(tempImage); return NULL; } @@ -654,7 +654,7 @@ _mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims, } } - _mesa_free(tempImage); + free(tempImage); tempImage = newImage; } @@ -1267,7 +1267,7 @@ _mesa_texstore_rgb565(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -1395,7 +1395,7 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -1606,7 +1606,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -1733,7 +1733,7 @@ _mesa_texstore_rgb888(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -1841,7 +1841,7 @@ _mesa_texstore_bgr888(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -1912,7 +1912,7 @@ _mesa_texstore_argb4444(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -1970,7 +1970,7 @@ _mesa_texstore_rgba5551(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2040,7 +2040,7 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2143,7 +2143,7 @@ _mesa_texstore_al88(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2218,7 +2218,7 @@ _mesa_texstore_al1616(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2273,7 +2273,7 @@ _mesa_texstore_rgb332(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2360,7 +2360,7 @@ _mesa_texstore_a8(TEXSTORE_PARAMS) src += srcWidth; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2518,7 +2518,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) GLbyte *tempImage, *dst, *src; GLint row; - tempImage = (GLbyte *) _mesa_malloc(srcWidth * srcHeight * srcDepth + tempImage = (GLbyte *) malloc(srcWidth * srcHeight * srcDepth * components * sizeof(GLbyte)); if (!tempImage) return GL_FALSE; @@ -2546,7 +2546,7 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS) dst += dstRowStride; src += srcWidth * texelBytes; } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2667,7 +2667,7 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS) dstRow += dstRowStride; } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2925,7 +2925,7 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } @@ -2996,7 +2996,7 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) } } - _mesa_free((void *) tempImage); + free((void *) tempImage); } return GL_TRUE; } diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 9d23c577bd..e474fe7fa5 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -122,7 +122,7 @@ _mesa_compute_version(GLcontext *ctx) compute_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor); - ctx->VersionString = (char *) _mesa_malloc(max); + ctx->VersionString = (char *) malloc(max); if (ctx->VersionString) { _mesa_snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING, ctx->VersionMajor, ctx->VersionMinor); diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index bdd26b7f3a..03ff30a239 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -85,7 +85,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, } if (program->Base.String != NULL) - _mesa_free(program->Base.String); + free(program->Base.String); /* Copy the relevant contents of the arb_program struct into the * fragment_program struct. @@ -130,7 +130,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, program->Base.InputsRead |= FRAG_BIT_FOGC; if (program->Base.Instructions) - _mesa_free(program->Base.Instructions); + free(program->Base.Instructions); program->Base.Instructions = prog.Instructions; if (program->Base.Parameters) @@ -181,7 +181,7 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, } if (program->Base.String != NULL) - _mesa_free(program->Base.String); + free(program->Base.String); /* Copy the relevant contents of the arb_program struct into the * vertex_program struct. @@ -203,7 +203,7 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, ? GL_TRUE : GL_FALSE; if (program->Base.Instructions) - _mesa_free(program->Base.Instructions); + free(program->Base.Instructions); program->Base.Instructions = prog.Instructions; if (program->Base.Parameters) diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index fb2fa4b95f..870f77e30d 100644 --- a/src/mesa/shader/atifragshader.c +++ b/src/mesa/shader/atifragshader.c @@ -60,11 +60,11 @@ _mesa_delete_ati_fragment_shader(GLcontext *ctx, struct ati_fragment_shader *s) GLuint i; for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { if (s->Instructions[i]) - _mesa_free(s->Instructions[i]); + free(s->Instructions[i]); if (s->SetupInst[i]) - _mesa_free(s->SetupInst[i]); + free(s->SetupInst[i]); } - _mesa_free(s); + free(s); } @@ -293,7 +293,7 @@ _mesa_DeleteFragmentShaderATI(GLuint id) if (prog) { prog->RefCount--; if (prog->RefCount <= 0) { - _mesa_free(prog); + free(prog); } } } @@ -318,9 +318,9 @@ _mesa_BeginFragmentShaderATI(void) /* no idea if it's allowed to redefine a shader */ for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { if (ctx->ATIFragmentShader.Current->Instructions[i]) - _mesa_free(ctx->ATIFragmentShader.Current->Instructions[i]); + free(ctx->ATIFragmentShader.Current->Instructions[i]); if (ctx->ATIFragmentShader.Current->SetupInst[i]) - _mesa_free(ctx->ATIFragmentShader.Current->SetupInst[i]); + free(ctx->ATIFragmentShader.Current->SetupInst[i]); } /* malloc the instructions here - not sure if the best place but its @@ -328,11 +328,11 @@ _mesa_BeginFragmentShaderATI(void) for (i = 0; i < MAX_NUM_PASSES_ATI; i++) { ctx->ATIFragmentShader.Current->Instructions[i] = (struct atifs_instruction *) - _mesa_calloc(sizeof(struct atifs_instruction) * + calloc(1, sizeof(struct atifs_instruction) * (MAX_NUM_INSTRUCTIONS_PER_PASS_ATI)); ctx->ATIFragmentShader.Current->SetupInst[i] = (struct atifs_setupinst *) - _mesa_calloc(sizeof(struct atifs_setupinst) * + calloc(1, sizeof(struct atifs_setupinst) * (MAX_NUM_FRAGMENT_REGISTERS_ATI)); } diff --git a/src/mesa/shader/hash_table.c b/src/mesa/shader/hash_table.c index e89a2564d7..fa6ba2bfdf 100644 --- a/src/mesa/shader/hash_table.c +++ b/src/mesa/shader/hash_table.c @@ -65,7 +65,7 @@ hash_table_ctor(unsigned num_buckets, hash_func_t hash, num_buckets = 16; } - ht = _mesa_malloc(sizeof(*ht) + ((num_buckets - 1) + ht = malloc(sizeof(*ht) + ((num_buckets - 1) * sizeof(ht->buckets[0]))); if (ht != NULL) { ht->hash = hash; @@ -85,7 +85,7 @@ void hash_table_dtor(struct hash_table *ht) { hash_table_clear(ht); - _mesa_free(ht); + free(ht); } @@ -100,7 +100,7 @@ hash_table_clear(struct hash_table *ht) for (i = 0; i < ht->num_buckets; i++) { foreach_s(node, temp, & ht->buckets[i]) { remove_from_list(node); - _mesa_free(node); + free(node); } assert(is_empty_list(& ht->buckets[i])); @@ -134,7 +134,7 @@ hash_table_insert(struct hash_table *ht, void *data, const void *key) const unsigned bucket = hash_value % ht->num_buckets; struct hash_node *node; - node = _mesa_calloc(sizeof(*node)); + node = calloc(1, sizeof(*node)); node->data = data; node->key = key; diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index 639408d82a..4f02703619 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -171,7 +171,7 @@ record_error(struct parse_state *parseState, const char *msg, int lineNo) _mesa_debug(parseState->ctx, "nvfragparse.c(%d): line %d, column %d:%s (%s)\n", lineNo, line, column, (char *) lineStr, msg); - _mesa_free((void *) lineStr); + free((void *) lineStr); #else (void) lineNo; #endif @@ -1231,7 +1231,7 @@ Parse_PrintInstruction(struct parse_state *parseState, for (len = 0; str[len] != '\''; len++) /* find closing quote */ ; parseState->pos += len + 1; - msg = (GLubyte*) _mesa_malloc(len + 1); + msg = (GLubyte*) malloc(len + 1); memcpy(msg, str, len); msg[len] = 0; @@ -1548,7 +1548,7 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget, program->Base.String = programString; program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; if (program->Base.Instructions) { - _mesa_free(program->Base.Instructions); + free(program->Base.Instructions); } program->Base.Instructions = newInst; program->Base.NumInstructions = parseState.numInst; diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index 3656438d42..fb36303bb9 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -82,7 +82,7 @@ record_error(struct parse_state *parseState, const char *msg, int lineNo) _mesa_debug(parseState->ctx, "nvfragparse.c(%d): line %d, column %d:%s (%s)\n", lineNo, line, column, (char *) lineStr, msg); - _mesa_free((void *) lineStr); + free((void *) lineStr); #else (void) lineNo; #endif @@ -1048,7 +1048,7 @@ Parse_PrintInstruction(struct parse_state *parseState, struct prog_instruction * for (len = 0; str[len] != '\''; len++) /* find closing quote */ ; parseState->pos += len + 1; - msg = (GLubyte*) _mesa_malloc(len + 1); + msg = (GLubyte*) malloc(len + 1); memcpy(msg, str, len); msg[len] = 0; @@ -1372,7 +1372,7 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, newInst = _mesa_alloc_instructions(parseState.numInst); if (!newInst) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV"); - _mesa_free(programString); + free(programString); return; /* out of memory */ } _mesa_copy_instructions(newInst, instBuffer, parseState.numInst); @@ -1380,12 +1380,12 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, /* install the program */ program->Base.Target = target; if (program->Base.String) { - _mesa_free(program->Base.String); + free(program->Base.String); } program->Base.String = programString; program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB; if (program->Base.Instructions) { - _mesa_free(program->Base.Instructions); + free(program->Base.Instructions); } program->Base.Instructions = newInst; program->Base.InputsRead = parseState.inputsRead; diff --git a/src/mesa/shader/prog_cache.c b/src/mesa/shader/prog_cache.c index 8e54f3a5a0..e5b602fc09 100644 --- a/src/mesa/shader/prog_cache.c +++ b/src/mesa/shader/prog_cache.c @@ -87,7 +87,7 @@ rehash(struct gl_program_cache *cache) cache->last = NULL; size = cache->size * 3; - items = (struct cache_item**) _mesa_malloc(size * sizeof(*items)); + items = (struct cache_item**) malloc(size * sizeof(*items)); memset(items, 0, size * sizeof(*items)); for (i = 0; i < cache->size; i++) @@ -97,7 +97,7 @@ rehash(struct gl_program_cache *cache) items[c->hash % size] = c; } - _mesa_free(cache->items); + free(cache->items); cache->items = items; cache->size = size; } @@ -114,9 +114,9 @@ clear_cache(GLcontext *ctx, struct gl_program_cache *cache) for (i = 0; i < cache->size; i++) { for (c = cache->items[i]; c; c = next) { next = c->next; - _mesa_free(c->key); + free(c->key); _mesa_reference_program(ctx, &c->program, NULL); - _mesa_free(c); + free(c); } cache->items[i] = NULL; } @@ -134,9 +134,9 @@ _mesa_new_program_cache(void) if (cache) { cache->size = 17; cache->items = (struct cache_item **) - _mesa_calloc(cache->size * sizeof(struct cache_item)); + calloc(1, cache->size * sizeof(struct cache_item)); if (!cache->items) { - _mesa_free(cache); + free(cache); return NULL; } } @@ -148,8 +148,8 @@ void _mesa_delete_program_cache(GLcontext *ctx, struct gl_program_cache *cache) { clear_cache(ctx, cache); - _mesa_free(cache->items); - _mesa_free(cache); + free(cache->items); + free(cache); } @@ -188,7 +188,7 @@ _mesa_program_cache_insert(GLcontext *ctx, c->hash = hash; - c->key = _mesa_malloc(keysize); + c->key = malloc(keysize); memcpy(c->key, key, keysize); c->program = program; /* no refcount change */ diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index 0c4da4d107..81099cb99c 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -70,7 +70,7 @@ struct prog_instruction * _mesa_alloc_instructions(GLuint numInst) { return (struct prog_instruction *) - _mesa_calloc(numInst * sizeof(struct prog_instruction)); + calloc(1, numInst * sizeof(struct prog_instruction)); } @@ -128,11 +128,11 @@ _mesa_free_instructions(struct prog_instruction *inst, GLuint count) GLuint i; for (i = 0; i < count; i++) { if (inst[i].Data) - _mesa_free(inst[i].Data); + free(inst[i].Data); if (inst[i].Comment) - _mesa_free((char *) inst[i].Comment); + free((char *) inst[i].Comment); } - _mesa_free(inst); + free(inst); } diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c index e1ec52254c..09816d5044 100644 --- a/src/mesa/shader/prog_optimize.c +++ b/src/mesa/shader/prog_optimize.c @@ -237,7 +237,7 @@ _mesa_remove_dead_code(struct gl_program *prog) } removeInst = (GLboolean *) - _mesa_calloc(prog->NumInstructions * sizeof(GLboolean)); + calloc(1, prog->NumInstructions * sizeof(GLboolean)); /* Determine which temps are read and written */ for (i = 0; i < prog->NumInstructions; i++) { @@ -347,7 +347,7 @@ _mesa_remove_dead_code(struct gl_program *prog) } done: - _mesa_free(removeInst); + free(removeInst); } @@ -538,7 +538,7 @@ _mesa_remove_extra_moves(struct gl_program *prog) } removeInst = (GLboolean *) - _mesa_calloc(prog->NumInstructions * sizeof(GLboolean)); + calloc(1, prog->NumInstructions * sizeof(GLboolean)); /* * Look for sequences such as this: @@ -621,7 +621,7 @@ _mesa_remove_extra_moves(struct gl_program *prog) /* now remove the instructions which aren't needed */ rem = remove_instructions(prog, removeInst); - _mesa_free(removeInst); + free(removeInst); if (dbg) { _mesa_printf("Optimize: End remove extra moves. %u instructions removed\n", rem); diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index 1feb7bd71d..25bb4f3d44 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -54,16 +54,16 @@ _mesa_new_parameter_list_sized(unsigned size) /* alloc arrays */ p->Parameters = (struct gl_program_parameter *) - _mesa_calloc(size * sizeof(struct gl_program_parameter)); + calloc(1, size * sizeof(struct gl_program_parameter)); p->ParameterValues = (GLfloat (*)[4]) _mesa_align_malloc(size * 4 *sizeof(GLfloat), 16); if ((p->Parameters == NULL) || (p->ParameterValues == NULL)) { - _mesa_free(p->Parameters); + free(p->Parameters); _mesa_align_free(p->ParameterValues); - _mesa_free(p); + free(p); p = NULL; } } @@ -81,12 +81,12 @@ _mesa_free_parameter_list(struct gl_program_parameter_list *paramList) GLuint i; for (i = 0; i < paramList->NumParameters; i++) { if (paramList->Parameters[i].Name) - _mesa_free((void *) paramList->Parameters[i].Name); + free((void *) paramList->Parameters[i].Name); } - _mesa_free(paramList->Parameters); + free(paramList->Parameters); if (paramList->ParameterValues) _mesa_align_free(paramList->ParameterValues); - _mesa_free(paramList); + free(paramList); } @@ -486,7 +486,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList, paramList->StateFlags |= _mesa_program_state_flags(stateTokens); /* free name string here since we duplicated it in add_parameter() */ - _mesa_free(name); + free(name); return index; } diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index 54fd88ad4f..b238537673 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -309,7 +309,7 @@ reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, = prog->Parameters->Parameters + index; char *state = _mesa_program_state_string(param->StateIndexes); _mesa_sprintf(str, state); - _mesa_free(state); + free(state); } break; case PROGRAM_ADDRESS: diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index f5264fa918..2c844490dd 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -957,7 +957,7 @@ append_index(char *dst, GLint index) /** * Make a string from the given state vector. * For example, return "state.matrix.texture[2].inverse". - * Use _mesa_free() to deallocate the string. + * Use free() to deallocate the string. */ char * _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) diff --git a/src/mesa/shader/prog_uniform.c b/src/mesa/shader/prog_uniform.c index a831ce8cb6..c408a8492c 100644 --- a/src/mesa/shader/prog_uniform.c +++ b/src/mesa/shader/prog_uniform.c @@ -45,10 +45,10 @@ _mesa_free_uniform_list(struct gl_uniform_list *list) { GLuint i; for (i = 0; i < list->NumUniforms; i++) { - _mesa_free((void *) list->Uniforms[i].Name); + free((void *) list->Uniforms[i].Name); } - _mesa_free(list->Uniforms); - _mesa_free(list); + free(list->Uniforms); + free(list); } diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 0c3c5ffbd5..f4f701b546 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -127,11 +127,11 @@ _mesa_free_program_data(GLcontext *ctx) if (ctx->ATIFragmentShader.Current) { ctx->ATIFragmentShader.Current->RefCount--; if (ctx->ATIFragmentShader.Current->RefCount <= 0) { - _mesa_free(ctx->ATIFragmentShader.Current); + free(ctx->ATIFragmentShader.Current); } } #endif - _mesa_free((void *) ctx->Program.ErrorString); + free((void *) ctx->Program.ErrorString); } @@ -162,7 +162,7 @@ _mesa_update_default_objects_program(GLcontext *ctx) if (ctx->ATIFragmentShader.Current) { ctx->ATIFragmentShader.Current->RefCount--; if (ctx->ATIFragmentShader.Current->RefCount <= 0) { - _mesa_free(ctx->ATIFragmentShader.Current); + free(ctx->ATIFragmentShader.Current); } } ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader; @@ -180,7 +180,7 @@ void _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string) { ctx->Program.ErrorPos = pos; - _mesa_free((void *) ctx->Program.ErrorString); + free((void *) ctx->Program.ErrorString); if (!string) string = ""; ctx->Program.ErrorString = _mesa_strdup(string); @@ -190,7 +190,7 @@ _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string) /** * Find the line number and column for 'pos' within 'string'. * Return a copy of the line which contains 'pos'. Free the line with - * _mesa_free(). + * free(). * \param string the program string * \param pos the position within the string * \param line returns the line number corresponding to 'pos'. @@ -222,7 +222,7 @@ _mesa_find_line_column(const GLubyte *string, const GLubyte *pos, while (*p != 0 && *p != '\n') p++; len = p - lineStart; - s = (GLubyte *) _mesa_malloc(len + 1); + s = (GLubyte *) malloc(len + 1); memcpy(s, lineStart, len); s[len] = 0; @@ -337,7 +337,7 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog) return; if (prog->String) - _mesa_free(prog->String); + free(prog->String); _mesa_free_instructions(prog->Instructions, prog->NumInstructions); @@ -351,7 +351,7 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog) _mesa_free_parameter_list(prog->Attributes); } - _mesa_free(prog); + free(prog); } diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index 182ef4c26d..e5ef25ec38 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -3140,7 +3140,7 @@ yyreduce: ? err_str : "invalid condition code"); if (err_str != NULL) { - _mesa_free(err_str); + free(err_str); } YYERROR; @@ -3166,7 +3166,7 @@ yyreduce: ? err_str : "invalid condition code"); if (err_str != NULL) { - _mesa_free(err_str); + free(err_str); } YYERROR; @@ -4547,7 +4547,7 @@ yyreduce: ? err_str : "invalid storage size specifier"); if (err_str != NULL) { - _mesa_free(err_str); + free(err_str); } YYERROR; @@ -5403,7 +5403,7 @@ int add_state_reference(struct gl_program_parameter_list *param_list, param_list->StateFlags |= _mesa_program_state_flags(tokens); /* free name string here since we duplicated it in add_parameter() */ - _mesa_free(name); + free(name); return index; } @@ -5568,7 +5568,7 @@ make_error_string(const char *fmt, ...) */ length = 1 + vsnprintf(NULL, 0, fmt, args); - str = _mesa_malloc(length); + str = malloc(length); if (str) { vsnprintf(str, length, fmt, args); } @@ -5588,7 +5588,7 @@ yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) err_str = make_error_string("glProgramStringARB(%s)\n", s); if (err_str) { _mesa_error(state->ctx, GL_INVALID_OPERATION, err_str); - _mesa_free(err_str); + free(err_str); } err_str = make_error_string("line %u, char %u: error: %s\n", @@ -5596,7 +5596,7 @@ yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) _mesa_set_program_error(state->ctx, locp->position, err_str); if (err_str) { - _mesa_free(err_str); + free(err_str); } } @@ -5618,7 +5618,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, /* Make a copy of the program string and force it to be NUL-terminated. */ - strz = (GLubyte *) _mesa_malloc(len + 1); + strz = (GLubyte *) malloc(len + 1); if (strz == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); return GL_FALSE; @@ -5706,7 +5706,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, error: for (inst = state->inst_head; inst != NULL; inst = temp) { temp = inst->next; - _mesa_free(inst); + free(inst); } state->inst_head = NULL; @@ -5715,8 +5715,8 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; - _mesa_free((void *) sym->name); - _mesa_free(sym); + free((void *) sym->name); + free(sym); } state->sym = NULL; diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 577bd2c38d..299e2477e4 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -1056,7 +1056,7 @@ ccMaskRule: IDENTIFIER ? err_str : "invalid condition code"); if (err_str != NULL) { - _mesa_free(err_str); + free(err_str); } YYERROR; @@ -1079,7 +1079,7 @@ ccMaskRule2: USED_IDENTIFIER ? err_str : "invalid condition code"); if (err_str != NULL) { - _mesa_free(err_str); + free(err_str); } YYERROR; @@ -1956,7 +1956,7 @@ optVarSize: string ? err_str : "invalid storage size specifier"); if (err_str != NULL) { - _mesa_free(err_str); + free(err_str); } YYERROR; @@ -2442,7 +2442,7 @@ int add_state_reference(struct gl_program_parameter_list *param_list, param_list->StateFlags |= _mesa_program_state_flags(tokens); /* free name string here since we duplicated it in add_parameter() */ - _mesa_free(name); + free(name); return index; } @@ -2607,7 +2607,7 @@ make_error_string(const char *fmt, ...) */ length = 1 + vsnprintf(NULL, 0, fmt, args); - str = _mesa_malloc(length); + str = malloc(length); if (str) { vsnprintf(str, length, fmt, args); } @@ -2627,7 +2627,7 @@ yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) err_str = make_error_string("glProgramStringARB(%s)\n", s); if (err_str) { _mesa_error(state->ctx, GL_INVALID_OPERATION, err_str); - _mesa_free(err_str); + free(err_str); } err_str = make_error_string("line %u, char %u: error: %s\n", @@ -2635,7 +2635,7 @@ yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) _mesa_set_program_error(state->ctx, locp->position, err_str); if (err_str) { - _mesa_free(err_str); + free(err_str); } } @@ -2657,7 +2657,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, /* Make a copy of the program string and force it to be NUL-terminated. */ - strz = (GLubyte *) _mesa_malloc(len + 1); + strz = (GLubyte *) malloc(len + 1); if (strz == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); return GL_FALSE; @@ -2745,7 +2745,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, error: for (inst = state->inst_head; inst != NULL; inst = temp) { temp = inst->next; - _mesa_free(inst); + free(inst); } state->inst_head = NULL; @@ -2754,8 +2754,8 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; - _mesa_free((void *) sym->name); - _mesa_free(sym); + free((void *) sym->name); + free(sym); } state->sym = NULL; diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 7e2a60f74b..ad3ff26c58 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -115,12 +115,12 @@ _mesa_free_shader_program_data(GLcontext *ctx, shProg->NumShaders = 0; if (shProg->Shaders) { - _mesa_free(shProg->Shaders); + free(shProg->Shaders); shProg->Shaders = NULL; } if (shProg->InfoLog) { - _mesa_free(shProg->InfoLog); + free(shProg->InfoLog); shProg->InfoLog = NULL; } } @@ -134,7 +134,7 @@ _mesa_free_shader_program(GLcontext *ctx, struct gl_shader_program *shProg) { _mesa_free_shader_program_data(ctx, shProg); - _mesa_free(shProg); + free(shProg); } @@ -262,11 +262,11 @@ void _mesa_free_shader(GLcontext *ctx, struct gl_shader *sh) { if (sh->Source) - _mesa_free((void *) sh->Source); + free((void *) sh->Source); if (sh->InfoLog) - _mesa_free(sh->InfoLog); + free(sh->InfoLog); _mesa_reference_program(ctx, &sh->Program, NULL); - _mesa_free(sh); + free(sh); } @@ -709,7 +709,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader) /* alloc new, smaller array */ newList = (struct gl_shader **) - _mesa_malloc((n - 1) * sizeof(struct gl_shader *)); + malloc((n - 1) * sizeof(struct gl_shader *)); if (!newList) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader"); return; @@ -719,7 +719,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader) } while (++i < n) newList[j++] = shProg->Shaders[i]; - _mesa_free(shProg->Shaders); + free(shProg->Shaders); shProg->Shaders = newList; shProg->NumShaders = n - 1; @@ -1377,7 +1377,7 @@ _mesa_get_uniform_location(GLcontext *ctx, GLuint program, const GLchar *name) if (c) { /* truncate name at [ */ const GLint len = c - name; - GLchar *newName = _mesa_malloc(len + 1); + GLchar *newName = malloc(len + 1); if (!newName) return -1; /* out of mem */ memcpy(newName, name, len); @@ -1400,7 +1400,7 @@ _mesa_get_uniform_location(GLcontext *ctx, GLuint program, const GLchar *name) } } - _mesa_free(newName); + free(newName); } } @@ -1431,7 +1431,7 @@ _mesa_shader_source(GLcontext *ctx, GLuint shader, const GLchar *source) /* free old shader source string and install new one */ if (sh->Source) { - _mesa_free((void *) sh->Source); + free((void *) sh->Source); } sh->Source = source; sh->CompileStatus = GL_FALSE; @@ -2155,7 +2155,7 @@ _mesa_validate_program(GLcontext *ctx, GLuint program) if (!shProg->Validated) { /* update info log */ if (shProg->InfoLog) { - _mesa_free(shProg->InfoLog); + free(shProg->InfoLog); } shProg->InfoLog = _mesa_strdup(errMsg); } diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 2280ceb9ee..6901b93d5d 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3639,7 +3639,7 @@ make_constant_array(slang_assemble_ctx *A, assert(initializer->type == SLANG_OPER_CALL); assert(initializer->array_constructor); - values = (GLfloat *) _mesa_malloc(numElements * 4 * sizeof(GLfloat)); + values = (GLfloat *) malloc(numElements * 4 * sizeof(GLfloat)); /* convert constructor params into ordinary floats */ for (i = 0; i < numElements; i++) { @@ -3670,7 +3670,7 @@ make_constant_array(slang_assemble_ctx *A, } assert(var->store->Size == size); - _mesa_free(values); + free(values); return GL_TRUE; } @@ -5321,7 +5321,7 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun) /* free codegen context */ /* - _mesa_free(A->codegen); + free(A->codegen); */ return success; diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 41d51cd98a..4280698cc9 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2948,7 +2948,7 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader) /* free shader's prev info log */ if (shader->InfoLog) { - _mesa_free(shader->InfoLog); + free(shader->InfoLog); shader->InfoLog = NULL; } diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index eab912710e..23c08a9039 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -182,7 +182,7 @@ slang_variable_destruct(slang_variable * var) } #if 0 if (var->aux) { - _mesa_free(var->aux); + free(var->aux); } #endif } diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index b621e892c3..8bd699ff9d 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -2528,7 +2528,7 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo) GLuint *subroutineLoc, i, total; subroutineLoc - = (GLuint *) _mesa_malloc(emitInfo->NumSubroutines * sizeof(GLuint)); + = (GLuint *) malloc(emitInfo->NumSubroutines * sizeof(GLuint)); /* total number of instructions */ total = mainP->NumInstructions; @@ -2566,7 +2566,7 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo) /* free subroutine list */ if (emitInfo->Subroutines) { - _mesa_free(emitInfo->Subroutines); + free(emitInfo->Subroutines); emitInfo->Subroutines = NULL; } emitInfo->NumSubroutines = 0; @@ -2585,7 +2585,7 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo) } } - _mesa_free(subroutineLoc); + free(subroutineLoc); } diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c index 1240621365..7e00b5787f 100644 --- a/src/mesa/shader/slang/slang_label.c +++ b/src/mesa/shader/slang/slang_label.c @@ -34,7 +34,7 @@ _slang_label_new_unique(const char *name) if (l) { l->Name = (char *) _slang_alloc(strlen(name) + 10); if (!l->Name) { - _mesa_free(l); + free(l); return NULL; } _mesa_sprintf(l->Name, "%s_%d", name, id); diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 68129d4c5a..89658c1a39 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -68,7 +68,7 @@ static void link_error(struct gl_shader_program *shProg, const char *msg) { if (shProg->InfoLog) { - _mesa_free(shProg->InfoLog); + free(shProg->InfoLog); } shProg->InfoLog = _mesa_strdup(msg); shProg->LinkStatus = GL_FALSE; @@ -103,7 +103,7 @@ link_varying_vars(GLcontext *ctx, GLuint *map, i, firstVarying, newFile; GLbitfield *inOutFlags; - map = (GLuint *) _mesa_malloc(prog->Varying->NumParameters * sizeof(GLuint)); + map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint)); if (!map) return GL_FALSE; @@ -134,7 +134,7 @@ link_varying_vars(GLcontext *ctx, &shProg->Varying->Parameters[j]; if (var->Size != v->Size) { link_error(shProg, "mismatched varying variable types"); - _mesa_free(map); + free(map); return GL_FALSE; } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) { @@ -142,7 +142,7 @@ link_varying_vars(GLcontext *ctx, _mesa_snprintf(msg, sizeof(msg), "centroid modifier mismatch for '%s'", var->Name); link_error(shProg, msg); - _mesa_free(map); + free(map); return GL_FALSE; } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) { @@ -150,7 +150,7 @@ link_varying_vars(GLcontext *ctx, _mesa_snprintf(msg, sizeof(msg), "invariant modifier mismatch for '%s'", var->Name); link_error(shProg, msg); - _mesa_free(map); + free(map); return GL_FALSE; } } @@ -162,7 +162,7 @@ link_varying_vars(GLcontext *ctx, if (shProg->Varying->NumParameters > ctx->Const.MaxVarying) { link_error(shProg, "Too many varying variables"); - _mesa_free(map); + free(map); return GL_FALSE; } @@ -202,7 +202,7 @@ link_varying_vars(GLcontext *ctx, } } - _mesa_free(map); + free(map); /* these will get recomputed before linking is completed */ prog->InputsRead = 0x0; @@ -594,7 +594,7 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) GLuint totalLen = 0, len = 0; GLuint i; - shaderLengths = (GLuint *)_mesa_malloc(shProg->NumShaders * sizeof(GLuint)); + shaderLengths = (GLuint *)malloc(shProg->NumShaders * sizeof(GLuint)); if (!shaderLengths) { return NULL; } @@ -611,13 +611,13 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) } if (totalLen == 0) { - _mesa_free(shaderLengths); + free(shaderLengths); return NULL; } - source = (GLchar *) _mesa_malloc(totalLen + 1); + source = (GLchar *) malloc(totalLen + 1); if (!source) { - _mesa_free(shaderLengths); + free(shaderLengths); return NULL; } @@ -634,13 +634,13 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) _mesa_printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source); */ - _mesa_free(shaderLengths); + free(shaderLengths); remove_extra_version_directives(source); newShader = CALLOC_STRUCT(gl_shader); if (!newShader) { - _mesa_free(source); + free(source); return NULL; } diff --git a/src/mesa/shader/slang/slang_log.c b/src/mesa/shader/slang/slang_log.c index 4f6b8541c5..23917fbd2c 100644 --- a/src/mesa/shader/slang/slang_log.c +++ b/src/mesa/shader/slang/slang_log.c @@ -43,7 +43,7 @@ void slang_info_log_destruct(slang_info_log * log) { if (!log->dont_free_text) - _mesa_free(log->text); + free(log->text); } static int @@ -63,7 +63,7 @@ slang_info_log_message(slang_info_log * log, const char *prefix, _mesa_realloc(log->text, old_len + 1, old_len + size); } else { - log->text = (char *) (_mesa_malloc(size)); + log->text = (char *) (malloc(size)); if (log->text != NULL) log->text[0] = '\0'; } diff --git a/src/mesa/shader/slang/slang_mem.c b/src/mesa/shader/slang/slang_mem.c index 54f5196617..5eaa7c4427 100644 --- a/src/mesa/shader/slang/slang_mem.c +++ b/src/mesa/shader/slang/slang_mem.c @@ -56,12 +56,12 @@ struct slang_mempool_ slang_mempool * _slang_new_mempool(GLuint initialSize) { - slang_mempool *pool = (slang_mempool *) _mesa_calloc(sizeof(slang_mempool)); + slang_mempool *pool = (slang_mempool *) calloc(1, sizeof(slang_mempool)); if (pool) { - pool->Data = (char *) _mesa_calloc(initialSize); + pool->Data = (char *) calloc(1, initialSize); /*printf("ALLOC MEMPOOL %d at %p\n", initialSize, pool->Data);*/ if (!pool->Data) { - _mesa_free(pool); + free(pool); return NULL; } pool->Size = initialSize; @@ -82,8 +82,8 @@ _slang_delete_mempool(slang_mempool *pool) pool->Used, pool->Size, pool->Count, pool->Largest); */ total += pool->Used; - _mesa_free(pool->Data); - _mesa_free(pool); + free(pool->Data); + free(pool); pool = next; } /*printf("TOTAL ALLOCATED: %u\n", total);*/ @@ -125,7 +125,7 @@ void * _slang_alloc(GLuint bytes) { #if USE_MALLOC_FREE - return _mesa_calloc(bytes); + return calloc(1, bytes); #else slang_mempool *pool; GET_CURRENT_CONTEXT(ctx); @@ -231,7 +231,7 @@ void _slang_free(void *addr) { #if USE_MALLOC_FREE - _mesa_free(addr); + free(addr); #else if (addr) { GET_CURRENT_CONTEXT(ctx); diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c index 56a33e6f6b..dc1e196bde 100644 --- a/src/mesa/shader/slang/slang_utility.c +++ b/src/mesa/shader/slang/slang_utility.c @@ -54,7 +54,7 @@ GLvoid slang_string_free (slang_string *self) { if (self->data != NULL) - _mesa_free (self->data); + free(self->data); } GLvoid diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c index 1f6d9b844d..6a5d686897 100644 --- a/src/mesa/shader/symbol_table.c +++ b/src/mesa/shader/symbol_table.c @@ -354,7 +354,7 @@ _mesa_symbol_table_dtor(struct _mesa_symbol_table *table) for (hdr = table->hdr; hdr != NULL; hdr = next) { next = hdr->next; - _mesa_free(hdr); + free(hdr); } hash_table_dtor(table->ht); diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 1be72e729e..33e43ddcc4 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -143,7 +143,7 @@ accum_accum(struct st_context *st, GLfloat value, PIPE_TRANSFER_READ, xpos, ypos, width, height); - buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf); @@ -165,7 +165,7 @@ accum_accum(struct st_context *st, GLfloat value, _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()"); } - _mesa_free(buf); + free(buf); screen->tex_transfer_destroy(color_trans); } @@ -192,7 +192,7 @@ accum_load(struct st_context *st, GLfloat value, PIPE_TRANSFER_READ, xpos, ypos, width, height); - buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf); @@ -214,7 +214,7 @@ accum_load(struct st_context *st, GLfloat value, _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()"); } - _mesa_free(buf); + free(buf); screen->tex_transfer_destroy(color_trans); } @@ -237,7 +237,7 @@ accum_return(GLcontext *ctx, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) usage = PIPE_TRANSFER_READ_WRITE; @@ -282,7 +282,7 @@ accum_return(GLcontext *ctx, GLfloat value, pipe_put_tile_rgba(color_trans, 0, 0, width, height, buf); - _mesa_free(buf); + free(buf); screen->tex_transfer_destroy(color_trans); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index e029ea7ffc..5968426a1d 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -837,7 +837,7 @@ st_destroy_bitmap(struct st_context *st) screen->tex_transfer_destroy(cache->trans); } pipe_texture_reference(&st->bitmap.cache->texture, NULL); - _mesa_free(st->bitmap.cache); + free(st->bitmap.cache); st->bitmap.cache = NULL; } } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index c92af34378..b55a085cc7 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -80,7 +80,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) if (st_obj->buffer) pipe_buffer_reference(&st_obj->buffer, NULL); - _mesa_free(st_obj); + free(st_obj); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 36c0a2b0e1..4e86450edf 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -828,7 +828,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, ubyte *buffer; int i; - buffer = _mesa_malloc(width * height * sizeof(ubyte)); + buffer = malloc(width * height * sizeof(ubyte)); if (!buffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels(stencil)"); return; @@ -907,7 +907,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } - _mesa_free(buffer); + free(buffer); /* unmap the stencil buffer */ screen->transfer_unmap(screen, ptDraw); @@ -1089,19 +1089,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (type == GL_COLOR) { /* alternate path using get/put_tile() */ - GLfloat *buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(ptRead, 0, 0, width, height, buf); pipe_put_tile_rgba(ptTex, 0, 0, width, height, buf); - _mesa_free(buf); + free(buf); } else { /* GL_DEPTH */ - GLuint *buf = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); + GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); pipe_get_tile_z(ptRead, 0, 0, width, height, buf); pipe_put_tile_z(ptTex, 0, 0, width, height, buf); - _mesa_free(buf); + free(buf); } screen->tex_transfer_destroy(ptRead); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 4638879fc2..bfa8e21095 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -102,14 +102,14 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, if(strb->software) { size_t size; - _mesa_free(strb->data); + free(strb->data); assert(strb->format != PIPE_FORMAT_NONE); strb->stride = util_format_get_stride(strb->format, width); size = util_format_get_2d_size(strb->format, strb->stride, height); - strb->data = _mesa_malloc(size); + strb->data = malloc(size); return strb->data != NULL; } @@ -181,8 +181,8 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) ASSERT(strb); pipe_surface_reference(&strb->surface, NULL); pipe_texture_reference(&strb->texture, NULL); - _mesa_free(strb->data); - _mesa_free(strb); + free(strb->data); + free(strb); } @@ -286,7 +286,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) default: _mesa_problem(NULL, "Unexpected format in st_new_renderbuffer_fb"); - _mesa_free(strb); + free(strb); return NULL; } diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index dc40c5d269..c66729b124 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -69,7 +69,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) stq->pq = NULL; } - _mesa_free(stq); + free(stq); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 4692891c8a..752b411b5f 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -101,7 +101,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim ) static void rastpos_destroy(struct draw_stage *stage) { - _mesa_free(stage); + free(stage); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 13f050900a..7e50e2ab2d 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1319,7 +1319,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, else { /* RGBA format */ GLfloat *tempSrc = - (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (tempSrc && texDest) { const GLint dims = 2; @@ -1359,7 +1359,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } if (tempSrc) - _mesa_free(tempSrc); + free(tempSrc); } st_texture_image_unmap(ctx->st, stImage); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 5b3987d73a..de8beaf5e2 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -222,7 +222,7 @@ static void st_destroy_context_priv( struct st_context *st ) st->default_texture = NULL; } - _mesa_free( st ); + free( st ); } @@ -257,7 +257,7 @@ void st_destroy_context( struct st_context *st ) pipe->destroy( pipe ); - _mesa_free(ctx); + free(ctx); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 50e98d7146..13b7b0e22d 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -239,7 +239,7 @@ st_fb_orientation(const struct gl_framebuffer *fb) /** clear-alloc a struct-sized object, with casting */ -#define ST_CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T)) +#define ST_CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) extern int diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 537a6a8648..807d21a719 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -1055,7 +1055,7 @@ out: /** - * Tokens cannot be free with _mesa_free otherwise the builtin gallium + * Tokens cannot be free with free otherwise the builtin gallium * malloc debugging will get confused. */ void diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c index f73ac78ae2..753f3136f5 100644 --- a/src/mesa/swrast/s_blit.c +++ b/src/mesa/swrast/s_blit.c @@ -198,14 +198,14 @@ blit_nearest(GLcontext *ctx, } /* allocate the src/dst row buffers */ - srcBuffer = _mesa_malloc(pixelSize * srcWidth); + srcBuffer = malloc(pixelSize * srcWidth); if (!srcBuffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); return; } - dstBuffer = _mesa_malloc(pixelSize * dstWidth); + dstBuffer = malloc(pixelSize * dstWidth); if (!dstBuffer) { - _mesa_free(srcBuffer); + free(srcBuffer); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); return; } @@ -235,8 +235,8 @@ blit_nearest(GLcontext *ctx, drawRb->PutRow(ctx, drawRb, dstWidth, dstXpos, dstY, dstBuffer, NULL); } - _mesa_free(srcBuffer); - _mesa_free(dstBuffer); + free(srcBuffer); + free(dstBuffer); } @@ -366,21 +366,21 @@ blit_linear(GLcontext *ctx, /* Allocate the src/dst row buffers. * Keep two adjacent src rows around for bilinear sampling. */ - srcBuffer0 = _mesa_malloc(pixelSize * srcWidth); + srcBuffer0 = malloc(pixelSize * srcWidth); if (!srcBuffer0) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); return; } - srcBuffer1 = _mesa_malloc(pixelSize * srcWidth); + srcBuffer1 = malloc(pixelSize * srcWidth); if (!srcBuffer1) { - _mesa_free(srcBuffer0); + free(srcBuffer0); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); return; } - dstBuffer = _mesa_malloc(pixelSize * dstWidth); + dstBuffer = malloc(pixelSize * dstWidth); if (!dstBuffer) { - _mesa_free(srcBuffer0); - _mesa_free(srcBuffer1); + free(srcBuffer0); + free(srcBuffer1); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); return; } @@ -444,9 +444,9 @@ blit_linear(GLcontext *ctx, drawRb->PutRow(ctx, drawRb, dstWidth, dstXpos, dstY, dstBuffer, NULL); } - _mesa_free(srcBuffer0); - _mesa_free(srcBuffer1); - _mesa_free(dstBuffer); + free(srcBuffer0); + free(srcBuffer1); + free(dstBuffer); } @@ -535,7 +535,7 @@ simple_blit(GLcontext *ctx, } /* allocate the row buffer */ - rowBuffer = _mesa_malloc(bytesPerRow); + rowBuffer = malloc(bytesPerRow); if (!rowBuffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBlitFrameBufferEXT"); return; @@ -548,7 +548,7 @@ simple_blit(GLcontext *ctx, dstY += yStep; } - _mesa_free(rowBuffer); + free(rowBuffer); } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index b69be50f51..3f37c027e4 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -114,14 +114,14 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, span.arrayAttribs = FRAG_BIT_COL0; /* allocate space for GLfloat image */ - tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!tmpImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); return; } - convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!convImage) { - _mesa_free(tmpImage); + free(tmpImage); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); return; } @@ -150,7 +150,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, ASSERT(ctx->Pixel.Separable2DEnabled); _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); } - _mesa_free(tmpImage); + free(tmpImage); /* do remaining post-convolution image transfer ops */ for (row = 0; row < height; row++) { @@ -185,7 +185,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, span.array->ChanType = CHAN_TYPE; } - _mesa_free(convImage); + free(convImage); } @@ -246,7 +246,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, span.arrayAttribs = FRAG_BIT_COL0; /* we'll fill in COL0 attrib values */ if (overlapping) { - tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4); + tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat) * 4); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -303,7 +303,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, span.array->ChanType = CHAN_TYPE; /* restore */ if (overlapping) - _mesa_free(tmpImage); + free(tmpImage); } @@ -352,7 +352,7 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy, if (overlapping) { GLint ssy = sy; - tmpImage = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); + tmpImage = (GLuint *) malloc(width * height * sizeof(GLuint)); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -397,7 +397,7 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } if (overlapping) - _mesa_free(tmpImage); + free(tmpImage); } @@ -487,7 +487,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, if (overlapping) { GLint ssy = sy; - tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat)); + tmpImage = (GLfloat *) malloc(width * height * sizeof(GLfloat)); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -537,7 +537,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } if (overlapping) - _mesa_free(tmpImage); + free(tmpImage); } @@ -584,7 +584,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, if (overlapping) { GLint ssy = sy; - tmpImage = (GLstencil *) _mesa_malloc(width * height * sizeof(GLstencil)); + tmpImage = (GLstencil *) malloc(width * height * sizeof(GLstencil)); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); return; @@ -626,7 +626,7 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } if (overlapping) - _mesa_free(tmpImage); + free(tmpImage); } @@ -688,7 +688,7 @@ copy_depth_stencil_pixels(GLcontext *ctx, if (stencilMask != 0x0) { tempStencilImage - = (GLstencil *) _mesa_malloc(width * height * sizeof(GLstencil)); + = (GLstencil *) malloc(width * height * sizeof(GLstencil)); if (!tempStencilImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); return; @@ -706,10 +706,10 @@ copy_depth_stencil_pixels(GLcontext *ctx, if (ctx->Depth.Mask) { tempDepthImage - = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat)); + = (GLfloat *) malloc(width * height * sizeof(GLfloat)); if (!tempDepthImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels"); - _mesa_free(tempStencilImage); + free(tempStencilImage); return; } @@ -799,10 +799,10 @@ copy_depth_stencil_pixels(GLcontext *ctx, } if (tempStencilImage) - _mesa_free(tempStencilImage); + free(tempStencilImage); if (tempDepthImage) - _mesa_free(tempDepthImage); + free(tempDepthImage); } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 136c296e98..7571d5b8c0 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -566,14 +566,14 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, GLint row; GLfloat *dest, *tmpImage; - tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!tmpImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); return; } - convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!convImage) { - _mesa_free(tmpImage); + free(tmpImage); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); return; } @@ -597,7 +597,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, ASSERT(ctx->Pixel.Separable2DEnabled); _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); } - _mesa_free(tmpImage); + free(tmpImage); /* continue transfer ops and draw the convolved image */ unpack = &ctx->DefaultPacking; @@ -677,7 +677,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, } if (convImage) { - _mesa_free(convImage); + free(convImage); } } diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index 94fb974eab..41911337b8 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -358,14 +358,14 @@ read_rgba_pixels( GLcontext *ctx, GLfloat *dest, *src, *tmpImage, *convImage; GLint row; - tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!tmpImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return; } - convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!convImage) { - _mesa_free(tmpImage); + free(tmpImage); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels"); return; } @@ -399,7 +399,7 @@ read_rgba_pixels( GLcontext *ctx, ASSERT(ctx->Pixel.Separable2DEnabled); _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage); } - _mesa_free(tmpImage); + free(tmpImage); /* finish transfer ops and pack the resulting image */ src = convImage; @@ -412,7 +412,7 @@ read_rgba_pixels( GLcontext *ctx, transferOps & IMAGE_POST_CONVOLUTION_BITS); src += width * 4; } - _mesa_free(convImage); + free(convImage); } else { /* no convolution */ diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 149f693711..8a2787a139 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -41,7 +41,7 @@ static GLubyte *get_space(GLcontext *ctx, GLuint bytes) { TNLcontext *tnl = TNL_CONTEXT(ctx); - GLubyte *space = _mesa_malloc(bytes); + GLubyte *space = malloc(bytes); tnl->block[tnl->nr_blocks++] = space; return space; @@ -53,7 +53,7 @@ static void free_space(GLcontext *ctx) TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint i; for (i = 0; i < tnl->nr_blocks; i++) - _mesa_free(tnl->block[i]); + free(tnl->block[i]); tnl->nr_blocks = 0; } diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index 693d3dc118..61ac409573 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -152,7 +152,7 @@ alloc_normal_data(GLcontext *ctx, struct tnl_pipeline_stage *stage) TNLcontext *tnl = TNL_CONTEXT(ctx); struct normal_stage_data *store; - stage->privatePtr = _mesa_malloc(sizeof(*store)); + stage->privatePtr = malloc(sizeof(*store)); store = NORMAL_STAGE_DATA(stage); if (!store) return GL_FALSE; @@ -171,7 +171,7 @@ free_normal_data(struct tnl_pipeline_stage *stage) struct normal_stage_data *store = NORMAL_STAGE_DATA(stage); if (store) { _mesa_vector4f_free( &store->normal ); - _mesa_free( store ); + free( store ); stage->privatePtr = NULL; } } diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index ab8ea60cf2..20634c80d1 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -81,7 +81,7 @@ alloc_point_data(GLcontext *ctx, struct tnl_pipeline_stage *stage) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct point_stage_data *store; - stage->privatePtr = _mesa_malloc(sizeof(*store)); + stage->privatePtr = malloc(sizeof(*store)); store = POINT_STAGE_DATA(stage); if (!store) return GL_FALSE; @@ -97,7 +97,7 @@ free_point_data(struct tnl_pipeline_stage *stage) struct point_stage_data *store = POINT_STAGE_DATA(stage); if (store) { _mesa_vector4f_free( &store->PointSize ); - _mesa_free( store ); + free( store ); stage->privatePtr = NULL; } } diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index 2b8c962f06..ed66c35be7 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -88,7 +88,7 @@ void _tnl_register_fastpath( struct tnl_clipspace *vtx, fastpath->match_strides = match_strides; fastpath->func = vtx->emit; fastpath->attr = (struct tnl_attr_type *) - _mesa_malloc(vtx->attr_count * sizeof(fastpath->attr[0])); + malloc(vtx->attr_count * sizeof(fastpath->attr[0])); for (i = 0; i < vtx->attr_count; i++) { fastpath->attr[i].format = vtx->attr[i].format; diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index a284e4047f..f2f1674b6a 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -854,7 +854,7 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, return; } - prim = _mesa_calloc(primcount * sizeof(*prim)); + prim = calloc(1, primcount * sizeof(*prim)); if (prim == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements"); return; @@ -960,7 +960,7 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, } } - _mesa_free(prim); + free(prim); } diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index 55a82ee369..1db36de3de 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -134,7 +134,7 @@ void vbo_rebase_prims( GLcontext *ctx, /* If we can just tell the hardware or the TNL to interpret our * indices with a different base, do so. */ - tmp_prims = (struct _mesa_prim *)_mesa_malloc(sizeof(*prim) * nr_prims); + tmp_prims = (struct _mesa_prim *)malloc(sizeof(*prim) * nr_prims); for (i = 0; i < nr_prims; i++) { tmp_prims[i] = prim[i]; @@ -187,7 +187,7 @@ void vbo_rebase_prims( GLcontext *ctx, else { /* Otherwise the primitives need adjustment. */ - tmp_prims = (struct _mesa_prim *)_mesa_malloc(sizeof(*prim) * nr_prims); + tmp_prims = (struct _mesa_prim *)malloc(sizeof(*prim) * nr_prims); for (i = 0; i < nr_prims; i++) { /* If this fails, it could indicate an application error: @@ -229,10 +229,10 @@ void vbo_rebase_prims( GLcontext *ctx, max_index - min_index ); if (tmp_indices) - _mesa_free(tmp_indices); + free(tmp_indices); if (tmp_prims) - _mesa_free(tmp_prims); + free(tmp_prims); } diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 2ca111217c..2fae267ff5 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -466,7 +466,7 @@ replay_init( struct copy_context *copy ) switch (copy->ib->type) { case GL_UNSIGNED_BYTE: - copy->translated_elt_buf = _mesa_malloc(sizeof(GLuint) * copy->ib->count); + copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); copy->srcelt = copy->translated_elt_buf; for (i = 0; i < copy->ib->count; i++) @@ -474,7 +474,7 @@ replay_init( struct copy_context *copy ) break; case GL_UNSIGNED_SHORT: - copy->translated_elt_buf = _mesa_malloc(sizeof(GLuint) * copy->ib->count); + copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count); copy->srcelt = copy->translated_elt_buf; for (i = 0; i < copy->ib->count; i++) @@ -500,7 +500,7 @@ replay_init( struct copy_context *copy ) * * XXX: This should be a VBO! */ - copy->dstbuf = _mesa_malloc(copy->dstbuf_size * copy->vertex_size); + copy->dstbuf = malloc(copy->dstbuf_size * copy->vertex_size); copy->dstptr = copy->dstbuf; /* Setup new vertex arrays to point into the output buffer: @@ -529,7 +529,7 @@ replay_init( struct copy_context *copy ) copy->ib->count * 2 + 3); copy->dstelt_size = MIN2(copy->dstelt_size, copy->limits->max_indices); - copy->dstelt = _mesa_malloc(sizeof(GLuint) * copy->dstelt_size); + copy->dstelt = malloc(sizeof(GLuint) * copy->dstelt_size); copy->dstelt_nr = 0; /* Setup the new index buffer to point to the allocated element @@ -553,9 +553,9 @@ replay_finish( struct copy_context *copy ) /* Free our vertex and index buffers: */ - _mesa_free(copy->translated_elt_buf); - _mesa_free(copy->dstbuf); - _mesa_free(copy->dstelt); + free(copy->translated_elt_buf); + free(copy->dstbuf); + free(copy->dstelt); /* Unmap VBO's */ diff --git a/src/mesa/vf/vf.c b/src/mesa/vf/vf.c index 15a78c4c0a..dab436e2ab 100644 --- a/src/mesa/vf/vf.c +++ b/src/mesa/vf/vf.c @@ -86,7 +86,7 @@ void vf_register_fastpath( struct vertex_fetch *vf, fastpath->match_strides = match_strides; fastpath->func = vf->emit; fastpath->attr = (struct vf_attr_type *) - _mesa_malloc(vf->attr_count * sizeof(fastpath->attr[0])); + malloc(vf->attr_count * sizeof(fastpath->attr[0])); for (i = 0; i < vf->attr_count; i++) { fastpath->attr[i].format = vf->attr[i].format; -- cgit v1.2.3 From 298be2b028263b2c343a707662c6fbfa18293cb2 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 19 Feb 2010 12:32:24 -0500 Subject: Replace the _mesa_*printf() wrappers with the plain libc versions --- src/gallium/auxiliary/util/u_gen_mipmap.c | 2 +- src/gallium/drivers/cell/spu/spu_tri.c | 2 +- src/gallium/state_trackers/glx/xlib/glx_api.c | 8 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 8 +- src/mesa/drivers/common/meta.c | 6 +- src/mesa/drivers/dri/i915/i915_context.c | 2 +- src/mesa/drivers/dri/i915/i915_debug.c | 178 ++++++------ src/mesa/drivers/dri/i915/i915_debug_fp.c | 80 +++--- src/mesa/drivers/dri/i915/i915_tex_layout.c | 4 +- src/mesa/drivers/dri/i915/intel_tris.c | 8 +- src/mesa/drivers/dri/i965/brw_context.c | 4 +- src/mesa/drivers/dri/i965/brw_curbe.c | 26 +- src/mesa/drivers/dri/i965/brw_draw.c | 4 +- src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 +- src/mesa/drivers/dri/i965/brw_eu_debug.c | 14 +- src/mesa/drivers/dri/i965/brw_eu_emit.c | 4 +- src/mesa/drivers/dri/i965/brw_state_cache.c | 10 +- src/mesa/drivers/dri/i965/brw_urb.c | 6 +- src/mesa/drivers/dri/i965/brw_vs_emit.c | 14 +- src/mesa/drivers/dri/i965/brw_wm_debug.c | 68 ++--- src/mesa/drivers/dri/i965/brw_wm_emit.c | 12 +- src/mesa/drivers/dri/i965/brw_wm_fp.c | 14 +- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 10 +- src/mesa/drivers/dri/i965/brw_wm_pass0.c | 4 +- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 4 +- src/mesa/drivers/dri/intel/intel_context.c | 2 +- src/mesa/drivers/dri/intel/intel_context.h | 2 +- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 4 +- src/mesa/drivers/dri/intel/intel_pixel_read.c | 14 +- src/mesa/drivers/dri/intel/intel_tex.c | 4 +- src/mesa/drivers/dri/nouveau/nouveau_driver.h | 2 +- src/mesa/drivers/dri/r300/r300_fragprog_common.c | 2 +- src/mesa/drivers/dri/r300/r300_render.c | 2 +- src/mesa/drivers/dri/r300/r300_state.c | 2 +- src/mesa/drivers/dri/r600/r700_state.c | 2 +- src/mesa/drivers/dri/radeon/radeon_fbo.c | 2 +- src/mesa/drivers/dri/swrast/swrast_priv.h | 4 +- src/mesa/drivers/x11/fakeglx.c | 10 +- src/mesa/drivers/x11/xm_api.c | 12 +- src/mesa/drivers/x11/xm_tri.c | 92 +++---- src/mesa/glapi/gl_enums.py | 2 +- src/mesa/main/arrayobj.c | 10 +- src/mesa/main/bufferobj.c | 8 +- src/mesa/main/debug.c | 56 ++-- src/mesa/main/dlist.c | 130 ++++----- src/mesa/main/enums.c | 2 +- src/mesa/main/execmem.c | 2 +- src/mesa/main/fbobject.c | 50 ++-- src/mesa/main/ffvertex_prog.c | 8 +- src/mesa/main/imports.c | 67 +---- src/mesa/main/imports.h | 16 -- src/mesa/main/mipmap.c | 2 +- src/mesa/main/shaders.c | 2 +- src/mesa/main/state.c | 2 +- src/mesa/main/texenvprogram.c | 2 +- src/mesa/main/teximage.c | 4 +- src/mesa/main/texobj.c | 6 +- src/mesa/main/texstate.c | 38 +-- src/mesa/main/texstore.c | 20 +- src/mesa/main/varray.c | 18 +- src/mesa/main/version.c | 4 +- src/mesa/math/m_debug_clip.c | 44 +-- src/mesa/math/m_debug_norm.c | 34 +-- src/mesa/math/m_debug_xform.c | 32 +-- src/mesa/math/m_vector.c | 16 +- src/mesa/shader/arbprogparse.c | 4 +- src/mesa/shader/nvfragparse.c | 6 +- src/mesa/shader/nvvertparse.c | 6 +- src/mesa/shader/prog_execute.c | 4 +- src/mesa/shader/prog_instruction.c | 2 +- src/mesa/shader/prog_optimize.c | 62 ++--- src/mesa/shader/prog_print.c | 330 +++++++++++------------ src/mesa/shader/prog_statevars.c | 6 +- src/mesa/shader/program_parse.tab.c | 6 +- src/mesa/shader/program_parse.y | 6 +- src/mesa/shader/shader_api.c | 36 +-- src/mesa/shader/slang/slang_codegen.c | 4 +- src/mesa/shader/slang/slang_emit.c | 4 +- src/mesa/shader/slang/slang_label.c | 2 +- src/mesa/shader/slang/slang_link.c | 26 +- src/mesa/shader/slang/slang_log.c | 6 +- src/mesa/shader/slang/slang_utility.c | 2 +- src/mesa/state_tracker/st_atom.c | 10 +- src/mesa/swrast/s_lines.c | 2 +- src/mesa/tnl/t_draw.c | 10 +- src/mesa/tnl/t_vb_cliptmp.h | 16 +- src/mesa/tnl/t_vertex.c | 10 +- src/mesa/tnl/t_vertex_sse.c | 8 +- src/mesa/vbo/vbo_exec_api.c | 6 +- src/mesa/vbo/vbo_exec_array.c | 70 ++--- src/mesa/vbo/vbo_exec_draw.c | 32 +-- src/mesa/vbo/vbo_rebase.c | 2 +- src/mesa/vbo/vbo_save_api.c | 8 +- src/mesa/vbo/vbo_save_draw.c | 2 +- src/mesa/vbo/vbo_save_loopback.c | 12 +- src/mesa/vbo/vbo_split_copy.c | 36 +-- src/mesa/vf/vf.c | 10 +- src/mesa/vf/vf_sse.c | 8 +- src/mesa/x86/rtasm/x86sse.c | 2 +- 99 files changed, 951 insertions(+), 1032 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 4e358d3938..1d7329d422 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1069,7 +1069,7 @@ reduce_3d(enum pipe_format pformat, */ /* - _mesa_printf("mip3d %d x %d x %d -> %d x %d x %d\n", + printf("mip3d %d x %d x %d -> %d x %d x %d\n", srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth); */ diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c index 58be001be4..f619380d80 100644 --- a/src/gallium/drivers/cell/spu/spu_tri.c +++ b/src/gallium/drivers/cell/spu/spu_tri.c @@ -752,7 +752,7 @@ subtriangle(struct edge *eleft, struct edge *eright, unsigned lines) finish_y -= sy; /* - _mesa_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y); + printf("%s %d %d\n", __FUNCTION__, start_y, finish_y); */ for (y = start_y; y < finish_y; y++) { diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 0932569bd3..656a69131e 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -1679,8 +1679,8 @@ PUBLIC const char * glXQueryServerString( Display *dpy, int screen, int name ) { static char version[1000]; - _mesa_sprintf(version, "%d.%d %s", - SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); + sprintf(version, "%d.%d %s", + SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); (void) dpy; (void) screen; @@ -1704,8 +1704,8 @@ PUBLIC const char * glXGetClientString( Display *dpy, int name ) { static char version[1000]; - _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, - CLIENT_MINOR_VERSION, MESA_GLX_VERSION); + sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, + CLIENT_MINOR_VERSION, MESA_GLX_VERSION); (void) dpy; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 61af663436..a274da0c62 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -550,10 +550,10 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, * reports bugs. */ if (_mesa_getenv("MESA_INFO")) { - _mesa_printf("X/Mesa visual = %p\n", (void *) v); - _mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level); - _mesa_printf("X/Mesa depth = %d\n", v->visinfo->depth); - _mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); + printf("X/Mesa visual = %p\n", (void *) v); + printf("X/Mesa level = %d\n", v->mesa_visual.level); + printf("X/Mesa depth = %d\n", v->visinfo->depth); + printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); } if (b && window) { diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 42ab7d4ed6..3aa70ddbf0 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1047,7 +1047,7 @@ init_blit_depth_pixels(GLcontext *ctx) texTarget = "RECT"; else texTarget = "2D"; - _mesa_snprintf(program2, sizeof(program2), program, texTarget); + snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenPrograms(1, &blit->DepthFP); _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, blit->DepthFP); @@ -1670,7 +1670,7 @@ init_draw_stencil_pixels(GLcontext *ctx) texTarget = "RECT"; else texTarget = "2D"; - _mesa_snprintf(program2, sizeof(program2), program, texTarget); + snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenPrograms(1, &drawpix->StencilFP); _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->StencilFP); @@ -1704,7 +1704,7 @@ init_draw_depth_pixels(GLcontext *ctx) texTarget = "RECT"; else texTarget = "2D"; - _mesa_snprintf(program2, sizeof(program2), program, texTarget); + snprintf(program2, sizeof(program2), program, texTarget); _mesa_GenPrograms(1, &drawpix->DepthFP); _mesa_BindProgram(GL_FRAGMENT_PROGRAM_ARB, drawpix->DepthFP); diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index ed9a44ff24..4d86aae87d 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -108,7 +108,7 @@ i915CreateContext(const __GLcontextModes * mesaVis, return GL_FALSE; if (0) - _mesa_printf("\ntexmem-0-3 branch\n\n"); + printf("\ntexmem-0-3 branch\n\n"); i915InitVtbl(i915); diff --git a/src/mesa/drivers/dri/i915/i915_debug.c b/src/mesa/drivers/dri/i915/i915_debug.c index fecfac3033..4569fb918e 100644 --- a/src/mesa/drivers/dri/i915/i915_debug.c +++ b/src/mesa/drivers/dri/i915/i915_debug.c @@ -31,27 +31,25 @@ #include "i915_context.h" #include "i915_debug.h" -#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) - static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len ) { GLuint i; GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { - PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + printf("Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return GL_FALSE; } if (stream->print_addresses) - PRINTF("%08x: ", stream->offset); + printf("%08x: ", stream->offset); - PRINTF("%s (%d dwords):\n", name, len); + printf("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - PRINTF("\t0x%08x\n", ptr[i]); - PRINTF("\n"); + printf("\t0x%08x\n", ptr[i]); + printf("\n"); stream->offset += len * sizeof(GLuint); @@ -88,17 +86,17 @@ static GLboolean debug_prim( struct debug_stream *stream, const char *name, - PRINTF("%s %s (%d dwords):\n", name, prim, len); - PRINTF("\t0x%08x\n", ptr[0]); + printf("%s %s (%d dwords):\n", name, prim, len); + printf("\t0x%08x\n", ptr[0]); for (i = 1; i < len; i++) { if (dump_floats) - PRINTF("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + printf("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); else - PRINTF("\t0x%08x\n", ptr[i]); + printf("\t0x%08x\n", ptr[i]); } - PRINTF("\n"); + printf("\n"); stream->offset += len * sizeof(GLuint); @@ -113,15 +111,15 @@ static GLboolean debug_program( struct debug_stream *stream, const char *name, G GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { - PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + printf("Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return GL_FALSE; } if (stream->print_addresses) - PRINTF("%08x: ", stream->offset); + printf("%08x: ", stream->offset); - PRINTF("%s (%d dwords):\n", name, len); + printf("%s (%d dwords):\n", name, len); i915_disassemble_program( ptr, len ); stream->offset += len * sizeof(GLuint); @@ -135,17 +133,17 @@ static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLu GLuint old_offset = stream->offset + len * sizeof(GLuint); GLuint i; - PRINTF("%s (%d dwords):\n", name, len); + printf("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - PRINTF("\t0x%08x\n", ptr[i]); + printf("\t0x%08x\n", ptr[i]); stream->offset = ptr[1] & ~0x3; if (stream->offset < old_offset) - PRINTF("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", + printf("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); else - PRINTF("\n... skipping from 0x%x --> 0x%x ...\n\n", + printf("\n... skipping from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); @@ -165,10 +163,10 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) len = 1+(i+2)/2; - PRINTF("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); + printf("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); for (i = 0; i < len; i++) - PRINTF("\t0x%08x\n", ptr[i]); - PRINTF("\n"); + printf("\t0x%08x\n", ptr[i]); + printf("\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE; @@ -178,9 +176,9 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) #define BITS( dw, hi, lo, ... ) \ do { \ unsigned himask = 0xffffffffU >> (31 - (hi)); \ - PRINTF("\t\t "); \ - PRINTF(__VA_ARGS__); \ - PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \ + printf("\t\t "); \ + printf(__VA_ARGS__); \ + printf(": 0x%x\n", ((dw) & himask) >> (lo)); \ } while (0) #define MBZ( dw, hi, lo) do { \ @@ -194,9 +192,9 @@ do { \ #define FLAG( dw, bit, ... ) \ do { \ if (((dw) >> (bit)) & 1) { \ - PRINTF("\t\t "); \ - PRINTF(__VA_ARGS__); \ - PRINTF("\n"); \ + printf("\t\t "); \ + printf(__VA_ARGS__); \ + printf("\n"); \ } \ } while (0) @@ -208,17 +206,17 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, GLuint bits = (ptr[0] >> 4) & 0xff; GLuint j = 0; - PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords, flags: %x):\n", name, len, bits); + printf("\t0x%08x\n", ptr[j++]); if (bits & (1<<0)) { - PRINTF("\t LIS0: 0x%08x\n", ptr[j]); - PRINTF("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); + printf("\t LIS0: 0x%08x\n", ptr[j]); + printf("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); BITS(ptr[j], 0, 0, "vb invalidate disable"); j++; } if (bits & (1<<1)) { - PRINTF("\t LIS1: 0x%08x\n", ptr[j]); + printf("\t LIS1: 0x%08x\n", ptr[j]); BITS(ptr[j], 29, 24, "vb dword width"); BITS(ptr[j], 21, 16, "vb dword pitch"); BITS(ptr[j], 15, 0, "vb max index"); @@ -226,7 +224,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, } if (bits & (1<<2)) { int i; - PRINTF("\t LIS2: 0x%08x\n", ptr[j]); + printf("\t LIS2: 0x%08x\n", ptr[j]); for (i = 0; i < 8; i++) { unsigned tc = (ptr[j] >> (i * 4)) & 0xf; if (tc != 0xf) @@ -235,11 +233,11 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<3)) { - PRINTF("\t LIS3: 0x%08x\n", ptr[j]); + printf("\t LIS3: 0x%08x\n", ptr[j]); j++; } if (bits & (1<<4)) { - PRINTF("\t LIS4: 0x%08x\n", ptr[j]); + printf("\t LIS4: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 23, "point width"); BITS(ptr[j], 22, 19, "line width"); FLAG(ptr[j], 18, "alpha flatshade"); @@ -261,7 +259,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<5)) { - PRINTF("\t LIS5: 0x%08x\n", ptr[j]); + printf("\t LIS5: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 28, "rgba write disables"); FLAG(ptr[j], 27, "force dflt point width"); FLAG(ptr[j], 26, "last pixel enable"); @@ -279,7 +277,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<6)) { - PRINTF("\t LIS6: 0x%08x\n", ptr[j]); + printf("\t LIS6: 0x%08x\n", ptr[j]); FLAG(ptr[j], 31, "alpha test enable"); BITS(ptr[j], 30, 28, "alpha func"); BITS(ptr[j], 27, 20, "alpha ref"); @@ -296,7 +294,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, } - PRINTF("\n"); + printf("\n"); assert(j == len); @@ -315,34 +313,34 @@ static GLboolean debug_load_indirect( struct debug_stream *stream, GLuint bits = (ptr[0] >> 8) & 0x3f; GLuint i, j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); for (i = 0; i < 6; i++) { if (bits & (1<ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR2223(stream, ptr[j], ptr[j+1]); @@ -460,8 +458,8 @@ static GLboolean debug_color_blit( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR2223(stream, ptr[j], ptr[j+1]); @@ -481,8 +479,8 @@ static GLboolean debug_modes4( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j]); BITS(ptr[j], 21, 18, "logicop func"); FLAG(ptr[j], 17, "stencil test mask modify-enable"); FLAG(ptr[j], 16, "stencil write mask modify-enable"); @@ -502,26 +500,26 @@ static GLboolean debug_map_state( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); + printf("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "map mask"); j++; } while (j < len) { { - PRINTF("\t TMn.0: 0x%08x\n", ptr[j]); - PRINTF("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); + printf("\t TMn.0: 0x%08x\n", ptr[j]); + printf("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); FLAG(ptr[j], 1, "vertical line stride"); FLAG(ptr[j], 0, "vertical line stride offset"); j++; } { - PRINTF("\t TMn.1: 0x%08x\n", ptr[j]); + printf("\t TMn.1: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 21, "height"); BITS(ptr[j], 20, 10, "width"); BITS(ptr[j], 9, 7, "surface format"); @@ -532,7 +530,7 @@ static GLboolean debug_map_state( struct debug_stream *stream, j++; } { - PRINTF("\t TMn.2: 0x%08x\n", ptr[j]); + printf("\t TMn.2: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 21, "dword pitch"); BITS(ptr[j], 20, 15, "cube face enables"); BITS(ptr[j], 14, 9, "max lod"); @@ -554,18 +552,18 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); + printf("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "sampler mask"); j++; } while (j < len) { { - PRINTF("\t TSn.0: 0x%08x\n", ptr[j]); + printf("\t TSn.0: 0x%08x\n", ptr[j]); FLAG(ptr[j], 31, "reverse gamma"); FLAG(ptr[j], 30, "planar to packed"); FLAG(ptr[j], 29, "yuv->rgb"); @@ -582,7 +580,7 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, } { - PRINTF("\t TSn.1: 0x%08x\n", ptr[j]); + printf("\t TSn.1: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 24, "min lod"); MBZ( ptr[j], 23, 18 ); FLAG(ptr[j], 17, "kill pixel enable"); @@ -597,7 +595,7 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, j++; } { - PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); + printf("\t TSn.2: 0x%08x (default color)\n", ptr[j]); j++; } } @@ -614,11 +612,11 @@ static GLboolean debug_dest_vars( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); + printf("\t0x%08x\n", ptr[j]); FLAG(ptr[j], 31, "early classic ztest"); FLAG(ptr[j], 30, "opengl tex default color"); FLAG(ptr[j], 29, "bypass iz"); @@ -649,11 +647,11 @@ static GLboolean debug_buf_info( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - PRINTF("%s (%d dwords):\n", name, len); - PRINTF("\t0x%08x\n", ptr[j++]); + printf("%s (%d dwords):\n", name, len); + printf("\t0x%08x\n", ptr[j++]); { - PRINTF("\t0x%08x\n", ptr[j]); + printf("\t0x%08x\n", ptr[j]); BITS(ptr[j], 28, 28, "aux buffer id"); BITS(ptr[j], 27, 24, "buffer id (7=depth, 3=back)"); FLAG(ptr[j], 23, "use fence regs"); @@ -665,7 +663,7 @@ static GLboolean debug_buf_info( struct debug_stream *stream, j++; } - PRINTF("\t0x%08x -- buffer base address\n", ptr[j++]); + printf("\t0x%08x -- buffer base address\n", ptr[j++]); stream->offset += len * sizeof(GLuint); assert(j == len); @@ -826,7 +824,7 @@ i915_dump_batchbuffer( GLuint *start, GLuint bytes = (end - start) * 4; GLboolean done = GL_FALSE; - PRINTF("\n\nBATCH: (%d)\n", bytes / 4); + printf("\n\nBATCH: (%d)\n", bytes / 4); stream.offset = 0; stream.ptr = (char *)start; @@ -843,7 +841,7 @@ i915_dump_batchbuffer( GLuint *start, stream.offset >= 0); } - PRINTF("END-BATCH\n\n\n"); + printf("END-BATCH\n\n\n"); } diff --git a/src/mesa/drivers/dri/i915/i915_debug_fp.c b/src/mesa/drivers/dri/i915/i915_debug_fp.c index bf500e54fa..adfc9e8945 100644 --- a/src/mesa/drivers/dri/i915/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915/i915_debug_fp.c @@ -31,8 +31,6 @@ #include "i915_debug.h" #include "main/imports.h" -#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) - static const char *opcodes[0x20] = { "NOP", "ADD", @@ -123,27 +121,27 @@ print_reg_type_nr(GLuint type, GLuint nr) case REG_TYPE_T: switch (nr) { case T_DIFFUSE: - PRINTF("T_DIFFUSE"); + printf("T_DIFFUSE"); return; case T_SPECULAR: - PRINTF("T_SPECULAR"); + printf("T_SPECULAR"); return; case T_FOG_W: - PRINTF("T_FOG_W"); + printf("T_FOG_W"); return; default: - PRINTF("T_TEX%d", nr); + printf("T_TEX%d", nr); return; } case REG_TYPE_OC: if (nr == 0) { - PRINTF("oC"); + printf("oC"); return; } break; case REG_TYPE_OD: if (nr == 0) { - PRINTF("oD"); + printf("oD"); return; } break; @@ -151,7 +149,7 @@ print_reg_type_nr(GLuint type, GLuint nr) break; } - PRINTF("%s[%d]", regname[type], nr); + printf("%s[%d]", regname[type], nr); } #define REG_SWIZZLE_MASK 0x7777 @@ -172,33 +170,33 @@ print_reg_neg_swizzle(GLuint reg) (reg & REG_NEGATE_MASK) == 0) return; - PRINTF("."); + printf("."); for (i = 3; i >= 0; i--) { if (reg & (1 << ((i * 4) + 3))) - PRINTF("-"); + printf("-"); switch ((reg >> (i * 4)) & 0x7) { case 0: - PRINTF("x"); + printf("x"); break; case 1: - PRINTF("y"); + printf("y"); break; case 2: - PRINTF("z"); + printf("z"); break; case 3: - PRINTF("w"); + printf("w"); break; case 4: - PRINTF("0"); + printf("0"); break; case 5: - PRINTF("1"); + printf("1"); break; default: - PRINTF("?"); + printf("?"); break; } } @@ -223,15 +221,15 @@ print_dest_reg(GLuint dword) print_reg_type_nr(type, nr); if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) return; - PRINTF("."); + printf("."); if (dword & A0_DEST_CHANNEL_X) - PRINTF("x"); + printf("x"); if (dword & A0_DEST_CHANNEL_Y) - PRINTF("y"); + printf("y"); if (dword & A0_DEST_CHANNEL_Z) - PRINTF("z"); + printf("z"); if (dword & A0_DEST_CHANNEL_W) - PRINTF("w"); + printf("w"); } @@ -246,29 +244,29 @@ print_arith_op(GLuint opcode, const GLuint * program) if (opcode != A0_NOP) { print_dest_reg(program[0]); if (program[0] & A0_DEST_SATURATE) - PRINTF(" = SATURATE "); + printf(" = SATURATE "); else - PRINTF(" = "); + printf(" = "); } - PRINTF("%s ", opcodes[opcode]); + printf("%s ", opcodes[opcode]); print_src_reg(GET_SRC0_REG(program[0], program[1])); if (args[opcode] == 1) { - PRINTF("\n"); + printf("\n"); return; } - PRINTF(", "); + printf(", "); print_src_reg(GET_SRC1_REG(program[1], program[2])); if (args[opcode] == 2) { - PRINTF("\n"); + printf("\n"); return; } - PRINTF(", "); + printf(", "); print_src_reg(GET_SRC2_REG(program[2])); - PRINTF("\n"); + printf("\n"); return; } @@ -277,24 +275,24 @@ static void print_tex_op(GLuint opcode, const GLuint * program) { print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - PRINTF(" = "); + printf(" = "); - PRINTF("%s ", opcodes[opcode]); + printf("%s ", opcodes[opcode]); - PRINTF("S[%d],", program[0] & T0_SAMPLER_NR_MASK); + printf("S[%d],", program[0] & T0_SAMPLER_NR_MASK); print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK, (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - PRINTF("\n"); + printf("\n"); } static void print_dcl_op(GLuint opcode, const GLuint * program) { - PRINTF("%s ", opcodes[opcode]); + printf("%s ", opcodes[opcode]); print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - PRINTF("\n"); + printf("\n"); } @@ -304,7 +302,7 @@ i915_disassemble_program(const GLuint * program, GLuint sz) GLuint size = program[0] & 0x1ff; GLint i; - PRINTF("\t\tBEGIN\n"); + printf("\t\tBEGIN\n"); assert(size + 2 == sz); @@ -312,7 +310,7 @@ i915_disassemble_program(const GLuint * program, GLuint sz) for (i = 1; i < sz; i += 3, program += 3) { GLuint opcode = program[0] & (0x1f << 24); - PRINTF("\t\t"); + printf("\t\t"); if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) print_arith_op(opcode >> 24, program); @@ -321,10 +319,10 @@ i915_disassemble_program(const GLuint * program, GLuint sz) else if (opcode == D0_DCL) print_dcl_op(opcode >> 24, program); else - PRINTF("Unknown opcode 0x%x\n", opcode); + printf("Unknown opcode 0x%x\n", opcode); } - PRINTF("\t\tEND\n\n"); + printf("\t\tEND\n\n"); } diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c index d9588e5b56..fe3908f580 100644 --- a/src/mesa/drivers/dri/i915/i915_tex_layout.c +++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c @@ -145,8 +145,8 @@ i915_miptree_layout_cube(struct intel_context *intel, intel_miptree_set_image_offset(mt, level, face, x, y); if (d == 0) - _mesa_printf("cube mipmap %d/%d (%d..%d) is 0x0\n", - face, level, mt->first_level, mt->last_level); + printf("cube mipmap %d/%d (%d..%d) is 0x0\n", + face, level, mt->first_level, mt->last_level); d >>= 1; x += step_offsets[face][0] * d; diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 6d498c5654..3816adae94 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -66,7 +66,7 @@ intel_flush_inline_primitive(struct intel_context *intel) assert(intel->prim.primitive != ~0); -/* _mesa_printf("/\n"); */ +/* printf("/\n"); */ if (used < 8) goto do_discard; @@ -93,7 +93,7 @@ static void intel_start_inline(struct intel_context *intel, uint32_t prim) intel->no_batch_wrap = GL_TRUE; - /*_mesa_printf("%s *", __progname);*/ + /*printf("%s *", __progname);*/ /* Emit a slot which will be filled with the inline primitive * command later. @@ -111,7 +111,7 @@ static void intel_start_inline(struct intel_context *intel, uint32_t prim) ADVANCE_BATCH(); intel->no_batch_wrap = GL_FALSE; -/* _mesa_printf(">"); */ +/* printf(">"); */ } static void intel_wrap_inline(struct intel_context *intel) @@ -133,7 +133,7 @@ static GLuint *intel_extend_inline(struct intel_context *intel, GLuint dwords) if (intel_batchbuffer_space(intel->batch) < sz) intel_wrap_inline(intel); -/* _mesa_printf("."); */ +/* printf("."); */ intel->vtbl.assert_not_dirty(intel); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 65f51be341..2ca29b7ae1 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -78,7 +78,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, GLcontext *ctx = &intel->ctx; if (!brw) { - _mesa_printf("%s: failed to alloc context\n", __FUNCTION__); + printf("%s: failed to alloc context\n", __FUNCTION__); return GL_FALSE; } @@ -87,7 +87,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, if (!intelInitContext( intel, mesaVis, driContextPriv, sharedContextPrivate, &functions )) { - _mesa_printf("%s: failed to init intel context\n", __FUNCTION__); + printf("%s: failed to init intel context\n", __FUNCTION__); FREE(brw); return GL_FALSE; } diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c index cb9cd836a0..6f2ead793d 100644 --- a/src/mesa/drivers/dri/i965/brw_curbe.c +++ b/src/mesa/drivers/dri/i965/brw_curbe.c @@ -114,13 +114,13 @@ static void calculate_curbe_offsets( struct brw_context *brw ) brw->curbe.total_size = reg; if (0) - _mesa_printf("curbe wm %d+%d clip %d+%d vs %d+%d\n", - brw->curbe.wm_start, - brw->curbe.wm_size, - brw->curbe.clip_start, - brw->curbe.clip_size, - brw->curbe.vs_start, - brw->curbe.vs_size ); + printf("curbe wm %d+%d clip %d+%d vs %d+%d\n", + brw->curbe.wm_start, + brw->curbe.wm_size, + brw->curbe.clip_start, + brw->curbe.clip_size, + brw->curbe.vs_start, + brw->curbe.vs_size ); brw->state.dirty.brw |= BRW_NEW_CURBE_OFFSETS; } @@ -280,13 +280,13 @@ static void prepare_constant_buffer(struct brw_context *brw) if (0) { for (i = 0; i < sz*16; i+=4) - _mesa_printf("curbe %d.%d: %f %f %f %f\n", i/8, i&4, - buf[i+0], buf[i+1], buf[i+2], buf[i+3]); + printf("curbe %d.%d: %f %f %f %f\n", i/8, i&4, + buf[i+0], buf[i+1], buf[i+2], buf[i+3]); - _mesa_printf("last_buf %p buf %p sz %d/%d cmp %d\n", - brw->curbe.last_buf, buf, - bufsz, brw->curbe.last_bufsz, - brw->curbe.last_buf ? memcmp(buf, brw->curbe.last_buf, bufsz) : -1); + printf("last_buf %p buf %p sz %d/%d cmp %d\n", + brw->curbe.last_buf, buf, + bufsz, brw->curbe.last_bufsz, + brw->curbe.last_buf ? memcmp(buf, brw->curbe.last_buf, bufsz) : -1); } if (brw->curbe.curbe_bo != NULL && diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 976249091e..e348d4686b 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -82,7 +82,7 @@ static GLuint brw_set_prim(struct brw_context *brw, GLenum prim) GLcontext *ctx = &brw->intel.ctx; if (INTEL_DEBUG & DEBUG_PRIMS) - _mesa_printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim)); + printf("PRIM: %s\n", _mesa_lookup_enum_by_nr(prim)); /* Slight optimization to avoid the GS program when not needed: */ @@ -125,7 +125,7 @@ static void brw_emit_prim(struct brw_context *brw, struct intel_context *intel = &brw->intel; if (INTEL_DEBUG & DEBUG_PRIMS) - _mesa_printf("PRIM: %s %d %d\n", _mesa_lookup_enum_by_nr(prim->mode), + printf("PRIM: %s %d %d\n", _mesa_lookup_enum_by_nr(prim->mode), prim->start, prim->count); prim_packet.header.opcode = CMD_3D_PRIM; diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index ceaeb923b0..106454de4a 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -169,7 +169,7 @@ static GLuint get_surface_type( GLenum type, GLuint size, GLenum format, GLboolean normalized ) { if (INTEL_DEBUG & DEBUG_VERTS) - _mesa_printf("type %s size %d normalized %d\n", + printf("type %s size %d normalized %d\n", _mesa_lookup_enum_by_nr(type), size, normalized); if (normalized) { @@ -355,7 +355,7 @@ static void brw_prepare_vertices(struct brw_context *brw) /* First build an array of pointers to ve's in vb.inputs_read */ if (0) - _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); + printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); /* Accumulate the list of enabled arrays. */ brw->vb.nr_enabled = 0; diff --git a/src/mesa/drivers/dri/i965/brw_eu_debug.c b/src/mesa/drivers/dri/i965/brw_eu_debug.c index 29f3f6d02f..99453afdca 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_debug.c +++ b/src/mesa/drivers/dri/i965/brw_eu_debug.c @@ -54,9 +54,9 @@ void brw_print_reg( struct brw_reg hwreg ) "f" }; - _mesa_printf("%s%s", - hwreg.abs ? "abs/" : "", - hwreg.negate ? "-" : ""); + printf("%s%s", + hwreg.abs ? "abs/" : "", + hwreg.negate ? "-" : ""); if (hwreg.file == BRW_GENERAL_REGISTER_FILE && hwreg.nr % 2 == 0 && @@ -66,7 +66,7 @@ void brw_print_reg( struct brw_reg hwreg ) hwreg.hstride == BRW_HORIZONTAL_STRIDE_1 && hwreg.type == BRW_REGISTER_TYPE_F) { /* vector register */ - _mesa_printf("vec%d", hwreg.nr); + printf("vec%d", hwreg.nr); } else if (hwreg.file == BRW_GENERAL_REGISTER_FILE && hwreg.vstride == BRW_VERTICAL_STRIDE_0 && @@ -74,13 +74,13 @@ void brw_print_reg( struct brw_reg hwreg ) hwreg.hstride == BRW_HORIZONTAL_STRIDE_0 && hwreg.type == BRW_REGISTER_TYPE_F) { /* "scalar" register */ - _mesa_printf("scl%d.%d", hwreg.nr, hwreg.subnr / 4); + printf("scl%d.%d", hwreg.nr, hwreg.subnr / 4); } else if (hwreg.file == BRW_IMMEDIATE_VALUE) { - _mesa_printf("imm %f", hwreg.dw1.f); + printf("imm %f", hwreg.dw1.f); } else { - _mesa_printf("%s%d.%d<%d;%d,%d>:%s", + printf("%s%d.%d<%d;%d,%d>:%s", file[hwreg.file], hwreg.nr, hwreg.subnr / type_sz(hwreg.type), diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 8d6ac00839..b832c7165d 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1272,7 +1272,7 @@ void brw_SAMPLE(struct brw_compile *p, GLboolean need_stall = 0; if (writemask == 0) { - /*_mesa_printf("%s: zero writemask??\n", __FUNCTION__); */ + /*printf("%s: zero writemask??\n", __FUNCTION__); */ return; } @@ -1304,7 +1304,7 @@ void brw_SAMPLE(struct brw_compile *p, if (newmask != writemask) { need_stall = 1; - /* _mesa_printf("need stall %x %x\n", newmask , writemask); */ + /* printf("need stall %x %x\n", newmask , writemask); */ } else { struct brw_reg m1 = brw_message_reg(msg_reg_nr); diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index dd9894d681..4bb98d8d5d 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -266,7 +266,7 @@ brw_upload_cache_with_auxdata(struct brw_cache *cache, } if (INTEL_DEBUG & DEBUG_STATE) - _mesa_printf("upload %s: %d bytes to cache id %d\n", + printf("upload %s: %d bytes to cache id %d\n", cache->name[cache_id], data_size, cache_id); @@ -425,7 +425,7 @@ brw_clear_cache(struct brw_context *brw, struct brw_cache *cache) GLuint i; if (INTEL_DEBUG & DEBUG_STATE) - _mesa_printf("%s\n", __FUNCTION__); + printf("%s\n", __FUNCTION__); for (i = 0; i < cache->size; i++) { for (c = cache->items[i]; c; c = next) { @@ -465,7 +465,7 @@ brw_state_cache_bo_delete(struct brw_cache *cache, dri_bo *bo) GLuint i; if (INTEL_DEBUG & DEBUG_STATE) - _mesa_printf("%s\n", __FUNCTION__); + printf("%s\n", __FUNCTION__); for (i = 0; i < cache->size; i++) { for (prev = &cache->items[i]; *prev;) { @@ -493,7 +493,7 @@ void brw_state_cache_check_size(struct brw_context *brw) { if (INTEL_DEBUG & DEBUG_STATE) - _mesa_printf("%s (n_items=%d)\n", __FUNCTION__, brw->cache.n_items); + printf("%s (n_items=%d)\n", __FUNCTION__, brw->cache.n_items); /* un-tuned guess. We've got around 20 state objects for a total of around * 32k, so 1000 of them is around 1.5MB. @@ -512,7 +512,7 @@ brw_destroy_cache(struct brw_context *brw, struct brw_cache *cache) GLuint i; if (INTEL_DEBUG & DEBUG_STATE) - _mesa_printf("%s\n", __FUNCTION__); + printf("%s\n", __FUNCTION__); brw_clear_cache(brw, cache); for (i = 0; i < BRW_MAX_CACHE; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_urb.c b/src/mesa/drivers/dri/i965/brw_urb.c index f2cdb203b8..4f6b9002ad 100644 --- a/src/mesa/drivers/dri/i965/brw_urb.c +++ b/src/mesa/drivers/dri/i965/brw_urb.c @@ -186,17 +186,17 @@ static void recalculate_urb_fence( struct brw_context *brw ) * entries and the values for minimum nr of entries * provided above. */ - _mesa_printf("couldn't calculate URB layout!\n"); + printf("couldn't calculate URB layout!\n"); exit(1); } if (INTEL_DEBUG & (DEBUG_URB|DEBUG_FALLBACKS)) - _mesa_printf("URB CONSTRAINED\n"); + printf("URB CONSTRAINED\n"); } done: if (INTEL_DEBUG & DEBUG_URB) - _mesa_printf("URB fence: %d ..VS.. %d ..GS.. %d ..CLP.. %d ..SF.. %d ..CS.. %d\n", + printf("URB fence: %d ..VS.. %d ..GS.. %d ..CLP.. %d ..SF.. %d ..CS.. %d\n", brw->urb.vs_start, brw->urb.gs_start, brw->urb.clip_start, diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 4f4eef85e8..88327d9927 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -287,9 +287,9 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c ) c->prog_data.total_grf = reg; if (INTEL_DEBUG & DEBUG_VS) { - _mesa_printf("%s NumAddrRegs %d\n", __FUNCTION__, c->vp->program.Base.NumAddressRegs); - _mesa_printf("%s NumTemps %d\n", __FUNCTION__, c->vp->program.Base.NumTemporaries); - _mesa_printf("%s reg = %d\n", __FUNCTION__, reg); + printf("%s NumAddrRegs %d\n", __FUNCTION__, c->vp->program.Base.NumAddressRegs); + printf("%s NumTemps %d\n", __FUNCTION__, c->vp->program.Base.NumTemporaries); + printf("%s reg = %d\n", __FUNCTION__, reg); } } @@ -1444,9 +1444,9 @@ void brw_vs_emit(struct brw_vs_compile *c ) GLuint file; if (INTEL_DEBUG & DEBUG_VS) { - _mesa_printf("vs-mesa:\n"); + printf("vs-mesa:\n"); _mesa_print_program(&c->vp->program.Base); - _mesa_printf("\n"); + printf("\n"); } brw_set_compression_control(p, BRW_COMPRESSION_NONE); @@ -1796,9 +1796,9 @@ void brw_vs_emit(struct brw_vs_compile *c ) if (INTEL_DEBUG & DEBUG_VS) { int i; - _mesa_printf("vs-native:\n"); + printf("vs-native:\n"); for (i = 0; i < p->nr_insn; i++) brw_disasm(stderr, &p->store[i]); - _mesa_printf("\n"); + printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_debug.c b/src/mesa/drivers/dri/i965/brw_wm_debug.c index 220821087c..a78cc8b54e 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_debug.c +++ b/src/mesa/drivers/dri/i965/brw_wm_debug.c @@ -41,21 +41,21 @@ void brw_wm_print_value( struct brw_wm_compile *c, if (c->state >= PASS2_DONE) brw_print_reg(value->hw_reg); else if( value == &c->undef_value ) - _mesa_printf("undef"); + printf("undef"); else if( value - c->vreg >= 0 && value - c->vreg < BRW_WM_MAX_VREG) - _mesa_printf("r%d", value - c->vreg); + printf("r%d", value - c->vreg); else if (value - c->creg >= 0 && value - c->creg < BRW_WM_MAX_PARAM) - _mesa_printf("c%d", value - c->creg); + printf("c%d", value - c->creg); else if (value - c->payload.input_interp >= 0 && value - c->payload.input_interp < FRAG_ATTRIB_MAX) - _mesa_printf("i%d", value - c->payload.input_interp); + printf("i%d", value - c->payload.input_interp); else if (value - c->payload.depth >= 0 && value - c->payload.depth < FRAG_ATTRIB_MAX) - _mesa_printf("d%d", value - c->payload.depth); + printf("d%d", value - c->payload.depth); else - _mesa_printf("?"); + printf("?"); } void brw_wm_print_ref( struct brw_wm_compile *c, @@ -64,16 +64,16 @@ void brw_wm_print_ref( struct brw_wm_compile *c, struct brw_reg hw_reg = ref->hw_reg; if (ref->unspill_reg) - _mesa_printf("UNSPILL(%x)/", ref->value->spill_slot); + printf("UNSPILL(%x)/", ref->value->spill_slot); if (c->state >= PASS2_DONE) brw_print_reg(ref->hw_reg); else { - _mesa_printf("%s", hw_reg.negate ? "-" : ""); - _mesa_printf("%s", hw_reg.abs ? "abs/" : ""); + printf("%s", hw_reg.negate ? "-" : ""); + printf("%s", hw_reg.abs ? "abs/" : ""); brw_wm_print_value(c, ref->value); if ((hw_reg.nr&1) || hw_reg.subnr) { - _mesa_printf("->%d.%d", (hw_reg.nr&1), hw_reg.subnr); + printf("->%d.%d", (hw_reg.nr&1), hw_reg.subnr); } } } @@ -84,22 +84,22 @@ void brw_wm_print_insn( struct brw_wm_compile *c, GLuint i, arg; GLuint nr_args = brw_wm_nr_args(inst->opcode); - _mesa_printf("["); + printf("["); for (i = 0; i < 4; i++) { if (inst->dst[i]) { brw_wm_print_value(c, inst->dst[i]); if (inst->dst[i]->spill_slot) - _mesa_printf("/SPILL(%x)",inst->dst[i]->spill_slot); + printf("/SPILL(%x)",inst->dst[i]->spill_slot); } else - _mesa_printf("#"); + printf("#"); if (i < 3) - _mesa_printf(","); + printf(","); } - _mesa_printf("]"); + printf("]"); if (inst->writemask != WRITEMASK_XYZW) - _mesa_printf(".%s%s%s%s", + printf(".%s%s%s%s", GET_BIT(inst->writemask, 0) ? "x" : "", GET_BIT(inst->writemask, 1) ? "y" : "", GET_BIT(inst->writemask, 2) ? "z" : "", @@ -107,58 +107,58 @@ void brw_wm_print_insn( struct brw_wm_compile *c, switch (inst->opcode) { case WM_PIXELXY: - _mesa_printf(" = PIXELXY"); + printf(" = PIXELXY"); break; case WM_DELTAXY: - _mesa_printf(" = DELTAXY"); + printf(" = DELTAXY"); break; case WM_PIXELW: - _mesa_printf(" = PIXELW"); + printf(" = PIXELW"); break; case WM_WPOSXY: - _mesa_printf(" = WPOSXY"); + printf(" = WPOSXY"); break; case WM_PINTERP: - _mesa_printf(" = PINTERP"); + printf(" = PINTERP"); break; case WM_LINTERP: - _mesa_printf(" = LINTERP"); + printf(" = LINTERP"); break; case WM_CINTERP: - _mesa_printf(" = CINTERP"); + printf(" = CINTERP"); break; case WM_FB_WRITE: - _mesa_printf(" = FB_WRITE"); + printf(" = FB_WRITE"); break; case WM_FRONTFACING: - _mesa_printf(" = FRONTFACING"); + printf(" = FRONTFACING"); break; default: - _mesa_printf(" = %s", _mesa_opcode_string(inst->opcode)); + printf(" = %s", _mesa_opcode_string(inst->opcode)); break; } if (inst->saturate) - _mesa_printf("_SAT"); + printf("_SAT"); for (arg = 0; arg < nr_args; arg++) { - _mesa_printf(" ["); + printf(" ["); for (i = 0; i < 4; i++) { if (inst->src[arg][i]) { brw_wm_print_ref(c, inst->src[arg][i]); } else - _mesa_printf("%%"); + printf("%%"); if (i < 3) - _mesa_printf(","); + printf(","); else - _mesa_printf("]"); + printf("]"); } } - _mesa_printf("\n"); + printf("\n"); } void brw_wm_print_program( struct brw_wm_compile *c, @@ -166,9 +166,9 @@ void brw_wm_print_program( struct brw_wm_compile *c, { GLuint insn; - _mesa_printf("%s:\n", stage); + printf("%s:\n", stage); for (insn = 0; insn < c->nr_insns; insn++) brw_wm_print_insn(c, &c->instruction[insn]); - _mesa_printf("\n"); + printf("\n"); } diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index fa0898c586..9315bca315 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -1622,10 +1622,10 @@ void brw_wm_emit( struct brw_wm_compile *c ) break; default: - _mesa_printf("Unsupported opcode %i (%s) in fragment shader\n", - inst->opcode, inst->opcode < MAX_OPCODE ? - _mesa_opcode_string(inst->opcode) : - "unknown"); + printf("Unsupported opcode %i (%s) in fragment shader\n", + inst->opcode, inst->opcode < MAX_OPCODE ? + _mesa_opcode_string(inst->opcode) : + "unknown"); } for (i = 0; i < 4; i++) @@ -1638,9 +1638,9 @@ void brw_wm_emit( struct brw_wm_compile *c ) if (INTEL_DEBUG & DEBUG_WM) { int i; - _mesa_printf("wm-native:\n"); + printf("wm-native:\n"); for (i = 0; i < p->nr_insn; i++) brw_disasm(stderr, &p->store[i]); - _mesa_printf("\n"); + printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index 3737faf26f..d73c391582 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -159,7 +159,7 @@ static struct prog_dst_register get_temp( struct brw_wm_compile *c ) int bit = _mesa_ffs( ~c->fp_temp ); if (!bit) { - _mesa_printf("%s: out of temporaries\n", __FILE__); + printf("%s: out of temporaries\n", __FILE__); exit(1); } @@ -1034,7 +1034,7 @@ static void print_insns( const struct prog_instruction *insn, { GLuint i; for (i = 0; i < nr; i++, insn++) { - _mesa_printf("%3d: ", i); + printf("%3d: ", i); if (insn->Opcode < MAX_OPCODE) _mesa_print_instruction(insn); else if (insn->Opcode < MAX_WM_OPCODE) { @@ -1045,7 +1045,7 @@ static void print_insns( const struct prog_instruction *insn, 3); } else - _mesa_printf("965 Opcode %d\n", insn->Opcode); + printf("965 Opcode %d\n", insn->Opcode); } } @@ -1060,9 +1060,9 @@ void brw_wm_pass_fp( struct brw_wm_compile *c ) GLuint insn; if (INTEL_DEBUG & DEBUG_WM) { - _mesa_printf("pre-fp:\n"); + printf("pre-fp:\n"); _mesa_print_program(&fp->program.Base); - _mesa_printf("\n"); + printf("\n"); } c->pixel_xy = src_undef(); @@ -1168,9 +1168,9 @@ void brw_wm_pass_fp( struct brw_wm_compile *c ) } if (INTEL_DEBUG & DEBUG_WM) { - _mesa_printf("pass_fp:\n"); + printf("pass_fp:\n"); print_insns( c->prog_instructions, c->nr_fp_insns ); - _mesa_printf("\n"); + printf("\n"); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index fde83eea62..562608e2ec 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -1849,7 +1849,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) c->cur_inst = i; #if 0 - _mesa_printf("Inst %d: ", i); + printf("Inst %d: ", i); _mesa_print_instruction(inst); #endif @@ -2115,7 +2115,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) } break; default: - _mesa_printf("unsupported IR in fragment shader %d\n", + printf("unsupported IR in fragment shader %d\n", inst->Opcode); } @@ -2127,10 +2127,10 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) post_wm_emit(c); if (INTEL_DEBUG & DEBUG_WM) { - _mesa_printf("wm-native:\n"); + printf("wm-native:\n"); for (i = 0; i < p->nr_insn; i++) brw_disasm(stderr, &p->store[i]); - _mesa_printf("\n"); + printf("\n"); } } @@ -2141,7 +2141,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c) { if (INTEL_DEBUG & DEBUG_WM) { - _mesa_printf("brw_wm_glsl_emit:\n"); + printf("brw_wm_glsl_emit:\n"); } /* initial instruction translation/simplification */ diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass0.c b/src/mesa/drivers/dri/i965/brw_wm_pass0.c index ff4c082d5e..60bd92ed22 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_pass0.c +++ b/src/mesa/drivers/dri/i965/brw_wm_pass0.c @@ -105,7 +105,7 @@ static const struct brw_wm_ref *get_param_ref( struct brw_wm_compile *c, GLuint i = c->prog_data.nr_params++; if (i >= BRW_WM_MAX_PARAM) { - _mesa_printf("%s: out of params\n", __FUNCTION__); + printf("%s: out of params\n", __FUNCTION__); c->prog_data.error = 1; return NULL; } @@ -154,7 +154,7 @@ static const struct brw_wm_ref *get_const_ref( struct brw_wm_compile *c, return c->constref[i].ref; } else { - _mesa_printf("%s: out of constrefs\n", __FUNCTION__); + printf("%s: out of constrefs\n", __FUNCTION__); c->prog_data.error = 1; return NULL; } diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index ae0f8a16f9..c9841724ee 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -209,8 +209,8 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch, int ret; if (batch->ptr - batch->map > batch->buf->size) - _mesa_printf ("bad relocation ptr %p map %p offset %d size %d\n", - batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size); + printf ("bad relocation ptr %p map %p offset %d size %d\n", + batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size); ret = dri_bo_emit_reloc(batch->buf, read_domains, write_domain, delta, batch->ptr - batch->map, buffer); diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 8f37fb82c1..3a0830a85b 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -592,7 +592,7 @@ intelInitContext(struct intel_context *intel, if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx, functions, (void *) intel)) { - _mesa_printf("%s: failed to init mesa context\n", __FUNCTION__); + printf("%s: failed to init mesa context\n", __FUNCTION__); return GL_FALSE; } diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index da5d901abf..d20d44497e 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -345,7 +345,7 @@ extern int INTEL_DEBUG; #define DBG(...) do { \ if (INTEL_DEBUG & FILE_DEBUG_FLAG) \ - _mesa_printf(__VA_ARGS__); \ + printf(__VA_ARGS__); \ } while(0) #define PCI_CHIP_845_G 0x2562 diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 54998a63f6..076fee89bd 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -123,7 +123,7 @@ static GLuint get_bitmap_rect(GLsizei width, GLsizei height, GLuint count = 0; if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n", + printf("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n", __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask); if (invert) { @@ -516,7 +516,7 @@ intelBitmap(GLcontext * ctx, return; if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: fallback to swrast\n", __FUNCTION__); + printf("%s: fallback to swrast\n", __FUNCTION__); _swrast_Bitmap(ctx, x, y, width, height, unpack, pixels); } diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index 514a17e2aa..2ac3da7f42 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -80,7 +80,7 @@ do_blit_readpixels(GLcontext * ctx, GLint dst_x, dst_y; if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s\n", __FUNCTION__); + printf("%s\n", __FUNCTION__); if (!src) return GL_FALSE; @@ -89,7 +89,7 @@ do_blit_readpixels(GLcontext * ctx, /* PBO only for now: */ if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - not PBO\n", __FUNCTION__); + printf("%s - not PBO\n", __FUNCTION__); return GL_FALSE; } @@ -97,13 +97,13 @@ do_blit_readpixels(GLcontext * ctx, if (ctx->_ImageTransferState || !intel_check_blit_format(src, format, type)) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - bad format for blit\n", __FUNCTION__); + printf("%s - bad format for blit\n", __FUNCTION__); return GL_FALSE; } if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: bad packing params\n", __FUNCTION__); + printf("%s: bad packing params\n", __FUNCTION__); return GL_FALSE; } @@ -114,7 +114,7 @@ do_blit_readpixels(GLcontext * ctx, if (pack->Invert) { if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__); + printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__); return GL_FALSE; } else { @@ -159,7 +159,7 @@ do_blit_readpixels(GLcontext * ctx, } if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s - DONE\n", __FUNCTION__); + printf("%s - DONE\n", __FUNCTION__); return GL_TRUE; } @@ -181,7 +181,7 @@ intelReadPixels(GLcontext * ctx, return; if (INTEL_DEBUG & DEBUG_PIXEL) - _mesa_printf("%s: fallback to swrast\n", __FUNCTION__); + printf("%s: fallback to swrast\n", __FUNCTION__); /* Update Mesa state before calling down into _swrast_ReadPixels, as * the spans code requires the computed buffer states to be up to date, diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index 215a534a5c..8bb6ae99fb 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -146,7 +146,7 @@ timed_memcpy(void *dest, const void *src, size_t n) double rate; if ((((unsigned) src) & 63) || (((unsigned) dest) & 63)) - _mesa_printf("Warning - non-aligned texture copy!\n"); + printf("Warning - non-aligned texture copy!\n"); t1 = fastrdtsc(); ret = do_memcpy(dest, src, n); @@ -154,7 +154,7 @@ timed_memcpy(void *dest, const void *src, size_t n) rate = time_diff(t1, t2); rate /= (double) n; - _mesa_printf("timed_memcpy: %u %u --> %f clocks/byte\n", t1, t2, rate); + printf("timed_memcpy: %u %u --> %f clocks/byte\n", t1, t2, rate); return ret; } #endif /* DO_DEBUG */ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.h b/src/mesa/drivers/dri/nouveau/nouveau_driver.h index 54bf981a0f..283f6eac2c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.h @@ -70,7 +70,7 @@ struct nouveau_driver { }; #define nouveau_error(format, ...) \ - _mesa_fprintf(stderr, "%s: " format, __func__, ## __VA_ARGS__) + fprintf(stderr, "%s: " format, __func__, ## __VA_ARGS__) void nouveau_clear(GLcontext *ctx, GLbitfield buffers); diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c index a5810ee500..61ea5e4d9a 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c @@ -227,7 +227,7 @@ static void translate_fragment_program(GLcontext *ctx, struct r300_fragment_prog if (compiler.Base.Debug) { fflush(stderr); - _mesa_printf("Fragment Program: Initial program:\n"); + printf("Fragment Program: Initial program:\n"); _mesa_print_program(&cont->Base.Base); fflush(stderr); } diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index e3e6285784..9596131486 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -440,7 +440,7 @@ void r300SwitchFallback(GLcontext *ctx, uint32_t bit, GLboolean mode) if (mode) { if ((fallback_warn & bit) == 0) { if (RADEON_DEBUG & RADEON_FALLBACKS) - _mesa_fprintf(stderr, "WARNING! Falling back to software for %s\n", getFallbackString(bit)); + fprintf(stderr, "WARNING! Falling back to software for %s\n", getFallbackString(bit)); fallback_warn |= bit; } rmesa->fallback |= bit; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 017d45a503..9d1ff6e2ba 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1970,7 +1970,7 @@ void r300UpdateShaders(r300ContextPtr rmesa) /* should only happenen once, just after context is created */ /* TODO: shouldn't we fallback to sw here? */ if (!ctx->FragmentProgram._Current) { - _mesa_fprintf(stderr, "No ctx->FragmentProgram._Current!!\n"); + fprintf(stderr, "No ctx->FragmentProgram._Current!!\n"); return; } diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 0240eefd5c..4ebdbbfad2 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -65,7 +65,7 @@ void r700UpdateShaders(GLcontext * ctx) /* should only happenen once, just after context is created */ /* TODO: shouldn't we fallback to sw here? */ if (!ctx->FragmentProgram._Current) { - _mesa_fprintf(stderr, "No ctx->FragmentProgram._Current!!\n"); + fprintf(stderr, "No ctx->FragmentProgram._Current!!\n"); return; } diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c index a8931e8478..3b066f5eef 100644 --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c @@ -43,7 +43,7 @@ #define FILE_DEBUG_FLAG RADEON_TEXTURE #define DBG(...) do { \ if (RADEON_DEBUG & FILE_DEBUG_FLAG) \ - _mesa_printf(__VA_ARGS__); \ + printf(__VA_ARGS__); \ } while(0) static struct gl_framebuffer * diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 1a5fb31d5a..59b4a6d228 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -43,13 +43,13 @@ #define DEBUG_SPAN 0 #if DEBUG_CORE -#define TRACE _mesa_printf("--> %s\n", __FUNCTION__) +#define TRACE printf("--> %s\n", __FUNCTION__) #else #define TRACE #endif #if DEBUG_SPAN -#define TRACE_SPAN _mesa_printf("--> %s\n", __FUNCTION__) +#define TRACE_SPAN printf("--> %s\n", __FUNCTION__) #else #define TRACE_SPAN #endif diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index f097d93a71..33a3ff6d5f 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -53,7 +53,7 @@ #include "xmesaP.h" #ifdef __VMS -#define _mesa_sprintf sprintf +#define sprintf sprintf #endif /* This indicates the client-side GLX API and GLX encoder version. */ @@ -2032,8 +2032,8 @@ static const char * Fake_glXQueryServerString( Display *dpy, int screen, int name ) { static char version[1000]; - _mesa_sprintf(version, "%d.%d %s", - SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); + sprintf(version, "%d.%d %s", + SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); (void) dpy; (void) screen; @@ -2057,8 +2057,8 @@ static const char * Fake_glXGetClientString( Display *dpy, int name ) { static char version[1000]; - _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, - CLIENT_MINOR_VERSION, MESA_GLX_VERSION); + sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, + CLIENT_MINOR_VERSION, MESA_GLX_VERSION); (void) dpy; diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index ed945023cf..3711c88148 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1110,12 +1110,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, * reports bugs. */ if (_mesa_getenv("MESA_INFO")) { - _mesa_printf("X/Mesa visual = %p\n", (void *) v); - _mesa_printf("X/Mesa dithered pf = %u\n", v->dithered_pf); - _mesa_printf("X/Mesa undithered pf = %u\n", v->undithered_pf); - _mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level); - _mesa_printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v)); - _mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); + printf("X/Mesa visual = %p\n", (void *) v); + printf("X/Mesa dithered pf = %u\n", v->dithered_pf); + printf("X/Mesa undithered pf = %u\n", v->undithered_pf); + printf("X/Mesa level = %d\n", v->mesa_visual.level); + printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v)); + printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); } if (b && window) { diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c index 3a0cf80139..a6efb35e3c 100644 --- a/src/mesa/drivers/x11/xm_tri.c +++ b/src/mesa/drivers/x11/xm_tri.c @@ -1330,97 +1330,97 @@ extern void _xmesa_print_triangle_func( swrast_tri_func triFunc ); void _xmesa_print_triangle_func( swrast_tri_func triFunc ) { - _mesa_printf("XMesa tri func = "); + printf("XMesa tri func = "); if (triFunc ==smooth_TRUECOLOR_z_triangle) - _mesa_printf("smooth_TRUECOLOR_z_triangle\n"); + printf("smooth_TRUECOLOR_z_triangle\n"); else if (triFunc ==smooth_8A8B8G8R_z_triangle) - _mesa_printf("smooth_8A8B8G8R_z_triangle\n"); + printf("smooth_8A8B8G8R_z_triangle\n"); else if (triFunc ==smooth_8A8R8G8B_z_triangle) - _mesa_printf("smooth_8A8R8G8B_z_triangle\n"); + printf("smooth_8A8R8G8B_z_triangle\n"); else if (triFunc ==smooth_8R8G8B_z_triangle) - _mesa_printf("smooth_8R8G8B_z_triangle\n"); + printf("smooth_8R8G8B_z_triangle\n"); else if (triFunc ==smooth_8R8G8B24_z_triangle) - _mesa_printf("smooth_8R8G8B24_z_triangle\n"); + printf("smooth_8R8G8B24_z_triangle\n"); else if (triFunc ==smooth_TRUEDITHER_z_triangle) - _mesa_printf("smooth_TRUEDITHER_z_triangle\n"); + printf("smooth_TRUEDITHER_z_triangle\n"); else if (triFunc ==smooth_5R6G5B_z_triangle) - _mesa_printf("smooth_5R6G5B_z_triangle\n"); + printf("smooth_5R6G5B_z_triangle\n"); else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle) - _mesa_printf("smooth_DITHER_5R6G5B_z_triangle\n"); + printf("smooth_DITHER_5R6G5B_z_triangle\n"); else if (triFunc ==smooth_HPCR_z_triangle) - _mesa_printf("smooth_HPCR_z_triangle\n"); + printf("smooth_HPCR_z_triangle\n"); else if (triFunc ==smooth_DITHER8_z_triangle) - _mesa_printf("smooth_DITHER8_z_triangle\n"); + printf("smooth_DITHER8_z_triangle\n"); else if (triFunc ==smooth_LOOKUP8_z_triangle) - _mesa_printf("smooth_LOOKUP8_z_triangle\n"); + printf("smooth_LOOKUP8_z_triangle\n"); else if (triFunc ==flat_TRUECOLOR_z_triangle) - _mesa_printf("flat_TRUECOLOR_z_triangle\n"); + printf("flat_TRUECOLOR_z_triangle\n"); else if (triFunc ==flat_8A8B8G8R_z_triangle) - _mesa_printf("flat_8A8B8G8R_z_triangle\n"); + printf("flat_8A8B8G8R_z_triangle\n"); else if (triFunc ==flat_8A8R8G8B_z_triangle) - _mesa_printf("flat_8A8R8G8B_z_triangle\n"); + printf("flat_8A8R8G8B_z_triangle\n"); else if (triFunc ==flat_8R8G8B_z_triangle) - _mesa_printf("flat_8R8G8B_z_triangle\n"); + printf("flat_8R8G8B_z_triangle\n"); else if (triFunc ==flat_8R8G8B24_z_triangle) - _mesa_printf("flat_8R8G8B24_z_triangle\n"); + printf("flat_8R8G8B24_z_triangle\n"); else if (triFunc ==flat_TRUEDITHER_z_triangle) - _mesa_printf("flat_TRUEDITHER_z_triangle\n"); + printf("flat_TRUEDITHER_z_triangle\n"); else if (triFunc ==flat_5R6G5B_z_triangle) - _mesa_printf("flat_5R6G5B_z_triangle\n"); + printf("flat_5R6G5B_z_triangle\n"); else if (triFunc ==flat_DITHER_5R6G5B_z_triangle) - _mesa_printf("flat_DITHER_5R6G5B_z_triangle\n"); + printf("flat_DITHER_5R6G5B_z_triangle\n"); else if (triFunc ==flat_HPCR_z_triangle) - _mesa_printf("flat_HPCR_z_triangle\n"); + printf("flat_HPCR_z_triangle\n"); else if (triFunc ==flat_DITHER8_z_triangle) - _mesa_printf("flat_DITHER8_z_triangle\n"); + printf("flat_DITHER8_z_triangle\n"); else if (triFunc ==flat_LOOKUP8_z_triangle) - _mesa_printf("flat_LOOKUP8_z_triangle\n"); + printf("flat_LOOKUP8_z_triangle\n"); else if (triFunc ==smooth_TRUECOLOR_triangle) - _mesa_printf("smooth_TRUECOLOR_triangle\n"); + printf("smooth_TRUECOLOR_triangle\n"); else if (triFunc ==smooth_8A8B8G8R_triangle) - _mesa_printf("smooth_8A8B8G8R_triangle\n"); + printf("smooth_8A8B8G8R_triangle\n"); else if (triFunc ==smooth_8A8R8G8B_triangle) - _mesa_printf("smooth_8A8R8G8B_triangle\n"); + printf("smooth_8A8R8G8B_triangle\n"); else if (triFunc ==smooth_8R8G8B_triangle) - _mesa_printf("smooth_8R8G8B_triangle\n"); + printf("smooth_8R8G8B_triangle\n"); else if (triFunc ==smooth_8R8G8B24_triangle) - _mesa_printf("smooth_8R8G8B24_triangle\n"); + printf("smooth_8R8G8B24_triangle\n"); else if (triFunc ==smooth_TRUEDITHER_triangle) - _mesa_printf("smooth_TRUEDITHER_triangle\n"); + printf("smooth_TRUEDITHER_triangle\n"); else if (triFunc ==smooth_5R6G5B_triangle) - _mesa_printf("smooth_5R6G5B_triangle\n"); + printf("smooth_5R6G5B_triangle\n"); else if (triFunc ==smooth_DITHER_5R6G5B_triangle) - _mesa_printf("smooth_DITHER_5R6G5B_triangle\n"); + printf("smooth_DITHER_5R6G5B_triangle\n"); else if (triFunc ==smooth_HPCR_triangle) - _mesa_printf("smooth_HPCR_triangle\n"); + printf("smooth_HPCR_triangle\n"); else if (triFunc ==smooth_DITHER8_triangle) - _mesa_printf("smooth_DITHER8_triangle\n"); + printf("smooth_DITHER8_triangle\n"); else if (triFunc ==smooth_LOOKUP8_triangle) - _mesa_printf("smooth_LOOKUP8_triangle\n"); + printf("smooth_LOOKUP8_triangle\n"); else if (triFunc ==flat_TRUECOLOR_triangle) - _mesa_printf("flat_TRUECOLOR_triangle\n"); + printf("flat_TRUECOLOR_triangle\n"); else if (triFunc ==flat_TRUEDITHER_triangle) - _mesa_printf("flat_TRUEDITHER_triangle\n"); + printf("flat_TRUEDITHER_triangle\n"); else if (triFunc ==flat_8A8B8G8R_triangle) - _mesa_printf("flat_8A8B8G8R_triangle\n"); + printf("flat_8A8B8G8R_triangle\n"); else if (triFunc ==flat_8A8R8G8B_triangle) - _mesa_printf("flat_8A8R8G8B_triangle\n"); + printf("flat_8A8R8G8B_triangle\n"); else if (triFunc ==flat_8R8G8B_triangle) - _mesa_printf("flat_8R8G8B_triangle\n"); + printf("flat_8R8G8B_triangle\n"); else if (triFunc ==flat_8R8G8B24_triangle) - _mesa_printf("flat_8R8G8B24_triangle\n"); + printf("flat_8R8G8B24_triangle\n"); else if (triFunc ==flat_5R6G5B_triangle) - _mesa_printf("flat_5R6G5B_triangle\n"); + printf("flat_5R6G5B_triangle\n"); else if (triFunc ==flat_DITHER_5R6G5B_triangle) - _mesa_printf("flat_DITHER_5R6G5B_triangle\n"); + printf("flat_DITHER_5R6G5B_triangle\n"); else if (triFunc ==flat_HPCR_triangle) - _mesa_printf("flat_HPCR_triangle\n"); + printf("flat_HPCR_triangle\n"); else if (triFunc ==flat_DITHER8_triangle) - _mesa_printf("flat_DITHER8_triangle\n"); + printf("flat_DITHER8_triangle\n"); else if (triFunc ==flat_LOOKUP8_triangle) - _mesa_printf("flat_LOOKUP8_triangle\n"); + printf("flat_LOOKUP8_triangle\n"); else - _mesa_printf("???\n"); + printf("???\n"); } #endif diff --git a/src/mesa/glapi/gl_enums.py b/src/mesa/glapi/gl_enums.py index adb0ca526c..3a9ea3c86c 100644 --- a/src/mesa/glapi/gl_enums.py +++ b/src/mesa/glapi/gl_enums.py @@ -105,7 +105,7 @@ const char *_mesa_lookup_enum_by_nr( int nr ) } else { /* this is not re-entrant safe, no big deal here */ - _mesa_sprintf(token_tmp, "0x%x", nr); + sprintf(token_tmp, "0x%x", nr); return token_tmp; } } diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 3a1fd37324..7feaee316d 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -295,11 +295,11 @@ compute_max_element(struct gl_client_array *array) - (GLsizeiptrARB) array->Ptr + array->StrideB - array->_ElementSize) / array->StrideB; if (0) - _mesa_printf("%s Object %u Size %u MaxElement %u\n", - __FUNCTION__, - array->BufferObj->Name, - (GLuint) array->BufferObj->Size, - array->_MaxElement); + printf("%s Object %u Size %u MaxElement %u\n", + __FUNCTION__, + array->BufferObj->Name, + (GLuint) array->BufferObj->Size, + array->_MaxElement); } else { /* user-space array, no idea how big it is */ diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 816465cea1..971b280f3b 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1155,7 +1155,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, bufObj->Written = GL_TRUE; #ifdef VBO_DEBUG - _mesa_printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n", + printf("glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n", bufObj->Name, size, data, usage); #endif @@ -1272,8 +1272,8 @@ _mesa_MapBufferARB(GLenum target, GLenum access) bufObj->Written = GL_TRUE; #ifdef VBO_DEBUG - _mesa_printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", - bufObj->Name, bufObj->Size, access); + printf("glMapBufferARB(%u, sz %ld, access 0x%x)\n", + bufObj->Name, bufObj->Size, access); if (access == GL_WRITE_ONLY_ARB) { GLuint i; GLubyte *b = (GLubyte *) bufObj->Pointer; @@ -1349,7 +1349,7 @@ _mesa_UnmapBufferARB(GLenum target) } } if (unchanged) { - _mesa_printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n", + printf("glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n", bufObj->Name, unchanged, bufObj->Size, pos); } } diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 79b63e940f..246dbd436d 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -314,9 +314,9 @@ write_texture_image(struct gl_texture_object *texObj, buffer, texObj, img); /* make filename */ - _mesa_sprintf(s, "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); + sprintf(s, "/tmp/tex%u.l%u.f%u.ppm", texObj->Name, level, face); - _mesa_printf(" Writing image level %u to %s\n", level, s); + printf(" Writing image level %u to %s\n", level, s); write_ppm(s, buffer, img->Width, img->Height, 4, 0, 1, 2, GL_FALSE); ctx->Pack = store; /* restore */ @@ -356,9 +356,9 @@ write_renderbuffer_image(const struct gl_renderbuffer *rb) format, type, &ctx->DefaultPacking, buffer); /* make filename */ - _mesa_sprintf(s, "/tmp/renderbuffer%u.ppm", rb->Name); + sprintf(s, "/tmp/renderbuffer%u.ppm", rb->Name); - _mesa_printf(" Writing renderbuffer image to %s\n", s); + printf(" Writing renderbuffer image to %s\n", s); write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE); free(buffer); @@ -380,17 +380,17 @@ dump_texture(struct gl_texture_object *texObj, GLuint writeImages) GLboolean written = GL_FALSE; GLuint i, j; - _mesa_printf("Texture %u\n", texObj->Name); - _mesa_printf(" Target %s\n", tex_target_name(texObj->Target)); + printf("Texture %u\n", texObj->Name); + printf(" Target %s\n", tex_target_name(texObj->Target)); for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { for (j = 0; j < numFaces; j++) { struct gl_texture_image *texImg = texObj->Image[j][i]; if (texImg) { - _mesa_printf(" Face %u level %u: %d x %d x %d, format %s at %p\n", - j, i, - texImg->Width, texImg->Height, texImg->Depth, - _mesa_get_format_name(texImg->TexFormat), - texImg->Data); + printf(" Face %u level %u: %d x %d x %d, format %s at %p\n", + j, i, + texImg->Width, texImg->Height, texImg->Depth, + _mesa_get_format_name(texImg->TexFormat), + texImg->Data); if (writeImages == WRITE_ALL || (writeImages == WRITE_ONE && !written)) { write_texture_image(texObj, j, i); @@ -441,9 +441,9 @@ _mesa_dump_textures(GLuint writeImages) static void dump_renderbuffer(const struct gl_renderbuffer *rb, GLboolean writeImage) { - _mesa_printf("Renderbuffer %u: %u x %u IntFormat = %s\n", - rb->Name, rb->Width, rb->Height, - _mesa_lookup_enum_by_nr(rb->InternalFormat)); + printf("Renderbuffer %u: %u x %u IntFormat = %s\n", + rb->Name, rb->Width, rb->Height, + _mesa_lookup_enum_by_nr(rb->InternalFormat)); if (writeImage) { write_renderbuffer_image(rb); } @@ -489,12 +489,12 @@ _mesa_dump_color_buffer(const char *filename) _mesa_ReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, buf); - _mesa_printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n", - ctx->ReadBuffer->_ColorReadBuffer, - ctx->ReadBuffer->ColorReadBuffer, - ctx->DrawBuffer->_ColorDrawBuffers[0], - ctx->DrawBuffer->ColorDrawBuffer[0]); - _mesa_printf("Writing %d x %d color buffer to %s\n", w, h, filename); + printf("ReadBuffer %p 0x%x DrawBuffer %p 0x%x\n", + ctx->ReadBuffer->_ColorReadBuffer, + ctx->ReadBuffer->ColorReadBuffer, + ctx->DrawBuffer->_ColorDrawBuffers[0], + ctx->DrawBuffer->ColorDrawBuffer[0]); + printf("Writing %d x %d color buffer to %s\n", w, h, filename); write_ppm(filename, buf, w, h, 4, 0, 1, 2, GL_TRUE); _mesa_PopClientAttrib(); @@ -529,7 +529,7 @@ _mesa_dump_depth_buffer(const char *filename) buf2[i*3+2] = (buf[i] >> 8) & 0xff; } - _mesa_printf("Writing %d x %d depth buffer to %s\n", w, h, filename); + printf("Writing %d x %d depth buffer to %s\n", w, h, filename); write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE); _mesa_PopClientAttrib(); @@ -564,7 +564,7 @@ _mesa_dump_stencil_buffer(const char *filename) buf2[i*3+2] = (buf[i] - 128) * 2; } - _mesa_printf("Writing %d x %d stencil buffer to %s\n", w, h, filename); + printf("Writing %d x %d stencil buffer to %s\n", w, h, filename); write_ppm(filename, buf2, w, h, 3, 0, 1, 2, GL_TRUE); _mesa_PopClientAttrib(); @@ -587,7 +587,7 @@ _mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img) const GLubyte *data = (const GLubyte *) img->Data; if (!data) { - _mesa_printf("No texture data\n"); + printf("No texture data\n"); return; } @@ -619,17 +619,17 @@ _mesa_print_texture(GLcontext *ctx, const struct gl_texture_image *img) for (i = 0; i < img->Height; i++) { for (j = 0; j < img->Width; j++) { if (c==1) - _mesa_printf("%02x ", data[0]); + printf("%02x ", data[0]); else if (c==2) - _mesa_printf("%02x%02x ", data[0], data[1]); + printf("%02x%02x ", data[0], data[1]); else if (c==3) - _mesa_printf("%02x%02x%02x ", data[0], data[1], data[2]); + printf("%02x%02x%02x ", data[0], data[1], data[2]); else if (c==4) - _mesa_printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]); + printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]); data += (img->RowStride - img->Width) * c; } /* XXX use img->ImageStride here */ - _mesa_printf("\n"); + printf("\n"); } #endif } diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 87b8ddacc2..9ef7fcae90 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -7685,7 +7685,7 @@ execute_list(GLcontext *ctx, GLuint list) default: { char msg[1000]; - _mesa_sprintf(msg, "Error in execute_list: opcode=%d", + sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode); _mesa_problem(ctx, msg); } @@ -9320,7 +9320,7 @@ print_list(GLcontext *ctx, GLuint list) GLboolean done; if (!islist(ctx, list)) { - _mesa_printf("%u is not a display list ID\n", list); + printf("%u is not a display list ID\n", list); return; } @@ -9330,7 +9330,7 @@ print_list(GLcontext *ctx, GLuint list) n = dlist->Head; - _mesa_printf("START-LIST %u, address %p\n", list, (void *) n); + printf("START-LIST %u, address %p\n", list, (void *) n); done = n ? GL_FALSE : GL_TRUE; while (!done) { @@ -9342,196 +9342,196 @@ print_list(GLcontext *ctx, GLuint list) else { switch (opcode) { case OPCODE_ACCUM: - _mesa_printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); + printf("Accum %s %g\n", enum_string(n[1].e), n[2].f); break; case OPCODE_BITMAP: - _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, + printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data); break; case OPCODE_CALL_LIST: - _mesa_printf("CallList %d\n", (int) n[1].ui); + printf("CallList %d\n", (int) n[1].ui); break; case OPCODE_CALL_LIST_OFFSET: - _mesa_printf("CallList %d + offset %u = %u\n", (int) n[1].ui, + printf("CallList %d + offset %u = %u\n", (int) n[1].ui, ctx->List.ListBase, ctx->List.ListBase + n[1].ui); break; case OPCODE_COLOR_TABLE_PARAMETER_FV: - _mesa_printf("ColorTableParameterfv %s %s %f %f %f %f\n", + printf("ColorTableParameterfv %s %s %f %f %f %f\n", enum_string(n[1].e), enum_string(n[2].e), n[3].f, n[4].f, n[5].f, n[6].f); break; case OPCODE_COLOR_TABLE_PARAMETER_IV: - _mesa_printf("ColorTableParameteriv %s %s %d %d %d %d\n", + printf("ColorTableParameteriv %s %s %d %d %d %d\n", enum_string(n[1].e), enum_string(n[2].e), n[3].i, n[4].i, n[5].i, n[6].i); break; case OPCODE_DISABLE: - _mesa_printf("Disable %s\n", enum_string(n[1].e)); + printf("Disable %s\n", enum_string(n[1].e)); break; case OPCODE_ENABLE: - _mesa_printf("Enable %s\n", enum_string(n[1].e)); + printf("Enable %s\n", enum_string(n[1].e)); break; case OPCODE_FRUSTUM: - _mesa_printf("Frustum %g %g %g %g %g %g\n", + printf("Frustum %g %g %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); break; case OPCODE_LINE_STIPPLE: - _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); + printf("LineStipple %d %x\n", n[1].i, (int) n[2].us); break; case OPCODE_LOAD_IDENTITY: - _mesa_printf("LoadIdentity\n"); + printf("LoadIdentity\n"); break; case OPCODE_LOAD_MATRIX: - _mesa_printf("LoadMatrix\n"); - _mesa_printf(" %8f %8f %8f %8f\n", + printf("LoadMatrix\n"); + printf(" %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f); - _mesa_printf(" %8f %8f %8f %8f\n", + printf(" %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f); - _mesa_printf(" %8f %8f %8f %8f\n", + printf(" %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f); - _mesa_printf(" %8f %8f %8f %8f\n", + printf(" %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f); break; case OPCODE_MULT_MATRIX: - _mesa_printf("MultMatrix (or Rotate)\n"); - _mesa_printf(" %8f %8f %8f %8f\n", + printf("MultMatrix (or Rotate)\n"); + printf(" %8f %8f %8f %8f\n", n[1].f, n[5].f, n[9].f, n[13].f); - _mesa_printf(" %8f %8f %8f %8f\n", + printf(" %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f); - _mesa_printf(" %8f %8f %8f %8f\n", + printf(" %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f); - _mesa_printf(" %8f %8f %8f %8f\n", + printf(" %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f); break; case OPCODE_ORTHO: - _mesa_printf("Ortho %g %g %g %g %g %g\n", + printf("Ortho %g %g %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f); break; case OPCODE_POP_ATTRIB: - _mesa_printf("PopAttrib\n"); + printf("PopAttrib\n"); break; case OPCODE_POP_MATRIX: - _mesa_printf("PopMatrix\n"); + printf("PopMatrix\n"); break; case OPCODE_POP_NAME: - _mesa_printf("PopName\n"); + printf("PopName\n"); break; case OPCODE_PUSH_ATTRIB: - _mesa_printf("PushAttrib %x\n", n[1].bf); + printf("PushAttrib %x\n", n[1].bf); break; case OPCODE_PUSH_MATRIX: - _mesa_printf("PushMatrix\n"); + printf("PushMatrix\n"); break; case OPCODE_PUSH_NAME: - _mesa_printf("PushName %d\n", (int) n[1].ui); + printf("PushName %d\n", (int) n[1].ui); break; case OPCODE_RASTER_POS: - _mesa_printf("RasterPos %g %g %g %g\n", + printf("RasterPos %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f); break; case OPCODE_ROTATE: - _mesa_printf("Rotate %g %g %g %g\n", + printf("Rotate %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f); break; case OPCODE_SCALE: - _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); + printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f); break; case OPCODE_TRANSLATE: - _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); + printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f); break; case OPCODE_BIND_TEXTURE: - _mesa_printf("BindTexture %s %d\n", + printf("BindTexture %s %d\n", _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui); break; case OPCODE_SHADE_MODEL: - _mesa_printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); + printf("ShadeModel %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); break; case OPCODE_MAP1: - _mesa_printf("Map1 %s %.3f %.3f %d %d\n", + printf("Map1 %s %.3f %.3f %d %d\n", _mesa_lookup_enum_by_nr(n[1].ui), n[2].f, n[3].f, n[4].i, n[5].i); break; case OPCODE_MAP2: - _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", + printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n", _mesa_lookup_enum_by_nr(n[1].ui), n[2].f, n[3].f, n[4].f, n[5].f, n[6].i, n[7].i, n[8].i, n[9].i); break; case OPCODE_MAPGRID1: - _mesa_printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); + printf("MapGrid1 %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f); break; case OPCODE_MAPGRID2: - _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", + printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n", n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f); break; case OPCODE_EVALMESH1: - _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); + printf("EvalMesh1 %d %d\n", n[1].i, n[2].i); break; case OPCODE_EVALMESH2: - _mesa_printf("EvalMesh2 %d %d %d %d\n", + printf("EvalMesh2 %d %d %d %d\n", n[1].i, n[2].i, n[3].i, n[4].i); break; case OPCODE_ATTR_1F_NV: - _mesa_printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); + printf("ATTR_1F_NV attr %d: %f\n", n[1].i, n[2].f); break; case OPCODE_ATTR_2F_NV: - _mesa_printf("ATTR_2F_NV attr %d: %f %f\n", + printf("ATTR_2F_NV attr %d: %f %f\n", n[1].i, n[2].f, n[3].f); break; case OPCODE_ATTR_3F_NV: - _mesa_printf("ATTR_3F_NV attr %d: %f %f %f\n", + printf("ATTR_3F_NV attr %d: %f %f %f\n", n[1].i, n[2].f, n[3].f, n[4].f); break; case OPCODE_ATTR_4F_NV: - _mesa_printf("ATTR_4F_NV attr %d: %f %f %f %f\n", + printf("ATTR_4F_NV attr %d: %f %f %f %f\n", n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); break; case OPCODE_ATTR_1F_ARB: - _mesa_printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); + printf("ATTR_1F_ARB attr %d: %f\n", n[1].i, n[2].f); break; case OPCODE_ATTR_2F_ARB: - _mesa_printf("ATTR_2F_ARB attr %d: %f %f\n", + printf("ATTR_2F_ARB attr %d: %f %f\n", n[1].i, n[2].f, n[3].f); break; case OPCODE_ATTR_3F_ARB: - _mesa_printf("ATTR_3F_ARB attr %d: %f %f %f\n", + printf("ATTR_3F_ARB attr %d: %f %f %f\n", n[1].i, n[2].f, n[3].f, n[4].f); break; case OPCODE_ATTR_4F_ARB: - _mesa_printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", + printf("ATTR_4F_ARB attr %d: %f %f %f %f\n", n[1].i, n[2].f, n[3].f, n[4].f, n[5].f); break; case OPCODE_MATERIAL: - _mesa_printf("MATERIAL %x %x: %f %f %f %f\n", + printf("MATERIAL %x %x: %f %f %f %f\n", n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f); break; case OPCODE_BEGIN: - _mesa_printf("BEGIN %x\n", n[1].i); + printf("BEGIN %x\n", n[1].i); break; case OPCODE_END: - _mesa_printf("END\n"); + printf("END\n"); break; case OPCODE_RECTF: - _mesa_printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, + printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, n[4].f); break; case OPCODE_EVAL_C1: - _mesa_printf("EVAL_C1 %f\n", n[1].f); + printf("EVAL_C1 %f\n", n[1].f); break; case OPCODE_EVAL_C2: - _mesa_printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); + printf("EVAL_C2 %f %f\n", n[1].f, n[2].f); break; case OPCODE_EVAL_P1: - _mesa_printf("EVAL_P1 %d\n", n[1].i); + printf("EVAL_P1 %d\n", n[1].i); break; case OPCODE_EVAL_P2: - _mesa_printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); + printf("EVAL_P2 %d %d\n", n[1].i, n[2].i); break; case OPCODE_PROVOKING_VERTEX: - _mesa_printf("ProvokingVertex %s\n", + printf("ProvokingVertex %s\n", _mesa_lookup_enum_by_nr(n[1].ui)); break; @@ -9539,26 +9539,26 @@ print_list(GLcontext *ctx, GLuint list) * meta opcodes/commands */ case OPCODE_ERROR: - _mesa_printf("Error: %s %s\n", + printf("Error: %s %s\n", enum_string(n[1].e), (const char *) n[2].data); break; case OPCODE_CONTINUE: - _mesa_printf("DISPLAY-LIST-CONTINUE\n"); + printf("DISPLAY-LIST-CONTINUE\n"); n = (Node *) n[1].next; break; case OPCODE_END_OF_LIST: - _mesa_printf("END-LIST %u\n", list); + printf("END-LIST %u\n", list); done = GL_TRUE; break; default: if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { - _mesa_printf + printf ("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n", opcode, (void *) n); return; } else { - _mesa_printf("command %d, %u operands\n", opcode, + printf("command %d, %u operands\n", opcode, InstSize[opcode]); } } diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index fc7f8beb50..140902f677 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -5216,7 +5216,7 @@ const char *_mesa_lookup_enum_by_nr( int nr ) } else { /* this is not re-entrant safe, no big deal here */ - _mesa_sprintf(token_tmp, "0x%x", nr); + sprintf(token_tmp, "0x%x", nr); return token_tmp; } } diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c index 07a7f9fed8..ccd6ab43fc 100644 --- a/src/mesa/main/execmem.c +++ b/src/mesa/main/execmem.c @@ -106,7 +106,7 @@ _mesa_exec_malloc(GLuint size) if (block) addr = exec_mem + block->ofs; else - _mesa_printf("_mesa_exec_malloc failed\n"); + printf("_mesa_exec_malloc failed\n"); bail: _glthread_UNLOCK_MUTEX(exec_mutex); diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 0e6f69f573..04ea3b4ed7 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -374,8 +374,8 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format, } if (texImage->Width < 1 || texImage->Height < 1) { att_incomplete("teximage width/height=0"); - _mesa_printf("texobj = %u\n", texObj->Name); - _mesa_printf("level = %d\n", att->TextureLevel); + printf("texobj = %u\n", texObj->Name); + printf("level = %d\n", att->TextureLevel); att->Complete = GL_FALSE; return; } @@ -2139,39 +2139,39 @@ _mesa_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, /* Debug code */ if (DEBUG_BLIT) { - _mesa_printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," - " 0x%x, 0x%x)\n", - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter); + printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d," + " 0x%x, 0x%x)\n", + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); if (colorReadRb) { const struct gl_renderbuffer_attachment *att; att = find_attachment(readFb, colorReadRb); - _mesa_printf(" Src FBO %u RB %u (%dx%d) ", - readFb->Name, colorReadRb->Name, - colorReadRb->Width, colorReadRb->Height); + printf(" Src FBO %u RB %u (%dx%d) ", + readFb->Name, colorReadRb->Name, + colorReadRb->Width, colorReadRb->Height); if (att && att->Texture) { - _mesa_printf("Tex %u tgt 0x%x level %u face %u", - att->Texture->Name, - att->Texture->Target, - att->TextureLevel, - att->CubeMapFace); + printf("Tex %u tgt 0x%x level %u face %u", + att->Texture->Name, + att->Texture->Target, + att->TextureLevel, + att->CubeMapFace); } - _mesa_printf("\n"); + printf("\n"); att = find_attachment(drawFb, colorDrawRb); - _mesa_printf(" Dst FBO %u RB %u (%dx%d) ", - drawFb->Name, colorDrawRb->Name, - colorDrawRb->Width, colorDrawRb->Height); + printf(" Dst FBO %u RB %u (%dx%d) ", + drawFb->Name, colorDrawRb->Name, + colorDrawRb->Width, colorDrawRb->Height); if (att && att->Texture) { - _mesa_printf("Tex %u tgt 0x%x level %u face %u", - att->Texture->Name, - att->Texture->Target, - att->TextureLevel, - att->CubeMapFace); + printf("Tex %u tgt 0x%x level %u face %u", + att->Texture->Name, + att->Texture->Target, + att->TextureLevel, + att->CubeMapFace); } - _mesa_printf("\n"); + printf("\n"); } } diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 48edec657b..ba94a38770 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -536,10 +536,10 @@ static void debug_insn( struct prog_instruction *inst, const char *fn, if (fn != last_fn) { last_fn = fn; - _mesa_printf("%s:\n", fn); + printf("%s:\n", fn); } - _mesa_printf("%d:\t", line); + printf("%d:\t", line); _mesa_print_instruction(inst); } } @@ -1577,7 +1577,7 @@ static void build_tnl_program( struct tnl_program *p ) /* Disassemble: */ if (DISASSEM) { - _mesa_printf ("\n"); + printf ("\n"); } } @@ -1647,7 +1647,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx) if (!prog) { /* OK, we'll have to build a new one */ if (0) - _mesa_printf("Build new TNL program\n"); + printf("Build new TNL program\n"); prog = (struct gl_vertex_program *) ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0); diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 10224f7888..112490915f 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -827,67 +827,6 @@ _mesa_str_checksum(const char *str) /*@}*/ -/**********************************************************************/ -/** \name I/O */ -/*@{*/ - -/** Wrapper around vsprintf() */ -int -_mesa_sprintf( char *str, const char *fmt, ... ) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsprintf( str, fmt, args ); - va_end( args ); - return r; -} - -/** Wrapper around vsnprintf() */ -int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsnprintf( str, size, fmt, args ); - va_end( args ); - return r; -} - -/** Wrapper around printf(), using vsprintf() for the formatting. */ -void -_mesa_printf( const char *fmtString, ... ) -{ - va_list args; - va_start( args, fmtString ); - vfprintf(stderr, fmtString, args); - va_end( args ); -} - -/** Wrapper around fprintf(), using vsprintf() for the formatting. */ -void -_mesa_fprintf( FILE *f, const char *fmtString, ... ) -{ - char s[MAXSTRING]; - va_list args; - va_start( args, fmtString ); - vsnprintf(s, MAXSTRING, fmtString, args); - va_end( args ); - fprintf(f, "%s", s); -} - - -/** Wrapper around vsprintf() */ -int -_mesa_vsprintf( char *str, const char *fmt, va_list args ) -{ - return vsprintf( str, fmt, args ); -} - -/*@}*/ - - /**********************************************************************/ /** \name Diagnostics */ /*@{*/ @@ -927,7 +866,7 @@ output_if_debug(const char *prefixString, const char *outputString, * visible, so communicate with the debugger instead */ { char buf[4096]; - _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); + snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : ""); OutputDebugStringA(buf); } #endif @@ -976,7 +915,7 @@ flush_delayed_errors( GLcontext *ctx ) char s[MAXSTRING]; if (ctx->ErrorDebugCount) { - _mesa_snprintf(s, MAXSTRING, "%d similar %s errors", + snprintf(s, MAXSTRING, "%d similar %s errors", ctx->ErrorDebugCount, error_string(ctx->ErrorValue)); @@ -1083,7 +1022,7 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) vsnprintf(s, MAXSTRING, fmtString, args); va_end(args); - _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); + snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s); output_if_debug("Mesa: User error", s2, GL_TRUE); ctx->ErrorDebugFmtString = fmtString; diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 4eabdfdb0d..a65c6a615f 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -594,22 +594,6 @@ _mesa_strtod( const char *s, char **end ); extern unsigned int _mesa_str_checksum(const char *str); -extern int -_mesa_sprintf( char *str, const char *fmt, ... ); - -extern int -_mesa_snprintf( char *str, size_t size, const char *fmt, ... ); - -extern void -_mesa_printf( const char *fmtString, ... ); - -extern void -_mesa_fprintf( FILE *f, const char *fmtString, ... ); - -extern int -_mesa_vsprintf( char *str, const char *fmt, va_list args ); - - extern void _mesa_warning( __GLcontext *gc, const char *fmtString, ... ); diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 415abcdfa1..355af56b41 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1115,7 +1115,7 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border, */ /* - _mesa_printf("mip3d %d x %d x %d -> %d x %d x %d\n", + printf("mip3d %d x %d x %d -> %d x %d x %d\n", srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth); */ diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index e6f6add768..f382680b44 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -489,7 +489,7 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, newSource = _mesa_read_shader(filename); if (newSource) { - _mesa_fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", + fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", shaderObj, checksum, filename); free(source); source = newSource; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 5e07d1d2f1..589029db58 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -682,7 +682,7 @@ _mesa_set_varying_vp_inputs( GLcontext *ctx, if (ctx->varying_vp_inputs != varying_inputs) { ctx->varying_vp_inputs = varying_inputs; ctx->NewState |= _NEW_ARRAY; - /*_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs);*/ + /*printf("%s %x\n", __FUNCTION__, varying_inputs);*/ } } diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index f790fd6562..7b8a8b85f2 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -1560,7 +1560,7 @@ create_new_program(GLcontext *ctx, struct state_key *key, if (DISASSEM) { _mesa_print_program(&p.program->Base); - _mesa_printf("\n"); + printf("\n"); } } diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 11e37dc34e..00329c755d 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1307,7 +1307,7 @@ texture_error_check( GLcontext *ctx, GLenum target, if (type != GL_UNSIGNED_SHORT_8_8_MESA && type != GL_UNSIGNED_SHORT_8_8_REV_MESA) { char message[100]; - _mesa_sprintf(message, + sprintf(message, "glTexImage%d(format/type YCBCR mismatch", dimensions); _mesa_error(ctx, GL_INVALID_ENUM, message); return GL_TRUE; /* error */ @@ -1323,7 +1323,7 @@ texture_error_check( GLcontext *ctx, GLenum target, if (border != 0) { if (!isProxy) { char message[100]; - _mesa_sprintf(message, + sprintf(message, "glTexImage%d(format=GL_YCBCR_MESA and border=%d)", dimensions, border); _mesa_error(ctx, GL_INVALID_VALUE, message); diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index feba6e95b6..2753b55c36 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -383,7 +383,7 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, static void incomplete(const struct gl_texture_object *t, const char *why) { - _mesa_printf("Texture Obj %d incomplete because: %s\n", t->Name, why); + printf("Texture Obj %d incomplete because: %s\n", t->Name, why); } #else #define incomplete(t, why) @@ -416,7 +416,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, */ if ((baseLevel < 0) || (baseLevel >= MAX_TEXTURE_LEVELS)) { char s[100]; - _mesa_sprintf(s, "base level = %d is invalid", baseLevel); + sprintf(s, "base level = %d is invalid", baseLevel); incomplete(t, s); t->_Complete = GL_FALSE; return; @@ -425,7 +425,7 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, /* Always need the base level image */ if (!t->Image[0][baseLevel]) { char s[100]; - _mesa_sprintf(s, "Image[baseLevel=%d] == NULL", baseLevel); + sprintf(s, "Image[baseLevel=%d] == NULL", baseLevel); incomplete(t, s); t->_Complete = GL_FALSE; return; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 8c4399a430..fce17c2b66 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -122,25 +122,25 @@ void _mesa_print_texunit_state( GLcontext *ctx, GLuint unit ) { const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit; - _mesa_printf("Texture Unit %d\n", unit); - _mesa_printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); - _mesa_printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); - _mesa_printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); - _mesa_printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); - _mesa_printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); - _mesa_printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); - _mesa_printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); - _mesa_printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); - _mesa_printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); - _mesa_printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); - _mesa_printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); - _mesa_printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); - _mesa_printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); - _mesa_printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); - _mesa_printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); - _mesa_printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); - _mesa_printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); - _mesa_printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); + printf("Texture Unit %d\n", unit); + printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode)); + printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB)); + printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA)); + printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0])); + printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1])); + printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2])); + printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0])); + printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1])); + printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2])); + printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0])); + printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1])); + printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2])); + printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0])); + printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1])); + printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2])); + printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB); + printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA); + printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]); } diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index bd63c77a39..65e3fcaa95 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -264,15 +264,15 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat, map[ONE] = ONE; #if 0 - _mesa_printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", - inFormat, _mesa_lookup_enum_by_nr(inFormat), - outFormat, _mesa_lookup_enum_by_nr(outFormat), - map[0], - map[1], - map[2], - map[3], - map[4], - map[5]); + printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", + inFormat, _mesa_lookup_enum_by_nr(inFormat), + outFormat, _mesa_lookup_enum_by_nr(outFormat), + map[0], + map[1], + map[2], + map[3], + map[4], + map[5]); #endif } @@ -884,7 +884,7 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx, for (i = 0; i < 4; i++) map[i] = srctype2ubyte[swap[src2base[base2rgba[rgba2dst[i]]]]]; -/* _mesa_printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ +/* printf("map %d %d %d %d\n", map[0], map[1], map[2], map[3]); */ if (srcComponents == dstComponents && srcRowStride == dstRowStride && diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 818ed792e3..86878d6a8a 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1083,14 +1083,14 @@ static void print_array(const char *name, GLint index, const struct gl_client_array *array) { if (index >= 0) - _mesa_printf(" %s[%d]: ", name, index); + printf(" %s[%d]: ", name, index); else - _mesa_printf(" %s: ", name); - _mesa_printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %u), MaxElem=%u\n", - array->Ptr, array->Type, array->Size, - array->_ElementSize, array->StrideB, - array->BufferObj->Name, array->BufferObj->Size, - array->_MaxElement); + printf(" %s: ", name); + printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %u), MaxElem=%u\n", + array->Ptr, array->Type, array->Size, + array->_ElementSize, array->StrideB, + array->BufferObj->Name, array->BufferObj->Size, + array->_MaxElement); } @@ -1105,7 +1105,7 @@ _mesa_print_arrays(GLcontext *ctx) _mesa_update_array_object_max_element(ctx, arrayObj); - _mesa_printf("Array Object %u\n", arrayObj->Name); + printf("Array Object %u\n", arrayObj->Name); if (arrayObj->Vertex.Enabled) print_array("Vertex", -1, &arrayObj->Vertex); if (arrayObj->Normal.Enabled) @@ -1118,7 +1118,7 @@ _mesa_print_arrays(GLcontext *ctx) for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) if (arrayObj->VertexAttrib[i].Enabled) print_array("Attrib", i, &arrayObj->VertexAttrib[i]); - _mesa_printf(" _MaxElement = %u\n", arrayObj->_MaxElement); + printf(" _MaxElement = %u\n", arrayObj->_MaxElement); } diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index e474fe7fa5..0d01f16059 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -124,7 +124,7 @@ _mesa_compute_version(GLcontext *ctx) ctx->VersionString = (char *) malloc(max); if (ctx->VersionString) { - _mesa_snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING, - ctx->VersionMajor, ctx->VersionMinor); + snprintf(ctx->VersionString, max, "%u.%u Mesa " MESA_VERSION_STRING, + ctx->VersionMajor, ctx->VersionMinor); } } diff --git a/src/mesa/math/m_debug_clip.c b/src/mesa/math/m_debug_clip.c index 95ae5a347d..7ea5428aa2 100644 --- a/src/mesa/math/m_debug_clip.c +++ b/src/mesa/math/m_debug_clip.c @@ -270,20 +270,20 @@ static int test_cliptest_function( clip_func func, int np, } if ( dco != rco ) { - _mesa_printf( "\n-----------------------------\n" ); - _mesa_printf( "dco = 0x%02x rco = 0x%02x\n", dco, rco ); + printf( "\n-----------------------------\n" ); + printf( "dco = 0x%02x rco = 0x%02x\n", dco, rco ); return 0; } if ( dca != rca ) { - _mesa_printf( "\n-----------------------------\n" ); - _mesa_printf( "dca = 0x%02x rca = 0x%02x\n", dca, rca ); + printf( "\n-----------------------------\n" ); + printf( "dca = 0x%02x rca = 0x%02x\n", dca, rca ); return 0; } for ( i = 0 ; i < TEST_COUNT ; i++ ) { if ( dm[i] != rm[i] ) { - _mesa_printf( "\n-----------------------------\n" ); - _mesa_printf( "(i = %i)\n", i ); - _mesa_printf( "dm = 0x%02x rm = 0x%02x\n", dm[i], rm[i] ); + printf( "\n-----------------------------\n" ); + printf( "(i = %i)\n", i ); + printf( "dm = 0x%02x rm = 0x%02x\n", dm[i], rm[i] ); return 0; } } @@ -297,19 +297,19 @@ static int test_cliptest_function( clip_func func, int np, for ( i = 0 ; i < TEST_COUNT ; i++ ) { for ( j = 0 ; j < 4 ; j++ ) { if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { - _mesa_printf( "\n-----------------------------\n" ); - _mesa_printf( "(i = %i, j = %i) dm = 0x%02x rm = 0x%02x\n", + printf( "\n-----------------------------\n" ); + printf( "(i = %i, j = %i) dm = 0x%02x rm = 0x%02x\n", i, j, dm[i], rm[i] ); - _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n", + printf( "%f \t %f \t [diff = %e - %i bit missed]\n", d[i][0], r[i][0], r[i][0]-d[i][0], MAX_PRECISION - significand_match( d[i][0], r[i][0] ) ); - _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n", + printf( "%f \t %f \t [diff = %e - %i bit missed]\n", d[i][1], r[i][1], r[i][1]-d[i][1], MAX_PRECISION - significand_match( d[i][1], r[i][1] ) ); - _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n", + printf( "%f \t %f \t [diff = %e - %i bit missed]\n", d[i][2], r[i][2], r[i][2]-d[i][2], MAX_PRECISION - significand_match( d[i][2], r[i][2] ) ); - _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n", + printf( "%f \t %f \t [diff = %e - %i bit missed]\n", d[i][3], r[i][3], r[i][3]-d[i][3], MAX_PRECISION - significand_match( d[i][3], r[i][3] ) ); return 0; @@ -335,19 +335,19 @@ void _math_test_all_cliptest_functions( char *description ) if ( mesa_profile ) { if ( !counter_overhead ) { INIT_COUNTER(); - _mesa_printf( "counter overhead: %ld cycles\n\n", counter_overhead ); + printf( "counter overhead: %ld cycles\n\n", counter_overhead ); } - _mesa_printf( "cliptest results after hooking in %s functions:\n", description ); + printf( "cliptest results after hooking in %s functions:\n", description ); } #endif #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) { - _mesa_printf( "\n\t" ); + printf( "\n\t" ); for ( psize = 2 ; psize <= 4 ; psize++ ) { - _mesa_printf( " p%d\t", psize ); + printf( " p%d\t", psize ); } - _mesa_printf( "\n--------------------------------------------------------\n\t" ); + printf( "\n--------------------------------------------------------\n\t" ); } #endif @@ -358,23 +358,23 @@ void _math_test_all_cliptest_functions( char *description ) if ( test_cliptest_function( func, np, psize, cycles ) == 0 ) { char buf[100]; - _mesa_sprintf( buf, "%s[%d] failed test (%s)", + sprintf( buf, "%s[%d] failed test (%s)", cnames[np], psize, description ); _mesa_problem( NULL, buf ); } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) - _mesa_printf( " %li\t", benchmark_tab[np][psize-1] ); + printf( " %li\t", benchmark_tab[np][psize-1] ); #endif } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) - _mesa_printf( " | [%s]\n\t", cstrings[np] ); + printf( " | [%s]\n\t", cstrings[np] ); #endif } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) - _mesa_printf( "\n" ); + printf( "\n" ); #endif } diff --git a/src/mesa/math/m_debug_norm.c b/src/mesa/math/m_debug_norm.c index f9b26d8047..546e8641da 100644 --- a/src/mesa/math/m_debug_norm.c +++ b/src/mesa/math/m_debug_norm.c @@ -294,15 +294,15 @@ static int test_norm_function( normal_func func, int mtype, long *cycles ) for ( i = 0 ; i < TEST_COUNT ; i++ ) { for ( j = 0 ; j < 3 ; j++ ) { if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { - _mesa_printf( "-----------------------------\n" ); - _mesa_printf( "(i = %i, j = %i)\n", i, j ); - _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", + printf( "-----------------------------\n" ); + printf( "(i = %i, j = %i)\n", i, j ); + printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", d[i][0], r[i][0], r[i][0]/d[i][0], MAX_PRECISION - significand_match( d[i][0], r[i][0] ) ); - _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", + printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", d[i][1], r[i][1], r[i][1]/d[i][1], MAX_PRECISION - significand_match( d[i][1], r[i][1] ) ); - _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", + printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", d[i][2], r[i][2], r[i][2]/d[i][2], MAX_PRECISION - significand_match( d[i][2], r[i][2] ) ); return 0; @@ -310,15 +310,15 @@ static int test_norm_function( normal_func func, int mtype, long *cycles ) if ( norm_normalize_types[mtype] != 0 ) { if ( significand_match( d2[i][j], r2[i][j] ) < REQUIRED_PRECISION ) { - _mesa_printf( "------------------- precalculated length case ------\n" ); - _mesa_printf( "(i = %i, j = %i)\n", i, j ); - _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", + printf( "------------------- precalculated length case ------\n" ); + printf( "(i = %i, j = %i)\n", i, j ); + printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", d2[i][0], r2[i][0], r2[i][0]/d2[i][0], MAX_PRECISION - significand_match( d2[i][0], r2[i][0] ) ); - _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", + printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", d2[i][1], r2[i][1], r2[i][1]/d2[i][1], MAX_PRECISION - significand_match( d2[i][1], r2[i][1] ) ); - _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", + printf( "%f \t %f \t [ratio = %e - %i bit missed]\n", d2[i][2], r2[i][2], r2[i][2]/d2[i][2], MAX_PRECISION - significand_match( d2[i][2], r2[i][2] ) ); return 0; @@ -346,11 +346,11 @@ void _math_test_all_normal_transform_functions( char *description ) if ( mesa_profile ) { if ( !counter_overhead ) { INIT_COUNTER(); - _mesa_printf( "counter overhead: %ld cycles\n\n", counter_overhead ); + printf( "counter overhead: %ld cycles\n\n", counter_overhead ); } - _mesa_printf( "normal transform results after hooking in %s functions:\n", + printf( "normal transform results after hooking in %s functions:\n", description ); - _mesa_printf( "\n-------------------------------------------------------\n" ); + printf( "\n-------------------------------------------------------\n" ); } #endif @@ -360,21 +360,21 @@ void _math_test_all_normal_transform_functions( char *description ) if ( test_norm_function( func, mtype, cycles ) == 0 ) { char buf[100]; - _mesa_sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)", + sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)", norm_strings[mtype], description ); _mesa_problem( NULL, buf ); } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) { - _mesa_printf( " %li\t", benchmark_tab[mtype] ); - _mesa_printf( " | [%s]\n", norm_strings[mtype] ); + printf( " %li\t", benchmark_tab[mtype] ); + printf( " | [%s]\n", norm_strings[mtype] ); } #endif } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) { - _mesa_printf( "\n" ); + printf( "\n" ); } #endif } diff --git a/src/mesa/math/m_debug_xform.c b/src/mesa/math/m_debug_xform.c index df8cc066b6..df1bc8aadf 100644 --- a/src/mesa/math/m_debug_xform.c +++ b/src/mesa/math/m_debug_xform.c @@ -254,18 +254,18 @@ static int test_transform_function( transform_func func, int psize, for ( i = 0 ; i < TEST_COUNT ; i++ ) { for ( j = 0 ; j < 4 ; j++ ) { if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) { - _mesa_printf("-----------------------------\n" ); - _mesa_printf("(i = %i, j = %i)\n", i, j ); - _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n", + printf("-----------------------------\n" ); + printf("(i = %i, j = %i)\n", i, j ); + printf("%f \t %f \t [diff = %e - %i bit missed]\n", d[i][0], r[i][0], r[i][0]-d[i][0], MAX_PRECISION - significand_match( d[i][0], r[i][0] ) ); - _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n", + printf("%f \t %f \t [diff = %e - %i bit missed]\n", d[i][1], r[i][1], r[i][1]-d[i][1], MAX_PRECISION - significand_match( d[i][1], r[i][1] ) ); - _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n", + printf("%f \t %f \t [diff = %e - %i bit missed]\n", d[i][2], r[i][2], r[i][2]-d[i][2], MAX_PRECISION - significand_match( d[i][2], r[i][2] ) ); - _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n", + printf("%f \t %f \t [diff = %e - %i bit missed]\n", d[i][3], r[i][3], r[i][3]-d[i][3], MAX_PRECISION - significand_match( d[i][3], r[i][3] ) ); return 0; @@ -292,19 +292,19 @@ void _math_test_all_transform_functions( char *description ) if ( mesa_profile ) { if ( !counter_overhead ) { INIT_COUNTER(); - _mesa_printf("counter overhead: %lu cycles\n\n", counter_overhead ); + printf("counter overhead: %lu cycles\n\n", counter_overhead ); } - _mesa_printf("transform results after hooking in %s functions:\n", description ); + printf("transform results after hooking in %s functions:\n", description ); } #endif #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) { - _mesa_printf("\n" ); + printf("\n" ); for ( psize = 1 ; psize <= 4 ; psize++ ) { - _mesa_printf(" p%d\t", psize ); + printf(" p%d\t", psize ); } - _mesa_printf("\n--------------------------------------------------------\n" ); + printf("\n--------------------------------------------------------\n" ); } #endif @@ -315,23 +315,23 @@ void _math_test_all_transform_functions( char *description ) if ( test_transform_function( func, psize, mtype, cycles ) == 0 ) { char buf[100]; - _mesa_sprintf(buf, "_mesa_transform_tab[0][%d][%s] failed test (%s)", - psize, mstrings[mtype], description ); + sprintf(buf, "_mesa_transform_tab[0][%d][%s] failed test (%s)", + psize, mstrings[mtype], description ); _mesa_problem( NULL, buf ); } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) - _mesa_printf(" %li\t", benchmark_tab[psize-1][mtype] ); + printf(" %li\t", benchmark_tab[psize-1][mtype] ); #endif } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) - _mesa_printf(" | [%s]\n", mstrings[mtype] ); + printf(" | [%s]\n", mstrings[mtype] ); #endif } #ifdef RUN_DEBUG_BENCHMARK if ( mesa_profile ) - _mesa_printf( "\n" ); + printf( "\n" ); #endif } diff --git a/src/mesa/math/m_vector.c b/src/mesa/math/m_vector.c index 4cbab11a35..65c381f383 100644 --- a/src/mesa/math/m_vector.c +++ b/src/mesa/math/m_vector.c @@ -148,27 +148,27 @@ _mesa_vector4f_print( const GLvector4f *v, const GLubyte *cullmask, GLfloat *d = (GLfloat *)v->data; GLuint j, i = 0, count; - _mesa_printf("data-start\n"); + printf("data-start\n"); for (; d != v->start; STRIDE_F(d, v->stride), i++) - _mesa_printf(t, i, d[0], d[1], d[2], d[3]); + printf(t, i, d[0], d[1], d[2], d[3]); - _mesa_printf("start-count(%u)\n", v->count); + printf("start-count(%u)\n", v->count); count = i + v->count; if (culling) { for (; i < count; STRIDE_F(d, v->stride), i++) if (cullmask[i]) - _mesa_printf(t, i, d[0], d[1], d[2], d[3]); + printf(t, i, d[0], d[1], d[2], d[3]); } else { for (; i < count; STRIDE_F(d, v->stride), i++) - _mesa_printf(t, i, d[0], d[1], d[2], d[3]); + printf(t, i, d[0], d[1], d[2], d[3]); } for (j = v->size; j < 4; j++) { if ((v->flags & (1<data; i < count && d[j] == c[j]; @@ -177,9 +177,9 @@ _mesa_vector4f_print( const GLvector4f *v, const GLubyte *cullmask, } if (i == count) - _mesa_printf(" --> ok\n"); + printf(" --> ok\n"); else - _mesa_printf(" --> Failed at %u ******\n", i); + printf(" --> Failed at %u ******\n", i); } } } diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 03ff30a239..6373529e4e 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -148,7 +148,7 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, } #if DEBUG_FP - _mesa_printf("____________Fragment program %u ________\n", program->Base.Id); + printf("____________Fragment program %u ________\n", program->Base.Id); _mesa_print_program(&program->Base); #endif } @@ -211,7 +211,7 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, program->Base.Parameters = prog.Parameters; #if DEBUG_VP - _mesa_printf("____________Vertex program %u __________\n", program->Base.Id); + printf("____________Vertex program %u __________\n", program->Base.Id); _mesa_print_program(&program->Base); #endif } diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index 4f02703619..d03cb4e493 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -200,7 +200,7 @@ do { \ #define RETURN_ERROR2(msg1, msg2) \ do { \ char err[1000]; \ - _mesa_sprintf(err, "%s %s", msg1, msg2); \ + sprintf(err, "%s %s", msg1, msg2); \ record_error(parseState, err, __LINE__); \ return GL_FALSE; \ } while(0) @@ -1566,9 +1566,9 @@ _mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget, #endif #ifdef DEBUG_foo - _mesa_printf("--- glLoadProgramNV(%d) result ---\n", program->Base.Id); + printf("--- glLoadProgramNV(%d) result ---\n", program->Base.Id); _mesa_fprint_program_opt(stdout, &program->Base, PROG_PRINT_NV, 0); - _mesa_printf("----------------------------------\n"); + printf("----------------------------------\n"); #endif } else { diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index fb36303bb9..631b315af3 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -111,7 +111,7 @@ do { \ #define RETURN_ERROR2(msg1, msg2) \ do { \ char err[1000]; \ - _mesa_sprintf(err, "%s %s", msg1, msg2); \ + sprintf(err, "%s %s", msg1, msg2); \ record_error(parseState, err, __LINE__); \ return GL_FALSE; \ } while(0) @@ -1397,9 +1397,9 @@ _mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget, program->IsNVProgram = GL_TRUE; #ifdef DEBUG_foo - _mesa_printf("--- glLoadProgramNV result ---\n"); + printf("--- glLoadProgramNV result ---\n"); _mesa_fprint_program_opt(stdout, &program->Base, PROG_PRINT_NV, 0); - _mesa_printf("------------------------------\n"); + printf("------------------------------\n"); #endif if (program->Base.Parameters) diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index ee422e7ec8..3b51f986e8 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -1782,8 +1782,8 @@ _mesa_execute_program(GLcontext * ctx, { GLfloat a[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - _mesa_printf("%s%g, %g, %g, %g\n", (const char *) inst->Data, - a[0], a[1], a[2], a[3]); + printf("%s%g, %g, %g, %g\n", (const char *) inst->Data, + a[0], a[1], a[2], a[3]); } break; case OPCODE_END: diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index 81099cb99c..e5534b20e3 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -345,7 +345,7 @@ _mesa_opcode_string(gl_inst_opcode opcode) return InstInfo[opcode].Name; else { static char s[20]; - _mesa_snprintf(s, sizeof(s), "OP%u", opcode); + snprintf(s, sizeof(s), "OP%u", opcode); return s; } } diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c index 09816d5044..2941a17da3 100644 --- a/src/mesa/shader/prog_optimize.c +++ b/src/mesa/shader/prog_optimize.c @@ -159,7 +159,7 @@ _mesa_consolidate_registers(struct gl_program *prog) GLuint tempMax = 0, i; if (dbg) { - _mesa_printf("Optimize: Begin register consolidation\n"); + printf("Optimize: Begin register consolidation\n"); } memset(tempUsed, 0, sizeof(tempUsed)); @@ -196,7 +196,7 @@ _mesa_consolidate_registers(struct gl_program *prog) for (i = 0; i <= tempMax; i++) { if (tempUsed[i]) { tempMap[i] = freeTemp++; - /*_mesa_printf("replace %u with %u\n", i, tempMap[i]);*/ + /*printf("replace %u with %u\n", i, tempMap[i]);*/ } } if (freeTemp == tempMax + 1) { @@ -204,14 +204,14 @@ _mesa_consolidate_registers(struct gl_program *prog) return; } if (dbg) { - _mesa_printf("Replace regs 0..%u with 0..%u\n", tempMax, freeTemp-1); + printf("Replace regs 0..%u with 0..%u\n", tempMax, freeTemp-1); } } replace_regs(prog, PROGRAM_TEMPORARY, tempMap); if (dbg) { - _mesa_printf("Optimize: End register consolidation\n"); + printf("Optimize: End register consolidation\n"); } } @@ -232,7 +232,7 @@ _mesa_remove_dead_code(struct gl_program *prog) memset(tempRead, 0, sizeof(tempRead)); if (dbg) { - _mesa_printf("Optimize: Begin dead code removal\n"); + printf("Optimize: Begin dead code removal\n"); /*_mesa_print_program(prog);*/ } @@ -255,7 +255,7 @@ _mesa_remove_dead_code(struct gl_program *prog) if (inst->SrcReg[j].RelAddr) { if (dbg) - _mesa_printf("abort remove dead code (indirect temp)\n"); + printf("abort remove dead code (indirect temp)\n"); goto done; } @@ -290,7 +290,7 @@ _mesa_remove_dead_code(struct gl_program *prog) if (inst->DstReg.RelAddr) { if (dbg) - _mesa_printf("abort remove dead code (indirect temp)\n"); + printf("abort remove dead code (indirect temp)\n"); goto done; } @@ -319,7 +319,7 @@ _mesa_remove_dead_code(struct gl_program *prog) if (!tempRead[index][chan] && inst->DstReg.WriteMask & (1 << chan)) { if (dbg) { - _mesa_printf("Remove writemask on %u.%c\n", i, + printf("Remove writemask on %u.%c\n", i, chan == 3 ? 'w' : 'x' + chan); } inst->DstReg.WriteMask &= ~(1 << chan); @@ -330,7 +330,7 @@ _mesa_remove_dead_code(struct gl_program *prog) if (inst->DstReg.WriteMask == 0) { /* If we cleared all writes, the instruction can be removed. */ if (dbg) - _mesa_printf("Remove instruction %u: \n", i); + printf("Remove instruction %u: \n", i); removeInst[i] = GL_TRUE; } } @@ -340,9 +340,9 @@ _mesa_remove_dead_code(struct gl_program *prog) rem = remove_instructions(prog, removeInst); if (dbg) { - _mesa_printf("Optimize: End dead code removal.\n"); - _mesa_printf(" %u channel writes removed\n", rem); - _mesa_printf(" %u instructions removed\n", rem); + printf("Optimize: End dead code removal.\n"); + printf(" %u channel writes removed\n", rem); + printf(" %u instructions removed\n", rem); /*_mesa_print_program(prog);*/ } @@ -427,7 +427,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog) GLuint i, j; if (dbg) { - _mesa_printf("Optimize: Begin remove extra move use\n"); + printf("Optimize: Begin remove extra move use\n"); _mesa_print_program(prog); } @@ -518,7 +518,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog) } if (dbg) { - _mesa_printf("Optimize: End remove extra move use.\n"); + printf("Optimize: End remove extra move use.\n"); /*_mesa_print_program(prog);*/ } } @@ -533,7 +533,7 @@ _mesa_remove_extra_moves(struct gl_program *prog) GLuint i, rem, loopNesting = 0, subroutineNesting = 0; if (dbg) { - _mesa_printf("Optimize: Begin remove extra moves\n"); + printf("Optimize: Begin remove extra moves\n"); _mesa_print_program(prog); } @@ -605,8 +605,8 @@ _mesa_remove_extra_moves(struct gl_program *prog) removeInst[i] = GL_TRUE; if (dbg) { - _mesa_printf("Remove MOV at %u\n", i); - _mesa_printf("new prev inst %u: ", prevI); + printf("Remove MOV at %u\n", i); + printf("new prev inst %u: ", prevI); _mesa_print_instruction(prevInst); } } @@ -624,7 +624,7 @@ _mesa_remove_extra_moves(struct gl_program *prog) free(removeInst); if (dbg) { - _mesa_printf("Optimize: End remove extra moves. %u instructions removed\n", rem); + printf("Optimize: End remove extra moves. %u instructions removed\n", rem); /*_mesa_print_program(prog);*/ } } @@ -837,7 +837,7 @@ find_live_intervals(struct gl_program *prog, */ if (dbg) { - _mesa_printf("Optimize: Begin find intervals\n"); + printf("Optimize: Begin find intervals\n"); } /* build intermediate arrays */ @@ -864,16 +864,16 @@ find_live_intervals(struct gl_program *prog, /* print interval info */ for (i = 0; i < liveIntervals->Num; i++) { const struct interval *inv = liveIntervals->Intervals + i; - _mesa_printf("Reg[%d] live [%d, %d]:", + printf("Reg[%d] live [%d, %d]:", inv->Reg, inv->Start, inv->End); if (1) { GLuint j; for (j = 0; j < inv->Start; j++) - _mesa_printf(" "); + printf(" "); for (j = inv->Start; j <= inv->End; j++) - _mesa_printf("x"); + printf("x"); } - _mesa_printf("\n"); + printf("\n"); } } @@ -914,7 +914,7 @@ _mesa_reallocate_registers(struct gl_program *prog) GLint maxTemp = -1; if (dbg) { - _mesa_printf("Optimize: Begin live-interval register reallocation\n"); + printf("Optimize: Begin live-interval register reallocation\n"); _mesa_print_program(prog); } @@ -925,7 +925,7 @@ _mesa_reallocate_registers(struct gl_program *prog) if (!find_live_intervals(prog, &liveIntervals)) { if (dbg) - _mesa_printf("Aborting register reallocation\n"); + printf("Aborting register reallocation\n"); return; } @@ -938,7 +938,7 @@ _mesa_reallocate_registers(struct gl_program *prog) const struct interval *live = liveIntervals.Intervals + i; if (dbg) - _mesa_printf("Consider register %u\n", live->Reg); + printf("Consider register %u\n", live->Reg); /* Expire old intervals. Intervals which have ended with respect * to the live interval can have their remapped registers freed. @@ -959,7 +959,7 @@ _mesa_reallocate_registers(struct gl_program *prog) ASSERT(regNew >= 0); if (dbg) - _mesa_printf(" expire interval for reg %u\n", inv->Reg); + printf(" expire interval for reg %u\n", inv->Reg); /* remove interval j from active list */ remove_interval(&activeIntervals, inv); @@ -967,7 +967,7 @@ _mesa_reallocate_registers(struct gl_program *prog) /* return register regNew to the free pool */ if (dbg) - _mesa_printf(" free reg %d\n", regNew); + printf(" free reg %d\n", regNew); ASSERT(usedRegs[regNew] == GL_TRUE); usedRegs[regNew] = GL_FALSE; } @@ -984,7 +984,7 @@ _mesa_reallocate_registers(struct gl_program *prog) registerMap[live->Reg] = k; maxTemp = MAX2(maxTemp, k); if (dbg) - _mesa_printf(" remap register %u -> %d\n", live->Reg, k); + printf(" remap register %u -> %d\n", live->Reg, k); } /* Insert this live interval into the active list which is sorted @@ -1005,8 +1005,8 @@ _mesa_reallocate_registers(struct gl_program *prog) } if (dbg) { - _mesa_printf("Optimize: End live-interval register reallocation\n"); - _mesa_printf("Num temp regs before: %u after: %u\n", + printf("Optimize: End live-interval register reallocation\n"); + printf("Num temp regs before: %u after: %u\n", liveIntervals.Num, maxTemp + 1); _mesa_print_program(prog); } diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index b238537673..a933f21857 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -77,7 +77,7 @@ file_string(gl_register_file f, gl_prog_print_mode mode) default: { static char s[20]; - _mesa_snprintf(s, sizeof(s), "FILE%u", f); + snprintf(s, sizeof(s), "FILE%u", f); return s; } } @@ -172,12 +172,12 @@ arb_input_attrib_string(GLint index, GLenum progType) void _mesa_print_vp_inputs(GLbitfield inputs) { - _mesa_printf("VP Inputs 0x%x: \n", inputs); + printf("VP Inputs 0x%x: \n", inputs); while (inputs) { GLint attr = _mesa_ffs(inputs) - 1; const char *name = arb_input_attrib_string(attr, GL_VERTEX_PROGRAM_ARB); - _mesa_printf(" %d: %s\n", attr, name); + printf(" %d: %s\n", attr, name); inputs &= ~(1 << attr); } } @@ -190,12 +190,12 @@ _mesa_print_vp_inputs(GLbitfield inputs) void _mesa_print_fp_inputs(GLbitfield inputs) { - _mesa_printf("FP Inputs 0x%x: \n", inputs); + printf("FP Inputs 0x%x: \n", inputs); while (inputs) { GLint attr = _mesa_ffs(inputs) - 1; const char *name = arb_input_attrib_string(attr, GL_FRAGMENT_PROGRAM_ARB); - _mesa_printf(" %d: %s\n", attr, name); + printf(" %d: %s\n", attr, name); inputs &= ~(1 << attr); } } @@ -274,46 +274,46 @@ reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, switch (mode) { case PROG_PRINT_DEBUG: - _mesa_sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); + sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); break; case PROG_PRINT_ARB: switch (f) { case PROGRAM_INPUT: - _mesa_sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); + sprintf(str, "%s", arb_input_attrib_string(index, prog->Target)); break; case PROGRAM_OUTPUT: - _mesa_sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); + sprintf(str, "%s", arb_output_attrib_string(index, prog->Target)); break; case PROGRAM_TEMPORARY: - _mesa_sprintf(str, "temp%d", index); + sprintf(str, "temp%d", index); break; case PROGRAM_ENV_PARAM: - _mesa_sprintf(str, "program.env[%s%d]", addr, index); + sprintf(str, "program.env[%s%d]", addr, index); break; case PROGRAM_LOCAL_PARAM: - _mesa_sprintf(str, "program.local[%s%d]", addr, index); + sprintf(str, "program.local[%s%d]", addr, index); break; case PROGRAM_VARYING: /* extension */ - _mesa_sprintf(str, "varying[%s%d]", addr, index); + sprintf(str, "varying[%s%d]", addr, index); break; case PROGRAM_CONSTANT: /* extension */ - _mesa_sprintf(str, "constant[%s%d]", addr, index); + sprintf(str, "constant[%s%d]", addr, index); break; case PROGRAM_UNIFORM: /* extension */ - _mesa_sprintf(str, "uniform[%s%d]", addr, index); + sprintf(str, "uniform[%s%d]", addr, index); break; case PROGRAM_STATE_VAR: { struct gl_program_parameter *param = prog->Parameters->Parameters + index; char *state = _mesa_program_state_string(param->StateIndexes); - _mesa_sprintf(str, state); + sprintf(str, state); free(state); } break; case PROGRAM_ADDRESS: - _mesa_sprintf(str, "A%d", index); + sprintf(str, "A%d", index); break; default: _mesa_problem(NULL, "bad file in reg_string()"); @@ -324,30 +324,30 @@ reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, switch (f) { case PROGRAM_INPUT: if (prog->Target == GL_VERTEX_PROGRAM_ARB) - _mesa_sprintf(str, "v[%d]", index); + sprintf(str, "v[%d]", index); else - _mesa_sprintf(str, "f[%d]", index); + sprintf(str, "f[%d]", index); break; case PROGRAM_OUTPUT: - _mesa_sprintf(str, "o[%d]", index); + sprintf(str, "o[%d]", index); break; case PROGRAM_TEMPORARY: - _mesa_sprintf(str, "R%d", index); + sprintf(str, "R%d", index); break; case PROGRAM_ENV_PARAM: - _mesa_sprintf(str, "c[%d]", index); + sprintf(str, "c[%d]", index); break; case PROGRAM_VARYING: /* extension */ - _mesa_sprintf(str, "varying[%s%d]", addr, index); + sprintf(str, "varying[%s%d]", addr, index); break; case PROGRAM_UNIFORM: /* extension */ - _mesa_sprintf(str, "uniform[%s%d]", addr, index); + sprintf(str, "uniform[%s%d]", addr, index); break; case PROGRAM_CONSTANT: /* extension */ - _mesa_sprintf(str, "constant[%s%d]", addr, index); + sprintf(str, "constant[%s%d]", addr, index); break; case PROGRAM_STATE_VAR: /* extension */ - _mesa_sprintf(str, "state[%s%d]", addr, index); + sprintf(str, "state[%s%d]", addr, index); break; default: _mesa_problem(NULL, "bad file in reg_string()"); @@ -419,11 +419,11 @@ void _mesa_print_swizzle(GLuint swizzle) { if (swizzle == SWIZZLE_XYZW) { - _mesa_printf(".xyzw\n"); + printf(".xyzw\n"); } else { const char *s = _mesa_swizzle_string(swizzle, 0, 0); - _mesa_printf("%s\n", s); + printf("%s\n", s); } } @@ -476,23 +476,23 @@ fprint_dst_reg(FILE * f, gl_prog_print_mode mode, const struct gl_program *prog) { - _mesa_fprintf(f, "%s%s", - reg_string((gl_register_file) dstReg->File, - dstReg->Index, mode, dstReg->RelAddr, prog), - _mesa_writemask_string(dstReg->WriteMask)); - + fprintf(f, "%s%s", + reg_string((gl_register_file) dstReg->File, + dstReg->Index, mode, dstReg->RelAddr, prog), + _mesa_writemask_string(dstReg->WriteMask)); + if (dstReg->CondMask != COND_TR) { - _mesa_fprintf(f, " (%s.%s)", - _mesa_condcode_string(dstReg->CondMask), - _mesa_swizzle_string(dstReg->CondSwizzle, - GL_FALSE, GL_FALSE)); + fprintf(f, " (%s.%s)", + _mesa_condcode_string(dstReg->CondMask), + _mesa_swizzle_string(dstReg->CondSwizzle, + GL_FALSE, GL_FALSE)); } #if 0 - _mesa_fprintf(f, "%s[%d]%s", - file_string((gl_register_file) dstReg->File, mode), - dstReg->Index, - _mesa_writemask_string(dstReg->WriteMask)); + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) dstReg->File, mode), + dstReg->Index, + _mesa_writemask_string(dstReg->WriteMask)); #endif } @@ -505,19 +505,19 @@ fprint_src_reg(FILE *f, { const char *abs = srcReg->Abs ? "|" : ""; - _mesa_fprintf(f, "%s%s%s%s", - abs, - reg_string((gl_register_file) srcReg->File, - srcReg->Index, mode, srcReg->RelAddr, prog), - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE), - abs); + fprintf(f, "%s%s%s%s", + abs, + reg_string((gl_register_file) srcReg->File, + srcReg->Index, mode, srcReg->RelAddr, prog), + _mesa_swizzle_string(srcReg->Swizzle, + srcReg->Negate, GL_FALSE), + abs); #if 0 - _mesa_fprintf(f, "%s[%d]%s", - file_string((gl_register_file) srcReg->File, mode), - srcReg->Index, - _mesa_swizzle_string(srcReg->Swizzle, - srcReg->Negate, GL_FALSE)); + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) srcReg->File, mode), + srcReg->Index, + _mesa_swizzle_string(srcReg->Swizzle, + srcReg->Negate, GL_FALSE)); #endif } @@ -526,9 +526,9 @@ static void fprint_comment(FILE *f, const struct prog_instruction *inst) { if (inst->Comment) - _mesa_fprintf(f, "; # %s\n", inst->Comment); + fprintf(f, "; # %s\n", inst->Comment); else - _mesa_fprintf(f, ";\n"); + fprintf(f, ";\n"); } @@ -541,29 +541,29 @@ fprint_alu_instruction(FILE *f, { GLuint j; - _mesa_fprintf(f, "%s", opcode_string); + fprintf(f, "%s", opcode_string); if (inst->CondUpdate) - _mesa_fprintf(f, ".C"); + fprintf(f, ".C"); /* frag prog only */ if (inst->SaturateMode == SATURATE_ZERO_ONE) - _mesa_fprintf(f, "_SAT"); + fprintf(f, "_SAT"); - _mesa_fprintf(f, " "); + fprintf(f, " "); if (inst->DstReg.File != PROGRAM_UNDEFINED) { fprint_dst_reg(f, &inst->DstReg, mode, prog); } else { - _mesa_fprintf(f, " ???"); + fprintf(f, " ???"); } if (numRegs > 0) - _mesa_fprintf(f, ", "); + fprintf(f, ", "); for (j = 0; j < numRegs; j++) { fprint_src_reg(f, inst->SrcReg + j, mode, prog); if (j + 1 < numRegs) - _mesa_fprintf(f, ", "); + fprintf(f, ", "); } fprint_comment(f, inst); @@ -598,177 +598,177 @@ _mesa_fprint_instruction_opt(FILE *f, indent -= 3; } for (i = 0; i < indent; i++) { - _mesa_fprintf(f, " "); + fprintf(f, " "); } switch (inst->Opcode) { case OPCODE_PRINT: - _mesa_fprintf(f, "PRINT '%s'", inst->Data); + fprintf(f, "PRINT '%s'", inst->Data); if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { - _mesa_fprintf(f, ", "); - _mesa_fprintf(f, "%s[%d]%s", - file_string((gl_register_file) inst->SrcReg[0].File, - mode), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_FALSE)); + fprintf(f, ", "); + fprintf(f, "%s[%d]%s", + file_string((gl_register_file) inst->SrcReg[0].File, + mode), + inst->SrcReg[0].Index, + _mesa_swizzle_string(inst->SrcReg[0].Swizzle, + inst->SrcReg[0].Negate, GL_FALSE)); } if (inst->Comment) - _mesa_fprintf(f, " # %s", inst->Comment); + fprintf(f, " # %s", inst->Comment); fprint_comment(f, inst); break; case OPCODE_SWZ: - _mesa_fprintf(f, "SWZ"); + fprintf(f, "SWZ"); if (inst->SaturateMode == SATURATE_ZERO_ONE) - _mesa_fprintf(f, "_SAT"); - _mesa_fprintf(f, " "); + fprintf(f, "_SAT"); + fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); - _mesa_fprintf(f, ", %s[%d], %s", - file_string((gl_register_file) inst->SrcReg[0].File, - mode), - inst->SrcReg[0].Index, - _mesa_swizzle_string(inst->SrcReg[0].Swizzle, - inst->SrcReg[0].Negate, GL_TRUE)); + fprintf(f, ", %s[%d], %s", + file_string((gl_register_file) inst->SrcReg[0].File, + mode), + inst->SrcReg[0].Index, + _mesa_swizzle_string(inst->SrcReg[0].Swizzle, + inst->SrcReg[0].Negate, GL_TRUE)); fprint_comment(f, inst); break; case OPCODE_TEX: case OPCODE_TXP: case OPCODE_TXL: case OPCODE_TXB: - _mesa_fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); if (inst->SaturateMode == SATURATE_ZERO_ONE) - _mesa_fprintf(f, "_SAT"); - _mesa_fprintf(f, " "); + fprintf(f, "_SAT"); + fprintf(f, " "); fprint_dst_reg(f, &inst->DstReg, mode, prog); - _mesa_fprintf(f, ", "); + fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - _mesa_fprintf(f, ", texture[%d], ", inst->TexSrcUnit); + fprintf(f, ", texture[%d], ", inst->TexSrcUnit); switch (inst->TexSrcTarget) { - case TEXTURE_1D_INDEX: _mesa_fprintf(f, "1D"); break; - case TEXTURE_2D_INDEX: _mesa_fprintf(f, "2D"); break; - case TEXTURE_3D_INDEX: _mesa_fprintf(f, "3D"); break; - case TEXTURE_CUBE_INDEX: _mesa_fprintf(f, "CUBE"); break; - case TEXTURE_RECT_INDEX: _mesa_fprintf(f, "RECT"); break; + case TEXTURE_1D_INDEX: fprintf(f, "1D"); break; + case TEXTURE_2D_INDEX: fprintf(f, "2D"); break; + case TEXTURE_3D_INDEX: fprintf(f, "3D"); break; + case TEXTURE_CUBE_INDEX: fprintf(f, "CUBE"); break; + case TEXTURE_RECT_INDEX: fprintf(f, "RECT"); break; default: ; } if (inst->TexShadow) - _mesa_fprintf(f, " SHADOW"); + fprintf(f, " SHADOW"); fprint_comment(f, inst); break; case OPCODE_KIL: - _mesa_fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - _mesa_fprintf(f, " "); + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, " "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprint_comment(f, inst); break; case OPCODE_KIL_NV: - _mesa_fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); - _mesa_fprintf(f, " "); - _mesa_fprintf(f, "%s.%s", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - GL_FALSE, GL_FALSE)); + fprintf(f, "%s", _mesa_opcode_string(inst->Opcode)); + fprintf(f, " "); + fprintf(f, "%s.%s", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, + GL_FALSE, GL_FALSE)); fprint_comment(f, inst); break; case OPCODE_ARL: - _mesa_fprintf(f, "ARL "); + fprintf(f, "ARL "); fprint_dst_reg(f, &inst->DstReg, mode, prog); - _mesa_fprintf(f, ", "); + fprintf(f, ", "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); fprint_comment(f, inst); break; case OPCODE_BRA: - _mesa_fprintf(f, "BRA %d (%s%s)", - inst->BranchTarget, - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); + fprintf(f, "BRA %d (%s%s)", + inst->BranchTarget, + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); fprint_comment(f, inst); break; case OPCODE_IF: if (inst->SrcReg[0].File != PROGRAM_UNDEFINED) { /* Use ordinary register */ - _mesa_fprintf(f, "IF "); + fprintf(f, "IF "); fprint_src_reg(f, &inst->SrcReg[0], mode, prog); - _mesa_fprintf(f, "; "); + fprintf(f, "; "); } else { /* Use cond codes */ - _mesa_fprintf(f, "IF (%s%s);", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, - 0, GL_FALSE)); + fprintf(f, "IF (%s%s);", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, + 0, GL_FALSE)); } - _mesa_fprintf(f, " # (if false, goto %d)", inst->BranchTarget); + fprintf(f, " # (if false, goto %d)", inst->BranchTarget); fprint_comment(f, inst); return indent + 3; case OPCODE_ELSE: - _mesa_fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); + fprintf(f, "ELSE; # (goto %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDIF: - _mesa_fprintf(f, "ENDIF;\n"); + fprintf(f, "ENDIF;\n"); break; case OPCODE_BGNLOOP: - _mesa_fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); + fprintf(f, "BGNLOOP; # (end at %d)\n", inst->BranchTarget); return indent + 3; case OPCODE_ENDLOOP: - _mesa_fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); + fprintf(f, "ENDLOOP; # (goto %d)\n", inst->BranchTarget); break; case OPCODE_BRK: case OPCODE_CONT: - _mesa_fprintf(f, "%s (%s%s); # (goto %d)", - _mesa_opcode_string(inst->Opcode), - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), - inst->BranchTarget); + fprintf(f, "%s (%s%s); # (goto %d)", + _mesa_opcode_string(inst->Opcode), + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE), + inst->BranchTarget); fprint_comment(f, inst); break; case OPCODE_BGNSUB: if (mode == PROG_PRINT_NV) { - _mesa_fprintf(f, "%s:\n", inst->Comment); /* comment is label */ + fprintf(f, "%s:\n", inst->Comment); /* comment is label */ return indent; } else { - _mesa_fprintf(f, "BGNSUB"); + fprintf(f, "BGNSUB"); fprint_comment(f, inst); return indent + 3; } case OPCODE_ENDSUB: if (mode == PROG_PRINT_DEBUG) { - _mesa_fprintf(f, "ENDSUB"); + fprintf(f, "ENDSUB"); fprint_comment(f, inst); } break; case OPCODE_CAL: if (mode == PROG_PRINT_NV) { - _mesa_fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); + fprintf(f, "CAL %s; # (goto %d)\n", inst->Comment, inst->BranchTarget); } else { - _mesa_fprintf(f, "CAL %u", inst->BranchTarget); + fprintf(f, "CAL %u", inst->BranchTarget); fprint_comment(f, inst); } break; case OPCODE_RET: - _mesa_fprintf(f, "RET (%s%s)", - _mesa_condcode_string(inst->DstReg.CondMask), - _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); + fprintf(f, "RET (%s%s)", + _mesa_condcode_string(inst->DstReg.CondMask), + _mesa_swizzle_string(inst->DstReg.CondSwizzle, 0, GL_FALSE)); fprint_comment(f, inst); break; case OPCODE_END: - _mesa_fprintf(f, "END\n"); + fprintf(f, "END\n"); break; case OPCODE_NOP: if (mode == PROG_PRINT_DEBUG) { - _mesa_fprintf(f, "NOP"); + fprintf(f, "NOP"); fprint_comment(f, inst); } else if (inst->Comment) { /* ARB/NV extensions don't have NOP instruction */ - _mesa_fprintf(f, "# %s\n", inst->Comment); + fprintf(f, "# %s\n", inst->Comment); } break; /* XXX may need other special-case instructions */ @@ -825,26 +825,26 @@ _mesa_fprint_program_opt(FILE *f, switch (prog->Target) { case GL_VERTEX_PROGRAM_ARB: if (mode == PROG_PRINT_ARB) - _mesa_fprintf(f, "!!ARBvp1.0\n"); + fprintf(f, "!!ARBvp1.0\n"); else if (mode == PROG_PRINT_NV) - _mesa_fprintf(f, "!!VP1.0\n"); + fprintf(f, "!!VP1.0\n"); else - _mesa_fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); + fprintf(f, "# Vertex Program/Shader %u\n", prog->Id); break; case GL_FRAGMENT_PROGRAM_ARB: case GL_FRAGMENT_PROGRAM_NV: if (mode == PROG_PRINT_ARB) - _mesa_fprintf(f, "!!ARBfp1.0\n"); + fprintf(f, "!!ARBfp1.0\n"); else if (mode == PROG_PRINT_NV) - _mesa_fprintf(f, "!!FP1.0\n"); + fprintf(f, "!!FP1.0\n"); else - _mesa_fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); + fprintf(f, "# Fragment Program/Shader %u\n", prog->Id); break; } for (i = 0; i < prog->NumInstructions; i++) { if (lineNumbers) - _mesa_fprintf(f, "%3d: ", i); + fprintf(f, "%3d: ", i); indent = _mesa_fprint_instruction_opt(f, prog->Instructions + i, indent, mode, prog); } @@ -896,30 +896,30 @@ _mesa_fprint_program_parameters(FILE *f, { GLuint i; - _mesa_fprintf(f, "InputsRead: 0x%x (0b%s)\n", + fprintf(f, "InputsRead: 0x%x (0b%s)\n", prog->InputsRead, binary(prog->InputsRead)); - _mesa_fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", + fprintf(f, "OutputsWritten: 0x%llx (0b%s)\n", prog->OutputsWritten, binary(prog->OutputsWritten)); - _mesa_fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); - _mesa_fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); - _mesa_fprintf(f, "NumParameters=%d\n", prog->NumParameters); - _mesa_fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); - _mesa_fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); - _mesa_fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", + fprintf(f, "NumInstructions=%d\n", prog->NumInstructions); + fprintf(f, "NumTemporaries=%d\n", prog->NumTemporaries); + fprintf(f, "NumParameters=%d\n", prog->NumParameters); + fprintf(f, "NumAttributes=%d\n", prog->NumAttributes); + fprintf(f, "NumAddressRegs=%d\n", prog->NumAddressRegs); + fprintf(f, "SamplersUsed: 0x%x (0b%s)\n", prog->SamplersUsed, binary(prog->SamplersUsed)); - _mesa_fprintf(f, "Samplers=[ "); + fprintf(f, "Samplers=[ "); for (i = 0; i < MAX_SAMPLERS; i++) { - _mesa_fprintf(f, "%d ", prog->SamplerUnits[i]); + fprintf(f, "%d ", prog->SamplerUnits[i]); } - _mesa_fprintf(f, "]\n"); + fprintf(f, "]\n"); _mesa_load_state_parameters(ctx, prog->Parameters); #if 0 - _mesa_fprintf(f, "Local Params:\n"); + fprintf(f, "Local Params:\n"); for (i = 0; i < MAX_PROGRAM_LOCAL_PARAMS; i++){ const GLfloat *p = prog->LocalParams[i]; - _mesa_fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); + fprintf(f, "%2d: %f, %f, %f, %f\n", i, p[0], p[1], p[2], p[3]); } #endif _mesa_print_parameter_list(prog->Parameters); @@ -950,24 +950,24 @@ _mesa_fprint_parameter_list(FILE *f, return; if (0) - _mesa_fprintf(f, "param list %p\n", (void *) list); - _mesa_fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); + fprintf(f, "param list %p\n", (void *) list); + fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); for (i = 0; i < list->NumParameters; i++){ struct gl_program_parameter *param = list->Parameters + i; const GLfloat *v = list->ParameterValues[i]; - _mesa_fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", - i, param->Size, - file_string(list->Parameters[i].Type, mode), - param->Name, v[0], v[1], v[2], v[3]); + fprintf(f, "param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", + i, param->Size, + file_string(list->Parameters[i].Type, mode), + param->Name, v[0], v[1], v[2], v[3]); if (param->Flags & PROG_PARAM_BIT_CENTROID) - _mesa_fprintf(f, " Centroid"); + fprintf(f, " Centroid"); if (param->Flags & PROG_PARAM_BIT_INVARIANT) - _mesa_fprintf(f, " Invariant"); + fprintf(f, " Invariant"); if (param->Flags & PROG_PARAM_BIT_FLAT) - _mesa_fprintf(f, " Flat"); + fprintf(f, " Flat"); if (param->Flags & PROG_PARAM_BIT_LINEAR) - _mesa_fprintf(f, " Linear"); - _mesa_fprintf(f, "\n"); + fprintf(f, " Linear"); + fprintf(f, "\n"); } } @@ -997,7 +997,7 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) else type = "vert"; - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); f = fopen(filename, "w"); if (!f) { fprintf(stderr, "Unable to open %s for writing\n", filename); @@ -1047,7 +1047,7 @@ _mesa_append_uniforms_to_file(const struct gl_shader *shader, else type = "vert"; - _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); + snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type); f = fopen(filename, "a"); /* append */ if (!f) { fprintf(stderr, "Unable to open %s for appending\n", filename); diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 2c844490dd..ead3ece95d 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -950,7 +950,7 @@ static void append_index(char *dst, GLint index) { char s[20]; - _mesa_sprintf(s, "[%d]", index); + sprintf(s, "[%d]", index); append(dst, s); } @@ -1029,9 +1029,9 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) if (modifier) append_token(str, modifier); if (firstRow == lastRow) - _mesa_sprintf(tmp, ".row[%d]", firstRow); + sprintf(tmp, ".row[%d]", firstRow); else - _mesa_sprintf(tmp, ".row[%d..%d]", firstRow, lastRow); + sprintf(tmp, ".row[%d..%d]", firstRow, lastRow); append(str, tmp); } break; diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index e5ef25ec38..3f26f9f84a 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -2984,7 +2984,7 @@ yyreduce: { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 63)) { char s[100]; - _mesa_snprintf(s, sizeof(s), + snprintf(s, sizeof(s), "relative address offset too large (%d)", (yyvsp[(1) - (1)].integer)); yyerror(& (yylsp[(1) - (1)]), state, s); YYERROR; @@ -3001,7 +3001,7 @@ yyreduce: { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 64)) { char s[100]; - _mesa_snprintf(s, sizeof(s), + snprintf(s, sizeof(s), "relative address offset too large (%d)", (yyvsp[(1) - (1)].integer)); yyerror(& (yylsp[(1) - (1)]), state, s); YYERROR; @@ -4915,7 +4915,7 @@ yyreduce: if (exist != NULL) { char m[1000]; - _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string)); + snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string)); free((yyvsp[(2) - (4)].string)); yyerror(& (yylsp[(2) - (4)]), state, m); YYERROR; diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 299e2477e4..1c856d859d 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -936,7 +936,7 @@ addrRegPosOffset: INTEGER { if (($1 < 0) || ($1 > 63)) { char s[100]; - _mesa_snprintf(s, sizeof(s), + snprintf(s, sizeof(s), "relative address offset too large (%d)", $1); yyerror(& @1, state, s); YYERROR; @@ -950,7 +950,7 @@ addrRegNegOffset: INTEGER { if (($1 < 0) || ($1 > 64)) { char s[100]; - _mesa_snprintf(s, sizeof(s), + snprintf(s, sizeof(s), "relative address offset too large (%d)", $1); yyerror(& @1, state, s); YYERROR; @@ -2173,7 +2173,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER if (exist != NULL) { char m[1000]; - _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2); + snprintf(m, sizeof(m), "redeclared identifier: %s", $2); free($2); yyerror(& @2, state, m); YYERROR; diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index ad3ff26c58..8bd780b0b0 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1483,12 +1483,12 @@ _mesa_link_program(GLcontext *ctx, GLuint program) if (0) { GLuint i; - _mesa_printf("Link %u shaders in program %u: %s\n", + printf("Link %u shaders in program %u: %s\n", shProg->NumShaders, shProg->Name, shProg->LinkStatus ? "Success" : "Failed"); for (i = 0; i < shProg->NumShaders; i++) { - _mesa_printf(" shader %u, type 0x%x\n", + printf(" shader %u, type 0x%x\n", shProg->Shaders[i]->Name, shProg->Shaders[i]->Type); } @@ -1504,7 +1504,7 @@ print_shader_info(const struct gl_shader_program *shProg) { GLuint i; - _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name); + printf("Mesa: glUseProgram(%u)\n", shProg->Name); for (i = 0; i < shProg->NumShaders; i++) { const char *s; switch (shProg->Shaders[i]->Type) { @@ -1520,14 +1520,14 @@ print_shader_info(const struct gl_shader_program *shProg) default: s = ""; } - _mesa_printf(" %s shader %u, checksum %u\n", s, - shProg->Shaders[i]->Name, - shProg->Shaders[i]->SourceChecksum); + printf(" %s shader %u, checksum %u\n", s, + shProg->Shaders[i]->Name, + shProg->Shaders[i]->SourceChecksum); } if (shProg->VertexProgram) - _mesa_printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); + printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); if (shProg->FragmentProgram) - _mesa_printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); + printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); } @@ -1697,8 +1697,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, /* This maps a sampler to a texture unit: */ if (sampler < MAX_SAMPLERS) { #if 0 - _mesa_printf("Set program %p sampler %d '%s' to unit %u\n", - program, sampler, param->Name, texUnit); + printf("Set program %p sampler %d '%s' to unit %u\n", + program, sampler, param->Name, texUnit); #endif if (program->SamplerUnits[sampler] != texUnit) { program->SamplerUnits[sampler] = texUnit; @@ -1861,21 +1861,21 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count, if (ctx->Shader.Flags & GLSL_UNIFORMS) { GLint i; - _mesa_printf("Mesa: set program %u uniform %s (loc %d) to: ", - shProg->Name, uniform->Name, location); + printf("Mesa: set program %u uniform %s (loc %d) to: ", + shProg->Name, uniform->Name, location); if (basicType == GL_INT) { const GLint *v = (const GLint *) values; for (i = 0; i < count * elems; i++) { - _mesa_printf("%d ", v[i]); + printf("%d ", v[i]); } } else { const GLfloat *v = (const GLfloat *) values; for (i = 0; i < count * elems; i++) { - _mesa_printf("%g ", v[i]); + printf("%g ", v[i]); } } - _mesa_printf("\n"); + printf("\n"); } /* A uniform var may be used by both a vertex shader and a fragment @@ -2076,9 +2076,9 @@ validate_samplers(GLcontext *ctx, const struct gl_program *prog, char *errMsg) unit = prog->SamplerUnits[sampler]; target = prog->SamplerTargets[sampler]; if (targetUsed[unit] != -1 && targetUsed[unit] != target) { - _mesa_snprintf(errMsg, 100, - "Texture unit %d is accessed both as %s and %s", - unit, targetName[targetUsed[unit]], targetName[target]); + snprintf(errMsg, 100, + "Texture unit %d is accessed both as %s and %s", + unit, targetName[targetUsed[unit]], targetName[target]); return GL_FALSE; } targetUsed[unit] = target; diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 6901b93d5d..b17256bb1e 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -1643,7 +1643,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun, if (A->pragmas->Debug) { char s[1000]; - _mesa_snprintf(s, sizeof(s), "Call/inline %s()", (char *) fun->header.a_name); + snprintf(s, sizeof(s), "Call/inline %s()", (char *) fun->header.a_name); n->Comment = _slang_strdup(s); } @@ -2190,7 +2190,7 @@ _slang_make_array_constructor(slang_assemble_ctx *A, slang_operation *oper) */ slang_variable *p = slang_variable_scope_grow(fun->parameters); char name[10]; - _mesa_snprintf(name, sizeof(name), "p%d", i); + snprintf(name, sizeof(name), "p%d", i); p->a_name = slang_atom_pool_atom(A->atoms, name); p->type.qualifier = SLANG_QUAL_CONST; p->type.specifier.type = baseType; diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 8bd699ff9d..52fe786890 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -2303,8 +2303,8 @@ emit_var_ref(slang_emit_info *emitInfo, slang_ir_node *n) /* error */ char s[100]; /* XXX isn't this really an out of memory/resources error? */ - _mesa_snprintf(s, sizeof(s), "Undefined variable '%s'", - (char *) n->Var->a_name); + snprintf(s, sizeof(s), "Undefined variable '%s'", + (char *) n->Var->a_name); slang_info_log_error(emitInfo->log, s); return NULL; } diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c index 7e00b5787f..225612a936 100644 --- a/src/mesa/shader/slang/slang_label.c +++ b/src/mesa/shader/slang/slang_label.c @@ -37,7 +37,7 @@ _slang_label_new_unique(const char *name) free(l); return NULL; } - _mesa_sprintf(l->Name, "%s_%d", name, id); + sprintf(l->Name, "%s_%d", name, id); id++; l->Location = -1; } diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 89658c1a39..b59fc0a43a 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -139,16 +139,16 @@ link_varying_vars(GLcontext *ctx, } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) { char msg[100]; - _mesa_snprintf(msg, sizeof(msg), - "centroid modifier mismatch for '%s'", var->Name); + snprintf(msg, sizeof(msg), + "centroid modifier mismatch for '%s'", var->Name); link_error(shProg, msg); free(map); return GL_FALSE; } if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) { char msg[100]; - _mesa_snprintf(msg, sizeof(msg), - "invariant modifier mismatch for '%s'", var->Name); + snprintf(msg, sizeof(msg), + "invariant modifier mismatch for '%s'", var->Name); link_error(shProg, msg); free(map); return GL_FALSE; @@ -269,8 +269,8 @@ link_uniform_vars(GLcontext *ctx, GLuint newSampNum = *numSamplers; if (newSampNum >= ctx->Const.MaxTextureImageUnits) { char s[100]; - _mesa_sprintf(s, "Too many texture samplers (%u, max is %u)", - newSampNum, ctx->Const.MaxTextureImageUnits); + sprintf(s, "Too many texture samplers (%u, max is %u)", + newSampNum, ctx->Const.MaxTextureImageUnits); link_error(shProg, s); return GL_FALSE; } @@ -631,7 +631,7 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) } source[len] = '\0'; /* - _mesa_printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source); + printf("---NEW CONCATENATED SHADER---:\n%s\n------------\n", source); */ free(shaderLengths); @@ -875,11 +875,11 @@ _slang_link(GLcontext *ctx, vertNotify = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, &shProg->FragmentProgram->Base); if (ctx->Shader.Flags & GLSL_DUMP) { - _mesa_printf("Mesa pre-link fragment program:\n"); + printf("Mesa pre-link fragment program:\n"); _mesa_print_program(&fragProg->Base); _mesa_print_program_parameters(ctx, &fragProg->Base); - _mesa_printf("Mesa post-link fragment program:\n"); + printf("Mesa post-link fragment program:\n"); _mesa_print_program(&shProg->FragmentProgram->Base); _mesa_print_program_parameters(ctx, &shProg->FragmentProgram->Base); } @@ -893,11 +893,11 @@ _slang_link(GLcontext *ctx, fragNotify = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, &shProg->VertexProgram->Base); if (ctx->Shader.Flags & GLSL_DUMP) { - _mesa_printf("Mesa pre-link vertex program:\n"); + printf("Mesa pre-link vertex program:\n"); _mesa_print_program(&vertProg->Base); _mesa_print_program_parameters(ctx, &vertProg->Base); - _mesa_printf("Mesa post-link vertex program:\n"); + printf("Mesa post-link vertex program:\n"); _mesa_print_program(&shProg->VertexProgram->Base); _mesa_print_program_parameters(ctx, &shProg->VertexProgram->Base); } @@ -912,10 +912,10 @@ _slang_link(GLcontext *ctx, } if (ctx->Shader.Flags & GLSL_DUMP) { - _mesa_printf("Varying vars:\n"); + printf("Varying vars:\n"); _mesa_print_parameter_list(shProg->Varying); if (shProg->InfoLog) { - _mesa_printf("Info Log: %s\n", shProg->InfoLog); + printf("Info Log: %s\n", shProg->InfoLog); } } diff --git a/src/mesa/shader/slang/slang_log.c b/src/mesa/shader/slang/slang_log.c index 23917fbd2c..9ff21417bc 100644 --- a/src/mesa/shader/slang/slang_log.c +++ b/src/mesa/shader/slang/slang_log.c @@ -86,7 +86,7 @@ slang_info_log_print(slang_info_log * log, const char *msg, ...) char buf[1024]; va_start(va, msg); - _mesa_vsprintf(buf, msg, va); + vsprintf(buf, msg, va); va_end(va); return slang_info_log_message(log, NULL, buf); } @@ -98,7 +98,7 @@ slang_info_log_error(slang_info_log * log, const char *msg, ...) char buf[1024]; va_start(va, msg); - _mesa_vsprintf(buf, msg, va); + vsprintf(buf, msg, va); va_end(va); log->error_flag = GL_TRUE; if (slang_info_log_message(log, "Error", buf)) @@ -114,7 +114,7 @@ slang_info_log_warning(slang_info_log * log, const char *msg, ...) char buf[1024]; va_start(va, msg); - _mesa_vsprintf(buf, msg, va); + vsprintf(buf, msg, va); va_end(va); if (slang_info_log_message(log, "Warning", buf)) return 1; diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c index dc1e196bde..e77404f692 100644 --- a/src/mesa/shader/slang/slang_utility.c +++ b/src/mesa/shader/slang/slang_utility.c @@ -120,7 +120,7 @@ slang_string_pushi (slang_string *self, GLint i) { char buffer[12]; - _mesa_sprintf (buffer, "%d", i); + sprintf (buffer, "%d", i); slang_string_pushs (self, buffer, strlen (buffer)); } diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 6a7ebff6ca..7806df4a53 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -143,7 +143,7 @@ void st_validate_state( struct st_context *st ) if (state->st == 0) return; - /*_mesa_printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/ + /*printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/ if (1) { /* Debug version which enforces various sanity checks on the @@ -158,17 +158,17 @@ void st_validate_state( struct st_context *st ) const struct st_tracked_state *atom = atoms[i]; struct st_state_flags generated; - /*_mesa_printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);*/ + /*printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);*/ if (!(atom->dirty.mesa || atom->dirty.st) || !atom->update) { - _mesa_printf("malformed atom %s\n", atom->name); + printf("malformed atom %s\n", atom->name); assert(0); } if (check_state(state, &atom->dirty)) { atoms[i]->update( st ); - /*_mesa_printf("after: %x\n", atom->dirty.mesa);*/ + /*printf("after: %x\n", atom->dirty.mesa);*/ } accumulate_state(&examined, &atom->dirty); @@ -181,7 +181,7 @@ void st_validate_state( struct st_context *st ) assert(!check_state(&examined, &generated)); prev = *state; } - /*_mesa_printf("\n");*/ + /*printf("\n");*/ } else { diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 5411229d70..cff36042cb 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -233,7 +233,7 @@ static const char *lineFuncName = NULL; #define USE(lineFunc) \ do { \ lineFuncName = #lineFunc; \ - /*_mesa_printf("%s\n", lineFuncName);*/ \ + /*printf("%s\n", lineFuncName);*/ \ swrast->Line = lineFunc; \ } while (0) diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 8a2787a139..fdde294257 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -413,12 +413,12 @@ void _tnl_draw_prims( GLcontext *ctx, if (0) { - _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); + printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); for (i = 0; i < nr_prims; i++) - _mesa_printf("prim %d: %s start %d count %d\n", i, - _mesa_lookup_enum_by_nr(prim[i].mode), - prim[i].start, - prim[i].count); + printf("prim %d: %s start %d count %d\n", i, + _mesa_lookup_enum_by_nr(prim[i].mode), + prim[i].start, + prim[i].count); } if (min_index) { diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 618b8b3130..8cc36e666d 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -202,12 +202,12 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) if (0) { /* print pre-clip vertex coords */ GLuint i, j; - _mesa_printf("pre clip:\n"); + printf("pre clip:\n"); for (i = 0; i < n; i++) { j = inlist[i]; - _mesa_printf(" %u: %u: %f, %f, %f, %f\n", - i, j, - coord[j][0], coord[j][1], coord[j][2], coord[j][3]); + printf(" %u: %u: %f, %f, %f, %f\n", + i, j, + coord[j][0], coord[j][1], coord[j][2], coord[j][3]); assert(!IS_INF_OR_NAN(coord[j][0])); assert(!IS_INF_OR_NAN(coord[j][1])); assert(!IS_INF_OR_NAN(coord[j][2])); @@ -247,12 +247,12 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) if (0) { /* print post-clip vertex coords */ GLuint i, j; - _mesa_printf("post clip:\n"); + printf("post clip:\n"); for (i = 0; i < n; i++) { j = inlist[i]; - _mesa_printf(" %u: %u: %f, %f, %f, %f\n", - i, j, - coord[j][0], coord[j][1], coord[j][2], coord[j][3]); + printf(" %u: %u: %f, %f, %f, %f\n", + i, j, + coord[j][0], coord[j][1], coord[j][2], coord[j][3]); } } diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index ed66c35be7..b35d6a284e 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -307,8 +307,8 @@ GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map, const GLuint format = map[i].format; if (format == EMIT_PAD) { if (DBG) - _mesa_printf("%d: pad %d, offset %d\n", i, - map[i].offset, offset); + printf("%d: pad %d, offset %d\n", i, + map[i].offset, offset); offset += map[i].offset; @@ -338,9 +338,9 @@ GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map, if (DBG) - _mesa_printf("%d: %s, vp %p, offset %d\n", i, - _tnl_format_info[format].name, (void *)vp, - vtx->attr[j].vertoffset); + printf("%d: %s, vp %p, offset %d\n", i, + _tnl_format_info[format].name, (void *)vp, + vtx->attr[j].vertoffset); offset += _tnl_format_info[format].attrsize; j++; diff --git a/src/mesa/tnl/t_vertex_sse.c b/src/mesa/tnl/t_vertex_sse.c index 6436cbfc6e..98058f3bda 100644 --- a/src/mesa/tnl/t_vertex_sse.c +++ b/src/mesa/tnl/t_vertex_sse.c @@ -496,7 +496,7 @@ static GLboolean build_vertex_emit( struct x86_program *p ) update_src_ptr(p, srcECX, vtxESI, a); } else { - _mesa_printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize ); + printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize ); return GL_FALSE; } break; @@ -542,7 +542,7 @@ static GLboolean build_vertex_emit( struct x86_program *p ) j++; /* NOTE: two attrs consumed */ } else { - _mesa_printf("Can't emit 3ub\n"); + printf("Can't emit 3ub\n"); return GL_FALSE; /* add this later */ } break; @@ -590,12 +590,12 @@ static GLboolean build_vertex_emit( struct x86_program *p ) break; case GL_UNSIGNED_SHORT: default: - _mesa_printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE)); + printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE)); return GL_FALSE; } break; default: - _mesa_printf("unknown a[%d].format %d\n", j, a->format); + printf("unknown a[%d].format %d\n", j, a->format); return GL_FALSE; /* catch any new opcodes */ } diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index b10ee2105a..aa7f1c40b1 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -857,7 +857,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) void vbo_exec_BeginVertices( GLcontext *ctx ) { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; - if (0) _mesa_printf("%s\n", __FUNCTION__); + if (0) printf("%s\n", __FUNCTION__); vbo_exec_vtx_map( exec ); assert((exec->ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) == 0); @@ -892,10 +892,10 @@ void vbo_exec_FlushVertices( GLcontext *ctx, GLuint flags ) assert(exec->flush_call_depth == 1); #endif - if (0) _mesa_printf("%s\n", __FUNCTION__); + if (0) printf("%s\n", __FUNCTION__); if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { - if (0) _mesa_printf("%s - inside begin/end\n", __FUNCTION__); + if (0) printf("%s - inside begin/end\n", __FUNCTION__); #ifdef DEBUG exec->flush_call_depth--; assert(exec->flush_call_depth == 0); diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index f2f1674b6a..90474da7c0 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -136,13 +136,13 @@ check_array_data(GLcontext *ctx, struct gl_client_array *array, for (k = 0; k < array->Size; k++) { if (IS_INF_OR_NAN(f[k]) || f[k] >= 1.0e20 || f[k] <= -1.0e10) { - _mesa_printf("Bad array data:\n"); - _mesa_printf(" Element[%u].%u = %f\n", j, k, f[k]); - _mesa_printf(" Array %u at %p\n", attrib, (void* ) array); - _mesa_printf(" Type 0x%x, Size %d, Stride %d\n", - array->Type, array->Size, array->Stride); - _mesa_printf(" Address/offset %p in Buffer Object %u\n", - array->Ptr, array->BufferObj->Name); + printf("Bad array data:\n"); + printf(" Element[%u].%u = %f\n", j, k, f[k]); + printf(" Array %u at %p\n", attrib, (void* ) array); + printf(" Type 0x%x, Size %d, Stride %d\n", + array->Type, array->Size, array->Stride); + printf(" Address/offset %p in Buffer Object %u\n", + array->Ptr, array->BufferObj->Name); f[k] = 1.0; /* XXX replace the bad value! */ } /*assert(!IS_INF_OR_NAN(f[k]));*/ @@ -257,21 +257,21 @@ print_draw_arrays(GLcontext *ctx, struct vbo_exec_context *exec, { int i; - _mesa_printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", - mode, start, count); + printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n", + mode, start, count); for (i = 0; i < 32; i++) { GLuint bufName = exec->array.inputs[i]->BufferObj->Name; GLint stride = exec->array.inputs[i]->Stride; - _mesa_printf("attr %2d: size %d stride %d enabled %d " - "ptr %p Bufobj %u\n", - i, - exec->array.inputs[i]->Size, - stride, - /*exec->array.inputs[i]->Enabled,*/ - exec->array.legacy_array[i]->Enabled, - exec->array.inputs[i]->Ptr, - bufName); + printf("attr %2d: size %d stride %d enabled %d " + "ptr %p Bufobj %u\n", + i, + exec->array.inputs[i]->Size, + stride, + /*exec->array.inputs[i]->Enabled,*/ + exec->array.legacy_array[i]->Enabled, + exec->array.inputs[i]->Ptr, + bufName); if (bufName) { struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, bufName); @@ -284,9 +284,9 @@ print_draw_arrays(GLcontext *ctx, struct vbo_exec_context *exec, int n = (count * stride) / 4; if (n > 32) n = 32; - _mesa_printf(" Data at offset %d:\n", offset); + printf(" Data at offset %d:\n", offset); for (i = 0; i < n; i++) { - _mesa_printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); + printf(" float[%d] = 0x%08x %f\n", i, k[i], f[i]); } ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, buf); } @@ -548,11 +548,11 @@ dump_element_buffer(GLcontext *ctx, GLenum type) const GLubyte *us = (const GLubyte *) map; GLint i; for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) { - _mesa_printf("%02x ", us[i]); + printf("%02x ", us[i]); if (i % 32 == 31) - _mesa_printf("\n"); + printf("\n"); } - _mesa_printf("\n"); + printf("\n"); } break; case GL_UNSIGNED_SHORT: @@ -560,11 +560,11 @@ dump_element_buffer(GLcontext *ctx, GLenum type) const GLushort *us = (const GLushort *) map; GLint i; for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) { - _mesa_printf("%04x ", us[i]); + printf("%04x ", us[i]); if (i % 16 == 15) - _mesa_printf("\n"); + printf("\n"); } - _mesa_printf("\n"); + printf("\n"); } break; case GL_UNSIGNED_INT: @@ -572,11 +572,11 @@ dump_element_buffer(GLcontext *ctx, GLenum type) const GLuint *us = (const GLuint *) map; GLint i; for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) { - _mesa_printf("%08x ", us[i]); + printf("%08x ", us[i]); if (i % 8 == 7) - _mesa_printf("\n"); + printf("\n"); } - _mesa_printf("\n"); + printf("\n"); } break; default: @@ -754,12 +754,12 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, end = ctx->Array.ArrayObj->_MaxElement - 1; } else if (0) { - _mesa_printf("glDraw[Range]Elements{,BaseVertex}" - "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, " - "base %d\n", - start, end, type, count, - ctx->Array.ElementArrayBufferObj->Name, - basevertex); + printf("glDraw[Range]Elements{,BaseVertex}" + "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, " + "base %d\n", + start, end, type, count, + ctx->Array.ElementArrayBufferObj->Name, + basevertex); } #if 0 diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 526bf7ae79..045af46da8 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -43,22 +43,22 @@ vbo_exec_debug_verts( struct vbo_exec_context *exec ) GLuint count = exec->vtx.vert_count; GLuint i; - _mesa_printf("%s: %u vertices %d primitives, %d vertsize\n", - __FUNCTION__, - count, - exec->vtx.prim_count, - exec->vtx.vertex_size); + printf("%s: %u vertices %d primitives, %d vertsize\n", + __FUNCTION__, + count, + exec->vtx.prim_count, + exec->vtx.vertex_size); for (i = 0 ; i < exec->vtx.prim_count ; i++) { struct _mesa_prim *prim = &exec->vtx.prim[i]; - _mesa_printf(" prim %d: %s%s %d..%d %s %s\n", - i, - _mesa_lookup_prim_by_nr(prim->mode), - prim->weak ? " (weak)" : "", - prim->start, - prim->start + prim->count, - prim->begin ? "BEGIN" : "(wrap)", - prim->end ? "END" : "(wrap)"); + printf(" prim %d: %s%s %d..%d %s %s\n", + i, + _mesa_lookup_prim_by_nr(prim->mode), + prim->weak ? " (weak)" : "", + prim->start, + prim->start + prim->count, + prim->begin ? "BEGIN" : "(wrap)", + prim->end ? "END" : "(wrap)"); } } @@ -343,7 +343,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec ) } if (0) - _mesa_printf("map %d..\n", exec->vtx.buffer_used); + printf("map %d..\n", exec->vtx.buffer_used); } @@ -378,8 +378,8 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap ) } if (0) - _mesa_printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, - exec->vtx.vert_count); + printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count, + exec->vtx.vert_count); vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index 1db36de3de..ff7c7a6b0d 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -124,7 +124,7 @@ void vbo_rebase_prims( GLcontext *ctx, assert(min_index != 0); if (0) - _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); + printf("%s %d..%d\n", __FUNCTION__, min_index, max_index); /* XXX this path is disabled for now. diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index e1caa6f8c5..3a64c0cf01 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -1185,10 +1185,10 @@ static void vbo_print_vertex_list( GLcontext *ctx, void *data ) GLuint i; (void) ctx; - _mesa_printf("VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n", - node->count, - node->prim_count, - node->vertex_size); + printf("VBO-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n", + node->count, + node->prim_count, + node->vertex_size); for (i = 0 ; i < node->prim_count ; i++) { struct _mesa_prim *prim = &node->prim[i]; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index d834fa1f2e..a7cf29acd4 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -243,7 +243,7 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data ) * includes operations such as glBegin or glDrawArrays. */ if (0) - _mesa_printf("displaylist recursive begin"); + printf("displaylist recursive begin"); vbo_save_loopback_vertex_list( ctx, node ); return; diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index f13a16e3b5..8d9ae307d6 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -95,12 +95,12 @@ static void loopback_prim( GLcontext *ctx, GLuint k; if (0) - _mesa_printf("loopback prim %s(%s,%s) verts %d..%d\n", - _mesa_lookup_prim_by_nr(prim->mode), - prim->begin ? "begin" : "..", - prim->end ? "end" : "..", - start, - end); + printf("loopback prim %s(%s,%s) verts %d..%d\n", + _mesa_lookup_prim_by_nr(prim->mode), + prim->begin ? "begin" : "..", + prim->end ? "end" : "..", + start, + end); if (prim->begin) { CALL_Begin(GET_DISPATCH(), ( prim->mode )); diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 2fae267ff5..bce401744d 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -147,21 +147,21 @@ dump_draw_info(GLcontext *ctx, { GLuint i, j; - _mesa_printf("VBO Draw:\n"); + printf("VBO Draw:\n"); for (i = 0; i < nr_prims; i++) { - _mesa_printf("Prim %u of %u\n", i, nr_prims); - _mesa_printf(" Prim mode 0x%x\n", prims[i].mode); - _mesa_printf(" IB: %p\n", (void*) ib); + printf("Prim %u of %u\n", i, nr_prims); + printf(" Prim mode 0x%x\n", prims[i].mode); + printf(" IB: %p\n", (void*) ib); for (j = 0; j < VERT_ATTRIB_MAX; j++) { - _mesa_printf(" array %d at %p:\n", j, (void*) arrays[j]); - _mesa_printf(" enabled %d, ptr %p, size %d, type 0x%x, stride %d\n", - arrays[j]->Enabled, arrays[j]->Ptr, - arrays[j]->Size, arrays[j]->Type, arrays[j]->StrideB); + printf(" array %d at %p:\n", j, (void*) arrays[j]); + printf(" enabled %d, ptr %p, size %d, type 0x%x, stride %d\n", + arrays[j]->Enabled, arrays[j]->Ptr, + arrays[j]->Size, arrays[j]->Type, arrays[j]->StrideB); if (0) { GLint k = prims[i].start + prims[i].count - 1; GLfloat *last = (GLfloat *) (arrays[j]->Ptr + arrays[j]->Stride * k); - _mesa_printf(" last: %f %f %f\n", - last[0], last[1], last[2]); + printf(" last: %f %f %f\n", + last[0], last[1], last[2]); } } } @@ -235,7 +235,7 @@ elt(struct copy_context *copy, GLuint elt_idx) GLuint elt = copy->srcelt[elt_idx]; GLuint slot = elt & (ELT_TABLE_SIZE-1); -/* _mesa_printf("elt %d\n", elt); */ +/* printf("elt %d\n", elt); */ /* Look up the incoming element in the vertex cache. Re-emit if * necessary. @@ -244,7 +244,7 @@ elt(struct copy_context *copy, GLuint elt_idx) GLubyte *csr = copy->dstptr; GLuint i; -/* _mesa_printf(" --> emit to dstelt %d\n", copy->dstbuf_nr); */ +/* printf(" --> emit to dstelt %d\n", copy->dstbuf_nr); */ for (i = 0; i < copy->nr_varying; i++) { const struct gl_client_array *srcarray = copy->varying[i].array; @@ -268,10 +268,10 @@ elt(struct copy_context *copy, GLuint elt_idx) { const GLuint *f = (const GLuint *)srcptr; GLuint j; - _mesa_printf(" varying %d: ", i); + printf(" varying %d: ", i); for(j = 0; j < copy->varying[i].size / 4; j++) - _mesa_printf("%x ", f[j]); - _mesa_printf("\n"); + printf("%x ", f[j]); + printf("\n"); } } @@ -284,9 +284,9 @@ elt(struct copy_context *copy, GLuint elt_idx) copy->dstbuf_nr * copy->vertex_size)); } /* else */ -/* _mesa_printf(" --> reuse vertex\n"); */ +/* printf(" --> reuse vertex\n"); */ -/* _mesa_printf(" --> emit %d\n", copy->vert_cache[slot].out); */ +/* printf(" --> emit %d\n", copy->vert_cache[slot].out); */ copy->dstelt[copy->dstelt_nr++] = copy->vert_cache[slot].out; return check_flush(copy); } @@ -300,7 +300,7 @@ end( struct copy_context *copy, GLboolean end_flag ) { struct _mesa_prim *prim = ©->dstprim[copy->dstprim_nr]; -/* _mesa_printf("end (%d)\n", end_flag); */ +/* printf("end (%d)\n", end_flag); */ prim->end = end_flag; prim->count = copy->dstelt_nr - prim->start; diff --git a/src/mesa/vf/vf.c b/src/mesa/vf/vf.c index dab436e2ab..defb7cbe2c 100644 --- a/src/mesa/vf/vf.c +++ b/src/mesa/vf/vf.c @@ -162,8 +162,8 @@ GLuint vf_set_vertex_attributes( struct vertex_fetch *vf, const GLuint format = map[i].format; if (format == EMIT_PAD) { if (DBG) - _mesa_printf("%d: pad %d, offset %d\n", i, - map[i].offset, offset); + printf("%d: pad %d, offset %d\n", i, + map[i].offset, offset); offset += map[i].offset; @@ -180,9 +180,9 @@ GLuint vf_set_vertex_attributes( struct vertex_fetch *vf, vf->attr[j].vertoffset = offset; if (DBG) - _mesa_printf("%d: %s, offset %d\n", i, - vf_format_info[format].name, - vf->attr[j].vertoffset); + printf("%d: %s, offset %d\n", i, + vf_format_info[format].name, + vf->attr[j].vertoffset); offset += vf_format_info[format].attrsize; j++; diff --git a/src/mesa/vf/vf_sse.c b/src/mesa/vf/vf_sse.c index 04275903c9..7b947b74a6 100644 --- a/src/mesa/vf/vf_sse.c +++ b/src/mesa/vf/vf_sse.c @@ -482,7 +482,7 @@ static GLboolean build_vertex_emit( struct x86_program *p ) update_src_ptr(p, srcECX, vfESI, a); } else { - _mesa_printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize ); + printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize ); return GL_FALSE; } break; @@ -527,7 +527,7 @@ static GLboolean build_vertex_emit( struct x86_program *p ) j++; /* NOTE: two attrs consumed */ } else { - _mesa_printf("Can't emit 3ub\n"); + printf("Can't emit 3ub\n"); } return GL_FALSE; /* add this later */ break; @@ -575,12 +575,12 @@ static GLboolean build_vertex_emit( struct x86_program *p ) break; case GL_UNSIGNED_SHORT: default: - _mesa_printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE)); + printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE)); return GL_FALSE; } break; default: - _mesa_printf("unknown a[%d].format %d\n", j, a->format); + printf("unknown a[%d].format %d\n", j, a->format); return GL_FALSE; /* catch any new opcodes */ } diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c index 647be995c1..c93faba792 100644 --- a/src/mesa/x86/rtasm/x86sse.c +++ b/src/mesa/x86/rtasm/x86sse.c @@ -1184,7 +1184,7 @@ void x86_release_func( struct x86_function *p ) void (*x86_get_func( struct x86_function *p ))(void) { if (DISASSEM && p->store) - _mesa_printf("disassemble %p %p\n", p->store, p->csr); + printf("disassemble %p %p\n", p->store, p->csr); return (void (*)(void)) (unsigned long) p->store; } -- cgit v1.2.3 From e16f0c14f353cc04ad6cbcf99e3b95ccb1d2c06b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 24 Feb 2010 00:24:51 -0800 Subject: r600: Assert that array index is not negative. --- src/mesa/drivers/dri/r600/r700_assembler.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index d0059fad2e..8344dd9a51 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -1250,6 +1250,7 @@ GLboolean assemble_src(r700_AssemblerBase *pAsm, if(pAsm->aArgSubst[1+src] >= 0) { + assert(fld >= 0); setaddrmode_PVSSRC(&(pAsm->S[fld].src), ADDR_ABSOLUTE); pAsm->S[fld].src.rtype = SRC_REG_TEMPORARY; pAsm->S[fld].src.reg = pAsm->aArgSubst[1+src]; -- cgit v1.2.3 From 5997501ca0d0c905025bc2a840e48e2176d64ea3 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 24 Feb 2010 11:43:33 -0500 Subject: r600: proper fix for 15601835361e2fdd34b38b265cfc3007749ee24d PRE_EMIT_STATE_BUFSZ accounts for the start 3d, idle, cd/db flush not for state. The relocs for CB_COLOR0_FRAG & CB_COLOR0_TILE are part of the render target state. --- src/mesa/drivers/dri/r600/r700_chip.c | 2 +- src/mesa/drivers/dri/r600/r700_render.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_chip.c b/src/mesa/drivers/dri/r600/r700_chip.c index a742dbcf12..63614b160c 100644 --- a/src/mesa/drivers/dri/r600/r700_chip.c +++ b/src/mesa/drivers/dri/r600/r700_chip.c @@ -1349,7 +1349,7 @@ void r600InitAtoms(context_t *context) ALLOC_STATE(poly, always, 10, r700SendPolyState); ALLOC_STATE(cb, cb, 18, r700SendCBState); ALLOC_STATE(clrcmp, always, 6, r700SendCBCLRCMPState); - ALLOC_STATE(cb_target, always, 25, r700SendRenderTargetState); + ALLOC_STATE(cb_target, always, 29, r700SendRenderTargetState); ALLOC_STATE(blnd, blnd, (6 + (R700_MAX_RENDER_TARGETS * 3)), r700SendCBBlendState); ALLOC_STATE(blnd_clr, always, 6, r700SendCBBlendColorState); ALLOC_STATE(sx, always, 9, r700SendSXState); diff --git a/src/mesa/drivers/dri/r600/r700_render.c b/src/mesa/drivers/dri/r600/r700_render.c index fdd02fac23..1d7a94cbb2 100644 --- a/src/mesa/drivers/dri/r600/r700_render.c +++ b/src/mesa/drivers/dri/r600/r700_render.c @@ -419,7 +419,7 @@ static void r700RunRenderPrimitiveImmediate(GLcontext * ctx, int start, int end, } /* start 3d, idle, cb/db flush */ -#define PRE_EMIT_STATE_BUFSZ 5 + 5 + 18 +#define PRE_EMIT_STATE_BUFSZ 5 + 5 + 14 static GLuint r700PredictRenderSize(GLcontext* ctx, const struct _mesa_prim *prim, -- cgit v1.2.3 From 424a8385e4d07860c6deca12c43d6c31698a29ed Mon Sep 17 00:00:00 2001 From: Klaus Schnass Date: Fri, 26 Feb 2010 15:09:50 -0500 Subject: r600: fail to validate unsupported texture formats --- src/mesa/drivers/dri/r600/r600_texstate.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index dd33ef3c6a..1600033b9b 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -373,17 +373,11 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, gl_format mesa break; */ case MESA_FORMAT_RGB_DXT1: /* not supported yet */ - - break; case MESA_FORMAT_RGBA_DXT1: /* not supported yet */ - - break; case MESA_FORMAT_RGBA_DXT3: /* not supported yet */ - - break; case MESA_FORMAT_RGBA_DXT5: /* not supported yet */ + return GL_FALSE; - break; case MESA_FORMAT_RGBA_FLOAT32: SETfield(t->SQ_TEX_RESOURCE1, FMT_32_32_32_32_FLOAT, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask); @@ -701,8 +695,8 @@ void r600SetDepthTexMode(struct gl_texture_object *tObj) t = radeon_tex_obj(tObj); - r600GetTexFormat(tObj, tObj->Image[0][tObj->BaseLevel]->TexFormat); - + if(!r600GetTexFormat(tObj, tObj->Image[0][tObj->BaseLevel]->TexFormat)) + t->validated = GL_FALSE; } /** @@ -711,7 +705,7 @@ void r600SetDepthTexMode(struct gl_texture_object *tObj) * \param rmesa Context pointer * \param t the r300 texture object */ -static void setup_hardware_state(GLcontext * ctx, struct gl_texture_object *texObj, int unit) +static GLboolean setup_hardware_state(GLcontext * ctx, struct gl_texture_object *texObj, int unit) { context_t *rmesa = R700_CONTEXT(ctx); radeonTexObj *t = radeon_tex_obj(texObj); @@ -721,15 +715,15 @@ static void setup_hardware_state(GLcontext * ctx, struct gl_texture_object *texO if (rmesa->radeon.radeonScreen->driScreen->dri2.enabled && t->image_override && t->bo) - return; + return GL_TRUE; firstImage = t->base.Image[0][t->minLod]; if (!t->image_override) { if (!r600GetTexFormat(texObj, firstImage->TexFormat)) { - radeon_error("unexpected texture format in %s\n", - __FUNCTION__); - return; + radeon_warning("unsupported texture format in %s\n", + __FUNCTION__); + return GL_FALSE; } } @@ -754,7 +748,7 @@ static void setup_hardware_state(GLcontext * ctx, struct gl_texture_object *texO break; default: radeon_error("unexpected texture target type in %s\n", __FUNCTION__); - return; + return GL_FALSE; } row_align = rmesa->radeon.texture_row_align - 1; @@ -799,6 +793,7 @@ static void setup_hardware_state(GLcontext * ctx, struct gl_texture_object *texO CLEARfield(t->SQ_TEX_SAMPLER0, DEPTH_COMPARE_FUNCTION_mask); } + return GL_TRUE; } /** @@ -815,7 +810,8 @@ static GLboolean r600_validate_texture(GLcontext * ctx, struct gl_texture_object /* Configure the hardware registers (more precisely, the cached version * of the hardware registers). */ - setup_hardware_state(ctx, texObj, unit); + if (!setup_hardware_state(ctx, texObj, unit)) + return GL_FALSE; t->validated = GL_TRUE; return GL_TRUE; -- cgit v1.2.3 From 52eb2ef6bf4e3327ed008c691efb821ecaa422b2 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 26 Feb 2010 15:24:12 -0500 Subject: r600: enable OQ on rv740 on drms with working pipe config --- src/mesa/drivers/dri/r600/r600_context.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index f575e74c3e..1a4b014d9f 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -340,9 +340,12 @@ static void r600InitGLExtensions(GLcontext *ctx) _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc"); } - /* XXX: RV740 only seems to report results from half of its DBs */ - if (r600->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV740) - _mesa_disable_extension(ctx, "GL_ARB_occlusion_query"); + /* RV740 had a broken pipe config prior to drm 1.32 */ + if (!r600->radeon.radeonScreen->kernel_mm) { + if ((r600->radeon.dri.drmMinor < 32) && + (r600->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV740)) + _mesa_disable_extension(ctx, "GL_ARB_occlusion_query"); + } } /* Create the device specific rendering context. -- cgit v1.2.3 From 226d98173886e9e26337d6e9593b2b561c8cb758 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 27 Feb 2010 01:52:46 -0800 Subject: r600: Assert pointer is not null before dereferencing. --- src/mesa/drivers/dri/r600/r700_assembler.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 8344dd9a51..834bcc63e3 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -1746,18 +1746,21 @@ GLboolean assemble_alu_src(R700ALUInstruction* alu_instruction_ptr, switch (source_index) { case 0: + assert(alu_instruction_ptr); alu_instruction_ptr->m_Word0.f.src0_sel = src_sel; alu_instruction_ptr->m_Word0.f.src0_rel = src_rel; alu_instruction_ptr->m_Word0.f.src0_chan = src_chan; alu_instruction_ptr->m_Word0.f.src0_neg = src_neg; break; case 1: + assert(alu_instruction_ptr); alu_instruction_ptr->m_Word0.f.src1_sel = src_sel; alu_instruction_ptr->m_Word0.f.src1_rel = src_rel; alu_instruction_ptr->m_Word0.f.src1_chan = src_chan; alu_instruction_ptr->m_Word0.f.src1_neg = src_neg; break; case 2: + assert(alu_instruction_ptr); alu_instruction_ptr->m_Word1_OP3.f.src2_sel = src_sel; alu_instruction_ptr->m_Word1_OP3.f.src2_rel = src_rel; alu_instruction_ptr->m_Word1_OP3.f.src2_chan = src_chan; -- cgit v1.2.3 From 8bf5c229f3fdf2f3a6ae44afe03d3e1bd7194d6a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 2 Mar 2010 14:05:21 +1000 Subject: r600: fix blender picking. This fixes the sw fallback for GL_SELECT picking modes. Fixes object picking blender + depthpick test http://bugs.freedesktop.org/show_bug.cgi?id=26419 Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/r600/r700_render.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_render.c b/src/mesa/drivers/dri/r600/r700_render.c index 1d7a94cbb2..1929b7cc12 100644 --- a/src/mesa/drivers/dri/r600/r700_render.c +++ b/src/mesa/drivers/dri/r600/r700_render.c @@ -829,11 +829,10 @@ static void r700SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer #if MESA_BIG_ENDIAN if (mesa_ind_buf->type == GL_UNSIGNED_INT) - { #else if (mesa_ind_buf->type != GL_UNSIGNED_BYTE) - { #endif + { const GLvoid *src_ptr; GLvoid *dst_ptr; GLboolean mapped_named_bo = GL_FALSE; @@ -872,6 +871,14 @@ static void r700SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer } } +static GLboolean check_fallbacks(GLcontext *ctx) +{ + if (ctx->RenderMode != GL_RENDER) + return GL_TRUE; + + return GL_FALSE; +} + static GLboolean r700TryDrawPrims(GLcontext *ctx, const struct gl_client_array *arrays[], const struct _mesa_prim *prim, @@ -888,6 +895,9 @@ static GLboolean r700TryDrawPrims(GLcontext *ctx, if (ctx->NewState) _mesa_update_state( ctx ); + if (check_fallbacks(ctx)) + return GL_FALSE; + _tnl_UpdateFixedFunctionProgram(ctx); r700SetVertexFormat(ctx, arrays, max_index + 1); /* shaders need to be updated before buffers are validated */ @@ -983,8 +993,10 @@ static void r700DrawPrims(GLcontext *ctx, retval = r700TryDrawPrims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); /* If failed run tnl pipeline - it should take care of fallbacks */ - if (!retval) + if (!retval) { + _swsetup_Wakeup(ctx); _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index); + } } void r700InitDraw(GLcontext *ctx) -- cgit v1.2.3 From daf85c460875c944d6918fdf4041467d97cba41e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 3 Mar 2010 16:27:21 +1000 Subject: radeon/r200/r300/r600: fix blit BO buffer validation there is no need for these to be persistent since we flush the CS at the end of the blit, and we don't reuse these buffers at all. on my r600 the Wine DX9 test suite doesn't crash at least anymore. Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/r200/r200_blit.c | 12 ++++++++---- src/mesa/drivers/dri/r300/r300_blit.c | 12 ++++++++---- src/mesa/drivers/dri/r600/r600_blit.c | 14 ++++++++------ src/mesa/drivers/dri/radeon/radeon_blit.c | 12 ++++++++---- 4 files changed, 32 insertions(+), 18 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index e446d532cf..56b08a21bd 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -211,11 +211,15 @@ static GLboolean validate_buffers(struct r200_context *r200, struct radeon_bo *dst_bo) { int ret; - radeon_cs_space_add_persistent_bo(r200->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, + src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + if (ret) + return GL_FALSE; - radeon_cs_space_add_persistent_bo(r200->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + if (ret) + return GL_FALSE; ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, first_elem(&r200->radeon.dma.reserved)->bo, diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 54ac2510e7..35fd06734f 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -373,11 +373,15 @@ static GLboolean validate_buffers(struct r300_context *r300, struct radeon_bo *dst_bo) { int ret; - radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + ret = radeon_cs_space_check_with_bo(r300->radeon.cmdbuf.cs, + src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + if (ret) + return GL_FALSE; - radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + ret = radeon_cs_space_check_with_bo(r300->radeon.cmdbuf.cs, + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + if (ret) + return GL_FALSE; ret = radeon_cs_space_check_with_bo(r300->radeon.cmdbuf.cs, first_elem(&r300->radeon.dma.reserved)->bo, diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 4bb77a398f..8eafd42e8f 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1532,14 +1532,16 @@ static GLboolean validate_buffers(context_t *rmesa, struct radeon_bo *dst_bo) { int ret; - radeon_cs_space_add_persistent_bo(rmesa->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); - radeon_cs_space_add_persistent_bo(rmesa->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, + src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + if (ret) + return GL_FALSE; - radeon_cs_space_add_persistent_bo(rmesa->radeon.cmdbuf.cs, - rmesa->blit_bo, RADEON_GEM_DOMAIN_GTT, 0); + ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + if (ret) + return GL_FALSE; ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, rmesa->blit_bo, diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index 0df4fbb33c..34b9af4063 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -204,11 +204,15 @@ static GLboolean validate_buffers(struct r100_context *r100, struct radeon_bo *dst_bo) { int ret; - radeon_cs_space_add_persistent_bo(r100->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, + src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + if (ret) + return GL_FALSE; - radeon_cs_space_add_persistent_bo(r100->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + if (ret) + return GL_FALSE; ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, first_elem(&r100->radeon.dma.reserved)->bo, -- cgit v1.2.3 From 3594bf233d16ceb21e97fcdfb57ea45cb0c5e41b Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 3 Mar 2010 16:12:22 -0500 Subject: radeon/r200/r300/r600: add check_blit vtbl function Check if the native blit formats are supported, if not, attempt to use an alternate format. Skip 3, >4 bpp as per comments from mcencora on irc. Signed-off-by: Alex Deucher --- src/mesa/drivers/dri/r200/r200_blit.c | 4 +- src/mesa/drivers/dri/r200/r200_blit.h | 2 + src/mesa/drivers/dri/r200/r200_context.c | 1 + src/mesa/drivers/dri/r300/r300_blit.c | 4 +- src/mesa/drivers/dri/r300/r300_blit.h | 4 +- src/mesa/drivers/dri/r300/r300_context.c | 3 +- src/mesa/drivers/dri/r600/r600_blit.c | 4 +- src/mesa/drivers/dri/r600/r600_blit.h | 33 ++++++++++++++++ src/mesa/drivers/dri/r600/r600_context.c | 1 + src/mesa/drivers/dri/radeon/radeon_blit.c | 4 +- src/mesa/drivers/dri/radeon/radeon_blit.h | 2 + .../drivers/dri/radeon/radeon_common_context.h | 1 + src/mesa/drivers/dri/radeon/radeon_context.c | 1 + src/mesa/drivers/dri/radeon/radeon_tex_copy.c | 44 +++++++++++++++++++--- 14 files changed, 93 insertions(+), 15 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 56b08a21bd..b56327dad5 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -38,7 +38,7 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, } /* common formats supported as both textures and render targets */ -static unsigned is_blit_supported(gl_format mesa_format) +unsigned r200_check_blit(gl_format mesa_format) { /* XXX others? BE/LE? */ switch (mesa_format) { @@ -337,7 +337,7 @@ unsigned r200_blit(GLcontext *ctx, { struct r200_context *r200 = R200_CONTEXT(ctx); - if (!is_blit_supported(dst_mesaformat)) + if (!r200_check_blit(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ diff --git a/src/mesa/drivers/dri/r200/r200_blit.h b/src/mesa/drivers/dri/r200/r200_blit.h index 38487266ae..53206f0b47 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.h +++ b/src/mesa/drivers/dri/r200/r200_blit.h @@ -30,6 +30,8 @@ void r200_blit_init(struct r200_context *r200); +unsigned r200_check_blit(gl_format mesa_format); + unsigned r200_blit(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 6ecd46ecd9..dad2580e08 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -264,6 +264,7 @@ static void r200_init_vtbl(radeonContextPtr radeon) radeon->vtbl.fallback = r200Fallback; radeon->vtbl.update_scissor = r200_vtbl_update_scissor; radeon->vtbl.emit_query_finish = r200_emit_query_finish; + radeon->vtbl.check_blit = r200_check_blit; radeon->vtbl.blit = r200_blit; } diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 35fd06734f..9637a9b7ad 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -498,7 +498,7 @@ static void emit_cb_setup(struct r300_context *r300, END_BATCH(); } -static unsigned is_blit_supported(gl_format dst_format) +unsigned r300_check_blit(gl_format dst_format) { switch (dst_format) { case MESA_FORMAT_RGB565: @@ -566,7 +566,7 @@ unsigned r300_blit(GLcontext *ctx, { r300ContextPtr r300 = R300_CONTEXT(ctx); - if (!is_blit_supported(dst_mesaformat)) + if (!r300_check_blit(dst_mesaformat)) return 0; /* Make sure that colorbuffer has even width - hw limitation */ diff --git a/src/mesa/drivers/dri/r300/r300_blit.h b/src/mesa/drivers/dri/r300/r300_blit.h index 735acaddd7..39b157a57b 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.h +++ b/src/mesa/drivers/dri/r300/r300_blit.h @@ -30,6 +30,8 @@ void r300_blit_init(struct r300_context *r300); +unsigned r300_check_blit(gl_format mesa_format); + unsigned r300_blit(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, @@ -51,4 +53,4 @@ unsigned r300_blit(GLcontext *ctx, unsigned reg_height, unsigned flip_y); -#endif // R300_BLIT_H \ No newline at end of file +#endif // R300_BLIT_H diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index fe2ed22dc2..df4cc11da4 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -320,7 +320,8 @@ static void r300_init_vtbl(radeonContextPtr radeon) } else radeon->vtbl.emit_query_finish = r300_emit_query_finish; - radeon->vtbl.blit = r300_blit; + radeon->vtbl.check_blit = r300_check_blit; + radeon->vtbl.blit = r300_blit; } static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen) diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 8eafd42e8f..9d17463cae 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -33,7 +33,7 @@ #include "r600_cmdbuf.h" /* common formats supported as both textures and render targets */ -static unsigned is_blit_supported(gl_format mesa_format) +unsigned r600_check_blit(gl_format mesa_format) { switch (mesa_format) { case MESA_FORMAT_RGBA8888: @@ -1582,7 +1582,7 @@ unsigned r600_blit(GLcontext *ctx, context_t *context = R700_CONTEXT(ctx); int id = 0; - if (!is_blit_supported(dst_mesaformat)) + if (!r600_check_blit(dst_mesaformat)) return GL_FALSE; if (src_bo == dst_bo) { diff --git a/src/mesa/drivers/dri/r600/r600_blit.h b/src/mesa/drivers/dri/r600/r600_blit.h index f280e23489..d56b21ba9b 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.h +++ b/src/mesa/drivers/dri/r600/r600_blit.h @@ -1,3 +1,35 @@ +/* + * Copyright (C) 2009 Advanced Micro Devices, Inc. + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef R600_BLIT_H +#define R600_BLIT_H + +unsigned r600_check_blit(gl_format mesa_format); + unsigned r600_blit(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, @@ -19,3 +51,4 @@ unsigned r600_blit(GLcontext *ctx, unsigned h, unsigned flip_y); +#endif // R600_BLIT_H diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 1a4b014d9f..3d6802e735 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -236,6 +236,7 @@ static void r600_init_vtbl(radeonContextPtr radeon) radeon->vtbl.pre_emit_atoms = r600_vtbl_pre_emit_atoms; radeon->vtbl.fallback = r600_fallback; radeon->vtbl.emit_query_finish = r600_emit_query_finish; + radeon->vtbl.check_blit = r600_check_blit; radeon->vtbl.blit = r600_blit; } diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index 34b9af4063..e188a122d5 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -38,7 +38,7 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, } /* common formats supported as both textures and render targets */ -static unsigned is_blit_supported(gl_format mesa_format) +unsigned r100_check_blit(gl_format mesa_format) { /* XXX others? BE/LE? */ switch (mesa_format) { @@ -333,7 +333,7 @@ unsigned r100_blit(GLcontext *ctx, { struct r100_context *r100 = R100_CONTEXT(ctx); - if (!is_blit_supported(dst_mesaformat)) + if (!r100_check_blit(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.h b/src/mesa/drivers/dri/radeon/radeon_blit.h index d36366ff79..d7d0b5554a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.h +++ b/src/mesa/drivers/dri/radeon/radeon_blit.h @@ -30,6 +30,8 @@ void r100_blit_init(struct r100_context *r100); +unsigned r100_check_blit(gl_format mesa_format); + unsigned r100_blit(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h index e397ee8c22..d1a24e265f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h @@ -518,6 +518,7 @@ struct radeon_context { void (*free_context)(GLcontext *ctx); void (*emit_query_finish)(radeonContextPtr radeon); void (*update_scissor)(GLcontext *ctx); + unsigned (*check_blit)(gl_format mesa_format); unsigned (*blit)(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 4625af14ad..878a453bd5 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -198,6 +198,7 @@ static void r100_init_vtbl(radeonContextPtr radeon) radeon->vtbl.fallback = radeonFallback; radeon->vtbl.free_context = r100_vtbl_free_context; radeon->vtbl.emit_query_finish = r100_emit_query_finish; + radeon->vtbl.check_blit = r100_check_blit; radeon->vtbl.blit = r100_blit; } diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c index 18cf182e54..89fe9915a7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c +++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c @@ -46,6 +46,12 @@ do_copy_texsubimage(GLcontext *ctx, { radeonContextPtr radeon = RADEON_CONTEXT(ctx); struct radeon_renderbuffer *rrb; + unsigned src_bpp; + unsigned dst_bpp; + gl_format src_mesaformat; + gl_format dst_mesaformat; + unsigned src_width; + unsigned dst_width; if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { rrb = radeon_get_depthbuffer(radeon); @@ -76,12 +82,40 @@ do_copy_texsubimage(GLcontext *ctx, } + src_mesaformat = rrb->base.Format; + dst_mesaformat = timg->base.TexFormat; + src_width = rrb->base.Width; + dst_width = timg->base.Width; + src_bpp = _mesa_get_format_bytes(src_mesaformat); + dst_bpp = _mesa_get_format_bytes(dst_mesaformat); + if (!radeon->vtbl.check_blit(dst_mesaformat)) { + if (src_bpp != dst_bpp) + return GL_FALSE; + + switch (dst_bpp) { + case 2: + src_mesaformat = MESA_FORMAT_RGB565; + dst_mesaformat = MESA_FORMAT_RGB565; + break; + case 4: + src_mesaformat = MESA_FORMAT_ARGB8888; + dst_mesaformat = MESA_FORMAT_ARGB8888; + break; + case 1: + src_mesaformat = MESA_FORMAT_A8; + dst_mesaformat = MESA_FORMAT_A8; + break; + default: + return GL_FALSE; + } + } + /* blit from src buffer to texture */ - return radeon->vtbl.blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, - rrb->base.Width, rrb->base.Height, x, y, - timg->mt->bo, dst_offset, timg->base.TexFormat, - timg->mt->levels[level].rowstride / _mesa_get_format_bytes(timg->base.TexFormat), - timg->base.Width, timg->base.Height, + return radeon->vtbl.blit(ctx, rrb->bo, src_offset, src_mesaformat, rrb->pitch/rrb->cpp, + src_width, rrb->base.Height, x, y, + timg->mt->bo, dst_offset, dst_mesaformat, + timg->mt->levels[level].rowstride / dst_bpp, + dst_width, timg->base.Height, dstx, dsty, width, height, 1); } -- cgit v1.2.3 From 8953bfce0eb7e56f13d4527ef86cdf4cf2db037f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 6 Mar 2010 06:33:20 +0200 Subject: dri: drop MINIGLX_SOURCES --- src/mesa/drivers/dri/i810/Makefile | 3 --- src/mesa/drivers/dri/i915/Makefile | 2 -- src/mesa/drivers/dri/i965/Makefile | 1 - src/mesa/drivers/dri/mach64/Makefile | 3 --- src/mesa/drivers/dri/mga/Makefile | 2 -- src/mesa/drivers/dri/nouveau/Makefile | 2 -- src/mesa/drivers/dri/r128/Makefile | 2 -- src/mesa/drivers/dri/r200/Makefile | 2 -- src/mesa/drivers/dri/r300/Makefile | 2 -- src/mesa/drivers/dri/r600/Makefile | 2 -- src/mesa/drivers/dri/radeon/Makefile | 2 -- src/mesa/drivers/dri/savage/Makefile | 3 --- src/mesa/drivers/dri/sis/Makefile | 4 ---- src/mesa/drivers/dri/tdfx/Makefile | 3 --- src/mesa/drivers/dri/unichrome/Makefile | 2 -- 15 files changed, 35 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/i810/Makefile b/src/mesa/drivers/dri/i810/Makefile index 3874faee51..54a837d5ea 100644 --- a/src/mesa/drivers/dri/i810/Makefile +++ b/src/mesa/drivers/dri/i810/Makefile @@ -5,9 +5,6 @@ include $(TOP)/configs/current LIBNAME = i810_dri.so -# Not yet -# MINIGLX_SOURCES = server/i810_dri.c - DRIVER_SOURCES = \ i810context.c \ i810ioctl.c \ diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index dc15ae425c..5b49d0c77c 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -4,8 +4,6 @@ include $(TOP)/configs/current LIBNAME = i915_dri.so -MINIGLX_SOURCES = server/intel_dri.c - DRIVER_SOURCES = \ i830_context.c \ i830_state.c \ diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index f98a1a27db..a242580273 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -99,7 +99,6 @@ DRIVER_SOURCES = \ C_SOURCES = \ $(COMMON_SOURCES) \ - $(MINIGLX_SOURCES) \ $(DRIVER_SOURCES) ASM_SOURCES = diff --git a/src/mesa/drivers/dri/mach64/Makefile b/src/mesa/drivers/dri/mach64/Makefile index a8f463e9fd..c20fdece29 100644 --- a/src/mesa/drivers/dri/mach64/Makefile +++ b/src/mesa/drivers/dri/mach64/Makefile @@ -5,9 +5,6 @@ include $(TOP)/configs/current LIBNAME = mach64_dri.so -# Not yet -# MINIGLX_SOURCES = server/mach64_dri.c - DRIVER_SOURCES = \ mach64_context.c \ mach64_ioctl.c \ diff --git a/src/mesa/drivers/dri/mga/Makefile b/src/mesa/drivers/dri/mga/Makefile index 0cc329fb22..92533bccc2 100644 --- a/src/mesa/drivers/dri/mga/Makefile +++ b/src/mesa/drivers/dri/mga/Makefile @@ -5,8 +5,6 @@ include $(TOP)/configs/current LIBNAME = mga_dri.so -MINIGLX_SOURCES = server/mga_dri.c - DRIVER_SOURCES = \ mgadd.c \ mgaioctl.c \ diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile index 49e8933561..7be19b26fd 100644 --- a/src/mesa/drivers/dri/nouveau/Makefile +++ b/src/mesa/drivers/dri/nouveau/Makefile @@ -8,8 +8,6 @@ DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs) LIBNAME = nouveau_vieux_dri.so -MINIGLX_SOURCES = - DRIVER_SOURCES = \ nouveau_screen.c \ nouveau_context.c \ diff --git a/src/mesa/drivers/dri/r128/Makefile b/src/mesa/drivers/dri/r128/Makefile index 52c5a38a70..8144c9b43f 100644 --- a/src/mesa/drivers/dri/r128/Makefile +++ b/src/mesa/drivers/dri/r128/Makefile @@ -5,8 +5,6 @@ include $(TOP)/configs/current LIBNAME = r128_dri.so -MINIGLX_SOURCES = server/r128_dri.c - DRIVER_SOURCES = \ r128_context.c \ r128_lock.c \ diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index 14eb96c1ba..2e86e8b941 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -7,8 +7,6 @@ CFLAGS += $(RADEON_CFLAGS) LIBNAME = r200_dri.so -MINIGLX_SOURCES = server/radeon_dri.c - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 04459c2ddf..08934fc996 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -7,8 +7,6 @@ CFLAGS += $(RADEON_CFLAGS) LIBNAME = r300_dri.so -MINIGLX_SOURCES = server/radeon_dri.c - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index 5d50941539..2478b12658 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -7,8 +7,6 @@ CFLAGS += $(RADEON_CFLAGS) LIBNAME = r600_dri.so -MINIGLX_SOURCES = server/radeon_dri.c - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index a54ea16ec6..fc6d1c8e89 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -8,8 +8,6 @@ CFLAGS += $(RADEON_CFLAGS) LIBNAME = radeon_dri.so -MINIGLX_SOURCES = server/radeon_dri.c - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/savage/Makefile b/src/mesa/drivers/dri/savage/Makefile index 2e5c40802c..53511552c6 100644 --- a/src/mesa/drivers/dri/savage/Makefile +++ b/src/mesa/drivers/dri/savage/Makefile @@ -5,9 +5,6 @@ include $(TOP)/configs/current LIBNAME = savage_dri.so -# Doesn't exist yet. -#MINIGLX_SOURCES = server/savage_dri.c - DRIVER_SOURCES = \ savage_xmesa.c \ savagedd.c \ diff --git a/src/mesa/drivers/dri/sis/Makefile b/src/mesa/drivers/dri/sis/Makefile index ad009fc239..6b4f938bab 100644 --- a/src/mesa/drivers/dri/sis/Makefile +++ b/src/mesa/drivers/dri/sis/Makefile @@ -5,10 +5,6 @@ include $(TOP)/configs/current LIBNAME = sis_dri.so - -# Not yet -# MINIGLX_SOURCES = server/sis_dri.c - DRIVER_SOURCES = \ sis6326_state.c \ sis6326_clear.c \ diff --git a/src/mesa/drivers/dri/tdfx/Makefile b/src/mesa/drivers/dri/tdfx/Makefile index b9f25db4fe..96bd8f8202 100644 --- a/src/mesa/drivers/dri/tdfx/Makefile +++ b/src/mesa/drivers/dri/tdfx/Makefile @@ -5,9 +5,6 @@ include $(TOP)/configs/current LIBNAME = tdfx_dri.so -# not yet -# MINIGLX_SOURCES = server/tdfx_dri.c - DRIVER_SOURCES = \ tdfx_context.c \ tdfx_dd.c \ diff --git a/src/mesa/drivers/dri/unichrome/Makefile b/src/mesa/drivers/dri/unichrome/Makefile index 344d34fce3..14cf9f3038 100644 --- a/src/mesa/drivers/dri/unichrome/Makefile +++ b/src/mesa/drivers/dri/unichrome/Makefile @@ -5,8 +5,6 @@ include $(TOP)/configs/current LIBNAME = unichrome_dri.so -MINIGLX_SOURCES = server/via_dri.c - DRIVER_SOURCES = \ via_context.c \ via_fb.c \ -- cgit v1.2.3 From 419f0f9d0426bc1eb40ceb60e7764af4013947a0 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 6 Mar 2010 06:33:21 +0200 Subject: dri: drop MINIGLX_SOURCES (2) --- src/mesa/drivers/dri/i810/server/i810_dri.c | 975 ----------------- src/mesa/drivers/dri/i915/server/intel_dri.c | 1 - src/mesa/drivers/dri/i965/server/intel_dri.c | 1 - src/mesa/drivers/dri/intel/server/intel_dri.c | 1306 ---------------------- src/mesa/drivers/dri/mga/server/mga_dri.c | 1088 ------------------ src/mesa/drivers/dri/r128/server/r128_dri.c | 1112 ------------------- src/mesa/drivers/dri/r200/server/radeon_dri.c | 1 - src/mesa/drivers/dri/r300/server/radeon_dri.c | 1 - src/mesa/drivers/dri/r600/server/radeon_dri.c | 1 - src/mesa/drivers/dri/radeon/server/radeon_dri.c | 1337 ----------------------- src/mesa/drivers/dri/tdfx/server/tdfx_dri.c | 471 -------- src/mesa/drivers/dri/unichrome/server/via_dri.c | 1251 --------------------- 12 files changed, 7545 deletions(-) delete mode 100644 src/mesa/drivers/dri/i810/server/i810_dri.c delete mode 120000 src/mesa/drivers/dri/i915/server/intel_dri.c delete mode 120000 src/mesa/drivers/dri/i965/server/intel_dri.c delete mode 100644 src/mesa/drivers/dri/intel/server/intel_dri.c delete mode 100644 src/mesa/drivers/dri/mga/server/mga_dri.c delete mode 100644 src/mesa/drivers/dri/r128/server/r128_dri.c delete mode 120000 src/mesa/drivers/dri/r200/server/radeon_dri.c delete mode 120000 src/mesa/drivers/dri/r300/server/radeon_dri.c delete mode 120000 src/mesa/drivers/dri/r600/server/radeon_dri.c delete mode 100644 src/mesa/drivers/dri/radeon/server/radeon_dri.c delete mode 100644 src/mesa/drivers/dri/tdfx/server/tdfx_dri.c delete mode 100644 src/mesa/drivers/dri/unichrome/server/via_dri.c (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/i810/server/i810_dri.c b/src/mesa/drivers/dri/i810/server/i810_dri.c deleted file mode 100644 index f52797c5ed..0000000000 --- a/src/mesa/drivers/dri/i810/server/i810_dri.c +++ /dev/null @@ -1,975 +0,0 @@ -/** - * \file server/i810_dri.c - * \brief File to perform the device-specific initialization tasks typically - * done in the X server. - * - * Here they are converted to run in the client (or perhaps a standalone - * process), and to work with the frame buffer device rather than the X - * server infrastructure. - * - * Copyright (C) 2004 Dave Airlie (airlied@linux.ie) - */ - -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" - -#include "i810.h" -#include "i810_dri.h" -#include "i810_reg.h" - - -static int i810_pitches[] = { - 512, - 1024, - 2048, - 4096, - 0 -}; - -static int i810_pitch_flags[] = { - 0x0, - 0x1, - 0x2, - 0x3, - 0 -}; - -static unsigned int i810_drm_version = 0; - -static int -I810AllocLow(I810MemRange * result, I810MemRange * pool, int size) -{ - if (size > pool->Size) - return 0; - - pool->Size -= size; - result->Size = size; - result->Start = pool->Start; - result->End = pool->Start += size; - - return 1; -} - -static int -I810AllocHigh(I810MemRange * result, I810MemRange * pool, int size) -{ - if (size > pool->Size) - return 0; - - pool->Size -= size; - result->Size = size; - result->End = pool->End; - result->Start = pool->End -= size; - - return 1; -} - - -/** - * \brief Wait for free FIFO entries. - * - * \param ctx display handle. - * \param entries number of free entries to wait. - * - * It polls the free entries from the chip until it reaches the requested value - * or a timeout (3000 tries) occurs. Aborts the program if the FIFO times out. - */ -static void I810WaitForFifo( const DRIDriverContext *ctx, - int entries ) -{ -} - -/** - * \brief Reset graphics card to known state. - * - * \param ctx display handle. - * - * Resets the values of several I810 registers. - */ -static void I810EngineReset( const DRIDriverContext *ctx ) -{ - unsigned char *I810MMIO = ctx->MMIOAddress; -} - -/** - * \brief Restore the drawing engine. - * - * \param ctx display handle - * - * Resets the graphics card and sets initial values for several registers of - * the card's drawing engine. - * - * Turns on the i810 command processor engine (i.e., the ringbuffer). - */ -static int I810EngineRestore( const DRIDriverContext *ctx ) -{ - I810Ptr info = ctx->driverPrivate; - unsigned char *I810MMIO = ctx->MMIOAddress; - - fprintf(stderr, "%s\n", __FUNCTION__); - - return 1; -} - - -/** - * \brief Shutdown the drawing engine. - * - * \param ctx display handle - * - * Turns off the command processor engine & restores the graphics card - * to a state that fbdev understands. - */ -static int I810EngineShutdown( const DRIDriverContext *ctx ) -{ - drmI810Init info; - int ret; - - memset(&info, 0, sizeof(drmI810Init)); - info.func = I810_CLEANUP_DMA; - - ret = drmCommandWrite(ctx->drmFD, DRM_I810_INIT, &info, sizeof(drmI810Init)); - if (ret>0) - { - fprintf(stderr,"[dri] I810 DMA Cleanup failed\n"); - return -errno; - } - return 0; -} - -/** - * \brief Compute base 2 logarithm. - * - * \param val value. - * - * \return base 2 logarithm of \p val. - */ -static int I810MinBits(int val) -{ - int bits; - - if (!val) return 1; - for (bits = 0; val; val >>= 1, ++bits); - return bits; -} - -static int I810DRIAgpPreInit( const DRIDriverContext *ctx, I810Ptr info) -{ - - if (drmAgpAcquire(ctx->drmFD) < 0) { - fprintf(stderr, "[gart] AGP not available\n"); - return 0; - } - - - if (drmAgpEnable(ctx->drmFD, 0) < 0) { - fprintf(stderr, "[gart] AGP not enabled\n"); - drmAgpRelease(ctx->drmFD); - return 0; - } -} - -/** - * \brief Initialize the AGP state - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Acquires and enables the AGP device. Reserves memory in the AGP space for - * the ring buffer, vertex buffers and textures. Initialize the I810 - * registers to point to that memory and add client mappings. - */ -static int I810DRIAgpInit( const DRIDriverContext *ctx, I810Ptr info) -{ - unsigned char *I810MMIO = ctx->MMIOAddress; - int ret; - int s, l; - unsigned long dcacheHandle; - unsigned long agpHandle; - int pitch_idx = 0; - int back_size = 0; - int sysmem_size = 0; - int width = ctx->shared.virtualWidth * ctx->cpp; - - - info->backHandle = DRM_AGP_NO_HANDLE; - info->zHandle = DRM_AGP_NO_HANDLE; - info->sysmemHandle = DRM_AGP_NO_HANDLE; - info->dcacheHandle = DRM_AGP_NO_HANDLE; - - memset(&info->DcacheMem, 0, sizeof(I810MemRange)); - memset(&info->BackBuffer, 0, sizeof(I810MemRange)); - memset(&info->DepthBuffer, 0, sizeof(I810MemRange)); - - drmAgpAlloc(ctx->drmFD, 4096 * 1024, 1, NULL, &dcacheHandle); - info->dcacheHandle = dcacheHandle; - - fprintf(stderr, "[agp] dcacheHandle : 0x%x\n", dcacheHandle); - -#define Elements(x) sizeof(x)/sizeof(*x) - for (pitch_idx = 0; pitch_idx < Elements(i810_pitches); pitch_idx++) - if (width <= i810_pitches[pitch_idx]) - break; - - if (pitch_idx == Elements(i810_pitches)) { - fprintf(stderr,"[dri] Couldn't find depth/back buffer pitch\n"); - exit(-1); - } - else - { - int lines = (ctx->shared.virtualWidth + 15) / 16 * 16; - back_size = i810_pitches[pitch_idx] * lines; - back_size = ((back_size + 4096 - 1) / 4096) * 4096; - } - - sysmem_size = ctx->shared.fbSize; - fprintf(stderr,"sysmem_size is %lu back_size is %lu\n", sysmem_size, back_size); - if (dcacheHandle != DRM_AGP_NO_HANDLE) { - if (back_size > 4 * 1024 * 1024) { - fprintf(stderr,"[dri] Backsize is larger then 4 meg\n"); - sysmem_size = sysmem_size - 2 * back_size; - drmAgpFree(ctx->drmFD, dcacheHandle); - info->dcacheHandle = dcacheHandle = DRM_AGP_NO_HANDLE; - } else { - sysmem_size = sysmem_size - back_size; - } - } else { - sysmem_size = sysmem_size - 2 * back_size; - } - - info->SysMem.Start=0; - info->SysMem.Size = sysmem_size; - info->SysMem.End = sysmem_size; - - if (dcacheHandle != DRM_AGP_NO_HANDLE) { - if (drmAgpBind(ctx->drmFD, dcacheHandle, info->DepthOffset) == 0) { - memset(&info->DcacheMem, 0, sizeof(I810MemRange)); - fprintf(stderr,"[agp] GART: Found 4096K Z buffer memory\n"); - info->DcacheMem.Start = info->DepthOffset; - info->DcacheMem.Size = 1024 * 4096; - info->DcacheMem.End = info->DcacheMem.Start + info->DcacheMem.Size; - } else { - fprintf(stderr, "[agp] GART: dcache bind failed\n"); - drmAgpFree(ctx->drmFD, dcacheHandle); - info->dcacheHandle = dcacheHandle = DRM_AGP_NO_HANDLE; - } - } else { - fprintf(stderr, "[agp] GART: no dcache memory found\n"); - } - - drmAgpAlloc(ctx->drmFD, back_size, 0, NULL, &agpHandle); - info->backHandle = agpHandle; - - if (agpHandle != DRM_AGP_NO_HANDLE) { - if (drmAgpBind(ctx->drmFD, agpHandle, info->BackOffset) == 0) { - fprintf(stderr, "[agp] Bound backbuffer memory\n"); - - info->BackBuffer.Start = info->BackOffset; - info->BackBuffer.Size = back_size; - info->BackBuffer.End = (info->BackBuffer.Start + - info->BackBuffer.Size); - } else { - fprintf(stderr,"[agp] Unable to bind backbuffer. Disabling DRI.\n"); - return 0; - } - } else { - fprintf(stderr, "[dri] Unable to allocate backbuffer memory. Disabling DRI.\n"); - return 0; - } - - if (dcacheHandle == DRM_AGP_NO_HANDLE) { - drmAgpAlloc(ctx->drmFD, back_size, 0, NULL, &agpHandle); - - info->zHandle = agpHandle; - - if (agpHandle != DRM_AGP_NO_HANDLE) { - if (drmAgpBind(ctx->drmFD, agpHandle, info->DepthOffset) == 0) { - fprintf(stderr,"[agp] Bound depthbuffer memory\n"); - info->DepthBuffer.Start = info->DepthOffset; - info->DepthBuffer.Size = back_size; - info->DepthBuffer.End = (info->DepthBuffer.Start + - info->DepthBuffer.Size); - } else { - fprintf(stderr,"[agp] Unable to bind depthbuffer. Disabling DRI.\n"); - return 0; - } - } else { - fprintf(stderr,"[agp] Unable to allocate depthbuffer memory. Disabling DRI.\n"); - return 0; - } - } - - /* Now allocate and bind the agp space. This memory will include the - * regular framebuffer as well as texture memory. - */ - drmAgpAlloc(ctx->drmFD, sysmem_size, 0, NULL, &agpHandle); - info->sysmemHandle = agpHandle; - - if (agpHandle != DRM_AGP_NO_HANDLE) { - if (drmAgpBind(ctx->drmFD, agpHandle, 0) == 0) { - fprintf(stderr, "[agp] Bound System Texture Memory\n"); - } else { - fprintf(stderr, "[agp] Unable to bind system texture memory. Disabling DRI.\n"); - return 0; - } - } else { - fprintf(stderr, "[agp] Unable to allocate system texture memory. Disabling DRI.\n"); - return 0; - } - - info->auxPitch = i810_pitches[pitch_idx]; - info->auxPitchBits = i810_pitch_flags[pitch_idx]; - - return 1; -} - - -/** - * \brief Initialize the kernel data structures and enable the CP engine. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * This function is a wrapper around the DRM_I810_CP_INIT command, passing - * all the parameters in a drmI810Init structure. - */ -static int I810DRIKernelInit( const DRIDriverContext *ctx, - I810Ptr info) -{ - int cpp = ctx->bpp / 8; - drmI810Init drmInfo; - int ret; - I810RingBuffer *ring = &(info->LpRing); - - /* This is the struct passed to the kernel module for its initialization */ - memset(&drmInfo, 0, sizeof(drmI810Init)); - - /* make sure we have at least 1.4 */ - drmInfo.func = I810_INIT_DMA_1_4; - - drmInfo.ring_start = ring->mem.Start; - drmInfo.ring_end = ring->mem.End; - drmInfo.ring_size = ring->mem.Size; - - drmInfo.mmio_offset = (unsigned int)info->regs; - drmInfo.buffers_offset = (unsigned int)info->buffer_map; - drmInfo.sarea_priv_offset = sizeof(drm_sarea_t); - - drmInfo.front_offset = 0; - drmInfo.back_offset = info->BackBuffer.Start; - drmInfo.depth_offset = info->DepthBuffer.Start; - - drmInfo.w = ctx->shared.virtualWidth; - drmInfo.h = ctx->shared.virtualHeight; - drmInfo.pitch = info->auxPitch; - drmInfo.pitch_bits = info->auxPitchBits; - - - ret = drmCommandWrite(ctx->drmFD, DRM_I810_INIT, &drmInfo, - sizeof(drmI810Init)); - - return ret >= 0; -} - - -/** - * \brief Add a map for the vertex buffers that will be accessed by any - * DRI-based clients. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Calls drmAddBufs() with the previously allocated vertex buffers. - */ -static int I810DRIBufInit( const DRIDriverContext *ctx, I810Ptr info ) -{ - /* Initialize vertex buffers */ - info->bufNumBufs = drmAddBufs(ctx->drmFD, - I810_DMA_BUF_NR, - I810_DMA_BUF_SZ, - DRM_AGP_BUFFER, - info->BufferMem.Start); - - if (info->bufNumBufs <= 0) { - fprintf(stderr, - "[drm] Could not create vertex/indirect buffers list\n"); - return 0; - } - fprintf(stderr, - "[drm] Added %d %d byte vertex/indirect buffers\n", - info->bufNumBufs, I810_DMA_BUF_SZ); - - return 1; -} - -/** - * \brief Install an IRQ handler. - * - * \param ctx display handle. - * \param info driver private data. - * - * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to - * IRQ-free operation on failure. - */ -static void I810DRIIrqInit(const DRIDriverContext *ctx, - I810Ptr info) -{ - if (!info->irq) { - info->irq = drmGetInterruptFromBusID(ctx->drmFD, - ctx->pciBus, - ctx->pciDevice, - ctx->pciFunc); - - if ((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) { - fprintf(stderr, - "[drm] failure adding irq handler, " - "there is a device already using that irq\n" - "[drm] falling back to irq-free operation\n"); - info->irq = 0; - } - } - - if (info->irq) - fprintf(stderr, - "[drm] dma control initialized, using IRQ %d\n", - info->irq); -} - -static int I810CheckDRMVersion( const DRIDriverContext *ctx, - I810Ptr info ) -{ - drmVersionPtr version; - - version = drmGetVersion(ctx->drmFD); - if (version) { - int req_minor, req_patch; - - req_minor = 4; - req_patch = 0; - - i810_drm_version = (version->version_major<<16) | version->version_minor; - if (version->version_major != 1 || - version->version_minor < req_minor || - (version->version_minor == req_minor && - version->version_patchlevel < req_patch)) { - /* Incompatible drm version */ - fprintf(stderr, - "[dri] I810DRIScreenInit failed because of a version " - "mismatch.\n" - "[dri] i810.o kernel module version is %d.%d.%d " - "but version 1.%d.%d or newer is needed.\n" - "[dri] Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel, - req_minor, - req_patch); - drmFreeVersion(version); - return 0; - } - - info->drmMinor = version->version_minor; - drmFreeVersion(version); - } - - return 1; -} - -static int I810MemoryInit( const DRIDriverContext *ctx, I810Ptr info ) -{ - int width_bytes = ctx->shared.virtualWidth * ctx->cpp; - int cpp = ctx->cpp; - int bufferSize = (ctx->shared.virtualHeight * width_bytes); - int depthSize = (((ctx->shared.virtualHeight+15) & ~15) * width_bytes); - int l; - - if (drmAddMap(ctx->drmFD, (drm_handle_t) info->BackBuffer.Start, - info->BackBuffer.Size, DRM_AGP, 0, - &info->backbuffer) < 0) { - fprintf(stderr, "[drm] drmAddMap(backbuffer) failed. Disabling DRI\n"); - return 0; - } - - if (drmAddMap(ctx->drmFD, (drm_handle_t) info->DepthBuffer.Start, - info->DepthBuffer.Size, DRM_AGP, 0, - &info->depthbuffer) < 0) { - fprintf(stderr, "[drm] drmAddMap(depthbuffer) failed. Disabling DRI.\n"); - return 0; - } - - if (!I810AllocLow(&(info->FrontBuffer), &(info->SysMem), (((ctx->shared.virtualHeight * width_bytes) + 4095) & ~4095))) - { - fprintf(stderr,"Framebuffer allocation failed\n"); - return 0; - } - else - fprintf(stderr,"Frame buffer at 0x%.8x (%luk, %lu bytes)\n", - info->FrontBuffer.Start, - info->FrontBuffer.Size / 1024, info->FrontBuffer.Size); - - memset(&(info->LpRing), 0, sizeof(I810RingBuffer)); - if (I810AllocLow(&(info->LpRing.mem), &(info->SysMem), 16 * 4096)) { - fprintf(stderr, - "Ring buffer at 0x%.8x (%luk, %lu bytes)\n", - info->LpRing.mem.Start, - info->LpRing.mem.Size / 1024, info->LpRing.mem.Size); - - info->LpRing.tail_mask = info->LpRing.mem.Size - 1; - info->LpRing.virtual_start = info->LpRing.mem.Start; - info->LpRing.head = 0; - info->LpRing.tail = 0; - info->LpRing.space = 0; - } else { - fprintf(stderr, "Ring buffer allocation failed\n"); - return (0); - } - - /* Allocate buffer memory */ - I810AllocHigh(&(info->BufferMem), &(info->SysMem), - I810_DMA_BUF_NR * I810_DMA_BUF_SZ); - - - fprintf(stderr, "[dri] Buffer map : %lx\n", - info->BufferMem.Start); - - if (info->BufferMem.Start == 0 || - info->BufferMem.End - info->BufferMem.Start > - I810_DMA_BUF_NR * I810_DMA_BUF_SZ) { - fprintf(stderr,"[dri] Not enough memory for dma buffers. Disabling DRI.\n"); - return 0; - } - - if (drmAddMap(ctx->drmFD, (drm_handle_t) info->BufferMem.Start, - info->BufferMem.Size, DRM_AGP, 0, &info->buffer_map) < 0) { - fprintf(stderr, "[drm] drmAddMap(buffer_map) failed. Disabling DRI.\n"); - return 0; - } - - if (drmAddMap(ctx->drmFD, (drm_handle_t) info->LpRing.mem.Start, - info->LpRing.mem.Size, DRM_AGP, 0, &info->ring_map) < 0) { - fprintf(stderr, "[drm] drmAddMap(ring_map) failed. Disabling DRI. \n"); - return 0; - } - - /* Front, back and depth buffers - everything else texture?? - */ - info->textureSize = info->SysMem.Size; - - if (info->textureSize < 0) - return 0; - - - l = I810MinBits((info->textureSize-1) / I810_NR_TEX_REGIONS); - if (l < I810_LOG_MIN_TEX_REGION_SIZE) l = I810_LOG_MIN_TEX_REGION_SIZE; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't - * round down. - */ - info->logTextureGranularity = l; - info->textureSize = (info->textureSize >> l) << l; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256x32bpp textures. - */ - if (info->textureSize < 512 * 1024) { - info->textureOffset = 0; - info->textureSize = 0; - } - - I810AllocLow(&(info->TexMem), &(info->SysMem), info->textureSize); - - if (drmAddMap(ctx->drmFD, (drm_handle_t) info->TexMem.Start, - info->TexMem.Size, DRM_AGP, 0, &info->textures) < 0) { - fprintf(stderr, - "[drm] drmAddMap(textures) failed. Disabling DRI.\n"); - return 0; - } - - /* Reserve space for textures */ - fprintf(stderr, - "Will use back buffer at offset 0x%x\n", - info->BackOffset); - fprintf(stderr, - "Will use depth buffer at offset 0x%x\n", - info->DepthOffset); - fprintf(stderr, - "Will use %d kb for textures at offset 0x%x\n", - info->TexMem.Size/1024, info->TexMem.Start); - - return 1; -} - - - -/** - * Called at the start of each server generation. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Performs static frame buffer allocation. Opens the DRM device and add maps - * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more - * information. Creates a \e server context to grab the lock for the - * initialization ioctls and calls the other initilization functions in this - * file. Starts the CP engine via the DRM_I810_CP_START command. - * - * Setups a I810DRIRec structure to be passed to i810_dri.so for its - * initialization. - */ -static int I810ScreenInit( DRIDriverContext *ctx, I810Ptr info ) -{ - I810DRIPtr pI810DRI; - int err; - - usleep(100); - /*assert(!ctx->IsClient);*/ - - /* from XFree86 driver */ - info->DepthOffset = 0x3000000; - info->BackOffset = 0x3800000; - { - int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); - int maxy = ctx->shared.fbSize / width_bytes; - - - if (maxy <= ctx->shared.virtualHeight * 3) { - fprintf(stderr, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (ctx->shared.virtualWidth * ctx->shared.virtualHeight * - ctx->cpp * 3 + 1023) / 1024, - ctx->shared.fbSize / 1024); - return 0; - } - } - - - info->regsSize = ctx->MMIOSize; - ctx->shared.SAREASize = 0x2000; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("i810", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - if (drmAddMap(ctx->drmFD, - ctx->MMIOStart, - ctx->MMIOSize, - DRM_REGISTERS, - DRM_READ_ONLY, - &info->regs) < 0) { - fprintf(stderr, "[drm] drmAddMap mmio failed\n"); - return 0; - } - fprintf(stderr, - "[drm] register handle = 0x%08x\n", info->regs); - - I810DRIAgpPreInit(ctx, info); - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, -#ifndef _EMBEDDED - 0, -#else - DRM_READ_ONLY, -#endif - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - /* Check the i810 DRM version */ - if (!I810CheckDRMVersion(ctx, info)) { - return 0; - } - - /* Initialize AGP */ - if (!I810DRIAgpInit(ctx, info)) { - return 0; - } - - - /* Memory manager setup */ - if (!I810MemoryInit(ctx, info)) { - return 0; - } - - /* Initialize the SAREA private data structure */ - { - I810SAREAPtr pSAREAPriv; - pSAREAPriv = (I810SAREAPtr)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - // pSAREAPriv->pf_enabled=1; - } - - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the vertex buffers list */ - if (!I810DRIBufInit(ctx, info)) { - fprintf(stderr, "I810DRIBufInit failed\n"); - DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); - return 0; - } - - /* Initialize the kernel data structures */ - if (!I810DRIKernelInit(ctx, info)) { - fprintf(stderr, "I810DRIKernelInit failed\n"); - DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); - return 0; - } - - /* Initialize IRQ */ - I810DRIIrqInit(ctx, info); - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ -#if 0 - memset((char *)ctx->FBAddress, - 0, - info->auxPitch * ctx->cpp * ctx->shared.virtualHeight ); - - memset((char *)info->backbuffer, - 0, - info->auxPitch * ctx->cpp * ctx->shared.virtualHeight ); -#endif - - /* This is the struct passed to i810_dri.so for its initialization */ - ctx->driverClientMsg = malloc(sizeof(I810DRIRec)); - ctx->driverClientMsgSize = sizeof(I810DRIRec); - pI810DRI = (I810DRIPtr)ctx->driverClientMsg; - - pI810DRI->regs = info->regs; - pI810DRI->regsSize = info->regsSize; - // regsMap is unused - - pI810DRI->backbufferSize = info->BackBuffer.Size; - pI810DRI->backbuffer = info->backbuffer; - - pI810DRI->depthbufferSize = info->DepthBuffer.Size; - pI810DRI->depthbuffer = info->depthbuffer; - - pI810DRI->textures = info->textures; - pI810DRI->textureSize = info->textureSize; - - pI810DRI->agp_buffers = info->buffer_map; - pI810DRI->agp_buf_size = info->BufferMem.Size; - - pI810DRI->deviceID = info->Chipset; - pI810DRI->width = ctx->shared.virtualWidth; - pI810DRI->height = ctx->shared.virtualHeight; - pI810DRI->mem = ctx->shared.fbSize; - pI810DRI->cpp = ctx->bpp / 8; - pI810DRI->bitsPerPixel = ctx->bpp; - pI810DRI->fbOffset = info->FrontBuffer.Start; - pI810DRI->fbStride = info->auxPitch; - - pI810DRI->backOffset = info->BackBuffer.Start; - pI810DRI->depthOffset = info->DepthBuffer.Start; - - pI810DRI->auxPitch = info->auxPitch; - pI810DRI->auxPitchBits = info->auxPitchBits; - - pI810DRI->logTextureGranularity = info->logTextureGranularity; - pI810DRI->textureOffset = info->TexMem.Start; - - pI810DRI->ringOffset = info->LpRing.mem.Start; - pI810DRI->ringSize = info->LpRing.mem.Size; - - // drmBufs looks unused - pI810DRI->irq = info->irq; - pI810DRI->sarea_priv_offset = sizeof(drm_sarea_t); - - /* Don't release the lock now - let the VT switch handler do it. */ - return 1; -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa i810ValidateMode(). - */ -static int i810ValidateMode( const DRIDriverContext *ctx ) -{ - unsigned char *I810MMIO = ctx->MMIOAddress; - I810Ptr info = ctx->driverPrivate; - - return 1; -} - - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa i810ValidateMode(). - */ -static int i810PostValidateMode( const DRIDriverContext *ctx ) -{ - unsigned char *I810MMIO = ctx->MMIOAddress; - I810Ptr info = ctx->driverPrivate; - - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p ctx - * and then calls I810ScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int i810InitFBDev( DRIDriverContext *ctx ) -{ - I810Ptr info = calloc(1, sizeof(*info)); - - { - int dummy = ctx->shared.virtualWidth; - - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - - ctx->shared.virtualWidth = dummy; - } - - ctx->driverPrivate = (void *)info; - - info->Chipset = ctx->chipset; - - if (!I810ScreenInit( ctx, info )) - return 0; - - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void i810HaltFBDev( DRIDriverContext *ctx ) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - - -extern void i810NotifyFocus( int ); - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -const struct DRIDriverRec __driDriver = { - i810ValidateMode, - i810PostValidateMode, - i810InitFBDev, - i810HaltFBDev, - I810EngineShutdown, - I810EngineRestore, -#ifndef _EMBEDDED - 0, -#else - i810NotifyFocus, -#endif -}; diff --git a/src/mesa/drivers/dri/i915/server/intel_dri.c b/src/mesa/drivers/dri/i915/server/intel_dri.c deleted file mode 120000 index effdd26448..0000000000 --- a/src/mesa/drivers/dri/i915/server/intel_dri.c +++ /dev/null @@ -1 +0,0 @@ -../../intel/server/intel_dri.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/i965/server/intel_dri.c b/src/mesa/drivers/dri/i965/server/intel_dri.c deleted file mode 120000 index effdd26448..0000000000 --- a/src/mesa/drivers/dri/i965/server/intel_dri.c +++ /dev/null @@ -1 +0,0 @@ -../../intel/server/intel_dri.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/intel/server/intel_dri.c b/src/mesa/drivers/dri/intel/server/intel_dri.c deleted file mode 100644 index e49c4214ad..0000000000 --- a/src/mesa/drivers/dri/intel/server/intel_dri.c +++ /dev/null @@ -1,1306 +0,0 @@ -/** - * \file server/intel_dri.c - * \brief File to perform the device-specific initialization tasks typically - * done in the X server. - * - * Here they are converted to run in the client (or perhaps a standalone - * process), and to work with the frame buffer device rather than the X - * server infrastructure. - * - * Copyright (C) 2006 Dave Airlie (airlied@linux.ie) - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sub license, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice (including the - next paragraph) shall be included in all copies or substantial portions - of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR - ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" - -#include "intel.h" -#include "i830_dri.h" - -#include "memops.h" -#include "pciaccess.h" - -static size_t drm_page_size; -static int nextTile = 0; -#define xf86DrvMsg(...) do {} while(0) - -static const int pitches[] = { - 128 * 8, - 128 * 16, - 128 * 32, - 128 * 64, - 0 -}; - -static Bool I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea); - -static unsigned long -GetBestTileAlignment(unsigned long size) -{ - unsigned long i; - - for (i = KB(512); i < size; i <<= 1) - ; - - if (i > MB(64)) - i = MB(64); - - return i; -} - -static void SetFenceRegs(const DRIDriverContext *ctx, I830Rec *pI830) -{ - int i; - unsigned char *MMIO = ctx->MMIOAddress; - - for (i = 0; i < 8; i++) { - OUTREG(FENCE + i * 4, pI830->Fence[i]); - // if (I810_DEBUG & DEBUG_VERBOSE_VGA) - fprintf(stderr,"Fence Register : %x\n", pI830->Fence[i]); - } -} - -/* Tiled memory is good... really, really good... - * - * Need to make it less likely that we miss out on this - probably - * need to move the frontbuffer away from the 'guarenteed' alignment - * of the first memory segment, or perhaps allocate a discontigous - * framebuffer to get more alignment 'sweet spots'. - */ -static void -SetFence(const DRIDriverContext *ctx, I830Rec *pI830, - int nr, unsigned int start, unsigned int pitch, - unsigned int size) -{ - unsigned int val; - unsigned int fence_mask = 0; - unsigned int fence_pitch; - - if (nr < 0 || nr > 7) { - fprintf(stderr, - "SetFence: fence %d out of range\n",nr); - return; - } - - pI830->Fence[nr] = 0; - - if (IS_I9XX(pI830)) - fence_mask = ~I915G_FENCE_START_MASK; - else - fence_mask = ~I830_FENCE_START_MASK; - - if (start & fence_mask) { - fprintf(stderr, - "SetFence: %d: start (0x%08x) is not %s aligned\n", - nr, start, (IS_I9XX(pI830)) ? "1MB" : "512k"); - return; - } - - if (start % size) { - fprintf(stderr, - "SetFence: %d: start (0x%08x) is not size (%dk) aligned\n", - nr, start, size / 1024); - return; - } - - if (pitch & 127) { - fprintf(stderr, - "SetFence: %d: pitch (%d) not a multiple of 128 bytes\n", - nr, pitch); - return; - } - - val = (start | FENCE_X_MAJOR | FENCE_VALID); - - if (IS_I9XX(pI830)) { - switch (size) { - case MB(1): - val |= I915G_FENCE_SIZE_1M; - break; - case MB(2): - val |= I915G_FENCE_SIZE_2M; - break; - case MB(4): - val |= I915G_FENCE_SIZE_4M; - break; - case MB(8): - val |= I915G_FENCE_SIZE_8M; - break; - case MB(16): - val |= I915G_FENCE_SIZE_16M; - break; - case MB(32): - val |= I915G_FENCE_SIZE_32M; - break; - case MB(64): - val |= I915G_FENCE_SIZE_64M; - break; - default: - fprintf(stderr, - "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024); - return; - } - } else { - switch (size) { - case KB(512): - val |= FENCE_SIZE_512K; - break; - case MB(1): - val |= FENCE_SIZE_1M; - break; - case MB(2): - val |= FENCE_SIZE_2M; - break; - case MB(4): - val |= FENCE_SIZE_4M; - break; - case MB(8): - val |= FENCE_SIZE_8M; - break; - case MB(16): - val |= FENCE_SIZE_16M; - break; - case MB(32): - val |= FENCE_SIZE_32M; - break; - case MB(64): - val |= FENCE_SIZE_64M; - break; - default: - fprintf(stderr, - "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024); - return; - } - } - - if (IS_I9XX(pI830)) - fence_pitch = pitch / 512; - else - fence_pitch = pitch / 128; - - switch (fence_pitch) { - case 1: - val |= FENCE_PITCH_1; - break; - case 2: - val |= FENCE_PITCH_2; - break; - case 4: - val |= FENCE_PITCH_4; - break; - case 8: - val |= FENCE_PITCH_8; - break; - case 16: - val |= FENCE_PITCH_16; - break; - case 32: - val |= FENCE_PITCH_32; - break; - case 64: - val |= FENCE_PITCH_64; - break; - default: - fprintf(stderr, - "SetFence: %d: illegal pitch (%d)\n", nr, pitch); - return; - } - - pI830->Fence[nr] = val; -} - -static Bool -MakeTiles(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *pMem) -{ - int pitch, ntiles, i; - - pitch = pMem->Pitch * ctx->cpp; - /* - * Simply try to break the region up into at most four pieces of size - * equal to the alignment. - */ - ntiles = ROUND_TO(pMem->Size, pMem->Alignment) / pMem->Alignment; - if (ntiles >= 4) { - return FALSE; - } - - for (i = 0; i < ntiles; i++, nextTile++) { - SetFence(ctx, pI830, nextTile, pMem->Start + i * pMem->Alignment, - pitch, pMem->Alignment); - } - return TRUE; -} - -static void I830SetupMemoryTiling(const DRIDriverContext *ctx, I830Rec *pI830) -{ - int i; - - /* Clear out */ - for (i = 0; i < 8; i++) - pI830->Fence[i] = 0; - - nextTile = 0; - - if (pI830->BackBuffer.Alignment >= KB(512)) { - if (MakeTiles(ctx, pI830, &(pI830->BackBuffer))) { - fprintf(stderr, - "Activating tiled memory for the back buffer.\n"); - } else { - fprintf(stderr, - "MakeTiles failed for the back buffer.\n"); - pI830->allowPageFlip = FALSE; - } - } - - if (pI830->DepthBuffer.Alignment >= KB(512)) { - if (MakeTiles(ctx, pI830, &(pI830->DepthBuffer))) { - fprintf(stderr, - "Activating tiled memory for the depth buffer.\n"); - } else { - fprintf(stderr, - "MakeTiles failed for the depth buffer.\n"); - } - } - - return; -} - -static int I830DetectMemory(const DRIDriverContext *ctx, I830Rec *pI830) -{ - struct pci_device host_bridge, ig_dev; - uint32_t gmch_ctrl; - int memsize = 0; - int range; - uint32_t aper_size; - uint32_t membase2 = 0; - - memset(&host_bridge, 0, sizeof(host_bridge)); - memset(&ig_dev, 0, sizeof(ig_dev)); - - ig_dev.dev = 2; - - pci_device_cfg_read_u32(&host_bridge, &gmch_ctrl, I830_GMCH_CTRL); - - if (IS_I830(pI830) || IS_845G(pI830)) { - if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { - aper_size = 0x80000000; - } else { - aper_size = 0x40000000; - } - } else { - if (IS_I9XX(pI830)) { - int ret; - ret = pci_device_cfg_read_u32(&ig_dev, &membase2, 0x18); - if (membase2 & 0x08000000) - aper_size = 0x8000000; - else - aper_size = 0x10000000; - - fprintf(stderr,"aper size is %08X %08x %d\n", aper_size, membase2, ret); - } else - aper_size = 0x8000000; - } - - pI830->aper_size = aper_size; - - - /* We need to reduce the stolen size, by the GTT and the popup. - * The GTT varying according the the FbMapSize and the popup is 4KB */ - range = (ctx->shared.fbSize / (1024*1024)) + 4; - - if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) { - switch (gmch_ctrl & I830_GMCH_GMS_MASK) { - case I855_GMCH_GMS_STOLEN_1M: - memsize = MB(1) - KB(range); - break; - case I855_GMCH_GMS_STOLEN_4M: - memsize = MB(4) - KB(range); - break; - case I855_GMCH_GMS_STOLEN_8M: - memsize = MB(8) - KB(range); - break; - case I855_GMCH_GMS_STOLEN_16M: - memsize = MB(16) - KB(range); - break; - case I855_GMCH_GMS_STOLEN_32M: - memsize = MB(32) - KB(range); - break; - case I915G_GMCH_GMS_STOLEN_48M: - if (IS_I9XX(pI830)) - memsize = MB(48) - KB(range); - break; - case I915G_GMCH_GMS_STOLEN_64M: - if (IS_I9XX(pI830)) - memsize = MB(64) - KB(range); - break; - } - } else { - switch (gmch_ctrl & I830_GMCH_GMS_MASK) { - case I830_GMCH_GMS_STOLEN_512: - memsize = KB(512) - KB(range); - break; - case I830_GMCH_GMS_STOLEN_1024: - memsize = MB(1) - KB(range); - break; - case I830_GMCH_GMS_STOLEN_8192: - memsize = MB(8) - KB(range); - break; - case I830_GMCH_GMS_LOCAL: - memsize = 0; - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "Local memory found, but won't be used.\n"); - break; - } - } - if (memsize > 0) { - fprintf(stderr, - "detected %d kB stolen memory.\n", memsize / 1024); - } else { - fprintf(stderr, - "no video memory detected.\n"); - } - return memsize; -} - -static int AgpInit(const DRIDriverContext *ctx, I830Rec *info) -{ - unsigned long mode = 0x4; - - if (drmAgpAcquire(ctx->drmFD) < 0) { - fprintf(stderr, "[gart] AGP not available\n"); - return 0; - } - - if (drmAgpEnable(ctx->drmFD, mode) < 0) { - fprintf(stderr, "[gart] AGP not enabled\n"); - drmAgpRelease(ctx->drmFD); - return 0; - } - else - fprintf(stderr, "[gart] AGP enabled at %dx\n", ctx->agpmode); - - return 1; -} - -/* - * Allocate memory from the given pool. Grow the pool if needed and if - * possible. - */ -static unsigned long -AllocFromPool(const DRIDriverContext *ctx, I830Rec *pI830, - I830MemRange *result, I830MemPool *pool, - long size, unsigned long alignment, int flags) -{ - long needed, start, end; - - if (!result || !pool || !size) - return 0; - - /* Calculate how much space is needed. */ - if (alignment <= GTT_PAGE_SIZE) - needed = size; - else { - start = ROUND_TO(pool->Free.Start, alignment); - end = ROUND_TO(start + size, alignment); - needed = end - pool->Free.Start; - } - if (needed > pool->Free.Size) { - return 0; - } - - result->Start = ROUND_TO(pool->Free.Start, alignment); - pool->Free.Start += needed; - result->End = pool->Free.Start; - - pool->Free.Size = pool->Free.End - pool->Free.Start; - result->Size = result->End - result->Start; - result->Pool = pool; - result->Alignment = alignment; - return needed; -} - -static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, long size, unsigned long alignment, I830MemRange *result) -{ - unsigned long start, end; - unsigned long newApStart, newApEnd; - int ret; - if (!result || !size) - return 0; - - if (!alignment) - alignment = 4; - - start = ROUND_TO(pI830->MemoryAperture.Start, alignment); - end = ROUND_TO(start + size, alignment); - newApStart = end; - newApEnd = pI830->MemoryAperture.End; - - ret=drmAgpAlloc(ctx->drmFD, size, 0, &(result->Physical), (drm_handle_t *)&(result->Key)); - - if (ret) - { - fprintf(stderr,"drmAgpAlloc failed %d\n", ret); - return 0; - } - pI830->allocatedMemory += size; - pI830->MemoryAperture.Start = newApStart; - pI830->MemoryAperture.End = newApEnd; - pI830->MemoryAperture.Size = newApEnd - newApStart; - // pI830->FreeMemory -= size; - result->Start = start; - result->End = start + size; - result->Size = size; - result->Offset = start; - result->Alignment = alignment; - result->Pool = NULL; - - return size; -} - -unsigned long -I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830, - I830MemRange *result, I830MemPool *pool, long size, - unsigned long alignment, int flags) -{ - unsigned long ret; - - if (!result) - return 0; - - /* Make sure these are initialised. */ - result->Size = 0; - result->Key = -1; - - if (!size) { - return 0; - } - - if (pool->Free.Size < size) { - ret = AllocFromAGP(ctx, pI830, size, alignment, result); - } - else { - ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags); - if (ret == 0) - ret = AllocFromAGP(ctx, pI830, size, alignment, result); - } - return ret; -} - -static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem) -{ - if (!mem) - return FALSE; - - if (mem->Key == -1) - return TRUE; - - return !drmAgpBind(ctx->drmFD, mem->Key, mem->Offset); -} - -/* simple memory allocation routines needed */ -/* put ring buffer in low memory */ -/* need to allocate front, back, depth buffers aligned correctly, - allocate ring buffer, -*/ - -/* */ -static Bool -I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830) -{ - unsigned long size, ret; - unsigned long lines, lineSize, align; - - /* allocate ring buffer */ - memset(pI830->LpRing, 0, sizeof(I830RingBuffer)); - pI830->LpRing->mem.Key = -1; - - size = PRIMARY_RINGBUFFER_SIZE; - - ret = I830AllocVidMem(ctx, pI830, &pI830->LpRing->mem, &pI830->StolenPool, size, 0x1000, 0); - - if (ret != size) - { - fprintf(stderr,"unable to allocate ring buffer %ld\n", ret); - return FALSE; - } - - pI830->LpRing->tail_mask = pI830->LpRing->mem.Size - 1; - - - /* allocate front buffer */ - memset(&(pI830->FrontBuffer), 0, sizeof(pI830->FrontBuffer)); - pI830->FrontBuffer.Key = -1; - pI830->FrontBuffer.Pitch = ctx->shared.virtualWidth; - - align = KB(512); - - lineSize = ctx->shared.virtualWidth * ctx->cpp; - lines = (ctx->shared.virtualHeight + 15) / 16 * 16; - size = lineSize * lines; - size = ROUND_TO_PAGE(size); - - align = GetBestTileAlignment(size); - - ret = I830AllocVidMem(ctx, pI830, &pI830->FrontBuffer, &pI830->StolenPool, size, align, 0); - if (ret < size) - { - fprintf(stderr,"unable to allocate front buffer %ld\n", ret); - return FALSE; - } - - memset(&(pI830->BackBuffer), 0, sizeof(pI830->BackBuffer)); - pI830->BackBuffer.Key = -1; - pI830->BackBuffer.Pitch = ctx->shared.virtualWidth; - - ret = I830AllocVidMem(ctx, pI830, &pI830->BackBuffer, &pI830->StolenPool, size, align, 0); - if (ret < size) - { - fprintf(stderr,"unable to allocate back buffer %ld\n", ret); - return FALSE; - } - - memset(&(pI830->DepthBuffer), 0, sizeof(pI830->DepthBuffer)); - pI830->DepthBuffer.Key = -1; - pI830->DepthBuffer.Pitch = ctx->shared.virtualWidth; - - ret = I830AllocVidMem(ctx, pI830, &pI830->DepthBuffer, &pI830->StolenPool, size, align, 0); - if (ret < size) - { - fprintf(stderr,"unable to allocate depth buffer %ld\n", ret); - return FALSE; - } - - memset(&(pI830->ContextMem), 0, sizeof(pI830->ContextMem)); - pI830->ContextMem.Key = -1; - size = KB(32); - - ret = I830AllocVidMem(ctx, pI830, &pI830->ContextMem, &pI830->StolenPool, size, align, 0); - if (ret < size) - { - fprintf(stderr,"unable to allocate context buffer %ld\n", ret); - return FALSE; - } - -#if 0 - memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem)); - pI830->TexMem.Key = -1; - - size = 32768 * 1024; - ret = AllocFromAGP(ctx, pI830, size, align, &pI830->TexMem); - if (ret < size) - { - fprintf(stderr,"unable to allocate texture memory %ld\n", ret); - return FALSE; - } -#endif - - return TRUE; -} - -static Bool -I830BindMemory(const DRIDriverContext *ctx, I830Rec *pI830) -{ - if (!BindAgpRange(ctx, &pI830->LpRing->mem)) - return FALSE; - if (!BindAgpRange(ctx, &pI830->FrontBuffer)) - return FALSE; - if (!BindAgpRange(ctx, &pI830->BackBuffer)) - return FALSE; - if (!BindAgpRange(ctx, &pI830->DepthBuffer)) - return FALSE; - if (!BindAgpRange(ctx, &pI830->ContextMem)) - return FALSE; -#if 0 - if (!BindAgpRange(ctx, &pI830->TexMem)) - return FALSE; -#endif - return TRUE; -} - -static void SetupDRIMM(const DRIDriverContext *ctx, I830Rec *pI830) -{ - unsigned long aperEnd = ROUND_DOWN_TO(pI830->aper_size, GTT_PAGE_SIZE) / GTT_PAGE_SIZE; - unsigned long aperStart = ROUND_TO(pI830->aper_size - KB(32768), GTT_PAGE_SIZE) / GTT_PAGE_SIZE; - - fprintf(stderr, "aper size is %08X\n", ctx->shared.fbSize); - if (drmMMInit(ctx->drmFD, aperStart, aperEnd - aperStart, DRM_BO_MEM_TT)) { - fprintf(stderr, - "DRM MM Initialization Failed\n"); - } else { - fprintf(stderr, - "DRM MM Initialized at offset 0x%lx length %d page\n", aperStart, aperEnd-aperStart); - } - -} - -static Bool -I830CleanupDma(const DRIDriverContext *ctx) -{ - drmI830Init info; - - memset(&info, 0, sizeof(drmI830Init)); - info.func = I830_CLEANUP_DMA; - - if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT, - &info, sizeof(drmI830Init))) { - fprintf(stderr, "I830 Dma Cleanup Failed\n"); - return FALSE; - } - - return TRUE; -} - -static Bool -I830InitDma(const DRIDriverContext *ctx, I830Rec *pI830) -{ - I830RingBuffer *ring = pI830->LpRing; - drmI830Init info; - - memset(&info, 0, sizeof(drmI830Init)); - info.func = I830_INIT_DMA; - - info.ring_start = ring->mem.Start + pI830->LinearAddr; - info.ring_end = ring->mem.End + pI830->LinearAddr; - info.ring_size = ring->mem.Size; - - info.mmio_offset = (unsigned int)ctx->MMIOStart; - - info.sarea_priv_offset = sizeof(drm_sarea_t); - - info.front_offset = pI830->FrontBuffer.Start; - info.back_offset = pI830->BackBuffer.Start; - info.depth_offset = pI830->DepthBuffer.Start; - info.w = ctx->shared.virtualWidth; - info.h = ctx->shared.virtualHeight; - info.pitch = ctx->shared.virtualWidth; - info.back_pitch = pI830->BackBuffer.Pitch; - info.depth_pitch = pI830->DepthBuffer.Pitch; - info.cpp = ctx->cpp; - - if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT, - &info, sizeof(drmI830Init))) { - fprintf(stderr, - "I830 Dma Initialization Failed\n"); - return FALSE; - } - - return TRUE; -} - -static int I830CheckDRMVersion( const DRIDriverContext *ctx, - I830Rec *pI830 ) -{ - drmVersionPtr version; - - version = drmGetVersion(ctx->drmFD); - - if (version) { - int req_minor, req_patch; - - req_minor = 4; - req_patch = 0; - - if (version->version_major != 1 || - version->version_minor < req_minor || - (version->version_minor == req_minor && - version->version_patchlevel < req_patch)) { - /* Incompatible drm version */ - fprintf(stderr, - "[dri] I830DRIScreenInit failed because of a version " - "mismatch.\n" - "[dri] i915.o kernel module version is %d.%d.%d " - "but version 1.%d.%d or newer is needed.\n" - "[dri] Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel, - req_minor, - req_patch); - drmFreeVersion(version); - return 0; - } - - pI830->drmMinor = version->version_minor; - drmFreeVersion(version); - } - return 1; -} - -static void -I830SetRingRegs(const DRIDriverContext *ctx, I830Rec *pI830) -{ - unsigned int itemp; - unsigned char *MMIO = ctx->MMIOAddress; - - OUTREG(LP_RING + RING_LEN, 0); - OUTREG(LP_RING + RING_TAIL, 0); - OUTREG(LP_RING + RING_HEAD, 0); - - if ((long)(pI830->LpRing->mem.Start & I830_RING_START_MASK) != - pI830->LpRing->mem.Start) { - fprintf(stderr, - "I830SetRingRegs: Ring buffer start (%lx) violates its " - "mask (%x)\n", pI830->LpRing->mem.Start, I830_RING_START_MASK); - } - /* Don't care about the old value. Reserved bits must be zero anyway. */ - itemp = pI830->LpRing->mem.Start & I830_RING_START_MASK; - OUTREG(LP_RING + RING_START, itemp); - - if (((pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES) != - pI830->LpRing->mem.Size - 4096) { - fprintf(stderr, - "I830SetRingRegs: Ring buffer size - 4096 (%lx) violates its " - "mask (%x)\n", pI830->LpRing->mem.Size - 4096, - I830_RING_NR_PAGES); - } - /* Don't care about the old value. Reserved bits must be zero anyway. */ - itemp = (pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES; - itemp |= (RING_NO_REPORT | RING_VALID); - OUTREG(LP_RING + RING_LEN, itemp); - - pI830->LpRing->head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK; - pI830->LpRing->tail = INREG(LP_RING + RING_TAIL); - pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8); - if (pI830->LpRing->space < 0) - pI830->LpRing->space += pI830->LpRing->mem.Size; - - SetFenceRegs(ctx, pI830); - - /* RESET THE DISPLAY PIPE TO POINT TO THE FRONTBUFFER - hacky - hacky hacky */ - OUTREG(DSPABASE, pI830->FrontBuffer.Start + pI830->LinearAddr); - -} - -static Bool -I830SetParam(const DRIDriverContext *ctx, int param, int value) -{ - drmI830SetParam sp; - - memset(&sp, 0, sizeof(sp)); - sp.param = param; - sp.value = value; - - if (drmCommandWrite(ctx->drmFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) { - fprintf(stderr, "I830 SetParam Failed\n"); - return FALSE; - } - - return TRUE; -} - -static Bool -I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) -{ - fprintf(stderr, - "[drm] Mapping front buffer\n"); - - if (drmAddMap(ctx->drmFD, - (drm_handle_t)(sarea->front_offset + pI830->LinearAddr), - sarea->front_size, - DRM_FRAME_BUFFER, /*DRM_AGP,*/ - 0, - &sarea->front_handle) < 0) { - fprintf(stderr, - "[drm] drmAddMap(front_handle) failed. Disabling DRI\n"); - return FALSE; - } - ctx->shared.hFrameBuffer = sarea->front_handle; - ctx->shared.fbSize = sarea->front_size; - fprintf(stderr, "[drm] Front Buffer = 0x%08x\n", - sarea->front_handle); - - if (drmAddMap(ctx->drmFD, - (drm_handle_t)(sarea->back_offset), - sarea->back_size, DRM_AGP, 0, - &sarea->back_handle) < 0) { - fprintf(stderr, - "[drm] drmAddMap(back_handle) failed. Disabling DRI\n"); - return FALSE; - } - fprintf(stderr, "[drm] Back Buffer = 0x%08x\n", - sarea->back_handle); - - if (drmAddMap(ctx->drmFD, - (drm_handle_t)sarea->depth_offset, - sarea->depth_size, DRM_AGP, 0, - &sarea->depth_handle) < 0) { - fprintf(stderr, - "[drm] drmAddMap(depth_handle) failed. Disabling DRI\n"); - return FALSE; - } - fprintf(stderr, "[drm] Depth Buffer = 0x%08x\n", - sarea->depth_handle); - -#if 0 - if (drmAddMap(ctx->drmFD, - (drm_handle_t)sarea->tex_offset, - sarea->tex_size, DRM_AGP, 0, - &sarea->tex_handle) < 0) { - fprintf(stderr, - "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n"); - return FALSE; - } - fprintf(stderr, "[drm] textures = 0x%08x\n", - sarea->tex_handle); -#endif - return TRUE; -} - - -static void -I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) -{ -#if 1 - if (sarea->front_handle) { - drmRmMap(ctx->drmFD, sarea->front_handle); - sarea->front_handle = 0; - } -#endif - if (sarea->back_handle) { - drmRmMap(ctx->drmFD, sarea->back_handle); - sarea->back_handle = 0; - } - if (sarea->depth_handle) { - drmRmMap(ctx->drmFD, sarea->depth_handle); - sarea->depth_handle = 0; - } - if (sarea->tex_handle) { - drmRmMap(ctx->drmFD, sarea->tex_handle); - sarea->tex_handle = 0; - } -} - -static Bool -I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) -{ - if (drmAddMap(ctx->drmFD, - (drm_handle_t)pI830->LpRing->mem.Start, - pI830->LpRing->mem.Size, DRM_AGP, 0, - &pI830->ring_map) < 0) { - fprintf(stderr, - "[drm] drmAddMap(ring_map) failed. Disabling DRI\n"); - return FALSE; - } - fprintf(stderr, "[drm] ring buffer = 0x%08x\n", - pI830->ring_map); - - if (I830InitDma(ctx, pI830) == FALSE) { - return FALSE; - } - - /* init to zero to be safe */ - - I830DRIMapScreenRegions(ctx, pI830, sarea); - SetupDRIMM(ctx, pI830); - - if (ctx->pciDevice != PCI_CHIP_845_G && - ctx->pciDevice != PCI_CHIP_I830_M) { - I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 ); - } - - /* Okay now initialize the dma engine */ - { - pI830->irq = drmGetInterruptFromBusID(ctx->drmFD, - ctx->pciBus, - ctx->pciDevice, - ctx->pciFunc); - - if (drmCtlInstHandler(ctx->drmFD, pI830->irq)) { - fprintf(stderr, - "[drm] failure adding irq handler\n"); - pI830->irq = 0; - return FALSE; - } - else - fprintf(stderr, - "[drm] dma control initialized, using IRQ %d\n", - pI830->irq); - } - - fprintf(stderr, "[dri] visual configs initialized\n"); - - return TRUE; -} - -static Bool -I830ClearScreen(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) -{ - /* need to drmMap front and back buffers and zero them */ - drmAddress map_addr; - int ret; - - ret = drmMap(ctx->drmFD, - sarea->front_handle, - sarea->front_size, - &map_addr); - - if (ret) - { - fprintf(stderr, "Unable to map front buffer\n"); - return FALSE; - } - - drimemsetio((char *)map_addr, - 0, - sarea->front_size); - drmUnmap(map_addr, sarea->front_size); - - - ret = drmMap(ctx->drmFD, - sarea->back_handle, - sarea->back_size, - &map_addr); - - if (ret) - { - fprintf(stderr, "Unable to map back buffer\n"); - return FALSE; - } - - drimemsetio((char *)map_addr, - 0, - sarea->back_size); - drmUnmap(map_addr, sarea->back_size); - - return TRUE; -} - -static Bool -I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830) - -{ - I830DRIPtr pI830DRI; - drmI830Sarea *pSAREAPriv; - int err; - - drm_page_size = getpagesize(); - - pI830->registerSize = ctx->MMIOSize; - /* This is a hack for now. We have to have more than a 4k page here - * because of the size of the state. However, the state should be - * in a per-context mapping. This will be added in the Mesa 3.5 port - * of the I830 driver. - */ - ctx->shared.SAREASize = SAREA_MAX; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("i915", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08x\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - - } - - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08x to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - - if (drmAddMap(ctx->drmFD, - ctx->MMIOStart, - ctx->MMIOSize, - DRM_REGISTERS, - DRM_READ_ONLY, - &pI830->registerHandle) < 0) { - fprintf(stderr, "[drm] drmAddMap mmio failed\n"); - return 0; - } - fprintf(stderr, - "[drm] register handle = 0x%08x\n", pI830->registerHandle); - - - if (!I830CheckDRMVersion(ctx, pI830)) { - return FALSE; - } - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the SAREA private data structure */ - pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - - pI830->StolenMemory.Size = I830DetectMemory(ctx, pI830); - pI830->StolenMemory.Start = 0; - pI830->StolenMemory.End = pI830->StolenMemory.Size; - - pI830->MemoryAperture.Start = pI830->StolenMemory.End; - pI830->MemoryAperture.End = KB(40000); - pI830->MemoryAperture.Size = pI830->MemoryAperture.End - pI830->MemoryAperture.Start; - - pI830->StolenPool.Fixed = pI830->StolenMemory; - pI830->StolenPool.Total = pI830->StolenMemory; - pI830->StolenPool.Free = pI830->StolenPool.Total; - pI830->FreeMemory = pI830->StolenPool.Total.Size; - - if (!AgpInit(ctx, pI830)) - return FALSE; - - if (I830AllocateMemory(ctx, pI830) == FALSE) - { - return FALSE; - } - - if (I830BindMemory(ctx, pI830) == FALSE) - { - return FALSE; - } - - pSAREAPriv->rotated_offset = -1; - pSAREAPriv->rotated_size = 0; - pSAREAPriv->rotated_pitch = ctx->shared.virtualWidth; - - pSAREAPriv->front_offset = pI830->FrontBuffer.Start; - pSAREAPriv->front_size = pI830->FrontBuffer.Size; - pSAREAPriv->width = ctx->shared.virtualWidth; - pSAREAPriv->height = ctx->shared.virtualHeight; - pSAREAPriv->pitch = ctx->shared.virtualWidth; - pSAREAPriv->virtualX = ctx->shared.virtualWidth; - pSAREAPriv->virtualY = ctx->shared.virtualHeight; - pSAREAPriv->back_offset = pI830->BackBuffer.Start; - pSAREAPriv->back_size = pI830->BackBuffer.Size; - pSAREAPriv->depth_offset = pI830->DepthBuffer.Start; - pSAREAPriv->depth_size = pI830->DepthBuffer.Size; -#if 0 - pSAREAPriv->tex_offset = pI830->TexMem.Start; - pSAREAPriv->tex_size = pI830->TexMem.Size; -#endif - pSAREAPriv->log_tex_granularity = pI830->TexGranularity; - - ctx->driverClientMsg = malloc(sizeof(I830DRIRec)); - ctx->driverClientMsgSize = sizeof(I830DRIRec); - pI830DRI = (I830DRIPtr)ctx->driverClientMsg; - pI830DRI->deviceID = pI830->Chipset; - pI830DRI->regsSize = I830_REG_SIZE; - pI830DRI->width = ctx->shared.virtualWidth; - pI830DRI->height = ctx->shared.virtualHeight; - pI830DRI->mem = ctx->shared.fbSize; - pI830DRI->cpp = ctx->cpp; - - pI830DRI->bitsPerPixel = ctx->bpp; - pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t); - - err = I830DRIDoMappings(ctx, pI830, pSAREAPriv); - if (err == FALSE) - return FALSE; - - I830SetupMemoryTiling(ctx, pI830); - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - I830ClearScreen(ctx, pI830, pSAREAPriv); - - I830SetRingRegs(ctx, pI830); - - return TRUE; -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa radeonValidateMode(). - */ -static int i830ValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa i810ValidateMode(). - */ -static int i830PostValidateMode( const DRIDriverContext *ctx ) -{ - I830Rec *pI830 = ctx->driverPrivate; - - I830SetRingRegs(ctx, pI830); - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p ctx - * and then calls I810ScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int i830InitFBDev( DRIDriverContext *ctx ) -{ - I830Rec *pI830 = calloc(1, sizeof(I830Rec)); - int i; - - { - int dummy = ctx->shared.virtualWidth; - - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - - ctx->shared.virtualWidth = dummy; - ctx->shared.Width = ctx->shared.virtualWidth; - } - - - for (i = 0; pitches[i] != 0; i++) { - if (pitches[i] >= ctx->shared.virtualWidth) { - ctx->shared.virtualWidth = pitches[i]; - break; - } - } - - ctx->driverPrivate = (void *)pI830; - - pI830->LpRing = calloc(1, sizeof(I830RingBuffer)); - pI830->Chipset = ctx->chipset; - pI830->LinearAddr = ctx->FBStart; - - if (!I830ScreenInit( ctx, pI830 )) - return 0; - - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void i830HaltFBDev( DRIDriverContext *ctx ) -{ - drmI830Sarea *pSAREAPriv; - I830Rec *pI830 = ctx->driverPrivate; - - if (pI830->irq) { - drmCtlUninstHandler(ctx->drmFD); - pI830->irq = 0; } - - I830CleanupDma(ctx); - - pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - - I830DRIUnmapScreenRegions(ctx, pI830, pSAREAPriv); - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - - -extern void i810NotifyFocus( int ); - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -const struct DRIDriverRec __driDriver = { - i830ValidateMode, - i830PostValidateMode, - i830InitFBDev, - i830HaltFBDev, - NULL,//I830EngineShutdown, - NULL, //I830EngineRestore, -#ifndef _EMBEDDED - 0, -#else - i810NotifyFocus, -#endif -}; diff --git a/src/mesa/drivers/dri/mga/server/mga_dri.c b/src/mesa/drivers/dri/mga/server/mga_dri.c deleted file mode 100644 index bc575e62ee..0000000000 --- a/src/mesa/drivers/dri/mga/server/mga_dri.c +++ /dev/null @@ -1,1088 +0,0 @@ - -/* - * Copyright 2000 VA Linux Systems Inc., Fremont, California. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - * Gareth Hughes - */ - -#include -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" -#include "memops.h" - -#include "mga_reg.h" -#include "mga.h" -#include "mga_macros.h" -#include "mga_dri.h" - - -/* Quiescence, locking - */ -#define MGA_TIMEOUT 2048 - -static void MGAWaitForIdleDMA( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - drm_lock_t lock; - int ret; - int i = 0; - - memset( &lock, 0, sizeof(lock) ); - - for (;;) { - do { - /* first ask for quiescent and flush */ - lock.flags = DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH; - do { - ret = drmCommandWrite( ctx->drmFD, DRM_MGA_FLUSH, - &lock, sizeof( lock ) ); - } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); - - /* if it's still busy just try quiescent */ - if ( ret == -EBUSY ) { - lock.flags = DRM_LOCK_QUIESCENT; - do { - ret = drmCommandWrite( ctx->drmFD, DRM_MGA_FLUSH, - &lock, sizeof( lock ) ); - } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY ); - } - } while ( ( ret == -EBUSY ) && ( i++ < MGA_TIMEOUT ) ); - - if ( ret == 0 ) - return; - - fprintf( stderr, - "[dri] Idle timed out, resetting engine...\n" ); - - drmCommandNone( ctx->drmFD, DRM_MGA_RESET ); - } -} - -static unsigned int mylog2( unsigned int n ) -{ - unsigned int log2 = 1; - while ( n > 1 ) n >>= 1, log2++; - return log2; -} - -static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga) -{ - unsigned long mode; - unsigned int vendor, device; - int ret, count, i; - - if(pMga->agpSize < 12)pMga->agpSize = 12; - if(pMga->agpSize > 64)pMga->agpSize = 64; /* cap */ - - /* FIXME: Make these configurable... - */ - pMga->agp.size = pMga->agpSize * 1024 * 1024; - - pMga->warp.offset = 0; - pMga->warp.size = MGA_WARP_UCODE_SIZE; - - pMga->primary.offset = (pMga->warp.offset + - pMga->warp.size); - pMga->primary.size = 1024 * 1024; - - pMga->buffers.offset = (pMga->primary.offset + - pMga->primary.size); - pMga->buffers.size = MGA_NUM_BUFFERS * MGA_BUFFER_SIZE; - - - pMga->agpTextures.offset = (pMga->buffers.offset + - pMga->buffers.size); - - pMga->agpTextures.size = pMga->agp.size - - pMga->agpTextures.offset; - - if ( drmAgpAcquire( ctx->drmFD ) < 0 ) { - fprintf( stderr, "[agp] AGP not available\n" ); - return 0; - } - - mode = drmAgpGetMode( ctx->drmFD ); /* Default mode */ - vendor = drmAgpVendorId( ctx->drmFD ); - device = drmAgpDeviceId( ctx->drmFD ); - - mode &= ~MGA_AGP_MODE_MASK; - switch ( pMga->agpMode ) { - case 4: - mode |= MGA_AGP_4X_MODE; - case 2: - mode |= MGA_AGP_2X_MODE; - case 1: - default: - mode |= MGA_AGP_1X_MODE; - } - -#if 0 - fprintf( stderr, - "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", - mode, vendor, device, - ctx->pciVendor, - ctx->pciChipType ); -#endif - - if ( drmAgpEnable( ctx->drmFD, mode ) < 0 ) { - fprintf( stderr, "[agp] AGP not enabled\n" ); - drmAgpRelease( ctx->drmFD ); - return 0; - } - - if ( pMga->Chipset == PCI_CHIP_MGAG200 ) { - switch ( pMga->agpMode ) { - case 2: - fprintf( stderr, - "[drm] Enabling AGP 2x PLL encoding\n" ); - OUTREG( MGAREG_AGP_PLL, MGA_AGP2XPLL_ENABLE ); - break; - - case 1: - default: - fprintf( stderr, - "[drm] Disabling AGP 2x PLL encoding\n" ); - OUTREG( MGAREG_AGP_PLL, MGA_AGP2XPLL_DISABLE ); - pMga->agpMode = 1; - break; - } - } - - ret = drmAgpAlloc( ctx->drmFD, pMga->agp.size, - 0, NULL, &pMga->agp.handle ); - if ( ret < 0 ) { - fprintf( stderr, "[agp] Out of memory (%d)\n", ret ); - drmAgpRelease( ctx->drmFD ); - return 0; - } - fprintf( stderr, - "[agp] %d kB allocated with handle 0x%08x\n", - pMga->agp.size/1024, (unsigned int)pMga->agp.handle ); - - if ( drmAgpBind( ctx->drmFD, pMga->agp.handle, 0 ) < 0 ) { - fprintf( stderr, "[agp] Could not bind memory\n" ); - drmAgpFree( ctx->drmFD, pMga->agp.handle ); - drmAgpRelease( ctx->drmFD ); - return 0; - } - - /* WARP microcode space - */ - if ( drmAddMap( ctx->drmFD, - pMga->warp.offset, - pMga->warp.size, - DRM_AGP, DRM_READ_ONLY, - &pMga->warp.handle ) < 0 ) { - fprintf( stderr, - "[agp] Could not add WARP microcode mapping\n" ); - return 0; - } - fprintf( stderr, - "[agp] WARP microcode handle = 0x%08x\n", - pMga->warp.handle ); - - if ( drmMap( ctx->drmFD, - pMga->warp.handle, - pMga->warp.size, - &pMga->warp.map ) < 0 ) { - fprintf( stderr, - "[agp] Could not map WARP microcode\n" ); - return 0; - } - fprintf( stderr, - "[agp] WARP microcode mapped at 0x%08lx\n", - (unsigned long)pMga->warp.map ); - - /* Primary DMA space - */ - if ( drmAddMap( ctx->drmFD, - pMga->primary.offset, - pMga->primary.size, - DRM_AGP, DRM_READ_ONLY, - &pMga->primary.handle ) < 0 ) { - fprintf( stderr, - "[agp] Could not add primary DMA mapping\n" ); - return 0; - } - fprintf( stderr, - "[agp] Primary DMA handle = 0x%08x\n", - pMga->primary.handle ); - - if ( drmMap( ctx->drmFD, - pMga->primary.handle, - pMga->primary.size, - &pMga->primary.map ) < 0 ) { - fprintf( stderr, - "[agp] Could not map primary DMA\n" ); - return 0; - } - fprintf( stderr, - "[agp] Primary DMA mapped at 0x%08lx\n", - (unsigned long)pMga->primary.map ); - - /* DMA buffers - */ - if ( drmAddMap( ctx->drmFD, - pMga->buffers.offset, - pMga->buffers.size, - DRM_AGP, 0, - &pMga->buffers.handle ) < 0 ) { - fprintf( stderr, - "[agp] Could not add DMA buffers mapping\n" ); - return 0; - } - fprintf( stderr, - "[agp] DMA buffers handle = 0x%08x\n", - pMga->buffers.handle ); - - if ( drmMap( ctx->drmFD, - pMga->buffers.handle, - pMga->buffers.size, - &pMga->buffers.map ) < 0 ) { - fprintf( stderr, - "[agp] Could not map DMA buffers\n" ); - return 0; - } - fprintf( stderr, - "[agp] DMA buffers mapped at 0x%08lx\n", - (unsigned long)pMga->buffers.map ); - - count = drmAddBufs( ctx->drmFD, - MGA_NUM_BUFFERS, MGA_BUFFER_SIZE, - DRM_AGP_BUFFER, pMga->buffers.offset ); - if ( count <= 0 ) { - fprintf( stderr, - "[drm] failure adding %d %d byte DMA buffers\n", - MGA_NUM_BUFFERS, MGA_BUFFER_SIZE ); - return 0; - } - fprintf( stderr, - "[drm] Added %d %d byte DMA buffers\n", - count, MGA_BUFFER_SIZE ); - - i = mylog2(pMga->agpTextures.size / MGA_NR_TEX_REGIONS); - if(i < MGA_LOG_MIN_TEX_REGION_SIZE) - i = MGA_LOG_MIN_TEX_REGION_SIZE; - pMga->agpTextures.size = (pMga->agpTextures.size >> i) << i; - - if ( drmAddMap( ctx->drmFD, - pMga->agpTextures.offset, - pMga->agpTextures.size, - DRM_AGP, 0, - &pMga->agpTextures.handle ) < 0 ) { - fprintf( stderr, - "[agp] Could not add agpTexture mapping\n" ); - return 0; - } -/* should i map it ? */ - fprintf( stderr, - "[agp] agpTexture handle = 0x%08x\n", - pMga->agpTextures.handle ); - fprintf( stderr, - "[agp] agpTexture size: %d kb\n", pMga->agpTextures.size/1024 ); - - return 1; -} - -static int MGADRIMapInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - pMga->registers.size = MGAIOMAPSIZE; - - if ( drmAddMap( ctx->drmFD, - (drm_handle_t)pMga->IOAddress, - pMga->registers.size, - DRM_REGISTERS, DRM_READ_ONLY, - &pMga->registers.handle ) < 0 ) { - fprintf( stderr, - "[drm] Could not add MMIO registers mapping\n" ); - return 0; - } - fprintf( stderr, - "[drm] Registers handle = 0x%08lx\n", - pMga->registers.handle ); - - pMga->status.size = SAREA_MAX; - - if ( drmAddMap( ctx->drmFD, 0, pMga->status.size, - DRM_SHM, DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL, - &pMga->status.handle ) < 0 ) { - fprintf( stderr, - "[drm] Could not add status page mapping\n" ); - return 0; - } - fprintf( stderr, - "[drm] Status handle = 0x%08x\n", - pMga->status.handle ); - - if ( drmMap( ctx->drmFD, - pMga->status.handle, - pMga->status.size, - &pMga->status.map ) < 0 ) { - fprintf( stderr, - "[agp] Could not map status page\n" ); - return 0; - } - fprintf( stderr, - "[agp] Status page mapped at 0x%08lx\n", - (unsigned long)pMga->status.map ); - - return 1; -} - -static int MGADRIKernelInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - drm_mga_init_t init; - int ret; - - memset( &init, 0, sizeof(init) ); - - init.func = MGA_INIT_DMA; - init.sarea_priv_offset = sizeof(drm_sarea_t); - - switch ( pMga->Chipset ) { - case PCI_CHIP_MGAG550: - case PCI_CHIP_MGAG400: - init.chipset = MGA_CARD_TYPE_G400; - break; - case PCI_CHIP_MGAG200: - case PCI_CHIP_MGAG200_PCI: - init.chipset = MGA_CARD_TYPE_G200; - break; - default: - return 0; - } - - init.sgram = 0; /* FIXME !pMga->HasSDRAM; */ - - - switch (ctx->bpp) - { - case 16: - init.maccess = MGA_MACCESS_PW16; - break; - case 32: - init.maccess = MGA_MACCESS_PW32; - break; - default: - fprintf( stderr, "[mga] invalid bpp (%d)\n", ctx->bpp ); - return 0; - } - - - init.fb_cpp = ctx->bpp / 8; - init.front_offset = pMga->frontOffset; - init.front_pitch = pMga->frontPitch / init.fb_cpp; - init.back_offset = pMga->backOffset; - init.back_pitch = pMga->backPitch / init.fb_cpp; - - init.depth_cpp = ctx->bpp / 8; - init.depth_offset = pMga->depthOffset; - init.depth_pitch = pMga->depthPitch / init.depth_cpp; - - init.texture_offset[0] = pMga->textureOffset; - init.texture_size[0] = pMga->textureSize; - - init.fb_offset = ctx->shared.hFrameBuffer; - init.mmio_offset = pMga->registers.handle; - init.status_offset = pMga->status.handle; - - init.warp_offset = pMga->warp.handle; - init.primary_offset = pMga->primary.handle; - init.buffers_offset = pMga->buffers.handle; - - init.texture_offset[1] = pMga->agpTextures.handle; - init.texture_size[1] = pMga->agpTextures.size; - - ret = drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(init)); - if ( ret < 0 ) { - fprintf( stderr, - "[drm] Failed to initialize DMA! (%d)\n", ret ); - return 0; - } - - return 1; -} - -static void MGADRIIrqInit(struct DRIDriverContextRec *ctx, MGAPtr pMga) -{ - if (!pMga->irq) - { - pMga->irq = drmGetInterruptFromBusID(ctx->drmFD, - ctx->pciBus, - ctx->pciDevice, - ctx->pciFunc); - - fprintf(stderr, "[drm] got IRQ %d\n", pMga->irq); - - if((drmCtlInstHandler(ctx->drmFD, pMga->irq)) != 0) - { - fprintf(stderr, - "[drm] failure adding irq handler, " - "there is a device already using that irq\n" - "[drm] falling back to irq-free operation\n"); - pMga->irq = 0; - } - else - { - pMga->reg_ien = INREG( MGAREG_IEN ); - } - } - - if (pMga->irq) - fprintf(stderr, - "[drm] dma control initialized, using IRQ %d\n", - pMga->irq); -} - -static int MGADRIBuffersInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - pMga->drmBuffers = drmMapBufs( ctx->drmFD ); - if ( !pMga->drmBuffers ) - { - fprintf( stderr, - "[drm] Failed to map DMA buffers list\n" ); - return 0; - } - - fprintf( stderr, - "[drm] Mapped %d DMA buffers\n", - pMga->drmBuffers->count ); - - return 1; -} - -static int MGAMemoryInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - int width_bytes = ctx->shared.virtualWidth * ctx->cpp; - int bufferSize = ((ctx->shared.virtualHeight * width_bytes - + MGA_BUFFER_ALIGN) - & ~MGA_BUFFER_ALIGN); - int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes - + MGA_BUFFER_ALIGN) - & ~MGA_BUFFER_ALIGN); - int l; - - pMga->frontOffset = 0; - pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp; - - fprintf(stderr, - "Using %d MB AGP aperture\n", pMga->agpSize); - fprintf(stderr, - "Using %d MB for vertex/indirect buffers\n", pMga->buffers.size>>20); - fprintf(stderr, - "Using %d MB for AGP textures\n", pMga->agpTextures.size>>20); - - /* Front, back and depth buffers - everything else texture?? - */ - pMga->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize; - - if (pMga->textureSize < 0) - return 0; - - l = mylog2( pMga->textureSize / MGA_NR_TEX_REGIONS ); - if ( l < MGA_LOG_MIN_TEX_REGION_SIZE ) - l = MGA_LOG_MIN_TEX_REGION_SIZE; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't - * round down. - */ - pMga->logTextureGranularity = l; - pMga->textureSize = (pMga->textureSize >> l) << l; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256x32bpp textures. - */ - if (pMga->textureSize < 512 * 1024) { - pMga->textureOffset = 0; - pMga->textureSize = 0; - } - - /* Reserve space for textures */ - pMga->textureOffset = ((ctx->shared.fbSize - pMga->textureSize + - MGA_BUFFER_ALIGN) & - ~MGA_BUFFER_ALIGN); - - /* Reserve space for the shared depth - * buffer. - */ - pMga->depthOffset = ((pMga->textureOffset - depthSize + - MGA_BUFFER_ALIGN) & - ~MGA_BUFFER_ALIGN); - pMga->depthPitch = ctx->shared.virtualWidth * ctx->cpp; - - pMga->backOffset = ((pMga->depthOffset - bufferSize + - MGA_BUFFER_ALIGN) & - ~MGA_BUFFER_ALIGN); - pMga->backPitch = ctx->shared.virtualWidth * ctx->cpp; - - - fprintf(stderr, - "Will use back buffer at offset 0x%x\n", - pMga->backOffset); - fprintf(stderr, - "Will use depth buffer at offset 0x%x\n", - pMga->depthOffset); - fprintf(stderr, - "Will use %d kb for textures at offset 0x%x\n", - pMga->textureSize/1024, pMga->textureOffset); - - return 1; -} - -static int MGACheckDRMVersion( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - drmVersionPtr version; - - /* Check the MGA DRM version */ - version = drmGetVersion(ctx->drmFD); - if ( version ) { - if ( version->version_major != 3 || - version->version_minor < 0 ) { - /* incompatible drm version */ - fprintf( stderr, - "[dri] MGADRIScreenInit failed because of a version mismatch.\n" - "[dri] mga.o kernel module version is %d.%d.%d but version 3.0.x is needed.\n" - "[dri] Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel ); - drmFreeVersion( version ); - return 0; - } - drmFreeVersion( version ); - } - - return 1; -} - -static void print_client_msg( MGADRIPtr pMGADRI ) -{ - fprintf( stderr, "chipset: %d\n", pMGADRI->chipset ); - - fprintf( stderr, "width: %d\n", pMGADRI->width ); - fprintf( stderr, "height: %d\n", pMGADRI->height ); - fprintf( stderr, "mem: %d\n", pMGADRI->mem ); - fprintf( stderr, "cpp: %d\n", pMGADRI->cpp ); - - fprintf( stderr, "agpMode: %d\n", pMGADRI->agpMode ); - - fprintf( stderr, "frontOffset: %d\n", pMGADRI->frontOffset ); - fprintf( stderr, "frontPitch: %d\n", pMGADRI->frontPitch ); - - fprintf( stderr, "backOffset: %d\n", pMGADRI->backOffset ); - fprintf( stderr, "backPitch: %d\n", pMGADRI->backPitch ); - - fprintf( stderr, "depthOffset: %d\n", pMGADRI->depthOffset ); - fprintf( stderr, "depthPitch: %d\n", pMGADRI->depthPitch ); - - fprintf( stderr, "textureOffset: %d\n", pMGADRI->textureOffset ); - fprintf( stderr, "textureSize: %d\n", pMGADRI->textureSize ); - - fprintf( stderr, "logTextureGranularity: %d\n", pMGADRI->logTextureGranularity ); - fprintf( stderr, "logAgpTextureGranularity: %d\n", pMGADRI->logAgpTextureGranularity ); - - fprintf( stderr, "agpTextureHandle: %u\n", (unsigned int)pMGADRI->agpTextureOffset ); - fprintf( stderr, "agpTextureSize: %u\n", (unsigned int)pMGADRI->agpTextureSize ); - -#if 0 - pMGADRI->registers.handle = pMga->registers.handle; - pMGADRI->registers.size = pMga->registers.size; - pMGADRI->status.handle = pMga->status.handle; - pMGADRI->status.size = pMga->status.size; - pMGADRI->primary.handle = pMga->primary.handle; - pMGADRI->primary.size = pMga->primary.size; - pMGADRI->buffers.handle = pMga->buffers.handle; - pMGADRI->buffers.size = pMga->buffers.size; - pMGADRI->sarea_priv_offset = sizeof(drm_sarea_t); -#endif -} - -static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga ) -{ - int i; - int err; - MGADRIPtr pMGADRI; - - usleep(100); - /*assert(!ctx->IsClient);*/ - - { - int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); - int maxy = ctx->shared.fbSize / width_bytes; - - - if (maxy <= ctx->shared.virtualHeight * 3) { - fprintf(stderr, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (ctx->shared.virtualWidth * ctx->shared.virtualHeight * - ctx->cpp * 3 + 1023) / 1024, - ctx->shared.fbSize / 1024); - return 0; - } - } - - switch(pMga->Chipset) { - case PCI_CHIP_MGAG550: - case PCI_CHIP_MGAG400: - case PCI_CHIP_MGAG200: -#if 0 - case PCI_CHIP_MGAG200_PCI: -#endif - break; - default: - fprintf(stderr, "[drm] Direct rendering only supported with G200/G400/G550 AGP\n"); - return 0; - } - - fprintf( stderr, - "[drm] bpp: %d depth: %d\n", - ctx->bpp, ctx->bpp /* FIXME: depth */ ); - - if ( (ctx->bpp / 8) != 2 && - (ctx->bpp / 8) != 4 ) { - fprintf( stderr, - "[dri] Direct rendering only supported in 16 and 32 bpp modes\n" ); - return 0; - } - - ctx->shared.SAREASize = SAREA_MAX; - - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("mga", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, - 0, - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - -#if 0 /* will be done in MGADRIMapInit */ - if (drmAddMap(ctx->drmFD, - ctx->FixedInfo.mmio_start, - ctx->FixedInfo.mmio_len, - DRM_REGISTERS, - DRM_READ_ONLY, - &pMga->registers.handle) < 0) { - fprintf(stderr, "[drm] drmAddMap mmio failed\n"); - return 0; - } - fprintf(stderr, - "[drm] register handle = 0x%08lx\n", pMga->registers.handle); -#endif - - - /* Check the mga DRM version */ - if (!MGACheckDRMVersion(ctx, pMga)) { - return 0; - } - - if ( !MGADRIAgpInit( ctx, pMga ) ) { - return 0; - } - - if ( !MGADRIMapInit( ctx, pMga ) ) { - return 0; - } - - /* Memory manager setup */ - if (!MGAMemoryInit(ctx, pMga)) { - return 0; - } - - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the kernel data structures */ - if (!MGADRIKernelInit(ctx, pMga)) { - fprintf(stderr, "MGADRIKernelInit failed\n"); - DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); - return 0; - } - - /* Initialize the vertex buffers list */ - if (!MGADRIBuffersInit(ctx, pMga)) { - fprintf(stderr, "MGADRIBuffersInit failed\n"); - DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); - return 0; - } - - /* Initialize IRQ */ - MGADRIIrqInit(ctx, pMga); - - - /* Initialize the SAREA private data structure */ - { - drm_mga_sarea_t *pSAREAPriv; - pSAREAPriv = (drm_mga_sarea_t *)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - } - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - drimemsetio((char *)ctx->FBAddress + pMga->frontOffset, - 0, - pMga->frontPitch * ctx->shared.virtualHeight ); - - drimemsetio((char *)ctx->FBAddress + pMga->backOffset, - 0, - pMga->backPitch * ctx->shared.virtualHeight ); - - /* Can release the lock now */ -/* DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);*/ - - /* This is the struct passed to radeon_dri.so for its initialization */ - ctx->driverClientMsg = malloc(sizeof(MGADRIRec)); - ctx->driverClientMsgSize = sizeof(MGADRIRec); - - pMGADRI = (MGADRIPtr)ctx->driverClientMsg; - - - switch(pMga->Chipset) { - case PCI_CHIP_MGAG550: - case PCI_CHIP_MGAG400: - pMGADRI->chipset = MGA_CARD_TYPE_G400; - break; - case PCI_CHIP_MGAG200: - case PCI_CHIP_MGAG200_PCI: - pMGADRI->chipset = MGA_CARD_TYPE_G200; - break; - default: - return 0; - } - pMGADRI->width = ctx->shared.virtualWidth; - pMGADRI->height = ctx->shared.virtualHeight; - pMGADRI->mem = ctx->shared.fbSize; - pMGADRI->cpp = ctx->bpp / 8; - - pMGADRI->agpMode = pMga->agpMode; - - pMGADRI->frontOffset = pMga->frontOffset; - pMGADRI->frontPitch = pMga->frontPitch; - pMGADRI->backOffset = pMga->backOffset; - pMGADRI->backPitch = pMga->backPitch; - pMGADRI->depthOffset = pMga->depthOffset; - pMGADRI->depthPitch = pMga->depthPitch; - pMGADRI->textureOffset = pMga->textureOffset; - pMGADRI->textureSize = pMga->textureSize; - pMGADRI->logTextureGranularity = pMga->logTextureGranularity; - - i = mylog2( pMga->agpTextures.size / MGA_NR_TEX_REGIONS ); - if ( i < MGA_LOG_MIN_TEX_REGION_SIZE ) - i = MGA_LOG_MIN_TEX_REGION_SIZE; - - pMGADRI->logAgpTextureGranularity = i; - pMGADRI->agpTextureOffset = (unsigned int)pMga->agpTextures.handle; - pMGADRI->agpTextureSize = (unsigned int)pMga->agpTextures.size; - - pMGADRI->registers.handle = pMga->registers.handle; - pMGADRI->registers.size = pMga->registers.size; - pMGADRI->status.handle = pMga->status.handle; - pMGADRI->status.size = pMga->status.size; - pMGADRI->primary.handle = pMga->primary.handle; - pMGADRI->primary.size = pMga->primary.size; - pMGADRI->buffers.handle = pMga->buffers.handle; - pMGADRI->buffers.size = pMga->buffers.size; - pMGADRI->sarea_priv_offset = sizeof(drm_sarea_t); - - print_client_msg( pMGADRI ); - - return 1; -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa mgaValidateMode(). - */ -static int mgaValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa mgaValidateMode(). - */ -static int mgaPostValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p ctx - * and then calls MGAScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memomry accessing it directly. - */ -static int mgaInitFBDev( struct DRIDriverContextRec *ctx ) -{ - MGAPtr pMga = calloc(1, sizeof(*pMga)); - - { - int dummy = ctx->shared.virtualWidth; - - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - - ctx->shared.virtualWidth = dummy; - } - - ctx->driverPrivate = (void *)pMga; - - pMga->agpMode = MGA_DEFAULT_AGP_MODE; - pMga->agpSize = MGA_DEFAULT_AGP_SIZE; - - pMga->Chipset = ctx->chipset; - - pMga->IOAddress = ctx->MMIOStart; - pMga->IOBase = ctx->MMIOAddress; - - pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp; - - if (!MGAScreenInit( ctx, pMga )) - return 0; - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void mgaHaltFBDev( struct DRIDriverContextRec *ctx ) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = NULL; - } -} - - -static int mgaEngineShutdown( const DRIDriverContext *ctx ) -{ - fprintf(stderr, "%s() is not yet implemented!\n", __FUNCTION__); - - return 1; -} - -static int mgaEngineRestore( const DRIDriverContext *ctx ) -{ - fprintf(stderr, "%s() is not yet implemented!\n", __FUNCTION__); - - return 1; -} - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -struct DRIDriverRec __driDriver = { - mgaValidateMode, - mgaPostValidateMode, - mgaInitFBDev, - mgaHaltFBDev, - mgaEngineShutdown, - mgaEngineRestore, - 0 -}; - - - - -#if 0 -void MGADRICloseScreen( ScreenPtr pScreen ) -{ - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - MGAPtr pMga = MGAPTR(pScrn); - MGADRIServerPrivatePtr pMga = pMga->DRIServerInfo; - drmMGAInit init; - - if ( pMga->drmBuffers ) { - drmUnmapBufs( pMga->drmBuffers ); - pMga->drmBuffers = NULL; - } - - if (pMga->irq) { - drmCtlUninstHandler(ctx->drmFD); - pMga->irq = 0; - } - - /* Cleanup DMA */ - memset( &init, 0, sizeof(drmMGAInit) ); - init.func = MGA_CLEANUP_DMA; - drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) ); - - if ( pMga->status.map ) { - drmUnmap( pMga->status.map, pMga->status.size ); - pMga->status.map = NULL; - } - if ( pMga->buffers.map ) { - drmUnmap( pMga->buffers.map, pMga->buffers.size ); - pMga->buffers.map = NULL; - } - if ( pMga->primary.map ) { - drmUnmap( pMga->primary.map, pMga->primary.size ); - pMga->primary.map = NULL; - } - if ( pMga->warp.map ) { - drmUnmap( pMga->warp.map, pMga->warp.size ); - pMga->warp.map = NULL; - } - - if ( pMga->agpTextures.map ) { - drmUnmap( pMga->agpTextures.map, pMga->agpTextures.size ); - pMga->agpTextures.map = NULL; - } - - if ( pMga->agp.handle ) { - drmAgpUnbind( ctx->drmFD, pMga->agp.handle ); - drmAgpFree( ctx->drmFD, pMga->agp.handle ); - pMga->agp.handle = 0; - drmAgpRelease( ctx->drmFD ); - } - - DRICloseScreen( pScreen ); - - if ( pMga->pDRIInfo ) { - if ( pMga->pDRIpMga->devPrivate ) { - xfree( pMga->pDRIpMga->devPrivate ); - pMga->pDRIpMga->devPrivate = 0; - } - DRIDestroyInfoRec( pMga->pDRIInfo ); - pMga->pDRIInfo = 0; - } - if ( pMga->DRIServerInfo ) { - xfree( pMga->DRIServerInfo ); - pMga->DRIServerInfo = 0; - } - if ( pMga->pVisualConfigs ) { - xfree( pMga->pVisualConfigs ); - } - if ( pMga->pVisualConfigsPriv ) { - xfree( pMga->pVisualConfigsPriv ); - } -} -#endif diff --git a/src/mesa/drivers/dri/r128/server/r128_dri.c b/src/mesa/drivers/dri/r128/server/r128_dri.c deleted file mode 100644 index 6e3db948af..0000000000 --- a/src/mesa/drivers/dri/r128/server/r128_dri.c +++ /dev/null @@ -1,1112 +0,0 @@ -/* - * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario, - * Precision Insight, Inc., Cedar Park, Texas, and - * VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation on the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX - * SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -/* - * Authors: - * Kevin E. Martin - * Rickard E. Faith - * Daryll Strauss - * Gareth Hughes - * - */ - -#include -#include -#include -#include -#include -// Fix this to use kernel pci_ids.h when all of these IDs make it into the kernel -#include "pci_ids.h" - -#include "driver.h" -#include "drm.h" -#include "memops.h" - -#include "r128.h" -#include "r128_dri.h" -#include "r128_macros.h" -#include "r128_reg.h" -#include "r128_version.h" -#include "r128_drm.h" - -static size_t r128_drm_page_size; - -/* Compute log base 2 of val. */ -static int R128MinBits(int val) -{ - int bits; - - if (!val) return 1; - for (bits = 0; val; val >>= 1, ++bits); - return bits; -} - -/* Initialize the AGP state. Request memory for use in AGP space, and - initialize the Rage 128 registers to point to that memory. */ -static GLboolean R128DRIAgpInit(const DRIDriverContext *ctx) -{ - unsigned char *R128MMIO = ctx->MMIOAddress; - R128InfoPtr info = ctx->driverPrivate; - unsigned long mode; - unsigned int vendor, device; - int ret; - unsigned long cntl, chunk; - int s, l; - int flags; - unsigned long agpBase; - - if (drmAgpAcquire(ctx->drmFD) < 0) { - fprintf(stderr, "[agp] AGP not available\n"); - return GL_FALSE; - } - - /* Modify the mode if the default mode is - not appropriate for this particular - combination of graphics card and AGP - chipset. */ - - mode = drmAgpGetMode(ctx->drmFD); /* Default mode */ - vendor = drmAgpVendorId(ctx->drmFD); - device = drmAgpDeviceId(ctx->drmFD); - - mode &= ~R128_AGP_MODE_MASK; - switch (info->agpMode) { - case 4: mode |= R128_AGP_4X_MODE; - case 2: mode |= R128_AGP_2X_MODE; - case 1: default: mode |= R128_AGP_1X_MODE; - } - - fprintf(stderr, - "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", - mode, vendor, device, - 0x1002, - info->Chipset); - - if (drmAgpEnable(ctx->drmFD, mode) < 0) { - fprintf(stderr, "[agp] AGP not enabled\n"); - drmAgpRelease(ctx->drmFD); - return GL_FALSE; - } - - info->agpOffset = 0; - - if ((ret = drmAgpAlloc(ctx->drmFD, info->agpSize*1024*1024, 0, NULL, - &info->agpMemHandle)) < 0) { - fprintf(stderr, "[agp] Out of memory (%d)\n", ret); - drmAgpRelease(ctx->drmFD); - return GL_FALSE; - } - fprintf(stderr, - "[agp] %d kB allocated with handle 0x%08x\n", - info->agpSize*1024, info->agpMemHandle); - - if (drmAgpBind(ctx->drmFD, info->agpMemHandle, info->agpOffset) < 0) { - fprintf(stderr, "[agp] Could not bind\n"); - drmAgpFree(ctx->drmFD, info->agpMemHandle); - drmAgpRelease(ctx->drmFD); - return GL_FALSE; - } - - /* Initialize the CCE ring buffer data */ - info->ringStart = info->agpOffset; - info->ringMapSize = info->ringSize*1024*1024 + r128_drm_page_size; - info->ringSizeLog2QW = R128MinBits(info->ringSize*1024*1024/8) - 1; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = r128_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->agpTexStart = info->bufStart + info->bufMapSize; - s = (info->agpSize*1024*1024 - info->agpTexStart); - l = R128MinBits((s-1) / R128_NR_TEX_REGIONS); - if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; - info->agpTexMapSize = (s >> l) << l; - info->log2AGPTexGran = l; - - if (info->CCESecure) flags = DRM_READ_ONLY; - else flags = 0; - - if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize, - DRM_AGP, flags, &info->ringHandle) < 0) { - fprintf(stderr, - "[agp] Could not add ring mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] ring handle = 0x%08x\n", info->ringHandle); - - if (drmMap(ctx->drmFD, info->ringHandle, info->ringMapSize, - (drmAddressPtr)&info->ring) < 0) { - fprintf(stderr, "[agp] Could not map ring\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] Ring mapped at 0x%08lx\n", - (unsigned long)info->ring); - - if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_AGP, flags, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[agp] Could not add ring read ptr mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] ring read ptr handle = 0x%08x\n", - info->ringReadPtrHandle); - - if (drmMap(ctx->drmFD, info->ringReadPtrHandle, info->ringReadMapSize, - (drmAddressPtr)&info->ringReadPtr) < 0) { - fprintf(stderr, - "[agp] Could not map ring read ptr\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] Ring read ptr mapped at 0x%08lx\n", - (unsigned long)info->ringReadPtr); - - if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize, - DRM_AGP, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[agp] Could not add vertex/indirect buffers mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmMap(ctx->drmFD, info->bufHandle, info->bufMapSize, - (drmAddressPtr)&info->buf) < 0) { - fprintf(stderr, - "[agp] Could not map vertex/indirect buffers\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] Vertex/indirect buffers mapped at 0x%08lx\n", - (unsigned long)info->buf); - - if (drmAddMap(ctx->drmFD, info->agpTexStart, info->agpTexMapSize, - DRM_AGP, 0, &info->agpTexHandle) < 0) { - fprintf(stderr, - "[agp] Could not add AGP texture map mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] AGP texture map handle = 0x%08lx\n", - info->agpTexHandle); - - if (drmMap(ctx->drmFD, info->agpTexHandle, info->agpTexMapSize, - (drmAddressPtr)&info->agpTex) < 0) { - fprintf(stderr, - "[agp] Could not map AGP texture map\n"); - return GL_FALSE; - } - fprintf(stderr, - "[agp] AGP Texture map mapped at 0x%08lx\n", - (unsigned long)info->agpTex); - - /* Initialize Rage 128's AGP registers */ - cntl = INREG(R128_AGP_CNTL); - cntl &= ~R128_AGP_APER_SIZE_MASK; - switch (info->agpSize) { - case 256: cntl |= R128_AGP_APER_SIZE_256MB; break; - case 128: cntl |= R128_AGP_APER_SIZE_128MB; break; - case 64: cntl |= R128_AGP_APER_SIZE_64MB; break; - case 32: cntl |= R128_AGP_APER_SIZE_32MB; break; - case 16: cntl |= R128_AGP_APER_SIZE_16MB; break; - case 8: cntl |= R128_AGP_APER_SIZE_8MB; break; - case 4: cntl |= R128_AGP_APER_SIZE_4MB; break; - default: - fprintf(stderr, - "[agp] Illegal aperture size %d kB\n", - info->agpSize*1024); - return GL_FALSE; - } - agpBase = drmAgpBase(ctx->drmFD); - OUTREG(R128_AGP_BASE, agpBase); - OUTREG(R128_AGP_CNTL, cntl); - - /* Disable Rage 128's PCIGART registers */ - chunk = INREG(R128_BM_CHUNK_0_VAL); - chunk &= ~(R128_BM_PTR_FORCE_TO_PCI | - R128_BM_PM4_RD_FORCE_TO_PCI | - R128_BM_GLOBAL_FORCE_TO_PCI); - OUTREG(R128_BM_CHUNK_0_VAL, chunk); - - OUTREG(R128_PCI_GART_PAGE, 1); /* Ensure AGP GART is used (for now) */ - - return GL_TRUE; -} - -static GLboolean R128DRIPciInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - unsigned char *R128MMIO = ctx->MMIOAddress; - uint32_t chunk; - int ret; - int flags; - - info->agpOffset = 0; - - ret = drmScatterGatherAlloc(ctx->drmFD, info->agpSize*1024*1024, - &info->pciMemHandle); - if (ret < 0) { - fprintf(stderr, "[pci] Out of memory (%d)\n", ret); - return GL_FALSE; - } - fprintf(stderr, - "[pci] %d kB allocated with handle 0x%08x\n", - info->agpSize*1024, info->pciMemHandle); - - /* Initialize the CCE ring buffer data */ - info->ringStart = info->agpOffset; - info->ringMapSize = info->ringSize*1024*1024 + r128_drm_page_size; - info->ringSizeLog2QW = R128MinBits(info->ringSize*1024*1024/8) - 1; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = r128_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL; - - if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize, - DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[pci] ring handle = 0x%08lx\n", info->ringHandle); - - if (drmMap(ctx->drmFD, info->ringHandle, info->ringMapSize, - (drmAddressPtr)&info->ring) < 0) { - fprintf(stderr, "[pci] Could not map ring\n"); - return GL_FALSE; - } - fprintf(stderr, - "[pci] Ring mapped at 0x%08lx\n", - (unsigned long)info->ring); - fprintf(stderr, - "[pci] Ring contents 0x%08lx\n", - *(unsigned long *)info->ring); - - if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring read ptr mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[pci] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmMap(ctx->drmFD, info->ringReadPtrHandle, info->ringReadMapSize, - (drmAddressPtr)&info->ringReadPtr) < 0) { - fprintf(stderr, - "[pci] Could not map ring read ptr\n"); - return GL_FALSE; - } - fprintf(stderr, - "[pci] Ring read ptr mapped at 0x%08lx\n", - (unsigned long)info->ringReadPtr); - fprintf(stderr, - "[pci] Ring read ptr contents 0x%08lx\n", - *(unsigned long *)info->ringReadPtr); - - if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize, - DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[pci] Could not add vertex/indirect buffers mapping\n"); - return GL_FALSE; - } - fprintf(stderr, - "[pci] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmMap(ctx->drmFD, info->bufHandle, info->bufMapSize, - (drmAddressPtr)&info->buf) < 0) { - fprintf(stderr, - "[pci] Could not map vertex/indirect buffers\n"); - return GL_FALSE; - } - fprintf(stderr, - "[pci] Vertex/indirect buffers mapped at 0x%08lx\n", - (unsigned long)info->buf); - fprintf(stderr, - "[pci] Vertex/indirect buffers contents 0x%08lx\n", - *(unsigned long *)info->buf); - - if (!info->IsPCI) { - /* This is really an AGP card, force PCI GART mode */ - chunk = INREG(R128_BM_CHUNK_0_VAL); - chunk |= (R128_BM_PTR_FORCE_TO_PCI | - R128_BM_PM4_RD_FORCE_TO_PCI | - R128_BM_GLOBAL_FORCE_TO_PCI); - OUTREG(R128_BM_CHUNK_0_VAL, chunk); - OUTREG(R128_PCI_GART_PAGE, 0); /* Ensure PCI GART is used */ - } - - return GL_TRUE; -} - -/* Add a map for the MMIO registers that will be accessed by any - DRI-based clients. */ -static GLboolean R128DRIMapInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - int flags; - - if (info->CCESecure) flags = DRM_READ_ONLY; - else flags = 0; - - /* Map registers */ - if (drmAddMap(ctx->drmFD, ctx->MMIOStart, ctx->MMIOSize, - DRM_REGISTERS, flags, &info->registerHandle) < 0) { - return GL_FALSE; - } - fprintf(stderr, - "[drm] register handle = 0x%08x\n", info->registerHandle); - - return GL_TRUE; -} - -/* Initialize the kernel data structures. */ -static int R128DRIKernelInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - drm_r128_init_t drmInfo; - - memset( &drmInfo, 0, sizeof(&drmInfo) ); - - drmInfo.func = R128_INIT_CCE; - drmInfo.sarea_priv_offset = sizeof(drm_sarea_t); - drmInfo.is_pci = info->IsPCI; - drmInfo.cce_mode = info->CCEMode; - drmInfo.cce_secure = info->CCESecure; - drmInfo.ring_size = info->ringSize*1024*1024; - drmInfo.usec_timeout = info->CCEusecTimeout; - - drmInfo.fb_bpp = ctx->bpp; - drmInfo.depth_bpp = ctx->bpp; - - drmInfo.front_offset = info->frontOffset; - drmInfo.front_pitch = info->frontPitch; - - drmInfo.back_offset = info->backOffset; - drmInfo.back_pitch = info->backPitch; - - drmInfo.depth_offset = info->depthOffset; - drmInfo.depth_pitch = info->depthPitch; - drmInfo.span_offset = info->spanOffset; - - drmInfo.fb_offset = info->LinearAddr; - drmInfo.mmio_offset = info->registerHandle; - drmInfo.ring_offset = info->ringHandle; - drmInfo.ring_rptr_offset = info->ringReadPtrHandle; - drmInfo.buffers_offset = info->bufHandle; - drmInfo.agp_textures_offset = info->agpTexHandle; - - if (drmCommandWrite(ctx->drmFD, DRM_R128_INIT, - &drmInfo, sizeof(drmInfo)) < 0) - return GL_FALSE; - - return GL_TRUE; -} - -/* Add a map for the vertex buffers that will be accessed by any - DRI-based clients. */ -static GLboolean R128DRIBufInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - /* Initialize vertex buffers */ - if (info->IsPCI) { - info->bufNumBufs = drmAddBufs(ctx->drmFD, - info->bufMapSize / R128_BUFFER_SIZE, - R128_BUFFER_SIZE, - DRM_SG_BUFFER, - info->bufStart); - } else { - info->bufNumBufs = drmAddBufs(ctx->drmFD, - info->bufMapSize / R128_BUFFER_SIZE, - R128_BUFFER_SIZE, - DRM_AGP_BUFFER, - info->bufStart); - } - if (info->bufNumBufs <= 0) { - fprintf(stderr, - "[drm] Could not create vertex/indirect buffers list\n"); - return GL_FALSE; - } - fprintf(stderr, - "[drm] Added %d %d byte vertex/indirect buffers\n", - info->bufNumBufs, R128_BUFFER_SIZE); - - if (!(info->buffers = drmMapBufs(ctx->drmFD))) { - fprintf(stderr, - "[drm] Failed to map vertex/indirect buffers list\n"); - return GL_FALSE; - } - fprintf(stderr, - "[drm] Mapped %d vertex/indirect buffers\n", - info->buffers->count); - - return GL_TRUE; -} - -static void R128DRIIrqInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - unsigned char *R128MMIO = ctx->MMIOAddress; - - if (!info->irq) { - info->irq = drmGetInterruptFromBusID( - ctx->drmFD, - ctx->pciBus, - ctx->pciDevice, - ctx->pciFunc); - - if((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) { - fprintf(stderr, - "[drm] failure adding irq handler, " - "there is a device already using that irq\n" - "[drm] falling back to irq-free operation\n"); - info->irq = 0; - } else { - info->gen_int_cntl = INREG( R128_GEN_INT_CNTL ); - } - } - - if (info->irq) - fprintf(stderr, - "[drm] dma control initialized, using IRQ %d\n", - info->irq); -} - -static int R128CCEStop(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - drm_r128_cce_stop_t stop; - int ret, i; - - stop.flush = 1; - stop.idle = 1; - - ret = drmCommandWrite( ctx->drmFD, DRM_R128_CCE_STOP, - &stop, sizeof(stop) ); - - if ( ret == 0 ) { - return 0; - } else if ( errno != EBUSY ) { - return -errno; - } - - stop.flush = 0; - - i = 0; - do { - ret = drmCommandWrite( ctx->drmFD, DRM_R128_CCE_STOP, - &stop, sizeof(stop) ); - } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY ); - - if ( ret == 0 ) { - return 0; - } else if ( errno != EBUSY ) { - return -errno; - } - - stop.idle = 0; - - if ( drmCommandWrite( ctx->drmFD, DRM_R128_CCE_STOP, - &stop, sizeof(stop) )) { - return -errno; - } else { - return 0; - } -} - -/* Initialize the CCE state, and start the CCE (if used by the X server) */ -static void R128DRICCEInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - - /* Turn on bus mastering */ - info->BusCntl &= ~R128_BUS_MASTER_DIS; - - /* CCEMode is initialized in r128_driver.c */ - switch (info->CCEMode) { - case R128_PM4_NONPM4: info->CCEFifoSize = 0; break; - case R128_PM4_192PIO: info->CCEFifoSize = 192; break; - case R128_PM4_192BM: info->CCEFifoSize = 192; break; - case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break; - case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break; - case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break; - case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break; - } - - /* Make sure the CCE is on for the X server */ - R128CCE_START(ctx, info); -} - - -static int R128MemoryInit(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - int width_bytes = ctx->shared.virtualWidth * ctx->cpp; - int cpp = ctx->cpp; - int bufferSize = ((ctx->shared.virtualHeight * width_bytes - + R128_BUFFER_ALIGN) - & ~R128_BUFFER_ALIGN); - int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes - + R128_BUFFER_ALIGN) - & ~R128_BUFFER_ALIGN); - int l; - - info->frontOffset = 0; - info->frontPitch = ctx->shared.virtualWidth; - - fprintf(stderr, - "Using %d MB AGP aperture\n", info->agpSize); - fprintf(stderr, - "Using %d MB for the ring buffer\n", info->ringSize); - fprintf(stderr, - "Using %d MB for vertex/indirect buffers\n", info->bufSize); - fprintf(stderr, - "Using %d MB for AGP textures\n", info->agpTexSize); - - /* Front, back and depth buffers - everything else texture?? - */ - info->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize; - - if (info->textureSize < 0) - return 0; - - l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); - if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't - * round down. - */ - info->log2TexGran = l; - info->textureSize = (info->textureSize >> l) << l; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256x32bpp textures. - */ - if (info->textureSize < 512 * 1024) { - info->textureOffset = 0; - info->textureSize = 0; - } - - /* Reserve space for textures */ - info->textureOffset = ((ctx->shared.fbSize - info->textureSize + - R128_BUFFER_ALIGN) & - ~R128_BUFFER_ALIGN); - - /* Reserve space for the shared depth - * buffer. - */ - info->depthOffset = ((info->textureOffset - depthSize + - R128_BUFFER_ALIGN) & - ~R128_BUFFER_ALIGN); - info->depthPitch = ctx->shared.virtualWidth; - - info->backOffset = ((info->depthOffset - bufferSize + - R128_BUFFER_ALIGN) & - ~R128_BUFFER_ALIGN); - info->backPitch = ctx->shared.virtualWidth; - - - fprintf(stderr, - "Will use back buffer at offset 0x%x\n", - info->backOffset); - fprintf(stderr, - "Will use depth buffer at offset 0x%x\n", - info->depthOffset); - fprintf(stderr, - "Will use %d kb for textures at offset 0x%x\n", - info->textureSize/1024, info->textureOffset); - - return 1; -} - - -/* Initialize the screen-specific data structures for the DRI and the - Rage 128. This is the main entry point to the device-specific - initialization code. It calls device-independent DRI functions to - create the DRI data structures and initialize the DRI state. */ -static GLboolean R128DRIScreenInit(DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - R128DRIPtr pR128DRI; - int err, major, minor, patch; - drmVersionPtr version; - drm_r128_sarea_t *pSAREAPriv; - - switch (ctx->bpp) { - case 8: - /* These modes are not supported (yet). */ - case 15: - case 24: - fprintf(stderr, - "[dri] R128DRIScreenInit failed (depth %d not supported). " - "[dri] Disabling DRI.\n", ctx->bpp); - return GL_FALSE; - - /* Only 16 and 32 color depths are supports currently. */ - case 16: - case 32: - break; - } - r128_drm_page_size = getpagesize(); - - info->registerSize = ctx->MMIOSize; - ctx->shared.SAREASize = SAREA_MAX; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("r128", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - /* Check the r128 DRM version */ - version = drmGetVersion(ctx->drmFD); - if (version) { - if (version->version_major != 2 || - version->version_minor < 2) { - /* incompatible drm version */ - fprintf(stderr, - "[dri] R128DRIScreenInit failed because of a version mismatch.\n" - "[dri] r128.o kernel module version is %d.%d.%d but version 2.2 or greater is needed.\n" - "[dri] Disabling the DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel); - drmFreeVersion(version); - return GL_FALSE; - } - info->drmMinor = version->version_minor; - drmFreeVersion(version); - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, - 0, - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - if (!R128MemoryInit(ctx)) - return GL_FALSE; - - /* Initialize AGP */ - if (!info->IsPCI && !R128DRIAgpInit(ctx)) { - info->IsPCI = GL_TRUE; - fprintf(stderr, - "[agp] AGP failed to initialize -- falling back to PCI mode.\n"); - fprintf(stderr, - "[agp] Make sure you have the agpgart kernel module loaded.\n"); - } - - /* Initialize PCIGART */ - if (info->IsPCI && !R128DRIPciInit(ctx)) { - return GL_FALSE; - } - - /* DRIScreenInit doesn't add all the - common mappings. Add additional - mappings here. */ - if (!R128DRIMapInit(ctx)) { - return GL_FALSE; - } - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the kernel data structures */ - if (!R128DRIKernelInit(ctx)) { - return GL_FALSE; - } - - /* Initialize the vertex buffers list */ - if (!R128DRIBufInit(ctx)) { - return GL_FALSE; - } - - /* Initialize IRQ */ - R128DRIIrqInit(ctx); - - /* Initialize and start the CCE if required */ - R128DRICCEInit(ctx); - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - drimemsetio((char *)ctx->FBAddress + info->frontOffset, - 0, - info->frontPitch * ctx->cpp * ctx->shared.virtualHeight ); - - drimemsetio((char *)ctx->FBAddress + info->backOffset, - 0, - info->backPitch * ctx->cpp * ctx->shared.virtualHeight ); - - pSAREAPriv = (drm_r128_sarea_t *)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - - /* This is the struct passed to radeon_dri.so for its initialization */ - ctx->driverClientMsg = malloc(sizeof(R128DRIRec)); - ctx->driverClientMsgSize = sizeof(R128DRIRec); - - pR128DRI = (R128DRIPtr)ctx->driverClientMsg; - pR128DRI->deviceID = info->Chipset; - pR128DRI->width = ctx->shared.virtualWidth; - pR128DRI->height = ctx->shared.virtualHeight; - pR128DRI->depth = ctx->bpp; - pR128DRI->bpp = ctx->bpp; - - pR128DRI->IsPCI = info->IsPCI; - pR128DRI->AGPMode = info->agpMode; - - pR128DRI->frontOffset = info->frontOffset; - pR128DRI->frontPitch = info->frontPitch; - pR128DRI->backOffset = info->backOffset; - pR128DRI->backPitch = info->backPitch; - pR128DRI->depthOffset = info->depthOffset; - pR128DRI->depthPitch = info->depthPitch; - pR128DRI->spanOffset = info->spanOffset; - pR128DRI->textureOffset = info->textureOffset; - pR128DRI->textureSize = info->textureSize; - pR128DRI->log2TexGran = info->log2TexGran; - - pR128DRI->registerHandle = info->registerHandle; - pR128DRI->registerSize = info->registerSize; - - pR128DRI->agpTexHandle = info->agpTexHandle; - pR128DRI->agpTexMapSize = info->agpTexMapSize; - pR128DRI->log2AGPTexGran = info->log2AGPTexGran; - pR128DRI->agpTexOffset = info->agpTexStart; - pR128DRI->sarea_priv_offset = sizeof(drm_sarea_t); - - return GL_TRUE; -} - -/* The screen is being closed, so clean up any state and free any - resources used by the DRI. */ -void R128DRICloseScreen(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - drm_r128_init_t drmInfo; - - /* Stop the CCE if it is still in use */ - R128CCE_STOP(ctx, info); - - if (info->irq) { - drmCtlUninstHandler(ctx->drmFD); - info->irq = 0; - } - - /* De-allocate vertex buffers */ - if (info->buffers) { - drmUnmapBufs(info->buffers); - info->buffers = NULL; - } - - /* De-allocate all kernel resources */ - memset(&drmInfo, 0, sizeof(drmInfo)); - drmInfo.func = R128_CLEANUP_CCE; - drmCommandWrite(ctx->drmFD, DRM_R128_INIT, - &drmInfo, sizeof(drmInfo)); - - /* De-allocate all AGP resources */ - if (info->agpTex) { - drmUnmap(info->agpTex, info->agpTexMapSize); - info->agpTex = NULL; - } - if (info->buf) { - drmUnmap(info->buf, info->bufMapSize); - info->buf = NULL; - } - if (info->ringReadPtr) { - drmUnmap(info->ringReadPtr, info->ringReadMapSize); - info->ringReadPtr = NULL; - } - if (info->ring) { - drmUnmap(info->ring, info->ringMapSize); - info->ring = NULL; - } - if (info->agpMemHandle != DRM_AGP_NO_HANDLE) { - drmAgpUnbind(ctx->drmFD, info->agpMemHandle); - drmAgpFree(ctx->drmFD, info->agpMemHandle); - info->agpMemHandle = 0; - drmAgpRelease(ctx->drmFD); - } - if (info->pciMemHandle) { - drmScatterGatherFree(ctx->drmFD, info->pciMemHandle); - info->pciMemHandle = 0; - } -} - -static GLboolean R128PreInitDRI(const DRIDriverContext *ctx) -{ - R128InfoPtr info = ctx->driverPrivate; - - /*info->CCEMode = R128_DEFAULT_CCE_PIO_MODE;*/ - info->CCEMode = R128_DEFAULT_CCE_BM_MODE; - info->CCESecure = GL_TRUE; - - info->agpMode = R128_DEFAULT_AGP_MODE; - info->agpSize = R128_DEFAULT_AGP_SIZE; - info->ringSize = R128_DEFAULT_RING_SIZE; - info->bufSize = R128_DEFAULT_BUFFER_SIZE; - info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE; - - info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT; - - return GL_TRUE; -} - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p ctx - * and then calls R128ScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int R128InitFBDev( DRIDriverContext *ctx ) -{ - R128InfoPtr info = calloc(1, sizeof(*info)); - - { - int dummy = ctx->shared.virtualWidth; - - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - - ctx->shared.virtualWidth = dummy; - } - - ctx->driverPrivate = (void *)info; - - info->Chipset = ctx->chipset; - - switch (info->Chipset) { - case PCI_DEVICE_ID_ATI_RAGE128_LE: - case PCI_DEVICE_ID_ATI_RAGE128_RE: - case PCI_DEVICE_ID_ATI_RAGE128_RK: - case PCI_DEVICE_ID_ATI_RAGE128_PD: - case PCI_DEVICE_ID_ATI_RAGE128_PP: - case PCI_DEVICE_ID_ATI_RAGE128_PR: - /* This is a PCI card */ - info->IsPCI = GL_TRUE; - break; - default: - /* This is an AGP card */ - info->IsPCI = GL_FALSE; - break; - } - - info->frontPitch = ctx->shared.virtualWidth; - info->LinearAddr = ctx->FBStart & 0xfc000000; - - if (!R128PreInitDRI(ctx)) - return 0; - - if (!R128DRIScreenInit(ctx)) - return 0; - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void R128HaltFBDev( DRIDriverContext *ctx ) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa R128PostValidateMode(). - */ -static int R128ValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa R128ValidateMode(). - */ -static int R128PostValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Shutdown the drawing engine. - * - * \param ctx display handle - * - * Turns off the command processor engine & restores the graphics card - * to a state that fbdev understands. - */ -static int R128EngineShutdown( const DRIDriverContext *ctx ) -{ - return 1; -} - -/** - * \brief Restore the drawing engine. - * - * \param ctx display handle - * - * Resets the graphics card and sets initial values for several registers of - * the card's drawing engine. - * - * Turns on the R128 command processor engine (i.e., the ringbuffer). - */ -static int R128EngineRestore( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -const struct DRIDriverRec __driDriver = { - R128ValidateMode, - R128PostValidateMode, - R128InitFBDev, - R128HaltFBDev, - R128EngineShutdown, - R128EngineRestore, - 0, -}; diff --git a/src/mesa/drivers/dri/r200/server/radeon_dri.c b/src/mesa/drivers/dri/r200/server/radeon_dri.c deleted file mode 120000 index d05847d650..0000000000 --- a/src/mesa/drivers/dri/r200/server/radeon_dri.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_dri.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/server/radeon_dri.c b/src/mesa/drivers/dri/r300/server/radeon_dri.c deleted file mode 120000 index d05847d650..0000000000 --- a/src/mesa/drivers/dri/r300/server/radeon_dri.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_dri.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/server/radeon_dri.c b/src/mesa/drivers/dri/r600/server/radeon_dri.c deleted file mode 120000 index d05847d650..0000000000 --- a/src/mesa/drivers/dri/r600/server/radeon_dri.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_dri.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/src/mesa/drivers/dri/radeon/server/radeon_dri.c deleted file mode 100644 index 7ead588dac..0000000000 --- a/src/mesa/drivers/dri/radeon/server/radeon_dri.c +++ /dev/null @@ -1,1337 +0,0 @@ -/** - * \file server/radeon_dri.c - * \brief File to perform the device-specific initialization tasks typically - * done in the X server. - * - * Here they are converted to run in the client (or perhaps a standalone - * process), and to work with the frame buffer device rather than the X - * server infrastructure. - */ - -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" -#include "memops.h" - -#include "radeon.h" -#include "radeon_dri.h" -#include "radeon_macros.h" -#include "radeon_reg.h" -#include "drm_sarea.h" - -static size_t radeon_drm_page_size; - -static int RadeonSetParam(const DRIDriverContext *ctx, int param, int value) -{ - drm_radeon_setparam_t sp; - - memset(&sp, 0, sizeof(sp)); - sp.param = param; - sp.value = value; - - if (drmCommandWrite(ctx->drmFD, DRM_RADEON_SETPARAM, &sp, sizeof(sp))) { - return -1; - } - - return 0; -} - -/** - * \brief Wait for free FIFO entries. - * - * \param ctx display handle. - * \param entries number of free entries to wait. - * - * It polls the free entries from the chip until it reaches the requested value - * or a timeout (3000 tries) occurs. Aborts the program if the FIFO times out. - */ -static void RADEONWaitForFifo( const DRIDriverContext *ctx, - int entries ) -{ - unsigned char *RADEONMMIO = ctx->MMIOAddress; - int i; - - for (i = 0; i < 3000; i++) { - int fifo_slots = - INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK; - if (fifo_slots >= entries) return; - } - - /* There are recoveries possible, but I haven't seen them work - * in practice: - */ - fprintf(stderr, "FIFO timed out: %d entries, stat=0x%08x\n", - INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK, - INREG(RADEON_RBBM_STATUS)); - exit(1); -} - -/** - * \brief Read a PLL register. - * - * \param ctx display handle. - * \param addr PLL register index. - * - * \return value of the PLL register. - */ -static unsigned int RADEONINPLL( const DRIDriverContext *ctx, int addr) -{ - unsigned char *RADEONMMIO = ctx->MMIOAddress; - unsigned int data; - - OUTREG8(RADEON_CLOCK_CNTL_INDEX, addr & 0x3f); - data = INREG(RADEON_CLOCK_CNTL_DATA); - - return data; -} - -/** - * \brief Reset graphics card to known state. - * - * \param ctx display handle. - * - * Resets the values of several Radeon registers. - */ -static void RADEONEngineReset( const DRIDriverContext *ctx ) -{ - unsigned char *RADEONMMIO = ctx->MMIOAddress; - unsigned int clock_cntl_index; - unsigned int mclk_cntl; - unsigned int rbbm_soft_reset; - unsigned int host_path_cntl; - int i; - - OUTREGP(RADEON_RB2D_DSTCACHE_CTLSTAT, - RADEON_RB2D_DC_FLUSH_ALL, - ~RADEON_RB2D_DC_FLUSH_ALL); - for (i = 0; i < 512; i++) { - if (!(INREG(RADEON_RB2D_DSTCACHE_CTLSTAT) & RADEON_RB2D_DC_BUSY)) - break; - } - - clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX); - - mclk_cntl = INPLL(ctx, RADEON_MCLK_CNTL); - OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl | - RADEON_FORCEON_MCLKA | - RADEON_FORCEON_MCLKB | - RADEON_FORCEON_YCLKA | - RADEON_FORCEON_YCLKB | - RADEON_FORCEON_MC | - RADEON_FORCEON_AIC)); - - /* Soft resetting HDP thru RBBM_SOFT_RESET register can cause some - * unexpected behaviour on some machines. Here we use - * RADEON_HOST_PATH_CNTL to reset it. - */ - host_path_cntl = INREG(RADEON_HOST_PATH_CNTL); - rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET); - - OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset | - RADEON_SOFT_RESET_CP | - RADEON_SOFT_RESET_HI | - RADEON_SOFT_RESET_SE | - RADEON_SOFT_RESET_RE | - RADEON_SOFT_RESET_PP | - RADEON_SOFT_RESET_E2 | - RADEON_SOFT_RESET_RB)); - INREG(RADEON_RBBM_SOFT_RESET); - OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset & - (unsigned int) ~(RADEON_SOFT_RESET_CP | - RADEON_SOFT_RESET_HI | - RADEON_SOFT_RESET_SE | - RADEON_SOFT_RESET_RE | - RADEON_SOFT_RESET_PP | - RADEON_SOFT_RESET_E2 | - RADEON_SOFT_RESET_RB))); - INREG(RADEON_RBBM_SOFT_RESET); - - OUTREG(RADEON_HOST_PATH_CNTL, host_path_cntl | RADEON_HDP_SOFT_RESET); - INREG(RADEON_HOST_PATH_CNTL); - OUTREG(RADEON_HOST_PATH_CNTL, host_path_cntl); - - OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset); - - OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index); - OUTPLL(RADEON_MCLK_CNTL, mclk_cntl); -} - -/** - * \brief Restore the drawing engine. - * - * \param ctx display handle - * - * Resets the graphics card and sets initial values for several registers of - * the card's drawing engine. - * - * Turns on the radeon command processor engine (i.e., the ringbuffer). - */ -static int RADEONEngineRestore( const DRIDriverContext *ctx ) -{ - RADEONInfoPtr info = ctx->driverPrivate; - unsigned char *RADEONMMIO = ctx->MMIOAddress; - int pitch64, datatype, dp_gui_master_cntl, err; - - fprintf(stderr, "%s\n", __FUNCTION__); - - OUTREG(RADEON_RB3D_CNTL, 0); - RADEONEngineReset( ctx ); - - switch (ctx->bpp) { - case 16: datatype = 4; break; - case 32: datatype = 6; break; - default: return 0; - } - - dp_gui_master_cntl = - ((datatype << RADEON_GMC_DST_DATATYPE_SHIFT) - | RADEON_GMC_CLR_CMP_CNTL_DIS); - - pitch64 = ((ctx->shared.virtualWidth * (ctx->bpp / 8) + 0x3f)) >> 6; - - RADEONWaitForFifo(ctx, 1); - OUTREG(RADEON_DEFAULT_OFFSET, ((INREG(RADEON_DEFAULT_OFFSET) & 0xC0000000) - | (pitch64 << 22))); - - RADEONWaitForFifo(ctx, 1); - OUTREG(RADEON_SURFACE_CNTL, RADEON_SURF_TRANSLATION_DIS); - - RADEONWaitForFifo(ctx, 1); - OUTREG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX - | RADEON_DEFAULT_SC_BOTTOM_MAX)); - - RADEONWaitForFifo(ctx, 1); - OUTREG(RADEON_DP_GUI_MASTER_CNTL, (dp_gui_master_cntl - | RADEON_GMC_BRUSH_SOLID_COLOR - | RADEON_GMC_SRC_DATATYPE_COLOR)); - - RADEONWaitForFifo(ctx, 7); - OUTREG(RADEON_DST_LINE_START, 0); - OUTREG(RADEON_DST_LINE_END, 0); - OUTREG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff); - OUTREG(RADEON_DP_BRUSH_BKGD_CLR, 0); - OUTREG(RADEON_DP_SRC_FRGD_CLR, 0xffffffff); - OUTREG(RADEON_DP_SRC_BKGD_CLR, 0); - OUTREG(RADEON_DP_WRITE_MASK, 0xffffffff); - OUTREG(RADEON_AUX_SC_CNTL, 0); - -/* RADEONWaitForIdleMMIO(ctx); */ - usleep(100); - - - OUTREG(RADEON_GEN_INT_CNTL, info->gen_int_cntl); - if (info->colorTiling) - info->crtc_offset_cntl |= RADEON_CRTC_TILE_EN; - OUTREG(RADEON_CRTC_OFFSET_CNTL, info->crtc_offset_cntl); - - /* Initialize and start the CP if required */ - if ((err = drmCommandNone(ctx->drmFD, DRM_RADEON_CP_START)) != 0) { - fprintf(stderr, "%s: CP start %d\n", __FUNCTION__, err); - return 0; - } - - return 1; -} - - -/** - * \brief Shutdown the drawing engine. - * - * \param ctx display handle - * - * Turns off the command processor engine & restores the graphics card - * to a state that fbdev understands. - */ -static int RADEONEngineShutdown( const DRIDriverContext *ctx ) -{ - drm_radeon_cp_stop_t stop; - int ret, i; - - stop.flush = 1; - stop.idle = 1; - - ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop, - sizeof(drm_radeon_cp_stop_t)); - - if (ret == 0) { - return 0; - } else if (errno != EBUSY) { - return -errno; - } - - stop.flush = 0; - - i = 0; - do { - ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop, - sizeof(drm_radeon_cp_stop_t)); - } while (ret && errno == EBUSY && i++ < 10); - - if (ret == 0) { - return 0; - } else if (errno != EBUSY) { - return -errno; - } - - stop.idle = 0; - - if (drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, - &stop, sizeof(drm_radeon_cp_stop_t))) { - return -errno; - } else { - return 0; - } -} - -/** - * \brief Compute base 2 logarithm. - * - * \param val value. - * - * \return base 2 logarithm of \p val. - */ -static int RADEONMinBits(int val) -{ - int bits; - - if (!val) return 1; - for (bits = 0; val; val >>= 1, ++bits); - return bits; -} - -/** - * \brief Initialize the AGP state - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Acquires and enables the AGP device. Reserves memory in the AGP space for - * the ring buffer, vertex buffers and textures. Initialize the Radeon - * registers to point to that memory and add client mappings. - */ -static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info) -{ - unsigned char *RADEONMMIO = ctx->MMIOAddress; - unsigned long mode; - int ret; - int s, l; - - if (drmAgpAcquire(ctx->drmFD) < 0) { - fprintf(stderr, "[gart] AGP not available\n"); - return 0; - } - - /* Modify the mode if the default mode is not appropriate for this - * particular combination of graphics card and AGP chipset. - */ - mode = drmAgpGetMode(ctx->drmFD); /* Default mode */ - - /* Disable fast write entirely - too many lockups. - */ - mode &= ~RADEON_AGP_MODE_MASK; - switch (ctx->agpmode) { - case 4: mode |= RADEON_AGP_4X_MODE; - case 2: mode |= RADEON_AGP_2X_MODE; - case 1: default: mode |= RADEON_AGP_1X_MODE; - } - - if (drmAgpEnable(ctx->drmFD, mode) < 0) { - fprintf(stderr, "[gart] AGP not enabled\n"); - drmAgpRelease(ctx->drmFD); - return 0; - } - else - fprintf(stderr, "[gart] AGP enabled at %dx\n", ctx->agpmode); - - /* Workaround for some hardware bugs */ - if (info->ChipFamily < CHIP_FAMILY_R200) - OUTREG(RADEON_AGP_CNTL, INREG(RADEON_AGP_CNTL) | 0x000e0000); - - info->gartOffset = 0; - - if ((ret = drmAgpAlloc(ctx->drmFD, info->gartSize*1024*1024, 0, NULL, - &info->gartMemHandle)) < 0) { - fprintf(stderr, "[gart] Out of memory (%d)\n", ret); - drmAgpRelease(ctx->drmFD); - return 0; - } - fprintf(stderr, - "[gart] %d kB allocated with handle 0x%08x\n", - info->gartSize*1024, (unsigned)info->gartMemHandle); - - if (drmAgpBind(ctx->drmFD, - info->gartMemHandle, info->gartOffset) < 0) { - fprintf(stderr, "[gart] Could not bind\n"); - drmAgpFree(ctx->drmFD, info->gartMemHandle); - drmAgpRelease(ctx->drmFD); - return 0; - } - - /* Initialize the CP ring buffer data */ - info->ringStart = info->gartOffset; - info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = radeon_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->gartTexStart = info->bufStart + info->bufMapSize; - s = (info->gartSize*1024*1024 - info->gartTexStart); - l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - info->gartTexMapSize = (s >> l) << l; - info->log2GARTTexGran = l; - - if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize, - DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) { - fprintf(stderr, "[gart] Could not add ring mapping\n"); - return 0; - } - fprintf(stderr, "[gart] ring handle = 0x%08x\n", info->ringHandle); - - - if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[gart] Could not add ring read ptr mapping\n"); - return 0; - } - - fprintf(stderr, - "[gart] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize, - DRM_AGP, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[gart] Could not add vertex/indirect buffers mapping\n"); - return 0; - } - fprintf(stderr, - "[gart] vertex/indirect buffers handle = 0x%08x\n", - info->bufHandle); - - if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize, - DRM_AGP, 0, &info->gartTexHandle) < 0) { - fprintf(stderr, - "[gart] Could not add AGP texture map mapping\n"); - return 0; - } - fprintf(stderr, - "[gart] AGP texture map handle = 0x%08lx\n", - info->gartTexHandle); - - /* Initialize Radeon's AGP registers */ - /* Ring buffer is at AGP offset 0 */ - OUTREG(RADEON_AGP_BASE, info->ringHandle); - - return 1; -} - -/* Initialize the PCI GART state. Request memory for use in PCI space, - * and initialize the Radeon registers to point to that memory. - */ -static int RADEONDRIPciInit(const DRIDriverContext *ctx, RADEONInfoPtr info) -{ - int ret; - int flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL; - int s, l; - - ret = drmScatterGatherAlloc(ctx->drmFD, info->gartSize*1024*1024, - &info->gartMemHandle); - if (ret < 0) { - fprintf(stderr, "[pci] Out of memory (%d)\n", ret); - return 0; - } - fprintf(stderr, - "[pci] %d kB allocated with handle 0x%08lx\n", - info->gartSize*1024, info->gartMemHandle); - - info->gartOffset = 0; - - /* Initialize the CP ring buffer data */ - info->ringStart = info->gartOffset; - info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = radeon_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->gartTexStart = info->bufStart + info->bufMapSize; - s = (info->gartSize*1024*1024 - info->gartTexStart); - l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - info->gartTexMapSize = (s >> l) << l; - info->log2GARTTexGran = l; - - if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize, - DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] ring handle = 0x%08x\n", info->ringHandle); - - if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring read ptr mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize, - DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[pci] Could not add vertex/indirect buffers mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize, - DRM_SCATTER_GATHER, 0, &info->gartTexHandle) < 0) { - fprintf(stderr, - "[pci] Could not add GART texture map mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] GART texture map handle = 0x%08x\n", - info->gartTexHandle); - - return 1; -} - - -/** - * \brief Initialize the kernel data structures and enable the CP engine. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * This function is a wrapper around the DRM_RADEON_CP_INIT command, passing - * all the parameters in a drm_radeon_init_t structure. - */ -static int RADEONDRIKernelInit( const DRIDriverContext *ctx, - RADEONInfoPtr info) -{ - int cpp = ctx->bpp / 8; - drm_radeon_init_t drmInfo; - int ret; - - memset(&drmInfo, 0, sizeof(drm_radeon_init_t)); - - if ( (info->ChipFamily == CHIP_FAMILY_R200) || - (info->ChipFamily == CHIP_FAMILY_RV250) || - (info->ChipFamily == CHIP_FAMILY_M9) || - (info->ChipFamily == CHIP_FAMILY_RV280) ) - drmInfo.func = RADEON_INIT_R200_CP; - else - drmInfo.func = RADEON_INIT_CP; - - /* This is the struct passed to the kernel module for its initialization */ - drmInfo.sarea_priv_offset = sizeof(drm_sarea_t); - drmInfo.is_pci = ctx->isPCI; - drmInfo.cp_mode = RADEON_DEFAULT_CP_BM_MODE; - drmInfo.gart_size = info->gartSize*1024*1024; - drmInfo.ring_size = info->ringSize*1024*1024; - drmInfo.usec_timeout = 1000; - drmInfo.fb_bpp = ctx->bpp; - drmInfo.depth_bpp = ctx->bpp; - drmInfo.front_offset = info->frontOffset; - drmInfo.front_pitch = info->frontPitch * cpp; - drmInfo.back_offset = info->backOffset; - drmInfo.back_pitch = info->backPitch * cpp; - drmInfo.depth_offset = info->depthOffset; - drmInfo.depth_pitch = info->depthPitch * cpp; - drmInfo.fb_offset = info->LinearAddr; - drmInfo.mmio_offset = info->registerHandle; - drmInfo.ring_offset = info->ringHandle; - drmInfo.ring_rptr_offset = info->ringReadPtrHandle; - drmInfo.buffers_offset = info->bufHandle; - drmInfo.gart_textures_offset = info->gartTexHandle; - - ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_INIT, &drmInfo, - sizeof(drm_radeon_init_t)); - - return ret >= 0; -} - - -/** - * \brief Initialize the AGP heap. - * - * \param ctx display handle. - * \param info driver private data. - * - * This function is a wrapper around the DRM_RADEON_INIT_HEAP command, passing - * all the parameters in a drm_radeon_mem_init_heap structure. - */ -static void RADEONDRIAgpHeapInit(const DRIDriverContext *ctx, - RADEONInfoPtr info) -{ - drm_radeon_mem_init_heap_t drmHeap; - - /* Start up the simple memory manager for gart space */ - drmHeap.region = RADEON_MEM_REGION_GART; - drmHeap.start = 0; - drmHeap.size = info->gartTexMapSize; - - if (drmCommandWrite(ctx->drmFD, DRM_RADEON_INIT_HEAP, - &drmHeap, sizeof(drmHeap))) { - fprintf(stderr, - "[drm] Failed to initialized gart heap manager\n"); - } else { - fprintf(stderr, - "[drm] Initialized kernel gart heap manager, %d\n", - info->gartTexMapSize); - } -} - -/** - * \brief Add a map for the vertex buffers that will be accessed by any - * DRI-based clients. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Calls drmAddBufs() with the previously allocated vertex buffers. - */ -static int RADEONDRIBufInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) -{ - /* Initialize vertex buffers */ - info->bufNumBufs = drmAddBufs(ctx->drmFD, - info->bufMapSize / RADEON_BUFFER_SIZE, - RADEON_BUFFER_SIZE, - ctx->isPCI ? DRM_SG_BUFFER : DRM_AGP_BUFFER, - info->bufStart); - - if (info->bufNumBufs <= 0) { - fprintf(stderr, - "[drm] Could not create vertex/indirect buffers list\n"); - return 0; - } - fprintf(stderr, - "[drm] Added %d %d byte vertex/indirect buffers\n", - info->bufNumBufs, RADEON_BUFFER_SIZE); - - return 1; -} - -/** - * \brief Install an IRQ handler. - * - * \param ctx display handle. - * \param info driver private data. - * - * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to - * IRQ-free operation on failure. - */ -static void RADEONDRIIrqInit(const DRIDriverContext *ctx, - RADEONInfoPtr info) -{ - if (!info->irq) { - info->irq = drmGetInterruptFromBusID(ctx->drmFD, - ctx->pciBus, - ctx->pciDevice, - ctx->pciFunc); - - if ((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) { - fprintf(stderr, - "[drm] failure adding irq handler, " - "there is a device already using that irq\n" - "[drm] falling back to irq-free operation\n"); - info->irq = 0; - } - } - - if (info->irq) - fprintf(stderr, - "[drm] dma control initialized, using IRQ %d\n", - info->irq); -} - -static int RADEONCheckDRMVersion( const DRIDriverContext *ctx, - RADEONInfoPtr info ) -{ - drmVersionPtr version; - - version = drmGetVersion(ctx->drmFD); - if (version) { - int req_minor, req_patch; - - /* Need 1.8.x for proper cleanup-on-client-exit behaviour. - */ - req_minor = 8; - req_patch = 0; - - if (version->version_major != 1 || - version->version_minor < req_minor || - (version->version_minor == req_minor && - version->version_patchlevel < req_patch)) { - /* Incompatible drm version */ - fprintf(stderr, - "[dri] RADEONDRIScreenInit failed because of a version " - "mismatch.\n" - "[dri] radeon.o kernel module version is %d.%d.%d " - "but version 1.%d.%d or newer is needed.\n" - "[dri] Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel, - req_minor, - req_patch); - drmFreeVersion(version); - return 0; - } - - info->drmMinor = version->version_minor; - drmFreeVersion(version); - } - - return 1; -} - -static int RADEONMemoryInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) -{ - int width_bytes = ctx->shared.virtualWidth * ctx->cpp; - int cpp = ctx->cpp; - int bufferSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); - int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes - + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN); - int l; - - info->frontOffset = 0; - info->frontPitch = ctx->shared.virtualWidth; - - fprintf(stderr, - "Using %d MB AGP aperture\n", info->gartSize); - fprintf(stderr, - "Using %d MB for the ring buffer\n", info->ringSize); - fprintf(stderr, - "Using %d MB for vertex/indirect buffers\n", info->bufSize); - fprintf(stderr, - "Using %d MB for AGP textures\n", info->gartTexSize); - - /* Front, back and depth buffers - everything else texture?? - */ - info->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize; - - if (ctx->colorTiling==1) - { - info->textureSize = ctx->shared.fbSize - ((ctx->shared.fbSize - info->textureSize + width_bytes * 16 - 1) / (width_bytes * 16)) * (width_bytes*16); - } - - if (info->textureSize < 0) - return 0; - - l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't - * round down. - */ - info->log2TexGran = l; - info->textureSize = (info->textureSize >> l) << l; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256x32bpp textures. - */ - if (info->textureSize < 512 * 1024) { - info->textureOffset = 0; - info->textureSize = 0; - } - - /* Reserve space for textures */ - if (ctx->colorTiling==1) - { - info->textureOffset = ((ctx->shared.fbSize - info->textureSize) / - (width_bytes * 16)) * (width_bytes*16); - } - else - { - info->textureOffset = ((ctx->shared.fbSize - info->textureSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - } - /* Reserve space for the shared depth - * buffer. - */ - info->depthOffset = ((info->textureOffset - depthSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - info->depthPitch = ctx->shared.virtualWidth; - - info->backOffset = ((info->depthOffset - bufferSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - info->backPitch = ctx->shared.virtualWidth; - - - fprintf(stderr, - "Will use back buffer at offset 0x%x\n", - info->backOffset); - fprintf(stderr, - "Will use depth buffer at offset 0x%x\n", - info->depthOffset); - fprintf(stderr, - "Will use %d kb for textures at offset 0x%x\n", - info->textureSize/1024, info->textureOffset); - - info->frontPitchOffset = (((info->frontPitch * cpp / 64) << 22) | - (info->frontOffset >> 10)); - - info->backPitchOffset = (((info->backPitch * cpp / 64) << 22) | - (info->backOffset >> 10)); - - info->depthPitchOffset = (((info->depthPitch * cpp / 64) << 22) | - (info->depthOffset >> 10)); - - return 1; -} - -static int RADEONColorTilingInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) -{ - int width_bytes = ctx->shared.virtualWidth * ctx->cpp; - int bufferSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes + RADEON_BUFFER_ALIGN) - & ~RADEON_BUFFER_ALIGN); - /* Setup color tiling */ - if (info->drmMinor<14) - info->colorTiling=0; - - if (info->colorTiling) - { - - int colorTilingFlag; - drm_radeon_surface_alloc_t front,back; - - RadeonSetParam(ctx, RADEON_SETPARAM_SWITCH_TILING, info->colorTiling ? 1 : 0); - - /* Setup the surfaces */ - if (info->ChipFamily < CHIP_FAMILY_R200) - colorTilingFlag=RADEON_SURF_TILE_COLOR_MACRO; - else - colorTilingFlag=R200_SURF_TILE_COLOR_MACRO; - - front.address = info->frontOffset; - front.size = bufferSize; - front.flags = (width_bytes) | colorTilingFlag; - drmCommandWrite(ctx->drmFD, DRM_RADEON_SURF_ALLOC, &front,sizeof(front)); - - back.address = info->backOffset; - back.size = bufferSize; - back.flags = (width_bytes) | colorTilingFlag; - drmCommandWrite(ctx->drmFD, DRM_RADEON_SURF_ALLOC, &back,sizeof(back)); - - } - return 1; -} - - - -/** - * Called at the start of each server generation. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Performs static frame buffer allocation. Opens the DRM device and add maps - * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more - * information. Creates a \e server context to grab the lock for the - * initialization ioctls and calls the other initilization functions in this - * file. Starts the CP engine via the DRM_RADEON_CP_START command. - * - * Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its - * initialization. - */ -static int RADEONScreenInit( DRIDriverContext *ctx, RADEONInfoPtr info ) -{ - RADEONDRIPtr pRADEONDRI; - int err; - - usleep(100); - /*assert(!ctx->IsClient);*/ - - { - int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); - int maxy = ctx->shared.fbSize / width_bytes; - - - if (maxy <= ctx->shared.virtualHeight * 3) { - fprintf(stderr, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (ctx->shared.virtualWidth * ctx->shared.virtualHeight * - ctx->cpp * 3 + 1023) / 1024, - ctx->shared.fbSize / 1024); - return 0; - } - } - - - if (info->ChipFamily >= CHIP_FAMILY_R300) { - fprintf(stderr, - "Direct rendering not yet supported on " - "Radeon 9700 and newer cards\n"); - return 0; - } - - radeon_drm_page_size = getpagesize(); - - info->registerSize = ctx->MMIOSize; - ctx->shared.SAREASize = SAREA_MAX; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("radeon", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, -#ifndef _EMBEDDED - 0, -#else - DRM_READ_ONLY, -#endif - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - - - if (drmAddMap(ctx->drmFD, - ctx->MMIOStart, - ctx->MMIOSize, - DRM_REGISTERS, - DRM_READ_ONLY, - &info->registerHandle) < 0) { - fprintf(stderr, "[drm] drmAddMap mmio failed\n"); - return 0; - } - fprintf(stderr, - "[drm] register handle = 0x%08lx\n", info->registerHandle); - - /* Check the radeon DRM version */ - if (!RADEONCheckDRMVersion(ctx, info)) { - return 0; - } - - if (ctx->isPCI) { - /* Initialize PCI */ - if (!RADEONDRIPciInit(ctx, info)) - return 0; - } - else { - /* Initialize AGP */ - if (!RADEONDRIAgpInit(ctx, info)) - return 0; - } - - /* Memory manager setup */ - if (!RADEONMemoryInit(ctx, info)) { - return 0; - } - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the kernel data structures */ - if (!RADEONDRIKernelInit(ctx, info)) { - fprintf(stderr, "RADEONDRIKernelInit failed\n"); - DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); - return 0; - } - - /* Initialize the vertex buffers list */ - if (!RADEONDRIBufInit(ctx, info)) { - fprintf(stderr, "RADEONDRIBufInit failed\n"); - DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext); - return 0; - } - - RADEONColorTilingInit(ctx, info); - - /* Initialize IRQ */ - RADEONDRIIrqInit(ctx, info); - - /* Initialize kernel gart memory manager */ - RADEONDRIAgpHeapInit(ctx, info); - - fprintf(stderr,"color tiling %sabled\n", info->colorTiling?"en":"dis"); - fprintf(stderr,"page flipping %sabled\n", info->page_flip_enable?"en":"dis"); - /* Initialize the SAREA private data structure */ - { - drm_radeon_sarea_t *pSAREAPriv; - pSAREAPriv = (drm_radeon_sarea_t *)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - pSAREAPriv->pfState = info->page_flip_enable; - } - - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - drimemsetio((char *)ctx->FBAddress + info->frontOffset, - 0, - info->frontPitch * ctx->cpp * ctx->shared.virtualHeight ); - - drimemsetio((char *)ctx->FBAddress + info->backOffset, - 0, - info->backPitch * ctx->cpp * ctx->shared.virtualHeight ); - - /* This is the struct passed to radeon_dri.so for its initialization */ - ctx->driverClientMsg = malloc(sizeof(RADEONDRIRec)); - ctx->driverClientMsgSize = sizeof(RADEONDRIRec); - pRADEONDRI = (RADEONDRIPtr)ctx->driverClientMsg; - pRADEONDRI->deviceID = info->Chipset; - pRADEONDRI->width = ctx->shared.virtualWidth; - pRADEONDRI->height = ctx->shared.virtualHeight; - pRADEONDRI->depth = ctx->bpp; /* XXX: depth */ - pRADEONDRI->bpp = ctx->bpp; - pRADEONDRI->IsPCI = ctx->isPCI; - pRADEONDRI->AGPMode = ctx->agpmode; - pRADEONDRI->frontOffset = info->frontOffset; - pRADEONDRI->frontPitch = info->frontPitch; - pRADEONDRI->backOffset = info->backOffset; - pRADEONDRI->backPitch = info->backPitch; - pRADEONDRI->depthOffset = info->depthOffset; - pRADEONDRI->depthPitch = info->depthPitch; - pRADEONDRI->textureOffset = info->textureOffset; - pRADEONDRI->textureSize = info->textureSize; - pRADEONDRI->log2TexGran = info->log2TexGran; - pRADEONDRI->registerHandle = info->registerHandle; - pRADEONDRI->registerSize = info->registerSize; - pRADEONDRI->statusHandle = info->ringReadPtrHandle; - pRADEONDRI->statusSize = info->ringReadMapSize; - pRADEONDRI->gartTexHandle = info->gartTexHandle; - pRADEONDRI->gartTexMapSize = info->gartTexMapSize; - pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran; - pRADEONDRI->gartTexOffset = info->gartTexStart; - pRADEONDRI->sarea_priv_offset = sizeof(drm_sarea_t); - - /* Don't release the lock now - let the VT switch handler do it. */ - - return 1; -} - - -/** - * \brief Get Radeon chip family from chipset number. - * - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Called by radeonInitFBDev() to set RADEONInfoRec::ChipFamily - * according to the value of RADEONInfoRec::Chipset. Fails if the - * chipset is unrecognized or not appropriate for this driver (i.e., not - * an r100 style radeon) - */ -static int get_chipfamily_from_chipset( RADEONInfoPtr info ) -{ - switch (info->Chipset) { - case PCI_CHIP_RADEON_LY: - case PCI_CHIP_RADEON_LZ: - info->ChipFamily = CHIP_FAMILY_M6; - break; - - case PCI_CHIP_RADEON_QY: - case PCI_CHIP_RADEON_QZ: - info->ChipFamily = CHIP_FAMILY_VE; - break; - - case PCI_CHIP_R200_QL: - case PCI_CHIP_R200_QN: - case PCI_CHIP_R200_QO: - case PCI_CHIP_R200_Ql: - case PCI_CHIP_R200_BB: - info->ChipFamily = CHIP_FAMILY_R200; - break; - - case PCI_CHIP_RV200_QW: /* RV200 desktop */ - case PCI_CHIP_RV200_QX: - info->ChipFamily = CHIP_FAMILY_RV200; - break; - - case PCI_CHIP_RADEON_LW: - case PCI_CHIP_RADEON_LX: - info->ChipFamily = CHIP_FAMILY_M7; - break; - - case PCI_CHIP_RV250_Id: - case PCI_CHIP_RV250_Ie: - case PCI_CHIP_RV250_If: - case PCI_CHIP_RV250_Ig: - info->ChipFamily = CHIP_FAMILY_RV250; - break; - - case PCI_CHIP_RV250_Ld: - case PCI_CHIP_RV250_Le: - case PCI_CHIP_RV250_Lf: - case PCI_CHIP_RV250_Lg: - info->ChipFamily = CHIP_FAMILY_M9; - break; - - case PCI_CHIP_RV280_Y_: - case PCI_CHIP_RV280_Ya: - case PCI_CHIP_RV280_Yb: - case PCI_CHIP_RV280_Yc: - info->ChipFamily = CHIP_FAMILY_RV280; - break; - - case PCI_CHIP_R300_ND: - case PCI_CHIP_R300_NE: - case PCI_CHIP_R300_NF: - case PCI_CHIP_R300_NG: - info->ChipFamily = CHIP_FAMILY_R300; - break; - - default: - /* Original Radeon/7200 */ - info->ChipFamily = CHIP_FAMILY_RADEON; - } - - return 1; -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa radeonValidateMode(). - */ -static int radeonValidateMode( const DRIDriverContext *ctx ) -{ - unsigned char *RADEONMMIO = ctx->MMIOAddress; - RADEONInfoPtr info = ctx->driverPrivate; - - info->gen_int_cntl = INREG(RADEON_GEN_INT_CNTL); - info->crtc_offset_cntl = INREG(RADEON_CRTC_OFFSET_CNTL); - - if (info->colorTiling) - info->crtc_offset_cntl |= RADEON_CRTC_TILE_EN; - return 1; -} - - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa radeonValidateMode(). - */ -static int radeonPostValidateMode( const DRIDriverContext *ctx ) -{ - unsigned char *RADEONMMIO = ctx->MMIOAddress; - RADEONInfoPtr info = ctx->driverPrivate; - - RADEONColorTilingInit( ctx, info); - OUTREG(RADEON_GEN_INT_CNTL, info->gen_int_cntl); - if (info->colorTiling) - info->crtc_offset_cntl |= RADEON_CRTC_TILE_EN; - OUTREG(RADEON_CRTC_OFFSET_CNTL, info->crtc_offset_cntl); - - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p ctx - * and then calls RADEONScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int radeonInitFBDev( DRIDriverContext *ctx ) -{ - RADEONInfoPtr info = calloc(1, sizeof(*info)); - - { - int dummy = ctx->shared.virtualWidth; - - if (ctx->colorTiling==1) - { - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 255) & ~255; break; - case 2: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 63) & ~63; break; - } - } else { - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - } - - ctx->shared.virtualWidth = dummy; - ctx->shared.Width = dummy; - } - - fprintf(stderr,"shared virtual width is %d\n", ctx->shared.virtualWidth); - ctx->driverPrivate = (void *)info; - - info->gartFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE; - info->gartSize = RADEON_DEFAULT_AGP_SIZE; - info->gartTexSize = RADEON_DEFAULT_AGP_TEX_SIZE; - info->bufSize = RADEON_DEFAULT_BUFFER_SIZE; - info->ringSize = RADEON_DEFAULT_RING_SIZE; - info->page_flip_enable = RADEON_DEFAULT_PAGE_FLIP; - info->colorTiling = ctx->colorTiling; - - info->Chipset = ctx->chipset; - - if (!get_chipfamily_from_chipset( info )) { - fprintf(stderr, "Unknown or non-radeon chipset -- cannot continue\n"); - fprintf(stderr, "==> Verify PCI BusID is correct in miniglx.conf\n"); - return 0; - } - - info->frontPitch = ctx->shared.virtualWidth; - info->LinearAddr = ctx->FBStart & 0xfc000000; - - - if (!RADEONScreenInit( ctx, info )) - return 0; - - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void radeonHaltFBDev( DRIDriverContext *ctx ) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - - -extern void radeonNotifyFocus( int ); - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -const struct DRIDriverRec __driDriver = { - radeonValidateMode, - radeonPostValidateMode, - radeonInitFBDev, - radeonHaltFBDev, - RADEONEngineShutdown, - RADEONEngineRestore, -#ifndef _EMBEDDED - 0, -#else - radeonNotifyFocus, -#endif -}; diff --git a/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c b/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c deleted file mode 100644 index 63fe875f59..0000000000 --- a/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 5.1 - * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* Authors: - * Keith Whitwell - * Daniel Borca - */ - - -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" -#include "imports.h" - -#include "dri_util.h" - -#include "tdfx_context.h" -#include "tdfx_dri.h" -#include "xf86drm.h" - - -#define TILE_WIDTH 128 -#define TILE_HEIGHT 32 - -#define CMDFIFO_PAGES 64 - - -static int -calcBufferStride (int xres, int tiled, int cpp) -{ - int strideInTiles; - - if (tiled) { - /* Calculate tile width stuff */ - strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH; - - return strideInTiles*cpp*TILE_WIDTH; - } else { - return xres*cpp; - } -} /* calcBufferStride */ - - -static int -calcBufferHeightInTiles (int yres) -{ - int heightInTiles; /* Height of buffer in tiles */ - - /* Calculate tile height stuff */ - heightInTiles = yres >> 5; - - if (yres & (TILE_HEIGHT - 1)) - heightInTiles++; - - return heightInTiles; - -} /* calcBufferHeightInTiles */ - - -static int -calcBufferSize (int xres, int yres, int tiled, int cpp) -{ - int stride, height, bufSize; - - if (tiled) { - stride = calcBufferStride(xres, tiled, cpp); - height = TILE_HEIGHT * calcBufferHeightInTiles(yres); - } else { - stride = xres*cpp; - height = yres; - } - - bufSize = stride * height; - - return bufSize; -} /* calcBufferSize */ - - -static void allocateMemory (const DRIDriverContext *ctx, TDFXDRIPtr pTDFX) -{ - int memRemaining, fifoSize, screenSizeInTiles; - int fbSize; - char *str; - int pixmapCacheLinesMin; - int cursorOffset, cursorSize; - - pTDFX->stride = calcBufferStride(pTDFX->width, !0, pTDFX->cpp); - - /* enough to do DVD */ - pixmapCacheLinesMin = ((720*480*pTDFX->cpp) + - pTDFX->stride - 1)/pTDFX->stride; - - if (pTDFX->deviceID > PCI_CHIP_VOODOO3) { - if ((pixmapCacheLinesMin + pTDFX->height) > 4095) - pixmapCacheLinesMin = 4095 - pTDFX->height; - } else { - if ((pixmapCacheLinesMin + pTDFX->height) > 2047) - pixmapCacheLinesMin = 2047 - pTDFX->height; - } - - if (pTDFX->cpp!=3) { - screenSizeInTiles=calcBufferSize(pTDFX->width, pTDFX->height, - !0, pTDFX->cpp); - } - else { - /* cpp==3 needs to bump up to 4 */ - screenSizeInTiles=calcBufferSize(pTDFX->width, pTDFX->height, - !0, 4); - } - - /* - * Layout is: - * cursor, fifo, fb, tex, bb, db - */ - - fbSize = (pTDFX->height + pixmapCacheLinesMin) * pTDFX->stride; - - memRemaining=(pTDFX->mem - 1) &~ 0xFFF; - /* Note that a page is 4096 bytes, and a */ - /* tile is 32 x 128 = 4096 bytes. So, */ - /* page and tile boundaries are the same */ - /* Place the depth offset first, forcing */ - /* it to be on an *odd* page boundary. */ - pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF; - if ((pTDFX->depthOffset & (0x1 << 12)) == 0) { - pTDFX->depthOffset -= (0x1 << 12); - } - /* Now, place the back buffer, forcing it */ - /* to be on an *even* page boundary. */ - pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF; - if (pTDFX->backOffset & (0x1 << 12)) { - pTDFX->backOffset -= (0x1 << 12); - } - /* Give the cmd fifo at least */ - /* CMDFIFO_PAGES pages, but no more than */ - /* 64. NOTE: Don't go higher than 64, as */ - /* there is suspect code in Glide3 ! */ - fifoSize = ((64 <= CMDFIFO_PAGES) ? 64 : CMDFIFO_PAGES) << 12; - - /* We give 4096 bytes to the cursor */ - cursorSize = 0/*4096*/; - cursorOffset = 0; - - pTDFX->fifoOffset = cursorOffset + cursorSize; - pTDFX->fifoSize = fifoSize; - /* Now, place the front buffer, forcing */ - /* it to be on a page boundary too, just */ - /* for giggles. */ - pTDFX->fbOffset = pTDFX->fifoOffset + pTDFX->fifoSize; - pTDFX->textureOffset = pTDFX->fbOffset + fbSize; - if (pTDFX->depthOffset <= pTDFX->textureOffset || - pTDFX->backOffset <= pTDFX->textureOffset) { - /* - * pTDFX->textureSize < 0 means that the DRI is disabled. pTDFX->backOffset - * is used to calculate the maximum amount of memory available for - * 2D offscreen use. With DRI disabled, set this to the top of memory. - */ - - pTDFX->textureSize = -1; - pTDFX->backOffset = pTDFX->mem; - pTDFX->depthOffset = -1; - fprintf(stderr, - "Not enough video memory available for textures and depth buffer\n" - "\tand/or back buffer. Disabling DRI. To use DRI try lower\n" - "\tresolution modes and/or a smaller virtual screen size\n"); - } else { - pTDFX->textureSize = pTDFX->backOffset - pTDFX->textureOffset; - } -} - - -static int createScreen (DRIDriverContext *ctx, TDFXDRIPtr pTDFX) -{ - int err; - - { - int width_bytes = (ctx->shared.virtualWidth * ctx->cpp); - int maxy = ctx->shared.fbSize / width_bytes; - - - if (maxy <= ctx->shared.virtualHeight * 3) { - fprintf(stderr, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (ctx->shared.virtualWidth * ctx->shared.virtualHeight * - ctx->cpp * 3 + 1023) / 1024, - ctx->shared.fbSize / 1024); - return 0; - } - } - - ctx->shared.SAREASize = SAREA_MAX; - pTDFX->regsSize = ctx->MMIOSize; - - /* Note that drmOpen will try to load the kernel module, if needed. */ - ctx->drmFD = drmOpen("tdfx", NULL ); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - - if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - if (drmAddMap( ctx->drmFD, - 0, - ctx->shared.SAREASize, - DRM_SHM, - DRM_CONTAINS_LOCK, - &ctx->shared.hSAREA) < 0) - { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap( ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap( ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, -#ifndef _EMBEDDED - 0, -#else - DRM_READ_ONLY, -#endif - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - - if (drmAddMap(ctx->drmFD, - ctx->MMIOStart, - ctx->MMIOSize, - DRM_REGISTERS, - DRM_READ_ONLY, - &pTDFX->regs) < 0) { - fprintf(stderr, "[drm] drmAddMap mmio failed\n"); - return 0; - } - fprintf(stderr, - "[drm] register handle = 0x%08lx\n", pTDFX->regs); - - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return 0; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - /* Initialize the kernel data structures */ - - /* Initialize kernel gart memory manager */ - allocateMemory(ctx, pTDFX); - - /* Initialize the SAREA private data structure */ - - - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - - - /* This is the struct passed to tdfx_dri.so for its initialization */ - ctx->driverClientMsg = malloc(sizeof(TDFXDRIRec)); - ctx->driverClientMsgSize = sizeof(TDFXDRIRec); - memcpy(ctx->driverClientMsg, pTDFX, ctx->driverClientMsgSize); - pTDFX = (TDFXDRIPtr)ctx->driverClientMsg; - - /* Don't release the lock now - let the VT switch handler do it. */ - - return 1; -} - - -/** - * \brief Validate the fbdev mode. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Saves some registers and returns 1. - * - * \sa tdfxValidateMode(). - */ -static int tdfxValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Examine mode returned by fbdev. - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Restores registers that fbdev has clobbered and returns 1. - * - * \sa tdfxValidateMode(). - */ -static int tdfxPostValidateMode( const DRIDriverContext *ctx ) -{ - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param ctx display handle. - * - * \return one on success, or zero on failure. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int tdfxInitFBDev( DRIDriverContext *ctx ) -{ - TDFXDRIPtr pTDFX = calloc(1, sizeof(TDFXDRIRec)); - - { - int dummy = ctx->shared.virtualWidth; - - switch (ctx->bpp / 8) { - case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break; - case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break; - case 3: - case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break; - } - - ctx->shared.virtualWidth = dummy; - } - - ctx->driverPrivate = (void *)pTDFX; - - pTDFX->deviceID = ctx->chipset; - pTDFX->width = ctx->shared.virtualWidth; - pTDFX->height = ctx->shared.virtualHeight; - pTDFX->cpp = ctx->cpp; - pTDFX->mem = ctx->FBSize; /* ->shared.fbSize? mem probe? */ - pTDFX->sarea_priv_offset = sizeof(drm_sarea_t); - - if (!createScreen(ctx, pTDFX)) - return 0; - - return 1; -} - - -/** - * \brief The screen is being closed, so clean up any state and free any - * resources used by the DRI. - * - * \param ctx display handle. - * - * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver - * private data. - */ -static void tdfxHaltFBDev( DRIDriverContext *ctx ) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - - -/** - * \brief Shutdown the drawing engine. - * - * \param ctx display handle - * - * Turns off the 3D engine & restores the graphics card - * to a state that fbdev understands. - */ -static int tdfxEngineShutdown( const DRIDriverContext *ctx ) -{ - fprintf(stderr, "%s: not implemented\n", __FUNCTION__); - return 1; -} - - -/** - * \brief Restore the drawing engine. - * - * \param ctx display handle - * - * Resets the graphics card and sets initial values for several registers of - * the card's drawing engine. - * - * Turns on 3dfx - */ -static int tdfxEngineRestore( const DRIDriverContext *ctx ) -{ - fprintf(stderr, "%s: not implemented\n", __FUNCTION__); - return 1; -} - - -/** - * \brief Exported driver interface for Mini GLX. - * - * \sa DRIDriverRec. - */ -struct DRIDriverRec __driDriver = { - tdfxValidateMode, - tdfxPostValidateMode, - tdfxInitFBDev, - tdfxHaltFBDev, - tdfxEngineShutdown, - tdfxEngineRestore, - 0 -}; diff --git a/src/mesa/drivers/dri/unichrome/server/via_dri.c b/src/mesa/drivers/dri/unichrome/server/via_dri.c deleted file mode 100644 index 74034485e2..0000000000 --- a/src/mesa/drivers/dri/unichrome/server/via_dri.c +++ /dev/null @@ -1,1251 +0,0 @@ -/* - * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. - * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sub license, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#include "driver.h" -#include "drm.h" -#include "imports.h" - -#include "dri_util.h" - -#include "via_context.h" -#include "via_dri.h" -#include "via_driver.h" -#include "xf86drm.h" - -static void VIAEnableMMIO(DRIDriverContext * ctx); -static void VIADisableMMIO(DRIDriverContext * ctx); -static void VIADisableExtendedFIFO(DRIDriverContext *ctx); -static void VIAEnableExtendedFIFO(DRIDriverContext *ctx); -static void VIAInitialize2DEngine(DRIDriverContext *ctx); -static void VIAInitialize3DEngine(DRIDriverContext *ctx); - -static int VIADRIScreenInit(DRIDriverContext * ctx); -static void VIADRICloseScreen(DRIDriverContext * ctx); -static int VIADRIFinishScreenInit(DRIDriverContext * ctx); - -/* _SOLO : missing macros normally defined by X code */ -#define xf86DrvMsg(a, b, ...) fprintf(stderr, __VA_ARGS__) -#define MMIO_IN8(base, addr) ((*(((volatile uint8_t*)base)+(addr)))+0) -#define MMIO_OUT8(base, addr, val) ((*(((volatile uint8_t*)base)+(addr)))=((uint8_t)val)) -#define MMIO_OUT16(base, addr, val) ((*(volatile uint16_t*)(((uint8_t*)base)+(addr)))=((uint16_t)val)) - -#define VIDEO 0 -#define AGP 1 -#define AGP_PAGE_SIZE 4096 -#define AGP_PAGES 8192 -#define AGP_SIZE (AGP_PAGE_SIZE * AGP_PAGES) -#define AGP_CMDBUF_PAGES 512 -#define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES) - -static char VIAKernelDriverName[] = "via"; -static char VIAClientDriverName[] = "unichrome"; - -static int VIADRIAgpInit(const DRIDriverContext *ctx, VIAPtr pVia); -static int VIADRIPciInit(DRIDriverContext * ctx, VIAPtr pVia); -static int VIADRIFBInit(DRIDriverContext * ctx, VIAPtr pVia); -static int VIADRIKernelInit(DRIDriverContext * ctx, VIAPtr pVia); -static int VIADRIMapInit(DRIDriverContext * ctx, VIAPtr pVia); - -static void VIADRIIrqInit( DRIDriverContext *ctx ) -{ - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI = pVia->devPrivate; - - pVIADRI->irqEnabled = drmGetInterruptFromBusID(pVia->drmFD, - ctx->pciBus, - ctx->pciDevice, - ctx->pciFunc); - - if ((drmCtlInstHandler(pVia->drmFD, pVIADRI->irqEnabled))) { - xf86DrvMsg(pScreen->myNum, X_WARNING, - "[drm] Failure adding irq handler. " - "Falling back to irq-free operation.\n"); - pVIADRI->irqEnabled = 0; - } - - if (pVIADRI->irqEnabled) - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Irq handler installed, using IRQ %d.\n", - pVIADRI->irqEnabled); -} - -static void VIADRIIrqExit( DRIDriverContext *ctx ) { - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI = pVia->devPrivate; - - if (pVIADRI->irqEnabled) { - if (drmCtlUninstHandler(pVia->drmFD)) { - xf86DrvMsg(pScreen-myNum, X_INFO,"[drm] Irq handler uninstalled.\n"); - } else { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Could not uninstall irq handler.\n"); - } - } -} - -static void VIADRIRingBufferCleanup(DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI = pVia->devPrivate; - drm_via_dma_init_t ringBufInit; - - if (pVIADRI->ringBufActive) { - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Cleaning up DMA ring-buffer.\n"); - ringBufInit.func = VIA_CLEANUP_DMA; - if (drmCommandWrite(pVia->drmFD, DRM_VIA_DMA_INIT, &ringBufInit, - sizeof(ringBufInit))) { - xf86DrvMsg(pScreen->myNum, X_WARNING, - "[drm] Failed to clean up DMA ring-buffer: %d\n", errno); - } - pVIADRI->ringBufActive = 0; - } -} - -static int VIADRIRingBufferInit(DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI = pVia->devPrivate; - drm_via_dma_init_t ringBufInit; - drmVersionPtr drmVer; - - pVIADRI->ringBufActive = 0; - - if (NULL == (drmVer = drmGetVersion(pVia->drmFD))) { - return GL_FALSE; - } - - if (((drmVer->version_major <= 1) && (drmVer->version_minor <= 3))) { - return GL_FALSE; - } - - /* - * Info frome code-snippet on DRI-DEVEL list; Erdi Chen. - */ - - switch (pVia->ChipId) { - case PCI_CHIP_VT3259: - ringBufInit.reg_pause_addr = 0x40c; - break; - default: - ringBufInit.reg_pause_addr = 0x418; - break; - } - - ringBufInit.offset = pVia->agpSize; - ringBufInit.size = AGP_CMDBUF_SIZE; - ringBufInit.func = VIA_INIT_DMA; - if (drmCommandWrite(pVia->drmFD, DRM_VIA_DMA_INIT, &ringBufInit, - sizeof(ringBufInit))) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Failed to initialize DMA ring-buffer: %d\n", errno); - return GL_FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] Initialized AGP ring-buffer, size 0x%lx at AGP offset 0x%lx.\n", - ringBufInit.size, ringBufInit.offset); - - pVIADRI->ringBufActive = 1; - return GL_TRUE; -} - -static int VIADRIAgpInit(const DRIDriverContext *ctx, VIAPtr pVia) -{ - unsigned long agp_phys; - drmAddress agpaddr; - VIADRIPtr pVIADRI; - pVIADRI = pVia->devPrivate; - pVia->agpSize = 0; - - if (drmAgpAcquire(pVia->drmFD) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed %d\n", errno); - return GL_FALSE; - } - - if (drmAgpEnable(pVia->drmFD, drmAgpGetMode(pVia->drmFD)&~0x0) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); - return GL_FALSE; - } - - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] drmAgpEnabled succeeded\n"); - - if (drmAgpAlloc(pVia->drmFD, AGP_SIZE, 0, &agp_phys, &pVia->agpHandle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] drmAgpAlloc failed\n"); - drmAgpRelease(pVia->drmFD); - return GL_FALSE; - } - - if (drmAgpBind(pVia->drmFD, pVia->agpHandle, 0) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] drmAgpBind failed\n"); - drmAgpFree(pVia->drmFD, pVia->agpHandle); - drmAgpRelease(pVia->drmFD); - - return GL_FALSE; - } - - /* - * Place the ring-buffer last in the AGP region, and restrict the - * public map not to include the buffer for security reasons. - */ - - pVia->agpSize = AGP_SIZE - AGP_CMDBUF_SIZE; - pVia->agpAddr = drmAgpBase(pVia->drmFD); - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] agpAddr = 0x%08lx\n",pVia->agpAddr); - - pVIADRI->agp.size = pVia->agpSize; - if (drmAddMap(pVia->drmFD, (drm_handle_t)0, - pVIADRI->agp.size, DRM_AGP, 0, - &pVIADRI->agp.handle) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] Failed to map public agp area\n"); - pVIADRI->agp.size = 0; - return GL_FALSE; - } - /* Map AGP from kernel to Xserver - Not really needed */ - drmMap(pVia->drmFD, pVIADRI->agp.handle,pVIADRI->agp.size, &agpaddr); - - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] agpAddr = 0x%08lx\n", pVia->agpAddr); - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] agpSize = 0x%08lx\n", pVia->agpSize); - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] agp physical addr = 0x%08lx\n", agp_phys); - - { - drm_via_agp_t agp; - agp.offset = 0; - agp.size = AGP_SIZE-AGP_CMDBUF_SIZE; - if (drmCommandWrite(pVia->drmFD, DRM_VIA_AGP_INIT, &agp, - sizeof(drm_via_agp_t)) < 0) { - drmUnmap(&agpaddr,pVia->agpSize); - drmRmMap(pVia->drmFD,pVIADRI->agp.handle); - drmAgpUnbind(pVia->drmFD, pVia->agpHandle); - drmAgpFree(pVia->drmFD, pVia->agpHandle); - drmAgpRelease(pVia->drmFD); - return GL_FALSE; - } - } - - return GL_TRUE; -} - -static int VIADRIFBInit(DRIDriverContext * ctx, VIAPtr pVia) -{ - int FBSize = pVia->FBFreeEnd-pVia->FBFreeStart; - int FBOffset = pVia->FBFreeStart; - VIADRIPtr pVIADRI = pVia->devPrivate; - pVIADRI->fbOffset = FBOffset; - pVIADRI->fbSize = pVia->videoRambytes; - - { - drm_via_fb_t fb; - fb.offset = FBOffset; - fb.size = FBSize; - - if (drmCommandWrite(pVia->drmFD, DRM_VIA_FB_INIT, &fb, - sizeof(drm_via_fb_t)) < 0) { - xf86DrvMsg(pScreen->myNum, X_ERROR, - "[drm] failed to init frame buffer area\n"); - return GL_FALSE; - } else { - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] FBFreeStart= 0x%08x FBFreeEnd= 0x%08x " - "FBSize= 0x%08x\n", - pVia->FBFreeStart, pVia->FBFreeEnd, FBSize); - return GL_TRUE; - } - } -} - -static int VIADRIPciInit(DRIDriverContext * ctx, VIAPtr pVia) -{ - return GL_TRUE; -} - -static int VIADRIScreenInit(DRIDriverContext * ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI; - int err; - -#if 0 - ctx->shared.SAREASize = ((sizeof(drm_sarea_t) + 0xfff) & 0x1000); -#else - if (sizeof(drm_sarea_t)+sizeof(drm_via_sarea_t) > SAREA_MAX) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Data does not fit in SAREA\n"); - return GL_FALSE; - } - ctx->shared.SAREASize = SAREA_MAX; -#endif - - ctx->drmFD = drmOpen(VIAKernelDriverName, NULL); - if (ctx->drmFD < 0) { - fprintf(stderr, "[drm] drmOpen failed\n"); - return 0; - } - pVia->drmFD = ctx->drmFD; - - err = drmSetBusid(ctx->drmFD, ctx->pciBusID); - if (err < 0) { - fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n", - ctx->drmFD, ctx->pciBusID, strerror(-err)); - return 0; - } - - err = drmAddMap(ctx->drmFD, 0, ctx->shared.SAREASize, DRM_SHM, - DRM_CONTAINS_LOCK, &ctx->shared.hSAREA); - if (err < 0) { - fprintf(stderr, "[drm] drmAddMap failed\n"); - return 0; - } - fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n", - ctx->shared.SAREASize, ctx->shared.hSAREA); - - if (drmMap(ctx->drmFD, - ctx->shared.hSAREA, - ctx->shared.SAREASize, - (drmAddressPtr)(&ctx->pSAREA)) < 0) - { - fprintf(stderr, "[drm] drmMap failed\n"); - return 0; - } - memset(ctx->pSAREA, 0, ctx->shared.SAREASize); - fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n", - ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize); - - /* Need to AddMap the framebuffer and mmio regions here: - */ - if (drmAddMap(ctx->drmFD, - (drm_handle_t)ctx->FBStart, - ctx->FBSize, - DRM_FRAME_BUFFER, -#ifndef _EMBEDDED - 0, -#else - DRM_READ_ONLY, -#endif - &ctx->shared.hFrameBuffer) < 0) - { - fprintf(stderr, "[drm] drmAddMap framebuffer failed\n"); - return 0; - } - - fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n", - ctx->shared.hFrameBuffer); - - pVIADRI = (VIADRIPtr) CALLOC(sizeof(VIADRIRec)); - if (!pVIADRI) { - drmClose(ctx->drmFD); - return GL_FALSE; - } - pVia->devPrivate = pVIADRI; - ctx->driverClientMsg = pVIADRI; - ctx->driverClientMsgSize = sizeof(*pVIADRI); - - /* DRIScreenInit doesn't add all the common mappings. Add additional mappings here. */ - if (!VIADRIMapInit(ctx, pVia)) { - VIADRICloseScreen(ctx); - return GL_FALSE; - } - - pVIADRI->regs.size = VIA_MMIO_REGSIZE; - pVIADRI->regs.handle = pVia->registerHandle; - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] mmio Registers = 0x%08lx\n", - pVIADRI->regs.handle); - - if (drmMap(pVia->drmFD, - pVIADRI->regs.handle, - pVIADRI->regs.size, - (drmAddress *)&pVia->MapBase) != 0) - { - VIADRICloseScreen(ctx); - return GL_FALSE; - } - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] mmio mapped.\n" ); - - VIAEnableMMIO(ctx); - - /* Get video memory clock. */ - VGAOUT8(0x3D4, 0x3D); - pVia->MemClk = (VGAIN8(0x3D5) & 0xF0) >> 4; - xf86DrvMsg(0, X_INFO, "[dri] MemClk (0x%x)\n", pVia->MemClk); - - /* 3D rendering has noise if not enabled. */ - VIAEnableExtendedFIFO(ctx); - - VIAInitialize2DEngine(ctx); - - /* Must disable MMIO or 3D won't work. */ - VIADisableMMIO(ctx); - - VIAInitialize3DEngine(ctx); - - pVia->IsPCI = !VIADRIAgpInit(ctx, pVia); - - if (pVia->IsPCI) { - VIADRIPciInit(ctx, pVia); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] use pci.\n" ); - } - else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] use agp.\n" ); - - if (!(VIADRIFBInit(ctx, pVia))) { - VIADRICloseScreen(ctx); - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] frame buffer initialize fail .\n" ); - return GL_FALSE; - } - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] frame buffer initialized.\n" ); - - return VIADRIFinishScreenInit(ctx); -} - -static void -VIADRICloseScreen(DRIDriverContext * ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI=(VIADRIPtr)pVia->devPrivate; - - VIADRIRingBufferCleanup(ctx); - - if (pVia->MapBase) { - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Unmapping MMIO registers\n"); - drmUnmap(pVia->MapBase, pVIADRI->regs.size); - } - - if (pVia->agpSize) { - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Freeing agp memory\n"); - drmAgpFree(pVia->drmFD, pVia->agpHandle); - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Releasing agp module\n"); - drmAgpRelease(pVia->drmFD); - } - -#if 0 - if (pVia->DRIIrqEnable) -#endif - VIADRIIrqExit(ctx); -} - -static int -VIADRIFinishScreenInit(DRIDriverContext * ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - VIADRIPtr pVIADRI; - int err; - - err = drmCreateContext(ctx->drmFD, &ctx->serverContext); - if (err != 0) { - fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err); - return GL_FALSE; - } - - DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0); - - - if (!VIADRIKernelInit(ctx, pVia)) { - VIADRICloseScreen(ctx); - return GL_FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, "[dri] kernel data initialized.\n"); - - /* set SAREA value */ - { - drm_via_sarea_t *saPriv; - - saPriv=(drm_via_sarea_t*)(((char*)ctx->pSAREA) + - sizeof(drm_sarea_t)); - assert(saPriv); - memset(saPriv, 0, sizeof(*saPriv)); - saPriv->ctxOwner = -1; - } - pVIADRI=(VIADRIPtr)pVia->devPrivate; - pVIADRI->deviceID=pVia->Chipset; - pVIADRI->width=ctx->shared.virtualWidth; - pVIADRI->height=ctx->shared.virtualHeight; - pVIADRI->mem=ctx->shared.fbSize; - pVIADRI->bytesPerPixel= (ctx->bpp+7) / 8; - pVIADRI->sarea_priv_offset = sizeof(drm_sarea_t); - /* TODO */ - pVIADRI->scrnX=pVIADRI->width; - pVIADRI->scrnY=pVIADRI->height; - - /* Initialize IRQ */ -#if 0 - if (pVia->DRIIrqEnable) -#endif - VIADRIIrqInit(ctx); - - pVIADRI->ringBufActive = 0; - VIADRIRingBufferInit(ctx); - - return GL_TRUE; -} - -/* Initialize the kernel data structures. */ -static int VIADRIKernelInit(DRIDriverContext * ctx, VIAPtr pVia) -{ - drm_via_init_t drmInfo; - memset(&drmInfo, 0, sizeof(drm_via_init_t)); - drmInfo.sarea_priv_offset = sizeof(drm_sarea_t); - drmInfo.func = VIA_INIT_MAP; - drmInfo.fb_offset = pVia->FrameBufferBase; - drmInfo.mmio_offset = pVia->registerHandle; - if (pVia->IsPCI) - drmInfo.agpAddr = (uint32_t)NULL; - else - drmInfo.agpAddr = (uint32_t)pVia->agpAddr; - - if ((drmCommandWrite(pVia->drmFD, DRM_VIA_MAP_INIT,&drmInfo, - sizeof(drm_via_init_t))) < 0) - return GL_FALSE; - - return GL_TRUE; -} -/* Add a map for the MMIO registers */ -static int VIADRIMapInit(DRIDriverContext * ctx, VIAPtr pVia) -{ - int flags = 0; - - if (drmAddMap(pVia->drmFD, pVia->MmioBase, VIA_MMIO_REGSIZE, - DRM_REGISTERS, flags, &pVia->registerHandle) < 0) { - return GL_FALSE; - } - - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] register handle = 0x%08lx\n", pVia->registerHandle); - - return GL_TRUE; -} - -static int viaValidateMode(const DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - - return 1; -} - -static int viaPostValidateMode(const DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - - return 1; -} - -static void VIAEnableMMIO(DRIDriverContext * ctx) -{ - /*vgaHWPtr hwp = VGAHWPTR(ctx);*/ - VIAPtr pVia = VIAPTR(ctx); - unsigned char val; - -#if 0 - if (xf86IsPrimaryPci(pVia->PciInfo)) { - /* If we are primary card, we still use std vga port. If we use - * MMIO, system will hang in vgaHWSave when our card used in - * PLE and KLE (integrated Trident MVP4) - */ - vgaHWSetStdFuncs(hwp); - } - else { - vgaHWSetMmioFuncs(hwp, pVia->MapBase, 0x8000); - } -#endif - - val = VGAIN8(0x3c3); - VGAOUT8(0x3c3, val | 0x01); - val = VGAIN8(0x3cc); - VGAOUT8(0x3c2, val | 0x01); - - /* Unlock Extended IO Space */ - VGAOUT8(0x3c4, 0x10); - VGAOUT8(0x3c5, 0x01); - - /* Enable MMIO */ - if(!pVia->IsSecondary) { - VGAOUT8(0x3c4, 0x1a); - val = VGAIN8(0x3c5); -#ifdef DEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "primary val = %x\n", val); -#endif - VGAOUT8(0x3c5, val | 0x68); - } - else { - VGAOUT8(0x3c4, 0x1a); - val = VGAIN8(0x3c5); -#ifdef DEBUG - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "secondary val = %x\n", val); -#endif - VGAOUT8(0x3c5, val | 0x38); - } - - /* Unlock CRTC registers */ - VGAOUT8(0x3d4, 0x47); - VGAOUT8(0x3d5, 0x00); - - return; -} - -static void VIADisableMMIO(DRIDriverContext * ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - unsigned char val; - - VGAOUT8(0x3c4, 0x1a); - val = VGAIN8(0x3c5); - VGAOUT8(0x3c5, val & 0x97); - - return; -} - -static void VIADisableExtendedFIFO(DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - uint32_t dwGE230, dwGE298; - - /* Cause of exit XWindow will dump back register value, others chipset no - * need to set extended fifo value */ - if (pVia->Chipset == VIA_CLE266 && pVia->ChipRev < 15 && - (ctx->shared.virtualWidth > 1024 || pVia->HasSecondary)) { - /* Turn off Extend FIFO */ - /* 0x298[29] */ - dwGE298 = VIAGETREG(0x298); - VIASETREG(0x298, dwGE298 | 0x20000000); - /* 0x230[21] */ - dwGE230 = VIAGETREG(0x230); - VIASETREG(0x230, dwGE230 & ~0x00200000); - /* 0x298[29] */ - dwGE298 = VIAGETREG(0x298); - VIASETREG(0x298, dwGE298 & ~0x20000000); - } -} - -static void VIAEnableExtendedFIFO(DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - uint8_t bRegTemp; - uint32_t dwGE230, dwGE298; - - switch (pVia->Chipset) { - case VIA_CLE266: - if (pVia->ChipRev > 14) { /* For 3123Cx */ - if (pVia->HasSecondary) { /* SAMM or DuoView case */ - if (ctx->shared.virtualWidth >= 1024) - { - /* 3c5.16[0:5] */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x1C; - VGAOUT8(0x3C5, bRegTemp); - /* 3c5.17[0:6] */ - VGAOUT8(0x3C4, 0x17); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x7F; - bRegTemp |= 0x3F; - VGAOUT8(0x3C5, bRegTemp); - pVia->EnableExtendedFIFO = GL_TRUE; - } - } - else /* Single view or Simultaneoue case */ - { - if (ctx->shared.virtualWidth > 1024) - { - /* 3c5.16[0:5] */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x17; - VGAOUT8(0x3C5, bRegTemp); - /* 3c5.17[0:6] */ - VGAOUT8(0x3C4, 0x17); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x7F; - bRegTemp |= 0x2F; - VGAOUT8(0x3C5, bRegTemp); - pVia->EnableExtendedFIFO = GL_TRUE; - } - } - /* 3c5.18[0:5] */ - VGAOUT8(0x3C4, 0x18); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x17; - bRegTemp |= 0x40; /* force the preq always higher than treq */ - VGAOUT8(0x3C5, bRegTemp); - } - else { /* for 3123Ax */ - if (ctx->shared.virtualWidth > 1024 || pVia->HasSecondary) { - /* Turn on Extend FIFO */ - /* 0x298[29] */ - dwGE298 = VIAGETREG(0x298); - VIASETREG(0x298, dwGE298 | 0x20000000); - /* 0x230[21] */ - dwGE230 = VIAGETREG(0x230); - VIASETREG(0x230, dwGE230 | 0x00200000); - /* 0x298[29] */ - dwGE298 = VIAGETREG(0x298); - VIASETREG(0x298, dwGE298 & ~0x20000000); - - /* 3c5.16[0:5] */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x17; - /* bRegTemp |= 0x10; */ - VGAOUT8(0x3C5, bRegTemp); - /* 3c5.17[0:6] */ - VGAOUT8(0x3C4, 0x17); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x7F; - bRegTemp |= 0x2F; - /*bRegTemp |= 0x1F;*/ - VGAOUT8(0x3C5, bRegTemp); - /* 3c5.18[0:5] */ - VGAOUT8(0x3C4, 0x18); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x17; - bRegTemp |= 0x40; /* force the preq always higher than treq */ - VGAOUT8(0x3C5, bRegTemp); - pVia->EnableExtendedFIFO = GL_TRUE; - } - } - break; - case VIA_KM400: - if (pVia->HasSecondary) { /* SAMM or DuoView case */ - if ((ctx->shared.virtualWidth >= 1600) && - (pVia->MemClk <= VIA_MEM_DDR200)) { - /* enable CRT extendded FIFO */ - VGAOUT8(0x3C4, 0x17); - VGAOUT8(0x3C5, 0x1C); - /* revise second display queue depth and read threshold */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp = (bRegTemp) | (0x09); - VGAOUT8(0x3C5, bRegTemp); - } - else { - /* enable CRT extendded FIFO */ - VGAOUT8(0x3C4, 0x17); - VGAOUT8(0x3C5,0x3F); - /* revise second display queue depth and read threshold */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp = (bRegTemp) | (0x1C); - VGAOUT8(0x3C5, bRegTemp); - } - /* 3c5.18[0:5] */ - VGAOUT8(0x3C4, 0x18); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x17; - bRegTemp |= 0x40; /* force the preq always higher than treq */ - VGAOUT8(0x3C5, bRegTemp); - pVia->EnableExtendedFIFO = GL_TRUE; - } - else { - if ( (ctx->shared.virtualWidth > 1024) && (ctx->shared.virtualWidth <= 1280) ) - { - /* enable CRT extendded FIFO */ - VGAOUT8(0x3C4, 0x17); - VGAOUT8(0x3C5, 0x3F); - /* revise second display queue depth and read threshold */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp = (bRegTemp) | (0x17); - VGAOUT8(0x3C5, bRegTemp); - pVia->EnableExtendedFIFO = GL_TRUE; - } - else if ((ctx->shared.virtualWidth > 1280)) - { - /* enable CRT extendded FIFO */ - VGAOUT8(0x3C4, 0x17); - VGAOUT8(0x3C5, 0x3F); - /* revise second display queue depth and read threshold */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp = (bRegTemp) | (0x1C); - VGAOUT8(0x3C5, bRegTemp); - pVia->EnableExtendedFIFO = GL_TRUE; - } - else - { - /* enable CRT extendded FIFO */ - VGAOUT8(0x3C4, 0x17); - VGAOUT8(0x3C5, 0x3F); - /* revise second display queue depth and read threshold */ - VGAOUT8(0x3C4, 0x16); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp = (bRegTemp) | (0x10); - VGAOUT8(0x3C5, bRegTemp); - } - /* 3c5.18[0:5] */ - VGAOUT8(0x3C4, 0x18); - bRegTemp = VGAIN8(0x3C5); - bRegTemp &= ~0x3F; - bRegTemp |= 0x17; - bRegTemp |= 0x40; /* force the preq always higher than treq */ - VGAOUT8(0x3C5, bRegTemp); - } - break; - case VIA_K8M800: - /*=* R1 Display FIFO depth (384 /8 -1 -> 0xbf) SR17[7:0] (8bits) *=*/ - VGAOUT8(0x3c4, 0x17); - VGAOUT8(0x3c5, 0xbf); - - /*=* R2 Display fetch datum threshold value (328/4 -> 0x52) - SR16[5:0], SR16[7] (7bits) *=*/ - VGAOUT8(0x3c4, 0x16); - bRegTemp = VGAIN8(0x3c5) & ~0xBF; - bRegTemp |= (0x52 & 0x3F); - bRegTemp |= ((0x52 & 0x40) << 1); - VGAOUT8(0x3c5, bRegTemp); - - /*=* R3 Switch to the highest agent threshold value (74 -> 0x4a) - SR18[5:0], SR18[7] (7bits) *=*/ - VGAOUT8(0x3c4, 0x18); - bRegTemp = VGAIN8(0x3c5) & ~0xBF; - bRegTemp |= (0x4a & 0x3F); - bRegTemp |= ((0x4a & 0x40) << 1); - VGAOUT8(0x3c5, bRegTemp); -#if 0 - /*=* R4 Fetch Number for a scan line (unit: 8 bytes) - SR1C[7:0], SR1D[1:0] (10bits) *=*/ - wRegTemp = (pBIOSInfo->offsetWidthByQWord >> 1) + 4; - VGAOUT8(0x3c4, 0x1c); - VGAOUT8(0x3c5, (uint8_t)(wRegTemp & 0xFF)); - VGAOUT8(0x3c4, 0x1d); - bRegTemp = VGAIN8(0x3c5) & ~0x03; - VGAOUT8(0x3c5, bRegTemp | ((wRegTemp & 0x300) >> 8)); -#endif - if (ctx->shared.virtualWidth >= 1400 && ctx->bpp == 32) - { - /*=* Max. length for a request SR22[4:0] (64/4 -> 0x10) *=*/ - VGAOUT8(0x3c4, 0x22); - bRegTemp = VGAIN8(0x3c5) & ~0x1F; - VGAOUT8(0x3c5, bRegTemp | 0x10); - } - else - { - /*=* Max. length for a request SR22[4:0] - (128/4 -> over flow 0x0) *=*/ - VGAOUT8(0x3c4, 0x22); - bRegTemp = VGAIN8(0x3c5) & ~0x1F; - VGAOUT8(0x3c5, bRegTemp); - } - break; - case VIA_PM800: - /*=* R1 Display FIFO depth (96-1 -> 0x5f) SR17[7:0] (8bits) *=*/ - VGAOUT8(0x3c4, 0x17); - VGAOUT8(0x3c5, 0x5f); - - /*=* R2 Display fetch datum threshold value (32 -> 0x20) - SR16[5:0], SR16[7] (7bits) *=*/ - VGAOUT8(0x3c4, 0x16); - bRegTemp = VGAIN8(0x3c5) & ~0xBF; - bRegTemp |= (0x20 & 0x3F); - bRegTemp |= ((0x20 & 0x40) << 1); - VGAOUT8(0x3c5, bRegTemp); - - /*=* R3 Switch to the highest agent threshold value (16 -> 0x10) - SR18[5:0], SR18[7] (7bits) *=*/ - VGAOUT8(0x3c4, 0x18); - bRegTemp = VGAIN8(0x3c5) & ~0xBF; - bRegTemp |= (0x10 & 0x3F); - bRegTemp |= ((0x10 & 0x40) << 1); - VGAOUT8(0x3c5, bRegTemp); -#if 0 - /*=* R4 Fetch Number for a scan line (unit: 8 bytes) - SR1C[7:0], SR1D[1:0] (10bits) *=*/ - wRegTemp = (pBIOSInfo->offsetWidthByQWord >> 1) + 4; - VGAOUT8(0x3c4, 0x1c); - VGAOUT8(0x3c5, (uint8_t)(wRegTemp & 0xFF)); - VGAOUT8(0x3c4, 0x1d); - bRegTemp = VGAIN8(0x3c5) & ~0x03; - VGAOUT8(0x3c5, bRegTemp | ((wRegTemp & 0x300) >> 8)); -#endif - if (ctx->shared.virtualWidth >= 1400 && ctx->bpp == 32) - { - /*=* Max. length for a request SR22[4:0] (64/4 -> 0x10) *=*/ - VGAOUT8(0x3c4, 0x22); - bRegTemp = VGAIN8(0x3c5) & ~0x1F; - VGAOUT8(0x3c5, bRegTemp | 0x10); - } - else - { - /*=* Max. length for a request SR22[4:0] (0x1F) *=*/ - VGAOUT8(0x3c4, 0x22); - bRegTemp = VGAIN8(0x3c5) & ~0x1F; - VGAOUT8(0x3c5, bRegTemp | 0x1F); - } - break; - default: - break; - } -} - -static void VIAInitialize2DEngine(DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - uint32_t dwVQStartAddr, dwVQEndAddr; - uint32_t dwVQLen, dwVQStartL, dwVQEndL, dwVQStartEndH; - uint32_t dwGEMode; - - /* init 2D engine regs to reset 2D engine */ - VIASETREG(0x04, 0x0); - VIASETREG(0x08, 0x0); - VIASETREG(0x0c, 0x0); - VIASETREG(0x10, 0x0); - VIASETREG(0x14, 0x0); - VIASETREG(0x18, 0x0); - VIASETREG(0x1c, 0x0); - VIASETREG(0x20, 0x0); - VIASETREG(0x24, 0x0); - VIASETREG(0x28, 0x0); - VIASETREG(0x2c, 0x0); - VIASETREG(0x30, 0x0); - VIASETREG(0x34, 0x0); - VIASETREG(0x38, 0x0); - VIASETREG(0x3c, 0x0); - VIASETREG(0x40, 0x0); - - VIADisableMMIO(ctx); - - /* Init AGP and VQ regs */ - VIASETREG(0x43c, 0x00100000); - VIASETREG(0x440, 0x00000000); - VIASETREG(0x440, 0x00333004); - VIASETREG(0x440, 0x60000000); - VIASETREG(0x440, 0x61000000); - VIASETREG(0x440, 0x62000000); - VIASETREG(0x440, 0x63000000); - VIASETREG(0x440, 0x64000000); - VIASETREG(0x440, 0x7D000000); - - VIASETREG(0x43c, 0xfe020000); - VIASETREG(0x440, 0x00000000); - - if (pVia->VQStart != 0) { - /* Enable VQ */ - dwVQStartAddr = pVia->VQStart; - dwVQEndAddr = pVia->VQEnd; - dwVQStartL = 0x50000000 | (dwVQStartAddr & 0xFFFFFF); - dwVQEndL = 0x51000000 | (dwVQEndAddr & 0xFFFFFF); - dwVQStartEndH = 0x52000000 | ((dwVQStartAddr & 0xFF000000) >> 24) | - ((dwVQEndAddr & 0xFF000000) >> 16); - dwVQLen = 0x53000000 | (VIA_VQ_SIZE >> 3); - - VIASETREG(0x43c, 0x00fe0000); - VIASETREG(0x440, 0x080003fe); - VIASETREG(0x440, 0x0a00027c); - VIASETREG(0x440, 0x0b000260); - VIASETREG(0x440, 0x0c000274); - VIASETREG(0x440, 0x0d000264); - VIASETREG(0x440, 0x0e000000); - VIASETREG(0x440, 0x0f000020); - VIASETREG(0x440, 0x1000027e); - VIASETREG(0x440, 0x110002fe); - VIASETREG(0x440, 0x200f0060); - - VIASETREG(0x440, 0x00000006); - VIASETREG(0x440, 0x40008c0f); - VIASETREG(0x440, 0x44000000); - VIASETREG(0x440, 0x45080c04); - VIASETREG(0x440, 0x46800408); - - VIASETREG(0x440, dwVQStartEndH); - VIASETREG(0x440, dwVQStartL); - VIASETREG(0x440, dwVQEndL); - VIASETREG(0x440, dwVQLen); - } - else { - /* Diable VQ */ - VIASETREG(0x43c, 0x00fe0000); - VIASETREG(0x440, 0x00000004); - VIASETREG(0x440, 0x40008c0f); - VIASETREG(0x440, 0x44000000); - VIASETREG(0x440, 0x45080c04); - VIASETREG(0x440, 0x46800408); - } - - dwGEMode = 0; - - switch (ctx->bpp) { - case 16: - dwGEMode |= VIA_GEM_16bpp; - break; - case 32: - dwGEMode |= VIA_GEM_32bpp; - break; - default: - dwGEMode |= VIA_GEM_8bpp; - break; - } - -#if 0 - switch (ctx->shared.virtualWidth) { - case 800: - dwGEMode |= VIA_GEM_800; - break; - case 1024: - dwGEMode |= VIA_GEM_1024; - break; - case 1280: - dwGEMode |= VIA_GEM_1280; - break; - case 1600: - dwGEMode |= VIA_GEM_1600; - break; - case 2048: - dwGEMode |= VIA_GEM_2048; - break; - default: - dwGEMode |= VIA_GEM_640; - break; - } -#endif - - VIAEnableMMIO(ctx); - - /* Set BPP and Pitch */ - VIASETREG(VIA_REG_GEMODE, dwGEMode); - - /* Set Src and Dst base address and pitch, pitch is qword */ - VIASETREG(VIA_REG_SRCBASE, 0x0); - VIASETREG(VIA_REG_DSTBASE, 0x0); - VIASETREG(VIA_REG_PITCH, VIA_PITCH_ENABLE | - ((ctx->shared.virtualWidth * ctx->bpp >> 3) >> 3) | - (((ctx->shared.virtualWidth * ctx->bpp >> 3) >> 3) << 16)); -} - -static int b3DRegsInitialized = 0; - -static void VIAInitialize3DEngine(DRIDriverContext *ctx) -{ - VIAPtr pVia = VIAPTR(ctx); - int i; - - if (!b3DRegsInitialized) - { - - VIASETREG(0x43C, 0x00010000); - - for (i = 0; i <= 0x7D; i++) - { - VIASETREG(0x440, (uint32_t) i << 24); - } - - VIASETREG(0x43C, 0x00020000); - - for (i = 0; i <= 0x94; i++) - { - VIASETREG(0x440, (uint32_t) i << 24); - } - - VIASETREG(0x440, 0x82400000); - - VIASETREG(0x43C, 0x01020000); - - - for (i = 0; i <= 0x94; i++) - { - VIASETREG(0x440, (uint32_t) i << 24); - } - - VIASETREG(0x440, 0x82400000); - VIASETREG(0x43C, 0xfe020000); - - for (i = 0; i <= 0x03; i++) - { - VIASETREG(0x440, (uint32_t) i << 24); - } - - VIASETREG(0x43C, 0x00030000); - - for (i = 0; i <= 0xff; i++) - { - VIASETREG(0x440, 0); - } - VIASETREG(0x43C, 0x00100000); - VIASETREG(0x440, 0x00333004); - VIASETREG(0x440, 0x10000002); - VIASETREG(0x440, 0x60000000); - VIASETREG(0x440, 0x61000000); - VIASETREG(0x440, 0x62000000); - VIASETREG(0x440, 0x63000000); - VIASETREG(0x440, 0x64000000); - - VIASETREG(0x43C, 0x00fe0000); - - if (pVia->ChipRev >= 3 ) - VIASETREG(0x440,0x40008c0f); - else - VIASETREG(0x440,0x4000800f); - - VIASETREG(0x440,0x44000000); - VIASETREG(0x440,0x45080C04); - VIASETREG(0x440,0x46800408); - VIASETREG(0x440,0x50000000); - VIASETREG(0x440,0x51000000); - VIASETREG(0x440,0x52000000); - VIASETREG(0x440,0x53000000); - - b3DRegsInitialized = 1; - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "3D Engine has been initialized.\n"); - } - - VIASETREG(0x43C,0x00fe0000); - VIASETREG(0x440,0x08000001); - VIASETREG(0x440,0x0A000183); - VIASETREG(0x440,0x0B00019F); - VIASETREG(0x440,0x0C00018B); - VIASETREG(0x440,0x0D00019B); - VIASETREG(0x440,0x0E000000); - VIASETREG(0x440,0x0F000000); - VIASETREG(0x440,0x10000000); - VIASETREG(0x440,0x11000000); - VIASETREG(0x440,0x20000000); -} - -static int -WaitIdleCLE266(VIAPtr pVia) -{ - int loop = 0; - - /*mem_barrier();*/ - - while (!(VIAGETREG(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && (loop++ < MAXLOOP)) - ; - - while ((VIAGETREG(VIA_REG_STATUS) & - (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) && - (loop++ < MAXLOOP)) - ; - - return loop >= MAXLOOP; -} - -static int viaInitFBDev(DRIDriverContext *ctx) -{ - VIAPtr pVia = CALLOC(sizeof(*pVia)); - - ctx->driverPrivate = (void *)pVia; - - switch (ctx->chipset) { - case PCI_CHIP_CLE3122: - case PCI_CHIP_CLE3022: - pVia->Chipset = VIA_CLE266; - break; - case PCI_CHIP_VT7205: - case PCI_CHIP_VT3205: - pVia->Chipset = VIA_KM400; - break; - case PCI_CHIP_VT3204: - case PCI_CHIP_VT3344: - pVia->Chipset = VIA_K8M800; - break; - case PCI_CHIP_VT3259: - pVia->Chipset = VIA_PM800; - break; - default: - xf86DrvMsg(0, X_ERROR, "VIA: Unknown device ID (0x%x)\n", ctx->chipset); - } - - /* _SOLO TODO XXX need to read ChipRev too */ - pVia->ChipRev = 0; - - pVia->videoRambytes = ctx->shared.fbSize; - pVia->MmioBase = ctx->MMIOStart; - pVia->FrameBufferBase = ctx->FBStart & 0xfc000000; - - pVia->FBFreeStart = ctx->shared.virtualWidth * ctx->cpp * - ctx->shared.virtualHeight; - -#if 1 - /* Alloc a second framebuffer for the second head */ - pVia->FBFreeStart += ctx->shared.virtualWidth * ctx->cpp * - ctx->shared.virtualHeight; -#endif - - pVia->VQStart = pVia->FBFreeStart; - pVia->VQEnd = pVia->FBFreeStart + VIA_VQ_SIZE - 1; - - pVia->FBFreeStart += VIA_VQ_SIZE; - - pVia->FBFreeEnd = pVia->videoRambytes; - - if (!VIADRIScreenInit(ctx)) - return 0; - - return 1; -} - -static void viaHaltFBDev(DRIDriverContext *ctx) -{ - drmUnmap( ctx->pSAREA, ctx->shared.SAREASize ); - drmClose(ctx->drmFD); - - if (ctx->driverPrivate) { - free(ctx->driverPrivate); - ctx->driverPrivate = 0; - } -} - -static int viaEngineShutdown(const DRIDriverContext *ctx) -{ - return 1; -} - -static int viaEngineRestore(const DRIDriverContext *ctx) -{ - return 1; -} - -const struct DRIDriverRec __driDriver = -{ - viaValidateMode, - viaPostValidateMode, - viaInitFBDev, - viaHaltFBDev, - viaEngineShutdown, - viaEngineRestore, - 0, -}; - -- cgit v1.2.3 From 88a99bb305186fd0eaaae9bd0dbfa4c45f14cac7 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 16 Jan 2010 18:38:17 +0100 Subject: radeon: added tiling functions --- src/mesa/drivers/dri/r200/Makefile | 3 +- src/mesa/drivers/dri/r200/radeon_tile.c | 1 + src/mesa/drivers/dri/r200/radeon_tile.h | 1 + src/mesa/drivers/dri/r300/Makefile | 3 +- src/mesa/drivers/dri/r300/radeon_tile.c | 1 + src/mesa/drivers/dri/r300/radeon_tile.h | 1 + src/mesa/drivers/dri/r600/Makefile | 3 +- src/mesa/drivers/dri/r600/radeon_tile.c | 1 + src/mesa/drivers/dri/r600/radeon_tile.h | 1 + src/mesa/drivers/dri/radeon/Makefile | 3 +- src/mesa/drivers/dri/radeon/radeon_tile.c | 246 ++++++++++++++++++++++++++++++ src/mesa/drivers/dri/radeon/radeon_tile.h | 32 ++++ 12 files changed, 292 insertions(+), 4 deletions(-) create mode 120000 src/mesa/drivers/dri/r200/radeon_tile.c create mode 120000 src/mesa/drivers/dri/r200/radeon_tile.h create mode 120000 src/mesa/drivers/dri/r300/radeon_tile.c create mode 120000 src/mesa/drivers/dri/r300/radeon_tile.h create mode 120000 src/mesa/drivers/dri/r600/radeon_tile.c create mode 120000 src/mesa/drivers/dri/r600/radeon_tile.h create mode 100644 src/mesa/drivers/dri/radeon/radeon_tile.c create mode 100644 src/mesa/drivers/dri/radeon/radeon_tile.h (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index 2e86e8b941..d91e5482e9 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -24,7 +24,8 @@ RADEON_COMMON_SOURCES = \ radeon_queryobj.c \ radeon_span.c \ radeon_texture.c \ - radeon_tex_copy.c + radeon_tex_copy.c \ + radeon_tile.c DRIVER_SOURCES = r200_context.c \ r200_ioctl.c \ diff --git a/src/mesa/drivers/dri/r200/radeon_tile.c b/src/mesa/drivers/dri/r200/radeon_tile.c new file mode 120000 index 0000000000..d4bfe27da6 --- /dev/null +++ b/src/mesa/drivers/dri/r200/radeon_tile.c @@ -0,0 +1 @@ +../radeon/radeon_tile.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r200/radeon_tile.h b/src/mesa/drivers/dri/r200/radeon_tile.h new file mode 120000 index 0000000000..31074c581e --- /dev/null +++ b/src/mesa/drivers/dri/r200/radeon_tile.h @@ -0,0 +1 @@ +../radeon/radeon_tile.h \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 08934fc996..730d801bb0 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -34,7 +34,8 @@ RADEON_COMMON_SOURCES = \ radeon_span.c \ radeon_queryobj.c \ radeon_texture.c \ - radeon_tex_copy.c + radeon_tex_copy.c \ + radeon_tile.c DRIVER_SOURCES = \ radeon_screen.c \ diff --git a/src/mesa/drivers/dri/r300/radeon_tile.c b/src/mesa/drivers/dri/r300/radeon_tile.c new file mode 120000 index 0000000000..d4bfe27da6 --- /dev/null +++ b/src/mesa/drivers/dri/r300/radeon_tile.c @@ -0,0 +1 @@ +../radeon/radeon_tile.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/radeon_tile.h b/src/mesa/drivers/dri/r300/radeon_tile.h new file mode 120000 index 0000000000..31074c581e --- /dev/null +++ b/src/mesa/drivers/dri/r300/radeon_tile.h @@ -0,0 +1 @@ +../radeon/radeon_tile.h \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index 2478b12658..b6d1c5f459 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -34,7 +34,8 @@ RADEON_COMMON_SOURCES = \ radeon_span.c \ radeon_texture.c \ radeon_queryobj.c \ - radeon_tex_copy.c + radeon_tex_copy.c \ + radeon_tile.c DRIVER_SOURCES = \ radeon_screen.c \ diff --git a/src/mesa/drivers/dri/r600/radeon_tile.c b/src/mesa/drivers/dri/r600/radeon_tile.c new file mode 120000 index 0000000000..d4bfe27da6 --- /dev/null +++ b/src/mesa/drivers/dri/r600/radeon_tile.c @@ -0,0 +1 @@ +../radeon/radeon_tile.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/radeon_tile.h b/src/mesa/drivers/dri/r600/radeon_tile.h new file mode 120000 index 0000000000..31074c581e --- /dev/null +++ b/src/mesa/drivers/dri/r600/radeon_tile.h @@ -0,0 +1 @@ +../radeon/radeon_tile.h \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index fc6d1c8e89..f7e8059c4f 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -25,7 +25,8 @@ RADEON_COMMON_SOURCES = \ radeon_queryobj.c \ radeon_span.c \ radeon_texture.c \ - radeon_tex_copy.c + radeon_tex_copy.c \ + radeon_tile.c DRIVER_SOURCES = \ radeon_context.c \ diff --git a/src/mesa/drivers/dri/radeon/radeon_tile.c b/src/mesa/drivers/dri/radeon/radeon_tile.c new file mode 100644 index 0000000000..56f2fc46d9 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_tile.c @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2010 Maciej Cencora + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "radeon_tile.h" + +#include +#include + +#include
+ +#define MICRO_TILE_SIZE 32 + +static void micro_tile_8_x_4_8bit(const void * const src, unsigned src_pitch, + void * const dst, unsigned dst_pitch, + unsigned width, unsigned height) +{ + unsigned row; /* current source row */ + unsigned col; /* current source column */ + unsigned k; /* number of processed tiles */ + const unsigned tile_width = 8, tile_height = 4; + const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width; + + k = 0; + for (row = 0; row < height; row += tile_height) + { + for (col = 0; col < width; col += tile_width, ++k) + { + uint8_t *src2 = (uint8_t *)src + src_pitch * row + col; + uint8_t *dst2 = (uint8_t *)dst + row * dst_pitch + + (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint8_t); + unsigned j; + + for (j = 0; j < MIN2(tile_height, height - row); ++j) + { + unsigned columns = MIN2(tile_width, width - col); + memcpy(dst2, src2, columns * sizeof(uint8_t)); + dst2 += tile_width; + src2 += src_pitch; + } + } + } +} + +static void micro_tile_4_x_4_16bit(const void * const src, unsigned src_pitch, + void * const dst, unsigned dst_pitch, + unsigned width, unsigned height) +{ + unsigned row; /* current source row */ + unsigned col; /* current source column */ + unsigned k; /* number of processed tiles */ + const unsigned tile_width = 4, tile_height = 4; + const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width; + + k = 0; + for (row = 0; row < height; row += tile_height) + { + for (col = 0; col < width; col += tile_width, ++k) + { + uint16_t *src2 = (uint16_t *)src + src_pitch * row + col; + uint16_t *dst2 = (uint16_t *)dst + row * dst_pitch + + (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t); + unsigned j; + + for (j = 0; j < MIN2(tile_height, height - row); ++j) + { + unsigned columns = MIN2(tile_width, width - col); + memcpy(dst2, src2, columns * sizeof(uint16_t)); + dst2 += tile_width; + src2 += src_pitch; + } + } + } +} + +static void micro_tile_8_x_2_16bit(const void * const src, unsigned src_pitch, + void * const dst, unsigned dst_pitch, + unsigned width, unsigned height) +{ + unsigned row; /* current source row */ + unsigned col; /* current source column */ + unsigned k; /* number of processed tiles */ + const unsigned tile_width = 8, tile_height = 2; + const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width; + + k = 0; + for (row = 0; row < height; row += tile_height) + { + for (col = 0; col < width; col += tile_width, ++k) + { + uint16_t *src2 = (uint16_t *)src + src_pitch * row + col; + uint16_t *dst2 = (uint16_t *)dst + row * dst_pitch + + (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint16_t); + unsigned j; + + for (j = 0; j < MIN2(tile_height, height - row); ++j) + { + unsigned columns = MIN2(tile_width, width - col); + memcpy(dst2, src2, columns * sizeof(uint16_t)); + dst2 += tile_width; + src2 += src_pitch; + } + } + } +} + +static void micro_tile_4_x_2_32bit(const void * const src, unsigned src_pitch, + void * const dst, unsigned dst_pitch, + unsigned width, unsigned height) +{ + unsigned row; /* current source row */ + unsigned col; /* current source column */ + unsigned k; /* number of processed tiles */ + const unsigned tile_width = 4, tile_height = 2; + const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width; + + k = 0; + for (row = 0; row < height; row += tile_height) + { + for (col = 0; col < width; col += tile_width, ++k) + { + uint32_t *src2 = (uint32_t *)src + src_pitch * row + col; + uint32_t *dst2 = (uint32_t *)dst + row * dst_pitch + + (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint32_t); + unsigned j; + + for (j = 0; j < MIN2(tile_height, height - row); ++j) + { + unsigned columns = MIN2(tile_width, width - col); + memcpy(dst2, src2, columns * sizeof(uint32_t)); + dst2 += tile_width; + src2 += src_pitch; + } + } + } +} + +static void micro_tile_2_x_2_64bit(const void * const src, unsigned src_pitch, + void * const dst, unsigned dst_pitch, + unsigned width, unsigned height) +{ + unsigned row; /* current source row */ + unsigned col; /* current source column */ + unsigned k; /* number of processed tiles */ + const unsigned tile_width = 2, tile_height = 2; + const unsigned tiles_in_row = (width + (tile_width - 1)) / tile_width; + + k = 0; + for (row = 0; row < height; row += tile_height) + { + for (col = 0; col < width; col += tile_width, ++k) + { + uint64_t *src2 = (uint64_t *)src + src_pitch * row + col; + uint64_t *dst2 = (uint64_t *)dst + row * dst_pitch + + (k % tiles_in_row) * MICRO_TILE_SIZE / sizeof(uint64_t); + unsigned j; + + for (j = 0; j < MIN2(tile_height, height - row); ++j) + { + unsigned columns = MIN2(tile_width, width - col); + memcpy(dst2, src2, columns * sizeof(uint64_t)); + dst2 += tile_width; + src2 += src_pitch; + } + } + } +} + +static void micro_tile_1_x_1_128bit(const void * src, unsigned src_pitch, + void * dst, unsigned dst_pitch, + unsigned width, unsigned height) +{ + unsigned i, j; + const unsigned elem_size = 16; /* sizeof(uint128_t) */ + + for (j = 0; j < height; ++j) + { + for (i = 0; i < width; ++i) + { + memcpy(dst, src, width * elem_size); + dst += dst_pitch * elem_size; + src += src_pitch * elem_size; + } + } +} + +void tile_image(const void * src, unsigned src_pitch, + void *dst, unsigned dst_pitch, + gl_format format, unsigned width, unsigned height) +{ + assert(src_pitch >= width); + assert(dst_pitch >= width); + assert(dst_pitch * _mesa_get_format_bytes(format) % MICRO_TILE_SIZE == 0); + + switch (_mesa_get_format_bytes(format)) + { + case 16: + micro_tile_1_x_1_128bit(src, src_pitch, dst, dst_pitch, width, height); + break; + case 8: + micro_tile_2_x_2_64bit(src, src_pitch, dst, dst_pitch, width, height); + break; + case 4: + micro_tile_4_x_2_32bit(src, src_pitch, dst, dst_pitch, width, height); + break; + case 2: + if (_mesa_get_format_bits(format, GL_DEPTH_BITS)) + { + micro_tile_4_x_4_16bit(src, src_pitch, dst, dst_pitch, width, height); + } + else + { + micro_tile_8_x_2_16bit(src, src_pitch, dst, dst_pitch, width, height); + } + break; + case 1: + micro_tile_8_x_4_8bit(src, src_pitch, dst, dst_pitch, width, height); + break; + default: + assert(0); + break; + } +} \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/radeon_tile.h b/src/mesa/drivers/dri/radeon/radeon_tile.h new file mode 100644 index 0000000000..4985e55204 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_tile.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2010 Maciej Cencora + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include
+ +void tile_image(const void * src, unsigned src_pitch, + void *dst, unsigned dst_pitch, + gl_format format, unsigned width, unsigned height); -- cgit v1.2.3 From ccbe3f0314c8278c55e1046a619969ae539564de Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 17 Jan 2010 12:47:46 +0100 Subject: radeon: move glGetTexImage handlers to seperate file --- src/mesa/drivers/dri/r200/Makefile | 1 + src/mesa/drivers/dri/r200/radeon_tex_getimage.c | 1 + src/mesa/drivers/dri/r300/Makefile | 1 + src/mesa/drivers/dri/r300/radeon_tex_getimage.c | 1 + src/mesa/drivers/dri/r600/Makefile | 1 + src/mesa/drivers/dri/r600/radeon_tex_getimage.c | 1 + src/mesa/drivers/dri/radeon/Makefile | 1 + src/mesa/drivers/dri/radeon/radeon_tex_getimage.c | 95 +++++++++++++++++++++++ src/mesa/drivers/dri/radeon/radeon_texture.c | 60 -------------- 9 files changed, 102 insertions(+), 60 deletions(-) create mode 120000 src/mesa/drivers/dri/r200/radeon_tex_getimage.c create mode 120000 src/mesa/drivers/dri/r300/radeon_tex_getimage.c create mode 120000 src/mesa/drivers/dri/r600/radeon_tex_getimage.c create mode 100644 src/mesa/drivers/dri/radeon/radeon_tex_getimage.c (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index d91e5482e9..3f87100570 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -25,6 +25,7 @@ RADEON_COMMON_SOURCES = \ radeon_span.c \ radeon_texture.c \ radeon_tex_copy.c \ + radeon_tex_getimage.c \ radeon_tile.c DRIVER_SOURCES = r200_context.c \ diff --git a/src/mesa/drivers/dri/r200/radeon_tex_getimage.c b/src/mesa/drivers/dri/r200/radeon_tex_getimage.c new file mode 120000 index 0000000000..d9836d7326 --- /dev/null +++ b/src/mesa/drivers/dri/r200/radeon_tex_getimage.c @@ -0,0 +1 @@ +../radeon/radeon_tex_getimage.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 730d801bb0..4257a32b89 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -35,6 +35,7 @@ RADEON_COMMON_SOURCES = \ radeon_queryobj.c \ radeon_texture.c \ radeon_tex_copy.c \ + radeon_tex_getimage.c \ radeon_tile.c DRIVER_SOURCES = \ diff --git a/src/mesa/drivers/dri/r300/radeon_tex_getimage.c b/src/mesa/drivers/dri/r300/radeon_tex_getimage.c new file mode 120000 index 0000000000..d9836d7326 --- /dev/null +++ b/src/mesa/drivers/dri/r300/radeon_tex_getimage.c @@ -0,0 +1 @@ +../radeon/radeon_tex_getimage.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index b6d1c5f459..f76859d11e 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -35,6 +35,7 @@ RADEON_COMMON_SOURCES = \ radeon_texture.c \ radeon_queryobj.c \ radeon_tex_copy.c \ + radeon_tex_getimage.c \ radeon_tile.c DRIVER_SOURCES = \ diff --git a/src/mesa/drivers/dri/r600/radeon_tex_getimage.c b/src/mesa/drivers/dri/r600/radeon_tex_getimage.c new file mode 120000 index 0000000000..d9836d7326 --- /dev/null +++ b/src/mesa/drivers/dri/r600/radeon_tex_getimage.c @@ -0,0 +1 @@ +../radeon/radeon_tex_getimage.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index f7e8059c4f..6904ebbee3 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -26,6 +26,7 @@ RADEON_COMMON_SOURCES = \ radeon_span.c \ radeon_texture.c \ radeon_tex_copy.c \ + radeon_tex_getimage.c \ radeon_tile.c DRIVER_SOURCES = \ diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_getimage.c b/src/mesa/drivers/dri/radeon/radeon_tex_getimage.c new file mode 100644 index 0000000000..7bf6dcc2e3 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_tex_getimage.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2009 Maciej Cencora. + * Copyright (C) 2008 Nicolai Haehnle. + * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. + * + * The Weather Channel (TM) funded Tungsten Graphics to develop the + * initial release of the Radeon 8500 driver under the XFree86 license. + * This notice must be preserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "radeon_common_context.h" +#include "radeon_texture.h" +#include "radeon_mipmap_tree.h" + +#include "main/texgetimage.h" + +/** + * Need to map texture image into memory before copying image data, + * then unmap it. + */ +static void +radeon_get_tex_image(GLcontext * ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid * pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, int compressed) +{ + radeon_texture_image *image = get_radeon_texture_image(texImage); + + radeon_print(RADEON_TEXTURE, RADEON_NORMAL, + "%s(%p, tex %p, image %p) compressed %d.\n", + __func__, ctx, texObj, image, compressed); + + if (image->mt) { + /* Map the texture image read-only */ + radeon_teximage_map(image, GL_FALSE); + } else { + /* Image hasn't been uploaded to a miptree yet */ + assert(image->base.Data); + } + + if (compressed) { + /* FIXME: this can't work for small textures (mips) which + use different hw stride */ + _mesa_get_compressed_teximage(ctx, target, level, pixels, + texObj, texImage); + } else { + _mesa_get_teximage(ctx, target, level, format, type, pixels, + texObj, texImage); + } + + if (image->mt) { + radeon_teximage_unmap(image); + } +} + +void +radeonGetTexImage(GLcontext * ctx, GLenum target, GLint level, + GLenum format, GLenum type, GLvoid * pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + radeon_get_tex_image(ctx, target, level, format, type, pixels, + texObj, texImage, 0); +} + +void +radeonGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level, + GLvoid *pixels, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + radeon_get_tex_image(ctx, target, level, 0, 0, pixels, + texObj, texImage, 1); +} diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 62dec2d4e0..6a8e70d47e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -39,7 +39,6 @@ #include "main/texstore.h" #include "main/teximage.h" #include "main/texobj.h" -#include "main/texgetimage.h" #include "xmlpool.h" /* for symbolic values of enum-type options */ @@ -998,62 +997,3 @@ void radeonTexSubImage3D(GLcontext * ctx, GLenum target, GLint level, radeon_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, width, height, depth, 0, format, type, pixels, packing, texObj, texImage, 0); } - -/** - * Need to map texture image into memory before copying image data, - * then unmap it. - */ -static void -radeon_get_tex_image(GLcontext * ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid * pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage, int compressed) -{ - radeon_texture_image *image = get_radeon_texture_image(texImage); - - radeon_print(RADEON_TEXTURE, RADEON_NORMAL, - "%s(%p, tex %p, image %p) compressed %d.\n", - __func__, ctx, texObj, image, compressed); - - if (image->mt) { - /* Map the texture image read-only */ - radeon_teximage_map(image, GL_FALSE); - } else { - /* Image hasn't been uploaded to a miptree yet */ - assert(image->base.Data); - } - - if (compressed) { - /* FIXME: this can't work for small textures (mips) which - use different hw stride */ - _mesa_get_compressed_teximage(ctx, target, level, pixels, - texObj, texImage); - } else { - _mesa_get_teximage(ctx, target, level, format, type, pixels, - texObj, texImage); - } - - if (image->mt) { - radeon_teximage_unmap(image); - } -} - -void -radeonGetTexImage(GLcontext * ctx, GLenum target, GLint level, - GLenum format, GLenum type, GLvoid * pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - radeon_get_tex_image(ctx, target, level, format, type, pixels, - texObj, texImage, 0); -} - -void -radeonGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level, - GLvoid *pixels, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage) -{ - radeon_get_tex_image(ctx, target, level, 0, 0, pixels, - texObj, texImage, 1); -} -- cgit v1.2.3 From 97d40edb07aa6c67d21eb831898ac5387c18fdbc Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 09:57:26 -0500 Subject: r600: no need to flush on context init --- src/mesa/drivers/dri/r600/r700_state.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 4ebdbbfad2..3e10e5b37a 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -1626,8 +1626,6 @@ void r700InitState(GLcontext * ctx) //------------------- R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw); int id = 0; - radeon_firevertices(&context->radeon); - r700->TA_CNTL_AUX.u32All = 0; SETfield(r700->TA_CNTL_AUX.u32All, 28, TD_FIFO_CREDIT_shift, TD_FIFO_CREDIT_mask); r700->VC_ENHANCE.u32All = 0; -- cgit v1.2.3 From cbe28cb892e3b451d2d2cf6769ef7ef131f1853b Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 10:00:59 -0500 Subject: r600: recalculate point size, if point min/max size changes --- src/mesa/drivers/dri/r600/r700_state.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 3e10e5b37a..6f156b5409 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -911,10 +911,12 @@ static void r700PointParameter(GLcontext * ctx, GLenum pname, const GLfloat * pa case GL_POINT_SIZE_MIN: SETfield(r700->PA_SU_POINT_MINMAX.u32All, (int)(ctx->Point.MinSize * 8.0), MIN_SIZE_shift, MIN_SIZE_mask); + r700PointSize(ctx, ctx->Point.Size); break; case GL_POINT_SIZE_MAX: SETfield(r700->PA_SU_POINT_MINMAX.u32All, (int)(ctx->Point.MaxSize * 8.0), MAX_SIZE_shift, MAX_SIZE_mask); + r700PointSize(ctx, ctx->Point.Size); break; case GL_POINT_DISTANCE_ATTENUATION: break; -- cgit v1.2.3 From 7959274858fe66a90e6f97fed81141c39cb6702b Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 10:04:02 -0500 Subject: radeon/r200/r600: reset bos when validating buffers during blit --- src/mesa/drivers/dri/r200/r200_blit.c | 3 +++ src/mesa/drivers/dri/r600/r600_blit.c | 2 ++ src/mesa/drivers/dri/radeon/radeon_blit.c | 3 +++ 3 files changed, 8 insertions(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index b56327dad5..2c8b3aafe5 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -211,6 +211,9 @@ static GLboolean validate_buffers(struct r200_context *r200, struct radeon_bo *dst_bo) { int ret; + + radeon_cs_space_reset_bos(r200->radeon.cmdbuf.cs); + ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, src_bo, RADEON_GEM_DOMAIN_VRAM, 0); if (ret) diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 9d17463cae..fb84825761 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1533,6 +1533,8 @@ static GLboolean validate_buffers(context_t *rmesa, { int ret; + radeon_cs_space_reset_bos(rmesa->radeon.cmdbuf.cs); + ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, src_bo, RADEON_GEM_DOMAIN_VRAM, 0); if (ret) diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index e188a122d5..8c3c2e4766 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -204,6 +204,9 @@ static GLboolean validate_buffers(struct r100_context *r100, struct radeon_bo *dst_bo) { int ret; + + radeon_cs_space_reset_bos(r100->radeon.cmdbuf.cs); + ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, src_bo, RADEON_GEM_DOMAIN_VRAM, 0); if (ret) -- cgit v1.2.3 From 39ab5ae30c303dd561252cb592d4de35814b6a70 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 10:13:49 -0500 Subject: radeon/r200/r600: allow src and dst BOs to be placed in GTT during blit --- src/mesa/drivers/dri/r200/r200_blit.c | 10 ++-------- src/mesa/drivers/dri/r600/r600_blit.c | 10 ++-------- src/mesa/drivers/dri/radeon/radeon_blit.c | 10 ++-------- 3 files changed, 6 insertions(+), 24 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 2c8b3aafe5..3075760093 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -215,18 +215,12 @@ static GLboolean validate_buffers(struct r200_context *r200, radeon_cs_space_reset_bos(r200->radeon.cmdbuf.cs); ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + src_bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); if (ret) return GL_FALSE; ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); - if (ret) - return GL_FALSE; - - ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, - first_elem(&r200->radeon.dma.reserved)->bo, - RADEON_GEM_DOMAIN_GTT, 0); + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT); if (ret) return GL_FALSE; diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index fb84825761..244fdc4ffb 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1536,12 +1536,12 @@ static GLboolean validate_buffers(context_t *rmesa, radeon_cs_space_reset_bos(rmesa->radeon.cmdbuf.cs); ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + src_bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); if (ret) return GL_FALSE; ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT); if (ret) return GL_FALSE; @@ -1551,12 +1551,6 @@ static GLboolean validate_buffers(context_t *rmesa, if (ret) return GL_FALSE; - ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, - first_elem(&rmesa->radeon.dma.reserved)->bo, - RADEON_GEM_DOMAIN_GTT, 0); - if (ret) - return GL_FALSE; - return GL_TRUE; } diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index 8c3c2e4766..e1e1f21550 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -208,18 +208,12 @@ static GLboolean validate_buffers(struct r100_context *r100, radeon_cs_space_reset_bos(r100->radeon.cmdbuf.cs); ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + src_bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); if (ret) return GL_FALSE; ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); - if (ret) - return GL_FALSE; - - ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, - first_elem(&r100->radeon.dma.reserved)->bo, - RADEON_GEM_DOMAIN_GTT, 0); + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT); if (ret) return GL_FALSE; -- cgit v1.2.3 From d18b3023653e709051a56f5806988f24724972e7 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 09:57:26 -0500 Subject: r600: no need to flush on context init --- src/mesa/drivers/dri/r600/r700_state.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 4ebdbbfad2..3e10e5b37a 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -1626,8 +1626,6 @@ void r700InitState(GLcontext * ctx) //------------------- R700_CHIP_CONTEXT *r700 = (R700_CHIP_CONTEXT*)(&context->hw); int id = 0; - radeon_firevertices(&context->radeon); - r700->TA_CNTL_AUX.u32All = 0; SETfield(r700->TA_CNTL_AUX.u32All, 28, TD_FIFO_CREDIT_shift, TD_FIFO_CREDIT_mask); r700->VC_ENHANCE.u32All = 0; -- cgit v1.2.3 From c65235f97efe30eb9444f7c8f20cb8f0cc529d19 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 10:00:59 -0500 Subject: r600: recalculate point size, if point min/max size changes --- src/mesa/drivers/dri/r600/r700_state.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 3e10e5b37a..6f156b5409 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -911,10 +911,12 @@ static void r700PointParameter(GLcontext * ctx, GLenum pname, const GLfloat * pa case GL_POINT_SIZE_MIN: SETfield(r700->PA_SU_POINT_MINMAX.u32All, (int)(ctx->Point.MinSize * 8.0), MIN_SIZE_shift, MIN_SIZE_mask); + r700PointSize(ctx, ctx->Point.Size); break; case GL_POINT_SIZE_MAX: SETfield(r700->PA_SU_POINT_MINMAX.u32All, (int)(ctx->Point.MaxSize * 8.0), MAX_SIZE_shift, MAX_SIZE_mask); + r700PointSize(ctx, ctx->Point.Size); break; case GL_POINT_DISTANCE_ATTENUATION: break; -- cgit v1.2.3 From d7ad1b8b0788536f6fcd261fbe0db7a10b84ac0a Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 10:04:02 -0500 Subject: radeon/r200/r600: reset bos when validating buffers during blit --- src/mesa/drivers/dri/r200/r200_blit.c | 3 +++ src/mesa/drivers/dri/r600/r600_blit.c | 2 ++ src/mesa/drivers/dri/radeon/radeon_blit.c | 3 +++ 3 files changed, 8 insertions(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index b56327dad5..2c8b3aafe5 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -211,6 +211,9 @@ static GLboolean validate_buffers(struct r200_context *r200, struct radeon_bo *dst_bo) { int ret; + + radeon_cs_space_reset_bos(r200->radeon.cmdbuf.cs); + ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, src_bo, RADEON_GEM_DOMAIN_VRAM, 0); if (ret) diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 9d17463cae..fb84825761 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1533,6 +1533,8 @@ static GLboolean validate_buffers(context_t *rmesa, { int ret; + radeon_cs_space_reset_bos(rmesa->radeon.cmdbuf.cs); + ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, src_bo, RADEON_GEM_DOMAIN_VRAM, 0); if (ret) diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index e188a122d5..8c3c2e4766 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -204,6 +204,9 @@ static GLboolean validate_buffers(struct r100_context *r100, struct radeon_bo *dst_bo) { int ret; + + radeon_cs_space_reset_bos(r100->radeon.cmdbuf.cs); + ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, src_bo, RADEON_GEM_DOMAIN_VRAM, 0); if (ret) -- cgit v1.2.3 From 9458c2061ba5d8857217d9a7504b42ea17022897 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 10:13:49 -0500 Subject: radeon/r200/r600: allow src and dst BOs to be placed in GTT during blit --- src/mesa/drivers/dri/r200/r200_blit.c | 10 ++-------- src/mesa/drivers/dri/r600/r600_blit.c | 10 ++-------- src/mesa/drivers/dri/radeon/radeon_blit.c | 10 ++-------- 3 files changed, 6 insertions(+), 24 deletions(-) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 2c8b3aafe5..3075760093 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -215,18 +215,12 @@ static GLboolean validate_buffers(struct r200_context *r200, radeon_cs_space_reset_bos(r200->radeon.cmdbuf.cs); ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + src_bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); if (ret) return GL_FALSE; ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); - if (ret) - return GL_FALSE; - - ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, - first_elem(&r200->radeon.dma.reserved)->bo, - RADEON_GEM_DOMAIN_GTT, 0); + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT); if (ret) return GL_FALSE; diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index fb84825761..244fdc4ffb 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1536,12 +1536,12 @@ static GLboolean validate_buffers(context_t *rmesa, radeon_cs_space_reset_bos(rmesa->radeon.cmdbuf.cs); ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + src_bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); if (ret) return GL_FALSE; ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT); if (ret) return GL_FALSE; @@ -1551,12 +1551,6 @@ static GLboolean validate_buffers(context_t *rmesa, if (ret) return GL_FALSE; - ret = radeon_cs_space_check_with_bo(rmesa->radeon.cmdbuf.cs, - first_elem(&rmesa->radeon.dma.reserved)->bo, - RADEON_GEM_DOMAIN_GTT, 0); - if (ret) - return GL_FALSE; - return GL_TRUE; } diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index 8c3c2e4766..e1e1f21550 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -208,18 +208,12 @@ static GLboolean validate_buffers(struct r100_context *r100, radeon_cs_space_reset_bos(r100->radeon.cmdbuf.cs); ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, - src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + src_bo, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); if (ret) return GL_FALSE; ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, - dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); - if (ret) - return GL_FALSE; - - ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, - first_elem(&r100->radeon.dma.reserved)->bo, - RADEON_GEM_DOMAIN_GTT, 0); + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT); if (ret) return GL_FALSE; -- cgit v1.2.3 From df9bf78f888702542a506f551204a2e7dc8b7df1 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 8 Mar 2010 11:59:02 -0500 Subject: r600: enable GL_ARB_pixel_buffer_object --- src/mesa/drivers/dri/r600/r600_context.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 3d6802e735..134e97e7c3 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -140,6 +140,7 @@ static const struct dri_extension card_extensions[] = { {"GL_NV_blend_square", NULL}, {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, {"GL_SGIS_generate_mipmap", NULL}, + {"GL_ARB_pixel_buffer_object", NULL}, {NULL, NULL} /* *INDENT-ON* */ }; -- cgit v1.2.3 From ac2b7835d5e61629f0a1f8b6c35eb1efa2ffbfa2 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Tue, 9 Mar 2010 21:41:00 +0100 Subject: radeon: add hw accelerated glReadPixel support (not enabled yet) --- src/mesa/drivers/dri/r200/Makefile | 1 + src/mesa/drivers/dri/r200/radeon_pixel_read.c | 1 + src/mesa/drivers/dri/r300/Makefile | 3 +- src/mesa/drivers/dri/r300/radeon_pixel_read.c | 1 + src/mesa/drivers/dri/r600/Makefile | 3 +- src/mesa/drivers/dri/r600/radeon_pixel_read.c | 1 + src/mesa/drivers/dri/radeon/Makefile | 1 + src/mesa/drivers/dri/radeon/radeon_common.h | 6 + src/mesa/drivers/dri/radeon/radeon_pixel_read.c | 188 ++++++++++++++++++++++++ 9 files changed, 203 insertions(+), 2 deletions(-) create mode 120000 src/mesa/drivers/dri/r200/radeon_pixel_read.c create mode 120000 src/mesa/drivers/dri/r300/radeon_pixel_read.c create mode 120000 src/mesa/drivers/dri/r600/radeon_pixel_read.c create mode 100644 src/mesa/drivers/dri/radeon/radeon_pixel_read.c (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index 3f87100570..9ea81fd505 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -21,6 +21,7 @@ RADEON_COMMON_SOURCES = \ radeon_fbo.c \ radeon_lock.c \ radeon_mipmap_tree.c \ + radeon_pixel_read.c \ radeon_queryobj.c \ radeon_span.c \ radeon_texture.c \ diff --git a/src/mesa/drivers/dri/r200/radeon_pixel_read.c b/src/mesa/drivers/dri/r200/radeon_pixel_read.c new file mode 120000 index 0000000000..3b03803126 --- /dev/null +++ b/src/mesa/drivers/dri/r200/radeon_pixel_read.c @@ -0,0 +1 @@ +../radeon/radeon_pixel_read.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 4257a32b89..2245998c95 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -31,8 +31,9 @@ RADEON_COMMON_SOURCES = \ radeon_fbo.c \ radeon_lock.c \ radeon_mipmap_tree.c \ - radeon_span.c \ + radeon_pixel_read.c \ radeon_queryobj.c \ + radeon_span.c \ radeon_texture.c \ radeon_tex_copy.c \ radeon_tex_getimage.c \ diff --git a/src/mesa/drivers/dri/r300/radeon_pixel_read.c b/src/mesa/drivers/dri/r300/radeon_pixel_read.c new file mode 120000 index 0000000000..3b03803126 --- /dev/null +++ b/src/mesa/drivers/dri/r300/radeon_pixel_read.c @@ -0,0 +1 @@ +../radeon/radeon_pixel_read.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index f76859d11e..17915621ee 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -31,9 +31,10 @@ RADEON_COMMON_SOURCES = \ radeon_fbo.c \ radeon_lock.c \ radeon_mipmap_tree.c \ + radeon_pixel_read.c \ + radeon_queryobj.c \ radeon_span.c \ radeon_texture.c \ - radeon_queryobj.c \ radeon_tex_copy.c \ radeon_tex_getimage.c \ radeon_tile.c diff --git a/src/mesa/drivers/dri/r600/radeon_pixel_read.c b/src/mesa/drivers/dri/r600/radeon_pixel_read.c new file mode 120000 index 0000000000..3b03803126 --- /dev/null +++ b/src/mesa/drivers/dri/r600/radeon_pixel_read.c @@ -0,0 +1 @@ +../radeon/radeon_pixel_read.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index 6904ebbee3..19df62742e 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -22,6 +22,7 @@ RADEON_COMMON_SOURCES = \ radeon_fbo.c \ radeon_lock.c \ radeon_mipmap_tree.c \ + radeon_pixel_read.c \ radeon_queryobj.c \ radeon_span.c \ radeon_texture.c \ diff --git a/src/mesa/drivers/dri/radeon/radeon_common.h b/src/mesa/drivers/dri/radeon/radeon_common.h index cd01c9984e..35b3f08fff 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.h +++ b/src/mesa/drivers/dri/radeon/radeon_common.h @@ -44,6 +44,12 @@ radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb, struct radeon_renderbuffer * radeon_create_renderbuffer(gl_format format, __DRIdrawable *driDrawPriv); +void +radeonReadPixels(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, GLvoid * pixels); + void radeon_check_front_buffer_rendering(GLcontext *ctx); static inline struct radeon_renderbuffer *radeon_renderbuffer(struct gl_renderbuffer *rb) { diff --git a/src/mesa/drivers/dri/radeon/radeon_pixel_read.c b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c new file mode 100644 index 0000000000..27841938e6 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_pixel_read.c @@ -0,0 +1,188 @@ +/* + * Copyright (C) 2010 Maciej Cencora + * + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "stdint.h" +#include "main/bufferobj.h" +#include "main/enums.h" +#include "main/image.h" +#include "main/state.h" +#include "swrast/swrast.h" + +#include "radeon_common_context.h" +#include "radeon_debug.h" +#include "radeon_mipmap_tree.h" + +static gl_format gl_format_and_type_to_mesa_format(GLenum format, GLenum type) +{ + switch (format) + { + case GL_RGB: + switch (type) { + case GL_UNSIGNED_SHORT_5_6_5: + return MESA_FORMAT_RGB565; + case GL_UNSIGNED_SHORT_5_6_5_REV: + return MESA_FORMAT_RGB565_REV; + } + break; + case GL_RGBA: + switch (type) { + case GL_UNSIGNED_BYTE: + return MESA_FORMAT_RGBA8888_REV; + case GL_FLOAT: + return MESA_FORMAT_RGBA_FLOAT32; + case GL_UNSIGNED_SHORT_4_4_4_4: + return MESA_FORMAT_ARGB4444; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + return MESA_FORMAT_ARGB4444; + case GL_UNSIGNED_SHORT_5_5_5_1: + return MESA_FORMAT_RGBA5551; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + return MESA_FORMAT_ARGB1555_REV; + case GL_UNSIGNED_INT_8_8_8_8: + return MESA_FORMAT_ARGB8888; + case GL_UNSIGNED_INT_8_8_8_8_REV: + return MESA_FORMAT_ARGB8888_REV; + } + break; + } + + return MESA_FORMAT_NONE; +} + +static GLboolean +do_blit_readpixels(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, GLvoid * pixels) +{ + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + const struct radeon_renderbuffer *rrb = radeon_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); + const gl_format dst_format = gl_format_and_type_to_mesa_format(format, type); + unsigned dst_rowstride, dst_imagesize, aligned_rowstride, flip_y; + struct radeon_bo *dst_buffer; + GLint dst_x = 0, dst_y = 0; + + /* It's not worth if number of pixels to copy is really small */ + if (width * height < 100) { + return GL_FALSE; + } + + if (dst_format == MESA_FORMAT_NONE || + !radeon->vtbl.check_blit(dst_format) || !radeon->vtbl.blit) { + return GL_FALSE; + } + + if (ctx->_ImageTransferState) { + return GL_FALSE; + } + + if (pack->SwapBytes || pack->LsbFirst) { + return GL_FALSE; + } + + if (pack->RowLength > 0) { + dst_rowstride = pack->RowLength; + } else { + dst_rowstride = width; + } + + if (!_mesa_clip_copytexsubimage(ctx, &dst_x, &dst_y, &x, &y, &width, &height)) { + return GL_TRUE; + } + assert(x >= 0 && y >= 0); + + aligned_rowstride = get_texture_image_row_stride(radeon, dst_format, dst_rowstride, 0); + dst_imagesize = get_texture_image_size(dst_format, + aligned_rowstride, + height, 1, 0); + dst_buffer = radeon_bo_open(radeon->radeonScreen->bom, 0, dst_imagesize, 1024, RADEON_GEM_DOMAIN_GTT, 0); + + /* Disable source Y flipping for FBOs */ + flip_y = (ctx->ReadBuffer->Name == 0); + if (pack->Invert) { + y = rrb->base.Height - height - y; + flip_y = !flip_y; + } + + if (radeon->vtbl.blit(ctx, + rrb->bo, + rrb->draw_offset, + rrb->base.Format, + rrb->pitch / rrb->cpp, + rrb->base.Width, + rrb->base.Height, + x, + y, + dst_buffer, + 0, /* dst_offset */ + dst_format, + aligned_rowstride / _mesa_get_format_bytes(dst_format), + width, + height, + 0, /* dst_x */ + 0, /* dst_y */ + width, + height, + flip_y)) + { + radeon_bo_map(dst_buffer, 0); + dst_rowstride *= _mesa_get_format_bytes(dst_format); + copy_rows(pixels, dst_rowstride, dst_buffer->ptr, + aligned_rowstride, height, dst_rowstride); + radeon_bo_unmap(dst_buffer); + radeon_bo_unref(dst_buffer); + return GL_TRUE; + } else { + radeon_bo_unref(dst_buffer); + return GL_FALSE; + } +} + +void +radeonReadPixels(GLcontext * ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *pack, GLvoid * pixels) +{ + if (do_blit_readpixels(ctx, x, y, width, height, format, type, pack, pixels)) + return; + + /* Update Mesa state before calling down into _swrast_ReadPixels, as + * the spans code requires the computed buffer states to be up to date, + * but _swrast_ReadPixels only updates Mesa state after setting up + * the spans code. + */ + + radeon_print(RADEON_FALLBACKS, RADEON_NORMAL, + "Falling back to sw for ReadPixels (format %s, type %s)\n", + _mesa_lookup_enum_by_nr(format), _mesa_lookup_enum_by_nr(type)); + + if (ctx->NewState) + _mesa_update_state(ctx); + + _swrast_ReadPixels(ctx, x, y, width, height, format, type, pack, pixels); +} -- cgit v1.2.3 From a17563c7ddfa58fe7f09d22a62a10f3488ef3147 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 7 Mar 2010 14:34:21 +0100 Subject: radeon/r200/r300/r600: add is_format_renderable function --- src/mesa/drivers/dri/r200/r200_context.c | 1 + src/mesa/drivers/dri/r300/r300_context.c | 6 ++++ src/mesa/drivers/dri/r300/r300_tex.c | 39 ++++++++++++++++++++++ src/mesa/drivers/dri/r300/r300_tex.h | 3 ++ src/mesa/drivers/dri/r600/r600_context.c | 1 + .../drivers/dri/radeon/radeon_common_context.h | 1 + src/mesa/drivers/dri/radeon/radeon_context.c | 1 + src/mesa/drivers/dri/radeon/radeon_texture.c | 16 +++++++++ src/mesa/drivers/dri/radeon/radeon_texture.h | 2 ++ 9 files changed, 70 insertions(+) (limited to 'src/mesa/drivers/dri/r600') diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index dad2580e08..4f1a56658c 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -266,6 +266,7 @@ static void r200_init_vtbl(radeonContextPtr radeon) radeon->vtbl.emit_query_finish = r200_emit_query_finish; radeon->vtbl.check_blit = r200_check_blit; radeon->vtbl.blit = r200_blit; + radeon->vtbl.is_format_renderable = radeonIsFormatRenderable; } diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index ff35cd5275..364e0ba6b6 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -321,6 +321,12 @@ static void r300_init_vtbl(radeonContextPtr radeon) radeon->vtbl.check_blit = r300_check_blit; radeon->vtbl.blit = r300_blit; + + if (radeon->radeonScreen->chip_family >= CHIP_FAMILY_RV515) { + radeon->vtbl.is_format_renderable = r500IsFormatRenderable; + } else { + radeon->vtbl.is_format_renderable = r300IsFormatRenderable; + } } static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen) diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c index 8dd8507395..baef206bc2 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.c +++ b/src/mesa/drivers/dri/r300/r300_tex.c @@ -308,6 +308,45 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx, return &t->base; } +unsigned r300IsFormatRenderable(gl_format mesa_format) +{ + switch (mesa_format) + { + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGBA5551: + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_RGB565_REV: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_ARGB4444_REV: + case MESA_FORMAT_ARGB1555_REV: + case MESA_FORMAT_XRGB8888_REV: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SARGB8: + case MESA_FORMAT_SL8: + case MESA_FORMAT_A8: + case MESA_FORMAT_L8: + case MESA_FORMAT_I8: + case MESA_FORMAT_Z16: + return 1; + default: + return 0; + } +} + +unsigned r500IsFormatRenderable(gl_format mesa_format) +{ + if (mesa_format == MESA_FORMAT_S8_Z24) { + return 1; + } else { + return r300IsFormatRenderable(mesa_format); + } +} + void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions) { /* Note: we only plug in the functions we implement in the driver diff --git a/src/mesa/drivers/dri/r300/r300_tex.h b/src/mesa/drivers/dri/r300/r300_tex.h index 9694e703b8..aca44cd766 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.h +++ b/src/mesa/drivers/dri/r300/r300_tex.h @@ -53,4 +53,7 @@ extern void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_tab int32_t r300TranslateTexFormat(gl_format mesaFormat); +unsigned r300IsFormatRenderable(gl_format mesaFormat); +unsigned r500IsFormatRenderable(gl_format mesaFormat); + #endif /* __r300_TEX_H__ */ diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 134e97e7c3..76d5027649 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -239,6 +239,7 @@ static void r600_init_vtbl(radeonContextPtr radeon) radeon->vtbl.emit_query_finish = r600_emit_query_finish; radeon->vtbl.check_blit = r600_check_blit; radeon->vtbl.blit = r600_blit; + radeon->vtbl.is_format_renderable = radeonIsFormatRenderable; } static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h index d1a24e265f..5156c5d0d0 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h @@ -539,6 +539,7 @@ struct radeon_context { unsigned reg_width, unsigned reg_height, unsigned flip_y); + unsigned (*is_format_renderable)(gl_format mesa_format); } vtbl; }; diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 878a453bd5..56aba16e9e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -200,6 +200,7 @@ static void r100_init_vtbl(radeonContextPtr radeon) radeon->vtbl.emit_query_finish = r100_emit_query_finish; radeon->vtbl.check_blit = r100_check_blit; radeon->vtbl.blit = r100_blit; + radeon->vtbl.is_format_renderable = radeonIsFormatRenderable; } /* Create the device specific context. diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 3ccc711253..2b655fbd95 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -1006,3 +1006,19 @@ void radeonTexSubImage3D(GLcontext * ctx, GLenum target, GLint level, radeon_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, width, height, depth, 0, format, type, pixels, packing, texObj, texImage, 0); } + +unsigned radeonIsFormatRenderable(gl_format mesa_format) +{ + if (mesa_format == _dri_texformat_argb8888 || mesa_format == _dri_texformat_rgb565 || + mesa_format == _dri_texformat_argb1555 || mesa_format == _dri_texformat_argb4444) + return 1; + + switch (mesa_format) + { + case MESA_FORMAT_Z16: + case MESA_FORMAT_S8_Z24: + return 1; + default: + return 0; + } +} diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h index f09dd65214..4ce639ea34 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.h +++ b/src/mesa/drivers/dri/radeon/radeon_texture.h @@ -135,4 +135,6 @@ void radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, GLint x, GLint y, GLsizei width, GLsizei height); +unsigned radeonIsFormatRenderable(gl_format mesa_format); + #endif -- cgit v1.2.3