From 30fd10f7f7e32e4e8b500192b5fff6535944d0af Mon Sep 17 00:00:00 2001 From: brianp Date: Mon, 25 Nov 2002 16:25:56 +0000 Subject: merge in Keith's glBitmap code --- xc/lib/GL/mesa/src/drv/r200/r200_pixel.c | 17 ++ xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c | 284 ++++++++++++++++++++++--------- xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h | 79 +++++++++ xc/lib/GL/mesa/src/drv/r200/r200_tcl.h | 66 +++++++ 4 files changed, 365 insertions(+), 81 deletions(-) create mode 100644 xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h create mode 100644 xc/lib/GL/mesa/src/drv/r200/r200_tcl.h diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c b/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c index 043f4133f..94977efd1 100644 --- a/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c +++ b/xc/lib/GL/mesa/src/drv/r200/r200_pixel.c @@ -42,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r200_context.h" #include "r200_ioctl.h" #include "r200_pixel.h" +#include "r200_swtcl.h" @@ -458,6 +459,20 @@ r200DrawPixels( GLcontext *ctx, } +static void +r200Bitmap( GLcontext *ctx, GLint px, GLint py, + GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ) +{ + r200ContextPtr rmesa = R200_CONTEXT(ctx); + + if (rmesa->Fallback) + _swrast_Bitmap( ctx, px, py, width, height, unpack, bitmap ); + else + r200PointsBitmap( ctx, px, py, width, height, unpack, bitmap ); +} + void r200InitPixelFuncs( GLcontext *ctx ) @@ -473,5 +488,7 @@ void r200InitPixelFuncs( GLcontext *ctx ) if (!getenv("R200_NO_BLITS") && R200_CONTEXT(ctx)->dri.drmMinor >= 6) { ctx->Driver.ReadPixels = r200ReadPixels; ctx->Driver.DrawPixels = r200DrawPixels; + if (getenv("R200_HW_BITMAP")) + ctx->Driver.Bitmap = r200Bitmap; } } diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c b/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c index 4c1584618..491fa51a7 100644 --- a/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c +++ b/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c @@ -36,10 +36,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "mtypes.h" #include "colormac.h" #include "enums.h" +#include "image.h" #include "imports.h" #include "mmath.h" #include "macros.h" +#include "swrast/s_fog.h" #include "swrast_setup/swrast_setup.h" #include "math/m_translate.h" #include "tnl/tnl.h" @@ -266,83 +268,11 @@ void r200PrintSetupFlags(char *msg, GLuint flags ) } -static void r200RenderStart( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - r200ContextPtr rmesa = R200_CONTEXT( ctx ); - - if (!setup_tab[rmesa->swtcl.SetupIndex].check_tex_sizes(ctx)) { - GLuint ind = rmesa->swtcl.SetupIndex |= (R200_PTEX_BIT|R200_RGBA_BIT); - - /* R200 handles projective textures nicely; just have to change - * up to the new vertex format. - */ - if (setup_tab[ind].vertex_format != rmesa->swtcl.vertex_format) { - int i; - R200_NEWPRIM(rmesa); - i = rmesa->swtcl.vertex_format = setup_tab[ind].vertex_format; - rmesa->swtcl.vertex_size = setup_tab[ind].vertex_size; - rmesa->swtcl.vertex_stride_shift = setup_tab[ind].vertex_stride_shift; - -/* fprintf(stderr, "%s: set vertex_format %d\n", __FUNCTION__, */ -/* rmesa->swtcl.vertex_format); */ -/* r200PrintSetupFlags( "setup flags", rmesa->swtcl.SetupIndex); */ - - R200_STATECHANGE( rmesa, vtx ); - rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = se_vtx_fmt_0[i]; - rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = se_vtx_fmt_1[i]; - } - - if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[rmesa->swtcl.SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[rmesa->swtcl.SetupIndex].copy_pv; - } - } - - if (rmesa->dma.flush != 0 && - rmesa->dma.flush != flush_last_swtcl_prim) - rmesa->dma.flush( rmesa ); -} - -void r200BuildVertices( GLcontext *ctx, GLuint start, GLuint count, - GLuint newinputs ) -{ - r200ContextPtr rmesa = R200_CONTEXT( ctx ); - GLubyte *v = ((GLubyte *)rmesa->swtcl.verts + - (start << rmesa->swtcl.vertex_stride_shift)); - GLuint stride = 1 << rmesa->swtcl.vertex_stride_shift; - - newinputs |= rmesa->swtcl.SetupNewInputs; - rmesa->swtcl.SetupNewInputs = 0; - -/* fprintf(stderr, "%s: vertex_format %d\n", __FUNCTION__, */ -/* rmesa->swtcl.vertex_format); */ - - if (!newinputs) - return; - - setup_tab[rmesa->swtcl.SetupIndex].emit( ctx, start, count, v, stride ); -} - -void r200ChooseVertexState( GLcontext *ctx ) +static void r200SetVertexFormat( GLcontext *ctx, GLuint ind ) { r200ContextPtr rmesa = R200_CONTEXT( ctx ); TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint ind = (R200_XYZW_BIT | R200_RGBA_BIT); - - if (!rmesa->TclFallback || rmesa->Fallback) - return; - - if (ctx->Fog.Enabled || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) - ind |= R200_SPEC_BIT; - - if (ctx->Texture._EnabledUnits & 0x2) - /* unit 1 enabled */ - ind |= R200_TEX0_BIT|R200_TEX1_BIT; - else if (ctx->Texture._EnabledUnits & 0x1) - /* unit 0 enabled */ - ind |= R200_TEX0_BIT; rmesa->swtcl.SetupIndex = ind; @@ -362,10 +292,6 @@ void r200ChooseVertexState( GLcontext *ctx ) rmesa->swtcl.vertex_size = setup_tab[ind].vertex_size; rmesa->swtcl.vertex_stride_shift = setup_tab[ind].vertex_stride_shift; -/* fprintf(stderr, "%s: set vertex_format %d\n", __FUNCTION__, */ -/* rmesa->swtcl.vertex_format); */ -/* r200PrintSetupFlags( "setup flags", rmesa->swtcl.SetupIndex); */ - R200_STATECHANGE( rmesa, vtx ); rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = se_vtx_fmt_0[i]; rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = se_vtx_fmt_1[i]; @@ -405,6 +331,57 @@ void r200ChooseVertexState( GLcontext *ctx ) } } +static void r200RenderStart( GLcontext *ctx ) +{ + r200ContextPtr rmesa = R200_CONTEXT( ctx ); + + if (!setup_tab[rmesa->swtcl.SetupIndex].check_tex_sizes(ctx)) { + r200SetVertexFormat( ctx, rmesa->swtcl.SetupIndex | R200_PTEX_BIT); + } + + if (rmesa->dma.flush != 0 && + rmesa->dma.flush != flush_last_swtcl_prim) + rmesa->dma.flush( rmesa ); +} + + +void r200BuildVertices( GLcontext *ctx, GLuint start, GLuint count, + GLuint newinputs ) +{ + r200ContextPtr rmesa = R200_CONTEXT( ctx ); + GLubyte *v = ((GLubyte *)rmesa->swtcl.verts + + (start << rmesa->swtcl.vertex_stride_shift)); + GLuint stride = 1 << rmesa->swtcl.vertex_stride_shift; + + newinputs |= rmesa->swtcl.SetupNewInputs; + rmesa->swtcl.SetupNewInputs = 0; + + if (!newinputs) + return; + + setup_tab[rmesa->swtcl.SetupIndex].emit( ctx, start, count, v, stride ); +} + + +void r200ChooseVertexState( GLcontext *ctx ) +{ + r200ContextPtr rmesa = R200_CONTEXT( ctx ); + GLuint ind = (R200_XYZW_BIT | R200_RGBA_BIT); + + if (!rmesa->TclFallback || rmesa->Fallback) + return; + + if (ctx->Fog.Enabled || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) + ind |= R200_SPEC_BIT; + + if (ctx->Texture._EnabledUnits & 0x2) /* unit 1 enabled */ + ind |= R200_TEX0_BIT|R200_TEX1_BIT; + else if (ctx->Texture._EnabledUnits & 0x1) /* unit 1 enabled */ + ind |= R200_TEX0_BIT; + + r200SetVertexFormat( ctx, ind ); +} + /* Flush vertices in the current dma region. */ @@ -457,11 +434,11 @@ static __inline void *r200AllocDmaLowVerts( r200ContextPtr rmesa, rmesa->dma.flush = flush_last_swtcl_prim; } - assert( vsize == rmesa->swtcl.vertex_size * 4 ); - assert( rmesa->dma.flush == flush_last_swtcl_prim ); - assert (rmesa->dma.current.start + + ASSERT( vsize == rmesa->swtcl.vertex_size * 4 ); + ASSERT( rmesa->dma.flush == flush_last_swtcl_prim ); + ASSERT( rmesa->dma.current.start + rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 == - rmesa->dma.current.ptr); + rmesa->dma.current.ptr ); { @@ -1089,6 +1066,151 @@ void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode ) } + + +/* Cope with depth operations by drawing individual pixels as points??? + */ +void +r200PointsBitmap( GLcontext *ctx, GLint px, GLint py, + GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ) +{ + r200ContextPtr rmesa = R200_CONTEXT(ctx); + const GLfloat *rc = ctx->Current.RasterColor; + GLint row, col; + r200Vertex vert; + GLuint orig_vte; + GLuint h; + + + /* Turn off tcl. + */ + TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 1 ); + + /* Choose tiny vertex format + */ + r200SetVertexFormat( ctx, R200_XYZW_BIT | R200_RGBA_BIT ); + + /* Ready for point primitives: + */ + r200RenderPrimitive( ctx, GL_POINTS ); + + /* Turn off the hw viewport transformation: + */ + R200_STATECHANGE( rmesa, vte ); + orig_vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]; + rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VPORT_X_SCALE_ENA | + R200_VPORT_Y_SCALE_ENA | + R200_VPORT_Z_SCALE_ENA | + R200_VPORT_X_OFFSET_ENA | + R200_VPORT_Y_OFFSET_ENA | + R200_VPORT_Z_OFFSET_ENA); + + /* Turn off other stuff: Stipple?, texture?, blending?, etc. + */ + + + /* Populate the vertex + * + * Incorporate FOG into RGBA + */ + if (ctx->Fog.Enabled) { + const GLfloat *fc = ctx->Fog.Color; + GLfloat color[4]; + GLfloat f; + + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) + f = _mesa_z_to_fogfactor(ctx, ctx->Current.Attrib[VERT_ATTRIB_FOG][0]); + else + f = _mesa_z_to_fogfactor(ctx, ctx->Current.RasterDistance); + + color[0] = f * rc[0] + (1.F - f) * fc[0]; + color[1] = f * rc[1] + (1.F - f) * fc[1]; + color[2] = f * rc[2] + (1.F - f) * fc[2]; + color[3] = rc[3]; + + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.red, color[0]); + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.green, color[1]); + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.blue, color[2]); + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.alpha, color[3]); + } + else { + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.red, rc[0]); + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.green, rc[1]); + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.blue, rc[2]); + UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.alpha, rc[3]); + } + + + vert.tv.z = ctx->Current.RasterPos[2]; + + + /* Update window height + */ + LOCK_HARDWARE( rmesa ); + UNLOCK_HARDWARE( rmesa ); + h = rmesa->dri.drawable->h + rmesa->dri.drawable->y; + px += rmesa->dri.drawable->x; + + /* Clipping handled by existing mechansims in r200_ioctl.c? + */ + for (row=0; rowLsbFirst) { + /* Lsb first */ + GLubyte mask = 1U << (unpack->SkipPixels & 0x7); + for (col=0; col> 7); + mask = ((mask << 1) & 0xff) | (mask >> 7); + } + + /* get ready for next row */ + if (mask != 1) + src++; + } + else { + /* Msb first */ + GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); + for (col=0; col> 1); + } + /* get ready for next row */ + if (mask != 128) + src++; + } + } + + /* Fire outstanding vertices, restore state + */ + R200_STATECHANGE( rmesa, vte ); + rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = orig_vte; + + /* Unfallback + */ + TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 0 ); + + /* Need to restore vertexformat? + */ + if (rmesa->TclFallback) + r200ChooseVertexState( ctx ); +} + + /**********************************************************************/ /* Initialization. */ /**********************************************************************/ diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h b/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h new file mode 100644 index 000000000..e3cee42b4 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h @@ -0,0 +1,79 @@ +/* $XFree86$ */ +/* +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. +*/ + +/* + * Authors: + * Keith Whitwell + */ + +#ifndef __R200_SWTCL_H__ +#define __R200_SWTCL_H__ + +#include "mtypes.h" +#include "swrast/swrast.h" +#include "r200_context.h" + +extern void r200InitSwtcl( GLcontext *ctx ); +extern void r200DestroySwtcl( GLcontext *ctx ); + +extern void r200ChooseRenderState( GLcontext *ctx ); +extern void r200ChooseVertexState( GLcontext *ctx ); + +extern void r200CheckTexSizes( GLcontext *ctx ); + +extern void r200BuildVertices( GLcontext *ctx, GLuint start, GLuint count, + GLuint newinputs ); + +extern void r200PrintSetupFlags(char *msg, GLuint flags ); + + +extern void r200_emit_contiguous_verts( GLcontext *ctx, + GLuint start, + GLuint count ); + +extern void r200_emit_indexed_verts( GLcontext *ctx, + GLuint start, + GLuint count ); + +extern void r200_translate_vertex( GLcontext *ctx, + const r200Vertex *src, + SWvertex *dst ); + +extern void r200_print_vertex( GLcontext *ctx, const r200Vertex *v ); + +extern void r200_import_float_colors( GLcontext *ctx ); +extern void r200_import_float_spec_colors( GLcontext *ctx ); + +extern void r200PointsBitmap( GLcontext *ctx, GLint px, GLint py, + GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap ); + + +#endif diff --git a/xc/lib/GL/mesa/src/drv/r200/r200_tcl.h b/xc/lib/GL/mesa/src/drv/r200/r200_tcl.h new file mode 100644 index 000000000..b0f4386ee --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r200/r200_tcl.h @@ -0,0 +1,66 @@ +/* $XFree86$ */ +/* +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. +*/ + +/* + * Authors: + * Keith Whitwell + */ + +#ifndef __R200_TCL_H__ +#define __R200_TCL_H__ + +#ifdef GLX_DIRECT_RENDERING + +#include "r200_context.h" + +extern void r200TclPrimitive( GLcontext *ctx, GLenum prim, int hw_prim ); +extern void r200EmitEltPrimitive( GLcontext *ctx, GLuint first, GLuint last, + GLuint flags ); +extern void r200EmitPrimitive( GLcontext *ctx, GLuint first, GLuint last, + GLuint flags ); + +extern void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode ); + +#define R200_TCL_FALLBACK_RASTER 0x1 /* rasterization */ +#define R200_TCL_FALLBACK_UNFILLED 0x2 /* unfilled tris */ +#define R200_TCL_FALLBACK_LIGHT_TWOSIDE 0x4 /* twoside tris */ +#define R200_TCL_FALLBACK_MATERIAL 0x8 /* material in vb */ +#define R200_TCL_FALLBACK_TEXGEN_0 0x10 /* texgen, unit 0 */ +#define R200_TCL_FALLBACK_TEXGEN_1 0x20 /* texgen, unit 1 */ +#define R200_TCL_FALLBACK_TEXGEN_2 0x40 /* texgen, unit 2 */ +#define R200_TCL_FALLBACK_TCL_DISABLE 0x80 /* user disable */ +#define R200_TCL_FALLBACK_BITMAP 0x100 /* draw bitmap with points */ + +#define R200_MAX_TCL_VERTSIZE (4*4) /* using maos now... */ + +#define TCL_FALLBACK( ctx, bit, mode ) r200TclFallback( ctx, bit, mode ) + + +#endif +#endif -- cgit v1.2.3