From ef82f004fab29f5aff809a31cbcb51e381df1a49 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 12 Jun 2007 15:08:43 -0600 Subject: fix comment --- src/mesa/main/imports.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index ca5f079f72a..8a5dfdb4b80 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -20,7 +20,7 @@ /* * Mesa 3-D graphics library - * Version: 7.0 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -254,7 +254,7 @@ _mesa_memset16( unsigned short *dst, unsigned short val, size_t n ) *dst++ = val; } -/** Wrapper around either memcpy() or bzero() */ +/** Wrapper around either memset() or bzero() */ void _mesa_bzero( void *dst, size_t n ) { -- cgit v1.2.3 From 261ed740749a7f358573ba470c25ed78d4abd2c4 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 12 Jun 2007 17:06:27 -0600 Subject: fix make clean commands so missing subdirs don't cause infinite loops --- src/mesa/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/Makefile b/src/mesa/Makefile index c03c5f80ff2..6943219036d 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -176,9 +176,9 @@ clean: -rm -f */*/*.o -rm -f depend depend.bak libmesa.a -rm -f drivers/*/*.o - (cd drivers/dri ; $(MAKE) clean) - (cd x86 ; $(MAKE) clean) - (cd x86-64 ; $(MAKE) clean) + (cd drivers/dri && $(MAKE) clean) + (cd x86 && $(MAKE) clean) + (cd x86-64 && $(MAKE) clean) include depend -- cgit v1.2.3 From 144e1e439faf994ad25901aaf2a9d60a1078eed9 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 12 Jun 2007 17:17:43 -0600 Subject: fix an error string, refactor _mesa_GetCompressedTexImageARB() to get rid of a goto --- src/mesa/main/teximage.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index f315c3de74e..f902365b9bd 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -3768,7 +3768,7 @@ _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, width, height, depth, /*size*/ format, imageSize); if (error) { - _mesa_error(ctx, error, "glCompressedTexSubImage2D"); + _mesa_error(ctx, error, "glCompressedTexSubImage3D"); return; } @@ -3819,7 +3819,6 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(ctx, texUnit, target); if (!texObj) { @@ -3840,24 +3839,25 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) return; } - _mesa_lock_texture(ctx, texObj); { texImage = _mesa_select_tex_image(ctx, texObj, target, level); - if (!texImage) { - /* probably invalid mipmap level */ - _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)"); - goto out; + if (texImage) { + if (texImage->IsCompressed) { + /* this typically calls _mesa_get_compressed_teximage() */ + ctx->Driver.GetCompressedTexImage(ctx, target, level, img, + texObj, texImage); + } + else { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glGetCompressedTexImageARB"); + } } - - if (!texImage->IsCompressed) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glGetCompressedTexImageARB"); - goto out; + else { + /* probably invalid mipmap level */ + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetCompressedTexImageARB(level)"); } - - /* this typically calls _mesa_get_compressed_teximage() */ - ctx->Driver.GetCompressedTexImage(ctx, target, level, img, texObj,texImage); } - out: _mesa_unlock_texture(ctx, texObj); } -- cgit v1.2.3 From 40cc47f8ee635c131af1328089d4a918555659e2 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 13 Jun 2007 12:56:48 +1000 Subject: move clip to r300 emit --- src/mesa/drivers/dri/r300/r300_emit.c | 4 +++- src/mesa/drivers/dri/r300/r300_render.c | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index 4670c28a02f..e8f0f89cf3f 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -358,9 +358,11 @@ int r300EmitArrays(GLcontext * ctx) DECLARE_RENDERINPUTS(render_inputs_bitset); RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset); + vb->AttribPtr[VERT_ATTRIB_POS] = vb->ClipPtr; + assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS)); assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_NORMAL) == 0); - assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0)); + //assert(RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_COLOR0)); if (RENDERINPUTS_TEST(render_inputs_bitset, _TNL_ATTRIB_POS)) { InputsRead |= 1 << VERT_ATTRIB_POS; diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 83999307b56..7770cbbacb5 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -293,11 +293,10 @@ static GLboolean r300RunRender(GLcontext * ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *vb = &tnl->vb; + if (RADEON_DEBUG & DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__); - if (hw_tcl_on == GL_FALSE) - vb->AttribPtr[VERT_ATTRIB_POS] = vb->ClipPtr; r300UpdateShaders(rmesa); if (r300EmitArrays(ctx)) return GL_TRUE; -- cgit v1.2.3 From bc81885bb2b498449a1362997ca67dd53f97d2e7 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 14 Jun 2007 15:26:39 +1000 Subject: Initial r300 modes for swtcl it compiles!! --- src/mesa/drivers/dri/r300/Makefile | 1 + src/mesa/drivers/dri/r300/r300_context.c | 4 +- src/mesa/drivers/dri/r300/r300_context.h | 67 +++- src/mesa/drivers/dri/r300/r300_swtcl.c | 570 +++++++++++++++++++++++++++++++ 4 files changed, 640 insertions(+), 2 deletions(-) create mode 100644 src/mesa/drivers/dri/r300/r300_swtcl.c (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index c1d223c7600..44248964fdb 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -41,6 +41,7 @@ DRIVER_SOURCES = \ r300_fragprog.c \ r300_shader.c \ r300_emit.c \ + r300_swtcl.c \ $(EGL_SOURCES) C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES) diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 9ea14ab4c78..311d003633a 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -63,6 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_ioctl.h" #include "r300_tex.h" #include "r300_emit.h" +#include "r300_swtcl.h" #ifdef USER_BUFFERS #include "r300_mem.h" @@ -164,7 +165,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = { /* Else do them here. */ - &_r300_render_stage, + // &_r300_render_stage, &_tnl_render_stage, /* FALLBACK */ 0, }; @@ -363,6 +364,7 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, radeonInitSpanFuncs(ctx); r300InitCmdBuf(r300); r300InitState(r300); + r300InitSwtcl(ctx); TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 076bb49a006..5e07cbd88fd 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -600,6 +600,11 @@ struct r300_vertex_shader_state { extern int hw_tcl_on; +#define COLOR_IS_RGBA +#define TAG(x) r300##x +#include "tnl_dd/t_dd_vertex.h" +#undef TAG + //#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Current) #define CURRENT_VERTEX_SHADER(ctx) (R300_CONTEXT(ctx)->selected_vp) @@ -796,7 +801,8 @@ struct r300_state { GLuint *Elts; struct r300_dma_region elt_dma; - DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for. + struct r300_dma_region swtcl_dma; + DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for. They are the same as tnl->render_inputs for fixed pipeline */ struct { @@ -811,6 +817,62 @@ struct r300_state { #define R300_FALLBACK_TCL 1 #define R300_FALLBACK_RAST 2 +/* r300_swtcl.c + */ +struct r300_swtcl_info { + GLuint RenderIndex; + + /** + * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is + * installed in the Mesa state vector. + */ + GLuint vertex_size; + + /** + * Attributes instructing the Mesa TCL pipeline where / how to put vertex + * data in the hardware buffer. + */ + struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; + + /** + * Number of elements of \c ::vertex_attrs that are actually used. + */ + GLuint vertex_attr_count; + + /** + * Cached pointer to the buffer where Mesa will store vertex data. + */ + GLubyte *verts; + + /* Fallback rasterization functions + */ + // r200_point_func draw_point; + // r200_line_func draw_line; + // r200_tri_func draw_tri; + + GLuint hw_primitive; + GLenum render_primitive; + GLuint numverts; + + /** + * Offset of the 4UB color data within a hardware (swtcl) vertex. + */ + GLuint coloroffset; + + /** + * Offset of the 3UB specular color data within a hardware (swtcl) vertex. + */ + GLuint specoffset; + + /** + * Should Mesa project vertex data or will the hardware do it? + */ + GLboolean needproj; + + struct r300_dma_region indexed_verts; +}; + + /** * \brief R300 context structure. */ @@ -849,6 +911,9 @@ struct r300_context { GLvector4f *temp_attrib[_TNL_ATTRIB_MAX]; GLboolean disable_lowimpact_fallback; + + DECLARE_RENDERINPUTS(tnl_index_bitset); /* index of bits for last tnl_install_attrs */ + struct r300_swtcl_info swtcl; }; struct r300_buffer_object { diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c new file mode 100644 index 00000000000..3ed454de484 --- /dev/null +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -0,0 +1,570 @@ +/************************************************************************** + +Copyright (C) 2007 Dave Airlie + +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, 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 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: + * Dave Airlie + */ + +/* derived from r200 swtcl path */ + + + +#include "glheader.h" +#include "mtypes.h" +#include "colormac.h" +#include "enums.h" +#include "image.h" +#include "imports.h" +#include "macros.h" + +#include "swrast/s_context.h" +#include "swrast/s_fog.h" +#include "swrast_setup/swrast_setup.h" +#include "math/m_translate.h" +#include "tnl/tnl.h" +#include "tnl/t_context.h" +#include "tnl/t_pipeline.h" + +#include "r300_context.h" +#include "r300_swtcl.h" +#include "r300_state.h" +#include "r300_ioctl.h" + +#define EMIT_ATTR( ATTR, STYLE, F0 ) \ +do { \ + rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR); \ + rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \ + rmesa->swtcl.vertex_attr_count++; \ + vap_fmt_0 |= F0; \ +} while (0) + +#define EMIT_PAD( N ) \ +do { \ + rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0; \ + rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD; \ + rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N); \ + rmesa->swtcl.vertex_attr_count++; \ +} while (0) + +static void r300SetVertexFormat( GLcontext *ctx ) +{ + r300ContextPtr rmesa = R300_CONTEXT( ctx ); + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + DECLARE_RENDERINPUTS(index_bitset); + int vap_fmt_0 = 0; + int vap_fmt_1 = 0; + int vap_vte_cntl = 0; + int offset = 0; + + RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); + + /* Important: + */ + if ( VB->NdcPtr != NULL ) { + VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; + } + else { + VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr; + } + + assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL ); + rmesa->swtcl.vertex_attr_count = 0; + + /* EMIT_ATTR's must be in order as they tell t_vertex.c how to + * build up a hardware vertex. + */ + if ( !rmesa->swtcl.needproj || + RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { /* need w coord for projected textures */ + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT); + vap_vte_cntl |= R300_VTX_XY_FMT | R300_VTX_Z_FMT | R300_VTX_W0_FMT; + + offset = 4; + } + else { + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F, R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT ); + vap_vte_cntl |= R300_VTX_XY_FMT | R300_VTX_Z_FMT; + offset = 3; + } + + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { + EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT); + offset += 1; + } + + rmesa->swtcl.coloroffset = offset; +#if MESA_LITTLE_ENDIAN + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT ); +#else + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT ); +#endif + offset += 1; + + rmesa->swtcl.specoffset = 0; + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || + RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { + +#if MESA_LITTLE_ENDIAN + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { + rmesa->swtcl.specoffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + } + else { + EMIT_PAD( 3 ); + } + + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + } + else { + EMIT_PAD( 1 ); + } +#else + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + } + else { + EMIT_PAD( 1 ); + } + + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { + rmesa->swtcl.specoffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + } + else { + EMIT_PAD( 3 ); + } +#endif + } + + if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { + int i; + + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { + GLuint sz = VB->TexCoordPtr[i]->size; + + vap_fmt_1 |= sz << (3 * i); + EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1, 0 ); + } + } + } + +#if 0 + if ( (rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK) + != R200_FOG_USE_SPEC_ALPHA ) { + R200_STATECHANGE( rmesa, ctx ); + rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK; + rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_SPEC_ALPHA; + } +#endif + + if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset ) || + (rmesa->hw.vof.cmd[R300_VOF_CNTL_0] != vap_fmt_0) || + (rmesa->hw.vof.cmd[R300_VOF_CNTL_1] != vap_fmt_1) ) { +// R200_NEWPRIM(rmesa); + R300_STATECHANGE(rmesa, vof); + rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = + vap_fmt_0; + rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = + vap_fmt_1; + + rmesa->swtcl.vertex_size = + _tnl_install_attrs( ctx, + rmesa->swtcl.vertex_attrs, + rmesa->swtcl.vertex_attr_count, + NULL, 0 ); + rmesa->swtcl.vertex_size /= 4; + RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); + } +} + +static void * +r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) +{ + GLuint bytes = vsize * nverts; + + r300AllocDmaRegion(rmesa, &rmesa->state.swtcl_dma, bytes, 0); + + rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; + rmesa->swtcl.numverts += nverts; + + return (rmesa->dma.current.address + rmesa->dma.current.ptr); +} + +static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ); +static void r300RenderPrimitive( GLcontext *ctx, GLenum prim ); +//static void r300ResetLineStipple( GLcontext *ctx ); + + +static const GLenum reduced_prim[GL_POLYGON+1] = { + GL_POINTS, + GL_LINES, + GL_LINES, + GL_LINES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES +}; + + +/*********************************************************************** + * Emit primitives as inline vertices * + ***********************************************************************/ + + +#define HAVE_POINTS 1 +#define HAVE_LINES 1 +#define HAVE_LINE_STRIPS 1 +#define HAVE_TRIANGLES 1 +#define HAVE_TRI_STRIPS 1 +#define HAVE_TRI_STRIP_1 0 +#define HAVE_TRI_FANS 1 +#define HAVE_QUADS 0 +#define HAVE_QUAD_STRIPS 0 +#define HAVE_POLYGONS 1 +#define HAVE_ELTS 1 + +#undef LOCAL_VARS +#undef ALLOC_VERTS +#define CTX_ARG r300ContextPtr rmesa +#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size +#define ALLOC_VERTS( n, size ) r300AllocDmaLowVerts( rmesa, n, size * 4 ) +#define LOCAL_VARS \ + r300ContextPtr rmesa = R300_CONTEXT(ctx); \ + const char *r300verts = (char *)rmesa->swtcl.verts; +#define VERT(x) (r300Vertex *)(r300verts + ((x) * vertsize * sizeof(int))) +#define VERTEX r300Vertex +#define DO_DEBUG_VERTS (1 && (RADEON_DEBUG & DEBUG_VERTS)) + +#undef TAG +#define TAG(x) r300_##x +#include "tnl_dd/t_dd_triemit.h" + + + +/*********************************************************************** + * Macros for t_dd_tritmp.h to draw basic primitives * + ***********************************************************************/ + +#define QUAD( a, b, c, d ) r300_quad( rmesa, a, b, c, d ) +#define TRI( a, b, c ) r300_triangle( rmesa, a, b, c ) +#define LINE( a, b ) r300_line( rmesa, a, b ) +#define POINT( a ) r300_point( rmesa, a ) + +/*********************************************************************** + * Build render functions from dd templates * + ***********************************************************************/ + +#define R300_TWOSIDE_BIT 0x01 +#define R300_UNFILLED_BIT 0x02 +#define R300_MAX_TRIFUNC 0x04 + +static struct { + tnl_points_func points; + tnl_line_func line; + tnl_triangle_func triangle; + tnl_quad_func quad; +} rast_tab[R300_MAX_TRIFUNC]; + +#define DO_FALLBACK 0 +#define DO_UNFILLED (IND & R300_UNFILLED_BIT) +#define DO_TWOSIDE (IND & R300_TWOSIDE_BIT) +#define DO_FLAT 0 +#define DO_OFFSET 0 +#define DO_TRI 1 +#define DO_QUAD 1 +#define DO_LINE 1 +#define DO_POINTS 1 +#define DO_FULL_QUAD 1 + +#define HAVE_RGBA 1 +#define HAVE_SPEC 1 +#define HAVE_BACK_COLORS 0 +#define HAVE_HW_FLATSHADE 1 +#define TAB rast_tab + +#define DEPTH_SCALE 1.0 +#define UNFILLED_TRI unfilled_tri +#define UNFILLED_QUAD unfilled_quad +#define VERT_X(_v) _v->v.x +#define VERT_Y(_v) _v->v.y +#define VERT_Z(_v) _v->v.z +#define AREA_IS_CCW( a ) (a < 0) +#define GET_VERTEX(e) (rmesa->swtcl.verts + (e*rmesa->swtcl.vertex_size*sizeof(int))) + +#define VERT_SET_RGBA( v, c ) \ +do { \ + r300_color_t *color = (r300_color_t *)&((v)->ui[coloroffset]); \ + UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ + UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ + UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ + UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ +} while (0) + +#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] + +#define VERT_SET_SPEC( v, c ) \ +do { \ + if (specoffset) { \ + r300_color_t *spec = (r300_color_t *)&((v)->ui[specoffset]); \ + UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ + UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ + UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ + } \ +} while (0) +#define VERT_COPY_SPEC( v0, v1 ) \ +do { \ + if (specoffset) { \ + r300_color_t *spec0 = (r300_color_t *)&((v0)->ui[specoffset]); \ + r300_color_t *spec1 = (r300_color_t *)&((v1)->ui[specoffset]); \ + spec0->red = spec1->red; \ + spec0->green = spec1->green; \ + spec0->blue = spec1->blue; \ + } \ +} while (0) + +/* These don't need LE32_TO_CPU() as they used to save and restore + * colors which are already in the correct format. + */ +#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] +#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] +#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset] +#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx] + +#undef LOCAL_VARS +#undef TAG +#undef INIT + +#define LOCAL_VARS(n) \ + r300ContextPtr rmesa = R300_CONTEXT(ctx); \ + GLuint color[n], spec[n]; \ + GLuint coloroffset = rmesa->swtcl.coloroffset; \ + GLuint specoffset = rmesa->swtcl.specoffset; \ + (void) color; (void) spec; (void) coloroffset; (void) specoffset; + +/*********************************************************************** + * Helpers for rendering unfilled primitives * + ***********************************************************************/ + +#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] ) +#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive +#undef TAG +#define TAG(x) x +#include "tnl_dd/t_dd_unfilled.h" +#undef IND + + +/*********************************************************************** + * Generate GL render functions * + ***********************************************************************/ + + +#define IND (0) +#define TAG(x) x +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (R300_TWOSIDE_BIT) +#define TAG(x) x##_twoside +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (R300_UNFILLED_BIT) +#define TAG(x) x##_unfilled +#include "tnl_dd/t_dd_tritmp.h" + +#define IND (R300_TWOSIDE_BIT|R300_UNFILLED_BIT) +#define TAG(x) x##_twoside_unfilled +#include "tnl_dd/t_dd_tritmp.h" + + +static void init_rast_tab( void ) +{ + init(); + init_twoside(); + init_unfilled(); + init_twoside_unfilled(); +} + +/**********************************************************************/ +/* Render unclipped begin/end objects */ +/**********************************************************************/ + +#define RENDER_POINTS( start, count ) \ + for ( ; start < count ; start++) \ + r300_point( rmesa, VERT(start) ) +#define RENDER_LINE( v0, v1 ) \ + r300_line( rmesa, VERT(v0), VERT(v1) ) +#define RENDER_TRI( v0, v1, v2 ) \ + r300_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) ) +#define RENDER_QUAD( v0, v1, v2, v3 ) \ + r300_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) +#define INIT(x) do { \ + r300RenderPrimitive( ctx, x ); \ +} while (0) +#undef LOCAL_VARS +#define LOCAL_VARS \ + r300ContextPtr rmesa = R300_CONTEXT(ctx); \ + const GLuint vertsize = rmesa->swtcl.vertex_size; \ + const char *r300verts = (char *)rmesa->swtcl.verts; \ + const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ + const GLboolean stipple = ctx->Line.StippleFlag; \ + (void) elt; (void) stipple; +#define RESET_STIPPLE //if ( stipple ) r200ResetLineStipple( ctx ); +#define RESET_OCCLUSION +#define PRESERVE_VB_DEFS +#define ELT(x) (x) +#define TAG(x) r300_##x##_verts +#include "tnl/t_vb_rendertmp.h" +#undef ELT +#undef TAG +#define TAG(x) r300_##x##_elts +#define ELT(x) elt[x] +#include "tnl/t_vb_rendertmp.h" + + + + +/**********************************************************************/ +/* Choose render functions */ +/**********************************************************************/ + +void r300ChooseRenderState( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + r300ContextPtr rmesa = R300_CONTEXT(ctx); + GLuint index = 0; + GLuint flags = ctx->_TriangleCaps; + + // if (!rmesa->TclFallback || rmesa->Fallback) +// return; + +// if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R200_TWOSIDE_BIT; +// if (flags & DD_TRI_UNFILLED) index |= R200_UNFILLED_BIT; + + if (index != rmesa->swtcl.RenderIndex) { + tnl->Driver.Render.Points = rast_tab[index].points; + tnl->Driver.Render.Line = rast_tab[index].line; + tnl->Driver.Render.ClippedLine = rast_tab[index].line; + tnl->Driver.Render.Triangle = rast_tab[index].triangle; + tnl->Driver.Render.Quad = rast_tab[index].quad; + + if (index == 0) { + tnl->Driver.Render.PrimTabVerts = r300_render_tab_verts; + tnl->Driver.Render.PrimTabElts = r300_render_tab_elts; + tnl->Driver.Render.ClippedPolygon = r300_fast_clipped_poly; + } else { + tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; + tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; + tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; + } + + rmesa->swtcl.RenderIndex = index; + } +} + + +static void r300RenderStart(GLcontext *ctx) +{ + fprintf(stderr, "%s\n", __FUNCTION__); + + r300SetVertexFormat(ctx); +} + +static void r300RenderFinish(GLcontext *ctx) +{ + fprintf(stderr, "%s\n", __FUNCTION__); +} + +static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ) +{ + r300ContextPtr rmesa = R300_CONTEXT(ctx); + + if (rmesa->swtcl.hw_primitive != hwprim) { +// R300_NEWPRIM( rmesa ); + rmesa->swtcl.hw_primitive = hwprim; + } +} + +static void r300RenderPrimitive(GLcontext *ctx, GLenum prim) +{ + + r300ContextPtr rmesa = R300_CONTEXT(ctx); + rmesa->swtcl.render_primitive = prim; + if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) + r300RasterPrimitive( ctx, reduced_prim[prim] ); + fprintf(stderr, "%s\n", __FUNCTION__); + +} + +static void r300ResetLineStipple(GLcontext *ctx) +{ + + +} + +void r300InitSwtcl(GLcontext *ctx) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + r300ContextPtr rmesa = R300_CONTEXT(ctx); + static int firsttime = 1; + + if (firsttime) { + init_rast_tab(); + firsttime = 0; + } + + tnl->Driver.Render.Start = r300RenderStart; + tnl->Driver.Render.Finish = r300RenderFinish; + tnl->Driver.Render.PrimitiveNotify = r300RenderPrimitive; + tnl->Driver.Render.ResetLineStipple = r300ResetLineStipple; + tnl->Driver.Render.BuildVertices = _tnl_build_vertices; + tnl->Driver.Render.CopyPV = _tnl_copy_pv; + tnl->Driver.Render.Interp = _tnl_interp; + + /* FIXME: what are these numbers? */ + _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, + 36 * sizeof(GLfloat) ); + + rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf; + rmesa->swtcl.RenderIndex = ~0; + rmesa->swtcl.render_primitive = GL_TRIANGLES; + rmesa->swtcl.hw_primitive = 0; + + r300ChooseRenderState(ctx); +} + +void r300DestroySwtcl(GLcontext *ctx) +{ + r300ContextPtr rmesa = R300_CONTEXT(ctx); +// if (rmesa->swtcl.indexed_verts.buf) +// r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ ); + +} -- cgit v1.2.3 From d42888dac3a0b648bf1babfde77e0e104e036831 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 17 Jun 2007 14:17:11 +1000 Subject: add more swtcl code to r300 - hangs card now --- src/mesa/drivers/dri/r300/r300_ioctl.c | 9 ++- src/mesa/drivers/dri/r300/r300_swtcl.c | 102 +++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 15c2cf3ad7b..52345855fe3 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -412,13 +412,16 @@ static void r300Clear(GLcontext * ctx, GLbitfield mask) void r300Flush(GLcontext * ctx) { - r300ContextPtr r300 = R300_CONTEXT(ctx); + r300ContextPtr rmesa = R300_CONTEXT(ctx); if (RADEON_DEBUG & DEBUG_IOCTL) fprintf(stderr, "%s\n", __FUNCTION__); - if (r300->cmdbuf.count_used > r300->cmdbuf.count_reemit) - r300FlushCmdBuf(r300, __FUNCTION__); + if (rmesa->dma.flush) + rmesa->dma.flush( rmesa ); + + if (rmesa->cmdbuf.count_used > rmesa->cmdbuf.count_reemit) + r300FlushCmdBuf(rmesa, __FUNCTION__); } #ifdef USER_BUFFERS diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 3ed454de484..7a3ddcd503f 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -54,7 +54,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_swtcl.h" #include "r300_state.h" #include "r300_ioctl.h" +#include "r300_emit.h" +#include "r300_mem.h" +static void flush_last_swtcl_prim( r300ContextPtr rmesa ); + +void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset); +void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr); #define EMIT_ATTR( ATTR, STYLE, F0 ) \ do { \ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR); \ @@ -204,6 +210,45 @@ static void r300SetVertexFormat( GLcontext *ctx ) } } + +/* Flush vertices in the current dma region. + */ +static void flush_last_swtcl_prim( r300ContextPtr rmesa ) +{ + if (RADEON_DEBUG & DEBUG_IOCTL) + fprintf(stderr, "%s\n", __FUNCTION__); + + rmesa->dma.flush = NULL; + + if (rmesa->dma.current.buf) { + struct r300_dma_region *current = &rmesa->dma.current; + // GLuint current_offset = rmesa->state.swtcl_dma.aos_offset; + + GLuint current_offset = r300_mem_offset(rmesa,current->buf->id); + // assert (!(rmesa->swtcl.hw_primitive & R200_VF_PRIM_WALK_IND)); + + assert (current->start + + rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 == + current->ptr); + + if (rmesa->dma.current.start != rmesa->dma.current.ptr) { + // r200EnsureCmdBufSpace( rmesa, VERT_AOS_BUFSZ + + // rmesa->hw.max_state_size + VBUF_BUFSZ ); + r300EmitVertexAOS( rmesa, + rmesa->swtcl.vertex_size, + current_offset); + + r300EmitVbufPrim( rmesa, + rmesa->swtcl.hw_primitive, + rmesa->swtcl.numverts); + } + + rmesa->swtcl.numverts = 0; + current->start = current->ptr; + } +} + + static void * r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) { @@ -211,9 +256,14 @@ r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) r300AllocDmaRegion(rmesa, &rmesa->state.swtcl_dma, bytes, 0); - rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; - rmesa->swtcl.numverts += nverts; + if (!rmesa->dma.flush) { + rmesa->dma.flush = flush_last_swtcl_prim; + rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; + } + + rmesa->swtcl.numverts += nverts; + rmesa->dma.current.ptr += bytes; return (rmesa->dma.current.address + rmesa->dma.current.ptr); } @@ -221,6 +271,11 @@ static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ); static void r300RenderPrimitive( GLcontext *ctx, GLenum prim ); //static void r300ResetLineStipple( GLcontext *ctx ); +static void r300PrintVertex(r300Vertex *v) +{ + fprintf(stderr,"Vertex %p\n", v); + +} static const GLenum reduced_prim[GL_POLYGON+1] = { GL_POINTS, @@ -264,7 +319,7 @@ static const GLenum reduced_prim[GL_POLYGON+1] = { #define VERT(x) (r300Vertex *)(r300verts + ((x) * vertsize * sizeof(int))) #define VERTEX r300Vertex #define DO_DEBUG_VERTS (1 && (RADEON_DEBUG & DEBUG_VERTS)) - +#define PRINT_VERTEX(x) r300PrintVertex(x) #undef TAG #define TAG(x) r300_##x #include "tnl_dd/t_dd_triemit.h" @@ -466,8 +521,8 @@ void r300ChooseRenderState( GLcontext *ctx ) // if (!rmesa->TclFallback || rmesa->Fallback) // return; -// if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R200_TWOSIDE_BIT; -// if (flags & DD_TRI_UNFILLED) index |= R200_UNFILLED_BIT; + if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT; + if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT; if (index != rmesa->swtcl.RenderIndex) { tnl->Driver.Render.Points = rast_tab[index].points; @@ -493,9 +548,13 @@ void r300ChooseRenderState( GLcontext *ctx ) static void r300RenderStart(GLcontext *ctx) { + r300ContextPtr rmesa = R300_CONTEXT( ctx ); fprintf(stderr, "%s\n", __FUNCTION__); r300SetVertexFormat(ctx); + if (rmesa->dma.flush != 0 && + rmesa->dma.flush != flush_last_swtcl_prim) + rmesa->dma.flush( rmesa ); } static void r300RenderFinish(GLcontext *ctx) @@ -558,6 +617,10 @@ void r300InitSwtcl(GLcontext *ctx) rmesa->swtcl.render_primitive = GL_TRIANGLES; rmesa->swtcl.hw_primitive = 0; + _tnl_invalidate_vertex_state( ctx, ~0 ); + _tnl_invalidate_vertices( ctx, ~0 ); + RENDERINPUTS_ZERO( rmesa->tnl_index_bitset ); + r300ChooseRenderState(ctx); } @@ -568,3 +631,32 @@ void r300DestroySwtcl(GLcontext *ctx) // r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ ); } + +void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) +{ + int cmd_reserved = 0; + int cmd_written = 0; + + drm_radeon_cmd_header_t *cmd = NULL; + if (1)//RADEON_DEBUG & DEBUG_VERTS) + fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n", + __FUNCTION__, vertex_size, offset); + + start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); + e32(1); + e32(vertex_size | (vertex_size << 8)); + e32(offset); +} + +void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) +{ + + int cmd_reserved = 0; + int cmd_written = 0; + + drm_radeon_cmd_header_t *cmd = NULL; + r300EmitState(rmesa); + + start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0); + e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_nr << 16) | primitive); +} -- cgit v1.2.3 From aaf76906e8dcad06a1af26863a6c1faf12014692 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 17 Jun 2007 14:27:58 +1000 Subject: add missing swtcl file --- src/mesa/drivers/dri/r300/r300_swtcl.h | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/mesa/drivers/dri/r300/r300_swtcl.h (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.h b/src/mesa/drivers/dri/r300/r300_swtcl.h new file mode 100644 index 00000000000..92362b745bc --- /dev/null +++ b/src/mesa/drivers/dri/r300/r300_swtcl.h @@ -0,0 +1,75 @@ +/* +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 __R300_SWTCL_H__ +#define __R300_SWTCL_H__ + +#include "mtypes.h" +#include "swrast/swrast.h" +#include "r300_context.h" + +extern void r300InitSwtcl( GLcontext *ctx ); +extern void r300DestroySwtcl( GLcontext *ctx ); + +#if 0 +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_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 + +#endif -- cgit v1.2.3 From 3b8cf84aa5019c0770ef13c571ec17f31041b25a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 17 Jun 2007 14:47:09 +1000 Subject: fixup packet setup - still hangs --- src/mesa/drivers/dri/r300/r300_emit.h | 2 ++ src/mesa/drivers/dri/r300/r300_render.c | 6 +++--- src/mesa/drivers/dri/r300/r300_swtcl.c | 31 +++++++++++++++++-------------- 3 files changed, 22 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h index 2f79ee3a23a..ce7279bbef4 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.h +++ b/src/mesa/drivers/dri/r300/r300_emit.h @@ -225,5 +225,7 @@ void r300UseArrays(GLcontext * ctx); #endif extern void r300ReleaseArrays(GLcontext * ctx); +extern int r300PrimitiveType(r300ContextPtr rmesa, int prim); +extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim); #endif diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 7770cbbacb5..7d97245281f 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -79,7 +79,7 @@ extern int future_hw_tcl_on; /** * \brief Convert a OpenGL primitive type into a R300 primitive type. */ -static int r300PrimitiveType(r300ContextPtr rmesa, GLcontext * ctx, int prim) +int r300PrimitiveType(r300ContextPtr rmesa, int prim) { switch (prim & PRIM_MODE_MASK) { case GL_POINTS: @@ -119,7 +119,7 @@ static int r300PrimitiveType(r300ContextPtr rmesa, GLcontext * ctx, int prim) } } -static int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim) +int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim) { int verts_off = 0; @@ -261,7 +261,7 @@ static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *vb = &tnl->vb; - type = r300PrimitiveType(rmesa, ctx, prim); + type = r300PrimitiveType(rmesa, prim); num_verts = r300NumVerts(rmesa, end - start, prim); if (type < 0 || num_verts <= 0) diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 7a3ddcd503f..f724a8e6f85 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -637,15 +637,15 @@ void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) int cmd_reserved = 0; int cmd_written = 0; - drm_radeon_cmd_header_t *cmd = NULL; - if (1)//RADEON_DEBUG & DEBUG_VERTS) - fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n", - __FUNCTION__, vertex_size, offset); - - start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); - e32(1); - e32(vertex_size | (vertex_size << 8)); - e32(offset); + drm_radeon_cmd_header_t *cmd = NULL; + if (1)//RADEON_DEBUG & DEBUG_VERTS) + fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n", + __FUNCTION__, vertex_size, offset); + + start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); + e32(1); + e32(vertex_size | (vertex_size << 8)); + e32(offset); } void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) @@ -653,10 +653,13 @@ void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) int cmd_reserved = 0; int cmd_written = 0; + int type, num_verts; + drm_radeon_cmd_header_t *cmd = NULL; - drm_radeon_cmd_header_t *cmd = NULL; - r300EmitState(rmesa); - - start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0); - e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_nr << 16) | primitive); + type = r300PrimitiveType(rmesa, primitive); + num_verts = r300NumVerts(rmesa, vertex_nr, primitive); + r300EmitState(rmesa); + + start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0); + e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type); } -- cgit v1.2.3 From 780ae9f17d23dc1a553e66298d223582f8a7f022 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 17 Jun 2007 15:05:43 +1000 Subject: cleaned up reduced prim --- src/mesa/drivers/dri/r300/r300_swtcl.c | 53 ++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index f724a8e6f85..fc101c3e75b 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -57,8 +57,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_emit.h" #include "r300_mem.h" +#define R300_NEWPRIM( rmesa ) \ + do { \ + if ( rmesa->dma.flush ) \ + rmesa->dma.flush( rmesa ); \ + } while (0) + static void flush_last_swtcl_prim( r300ContextPtr rmesa ); + void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset); void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr); #define EMIT_ATTR( ATTR, STYLE, F0 ) \ @@ -193,7 +200,7 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset ) || (rmesa->hw.vof.cmd[R300_VOF_CNTL_0] != vap_fmt_0) || (rmesa->hw.vof.cmd[R300_VOF_CNTL_1] != vap_fmt_1) ) { -// R200_NEWPRIM(rmesa); + R300_NEWPRIM(rmesa); R300_STATECHANGE(rmesa, vof); rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = vap_fmt_0; @@ -267,6 +274,26 @@ r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) return (rmesa->dma.current.address + rmesa->dma.current.ptr); } + +static INLINE GLuint reduced_hw_prim( GLcontext *ctx, GLuint prim) +{ + switch (prim) { + case GL_POINTS: + return R300_VAP_VF_CNTL__PRIM_POINTS; + case GL_LINES: + return R300_VAP_VF_CNTL__PRIM_LINES; + /* fallthrough */ + case GL_LINE_LOOP: + return R300_VAP_VF_CNTL__PRIM_LINE_LOOP; + /* fallthrough */ + case GL_LINE_STRIP: + return R300_VAP_VF_CNTL__PRIM_LINE_STRIP; + default: + /* all others reduced to triangles */ + return R300_VAP_VF_CNTL__PRIM_TRIANGLES; + } +} + static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ); static void r300RenderPrimitive( GLcontext *ctx, GLenum prim ); //static void r300ResetLineStipple( GLcontext *ctx ); @@ -277,20 +304,6 @@ static void r300PrintVertex(r300Vertex *v) } -static const GLenum reduced_prim[GL_POLYGON+1] = { - GL_POINTS, - GL_LINES, - GL_LINES, - GL_LINES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES, - GL_TRIANGLES -}; - - /*********************************************************************** * Emit primitives as inline vertices * ***********************************************************************/ @@ -430,7 +443,7 @@ do { \ * Helpers for rendering unfilled primitives * ***********************************************************************/ -#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] ) +#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_hw_prim(ctx, x) ) #define RENDER_PRIMITIVE rmesa->swtcl.render_primitive #undef TAG #define TAG(x) x @@ -567,7 +580,7 @@ static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ) r300ContextPtr rmesa = R300_CONTEXT(ctx); if (rmesa->swtcl.hw_primitive != hwprim) { -// R300_NEWPRIM( rmesa ); + R300_NEWPRIM( rmesa ); rmesa->swtcl.hw_primitive = hwprim; } } @@ -578,7 +591,7 @@ static void r300RenderPrimitive(GLcontext *ctx, GLenum prim) r300ContextPtr rmesa = R300_CONTEXT(ctx); rmesa->swtcl.render_primitive = prim; if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) - r300RasterPrimitive( ctx, reduced_prim[prim] ); + r300RasterPrimitive( ctx, reduced_hw_prim(ctx, prim) ); fprintf(stderr, "%s\n", __FUNCTION__); } @@ -626,10 +639,6 @@ void r300InitSwtcl(GLcontext *ctx) void r300DestroySwtcl(GLcontext *ctx) { - r300ContextPtr rmesa = R300_CONTEXT(ctx); -// if (rmesa->swtcl.indexed_verts.buf) -// r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ ); - } void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) -- cgit v1.2.3 From 492bc67df1ceefe7580e8d7129f6f11a2f11ea67 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 17 Jun 2007 15:44:42 +1000 Subject: swtcl add debug and fix offset --- src/mesa/drivers/dri/r300/r300_swtcl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index fc101c3e75b..e7c2d8f4965 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -231,7 +231,8 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) struct r300_dma_region *current = &rmesa->dma.current; // GLuint current_offset = rmesa->state.swtcl_dma.aos_offset; - GLuint current_offset = r300_mem_offset(rmesa,current->buf->id); + GLuint current_offset; + current_offset = GET_START(current); // assert (!(rmesa->swtcl.hw_primitive & R200_VF_PRIM_WALK_IND)); assert (current->start + @@ -669,6 +670,7 @@ void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) num_verts = r300NumVerts(rmesa, vertex_nr, primitive); r300EmitState(rmesa); + fprintf(stderr, "num verts is %d, type is %d\n", num_verts, type); start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0); e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type); } -- cgit v1.2.3 From 4a841b969ae0f05a4982215a0fc087be12c53e0c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 17 Jun 2007 19:55:13 +1000 Subject: more commits to fix things and stuff - still not doing anything except crashin --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 2 +- src/mesa/drivers/dri/r300/r300_swtcl.c | 55 +++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 7055286ba95..aebc895d63f 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -54,7 +54,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_state.h" // Set this to 1 for extremely verbose debugging of command buffers -#define DEBUG_CMDBUF 0 +#define DEBUG_CMDBUF 1 /** * Send the current command buffer via ioctl to the hardware. diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index e7c2d8f4965..a7acee84800 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -112,18 +112,10 @@ static void r300SetVertexFormat( GLcontext *ctx ) /* EMIT_ATTR's must be in order as they tell t_vertex.c how to * build up a hardware vertex. */ - if ( !rmesa->swtcl.needproj || - RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { /* need w coord for projected textures */ - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT); - vap_vte_cntl |= R300_VTX_XY_FMT | R300_VTX_Z_FMT | R300_VTX_W0_FMT; - - offset = 4; - } - else { - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F, R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT ); - vap_vte_cntl |= R300_VTX_XY_FMT | R300_VTX_Z_FMT; - offset = 3; - } + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT); + // vap_vte_cntl |= R300_VTX_XY_FMT | R300_VTX_Z_FMT | R300_VTX_W0_FMT; + + offset = 4; if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT); @@ -212,6 +204,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) rmesa->swtcl.vertex_attrs, rmesa->swtcl.vertex_attr_count, NULL, 0 ); + fprintf(stderr,"Vap fmt 0 %08X, 1 %08X %d \n", vap_fmt_0, vap_fmt_1, rmesa->swtcl.vertex_size); + rmesa->swtcl.vertex_size /= 4; RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); } @@ -261,18 +255,19 @@ static void * r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) { GLuint bytes = vsize * nverts; - + GLubyte *head; r300AllocDmaRegion(rmesa, &rmesa->state.swtcl_dma, bytes, 0); - + + fprintf(stderr, "Alloc DMA region %d\n", bytes); if (!rmesa->dma.flush) { rmesa->dma.flush = flush_last_swtcl_prim; rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; } - + head = (GLubyte *)(rmesa->dma.current.address + rmesa->dma.current.ptr); rmesa->swtcl.numverts += nverts; rmesa->dma.current.ptr += bytes; - return (rmesa->dma.current.address + rmesa->dma.current.ptr); + return head; } @@ -525,6 +520,19 @@ static void init_rast_tab( void ) /* Choose render functions */ /**********************************************************************/ +void r300ChooseVertexState( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + r300ContextPtr rmesa = R300_CONTEXT(ctx); + GLuint vte[2]; + _tnl_need_projected_coords( ctx, GL_FALSE ); + + vte[0] = rmesa->hw.vte.cmd[0]; + vte[1] = rmesa->hw.vte.cmd[1]; + + +} + void r300ChooseRenderState( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -636,6 +644,7 @@ void r300InitSwtcl(GLcontext *ctx) RENDERINPUTS_ZERO( rmesa->tnl_index_bitset ); r300ChooseRenderState(ctx); + // r300ChooseVertexState(ctx); } void r300DestroySwtcl(GLcontext *ctx) @@ -646,12 +655,23 @@ void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) { int cmd_reserved = 0; int cmd_written = 0; + int vte; drm_radeon_cmd_header_t *cmd = NULL; if (1)//RADEON_DEBUG & DEBUG_VERTS) fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n", __FUNCTION__, vertex_size, offset); - + + /* emit vte */ + vte = rmesa->hw.vte.cmd[1]; + if (vertex_size == 5) { + vte &= ~R300_VTX_W0_FMT; + vte |= R300_VTX_XY_FMT; + } + R300_STATECHANGE(rmesa, vte); + rmesa->hw.vte.cmd[1] = vte; + rmesa->hw.vte.cmd[2] = vertex_size; + start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); e32(1); e32(vertex_size | (vertex_size << 8)); @@ -668,6 +688,7 @@ void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) type = r300PrimitiveType(rmesa, primitive); num_verts = r300NumVerts(rmesa, vertex_nr, primitive); + r300EmitState(rmesa); fprintf(stderr, "num verts is %d, type is %d\n", num_verts, type); -- cgit v1.2.3 From 2a6082b5319a21e0af8dc30516c38f7e7d704b04 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 20 Jun 2007 18:01:47 +1000 Subject: swtcl: gears works --- src/mesa/drivers/dri/r300/r300_ioctl.c | 2 +- src/mesa/drivers/dri/r300/r300_ioctl.h | 1 + src/mesa/drivers/dri/r300/r300_swtcl.c | 295 ++++++++++++++++++--------------- 3 files changed, 161 insertions(+), 137 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 52345855fe3..664a36a78b3 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -427,7 +427,7 @@ void r300Flush(GLcontext * ctx) #ifdef USER_BUFFERS #include "r300_mem.h" -static void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size) +void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size) { struct r300_dma_buffer *dmabuf; size = MAX2(size, RADEON_BUFFER_SIZE * 16); diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.h b/src/mesa/drivers/dri/r300/r300_ioctl.h index 7a19a2cf3f9..e1143fb6c34 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.h +++ b/src/mesa/drivers/dri/r300/r300_ioctl.h @@ -56,4 +56,5 @@ extern void r300AllocDmaRegion(r300ContextPtr rmesa, extern void r300InitIoctlFuncs(struct dd_function_table *functions); +extern void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size); #endif /* __R300_IOCTL_H__ */ diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index a7acee84800..ab771aba87b 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -68,12 +68,11 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ); void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset); void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr); -#define EMIT_ATTR( ATTR, STYLE, F0 ) \ +#define EMIT_ATTR( ATTR, STYLE ) \ do { \ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR); \ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \ rmesa->swtcl.vertex_attr_count++; \ - vap_fmt_0 |= F0; \ } while (0) #define EMIT_PAD( N ) \ @@ -92,11 +91,19 @@ static void r300SetVertexFormat( GLcontext *ctx ) DECLARE_RENDERINPUTS(index_bitset); int vap_fmt_0 = 0; int vap_fmt_1 = 0; + int vic_0 = 0, vic_1 = 0; int vap_vte_cntl = 0; int offset = 0; + int vte = 0; + + DECLARE_RENDERINPUTS(render_inputs_bitset); + + RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset); RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); + RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset); + /* Important: */ if ( VB->NdcPtr != NULL ) { @@ -112,23 +119,30 @@ static void r300SetVertexFormat( GLcontext *ctx ) /* EMIT_ATTR's must be in order as they tell t_vertex.c how to * build up a hardware vertex. */ - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT); - // vap_vte_cntl |= R300_VTX_XY_FMT | R300_VTX_Z_FMT | R300_VTX_W0_FMT; - + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; + vap_vte_cntl |= R300_VTX_W0_FMT; + vic_1 |= R300_INPUT_CNTL_POS; + offset = 4; if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { - EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT); - offset += 1; + EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; + offset += 1; } rmesa->swtcl.coloroffset = offset; #if MESA_LITTLE_ENDIAN - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT ); + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); #else - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT ); + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); #endif - offset += 1; + + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; + vic_1 |= R300_INPUT_CNTL_COLOR; + vic_0 |= 1; + offset += 4; rmesa->swtcl.specoffset = 0; if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || @@ -137,21 +151,25 @@ static void r300SetVertexFormat( GLcontext *ctx ) #if MESA_LITTLE_ENDIAN if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3F ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; + vic_0 |= (1<<2); } else { EMIT_PAD( 3 ); } if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; } else { EMIT_PAD( 1 ); } #else if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; } else { EMIT_PAD( 1 ); @@ -159,7 +177,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT ); + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; } else { EMIT_PAD( 3 ); @@ -175,7 +194,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) GLuint sz = VB->TexCoordPtr[i]->size; vap_fmt_1 |= sz << (3 * i); - EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1, 0 ); + vic_1 |= 0x400 << i; + EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1 ); } } } @@ -189,25 +209,30 @@ static void r300SetVertexFormat( GLcontext *ctx ) } #endif - if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset ) || - (rmesa->hw.vof.cmd[R300_VOF_CNTL_0] != vap_fmt_0) || - (rmesa->hw.vof.cmd[R300_VOF_CNTL_1] != vap_fmt_1) ) { - R300_NEWPRIM(rmesa); - R300_STATECHANGE(rmesa, vof); - rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = - vap_fmt_0; - rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = - vap_fmt_1; + R300_STATECHANGE(rmesa, vic); + rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = 0x1; + rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = vic_1; + + R300_STATECHANGE(rmesa, vof); + rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = vap_fmt_0; + rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = vap_fmt_1; + + if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset)) { + rmesa->swtcl.vertex_size = _tnl_install_attrs( ctx, rmesa->swtcl.vertex_attrs, rmesa->swtcl.vertex_attr_count, NULL, 0 ); - fprintf(stderr,"Vap fmt 0 %08X, 1 %08X %d \n", vap_fmt_0, vap_fmt_1, rmesa->swtcl.vertex_size); rmesa->swtcl.vertex_size /= 4; RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); + + vte = rmesa->hw.vte.cmd[1]; + R300_STATECHANGE(rmesa, vte); + rmesa->hw.vte.cmd[1] = vte; + rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size; } } @@ -223,19 +248,14 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) if (rmesa->dma.current.buf) { struct r300_dma_region *current = &rmesa->dma.current; - // GLuint current_offset = rmesa->state.swtcl_dma.aos_offset; - - GLuint current_offset; - current_offset = GET_START(current); - // assert (!(rmesa->swtcl.hw_primitive & R200_VF_PRIM_WALK_IND)); + GLuint current_offset = GET_START(current); assert (current->start + rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 == current->ptr); if (rmesa->dma.current.start != rmesa->dma.current.ptr) { - // r200EnsureCmdBufSpace( rmesa, VERT_AOS_BUFSZ + - // rmesa->hw.max_state_size + VBUF_BUFSZ ); + r300EmitVertexAOS( rmesa, rmesa->swtcl.vertex_size, current_offset); @@ -250,56 +270,54 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) } } - +/* Alloc space in the current dma region. + */ static void * r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) { - GLuint bytes = vsize * nverts; - GLubyte *head; - r300AllocDmaRegion(rmesa, &rmesa->state.swtcl_dma, bytes, 0); - - fprintf(stderr, "Alloc DMA region %d\n", bytes); - if (!rmesa->dma.flush) { - rmesa->dma.flush = flush_last_swtcl_prim; - rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; - } - - head = (GLubyte *)(rmesa->dma.current.address + rmesa->dma.current.ptr); - rmesa->swtcl.numverts += nverts; - rmesa->dma.current.ptr += bytes; - return head; -} + GLuint bytes = vsize * nverts; + if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) + r300RefillCurrentDmaRegion( rmesa, bytes); -static INLINE GLuint reduced_hw_prim( GLcontext *ctx, GLuint prim) -{ - switch (prim) { - case GL_POINTS: - return R300_VAP_VF_CNTL__PRIM_POINTS; - case GL_LINES: - return R300_VAP_VF_CNTL__PRIM_LINES; - /* fallthrough */ - case GL_LINE_LOOP: - return R300_VAP_VF_CNTL__PRIM_LINE_LOOP; - /* fallthrough */ - case GL_LINE_STRIP: - return R300_VAP_VF_CNTL__PRIM_LINE_STRIP; - default: - /* all others reduced to triangles */ - return R300_VAP_VF_CNTL__PRIM_TRIANGLES; + if (!rmesa->dma.flush) { + rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; + rmesa->dma.flush = flush_last_swtcl_prim; } -} -static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ); -static void r300RenderPrimitive( GLcontext *ctx, GLenum prim ); -//static void r300ResetLineStipple( GLcontext *ctx ); + 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 ); -static void r300PrintVertex(r300Vertex *v) -{ - fprintf(stderr,"Vertex %p\n", v); + + { + GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr); + rmesa->dma.current.ptr += bytes; + rmesa->swtcl.numverts += nverts; + return head; + } } +static GLuint reduced_prim[] = { + GL_POINTS, + GL_LINES, + GL_LINES, + GL_LINES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, + GL_TRIANGLES, +}; + +static void r300RasterPrimitive( GLcontext *ctx, GLuint prim ); +static void r300RenderPrimitive( GLcontext *ctx, GLenum prim ); +//static void r300ResetLineStipple( GLcontext *ctx ); + /*********************************************************************** * Emit primitives as inline vertices * ***********************************************************************/ @@ -313,7 +331,7 @@ static void r300PrintVertex(r300Vertex *v) #define HAVE_TRI_STRIP_1 0 #define HAVE_TRI_FANS 1 #define HAVE_QUADS 0 -#define HAVE_QUAD_STRIPS 0 +#define HAVE_QUAD_STRIPS 1 #define HAVE_POLYGONS 1 #define HAVE_ELTS 1 @@ -328,7 +346,7 @@ static void r300PrintVertex(r300Vertex *v) #define VERT(x) (r300Vertex *)(r300verts + ((x) * vertsize * sizeof(int))) #define VERTEX r300Vertex #define DO_DEBUG_VERTS (1 && (RADEON_DEBUG & DEBUG_VERTS)) -#define PRINT_VERTEX(x) r300PrintVertex(x) +#define PRINT_VERTEX(x) #undef TAG #define TAG(x) r300_##x #include "tnl_dd/t_dd_triemit.h" @@ -385,42 +403,31 @@ static struct { #define AREA_IS_CCW( a ) (a < 0) #define GET_VERTEX(e) (rmesa->swtcl.verts + (e*rmesa->swtcl.vertex_size*sizeof(int))) -#define VERT_SET_RGBA( v, c ) \ -do { \ - r300_color_t *color = (r300_color_t *)&((v)->ui[coloroffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \ - UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \ +/* Only used to pull back colors into vertices (ie, we know color is + * floating point). + */ +#define R300_COLOR( dst, src ) \ +do { \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]); \ } while (0) -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] +#define VERT_SET_RGBA( v, c ) if (coloroffset) R300_COLOR( v->ub4[coloroffset], c ) +#define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset] +#define VERT_SAVE_RGBA( idx ) if (coloroffset) color[idx] = v[idx]->ui[coloroffset] +#define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx] -#define VERT_SET_SPEC( v, c ) \ -do { \ - if (specoffset) { \ - r300_color_t *spec = (r300_color_t *)&((v)->ui[specoffset]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \ - UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \ - } \ -} while (0) -#define VERT_COPY_SPEC( v0, v1 ) \ +#define R300_SPEC( dst, src ) \ do { \ - if (specoffset) { \ - r300_color_t *spec0 = (r300_color_t *)&((v0)->ui[specoffset]); \ - r300_color_t *spec1 = (r300_color_t *)&((v1)->ui[specoffset]); \ - spec0->red = spec1->red; \ - spec0->green = spec1->green; \ - spec0->blue = spec1->blue; \ - } \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \ + UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \ } while (0) -/* These don't need LE32_TO_CPU() as they used to save and restore - * colors which are already in the correct format. - */ -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] +#define VERT_SET_SPEC( v, c ) if (specoffset) R300_SPEC( v->ub4[specoffset], c ) +#define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset]) #define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset] #define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx] @@ -439,7 +446,7 @@ do { \ * Helpers for rendering unfilled primitives * ***********************************************************************/ -#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_hw_prim(ctx, x) ) +#define RASTERIZE(x) r300RasterPrimitive( ctx, reduced_prim[x] ) #define RENDER_PRIMITIVE rmesa->swtcl.render_primitive #undef TAG #define TAG(x) x @@ -469,6 +476,7 @@ do { \ #include "tnl_dd/t_dd_tritmp.h" + static void init_rast_tab( void ) { init(); @@ -491,7 +499,7 @@ static void init_rast_tab( void ) #define RENDER_QUAD( v0, v1, v2, v3 ) \ r300_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) #define INIT(x) do { \ - r300RenderPrimitive( ctx, x ); \ + r300RenderPrimitive( ctx, reduced_prim[x] ); \ } while (0) #undef LOCAL_VARS #define LOCAL_VARS \ @@ -519,21 +527,7 @@ static void init_rast_tab( void ) /**********************************************************************/ /* Choose render functions */ /**********************************************************************/ - -void r300ChooseVertexState( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - r300ContextPtr rmesa = R300_CONTEXT(ctx); - GLuint vte[2]; - _tnl_need_projected_coords( ctx, GL_FALSE ); - - vte[0] = rmesa->hw.vte.cmd[0]; - vte[1] = rmesa->hw.vte.cmd[1]; - - -} - -void r300ChooseRenderState( GLcontext *ctx ) +static void r300ChooseRenderState( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); r300ContextPtr rmesa = R300_CONTEXT(ctx); @@ -571,9 +565,23 @@ void r300ChooseRenderState( GLcontext *ctx ) static void r300RenderStart(GLcontext *ctx) { r300ContextPtr rmesa = R300_CONTEXT( ctx ); - fprintf(stderr, "%s\n", __FUNCTION__); + int cmd_reserved = 0; + int cmd_written = 0; + drm_radeon_cmd_header_t *cmd = NULL; + // fprintf(stderr, "%s\n", __FUNCTION__); + r300SetVertexFormat(ctx); + + r300UpdateShaderStates(rmesa); + + reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); + e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); + + reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); + e32(R300_RB3D_ZCACHE_UNKNOWN_03); + + if (rmesa->dma.flush != 0 && rmesa->dma.flush != flush_last_swtcl_prim) rmesa->dma.flush( rmesa ); @@ -581,7 +589,16 @@ static void r300RenderStart(GLcontext *ctx) static void r300RenderFinish(GLcontext *ctx) { - fprintf(stderr, "%s\n", __FUNCTION__); + r300ContextPtr rmesa = R300_CONTEXT( ctx ); + int cmd_reserved = 0; + int cmd_written = 0; + drm_radeon_cmd_header_t *cmd = NULL; + + reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); + e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); + + reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); + e32(R300_RB3D_ZCACHE_UNKNOWN_03); } static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ) @@ -600,8 +617,8 @@ static void r300RenderPrimitive(GLcontext *ctx, GLenum prim) r300ContextPtr rmesa = R300_CONTEXT(ctx); rmesa->swtcl.render_primitive = prim; if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) - r300RasterPrimitive( ctx, reduced_hw_prim(ctx, prim) ); - fprintf(stderr, "%s\n", __FUNCTION__); + r300RasterPrimitive( ctx, prim ); + // fprintf(stderr, "%s\n", __FUNCTION__); } @@ -632,7 +649,7 @@ void r300InitSwtcl(GLcontext *ctx) /* FIXME: what are these numbers? */ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, - 36 * sizeof(GLfloat) ); + 48 * sizeof(GLfloat) ); rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf; rmesa->swtcl.RenderIndex = ~0; @@ -643,8 +660,8 @@ void r300InitSwtcl(GLcontext *ctx) _tnl_invalidate_vertices( ctx, ~0 ); RENDERINPUTS_ZERO( rmesa->tnl_index_bitset ); + _tnl_need_projected_coords( ctx, GL_FALSE ); r300ChooseRenderState(ctx); - // r300ChooseVertexState(ctx); } void r300DestroySwtcl(GLcontext *ctx) @@ -656,21 +673,28 @@ void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) int cmd_reserved = 0; int cmd_written = 0; int vte; + int route0; drm_radeon_cmd_header_t *cmd = NULL; - if (1)//RADEON_DEBUG & DEBUG_VERTS) + if (RADEON_DEBUG & DEBUG_VERTS) fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n", __FUNCTION__, vertex_size, offset); /* emit vte */ - vte = rmesa->hw.vte.cmd[1]; - if (vertex_size == 5) { - vte &= ~R300_VTX_W0_FMT; - vte |= R300_VTX_XY_FMT; - } - R300_STATECHANGE(rmesa, vte); - rmesa->hw.vte.cmd[1] = vte; - rmesa->hw.vte.cmd[2] = vertex_size; + + R300_STATECHANGE(rmesa, vir[0]); + ((drm_r300_cmd_header_t *)rmesa->hw.vir[0].cmd)->packet0.count = 1; + rmesa->hw.vir[0].cmd[1] = 0x22030003; + + R300_STATECHANGE(rmesa, vir[1]); + ((drm_r300_cmd_header_t *)rmesa->hw.vir[1].cmd)->packet0.count = 1; + + route0 = (R300_INPUT_ROUTE_SELECT_X | + (R300_INPUT_ROUTE_SELECT_Y << R300_INPUT_ROUTE_Y_SHIFT) | + (R300_INPUT_ROUTE_SELECT_Z << R300_INPUT_ROUTE_Z_SHIFT) | + (R300_INPUT_ROUTE_SELECT_W << R300_INPUT_ROUTE_W_SHIFT) |(R300_INPUT_ROUTE_ENABLE)); + + rmesa->hw.vir[1].cmd[1] = route0 | (route0 << 16); start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); e32(1); @@ -691,7 +715,6 @@ void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) r300EmitState(rmesa); - fprintf(stderr, "num verts is %d, type is %d\n", num_verts, type); start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0); e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type); } -- cgit v1.2.3 From d7777f45981bf91d2cb31502ba078312b1b4cf13 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 20 Jun 2007 18:02:08 +1000 Subject: fixup some bits of tcl path --- src/mesa/drivers/dri/r300/r300_emit.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index e8f0f89cf3f..adeb688d198 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -217,14 +217,14 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[i]] << 8) | (attribptr[tab[i]]->size - 1); dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16; if (i + 2 == nr) { - dw |= (1 << (13 + 16)); + dw |= (R300_VAP_INPUT_ROUTE_END << 16); } dst[i >> 1] = dw; } if (nr & 1) { dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[nr - 1]] << 8) | (attribptr[tab[nr - 1]]->size - 1); - dw |= 1 << 13; + dw |= R300_VAP_INPUT_ROUTE_END; dst[nr >> 1] = dw; } @@ -394,20 +394,18 @@ int r300EmitArrays(GLcontext * ctx) } } - if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) { - /* Fixed, apply to vir0 only */ - memcpy(vir_inputs, inputs, VERT_ATTRIB_MAX * sizeof(int)); - inputs = vir_inputs; - if (InputsRead & VERT_ATTRIB_POS) - inputs[VERT_ATTRIB_POS] = 0; - if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) - inputs[VERT_ATTRIB_COLOR0] = 2; - if (InputsRead & (1 << VERT_ATTRIB_COLOR1)) - inputs[VERT_ATTRIB_COLOR1] = 3; - for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) - if (InputsRead & (1 << i)) - inputs[i] = 6 + (i - VERT_ATTRIB_TEX0); - } + /* Fixed, apply to vir0 only */ + memcpy(vir_inputs, inputs, VERT_ATTRIB_MAX * sizeof(int)); + inputs = vir_inputs; + if (InputsRead & VERT_ATTRIB_POS) + inputs[VERT_ATTRIB_POS] = 0; + if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) + inputs[VERT_ATTRIB_COLOR0] = 2; + if (InputsRead & (1 << VERT_ATTRIB_COLOR1)) + inputs[VERT_ATTRIB_COLOR1] = 3; + for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) + if (InputsRead & (1 << i)) + inputs[i] = 6 + (i - VERT_ATTRIB_TEX0); RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset); } -- cgit v1.2.3 From 08fb0bad728a445adf8eaf4f3978ba9a41b69947 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 10:19:00 +1000 Subject: bring over vertex engine setup code from r300_Render and fix up now have gears going.. + a few other trivial textured demoes --- src/mesa/drivers/dri/r300/r300_swtcl.c | 225 ++++++++++++++++++++++++++++----- 1 file changed, 191 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index ab771aba87b..cf2e4b6e338 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -83,18 +83,142 @@ do { \ rmesa->swtcl.vertex_attr_count++; \ } while (0) +static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, + int *inputs, GLint * tab, GLuint nr) +{ + GLuint i, dw; + + /* type, inputs, stop bit, size */ + for (i = 0; i + 1 < nr; i += 2) { + dw = (inputs[tab[i]] << 8) | 0x3; + dw |= ((inputs[tab[i + 1]] << 8) | 0x3) << 16; + if (i + 2 == nr) { + dw |= (R300_VAP_INPUT_ROUTE_END << 16); + } + dst[i >> 1] = dw; + } + + if (nr & 1) { + dw = (inputs[tab[nr - 1]] << 8) | 0x3; + dw |= R300_VAP_INPUT_ROUTE_END; + dst[nr >> 1] = dw; + } + + return (nr + 1) >> 1; +} + +static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]) +{ + return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) | + (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) | + (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) | + (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); +} + +static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) +{ + GLuint i; + + for (i = 0; i + 1 < nr; i += 2) { + dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE; + dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16; + } + + if (nr & 1) { + dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE; + } + + return (nr + 1) >> 1; +} + +static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) +{ + /* No idea what this value means. I have seen other values written to + * this register... */ + return 0x5555; +} + +static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) +{ + r300ContextPtr rmesa = R300_CONTEXT(ctx); + GLuint i, vic_1 = 0; + + if (InputsRead & (1 << VERT_ATTRIB_POS)) + vic_1 |= R300_INPUT_CNTL_POS; + + if (InputsRead & (1 << VERT_ATTRIB_NORMAL)) + vic_1 |= R300_INPUT_CNTL_NORMAL; + + if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) + vic_1 |= R300_INPUT_CNTL_COLOR; + + rmesa->state.texture.tc_count = 0; + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) + if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) { + rmesa->state.texture.tc_count++; + vic_1 |= R300_INPUT_CNTL_TC0 << i; + } + + return vic_1; +} + +static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) +{ + GLuint ret = 0; + + if (OutputsWritten & (1 << VERT_RESULT_HPOS)) + ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; + + if (OutputsWritten & (1 << VERT_RESULT_COL0)) + ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; + + if (OutputsWritten & (1 << VERT_RESULT_COL1)) + ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; + +#if 0 + if (OutputsWritten & (1 << VERT_RESULT_BFC0)) + ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT; + + if (OutputsWritten & (1 << VERT_RESULT_BFC1)) + ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; + + if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; +#endif + + if (OutputsWritten & (1 << VERT_RESULT_PSIZ)) + ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; + + return ret; +} + +static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) +{ + GLuint i, ret = 0; + + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) { + ret |= (4 << (3 * i)); + } + } + + return ret; +} + static void r300SetVertexFormat( GLcontext *ctx ) { r300ContextPtr rmesa = R300_CONTEXT( ctx ); TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; DECLARE_RENDERINPUTS(index_bitset); + GLuint InputsRead = 0, OutputsWritten = 0; int vap_fmt_0 = 0; - int vap_fmt_1 = 0; - int vic_0 = 0, vic_1 = 0; int vap_vte_cntl = 0; int offset = 0; int vte = 0; + GLuint inputs[VERT_ATTRIB_MAX]; + GLint tab[VERT_ATTRIB_MAX]; + int swizzle[VERT_ATTRIB_MAX][4]; + GLuint i, nr; DECLARE_RENDERINPUTS(render_inputs_bitset); @@ -120,10 +244,9 @@ static void r300SetVertexFormat( GLcontext *ctx ) * build up a hardware vertex. */ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F ); - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; vap_vte_cntl |= R300_VTX_W0_FMT; - vic_1 |= R300_INPUT_CNTL_POS; - + InputsRead |= 1 << VERT_ATTRIB_POS; + OutputsWritten |= 1 << VERT_RESULT_HPOS; offset = 4; if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { @@ -139,9 +262,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); #endif - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; - vic_1 |= R300_INPUT_CNTL_COLOR; - vic_0 |= 1; + InputsRead |= 1 << VERT_ATTRIB_COLOR0; + OutputsWritten |= 1 << VERT_RESULT_COL0; offset += 4; rmesa->swtcl.specoffset = 0; @@ -152,8 +274,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3F ); - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; - vic_0 |= (1<<2); + InputsRead |= 1 << VERT_ATTRIB_COLOR1; + OutputsWritten |= 1 << VERT_RESULT_COL1; } else { EMIT_PAD( 3 ); @@ -161,7 +283,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; + InputsRead |= 1 << VERT_ATTRIB_COLOR1; + OutputsWritten |= 1 << VERT_RESULT_COL1; } else { EMIT_PAD( 1 ); @@ -169,7 +292,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) #else if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; + InputsRead |= 1 << VERT_ATTRIB_COLOR1; + OutputsWritten |= 1 << VERT_RESULT_COL1; } else { EMIT_PAD( 1 ); @@ -178,7 +302,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR ); - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; + InputsRead |= 1 << VERT_ATTRIB_COLOR1; + OutputsWritten |= 1 << VERT_RESULT_COL1; } else { EMIT_PAD( 3 ); @@ -193,9 +318,9 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { GLuint sz = VB->TexCoordPtr[i]->size; - vap_fmt_1 |= sz << (3 * i); - vic_1 |= 0x400 << i; - EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1 ); + InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i); + OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i); + EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F ); } } } @@ -209,14 +334,60 @@ static void r300SetVertexFormat( GLcontext *ctx ) } #endif + for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { + if (InputsRead & (1 << i)) { + inputs[i] = nr++; + } else { + inputs[i] = -1; + } + } + + /* Fixed, apply to vir0 only */ + if (InputsRead & VERT_ATTRIB_POS) + inputs[VERT_ATTRIB_POS] = 0; + if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) + inputs[VERT_ATTRIB_COLOR0] = 2; + if (InputsRead & (1 << VERT_ATTRIB_COLOR1)) + inputs[VERT_ATTRIB_COLOR1] = 3; + for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) + if (InputsRead & (1 << i)) + inputs[i] = 6 + (i - VERT_ATTRIB_TEX0); + + for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { + if (InputsRead & (1 << i)) { + tab[nr++] = i; + } + } + + for (i = 0; i < nr; i++) { + int ci, fix, found = 0; + + swizzle[i][0] = SWIZZLE_ZERO; + swizzle[i][1] = SWIZZLE_ZERO; + swizzle[i][2] = SWIZZLE_ZERO; + swizzle[i][3] = SWIZZLE_ONE; + + for (ci = 0; ci < VB->AttribPtr[tab[i]]->size; ci++) { + swizzle[i][ci] = ci; + } + } + + R300_STATECHANGE(rmesa, vir[0]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = + r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], + VB->AttribPtr, inputs, tab, nr); + R300_STATECHANGE(rmesa, vir[1]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = + r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, + nr); R300_STATECHANGE(rmesa, vic); - rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = 0x1; - rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = vic_1; + rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); + rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); R300_STATECHANGE(rmesa, vof); - rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = vap_fmt_0; - rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = vap_fmt_1; + rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); + rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset)) { @@ -682,20 +853,6 @@ void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) /* emit vte */ - R300_STATECHANGE(rmesa, vir[0]); - ((drm_r300_cmd_header_t *)rmesa->hw.vir[0].cmd)->packet0.count = 1; - rmesa->hw.vir[0].cmd[1] = 0x22030003; - - R300_STATECHANGE(rmesa, vir[1]); - ((drm_r300_cmd_header_t *)rmesa->hw.vir[1].cmd)->packet0.count = 1; - - route0 = (R300_INPUT_ROUTE_SELECT_X | - (R300_INPUT_ROUTE_SELECT_Y << R300_INPUT_ROUTE_Y_SHIFT) | - (R300_INPUT_ROUTE_SELECT_Z << R300_INPUT_ROUTE_Z_SHIFT) | - (R300_INPUT_ROUTE_SELECT_W << R300_INPUT_ROUTE_W_SHIFT) |(R300_INPUT_ROUTE_ENABLE)); - - rmesa->hw.vir[1].cmd[1] = route0 | (route0 << 16); - start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); e32(1); e32(vertex_size | (vertex_size << 8)); -- cgit v1.2.3 From ad8abf71472ac7d8f25764e7a235ce97cf2fa700 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 10:32:39 +1000 Subject: fix quad-clip --- src/mesa/drivers/dri/r300/r300_swtcl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index cf2e4b6e338..3b4e92cd042 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -502,7 +502,7 @@ static void r300RenderPrimitive( GLcontext *ctx, GLenum prim ); #define HAVE_TRI_STRIP_1 0 #define HAVE_TRI_FANS 1 #define HAVE_QUADS 0 -#define HAVE_QUAD_STRIPS 1 +#define HAVE_QUAD_STRIPS 0 #define HAVE_POLYGONS 1 #define HAVE_ELTS 1 @@ -670,7 +670,7 @@ static void init_rast_tab( void ) #define RENDER_QUAD( v0, v1, v2, v3 ) \ r300_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) #define INIT(x) do { \ - r300RenderPrimitive( ctx, reduced_prim[x] ); \ + r300RenderPrimitive( ctx, x ); \ } while (0) #undef LOCAL_VARS #define LOCAL_VARS \ @@ -788,7 +788,7 @@ static void r300RenderPrimitive(GLcontext *ctx, GLenum prim) r300ContextPtr rmesa = R300_CONTEXT(ctx); rmesa->swtcl.render_primitive = prim; if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) - r300RasterPrimitive( ctx, prim ); + r300RasterPrimitive( ctx, reduced_prim[prim] ); // fprintf(stderr, "%s\n", __FUNCTION__); } -- cgit v1.2.3 From 6d8a4312ed0a05c104205236ac1eec69ac457116 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 10:50:27 +1000 Subject: fix projtex --- src/mesa/drivers/dri/r300/r300_swtcl.c | 39 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 3b4e92cd042..c4c928f374f 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -372,25 +372,25 @@ static void r300SetVertexFormat( GLcontext *ctx ) } } - R300_STATECHANGE(rmesa, vir[0]); - ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = - r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], - VB->AttribPtr, inputs, tab, nr); - R300_STATECHANGE(rmesa, vir[1]); - ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = - r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, - nr); - - R300_STATECHANGE(rmesa, vic); - rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); - rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); - - R300_STATECHANGE(rmesa, vof); - rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); - rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); - if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset)) { - + R300_NEWPRIM(rmesa); + R300_STATECHANGE(rmesa, vir[0]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = + r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], + VB->AttribPtr, inputs, tab, nr); + R300_STATECHANGE(rmesa, vir[1]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = + r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, + nr); + + R300_STATECHANGE(rmesa, vic); + rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); + rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); + + R300_STATECHANGE(rmesa, vof); + rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); + rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); + rmesa->swtcl.vertex_size = _tnl_install_attrs( ctx, rmesa->swtcl.vertex_attrs, @@ -398,6 +398,7 @@ static void r300SetVertexFormat( GLcontext *ctx ) NULL, 0 ); rmesa->swtcl.vertex_size /= 4; + RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); vte = rmesa->hw.vte.cmd[1]; @@ -752,10 +753,10 @@ static void r300RenderStart(GLcontext *ctx) reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); e32(R300_RB3D_ZCACHE_UNKNOWN_03); - if (rmesa->dma.flush != 0 && rmesa->dma.flush != flush_last_swtcl_prim) rmesa->dma.flush( rmesa ); + } static void r300RenderFinish(GLcontext *ctx) -- cgit v1.2.3 From 025efae411a8146a9766aa863d7baee13c2c79aa Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 10:59:11 +1000 Subject: fix secondary color, fog is off for now --- src/mesa/drivers/dri/r300/r300_swtcl.c | 51 ++++++---------------------------- 1 file changed, 9 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index c4c928f374f..1eb485f7389 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -256,11 +256,10 @@ static void r300SetVertexFormat( GLcontext *ctx ) } rmesa->swtcl.coloroffset = offset; -#if MESA_LITTLE_ENDIAN - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); -#else - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); -#endif + if (_mesa_little_endian()) + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); + else + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); InputsRead |= 1 << VERT_ATTRIB_COLOR0; OutputsWritten |= 1 << VERT_RESULT_COL0; @@ -270,45 +269,22 @@ static void r300SetVertexFormat( GLcontext *ctx ) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { -#if MESA_LITTLE_ENDIAN + if (_mesa_little_endian()) { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3F ); + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F ); InputsRead |= 1 << VERT_ATTRIB_COLOR1; OutputsWritten |= 1 << VERT_RESULT_COL1; } - else { - EMIT_PAD( 3 ); - } - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); - InputsRead |= 1 << VERT_ATTRIB_COLOR1; - OutputsWritten |= 1 << VERT_RESULT_COL1; - } - else { - EMIT_PAD( 1 ); - } -#else - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F ); - InputsRead |= 1 << VERT_ATTRIB_COLOR1; - OutputsWritten |= 1 << VERT_RESULT_COL1; - } - else { - EMIT_PAD( 1 ); - } + } else { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR ); + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F ); InputsRead |= 1 << VERT_ATTRIB_COLOR1; OutputsWritten |= 1 << VERT_RESULT_COL1; } - else { - EMIT_PAD( 3 ); - } -#endif + } } if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { @@ -325,15 +301,6 @@ static void r300SetVertexFormat( GLcontext *ctx ) } } -#if 0 - if ( (rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK) - != R200_FOG_USE_SPEC_ALPHA ) { - R200_STATECHANGE( rmesa, ctx ); - rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK; - rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_SPEC_ALPHA; - } -#endif - for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { if (InputsRead & (1 << i)) { inputs[i] = nr++; -- cgit v1.2.3 From d1be4ab80fc266ba6792ef1151d4bdf804cff92a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 14:20:33 +1000 Subject: fix up vertex emission before state change --- src/mesa/drivers/dri/r300/r300_state.h | 7 +++++++ src/mesa/drivers/dri/r300/r300_swtcl.c | 23 ++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.h b/src/mesa/drivers/dri/r300/r300_state.h index 21a49b7f361..365f7ecd0c6 100644 --- a/src/mesa/drivers/dri/r300/r300_state.h +++ b/src/mesa/drivers/dri/r300/r300_state.h @@ -37,8 +37,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_context.h" +#define R300_NEWPRIM( rmesa ) \ + do { \ + if ( rmesa->dma.flush ) \ + rmesa->dma.flush( rmesa ); \ + } while (0) + #define R300_STATECHANGE(r300, atom) \ do { \ + R300_NEWPRIM(r300); \ r300->hw.atom.dirty = GL_TRUE; \ r300->hw.is_dirty = GL_TRUE; \ } while(0) diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 1eb485f7389..ab85be37f03 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -57,12 +57,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_emit.h" #include "r300_mem.h" -#define R300_NEWPRIM( rmesa ) \ - do { \ - if ( rmesa->dma.flush ) \ - rmesa->dma.flush( rmesa ); \ - } while (0) - static void flush_last_swtcl_prim( r300ContextPtr rmesa ); @@ -215,7 +209,7 @@ static void r300SetVertexFormat( GLcontext *ctx ) int vap_vte_cntl = 0; int offset = 0; int vte = 0; - GLuint inputs[VERT_ATTRIB_MAX]; + GLint inputs[VERT_ATTRIB_MAX]; GLint tab[VERT_ATTRIB_MAX]; int swizzle[VERT_ATTRIB_MAX][4]; GLuint i, nr; @@ -256,10 +250,7 @@ static void r300SetVertexFormat( GLcontext *ctx ) } rmesa->swtcl.coloroffset = offset; - if (_mesa_little_endian()) - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); - else - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); InputsRead |= 1 << VERT_ATTRIB_COLOR0; OutputsWritten |= 1 << VERT_RESULT_COL0; @@ -292,8 +283,6 @@ static void r300SetVertexFormat( GLcontext *ctx ) for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { - GLuint sz = VB->TexCoordPtr[i]->size; - InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i); OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i); EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F ); @@ -327,8 +316,8 @@ static void r300SetVertexFormat( GLcontext *ctx ) } for (i = 0; i < nr; i++) { - int ci, fix, found = 0; - + int ci; + swizzle[i][0] = SWIZZLE_ZERO; swizzle[i][1] = SWIZZLE_ZERO; swizzle[i][2] = SWIZZLE_ZERO; @@ -811,16 +800,12 @@ void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, GLuint offset) { int cmd_reserved = 0; int cmd_written = 0; - int vte; - int route0; drm_radeon_cmd_header_t *cmd = NULL; if (RADEON_DEBUG & DEBUG_VERTS) fprintf(stderr, "%s: vertex_size %d, offset 0x%x \n", __FUNCTION__, vertex_size, offset); - /* emit vte */ - start_packet3(CP_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2), 2); e32(1); e32(vertex_size | (vertex_size << 8)); -- cgit v1.2.3 From d3ef71166d032d1f77f0d83eaca76fbf612ac79c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 14:43:53 +1000 Subject: ensure cmd buffer space --- src/mesa/drivers/dri/r300/r300_swtcl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index ab85be37f03..dfa02f95232 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -384,6 +384,7 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) if (rmesa->dma.current.start != rmesa->dma.current.ptr) { + r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (8*sizeof(int)), __FUNCTION__); r300EmitVertexAOS( rmesa, rmesa->swtcl.vertex_size, current_offset); -- cgit v1.2.3 From faab84cfa6576a166c93d92e3faf3f3582a3a4bd Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 15:07:31 +1000 Subject: fix unfilled tris/quads --- src/mesa/drivers/dri/r300/r300_swtcl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index dfa02f95232..97f1583abdd 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -699,7 +699,8 @@ static void r300RenderStart(GLcontext *ctx) drm_radeon_cmd_header_t *cmd = NULL; // fprintf(stderr, "%s\n", __FUNCTION__); - + + r300ChooseRenderState(ctx); r300SetVertexFormat(ctx); r300UpdateShaderStates(rmesa); @@ -745,8 +746,11 @@ static void r300RenderPrimitive(GLcontext *ctx, GLenum prim) r300ContextPtr rmesa = R300_CONTEXT(ctx); rmesa->swtcl.render_primitive = prim; - if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED)) - r300RasterPrimitive( ctx, reduced_prim[prim] ); + + if ((prim == GL_TRIANGLES) && (ctx->_TriangleCaps & DD_TRI_UNFILLED)) + return; + + r300RasterPrimitive( ctx, reduced_prim[prim] ); // fprintf(stderr, "%s\n", __FUNCTION__); } -- cgit v1.2.3 From 36235e5ff169985e010659f0e5af0ab9bf6bbf3d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 18:35:00 +1000 Subject: add a mem use for current dma buffer --- src/mesa/drivers/dri/r300/r300_ioctl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 664a36a78b3..f7a44832e9b 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -439,9 +439,12 @@ void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size) rmesa->dma.flush(rmesa); } - if (rmesa->dma.current.buf) + if (rmesa->dma.current.buf) { +#ifdef USER_BUFFERS + r300_mem_use(rmesa, rmesa->dma.current.buf->id); +#endif r300ReleaseDmaRegion(rmesa, &rmesa->dma.current, __FUNCTION__); - + } if (rmesa->dma.nr_released_bufs > 4) r300FlushCmdBuf(rmesa, __FUNCTION__); -- cgit v1.2.3 From 41d28d97f5916ff1bdaae525c4de0e53e2dc470c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 21 Jun 2007 18:35:25 +1000 Subject: clean up color0 code --- src/mesa/drivers/dri/r300/r300_swtcl.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 97f1583abdd..35b0235aa14 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -257,25 +257,11 @@ static void r300SetVertexFormat( GLcontext *ctx ) offset += 4; rmesa->swtcl.specoffset = 0; - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) || - RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { - - if (_mesa_little_endian()) { - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { - rmesa->swtcl.specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F ); - InputsRead |= 1 << VERT_ATTRIB_COLOR1; - OutputsWritten |= 1 << VERT_RESULT_COL1; - } - - } else { - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { rmesa->swtcl.specoffset = offset; EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F ); InputsRead |= 1 << VERT_ATTRIB_COLOR1; OutputsWritten |= 1 << VERT_RESULT_COL1; - } - } } if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { -- cgit v1.2.3 From 93becd8a18f6ccf2f86e506ee36fc0bb75787c29 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 21 Jun 2007 16:04:02 -0600 Subject: fix rgba pointer bug hit on zoomed+fogged glDrawPixels --- src/mesa/swrast/s_span.c | 7 +++++-- src/mesa/swrast/s_zoom.c | 17 +++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 431629efb1f..9777391ded2 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1150,6 +1150,7 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output) span->end, span->array->mask); span->array->ChanType = newType; + span->array->rgba = dst; } @@ -1234,7 +1235,8 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) const GLbitfield origInterpMask = span->interpMask; const GLbitfield origArrayMask = span->arrayMask; const GLbitfield origArrayAttribs = span->arrayAttribs; - const GLenum chanType = span->array->ChanType; + const GLenum origChanType = span->array->ChanType; + void * const origRgba = span->array->rgba; const GLboolean shader = (ctx->FragmentProgram._Current || ctx->ATIFragmentShader._Enabled); const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledUnits; @@ -1456,7 +1458,8 @@ end: span->interpMask = origInterpMask; span->arrayMask = origArrayMask; span->arrayAttribs = origArrayAttribs; - span->array->ChanType = chanType; + span->array->ChanType = origChanType; + span->array->rgba = origRgba; } diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 1ab5911f2f1..ab02e3fbb35 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -153,16 +153,13 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, zoomed.end = zoomedWidth; zoomed.array = &zoomed_arrays; zoomed_arrays.ChanType = span->array->ChanType; - /* XXX temporary */ -#if CHAN_TYPE == GL_UNSIGNED_BYTE - zoomed_arrays.rgba = zoomed_arrays.rgba8; -#elif CHAN_TYPE == GL_UNSIGNED_SHORT - zoomed_arrays.rgba = zoomed_arrays.rgba16; -#else - zoomed_arrays.rgba = zoomed_arrays.attribs[FRAG_ATTRIB_COL0]; -#endif - - /* copy attribute info (XXX copy all attribs?) */ + if (zoomed_arrays.ChanType == GL_UNSIGNED_BYTE) + zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba8; + else if (zoomed_arrays.ChanType == GL_UNSIGNED_SHORT) + zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba16; + else + zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.attribs[FRAG_ATTRIB_COL0]; + COPY_4V(zoomed.attrStart[FRAG_ATTRIB_WPOS], span->attrStart[FRAG_ATTRIB_WPOS]); COPY_4V(zoomed.attrStepX[FRAG_ATTRIB_WPOS], span->attrStepX[FRAG_ATTRIB_WPOS]); COPY_4V(zoomed.attrStepY[FRAG_ATTRIB_WPOS], span->attrStepY[FRAG_ATTRIB_WPOS]); -- cgit v1.2.3 From 0f7f6e4e9586b792548349567ba1646fcf1cac44 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 22 Jun 2007 19:18:04 +1000 Subject: clean up cache flush emission into one place makes gears work with swtcl --- src/mesa/drivers/dri/r300/r300_emit.c | 16 ++++++++++++++++ src/mesa/drivers/dri/r300/r300_emit.h | 1 + src/mesa/drivers/dri/r300/r300_ioctl.c | 6 +----- src/mesa/drivers/dri/r300/r300_render.c | 16 ++-------------- src/mesa/drivers/dri/r300/r300_swtcl.c | 26 +++++--------------------- 5 files changed, 25 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index adeb688d198..a7763bd76e6 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -532,3 +532,19 @@ void r300ReleaseArrays(GLcontext * ctx) r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__); } } + +void r300EmitCacheFlush(r300ContextPtr rmesa) +{ + int cmd_reserved = 0; + int cmd_written = 0; + + drm_radeon_cmd_header_t *cmd = NULL; + + reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); + e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); + + reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); + e32(R300_RB3D_ZCACHE_UNKNOWN_03); + + +} diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h index ce7279bbef4..400e97f6f85 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.h +++ b/src/mesa/drivers/dri/r300/r300_emit.h @@ -228,4 +228,5 @@ extern void r300ReleaseArrays(GLcontext * ctx); extern int r300PrimitiveType(r300ContextPtr rmesa, int prim); extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim); +extern void r300EmitCacheFlush(r300ContextPtr rmesa); #endif diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index f7a44832e9b..1001c4ec073 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -172,11 +172,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer) cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]); cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]); - reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); - e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); - - reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); - e32(R300_RB3D_ZCACHE_UNKNOWN_03); + r300EmitCacheFlush(rmesa); cp_wait(rmesa, R300_WAIT_3D | R300_WAIT_3D_CLEAN); } diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 7d97245281f..db935795c79 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -287,9 +287,6 @@ static GLboolean r300RunRender(GLcontext * ctx, { r300ContextPtr rmesa = R300_CONTEXT(ctx); int i; - int cmd_reserved = 0; - int cmd_written = 0; - drm_radeon_cmd_header_t *cmd = NULL; TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *vb = &tnl->vb; @@ -303,12 +300,7 @@ static GLboolean r300RunRender(GLcontext * ctx, r300UpdateShaderStates(rmesa); - reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); - e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); - - reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); - e32(R300_RB3D_ZCACHE_UNKNOWN_03); - + r300EmitCacheFlush(rmesa); r300EmitState(rmesa); for (i = 0; i < vb->PrimitiveCount; i++) { @@ -318,11 +310,7 @@ static GLboolean r300RunRender(GLcontext * ctx, r300RunRenderPrimitive(rmesa, ctx, start, end, prim); } - reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); - e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); - - reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); - e32(R300_RB3D_ZCACHE_UNKNOWN_03); + r300EmitCacheFlush(rmesa); #ifdef USER_BUFFERS r300UseArrays(ctx); diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 35b0235aa14..e340f0b6e33 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -370,7 +370,7 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) if (rmesa->dma.current.start != rmesa->dma.current.ptr) { - r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (8*sizeof(int)), __FUNCTION__); + r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__); r300EmitVertexAOS( rmesa, rmesa->swtcl.vertex_size, current_offset); @@ -378,6 +378,8 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) r300EmitVbufPrim( rmesa, rmesa->swtcl.hw_primitive, rmesa->swtcl.numverts); + + r300EmitCacheFlush(rmesa); } rmesa->swtcl.numverts = 0; @@ -679,11 +681,7 @@ static void r300ChooseRenderState( GLcontext *ctx ) static void r300RenderStart(GLcontext *ctx) { - r300ContextPtr rmesa = R300_CONTEXT( ctx ); - int cmd_reserved = 0; - int cmd_written = 0; - drm_radeon_cmd_header_t *cmd = NULL; - + r300ContextPtr rmesa = R300_CONTEXT( ctx ); // fprintf(stderr, "%s\n", __FUNCTION__); r300ChooseRenderState(ctx); @@ -691,11 +689,7 @@ static void r300RenderStart(GLcontext *ctx) r300UpdateShaderStates(rmesa); - reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); - e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); - - reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); - e32(R300_RB3D_ZCACHE_UNKNOWN_03); + r300EmitCacheFlush(rmesa); if (rmesa->dma.flush != 0 && rmesa->dma.flush != flush_last_swtcl_prim) @@ -705,16 +699,6 @@ static void r300RenderStart(GLcontext *ctx) static void r300RenderFinish(GLcontext *ctx) { - r300ContextPtr rmesa = R300_CONTEXT( ctx ); - int cmd_reserved = 0; - int cmd_written = 0; - drm_radeon_cmd_header_t *cmd = NULL; - - reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0); - e32(R300_RB3D_DSTCACHE_UNKNOWN_0A); - - reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0); - e32(R300_RB3D_ZCACHE_UNKNOWN_03); } static void r300RasterPrimitive( GLcontext *ctx, GLuint hwprim ) -- cgit v1.2.3 From 1bf507656921f216a69599143f1aef9bbb170b4e Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 22 Jun 2007 08:02:46 -0600 Subject: Fix feedback color bug #11332. In feedback mode, produce float colors. --- src/mesa/swrast/s_feedback.c | 7 +------ src/mesa/swrast_setup/ss_context.c | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_feedback.c b/src/mesa/swrast/s_feedback.c index 606afc63ba9..07b7409ab57 100644 --- a/src/mesa/swrast/s_feedback.c +++ b/src/mesa/swrast/s_feedback.c @@ -39,19 +39,14 @@ static void feedback_vertex(GLcontext * ctx, const SWvertex * v, const SWvertex * pv) { GLfloat win[4]; - GLfloat color[4]; const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX0]; + const GLfloat *color = v->attrib[FRAG_ATTRIB_COL0]; win[0] = v->attrib[FRAG_ATTRIB_WPOS][0]; win[1] = v->attrib[FRAG_ATTRIB_WPOS][1]; win[2] = v->attrib[FRAG_ATTRIB_WPOS][2] / ctx->DrawBuffer->_DepthMaxF; win[3] = 1.0F / v->attrib[FRAG_ATTRIB_WPOS][3]; - color[0] = CHAN_TO_FLOAT(pv->color[0]); - color[1] = CHAN_TO_FLOAT(pv->color[1]); - color[2] = CHAN_TO_FLOAT(pv->color[2]); - color[3] = CHAN_TO_FLOAT(pv->color[3]); - _mesa_feedback_vertex(ctx, win, color, v->attrib[FRAG_ATTRIB_CI][0], vtc); } diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index cd4ac57d37d..50b93b36c2b 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -125,6 +125,7 @@ setup_vertex_format(GLcontext *ctx) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) { swsetup->intColors = !ctx->FragmentProgram._Current && !ctx->ATIFragmentShader._Enabled + && ctx->RenderMode == GL_RENDER && CHAN_TYPE == GL_UNSIGNED_BYTE; if (swsetup->intColors) EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); -- cgit v1.2.3 From 1d52b6aaf41b32aaf8d1cdf5a3cd5ff4ecba28f4 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 22 Jun 2007 09:47:30 -0600 Subject: fix bug rendering points with fragment program (see #11330) --- src/mesa/swrast/s_points.c | 20 +++++++++++++------- src/mesa/swrast/s_span.c | 7 +++++-- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 02c9d9b4251..b91ce73d7a3 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -208,6 +208,14 @@ _swrast_choose_point( GLcontext *ctx ) GLboolean specular = (ctx->Fog.ColorSumEnabled || (ctx->Light.Enabled && ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)); + GLboolean attribs = (ctx->FragmentProgram._Current || + ctx->Texture._EnabledCoordUnits || + swrast->_FogEnabled || + specular); + + /* + * XXX this is a mess that should be cleaned up someday + */ if (ctx->RenderMode==GL_RENDER) { if (ctx->Point.PointSprite) { @@ -218,7 +226,7 @@ _swrast_choose_point( GLcontext *ctx ) else USE(sprite_point); } - else if (ctx->Point.SmoothFlag) { + else if (ctx->Point.SmoothFlag && !attribs) { /* Smooth points */ if (rgbMode) { if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { @@ -237,7 +245,7 @@ _swrast_choose_point( GLcontext *ctx ) } else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { if (rgbMode) { - if (ctx->Texture._EnabledCoordUnits) { + if (attribs) { if (ctx->Point.SmoothFlag) { USE(atten_antialiased_rgba_point); } @@ -254,9 +262,7 @@ _swrast_choose_point( GLcontext *ctx ) USE(atten_general_ci_point); } } - else if ((ctx->Texture._EnabledCoordUnits - || specular - || swrast->_FogEnabled) && rgbMode) { + else if (attribs && rgbMode) { /* textured, fogged */ USE(textured_rgba_point); } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 9777391ded2..4ab6e2e9fbf 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -1178,7 +1178,10 @@ shade_texture_span(GLcontext *ctx, SWspan *span) if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) { convert_color_type(span, GL_FLOAT, 0); } - interpolate_active_attribs(ctx, span, ~0); + if (span->primitive != GL_POINT) { + /* for points, we populated the arrays already */ + interpolate_active_attribs(ctx, span, ~0); + } span->array->ChanType = GL_FLOAT; if (!(span->arrayMask & SPAN_Z)) -- cgit v1.2.3 From 5eb2015a966e52dc0dabfe2c2e923bb5b354ffce Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 24 Jun 2007 17:21:26 +1000 Subject: r300: 2288 is a tcl only reg --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 8 ++++++-- src/mesa/drivers/dri/r300/r300_state.c | 16 +++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index aebc895d63f..6adf1413219 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -321,8 +321,12 @@ void r300InitCmdBuf(r300ContextPtr r300) r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1); ALLOC_STATE(vap_clip, always, 5, 0); r300->hw.vap_clip.cmd[0] = cmdpacket0(R300_VAP_CLIP_X_0, 4); - ALLOC_STATE(unk2288, always, 2, 0); - r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1); + + if (has_tcl) { + ALLOC_STATE(unk2288, always, 2, 0); + r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1); + } + ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, 0); r300->hw.vof.cmd[R300_VOF_CMD_0] = cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2); diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index e6c394610dd..a723c3c5305 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1862,13 +1862,15 @@ static void r300ResetHwState(r300ContextPtr r300) r300->hw.vap_clip.cmd[4] = r300PackFloat32(1.0); /* Y */ /* XXX: Other families? */ - switch (r300->radeon.radeonScreen->chip_family) { - case CHIP_FAMILY_R300: - r300->hw.unk2288.cmd[1] = R300_2288_R300; - break; - default: - r300->hw.unk2288.cmd[1] = R300_2288_RV350; - break; + if (has_tcl) { + switch (r300->radeon.radeonScreen->chip_family) { + case CHIP_FAMILY_R300: + r300->hw.unk2288.cmd[1] = R300_2288_R300; + break; + default: + r300->hw.unk2288.cmd[1] = R300_2288_RV350; + break; + } } r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE -- cgit v1.2.3 From 381b86329e827ea81e4a7e8a99c4aaa21c5ec8ac Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Sun, 17 Jun 2007 02:04:58 +0000 Subject: r300: Trivial clean up in radeon_lock.h. --- src/mesa/drivers/dri/r300/radeon_lock.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/radeon_lock.h b/src/mesa/drivers/dri/r300/radeon_lock.h index c47adc9575b..a344837f475 100644 --- a/src/mesa/drivers/dri/r300/radeon_lock.h +++ b/src/mesa/drivers/dri/r300/radeon_lock.h @@ -42,9 +42,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __RADEON_LOCK_H__ #define __RADEON_LOCK_H__ -#if 0 -#include "r200_ioctl.h" -#endif #include "radeon_context.h" extern void radeonGetLock(radeonContextPtr rmesa, GLuint flags); -- cgit v1.2.3 From 204f9e3fdb83fa9ef94c6e94a5fbd0dfa8d3b3dc Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 02:31:35 +0000 Subject: r300: Cleaned up the r300SetupPixelShader function. --- src/mesa/drivers/dri/r300/r300_state.c | 83 +++++++++++++++++----------------- 1 file changed, 41 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index bdd6855802b..6ae2d924d6e 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -2111,62 +2111,61 @@ static void r300SetupPixelShader(r300ContextPtr rmesa) __FUNCTION__); return; } -#define OUTPUT_FIELD(st, reg, field) \ - R300_STATECHANGE(rmesa, st); \ - for(i=0;i<=fp->alu_end;i++) \ - rmesa->hw.st.cmd[R300_FPI_INSTR_0+i]=fp->alu.inst[i].field;\ - rmesa->hw.st.cmd[R300_FPI_CMD_0]=cmdpacket0(reg, fp->alu_end+1); - - OUTPUT_FIELD(fpi[0], R300_PFS_INSTR0_0, inst0); - OUTPUT_FIELD(fpi[1], R300_PFS_INSTR1_0, inst1); - OUTPUT_FIELD(fpi[2], R300_PFS_INSTR2_0, inst2); - OUTPUT_FIELD(fpi[3], R300_PFS_INSTR3_0, inst3); -#undef OUTPUT_FIELD + + R300_STATECHANGE(rmesa, fpi[0]); + rmesa->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, fp->alu_end + 1); + for (i = 0; i <= fp->alu_end; i++) { + rmesa->hw.fpi[0].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst0; + } + + R300_STATECHANGE(rmesa, fpi[1]); + rmesa->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, fp->alu_end + 1); + for (i = 0; i <= fp->alu_end; i++) { + rmesa->hw.fpi[1].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst1; + } + + R300_STATECHANGE(rmesa, fpi[2]); + rmesa->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, fp->alu_end + 1); + for (i = 0; i <= fp->alu_end; i++) { + rmesa->hw.fpi[2].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst2; + } + + R300_STATECHANGE(rmesa, fpi[3]); + rmesa->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, fp->alu_end + 1); + for (i = 0; i <= fp->alu_end; i++) { + rmesa->hw.fpi[3].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst3; + } R300_STATECHANGE(rmesa, fp); + rmesa->hw.fp.cmd[R300_FP_CNTL0] = fp->cur_node | (fp->first_node_has_tex << 3); + rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx; + rmesa->hw.fp.cmd[R300_FP_CNTL2] = + (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT) | + (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT) | + (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT) | + (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT); /* I just want to say, the way these nodes are stored.. weird.. */ for (i = 0, k = (4 - (fp->cur_node + 1)); i < 4; i++, k++) { if (i < (fp->cur_node + 1)) { rmesa->hw.fp.cmd[R300_FP_NODE0 + k] = - (fp->node[i]. - alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT) - | (fp->node[i]. - alu_end << R300_PFS_NODE_ALU_END_SHIFT) - | (fp->node[i]. - tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT) - | (fp->node[i]. - tex_end << R300_PFS_NODE_TEX_END_SHIFT) - | fp->node[i].flags; + (fp->node[i].alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT) | + (fp->node[i].alu_end << R300_PFS_NODE_ALU_END_SHIFT) | + (fp->node[i].tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT) | + (fp->node[i].tex_end << R300_PFS_NODE_TEX_END_SHIFT) | + fp->node[i].flags; } else { rmesa->hw.fp.cmd[R300_FP_NODE0 + (3 - i)] = 0; } } - /* PFS_CNTL_0 */ - rmesa->hw.fp.cmd[R300_FP_CNTL0] = - fp->cur_node | (fp->first_node_has_tex << 3); - /* PFS_CNTL_1 */ - rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx; - /* PFS_CNTL_2 */ - rmesa->hw.fp.cmd[R300_FP_CNTL2] = - (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT) - | (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT) - | (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT) - | (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT); - R300_STATECHANGE(rmesa, fpp); + rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4); for (i = 0; i < fp->const_nr; i++) { - rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = - r300PackFloat24(fp->constant[i][0]); - rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = - r300PackFloat24(fp->constant[i][1]); - rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = - r300PackFloat24(fp->constant[i][2]); - rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = - r300PackFloat24(fp->constant[i][3]); + rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat24(fp->constant[i][0]); + rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat24(fp->constant[i][1]); + rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(fp->constant[i][2]); + rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat24(fp->constant[i][3]); } - rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = - cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4); } void r300UpdateShaderStates(r300ContextPtr rmesa) -- cgit v1.2.3 From bf334d852d60b9a5ea21234a816d0acb03f1b48c Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 02:37:44 +0000 Subject: r300: Cleaned up the r300SetupVertexShader function. --- src/mesa/drivers/dri/r300/r300_state.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 6ae2d924d6e..85212b56c7b 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1649,9 +1649,7 @@ static void r300SetupVertexShader(r300ContextPtr rmesa) 0x400 area might have something to do with pixel shaders as it appears right after pfs programming. 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */ //setup_vertex_shader_fragment(rmesa, 0x406, &unk4); - if (hw_tcl_on - && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))-> - translated) { + if (hw_tcl_on && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->translated) { r300SetupVertexProgram(rmesa); return; } @@ -1659,33 +1657,24 @@ static void r300SetupVertexShader(r300ContextPtr rmesa) /* This needs to be replaced by vertex shader generation code */ r300GenerateSimpleVertexShader(rmesa); - setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, - &(rmesa->state.vertex_shader.program)); + setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(rmesa->state.vertex_shader.program)); #if 0 - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, - &(rmesa->state.vertex_shader.unknown1)); - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, - &(rmesa->state.vertex_shader.unknown2)); + setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); + setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); #endif R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = - (rmesa->state.vertex_shader. - program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) - | (rmesa->state.vertex_shader. - unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT) - | (rmesa->state.vertex_shader. - program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); + (rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | + (rmesa->state.vertex_shader.unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT) | + (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = - (rmesa->state.vertex_shader. - param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) - | (rmesa->state.vertex_shader. - param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); + (rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | + (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (rmesa->state.vertex_shader. - unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) - | (rmesa->state.vertex_shader.unknown_ptr3 << 0); + (rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (rmesa->state.vertex_shader.unknown_ptr3 << 0); /* This is done for vertex shader fragments, but also needs to be done for vap_pvs, so I leave it as a reminder */ -- cgit v1.2.3 From 909091b7dc2ee2875807a1d3ebcb9732fdfeaab3 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 03:02:34 +0000 Subject: r300: Setup the default state for polygon offset point/line. I believe there are still bugs with all polygon offset types. The point and line types may need to be handled specially, too. This shouldn't break anything because it just enabled the occlusion control bits for polygon offset. --- src/mesa/drivers/dri/r300/r300_state.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 85212b56c7b..dfde2f090f5 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1928,6 +1928,8 @@ static void r300ResetHwState(r300ContextPtr r300) r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor, ctx->Polygon.OffsetUnits); + r300Enable(ctx, GL_POLYGON_OFFSET_POINT, ctx->Polygon.OffsetPoint); + r300Enable(ctx, GL_POLYGON_OFFSET_LINE, ctx->Polygon.OffsetLine); r300Enable(ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill); r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF; -- cgit v1.2.3 From 804d3a8f6eaa0beee1504c3e6fbda5dae9f79299 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 11:42:53 +0000 Subject: r300: Cleaned up long lines in the vertex functions. --- src/mesa/drivers/dri/r300/r300_state.c | 62 ++++++++++++---------------------- 1 file changed, 22 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index dfde2f090f5..dea0482123f 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1477,9 +1477,7 @@ static void r300SetupRSUnit(GLcontext * ctx) if(_nc>_p->vpu.count)_p->vpu.count=_nc;\ }while(0) -void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, struct - r300_vertex_shader_fragment - *vsf) +static inline void setup_vertex_shader_fragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf) { int i; @@ -1487,8 +1485,7 @@ void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s return; if (vsf->length & 0x3) { - fprintf(stderr, - "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n"); + fprintf(stderr, "VERTEX_SHADER_FRAGMENT must have length divisible by 4\n"); _mesa_exit(-1); } @@ -1496,32 +1493,24 @@ void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s case 0: R300_STATECHANGE(r300, vpi); for (i = 0; i < vsf->length; i++) - r300->hw.vpi.cmd[R300_VPI_INSTR_0 + i + - 4 * (dest & 0xff)] = (vsf->body.d[i]); - bump_vpu_count(r300->hw.vpi.cmd, - vsf->length + 4 * (dest & 0xff)); + r300->hw.vpi.cmd[R300_VPI_INSTR_0 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]); + bump_vpu_count(r300->hw.vpi.cmd, vsf->length + 4 * (dest & 0xff)); break; case 2: R300_STATECHANGE(r300, vpp); for (i = 0; i < vsf->length; i++) - r300->hw.vpp.cmd[R300_VPP_PARAM_0 + i + - 4 * (dest & 0xff)] = (vsf->body.d[i]); - bump_vpu_count(r300->hw.vpp.cmd, - vsf->length + 4 * (dest & 0xff)); + r300->hw.vpp.cmd[R300_VPP_PARAM_0 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]); + bump_vpu_count(r300->hw.vpp.cmd, vsf->length + 4 * (dest & 0xff)); break; case 4: R300_STATECHANGE(r300, vps); for (i = 0; i < vsf->length; i++) - r300->hw.vps.cmd[1 + i + 4 * (dest & 0xff)] = - (vsf->body.d[i]); - bump_vpu_count(r300->hw.vps.cmd, - vsf->length + 4 * (dest & 0xff)); + r300->hw.vps.cmd[1 + i + 4 * (dest & 0xff)] = (vsf->body.d[i]); + bump_vpu_count(r300->hw.vps.cmd, vsf->length + 4 * (dest & 0xff)); break; default: - fprintf(stderr, - "%s:%s don't know how to handle dest %04x\n", - __FILE__, __FUNCTION__, dest); + fprintf(stderr, "%s:%s don't know how to handle dest %04x\n", __FILE__, __FUNCTION__, dest); _mesa_exit(-1); } } @@ -1586,16 +1575,13 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) GLcontext *ctx = rmesa->radeon.glCtx; int inst_count; int param_count; - struct r300_vertex_program *prog = - (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); + struct r300_vertex_program *prog = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0; R300_STATECHANGE(rmesa, vpp); - param_count = - r300VertexProgUpdateParams(ctx, (struct r300_vertex_program_cont *) - ctx->VertexProgram._Current /*prog */ , - (float *)&rmesa->hw.vpp. - cmd[R300_VPP_PARAM_0]); + param_count = r300VertexProgUpdateParams(ctx, (struct r300_vertex_program_cont *) + ctx->VertexProgram._Current /*prog */ , + (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]); bump_vpu_count(rmesa->hw.vpp.cmd, param_count); param_count /= 4; @@ -1606,27 +1592,23 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); #if 0 - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, - &(rmesa->state.vertex_shader.unknown1)); - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, - &(rmesa->state.vertex_shader.unknown2)); + setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); + setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); #endif inst_count = prog->program.length / 4 - 1; R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = - (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) - | (inst_count /*pos_end */ << R300_PVS_CNTL_1_POS_END_SHIFT) - | (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); + (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | + (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) | + (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = - (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) - | (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); + (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | + (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (0 /*rmesa->state.vertex_shader.unknown_ptr2 */ << - R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) - | (inst_count /*rmesa->state.vertex_shader.unknown_ptr3 */ << - 0); + (0 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (inst_count << 0); /* This is done for vertex shader fragments, but also needs to be done for vap_pvs, so I leave it as a reminder */ -- cgit v1.2.3 From 27c8488526c5b3b0606cb5a3fbfac7a82246c0bd Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 11:45:07 +0000 Subject: r300: Removed unused vap_param structure. --- src/mesa/drivers/dri/r300/r300_context.h | 4 ---- src/mesa/drivers/dri/r300/r300_state.c | 1 - 2 files changed, 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 076bb49a006..c150053d873 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -799,10 +799,6 @@ struct r300_state { DECLARE_RENDERINPUTS(render_inputs_bitset); /* actual render inputs that R300 was configured for. They are the same as tnl->render_inputs for fixed pipeline */ - struct { - int transform_offset; /* Transform matrix offset, -1 if none */ - } vap_param; /* vertex processor parameter allocation - tells where to write parameters */ - struct r300_stencilbuffer_state stencil; }; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index dea0482123f..c37964957a4 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1527,7 +1527,6 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) GLuint o_reg = 0; /* Allocate parameters */ - r300->state.vap_param.transform_offset = 0x0; /* transform matrix */ r300->state.vertex_shader.param_offset = 0x0; r300->state.vertex_shader.param_count = 0x4; /* 4 vector values - 4x4 matrix */ -- cgit v1.2.3 From 252fc61e4860f6a539faaf48f7d657d7d2242fbe Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 12:03:42 +0000 Subject: r300: Vertex program position end bits are known. Possibly performance may improve by setting it to the last instruction that writes result.position, rather than the last instruction in the vertex program. --- src/mesa/drivers/dri/r300/r300_context.h | 2 +- src/mesa/drivers/dri/r300/r300_reg.h | 8 +++++--- src/mesa/drivers/dri/r300/r300_state.c | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index c150053d873..44f02229b38 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -588,7 +588,7 @@ struct r300_vertex_shader_state { struct r300_vertex_shader_fragment unknown2; int program_start; - int unknown_ptr1; /* pointer within program space */ + int program_pos_end; int program_end; int param_offset; diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index 3ce09c16d3f..e59919be493 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -336,13 +336,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * The meaning of the two UNKNOWN fields is obviously not known. However, * experiments so far have shown that both *must* point to an instruction * inside the vertex program, otherwise the GPU locks up. + * * fglrx usually sets CNTL_3_UNKNOWN to the end of the program and - * CNTL_1_UNKNOWN points to instruction where last write to position takes - * place. + * R300_PVS_CNTL_1_POS_END_SHIFT points to instruction where last write to + * position takes place. + * * Most likely this is used to ignore rest of the program in cases * where group of verts arent visible. For some reason this "section" * is sometimes accepted other instruction that have no relationship with - *position calculations. + * position calculations. */ #define R300_VAP_PVS_CNTL_1 0x22D0 # define R300_PVS_CNTL_1_PROGRAM_START_SHIFT 0 diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index c37964957a4..8d08279b3a8 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1531,7 +1531,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) r300->state.vertex_shader.param_count = 0x4; /* 4 vector values - 4x4 matrix */ r300->state.vertex_shader.program_start = 0x0; - r300->state.vertex_shader.unknown_ptr1 = 0x4; /* magic value ? */ + r300->state.vertex_shader.program_pos_end = 0x4; r300->state.vertex_shader.program_end = 0x0; r300->state.vertex_shader.unknown_ptr2 = 0x0; /* magic value */ @@ -1563,7 +1563,7 @@ static void r300GenerateSimpleVertexShader(r300ContextPtr r300) r300->state.vertex_shader.program.length = (r300->state.vertex_shader.program_end + 1) * 4; - r300->state.vertex_shader.unknown_ptr1 = r300->state.vertex_shader.program_end; /* magic value ? */ + r300->state.vertex_shader.program_pos_end = r300->state.vertex_shader.program_end; r300->state.vertex_shader.unknown_ptr2 = r300->state.vertex_shader.program_end; /* magic value ? */ r300->state.vertex_shader.unknown_ptr3 = r300->state.vertex_shader.program_end; /* magic value ? */ @@ -1607,7 +1607,7 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (0 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | - (inst_count << 0); + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); /* This is done for vertex shader fragments, but also needs to be done for vap_pvs, so I leave it as a reminder */ @@ -1648,14 +1648,14 @@ static void r300SetupVertexShader(r300ContextPtr rmesa) R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = (rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | - (rmesa->state.vertex_shader.unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT) | + (rmesa->state.vertex_shader.program_pos_end << R300_PVS_CNTL_1_POS_END_SHIFT) | (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = (rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | - (rmesa->state.vertex_shader.unknown_ptr3 << 0); + (rmesa->state.vertex_shader.unknown_ptr3 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); /* This is done for vertex shader fragments, but also needs to be done for vap_pvs, so I leave it as a reminder */ -- cgit v1.2.3 From b41ef5506153fc2cd471341b4ad1eda2338f2438 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 12:13:44 +0000 Subject: r300: Clean up the vertex program state code slightly; still needs lots of work. --- src/mesa/drivers/dri/r300/r300_state.c | 115 +++++++++++++++------------------ 1 file changed, 51 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 8d08279b3a8..03c65b46750 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1521,54 +1521,68 @@ static inline void setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s while leaving colors intact. Nothing fancy (like lights) If implementing lights make a copy first, so it is easy to switch between the two versions */ -static void r300GenerateSimpleVertexShader(r300ContextPtr r300) + +#define WRITE_OP(oper,source1,source2,source3) {\ + rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].op=(oper); \ + rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].src[0]=(source1); \ + rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].src[1]=(source2); \ + rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].src[2]=(source3); \ + rmesa->state.vertex_shader.program_end++; \ + } + +static void r300GenerateSimpleVertexShader(r300ContextPtr rmesa) { int i; GLuint o_reg = 0; /* Allocate parameters */ - r300->state.vertex_shader.param_offset = 0x0; - r300->state.vertex_shader.param_count = 0x4; /* 4 vector values - 4x4 matrix */ - - r300->state.vertex_shader.program_start = 0x0; - r300->state.vertex_shader.program_pos_end = 0x4; - r300->state.vertex_shader.program_end = 0x0; - - r300->state.vertex_shader.unknown_ptr2 = 0x0; /* magic value */ - r300->state.vertex_shader.unknown_ptr3 = 0x4; /* magic value */ - - r300->state.vertex_shader.unknown1.length = 0; - r300->state.vertex_shader.unknown2.length = 0; - -#define WRITE_OP(oper,source1,source2,source3) {\ - r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].op=(oper); \ - r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src[0]=(source1); \ - r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src[1]=(source2); \ - r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src[2]=(source3); \ - r300->state.vertex_shader.program_end++; \ - } + rmesa->state.vertex_shader.param_offset = 0x0; + rmesa->state.vertex_shader.param_count = 0x4; /* 4 vector values - 4x4 matrix */ + rmesa->state.vertex_shader.program_start = 0x0; + rmesa->state.vertex_shader.program_pos_end = 0x4; + rmesa->state.vertex_shader.program_end = 0x0; + rmesa->state.vertex_shader.unknown_ptr2 = 0x0; /* magic value */ + rmesa->state.vertex_shader.unknown_ptr3 = 0x4; /* magic value */ + rmesa->state.vertex_shader.unknown1.length = 0; + rmesa->state.vertex_shader.unknown2.length = 0; for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) - if (r300->state.sw_tcl_inputs[i] != -1) { + if (rmesa->state.sw_tcl_inputs[i] != -1) { WRITE_OP(EASY_VSF_OP(MUL, o_reg++, ALL, RESULT), - VSF_REG(r300->state.sw_tcl_inputs[i]), - VSF_ATTR_UNITY(r300->state. + VSF_REG(rmesa->state.sw_tcl_inputs[i]), + VSF_ATTR_UNITY(rmesa->state. sw_tcl_inputs[i]), - VSF_UNITY(r300->state.sw_tcl_inputs[i]) + VSF_UNITY(rmesa->state.sw_tcl_inputs[i]) ) - } - r300->state.vertex_shader.program_end--; /* r300 wants program length to be one more - no idea why */ - r300->state.vertex_shader.program.length = - (r300->state.vertex_shader.program_end + 1) * 4; + rmesa->state.vertex_shader.program_end--; /* rmesa wants program length to be one more - no idea why */ + rmesa->state.vertex_shader.program.length = (rmesa->state.vertex_shader.program_end + 1) * 4; + rmesa->state.vertex_shader.program_pos_end = rmesa->state.vertex_shader.program_end; + rmesa->state.vertex_shader.unknown_ptr2 = rmesa->state.vertex_shader.program_end; /* magic value ? */ + rmesa->state.vertex_shader.unknown_ptr3 = rmesa->state.vertex_shader.program_end; /* magic value ? */ - r300->state.vertex_shader.program_pos_end = r300->state.vertex_shader.program_end; - r300->state.vertex_shader.unknown_ptr2 = r300->state.vertex_shader.program_end; /* magic value ? */ - r300->state.vertex_shader.unknown_ptr3 = r300->state.vertex_shader.program_end; /* magic value ? */ + setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(rmesa->state.vertex_shader.program)); +#if 0 + setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); + setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); +#endif + R300_STATECHANGE(rmesa, pvs); + rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = + (rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | + (rmesa->state.vertex_shader.program_pos_end << R300_PVS_CNTL_1_POS_END_SHIFT) | + (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); + rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = + (rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | + (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); + rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = + (rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (rmesa->state.vertex_shader.unknown_ptr3 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); } +#undef WRITE_OP + static void r300SetupVertexProgram(r300ContextPtr rmesa) { GLcontext *ctx = rmesa->radeon.glCtx; @@ -1589,7 +1603,6 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0; setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); - #if 0 setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); @@ -1608,13 +1621,6 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = (0 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); - - /* This is done for vertex shader fragments, but also needs to be done for vap_pvs, - so I leave it as a reminder */ -#if 0 - reg_start(R300_VAP_PVS_WAITIDLE, 0); - e32(0x00000000); -#endif } static void r300SetupVertexShader(r300ContextPtr rmesa) @@ -1632,33 +1638,14 @@ static void r300SetupVertexShader(r300ContextPtr rmesa) //setup_vertex_shader_fragment(rmesa, 0x406, &unk4); if (hw_tcl_on && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->translated) { r300SetupVertexProgram(rmesa); - return; + } else { + /* FIXME: This needs to be replaced by vertex shader generation code. */ + r300GenerateSimpleVertexShader(rmesa); } - /* This needs to be replaced by vertex shader generation code */ - r300GenerateSimpleVertexShader(rmesa); - - setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(rmesa->state.vertex_shader.program)); - -#if 0 - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); -#endif - - R300_STATECHANGE(rmesa, pvs); - rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = - (rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | - (rmesa->state.vertex_shader.program_pos_end << R300_PVS_CNTL_1_POS_END_SHIFT) | - (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); - rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = - (rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | - (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); - rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | - (rmesa->state.vertex_shader.unknown_ptr3 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); - /* This is done for vertex shader fragments, but also needs to be done for vap_pvs, - so I leave it as a reminder */ + /* FIXME: This is done for vertex shader fragments, but also needs to be + * done for vap_pvs, so I leave it as a reminder. */ #if 0 reg_start(R300_VAP_PVS_WAITIDLE, 0); e32(0x00000000); -- cgit v1.2.3 From 62b83638a5ffe4df25994ce5f36c493d51da046e Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 12:23:47 +0000 Subject: r300: The vpi, vpp, and vps counts are already initialized; don't do it twice. --- src/mesa/drivers/dri/r300/r300_state.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 03c65b46750..9d6de67bbf3 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1590,7 +1590,6 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) int param_count; struct r300_vertex_program *prog = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); - ((drm_r300_cmd_header_t *) rmesa->hw.vpp.cmd)->vpu.count = 0; R300_STATECHANGE(rmesa, vpp); param_count = r300VertexProgUpdateParams(ctx, (struct r300_vertex_program_cont *) ctx->VertexProgram._Current /*prog */ , @@ -1598,10 +1597,6 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) bump_vpu_count(rmesa->hw.vpp.cmd, param_count); param_count /= 4; - /* Reset state, in case we don't use something */ - ((drm_r300_cmd_header_t *) rmesa->hw.vpi.cmd)->vpu.count = 0; - ((drm_r300_cmd_header_t *) rmesa->hw.vps.cmd)->vpu.count = 0; - setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); #if 0 setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); -- cgit v1.2.3 From 43e601206d9618eb5f9ec9660d9a7e0fa22feff0 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 12:42:19 +0000 Subject: r300: Should use inst_count not 0 for R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT. --- src/mesa/drivers/dri/r300/r300_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 9d6de67bbf3..770b16ed453 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1614,7 +1614,7 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (0 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); } -- cgit v1.2.3 From e92903e24c245df80245776ed9423bd933a97740 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 20 Jun 2007 14:24:04 +0000 Subject: r300: Initial work on merging the real and generated vertex program functions. --- src/mesa/drivers/dri/r300/r300_context.h | 13 ---- src/mesa/drivers/dri/r300/r300_state.c | 113 +++++++++++-------------------- 2 files changed, 40 insertions(+), 86 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 44f02229b38..afd3dd384b5 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -583,19 +583,6 @@ struct r300_vertex_shader_fragment { struct r300_vertex_shader_state { struct r300_vertex_shader_fragment program; - - struct r300_vertex_shader_fragment unknown1; - struct r300_vertex_shader_fragment unknown2; - - int program_start; - int program_pos_end; - int program_end; - - int param_offset; - int param_count; - - int unknown_ptr2; /* pointer within program space */ - int unknown_ptr3; /* pointer within program space */ }; extern int hw_tcl_on; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 770b16ed453..310102fcc51 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1477,7 +1477,7 @@ static void r300SetupRSUnit(GLcontext * ctx) if(_nc>_p->vpu.count)_p->vpu.count=_nc;\ }while(0) -static inline void setup_vertex_shader_fragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf) +static inline void r300SetupVertexProgramFragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf) { int i; @@ -1515,95 +1515,63 @@ static inline void setup_vertex_shader_fragment(r300ContextPtr r300, int dest, s } } -/* just a skeleton for now.. */ - -/* Generate a vertex shader that simply transforms vertex and texture coordinates, - while leaving colors intact. Nothing fancy (like lights) - - If implementing lights make a copy first, so it is easy to switch between the two versions */ - -#define WRITE_OP(oper,source1,source2,source3) {\ - rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].op=(oper); \ - rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].src[0]=(source1); \ - rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].src[1]=(source2); \ - rmesa->state.vertex_shader.program.body.i[rmesa->state.vertex_shader.program_end].src[2]=(source3); \ - rmesa->state.vertex_shader.program_end++; \ - } - -static void r300GenerateSimpleVertexShader(r300ContextPtr rmesa) +static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa) { - int i; + struct r300_vertex_shader_state *prog = &(rmesa->state.vertex_shader); GLuint o_reg = 0; + int i; + int inst_count = 0; + int param_count = 0; + int program_end = 0; - /* Allocate parameters */ - rmesa->state.vertex_shader.param_offset = 0x0; - rmesa->state.vertex_shader.param_count = 0x4; /* 4 vector values - 4x4 matrix */ - rmesa->state.vertex_shader.program_start = 0x0; - rmesa->state.vertex_shader.program_pos_end = 0x4; - rmesa->state.vertex_shader.program_end = 0x0; - rmesa->state.vertex_shader.unknown_ptr2 = 0x0; /* magic value */ - rmesa->state.vertex_shader.unknown_ptr3 = 0x4; /* magic value */ - rmesa->state.vertex_shader.unknown1.length = 0; - rmesa->state.vertex_shader.unknown2.length = 0; - - for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) + for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) { if (rmesa->state.sw_tcl_inputs[i] != -1) { - WRITE_OP(EASY_VSF_OP(MUL, o_reg++, ALL, RESULT), - VSF_REG(rmesa->state.sw_tcl_inputs[i]), - VSF_ATTR_UNITY(rmesa->state. - sw_tcl_inputs[i]), - VSF_UNITY(rmesa->state.sw_tcl_inputs[i]) - ) + prog->program.body.i[program_end].op = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); + prog->program.body.i[program_end].src[0] = VSF_REG(rmesa->state.sw_tcl_inputs[i]); + prog->program.body.i[program_end].src[1] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]); + prog->program.body.i[program_end].src[2] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]); + program_end++; } + } - rmesa->state.vertex_shader.program_end--; /* rmesa wants program length to be one more - no idea why */ - rmesa->state.vertex_shader.program.length = (rmesa->state.vertex_shader.program_end + 1) * 4; - rmesa->state.vertex_shader.program_pos_end = rmesa->state.vertex_shader.program_end; - rmesa->state.vertex_shader.unknown_ptr2 = rmesa->state.vertex_shader.program_end; /* magic value ? */ - rmesa->state.vertex_shader.unknown_ptr3 = rmesa->state.vertex_shader.program_end; /* magic value ? */ + prog->program.length = program_end * 4; - setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(rmesa->state.vertex_shader.program)); -#if 0 - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); -#endif + r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); + inst_count = (prog->program.length / 4) - 1; R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = - (rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | - (rmesa->state.vertex_shader.program_pos_end << R300_PVS_CNTL_1_POS_END_SHIFT) | - (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); + (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | + (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) | + (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = - (rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | - (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); + (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | + (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | - (rmesa->state.vertex_shader.unknown_ptr3 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); } -#undef WRITE_OP - -static void r300SetupVertexProgram(r300ContextPtr rmesa) +static void r300SetupRealVertexProgram(r300ContextPtr rmesa) { GLcontext *ctx = rmesa->radeon.glCtx; - int inst_count; - int param_count; struct r300_vertex_program *prog = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx); + int inst_count = 0; + int param_count = 0; + /* FIXME: r300SetupVertexProgramFragment */ R300_STATECHANGE(rmesa, vpp); - param_count = r300VertexProgUpdateParams(ctx, (struct r300_vertex_program_cont *) - ctx->VertexProgram._Current /*prog */ , - (float *)&rmesa->hw.vpp.cmd[R300_VPP_PARAM_0]); + param_count = + r300VertexProgUpdateParams(ctx, + (struct r300_vertex_program_cont *) + ctx->VertexProgram._Current, + (float *)&rmesa->hw.vpp. + cmd[R300_VPP_PARAM_0]); bump_vpu_count(rmesa->hw.vpp.cmd, param_count); param_count /= 4; - setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); -#if 0 - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1)); - setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2)); -#endif - - inst_count = prog->program.length / 4 - 1; + r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); + inst_count = (prog->program.length / 4) - 1; R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = @@ -1618,7 +1586,7 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa) (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); } -static void r300SetupVertexShader(r300ContextPtr rmesa) +static void r300SetupVertexProgram(r300ContextPtr rmesa) { GLcontext *ctx = rmesa->radeon.glCtx; @@ -1632,10 +1600,10 @@ static void r300SetupVertexShader(r300ContextPtr rmesa) 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */ //setup_vertex_shader_fragment(rmesa, 0x406, &unk4); if (hw_tcl_on && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->translated) { - r300SetupVertexProgram(rmesa); + r300SetupRealVertexProgram(rmesa); } else { /* FIXME: This needs to be replaced by vertex shader generation code. */ - r300GenerateSimpleVertexShader(rmesa); + r300SetupDefaultVertexProgram(rmesa); } @@ -2046,7 +2014,6 @@ void r300UpdateShaders(r300ContextPtr rmesa) } r300UpdateStateParameters(ctx, _NEW_PROGRAM); } - } static void r300SetupPixelShader(r300ContextPtr rmesa) @@ -2133,7 +2100,7 @@ void r300UpdateShaderStates(r300ContextPtr rmesa) r300SetupTextures(ctx); if ((rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) - r300SetupVertexShader(rmesa); + r300SetupVertexProgram(rmesa); r300SetupRSUnit(ctx); } -- cgit v1.2.3 From 369d6654d4cdac7bf964918b2412c71d977bcbf5 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 28 Jun 2007 07:12:55 -0600 Subject: added comment, remove dead code --- src/mesa/swrast_setup/ss_context.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index 50b93b36c2b..f8a1cadfa5a 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -288,13 +288,11 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest ) dest->attrib[FRAG_ATTRIB_VAR0 + i] ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp ); + /* XXX need float color FRAG_ATTRIB_COL0?? */ UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp ); COPY_4V(dest->attrib[FRAG_ATTRIB_COL1], tmp); - /* - UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->specular, tmp ); - */ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp ); dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0]; -- cgit v1.2.3 From 3156854c25cb41d7651a992cf30d42bfce04d593 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 28 Jun 2007 07:13:20 -0600 Subject: XXX comment about point clamping --- src/mesa/main/points.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 8674c7299c5..0f562420b08 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -57,6 +57,7 @@ _mesa_PointSize( GLfloat size ) FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.Size = size; + /* XXX correct clamp limits? */ ctx->Point._Size = CLAMP(ctx->Point.Size, ctx->Point.MinSize, ctx->Point.MaxSize); -- cgit v1.2.3 From 1a55e97c9c1734f0808e4ed570be3826dba24417 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 28 Jun 2007 07:13:39 -0600 Subject: increase MAX_POINT_SIZE to 60 --- src/mesa/main/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 55199245568..cebef1c3832 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -82,7 +82,7 @@ /** Minimum point size */ #define MIN_POINT_SIZE 1.0 /** Maximum point size */ -#define MAX_POINT_SIZE 20.0 +#define MAX_POINT_SIZE 60.0 /** Point size granularity */ #define POINT_SIZE_GRANULARITY 0.1 -- cgit v1.2.3 From 2233d4c1ee53f1cfd016b68d8249b8d934ef17ee Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 28 Jun 2007 07:15:37 -0600 Subject: remove obsolete t_save_api.c --- src/mesa/tnl/t_save_api.c | 1834 --------------------------------------------- 1 file changed, 1834 deletions(-) delete mode 100644 src/mesa/tnl/t_save_api.c (limited to 'src') diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c deleted file mode 100644 index b08f05374e4..00000000000 --- a/src/mesa/tnl/t_save_api.c +++ /dev/null @@ -1,1834 +0,0 @@ -/************************************************************************** - -Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas. - -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, 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 -TUNGSTEN GRAPHICS 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: - * Keith Whitwell - */ - - - -/** - * The display list compiler attempts to store lists of vertices with the - * same vertex layout. Additionally it attempts to minimize the need - * for execute-time fixup of these vertex lists, allowing them to be - * cached on hardware. - * - * There are still some circumstances where this can be thwarted, for - * example by building a list that consists of one very long primitive - * (eg Begin(Triangles), 1000 vertices, End), and calling that list - * from inside a different begin/end object (Begin(Lines), CallList, - * End). - * - * In that case the code will have to replay the list as individual - * commands through the Exec dispatch table, or fix up the copied - * vertices at execute-time. - * - * The other case where fixup is required is when a vertex attribute - * is introduced in the middle of a primitive. Eg: - * Begin(Lines) - * TexCoord1f() Vertex2f() - * TexCoord1f() Color3f() Vertex2f() - * End() - * - * If the current value of Color isn't known at compile-time, this - * primitive will require fixup. - * - * - * The list compiler currently doesn't attempt to compile lists - * containing EvalCoord or EvalPoint commands. On encountering one of - * these, compilation falls back to opcodes. - * - * This could be improved to fallback only when a mix of EvalCoord and - * Vertex commands are issued within a single primitive. - */ - - -#include "glheader.h" -#include "context.h" -#include "dlist.h" -#include "enums.h" -#include "macros.h" -#include "api_validate.h" -#include "api_arrayelt.h" -#include "vtxfmt.h" -#include "t_save_api.h" -#include "dispatch.h" - -/* - * NOTE: Old 'parity' issue is gone, but copying can still be - * wrong-footed on replay. - */ -static GLuint _save_copy_vertices( GLcontext *ctx, - const struct tnl_vertex_list *node ) -{ - TNLcontext *tnl = TNL_CONTEXT( ctx ); - const struct tnl_prim *prim = &node->prim[node->prim_count-1]; - GLuint nr = prim->count; - GLuint sz = tnl->save.vertex_size; - const GLfloat *src = node->buffer + prim->start * sz; - GLfloat *dst = tnl->save.copied.buffer; - GLuint ovf, i; - - if (prim->mode & PRIM_END) - return 0; - - switch( prim->mode & PRIM_MODE_MASK ) - { - case GL_POINTS: - return 0; - case GL_LINES: - ovf = nr&1; - for (i = 0 ; i < ovf ; i++) - _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) ); - return i; - case GL_TRIANGLES: - ovf = nr%3; - for (i = 0 ; i < ovf ; i++) - _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) ); - return i; - case GL_QUADS: - ovf = nr&3; - for (i = 0 ; i < ovf ; i++) - _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) ); - return i; - case GL_LINE_STRIP: - if (nr == 0) - return 0; - else { - _mesa_memcpy( dst, src+(nr-1)*sz, sz*sizeof(GLfloat) ); - return 1; - } - case GL_LINE_LOOP: - case GL_TRIANGLE_FAN: - case GL_POLYGON: - if (nr == 0) - return 0; - else if (nr == 1) { - _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) ); - return 1; - } else { - _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) ); - _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz*sizeof(GLfloat) ); - return 2; - } - case GL_TRIANGLE_STRIP: - case GL_QUAD_STRIP: - switch (nr) { - case 0: ovf = 0; break; - case 1: ovf = 1; break; - default: ovf = 2 + (nr&1); break; - } - for (i = 0 ; i < ovf ; i++) - _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) ); - return i; - default: - assert(0); - return 0; - } -} - - -static void -build_normal_lengths( struct tnl_vertex_list *node ) -{ - GLuint i; - GLfloat *len; - GLfloat *n = node->buffer; - GLuint stride = node->vertex_size; - GLuint count = node->count; - - len = node->normal_lengths = (GLfloat *) MALLOC( count * sizeof(GLfloat) ); - if (!len) - return; - - /* Find the normal of the first vertex: - */ - for (i = 0 ; i < _TNL_ATTRIB_NORMAL ; i++) - n += node->attrsz[i]; - - for (i = 0 ; i < count ; i++, n += stride) { - len[i] = LEN_3FV( n ); - if (len[i] > 0.0F) len[i] = 1.0F / len[i]; - } -} - -static struct tnl_vertex_store *alloc_vertex_store( GLcontext *ctx ) -{ - struct tnl_vertex_store *store = MALLOC_STRUCT(tnl_vertex_store); - (void) ctx; - store->used = 0; - store->refcount = 1; - return store; -} - -static struct tnl_primitive_store *alloc_prim_store( GLcontext *ctx ) -{ - struct tnl_primitive_store *store = MALLOC_STRUCT(tnl_primitive_store); - (void) ctx; - store->used = 0; - store->refcount = 1; - return store; -} - -static void _save_reset_counters( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - tnl->save.prim = tnl->save.prim_store->buffer + tnl->save.prim_store->used; - tnl->save.buffer = (tnl->save.vertex_store->buffer + - tnl->save.vertex_store->used); - - if (tnl->save.vertex_size) - tnl->save.initial_counter = ((SAVE_BUFFER_SIZE - - tnl->save.vertex_store->used) / - tnl->save.vertex_size); - else - tnl->save.initial_counter = 0; - - if (tnl->save.initial_counter > ctx->Const.MaxArrayLockSize ) - tnl->save.initial_counter = ctx->Const.MaxArrayLockSize; - - tnl->save.counter = tnl->save.initial_counter; - tnl->save.prim_count = 0; - tnl->save.prim_max = SAVE_PRIM_SIZE - tnl->save.prim_store->used; - tnl->save.copied.nr = 0; - tnl->save.dangling_attr_ref = 0; -} - - -/* Insert the active immediate struct onto the display list currently - * being built. - */ -static void _save_compile_vertex_list( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct tnl_vertex_list *node; - - /* Allocate space for this structure in the display list currently - * being compiled. - */ - node = (struct tnl_vertex_list *) - _mesa_alloc_instruction(ctx, tnl->save.opcode_vertex_list, sizeof(*node)); - - if (!node) - return; - - /* Duplicate our template, increment refcounts to the storage structs: - */ - _mesa_memcpy(node->attrsz, tnl->save.attrsz, sizeof(node->attrsz)); - node->vertex_size = tnl->save.vertex_size; - node->buffer = tnl->save.buffer; - node->count = tnl->save.initial_counter - tnl->save.counter; - node->wrap_count = tnl->save.copied.nr; - node->have_materials = tnl->save.have_materials; - node->dangling_attr_ref = tnl->save.dangling_attr_ref; - node->normal_lengths = NULL; - node->prim = tnl->save.prim; - node->prim_count = tnl->save.prim_count; - node->vertex_store = tnl->save.vertex_store; - node->prim_store = tnl->save.prim_store; - - node->vertex_store->refcount++; - node->prim_store->refcount++; - - assert(node->attrsz[_TNL_ATTRIB_POS] != 0 || - node->count == 0); - - if (tnl->save.dangling_attr_ref) - ctx->ListState.CurrentList->flags |= MESA_DLIST_DANGLING_REFS; - - /* Maybe calculate normal lengths: - */ - if (tnl->CalcDListNormalLengths && - node->attrsz[_TNL_ATTRIB_NORMAL] == 3 && - !(ctx->ListState.CurrentList->flags & MESA_DLIST_DANGLING_REFS)) - build_normal_lengths( node ); - - - tnl->save.vertex_store->used += tnl->save.vertex_size * node->count; - tnl->save.prim_store->used += node->prim_count; - - /* Decide whether the storage structs are full, or can be used for - * the next vertex lists as well. - */ - if (tnl->save.vertex_store->used > - SAVE_BUFFER_SIZE - 16 * (tnl->save.vertex_size + 4)) { - - tnl->save.vertex_store->refcount--; - assert(tnl->save.vertex_store->refcount != 0); - tnl->save.vertex_store = alloc_vertex_store( ctx ); - tnl->save.vbptr = tnl->save.vertex_store->buffer; - } - - if (tnl->save.prim_store->used > SAVE_PRIM_SIZE - 6) { - tnl->save.prim_store->refcount--; - assert(tnl->save.prim_store->refcount != 0); - tnl->save.prim_store = alloc_prim_store( ctx ); - } - - /* Reset our structures for the next run of vertices: - */ - _save_reset_counters( ctx ); - - /* Copy duplicated vertices - */ - tnl->save.copied.nr = _save_copy_vertices( ctx, node ); - - - /* Deal with GL_COMPILE_AND_EXECUTE: - */ - if (ctx->ExecuteFlag) { - _tnl_playback_vertex_list( ctx, (void *) node ); - } -} - - -/* TODO -- If no new vertices have been stored, don't bother saving - * it. - */ -static void _save_wrap_buffers( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLint i = tnl->save.prim_count - 1; - GLenum mode; - - assert(i < (GLint) tnl->save.prim_max); - assert(i >= 0); - - /* Close off in-progress primitive. - */ - tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) - - tnl->save.prim[i].start); - mode = tnl->save.prim[i].mode & ~(PRIM_BEGIN|PRIM_END); - - /* store the copied vertices, and allocate a new list. - */ - _save_compile_vertex_list( ctx ); - - /* Restart interrupted primitive - */ - tnl->save.prim[0].mode = mode; - tnl->save.prim[0].start = 0; - tnl->save.prim[0].count = 0; - tnl->save.prim_count = 1; -} - - - -/* Called only when buffers are wrapped as the result of filling the - * vertex_store struct. - */ -static void _save_wrap_filled_vertex( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLfloat *data = tnl->save.copied.buffer; - GLuint i; - - /* Emit a glEnd to close off the last vertex list. - */ - _save_wrap_buffers( ctx ); - - /* Copy stored stored vertices to start of new list. - */ - assert(tnl->save.counter > tnl->save.copied.nr); - - for (i = 0 ; i < tnl->save.copied.nr ; i++) { - _mesa_memcpy( tnl->save.vbptr, data, tnl->save.vertex_size * sizeof(GLfloat)); - data += tnl->save.vertex_size; - tnl->save.vbptr += tnl->save.vertex_size; - tnl->save.counter--; - } -} - - -static void _save_copy_to_current( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint i; - - /* XXX Use _TNL_FIRST_* and _TNL_LAST_* values instead? */ - for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_EDGEFLAG ; i++) { - if (tnl->save.attrsz[i]) { - tnl->save.currentsz[i][0] = tnl->save.attrsz[i]; - COPY_CLEAN_4V(tnl->save.current[i], - tnl->save.attrsz[i], - tnl->save.attrptr[i]); - } - } - - /* Edgeflag requires special treatment: - * - * TODO: change edgeflag to GLfloat in Mesa. - */ - if (tnl->save.attrsz[_TNL_ATTRIB_EDGEFLAG]) { - ctx->ListState.ActiveEdgeFlag = 1; - tnl->save.CurrentFloatEdgeFlag = - tnl->save.attrptr[_TNL_ATTRIB_EDGEFLAG][0]; - ctx->ListState.CurrentEdgeFlag = - (tnl->save.CurrentFloatEdgeFlag == 1.0); - } -} - - -static void _save_copy_from_current( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLint i; - - for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_EDGEFLAG ; i++) - switch (tnl->save.attrsz[i]) { - case 4: tnl->save.attrptr[i][3] = tnl->save.current[i][3]; - case 3: tnl->save.attrptr[i][2] = tnl->save.current[i][2]; - case 2: tnl->save.attrptr[i][1] = tnl->save.current[i][1]; - case 1: tnl->save.attrptr[i][0] = tnl->save.current[i][0]; - case 0: break; - } - - /* Edgeflag requires special treatment: - */ - if (tnl->save.attrsz[_TNL_ATTRIB_EDGEFLAG]) { - tnl->save.CurrentFloatEdgeFlag = (GLfloat)ctx->ListState.CurrentEdgeFlag; - tnl->save.attrptr[_TNL_ATTRIB_EDGEFLAG][0] = tnl->save.CurrentFloatEdgeFlag; - } -} - - - - -/* Flush existing data, set new attrib size, replay copied vertices. - */ -static void _save_upgrade_vertex( GLcontext *ctx, - GLuint attr, - GLuint newsz ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldsz; - GLuint i; - GLfloat *tmp; - - /* Store the current run of vertices, and emit a GL_END. Emit a - * BEGIN in the new buffer. - */ - if (tnl->save.initial_counter != tnl->save.counter) - _save_wrap_buffers( ctx ); - else - assert( tnl->save.copied.nr == 0 ); - - /* Do a COPY_TO_CURRENT to ensure back-copying works for the case - * when the attribute already exists in the vertex and is having - * its size increased. - */ - _save_copy_to_current( ctx ); - - /* Fix up sizes: - */ - oldsz = tnl->save.attrsz[attr]; - tnl->save.attrsz[attr] = newsz; - - tnl->save.vertex_size += newsz - oldsz; - tnl->save.counter = ((SAVE_BUFFER_SIZE - tnl->save.vertex_store->used) / - tnl->save.vertex_size); - if (tnl->save.counter > ctx->Const.MaxArrayLockSize ) - tnl->save.counter = ctx->Const.MaxArrayLockSize; - tnl->save.initial_counter = tnl->save.counter; - - /* Recalculate all the attrptr[] values: - */ - for (i = 0, tmp = tnl->save.vertex ; i < _TNL_ATTRIB_MAX ; i++) { - if (tnl->save.attrsz[i]) { - tnl->save.attrptr[i] = tmp; - tmp += tnl->save.attrsz[i]; - } - else - tnl->save.attrptr[i] = NULL; /* will not be dereferenced. */ - } - - /* Copy from current to repopulate the vertex with correct values. - */ - _save_copy_from_current( ctx ); - - /* Replay stored vertices to translate them to new format here. - * - * If there are copied vertices and the new (upgraded) attribute - * has not been defined before, this list is somewhat degenerate, - * and will need fixup at runtime. - */ - if (tnl->save.copied.nr) - { - GLfloat *data = tnl->save.copied.buffer; - GLfloat *dest = tnl->save.buffer; - GLuint j; - - /* Need to note this and fix up at runtime (or loopback): - */ - if (tnl->save.currentsz[attr][0] == 0) { - assert(oldsz == 0); - tnl->save.dangling_attr_ref = GL_TRUE; - -/* _mesa_debug(NULL, "_save_upgrade_vertex: dangling reference attr %d\n", */ -/* attr); */ - -#if 0 - /* The current strategy is to punt these degenerate cases - * through _tnl_loopback_vertex_list(), a lower-performance - * option. To minimize the impact of this, artificially - * reduce the size of this vertex_list. - */ - if (t->save.counter > 10) { - t->save.initial_counter = 10; - t->save.counter = 10; - } -#endif - } - - for (i = 0 ; i < tnl->save.copied.nr ; i++) { - for (j = 0 ; j < _TNL_ATTRIB_MAX ; j++) { - if (tnl->save.attrsz[j]) { - if (j == attr) { - if (oldsz) { - COPY_CLEAN_4V( dest, oldsz, data ); - data += oldsz; - dest += newsz; - } - else { - COPY_SZ_4V( dest, newsz, tnl->save.current[attr] ); - dest += newsz; - } - } - else { - GLint sz = tnl->save.attrsz[j]; - COPY_SZ_4V( dest, sz, data ); - data += sz; - dest += sz; - } - } - } - } - - tnl->save.vbptr = dest; - tnl->save.counter -= tnl->save.copied.nr; - } -} - - - - -/* Helper function for 'CHOOSE' macro. Do what's necessary when an - * entrypoint is called for the first time. - */ -static void do_choose( GLuint attr, GLuint sz, - void (*attr_func)( const GLfloat *), - void (*choose1)( const GLfloat *), - void (*choose2)( const GLfloat *), - void (*choose3)( const GLfloat *), - void (*choose4)( const GLfloat *), - const GLfloat *v ) -{ - GET_CURRENT_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - static GLfloat id[4] = { 0, 0, 0, 1 }; - int i; - - if (tnl->save.attrsz[attr] < sz) { - /* New size is larger. Need to flush existing vertices and get - * an enlarged vertex format. - */ - _save_upgrade_vertex( ctx, attr, sz ); - } - else { - /* New size is equal or smaller - just need to fill in some - * zeros. - */ - for (i = sz ; i <= tnl->save.attrsz[attr] ; i++) - tnl->save.attrptr[attr][i-1] = id[i-1]; - } - - /* Reset any active pointers for this attribute - */ - tnl->save.tabfv[attr][0] = choose1; - tnl->save.tabfv[attr][1] = choose2; - tnl->save.tabfv[attr][2] = choose3; - tnl->save.tabfv[attr][3] = choose4; - - /* Update the secondary dispatch table with the new function - */ - tnl->save.tabfv[attr][sz-1] = attr_func; - - (*attr_func)(v); -} - - - -/* Only one size for each attribute may be active at once. Eg. if - * Color3f is installed/active, then Color4f may not be, even if the - * vertex actually contains 4 color coordinates. This is because the - * 3f version won't otherwise set color[3] to 1.0 -- this is the job - * of the chooser function when switching between Color4f and Color3f. - */ -#define ATTRFV( ATTR, N ) \ -static void save_choose_##ATTR##_##N( const GLfloat *v ); \ - \ -static void save_attrib_##ATTR##_##N( const GLfloat *v ) \ -{ \ - GET_CURRENT_CONTEXT( ctx ); \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - \ - if ((ATTR) == 0) { \ - GLuint i; \ - \ - if (N>0) tnl->save.vbptr[0] = v[0]; \ - if (N>1) tnl->save.vbptr[1] = v[1]; \ - if (N>2) tnl->save.vbptr[2] = v[2]; \ - if (N>3) tnl->save.vbptr[3] = v[3]; \ - \ - for (i = N; i < tnl->save.vertex_size; i++) \ - tnl->save.vbptr[i] = tnl->save.vertex[i]; \ - \ - tnl->save.vbptr += tnl->save.vertex_size; \ - \ - if (--tnl->save.counter == 0) \ - _save_wrap_filled_vertex( ctx ); \ - } \ - else { \ - GLfloat *dest = tnl->save.attrptr[ATTR]; \ - if (N>0) dest[0] = v[0]; \ - if (N>1) dest[1] = v[1]; \ - if (N>2) dest[2] = v[2]; \ - if (N>3) dest[3] = v[3]; \ - } \ -} - -#define CHOOSE( ATTR, N ) \ -static void save_choose_##ATTR##_##N( const GLfloat *v ) \ -{ \ - do_choose(ATTR, N, \ - save_attrib_##ATTR##_##N, \ - save_choose_##ATTR##_1, \ - save_choose_##ATTR##_2, \ - save_choose_##ATTR##_3, \ - save_choose_##ATTR##_4, \ - v ); \ -} - -#define INIT(ATTR) \ -static void save_init_##ATTR( TNLcontext *tnl ) \ -{ \ - tnl->save.tabfv[ATTR][0] = save_choose_##ATTR##_1; \ - tnl->save.tabfv[ATTR][1] = save_choose_##ATTR##_2; \ - tnl->save.tabfv[ATTR][2] = save_choose_##ATTR##_3; \ - tnl->save.tabfv[ATTR][3] = save_choose_##ATTR##_4; \ -} - -#define ATTRS( ATTRIB ) \ - ATTRFV( ATTRIB, 1 ) \ - ATTRFV( ATTRIB, 2 ) \ - ATTRFV( ATTRIB, 3 ) \ - ATTRFV( ATTRIB, 4 ) \ - CHOOSE( ATTRIB, 1 ) \ - CHOOSE( ATTRIB, 2 ) \ - CHOOSE( ATTRIB, 3 ) \ - CHOOSE( ATTRIB, 4 ) \ - INIT( ATTRIB ) \ - - -/* Generate a lot of functions. These are the actual worker - * functions, which are equivalent to those generated via codegen - * elsewhere. - */ -ATTRS( 0 ) -ATTRS( 1 ) -ATTRS( 2 ) -ATTRS( 3 ) -ATTRS( 4 ) -ATTRS( 5 ) -ATTRS( 6 ) -ATTRS( 7 ) -ATTRS( 8 ) -ATTRS( 9 ) -ATTRS( 10 ) -ATTRS( 11 ) -ATTRS( 12 ) -ATTRS( 13 ) -ATTRS( 14 ) -ATTRS( 15 ) - -ATTRS( 16 ) -ATTRS( 17 ) -ATTRS( 18 ) -ATTRS( 19 ) -ATTRS( 20 ) -ATTRS( 21 ) -ATTRS( 22 ) -ATTRS( 23 ) -ATTRS( 24 ) -ATTRS( 25 ) -ATTRS( 26 ) -ATTRS( 27 ) -ATTRS( 28 ) -ATTRS( 29 ) -ATTRS( 30 ) -ATTRS( 31 ) - - -static void _save_reset_vertex( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint i; - - /* conventional attributes */ - save_init_0( tnl ); - save_init_1( tnl ); - save_init_2( tnl ); - save_init_3( tnl ); - save_init_4( tnl ); - save_init_5( tnl ); - save_init_6( tnl ); - save_init_7( tnl ); - save_init_8( tnl ); - save_init_9( tnl ); - save_init_10( tnl ); - save_init_11( tnl ); - save_init_12( tnl ); - save_init_13( tnl ); - save_init_14( tnl ); - save_init_15( tnl ); - - /* generic attributes */ - save_init_16( tnl ); - save_init_17( tnl ); - save_init_18( tnl ); - save_init_19( tnl ); - save_init_20( tnl ); - save_init_21( tnl ); - save_init_22( tnl ); - save_init_23( tnl ); - save_init_24( tnl ); - save_init_25( tnl ); - save_init_26( tnl ); - save_init_27( tnl ); - save_init_28( tnl ); - save_init_29( tnl ); - save_init_30( tnl ); - save_init_31( tnl ); - - for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++) - tnl->save.attrsz[i] = 0; - - tnl->save.vertex_size = 0; - tnl->save.have_materials = 0; - - _save_reset_counters( ctx ); -} - - - -/* Cope with aliasing of classic Vertex, Normal, etc. and the fan-out - * of glMultTexCoord and glProgramParamterNV by routing all these - * through a second level dispatch table. - */ -#define DISPATCH_ATTRFV( ATTR, COUNT, P ) \ -do { \ - GET_CURRENT_CONTEXT( ctx ); \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - tnl->save.tabfv[ATTR][COUNT-1]( P ); \ -} while (0) - -#define DISPATCH_ATTR1FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 1, V ) -#define DISPATCH_ATTR2FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 2, V ) -#define DISPATCH_ATTR3FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 3, V ) -#define DISPATCH_ATTR4FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 4, V ) - -#define DISPATCH_ATTR1F( ATTR, S ) DISPATCH_ATTRFV( ATTR, 1, &(S) ) - -#if defined(USE_X86_ASM) && 0 /* will break register calling convention */ -/* Naughty cheat: - */ -#define DISPATCH_ATTR2F( ATTR, S,T ) DISPATCH_ATTRFV( ATTR, 2, &(S) ) -#define DISPATCH_ATTR3F( ATTR, S,T,R ) DISPATCH_ATTRFV( ATTR, 3, &(S) ) -#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) DISPATCH_ATTRFV( ATTR, 4, &(S) ) -#else -/* Safe: - */ -#define DISPATCH_ATTR2F( ATTR, S,T ) \ -do { \ - GLfloat v[2]; \ - v[0] = S; v[1] = T; \ - DISPATCH_ATTR2FV( ATTR, v ); \ -} while (0) -#define DISPATCH_ATTR3F( ATTR, S,T,R ) \ -do { \ - GLfloat v[3]; \ - v[0] = S; v[1] = T; v[2] = R; \ - DISPATCH_ATTR3FV( ATTR, v ); \ -} while (0) -#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) \ -do { \ - GLfloat v[4]; \ - v[0] = S; v[1] = T; v[2] = R; v[3] = Q; \ - DISPATCH_ATTR4FV( ATTR, v ); \ -} while (0) -#endif - - -static void enum_error( void ) -{ - GET_CURRENT_CONTEXT( ctx ); - _mesa_compile_error( ctx, GL_INVALID_ENUM, "glVertexAttrib" ); -} - -static void GLAPIENTRY _save_Vertex2f( GLfloat x, GLfloat y ) -{ - DISPATCH_ATTR2F( _TNL_ATTRIB_POS, x, y ); -} - -static void GLAPIENTRY _save_Vertex2fv( const GLfloat *v ) -{ - DISPATCH_ATTR2FV( _TNL_ATTRIB_POS, v ); -} - -static void GLAPIENTRY _save_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) -{ - DISPATCH_ATTR3F( _TNL_ATTRIB_POS, x, y, z ); -} - -static void GLAPIENTRY _save_Vertex3fv( const GLfloat *v ) -{ - DISPATCH_ATTR3FV( _TNL_ATTRIB_POS, v ); -} - -static void GLAPIENTRY _save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - DISPATCH_ATTR4F( _TNL_ATTRIB_POS, x, y, z, w ); -} - -static void GLAPIENTRY _save_Vertex4fv( const GLfloat *v ) -{ - DISPATCH_ATTR4FV( _TNL_ATTRIB_POS, v ); -} - -static void GLAPIENTRY _save_TexCoord1f( GLfloat x ) -{ - DISPATCH_ATTR1F( _TNL_ATTRIB_TEX0, x ); -} - -static void GLAPIENTRY _save_TexCoord1fv( const GLfloat *v ) -{ - DISPATCH_ATTR1FV( _TNL_ATTRIB_TEX0, v ); -} - -static void GLAPIENTRY _save_TexCoord2f( GLfloat x, GLfloat y ) -{ - DISPATCH_ATTR2F( _TNL_ATTRIB_TEX0, x, y ); -} - -static void GLAPIENTRY _save_TexCoord2fv( const GLfloat *v ) -{ - DISPATCH_ATTR2FV( _TNL_ATTRIB_TEX0, v ); -} - -static void GLAPIENTRY _save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z ) -{ - DISPATCH_ATTR3F( _TNL_ATTRIB_TEX0, x, y, z ); -} - -static void GLAPIENTRY _save_TexCoord3fv( const GLfloat *v ) -{ - DISPATCH_ATTR3FV( _TNL_ATTRIB_TEX0, v ); -} - -static void GLAPIENTRY _save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - DISPATCH_ATTR4F( _TNL_ATTRIB_TEX0, x, y, z, w ); -} - -static void GLAPIENTRY _save_TexCoord4fv( const GLfloat *v ) -{ - DISPATCH_ATTR4FV( _TNL_ATTRIB_TEX0, v ); -} - -static void GLAPIENTRY _save_Normal3f( GLfloat x, GLfloat y, GLfloat z ) -{ - DISPATCH_ATTR3F( _TNL_ATTRIB_NORMAL, x, y, z ); -} - -static void GLAPIENTRY _save_Normal3fv( const GLfloat *v ) -{ - DISPATCH_ATTR3FV( _TNL_ATTRIB_NORMAL, v ); -} - -static void GLAPIENTRY _save_FogCoordfEXT( GLfloat x ) -{ - DISPATCH_ATTR1F( _TNL_ATTRIB_FOG, x ); -} - -static void GLAPIENTRY _save_FogCoordfvEXT( const GLfloat *v ) -{ - DISPATCH_ATTR1FV( _TNL_ATTRIB_FOG, v ); -} - -static void GLAPIENTRY _save_Color3f( GLfloat x, GLfloat y, GLfloat z ) -{ - DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR0, x, y, z ); -} - -static void GLAPIENTRY _save_Color3fv( const GLfloat *v ) -{ - DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR0, v ); -} - -static void GLAPIENTRY _save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - DISPATCH_ATTR4F( _TNL_ATTRIB_COLOR0, x, y, z, w ); -} - -static void GLAPIENTRY _save_Color4fv( const GLfloat *v ) -{ - DISPATCH_ATTR4FV( _TNL_ATTRIB_COLOR0, v ); -} - -static void GLAPIENTRY _save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z ) -{ - DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR1, x, y, z ); -} - -static void GLAPIENTRY _save_SecondaryColor3fvEXT( const GLfloat *v ) -{ - DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR1, v ); -} - -static void GLAPIENTRY _save_MultiTexCoord1f( GLenum target, GLfloat x ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR1F( attr, x ); -} - -static void GLAPIENTRY _save_MultiTexCoord1fv( GLenum target, const GLfloat *v ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR1FV( attr, v ); -} - -static void GLAPIENTRY _save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR2F( attr, x, y ); -} - -static void GLAPIENTRY _save_MultiTexCoord2fv( GLenum target, const GLfloat *v ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR2FV( attr, v ); -} - -static void GLAPIENTRY _save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y, - GLfloat z) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR3F( attr, x, y, z ); -} - -static void GLAPIENTRY _save_MultiTexCoord3fv( GLenum target, const GLfloat *v ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR3FV( attr, v ); -} - -static void GLAPIENTRY _save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y, - GLfloat z, GLfloat w ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR4F( attr, x, y, z, w ); -} - -static void GLAPIENTRY _save_MultiTexCoord4fv( GLenum target, const GLfloat *v ) -{ - GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0; - DISPATCH_ATTR4FV( attr, v ); -} - - - -static void GLAPIENTRY -_save_VertexAttrib1fNV(GLuint index, GLfloat x) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR1F( index, x ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib1fvNV(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR1FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR2F( index, x, y ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib2fvNV(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR2FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR3F( index, x, y, z ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib3fvNV(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR3FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR4F( index, x, y, z, w ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib4fvNV(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_PROGRAM_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR4FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib1fARB(GLuint index, GLfloat x) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR1F( index, x ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib1fvARB(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR1FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR2F( index, x, y ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib2fvARB(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR2FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR3F( index, x, y, z ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib3fvARB(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR3FV( index, v ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, - GLfloat z, GLfloat w) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR4F( index, x, y, z, w ); - } - else - enum_error(); -} - -static void GLAPIENTRY -_save_VertexAttrib4fvARB(GLuint index, const GLfloat *v) -{ - if (index < MAX_VERTEX_ATTRIBS) { - if (index > 0) - index += VERT_ATTRIB_GENERIC0; - DISPATCH_ATTR4FV( index, v ); - } - else - enum_error(); -} - - -/* Materials: - * - * These are treated as per-vertex attributes, at indices above where - * the NV_vertex_program leaves off. There are a lot of good things - * about treating materials this way. - * - * However: I don't want to double the number of generated functions - * just to cope with this, so I unroll the 'C' varients of CHOOSE and - * ATTRF into this function, and dispense with codegen and - * second-level dispatch. - * - * There is no aliasing of material attributes with other entrypoints. - */ -#define MAT_ATTR( A, N, params ) \ -do { \ - if (tnl->save.attrsz[A] < N) { \ - _save_upgrade_vertex( ctx, A, N ); \ - tnl->save.have_materials = GL_TRUE; \ - } \ - \ - { \ - GLfloat *dest = tnl->save.attrptr[A]; \ - if (N>0) dest[0] = params[0]; \ - if (N>1) dest[1] = params[1]; \ - if (N>2) dest[2] = params[2]; \ - if (N>3) dest[3] = params[3]; \ - } \ -} while (0) - - -#define MAT( ATTR, N, face, params ) \ -do { \ - if (face != GL_BACK) \ - MAT_ATTR( ATTR, N, params ); /* front */ \ - if (face != GL_FRONT) \ - MAT_ATTR( ATTR + 1, N, params ); /* back */ \ -} while (0) - - -/* NOTE: Have to remove/deal-with colormaterial crossovers, probably - * later on - in the meantime just store everything. - */ -static void GLAPIENTRY _save_Materialfv( GLenum face, GLenum pname, - const GLfloat *params ) -{ - GET_CURRENT_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - - switch (pname) { - case GL_EMISSION: - MAT( _TNL_ATTRIB_MAT_FRONT_EMISSION, 4, face, params ); - break; - case GL_AMBIENT: - MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params ); - break; - case GL_DIFFUSE: - MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params ); - break; - case GL_SPECULAR: - MAT( _TNL_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params ); - break; - case GL_SHININESS: - MAT( _TNL_ATTRIB_MAT_FRONT_SHININESS, 1, face, params ); - break; - case GL_COLOR_INDEXES: - MAT( _TNL_ATTRIB_MAT_FRONT_INDEXES, 3, face, params ); - break; - case GL_AMBIENT_AND_DIFFUSE: - MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params ); - MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params ); - break; - default: - _mesa_compile_error( ctx, GL_INVALID_ENUM, "glMaterialfv" ); - return; - } -} - - -#define IDX_ATTR( A, IDX ) \ -do { \ - GET_CURRENT_CONTEXT( ctx ); \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - \ - if (tnl->save.attrsz[A] < 1) { \ - _save_upgrade_vertex( ctx, A, 1 ); \ - } \ - \ - { \ - GLfloat *dest = tnl->save.attrptr[A]; \ - dest[0] = IDX; \ - } \ -} while (0) - - -static void GLAPIENTRY _save_EdgeFlag( GLboolean b ) -{ - IDX_ATTR( _TNL_ATTRIB_EDGEFLAG, (GLfloat)b ); -} - - -static void GLAPIENTRY _save_Indexf( GLfloat f ) -{ - IDX_ATTR( _TNL_ATTRIB_COLOR_INDEX, f ); -} - -static void GLAPIENTRY _save_Indexfv( const GLfloat *f ) -{ - IDX_ATTR( _TNL_ATTRIB_COLOR_INDEX, f[0] ); -} - - - - -/* Cope with EvalCoord/CallList called within a begin/end object: - * -- Flush current buffer - * -- Fallback to opcodes for the rest of the begin/end object. - */ -#define FALLBACK(ctx) \ -do { \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - \ - if (tnl->save.initial_counter != tnl->save.counter || \ - tnl->save.prim_count) \ - _save_compile_vertex_list( ctx ); \ - \ - _save_copy_to_current( ctx ); \ - _save_reset_vertex( ctx ); \ - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); \ - ctx->Driver.SaveNeedFlush = 0; \ -} while (0) - -static void GLAPIENTRY _save_EvalCoord1f( GLfloat u ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_EvalCoord1f(ctx->Save, ( u )); -} - -static void GLAPIENTRY _save_EvalCoord1fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_EvalCoord1fv(ctx->Save, ( v )); -} - -static void GLAPIENTRY _save_EvalCoord2f( GLfloat u, GLfloat v ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_EvalCoord2f(ctx->Save, ( u, v )); -} - -static void GLAPIENTRY _save_EvalCoord2fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_EvalCoord2fv(ctx->Save, ( v )); -} - -static void GLAPIENTRY _save_EvalPoint1( GLint i ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_EvalPoint1(ctx->Save, ( i )); -} - -static void GLAPIENTRY _save_EvalPoint2( GLint i, GLint j ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_EvalPoint2(ctx->Save, ( i, j )); -} - -static void GLAPIENTRY _save_CallList( GLuint l ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_CallList(ctx->Save, ( l )); -} - -static void GLAPIENTRY _save_CallLists( GLsizei n, GLenum type, const GLvoid *v ) -{ - GET_CURRENT_CONTEXT(ctx); - FALLBACK(ctx); - CALL_CallLists(ctx->Save, ( n, type, v )); -} - - - - -/** - * Called via ctx->Driver.NotifySaveBegin(ctx, mode) when we get a - * glBegin() call while compiling a display list. - * See save_Begin() in dlist.c - * - * This plugs in our special TNL-related display list functions. - * All subsequent glBegin/glVertex/glEnd()s found while compiling a - * display list will get routed to the functions in this file. - * - * Updating of ctx->Driver.CurrentSavePrimitive is already taken care of. - */ -static GLboolean _save_NotifyBegin( GLcontext *ctx, GLenum mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - if (1) { - GLuint i = tnl->save.prim_count++; - - assert(i < tnl->save.prim_max); - tnl->save.prim[i].mode = mode | PRIM_BEGIN; - tnl->save.prim[i].start = tnl->save.initial_counter - tnl->save.counter; - tnl->save.prim[i].count = 0; - - _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); - ctx->Driver.SaveNeedFlush = 1; - return GL_TRUE; - } - else - return GL_FALSE; -} - - - -static void GLAPIENTRY _save_End( void ) -{ - GET_CURRENT_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLint i = tnl->save.prim_count - 1; - - ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END; - if (ctx->ExecuteFlag) - ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END; - - tnl->save.prim[i].mode |= PRIM_END; - tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) - - tnl->save.prim[i].start); - - if (i == (GLint) tnl->save.prim_max - 1) { - _save_compile_vertex_list( ctx ); - assert(tnl->save.copied.nr == 0); - } - - /* Swap out this vertex format while outside begin/end. Any color, - * etc. received between here and the next begin will be compiled - * as opcodes. - */ - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); -} - - -/* These are all errors as this vtxfmt is only installed inside - * begin/end pairs. - */ -static void GLAPIENTRY _save_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; (void) count; (void) type; (void) indices; - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawElements" ); -} - - -static void GLAPIENTRY _save_DrawRangeElements(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; (void) start; (void) end; (void) count; (void) type; (void) indices; - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawRangeElements" ); -} - -static void GLAPIENTRY _save_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; (void) start; (void) count; - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawArrays" ); -} - -static void GLAPIENTRY _save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) -{ - GET_CURRENT_CONTEXT(ctx); - (void) x1; (void) y1; (void) x2; (void) y2; - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glRectf" ); -} - -static void GLAPIENTRY _save_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; (void) i1; (void) i2; - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh1" ); -} - -static void GLAPIENTRY _save_EvalMesh2( GLenum mode, GLint i1, GLint i2, - GLint j1, GLint j2 ) -{ - GET_CURRENT_CONTEXT(ctx); - (void) mode; (void) i1; (void) i2; (void) j1; (void) j2; - _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh2" ); -} - -/** - * This is only called if someone tries to compile nested glBegin()s - * in their display list. - */ -static void GLAPIENTRY _save_Begin( GLenum mode ) -{ - GET_CURRENT_CONTEXT( ctx ); - (void) mode; - _mesa_compile_error(ctx, GL_INVALID_OPERATION, - "glBegin(called inside glBegin/End)"); -} - - -/* Unlike the functions above, these are to be hooked into the vtxfmt - * maintained in ctx->ListState, active when the list is known or - * suspected to be outside any begin/end primitive. - */ -static void GLAPIENTRY _save_OBE_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) -{ - GET_CURRENT_CONTEXT(ctx); - _save_NotifyBegin( ctx, GL_QUADS | PRIM_WEAK ); - CALL_Vertex2f(GET_DISPATCH(), ( x1, y1 )); - CALL_Vertex2f(GET_DISPATCH(), ( x2, y1 )); - CALL_Vertex2f(GET_DISPATCH(), ( x2, y2 )); - CALL_Vertex2f(GET_DISPATCH(), ( x1, y2 )); - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) - return; - - _ae_map_vbos( ctx ); - - _save_NotifyBegin( ctx, mode | PRIM_WEAK ); - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (start + i)); - CALL_End(GET_DISPATCH(), ()); - - _ae_unmap_vbos( ctx ); -} - - -static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices )) - return; - - _ae_map_vbos( ctx ); - - _save_NotifyBegin( ctx, mode | PRIM_WEAK ); - - switch (type) { - case GL_UNSIGNED_BYTE: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] )); - break; - case GL_UNSIGNED_SHORT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] )); - break; - case GL_UNSIGNED_INT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] )); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); - break; - } - - CALL_End(GET_DISPATCH(), ()); - - _ae_unmap_vbos( ctx ); -} - -static void GLAPIENTRY _save_OBE_DrawRangeElements(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - if (_mesa_validate_DrawRangeElements( ctx, mode, - start, end, - count, type, indices )) - _save_OBE_DrawElements( mode, count, type, indices ); -} - - - - - -static void _save_vtxfmt_init( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLvertexformat *vfmt = &tnl->save_vtxfmt; - - vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */ - vfmt->Begin = _save_Begin; - vfmt->Color3f = _save_Color3f; - vfmt->Color3fv = _save_Color3fv; - vfmt->Color4f = _save_Color4f; - vfmt->Color4fv = _save_Color4fv; - vfmt->EdgeFlag = _save_EdgeFlag; - vfmt->End = _save_End; - vfmt->FogCoordfEXT = _save_FogCoordfEXT; - vfmt->FogCoordfvEXT = _save_FogCoordfvEXT; - vfmt->Indexf = _save_Indexf; - vfmt->Indexfv = _save_Indexfv; - vfmt->Materialfv = _save_Materialfv; - vfmt->MultiTexCoord1fARB = _save_MultiTexCoord1f; - vfmt->MultiTexCoord1fvARB = _save_MultiTexCoord1fv; - vfmt->MultiTexCoord2fARB = _save_MultiTexCoord2f; - vfmt->MultiTexCoord2fvARB = _save_MultiTexCoord2fv; - vfmt->MultiTexCoord3fARB = _save_MultiTexCoord3f; - vfmt->MultiTexCoord3fvARB = _save_MultiTexCoord3fv; - vfmt->MultiTexCoord4fARB = _save_MultiTexCoord4f; - vfmt->MultiTexCoord4fvARB = _save_MultiTexCoord4fv; - vfmt->Normal3f = _save_Normal3f; - vfmt->Normal3fv = _save_Normal3fv; - vfmt->SecondaryColor3fEXT = _save_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = _save_SecondaryColor3fvEXT; - vfmt->TexCoord1f = _save_TexCoord1f; - vfmt->TexCoord1fv = _save_TexCoord1fv; - vfmt->TexCoord2f = _save_TexCoord2f; - vfmt->TexCoord2fv = _save_TexCoord2fv; - vfmt->TexCoord3f = _save_TexCoord3f; - vfmt->TexCoord3fv = _save_TexCoord3fv; - vfmt->TexCoord4f = _save_TexCoord4f; - vfmt->TexCoord4fv = _save_TexCoord4fv; - vfmt->Vertex2f = _save_Vertex2f; - vfmt->Vertex2fv = _save_Vertex2fv; - vfmt->Vertex3f = _save_Vertex3f; - vfmt->Vertex3fv = _save_Vertex3fv; - vfmt->Vertex4f = _save_Vertex4f; - vfmt->Vertex4fv = _save_Vertex4fv; - vfmt->VertexAttrib1fNV = _save_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = _save_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = _save_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = _save_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = _save_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = _save_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = _save_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = _save_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = _save_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = _save_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = _save_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = _save_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = _save_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = _save_VertexAttrib4fvARB; - - /* This will all require us to fallback to saving the list as opcodes: - */ - vfmt->CallList = _save_CallList; /* inside begin/end */ - vfmt->CallLists = _save_CallLists; /* inside begin/end */ - vfmt->EvalCoord1f = _save_EvalCoord1f; - vfmt->EvalCoord1fv = _save_EvalCoord1fv; - vfmt->EvalCoord2f = _save_EvalCoord2f; - vfmt->EvalCoord2fv = _save_EvalCoord2fv; - vfmt->EvalPoint1 = _save_EvalPoint1; - vfmt->EvalPoint2 = _save_EvalPoint2; - - /* These are all errors as we at least know we are in some sort of - * begin/end pair: - */ - vfmt->EvalMesh1 = _save_EvalMesh1; - vfmt->EvalMesh2 = _save_EvalMesh2; - vfmt->Begin = _save_Begin; - vfmt->Rectf = _save_Rectf; - vfmt->DrawArrays = _save_DrawArrays; - vfmt->DrawElements = _save_DrawElements; - vfmt->DrawRangeElements = _save_DrawRangeElements; - -} - - -void _tnl_SaveFlushVertices( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Noop when we are actually active: - */ - if (ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM || - ctx->Driver.CurrentSavePrimitive <= GL_POLYGON) - return; - - if (tnl->save.initial_counter != tnl->save.counter || - tnl->save.prim_count) - _save_compile_vertex_list( ctx ); - - _save_copy_to_current( ctx ); - _save_reset_vertex( ctx ); - ctx->Driver.SaveNeedFlush = 0; -} - -void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - (void) list; (void) mode; - - if (!tnl->save.prim_store) - tnl->save.prim_store = alloc_prim_store( ctx ); - - if (!tnl->save.vertex_store) { - tnl->save.vertex_store = alloc_vertex_store( ctx ); - tnl->save.vbptr = tnl->save.vertex_store->buffer; - } - - _save_reset_vertex( ctx ); - ctx->Driver.SaveNeedFlush = 0; -} - -void _tnl_EndList( GLcontext *ctx ) -{ - (void) ctx; - assert(TNL_CONTEXT(ctx)->save.vertex_size == 0); -} - -void _tnl_BeginCallList( GLcontext *ctx, struct mesa_display_list *dlist ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->save.replay_flags |= dlist->flags; - tnl->save.replay_flags |= tnl->LoopbackDListCassettes; -} - -void _tnl_EndCallList( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - if (ctx->ListState.CallDepth == 1) - tnl->save.replay_flags = 0; -} - - -static void _tnl_destroy_vertex_list( GLcontext *ctx, void *data ) -{ - struct tnl_vertex_list *node = (struct tnl_vertex_list *)data; - (void) ctx; - - if ( --node->vertex_store->refcount == 0 ) - FREE( node->vertex_store ); - - if ( --node->prim_store->refcount == 0 ) - FREE( node->prim_store ); - - if ( node->normal_lengths ) - FREE( node->normal_lengths ); -} - - -static void _tnl_print_vertex_list( GLcontext *ctx, void *data ) -{ - struct tnl_vertex_list *node = (struct tnl_vertex_list *)data; - GLuint i; - (void) ctx; - - _mesa_debug(NULL, "TNL-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 tnl_prim *prim = &node->prim[i]; - _mesa_debug(NULL, " prim %d: %s %d..%d %s %s\n", - i, - _mesa_lookup_enum_by_nr(prim->mode & PRIM_MODE_MASK), - prim->start, - prim->start + prim->count, - (prim->mode & PRIM_BEGIN) ? "BEGIN" : "(wrap)", - (prim->mode & PRIM_END) ? "END" : "(wrap)"); - } -} - - -static void _save_current_init( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLint i; - - for (i = 0; i < _TNL_ATTRIB_MAT_FRONT_AMBIENT; i++) { - ASSERT(i < VERT_ATTRIB_MAX); - tnl->save.currentsz[i] = &ctx->ListState.ActiveAttribSize[i]; - tnl->save.current[i] = ctx->ListState.CurrentAttrib[i]; - } - - for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++) { - const GLuint j = i - _TNL_FIRST_MAT; - ASSERT(j < MAT_ATTRIB_MAX); - tnl->save.currentsz[i] = &ctx->ListState.ActiveMaterialSize[j]; - tnl->save.current[i] = ctx->ListState.CurrentMaterial[j]; - } - - tnl->save.currentsz[_TNL_ATTRIB_EDGEFLAG] = &ctx->ListState.ActiveEdgeFlag; - tnl->save.current[_TNL_ATTRIB_EDGEFLAG] = &tnl->save.CurrentFloatEdgeFlag; -} - -/** - * Initialize the display list compiler - */ -void _tnl_save_init( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct tnl_vertex_arrays *tmp = &tnl->save_inputs; - GLuint i; - - - for (i = 0; i < _TNL_ATTRIB_MAX; i++) - _mesa_vector4f_init( &tmp->Attribs[i], 0, NULL); - - tnl->save.opcode_vertex_list = - _mesa_alloc_opcode( ctx, - sizeof(struct tnl_vertex_list), - _tnl_playback_vertex_list, - _tnl_destroy_vertex_list, - _tnl_print_vertex_list ); - - ctx->Driver.NotifySaveBegin = _save_NotifyBegin; - - _save_vtxfmt_init( ctx ); - _save_current_init( ctx ); - - /* Hook our array functions into the outside-begin-end vtxfmt in - * ctx->ListState. - */ - ctx->ListState.ListVtxfmt.Rectf = _save_OBE_Rectf; - ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays; - ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements; - ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements; - _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); -} - - -/** - * Deallocate the immediate-mode buffer for the given context, if - * its reference count goes to zero. - */ -void _tnl_save_destroy( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Decrement the refcounts. References may still be held by - * display lists yet to be destroyed, so it may not yet be time to - * free these items. - */ - if (tnl->save.prim_store && - --tnl->save.prim_store->refcount == 0 ) - FREE( tnl->save.prim_store ); - - if (tnl->save.vertex_store && - --tnl->save.vertex_store->refcount == 0 ) - FREE( tnl->save.vertex_store ); -} -- cgit v1.2.3 From 37aca21129d87946d2dc6b45fa5bacd514921550 Mon Sep 17 00:00:00 2001 From: zhang Date: Thu, 28 Jun 2007 08:12:52 -0600 Subject: a variety of fixes for MingW --- Makefile.mgw | 25 +++- include/GL/glu.h | 13 +++ include/GL/glut.h | 8 +- src/glu/sgi/libnurbs/nurbtess/monoTriangulation.h | 3 +- src/glut/glx/glut_input.c | 3 + src/glut/glx/glut_joy.c | 3 + src/glut/glx/win32_util.c | 1 + src/glut/glx/win32_x11.h | 10 +- src/mesa/drivers/windows/gdi/wgl.c | 6 + src/mesa/drivers/windows/gdi/wmesa.c | 132 +++++++++++----------- src/mesa/main/glheader.h | 3 + src/mesa/vbo/vbo_exec_api.c | 5 + src/mesa/vbo/vbo_save_api.c | 4 + 13 files changed, 136 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/Makefile.mgw b/Makefile.mgw index 70c264a8d86..948860890c0 100644 --- a/Makefile.mgw +++ b/Makefile.mgw @@ -51,16 +51,23 @@ # realclean: remove all generated files # +# MinGW core makefile updated for Mesa 7.0 +# +# updated : by Heromyth, 2007-6-25 +# Email : zxpmyth@yahoo.com.cn +# Bug : All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. + .PHONY : all libgl clean realclean ifeq ($(ICD),1) # when -std=c99 mingw will not define WIN32 - CFLAGS = -Wall -W -Werror + CFLAGS = -Wall -Werror else # I love c89 - CFLAGS = -Wall -W -pedantic + CFLAGS = -Wall -pedantic endif CFLAGS += -O2 -ffast-math @@ -72,16 +79,28 @@ else UNLINK = $(RM) $(1) endif -all: libgl +all: libgl libglu libglut libgl: lib $(MAKE) -f Makefile.mgw -C src/mesa +libglu: libgl + $(MAKE) -f Makefile.mgw -C src/glu/sgi + +libglut: libglu + $(MAKE) -f Makefile.mgw -C src/glut/glx + +example: libglut + $(MAKE) -f Makefile.mgw star -C progs/samples + copy progs\samples\star.exe lib + lib: mkdir lib clean: $(MAKE) -f Makefile.mgw clean -C src/mesa + $(MAKE) -f Makefile.mgw clean -C src/glu/sgi + $(MAKE) -f Makefile.mgw clean -C src/glut/glx realclean: clean -$(call UNLINK,lib/*.a) diff --git a/include/GL/glu.h b/include/GL/glu.h index c0bac75a8cc..d82103d141a 100644 --- a/include/GL/glu.h +++ b/include/GL/glu.h @@ -44,6 +44,19 @@ #define GLAPIENTRYP GLAPIENTRY * #endif +#ifdef GLAPI +#undef GLAPI +#endif + +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32) +# define GLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ + + #ifndef GLAPI #define GLAPI #endif diff --git a/include/GL/glut.h b/include/GL/glut.h index 23c740ee117..e0fad6e5cb0 100644 --- a/include/GL/glut.h +++ b/include/GL/glut.h @@ -115,7 +115,7 @@ extern _CRTIMP void __cdecl exit(int); #endif /* GLUT API entry point declarations for Win32. */ -#if defined(GLUT_BUILDING_LIB) && defined(_DLL) +#if (defined(BUILD_GLUT32) || defined(GLUT_BUILDING_LIB)) && defined(_DLL) # define GLUTAPI __declspec(dllexport) #elif defined(_DLL) # define GLUTAPI __declspec(dllimport) @@ -131,8 +131,10 @@ extern _CRTIMP void __cdecl exit(int); # endif # define CALLBACK __stdcall typedef int (GLUTAPIENTRY *PROC)(); -typedef void *HGLRC; -typedef void *HDC; +#if !defined(__MINGW32__) + typedef void *HGLRC; + typedef void *HDC; +#endif typedef unsigned long COLORREF; #endif diff --git a/src/glu/sgi/libnurbs/nurbtess/monoTriangulation.h b/src/glu/sgi/libnurbs/nurbtess/monoTriangulation.h index 7ff77394341..002549ecbd7 100644 --- a/src/glu/sgi/libnurbs/nurbtess/monoTriangulation.h +++ b/src/glu/sgi/libnurbs/nurbtess/monoTriangulation.h @@ -43,10 +43,9 @@ #include "definitions.h" #include "primitiveStream.h" #include "directedLine.h" +#include "arc.h" class Backend; -class Arc; -typedef Arc *Arc_ptr; class reflexChain{ Real2 *queue; diff --git a/src/glut/glx/glut_input.c b/src/glut/glx/glut_input.c index add3df7c3fd..a76ff9a435e 100644 --- a/src/glut/glx/glut_input.c +++ b/src/glut/glx/glut_input.c @@ -23,6 +23,9 @@ #endif #include #else +#ifdef __MINGW32__ +#include +#endif #include #ifndef __CYGWIN32__ #include /* Win32 Multimedia API header. */ diff --git a/src/glut/glx/glut_joy.c b/src/glut/glx/glut_joy.c index a4528ae1ce4..5025607922c 100644 --- a/src/glut/glx/glut_joy.c +++ b/src/glut/glx/glut_joy.c @@ -6,6 +6,9 @@ implied. This program is -not- in the public domain. */ #ifdef _WIN32 +#ifdef __MINGW32__ +#include +#endif #include #ifndef __CYGWIN32__ #include /* Win32 Multimedia API header. */ diff --git a/src/glut/glx/win32_util.c b/src/glut/glx/win32_util.c index becd823a409..25af48a1125 100644 --- a/src/glut/glx/win32_util.c +++ b/src/glut/glx/win32_util.c @@ -15,6 +15,7 @@ /* The following added by Paul Garceau */ #if defined(__MINGW32__) +#include #include #include struct timeval; diff --git a/src/glut/glx/win32_x11.h b/src/glut/glx/win32_x11.h index 1d8d048b2e0..6f5c3a9aeaf 100644 --- a/src/glut/glx/win32_x11.h +++ b/src/glut/glx/win32_x11.h @@ -6,16 +6,14 @@ /* This program is freely distributable without licensing fees and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ - +#ifdef __MINGW32__ +#include +#endif #include #include /* These definitions are missing from windows.h */ -WINGDIAPI int WINAPI wglChoosePixelFormat(HDC, PIXELFORMATDESCRIPTOR *); -WINGDIAPI int WINAPI wglDescribePixelFormat(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR); -WINGDIAPI int WINAPI wglGetPixelFormat(HDC); -WINGDIAPI BOOL WINAPI wglSetPixelFormat(HDC, int, PIXELFORMATDESCRIPTOR *); -WINGDIAPI BOOL WINAPI wglSwapBuffers(HDC); + /* Type definitions (conversions) */ typedef int Visual; /* Win32 equivalent of X11 type */ diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index 197de0743c7..49b4ddbd1f9 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -32,8 +32,14 @@ /* We're essentially building part of GDI here, so define this so that * we get the right export linkage. */ +#ifdef __MINGW32__ +#include +#include +#else #define _GDI32_ +#endif #include + #include "glapi.h" #include "GL/wmesa.h" /* protos for wmesa* functions */ diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index c5cd2c615b7..2eec188912e 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -1404,70 +1404,70 @@ void WMesaSwapBuffers( HDC hdc ) * table entries. Hopefully, I'll find a better solution. The * dispatch table generation scripts ought to be making these dummy * stubs as well. */ -void gl_dispatch_stub_543(void){}; -void gl_dispatch_stub_544(void){}; -void gl_dispatch_stub_545(void){}; -void gl_dispatch_stub_546(void){}; -void gl_dispatch_stub_547(void){}; -void gl_dispatch_stub_548(void){}; -void gl_dispatch_stub_549(void){}; -void gl_dispatch_stub_550(void){}; -void gl_dispatch_stub_551(void){}; -void gl_dispatch_stub_552(void){}; -void gl_dispatch_stub_553(void){}; -void gl_dispatch_stub_554(void){}; -void gl_dispatch_stub_555(void){}; -void gl_dispatch_stub_556(void){}; -void gl_dispatch_stub_557(void){}; -void gl_dispatch_stub_558(void){}; -void gl_dispatch_stub_559(void){}; -void gl_dispatch_stub_560(void){}; -void gl_dispatch_stub_561(void){}; -void gl_dispatch_stub_565(void){}; -void gl_dispatch_stub_566(void){}; -void gl_dispatch_stub_577(void){}; -void gl_dispatch_stub_578(void){}; -void gl_dispatch_stub_603(void){}; -void gl_dispatch_stub_645(void){}; -void gl_dispatch_stub_646(void){}; -void gl_dispatch_stub_647(void){}; -void gl_dispatch_stub_648(void){}; -void gl_dispatch_stub_649(void){}; -void gl_dispatch_stub_650(void){}; -void gl_dispatch_stub_651(void){}; -void gl_dispatch_stub_652(void){}; -void gl_dispatch_stub_653(void){}; -void gl_dispatch_stub_734(void){}; -void gl_dispatch_stub_735(void){}; -void gl_dispatch_stub_736(void){}; -void gl_dispatch_stub_737(void){}; -void gl_dispatch_stub_738(void){}; -void gl_dispatch_stub_745(void){}; -void gl_dispatch_stub_746(void){}; -void gl_dispatch_stub_760(void){}; -void gl_dispatch_stub_761(void){}; -void gl_dispatch_stub_766(void){}; -void gl_dispatch_stub_767(void){}; -void gl_dispatch_stub_768(void){}; - -void gl_dispatch_stub_562(void){}; -void gl_dispatch_stub_563(void){}; -void gl_dispatch_stub_564(void){}; -void gl_dispatch_stub_567(void){}; -void gl_dispatch_stub_568(void){}; -void gl_dispatch_stub_569(void){}; -void gl_dispatch_stub_580(void){}; -void gl_dispatch_stub_581(void){}; -void gl_dispatch_stub_606(void){}; -void gl_dispatch_stub_654(void){}; -void gl_dispatch_stub_655(void){}; -void gl_dispatch_stub_656(void){}; -void gl_dispatch_stub_739(void){}; -void gl_dispatch_stub_740(void){}; -void gl_dispatch_stub_741(void){}; -void gl_dispatch_stub_748(void){}; -void gl_dispatch_stub_749(void){}; -void gl_dispatch_stub_769(void){}; -void gl_dispatch_stub_770(void){}; -void gl_dispatch_stub_771(void){}; +void gl_dispatch_stub_543(void){} +void gl_dispatch_stub_544(void){} +void gl_dispatch_stub_545(void){} +void gl_dispatch_stub_546(void){} +void gl_dispatch_stub_547(void){} +void gl_dispatch_stub_548(void){} +void gl_dispatch_stub_549(void){} +void gl_dispatch_stub_550(void){} +void gl_dispatch_stub_551(void){} +void gl_dispatch_stub_552(void){} +void gl_dispatch_stub_553(void){} +void gl_dispatch_stub_554(void){} +void gl_dispatch_stub_555(void){} +void gl_dispatch_stub_556(void){} +void gl_dispatch_stub_557(void){} +void gl_dispatch_stub_558(void){} +void gl_dispatch_stub_559(void){} +void gl_dispatch_stub_560(void){} +void gl_dispatch_stub_561(void){} +void gl_dispatch_stub_565(void){} +void gl_dispatch_stub_566(void){} +void gl_dispatch_stub_577(void){} +void gl_dispatch_stub_578(void){} +void gl_dispatch_stub_603(void){} +void gl_dispatch_stub_645(void){} +void gl_dispatch_stub_646(void){} +void gl_dispatch_stub_647(void){} +void gl_dispatch_stub_648(void){} +void gl_dispatch_stub_649(void){} +void gl_dispatch_stub_650(void){} +void gl_dispatch_stub_651(void){} +void gl_dispatch_stub_652(void){} +void gl_dispatch_stub_653(void){} +void gl_dispatch_stub_734(void){} +void gl_dispatch_stub_735(void){} +void gl_dispatch_stub_736(void){} +void gl_dispatch_stub_737(void){} +void gl_dispatch_stub_738(void){} +void gl_dispatch_stub_745(void){} +void gl_dispatch_stub_746(void){} +void gl_dispatch_stub_760(void){} +void gl_dispatch_stub_761(void){} +void gl_dispatch_stub_766(void){} +void gl_dispatch_stub_767(void){} +void gl_dispatch_stub_768(void){} + +void gl_dispatch_stub_562(void){} +void gl_dispatch_stub_563(void){} +void gl_dispatch_stub_564(void){} +void gl_dispatch_stub_567(void){} +void gl_dispatch_stub_568(void){} +void gl_dispatch_stub_569(void){} +void gl_dispatch_stub_580(void){} +void gl_dispatch_stub_581(void){} +void gl_dispatch_stub_606(void){} +void gl_dispatch_stub_654(void){} +void gl_dispatch_stub_655(void){} +void gl_dispatch_stub_656(void){} +void gl_dispatch_stub_739(void){} +void gl_dispatch_stub_740(void){} +void gl_dispatch_stub_741(void){} +void gl_dispatch_stub_748(void){} +void gl_dispatch_stub_749(void){} +void gl_dispatch_stub_769(void){} +void gl_dispatch_stub_770(void){} +void gl_dispatch_stub_771(void){} diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 5abea137d74..63dd002a412 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -91,6 +91,9 @@ # pragma disable_message(201) /* Disable unreachable code warnings */ #endif +#ifdef WGLAPI +#undef WGLAPI +#endif #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) # if !defined(__GNUC__) /* mingw environment */ diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 8d13ef9d081..2d4ded0f984 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -43,6 +43,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo_context.h" +#ifdef ERROR +#undef ERROR +#endif + + static void reset_attrfv( struct vbo_exec_context *exec ); diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index c08fd1fe555..e7794c2a6cc 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -80,6 +80,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo_context.h" +#ifdef ERROR +#undef ERROR +#endif + /* * NOTE: Old 'parity' issue is gone, but copying can still be -- cgit v1.2.3 From 767cac149441ee0a8423713a9817c7ac154cbf9e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 28 Jun 2007 16:34:40 -0600 Subject: Add a few missing GL 2.0 entrypoints, regenerate related files. Specifically: glVertexAttrib4bv glVertexAttrib4iv glVertexAttrib4ubv glVertexAttrib4uiv glVertexAttrib4usv --- src/mesa/drivers/dri/common/extension_helper.h | 20 +- src/mesa/glapi/gl_API.xml | 21 +- src/mesa/glapi/glapitemp.h | 30 +++ src/mesa/glapi/glprocs.h | 282 +++++++++++++------------ src/mesa/sparc/glapi_sparc.S | 5 + src/mesa/x86-64/glapi_x86-64.S | 5 + src/mesa/x86/glapi_x86.S | 6 + 7 files changed, 227 insertions(+), 142 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/extension_helper.h b/src/mesa/drivers/dri/common/extension_helper.h index 10f75edaaa4..bf103a3931f 100644 --- a/src/mesa/drivers/dri/common/extension_helper.h +++ b/src/mesa/drivers/dri/common/extension_helper.h @@ -1478,9 +1478,10 @@ static const char ImageTransformParameterfvHP_names[] = ""; #endif -#if defined(need_GL_ARB_vertex_program) +#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program) static const char VertexAttrib4ivARB_names[] = "ip\0" /* Parameter signature */ + "glVertexAttrib4iv\0" "glVertexAttrib4ivARB\0" ""; #endif @@ -1586,9 +1587,10 @@ static const char PixelTransformParameterfvEXT_names[] = ""; #endif -#if defined(need_GL_ARB_vertex_program) +#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program) static const char VertexAttrib4bvARB_names[] = "ip\0" /* Parameter signature */ + "glVertexAttrib4bv\0" "glVertexAttrib4bvARB\0" ""; #endif @@ -2391,9 +2393,10 @@ static const char GetAttribLocationARB_names[] = ""; #endif -#if defined(need_GL_ARB_vertex_program) +#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program) static const char VertexAttrib4ubvARB_names[] = "ip\0" /* Parameter signature */ + "glVertexAttrib4ubv\0" "glVertexAttrib4ubvARB\0" ""; #endif @@ -2910,9 +2913,10 @@ static const char ReplacementCodeuiColor4ubVertex3fSUN_names[] = ""; #endif -#if defined(need_GL_ARB_vertex_program) +#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program) static const char VertexAttrib4usvARB_names[] = "ip\0" /* Parameter signature */ + "glVertexAttrib4usv\0" "glVertexAttrib4usvARB\0" ""; #endif @@ -4393,9 +4397,10 @@ static const char WindowPos4iMESA_names[] = ""; #endif -#if defined(need_GL_ARB_vertex_program) +#if defined(need_GL_VERSION_2_0) || defined(need_GL_ARB_vertex_program) static const char VertexAttrib4uivARB_names[] = "ip\0" /* Parameter signature */ + "glVertexAttrib4uiv\0" "glVertexAttrib4uivARB\0" ""; #endif @@ -6257,6 +6262,8 @@ static const struct dri_extension_function GL_VERSION_2_0_functions[] = { { GetVertexAttribivARB_names, GetVertexAttribivARB_remap_index, -1 }, { CreateProgram_names, CreateProgram_remap_index, -1 }, { StencilFuncSeparate_names, StencilFuncSeparate_remap_index, -1 }, + { VertexAttrib4ivARB_names, VertexAttrib4ivARB_remap_index, -1 }, + { VertexAttrib4bvARB_names, VertexAttrib4bvARB_remap_index, -1 }, { VertexAttrib3dARB_names, VertexAttrib3dARB_remap_index, -1 }, { VertexAttrib4fARB_names, VertexAttrib4fARB_remap_index, -1 }, { VertexAttrib4fvARB_names, VertexAttrib4fvARB_remap_index, -1 }, @@ -6270,6 +6277,7 @@ static const struct dri_extension_function GL_VERSION_2_0_functions[] = { { VertexAttrib1dvARB_names, VertexAttrib1dvARB_remap_index, -1 }, { GetVertexAttribfvARB_names, GetVertexAttribfvARB_remap_index, -1 }, { GetAttribLocationARB_names, GetAttribLocationARB_remap_index, -1 }, + { VertexAttrib4ubvARB_names, VertexAttrib4ubvARB_remap_index, -1 }, { Uniform3ivARB_names, Uniform3ivARB_remap_index, -1 }, { VertexAttrib4sARB_names, VertexAttrib4sARB_remap_index, -1 }, { VertexAttrib2dvARB_names, VertexAttrib2dvARB_remap_index, -1 }, @@ -6282,6 +6290,7 @@ static const struct dri_extension_function GL_VERSION_2_0_functions[] = { { VertexAttrib4NuivARB_names, VertexAttrib4NuivARB_remap_index, -1 }, { Uniform4fARB_names, Uniform4fARB_remap_index, -1 }, { VertexAttrib1dARB_names, VertexAttrib1dARB_remap_index, -1 }, + { VertexAttrib4usvARB_names, VertexAttrib4usvARB_remap_index, -1 }, { LinkProgramARB_names, LinkProgramARB_remap_index, -1 }, { ShaderSourceARB_names, ShaderSourceARB_remap_index, -1 }, { VertexAttrib3svARB_names, VertexAttrib3svARB_remap_index, -1 }, @@ -6311,6 +6320,7 @@ static const struct dri_extension_function GL_VERSION_2_0_functions[] = { { DrawBuffersARB_names, DrawBuffersARB_remap_index, -1 }, { Uniform1fvARB_names, Uniform1fvARB_remap_index, -1 }, { EnableVertexAttribArrayARB_names, EnableVertexAttribArrayARB_remap_index, -1 }, + { VertexAttrib4uivARB_names, VertexAttrib4uivARB_remap_index, -1 }, { VertexAttrib4svARB_names, VertexAttrib4svARB_remap_index, -1 }, { GetShaderiv_names, GetShaderiv_remap_index, -1 }, { VertexAttrib2svARB_names, VertexAttrib2svARB_remap_index, -1 }, diff --git a/src/mesa/glapi/gl_API.xml b/src/mesa/glapi/gl_API.xml index c7b48c45b51..4bd3b2f0fb7 100644 --- a/src/mesa/glapi/gl_API.xml +++ b/src/mesa/glapi/gl_API.xml @@ -5605,7 +5605,10 @@ - + + + + @@ -5628,6 +5631,10 @@ + + + + @@ -5639,6 +5646,18 @@ + + + + + + + + + + + + diff --git a/src/mesa/glapi/glapitemp.h b/src/mesa/glapi/glapitemp.h index 2a2fe2a35df..10af9b30858 100644 --- a/src/mesa/glapi/glapitemp.h +++ b/src/mesa/glapi/glapitemp.h @@ -3284,6 +3284,11 @@ KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NusvARB)(GLuint index, const GLushort * DISPATCH(VertexAttrib4NusvARB, (index, v), (F, "glVertexAttrib4NusvARB(%d, %p);\n", index, (const void *) v)); } +KEYWORD1 void KEYWORD2 NAME(VertexAttrib4bv)(GLuint index, const GLbyte * v) +{ + DISPATCH(VertexAttrib4bvARB, (index, v), (F, "glVertexAttrib4bv(%d, %p);\n", index, (const void *) v)); +} + KEYWORD1 void KEYWORD2 NAME(VertexAttrib4bvARB)(GLuint index, const GLbyte * v) { DISPATCH(VertexAttrib4bvARB, (index, v), (F, "glVertexAttrib4bvARB(%d, %p);\n", index, (const void *) v)); @@ -3329,6 +3334,11 @@ KEYWORD1 void KEYWORD2 NAME(VertexAttrib4fvARB)(GLuint index, const GLfloat * v) DISPATCH(VertexAttrib4fvARB, (index, v), (F, "glVertexAttrib4fvARB(%d, %p);\n", index, (const void *) v)); } +KEYWORD1 void KEYWORD2 NAME(VertexAttrib4iv)(GLuint index, const GLint * v) +{ + DISPATCH(VertexAttrib4ivARB, (index, v), (F, "glVertexAttrib4iv(%d, %p);\n", index, (const void *) v)); +} + KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ivARB)(GLuint index, const GLint * v) { DISPATCH(VertexAttrib4ivARB, (index, v), (F, "glVertexAttrib4ivARB(%d, %p);\n", index, (const void *) v)); @@ -3354,16 +3364,31 @@ KEYWORD1 void KEYWORD2 NAME(VertexAttrib4svARB)(GLuint index, const GLshort * v) DISPATCH(VertexAttrib4svARB, (index, v), (F, "glVertexAttrib4svARB(%d, %p);\n", index, (const void *) v)); } +KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ubv)(GLuint index, const GLubyte * v) +{ + DISPATCH(VertexAttrib4ubvARB, (index, v), (F, "glVertexAttrib4ubv(%d, %p);\n", index, (const void *) v)); +} + KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ubvARB)(GLuint index, const GLubyte * v) { DISPATCH(VertexAttrib4ubvARB, (index, v), (F, "glVertexAttrib4ubvARB(%d, %p);\n", index, (const void *) v)); } +KEYWORD1 void KEYWORD2 NAME(VertexAttrib4uiv)(GLuint index, const GLuint * v) +{ + DISPATCH(VertexAttrib4uivARB, (index, v), (F, "glVertexAttrib4uiv(%d, %p);\n", index, (const void *) v)); +} + KEYWORD1 void KEYWORD2 NAME(VertexAttrib4uivARB)(GLuint index, const GLuint * v) { DISPATCH(VertexAttrib4uivARB, (index, v), (F, "glVertexAttrib4uivARB(%d, %p);\n", index, (const void *) v)); } +KEYWORD1 void KEYWORD2 NAME(VertexAttrib4usv)(GLuint index, const GLushort * v) +{ + DISPATCH(VertexAttrib4usvARB, (index, v), (F, "glVertexAttrib4usv(%d, %p);\n", index, (const void *) v)); +} + KEYWORD1 void KEYWORD2 NAME(VertexAttrib4usvARB)(GLuint index, const GLushort * v) { DISPATCH(VertexAttrib4usvARB, (index, v), (F, "glVertexAttrib4usvARB(%d, %p);\n", index, (const void *) v)); @@ -6464,12 +6489,17 @@ static _glapi_proc UNUSED_TABLE_NAME[] = { TABLE_ENTRY(VertexAttrib4Nubv), TABLE_ENTRY(VertexAttrib4Nuiv), TABLE_ENTRY(VertexAttrib4Nusv), + TABLE_ENTRY(VertexAttrib4bv), TABLE_ENTRY(VertexAttrib4d), TABLE_ENTRY(VertexAttrib4dv), TABLE_ENTRY(VertexAttrib4f), TABLE_ENTRY(VertexAttrib4fv), + TABLE_ENTRY(VertexAttrib4iv), TABLE_ENTRY(VertexAttrib4s), TABLE_ENTRY(VertexAttrib4sv), + TABLE_ENTRY(VertexAttrib4ubv), + TABLE_ENTRY(VertexAttrib4uiv), + TABLE_ENTRY(VertexAttrib4usv), TABLE_ENTRY(VertexAttribPointer), TABLE_ENTRY(BindBuffer), TABLE_ENTRY(BufferData), diff --git a/src/mesa/glapi/glprocs.h b/src/mesa/glapi/glprocs.h index b6651a6bf4b..c461333c51e 100644 --- a/src/mesa/glapi/glprocs.h +++ b/src/mesa/glapi/glprocs.h @@ -958,12 +958,17 @@ static const char gl_string_table[] = "glVertexAttrib4Nubv\0" "glVertexAttrib4Nuiv\0" "glVertexAttrib4Nusv\0" + "glVertexAttrib4bv\0" "glVertexAttrib4d\0" "glVertexAttrib4dv\0" "glVertexAttrib4f\0" "glVertexAttrib4fv\0" + "glVertexAttrib4iv\0" "glVertexAttrib4s\0" "glVertexAttrib4sv\0" + "glVertexAttrib4ubv\0" + "glVertexAttrib4uiv\0" + "glVertexAttrib4usv\0" "glVertexAttribPointer\0" "glBindBuffer\0" "glBufferData\0" @@ -2102,142 +2107,147 @@ static const glprocs_table_t static_functions[] = { NAME_FUNC_OFFSET(16297, glVertexAttrib4NubvARB, glVertexAttrib4NubvARB, NULL, _gloffset_VertexAttrib4NubvARB), NAME_FUNC_OFFSET(16317, glVertexAttrib4NuivARB, glVertexAttrib4NuivARB, NULL, _gloffset_VertexAttrib4NuivARB), NAME_FUNC_OFFSET(16337, glVertexAttrib4NusvARB, glVertexAttrib4NusvARB, NULL, _gloffset_VertexAttrib4NusvARB), - NAME_FUNC_OFFSET(16357, glVertexAttrib4dARB, glVertexAttrib4dARB, NULL, _gloffset_VertexAttrib4dARB), - NAME_FUNC_OFFSET(16374, glVertexAttrib4dvARB, glVertexAttrib4dvARB, NULL, _gloffset_VertexAttrib4dvARB), - NAME_FUNC_OFFSET(16392, glVertexAttrib4fARB, glVertexAttrib4fARB, NULL, _gloffset_VertexAttrib4fARB), - NAME_FUNC_OFFSET(16409, glVertexAttrib4fvARB, glVertexAttrib4fvARB, NULL, _gloffset_VertexAttrib4fvARB), - NAME_FUNC_OFFSET(16427, glVertexAttrib4sARB, glVertexAttrib4sARB, NULL, _gloffset_VertexAttrib4sARB), - NAME_FUNC_OFFSET(16444, glVertexAttrib4svARB, glVertexAttrib4svARB, NULL, _gloffset_VertexAttrib4svARB), - NAME_FUNC_OFFSET(16462, glVertexAttribPointerARB, glVertexAttribPointerARB, NULL, _gloffset_VertexAttribPointerARB), - NAME_FUNC_OFFSET(16484, glBindBufferARB, glBindBufferARB, NULL, _gloffset_BindBufferARB), - NAME_FUNC_OFFSET(16497, glBufferDataARB, glBufferDataARB, NULL, _gloffset_BufferDataARB), - NAME_FUNC_OFFSET(16510, glBufferSubDataARB, glBufferSubDataARB, NULL, _gloffset_BufferSubDataARB), - NAME_FUNC_OFFSET(16526, glDeleteBuffersARB, glDeleteBuffersARB, NULL, _gloffset_DeleteBuffersARB), - NAME_FUNC_OFFSET(16542, glGenBuffersARB, glGenBuffersARB, NULL, _gloffset_GenBuffersARB), - NAME_FUNC_OFFSET(16555, glGetBufferParameterivARB, glGetBufferParameterivARB, NULL, _gloffset_GetBufferParameterivARB), - NAME_FUNC_OFFSET(16578, glGetBufferPointervARB, glGetBufferPointervARB, NULL, _gloffset_GetBufferPointervARB), - NAME_FUNC_OFFSET(16598, glGetBufferSubDataARB, glGetBufferSubDataARB, NULL, _gloffset_GetBufferSubDataARB), - NAME_FUNC_OFFSET(16617, glIsBufferARB, glIsBufferARB, NULL, _gloffset_IsBufferARB), - NAME_FUNC_OFFSET(16628, glMapBufferARB, glMapBufferARB, NULL, _gloffset_MapBufferARB), - NAME_FUNC_OFFSET(16640, glUnmapBufferARB, glUnmapBufferARB, NULL, _gloffset_UnmapBufferARB), - NAME_FUNC_OFFSET(16654, glBeginQueryARB, glBeginQueryARB, NULL, _gloffset_BeginQueryARB), - NAME_FUNC_OFFSET(16667, glDeleteQueriesARB, glDeleteQueriesARB, NULL, _gloffset_DeleteQueriesARB), - NAME_FUNC_OFFSET(16683, glEndQueryARB, glEndQueryARB, NULL, _gloffset_EndQueryARB), - NAME_FUNC_OFFSET(16694, glGenQueriesARB, glGenQueriesARB, NULL, _gloffset_GenQueriesARB), - NAME_FUNC_OFFSET(16707, glGetQueryObjectivARB, glGetQueryObjectivARB, NULL, _gloffset_GetQueryObjectivARB), - NAME_FUNC_OFFSET(16726, glGetQueryObjectuivARB, glGetQueryObjectuivARB, NULL, _gloffset_GetQueryObjectuivARB), - NAME_FUNC_OFFSET(16746, glGetQueryivARB, glGetQueryivARB, NULL, _gloffset_GetQueryivARB), - NAME_FUNC_OFFSET(16759, glIsQueryARB, glIsQueryARB, NULL, _gloffset_IsQueryARB), - NAME_FUNC_OFFSET(16769, glCompileShaderARB, glCompileShaderARB, NULL, _gloffset_CompileShaderARB), - NAME_FUNC_OFFSET(16785, glGetActiveUniformARB, glGetActiveUniformARB, NULL, _gloffset_GetActiveUniformARB), - NAME_FUNC_OFFSET(16804, glGetShaderSourceARB, glGetShaderSourceARB, NULL, _gloffset_GetShaderSourceARB), - NAME_FUNC_OFFSET(16822, glGetUniformLocationARB, glGetUniformLocationARB, NULL, _gloffset_GetUniformLocationARB), - NAME_FUNC_OFFSET(16843, glGetUniformfvARB, glGetUniformfvARB, NULL, _gloffset_GetUniformfvARB), - NAME_FUNC_OFFSET(16858, glGetUniformivARB, glGetUniformivARB, NULL, _gloffset_GetUniformivARB), - NAME_FUNC_OFFSET(16873, glLinkProgramARB, glLinkProgramARB, NULL, _gloffset_LinkProgramARB), - NAME_FUNC_OFFSET(16887, glShaderSourceARB, glShaderSourceARB, NULL, _gloffset_ShaderSourceARB), - NAME_FUNC_OFFSET(16902, glUniform1fARB, glUniform1fARB, NULL, _gloffset_Uniform1fARB), - NAME_FUNC_OFFSET(16914, glUniform1fvARB, glUniform1fvARB, NULL, _gloffset_Uniform1fvARB), - NAME_FUNC_OFFSET(16927, glUniform1iARB, glUniform1iARB, NULL, _gloffset_Uniform1iARB), - NAME_FUNC_OFFSET(16939, glUniform1ivARB, glUniform1ivARB, NULL, _gloffset_Uniform1ivARB), - NAME_FUNC_OFFSET(16952, glUniform2fARB, glUniform2fARB, NULL, _gloffset_Uniform2fARB), - NAME_FUNC_OFFSET(16964, glUniform2fvARB, glUniform2fvARB, NULL, _gloffset_Uniform2fvARB), - NAME_FUNC_OFFSET(16977, glUniform2iARB, glUniform2iARB, NULL, _gloffset_Uniform2iARB), - NAME_FUNC_OFFSET(16989, glUniform2ivARB, glUniform2ivARB, NULL, _gloffset_Uniform2ivARB), - NAME_FUNC_OFFSET(17002, glUniform3fARB, glUniform3fARB, NULL, _gloffset_Uniform3fARB), - NAME_FUNC_OFFSET(17014, glUniform3fvARB, glUniform3fvARB, NULL, _gloffset_Uniform3fvARB), - NAME_FUNC_OFFSET(17027, glUniform3iARB, glUniform3iARB, NULL, _gloffset_Uniform3iARB), - NAME_FUNC_OFFSET(17039, glUniform3ivARB, glUniform3ivARB, NULL, _gloffset_Uniform3ivARB), - NAME_FUNC_OFFSET(17052, glUniform4fARB, glUniform4fARB, NULL, _gloffset_Uniform4fARB), - NAME_FUNC_OFFSET(17064, glUniform4fvARB, glUniform4fvARB, NULL, _gloffset_Uniform4fvARB), - NAME_FUNC_OFFSET(17077, glUniform4iARB, glUniform4iARB, NULL, _gloffset_Uniform4iARB), - NAME_FUNC_OFFSET(17089, glUniform4ivARB, glUniform4ivARB, NULL, _gloffset_Uniform4ivARB), - NAME_FUNC_OFFSET(17102, glUniformMatrix2fvARB, glUniformMatrix2fvARB, NULL, _gloffset_UniformMatrix2fvARB), - NAME_FUNC_OFFSET(17121, glUniformMatrix3fvARB, glUniformMatrix3fvARB, NULL, _gloffset_UniformMatrix3fvARB), - NAME_FUNC_OFFSET(17140, glUniformMatrix4fvARB, glUniformMatrix4fvARB, NULL, _gloffset_UniformMatrix4fvARB), - NAME_FUNC_OFFSET(17159, glUseProgramObjectARB, glUseProgramObjectARB, NULL, _gloffset_UseProgramObjectARB), - NAME_FUNC_OFFSET(17172, glValidateProgramARB, glValidateProgramARB, NULL, _gloffset_ValidateProgramARB), - NAME_FUNC_OFFSET(17190, glBindAttribLocationARB, glBindAttribLocationARB, NULL, _gloffset_BindAttribLocationARB), - NAME_FUNC_OFFSET(17211, glGetActiveAttribARB, glGetActiveAttribARB, NULL, _gloffset_GetActiveAttribARB), - NAME_FUNC_OFFSET(17229, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB), - NAME_FUNC_OFFSET(17249, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB), - NAME_FUNC_OFFSET(17263, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB), - NAME_FUNC_OFFSET(17280, gl_dispatch_stub_568, gl_dispatch_stub_568, NULL, _gloffset_SampleMaskSGIS), - NAME_FUNC_OFFSET(17296, gl_dispatch_stub_569, gl_dispatch_stub_569, NULL, _gloffset_SamplePatternSGIS), - NAME_FUNC_OFFSET(17315, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT), - NAME_FUNC_OFFSET(17333, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT), - NAME_FUNC_OFFSET(17354, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT), - NAME_FUNC_OFFSET(17376, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT), - NAME_FUNC_OFFSET(17395, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT), - NAME_FUNC_OFFSET(17417, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT), - NAME_FUNC_OFFSET(17440, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT), - NAME_FUNC_OFFSET(17459, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT), - NAME_FUNC_OFFSET(17479, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT), - NAME_FUNC_OFFSET(17498, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT), - NAME_FUNC_OFFSET(17518, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT), - NAME_FUNC_OFFSET(17537, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT), - NAME_FUNC_OFFSET(17557, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT), - NAME_FUNC_OFFSET(17576, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT), - NAME_FUNC_OFFSET(17596, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT), - NAME_FUNC_OFFSET(17615, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT), - NAME_FUNC_OFFSET(17635, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT), - NAME_FUNC_OFFSET(17655, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT), - NAME_FUNC_OFFSET(17676, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT), - NAME_FUNC_OFFSET(17696, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT), - NAME_FUNC_OFFSET(17717, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT), - NAME_FUNC_OFFSET(17737, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT), - NAME_FUNC_OFFSET(17758, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT), - NAME_FUNC_OFFSET(17782, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT), - NAME_FUNC_OFFSET(17800, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT), - NAME_FUNC_OFFSET(17820, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT), - NAME_FUNC_OFFSET(17838, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT), - NAME_FUNC_OFFSET(17850, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT), - NAME_FUNC_OFFSET(17863, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT), - NAME_FUNC_OFFSET(17875, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT), - NAME_FUNC_OFFSET(17888, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT), - NAME_FUNC_OFFSET(17908, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT), - NAME_FUNC_OFFSET(17932, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA), - NAME_FUNC_OFFSET(17946, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA), - NAME_FUNC_OFFSET(17963, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA), - NAME_FUNC_OFFSET(17978, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA), - NAME_FUNC_OFFSET(17996, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA), - NAME_FUNC_OFFSET(18010, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA), - NAME_FUNC_OFFSET(18027, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA), - NAME_FUNC_OFFSET(18042, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA), - NAME_FUNC_OFFSET(18060, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA), - NAME_FUNC_OFFSET(18074, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA), - NAME_FUNC_OFFSET(18091, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA), - NAME_FUNC_OFFSET(18106, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA), - NAME_FUNC_OFFSET(18124, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA), - NAME_FUNC_OFFSET(18138, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA), - NAME_FUNC_OFFSET(18155, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA), - NAME_FUNC_OFFSET(18170, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA), - NAME_FUNC_OFFSET(18188, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA), - NAME_FUNC_OFFSET(18202, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA), - NAME_FUNC_OFFSET(18219, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA), - NAME_FUNC_OFFSET(18234, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA), - NAME_FUNC_OFFSET(18252, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA), - NAME_FUNC_OFFSET(18266, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA), - NAME_FUNC_OFFSET(18283, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA), - NAME_FUNC_OFFSET(18298, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA), - NAME_FUNC_OFFSET(18316, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA), - NAME_FUNC_OFFSET(18330, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA), - NAME_FUNC_OFFSET(18347, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA), - NAME_FUNC_OFFSET(18362, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA), - NAME_FUNC_OFFSET(18380, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA), - NAME_FUNC_OFFSET(18394, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA), - NAME_FUNC_OFFSET(18411, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA), - NAME_FUNC_OFFSET(18426, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA), - NAME_FUNC_OFFSET(18444, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV), - NAME_FUNC_OFFSET(18461, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV), - NAME_FUNC_OFFSET(18481, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV), - NAME_FUNC_OFFSET(18498, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV), - NAME_FUNC_OFFSET(18524, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV), - NAME_FUNC_OFFSET(18553, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV), - NAME_FUNC_OFFSET(18568, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV), - NAME_FUNC_OFFSET(18586, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV), - NAME_FUNC_OFFSET(18605, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT), - NAME_FUNC_OFFSET(18629, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT), + NAME_FUNC_OFFSET(16357, glVertexAttrib4bvARB, glVertexAttrib4bvARB, NULL, _gloffset_VertexAttrib4bvARB), + NAME_FUNC_OFFSET(16375, glVertexAttrib4dARB, glVertexAttrib4dARB, NULL, _gloffset_VertexAttrib4dARB), + NAME_FUNC_OFFSET(16392, glVertexAttrib4dvARB, glVertexAttrib4dvARB, NULL, _gloffset_VertexAttrib4dvARB), + NAME_FUNC_OFFSET(16410, glVertexAttrib4fARB, glVertexAttrib4fARB, NULL, _gloffset_VertexAttrib4fARB), + NAME_FUNC_OFFSET(16427, glVertexAttrib4fvARB, glVertexAttrib4fvARB, NULL, _gloffset_VertexAttrib4fvARB), + NAME_FUNC_OFFSET(16445, glVertexAttrib4ivARB, glVertexAttrib4ivARB, NULL, _gloffset_VertexAttrib4ivARB), + NAME_FUNC_OFFSET(16463, glVertexAttrib4sARB, glVertexAttrib4sARB, NULL, _gloffset_VertexAttrib4sARB), + NAME_FUNC_OFFSET(16480, glVertexAttrib4svARB, glVertexAttrib4svARB, NULL, _gloffset_VertexAttrib4svARB), + NAME_FUNC_OFFSET(16498, glVertexAttrib4ubvARB, glVertexAttrib4ubvARB, NULL, _gloffset_VertexAttrib4ubvARB), + NAME_FUNC_OFFSET(16517, glVertexAttrib4uivARB, glVertexAttrib4uivARB, NULL, _gloffset_VertexAttrib4uivARB), + NAME_FUNC_OFFSET(16536, glVertexAttrib4usvARB, glVertexAttrib4usvARB, NULL, _gloffset_VertexAttrib4usvARB), + NAME_FUNC_OFFSET(16555, glVertexAttribPointerARB, glVertexAttribPointerARB, NULL, _gloffset_VertexAttribPointerARB), + NAME_FUNC_OFFSET(16577, glBindBufferARB, glBindBufferARB, NULL, _gloffset_BindBufferARB), + NAME_FUNC_OFFSET(16590, glBufferDataARB, glBufferDataARB, NULL, _gloffset_BufferDataARB), + NAME_FUNC_OFFSET(16603, glBufferSubDataARB, glBufferSubDataARB, NULL, _gloffset_BufferSubDataARB), + NAME_FUNC_OFFSET(16619, glDeleteBuffersARB, glDeleteBuffersARB, NULL, _gloffset_DeleteBuffersARB), + NAME_FUNC_OFFSET(16635, glGenBuffersARB, glGenBuffersARB, NULL, _gloffset_GenBuffersARB), + NAME_FUNC_OFFSET(16648, glGetBufferParameterivARB, glGetBufferParameterivARB, NULL, _gloffset_GetBufferParameterivARB), + NAME_FUNC_OFFSET(16671, glGetBufferPointervARB, glGetBufferPointervARB, NULL, _gloffset_GetBufferPointervARB), + NAME_FUNC_OFFSET(16691, glGetBufferSubDataARB, glGetBufferSubDataARB, NULL, _gloffset_GetBufferSubDataARB), + NAME_FUNC_OFFSET(16710, glIsBufferARB, glIsBufferARB, NULL, _gloffset_IsBufferARB), + NAME_FUNC_OFFSET(16721, glMapBufferARB, glMapBufferARB, NULL, _gloffset_MapBufferARB), + NAME_FUNC_OFFSET(16733, glUnmapBufferARB, glUnmapBufferARB, NULL, _gloffset_UnmapBufferARB), + NAME_FUNC_OFFSET(16747, glBeginQueryARB, glBeginQueryARB, NULL, _gloffset_BeginQueryARB), + NAME_FUNC_OFFSET(16760, glDeleteQueriesARB, glDeleteQueriesARB, NULL, _gloffset_DeleteQueriesARB), + NAME_FUNC_OFFSET(16776, glEndQueryARB, glEndQueryARB, NULL, _gloffset_EndQueryARB), + NAME_FUNC_OFFSET(16787, glGenQueriesARB, glGenQueriesARB, NULL, _gloffset_GenQueriesARB), + NAME_FUNC_OFFSET(16800, glGetQueryObjectivARB, glGetQueryObjectivARB, NULL, _gloffset_GetQueryObjectivARB), + NAME_FUNC_OFFSET(16819, glGetQueryObjectuivARB, glGetQueryObjectuivARB, NULL, _gloffset_GetQueryObjectuivARB), + NAME_FUNC_OFFSET(16839, glGetQueryivARB, glGetQueryivARB, NULL, _gloffset_GetQueryivARB), + NAME_FUNC_OFFSET(16852, glIsQueryARB, glIsQueryARB, NULL, _gloffset_IsQueryARB), + NAME_FUNC_OFFSET(16862, glCompileShaderARB, glCompileShaderARB, NULL, _gloffset_CompileShaderARB), + NAME_FUNC_OFFSET(16878, glGetActiveUniformARB, glGetActiveUniformARB, NULL, _gloffset_GetActiveUniformARB), + NAME_FUNC_OFFSET(16897, glGetShaderSourceARB, glGetShaderSourceARB, NULL, _gloffset_GetShaderSourceARB), + NAME_FUNC_OFFSET(16915, glGetUniformLocationARB, glGetUniformLocationARB, NULL, _gloffset_GetUniformLocationARB), + NAME_FUNC_OFFSET(16936, glGetUniformfvARB, glGetUniformfvARB, NULL, _gloffset_GetUniformfvARB), + NAME_FUNC_OFFSET(16951, glGetUniformivARB, glGetUniformivARB, NULL, _gloffset_GetUniformivARB), + NAME_FUNC_OFFSET(16966, glLinkProgramARB, glLinkProgramARB, NULL, _gloffset_LinkProgramARB), + NAME_FUNC_OFFSET(16980, glShaderSourceARB, glShaderSourceARB, NULL, _gloffset_ShaderSourceARB), + NAME_FUNC_OFFSET(16995, glUniform1fARB, glUniform1fARB, NULL, _gloffset_Uniform1fARB), + NAME_FUNC_OFFSET(17007, glUniform1fvARB, glUniform1fvARB, NULL, _gloffset_Uniform1fvARB), + NAME_FUNC_OFFSET(17020, glUniform1iARB, glUniform1iARB, NULL, _gloffset_Uniform1iARB), + NAME_FUNC_OFFSET(17032, glUniform1ivARB, glUniform1ivARB, NULL, _gloffset_Uniform1ivARB), + NAME_FUNC_OFFSET(17045, glUniform2fARB, glUniform2fARB, NULL, _gloffset_Uniform2fARB), + NAME_FUNC_OFFSET(17057, glUniform2fvARB, glUniform2fvARB, NULL, _gloffset_Uniform2fvARB), + NAME_FUNC_OFFSET(17070, glUniform2iARB, glUniform2iARB, NULL, _gloffset_Uniform2iARB), + NAME_FUNC_OFFSET(17082, glUniform2ivARB, glUniform2ivARB, NULL, _gloffset_Uniform2ivARB), + NAME_FUNC_OFFSET(17095, glUniform3fARB, glUniform3fARB, NULL, _gloffset_Uniform3fARB), + NAME_FUNC_OFFSET(17107, glUniform3fvARB, glUniform3fvARB, NULL, _gloffset_Uniform3fvARB), + NAME_FUNC_OFFSET(17120, glUniform3iARB, glUniform3iARB, NULL, _gloffset_Uniform3iARB), + NAME_FUNC_OFFSET(17132, glUniform3ivARB, glUniform3ivARB, NULL, _gloffset_Uniform3ivARB), + NAME_FUNC_OFFSET(17145, glUniform4fARB, glUniform4fARB, NULL, _gloffset_Uniform4fARB), + NAME_FUNC_OFFSET(17157, glUniform4fvARB, glUniform4fvARB, NULL, _gloffset_Uniform4fvARB), + NAME_FUNC_OFFSET(17170, glUniform4iARB, glUniform4iARB, NULL, _gloffset_Uniform4iARB), + NAME_FUNC_OFFSET(17182, glUniform4ivARB, glUniform4ivARB, NULL, _gloffset_Uniform4ivARB), + NAME_FUNC_OFFSET(17195, glUniformMatrix2fvARB, glUniformMatrix2fvARB, NULL, _gloffset_UniformMatrix2fvARB), + NAME_FUNC_OFFSET(17214, glUniformMatrix3fvARB, glUniformMatrix3fvARB, NULL, _gloffset_UniformMatrix3fvARB), + NAME_FUNC_OFFSET(17233, glUniformMatrix4fvARB, glUniformMatrix4fvARB, NULL, _gloffset_UniformMatrix4fvARB), + NAME_FUNC_OFFSET(17252, glUseProgramObjectARB, glUseProgramObjectARB, NULL, _gloffset_UseProgramObjectARB), + NAME_FUNC_OFFSET(17265, glValidateProgramARB, glValidateProgramARB, NULL, _gloffset_ValidateProgramARB), + NAME_FUNC_OFFSET(17283, glBindAttribLocationARB, glBindAttribLocationARB, NULL, _gloffset_BindAttribLocationARB), + NAME_FUNC_OFFSET(17304, glGetActiveAttribARB, glGetActiveAttribARB, NULL, _gloffset_GetActiveAttribARB), + NAME_FUNC_OFFSET(17322, glGetAttribLocationARB, glGetAttribLocationARB, NULL, _gloffset_GetAttribLocationARB), + NAME_FUNC_OFFSET(17342, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB), + NAME_FUNC_OFFSET(17356, glDrawBuffersARB, glDrawBuffersARB, NULL, _gloffset_DrawBuffersARB), + NAME_FUNC_OFFSET(17373, gl_dispatch_stub_568, gl_dispatch_stub_568, NULL, _gloffset_SampleMaskSGIS), + NAME_FUNC_OFFSET(17389, gl_dispatch_stub_569, gl_dispatch_stub_569, NULL, _gloffset_SamplePatternSGIS), + NAME_FUNC_OFFSET(17408, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT), + NAME_FUNC_OFFSET(17426, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT), + NAME_FUNC_OFFSET(17447, glPointParameterfEXT, glPointParameterfEXT, NULL, _gloffset_PointParameterfEXT), + NAME_FUNC_OFFSET(17469, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT), + NAME_FUNC_OFFSET(17488, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT), + NAME_FUNC_OFFSET(17510, glPointParameterfvEXT, glPointParameterfvEXT, NULL, _gloffset_PointParameterfvEXT), + NAME_FUNC_OFFSET(17533, glSecondaryColor3bEXT, glSecondaryColor3bEXT, NULL, _gloffset_SecondaryColor3bEXT), + NAME_FUNC_OFFSET(17552, glSecondaryColor3bvEXT, glSecondaryColor3bvEXT, NULL, _gloffset_SecondaryColor3bvEXT), + NAME_FUNC_OFFSET(17572, glSecondaryColor3dEXT, glSecondaryColor3dEXT, NULL, _gloffset_SecondaryColor3dEXT), + NAME_FUNC_OFFSET(17591, glSecondaryColor3dvEXT, glSecondaryColor3dvEXT, NULL, _gloffset_SecondaryColor3dvEXT), + NAME_FUNC_OFFSET(17611, glSecondaryColor3fEXT, glSecondaryColor3fEXT, NULL, _gloffset_SecondaryColor3fEXT), + NAME_FUNC_OFFSET(17630, glSecondaryColor3fvEXT, glSecondaryColor3fvEXT, NULL, _gloffset_SecondaryColor3fvEXT), + NAME_FUNC_OFFSET(17650, glSecondaryColor3iEXT, glSecondaryColor3iEXT, NULL, _gloffset_SecondaryColor3iEXT), + NAME_FUNC_OFFSET(17669, glSecondaryColor3ivEXT, glSecondaryColor3ivEXT, NULL, _gloffset_SecondaryColor3ivEXT), + NAME_FUNC_OFFSET(17689, glSecondaryColor3sEXT, glSecondaryColor3sEXT, NULL, _gloffset_SecondaryColor3sEXT), + NAME_FUNC_OFFSET(17708, glSecondaryColor3svEXT, glSecondaryColor3svEXT, NULL, _gloffset_SecondaryColor3svEXT), + NAME_FUNC_OFFSET(17728, glSecondaryColor3ubEXT, glSecondaryColor3ubEXT, NULL, _gloffset_SecondaryColor3ubEXT), + NAME_FUNC_OFFSET(17748, glSecondaryColor3ubvEXT, glSecondaryColor3ubvEXT, NULL, _gloffset_SecondaryColor3ubvEXT), + NAME_FUNC_OFFSET(17769, glSecondaryColor3uiEXT, glSecondaryColor3uiEXT, NULL, _gloffset_SecondaryColor3uiEXT), + NAME_FUNC_OFFSET(17789, glSecondaryColor3uivEXT, glSecondaryColor3uivEXT, NULL, _gloffset_SecondaryColor3uivEXT), + NAME_FUNC_OFFSET(17810, glSecondaryColor3usEXT, glSecondaryColor3usEXT, NULL, _gloffset_SecondaryColor3usEXT), + NAME_FUNC_OFFSET(17830, glSecondaryColor3usvEXT, glSecondaryColor3usvEXT, NULL, _gloffset_SecondaryColor3usvEXT), + NAME_FUNC_OFFSET(17851, glSecondaryColorPointerEXT, glSecondaryColorPointerEXT, NULL, _gloffset_SecondaryColorPointerEXT), + NAME_FUNC_OFFSET(17875, glMultiDrawArraysEXT, glMultiDrawArraysEXT, NULL, _gloffset_MultiDrawArraysEXT), + NAME_FUNC_OFFSET(17893, glMultiDrawElementsEXT, glMultiDrawElementsEXT, NULL, _gloffset_MultiDrawElementsEXT), + NAME_FUNC_OFFSET(17913, glFogCoordPointerEXT, glFogCoordPointerEXT, NULL, _gloffset_FogCoordPointerEXT), + NAME_FUNC_OFFSET(17931, glFogCoorddEXT, glFogCoorddEXT, NULL, _gloffset_FogCoorddEXT), + NAME_FUNC_OFFSET(17943, glFogCoorddvEXT, glFogCoorddvEXT, NULL, _gloffset_FogCoorddvEXT), + NAME_FUNC_OFFSET(17956, glFogCoordfEXT, glFogCoordfEXT, NULL, _gloffset_FogCoordfEXT), + NAME_FUNC_OFFSET(17968, glFogCoordfvEXT, glFogCoordfvEXT, NULL, _gloffset_FogCoordfvEXT), + NAME_FUNC_OFFSET(17981, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT), + NAME_FUNC_OFFSET(18001, glBlendFuncSeparateEXT, glBlendFuncSeparateEXT, NULL, _gloffset_BlendFuncSeparateEXT), + NAME_FUNC_OFFSET(18025, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA), + NAME_FUNC_OFFSET(18039, glWindowPos2dMESA, glWindowPos2dMESA, NULL, _gloffset_WindowPos2dMESA), + NAME_FUNC_OFFSET(18056, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA), + NAME_FUNC_OFFSET(18071, glWindowPos2dvMESA, glWindowPos2dvMESA, NULL, _gloffset_WindowPos2dvMESA), + NAME_FUNC_OFFSET(18089, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA), + NAME_FUNC_OFFSET(18103, glWindowPos2fMESA, glWindowPos2fMESA, NULL, _gloffset_WindowPos2fMESA), + NAME_FUNC_OFFSET(18120, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA), + NAME_FUNC_OFFSET(18135, glWindowPos2fvMESA, glWindowPos2fvMESA, NULL, _gloffset_WindowPos2fvMESA), + NAME_FUNC_OFFSET(18153, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA), + NAME_FUNC_OFFSET(18167, glWindowPos2iMESA, glWindowPos2iMESA, NULL, _gloffset_WindowPos2iMESA), + NAME_FUNC_OFFSET(18184, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA), + NAME_FUNC_OFFSET(18199, glWindowPos2ivMESA, glWindowPos2ivMESA, NULL, _gloffset_WindowPos2ivMESA), + NAME_FUNC_OFFSET(18217, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA), + NAME_FUNC_OFFSET(18231, glWindowPos2sMESA, glWindowPos2sMESA, NULL, _gloffset_WindowPos2sMESA), + NAME_FUNC_OFFSET(18248, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA), + NAME_FUNC_OFFSET(18263, glWindowPos2svMESA, glWindowPos2svMESA, NULL, _gloffset_WindowPos2svMESA), + NAME_FUNC_OFFSET(18281, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA), + NAME_FUNC_OFFSET(18295, glWindowPos3dMESA, glWindowPos3dMESA, NULL, _gloffset_WindowPos3dMESA), + NAME_FUNC_OFFSET(18312, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA), + NAME_FUNC_OFFSET(18327, glWindowPos3dvMESA, glWindowPos3dvMESA, NULL, _gloffset_WindowPos3dvMESA), + NAME_FUNC_OFFSET(18345, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA), + NAME_FUNC_OFFSET(18359, glWindowPos3fMESA, glWindowPos3fMESA, NULL, _gloffset_WindowPos3fMESA), + NAME_FUNC_OFFSET(18376, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA), + NAME_FUNC_OFFSET(18391, glWindowPos3fvMESA, glWindowPos3fvMESA, NULL, _gloffset_WindowPos3fvMESA), + NAME_FUNC_OFFSET(18409, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA), + NAME_FUNC_OFFSET(18423, glWindowPos3iMESA, glWindowPos3iMESA, NULL, _gloffset_WindowPos3iMESA), + NAME_FUNC_OFFSET(18440, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA), + NAME_FUNC_OFFSET(18455, glWindowPos3ivMESA, glWindowPos3ivMESA, NULL, _gloffset_WindowPos3ivMESA), + NAME_FUNC_OFFSET(18473, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA), + NAME_FUNC_OFFSET(18487, glWindowPos3sMESA, glWindowPos3sMESA, NULL, _gloffset_WindowPos3sMESA), + NAME_FUNC_OFFSET(18504, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA), + NAME_FUNC_OFFSET(18519, glWindowPos3svMESA, glWindowPos3svMESA, NULL, _gloffset_WindowPos3svMESA), + NAME_FUNC_OFFSET(18537, glBindProgramNV, glBindProgramNV, NULL, _gloffset_BindProgramNV), + NAME_FUNC_OFFSET(18554, glDeleteProgramsNV, glDeleteProgramsNV, NULL, _gloffset_DeleteProgramsNV), + NAME_FUNC_OFFSET(18574, glGenProgramsNV, glGenProgramsNV, NULL, _gloffset_GenProgramsNV), + NAME_FUNC_OFFSET(18591, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV), + NAME_FUNC_OFFSET(18617, glGetVertexAttribPointervNV, glGetVertexAttribPointervNV, NULL, _gloffset_GetVertexAttribPointervNV), + NAME_FUNC_OFFSET(18646, glIsProgramNV, glIsProgramNV, NULL, _gloffset_IsProgramNV), + NAME_FUNC_OFFSET(18661, glPointParameteriNV, glPointParameteriNV, NULL, _gloffset_PointParameteriNV), + NAME_FUNC_OFFSET(18679, glPointParameterivNV, glPointParameterivNV, NULL, _gloffset_PointParameterivNV), + NAME_FUNC_OFFSET(18698, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT), + NAME_FUNC_OFFSET(18722, gl_dispatch_stub_749, gl_dispatch_stub_749, NULL, _gloffset_BlendEquationSeparateEXT), NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0) }; diff --git a/src/mesa/sparc/glapi_sparc.S b/src/mesa/sparc/glapi_sparc.S index d4ea12870fe..8725c7ee4d3 100644 --- a/src/mesa/sparc/glapi_sparc.S +++ b/src/mesa/sparc/glapi_sparc.S @@ -1733,12 +1733,17 @@ _mesa_sparc_glapi_end: .globl glVertexAttrib4Nubv ; .type glVertexAttrib4Nubv,#function ; glVertexAttrib4Nubv = glVertexAttrib4NubvARB .globl glVertexAttrib4Nuiv ; .type glVertexAttrib4Nuiv,#function ; glVertexAttrib4Nuiv = glVertexAttrib4NuivARB .globl glVertexAttrib4Nusv ; .type glVertexAttrib4Nusv,#function ; glVertexAttrib4Nusv = glVertexAttrib4NusvARB + .globl glVertexAttrib4bv ; .type glVertexAttrib4bv,#function ; glVertexAttrib4bv = glVertexAttrib4bvARB .globl glVertexAttrib4d ; .type glVertexAttrib4d,#function ; glVertexAttrib4d = glVertexAttrib4dARB .globl glVertexAttrib4dv ; .type glVertexAttrib4dv,#function ; glVertexAttrib4dv = glVertexAttrib4dvARB .globl glVertexAttrib4f ; .type glVertexAttrib4f,#function ; glVertexAttrib4f = glVertexAttrib4fARB .globl glVertexAttrib4fv ; .type glVertexAttrib4fv,#function ; glVertexAttrib4fv = glVertexAttrib4fvARB + .globl glVertexAttrib4iv ; .type glVertexAttrib4iv,#function ; glVertexAttrib4iv = glVertexAttrib4ivARB .globl glVertexAttrib4s ; .type glVertexAttrib4s,#function ; glVertexAttrib4s = glVertexAttrib4sARB .globl glVertexAttrib4sv ; .type glVertexAttrib4sv,#function ; glVertexAttrib4sv = glVertexAttrib4svARB + .globl glVertexAttrib4ubv ; .type glVertexAttrib4ubv,#function ; glVertexAttrib4ubv = glVertexAttrib4ubvARB + .globl glVertexAttrib4uiv ; .type glVertexAttrib4uiv,#function ; glVertexAttrib4uiv = glVertexAttrib4uivARB + .globl glVertexAttrib4usv ; .type glVertexAttrib4usv,#function ; glVertexAttrib4usv = glVertexAttrib4usvARB .globl glVertexAttribPointer ; .type glVertexAttribPointer,#function ; glVertexAttribPointer = glVertexAttribPointerARB .globl glBindBuffer ; .type glBindBuffer,#function ; glBindBuffer = glBindBufferARB .globl glBufferData ; .type glBufferData,#function ; glBufferData = glBufferDataARB diff --git a/src/mesa/x86-64/glapi_x86-64.S b/src/mesa/x86-64/glapi_x86-64.S index e62dde8a2f7..171e95d1b83 100644 --- a/src/mesa/x86-64/glapi_x86-64.S +++ b/src/mesa/x86-64/glapi_x86-64.S @@ -29398,12 +29398,17 @@ GL_PREFIX(_dispatch_stub_772): .globl GL_PREFIX(VertexAttrib4Nubv) ; .set GL_PREFIX(VertexAttrib4Nubv), GL_PREFIX(VertexAttrib4NubvARB) .globl GL_PREFIX(VertexAttrib4Nuiv) ; .set GL_PREFIX(VertexAttrib4Nuiv), GL_PREFIX(VertexAttrib4NuivARB) .globl GL_PREFIX(VertexAttrib4Nusv) ; .set GL_PREFIX(VertexAttrib4Nusv), GL_PREFIX(VertexAttrib4NusvARB) + .globl GL_PREFIX(VertexAttrib4bv) ; .set GL_PREFIX(VertexAttrib4bv), GL_PREFIX(VertexAttrib4bvARB) .globl GL_PREFIX(VertexAttrib4d) ; .set GL_PREFIX(VertexAttrib4d), GL_PREFIX(VertexAttrib4dARB) .globl GL_PREFIX(VertexAttrib4dv) ; .set GL_PREFIX(VertexAttrib4dv), GL_PREFIX(VertexAttrib4dvARB) .globl GL_PREFIX(VertexAttrib4f) ; .set GL_PREFIX(VertexAttrib4f), GL_PREFIX(VertexAttrib4fARB) .globl GL_PREFIX(VertexAttrib4fv) ; .set GL_PREFIX(VertexAttrib4fv), GL_PREFIX(VertexAttrib4fvARB) + .globl GL_PREFIX(VertexAttrib4iv) ; .set GL_PREFIX(VertexAttrib4iv), GL_PREFIX(VertexAttrib4ivARB) .globl GL_PREFIX(VertexAttrib4s) ; .set GL_PREFIX(VertexAttrib4s), GL_PREFIX(VertexAttrib4sARB) .globl GL_PREFIX(VertexAttrib4sv) ; .set GL_PREFIX(VertexAttrib4sv), GL_PREFIX(VertexAttrib4svARB) + .globl GL_PREFIX(VertexAttrib4ubv) ; .set GL_PREFIX(VertexAttrib4ubv), GL_PREFIX(VertexAttrib4ubvARB) + .globl GL_PREFIX(VertexAttrib4uiv) ; .set GL_PREFIX(VertexAttrib4uiv), GL_PREFIX(VertexAttrib4uivARB) + .globl GL_PREFIX(VertexAttrib4usv) ; .set GL_PREFIX(VertexAttrib4usv), GL_PREFIX(VertexAttrib4usvARB) .globl GL_PREFIX(VertexAttribPointer) ; .set GL_PREFIX(VertexAttribPointer), GL_PREFIX(VertexAttribPointerARB) .globl GL_PREFIX(BindBuffer) ; .set GL_PREFIX(BindBuffer), GL_PREFIX(BindBufferARB) .globl GL_PREFIX(BufferData) ; .set GL_PREFIX(BufferData), GL_PREFIX(BufferDataARB) diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index 74e93721bc3..1d04779d148 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -63,6 +63,7 @@ #else # define CTX_INSNS NOP /* Pad for init_glapi_relocs() */ #endif + # define GL_STUB(fn,off,fn_alt) \ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ @@ -1128,12 +1129,17 @@ GLNAME(gl_dispatch_functions_start): GL_STUB_ALIAS(VertexAttrib4Nubv, _gloffset_VertexAttrib4NubvARB, VertexAttrib4Nubv@8, VertexAttrib4NubvARB, VertexAttrib4NubvARB@8) GL_STUB_ALIAS(VertexAttrib4Nuiv, _gloffset_VertexAttrib4NuivARB, VertexAttrib4Nuiv@8, VertexAttrib4NuivARB, VertexAttrib4NuivARB@8) GL_STUB_ALIAS(VertexAttrib4Nusv, _gloffset_VertexAttrib4NusvARB, VertexAttrib4Nusv@8, VertexAttrib4NusvARB, VertexAttrib4NusvARB@8) + GL_STUB_ALIAS(VertexAttrib4bv, _gloffset_VertexAttrib4bvARB, VertexAttrib4bv@8, VertexAttrib4bvARB, VertexAttrib4bvARB@8) GL_STUB_ALIAS(VertexAttrib4d, _gloffset_VertexAttrib4dARB, VertexAttrib4d@36, VertexAttrib4dARB, VertexAttrib4dARB@36) GL_STUB_ALIAS(VertexAttrib4dv, _gloffset_VertexAttrib4dvARB, VertexAttrib4dv@8, VertexAttrib4dvARB, VertexAttrib4dvARB@8) GL_STUB_ALIAS(VertexAttrib4f, _gloffset_VertexAttrib4fARB, VertexAttrib4f@20, VertexAttrib4fARB, VertexAttrib4fARB@20) GL_STUB_ALIAS(VertexAttrib4fv, _gloffset_VertexAttrib4fvARB, VertexAttrib4fv@8, VertexAttrib4fvARB, VertexAttrib4fvARB@8) + GL_STUB_ALIAS(VertexAttrib4iv, _gloffset_VertexAttrib4ivARB, VertexAttrib4iv@8, VertexAttrib4ivARB, VertexAttrib4ivARB@8) GL_STUB_ALIAS(VertexAttrib4s, _gloffset_VertexAttrib4sARB, VertexAttrib4s@20, VertexAttrib4sARB, VertexAttrib4sARB@20) GL_STUB_ALIAS(VertexAttrib4sv, _gloffset_VertexAttrib4svARB, VertexAttrib4sv@8, VertexAttrib4svARB, VertexAttrib4svARB@8) + GL_STUB_ALIAS(VertexAttrib4ubv, _gloffset_VertexAttrib4ubvARB, VertexAttrib4ubv@8, VertexAttrib4ubvARB, VertexAttrib4ubvARB@8) + GL_STUB_ALIAS(VertexAttrib4uiv, _gloffset_VertexAttrib4uivARB, VertexAttrib4uiv@8, VertexAttrib4uivARB, VertexAttrib4uivARB@8) + GL_STUB_ALIAS(VertexAttrib4usv, _gloffset_VertexAttrib4usvARB, VertexAttrib4usv@8, VertexAttrib4usvARB, VertexAttrib4usvARB@8) GL_STUB_ALIAS(VertexAttribPointer, _gloffset_VertexAttribPointerARB, VertexAttribPointer@24, VertexAttribPointerARB, VertexAttribPointerARB@24) GL_STUB_ALIAS(BindBuffer, _gloffset_BindBufferARB, BindBuffer@8, BindBufferARB, BindBufferARB@8) GL_STUB_ALIAS(BufferData, _gloffset_BufferDataARB, BufferData@16, BufferDataARB, BufferDataARB@16) -- cgit v1.2.3 From 17e81bda6ed1d2cc4e5c0fad895030911b4fa53c Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 8 Jun 2007 13:27:57 +1000 Subject: nouveau: NV30_TCL viewport/scissor fixes --- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 4 +++ src/mesa/drivers/dri/nouveau/nouveau_context.h | 2 +- src/mesa/drivers/dri/nouveau/nouveau_state.c | 4 +-- src/mesa/drivers/dri/nouveau/nv30_state.c | 50 ++++++++++++++++++-------- 4 files changed, 43 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index b54f68f4023..e3968bd02fc 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -299,6 +299,8 @@ nouveau_cliprects_drawable_set(nouveauContextPtr nmesa, nmesa->pClipRects = dPriv->pClipRects; nmesa->drawX = dPriv->x; nmesa->drawY = dPriv->y; + nmesa->drawW = dPriv->w; + nmesa->drawH = dPriv->h; } static void @@ -313,6 +315,8 @@ nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, nmesa->osClipRect.y2 = nrb->mesa.Height; nmesa->drawX = 0; nmesa->drawY = 0; + nmesa->drawW = nrb->mesa.Width; + nmesa->drawH = nrb->mesa.Height; } void diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 87e4479da34..53f3393676f 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -150,7 +150,7 @@ typedef struct nouveau_context { GLuint numClipRects; drm_clip_rect_t *pClipRects; drm_clip_rect_t osClipRect; - GLuint drawX, drawY; + GLuint drawX, drawY, drawW, drawH; /* The rendering context information */ GLenum current_primitive; /* the current primitive enum */ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index e9fd188d73e..7cb805902a7 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -60,14 +60,14 @@ static void nouveauCalcViewport(GLcontext *ctx) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); const GLfloat *v = ctx->Viewport._WindowMap.m; GLfloat *m = nmesa->viewport.m; - GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY; + GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY + nmesa->drawH; nmesa->depth_scale = 1.0 / ctx->DrawBuffer->_DepthMaxF; m[MAT_SX] = v[MAT_SX]; m[MAT_TX] = v[MAT_TX] + xoffset + SUBPIXEL_X; m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = v[MAT_TY] + yoffset + SUBPIXEL_Y; + m[MAT_TY] = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y; m[MAT_SZ] = v[MAT_SZ] * nmesa->depth_scale; m[MAT_TZ] = v[MAT_TZ] * nmesa->depth_scale; diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index ad21fa27302..d329071d1ee 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -639,25 +639,45 @@ void (*ReadBuffer)( GLcontext *ctx, GLenum buffer ); /** Set rasterization mode */ void (*RenderMode)(GLcontext *ctx, GLenum mode ); +/* Translate GL coords to window coords, clamping w/h to the + * dimensions of the window. + */ +static void nv30WindowCoords(nouveauContextPtr nmesa, + GLuint x, GLuint y, GLuint w, GLuint h, + GLuint *wX, GLuint *wY, GLuint *wW, GLuint *wH) +{ + if ((x+w) > nmesa->drawW) + w = nmesa->drawW - x; + (*wX) = x + nmesa->drawX; + (*wW) = w; + + if ((y+h) > nmesa->drawH) + h = nmesa->drawH - y; + (*wY) = (nmesa->drawH - y) - h + nmesa->drawY; + (*wH) = h; +} + /** Define the scissor box */ static void nv30Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + GLuint wX, wY, wW, wH; /* There's no scissor enable bit, so adjust the scissor to cover the * maximum draw buffer bounds */ if (!ctx->Scissor.Enabled) { - x = y = 0; - w = h = 4095; + wX = nmesa->drawX; + wY = nmesa->drawY; + wW = nmesa->drawW; + wH = nmesa->drawH; } else { - x += nmesa->drawX; - y += nmesa->drawY; + nv30WindowCoords(nmesa, x, y, w, h, &wX, &wY, &wW, &wH); } BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2); - OUT_RING_CACHE(((w) << 16) | x); - OUT_RING_CACHE(((h) << 16) | y); + OUT_RING_CACHE ((wW << 16) | wX); + OUT_RING_CACHE ((wH << 16) | wY); } /** Select flat or smooth shading */ @@ -751,19 +771,21 @@ static void nv30WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; GLfloat *v = nmesa->viewport.m; - GLuint w = ctx->Viewport.Width; - GLuint h = ctx->Viewport.Height; - GLuint x = ctx->Viewport.X + nmesa->drawX; - GLuint y = ctx->Viewport.Y + nmesa->drawY; + GLuint wX, wY, wW, wH; + nv30WindowCoords(nmesa, ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + &wX, &wY, &wW, &wH); BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_0, 2); - OUT_RING_CACHE((w << 16) | x); - OUT_RING_CACHE((h << 16) | y); + OUT_RING_CACHE ((wW << 16) | wX); + OUT_RING_CACHE ((wH << 16) | wY); + /* something to do with clears, possibly doesn't belong here */ BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_OFS0, 2); - OUT_RING_CACHE(((w+x) << 16) | x); - OUT_RING_CACHE(((h+y) << 16) | y); + OUT_RING_CACHE(((nmesa->drawX + nmesa->drawW) << 16) | nmesa->drawX); + OUT_RING_CACHE(((nmesa->drawY + nmesa->drawH) << 16) | nmesa->drawY); + /* viewport transform */ BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OX, 8); OUT_RING_CACHEf (v[MAT_TX]); -- cgit v1.2.3 From 5e4a0f42f243cd5fbc8718660d78705e8c70808f Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Sun, 10 Jun 2007 03:05:05 +1000 Subject: nouveau: match drm changes (0.0.7) --- src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c | 6 +-- src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h | 2 +- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 6 +-- src/mesa/drivers/dri/nouveau/nouveau_context.c | 4 +- src/mesa/drivers/dri/nouveau/nouveau_context.h | 11 ++-- src/mesa/drivers/dri/nouveau/nouveau_fifo.c | 14 ++++- src/mesa/drivers/dri/nouveau/nouveau_object.c | 59 ++------------------- src/mesa/drivers/dri/nouveau/nouveau_object.h | 14 +---- src/mesa/drivers/dri/nouveau/nouveau_query.c | 9 ++-- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_span.c | 5 +- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 67 ++++++++++++------------ src/mesa/drivers/dri/nouveau/nouveau_sync.h | 32 +++++------ src/mesa/drivers/dri/nouveau/nv30_state.c | 2 +- 14 files changed, 94 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c index 684ed7b017d..fc14060c049 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c @@ -41,7 +41,7 @@ nouveau_bo_download_from_screen(GLcontext *ctx, GLuint offset, GLuint size, DEBUG("..sys_mem\n"); in_mem = nouveau_mem_alloc(ctx, NOUVEAU_MEM_AGP, size, 0); if (in_mem) { - DEBUG("....via AGP\n"); + DEBUG("....via GART\n"); /* otherwise, try blitting to faster memory and * copying from there */ @@ -86,7 +86,7 @@ nouveau_bo_upload_to_screen(GLcontext *ctx, GLuint offset, GLuint size, NOUVEAU_MEM_MAPPED, size, 0); if (out_mem) { - DEBUG("....via AGP\n"); + DEBUG("....via GART\n"); _mesa_memcpy(out_mem->map, nbo->cpu_mem_sys + offset, size); nouveau_memformat_flat_emit(ctx, nbo->gpu_mem, out_mem, @@ -511,7 +511,7 @@ nouveauBufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size, gpu_flags = 0; break; default: - gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_AGP_OK; + gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_GART_OK; break; } nouveau_bo_init_storage(ctx, gpu_flags, size, data, usage, obj); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h index 932450fd877..3439a35e7c8 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h @@ -5,7 +5,7 @@ #include "nouveau_buffers.h" #define NOUVEAU_BO_VRAM_OK (NOUVEAU_MEM_FB | NOUVEAU_MEM_FB_ACCEPTABLE) -#define NOUVEAU_BO_AGP_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE) +#define NOUVEAU_BO_GART_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE) typedef struct nouveau_bufferobj_region_t { uint32_t start; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index e3968bd02fc..857cd30584c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -32,8 +32,8 @@ nouveau_memformat_flat_emit(GLcontext *ctx, return GL_FALSE; } - src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaAGP; - dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaAGP; + src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; + dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; src_offset += nouveau_mem_gpu_offset_get(ctx, src); dst_offset += nouveau_mem_gpu_offset_get(ctx, dst); @@ -138,7 +138,7 @@ nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem) if (mem->type & NOUVEAU_MEM_FB) return (uint32_t)mem->offset - nmesa->vram_phys; else if (mem->type & NOUVEAU_MEM_AGP) - return (uint32_t)mem->offset - nmesa->agp_phys; + return (uint32_t)mem->offset - nmesa->gart_phys; else return 0xDEADF00D; } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 8e11eb61342..d96b00242cd 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -145,10 +145,10 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, &nmesa->vram_size)) return GL_FALSE; if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_PHYSICAL, - &nmesa->agp_phys)) + &nmesa->gart_phys)) return GL_FALSE; if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_SIZE, - &nmesa->agp_size)) + &nmesa->gart_size)) return GL_FALSE; if (!nouveauFifoInit(nmesa)) return GL_FALSE; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 53f3393676f..10d2ed6e172 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -99,19 +99,22 @@ typedef struct nouveau_context { /* The read-only regs */ volatile unsigned char* mmio; + /* The per-channel notifier block */ + volatile void *notifier_block; + /* Physical addresses of AGP/VRAM apertures */ uint64_t vram_phys; uint64_t vram_size; - uint64_t agp_phys; - uint64_t agp_size; + uint64_t gart_phys; + uint64_t gart_size; /* Channel synchronisation */ - nouveau_notifier *syncNotifier; + drm_nouveau_notifier_alloc_t *syncNotifier; /* ARB_occlusion_query / EXT_timer_query */ GLuint query_object_max; GLboolean * query_alloc; - nouveau_notifier *queryNotifier; + drm_nouveau_notifier_alloc_t *queryNotifier; /* Additional hw-specific functions */ nouveau_hw_func hw_func; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c index bd2b2eddd08..e9320918f9f 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c @@ -99,13 +99,14 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa) GLboolean nouveauFifoInit(nouveauContextPtr nmesa) { drm_nouveau_fifo_alloc_t fifo_init; - int i; + int i, ret; #ifdef NOUVEAU_RING_DEBUG return GL_TRUE; #endif - int ret; + fifo_init.fb_ctxdma_handle = NvDmaFB; + fifo_init.tt_ctxdma_handle = NvDmaTT; ret=drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_FIFO_ALLOC, &fifo_init, sizeof(fifo_init)); if (ret) { FATAL("Fifo initialization ioctl failed (returned %d)\n",ret); @@ -117,12 +118,21 @@ GLboolean nouveauFifoInit(nouveauContextPtr nmesa) FATAL("Unable to map the fifo (returned %d)\n",ret); return GL_FALSE; } + ret = drmMap(nmesa->driFd, fifo_init.ctrl, fifo_init.ctrl_size, &nmesa->fifo.mmio); if (ret) { FATAL("Unable to map the control regs (returned %d)\n",ret); return GL_FALSE; } + ret = drmMap(nmesa->driFd, fifo_init.notifier, + fifo_init.notifier_size, + &nmesa->notifier_block); + if (ret) { + FATAL("Unable to map the notifier block (returned %d)\n",ret); + return GL_FALSE; + } + /* Setup our initial FIFO tracking params */ nmesa->fifo.channel = fifo_init.channel; nmesa->fifo.put_base = fifo_init.put_base; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index b71acff4301..69f8dbf7946 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -7,61 +7,18 @@ GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, uint32_t handle, int class) { - drm_nouveau_object_init_t cto; + drm_nouveau_grobj_alloc_t cto; int ret; cto.channel = nmesa->fifo.channel; cto.handle = handle; cto.class = class; - ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_OBJECT_INIT, &cto, sizeof(cto)); + ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_GROBJ_ALLOC, + &cto, sizeof(cto)); return ret == 0; } -GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, - uint32_t handle, - int class, - uint32_t offset, - uint32_t size, - int target, - int access) -{ - drm_nouveau_dma_object_init_t dma; - int ret; - - dma.channel = nmesa->fifo.channel; - dma.class = class; - dma.handle = handle; - dma.target = target; - dma.access = access; - dma.offset = offset; - dma.size = size; - ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_DMA_OBJECT_INIT, - &dma, sizeof(dma)); - return ret == 0; -} - -GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa, - uint32_t handle, int class, - nouveau_mem *mem, - int access) -{ - uint32_t offset = mem->offset; - int target = mem->type & (NOUVEAU_MEM_FB | NOUVEAU_MEM_AGP); - - if (!target) - return GL_FALSE; - - if (target & NOUVEAU_MEM_FB) - offset -= nmesa->vram_phys; - else if (target & NOUVEAU_MEM_AGP) - offset -= nmesa->agp_phys; - - return nouveauCreateDmaObject(nmesa, handle, class, - offset, mem->size, - target, access); -} - void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle) { BEGIN_RING_SIZE(subchannel, 0, 1); @@ -74,16 +31,6 @@ void nouveauObjectInit(nouveauContextPtr nmesa) return; #endif -/* We need to know vram size.. and AGP size (and even if the card is AGP..) */ - nouveauCreateDmaObject( nmesa, NvDmaFB, NV_DMA_IN_MEMORY, - 0, nmesa->vram_size, - NOUVEAU_MEM_FB, - NOUVEAU_MEM_ACCESS_RW); - nouveauCreateDmaObject( nmesa, NvDmaAGP, NV_DMA_IN_MEMORY, - 0, nmesa->agp_size, - NOUVEAU_MEM_AGP, - NOUVEAU_MEM_ACCESS_RW); - nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d); if (nmesa->screen->card->type>=NV_10) { nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.h b/src/mesa/drivers/dri/nouveau/nouveau_object.h index 0be9b4309c6..8c72d014daa 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.h @@ -14,7 +14,7 @@ enum DMAObjects { NvMemFormat = 0x80000022, NvCtxSurf3D = 0x80000023, NvDmaFB = 0xD0FB0001, - NvDmaAGP = 0xD0AA0001, + NvDmaTT = 0xD0AA0001, NvSyncNotify = 0xD0000001, NvQueryNotify = 0xD0000002 }; @@ -31,17 +31,5 @@ extern void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, i extern GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, uint32_t handle, int class); -extern GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa, - uint32_t handle, - int class, - uint32_t offset, - uint32_t size, - int target, - int access); -extern GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa, - uint32_t handle, - int class, - nouveau_mem *mem, - int access); #endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_query.c b/src/mesa/drivers/dri/nouveau/nouveau_query.c index de3f5b0378b..01541400690 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_query.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_query.c @@ -68,7 +68,7 @@ nouveauBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); nouveau_query_object *nq = (nouveau_query_object *)q; - nouveau_notifier_reset(nmesa->queryNotifier, nq->notifier_id); + nouveau_notifier_reset(ctx, nmesa->queryNotifier, nq->notifier_id); switch (nmesa->screen->card->type) { case NV_20: @@ -105,12 +105,13 @@ nouveauUpdateQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) nouveau_query_object *nq = (nouveau_query_object *)q; int status; - status = nouveau_notifier_status(nmesa->queryNotifier, + status = nouveau_notifier_status(ctx, nmesa->queryNotifier, nq->notifier_id); q->Ready = (status == NV_NOTIFY_STATE_STATUS_COMPLETED); if (q->Ready) - q->Result = nouveau_notifier_return_val(nmesa->queryNotifier, + q->Result = nouveau_notifier_return_val(ctx, + nmesa->queryNotifier, nq->notifier_id); } @@ -120,7 +121,7 @@ nouveauWaitQueryResult(GLcontext *ctx, GLenum target, struct gl_query_object *q) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); nouveau_query_object *nq = (nouveau_query_object *)q; - nouveau_notifier_wait_status(nmesa->queryNotifier, nq->notifier_id, + nouveau_notifier_wait_status(ctx, nmesa->queryNotifier, nq->notifier_id, NV_NOTIFY_STATE_STATUS_COMPLETED, 0); nouveauUpdateQuery(ctx, target, q); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 7a4b9f1cd00..bc7f39b042a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 6 +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 7 #error nouveau_drm.h version doesn't match expected version #endif dri_interface = interface; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c index 74dec66afcf..6e3f9fadf4e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c @@ -37,6 +37,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define HAVE_HW_STENCIL_SPANS 0 #define HAVE_HW_STENCIL_PIXELS 0 +static char *fake_span[1280*1024*4]; + #define HW_CLIPLOOP() \ do { \ int _nc = nmesa->numClipRects; \ @@ -52,6 +54,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. GLuint height = nrb->mesa.Height; \ GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) + \ (nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp); \ + map = fake_span; \ GLuint p; \ (void) p; @@ -120,6 +123,6 @@ nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis) { if (nrb->mesa._ActualFormat == GL_RGBA8) nouveauInitPointers_ARGB8888(&nrb->mesa); - else if (nrb->mesa._ActualFormat == GL_RGB5) + else // if (nrb->mesa._ActualFormat == GL_RGB5) nouveauInitPointers_RGB565(&nrb->mesa); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index 30e66962699..1d1eeede18b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -35,53 +35,51 @@ #include "nouveau_msg.h" #include "nouveau_sync.h" -nouveau_notifier * +#define NOTIFIER(__v) \ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \ + volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset + +drm_nouveau_notifier_alloc_t * nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_notifier *notifier; + drm_nouveau_notifier_alloc_t *notifier; + int ret; #ifdef NOUVEAU_RING_DEBUG return NULL; #endif - notifier = CALLOC_STRUCT(nouveau_notifier_t); + notifier = CALLOC_STRUCT(drm_nouveau_notifier_alloc); if (!notifier) return NULL; - notifier->mem = nouveau_mem_alloc(ctx, - NOUVEAU_MEM_FB | NOUVEAU_MEM_MAPPED, - count * NV_NOTIFIER_SIZE, - 0); - if (!notifier->mem) { - FREE(notifier); - return NULL; - } - - if (!nouveauCreateDmaObjectFromMem(nmesa, handle, NV_DMA_IN_MEMORY, - notifier->mem, - NOUVEAU_MEM_ACCESS_RW)) { - nouveau_mem_free(ctx, notifier->mem); + notifier->channel = nmesa->fifo.channel; + notifier->handle = handle; + notifier->count = count; + ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIER_ALLOC, + notifier, sizeof(*notifier)); + if (ret) { + MESSAGE("Failed to create notifier 0x%08x: %d\n", handle, ret); FREE(notifier); return NULL; } - notifier->handle = handle; return notifier; } void -nouveau_notifier_destroy(GLcontext *ctx, nouveau_notifier *notifier) +nouveau_notifier_destroy(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier) { - /*XXX: free DMA object.. */ - nouveau_mem_free(ctx, notifier->mem); + /*XXX: free notifier object.. */ FREE(notifier); } void -nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id) +nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier, + GLuint id) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); #ifdef NOUVEAU_RING_DEBUG return; @@ -95,26 +93,29 @@ nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id) } GLuint -nouveau_notifier_status(nouveau_notifier *notifier, GLuint id) +nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier, + GLuint id) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT; } GLuint -nouveau_notifier_return_val(nouveau_notifier *notifier, GLuint id) +nouveau_notifier_return_val(GLcontext *ctx, + drm_nouveau_notifier_alloc_t *notifier, GLuint id) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); return n[NV_NOTIFY_RETURN_VALUE/4]; } GLboolean -nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id, +nouveau_notifier_wait_status(GLcontext *ctx, + drm_nouveau_notifier_alloc_t *notifier, GLuint id, GLuint status, GLuint timeout) { - volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE); + NOTIFIER(n); unsigned int time = 0; #ifdef NOUVEAU_RING_DEBUG @@ -144,13 +145,13 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id, } void -nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier, - GLuint subc) +nouveau_notifier_wait_nop(GLcontext *ctx, + drm_nouveau_notifier_alloc_t *notifier, GLuint subc) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + NOTIFIER(n); GLboolean ret; - nouveau_notifier_reset(notifier, 0); + nouveau_notifier_reset(ctx, notifier, 0); BEGIN_RING_SIZE(subc, NV_NOTIFY, 1); OUT_RING (NV_NOTIFY_STYLE_WRITE_ONLY); @@ -158,7 +159,7 @@ nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier, OUT_RING (0); FIRE_RING(); - ret = nouveau_notifier_wait_status(notifier, 0, + ret = nouveau_notifier_wait_status(ctx, notifier, 0, NV_NOTIFY_STATE_STATUS_COMPLETED, 0 /* no timeout */); if (ret == GL_FALSE) MESSAGE("wait on notifier failed\n"); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h index 019d5f6629b..b56cc5fb544 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.h @@ -47,21 +47,23 @@ #define NV_NOTIFY 0x00000104 #define NV_NOTIFY_STYLE_WRITE_ONLY 0 -typedef struct nouveau_notifier_t { - GLuint handle; - nouveau_mem *mem; -} nouveau_notifier; - -extern nouveau_notifier *nouveau_notifier_new(GLcontext *, GLuint handle, - GLuint count); -extern void nouveau_notifier_destroy(GLcontext *, nouveau_notifier *); -extern void nouveau_notifier_reset(nouveau_notifier *, GLuint id); -extern GLuint nouveau_notifier_status(nouveau_notifier *, GLuint id); -extern GLuint nouveau_notifier_return_val(nouveau_notifier *, GLuint id); -extern GLboolean nouveau_notifier_wait_status(nouveau_notifier *r, GLuint id, - GLuint status, GLuint timeout); -extern void nouveau_notifier_wait_nop(GLcontext *ctx, - nouveau_notifier *, GLuint subc); +extern drm_nouveau_notifier_alloc_t * +nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count); +extern void +nouveau_notifier_destroy(GLcontext *, drm_nouveau_notifier_alloc_t *); +extern void +nouveau_notifier_reset(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id); +extern GLuint +nouveau_notifier_status(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id); +extern GLuint +nouveau_notifier_return_val(GLcontext *, drm_nouveau_notifier_alloc_t *, + GLuint id); +extern GLboolean +nouveau_notifier_wait_status(GLcontext *, drm_nouveau_notifier_alloc_t *, + GLuint id, GLuint status, GLuint timeout); +extern void +nouveau_notifier_wait_nop(GLcontext *ctx, drm_nouveau_notifier_alloc_t *, + GLuint subc); extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx); #endif diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index d329071d1ee..9b010954b33 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -808,7 +808,7 @@ static GLboolean nv30InitCard(nouveauContextPtr nmesa) BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT1, 3); OUT_RING(NvDmaFB); - OUT_RING(NvDmaAGP); + OUT_RING(NvDmaTT); OUT_RING(NvDmaFB); BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT8, 1); OUT_RING(NvDmaFB); -- cgit v1.2.3 From fc5bf536440efeb9766cc1fd6e69642bc27afbd8 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 29 Jun 2007 21:12:46 -0600 Subject: overhaul point rasterization, no longer use s_pointtemp.h --- src/mesa/swrast/s_points.c | 657 ++++++++++++++++++++++++++++++++------------- 1 file changed, 465 insertions(+), 192 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index b91ce73d7a3..ade1eab8917 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -34,134 +34,493 @@ #include "s_span.h" -#define RGBA 0x1 -#define INDEX 0x2 -#define SMOOTH 0x4 -#define ATTRIBS 0x8 -#define SPECULAR 0x10 -#define LARGE 0x20 -#define ATTENUATE 0x40 -#define SPRITE 0x80 - - -/* - * CI points with size == 1.0 - */ -#define FLAGS (INDEX) -#define NAME size1_ci_point -#include "s_pointtemp.h" - - -/* - * General CI points. +/** + * Used to cull points with invalid coords */ -#define FLAGS (INDEX | LARGE) -#define NAME general_ci_point -#include "s_pointtemp.h" +#define CULL_INVALID(V) \ + do { \ + float tmp = (V)->attrib[FRAG_ATTRIB_WPOS][0] \ + + (V)->attrib[FRAG_ATTRIB_WPOS][1]; \ + if (IS_INF_OR_NAN(tmp)) \ + return; \ + } while(0) -/* - * Antialiased CI points. +/** + * Draw a point sprite */ -#define FLAGS (INDEX | SMOOTH) -#define NAME antialiased_ci_point -#include "s_pointtemp.h" +static void +sprite_point(GLcontext *ctx, const SWvertex *vert) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + SWspan span; + GLfloat size; + GLuint tCoords[MAX_TEXTURE_COORD_UNITS]; + GLuint numTcoords = 0; + GLfloat t0, dtdy; + + CULL_INVALID(vert); + + /* z coord */ + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + else + span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + span.zStep = 0; + + /* compute size */ + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + /* first, clamp attenuated size to the user-specifed range */ + size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); + } + else { + /* use constant point size */ + size = ctx->Point._Size; /* already clamped to user range */ + } + /* clamp to non-AA implementation limits */ + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + + /* span init */ + INIT_SPAN(span, GL_POINT, 0, 0, 0); + span.interpMask = SPAN_Z | SPAN_RGBA; + + span.red = ChanToFixed(vert->color[0]); + span.green = ChanToFixed(vert->color[1]); + span.blue = ChanToFixed(vert->color[2]); + span.alpha = ChanToFixed(vert->color[3]); + span.redStep = 0; + span.greenStep = 0; + span.blueStep = 0; + span.alphaStep = 0; + + /* need these for fragment programs */ + span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; + span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + ATTRIB_LOOP_BEGIN + if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) { + const GLuint u = attr - FRAG_ATTRIB_TEX0; + /* a texcoord */ + if (ctx->Point.CoordReplace[u]) { + GLfloat s, r, dsdx; + + s = 0.0; + dsdx = 1.0 / size; + + if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) { + t0 = 0.0; + dtdy = 1.0 / size; + } + else { + /* GL_UPPER_LEFT */ + t0 = 1.0; + dtdy = -1.0 / size; + } + tCoords[numTcoords++] = attr; + + if (ctx->Point.SpriteRMode == GL_ZERO) + r = 0.0F; + else if (ctx->Point.SpriteRMode == GL_S) + r = vert->attrib[attr][0]; + else /* GL_R */ + r = vert->attrib[attr][2]; + + span.attrStart[attr][0] = s; + span.attrStart[attr][1] = 0.0; /* overwritten below */ + span.attrStart[attr][2] = r; + span.attrStart[attr][3] = 1.0; + + span.attrStepX[attr][0] = dsdx; + span.attrStepX[attr][1] = 0.0; + span.attrStepX[attr][2] = 0.0; + span.attrStepX[attr][3] = 0.0; + + span.attrStepY[attr][0] = 0.0; + span.attrStepY[attr][1] = dtdy; + span.attrStepY[attr][2] = 0.0; + span.attrStepY[attr][3] = 0.0; + + continue; + } + } + /* use vertex's texcoord/attrib */ + COPY_4V(span.attrStart[attr], vert->attrib[attr]); + ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); + ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); + ATTRIB_LOOP_END + + /* compute pos, bounds and render */ + { + const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; + const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; + GLint iSize = (GLint) (size + 0.5F); + GLint xmin, xmax, ymin, ymax, iy; + GLint iRadius; + GLfloat tcoord = t0; + + iSize = MAX2(1, iSize); + iRadius = iSize / 2; + + if (iSize & 1) { + /* odd size */ + xmin = (GLint) (x - iRadius); + xmax = (GLint) (x + iRadius); + ymin = (GLint) (y - iRadius); + ymax = (GLint) (y + iRadius); + } + else { + /* even size */ + xmin = (GLint) x - iRadius + 1; + xmax = xmin + iSize - 1; + ymin = (GLint) y - iRadius + 1; + ymax = ymin + iSize - 1; + } + /* render spans */ + for (iy = ymin; iy <= ymax; iy++) { + GLuint i; + /* setup texcoord T for this row */ + for (i = 0; i < numTcoords; i++) { + span.attrStart[tCoords[i]][1] = tcoord; + } -/* - * Distance attenuated, general CI points. - */ -#define FLAGS (INDEX | ATTENUATE) -#define NAME atten_general_ci_point -#include "s_pointtemp.h" + /* these might get changed by span clipping */ + span.x = xmin; + span.y = iy; + span.end = xmax - xmin + 1; + _swrast_write_rgba_span(ctx, &span); -/* - * RGBA points with size == 1.0 - */ -#define FLAGS (RGBA) -#define NAME size1_rgba_point -#include "s_pointtemp.h" + tcoord += dtdy; + } + } +} -/* - * General RGBA points. +/** + * Draw smooth/antialiased point. RGB or CI mode. */ -#define FLAGS (RGBA | LARGE) -#define NAME general_rgba_point -#include "s_pointtemp.h" - +static void +smooth_point(GLcontext *ctx, const SWvertex *vert) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + const GLboolean ciMode = !ctx->Visual.rgbMode; + SWspan span; + GLfloat size, alphaAtten; + + CULL_INVALID(vert); + + /* z coord */ + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + else + span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + span.zStep = 0; + + /* compute size */ + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + /* first, clamp attenuated size to the user-specifed range */ + size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); + } + else { + /* use constant point size */ + size = ctx->Point._Size; /* this is already clamped */ + } + /* clamp to AA implementation limits */ + size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); -/* - * Antialiased RGBA points. - */ -#define FLAGS (RGBA | SMOOTH) -#define NAME antialiased_rgba_point -#include "s_pointtemp.h" + /* alpha attenuation / fade factor */ + if (ctx->Multisample.Enabled) { + if (vert->pointSize >= ctx->Point.Threshold) { + alphaAtten = 1.0F; + } + else { + GLfloat dsize = vert->pointSize / ctx->Point.Threshold; + alphaAtten = dsize * dsize; + } + } + else { + alphaAtten = 1.0; + } + (void) alphaAtten; /* not used */ + + /* span init */ + INIT_SPAN(span, GL_POINT, 0, 0, 0); + span.interpMask = SPAN_Z | SPAN_RGBA; + span.arrayMask = SPAN_COVERAGE | SPAN_MASK; + + span.red = ChanToFixed(vert->color[0]); + span.green = ChanToFixed(vert->color[1]); + span.blue = ChanToFixed(vert->color[2]); + span.alpha = ChanToFixed(vert->color[3]); + span.redStep = 0; + span.greenStep = 0; + span.blueStep = 0; + span.alphaStep = 0; + + /* need these for fragment programs */ + span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; + span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + ATTRIB_LOOP_BEGIN + COPY_4V(span.attrStart[attr], vert->attrib[attr]); + ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); + ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); + ATTRIB_LOOP_END + + /* compute pos, bounds and render */ + { + const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; + const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; + const GLfloat radius = 0.5F * size; + const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + const GLfloat rmax = radius + 0.7071F; + const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); + const GLfloat rmax2 = rmax * rmax; + const GLfloat cscale = 1.0F / (rmax2 - rmin2); + const GLint xmin = (GLint) (x - radius); + const GLint xmax = (GLint) (x + radius); + const GLint ymin = (GLint) (y - radius); + const GLint ymax = (GLint) (y + radius); + GLint ix, iy; + + for (iy = ymin; iy <= ymax; iy++) { + + /* these might get changed by span clipping */ + span.x = xmin; + span.y = iy; + span.end = xmax - xmin + 1; + + /* compute coverage for each pixel in span */ + for (ix = xmin; ix <= xmax; ix++) { + const GLfloat dx = ix - x + 0.5F; + const GLfloat dy = iy - y + 0.5F; + const GLfloat dist2 = dx * dx + dy * dy; + GLfloat coverage; + + if (dist2 < rmax2) { + if (dist2 >= rmin2) { + /* compute partial coverage */ + coverage = 1.0F - (dist2 - rmin2) * cscale; + if (ciMode) { + /* coverage in [0,15] */ + coverage *= 15.0; + } + } + else { + /* full coverage */ + coverage = 1.0F; + } + span.array->mask[ix - xmin] = 1; + } + else { + /* zero coverage - fragment outside the radius */ + coverage = 0.0; + span.array->mask[ix - xmin] = 0; + } + span.array->coverage[ix - xmin] = coverage; + } + /* render span */ + _swrast_write_rgba_span(ctx, &span); -/* - * Textured RGBA points. - */ -#define FLAGS (RGBA | LARGE | ATTRIBS | SPECULAR) -#define NAME textured_rgba_point -#include "s_pointtemp.h" + } + } +} -/* - * Antialiased points with texture mapping. +/** + * Draw large (size >= 1) non-AA point. RGB or CI mode. */ -#define FLAGS (RGBA | SMOOTH | ATTRIBS | SPECULAR) -#define NAME antialiased_tex_rgba_point -#include "s_pointtemp.h" +static void +large_point(GLcontext *ctx, const SWvertex *vert) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + const GLboolean ciMode = !ctx->Visual.rgbMode; + SWspan span; + GLfloat size; + + CULL_INVALID(vert); + + /* z coord */ + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span.z = FloatToFixed(vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + else + span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); + span.zStep = 0; + + /* compute size */ + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { + /* use vertex's point size */ + /* first, clamp attenuated size to the user-specifed range */ + size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); + } + else { + /* use constant point size */ + size = ctx->Point._Size; /* already clamped to user range */ + } + /* clamp to non-AA implementation limits */ + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); + /* span init */ + INIT_SPAN(span, GL_POINT, 0, 0, 0); + span.arrayMask = SPAN_XY; -/* - * Distance attenuated, general RGBA points. - */ -#define FLAGS (RGBA | ATTENUATE) -#define NAME atten_general_rgba_point -#include "s_pointtemp.h" + if (ciMode) { + span.interpMask = SPAN_Z | SPAN_INDEX; + span.index = FloatToFixed(vert->attrib[FRAG_ATTRIB_CI][0]); + span.indexStep = 0; + } + else { + span.interpMask = SPAN_Z | SPAN_RGBA; + span.red = ChanToFixed(vert->color[0]); + span.green = ChanToFixed(vert->color[1]); + span.blue = ChanToFixed(vert->color[2]); + span.alpha = ChanToFixed(vert->color[3]); + span.redStep = 0; + span.greenStep = 0; + span.blueStep = 0; + span.alphaStep = 0; + } + /* need these for fragment programs */ + span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; + span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + ATTRIB_LOOP_BEGIN + COPY_4V(span.attrStart[attr], vert->attrib[attr]); + ASSIGN_4V(span.attrStepX[attr], 0, 0, 0, 0); + ASSIGN_4V(span.attrStepY[attr], 0, 0, 0, 0); + ATTRIB_LOOP_END + + /* compute pos, bounds and render */ + { + const GLfloat x = vert->attrib[FRAG_ATTRIB_WPOS][0]; + const GLfloat y = vert->attrib[FRAG_ATTRIB_WPOS][1]; + GLint iSize = (GLint) (size + 0.5F); + GLint xmin, xmax, ymin, ymax, ix, iy; + GLint iRadius; + + iSize = MAX2(1, iSize); + iRadius = iSize / 2; + + if (iSize & 1) { + /* odd size */ + xmin = (GLint) (x - iRadius); + xmax = (GLint) (x + iRadius); + ymin = (GLint) (y - iRadius); + ymax = (GLint) (y + iRadius); + } + else { + /* even size */ + xmin = (GLint) x - iRadius + 1; + xmax = xmin + iSize - 1; + ymin = (GLint) y - iRadius + 1; + ymax = ymin + iSize - 1; + } -/* - * Distance attenuated, textured RGBA points. - */ -#define FLAGS (RGBA | ATTENUATE | ATTRIBS | SPECULAR) -#define NAME atten_textured_rgba_point -#include "s_pointtemp.h" + /* generate fragments */ + span.end = 0; + for (iy = ymin; iy <= ymax; iy++) { + for (ix = xmin; ix <= xmax; ix++) { + span.array->x[span.end] = ix; + span.array->y[span.end] = iy; + span.end++; + } + } + assert(span.end <= MAX_WIDTH); + _swrast_write_rgba_span(ctx, &span); + } +} -/* - * Distance attenuated, antialiased points with or without texture mapping. +/** + * Draw size=1, single-pixel point */ -#define FLAGS (RGBA | ATTENUATE | ATTRIBS | SMOOTH) -#define NAME atten_antialiased_rgba_point -#include "s_pointtemp.h" +static void +pixel_point(GLcontext *ctx, const SWvertex *vert) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + const GLboolean ciMode = !ctx->Visual.rgbMode; + /* + * Note that unlike the other functions, we put single-pixel points + * into a special span array in order to render as many points as + * possible with a single _swrast_write_rgba_span() call. + */ + SWspan *span = &(swrast->PointSpan); + GLuint count; + + CULL_INVALID(vert); + + /* Span init */ + span->interpMask = 0; + span->arrayMask = SPAN_XY | SPAN_Z; + if (ciMode) + span->arrayMask |= SPAN_INDEX; + else + span->arrayMask |= SPAN_RGBA; + /*span->arrayMask |= SPAN_LAMBDA;*/ + span->arrayAttribs = swrast->_ActiveAttribMask; /* we'll produce these vals */ + + /* need these for fragment programs */ + span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; + span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; + span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; + + /* check if we need to flush */ + if (span->end >= MAX_WIDTH || + (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { + if (ciMode) + _swrast_write_index_span(ctx, span); + else + _swrast_write_rgba_span(ctx, span); + span->end = 0; + } + count = span->end; -/* - * Sprite (textured point) - */ -#define FLAGS (RGBA | SPRITE | SPECULAR) -#define NAME sprite_point -#include "s_pointtemp.h" + /* fragment attributes */ + if (ciMode) { + span->array->index[count] = (GLuint) vert->attrib[FRAG_ATTRIB_CI][0]; + } + else { + span->array->rgba[count][RCOMP] = vert->color[0]; + span->array->rgba[count][GCOMP] = vert->color[1]; + span->array->rgba[count][BCOMP] = vert->color[2]; + span->array->rgba[count][ACOMP] = vert->color[3]; + } + ATTRIB_LOOP_BEGIN + COPY_4V(span->array->attribs[attr][count], vert->attrib[attr]); + ATTRIB_LOOP_END + /* fragment position */ + span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0]; + span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1]; + span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); -#define FLAGS (RGBA | SPRITE | SPECULAR | ATTENUATE) -#define NAME atten_sprite_point -#include "s_pointtemp.h" + span->end = count + 1; + ASSERT(span->end <= MAX_WIDTH); +} +/** + * Add specular color to primary color, draw point, restore original + * primary color. + */ void _swrast_add_spec_terms_point(GLcontext *ctx, const SWvertex *v0) { - SWvertex *ncv0 = (SWvertex *) v0; + SWvertex *ncv0 = (SWvertex *) v0; /* cast away const */ GLfloat rSum, gSum, bSum; GLchan cSave[4]; /* save */ - COPY_CHAN4( cSave, ncv0->color ); + COPY_CHAN4(cSave, ncv0->color); /* sum */ rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0]; gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1]; @@ -176,121 +535,35 @@ _swrast_add_spec_terms_point(GLcontext *ctx, const SWvertex *v0) } - -/* record the current point function name */ -#ifdef DEBUG - -static const char *pntFuncName = NULL; - -#define USE(pntFunc) \ -do { \ - pntFuncName = #pntFunc; \ - /*printf("%s\n", pntFuncName);*/ \ - swrast->Point = pntFunc; \ -} while (0) - -#else - -#define USE(pntFunc) swrast->Point = pntFunc - -#endif - - -/* - * Examine the current context to determine which point drawing function - * should be used. +/** + * Examine current state to determine which point drawing function to use. */ void -_swrast_choose_point( GLcontext *ctx ) +_swrast_choose_point(GLcontext *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - GLboolean rgbMode = ctx->Visual.rgbMode; - GLboolean specular = (ctx->Fog.ColorSumEnabled || - (ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)); - GLboolean attribs = (ctx->FragmentProgram._Current || - ctx->Texture._EnabledCoordUnits || - swrast->_FogEnabled || - specular); - /* - * XXX this is a mess that should be cleaned up someday - */ - - if (ctx->RenderMode==GL_RENDER) { + if (ctx->RenderMode == GL_RENDER) { if (ctx->Point.PointSprite) { - /* GL_ARB_point_sprite / GL_NV_point_sprite */ - /* XXX this might not be good enough */ - if (ctx->Point._Attenuated) - USE(atten_sprite_point); - else - USE(sprite_point); - } - else if (ctx->Point.SmoothFlag && !attribs) { - /* Smooth points */ - if (rgbMode) { - if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - USE(atten_antialiased_rgba_point); - } - else if (ctx->Texture._EnabledCoordUnits) { - USE(antialiased_tex_rgba_point); - } - else { - USE(antialiased_rgba_point); - } - } - else { - USE(antialiased_ci_point); - } + swrast->Point = sprite_point; } - else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { - if (rgbMode) { - if (attribs) { - if (ctx->Point.SmoothFlag) { - USE(atten_antialiased_rgba_point); - } - else { - USE(atten_textured_rgba_point); - } - } - else { - USE(atten_general_rgba_point); - } - } - else { - /* ci, atten */ - USE(atten_general_ci_point); - } + else if (ctx->Point.SmoothFlag) { + swrast->Point = smooth_point; } - else if (attribs && rgbMode) { - /* textured, fogged */ - USE(textured_rgba_point); - } - else if (ctx->Point._Size != 1.0) { - /* large points */ - if (rgbMode) { - USE(general_rgba_point); - } - else { - USE(general_ci_point); - } + else if (ctx->Point._Size > 1.0 || + ctx->Point._Attenuated || + ctx->VertexProgram.PointSizeEnabled) { + swrast->Point = large_point; } else { - /* single pixel points */ - if (rgbMode) { - assert((swrast->_ActiveAttribMask & FRAG_BIT_COL1) == 0); - USE(size1_rgba_point); - } - else { - USE(size1_ci_point); - } + swrast->Point = pixel_point; } } - else if (ctx->RenderMode==GL_FEEDBACK) { - USE(_swrast_feedback_point); + else if (ctx->RenderMode == GL_FEEDBACK) { + swrast->Point = _swrast_feedback_point; } else { /* GL_SELECT mode */ - USE(_swrast_select_point); + swrast->Point = _swrast_select_point; } } -- cgit v1.2.3 From fb4f4e2d186fac24cafa5e637461042706d4a123 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 29 Jun 2007 21:13:20 -0600 Subject: Obsolete --- src/mesa/swrast/s_pointtemp.h | 406 ------------------------------------------ 1 file changed, 406 deletions(-) delete mode 100644 src/mesa/swrast/s_pointtemp.h (limited to 'src') diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h deleted file mode 100644 index 206085b5b87..00000000000 --- a/src/mesa/swrast/s_pointtemp.h +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.3 - * - * Copyright (C) 1999-2007 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. - */ - -/* - * Regarding GL_NV_point_sprite: - * - * Portions of this software may use or implement intellectual - * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims - * any and all warranties with respect to such intellectual property, - * including any use thereof or modifications thereto. - */ - - -/* - * Point rendering template code. - * - * Set FLAGS = bitwise-OR of the following tokens: - * - * RGBA = do rgba instead of color index - * SMOOTH = do antialiasing - * ATTRIBS = general attributes (texcoords, etc) - * LARGE = do points with diameter > 1 pixel - * ATTENUATE = compute point size attenuation - * SPRITE = GL_ARB_point_sprite / GL_NV_point_sprite - * - * Notes: LARGE and ATTENUATE are exclusive of each other. - * ATTRIBS requires RGBA - */ - - -/* - * NOTES on antialiased point rasterization: - * - * Let d = distance of fragment center from vertex. - * if d < rmin2 then - * fragment has 100% coverage - * else if d > rmax2 then - * fragment has 0% coverage - * else - * fragment has % coverage = (d - rmin2) / (rmax2 - rmin2) - */ - - -static void -NAME ( GLcontext *ctx, const SWvertex *vert ) -{ -#if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE) - GLfloat size; -#endif -#if FLAGS & RGBA -#if (FLAGS & ATTENUATE) && (FLAGS & SMOOTH) - GLfloat alphaAtten; -#endif - const GLchan red = vert->color[0]; - const GLchan green = vert->color[1]; - const GLchan blue = vert->color[2]; - const GLchan alpha = vert->color[3]; -#endif -#if FLAGS & INDEX - const GLuint colorIndex = (GLuint) vert->attrib[FRAG_ATTRIB_CI][0]; /* XXX round? */ -#endif -#if FLAGS & ATTRIBS - GLfloat attrib[FRAG_ATTRIB_MAX][4]; /* texture & varying */ -#endif - SWcontext *swrast = SWRAST_CONTEXT(ctx); - SWspan *span = &(swrast->PointSpan); - - /* - printf("%s %g %g %g %g\n", __FUNCTION__, - vert->attrib[FRAG_ATTRIB_COL1][0], - vert->attrib[FRAG_ATTRIB_COL1][1], - vert->attrib[FRAG_ATTRIB_COL1][2], - vert->attrib[FRAG_ATTRIB_COL1][3]); - if ( vert->attrib[FRAG_ATTRIB_COL1][0] == 0.0 && - vert->attrib[FRAG_ATTRIB_COL1][1] == 1.0 && - vert->attrib[FRAG_ATTRIB_COL1][2] == 0.0) - foo(); - */ - - /* Cull primitives with malformed coordinates. - */ - { - float tmp = vert->attrib[FRAG_ATTRIB_WPOS][0] + vert->attrib[FRAG_ATTRIB_WPOS][1]; - if (IS_INF_OR_NAN(tmp)) - return; - } - - /* - * Span init - */ - span->interpMask = 0; - span->arrayMask = SPAN_XY | SPAN_Z; -#if FLAGS & RGBA - span->arrayMask |= SPAN_RGBA; -#endif -#if FLAGS & INDEX - span->arrayMask |= SPAN_INDEX; -#endif -#if FLAGS & ATTRIBS - span->arrayMask |= SPAN_LAMBDA; - - /* we're filling in the attrib arrays: */ - span->arrayAttribs = swrast->_ActiveAttribMask; - - ATTRIB_LOOP_BEGIN - COPY_4V(attrib[attr], vert->attrib[attr]); - ATTRIB_LOOP_END - - /* need these for fragment programs */ - span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; - span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; - span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; -#else - assert((swrast->_ActiveAttribMask & FRAG_BIT_COL1) == 0); -#endif - -#if FLAGS & SMOOTH - span->arrayMask |= SPAN_COVERAGE; -#endif -#if FLAGS & SPRITE - span->arrayMask |= SPAN_LAMBDA; -#endif - - /* Compute point size if not known to be one */ -#if FLAGS & ATTENUATE - /* first, clamp attenuated size to the user-specifed range */ - size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize); -#if (FLAGS & RGBA) && (FLAGS & SMOOTH) - /* only if multisampling, compute the fade factor */ - if (ctx->Multisample.Enabled) { - if (vert->pointSize >= ctx->Point.Threshold) { - alphaAtten = 1.0F; - } - else { - GLfloat dsize = vert->pointSize / ctx->Point.Threshold; - alphaAtten = dsize * dsize; - } - } - else { - alphaAtten = 1.0; - } -#endif -#elif FLAGS & (LARGE | SMOOTH | SPRITE) - /* constant, non-attenuated size */ - size = ctx->Point._Size; /* this is already clamped */ -#endif - - -#if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE) - /*** - *** Multi-pixel points - ***/ - - /* do final clamping now */ - if (ctx->Point.SmoothFlag) { - size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); - } - else { - size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); - } - - {{ - GLint x, y; - const GLfloat radius = 0.5F * size; - const GLuint z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - GLuint count; -#if FLAGS & SMOOTH - const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ - const GLfloat rmax = radius + 0.7071F; - const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); - const GLfloat rmax2 = rmax * rmax; - const GLfloat cscale = 1.0F / (rmax2 - rmin2); - const GLint xmin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] - radius); - const GLint xmax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] + radius); - const GLint ymin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] - radius); - const GLint ymax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] + radius); -#else - /* non-smooth */ - GLint xmin, xmax, ymin, ymax; - GLint iSize = (GLint) (size + 0.5F); - GLint iRadius; - iSize = MAX2(1, iSize); - iRadius = iSize / 2; - if (iSize & 1) { - /* odd size */ - xmin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] - iRadius); - xmax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] + iRadius); - ymin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] - iRadius); - ymax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] + iRadius); - } - else { - /* even size */ - xmin = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0] - iRadius + 1; - xmax = xmin + iSize - 1; - ymin = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1] - iRadius + 1; - ymax = ymin + iSize - 1; - } -#endif /*SMOOTH*/ - - /* check if we need to flush */ - if (span->end + (xmax-xmin+1) * (ymax-ymin+1) >= MAX_WIDTH || - (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { - if (span->end > 0) { -#if FLAGS & RGBA - _swrast_write_rgba_span(ctx, span); -#else - _swrast_write_index_span(ctx, span); -#endif - span->end = 0; - } - } - - /* - * OK, generate fragments - */ - count = span->end; - (void) radius; - for (y = ymin; y <= ymax; y++) { - /* check if we need to flush */ - if (count + (xmax-xmin+1) >= MAX_WIDTH) { - span->end = count; -#if FLAGS & RGBA - _swrast_write_rgba_span(ctx, span); -#else - _swrast_write_index_span(ctx, span); -#endif - count = span->end = 0; - } - for (x = xmin; x <= xmax; x++) { -#if FLAGS & SPRITE - GLuint u; -#endif - -#if FLAGS & RGBA - span->array->rgba[count][RCOMP] = red; - span->array->rgba[count][GCOMP] = green; - span->array->rgba[count][BCOMP] = blue; - span->array->rgba[count][ACOMP] = alpha; -#endif -#if FLAGS & INDEX - span->array->index[count] = colorIndex; -#endif -#if FLAGS & ATTRIBS - ATTRIB_LOOP_BEGIN - COPY_4V(span->array->attribs[attr][count], attrib[attr]); - /** - if (attr < FRAG_ATTRIB_VAR0) { - const GLuint u = attr - FRAG_ATTRIB_TEX0; - span->array->lambda[u][count] = 0.0; - } - **/ - ATTRIB_LOOP_END -#endif - -#if FLAGS & SMOOTH - /* compute coverage */ - { - const GLfloat dx = x - vert->attrib[FRAG_ATTRIB_WPOS][0] + 0.5F; - const GLfloat dy = y - vert->attrib[FRAG_ATTRIB_WPOS][1] + 0.5F; - const GLfloat dist2 = dx * dx + dy * dy; - if (dist2 < rmax2) { - if (dist2 >= rmin2) { - /* compute partial coverage */ - span->array->coverage[count] = 1.0F - (dist2 - rmin2) * cscale; -#if FLAGS & INDEX - /* coverage in [0,15] */ - span->array->coverage[count] *= 15.0; -#endif - } - else { - /* full coverage */ - span->array->coverage[count] = 1.0F; - } - - span->array->x[count] = x; - span->array->y[count] = y; - span->array->z[count] = z; - -#if (FLAGS & ATTENUATE) && (FLAGS & RGBA) - span->array->rgba[count][ACOMP] = (GLchan) (alpha * alphaAtten); -#elif FLAGS & RGBA - span->array->rgba[count][ACOMP] = alpha; -#endif /*ATTENUATE*/ - count++; - } /*if*/ - } - -#else /*SMOOTH*/ - - /* not smooth (square points) */ - span->array->x[count] = x; - span->array->y[count] = y; - span->array->z[count] = z; - -#if FLAGS & SPRITE - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - GLuint attr = FRAG_ATTRIB_TEX0 + u; - if (ctx->Texture.Unit[u]._ReallyEnabled) { - if (ctx->Point.CoordReplace[u]) { - GLfloat s = 0.5F + (x + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][0]) / size; - GLfloat t, r; - if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) - t = 0.5F + (y + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][1]) / size; - else /* GL_UPPER_LEFT */ - t = 0.5F - (y + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][1]) / size; - if (ctx->Point.SpriteRMode == GL_ZERO) - r = 0.0F; - else if (ctx->Point.SpriteRMode == GL_S) - r = vert->attrib[attr][0]; - else /* GL_R */ - r = vert->attrib[attr][2]; - span->array->attribs[attr][count][0] = s; - span->array->attribs[attr][count][1] = t; - span->array->attribs[attr][count][2] = r; - span->array->attribs[attr][count][3] = 1.0F; - span->array->lambda[u][count] = 0.0; /* XXX fix? */ - } - else { - COPY_4V(span->array->attribs[attr][count], - vert->attrib[attr]); - } - } - } -#endif /*SPRITE*/ - - count++; /* square point */ - -#endif /*SMOOTH*/ - - } /*for x*/ - } /*for y*/ - span->end = count; - }} - -#else /* LARGE | ATTENUATE | SMOOTH | SPRITE */ - - /*** - *** Single-pixel points - ***/ - {{ - GLuint count; - - /* check if we need to flush */ - if (span->end >= MAX_WIDTH || - (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) { -#if FLAGS & RGBA - _swrast_write_rgba_span(ctx, span); -#else - _swrast_write_index_span(ctx, span); -#endif - span->end = 0; - } - - count = span->end; - -#if FLAGS & RGBA - span->array->rgba[count][RCOMP] = red; - span->array->rgba[count][GCOMP] = green; - span->array->rgba[count][BCOMP] = blue; - span->array->rgba[count][ACOMP] = alpha; -#endif -#if FLAGS & INDEX - span->array->index[count] = colorIndex; -#endif -#if FLAGS & ATTRIBS - ATTRIB_LOOP_BEGIN - COPY_4V(span->array->attribs[attr][count], attribs[attr]); - ATTRIB_LOOP_END -#endif - - span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0]; - span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1]; - span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F); - - span->end = count + 1; - }} - -#endif /* LARGE || ATTENUATE || SMOOTH */ - - ASSERT(span->end <= MAX_WIDTH); -} - - -#undef FLAGS -#undef NAME -- cgit v1.2.3 From 9dca42a4a10acbf1980c0f2eafb3e28e11ca1bf3 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 29 Jun 2007 21:29:30 -0600 Subject: Undo some prev glDraw/CopyPixel changes which fixed a bug in which colors were overwritten by interpolating attributes. Now just set the span->arrayAttribs mask in glDraw/CopyPixels and be sure we don't overwrite the values in interpolate_active_attribs(). --- src/mesa/swrast/s_copypix.c | 17 +++++------------ src/mesa/swrast/s_drawpix.c | 15 ++++----------- src/mesa/swrast/s_span.c | 8 +++++--- src/mesa/swrast/s_zoom.c | 1 + 4 files changed, 15 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 2383015000a..9cd6ca20a9d 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -156,7 +156,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, /* write the new image */ for (row = 0; row < height; row++) { const GLfloat *src = convImage + row * width * 4; - GLvoid *rgba = (GLvoid *) span.array->attribs[FRAG_ATTRIB_COL0]; + GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0]; /* copy convolved colors into span array */ _mesa_memcpy(rgba, src, width * 4 * sizeof(GLfloat)); @@ -188,8 +188,6 @@ static void copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint width, GLint height, GLint destx, GLint desty) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLbitfield prevActiveAttribs = swrast->_ActiveAttribMask; GLfloat *tmpImage, *p; GLint sy, dy, stepy, row; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; @@ -199,15 +197,12 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, if (!ctx->ReadBuffer->_ColorReadBuffer) { /* no readbuffer - OK */ - goto end; + return; } - /* don't interpolate COL0 and overwrite the glDrawPixel colors! */ - swrast->_ActiveAttribMask &= ~FRAG_BIT_COL0; - if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty); - goto end; + return; } else if (ctx->Pixel.Convolution1DEnabled) { /* make sure we don't apply 1D convolution */ @@ -239,12 +234,13 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); _swrast_span_default_attribs(ctx, &span); + span.arrayAttribs = FRAG_BIT_COL0; /* we'll fill in COL0 attrib values */ if (overlapping) { tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4); if (!tmpImage) { _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" ); - goto end; + return; } /* read the source image as RGBA/float */ p = tmpImage; @@ -299,9 +295,6 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, if (overlapping) _mesa_free(tmpImage); - -end: - swrast->_ActiveAttribMask = prevActiveAttribs; } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 925358d77eb..b5388745bab 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -532,25 +532,21 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels ) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); - const GLbitfield prevActiveAttribs = swrast->_ActiveAttribMask; const GLint imgX = x, imgY = y; const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; GLfloat *convImage = NULL; GLbitfield transferOps = ctx->_ImageTransferState; SWspan span; - /* don't interpolate COL0 and overwrite the glDrawPixel colors! */ - swrast->_ActiveAttribMask &= ~FRAG_BIT_COL0; - /* Try an optimized glDrawPixels first */ if (fast_draw_rgba_pixels(ctx, x, y, width, height, format, type, unpack, pixels)) { - goto end; + return; } INIT_SPAN(span, GL_BITMAP, 0, 0x0, SPAN_RGBA); _swrast_span_default_attribs(ctx, &span); + span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { /* Convolution has to be handled specially. We'll create an @@ -565,13 +561,13 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); if (!tmpImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - goto end; + return; } convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); if (!convImage) { _mesa_free(tmpImage); _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels"); - goto end; + return; } /* Unpack the image and apply transfer ops up to convolution */ @@ -675,9 +671,6 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, if (convImage) { _mesa_free(convImage); } - -end: - swrast->_ActiveAttribMask = prevActiveAttribs; } diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 4ab6e2e9fbf..f23272c2bee 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -171,10 +171,11 @@ interpolate_active_attribs(GLcontext *ctx, SWspan *span, GLbitfield attrMask) { const SWcontext *swrast = SWRAST_CONTEXT(ctx); - /* for glDraw/CopyPixels() we may have turned off some bits in - * the _ActiveAttribMask - be sure to obey that mask now. + /* + * Don't overwrite existing array values, such as colors that may have + * been produced by glDraw/CopyPixels. */ - attrMask &= swrast->_ActiveAttribMask; + attrMask &= ~span->arrayAttribs; ATTRIB_LOOP_BEGIN if (attrMask & (1 << attr)) { @@ -201,6 +202,7 @@ interpolate_active_attribs(GLcontext *ctx, SWspan *span, GLbitfield attrMask) v3 += dv3dx; w += dwdx; } + ASSERT((span->arrayAttribs & (1 << attr)) == 0); span->arrayAttribs |= (1 << attr); } ATTRIB_LOOP_END diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index ab02e3fbb35..5f495e36c12 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -175,6 +175,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, /* we'll generate an array of colorss */ zoomed.interpMask = span->interpMask & ~SPAN_RGBA; zoomed.arrayMask |= SPAN_RGBA; + zoomed.arrayAttribs |= FRAG_BIT_COL0; /* we'll produce these values */ ASSERT(span->arrayMask & SPAN_RGBA); } else if (format == GL_COLOR_INDEX) { -- cgit v1.2.3 From fcc77d3ece160743e3f0f034ce2e130030c6386d Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 29 Jun 2007 21:33:59 -0600 Subject: s/SPAN_RGBA/SPAN_INDEX/ in clear_ci_buffer_with_masking() --- src/mesa/swrast/s_buffers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 35f2dd64909..bd66cf125b5 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -119,7 +119,7 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) ASSERT(rb->DataType == GL_UNSIGNED_INT); /* Initialize index span with clear index */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_INDEX); for (i = 0; i < width;i++) { span.array->index[i] = ctx->Color.ClearIndex; } -- cgit v1.2.3 From f4b103dc993491355ec3e3640d9cb060138175c2 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 29 Jun 2007 21:52:18 -0600 Subject: simplify INIT_SPAN code --- src/mesa/swrast/s_aalinetemp.h | 4 ++-- src/mesa/swrast/s_aatritemp.h | 3 ++- src/mesa/swrast/s_accum.c | 4 +++- src/mesa/swrast/s_bitmap.c | 8 ++++++-- src/mesa/swrast/s_buffers.c | 8 ++++++-- src/mesa/swrast/s_copypix.c | 13 +++++++++---- src/mesa/swrast/s_drawpix.c | 13 +++++++++---- src/mesa/swrast/s_linetemp.h | 5 ++++- src/mesa/swrast/s_points.c | 6 +++--- src/mesa/swrast/s_span.h | 18 +++++++++--------- src/mesa/swrast/s_tritemp.h | 2 +- src/mesa/swrast/s_zoom.c | 2 +- 12 files changed, 55 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 3d3511823d7..69a1f0cd396 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -137,8 +137,8 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) return; - INIT_SPAN(line.span, GL_LINE, 0, 0, SPAN_XY | SPAN_COVERAGE); - + INIT_SPAN(line.span, GL_LINE); + line.span.arrayMask = SPAN_XY | SPAN_COVERAGE; line.xAdj = line.dx / line.len * line.halfWidth; line.yAdj = line.dy / line.len * line.halfWidth; diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 34a2305b393..42d74a16328 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -69,7 +69,8 @@ (void) swrast; - INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE); + INIT_SPAN(span, GL_POLYGON); + span.arrayMask = SPAN_COVERAGE; /* determine bottom to top order of vertices */ { diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index f53e7f52c5e..3c45dee3998 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -474,7 +474,9 @@ accum_return(GLcontext *ctx, GLfloat value, SWspan span; /* init color span */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_RGBA; span.x = xpos; span.y = ypos + i; diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index 563b5fe602c..1e7f6c18e6a 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -82,7 +82,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_XY); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_XY; _swrast_span_default_attribs(ctx, &span); for (row = 0; row < height; row++) { @@ -180,7 +182,9 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_MASK); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_MASK; _swrast_span_default_attribs(ctx, &span); /*span.arrayMask |= SPAN_MASK;*/ /* we'll init span.mask[] */ diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index bd66cf125b5..90a56284c51 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -55,7 +55,9 @@ clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) /* Initialize color span with clear color */ /* XXX optimize for clearcolor == black/zero (bzero) */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_RGBA; span.array->ChanType = rb->DataType; if (span.array->ChanType == GL_UNSIGNED_BYTE) { GLubyte clearColor[4]; @@ -119,7 +121,9 @@ clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb) ASSERT(rb->DataType == GL_UNSIGNED_INT); /* Initialize index span with clear index */ - INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_INDEX); + INIT_SPAN(span, GL_BITMAP); + span.end = width; + span.arrayMask = SPAN_INDEX; for (i = 0; i < width;i++) { span.array->index[i] = ctx->Color.ClearIndex; } diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 9cd6ca20a9d..bbe1081860d 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -102,8 +102,10 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLfloat *dest, *tmpImage, *convImage; SWspan span; - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_RGBA; + span.arrayAttribs = FRAG_BIT_COL0; /* allocate space for GLfloat image */ tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); @@ -232,8 +234,9 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, stepy = 1; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_RGBA; span.arrayAttribs = FRAG_BIT_COL0; /* we'll fill in COL0 attrib values */ if (overlapping) { @@ -315,8 +318,9 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy, return; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_INDEX; if (ctx->DrawBuffer == ctx->ReadBuffer) { overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, @@ -449,8 +453,9 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, return; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_Z; if (ctx->DrawBuffer == ctx->ReadBuffer) { overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index b5388745bab..b8b452e33dd 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -70,7 +70,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y, return GL_FALSE; } - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); + span.arrayMask = SPAN_RGBA; + span.arrayAttribs = FRAG_BIT_COL0; _swrast_span_default_attribs(ctx, &span); /* copy input params since clipping may change them */ @@ -332,7 +334,8 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, GLint row, skipPixels; SWspan span; - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); + INIT_SPAN(span, GL_BITMAP); + span.arrayMask = SPAN_INDEX; _swrast_span_default_attribs(ctx, &span); /* @@ -427,7 +430,8 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; SWspan span; - INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); + INIT_SPAN(span, GL_BITMAP); + span.arrayMask = SPAN_Z; _swrast_span_default_attribs(ctx, &span); if (type == GL_UNSIGNED_SHORT @@ -544,8 +548,9 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, return; } - INIT_SPAN(span, GL_BITMAP, 0, 0x0, SPAN_RGBA); + INIT_SPAN(span, GL_BITMAP); _swrast_span_default_attribs(ctx, &span); + span.arrayMask = SPAN_RGBA; span.arrayAttribs = FRAG_BIT_COL0; /* we're fill in COL0 attrib values */ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 55548f27b08..1accfc67e2c 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -303,7 +303,10 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 ) } #endif - INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY); + INIT_SPAN(span, GL_LINE); + span.end = numPixels; + span.interpMask = interpFlags; + span.arrayMask = SPAN_XY; /* * Draw diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index ade1eab8917..8eba53c8076 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -82,7 +82,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); /* span init */ - INIT_SPAN(span, GL_POINT, 0, 0, 0); + INIT_SPAN(span, GL_POINT); span.interpMask = SPAN_Z | SPAN_RGBA; span.red = ChanToFixed(vert->color[0]); @@ -248,7 +248,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert) (void) alphaAtten; /* not used */ /* span init */ - INIT_SPAN(span, GL_POINT, 0, 0, 0); + INIT_SPAN(span, GL_POINT); span.interpMask = SPAN_Z | SPAN_RGBA; span.arrayMask = SPAN_COVERAGE | SPAN_MASK; @@ -367,7 +367,7 @@ large_point(GLcontext *ctx, const SWvertex *vert) size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); /* span init */ - INIT_SPAN(span, GL_POINT, 0, 0, 0); + INIT_SPAN(span, GL_POINT); span.arrayMask = SPAN_XY; if (ciMode) { diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index 585cce91ee9..512134db0f8 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -159,15 +159,15 @@ typedef struct sw_span -#define INIT_SPAN(S, PRIMITIVE, END, INTERP_MASK, ARRAY_MASK) \ -do { \ - (S).primitive = (PRIMITIVE); \ - (S).interpMask = (INTERP_MASK); \ - (S).arrayMask = (ARRAY_MASK); \ - (S).arrayAttribs = 0x0; \ - (S).end = (END); \ - (S).facing = 0; \ - (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ +#define INIT_SPAN(S, PRIMITIVE) \ +do { \ + (S).primitive = (PRIMITIVE); \ + (S).interpMask = 0x0; \ + (S).arrayMask = 0x0; \ + (S).arrayAttribs = 0x0; \ + (S).end = 0; \ + (S).facing = 0; \ + (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ } while (0) diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 2a90ffd85f8..f5bc03e81e4 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -144,7 +144,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, (void) swrast; - INIT_SPAN(span, GL_POLYGON, 0, 0, 0); + INIT_SPAN(span, GL_POLYGON); span.y = 0; /* silence warnings */ #ifdef INTERP_Z diff --git a/src/mesa/swrast/s_zoom.c b/src/mesa/swrast/s_zoom.c index 5f495e36c12..9f1a4c6f0a7 100644 --- a/src/mesa/swrast/s_zoom.c +++ b/src/mesa/swrast/s_zoom.c @@ -148,7 +148,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span, ASSERT((span->arrayMask & SPAN_XY) == 0); ASSERT(span->primitive == GL_BITMAP); - INIT_SPAN(zoomed, GL_BITMAP, 0, 0, 0); + INIT_SPAN(zoomed, GL_BITMAP); zoomed.x = x0; zoomed.end = zoomedWidth; zoomed.array = &zoomed_arrays; -- cgit v1.2.3 From 885c1326c3ae10b7196d2f7e95f1b6400fe29e12 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 17:15:50 +1000 Subject: r300: fix tabbing --- src/mesa/drivers/dri/r300/r300_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 1001c4ec073..90f5027c9ad 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -414,7 +414,7 @@ void r300Flush(GLcontext * ctx) fprintf(stderr, "%s\n", __FUNCTION__); if (rmesa->dma.flush) - rmesa->dma.flush( rmesa ); + rmesa->dma.flush( rmesa ); if (rmesa->cmdbuf.count_used > rmesa->cmdbuf.count_reemit) r300FlushCmdBuf(rmesa, __FUNCTION__); -- cgit v1.2.3 From 8f7478e5cb28912f81ec302a3c1b80733a3a6df3 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:29:23 +1000 Subject: r300: fixup manytex, we needed to emit the vic/vir/vof every time --- src/mesa/drivers/dri/r300/r300_swtcl.c | 98 ++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index e340f0b6e33..ef3f3b347c9 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -104,9 +104,9 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]) { return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) | - (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) | - (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) | - (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); + (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) | + (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) | + (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); } static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) @@ -237,10 +237,14 @@ static void r300SetVertexFormat( GLcontext *ctx ) /* EMIT_ATTR's must be in order as they tell t_vertex.c how to * build up a hardware vertex. */ - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F ); - vap_vte_cntl |= R300_VTX_W0_FMT; - InputsRead |= 1 << VERT_ATTRIB_POS; - OutputsWritten |= 1 << VERT_RESULT_HPOS; + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) { + vap_vte_cntl |= R300_VTX_W0_FMT; + InputsRead |= 1 << VERT_ATTRIB_POS; + OutputsWritten |= 1 << VERT_RESULT_HPOS; + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F ); + } else + EMIT_PAD(4 * sizeof(float)); + offset = 4; if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { @@ -250,10 +254,13 @@ static void r300SetVertexFormat( GLcontext *ctx ) } rmesa->swtcl.coloroffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) { + InputsRead |= 1 << VERT_ATTRIB_COLOR0; + OutputsWritten |= 1 << VERT_RESULT_COL0; + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); + } else + EMIT_PAD(4*sizeof(float)); - InputsRead |= 1 << VERT_ATTRIB_COLOR0; - OutputsWritten |= 1 << VERT_RESULT_COL0; offset += 4; rmesa->swtcl.specoffset = 0; @@ -314,40 +321,38 @@ static void r300SetVertexFormat( GLcontext *ctx ) } } - if (!RENDERINPUTS_EQUAL( rmesa->tnl_index_bitset, index_bitset)) { - R300_NEWPRIM(rmesa); - R300_STATECHANGE(rmesa, vir[0]); - ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = - r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], - VB->AttribPtr, inputs, tab, nr); - R300_STATECHANGE(rmesa, vir[1]); - ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = - r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, - nr); - - R300_STATECHANGE(rmesa, vic); - rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); - rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); - - R300_STATECHANGE(rmesa, vof); - rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); - rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); - - rmesa->swtcl.vertex_size = - _tnl_install_attrs( ctx, - rmesa->swtcl.vertex_attrs, - rmesa->swtcl.vertex_attr_count, - NULL, 0 ); - - rmesa->swtcl.vertex_size /= 4; - - RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); - - vte = rmesa->hw.vte.cmd[1]; - R300_STATECHANGE(rmesa, vte); - rmesa->hw.vte.cmd[1] = vte; - rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size; - } + R300_NEWPRIM(rmesa); + R300_STATECHANGE(rmesa, vir[0]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = + r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], + VB->AttribPtr, inputs, tab, nr); + R300_STATECHANGE(rmesa, vir[1]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = + r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, + nr); + + R300_STATECHANGE(rmesa, vic); + rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); + rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); + + R300_STATECHANGE(rmesa, vof); + rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); + rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); + + rmesa->swtcl.vertex_size = + _tnl_install_attrs( ctx, + rmesa->swtcl.vertex_attrs, + rmesa->swtcl.vertex_attr_count, + NULL, 0 ); + + rmesa->swtcl.vertex_size /= 4; + + RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); + + vte = rmesa->hw.vte.cmd[1]; + R300_STATECHANGE(rmesa, vte); + rmesa->hw.vte.cmd[1] = vte; + rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size; } @@ -371,6 +376,9 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) if (rmesa->dma.current.start != rmesa->dma.current.ptr) { r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__); + + r300EmitState(rmesa); + r300EmitVertexAOS( rmesa, rmesa->swtcl.vertex_size, current_offset); @@ -798,8 +806,6 @@ void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr) type = r300PrimitiveType(rmesa, primitive); num_verts = r300NumVerts(rmesa, vertex_nr, primitive); - r300EmitState(rmesa); - start_packet3(CP_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0), 0); e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (num_verts << 16) | type); } -- cgit v1.2.3 From b691d460465f992dc3febde06593341f192be970 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:40:26 +1000 Subject: r300: cleanup some of the swtcl code --- src/mesa/drivers/dri/r300/r300_context.c | 2 +- src/mesa/drivers/dri/r300/r300_emit.c | 10 +-- src/mesa/drivers/dri/r300/r300_emit.h | 7 +++ src/mesa/drivers/dri/r300/r300_render.c | 5 ++ src/mesa/drivers/dri/r300/r300_swtcl.c | 101 +------------------------------ 5 files changed, 19 insertions(+), 106 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 311d003633a..04e3fffa5df 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -165,7 +165,7 @@ static const struct tnl_pipeline_stage *r300_pipeline[] = { /* Else do them here. */ - // &_r300_render_stage, + &_r300_render_stage, &_tnl_render_stage, /* FALLBACK */ 0, }; diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index a7763bd76e6..229439dfa87 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -239,7 +239,7 @@ static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]) (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); } -static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) +GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) { GLuint i; @@ -255,14 +255,14 @@ static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) return (nr + 1) >> 1; } -static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) +GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) { /* No idea what this value means. I have seen other values written to * this register... */ return 0x5555; } -static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) +GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) { r300ContextPtr rmesa = R300_CONTEXT(ctx); GLuint i, vic_1 = 0; @@ -286,7 +286,7 @@ static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) return vic_1; } -static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) +GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) { GLuint ret = 0; @@ -315,7 +315,7 @@ static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) return ret; } -static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) +GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) { GLuint i, ret = 0; diff --git a/src/mesa/drivers/dri/r300/r300_emit.h b/src/mesa/drivers/dri/r300/r300_emit.h index 400e97f6f85..a6d69ec5ff8 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.h +++ b/src/mesa/drivers/dri/r300/r300_emit.h @@ -229,4 +229,11 @@ extern int r300PrimitiveType(r300ContextPtr rmesa, int prim); extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim); extern void r300EmitCacheFlush(r300ContextPtr rmesa); + +extern GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr); +extern GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead); +extern GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead); +extern GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten); +extern GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten); + #endif diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index db935795c79..7d8defd1cd8 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -371,12 +371,17 @@ static int r300Fallback(GLcontext * ctx) static GLboolean r300RunNonTCLRender(GLcontext * ctx, struct tnl_pipeline_stage *stage) { + r300ContextPtr rmesa = R300_CONTEXT(ctx); + if (RADEON_DEBUG & DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__); if (r300Fallback(ctx) >= R300_FALLBACK_RAST) return GL_TRUE; + if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) + return GL_TRUE; + return r300RunRender(ctx, stage); } diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index ef3f3b347c9..3fc229807f5 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -77,6 +77,7 @@ do { \ rmesa->swtcl.vertex_attr_count++; \ } while (0) +/* this differs from the VIR0 in emit.c - TODO merge them using another option */ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, int *inputs, GLint * tab, GLuint nr) { @@ -101,103 +102,6 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, return (nr + 1) >> 1; } -static GLuint r300VAPInputRoute1Swizzle(int swizzle[4]) -{ - return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) | - (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) | - (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) | - (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT); -} - -static GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr) -{ - GLuint i; - - for (i = 0; i + 1 < nr; i += 2) { - dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE; - dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16; - } - - if (nr & 1) { - dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE; - } - - return (nr + 1) >> 1; -} - -static GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) -{ - /* No idea what this value means. I have seen other values written to - * this register... */ - return 0x5555; -} - -static GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead) -{ - r300ContextPtr rmesa = R300_CONTEXT(ctx); - GLuint i, vic_1 = 0; - - if (InputsRead & (1 << VERT_ATTRIB_POS)) - vic_1 |= R300_INPUT_CNTL_POS; - - if (InputsRead & (1 << VERT_ATTRIB_NORMAL)) - vic_1 |= R300_INPUT_CNTL_NORMAL; - - if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) - vic_1 |= R300_INPUT_CNTL_COLOR; - - rmesa->state.texture.tc_count = 0; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - if (InputsRead & (1 << (VERT_ATTRIB_TEX0 + i))) { - rmesa->state.texture.tc_count++; - vic_1 |= R300_INPUT_CNTL_TC0 << i; - } - - return vic_1; -} - -static GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) -{ - GLuint ret = 0; - - if (OutputsWritten & (1 << VERT_RESULT_HPOS)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_COL0)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_COL1)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; - -#if 0 - if (OutputsWritten & (1 << VERT_RESULT_BFC0)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_BFC1)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; - - if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; -#endif - - if (OutputsWritten & (1 << VERT_RESULT_PSIZ)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; - - return ret; -} - -static GLuint r300VAPOutputCntl1(GLcontext * ctx, GLuint OutputsWritten) -{ - GLuint i, ret = 0; - - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (OutputsWritten & (1 << (VERT_RESULT_TEX0 + i))) { - ret |= (4 << (3 * i)); - } - } - - return ret; -} - static void r300SetVertexFormat( GLcontext *ctx ) { r300ContextPtr rmesa = R300_CONTEXT( ctx ); @@ -659,9 +563,6 @@ static void r300ChooseRenderState( GLcontext *ctx ) GLuint index = 0; GLuint flags = ctx->_TriangleCaps; - // if (!rmesa->TclFallback || rmesa->Fallback) -// return; - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT; if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT; -- cgit v1.2.3 From 2d5313db72354ef52e5d041c8c2efac52efc12a9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:42:27 +1000 Subject: r300: remove some unused code --- src/mesa/drivers/dri/r300/r300_swtcl.h | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.h b/src/mesa/drivers/dri/r300/r300_swtcl.h index 92362b745bc..8e56c5d9b2f 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.h +++ b/src/mesa/drivers/dri/r300/r300_swtcl.h @@ -41,35 +41,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. extern void r300InitSwtcl( GLcontext *ctx ); extern void r300DestroySwtcl( GLcontext *ctx ); -#if 0 -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_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 - #endif -- cgit v1.2.3 From 6564e4bffac60a500ac55b6b5ff01919fa28ca0b Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:43:22 +1000 Subject: r300: add authorship --- src/mesa/drivers/dri/r300/r300_swtcl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.h b/src/mesa/drivers/dri/r300/r300_swtcl.h index 8e56c5d9b2f..2ea6ceded7b 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.h +++ b/src/mesa/drivers/dri/r300/r300_swtcl.h @@ -28,7 +28,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: - * Keith Whitwell + * Keith Whitwell - original r200 code + * Dave Airlie */ #ifndef __R300_SWTCL_H__ -- cgit v1.2.3 From 646ed82e6b2c092c6db364bf87d6881f39e83eec Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:46:39 +1000 Subject: fix tabbing --- src/mesa/drivers/dri/r300/r300_swtcl.c | 457 ++++++++++++++++----------------- 1 file changed, 226 insertions(+), 231 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 3fc229807f5..48122546c26 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -104,159 +104,156 @@ static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr, static void r300SetVertexFormat( GLcontext *ctx ) { - r300ContextPtr rmesa = R300_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - DECLARE_RENDERINPUTS(index_bitset); - GLuint InputsRead = 0, OutputsWritten = 0; - int vap_fmt_0 = 0; - int vap_vte_cntl = 0; - int offset = 0; - int vte = 0; - GLint inputs[VERT_ATTRIB_MAX]; - GLint tab[VERT_ATTRIB_MAX]; - int swizzle[VERT_ATTRIB_MAX][4]; - GLuint i, nr; - - DECLARE_RENDERINPUTS(render_inputs_bitset); - - RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset); - - RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); - - RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset); - - /* Important: - */ - if ( VB->NdcPtr != NULL ) { - VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; - } - else { - VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr; - } - - assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL ); - rmesa->swtcl.vertex_attr_count = 0; - - /* EMIT_ATTR's must be in order as they tell t_vertex.c how to - * build up a hardware vertex. - */ - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) { - vap_vte_cntl |= R300_VTX_W0_FMT; - InputsRead |= 1 << VERT_ATTRIB_POS; - OutputsWritten |= 1 << VERT_RESULT_HPOS; - EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F ); - } else - EMIT_PAD(4 * sizeof(float)); - - offset = 4; - - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { - EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F ); - vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; - offset += 1; - } - - rmesa->swtcl.coloroffset = offset; - if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) { - InputsRead |= 1 << VERT_ATTRIB_COLOR0; - OutputsWritten |= 1 << VERT_RESULT_COL0; - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); - } else - EMIT_PAD(4*sizeof(float)); - - offset += 4; - - rmesa->swtcl.specoffset = 0; - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { - rmesa->swtcl.specoffset = offset; - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F ); - InputsRead |= 1 << VERT_ATTRIB_COLOR1; - OutputsWritten |= 1 << VERT_RESULT_COL1; - } - - if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { - int i; - - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { - InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i); - OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i); - EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F ); - } - } - } - - for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { - if (InputsRead & (1 << i)) { - inputs[i] = nr++; - } else { - inputs[i] = -1; - } - } - - /* Fixed, apply to vir0 only */ - if (InputsRead & VERT_ATTRIB_POS) - inputs[VERT_ATTRIB_POS] = 0; - if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) - inputs[VERT_ATTRIB_COLOR0] = 2; - if (InputsRead & (1 << VERT_ATTRIB_COLOR1)) - inputs[VERT_ATTRIB_COLOR1] = 3; - for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) - if (InputsRead & (1 << i)) - inputs[i] = 6 + (i - VERT_ATTRIB_TEX0); - - for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { - if (InputsRead & (1 << i)) { - tab[nr++] = i; - } - } - - for (i = 0; i < nr; i++) { - int ci; - - swizzle[i][0] = SWIZZLE_ZERO; - swizzle[i][1] = SWIZZLE_ZERO; - swizzle[i][2] = SWIZZLE_ZERO; - swizzle[i][3] = SWIZZLE_ONE; - - for (ci = 0; ci < VB->AttribPtr[tab[i]]->size; ci++) { - swizzle[i][ci] = ci; - } - } - - R300_NEWPRIM(rmesa); - R300_STATECHANGE(rmesa, vir[0]); - ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = - r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], - VB->AttribPtr, inputs, tab, nr); - R300_STATECHANGE(rmesa, vir[1]); - ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = - r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, - nr); - - R300_STATECHANGE(rmesa, vic); - rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); - rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); - - R300_STATECHANGE(rmesa, vof); - rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); - rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); - - rmesa->swtcl.vertex_size = - _tnl_install_attrs( ctx, - rmesa->swtcl.vertex_attrs, - rmesa->swtcl.vertex_attr_count, - NULL, 0 ); + r300ContextPtr rmesa = R300_CONTEXT( ctx ); + TNLcontext *tnl = TNL_CONTEXT(ctx); + struct vertex_buffer *VB = &tnl->vb; + DECLARE_RENDERINPUTS(index_bitset); + GLuint InputsRead = 0, OutputsWritten = 0; + int vap_fmt_0 = 0; + int vap_vte_cntl = 0; + int offset = 0; + int vte = 0; + GLint inputs[VERT_ATTRIB_MAX]; + GLint tab[VERT_ATTRIB_MAX]; + int swizzle[VERT_ATTRIB_MAX][4]; + GLuint i, nr; + + DECLARE_RENDERINPUTS(render_inputs_bitset); + RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset); + RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); + RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset); + + /* Important: + */ + if ( VB->NdcPtr != NULL ) { + VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; + } + else { + VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr; + } + + assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL ); + rmesa->swtcl.vertex_attr_count = 0; + + /* EMIT_ATTR's must be in order as they tell t_vertex.c how to + * build up a hardware vertex. + */ + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) { + vap_vte_cntl |= R300_VTX_W0_FMT; + InputsRead |= 1 << VERT_ATTRIB_POS; + OutputsWritten |= 1 << VERT_RESULT_HPOS; + EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F ); + } else + EMIT_PAD(4 * sizeof(float)); + + offset = 4; + + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) { + EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F ); + vap_fmt_0 |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; + offset += 1; + } + + rmesa->swtcl.coloroffset = offset; + if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) { + InputsRead |= 1 << VERT_ATTRIB_COLOR0; + OutputsWritten |= 1 << VERT_RESULT_COL0; + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); + } else + EMIT_PAD(4*sizeof(float)); + + offset += 4; + + rmesa->swtcl.specoffset = 0; + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { + rmesa->swtcl.specoffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F ); + InputsRead |= 1 << VERT_ATTRIB_COLOR1; + OutputsWritten |= 1 << VERT_RESULT_COL1; + } + + if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) { + int i; + + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) { + InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i); + OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i); + EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F ); + } + } + } + + for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { + if (InputsRead & (1 << i)) { + inputs[i] = nr++; + } else { + inputs[i] = -1; + } + } + + /* Fixed, apply to vir0 only */ + if (InputsRead & VERT_ATTRIB_POS) + inputs[VERT_ATTRIB_POS] = 0; + if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) + inputs[VERT_ATTRIB_COLOR0] = 2; + if (InputsRead & (1 << VERT_ATTRIB_COLOR1)) + inputs[VERT_ATTRIB_COLOR1] = 3; + for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) + if (InputsRead & (1 << i)) + inputs[i] = 6 + (i - VERT_ATTRIB_TEX0); + + for (i = 0, nr = 0; i < VERT_ATTRIB_MAX; i++) { + if (InputsRead & (1 << i)) { + tab[nr++] = i; + } + } + + for (i = 0; i < nr; i++) { + int ci; + + swizzle[i][0] = SWIZZLE_ZERO; + swizzle[i][1] = SWIZZLE_ZERO; + swizzle[i][2] = SWIZZLE_ZERO; + swizzle[i][3] = SWIZZLE_ONE; + + for (ci = 0; ci < VB->AttribPtr[tab[i]]->size; ci++) { + swizzle[i][ci] = ci; + } + } + + R300_NEWPRIM(rmesa); + R300_STATECHANGE(rmesa, vir[0]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[0].cmd)->packet0.count = + r300VAPInputRoute0(&rmesa->hw.vir[0].cmd[R300_VIR_CNTL_0], + VB->AttribPtr, inputs, tab, nr); + R300_STATECHANGE(rmesa, vir[1]); + ((drm_r300_cmd_header_t *) rmesa->hw.vir[1].cmd)->packet0.count = + r300VAPInputRoute1(&rmesa->hw.vir[1].cmd[R300_VIR_CNTL_0], swizzle, + nr); - rmesa->swtcl.vertex_size /= 4; + R300_STATECHANGE(rmesa, vic); + rmesa->hw.vic.cmd[R300_VIC_CNTL_0] = r300VAPInputCntl0(ctx, InputsRead); + rmesa->hw.vic.cmd[R300_VIC_CNTL_1] = r300VAPInputCntl1(ctx, InputsRead); - RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); + R300_STATECHANGE(rmesa, vof); + rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten); + rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten); - vte = rmesa->hw.vte.cmd[1]; - R300_STATECHANGE(rmesa, vte); - rmesa->hw.vte.cmd[1] = vte; - rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size; + rmesa->swtcl.vertex_size = + _tnl_install_attrs( ctx, + rmesa->swtcl.vertex_attrs, + rmesa->swtcl.vertex_attr_count, + NULL, 0 ); + + rmesa->swtcl.vertex_size /= 4; + + RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset ); + + vte = rmesa->hw.vte.cmd[1]; + R300_STATECHANGE(rmesa, vte); + rmesa->hw.vte.cmd[1] = vte; + rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size; } @@ -264,39 +261,39 @@ static void r300SetVertexFormat( GLcontext *ctx ) */ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) { - if (RADEON_DEBUG & DEBUG_IOCTL) - fprintf(stderr, "%s\n", __FUNCTION__); - - rmesa->dma.flush = NULL; - - if (rmesa->dma.current.buf) { - struct r300_dma_region *current = &rmesa->dma.current; - GLuint current_offset = GET_START(current); - - assert (current->start + - rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 == - current->ptr); - - if (rmesa->dma.current.start != rmesa->dma.current.ptr) { - - r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__); - - r300EmitState(rmesa); - - r300EmitVertexAOS( rmesa, - rmesa->swtcl.vertex_size, - current_offset); + if (RADEON_DEBUG & DEBUG_IOCTL) + fprintf(stderr, "%s\n", __FUNCTION__); - r300EmitVbufPrim( rmesa, - rmesa->swtcl.hw_primitive, - rmesa->swtcl.numverts); - - r300EmitCacheFlush(rmesa); - } - - rmesa->swtcl.numverts = 0; - current->start = current->ptr; - } + rmesa->dma.flush = NULL; + + if (rmesa->dma.current.buf) { + struct r300_dma_region *current = &rmesa->dma.current; + GLuint current_offset = GET_START(current); + + assert (current->start + + rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 == + current->ptr); + + if (rmesa->dma.current.start != rmesa->dma.current.ptr) { + + r300EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size + (12*sizeof(int)), __FUNCTION__); + + r300EmitState(rmesa); + + r300EmitVertexAOS( rmesa, + rmesa->swtcl.vertex_size, + current_offset); + + r300EmitVbufPrim( rmesa, + rmesa->swtcl.hw_primitive, + rmesa->swtcl.numverts); + + r300EmitCacheFlush(rmesa); + } + + rmesa->swtcl.numverts = 0; + current->start = current->ptr; + } } /* Alloc space in the current dma region. @@ -304,30 +301,28 @@ static void flush_last_swtcl_prim( r300ContextPtr rmesa ) static void * r300AllocDmaLowVerts( r300ContextPtr rmesa, int nverts, int vsize ) { - GLuint bytes = vsize * nverts; - - if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) - r300RefillCurrentDmaRegion( rmesa, bytes); + GLuint bytes = vsize * nverts; - if (!rmesa->dma.flush) { - rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; - rmesa->dma.flush = flush_last_swtcl_prim; - } + if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end ) + r300RefillCurrentDmaRegion( rmesa, bytes); - 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 ); - - - { - GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr); - rmesa->dma.current.ptr += bytes; - rmesa->swtcl.numverts += nverts; - return head; - } + if (!rmesa->dma.flush) { + rmesa->radeon.glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; + 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 + + rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 == + rmesa->dma.current.ptr ); + + { + GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr); + rmesa->dma.current.ptr += bytes; + rmesa->swtcl.numverts += nverts; + return head; + } } static GLuint reduced_prim[] = { @@ -558,33 +553,33 @@ static void init_rast_tab( void ) /**********************************************************************/ static void r300ChooseRenderState( GLcontext *ctx ) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - r300ContextPtr rmesa = R300_CONTEXT(ctx); - GLuint index = 0; - GLuint flags = ctx->_TriangleCaps; - - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT; - if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT; - - if (index != rmesa->swtcl.RenderIndex) { - tnl->Driver.Render.Points = rast_tab[index].points; - tnl->Driver.Render.Line = rast_tab[index].line; - tnl->Driver.Render.ClippedLine = rast_tab[index].line; - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (index == 0) { - tnl->Driver.Render.PrimTabVerts = r300_render_tab_verts; - tnl->Driver.Render.PrimTabElts = r300_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = r300_fast_clipped_poly; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; - } - - rmesa->swtcl.RenderIndex = index; - } + TNLcontext *tnl = TNL_CONTEXT(ctx); + r300ContextPtr rmesa = R300_CONTEXT(ctx); + GLuint index = 0; + GLuint flags = ctx->_TriangleCaps; + + if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R300_TWOSIDE_BIT; + if (flags & DD_TRI_UNFILLED) index |= R300_UNFILLED_BIT; + + if (index != rmesa->swtcl.RenderIndex) { + tnl->Driver.Render.Points = rast_tab[index].points; + tnl->Driver.Render.Line = rast_tab[index].line; + tnl->Driver.Render.ClippedLine = rast_tab[index].line; + tnl->Driver.Render.Triangle = rast_tab[index].triangle; + tnl->Driver.Render.Quad = rast_tab[index].quad; + + if (index == 0) { + tnl->Driver.Render.PrimTabVerts = r300_render_tab_verts; + tnl->Driver.Render.PrimTabElts = r300_render_tab_elts; + tnl->Driver.Render.ClippedPolygon = r300_fast_clipped_poly; + } else { + tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; + tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; + tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; + } + + rmesa->swtcl.RenderIndex = index; + } } @@ -602,7 +597,7 @@ static void r300RenderStart(GLcontext *ctx) if (rmesa->dma.flush != 0 && rmesa->dma.flush != flush_last_swtcl_prim) - rmesa->dma.flush( rmesa ); + rmesa->dma.flush( rmesa ); } -- cgit v1.2.3 From 0caee6b006aa2982f743bd60391d2c5406e167b7 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 18:52:47 +1000 Subject: r300: oops turn back off cmd buf debugging --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index 6adf1413219..9eca41fa38c 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -54,7 +54,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_state.h" // Set this to 1 for extremely verbose debugging of command buffers -#define DEBUG_CMDBUF 1 +#define DEBUG_CMDBUF 0 /** * Send the current command buffer via ioctl to the hardware. -- cgit v1.2.3 From ad1903808037b21eda002857a478c68399ba4519 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 1 Jul 2007 19:27:26 +1000 Subject: r300: oops wrong logic for swtcl --- src/mesa/drivers/dri/r300/r300_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 7d8defd1cd8..eee1e803a00 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -379,7 +379,7 @@ static GLboolean r300RunNonTCLRender(GLcontext * ctx, if (r300Fallback(ctx) >= R300_FALLBACK_RAST) return GL_TRUE; - if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) + if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL)) return GL_TRUE; return r300RunRender(ctx, stage); -- cgit v1.2.3 From 33da6cb133dfcfa434a1360123ecf683af329fa0 Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Sun, 1 Jul 2007 12:23:12 +0200 Subject: Fixed initialization of render buffer and deinitialization of context. --- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c index 88ac4bb31d5..694eeb054df 100644 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ b/src/mesa/drivers/directfb/idirectfbgl_mesa.c @@ -134,7 +134,6 @@ static bool directfbgl_init_visual ( GLvisual *visual, static bool directfbgl_create_context ( GLcontext *context, GLframebuffer *framebuffer, GLvisual *visual, - DFBSurfacePixelFormat format, IDirectFBGL_data *data ); static void directfbgl_destroy_context( GLcontext *context, GLframebuffer *framebuffer ); @@ -340,8 +339,9 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) } /* Create context. */ - if (!directfbgl_create_context( &data->context, &data->framebuffer, - &data->visual, data->format, data )) { + if (!directfbgl_create_context( &data->context, + &data->framebuffer, + &data->visual, data )) { D_ERROR( "DirectFBGL/Mesa: failed to create context.\n" ); IDirectFBGL_Mesa_Destruct( thiz ); return DFB_UNSUPPORTED; @@ -762,11 +762,10 @@ directfbgl_init_visual( GLvisual *visual, } static bool -directfbgl_create_context( GLcontext *context, - GLframebuffer *framebuffer, - GLvisual *visual, - DFBSurfacePixelFormat format, - IDirectFBGL_data *data ) +directfbgl_create_context( GLcontext *context, + GLframebuffer *framebuffer, + GLvisual *visual, + IDirectFBGL_data *data ) { struct dd_function_table functions; @@ -800,7 +799,7 @@ directfbgl_create_context( GLcontext *context, data->render.Delete = dfbDeleteRenderbuffer; data->render.AllocStorage = dfbRenderbufferStorage; - switch (format) { + switch (data->format) { case DSPF_RGB332: data->render.GetRow = get_row_RGB332; data->render.GetValues = get_values_RGB332; @@ -887,6 +886,9 @@ directfbgl_create_context( GLcontext *context, return false; } + data->render.Width = data->width; + data->render.Height = data->height; + _mesa_add_renderbuffer( framebuffer, BUFFER_FRONT_LEFT, &data->render ); _mesa_add_soft_renderbuffers( framebuffer, @@ -908,8 +910,11 @@ static void directfbgl_destroy_context( GLcontext *context, GLframebuffer *framebuffer ) { - _mesa_free_framebuffer_data( framebuffer ); - _mesa_notifyDestroy( context ); + _swsetup_DestroyContext( context ); + _swrast_DestroyContext( context ); + _tnl_DestroyContext( context ); + _vbo_DestroyContext( context ); + //_mesa_free_framebuffer_data( framebuffer ); _mesa_free_context_data( context ); } -- cgit v1.2.3 From a49570794ab12b42633ecf94faad28abdcbb5bbd Mon Sep 17 00:00:00 2001 From: Claudio Ciccani Date: Sun, 1 Jul 2007 12:24:44 +0200 Subject: Compute the amount of time to sleep on idle event using timers as reference. --- src/glut/directfb/callback.c | 68 +++++++++++++++++++++++++++++--------------- src/glut/directfb/events.c | 11 +++++-- src/glut/directfb/internal.h | 1 + 3 files changed, 55 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/glut/directfb/callback.c b/src/glut/directfb/callback.c index 38cfccbd4f8..4f23441167a 100644 --- a/src/glut/directfb/callback.c +++ b/src/glut/directfb/callback.c @@ -28,14 +28,13 @@ typedef void (GLUTCALLBACK *__GlutTimerCallback) ( int value ); typedef struct __GlutTimer_s { - unsigned int interval; + struct timeval interval; struct timeval expire; __GlutTimerCallback func; int value; struct __GlutTimer_s *next; - struct __GlutTimer_s *prev; } __GlutTimer; /*****************************************************************************/ @@ -207,8 +206,7 @@ glutIdleFunc( void (GLUTCALLBACK *func) (void) ) void GLUTAPIENTRY glutTimerFunc( unsigned int msec, void (GLUTCALLBACK *func) (int value), int value ) { - __GlutTimer *timer; - struct timeval now; + __GlutTimer *timer; if (!func) return; @@ -217,24 +215,19 @@ glutTimerFunc( unsigned int msec, void (GLUTCALLBACK *func) (int value), int val if (!timer) __glutFatalError( "out of memory" ); - gettimeofday( &now, NULL ); - - timer->interval = msec; - timer->expire.tv_sec = now.tv_sec + (now.tv_usec/1000 + msec) / 1000; - timer->expire.tv_usec = (now.tv_usec + msec*1000) % 1000000; + timer->interval.tv_sec = msec / 1000; + timer->interval.tv_usec = (msec % 1000) * 1000; + + gettimeofday( &timer->expire, NULL ); + timer->expire.tv_usec += timer->interval.tv_usec; + timer->expire.tv_sec += timer->interval.tv_sec + timer->expire.tv_usec/1000000; + timer->expire.tv_usec %= 1000000; timer->func = func; timer->value = value; - if (g_timers) { - timer->prev = g_timers->prev; - g_timers->prev->next = timer; - g_timers->prev = timer; - } - else { - g_timers = timer; - g_timers->prev = timer; - } + timer->next = g_timers; + g_timers = timer; } @@ -254,12 +247,41 @@ __glutHandleTimers( void ) g_idle = GL_FALSE; cur->func( cur->value ); - - cur->expire.tv_sec += (cur->expire.tv_usec/1000 + cur->interval) / 1000; - cur->expire.tv_usec = (cur->expire.tv_usec + cur->interval*1000) % 1000000; + + cur->expire.tv_usec += cur->interval.tv_usec; + cur->expire.tv_sec += cur->interval.tv_sec + cur->expire.tv_usec/1000000; + cur->expire.tv_usec %= 1000000; } } -} +} + + +GLboolean +__glutGetTimeout( int *ret_msec ) +{ + __GlutTimer *cur; + struct timeval *time = NULL; + struct timeval now; + + for (cur = g_timers; cur; cur = cur->next) { + if (time == NULL || + time->tv_sec > cur->expire.tv_sec || + (time->tv_sec == cur->expire.tv_sec && + time->tv_usec > cur->expire.tv_usec)) { + time = &cur->expire; + } + } + + if (time == NULL) + return GL_FALSE; + + gettimeofday( &now, NULL ); + + *ret_msec = (time->tv_sec - now.tv_sec) * 1000 + + (time->tv_usec - now.tv_usec + 500) / 1000; + + return GL_TRUE; +} void @@ -275,4 +297,4 @@ __glutFreeTimers( void ) g_timers = NULL; } - + diff --git a/src/glut/directfb/events.c b/src/glut/directfb/events.c index 4c474710abe..6ebdd166ac8 100644 --- a/src/glut/directfb/events.c +++ b/src/glut/directfb/events.c @@ -435,13 +435,14 @@ glutMainLoop( void ) { __glutAssert( events != NULL ); + __glutHandleWindows(); + while (GL_TRUE) { DFBEvent evt, prev; g_idle = GL_TRUE; __glutHandleTimers(); - __glutHandleWindows(); prev.clazz = DFEC_NONE; @@ -471,13 +472,19 @@ glutMainLoop( void ) __glutHandleTimers(); } + __glutHandleWindows(); + if (g_idle) { if (idle_func) { idle_func(); } else { + int msec; __glutSetWindow( NULL ); - usleep( 500 ); + if (__glutGetTimeout( &msec )) + events->WaitForEventWithTimeout( events, msec/1000, msec%1000 ); + else + events->WaitForEvent( events ); } } } diff --git a/src/glut/directfb/internal.h b/src/glut/directfb/internal.h index bc3e20e93e7..47311c9342b 100644 --- a/src/glut/directfb/internal.h +++ b/src/glut/directfb/internal.h @@ -124,6 +124,7 @@ extern void __glutDestroyWindow( __GlutWindow *window ); extern void __glutDestroyWindows( void ); /* callback.c */ extern void __glutHandleTimers( void ); +extern GLboolean __glutGetTimeout( int *ret_msec ); extern void __glutFreeTimers( void ); -- cgit v1.2.3 From 6257ed8663eddb4ebdf99ba69cfe2ced82182ed3 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Jul 2007 17:21:45 +1000 Subject: r300: fix compiz crash on swtcl - doesn't fix compiz though. Compiz for some reason looks like ass, everything with textures looks like it has a 2x width/height multiplier on the texture coords... --- src/mesa/drivers/dri/r300/r300_swtcl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 48122546c26..7aea063447a 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -154,13 +154,12 @@ static void r300SetVertexFormat( GLcontext *ctx ) offset += 1; } - rmesa->swtcl.coloroffset = offset; if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) { + rmesa->swtcl.coloroffset = offset; InputsRead |= 1 << VERT_ATTRIB_COLOR0; OutputsWritten |= 1 << VERT_RESULT_COL0; EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F ); - } else - EMIT_PAD(4*sizeof(float)); + } offset += 4; @@ -193,7 +192,7 @@ static void r300SetVertexFormat( GLcontext *ctx ) } /* Fixed, apply to vir0 only */ - if (InputsRead & VERT_ATTRIB_POS) + if (InputsRead & (1 << VERT_ATTRIB_POS)) inputs[VERT_ATTRIB_POS] = 0; if (InputsRead & (1 << VERT_ATTRIB_COLOR0)) inputs[VERT_ATTRIB_COLOR0] = 2; -- cgit v1.2.3 From 06542019a86d4b9e4f4dfb7a73aa131910465230 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 2 Jul 2007 08:46:57 -0600 Subject: avoid unnecessary clamping of depth values (bug 11448) --- src/mesa/main/image.c | 79 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index caaf2816571..e2e7f806ab1 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.0 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -3878,7 +3878,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, SWAP4BYTE(value); \ } \ } \ - depthValues[i] = CLAMP(GLTYPE2FLOAT(value), 0.0F, 1.0F); \ + depthValues[i] = GLTYPE2FLOAT(value); \ } \ } while (0) @@ -3889,6 +3889,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, const struct gl_pixelstore_attrib *srcPacking ) { GLfloat depthTemp[MAX_WIDTH], *depthValues; + GLboolean needClamp = GL_FALSE; /* Look for special cases first. * Not only are these faster, they're less prone to numeric conversion @@ -3918,7 +3919,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, /* XXX may want to add additional cases here someday */ } - /* general case path */ + /* general case path follows */ if (dstType == GL_FLOAT) { depthValues = (GLfloat *) dest; @@ -3927,29 +3928,31 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, depthValues = depthTemp; } - /* XXX we need to obey srcPacking->SwapBytes here!!! */ - (void) srcPacking; - - /* convert incoming values to GLfloat */ + /* Convert incoming values to GLfloat. Some conversions will require + * clamping, below. + */ switch (srcType) { case GL_BYTE: - DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); - break; + DEPTH_VALUES(GLbyte, BYTE_TO_FLOAT); + needClamp = GL_TRUE; + break; case GL_UNSIGNED_BYTE: - DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); - break; + DEPTH_VALUES(GLubyte, UBYTE_TO_FLOAT); + break; case GL_SHORT: - DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); - break; + DEPTH_VALUES(GLshort, SHORT_TO_FLOAT); + needClamp = GL_TRUE; + break; case GL_UNSIGNED_SHORT: - DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); - break; + DEPTH_VALUES(GLushort, USHORT_TO_FLOAT); + break; case GL_INT: - DEPTH_VALUES(GLint, INT_TO_FLOAT); - break; + DEPTH_VALUES(GLint, INT_TO_FLOAT); + needClamp = GL_TRUE; + break; case GL_UNSIGNED_INT: - DEPTH_VALUES(GLuint, UINT_TO_FLOAT); - break; + DEPTH_VALUES(GLuint, UINT_TO_FLOAT); + break; case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ if (dstType == GL_UNSIGNED_INT && depthScale == (GLfloat) 0xffffff && @@ -3981,19 +3984,21 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, } break; case GL_FLOAT: - DEPTH_VALUES(GLfloat, 1*); - break; + DEPTH_VALUES(GLfloat, 1*); + needClamp = GL_TRUE; + break; case GL_HALF_FLOAT_ARB: { GLuint i; const GLhalfARB *src = (const GLhalfARB *) source; for (i = 0; i < n; i++) { - GLhalfARB value = src[i]; - if (srcPacking->SwapBytes) { - SWAP2BYTE(value); - } + GLhalfARB value = src[i]; + if (srcPacking->SwapBytes) { + SWAP2BYTE(value); + } depthValues[i] = _mesa_half_to_float(value); } + needClamp = GL_TRUE; } break; default: @@ -4001,12 +4006,30 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, return; } + /* apply depth scale and bias */ + { + const GLfloat scale = ctx->Pixel.DepthScale; + const GLfloat bias = ctx->Pixel.DepthBias; + if (scale != 1.0 || bias != 0.0) { + GLuint i; + for (i = 0; i < n; i++) { + depthValues[i] = depthValues[i] * scale + bias; + } + needClamp = GL_TRUE; + } + } - /* apply depth scale and bias and clamp to [0,1] */ - if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) { - _mesa_scale_and_bias_depth(ctx, n, depthValues); + /* clamp to [0, 1] */ + if (needClamp) { + GLuint i; + for (i = 0; i < n; i++) { + depthValues[i] = CLAMP(depthValues[i], 0.0, 1.0); + } } + /* + * Convert values to dstType + */ if (dstType == GL_UNSIGNED_INT) { GLuint *zValues = (GLuint *) dest; GLuint i; -- cgit v1.2.3 From 9220255d75f14e8bea0c4e677d138f002aec55eb Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 2 Jul 2007 10:16:02 -0600 Subject: add const to wglSetPixelFormat() to match .h declaration --- src/mesa/drivers/windows/gdi/wgl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index 49b4ddbd1f9..fb23d210db7 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -339,7 +339,7 @@ WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc) } WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat, - PIXELFORMATDESCRIPTOR *ppfd) + const PIXELFORMATDESCRIPTOR *ppfd) { (void) hdc; -- cgit v1.2.3 From 9a45176dd85a1cd523498efeebd0481950a1bf58 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 3 Jul 2007 14:27:41 +0200 Subject: fix GL_DOT3_RGBA texture combiner mode in generated fragment programs (bug #11030) --- src/mesa/main/texenvprogram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 0c6fa82f112..1a46c10ffa3 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -871,7 +871,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit) key->unit[unit].OptRGB); } else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT || - key->unit[unit].ModeA == MODE_DOT3_RGBA) { + key->unit[unit].ModeRGB == MODE_DOT3_RGBA) { out = emit_combine( p, dest, WRITEMASK_XYZW, saturate, unit, -- cgit v1.2.3 From f9b53f648d12ef7e4505d8303e14b90ebd444872 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 3 Jul 2007 08:53:49 -0600 Subject: use _mesa_unpack_stencil_span() in draw_stencil_pixels(), bug 11457 --- src/mesa/swrast/s_drawpix.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index b8b452e33dd..1c9f64b275e 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -398,10 +398,9 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, width, height, GL_COLOR_INDEX, type, row, skipPixels); - _mesa_unpack_index_span(ctx, spanWidth, destType, values, - type, source, unpack, - ctx->_ImageTransferState); - _mesa_apply_stencil_transfer_ops(ctx, spanWidth, values); + _mesa_unpack_stencil_span(ctx, spanWidth, destType, values, + type, source, unpack, + ctx->_ImageTransferState); if (zoom) { _swrast_write_zoomed_stencil_span(ctx, x, y, spanWidth, spanX, spanY, values); -- cgit v1.2.3 From 3d04682b7a729ff4471528a57a6bdf64d235a43e Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 3 Jul 2007 10:06:13 -0600 Subject: fix StepX/StepY typo --- src/mesa/swrast/s_tritemp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index f5bc03e81e4..cded4a6c1c4 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -393,7 +393,7 @@ static void NAME(GLcontext *ctx, const SWvertex *v0, span.greenStep = 0; span.blueStep = 0; # ifdef INTERP_ALPHA - span.attrStepX[FRAG_ATTRIB_COL0][3] = span.attrStepX[FRAG_ATTRIB_COL0][3] = 0.0F; + span.attrStepX[FRAG_ATTRIB_COL0][3] = span.attrStepY[FRAG_ATTRIB_COL0][3] = 0.0F; span.alphaStep = 0; # endif } -- cgit v1.2.3 From a36b5c6d4700a0eaa8c2430f1121babafe9294ed Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 3 Jul 2007 11:41:21 -0600 Subject: add code for stpq, rgba writemasks in make_writemask(), bug 11404 --- src/mesa/shader/slang/slang_codegen.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 02260d3422e..f3a6d04428f 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -1261,15 +1261,23 @@ make_writemask(const char *field) while (*field) { switch (*field) { case 'x': + case 's': + case 'r': mask |= WRITEMASK_X; break; case 'y': + case 't': + case 'g': mask |= WRITEMASK_Y; break; case 'z': + case 'p': + case 'b': mask |= WRITEMASK_Z; break; case 'w': + case 'q': + case 'a': mask |= WRITEMASK_W; break; default: -- cgit v1.2.3 From 7ff4359a3be1278b26950f96ab23014a667af838 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 3 Jul 2007 11:41:56 -0600 Subject: added vec2(vec4) constructor, bug 11404 --- src/mesa/shader/slang/library/slang_core.gc | 5 ++ src/mesa/shader/slang/library/slang_core_gc.h | 109 +++++++++++++------------- 2 files changed, 60 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/library/slang_core.gc b/src/mesa/shader/slang/library/slang_core.gc index e398eabb15d..2e7ebc347a6 100644 --- a/src/mesa/shader/slang/library/slang_core.gc +++ b/src/mesa/shader/slang/library/slang_core.gc @@ -181,6 +181,11 @@ vec2 __constructor(const vec3 v) __retVal.xy = v.xy; } +vec2 __constructor(const vec4 v) +{ + __retVal.st = v.xy; +} + //// vec3 constructors diff --git a/src/mesa/shader/slang/library/slang_core_gc.h b/src/mesa/shader/slang/library/slang_core_gc.h index dcd39a0e28d..f2b4fd6464b 100644 --- a/src/mesa/shader/slang/library/slang_core_gc.h +++ b/src/mesa/shader/slang/library/slang_core_gc.h @@ -18,59 +18,60 @@ 20,0,0,1,0,10,1,1,1,0,5,105,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,105,0,59, 120,120,0,20,0,0,1,0,10,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,98, 0,59,120,120,0,20,0,0,1,0,10,1,1,1,0,11,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121, -0,18,118,0,59,120,121,0,20,0,0,1,0,11,1,1,1,0,9,120,0,0,1,1,0,9,121,0,0,1,1,0,9,122,0,0,0,1,9,18, -95,95,114,101,116,86,97,108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0, -18,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,0,1,0,11,1,1,1,0,9,102,0,0, -0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,102,0,59,120,120,120,0,20,0,0,1,0,11,1, -1,1,0,5,105,0,0,0,1,4,105,110,116,95,116,111,95,102,108,111,97,116,0,18,95,95,114,101,116,86,97, -108,0,59,120,121,122,0,0,18,105,0,59,120,120,120,0,0,0,0,1,0,11,1,1,1,0,1,98,0,0,0,1,9,18,95,95, -114,101,116,86,97,108,0,59,120,121,122,0,18,98,0,59,120,120,120,0,20,0,0,1,0,11,1,1,1,0,12,118,0,0, -0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,118,0,59,120,121,122,0,20,0,0,1,0,12,1, -1,1,0,9,120,0,0,1,1,0,9,121,0,0,1,1,0,9,122,0,0,1,1,0,9,119,0,0,0,1,9,18,95,95,114,101,116,86,97, -108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,121,0,20,0,9,18,95,95, -114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,119, -0,20,0,0,1,0,12,1,1,1,0,9,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,102,0,59,120,120,120, -120,0,20,0,0,1,0,12,1,1,1,0,5,105,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,105,0,59,120,120, -120,120,0,20,0,0,1,0,12,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,98,0,59,120,120, -120,120,0,20,0,0,1,0,12,1,1,1,0,11,118,51,0,0,1,1,0,9,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108, -0,59,120,121,122,0,18,118,51,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,102,0,20,0,0,1, -0,6,1,1,1,0,5,105,0,0,1,1,0,5,106,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,105,0,20, -0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,106,0,20,0,0,1,0,6,1,1,1,0,5,105,0,0,0,1,9,18,95, -95,114,101,116,86,97,108,0,59,120,121,0,18,105,0,59,120,120,0,20,0,0,1,0,6,1,1,1,0,9,102,0,0,0,1,4, -102,108,111,97,116,95,116,111,95,105,110,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18, -102,0,59,120,120,0,0,0,0,1,0,6,1,1,1,0,1,98,0,0,0,1,4,102,108,111,97,116,95,116,111,95,105,110,116, -0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,98,0,59,120,120,0,0,0,0,1,0,7,1,1,1,0,5,105,0, -0,1,1,0,5,106,0,0,1,1,0,5,107,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,105,0,20,0,9, -18,95,95,114,101,116,86,97,108,0,59,121,0,18,106,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122, -0,18,107,0,20,0,0,1,0,7,1,1,1,0,5,105,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0, -18,105,0,59,120,120,120,0,20,0,0,1,0,7,1,1,1,0,9,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59, -120,121,122,0,18,102,0,59,120,120,120,0,20,0,0,1,0,7,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116, -86,97,108,0,59,120,121,122,0,18,98,0,59,120,120,120,0,20,0,0,1,0,8,1,1,1,0,5,120,0,0,1,1,0,5,121,0, -0,1,1,0,5,122,0,0,1,1,0,5,119,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,120,0,20,0,9, -18,95,95,114,101,116,86,97,108,0,59,121,0,18,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122, -0,18,122,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,119,0,20,0,0,1,0,8,1,1,1,0,5,105,0, -0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,105,0,59,120,120,120,120,0,20,0,0,1,0,8,1,1,1,0,9,102, -0,0,0,1,4,102,108,111,97,116,95,116,111,95,105,110,116,0,18,95,95,114,101,116,86,97,108,0,0,18,102, -0,59,120,120,120,120,0,0,0,0,1,0,8,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,98,0, -59,120,120,120,120,0,20,0,0,1,0,2,1,1,1,0,1,98,49,0,0,1,1,0,1,98,50,0,0,0,1,9,18,95,95,114,101,116, -86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,98,50,0,20,0,0, -1,0,2,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,98,0,59,120,120,0,20, -0,0,1,0,2,1,1,1,0,9,102,0,0,0,1,3,2,1,10,1,122,101,114,111,0,2,58,118,101,99,50,0,17,48,0,48,0,0,0, -17,48,0,48,0,0,0,0,0,0,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120, -121,0,0,18,102,0,59,120,120,0,0,18,122,101,114,111,0,0,0,0,1,0,2,1,1,1,0,5,105,0,0,0,1,3,2,1,6,1, -122,101,114,111,0,2,58,105,118,101,99,50,0,16,8,48,0,0,16,8,48,0,0,0,0,0,4,118,101,99,52,95,115, -101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,105,0,59,120,120,0,0,18,122,101,114, -111,0,0,0,0,1,0,3,1,1,1,0,1,98,49,0,0,1,1,0,1,98,50,0,0,1,1,0,1,98,51,0,0,0,1,9,18,95,95,114,101, -116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,98,50,0,20, -0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,98,51,0,20,0,0,1,0,3,1,1,1,0,1,98,0,0,0,1,9,18,95, -95,114,101,116,86,97,108,0,59,120,121,122,0,18,98,0,59,120,120,120,0,20,0,0,1,0,3,1,1,1,0,9,102,0, -0,0,1,3,2,1,11,1,122,101,114,111,0,2,58,118,101,99,51,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,17,48,0, -48,0,0,0,0,0,0,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0, -0,18,102,0,59,120,120,120,0,0,18,122,101,114,111,0,0,0,0,1,0,3,1,1,1,0,5,105,0,0,0,1,3,2,1,7,1,122, -101,114,111,0,2,58,105,118,101,99,51,0,16,8,48,0,0,16,8,48,0,0,16,8,48,0,0,0,0,0,4,118,101,99,52, -95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,105,0,59,120,120,120,0,0, -18,122,101,114,111,0,0,0,0,1,0,4,1,1,1,0,1,98,49,0,0,1,1,0,1,98,50,0,0,1,1,0,1,98,51,0,0,1,1,0,1, -98,52,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116, +0,18,118,0,59,120,121,0,20,0,0,1,0,10,1,1,1,0,12,118,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59, +115,116,0,18,118,0,59,120,121,0,20,0,0,1,0,11,1,1,1,0,9,120,0,0,1,1,0,9,121,0,0,1,1,0,9,122,0,0,0, +1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59, +121,0,18,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,0,1,0,11,1,1,1,0,9, +102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,102,0,59,120,120,120,0,20,0,0,1, +0,11,1,1,1,0,5,105,0,0,0,1,4,105,110,116,95,116,111,95,102,108,111,97,116,0,18,95,95,114,101,116, +86,97,108,0,59,120,121,122,0,0,18,105,0,59,120,120,120,0,0,0,0,1,0,11,1,1,1,0,1,98,0,0,0,1,9,18,95, +95,114,101,116,86,97,108,0,59,120,121,122,0,18,98,0,59,120,120,120,0,20,0,0,1,0,11,1,1,1,0,12,118, +0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,118,0,59,120,121,122,0,20,0,0,1,0, +12,1,1,1,0,9,120,0,0,1,1,0,9,121,0,0,1,1,0,9,122,0,0,1,1,0,9,119,0,0,0,1,9,18,95,95,114,101,116,86, +97,108,0,59,120,0,18,120,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,121,0,20,0,9,18,95, +95,114,101,116,86,97,108,0,59,122,0,18,122,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18, +119,0,20,0,0,1,0,12,1,1,1,0,9,102,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,102,0,59,120,120, +120,120,0,20,0,0,1,0,12,1,1,1,0,5,105,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,105,0,59,120, +120,120,120,0,20,0,0,1,0,12,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,98,0,59,120, +120,120,120,0,20,0,0,1,0,12,1,1,1,0,11,118,51,0,0,1,1,0,9,102,0,0,0,1,9,18,95,95,114,101,116,86,97, +108,0,59,120,121,122,0,18,118,51,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,102,0,20,0, +0,1,0,6,1,1,1,0,5,105,0,0,1,1,0,5,106,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,105,0, +20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,106,0,20,0,0,1,0,6,1,1,1,0,5,105,0,0,0,1,9,18, +95,95,114,101,116,86,97,108,0,59,120,121,0,18,105,0,59,120,120,0,20,0,0,1,0,6,1,1,1,0,9,102,0,0,0, +1,4,102,108,111,97,116,95,116,111,95,105,110,116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0, +18,102,0,59,120,120,0,0,0,0,1,0,6,1,1,1,0,1,98,0,0,0,1,4,102,108,111,97,116,95,116,111,95,105,110, +116,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,98,0,59,120,120,0,0,0,0,1,0,7,1,1,1,0,5, +105,0,0,1,1,0,5,106,0,0,1,1,0,5,107,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,105,0, +20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,106,0,20,0,9,18,95,95,114,101,116,86,97,108,0, +59,122,0,18,107,0,20,0,0,1,0,7,1,1,1,0,5,105,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121, +122,0,18,105,0,59,120,120,120,0,20,0,0,1,0,7,1,1,1,0,9,102,0,0,0,1,9,18,95,95,114,101,116,86,97, +108,0,59,120,121,122,0,18,102,0,59,120,120,120,0,20,0,0,1,0,7,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114, +101,116,86,97,108,0,59,120,121,122,0,18,98,0,59,120,120,120,0,20,0,0,1,0,8,1,1,1,0,5,120,0,0,1,1,0, +5,121,0,0,1,1,0,5,122,0,0,1,1,0,5,119,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,120,0, +20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,121,0,20,0,9,18,95,95,114,101,116,86,97,108,0, +59,122,0,18,122,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,119,0,18,119,0,20,0,0,1,0,8,1,1,1,0,5, +105,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,18,105,0,59,120,120,120,120,0,20,0,0,1,0,8,1,1,1,0, +9,102,0,0,0,1,4,102,108,111,97,116,95,116,111,95,105,110,116,0,18,95,95,114,101,116,86,97,108,0,0, +18,102,0,59,120,120,120,120,0,0,0,0,1,0,8,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0, +18,98,0,59,120,120,120,120,0,20,0,0,1,0,2,1,1,1,0,1,98,49,0,0,1,1,0,1,98,50,0,0,0,1,9,18,95,95,114, +101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,98,50, +0,20,0,0,1,0,2,1,1,1,0,1,98,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,121,0,18,98,0,59,120, +120,0,20,0,0,1,0,2,1,1,1,0,9,102,0,0,0,1,3,2,1,10,1,122,101,114,111,0,2,58,118,101,99,50,0,17,48,0, +48,0,0,0,17,48,0,48,0,0,0,0,0,0,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0, +59,120,121,0,0,18,102,0,59,120,120,0,0,18,122,101,114,111,0,0,0,0,1,0,2,1,1,1,0,5,105,0,0,0,1,3,2, +1,6,1,122,101,114,111,0,2,58,105,118,101,99,50,0,16,8,48,0,0,16,8,48,0,0,0,0,0,4,118,101,99,52,95, +115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,0,0,18,105,0,59,120,120,0,0,18,122,101, +114,111,0,0,0,0,1,0,3,1,1,1,0,1,98,49,0,0,1,1,0,1,98,50,0,0,1,1,0,1,98,51,0,0,0,1,9,18,95,95,114, +101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,121,0,18,98,50, +0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,98,51,0,20,0,0,1,0,3,1,1,1,0,1,98,0,0,0,1,9, +18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,18,98,0,59,120,120,120,0,20,0,0,1,0,3,1,1,1,0,9, +102,0,0,0,1,3,2,1,11,1,122,101,114,111,0,2,58,118,101,99,51,0,17,48,0,48,0,0,0,17,48,0,48,0,0,0,17, +48,0,48,0,0,0,0,0,0,4,118,101,99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121, +122,0,0,18,102,0,59,120,120,120,0,0,18,122,101,114,111,0,0,0,0,1,0,3,1,1,1,0,5,105,0,0,0,1,3,2,1,7, +1,122,101,114,111,0,2,58,105,118,101,99,51,0,16,8,48,0,0,16,8,48,0,0,16,8,48,0,0,0,0,0,4,118,101, +99,52,95,115,101,113,0,18,95,95,114,101,116,86,97,108,0,59,120,121,122,0,0,18,105,0,59,120,120,120, +0,0,18,122,101,114,111,0,0,0,0,1,0,4,1,1,1,0,1,98,49,0,0,1,1,0,1,98,50,0,0,1,1,0,1,98,51,0,0,1,1,0, +1,98,52,0,0,0,1,9,18,95,95,114,101,116,86,97,108,0,59,120,0,18,98,49,0,20,0,9,18,95,95,114,101,116, 86,97,108,0,59,121,0,18,98,50,0,20,0,9,18,95,95,114,101,116,86,97,108,0,59,122,0,18,98,51,0,20,0,9, 18,95,95,114,101,116,86,97,108,0,59,119,0,18,98,52,0,20,0,0,1,0,4,1,1,1,0,1,98,0,0,0,1,9,18,95,95, 114,101,116,86,97,108,0,59,120,121,122,119,0,18,98,0,59,120,120,120,120,0,20,0,0,1,0,4,1,1,1,0,9, @@ -646,7 +647,7 @@ 1,0,12,2,21,1,1,0,15,109,0,0,1,1,0,12,118,0,0,0,1,2,3,2,0,12,1,114,48,0,0,0,9,18,114,48,0,59,120,0, 18,109,0,16,8,48,0,57,59,120,0,20,0,9,18,114,48,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,20,0,9, 18,114,48,0,59,122,0,18,109,0,16,10,50,0,57,59,120,0,20,0,9,18,114,48,0,59,119,0,18,109,0,16,10,51, -0,57,59,120,0,20,0,4,118,101,99,52,95,100,111,116,0,18,95,95,114,101,116,86,97,108,0,59,120,0,0,18, +0,57,59,120,0,20,0,4,118,101,99,52,95,100,111,116,0,18,95,95,114,101,116,86,97,108,0,59,115,0,0,18, 114,48,0,0,18,118,0,0,0,0,2,3,2,0,12,1,114,49,0,0,0,9,18,114,49,0,59,120,0,18,109,0,16,8,48,0,57, 59,121,0,20,0,9,18,114,49,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,20,0,9,18,114,49,0,59,122,0, 18,109,0,16,10,50,0,57,59,121,0,20,0,9,18,114,49,0,59,119,0,18,109,0,16,10,51,0,57,59,121,0,20,0,4, -- cgit v1.2.3 From 5657fc5b4c6581166430f1a5144f1f8b7e4e78eb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 4 Jul 2007 15:29:31 +1000 Subject: r300: only init swtcl on tcl-less cards --- src/mesa/drivers/dri/r300/r300_context.c | 23 +++++++++++++---------- src/mesa/drivers/dri/r300/r300_swtcl.c | 5 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 04e3fffa5df..14e0f052fd5 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -318,15 +318,17 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, _tnl_allow_vertex_fog(ctx, GL_TRUE); /* currently bogus data */ - ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4; - ctx->Const.VertexProgram.MaxNativeInstructions = - VSF_MAX_FRAGMENT_LENGTH / 4; - ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */ - ctx->Const.VertexProgram.MaxTemps = 32; - ctx->Const.VertexProgram.MaxNativeTemps = - /*VSF_MAX_FRAGMENT_TEMPS */ 32; - ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */ - ctx->Const.VertexProgram.MaxNativeAddressRegs = 1; + if (screen->chip_flags & RADEON_CHIPSET_TCL) { + ctx->Const.VertexProgram.MaxInstructions = VSF_MAX_FRAGMENT_LENGTH / 4; + ctx->Const.VertexProgram.MaxNativeInstructions = + VSF_MAX_FRAGMENT_LENGTH / 4; + ctx->Const.VertexProgram.MaxNativeAttribs = 16; /* r420 */ + ctx->Const.VertexProgram.MaxTemps = 32; + ctx->Const.VertexProgram.MaxNativeTemps = + /*VSF_MAX_FRAGMENT_TEMPS */ 32; + ctx->Const.VertexProgram.MaxNativeParameters = 256; /* r420 */ + ctx->Const.VertexProgram.MaxNativeAddressRegs = 1; + } ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS; ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* copy i915... */ @@ -364,7 +366,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, radeonInitSpanFuncs(ctx); r300InitCmdBuf(r300); r300InitState(r300); - r300InitSwtcl(ctx); + if (!(screen->chip_flags & RADEON_CHIPSET_TCL)) + r300InitSwtcl(ctx); TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index 7aea063447a..c949f33bf33 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -668,6 +668,11 @@ void r300InitSwtcl(GLcontext *ctx) _tnl_need_projected_coords( ctx, GL_FALSE ); r300ChooseRenderState(ctx); + + _mesa_validate_all_lighting_tables( ctx ); + + tnl->Driver.NotifyMaterialChange = + _mesa_validate_all_lighting_tables; } void r300DestroySwtcl(GLcontext *ctx) -- cgit v1.2.3 From bd9db5eed2cca6cd394c88adf09c70204be9da33 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 4 Jul 2007 07:37:14 -0600 Subject: fix LogicOp/bitmap problem, bug 11133 --- src/mesa/drivers/dri/i965/intel_blit.c | 7 +++++-- src/mesa/drivers/dri/i965/intel_blit.h | 3 ++- src/mesa/drivers/dri/i965/intel_pixel_bitmap.c | 7 +++++-- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/intel_blit.c b/src/mesa/drivers/dri/i965/intel_blit.c index 173d1d5b6c2..f88cbb2328d 100644 --- a/src/mesa/drivers/dri/i965/intel_blit.c +++ b/src/mesa/drivers/dri/i965/intel_blit.c @@ -532,12 +532,15 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel, GLuint dst_offset, GLboolean dst_tiled, GLshort x, GLshort y, - GLshort w, GLshort h) + GLshort w, GLshort h, + GLenum logic_op) { struct xy_setup_blit setup; struct xy_text_immediate_blit text; int dwords = ((src_size + 7) & ~7) / 4; + assert( logic_op - GL_CLEAR >= 0 ); + assert( logic_op - GL_CLEAR < 0x10 ); if (w < 0 || h < 0) return; @@ -561,7 +564,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel, setup.br0.length = (sizeof(setup) / sizeof(int)) - 2; setup.br13.dest_pitch = dst_pitch; - setup.br13.rop = 0xcc; + setup.br13.rop = translate_raster_op(logic_op); setup.br13.color_depth = (cpp == 4) ? BR13_8888 : BR13_565; setup.br13.clipping_enable = 0; setup.br13.mono_source_transparency = 1; diff --git a/src/mesa/drivers/dri/i965/intel_blit.h b/src/mesa/drivers/dri/i965/intel_blit.h index 8b0cc65243c..e361545c8fa 100644 --- a/src/mesa/drivers/dri/i965/intel_blit.h +++ b/src/mesa/drivers/dri/i965/intel_blit.h @@ -72,6 +72,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel, GLuint dst_offset, GLboolean dst_tiled, GLshort dst_x, GLshort dst_y, - GLshort w, GLshort h); + GLshort w, GLshort h, + GLenum logic_op ); #endif diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c index 5841afaa3ef..421fcc5e511 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c @@ -260,7 +260,9 @@ do_blit_bitmap( GLcontext *ctx, int h = MIN2(DY, box_h - py); int w = MIN2(DX, box_w - px); GLuint sz = align(align(w,8) * h, 64)/8; - + GLenum logic_op = ctx->Color.ColorLogicOpEnabled ? + ctx->Color.LogicOp : GL_COPY; + assert(sz <= sizeof(stipple)); memset(stipple, 0, sz); @@ -288,7 +290,8 @@ do_blit_bitmap( GLcontext *ctx, dst->tiled, rect.x1 + px, rect.y2 - (py + h), - w, h); + w, h, + logic_op); } } } -- cgit v1.2.3 From 9aa8223605989eec99bc58a7e69ef2f7a9f7f15d Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 4 Jul 2007 09:22:15 -0600 Subject: assorted clean-ups --- src/mesa/drivers/fbdev/glfbdev.c | 103 +++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c index 6c6511b7e53..e95a424698c 100644 --- a/src/mesa/drivers/fbdev/glfbdev.c +++ b/src/mesa/drivers/fbdev/glfbdev.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -63,6 +63,9 @@ #include "drivers/common/driverfuncs.h" +/** + * Pixel formats we support: + */ #define PF_B8G8R8 1 #define PF_B8G8R8A8 2 #define PF_B5G6R5 3 @@ -70,7 +73,7 @@ #define PF_CI8 5 -/* +/** * Derived from Mesa's GLvisual class. */ struct GLFBDevVisualRec { @@ -80,7 +83,7 @@ struct GLFBDevVisualRec { int pixelFormat; }; -/* +/** * Derived from Mesa's GLframebuffer class. */ struct GLFBDevBufferRec { @@ -92,7 +95,7 @@ struct GLFBDevBufferRec { GLuint bytesPerPixel; }; -/* +/** * Derived from Mesa's GLcontext class. */ struct GLFBDevContextRec { @@ -103,7 +106,7 @@ struct GLFBDevContextRec { GLFBDevBufferPtr curBuffer; }; -/* +/** * Derived from Mesa's gl_renderbuffer class. */ struct GLFBDevRenderbufferRec { @@ -114,11 +117,6 @@ struct GLFBDevRenderbufferRec { }; - -#define GLFBDEV_CONTEXT(CTX) ((GLFBDevContextPtr) (CTX)) -#define GLFBDEV_BUFFER(BUF) ((GLFBDevBufferPtr) (BUF)) - - /**********************************************************************/ /* Internal device driver functions */ /**********************************************************************/ @@ -151,7 +149,7 @@ update_state( GLcontext *ctx, GLuint new_state ) static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) { - const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer); + const GLFBDevBufferPtr fbdevbuffer = (GLFBDevBufferPtr) buffer; *width = fbdevbuffer->var.xres; *height = fbdevbuffer->var.yres; } @@ -389,8 +387,8 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, /* ignored for now */ break; case GLFBDEV_MULTISAMPLE: - numSamples = attrib[1]; - attrib++; + numSamples = attrib[1]; + attrib++; break; default: /* unexpected token */ @@ -406,36 +404,36 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, alphaBits = varInfo->transp.length; if (fixInfo->visual == FB_VISUAL_TRUECOLOR || - fixInfo->visual == FB_VISUAL_DIRECTCOLOR) { - if(varInfo->bits_per_pixel == 24 - && varInfo->red.offset == 16 - && varInfo->green.offset == 8 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B8G8R8; - - else if(varInfo->bits_per_pixel == 32 - && varInfo->red.offset == 16 - && varInfo->green.offset == 8 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B8G8R8A8; - - else if(varInfo->bits_per_pixel == 16 - && varInfo->red.offset == 11 - && varInfo->green.offset == 5 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B5G6R5; - - else if(varInfo->bits_per_pixel == 16 - && varInfo->red.offset == 10 - && varInfo->green.offset == 5 - && varInfo->blue.offset == 0) - vis->pixelFormat = PF_B5G5R5; - - else { - _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n"); - _mesa_free(vis); - return NULL; - } + fixInfo->visual == FB_VISUAL_DIRECTCOLOR) { + if (varInfo->bits_per_pixel == 24 + && varInfo->red.offset == 16 + && varInfo->green.offset == 8 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B8G8R8; + } + else if (varInfo->bits_per_pixel == 32 + && varInfo->red.offset == 16 + && varInfo->green.offset == 8 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B8G8R8A8; + } + else if (varInfo->bits_per_pixel == 16 + && varInfo->red.offset == 11 + && varInfo->green.offset == 5 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B5G6R5; + } + else if (varInfo->bits_per_pixel == 16 + && varInfo->red.offset == 10 + && varInfo->green.offset == 5 + && varInfo->blue.offset == 0) { + vis->pixelFormat = PF_B5G5R5; + } + else { + _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n"); + _mesa_free(vis); + return NULL; + } } } else { @@ -578,7 +576,7 @@ new_glfbdev_renderbuffer(void *bufferStart, const GLFBDevVisualPtr visual) rb->rowStride = visual->var.xres_virtual * visual->var.bits_per_pixel / 8; rb->bottom = (GLubyte *) bufferStart - + (visual->var.yres - 1) * rb->rowStride; + + (visual->var.yres - 1) * rb->rowStride; rb->Base.Width = visual->var.xres; rb->Base.Height = visual->var.yres; @@ -635,7 +633,7 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo, &frontrb->Base); /* add back renderbuffer */ if (visual->glvisual.doubleBufferMode) { - int malloced = !backBuffer; + const int malloced = !backBuffer; if (malloced) { /* malloc a back buffer */ backBuffer = _mesa_malloc(size); @@ -647,8 +645,11 @@ glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo, } backrb = new_glfbdev_renderbuffer(backBuffer, visual); - if(malloced) - backrb->mallocedBuffer = GL_TRUE; + if (!backrb) { + /* out of mem */ + return NULL; + } + backrb->mallocedBuffer = malloced; _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_BACK_LEFT, &backrb->Base); @@ -682,16 +683,10 @@ glFBDevDestroyBuffer( GLFBDevBufferPtr buffer ) if (buffer == curDraw || buffer == curRead) { glFBDevMakeCurrent( NULL, NULL, NULL); } -#if 0 - /* free the software depth, stencil, accum buffers */ - _mesa_free_framebuffer_data(&buffer->glframebuffer); - _mesa_free(buffer); -#else { struct gl_framebuffer *fb = &buffer->glframebuffer; _mesa_unreference_framebuffer(&fb); } -#endif } } -- cgit v1.2.3 From c223c6b663cd5db39ba19c2be74b88cc3b8f53f3 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 4 Jul 2007 13:15:20 -0600 Subject: Be more consistant with paths in #includes. Eventually, eliminate a bunch of -I flags. --- src/mesa/main/api_arrayelt.c | 4 ++-- src/mesa/main/api_loopback.c | 8 ++++---- src/mesa/main/api_noop.c | 2 +- src/mesa/main/arrayobj.c | 2 +- src/mesa/main/context.c | 14 +++++++------- src/mesa/main/context.h | 2 +- src/mesa/main/dlist.c | 18 +++++++++--------- src/mesa/main/execmem.c | 2 +- src/mesa/main/hash.c | 2 +- src/mesa/main/mtypes.h | 4 ++-- src/mesa/main/state.c | 12 ++++++------ src/mesa/main/texenvprogram.c | 8 ++++---- src/mesa/main/varray.c | 2 +- src/mesa/main/vtxfmt_tmp.h | 4 ++-- src/mesa/math/m_eval.c | 4 ++-- src/mesa/math/m_eval.h | 2 +- src/mesa/math/m_translate.h | 4 ++-- src/mesa/math/m_xform.c | 4 ++-- src/mesa/shader/arbprogparse.c | 8 ++++---- src/mesa/shader/prog_execute.c | 2 +- src/mesa/shader/shader_api.c | 7 +++---- src/mesa/shader/slang/slang_builtin.c | 16 ++++++++-------- src/mesa/shader/slang/slang_builtin.h | 2 +- src/mesa/shader/slang/slang_codegen.c | 14 +++++++------- src/mesa/shader/slang/slang_compile.c | 10 +++++----- src/mesa/shader/slang/slang_emit.c | 14 +++++++------- src/mesa/shader/slang/slang_ir.c | 2 +- src/mesa/shader/slang/slang_label.h | 6 +++--- src/mesa/shader/slang/slang_link.c | 20 ++++++++++---------- src/mesa/shader/slang/slang_preprocess.c | 2 +- src/mesa/shader/slang/slang_typeinfo.c | 4 ++-- src/mesa/shader/slang/slang_vartable.c | 4 ++-- src/mesa/swrast/s_atifragshader.c | 7 +++---- src/mesa/swrast/s_context.c | 2 +- src/mesa/swrast/s_context.h | 4 ++-- src/mesa/swrast/s_fragprog.c | 10 +++++----- src/mesa/swrast/swrast.h | 2 +- src/mesa/tnl/t_context.c | 12 ++++++------ src/mesa/tnl/t_context.h | 4 ++-- src/mesa/tnl/t_pipeline.c | 10 +++++----- src/mesa/tnl/t_vb_program.c | 10 +++++----- src/mesa/tnl/t_vp_build.c | 10 +++++----- src/mesa/tnl/tnl.h | 2 +- src/mesa/vbo/vbo.h | 2 +- src/mesa/vbo/vbo_context.c | 6 +++--- src/mesa/vbo/vbo_exec.c | 16 ++++++++-------- src/mesa/vbo/vbo_exec.h | 2 +- src/mesa/vbo/vbo_exec_api.c | 20 ++++++++++---------- src/mesa/vbo/vbo_exec_array.c | 12 ++++++------ src/mesa/vbo/vbo_exec_draw.c | 10 +++++----- src/mesa/vbo/vbo_exec_eval.c | 10 +++++----- src/mesa/vbo/vbo_rebase.c | 6 +++--- src/mesa/vbo/vbo_save.c | 8 ++++---- src/mesa/vbo/vbo_save.h | 2 +- src/mesa/vbo/vbo_save_api.c | 18 +++++++++--------- src/mesa/vbo/vbo_save_draw.c | 14 +++++++------- src/mesa/vbo/vbo_save_loopback.c | 16 ++++++++-------- src/mesa/vbo/vbo_split.c | 6 +++--- src/mesa/vbo/vbo_split_copy.c | 10 +++++----- src/mesa/vbo/vbo_split_inplace.c | 6 +++--- 60 files changed, 222 insertions(+), 224 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c index 1899975213f..72091b0789c 100644 --- a/src/mesa/main/api_arrayelt.c +++ b/src/mesa/main/api_arrayelt.c @@ -31,8 +31,8 @@ #include "context.h" #include "imports.h" #include "macros.h" -#include "glapioffsets.h" -#include "dispatch.h" +#include "glapi/glapioffsets.h" +#include "glapi/dispatch.h" typedef void (GLAPIENTRY *array_func)( const void * ); diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c index efe5a77d581..924d7134a27 100644 --- a/src/mesa/main/api_loopback.c +++ b/src/mesa/main/api_loopback.c @@ -30,14 +30,14 @@ #include "glheader.h" -#include "glapi.h" -#include "glapitable.h" #include "macros.h" #include "colormac.h" #include "api_loopback.h" -#include "glthread.h" #include "mtypes.h" -#include "dispatch.h" +#include "glapi/glapi.h" +#include "glapi/glapitable.h" +#include "glapi/glthread.h" +#include "glapi/dispatch.h" /* KW: A set of functions to convert unusual Color/Normal/Vertex/etc * calls to a smaller set of driver-provided formats. Currently just diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index 0c1a35361f1..3df64362eab 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -31,7 +31,7 @@ #include "light.h" #include "macros.h" #include "dlist.h" -#include "dispatch.h" +#include "glapi/dispatch.h" /** diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index d601ee461e6..f08f99d8e17 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -46,7 +46,7 @@ #include "bufferobj.h" #endif #include "arrayobj.h" -#include "dispatch.h" +#include "glapi/dispatch.h" /** diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 255023c0fa9..21adcf32106 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -97,12 +97,9 @@ #include "fog.h" #include "framebuffer.h" #include "get.h" -#include "glthread.h" -#include "glapioffsets.h" #include "histogram.h" #include "hint.h" #include "hash.h" -#include "atifragshader.h" #include "light.h" #include "lines.h" #include "macros.h" @@ -110,9 +107,6 @@ #include "pixel.h" #include "points.h" #include "polygon.h" -#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "program.h" -#endif #include "queryobj.h" #include "rastpos.h" #include "simple_list.h" @@ -126,13 +120,19 @@ #include "varray.h" #include "version.h" #include "vtxfmt.h" +#include "glapi/glthread.h" +#include "glapi/glapioffsets.h" +#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program +#include "shader/program.h" +#endif +#include "shader/shader_api.h" +#include "shader/atifragshader.h" #if _HAVE_FULL_GL #include "math/m_translate.h" #include "math/m_matrix.h" #include "math/m_xform.h" #include "math/mathmod.h" #endif -#include "shader_api.h" #ifdef USE_SPARC_ASM #include "sparc/sparc.h" diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index b6a9d131493..099912aa152 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -49,7 +49,7 @@ #define CONTEXT_H -#include "glapi.h" +#include "glapi/glapi.h" #include "imports.h" #include "mtypes.h" diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 91ddcbf9ed6..293ee5fa349 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -33,10 +33,6 @@ #include "api_arrayelt.h" #include "api_loopback.h" #include "config.h" -#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" -#include "program.h" -#endif #include "attrib.h" #include "blend.h" #include "buffers.h" @@ -57,7 +53,7 @@ #include "extensions.h" #include "feedback.h" #include "get.h" -#include "glapi.h" +#include "glapi/glapi.h" #include "hash.h" #include "histogram.h" #include "image.h" @@ -76,18 +72,22 @@ #include "texstate.h" #include "mtypes.h" #include "varray.h" +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program +#include "shader/arbprogram.h" +#include "shader/program.h" +#endif #if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program -#include "nvprogram.h" -#include "program.h" +#include "shader/nvprogram.h" +#include "shader/program.h" #endif #if FEATURE_ATI_fragment_shader -#include "atifragshader.h" +#include "shader/atifragshader.h" #endif #include "math/m_matrix.h" #include "math/m_xform.h" -#include "dispatch.h" +#include "glapi/dispatch.h" /** diff --git a/src/mesa/main/execmem.c b/src/mesa/main/execmem.c index df3095232de..40f66d7da2d 100644 --- a/src/mesa/main/execmem.c +++ b/src/mesa/main/execmem.c @@ -32,7 +32,7 @@ #include "imports.h" -#include "glthread.h" +#include "glapi/glthread.h" diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index 2d5bcc3e01e..ffb2c4d946e 100644 --- a/src/mesa/main/hash.c +++ b/src/mesa/main/hash.c @@ -37,7 +37,7 @@ #include "glheader.h" #include "imports.h" -#include "glthread.h" +#include "glapi/glthread.h" #include "hash.h" diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 05c08c19fec..709b88d2ef5 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -38,8 +38,8 @@ #include "glheader.h" #include /* __GLcontextModes (GLvisual) */ #include "config.h" /* Hardwired parameters */ -#include "glapitable.h" -#include "glthread.h" +#include "glapi/glapitable.h" +#include "glapi/glthread.h" #include "math/m_matrix.h" /* GLmatrix */ #include "bitset.h" diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 0a83abc7dda..66f8ac64088 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -35,10 +35,10 @@ #include "accum.h" #include "api_loopback.h" #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program -#include "arbprogram.h" +#include "shader/arbprogram.h" #endif #if FEATURE_ATI_fragment_shader -#include "atifragshader.h" +#include "shader/atifragshader.h" #endif #include "attrib.h" #include "blend.h" @@ -85,18 +85,18 @@ #include "mtypes.h" #include "varray.h" #if FEATURE_NV_vertex_program -#include "nvprogram.h" +#include "shader/nvprogram.h" #endif #if FEATURE_NV_fragment_program -#include "nvprogram.h" -#include "program.h" +#include "shader/nvprogram.h" +#include "shader/program.h" #include "texenvprogram.h" #endif #if FEATURE_ARB_shader_objects #include "shaders.h" #endif #include "debug.h" -#include "dispatch.h" +#include "glapi/dispatch.h" diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 1a46c10ffa3..72b54b27d9a 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -28,10 +28,10 @@ #include "glheader.h" #include "macros.h" #include "enums.h" -#include "prog_parameter.h" -#include "prog_instruction.h" -#include "prog_print.h" -#include "prog_statevars.h" +#include "shader/prog_parameter.h" +#include "shader/prog_instruction.h" +#include "shader/prog_print.h" +#include "shader/prog_statevars.h" #include "texenvprogram.h" /** diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index bf1ad0165e6..fe4a7c684f6 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -32,7 +32,7 @@ #include "mtypes.h" #include "varray.h" #include "arrayobj.h" -#include "dispatch.h" +#include "glapi/dispatch.h" /** diff --git a/src/mesa/main/vtxfmt_tmp.h b/src/mesa/main/vtxfmt_tmp.h index 783b06558d5..6f5d01e40f2 100644 --- a/src/mesa/main/vtxfmt_tmp.h +++ b/src/mesa/main/vtxfmt_tmp.h @@ -29,8 +29,8 @@ #define PRE_LOOPBACK( FUNC ) #endif -#include "dispatch.h" -#include "glapioffsets.h" +#include "glapi/dispatch.h" +#include "glapi/glapioffsets.h" static void GLAPIENTRY TAG(ArrayElement)( GLint i ) { diff --git a/src/mesa/math/m_eval.c b/src/mesa/math/m_eval.c index 42ffd4133d3..d324673c5d7 100644 --- a/src/mesa/math/m_eval.c +++ b/src/mesa/math/m_eval.c @@ -37,8 +37,8 @@ */ -#include "glheader.h" -#include "config.h" +#include "main/glheader.h" +#include "main/config.h" #include "m_eval.h" static GLfloat inv_tab[MAX_EVAL_ORDER]; diff --git a/src/mesa/math/m_eval.h b/src/mesa/math/m_eval.h index a23cbd402e6..d73ecaafb28 100644 --- a/src/mesa/math/m_eval.h +++ b/src/mesa/math/m_eval.h @@ -26,7 +26,7 @@ #ifndef _M_EVAL_H #define _M_EVAL_H -#include "glheader.h" +#include "main/glheader.h" void _math_init_eval( void ); diff --git a/src/mesa/math/m_translate.h b/src/mesa/math/m_translate.h index 0bcf96005c7..c677682d506 100644 --- a/src/mesa/math/m_translate.h +++ b/src/mesa/math/m_translate.h @@ -26,8 +26,8 @@ #ifndef _M_TRANSLATE_H_ #define _M_TRANSLATE_H_ -#include "config.h" -#include "mtypes.h" /* hack for GLchan */ +#include "main/config.h" +#include "main/mtypes.h" /* hack for GLchan */ /** diff --git a/src/mesa/math/m_xform.c b/src/mesa/math/m_xform.c index fa3f57a8e5a..901ae5b416a 100644 --- a/src/mesa/math/m_xform.c +++ b/src/mesa/math/m_xform.c @@ -33,8 +33,8 @@ * 3. Transformation of a point p by a matrix M is: p' = M * p */ -#include "glheader.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/macros.h" #include "m_eval.h" #include "m_matrix.h" diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 5d8f763741f..9a5290d920e 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -30,10 +30,10 @@ * \author Karl Rasche */ -#include "glheader.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "shader/grammar/grammar_mesa.h" #include "arbprogparse.h" -#include "grammar_mesa.h" #include "program.h" #include "prog_parameter.h" #include "prog_statevars.h" @@ -3573,7 +3573,7 @@ parse_instructions(GLcontext * ctx, const GLubyte * inst, /* XXX temporary */ LONGSTRING static char core_grammar_text[] = -#include "grammar_syn.h" +#include "shader/grammar/grammar_syn.h" ; diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 9faf9d86134..28d195d0ee9 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -43,7 +43,7 @@ #include "prog_instruction.h" #include "prog_parameter.h" #include "prog_print.h" -#include "slang_library_noise.h" +#include "shader/slang/slang_library_noise.h" /* See comments below for info about this */ diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 3a54e68d0de..66509d56db1 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -43,10 +43,9 @@ #include "prog_parameter.h" #include "prog_print.h" #include "prog_statevars.h" -#include "shader_api.h" - -#include "slang_compile.h" -#include "slang_link.h" +#include "shader/shader_api.h" +#include "shader/slang/slang_compile.h" +#include "shader/slang/slang_link.h" diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c index 6ee0fd33b6a..1081d8ff8db 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -28,14 +28,14 @@ * \author Brian Paul */ -#include "imports.h" -#include "slang_builtin.h" -#include "slang_ir.h" -#include "mtypes.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_statevars.h" +#include "main/imports.h" +#include "main/mtypes.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/prog_statevars.h" +#include "shader/slang/slang_ir.h" +#include "shader/slang/slang_builtin.h" /** diff --git a/src/mesa/shader/slang/slang_builtin.h b/src/mesa/shader/slang/slang_builtin.h index ae20c844d58..58629f4f7fe 100644 --- a/src/mesa/shader/slang/slang_builtin.h +++ b/src/mesa/shader/slang/slang_builtin.h @@ -26,7 +26,7 @@ #ifndef SLANG_BUILTIN_H #define SLANG_BUILTIN_H -#include "prog_parameter.h" +#include "shader/prog_parameter.h" #include "slang_utility.h" #include "slang_ir.h" diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index f3a6d04428f..2b5196f095f 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -37,13 +37,13 @@ -#include "imports.h" -#include "macros.h" -#include "mtypes.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_statevars.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/prog_statevars.h" #include "slang_typeinfo.h" #include "slang_codegen.h" #include "slang_compile.h" diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index a4dd5b8b4ae..70f5aac16d4 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -28,11 +28,11 @@ * \author Michal Krol */ -#include "imports.h" -#include "context.h" -#include "program.h" -#include "prog_parameter.h" -#include "grammar_mesa.h" +#include "main/imports.h" +#include "main/context.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/grammar/grammar_mesa.h" #include "slang_codegen.h" #include "slang_compile.h" #include "slang_preprocess.h" diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 7804e192360..02c74095a9e 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -36,13 +36,13 @@ ***/ -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_print.h" +#include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" #include "slang_builtin.h" #include "slang_emit.h" #include "slang_mem.h" diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c index a6903cc8b62..a29f3026873 100644 --- a/src/mesa/shader/slang/slang_ir.c +++ b/src/mesa/shader/slang/slang_ir.c @@ -27,7 +27,7 @@ #include "context.h" #include "slang_ir.h" #include "slang_mem.h" -#include "prog_print.h" +#include "shader/prog_print.h" static const slang_ir_info IrInfo[] = { diff --git a/src/mesa/shader/slang/slang_label.h b/src/mesa/shader/slang/slang_label.h index 0f1a45b30f9..87068ae7a7f 100644 --- a/src/mesa/shader/slang/slang_label.h +++ b/src/mesa/shader/slang/slang_label.h @@ -1,9 +1,9 @@ #ifndef SLANG_LABEL_H #define SLANG_LABEL_H 1 -#include "imports.h" -#include "mtypes.h" -#include "prog_instruction.h" +#include "main/imports.h" +#include "main/mtypes.h" +#include "shader/prog_instruction.h" struct slang_label_ diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index d6d1c7523e5..eaa29ba094e 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -28,16 +28,16 @@ * \author Brian Paul */ -#include "imports.h" -#include "context.h" -#include "hash.h" -#include "macros.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "prog_statevars.h" -#include "shader_api.h" +#include "main/imports.h" +#include "main/context.h" +#include "main/hash.h" +#include "main/macros.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" +#include "shader/prog_statevars.h" +#include "shader/shader_api.h" #include "slang_link.h" diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index 72281eda57d..076e982f8f2 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -29,7 +29,7 @@ */ #include "imports.h" -#include "grammar_mesa.h" +#include "shader/grammar/grammar_mesa.h" #include "slang_preprocess.h" LONGSTRING static const char *slang_pp_directives_syn = diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c index da0b32bc444..8a1c3abf480 100644 --- a/src/mesa/shader/slang/slang_typeinfo.c +++ b/src/mesa/shader/slang/slang_typeinfo.c @@ -28,12 +28,12 @@ * \author Michal Krol */ -#include "imports.h" +#include "main/imports.h" +#include "shader/prog_instruction.h" #include "slang_typeinfo.h" #include "slang_compile.h" #include "slang_log.h" #include "slang_mem.h" -#include "prog_instruction.h" /** diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c index 8a3c299d19c..1d817000c60 100644 --- a/src/mesa/shader/slang/slang_vartable.c +++ b/src/mesa/shader/slang/slang_vartable.c @@ -1,11 +1,11 @@ -#include "imports.h" +#include "main/imports.h" +#include "shader/prog_instruction.h" #include "slang_compile.h" #include "slang_compile_variable.h" #include "slang_mem.h" #include "slang_vartable.h" #include "slang_ir.h" -#include "prog_instruction.h" static int dbg = 0; diff --git a/src/mesa/swrast/s_atifragshader.c b/src/mesa/swrast/s_atifragshader.c index 947054faa30..55ec757ee06 100644 --- a/src/mesa/swrast/s_atifragshader.c +++ b/src/mesa/swrast/s_atifragshader.c @@ -23,11 +23,10 @@ #include "glheader.h" #include "colormac.h" #include "context.h" -#include "atifragshader.h" #include "macros.h" -#include "program.h" - -#include "s_atifragshader.h" +#include "shader/program.h" +#include "shader/atifragshader.h" +#include "swrast/s_atifragshader.h" /** diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 791850cb502..39569256514 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -31,9 +31,9 @@ #include "context.h" #include "colormac.h" #include "mtypes.h" -#include "prog_statevars.h" #include "teximage.h" #include "swrast.h" +#include "shader/prog_statevars.h" #include "s_blend.h" #include "s_context.h" #include "s_lines.h" diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index f118eb92ca4..daa07e15783 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -43,10 +43,10 @@ #ifndef S_CONTEXT_H #define S_CONTEXT_H -#include "mtypes.h" +#include "main/mtypes.h" +#include "shader/prog_execute.h" #include "swrast.h" #include "s_span.h" -#include "prog_execute.h" typedef void (*texture_sample_func)(GLcontext *ctx, diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 923b67e78e6..14c9868c180 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -22,11 +22,11 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "prog_instruction.h" -#include "texstate.h" +#include "main/glheader.h" +#include "main/colormac.h" +#include "main/context.h" +#include "main/texstate.h" +#include "shader/prog_instruction.h" #include "s_fragprog.h" #include "s_span.h" diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index d101a9e2ae2..85a27fd55bf 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -32,7 +32,7 @@ #ifndef SWRAST_H #define SWRAST_H -#include "mtypes.h" +#include "main/mtypes.h" /** * \struct SWvertex diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 3017c73cf1f..3b8dd18bbb2 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -26,12 +26,12 @@ */ -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "mtypes.h" -#include "light.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "main/light.h" #include "tnl.h" #include "t_context.h" diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 31b89aca41f..baf283ef0f6 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -49,8 +49,8 @@ #ifndef _T_CONTEXT_H #define _T_CONTEXT_H -#include "glheader.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/mtypes.h" #include "math/m_matrix.h" #include "math/m_vector.h" diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index c7188da34aa..2a0ed8852a2 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -25,11 +25,11 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "imports.h" -#include "state.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/state.h" +#include "main/mtypes.h" #include "t_context.h" #include "t_pipeline.h" diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 9961af70ce7..f8e561ac57e 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -35,16 +35,16 @@ #include "context.h" #include "macros.h" #include "imports.h" -#include "prog_instruction.h" -#include "prog_statevars.h" -#include "prog_execute.h" +#include "shader/prog_instruction.h" +#include "shader/prog_statevars.h" +#include "shader/prog_execute.h" +#include "swrast/s_context.h" +#include "swrast/s_texfilter.h" #include "tnl.h" #include "t_context.h" #include "t_pipeline.h" -#include "swrast/s_context.h" -#include "swrast/s_texfilter.h" /** * XXX the texture sampling code in this module is a bit of a hack. diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 2a1cae77f29..ee1a2498b32 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -33,11 +33,11 @@ #include "glheader.h" #include "macros.h" #include "enums.h" -#include "program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "prog_print.h" -#include "prog_statevars.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" +#include "shader/prog_statevars.h" #include "t_context.h" /* NOTE: very light dependency on this */ #include "t_vp_build.h" diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h index 20bed5546de..047b764dcba 100644 --- a/src/mesa/tnl/tnl.h +++ b/src/mesa/tnl/tnl.h @@ -29,7 +29,7 @@ #ifndef _TNL_H #define _TNL_H -#include "mtypes.h" +#include "main/mtypes.h" diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 874a5f9e0e2..04c59c05b27 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -32,7 +32,7 @@ #ifndef _VBO_H #define _VBO_H -#include "mtypes.h" +#include "main/mtypes.h" struct _mesa_prim { GLuint mode:8; diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index f64f59d11ec..ad4556c500b 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -25,11 +25,11 @@ * Keith Whitwell */ -#include "mtypes.h" +#include "main/imports.h" +#include "main/mtypes.h" +#include "main/api_arrayelt.h" #include "vbo.h" #include "vbo_context.h" -#include "imports.h" -#include "api_arrayelt.h" /* Reach out and grab this to use as the default: */ diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index 7d958732479..1efa74945dd 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -26,14 +26,14 @@ */ -#include "api_arrayelt.h" -#include "glheader.h" -#include "imports.h" -#include "context.h" -#include "macros.h" -#include "mtypes.h" -#include "dlist.h" -#include "vtxfmt.h" +#include "main/api_arrayelt.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "main/dlist.h" +#include "main/vtxfmt.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index a9b01e08e6a..b7e8c9fe79f 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -34,7 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef __VBO_EXEC_H__ #define __VBO_EXEC_H__ -#include "mtypes.h" +#include "main/mtypes.h" #include "vbo.h" #include "vbo_attrib.h" diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 2d4ded0f984..7f56b3b6293 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -30,16 +30,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "macros.h" -#include "vtxfmt.h" -#include "dlist.h" -#include "state.h" -#include "light.h" -#include "api_arrayelt.h" -#include "api_noop.h" -#include "dispatch.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/macros.h" +#include "main/vtxfmt.h" +#include "main/dlist.h" +#include "main/state.h" +#include "main/light.h" +#include "main/api_arrayelt.h" +#include "main/api_noop.h" +#include "glapi/dispatch.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 1e4c310203b..77f3cf1455b 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -25,12 +25,12 @@ * **************************************************************************/ -#include "glheader.h" -#include "context.h" -#include "state.h" -#include "api_validate.h" -#include "api_noop.h" -#include "dispatch.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/state.h" +#include "main/api_validate.h" +#include "main/api_noop.h" +#include "glapi/dispatch.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index d8f167b3577..0ef26cdfe36 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -25,11 +25,11 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "enums.h" -#include "state.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/enums.h" +#include "main/state.h" +#include "main/macros.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_exec_eval.c b/src/mesa/vbo/vbo_exec_eval.c index fe533290bd1..0ba5585d246 100644 --- a/src/mesa/vbo/vbo_exec_eval.c +++ b/src/mesa/vbo/vbo_exec_eval.c @@ -25,13 +25,13 @@ * Keith Whitwell */ -#include "glheader.h" -#include "api_eval.h" -#include "context.h" -#include "macros.h" +#include "main/glheader.h" +#include "main/api_eval.h" +#include "main/context.h" +#include "main/macros.h" #include "math/m_eval.h" +#include "glapi/dispatch.h" #include "vbo_exec.h" -#include "dispatch.h" static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index bc4211d8529..dae778e741e 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -46,9 +46,9 @@ * of zero. */ -#include "glheader.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "vbo.h" diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c index e7f46879639..87248e10f3b 100644 --- a/src/mesa/vbo/vbo_save.c +++ b/src/mesa/vbo/vbo_save.c @@ -26,10 +26,10 @@ */ -#include "mtypes.h" -#include "dlist.h" -#include "vtxfmt.h" -#include "imports.h" +#include "main/mtypes.h" +#include "main/dlist.h" +#include "main/vtxfmt.h" +#include "main/imports.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h index b81f275a602..b7e9baabf81 100644 --- a/src/mesa/vbo/vbo_save.h +++ b/src/mesa/vbo/vbo_save.h @@ -34,7 +34,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef VBO_SAVE_H #define VBO_SAVE_H -#include "mtypes.h" +#include "main/mtypes.h" #include "vbo.h" #include "vbo_attrib.h" diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index e7794c2a6cc..aded7381436 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -67,15 +67,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "glheader.h" -#include "context.h" -#include "dlist.h" -#include "enums.h" -#include "macros.h" -#include "api_validate.h" -#include "api_arrayelt.h" -#include "vtxfmt.h" -#include "dispatch.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/dlist.h" +#include "main/enums.h" +#include "main/macros.h" +#include "main/api_validate.h" +#include "main/api_arrayelt.h" +#include "main/vtxfmt.h" +#include "glapi/dispatch.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 8940551d08b..3c6f0fccd98 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -26,13 +26,13 @@ * Keith Whitwell */ -#include "glheader.h" -#include "context.h" -#include "imports.h" -#include "mtypes.h" -#include "macros.h" -#include "light.h" -#include "state.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/mtypes.h" +#include "main/macros.h" +#include "main/light.h" +#include "main/state.h" #include "vbo_context.h" diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c index 430333b84dd..f2cef698fbe 100644 --- a/src/mesa/vbo/vbo_save_loopback.c +++ b/src/mesa/vbo/vbo_save_loopback.c @@ -28,17 +28,17 @@ #include "swrast_setup/swrast_setup.h" #include "swrast/swrast.h" #include "tnl/tnl.h" -#include "context.h" +#include "main/context.h" +#include "main/glheader.h" +#include "main/enums.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "glapi/dispatch.h" +#include "glapi/glapi.h" #include "vbo_context.h" -#include "glheader.h" -#include "enums.h" -#include "glapi.h" -#include "imports.h" -#include "macros.h" -#include "mtypes.h" -#include "dispatch.h" typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * ); diff --git a/src/mesa/vbo/vbo_split.c b/src/mesa/vbo/vbo_split.c index ef205a3bb1f..58e879628de 100644 --- a/src/mesa/vbo/vbo_split.c +++ b/src/mesa/vbo/vbo_split.c @@ -47,9 +47,9 @@ * limitations on drivers which want to use it as a fallback path. */ -#include "glheader.h" -#include "imports.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/mtypes.h" #include "vbo_split.h" #include "vbo.h" diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index e142dde6803..e5c4429350e 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -29,11 +29,11 @@ /* Split indexed primitives with per-vertex copying. */ -#include "glheader.h" -#include "imports.h" -#include "macros.h" -#include "enums.h" -#include "mtypes.h" +#include "main/glheader.h" +#include "main/imports.h" +#include "main/macros.h" +#include "main/enums.h" +#include "main/mtypes.h" #include "vbo_split.h" #include "vbo.h" diff --git a/src/mesa/vbo/vbo_split_inplace.c b/src/mesa/vbo/vbo_split_inplace.c index ea62866e7c9..958afccd0c0 100644 --- a/src/mesa/vbo/vbo_split_inplace.c +++ b/src/mesa/vbo/vbo_split_inplace.c @@ -27,9 +27,9 @@ */ -#include "mtypes.h" -#include "macros.h" -#include "enums.h" +#include "main/mtypes.h" +#include "main/macros.h" +#include "main/enums.h" #include "vbo_split.h" -- cgit v1.2.3 From ffa2659204121f703208782ff225a22e0c21b173 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 5 Jul 2007 09:37:46 -0600 Subject: stencil pixel map didn't work in _mesa_unpack_stencil_span(), bug 11475 --- src/mesa/main/image.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index e2e7f806ab1..e874719e645 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3648,11 +3648,13 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, * Try simple cases first */ if (transferOps == 0 && + !ctx->Pixel.MapStencilFlag && srcType == GL_UNSIGNED_BYTE && dstType == GL_UNSIGNED_BYTE) { _mesa_memcpy(dest, source, n * sizeof(GLubyte)); } else if (transferOps == 0 && + !ctx->Pixel.MapStencilFlag && srcType == GL_UNSIGNED_INT && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) { @@ -3668,19 +3670,17 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, extract_uint_indexes(n, indexes, GL_STENCIL_INDEX, srcType, source, srcPacking); - if (transferOps) { - if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { - /* shift and offset indexes */ - shift_and_offset_ci(ctx, n, indexes); - } + if (transferOps & IMAGE_SHIFT_OFFSET_BIT) { + /* shift and offset indexes */ + shift_and_offset_ci(ctx, n, indexes); + } - if (ctx->Pixel.MapStencilFlag) { - /* Apply stencil lookup table */ - GLuint mask = ctx->PixelMaps.StoS.Size - 1; - GLuint i; - for (i=0;iPixelMaps.StoS.Map[ indexes[i] & mask ]; - } + if (ctx->Pixel.MapStencilFlag) { + /* Apply stencil lookup table */ + const GLuint mask = ctx->PixelMaps.StoS.Size - 1; + GLuint i; + for (i = 0; i < n; i++) { + indexes[i] = ctx->PixelMaps.StoS.Map[ indexes[i] & mask ]; } } -- cgit v1.2.3 From 2adcd5bdd2ac4931bbbfd16140800330d3fd14f8 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Fri, 6 Jul 2007 23:55:51 +0200 Subject: NV1X don't support VIEWPORT_ORIGIN in hardware --- src/mesa/drivers/dri/nouveau/nv10_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 5f304ccab92..4db8296f04a 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -739,11 +739,11 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, OUT_RING_CACHE(depth ? depth->offset : color[0]->offset); /* Always set to bottom left of buffer */ - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); + /*BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); OUT_RING_CACHEf (0.0); OUT_RING_CACHEf ((GLfloat) h); OUT_RING_CACHEf (0.0); - OUT_RING_CACHEf (0.0); + OUT_RING_CACHEf (0.0);*/ return GL_TRUE; } -- cgit v1.2.3 From 69501d76fc6a45da48bf4c416ac9e15edd44e7a9 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Fri, 6 Jul 2007 23:59:29 +0200 Subject: NV_17 is different from NV_10 --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_state.c | 1 + src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index d96b00242cd..319c0481bd4 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -224,6 +224,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, nv04TriInitFunctions( ctx ); break; case NV_10: + case NV_17: case NV_20: case NV_30: case NV_40: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 7cb805902a7..41fdd2d377a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -162,6 +162,7 @@ void nouveauDDInitState(nouveauContextPtr nmesa) nv04InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); break; case NV_10: + case NV_17: nv10InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); break; case NV_20: diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 4576c1ede4d..586e0b9d594 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -58,7 +58,7 @@ static void nv10ResetLineStipple( GLcontext *ctx ); static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size) { - if (nmesa->screen->card->type==NV_10) + if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -66,7 +66,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_BEGIN_END,1); OUT_RING(primitive); - if (nmesa->screen->card->type==NV_10) + if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_DATA|NONINC_METHOD,size); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VERTEX_DATA|NONINC_METHOD,size); @@ -76,7 +76,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri inline void nv10FinishPrimitive(struct nouveau_context *nmesa) { - if (nmesa->screen->card->type==NV_10) + if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -454,7 +454,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) /* * Tell the hardware about the vertex format */ - if (nmesa->screen->card->type==NV_10) { + if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) { int size; #define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2 -- cgit v1.2.3 From 0bf2479aef5def4d01bfc55b08992f41664f1431 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 6 Jul 2007 16:50:13 -0600 Subject: Add case for GL_QUADS in i915_reduced_primitive_state(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The t_dd_tritemp.h code can emit GL_QUADS primitives. We need to catch that case to determine if polygon stipple should be enabled. Fixes bug reported by Carlos Diógenes on 4 July 2007. --- src/mesa/drivers/dri/i915/i915_vtbl.c | 1 + src/mesa/drivers/dri/i915tex/i915_vtbl.c | 1 + 2 files changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index b0e5f87fc75..cc8a605e505 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -64,6 +64,7 @@ static void i915_reduced_primitive_state( intelContextPtr intel, st1 &= ~ST1_ENABLE; switch (rprim) { + case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */ case GL_TRIANGLES: if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple) diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index f80e8d6327f..ad333b490b7 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -61,6 +61,7 @@ i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) st1 &= ~ST1_ENABLE; switch (rprim) { + case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */ case GL_TRIANGLES: if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple) st1 |= ST1_ENABLE; -- cgit v1.2.3 From a164d3aee063580503e5e9a77980059d52c486d7 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 6 Jul 2007 16:51:19 -0600 Subject: In _swsetup_Translate(), update dest->attrib[FRAG_ATTRIB_COL0]. Also, check if we're in RGB vs. CI mode. This fixes a problem with incorrect rendering color seen with the redbook/polys demo. --- src/mesa/swrast_setup/ss_context.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index f8a1cadfa5a..a9c7d941e5b 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -280,26 +280,29 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest ) /** XXX try to limit these loops someday */ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i, + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0 + i, dest->attrib[FRAG_ATTRIB_TEX0 + i] ); for (i = 0 ; i < ctx->Const.MaxVarying ; i++) - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0+i, + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i, dest->attrib[FRAG_ATTRIB_VAR0 + i] ); - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp ); - /* XXX need float color FRAG_ATTRIB_COL0?? */ - UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); + if (ctx->Visual.rgbMode) { + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, + dest->attrib[FRAG_ATTRIB_COL0] ); + UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp ); - COPY_4V(dest->attrib[FRAG_ATTRIB_COL1], tmp); + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, + dest->attrib[FRAG_ATTRIB_COL1]); + } + else { + _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp ); + dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0]; + } _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp ); dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0]; - _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp ); - dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0]; - /* XXX See _tnl_get_attr about pointsize ... */ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp ); dest->pointSize = tmp[0]; -- cgit v1.2.3 From 64359af07188c06dcc6a9a95ba05f7e8209a7379 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 8 Jul 2007 08:53:19 -0600 Subject: check depthScale value for optimized ushort->uint case (fixes bug 11474) --- src/mesa/main/image.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index e874719e645..e5b9ce82800 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3882,6 +3882,16 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, } \ } while (0) + +/** + * Unpack a row of depth/z values from memory, returning GLushort, GLuint + * or GLfloat values. + * The glPixelTransfer (scale/bias) params will be applied. + * + * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT + * \param depthScale scale factor (max value) for returned GLushort or + * GLuint values (ignored for GLfloat). + */ void _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLenum dstType, GLvoid *dest, GLfloat depthScale, @@ -3907,7 +3917,9 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, } return; } - if (srcType == GL_UNSIGNED_SHORT && dstType == GL_UNSIGNED_INT) { + if (srcType == GL_UNSIGNED_SHORT + && dstType == GL_UNSIGNED_INT + && depthScale == (GLfloat) 0xffffffff) { const GLushort *src = (const GLushort *) source; GLuint *dst = (GLuint *) dest; GLuint i; -- cgit v1.2.3 From 25cfb68f0b3baf0e74d1f6a37afab46370f6711b Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 8 Jul 2007 09:02:36 -0600 Subject: Change float depthScale param to _mesa_unpack_depth_span() to GLuint depthMax. --- src/mesa/main/image.c | 22 +++++++++++----------- src/mesa/main/image.h | 6 +++--- src/mesa/main/texstore.c | 8 +++++--- src/mesa/swrast/s_drawpix.c | 6 +++--- 4 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index e5b9ce82800..ba46cdc1b17 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3889,12 +3889,12 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, * The glPixelTransfer (scale/bias) params will be applied. * * \param dstType one of GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, GL_FLOAT - * \param depthScale scale factor (max value) for returned GLushort or - * GLuint values (ignored for GLfloat). + * \param depthMax max value for returned GLushort or GLuint values + * (ignored for GLfloat). */ void _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLfloat depthScale, + GLenum dstType, GLvoid *dest, GLuint depthMax, GLenum srcType, const GLvoid *source, const struct gl_pixelstore_attrib *srcPacking ) { @@ -3919,7 +3919,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, } if (srcType == GL_UNSIGNED_SHORT && dstType == GL_UNSIGNED_INT - && depthScale == (GLfloat) 0xffffffff) { + && depthMax == 0xffffffff) { const GLushort *src = (const GLushort *) source; GLuint *dst = (GLuint *) dest; GLuint i; @@ -3967,7 +3967,7 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, break; case GL_UNSIGNED_INT_24_8_EXT: /* GL_EXT_packed_depth_stencil */ if (dstType == GL_UNSIGNED_INT && - depthScale == (GLfloat) 0xffffff && + depthMax == 0xffffff && ctx->Pixel.DepthScale == 1.0 && ctx->Pixel.DepthBias == 0.0) { const GLuint *src = (const GLuint *) source; @@ -4045,16 +4045,16 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, if (dstType == GL_UNSIGNED_INT) { GLuint *zValues = (GLuint *) dest; GLuint i; - if (depthScale <= (GLfloat) 0xffffff) { + if (depthMax <= 0xffffff) { /* no overflow worries */ for (i = 0; i < n; i++) { - zValues[i] = (GLuint) (depthValues[i] * depthScale); + zValues[i] = (GLuint) (depthValues[i] * (GLfloat) depthMax); } } else { /* need to use double precision to prevent overflow problems */ for (i = 0; i < n; i++) { - GLdouble z = depthValues[i] * depthScale; + GLdouble z = depthValues[i] * (GLfloat) depthMax; if (z >= (GLdouble) 0xffffffff) zValues[i] = 0xffffffff; else @@ -4065,14 +4065,14 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, else if (dstType == GL_UNSIGNED_SHORT) { GLushort *zValues = (GLushort *) dest; GLuint i; - ASSERT(depthScale <= 65535.0); + ASSERT(depthMax <= 0xffff); for (i = 0; i < n; i++) { - zValues[i] = (GLushort) (depthValues[i] * depthScale); + zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax); } } else { ASSERT(dstType == GL_FLOAT); - ASSERT(depthScale == 1.0F); + /*ASSERT(depthMax == 1.0F);*/ } } diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 990398a7c45..2a16989fa7e 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -181,7 +181,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, extern void _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, - GLenum dstType, GLvoid *dest, GLfloat depthScale, + GLenum dstType, GLvoid *dest, GLuint depthMax, GLenum srcType, const GLvoid *source, const struct gl_pixelstore_attrib *srcPacking ); diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 9b8a06df145..3b5151ed171 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1077,7 +1077,7 @@ _mesa_texstore_rgba(TEXSTORE_PARAMS) GLboolean _mesa_texstore_z32(TEXSTORE_PARAMS) { - const GLfloat depthScale = (GLfloat) 0xffffffff; + const GLuint depthScale = 0xffffffff; (void) dims; ASSERT(dstFormat == &_mesa_texformat_z32); ASSERT(dstFormat->TexelBytes == sizeof(GLuint)); @@ -1124,7 +1124,7 @@ _mesa_texstore_z32(TEXSTORE_PARAMS) GLboolean _mesa_texstore_z16(TEXSTORE_PARAMS) { - const GLfloat depthScale = 65535.0f; + const GLuint depthScale = 0xffff; (void) dims; ASSERT(dstFormat == &_mesa_texformat_z16); ASSERT(dstFormat->TexelBytes == sizeof(GLushort)); @@ -2319,6 +2319,8 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS) GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS) { + const GLuint depthScale = 0xffffff; + ASSERT(dstFormat == &_mesa_texformat_z24_s8); ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT); ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT); @@ -2357,7 +2359,7 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS) _mesa_unpack_depth_span(ctx, srcWidth, GL_UNSIGNED_INT, /* dst type */ dstRow, /* dst addr */ - (GLfloat) 0xffffff, /* depthScale */ + depthScale, srcType, src, srcPacking); /* get the 8-bit stencil values */ _mesa_unpack_stencil_span(ctx, srcWidth, diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 1c9f64b275e..0cf425e1c62 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -484,7 +484,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, } else { /* General case */ - const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; + const GLuint depthMax = ctx->DrawBuffer->_DepthMax; GLint skipPixels = 0; /* in case width > MAX_WIDTH do the copy in chunks */ @@ -695,7 +695,7 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y, const GLint imgX = x, imgY = y; const GLboolean scaleOrBias = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0; - const GLfloat depthScale = ctx->DrawBuffer->_DepthMaxF; + const GLuint depthMax = ctx->DrawBuffer->_DepthMax; const GLuint stencilMask = ctx->Stencil.WriteMask[0]; const GLuint stencilType = (STENCIL_BITS == 8) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; @@ -783,7 +783,7 @@ draw_depth_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* general case */ GLuint zValues[MAX_WIDTH]; /* 16 or 32-bit Z value storage */ _mesa_unpack_depth_span(ctx, width, - depthRb->DataType, zValues, depthScale, + depthRb->DataType, zValues, depthMax, type, depthStencilSrc, &clippedUnpack); if (zoom) { _swrast_write_zoomed_z_span(ctx, imgX, imgY, width, x, -- cgit v1.2.3 From 37ece4df7c654b30b6720044b35a83694d7e5bb3 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 8 Jul 2007 09:20:42 -0600 Subject: Check if 'indices' parameter is NULL (bug 11314) --- src/mesa/main/api_validate.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 3d20ba7d144..841c6a53026 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.0.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -100,6 +100,11 @@ _mesa_validate_DrawElements(GLcontext *ctx, (const GLubyte *) indices); } } + else { + /* not using a VBO */ + if (!indices) + return GL_FALSE; + } if (ctx->Const.CheckArrayBounds) { /* find max array index */ @@ -170,6 +175,16 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) return GL_FALSE; + /* Vertex buffer object tests */ + if (ctx->Array.ElementArrayBufferObj->Name) { + /* XXX re-use code from above? */ + } + else { + /* not using VBO */ + if (!indices) + return GL_FALSE; + } + if (ctx->Const.CheckArrayBounds) { /* Find max array index. * We don't trust the user's start and end values. -- cgit v1.2.3 From aa328291c5b015e74ebfd9c5cdb39227265b3000 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 8 Jul 2007 09:58:18 -0600 Subject: Fix size test bug in _mesa_test_proxy_teximage(). width/height/depth == 0 is a legal texture size (no error generated). Later, the texture will be considered incomplete, however, and texturing will effectively be disabled. See bug 11309. --- src/mesa/main/teximage.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index f902365b9bd..1656b228b9b 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1264,6 +1264,10 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target, * A hardware driver might override this function if, for example, the * max 3D texture size is 512x512x64 (i.e. not a cube). * + * Note that width, height, depth == 0 is not an error. However, a + * texture with zero width/height/depth will be considered "incomplete" + * and texturing will effectively be disabled. + * * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV, * GL_PROXY_TEXTURE_CUBE_MAP_ARB. @@ -1293,7 +1297,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); if (width < 2 * border || width > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || + width >0 && _mesa_bitcount(width - 2 * border) != 1) || level >= ctx->Const.MaxTextureLevels) { /* bad width or level */ return GL_FALSE; @@ -1303,10 +1307,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); if (width < 2 * border || width > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || + width > 0 && _mesa_bitcount(width - 2 * border) != 1) || height < 2 * border || height > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(height - 2 * border) != 1) || + height > 0 && _mesa_bitcount(height - 2 * border) != 1) || level >= ctx->Const.MaxTextureLevels) { /* bad width or height or level */ return GL_FALSE; @@ -1316,21 +1320,21 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1); if (width < 2 * border || width > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || + width > 0 && _mesa_bitcount(width - 2 * border) != 1) || height < 2 * border || height > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(height - 2 * border) != 1) || + height > 0 && _mesa_bitcount(height - 2 * border) != 1) || depth < 2 * border || depth > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(depth - 2 * border) != 1) || + depth > 0 && _mesa_bitcount(depth - 2 * border) != 1) || level >= ctx->Const.Max3DTextureLevels) { /* bad width or height or depth or level */ return GL_FALSE; } return GL_TRUE; case GL_PROXY_TEXTURE_RECTANGLE_NV: - if (width < 1 || width > ctx->Const.MaxTextureRectSize || - height < 1 || height > ctx->Const.MaxTextureRectSize || + if (width < 0 || width > ctx->Const.MaxTextureRectSize || + height < 0 || height > ctx->Const.MaxTextureRectSize || level != 0) { /* bad width or height or level */ return GL_FALSE; @@ -1340,10 +1344,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1); if (width < 2 * border || width > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || + width > 0 && _mesa_bitcount(width - 2 * border) != 1) || height < 2 * border || height > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(height - 2 * border) != 1) || + height > 0 && _mesa_bitcount(height - 2 * border) != 1) || level >= ctx->Const.MaxCubeTextureLevels) { /* bad width or height */ return GL_FALSE; @@ -1353,7 +1357,7 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); if (width < 2 * border || width > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || + width > 0 && _mesa_bitcount(width - 2 * border) != 1) || level >= ctx->Const.MaxTextureLevels) { /* bad width or level */ return GL_FALSE; @@ -1367,10 +1371,10 @@ _mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level, maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); if (width < 2 * border || width > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(width - 2 * border) != 1) || + width > 0 && _mesa_bitcount(width - 2 * border) != 1) || height < 2 * border || height > 2 + maxSize || (!ctx->Extensions.ARB_texture_non_power_of_two && - _mesa_bitcount(height - 2 * border) != 1) || + height > 0 && _mesa_bitcount(height - 2 * border) != 1) || level >= ctx->Const.MaxTextureLevels) { /* bad width or height or level */ return GL_FALSE; -- cgit v1.2.3 From a903749b246fce26038c66d06fe7eb77daf815ab Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 10 Jul 2007 10:49:28 +0200 Subject: Clear pointers to freed cliprects. Not doing this could lead to double frees under rare circumstances. --- src/mesa/drivers/dri/common/dri_util.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index dd52f7e9151..c30e66f1722 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -428,10 +428,12 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) if (pdp->pClipRects) { _mesa_free(pdp->pClipRects); + pdp->pClipRects = NULL; } if (pdp->pBackClipRects) { _mesa_free(pdp->pBackClipRects); + pdp->pBackClipRects = NULL; } DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); -- cgit v1.2.3 From f1e1b2ed167b63409a88ba489418e407fce68f21 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 10 Jul 2007 10:54:51 +0200 Subject: i915tex: Only wait for vblank when really necessary. This avoids superfluous waits for vblank timing out under some circumstances. --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 10 +++++++--- src/mesa/drivers/dri/i915tex/intel_context.c | 27 ++++++++++++++++++++------- 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 62ff54b0075..15d02f8e2cf 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -316,7 +316,8 @@ intelWindowMoved(struct intel_context *intel) flags = intel_fb->vblank_flags & ~VBLANK_FLAG_SECONDARY; } - if (flags != intel_fb->vblank_flags) { + if (flags != intel_fb->vblank_flags && intel_fb->vblank_flags && + !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ)) { drmVBlank vbl; int i; @@ -327,7 +328,9 @@ intelWindowMoved(struct intel_context *intel) } for (i = 0; i < intel_fb->pf_num_pages; i++) { - if (!intel_fb->color_rb[i]) + if (!intel_fb->color_rb[i] || + (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <= + (1<<23)) continue; vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending; @@ -828,7 +831,8 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) drm_i915_vblank_swap_t swap; GLboolean ret; - if ((intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) || + if (!intel_fb->vblank_flags || + (intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) || intelScreen->current_rotation != 0 || intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6)) return GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index c927dca8e5a..5334efd63d4 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -619,12 +619,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, if (intel->ctx.DrawBuffer == &intel_fb->Base) { if (intel->driDrawable != driDrawPriv) { - intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) - ? driGetDefaultVBlankFlags(&intel->optionCache) - : VBLANK_FLAG_NO_IRQ; - (*dri_interface->getUST) (&intel_fb->swap_ust); - driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags, - &intel_fb->vbl_seq); + if (driDrawPriv->pdraw->swap_interval == (unsigned)-1) { + int i; + + intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0) + ? driGetDefaultVBlankFlags(&intel->optionCache) + : VBLANK_FLAG_NO_IRQ; + + (*dri_interface->getUST) (&intel_fb->swap_ust); + driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags, + &intel_fb->vbl_seq); + intel_fb->vbl_waited = intel_fb->vbl_seq; + + for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) { + if (intel_fb->color_rb[i]) + intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_seq; + } + } intel->driDrawable = driDrawPriv; intelWindowMoved(intel); } @@ -741,7 +752,9 @@ void LOCK_HARDWARE( struct intel_context *intel ) BUFFER_BACK_LEFT); } - if (intel_rb && (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) { + if (intel_rb && intel_fb->vblank_flags && + !(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) && + (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) { drmVBlank vbl; vbl.request.type = DRM_VBLANK_ABSOLUTE; -- cgit v1.2.3 From 7c42222111d3697ea8d76e3d94d7455c69c7f2d1 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 10 Jul 2007 11:02:18 +0200 Subject: i915tex: Better procedure for dropping batchbuffer on virtual resolution change. The previous procedure would often result in a GPU lockup. --- src/mesa/drivers/dri/i915tex/intel_context.c | 30 ++++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 5334efd63d4..40ea7564126 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c +++ b/src/mesa/drivers/dri/i915tex/intel_context.c @@ -681,37 +681,27 @@ intelContendedLock(struct intel_context *intel, GLuint flags) if (sarea->width != intel->width || sarea->height != intel->height || sarea->rotation != intel->current_rotation) { - - void *batchMap = intel->batch->map; - + int numClipRects = intel->numClipRects; + /* * FIXME: Really only need to do this when drawing to a * common back- or front buffer. */ /* - * This will drop the outstanding batchbuffer on the floor + * This will essentially drop the outstanding batchbuffer on the floor. */ + intel->numClipRects = 0; - if (batchMap != NULL) { - driBOUnmap(intel->batch->buffer); - intel->batch->map = NULL; - } - - intel_batchbuffer_reset(intel->batch); + if (intel->Fallback) + _swrast_flush(&intel->ctx); - if (batchMap == NULL) { - driBOUnmap(intel->batch->buffer); - intel->batch->map = NULL; - } + INTEL_FIREVERTICES(intel); - /* lose all primitives */ - intel->prim.primitive = ~0; - intel->prim.start_ptr = 0; - intel->prim.flush = 0; + if (intel->batch->map != intel->batch->ptr) + intel_batchbuffer_flush(intel->batch); - /* re-emit all state */ - intel->vtbl.lost_hardware(intel); + intel->numClipRects = numClipRects; /* force window update */ intel->lastStamp = 0; -- cgit v1.2.3 From a8ec5dac3c8c564b1c405798f7703e0d8e650f2d Mon Sep 17 00:00:00 2001 From: Arthur Huillet Date: Wed, 11 Jul 2007 02:48:40 +0200 Subject: bumped nouveau DRM interface version number --- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index bc7f39b042a..c62063db05d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 7 +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 8 #error nouveau_drm.h version doesn't match expected version #endif dri_interface = interface; -- cgit v1.2.3 From 922dadf422440e120c7123a728454e517289e430 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 11 Jul 2007 19:25:32 +0200 Subject: nouveau: nv20 does not support hw scissors --- src/mesa/drivers/dri/nouveau/nv20_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index 3d8d83a865a..a6961edf0ba 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -568,10 +568,10 @@ static void nv20Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) y += nmesa->drawY; } - BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1); + /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1); OUT_RING_CACHE((w << 16) | x ); BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_Y2_Y1, 1); - OUT_RING_CACHE((h << 16) | y ); + OUT_RING_CACHE((h << 16) | y );*/ } -- cgit v1.2.3 From 4bd04c9851097ff4dfbfd73f6c62e1bc4143fc0d Mon Sep 17 00:00:00 2001 From: Tommy Schultz Lassen Date: Wed, 11 Jul 2007 17:35:35 +0000 Subject: r300: Corrected r300UpdateCulling; would only set font face if culling was set. --- src/mesa/drivers/dri/r300/r300_state.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index b5cf21d644a..6e1eeb857a4 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -325,12 +325,11 @@ static void r300UpdateCulling(GLcontext * ctx) val = R300_CULL_FRONT; else val = R300_CULL_BACK; - - if (ctx->Polygon.FrontFace == GL_CW) - val |= R300_FRONT_FACE_CW; - else - val |= R300_FRONT_FACE_CCW; } + if (ctx->Polygon.FrontFace == GL_CW) + val |= R300_FRONT_FACE_CW; + else + val |= R300_FRONT_FACE_CCW; r300->hw.cul.cmd[R300_CUL_CULL] = val; } -- cgit v1.2.3 From ee7fece05462e3cc00b4f24069748c1401fcacef Mon Sep 17 00:00:00 2001 From: Tommy Schultz Lassen Date: Wed, 11 Jul 2007 17:37:12 +0000 Subject: r300: Added support for Back Facing Color. --- src/mesa/drivers/dri/r300/r300_emit.c | 4 +-- src/mesa/drivers/dri/r300/r300_vertprog.c | 56 ++++++++++++++----------------- 2 files changed, 28 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index 229439dfa87..732dbcbc9d9 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -299,13 +299,13 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) if (OutputsWritten & (1 << VERT_RESULT_COL1)) ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; -#if 0 if (OutputsWritten & (1 << VERT_RESULT_BFC0)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT; + ret |= (7 << 2); if (OutputsWritten & (1 << VERT_RESULT_BFC1)) ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; +#if 0 if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; #endif diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 16dddf6557d..d5cae478539 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -438,32 +438,42 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, assert(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)); /* Assign outputs */ - if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) - vp->outputs[VERT_RESULT_HPOS] = cur_reg++; + if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) { + vp->outputs[VERT_RESULT_HPOS] = cur_reg; + cur_reg = 1; + } - if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) - vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; + if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) { + vp->outputs[VERT_RESULT_COL0] = 1; + cur_reg = 2; + } - if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) - vp->outputs[VERT_RESULT_COL0] = cur_reg++; + if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) { + vp->outputs[VERT_RESULT_COL1] = 2; + cur_reg = 3; + } - if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) - vp->outputs[VERT_RESULT_COL1] = cur_reg++; + if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { + vp->outputs[VERT_RESULT_BFC0] = 3; + cur_reg = 5; + } + if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { + vp->outputs[VERT_RESULT_BFC1] = 4; + cur_reg = 5; + } #if 0 /* Not supported yet */ - if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) - vp->outputs[VERT_RESULT_BFC0] = cur_reg++; - - if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) - vp->outputs[VERT_RESULT_BFC1] = cur_reg++; - if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) vp->outputs[VERT_RESULT_FOGC] = cur_reg++; #endif + if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) + vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; + for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) - if (vp->key.OutputsWritten & (1 << i)) + if (vp->key.OutputsWritten & (1 << i)) { vp->outputs[i] = cur_reg++; + } vp->translated = GL_TRUE; vp->native = GL_TRUE; @@ -1255,8 +1265,6 @@ void r300SelectVertexShader(r300ContextPtr r300) vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current; InputsRead = ctx->FragmentProgram._Current->Base.InputsRead; - wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS; - wpos_idx = -1; if (InputsRead & FRAG_BIT_WPOS) { for (i = 0; i < ctx->Const.MaxTextureUnits; i++) @@ -1271,20 +1279,8 @@ void r300SelectVertexShader(r300ContextPtr r300) InputsRead |= (FRAG_BIT_TEX0 << i); wpos_idx = i; } - - if (InputsRead & FRAG_BIT_COL0) - wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL0; - - if ((InputsRead & FRAG_BIT_COL1) /*|| - (InputsRead & FRAG_BIT_FOGC) */ ) - wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1; - - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - if (InputsRead & (FRAG_BIT_TEX0 << i)) - wanted_key.OutputsWritten |= - 1 << (VERT_RESULT_TEX0 + i); - wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead; + wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten; if (vpc->mesa_program.IsPositionInvariant) { /* we wan't position don't we ? */ wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS); -- cgit v1.2.3 From b755a2d9de5b7977c410a904a8adb7c07c88f82a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 11 Jul 2007 16:19:51 -0600 Subject: Minor clean-up of polygon offset logic. Properly compute _MRD field. --- src/mesa/main/framebuffer.c | 4 +++- src/mesa/swrast_setup/ss_tritmp.h | 40 ++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 1fd31a53211..dc10d9ffbc8 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -65,7 +65,9 @@ compute_depth_max(struct gl_framebuffer *fb) fb->_DepthMax = 0xffffffff; } fb->_DepthMaxF = (GLfloat) fb->_DepthMax; - fb->_MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */ + + /* Minimum resolvable depth value, for polygon offset */ + fb->_MRD = 1.0 / fb->_DepthMaxF; } diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h index c14468e9514..f6b738d60df 100644 --- a/src/mesa/swrast_setup/ss_tritmp.h +++ b/src/mesa/swrast_setup/ss_tritmp.h @@ -37,7 +37,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; SWvertex *v[3]; GLfloat z[3]; - GLfloat offset; + GLfloat offset, oz0, oz1, oz2; GLenum mode = GL_FILL; GLuint facing = 0; GLchan saved_color[3][4]; @@ -142,12 +142,16 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) } } - if (IND & SS_OFFSET_BIT) - { - offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD; + if (IND & SS_OFFSET_BIT) { + const GLfloat max = ctx->DrawBuffer->_DepthMaxF; + /* save original Z values (restored later) */ z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2]; z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2]; z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2]; + /* Note that Z values are already scaled to [0,65535] (for example) + * so no MRD value is used here. + */ + offset = ctx->Polygon.OffsetUnits; if (cc * cc > 1e-16) { const GLfloat ez = z[0] - z[2]; const GLfloat fz = z[1] - z[2]; @@ -155,35 +159,33 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea); const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea); offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; - /* Unfortunately, we need to clamp to prevent negative Zs below. - * Technically, we should do the clamping per-fragment. - */ - offset = MAX2(offset, -v[0]->attrib[FRAG_ATTRIB_WPOS][2]); - offset = MAX2(offset, -v[1]->attrib[FRAG_ATTRIB_WPOS][2]); - offset = MAX2(offset, -v[2]->attrib[FRAG_ATTRIB_WPOS][2]); } + /* new Z values */ + oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max); + oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max); + oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max); } } if (mode == GL_POINT) { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset; + v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; + v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; + v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; } _swsetup_render_point_tri( ctx, e0, e1, e2, facing ); } else if (mode == GL_LINE) { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset; + v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; + v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; + v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; } _swsetup_render_line_tri( ctx, e0, e1, e2, facing ); } else { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { - v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset; - v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset; - v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset; + v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0; + v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1; + v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2; } _swrast_Triangle( ctx, v[0], v[1], v[2] ); } -- cgit v1.2.3 From 3ffa09b09dfd55c64cb98bd8e7bab0370f93cdbd Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 11 Jul 2007 16:33:15 -0600 Subject: clean-up of stencil code --- src/mesa/swrast/s_stencil.c | 85 +++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index 89991fad02d..d0cbdd6917d 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -392,6 +392,23 @@ do_stencil_test( GLcontext *ctx, GLuint face, GLuint n, GLstencil stencil[], } +/** + * Compute the zpass/zfail masks by comparing the pre- and post-depth test + * masks. + */ +static INLINE void +compute_pass_fail_masks(GLuint n, const GLubyte origMask[], + const GLubyte newMask[], + GLubyte passMask[], GLubyte failMask[]) +{ + GLuint i; + for (i = 0; i < n; i++) { + ASSERT(newMask[i] == 0 || newMask[i] == 1); + passMask[i] = origMask[i] & newMask[i]; + failMask[i] = origMask[i] & (newMask[i] ^ 1); + } +} + /** * Apply stencil and depth testing to the span of pixels. @@ -460,39 +477,24 @@ stencil_and_ztest_span(GLcontext *ctx, SWspan *span, GLuint face) /* * Perform depth buffering, then apply zpass or zfail stencil function. */ - GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH]; - GLuint i; + GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH]; /* save the current mask bits */ - _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte)); + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); /* apply the depth test */ _swrast_depth_test_span(ctx, span); - /* Set the stencil pass/fail flags according to result of depth testing. - * if oldmask[i] == 0 then - * Don't touch the stencil value - * else if oldmask[i] and newmask[i] then - * Depth test passed - * else - * assert(oldmask[i] && !newmask[i]) - * Depth test failed - * endif - */ - for (i=0;iStencil.ZFailFunc[face] != GL_KEEP) { apply_stencil_op( ctx, ctx->Stencil.ZFailFunc[face], face, - n, stencil, failmask ); + n, stencil, failMask ); } if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) { apply_stencil_op( ctx, ctx->Stencil.ZPassFunc[face], face, - n, stencil, passmask ); + n, stencil, passMask ); } } @@ -902,6 +904,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n, static GLboolean stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) { + GLubyte passMask[MAX_WIDTH], failMask[MAX_WIDTH], origMask[MAX_WIDTH]; struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_renderbuffer *rb = fb->_StencilBuffer; const GLuint n = span->end; @@ -916,13 +919,10 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) if (!rb->GetPointer(ctx, rb, 0, 0)) { /* No direct access */ GLstencil stencil[MAX_WIDTH]; - GLubyte origMask[MAX_WIDTH]; ASSERT(rb->DataType == GL_UNSIGNED_BYTE); _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte)); - _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); - (void) do_stencil_test(ctx, face, n, stencil, mask); if (ctx->Depth.Test == GL_FALSE) { @@ -930,27 +930,19 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) n, stencil, mask); } else { + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); + _swrast_depth_test_span(ctx, span); + compute_pass_fail_masks(n, origMask, mask, passMask, failMask); + if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) { - GLubyte failmask[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) { - ASSERT(mask[i] == 0 || mask[i] == 1); - failmask[i] = origMask[i] & (mask[i] ^ 1); - } apply_stencil_op(ctx, ctx->Stencil.ZFailFunc[face], face, - n, stencil, failmask); + n, stencil, failMask); } if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) { - GLubyte passmask[MAX_WIDTH]; - GLuint i; - for (i = 0; i < n; i++) { - ASSERT(mask[i] == 0 || mask[i] == 1); - passmask[i] = origMask[i] & mask[i]; - } apply_stencil_op(ctx, ctx->Stencil.ZPassFunc[face], face, - n, stencil, passmask); + n, stencil, passMask); } } @@ -972,28 +964,21 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) ctx->Stencil.ZPassFunc[face], face, mask); } else { - GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH]; - GLuint i; - - _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte)); + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); _swrast_depth_test_span(ctx, span); - for (i=0;iStencil.ZFailFunc[face] != GL_KEEP) { apply_stencil_op_to_pixels(ctx, n, x, y, ctx->Stencil.ZFailFunc[face], - face, failmask); + face, failMask); } if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) { apply_stencil_op_to_pixels(ctx, n, x, y, ctx->Stencil.ZPassFunc[face], - face, passmask); + face, passMask); } } -- cgit v1.2.3 From cd8613e59d2d27b5f41d23d978afe8e33d206447 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 12 Jul 2007 11:08:17 +1000 Subject: nouveau: match drm 0.0.9 interface --- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 15 +++++---------- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index 857cd30584c..35afb364348 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -78,8 +78,8 @@ nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem) if (mem->map) drmUnmap(mem->map, mem->size); - memf.flags = mem->type; - memf.region_offset = mem->offset; + memf.flags = mem->type; + memf.offset = mem->offset; drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, sizeof(memf)); FREE(mem); } @@ -111,7 +111,7 @@ nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) FREE(mem); return NULL; } - mem->offset = mema.region_offset; + mem->offset = mema.offset; mem->type = mema.flags; if (NOUVEAU_DEBUG & DEBUG_MEM) { @@ -120,7 +120,7 @@ nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) } if (type & NOUVEAU_MEM_MAPPED) - ret = drmMap(nmesa->driFd, mem->offset, mem->size, &mem->map); + ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, &mem->map); if (ret) { mem->map = NULL; nouveau_mem_free(ctx, mem); @@ -135,12 +135,7 @@ nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - if (mem->type & NOUVEAU_MEM_FB) - return (uint32_t)mem->offset - nmesa->vram_phys; - else if (mem->type & NOUVEAU_MEM_AGP) - return (uint32_t)mem->offset - nmesa->gart_phys; - else - return 0xDEADF00D; + return mem->offset; } static GLboolean diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index c62063db05d..69b0691bb7b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 8 +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 9 #error nouveau_drm.h version doesn't match expected version #endif dri_interface = interface; -- cgit v1.2.3 From e5dd38942989475f7fd8936a98738bbd57de6b50 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 12 Jul 2007 18:36:41 +0200 Subject: nv20 also don't support viewport_origin, like nv10 --- src/mesa/drivers/dri/nouveau/nv20_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index a6961edf0ba..ccf2f6148b4 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -764,11 +764,11 @@ static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color, } /* Always set to bottom left of buffer */ - BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); + /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); OUT_RING_CACHEf (0.0); OUT_RING_CACHEf ((GLfloat) h); OUT_RING_CACHEf (0.0); - OUT_RING_CACHEf (0.0); + OUT_RING_CACHEf (0.0);*/ return GL_TRUE; } -- cgit v1.2.3 From f5eb25e9c7b09612766255f2e2059f3df2bf2095 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 12 Jul 2007 14:50:53 -0600 Subject: fix swizzle-related bug 11534 --- src/mesa/shader/slang/slang_codegen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 2b5196f095f..35e80e04523 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. * @@ -2328,7 +2328,8 @@ _slang_gen_field(slang_assemble_ctx * A, slang_operation *oper) n = _slang_gen_swizzle(n, swizzle); return n; } - else if (ti.spec.type == SLANG_SPEC_FLOAT) { + else if ( ti.spec.type == SLANG_SPEC_FLOAT + || ti.spec.type == SLANG_SPEC_INT) { const GLuint rows = 1; slang_swizzle swz; slang_ir_node *n; -- cgit v1.2.3 From 7c4c82fc6d5301e27643868517aeb23fcb5c40e6 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 12 Jul 2007 21:32:35 -0600 Subject: fix width/depth mix-up (bug 11577) --- src/mesa/main/teximage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 1656b228b9b..3420d8e2baf 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1476,7 +1476,7 @@ texture_error_check( GLcontext *ctx, GLenum target, if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) { proxy_target = GL_PROXY_TEXTURE_1D; height = 1; - width = 1; + depth = 1; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); -- cgit v1.2.3 From 4b08b9c3e9da922d80aaff4720ed2dec026c012e Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Thu, 12 Jul 2007 23:52:06 +0000 Subject: r300: Setup the back facing color bits correctly. Apparently for back facing color to work you must set all 3 color bits; I guess the hardware cannot handle them separately. --- src/mesa/drivers/dri/r300/r300_emit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index 732dbcbc9d9..424bf44e595 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -299,11 +299,12 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) if (OutputsWritten & (1 << VERT_RESULT_COL1)) ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT; - if (OutputsWritten & (1 << VERT_RESULT_BFC0)) - ret |= (7 << 2); - - if (OutputsWritten & (1 << VERT_RESULT_BFC1)) - ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; + if (OutputsWritten & (1 << VERT_RESULT_BFC0) + || OutputsWritten & (1 << VERT_RESULT_BFC1)) + ret |= + R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT | + R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT | + R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT; #if 0 if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; -- cgit v1.2.3 From 08a005e076d4520f564881e4c7e54b47cc7e20c3 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Fri, 13 Jul 2007 01:45:05 +0000 Subject: r300: Use a switch statement in r300UpdateCulling. --- src/mesa/drivers/dri/r300/r300_state.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 6e1eeb857a4..d6f477bbf5c 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -317,19 +317,34 @@ static void r300UpdateCulling(GLcontext * ctx) r300ContextPtr r300 = R300_CONTEXT(ctx); uint32_t val = 0; - R300_STATECHANGE(r300, cul); if (ctx->Polygon.CullFlag) { - if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) - val = R300_CULL_FRONT | R300_CULL_BACK; - else if (ctx->Polygon.CullFaceMode == GL_FRONT) + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: val = R300_CULL_FRONT; - else + break; + case GL_BACK: val = R300_CULL_BACK; + break; + case GL_FRONT_AND_BACK: + val = R300_CULL_FRONT | R300_CULL_BACK; + break; + default: + break; + } } - if (ctx->Polygon.FrontFace == GL_CW) + + switch (ctx->Polygon.FrontFace) { + case GL_CW: val |= R300_FRONT_FACE_CW; - else + break; + case GL_CCW: val |= R300_FRONT_FACE_CCW; + break; + default: + break; + } + + R300_STATECHANGE(r300, cul); r300->hw.cul.cmd[R300_CUL_CULL] = val; } -- cgit v1.2.3 From 42dcdb9372f541f35c06920368946ebe24696fc4 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Fri, 13 Jul 2007 02:11:58 +0000 Subject: r300: Moved some hardware initialization into appropriate functions. --- src/mesa/drivers/dri/r300/r300_state.c | 53 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index d6f477bbf5c..48d92da2118 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -82,6 +82,8 @@ static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4]) rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0], color[1], color[2]); + rmesa->hw.blend_color.cmd[2] = 0; + rmesa->hw.blend_color.cmd[3] = 0; } /** @@ -358,6 +360,20 @@ static void r300SetEarlyZState(GLcontext * ctx) r300ContextPtr r300 = R300_CONTEXT(ctx); R300_STATECHANGE(r300, zstencil_format); + switch (ctx->Visual.depthBits) { + case 16: + r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z; + break; + case 24: + r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z; + break; + default: + fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits); + _mesa_exit(-1); + } + + // r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32; + if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS) /* disable early Z */ r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE; @@ -369,6 +385,9 @@ static void r300SetEarlyZState(GLcontext * ctx) /* disable early Z */ r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE; } + + r300->hw.zstencil_format.cmd[3] = 0x00000003; + r300->hw.zstencil_format.cmd[4] = 0x00000000; } static void r300SetAlphaState(GLcontext * ctx) @@ -417,6 +436,7 @@ static void r300SetAlphaState(GLcontext * ctx) R300_STATECHANGE(r300, at); r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc; + r300->hw.at.cmd[R300_AT_UNKNOWN] = 0; r300SetEarlyZState(ctx); } @@ -527,6 +547,9 @@ static void r300UpdatePolygonMode(GLcontext * ctx) R300_STATECHANGE(r300, polygon_mode); r300->hw.polygon_mode.cmd[1] = hw_mode; } + + r300->hw.polygon_mode.cmd[2] = 0x00000001; + r300->hw.polygon_mode.cmd[3] = 0x00000000; } /** @@ -776,6 +799,7 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode) r300ContextPtr rmesa = R300_CONTEXT(ctx); R300_STATECHANGE(rmesa, shade); + rmesa->hw.shade.cmd[1] = 0x00000002; switch (mode) { case GL_FLAT: rmesa->hw.shade.cmd[2] = R300_RE_SHADE_MODEL_FLAT; @@ -786,6 +810,8 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode) default: return; } + rmesa->hw.shade.cmd[3] = 0x00000000; + rmesa->hw.shade.cmd[4] = 0x00000000; } static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face, @@ -1862,15 +1888,10 @@ static void r300ResetHwState(r300ContextPtr r300) r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0); r300->hw.unk4260.cmd[3] = r300PackFloat32(1.0); - r300->hw.shade.cmd[1] = 0x00000002; r300ShadeModel(ctx, ctx->Light.ShadeModel); - r300->hw.shade.cmd[3] = 0x00000000; - r300->hw.shade.cmd[4] = 0x00000000; r300PolygonMode(ctx, GL_FRONT, ctx->Polygon.FrontMode); r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode); - r300->hw.polygon_mode.cmd[2] = 0x00000001; - r300->hw.polygon_mode.cmd[3] = 0x00000000; r300->hw.zbias_cntl.cmd[1] = 0x00000000; r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor, @@ -1901,14 +1922,11 @@ static void r300ResetHwState(r300ContextPtr r300) r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color); r300Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL); - r300->hw.at.cmd[R300_AT_UNKNOWN] = 0; r300->hw.unk4BD8.cmd[1] = 0; r300->hw.unk4E00.cmd[1] = 0; r300BlendColor(ctx, ctx->Color.BlendColor); - r300->hw.blend_color.cmd[2] = 0; - r300->hw.blend_color.cmd[3] = 0; /* Again, r300ClearBuffer uses this */ r300->hw.cb.cmd[R300_CB_OFFSET] = @@ -1939,25 +1957,6 @@ static void r300ResetHwState(r300ContextPtr r300) r300->hw.unk4EA0.cmd[1] = 0x00000000; r300->hw.unk4EA0.cmd[2] = 0xffffffff; - switch (ctx->Visual.depthBits) { - case 16: - r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z; - break; - case 24: - r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z; - break; - default: - fprintf(stderr, "Error: Unsupported depth %d... exiting\n", - ctx->Visual.depthBits); - _mesa_exit(-1); - - } - /* z compress? */ - //r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32; - - r300->hw.zstencil_format.cmd[3] = 0x00000003; - r300->hw.zstencil_format.cmd[4] = 0x00000000; - r300->hw.zb.cmd[R300_ZB_OFFSET] = r300->radeon.radeonScreen->depthOffset + r300->radeon.radeonScreen->fbLocation; -- cgit v1.2.3 From 07ac2386f5c0ab9c2432d4b5e3490b1e13d033fc Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Fri, 13 Jul 2007 04:58:32 +0000 Subject: r300: Corrected off-by-one error in r300_vertprog.c. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index d5cae478539..60f151c5423 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -455,7 +455,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { vp->outputs[VERT_RESULT_BFC0] = 3; - cur_reg = 5; + cur_reg = 4; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { -- cgit v1.2.3 From 5ec66cf62dab00a50499bc8d2a666146a334a3cb Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Fri, 13 Jul 2007 09:39:23 +0000 Subject: Revert "r300: Corrected off-by-one error in r300_vertprog.c." This reverts commit 07ac2386f5c0ab9c2432d4b5e3490b1e13d033fc. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 60f151c5423..d5cae478539 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -455,7 +455,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { vp->outputs[VERT_RESULT_BFC0] = 3; - cur_reg = 4; + cur_reg = 5; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { -- cgit v1.2.3 From 8fcfaa3238599f5a9b28794b748b8417e042c597 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 13 Jul 2007 23:39:24 +1000 Subject: Play "nuke the typedef" --- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 4 ++-- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_context.h | 6 +++--- src/mesa/drivers/dri/nouveau/nouveau_driver.c | 4 ++-- src/mesa/drivers/dri/nouveau/nouveau_fifo.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_lock.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_object.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 23 ++++++++++++++--------- src/mesa/drivers/dri/nouveau/nouveau_sync.h | 16 +++++++++------- 9 files changed, 34 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index 35afb364348..f98d6665635 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -69,7 +69,7 @@ void nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - drm_nouveau_mem_free_t memf; + struct drm_nouveau_mem_free memf; if (NOUVEAU_DEBUG & DEBUG_MEM) { fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n", @@ -88,7 +88,7 @@ nouveau_mem * nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - drm_nouveau_mem_alloc_t mema; + struct drm_nouveau_mem_alloc mema; nouveau_mem *mem; int ret; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 319c0481bd4..3b2bd21a46c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -180,7 +180,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, driParseConfigFiles (&nmesa->optionCache, &screen->optionCache, screen->driScreen->myNum, "nouveau"); - nmesa->sarea = (drm_nouveau_sarea_t *)((char *)sPriv->pSAREA + + nmesa->sarea = (struct drm_nouveau_sarea *)((char *)sPriv->pSAREA + screen->sarea_priv_offset); /* Enable any supported extensions */ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 10d2ed6e172..9a0be2cb2a5 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -109,12 +109,12 @@ typedef struct nouveau_context { uint64_t gart_size; /* Channel synchronisation */ - drm_nouveau_notifier_alloc_t *syncNotifier; + struct drm_nouveau_notifier_alloc *syncNotifier; /* ARB_occlusion_query / EXT_timer_query */ GLuint query_object_max; GLboolean * query_alloc; - drm_nouveau_notifier_alloc_t *queryNotifier; + struct drm_nouveau_notifier_alloc *queryNotifier; /* Additional hw-specific functions */ nouveau_hw_func hw_func; @@ -168,7 +168,7 @@ typedef struct nouveau_context { nouveauShader *passthrough_fp; nouveauScreenRec *screen; - drm_nouveau_sarea_t *sarea; + struct drm_nouveau_sarea *sarea; __DRIcontextPrivate *driContext; /* DRI context */ __DRIscreenPrivate *driScreen; /* DRI screen */ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c index 00956aa8f8b..ddc9535624b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_driver.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_driver.c @@ -41,7 +41,7 @@ GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa, unsigned int param, uint64_t* value) { - drm_nouveau_getparam_t getp; + struct drm_nouveau_getparam getp; getp.param = param; if (!value || drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_GETPARAM, @@ -56,7 +56,7 @@ GLboolean nouveauDRMSetParam(nouveauContextPtr nmesa, unsigned int param, uint64_t value) { - drm_nouveau_setparam_t setp; + struct drm_nouveau_setparam setp; setp.param = param; setp.value = value; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c index e9320918f9f..7b5e96b4c26 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c @@ -98,7 +98,7 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa) // here we call the fifo initialization ioctl and fill in stuff accordingly GLboolean nouveauFifoInit(nouveauContextPtr nmesa) { - drm_nouveau_fifo_alloc_t fifo_init; + struct drm_nouveau_fifo_alloc fifo_init; int i, ret; #ifdef NOUVEAU_RING_DEBUG diff --git a/src/mesa/drivers/dri/nouveau/nouveau_lock.c b/src/mesa/drivers/dri/nouveau/nouveau_lock.c index c119d14dd75..aa86c9e7838 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_lock.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_lock.c @@ -44,7 +44,7 @@ void nouveauGetLock( nouveauContextPtr nmesa, GLuint flags ) { __DRIdrawablePrivate *dPriv = nmesa->driDrawable; __DRIscreenPrivate *sPriv = nmesa->driScreen; - drm_nouveau_sarea_t *sarea = nmesa->sarea; + struct drm_nouveau_sarea *sarea = nmesa->sarea; drmGetLock( nmesa->driFd, nmesa->hHWContext, flags ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index 69f8dbf7946..ec517f8b16a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -7,7 +7,7 @@ GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, uint32_t handle, int class) { - drm_nouveau_grobj_alloc_t cto; + struct drm_nouveau_grobj_alloc cto; int ret; cto.channel = nmesa->fifo.channel; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index 1d1eeede18b..8abc847e1e2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -39,11 +39,11 @@ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \ volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset -drm_nouveau_notifier_alloc_t * +struct drm_nouveau_notifier_alloc * nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - drm_nouveau_notifier_alloc_t *notifier; + struct drm_nouveau_notifier_alloc *notifier; int ret; #ifdef NOUVEAU_RING_DEBUG @@ -69,14 +69,16 @@ nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) } void -nouveau_notifier_destroy(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier) +nouveau_notifier_destroy(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier) { /*XXX: free notifier object.. */ FREE(notifier); } void -nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier, +nouveau_notifier_reset(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, GLuint id) { NOTIFIER(n); @@ -93,7 +95,8 @@ nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier, } GLuint -nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier, +nouveau_notifier_status(GLcontext *ctx, + struct drm_nouveau_notifier_alloc *notifier, GLuint id) { NOTIFIER(n); @@ -103,7 +106,8 @@ nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier, GLuint nouveau_notifier_return_val(GLcontext *ctx, - drm_nouveau_notifier_alloc_t *notifier, GLuint id) + struct drm_nouveau_notifier_alloc *notifier, + GLuint id) { NOTIFIER(n); @@ -112,8 +116,8 @@ nouveau_notifier_return_val(GLcontext *ctx, GLboolean nouveau_notifier_wait_status(GLcontext *ctx, - drm_nouveau_notifier_alloc_t *notifier, GLuint id, - GLuint status, GLuint timeout) + struct drm_nouveau_notifier_alloc *notifier, + GLuint id, GLuint status, GLuint timeout) { NOTIFIER(n); unsigned int time = 0; @@ -146,7 +150,8 @@ nouveau_notifier_wait_status(GLcontext *ctx, void nouveau_notifier_wait_nop(GLcontext *ctx, - drm_nouveau_notifier_alloc_t *notifier, GLuint subc) + struct drm_nouveau_notifier_alloc *notifier, + GLuint subc) { NOTIFIER(n); GLboolean ret; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h index b56cc5fb544..b76af172762 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.h @@ -47,22 +47,24 @@ #define NV_NOTIFY 0x00000104 #define NV_NOTIFY_STYLE_WRITE_ONLY 0 -extern drm_nouveau_notifier_alloc_t * +extern struct drm_nouveau_notifier_alloc * nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count); extern void -nouveau_notifier_destroy(GLcontext *, drm_nouveau_notifier_alloc_t *); +nouveau_notifier_destroy(GLcontext *, struct drm_nouveau_notifier_alloc *); extern void -nouveau_notifier_reset(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id); +nouveau_notifier_reset(GLcontext *, struct drm_nouveau_notifier_alloc *, + GLuint id); extern GLuint -nouveau_notifier_status(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id); +nouveau_notifier_status(GLcontext *, struct drm_nouveau_notifier_alloc *, + GLuint id); extern GLuint -nouveau_notifier_return_val(GLcontext *, drm_nouveau_notifier_alloc_t *, +nouveau_notifier_return_val(GLcontext *, struct drm_nouveau_notifier_alloc *, GLuint id); extern GLboolean -nouveau_notifier_wait_status(GLcontext *, drm_nouveau_notifier_alloc_t *, +nouveau_notifier_wait_status(GLcontext *, struct drm_nouveau_notifier_alloc *, GLuint id, GLuint status, GLuint timeout); extern void -nouveau_notifier_wait_nop(GLcontext *ctx, drm_nouveau_notifier_alloc_t *, +nouveau_notifier_wait_nop(GLcontext *ctx, struct drm_nouveau_notifier_alloc *, GLuint subc); extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx); -- cgit v1.2.3 From 5a0f02a394cec0603fe48de55f4cbe323d2357e0 Mon Sep 17 00:00:00 2001 From: Jan Dvorak Date: Fri, 13 Jul 2007 16:36:00 -0600 Subject: fix shader/info string length queries (bug 11588) --- src/mesa/shader/shader_api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 66509d56db1..1a931326afa 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -779,7 +779,7 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program, *params = shProg->Validated; break; case GL_INFO_LOG_LENGTH: - *params = shProg->InfoLog ? strlen(shProg->InfoLog) : 0; + *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0; break; case GL_ATTACHED_SHADERS: *params = shProg->NumShaders; @@ -831,10 +831,10 @@ _mesa_get_shaderiv(GLcontext *ctx, GLuint name, GLenum pname, GLint *params) *params = shader->CompileStatus; break; case GL_INFO_LOG_LENGTH: - *params = shader->InfoLog ? strlen(shader->InfoLog) : 0; + *params = shader->InfoLog ? strlen(shader->InfoLog) + 1 : 0; break; case GL_SHADER_SOURCE_LENGTH: - *params = shader->Source ? strlen((char *) shader->Source) : 0; + *params = shader->Source ? strlen((char *) shader->Source) + 1 : 0; break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)"); -- cgit v1.2.3 From 24f85f047b8b9e9b465bd3f9af2cc113582bfc0d Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 14 Jul 2007 18:54:22 +0200 Subject: nouveau: nv10 and nv11,15 are different --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_object.c | 5 ++++- src/mesa/drivers/dri/nouveau/nouveau_state.c | 1 + src/mesa/drivers/dri/nouveau/nv10_state.c | 3 +-- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 8 ++++---- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 3b2bd21a46c..44392c0267c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -224,6 +224,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, nv04TriInitFunctions( ctx ); break; case NV_10: + case NV_11: case NV_17: case NV_20: case NV_30: diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index ec517f8b16a..a143488e8d5 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -34,10 +34,13 @@ void nouveauObjectInit(nouveauContextPtr nmesa) nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d); if (nmesa->screen->card->type>=NV_10) { nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D); - nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT); } else { nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D); nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D); + } + if (nmesa->screen->card->type>=NV_11) { + nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT); + } else { nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT); } nouveauCreateContextObject(nmesa, NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 41fdd2d377a..f618dcfc99b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -162,6 +162,7 @@ void nouveauDDInitState(nouveauContextPtr nmesa) nv04InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); break; case NV_10: + case NV_11: case NV_17: nv10InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); break; diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 4db8296f04a..47c4b14ba6b 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -697,8 +697,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) BEGIN_RING_SIZE(NvSub3D, 0x03f4, 1); OUT_RING(0); - /* not for nv10, only for >= nv11 */ - if ((nmesa->screen->card->id>>4) >= 0x11) { + if (nmesa->screen->card->type >= NV_11) { BEGIN_RING_SIZE(NvSub3D, 0x120, 3); OUT_RING(0); OUT_RING(1); diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 586e0b9d594..611469b6e41 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -58,7 +58,7 @@ static void nv10ResetLineStipple( GLcontext *ctx ); static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size) { - if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -66,7 +66,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_BEGIN_END,1); OUT_RING(primitive); - if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_DATA|NONINC_METHOD,size); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VERTEX_DATA|NONINC_METHOD,size); @@ -76,7 +76,7 @@ static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t pri inline void nv10FinishPrimitive(struct nouveau_context *nmesa) { - if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); else if (nmesa->screen->card->type==NV_20) BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -454,7 +454,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) /* * Tell the hardware about the vertex format */ - if ((nmesa->screen->card->type==NV_10) || (nmesa->screen->card->type==NV_17)) { + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) { int size; #define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2 -- cgit v1.2.3 From 491f646c798ec2f20ba5a6adc600bc7ea92ddf24 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Sat, 14 Jul 2007 18:11:45 +0000 Subject: r300: Clean up the vertex program output assignment. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index d5cae478539..a40fb4f4ac9 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -439,41 +439,43 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, /* Assign outputs */ if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) { - vp->outputs[VERT_RESULT_HPOS] = cur_reg; - cur_reg = 1; + vp->outputs[VERT_RESULT_HPOS] = cur_reg++; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) { - vp->outputs[VERT_RESULT_COL0] = 1; - cur_reg = 2; + vp->outputs[VERT_RESULT_COL0] = cur_reg++; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) { - vp->outputs[VERT_RESULT_COL1] = 2; - cur_reg = 3; + vp->outputs[VERT_RESULT_COL1] = vp->outputs[VERT_RESULT_COL0] + 1; + cur_reg = vp->outputs[VERT_RESULT_COL1] + 1; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { - vp->outputs[VERT_RESULT_BFC0] = 3; - cur_reg = 5; + vp->outputs[VERT_RESULT_BFC0] = vp->outputs[VERT_RESULT_COL0] + 2; + cur_reg = vp->outputs[VERT_RESULT_BFC0] + 1; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { - vp->outputs[VERT_RESULT_BFC1] = 4; - cur_reg = 5; + vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; + cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; } -#if 0 /* Not supported yet */ - if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) + +#if 0 + if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { vp->outputs[VERT_RESULT_FOGC] = cur_reg++; -#endif + } - if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) + if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; + } +#endif - for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) + for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) { if (vp->key.OutputsWritten & (1 << i)) { vp->outputs[i] = cur_reg++; } + } vp->translated = GL_TRUE; vp->native = GL_TRUE; -- cgit v1.2.3 From 393558a933670705f9d3482fd976393a2baca957 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Sat, 14 Jul 2007 18:31:29 +0000 Subject: r300: Disable vertex program point size; it's almost certainly wrong. See the conversation between myself and Tommy Schultz Lassen on mesa3d-dev. --- src/mesa/drivers/dri/r300/r300_emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index 424bf44e595..6da22f652f3 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -308,10 +308,10 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) #if 0 if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; -#endif if (OutputsWritten & (1 << VERT_RESULT_PSIZ)) ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; +#endif return ret; } -- cgit v1.2.3 From 9457bf62bbba3b9226ebbbea5dc7798ca22485f6 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Sun, 15 Jul 2007 01:17:54 +0000 Subject: r300: Gracefully exit after GART memory is exhausted. --- src/mesa/drivers/dri/r300/r300_mem.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_mem.c b/src/mesa/drivers/dri/r300/r300_mem.c index f8f9d4fcdf1..a66508bdcdb 100644 --- a/src/mesa/drivers/dri/r300/r300_mem.c +++ b/src/mesa/drivers/dri/r300/r300_mem.c @@ -208,23 +208,10 @@ int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size) drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc, sizeof(alloc)); if (ret) { -#if 0 - WARN_ONCE("Ran out of mem!\n"); - r300FlushCmdBuf(rmesa, __FUNCTION__); - //usleep(100); - tries2++; - tries = 0; - if (tries2 > 100) { - WARN_ONCE("Ran out of GART memory!\n"); - exit(1); - } - goto again; -#else WARN_ONCE ("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n", size); - return 0; -#endif + exit(1); } i = free; -- cgit v1.2.3 From b0f0b4044cae50af3443e1bfeb87b2d7d6042913 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 05:04:10 +0000 Subject: r300: Replaced the ugly VERTEX_SHADER_INSTRUCTION typedef. --- src/mesa/drivers/dri/r300/r300_context.h | 2 +- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- src/mesa/drivers/dri/r300/r300_vertprog.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 6615bc79fb3..00fa498e5fe 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -568,7 +568,7 @@ struct r300_vertex_shader_fragment { union { GLuint d[VSF_MAX_FRAGMENT_LENGTH]; float f[VSF_MAX_FRAGMENT_LENGTH]; - VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH / 4]; + struct r300_vertprog_instruction i[VSF_MAX_FRAGMENT_LENGTH / 4]; } body; }; diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index a40fb4f4ac9..dfea8b46c9b 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -415,7 +415,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct prog_instruction *vpi) { int i, cur_reg = 0; - VERTEX_SHADER_INSTRUCTION *o_inst; + struct r300_vertprog_instruction *o_inst; unsigned long operands; int are_srcs_scalar; unsigned long hw_op; diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h index 252d5a901f4..0da158cc551 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.h +++ b/src/mesa/drivers/dri/r300/r300_vertprog.h @@ -3,10 +3,10 @@ #include "r300_reg.h" -typedef struct { +struct r300_vertprog_instruction { GLuint op; GLuint src[3]; -} VERTEX_SHADER_INSTRUCTION; +}; #define VSF_FLAG_X 1 #define VSF_FLAG_Y 2 -- cgit v1.2.3 From 79773ba13ac75fcdf12f187eead41ff35d75d6c0 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 06:16:35 +0000 Subject: r300: Major vertex program code clean up and rework. --- src/mesa/drivers/dri/r300/r300_state.c | 2 +- src/mesa/drivers/dri/r300/r300_vertprog.c | 1207 +++++++++++++++-------------- src/mesa/drivers/dri/r300/r300_vertprog.h | 2 +- 3 files changed, 640 insertions(+), 571 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 48d92da2118..adf736f756a 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1566,7 +1566,7 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa) for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) { if (rmesa->state.sw_tcl_inputs[i] != -1) { - prog->program.body.i[program_end].op = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); + prog->program.body.i[program_end].opcode = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); prog->program.body.i[program_end].src[0] = VSF_REG(rmesa->state.sw_tcl_inputs[i]); prog->program.body.i[program_end].src[1] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]); prog->program.body.i[program_end].src[2] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]); diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index dfea8b46c9b..e3278d7ba19 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -55,6 +55,55 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #error Cannot change these! #endif +/* TODO: Get rid of t_src_class call */ +#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \ + ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \ + t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \ + (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \ + t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \ + +#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \ + SWIZZLE_ZERO, SWIZZLE_ZERO, \ + SWIZZLE_ZERO, SWIZZLE_ZERO, \ + t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4)) + +#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \ + SWIZZLE_ZERO, SWIZZLE_ZERO, \ + SWIZZLE_ZERO, SWIZZLE_ZERO, \ + t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4)) + +#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \ + SWIZZLE_ZERO, SWIZZLE_ZERO, \ + SWIZZLE_ZERO, SWIZZLE_ZERO, \ + t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4)) + +#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \ + SWIZZLE_ONE, SWIZZLE_ONE, \ + SWIZZLE_ONE, SWIZZLE_ONE, \ + t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4)) + +#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \ + SWIZZLE_ONE, SWIZZLE_ONE, \ + SWIZZLE_ONE, SWIZZLE_ONE, \ + t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4)) + +#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \ + SWIZZLE_ONE, SWIZZLE_ONE, \ + SWIZZLE_ONE, SWIZZLE_ONE, \ + t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4)) + +/* DP4 version seems to trigger some hw peculiarity */ +//#define PREFER_DP4 + +#define FREE_TEMPS() \ + do { \ + if(u_temp_i < vp->num_temporaries) { \ + WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \ + vp->native = GL_FALSE; \ + } \ + u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \ + } while (0) + #define SCALAR_FLAG (1<<31) #define FLAG_MASK (1<<31) #define OP_MASK (0xf) /* we are unlikely to have more than 15 */ @@ -102,7 +151,8 @@ static struct { #undef OPN int r300VertexProgUpdateParams(GLcontext * ctx, - struct r300_vertex_program_cont *vp, float *dst) + struct r300_vertex_program_cont *vp, + float *dst) { int pi; struct gl_vertex_program *mesa_vp = &vp->mesa_program; @@ -234,8 +284,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller) int i; if (vp == NULL) { - fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__, - caller); + fprintf(stderr, "vp null in call to %s from %s\n", + __FUNCTION__, caller); return; } @@ -276,6 +326,8 @@ static unsigned long t_src_index(struct r300_vertex_program *vp, } } +/* these two functions should probably be merged... */ + static unsigned long t_src(struct r300_vertex_program *vp, struct prog_src_register *src) { @@ -294,7 +346,9 @@ static unsigned long t_src(struct r300_vertex_program *vp, static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct prog_src_register *src) { - + /* src->NegateBase uses the NEGATE_ flags from program_instruction.h, + * which equal our VSF_FLAGS_ values, so it's safe to just pass it here. + */ return MAKE_VSF_SOURCE(t_src_index(vp, src), t_swizzle(GET_SWZ(src->Swizzle, 0)), t_swizzle(GET_SWZ(src->Swizzle, 0)), @@ -362,72 +416,456 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, return GL_TRUE; } -/* TODO: Get rid of t_src_class call */ -#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \ - ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \ - t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \ - (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \ - t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \ +static void t_opcode_pow(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = t_src_scalar(vp, &src[1]); +} -#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \ - SWIZZLE_ZERO, SWIZZLE_ZERO, \ - SWIZZLE_ZERO, SWIZZLE_ZERO, \ - t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4)) +static void t_opcode_mov(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} -#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \ - SWIZZLE_ZERO, SWIZZLE_ZERO, \ - SWIZZLE_ZERO, SWIZZLE_ZERO, \ - t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4)) +#if 1 + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +#else + hw_op = + (src[0].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ONE_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +#endif +} -#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \ - SWIZZLE_ZERO, SWIZZLE_ZERO, \ - SWIZZLE_ZERO, SWIZZLE_ZERO, \ - t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4)) +static void t_opcode_add(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + unsigned long hw_op; -#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \ - SWIZZLE_ONE, SWIZZLE_ONE, \ - SWIZZLE_ONE, SWIZZLE_ONE, \ - t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4)) +#if 1 + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = ONE_SRC_0; + o_inst->src[1] = t_src(vp, &src[0]); + o_inst->src[2] = t_src(vp, &src[1]); +#else + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; -#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \ - SWIZZLE_ONE, SWIZZLE_ONE, \ - SWIZZLE_ONE, SWIZZLE_ONE, \ - t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4)) +#endif +} -#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \ - SWIZZLE_ONE, SWIZZLE_ONE, \ - SWIZZLE_ONE, SWIZZLE_ONE, \ - t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4)) +static void t_opcode_mad(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + unsigned long hw_op; -/* DP4 version seems to trigger some hw peculiarity */ -//#define PREFER_DP4 + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == PROGRAM_TEMPORARY + && src[2].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = t_src(vp, &src[2]); +} -#define FREE_TEMPS() \ - do { \ - if(u_temp_i < vp->num_temporaries) { \ - WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \ - vp->native = GL_FALSE; \ - } \ - u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \ - } while (0) +static void t_opcode_mul(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + unsigned long hw_op; -static void r300TranslateVertexShader(struct r300_vertex_program *vp, - struct prog_instruction *vpi) + // HW mul can take third arg but appears to have some other limitations. + + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + + o_inst->src[2] = ZERO_SRC_1; +} + +static void t_opcode_dp3(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), + t_swizzle(GET_SWZ(src[0].Swizzle, 2)), + SWIZZLE_ZERO, t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | + (src[0].RelAddr << 4); + + o_inst->src[1] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), + SWIZZLE_ZERO, t_src_class(src[1].File), + src[1]. + NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | + (src[1].RelAddr << 4); + + o_inst->src[2] = ZERO_SRC_1; +} + +static void t_opcode_sub(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { - int i, cur_reg = 0; - struct r300_vertprog_instruction *o_inst; - unsigned long operands; - int are_srcs_scalar; unsigned long hw_op; - /* Initial value should be last tmp reg that hw supports. - Strangely enough r300 doesnt mind even though these would be out of range. - Smart enough to realize that it doesnt need it? */ - int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1; - struct prog_src_register src[3]; - vp->pos_end = 0; /* Not supported yet */ - vp->program.length = 0; - /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */ + //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W + +#if 1 + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ONE_SRC_0; + o_inst->src[2] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), + t_src_class(src[1].File), + (!src[1]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[1].RelAddr << 4); +#else + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), + t_src_class(src[1].File), + (!src[1]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[1].RelAddr << 4); + o_inst->src[2] = 0; +#endif +} + +static void t_opcode_abs(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), + t_swizzle(GET_SWZ(src[0].Swizzle, 2)), + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), + t_src_class(src[0].File), + (!src[0]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[0].RelAddr << 4); + o_inst->src[2] = 0; +} + +static void t_opcode_flr(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], int u_temp_i) +{ + /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} + ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i, + t_dst_mask(vpi->DstReg.WriteMask), + VSF_OUT_CLASS_TMP); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; + o_inst++; + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = + MAKE_VSF_SOURCE(u_temp_i, VSF_IN_COMPONENT_X, + VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, + VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, + /* Not 100% sure about this */ + (!src[0]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE + /*VSF_FLAG_ALL */ ); + + o_inst->src[2] = ZERO_SRC_0; + u_temp_i--; +} + +static void t_opcode_lg2(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X} + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[0].RelAddr << 4); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} + +static void t_opcode_lit(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + /* NOTE: Users swizzling might not work. */ + o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0]. + RelAddr << 4); + o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0]. + RelAddr << 4); + o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0]. + RelAddr << 4); +} + +static void t_opcode_dph(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), + t_swizzle(GET_SWZ(src[0].Swizzle, 2)), + VSF_IN_COMPONENT_ONE, t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | + (src[0].RelAddr << 4); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} + +static void t_opcode_xpd(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], int u_temp_i) +{ + /* mul r0, r1.yzxw, r2.zxyw + mad r0, -r2.yzxw, r1.zxyw, r0 + NOTE: might need MAD_2 + */ + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i, + t_dst_mask(vpi->DstReg.WriteMask), + VSF_OUT_CLASS_TMP); + + o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0]. + RelAddr << 4); + + o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w + t_src_class(src[1].File), + src[1]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[1]. + RelAddr << 4); + + o_inst->src[2] = ZERO_SRC_1; + o_inst++; + u_temp_i--; + + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w + t_src_class(src[1].File), + (!src[1]. + NegateBase) ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[1]. + RelAddr << 4); + + o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0]. + RelAddr << 4); + + o_inst->src[2] = + MAKE_VSF_SOURCE(u_temp_i + 1, VSF_IN_COMPONENT_X, + VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, + VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, + VSF_FLAG_NONE); + +} + +static void t_opcode_rcc(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + fprintf(stderr, "Dont know how to handle op %d yet\n", + vpi->Opcode); + _mesa_exit(-1); +} + +static void t_inputs_outputs(struct r300_vertex_program *vp) +{ + int i; + int cur_reg = 0; for (i = 0; i < VERT_ATTRIB_MAX; i++) vp->inputs[i] = -1; @@ -460,7 +898,6 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; } - #if 0 if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { vp->outputs[VERT_RESULT_FOGC] = cur_reg++; @@ -476,12 +913,32 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, vp->outputs[i] = cur_reg++; } } +} +static void r300TranslateVertexShader(struct r300_vertex_program *vp, + struct prog_instruction *vpi) +{ + int i; + struct r300_vertprog_instruction *o_inst; + unsigned long num_operands; + int are_srcs_scalar; + /* Initial value should be last tmp reg that hw supports. + Strangely enough r300 doesnt mind even though these would be out of range. + Smart enough to realize that it doesnt need it? */ + int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1; + struct prog_src_register src[3]; + + vp->pos_end = 0; /* Not supported yet */ + vp->program.length = 0; + /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */ vp->translated = GL_TRUE; vp->native = GL_TRUE; + t_inputs_outputs(vp); + o_inst = vp->program.body.i; for (; vpi->Opcode != OPCODE_END; vpi++, o_inst++) { + FREE_TEMPS(); if (!valid_dst(vp, &vpi->DstReg)) { @@ -490,29 +947,31 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, vpi->DstReg.Index = u_temp_i; } - operands = op_operands(vpi->Opcode); - are_srcs_scalar = operands & SCALAR_FLAG; - operands &= OP_MASK; + num_operands = op_operands(vpi->Opcode) & OP_MASK; + are_srcs_scalar = op_operands(vpi->Opcode) & SCALAR_FLAG; - for (i = 0; i < operands; i++) + /* copy the sources (src) from mesa into a local variable... is this needed? */ + for (i = 0; i < num_operands; i++) { src[i] = vpi->SrcReg[i]; + } - if (operands == 3) { /* TODO: scalars */ + if (num_operands == 3) { /* TODO: scalars */ if (CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2])) { - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, - VSF_FLAG_ALL, + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, + u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); o_inst->src[0] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), + MAKE_VSF_SOURCE(t_src_index + (vp, &src[2]), SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, - t_src_class(src[2].File), - VSF_FLAG_NONE) | (src[2]. - RelAddr << - 4); + t_src_class(src[2]. + File), + VSF_FLAG_NONE) | + (src[2].RelAddr << 4); o_inst->src[1] = ZERO_SRC_2; o_inst->src[2] = ZERO_SRC_2; @@ -523,24 +982,24 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, src[2].RelAddr = 0; u_temp_i--; } - } - if (operands >= 2) { + if (num_operands >= 2) { if (CMP_SRCS(src[1], src[0])) { - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, - VSF_FLAG_ALL, + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, + u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); o_inst->src[0] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), + MAKE_VSF_SOURCE(t_src_index + (vp, &src[0]), SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, - t_src_class(src[0].File), - VSF_FLAG_NONE) | (src[0]. - RelAddr << - 4); + t_src_class(src[0]. + File), + VSF_FLAG_NONE) | + (src[0].RelAddr << 4); o_inst->src[1] = ZERO_SRC_0; o_inst->src[2] = ZERO_SRC_0; @@ -553,508 +1012,115 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, } } - /* These ops need special handling. */ switch (vpi->Opcode) { case OPCODE_POW: - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_POW, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = t_src_scalar(vp, &src[1]); - goto next; - - case OPCODE_MOV: //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} + t_opcode_pow(vp, vpi, o_inst, src); + break; + case OPCODE_MOV: + t_opcode_mov(vp, vpi, o_inst, src); + break; case OPCODE_SWZ: -#if 1 - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; -#else - hw_op = - (src[0].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->op = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = ZERO_SRC_0; -#endif - - goto next; - + t_opcode_mov(vp, vpi, o_inst, src); + break; case OPCODE_ADD: -#if 1 - hw_op = (src[0].File == PROGRAM_TEMPORARY && - src[1].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->op = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = ONE_SRC_0; - o_inst->src[1] = t_src(vp, &src[0]); - o_inst->src[2] = t_src(vp, &src[1]); -#else - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; - -#endif - goto next; - + t_opcode_add(vp, vpi, o_inst, src); + break; case OPCODE_MAD: - hw_op = (src[0].File == PROGRAM_TEMPORARY && - src[1].File == PROGRAM_TEMPORARY && - src[2].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->op = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = t_src(vp, &src[2]); - goto next; - - case OPCODE_MUL: /* HW mul can take third arg but appears to have some other limitations. */ - hw_op = (src[0].File == PROGRAM_TEMPORARY && - src[1].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->op = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - - o_inst->src[2] = ZERO_SRC_1; - goto next; - - case OPCODE_DP3: //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 1)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 2)), - SWIZZLE_ZERO, - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_XYZ : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - - o_inst->src[1] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), - t_swizzle(GET_SWZ - (src[1].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 1)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 2)), - SWIZZLE_ZERO, - t_src_class(src[1].File), - src[1]. - NegateBase ? VSF_FLAG_XYZ : - VSF_FLAG_NONE) | (src[1]. - RelAddr << 4); - - o_inst->src[2] = ZERO_SRC_1; - goto next; - - case OPCODE_SUB: //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W -#if 1 - hw_op = (src[0].File == PROGRAM_TEMPORARY && - src[1].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->op = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), - t_swizzle(GET_SWZ - (src[1].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 1)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 2)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 3)), - t_src_class(src[1].File), - (!src[1]. - NegateBase) ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[1]. - RelAddr << 4); -#else - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), - t_swizzle(GET_SWZ - (src[1].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 1)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 2)), - t_swizzle(GET_SWZ - (src[1].Swizzle, 3)), - t_src_class(src[1].File), - (!src[1]. - NegateBase) ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[1]. - RelAddr << 4); - o_inst->src[2] = 0; -#endif - goto next; - - case OPCODE_ABS: //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 1)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 2)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 3)), - t_src_class(src[0].File), - (!src[0]. - NegateBase) ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[2] = 0; - goto next; - + t_opcode_mad(vp, vpi, o_inst, src); + break; + case OPCODE_MUL: + t_opcode_mul(vp, vpi, o_inst, src); + break; + case OPCODE_DP3: + t_opcode_dp3(vp, vpi, o_inst, src); + break; + case OPCODE_SUB: + t_opcode_sub(vp, vpi, o_inst, src); + break; + case OPCODE_ABS: + t_opcode_abs(vp, vpi, o_inst, src); + break; case OPCODE_FLR: - /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} - ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ - - o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i, - t_dst_mask(vpi->DstReg. - WriteMask), - VSF_OUT_CLASS_TMP); - - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - o_inst++; - - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = MAKE_VSF_SOURCE(u_temp_i, - VSF_IN_COMPONENT_X, - VSF_IN_COMPONENT_Y, - VSF_IN_COMPONENT_Z, - VSF_IN_COMPONENT_W, - VSF_IN_CLASS_TMP, - /* Not 100% sure about this */ - (!src[0]. - NegateBase) ? - VSF_FLAG_ALL : - VSF_FLAG_NONE - /*VSF_FLAG_ALL */ ); - - o_inst->src[2] = ZERO_SRC_0; - u_temp_i--; - goto next; - - case OPCODE_LG2: // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X} - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - goto next; - - case OPCODE_LIT: //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - /* NOTE: Users swizzling might not work. */ - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_src_class(src[0]. - File), - src[0]. - NegateBase ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[0].RelAddr << 4); - o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_src_class(src[0]. - File), - src[0]. - NegateBase ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[0].RelAddr << 4); - o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - t_src_class(src[0]. - File), - src[0]. - NegateBase ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[0].RelAddr << 4); - goto next; - - case OPCODE_DPH: //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), - t_swizzle(GET_SWZ - (src[0].Swizzle, 0)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 1)), - t_swizzle(GET_SWZ - (src[0].Swizzle, 2)), - VSF_IN_COMPONENT_ONE, - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_XYZ : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; - goto next; - + t_opcode_flr(vp, vpi, o_inst, src, /* FIXME */ + u_temp_i); + break; + case OPCODE_LG2: + t_opcode_lg2(vp, vpi, o_inst, src); + break; + case OPCODE_LIT: + t_opcode_lit(vp, vpi, o_inst, src); + break; + case OPCODE_DPH: + t_opcode_dph(vp, vpi, o_inst, src); + break; case OPCODE_XPD: - /* mul r0, r1.yzxw, r2.zxyw - mad r0, -r2.yzxw, r1.zxyw, r0 - NOTE: might need MAD_2 - */ - - o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i, - t_dst_mask(vpi->DstReg. - WriteMask), - VSF_OUT_CLASS_TMP); - - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - t_src_class(src[0]. - File), - src[0]. - NegateBase ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[0].RelAddr << 4); - - o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w - t_src_class(src[1]. - File), - src[1]. - NegateBase ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[1].RelAddr << 4); - - o_inst->src[2] = ZERO_SRC_1; - o_inst++; - u_temp_i--; - - o_inst->op = - MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w - t_src_class(src[1]. - File), - (!src[1]. - NegateBase) ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[1].RelAddr << 4); - - o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - t_src_class(src[0]. - File), - src[0]. - NegateBase ? - VSF_FLAG_ALL : - VSF_FLAG_NONE) | - (src[0].RelAddr << 4); - - o_inst->src[2] = MAKE_VSF_SOURCE(u_temp_i + 1, - VSF_IN_COMPONENT_X, - VSF_IN_COMPONENT_Y, - VSF_IN_COMPONENT_Z, - VSF_IN_COMPONENT_W, - VSF_IN_CLASS_TMP, - VSF_FLAG_NONE); - - goto next; - + t_opcode_xpd(vp, vpi, o_inst, src, /* FIXME */ + u_temp_i); + break; case OPCODE_RCC: - fprintf(stderr, "Dont know how to handle op %d yet\n", - vpi->Opcode); - _mesa_exit(-1); + t_opcode_rcc(vp, vpi, o_inst, src); break; case OPCODE_END: break; - default: - break; - } - o_inst->op = - MAKE_VSF_OP(t_opcode(vpi->Opcode), - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); + /* all other opcodes */ + default: + o_inst->opcode = + MAKE_VSF_OP(t_opcode(vpi->Opcode), + t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); - if (are_srcs_scalar) { - switch (operands) { + switch (num_operands) { case 1: - o_inst->src[0] = t_src_scalar(vp, &src[0]); + if (are_srcs_scalar) { + o_inst->src[0] = + t_src_scalar(vp, &src[0]); + } else { + o_inst->src[0] = + t_src(vp, &src[0]); + } o_inst->src[1] = ZERO_SRC_0; o_inst->src[2] = ZERO_SRC_0; break; - case 2: - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = t_src_scalar(vp, &src[1]); + if (are_srcs_scalar) { + o_inst->src[0] = + t_src_scalar(vp, &src[0]); + o_inst->src[1] = + t_src_scalar(vp, &src[1]); + } else { + o_inst->src[0] = + t_src(vp, &src[0]); + o_inst->src[1] = + t_src(vp, &src[1]); + } o_inst->src[2] = ZERO_SRC_1; break; - case 3: - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = t_src_scalar(vp, &src[1]); - o_inst->src[2] = t_src_scalar(vp, &src[2]); + if (are_srcs_scalar) { + o_inst->src[0] = + t_src_scalar(vp, &src[0]); + o_inst->src[1] = + t_src_scalar(vp, &src[1]); + o_inst->src[2] = + t_src_scalar(vp, &src[2]); + } else { + o_inst->src[0] = + t_src(vp, &src[0]); + o_inst->src[1] = + t_src(vp, &src[1]); + o_inst->src[2] = + t_src(vp, &src[2]); + } break; - default: - fprintf(stderr, - "scalars and op RCC not handled yet"); - _mesa_exit(-1); + assert(0); break; } - } else { - switch (operands) { - case 1: - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - break; - - case 2: - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; - break; - case 3: - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = t_src(vp, &src[2]); - break; - - default: - fprintf(stderr, - "scalars and op RCC not handled yet"); - _mesa_exit(-1); - break; - } + break; } - next:; } /* Will most likely segfault before we get here... fix later. */ @@ -1064,6 +1130,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, return; } vp->program.length = (o_inst - vp->program.body.i) * 4; + #if 0 fprintf(stderr, "hw program:\n"); for (i = 0; i < vp->program.length; i++) @@ -1077,7 +1144,8 @@ static void position_invariant(struct gl_program *prog) struct gl_program_parameter_list *paramList; int i; - gl_state_index tokens[STATE_LENGTH] = { STATE_MVP_MATRIX, 0, 0, 0, 0 }; + gl_state_index tokens[STATE_LENGTH] = + { STATE_MVP_MATRIX, 0, 0, 0, 0 }; /* tokens[4] = matrix modifier */ #ifdef PREFER_DP4 @@ -1171,8 +1239,8 @@ static void insert_wpos(struct r300_vertex_program *vp, prog->NumInstructions - 1); /* END */ _mesa_copy_instructions(&vpi[prog->NumInstructions + 1], - &prog->Instructions[prog->NumInstructions - 1], - 1); + &prog->Instructions[prog->NumInstructions - + 1], 1); vpi_insert = &vpi[prog->NumInstructions - 1]; vpi_insert[i].Opcode = OPCODE_MOV; @@ -1218,8 +1286,8 @@ static void pos_as_texcoord(struct r300_vertex_program *vp, prog->NumTemporaries++; for (vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++) { - if (vpi->DstReg.File == PROGRAM_OUTPUT && - vpi->DstReg.Index == VERT_RESULT_HPOS) { + if (vpi->DstReg.File == PROGRAM_OUTPUT + && vpi->DstReg.Index == VERT_RESULT_HPOS) { vpi->DstReg.File = PROGRAM_TEMPORARY; vpi->DstReg.Index = tempregi; } @@ -1235,20 +1303,18 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key vp = _mesa_calloc(sizeof(*vp)); _mesa_memcpy(&vp->key, wanted_key, sizeof(vp->key)); - vp->wpos_idx = wpos_idx; if (mesa_vp->IsPositionInvariant) { position_invariant(&mesa_vp->Base); } - if (wpos_idx > -1) + if (wpos_idx > -1) { pos_as_texcoord(vp, &mesa_vp->Base); + } assert(mesa_vp->Base.NumInstructions); - vp->num_temporaries = mesa_vp->Base.NumTemporaries; - r300TranslateVertexShader(vp, mesa_vp->Base.Instructions); return vp; @@ -1264,7 +1330,8 @@ void r300SelectVertexShader(r300ContextPtr r300) struct r300_vertex_program *vp; GLint wpos_idx; - vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current; + vpc = + (struct r300_vertex_program_cont *)ctx->VertexProgram._Current; InputsRead = ctx->FragmentProgram._Current->Base.InputsRead; wpos_idx = -1; @@ -1289,8 +1356,8 @@ void r300SelectVertexShader(r300ContextPtr r300) } for (vp = vpc->progs; vp; vp = vp->next) - if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) == - 0) { + if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) + == 0) { r300->selected_vp = vp; return; } @@ -1301,3 +1368,5 @@ void r300SelectVertexShader(r300ContextPtr r300) vpc->progs = vp; r300->selected_vp = vp; } + +/* vim: set foldenable foldmethod=marker : */ diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h index 0da158cc551..2d399e243a8 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.h +++ b/src/mesa/drivers/dri/r300/r300_vertprog.h @@ -4,7 +4,7 @@ #include "r300_reg.h" struct r300_vertprog_instruction { - GLuint op; + GLuint opcode; GLuint src[3]; }; -- cgit v1.2.3 From d0b3f3ce817700286e059bb24caa12b09e7ec954 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 06:27:29 +0000 Subject: r300: Corrected indenting in r300_vertprog.c. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 97 ++++++++++++++++--------------- 1 file changed, 50 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index e3278d7ba19..9c125136083 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -417,9 +417,9 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, } static void t_opcode_pow(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { o_inst->opcode = MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg), @@ -431,9 +431,9 @@ static void t_opcode_pow(struct r300_vertex_program *vp, } static void t_opcode_mov(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} @@ -462,9 +462,9 @@ static void t_opcode_mov(struct r300_vertex_program *vp, } static void t_opcode_add(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -494,9 +494,9 @@ static void t_opcode_add(struct r300_vertex_program *vp, } static void t_opcode_mad(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -516,9 +516,9 @@ static void t_opcode_mad(struct r300_vertex_program *vp, } static void t_opcode_mul(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -540,9 +540,9 @@ static void t_opcode_mul(struct r300_vertex_program *vp, } static void t_opcode_dp3(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} @@ -575,9 +575,9 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, } static void t_opcode_sub(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -627,9 +627,9 @@ static void t_opcode_sub(struct r300_vertex_program *vp, } static void t_opcode_abs(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W @@ -653,9 +653,9 @@ static void t_opcode_abs(struct r300_vertex_program *vp, } static void t_opcode_flr(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], int u_temp_i) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], int u_temp_i) { /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ @@ -690,9 +690,9 @@ static void t_opcode_flr(struct r300_vertex_program *vp, } static void t_opcode_lg2(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X} @@ -716,9 +716,9 @@ static void t_opcode_lg2(struct r300_vertex_program *vp, } static void t_opcode_lit(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} @@ -757,9 +757,9 @@ static void t_opcode_lit(struct r300_vertex_program *vp, } static void t_opcode_dph(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} o_inst->opcode = @@ -781,9 +781,9 @@ static void t_opcode_dph(struct r300_vertex_program *vp, } static void t_opcode_xpd(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], int u_temp_i) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], int u_temp_i) { /* mul r0, r1.yzxw, r2.zxyw mad r0, -r2.yzxw, r1.zxyw, r0 @@ -853,9 +853,9 @@ static void t_opcode_xpd(struct r300_vertex_program *vp, } static void t_opcode_rcc(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) { fprintf(stderr, "Dont know how to handle op %d yet\n", vpi->Opcode); @@ -885,17 +885,20 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) } if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) { - vp->outputs[VERT_RESULT_COL1] = vp->outputs[VERT_RESULT_COL0] + 1; + vp->outputs[VERT_RESULT_COL1] = + vp->outputs[VERT_RESULT_COL0] + 1; cur_reg = vp->outputs[VERT_RESULT_COL1] + 1; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { - vp->outputs[VERT_RESULT_BFC0] = vp->outputs[VERT_RESULT_COL0] + 2; + vp->outputs[VERT_RESULT_BFC0] = + vp->outputs[VERT_RESULT_COL0] + 2; cur_reg = vp->outputs[VERT_RESULT_BFC0] + 1; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { - vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; + vp->outputs[VERT_RESULT_BFC1] = + vp->outputs[VERT_RESULT_COL0] + 3; cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; } #if 0 @@ -1042,7 +1045,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, break; case OPCODE_FLR: t_opcode_flr(vp, vpi, o_inst, src, /* FIXME */ - u_temp_i); + u_temp_i); break; case OPCODE_LG2: t_opcode_lg2(vp, vpi, o_inst, src); @@ -1055,7 +1058,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, break; case OPCODE_XPD: t_opcode_xpd(vp, vpi, o_inst, src, /* FIXME */ - u_temp_i); + u_temp_i); break; case OPCODE_RCC: t_opcode_rcc(vp, vpi, o_inst, src); -- cgit v1.2.3 From ddb74cb443913a159ec800891710f18d4700d398 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 06:33:53 +0000 Subject: r300: Clean up the vertex program maximum length check. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 9c125136083..1fea88a8539 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1126,13 +1126,11 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, } } - /* Will most likely segfault before we get here... fix later. */ - if (o_inst - vp->program.body.i >= VSF_MAX_FRAGMENT_LENGTH / 4) { + vp->program.length = (o_inst - vp->program.body.i) * 4; + if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) { vp->program.length = 0; vp->native = GL_FALSE; - return; } - vp->program.length = (o_inst - vp->program.body.i) * 4; #if 0 fprintf(stderr, "hw program:\n"); -- cgit v1.2.3 From 87855fb32cf7df0162720fc71976d3d23c0dbba6 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 06:38:12 +0000 Subject: r300: Added a function for vertex program default opcode translation. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 109 ++++++++++++++---------------- 1 file changed, 52 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 1fea88a8539..d960419240f 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -862,6 +862,55 @@ static void t_opcode_rcc(struct r300_vertex_program *vp, _mesa_exit(-1); } +static void t_opcode_default(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], + int num_operands, int are_srcs_scalar) +{ + o_inst->opcode = + MAKE_VSF_OP(t_opcode(vpi->Opcode), + t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + switch (num_operands) { + case 1: + if (are_srcs_scalar) { + o_inst->src[0] = t_src_scalar(vp, &src[0]); + } else { + o_inst->src[0] = t_src(vp, &src[0]); + } + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; + break; + case 2: + if (are_srcs_scalar) { + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = t_src_scalar(vp, &src[1]); + } else { + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + } + o_inst->src[2] = ZERO_SRC_1; + break; + case 3: + if (are_srcs_scalar) { + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = t_src_scalar(vp, &src[1]); + o_inst->src[2] = t_src_scalar(vp, &src[2]); + } else { + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = t_src(vp, &src[2]); + } + break; + default: + assert(0); + break; + } +} + static void t_inputs_outputs(struct r300_vertex_program *vp) { int i; @@ -1064,64 +1113,11 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, t_opcode_rcc(vp, vpi, o_inst, src); break; case OPCODE_END: + /* empty */ break; - - /* all other opcodes */ default: - o_inst->opcode = - MAKE_VSF_OP(t_opcode(vpi->Opcode), - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - switch (num_operands) { - case 1: - if (are_srcs_scalar) { - o_inst->src[0] = - t_src_scalar(vp, &src[0]); - } else { - o_inst->src[0] = - t_src(vp, &src[0]); - } - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - break; - case 2: - if (are_srcs_scalar) { - o_inst->src[0] = - t_src_scalar(vp, &src[0]); - o_inst->src[1] = - t_src_scalar(vp, &src[1]); - } else { - o_inst->src[0] = - t_src(vp, &src[0]); - o_inst->src[1] = - t_src(vp, &src[1]); - } - o_inst->src[2] = ZERO_SRC_1; - break; - case 3: - if (are_srcs_scalar) { - o_inst->src[0] = - t_src_scalar(vp, &src[0]); - o_inst->src[1] = - t_src_scalar(vp, &src[1]); - o_inst->src[2] = - t_src_scalar(vp, &src[2]); - } else { - o_inst->src[0] = - t_src(vp, &src[0]); - o_inst->src[1] = - t_src(vp, &src[1]); - o_inst->src[2] = - t_src(vp, &src[2]); - } - break; - default: - assert(0); - break; - } - + t_opcode_default(vp, vpi, o_inst, src, + num_operands, are_srcs_scalar); break; } } @@ -1131,7 +1127,6 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, vp->program.length = 0; vp->native = GL_FALSE; } - #if 0 fprintf(stderr, "hw program:\n"); for (i = 0; i < vp->program.length; i++) -- cgit v1.2.3 From 72581241a85081d6103158c484c18d356935b46c Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 07:12:29 +0000 Subject: r300: Make sure the modified value of u_temp_i is respected. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index d960419240f..dfba747e726 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -655,13 +655,13 @@ static void t_opcode_abs(struct r300_vertex_program *vp, static void t_opcode_flr(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], int u_temp_i) + struct prog_src_register src[3], int *u_temp_i) { /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i, + MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); @@ -677,7 +677,7 @@ static void t_opcode_flr(struct r300_vertex_program *vp, o_inst->src[0] = t_src(vp, &src[0]); o_inst->src[1] = - MAKE_VSF_SOURCE(u_temp_i, VSF_IN_COMPONENT_X, + MAKE_VSF_SOURCE(*u_temp_i, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, /* Not 100% sure about this */ @@ -686,7 +686,7 @@ static void t_opcode_flr(struct r300_vertex_program *vp, /*VSF_FLAG_ALL */ ); o_inst->src[2] = ZERO_SRC_0; - u_temp_i--; + (*u_temp_i)--; } static void t_opcode_lg2(struct r300_vertex_program *vp, @@ -783,7 +783,7 @@ static void t_opcode_dph(struct r300_vertex_program *vp, static void t_opcode_xpd(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], int u_temp_i) + struct prog_src_register src[3], int *u_temp_i) { /* mul r0, r1.yzxw, r2.zxyw mad r0, -r2.yzxw, r1.zxyw, r0 @@ -791,7 +791,7 @@ static void t_opcode_xpd(struct r300_vertex_program *vp, */ o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i, + MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); @@ -817,7 +817,7 @@ static void t_opcode_xpd(struct r300_vertex_program *vp, o_inst->src[2] = ZERO_SRC_1; o_inst++; - u_temp_i--; + (*u_temp_i)--; o_inst->opcode = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg), @@ -845,7 +845,7 @@ static void t_opcode_xpd(struct r300_vertex_program *vp, RelAddr << 4); o_inst->src[2] = - MAKE_VSF_SOURCE(u_temp_i + 1, VSF_IN_COMPONENT_X, + MAKE_VSF_SOURCE(*u_temp_i + 1, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, VSF_FLAG_NONE); @@ -1093,8 +1093,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, t_opcode_abs(vp, vpi, o_inst, src); break; case OPCODE_FLR: - t_opcode_flr(vp, vpi, o_inst, src, /* FIXME */ - u_temp_i); + /* FIXME */ + t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); break; case OPCODE_LG2: t_opcode_lg2(vp, vpi, o_inst, src); @@ -1106,8 +1106,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, t_opcode_dph(vp, vpi, o_inst, src); break; case OPCODE_XPD: - t_opcode_xpd(vp, vpi, o_inst, src, /* FIXME */ - u_temp_i); + /* FIXME */ + t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); break; case OPCODE_RCC: t_opcode_rcc(vp, vpi, o_inst, src); -- cgit v1.2.3 From aa9d77ca3c89c2b8119149ff3d49eec226dc80d1 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 07:17:22 +0000 Subject: r300: Removed Vim modeline I left in the file by mistake. :-) --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index dfba747e726..b73d215b588 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1364,5 +1364,3 @@ void r300SelectVertexShader(r300ContextPtr r300) vpc->progs = vp; r300->selected_vp = vp; } - -/* vim: set foldenable foldmethod=marker : */ -- cgit v1.2.3 From 03105d7b3edb5ab7c77925fdfce832882a7191ab Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 11:34:40 +0000 Subject: r300: Corrected position bug with position invariant option. Bug #11594. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index b73d215b588..7d8ac4c8c13 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1349,6 +1349,7 @@ void r300SelectVertexShader(r300ContextPtr r300) if (vpc->mesa_program.IsPositionInvariant) { /* we wan't position don't we ? */ wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS); + wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS); } for (vp = vpc->progs; vp; vp = vp->next) -- cgit v1.2.3 From 81c333adbcb5c853d2f9e864f701080279977ac6 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 12:21:38 +0000 Subject: r300: Enable the vertprog point size again. --- src/mesa/drivers/dri/r300/r300_emit.c | 2 +- src/mesa/drivers/dri/r300/r300_vertprog.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index 6da22f652f3..424bf44e595 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -308,10 +308,10 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten) #if 0 if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ; +#endif if (OutputsWritten & (1 << VERT_RESULT_PSIZ)) ret |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; -#endif return ret; } diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 7d8ac4c8c13..313d0b28cf2 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -924,11 +924,14 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) assert(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)); - /* Assign outputs */ if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) { vp->outputs[VERT_RESULT_HPOS] = cur_reg++; } + if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { + vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; + } + if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) { vp->outputs[VERT_RESULT_COL0] = cur_reg++; } @@ -954,10 +957,6 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { vp->outputs[VERT_RESULT_FOGC] = cur_reg++; } - - if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) { - vp->outputs[VERT_RESULT_PSIZ] = cur_reg++; - } #endif for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) { -- cgit v1.2.3 From 4013382ea2ab08b7904ad908f7b66d2a737b59da Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 15:39:12 +0000 Subject: r300: Added the clip plane upload defines. --- src/mesa/drivers/dri/r300/r300_reg.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index e59919be493..44b54900aa6 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -282,7 +282,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define R300_VAP_PVS_UPLOAD_ADDRESS 0x2200 # define R300_PVS_UPLOAD_PROGRAM 0x00000000 +/* gap */ # define R300_PVS_UPLOAD_PARAMETERS 0x00000200 +/* gap */ +# define R300_PVS_UPLOAD_CLIP_PLANE0 0x00000400 +# define R300_PVS_UPLOAD_CLIP_PLANE1 0x00000401 +# define R300_PVS_UPLOAD_CLIP_PLANE2 0x00000402 +# define R300_PVS_UPLOAD_CLIP_PLANE3 0x00000403 +# define R300_PVS_UPLOAD_CLIP_PLANE4 0x00000404 +# define R300_PVS_UPLOAD_CLIP_PLANE5 0x00000405 # define R300_PVS_UPLOAD_POINTSIZE 0x00000406 /* gap */ -- cgit v1.2.3 From d895c5a08f18c8b550631f7c735c2dafaf8ec785 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 15:42:16 +0000 Subject: r300: Use the R300_PVS_UPLOAD_* defines. --- src/mesa/drivers/dri/r300/r300_context.h | 9 --------- src/mesa/drivers/dri/r300/r300_reg.h | 15 +++++++++++++++ src/mesa/drivers/dri/r300/r300_state.c | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 00fa498e5fe..0349bac9a26 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -572,15 +572,6 @@ struct r300_vertex_shader_fragment { } body; }; -#define VSF_DEST_PROGRAM 0x0 -#define VSF_DEST_MATRIX0 0x200 -#define VSF_DEST_MATRIX1 0x204 -#define VSF_DEST_MATRIX2 0x208 -#define VSF_DEST_VECTOR0 0x20c -#define VSF_DEST_VECTOR1 0x20d -#define VSF_DEST_UNKNOWN1 0x400 -#define VSF_DEST_UNKNOWN2 0x406 - struct r300_vertex_shader_state { struct r300_vertex_shader_fragment program; }; diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index 44b54900aa6..1baa74c5269 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -293,6 +293,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_PVS_UPLOAD_CLIP_PLANE5 0x00000405 # define R300_PVS_UPLOAD_POINTSIZE 0x00000406 +/* + * These are obsolete defines form r300_context.h, but they might give some + * clues when investigating the addresses further... + */ +#if 0 +#define VSF_DEST_PROGRAM 0x0 +#define VSF_DEST_MATRIX0 0x200 +#define VSF_DEST_MATRIX1 0x204 +#define VSF_DEST_MATRIX2 0x208 +#define VSF_DEST_VECTOR0 0x20c +#define VSF_DEST_VECTOR1 0x20d +#define VSF_DEST_UNKNOWN1 0x400 +#define VSF_DEST_UNKNOWN2 0x406 +#endif + /* gap */ #define R300_VAP_PVS_UPLOAD_DATA 0x2208 diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index adf736f756a..6789efd4281 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1576,7 +1576,7 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa) prog->program.length = program_end * 4; - r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); + r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program)); inst_count = (prog->program.length / 4) - 1; R300_STATECHANGE(rmesa, pvs); @@ -1610,7 +1610,7 @@ static void r300SetupRealVertexProgram(r300ContextPtr rmesa) bump_vpu_count(rmesa->hw.vpp.cmd, param_count); param_count /= 4; - r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program)); + r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program)); inst_count = (prog->program.length / 4) - 1; R300_STATECHANGE(rmesa, pvs); -- cgit v1.2.3 From fb3b9060d48934ca4faa72e966c00aee627ce96d Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 18:09:30 +0200 Subject: fix segfault with i915 drivers in swrast drawpixels path when resizing windows --- src/mesa/drivers/dri/i915/intel_pixel.c | 6 ++++++ src/mesa/drivers/dri/i915tex/intel_pixel_draw.c | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c index d175870a0c5..c3030d42b04 100644 --- a/src/mesa/drivers/dri/i915/intel_pixel.c +++ b/src/mesa/drivers/dri/i915/intel_pixel.c @@ -450,10 +450,16 @@ intelDrawPixels( GLcontext *ctx, * wise happily run the fragment program on each pixel in the image). */ struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current; + /* can't just set current frag prog to 0 here as on buffer resize + we'll get new state checks which will segfault. Remains a hack. */ ctx->FragmentProgram._Current = NULL; + ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE; + ctx->FragmentProgram._Active = GL_FALSE; _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels ); ctx->FragmentProgram._Current = fpSave; + ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; + ctx->FragmentProgram._Active = GL_TRUE; } else { _swrast_DrawPixels( ctx, x, y, width, height, format, type, diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c index 77c67c821eb..e4e57cb3a7e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c @@ -370,10 +370,16 @@ intelDrawPixels(GLcontext * ctx, * wise happily run the fragment program on each pixel in the image). */ struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current; + /* can't just set current frag prog to 0 here as on buffer resize + we'll get new state checks which will segfault. Remains a hack. */ ctx->FragmentProgram._Current = NULL; + ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE; + ctx->FragmentProgram._Active = GL_FALSE; _swrast_DrawPixels( ctx, x, y, width, height, format, type, unpack, pixels ); ctx->FragmentProgram._Current = fpSave; + ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE; + ctx->FragmentProgram._Active = GL_TRUE; } else { _swrast_DrawPixels( ctx, x, y, width, height, format, type, -- cgit v1.2.3 From cbfe29cdee5d338a25f13abbbb191b80428d05c8 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 16 Jul 2007 18:21:36 +0200 Subject: fix bogus fb/drawable information the framebuffer objects attached to drawables can have invalidate state associated with them, since for the window framebuffer this is per-context state and not per-fbo state. Since drivers rely on that information (otherwise would need to check if currently the window-framebuffer is bound in a lot of places) fix it up in _mesa_make_current (ugly). (Brought over from i915tex_privbuffers, where it fixes xdemos/wincopy when switching to front buffer rendering.) --- src/mesa/main/context.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 21adcf32106..2ad1badac70 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1495,9 +1495,20 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); + /* fix up the fb fields - these will end up wrong otherwise + if the DRIdrawable changes, and someone may rely on them. + */ + /* What a mess!?! */ + int i; + GLenum buffers[MAX_DRAW_BUFFERS]; + for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { + buffers[i] = newCtx->Color.DrawBuffer[i]; + } + _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL); } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); + _mesa_ReadBuffer(newCtx->Pixel.ReadBuffer); } newCtx->NewState |= _NEW_BUFFERS; -- cgit v1.2.3 From cc85860ccb44ac0a5a08217b9c9ba3fcef3b3a52 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 16:17:50 +0000 Subject: r300: Reorder the vertprog code to the ARB specification. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 427 ++++++++++++++++++------------ 1 file changed, 255 insertions(+), 172 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 313d0b28cf2..da2c6dbcd5b 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -416,49 +416,68 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, return GL_TRUE; } -static void t_opcode_pow(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) -{ - o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = t_src_scalar(vp, &src[1]); -} +/* + * Instruction Inputs Output Description + * ----------- ------ ------ -------------------------------- + * ABS v v absolute value + * ADD v,v v add + * ARL s a address register load + * DP3 v,v ssss 3-component dot product + * DP4 v,v ssss 4-component dot product + * DPH v,v ssss homogeneous dot product + * DST v,v v distance vector + * EX2 s ssss exponential base 2 + * EXP s v exponential base 2 (approximate) + * FLR v v floor + * FRC v v fraction + * LG2 s ssss logarithm base 2 + * LIT v v compute light coefficients + * LOG s v logarithm base 2 (approximate) + * MAD v,v,v v multiply and add + * MAX v,v v maximum + * MIN v,v v minimum + * MOV v v move + * MUL v,v v multiply + * POW s,s ssss exponentiate + * RCP s ssss reciprocal + * RSQ s ssss reciprocal square root + * SGE v,v v set on greater than or equal + * SLT v,v v set on less than + * SUB v,v v subtract + * SWZ v v extended swizzle + * XPD v,v v cross product + * + * Table X.5: Summary of vertex program instructions. "v" indicates a + * floating-point vector input or output, "s" indicates a floating-point + * scalar input, "ssss" indicates a scalar output replicated across a + * 4-component result vector, and "a" indicates a single address register + * component. + */ -static void t_opcode_mov(struct r300_vertex_program *vp, +static void t_opcode_abs(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, struct prog_src_register src[3]) { - //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} + //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W -#if 1 o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; -#else - hw_op = - (src[0].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - o_inst->opcode = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = ZERO_SRC_0; -#endif + o_inst->src[1] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), + t_swizzle(GET_SWZ(src[0].Swizzle, 2)), + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), + t_src_class(src[0].File), + (!src[0]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[0].RelAddr << 4); + o_inst->src[2] = 0; } static void t_opcode_add(struct r300_vertex_program *vp, @@ -493,51 +512,7 @@ static void t_opcode_add(struct r300_vertex_program *vp, #endif } -static void t_opcode_mad(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) -{ - unsigned long hw_op; - - hw_op = (src[0].File == PROGRAM_TEMPORARY - && src[1].File == PROGRAM_TEMPORARY - && src[2].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->opcode = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = t_src(vp, &src[2]); -} - -static void t_opcode_mul(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) -{ - unsigned long hw_op; - - // HW mul can take third arg but appears to have some other limitations. - - hw_op = (src[0].File == PROGRAM_TEMPORARY - && src[1].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->opcode = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - - o_inst->src[2] = ZERO_SRC_1; -} +/* TODO: ARL */ static void t_opcode_dp3(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -574,84 +549,38 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, o_inst->src[2] = ZERO_SRC_1; } -static void t_opcode_sub(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) -{ - unsigned long hw_op; - - //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W - -#if 1 - hw_op = (src[0].File == PROGRAM_TEMPORARY - && src[1].File == - PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : - R300_VPI_OUT_OP_MAD; - - o_inst->opcode = - MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), - t_swizzle(GET_SWZ(src[1].Swizzle, 1)), - t_swizzle(GET_SWZ(src[1].Swizzle, 2)), - t_swizzle(GET_SWZ(src[1].Swizzle, 3)), - t_src_class(src[1].File), - (!src[1]. - NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | - (src[1].RelAddr << 4); -#else - o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); +/* TODO: DP4 */ - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), - t_swizzle(GET_SWZ(src[1].Swizzle, 1)), - t_swizzle(GET_SWZ(src[1].Swizzle, 2)), - t_swizzle(GET_SWZ(src[1].Swizzle, 3)), - t_src_class(src[1].File), - (!src[1]. - NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | - (src[1].RelAddr << 4); - o_inst->src[2] = 0; -#endif -} - -static void t_opcode_abs(struct r300_vertex_program *vp, +static void t_opcode_dph(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, struct prog_src_register src[3]) { - //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W - + //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), + MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), - t_src_class(src[0].File), - (!src[0]. - NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + VSF_IN_COMPONENT_ONE, t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[2] = 0; + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; } +/* TODO: DST */ + +/* TODO: EX2 */ + +/* TODO: EXP */ + static void t_opcode_flr(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, @@ -689,6 +618,8 @@ static void t_opcode_flr(struct r300_vertex_program *vp, (*u_temp_i)--; } +/* TODO: FRC */ + static void t_opcode_lg2(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, @@ -756,30 +687,165 @@ static void t_opcode_lit(struct r300_vertex_program *vp, RelAddr << 4); } -static void t_opcode_dph(struct r300_vertex_program *vp, +/* TODO: LOG */ + +static void t_opcode_mad(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, struct prog_src_register src[3]) { - //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} + unsigned long hw_op; + + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == PROGRAM_TEMPORARY + && src[2].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + o_inst->opcode = - MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = t_src(vp, &src[2]); +} - o_inst->src[0] = - MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), - t_swizzle(GET_SWZ(src[0].Swizzle, 2)), - VSF_IN_COMPONENT_ONE, t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | - (src[0].RelAddr << 4); +/* TODO: MAX */ + +/* TODO: MIN */ + +static void t_opcode_mov(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} + +#if 1 + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +#else + hw_op = + (src[0].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ONE_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +#endif +} + +static void t_opcode_mul(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + unsigned long hw_op; + + // HW mul can take third arg but appears to have some other limitations. + + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; } +static void t_opcode_pow(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = t_src_scalar(vp, &src[1]); +} + +/* TODO: RCP */ + +/* TODO: RSQ */ + +/* TODO: SGE */ + +/* TODO: SLT */ + +static void t_opcode_sub(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + unsigned long hw_op; + + //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W + +#if 1 + hw_op = (src[0].File == PROGRAM_TEMPORARY + && src[1].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ONE_SRC_0; + o_inst->src[2] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), + t_src_class(src[1].File), + (!src[1]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[1].RelAddr << 4); +#else + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = + MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), + t_src_class(src[1].File), + (!src[1]. + NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | + (src[1].RelAddr << 4); + o_inst->src[2] = 0; +#endif +} + +/* TODO: SWZ */ + static void t_opcode_xpd(struct r300_vertex_program *vp, struct prog_instruction *vpi, struct r300_vertprog_instruction *o_inst, @@ -1064,56 +1130,73 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, } switch (vpi->Opcode) { - case OPCODE_POW: - t_opcode_pow(vp, vpi, o_inst, src); - break; - case OPCODE_MOV: - t_opcode_mov(vp, vpi, o_inst, src); - break; - case OPCODE_SWZ: - t_opcode_mov(vp, vpi, o_inst, src); + case OPCODE_ABS: + t_opcode_abs(vp, vpi, o_inst, src); break; case OPCODE_ADD: t_opcode_add(vp, vpi, o_inst, src); break; - case OPCODE_MAD: - t_opcode_mad(vp, vpi, o_inst, src); - break; - case OPCODE_MUL: - t_opcode_mul(vp, vpi, o_inst, src); - break; + /* TODO: ARL */ case OPCODE_DP3: t_opcode_dp3(vp, vpi, o_inst, src); break; - case OPCODE_SUB: - t_opcode_sub(vp, vpi, o_inst, src); - break; - case OPCODE_ABS: - t_opcode_abs(vp, vpi, o_inst, src); + /* TODO: DP4 */ + case OPCODE_DPH: + t_opcode_dph(vp, vpi, o_inst, src); break; + /* TODO: DST */ + /* TODO: EX2 */ + /* TODO: EXP */ case OPCODE_FLR: /* FIXME */ t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); break; + /* TODO: FRC */ case OPCODE_LG2: t_opcode_lg2(vp, vpi, o_inst, src); break; case OPCODE_LIT: t_opcode_lit(vp, vpi, o_inst, src); break; - case OPCODE_DPH: - t_opcode_dph(vp, vpi, o_inst, src); + /* TODO: LOG */ + case OPCODE_MAD: + t_opcode_mad(vp, vpi, o_inst, src); + break; + /* TODO: MAX */ + /* TODO: MIN */ + case OPCODE_MOV: + t_opcode_mov(vp, vpi, o_inst, src); + break; + case OPCODE_MUL: + t_opcode_mul(vp, vpi, o_inst, src); + break; + case OPCODE_POW: + t_opcode_pow(vp, vpi, o_inst, src); + break; + /* TODO: RCP */ + /* TODO: RSQ */ + /* TODO: SGE */ + /* TODO: SLT */ + case OPCODE_SUB: + t_opcode_sub(vp, vpi, o_inst, src); break; + case OPCODE_SWZ: + t_opcode_mov(vp, vpi, o_inst, src); + break; + /* TODO: SWZ */ case OPCODE_XPD: /* FIXME */ t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); break; + case OPCODE_RCC: t_opcode_rcc(vp, vpi, o_inst, src); break; + case OPCODE_END: /* empty */ break; + default: t_opcode_default(vp, vpi, o_inst, src, num_operands, are_srcs_scalar); -- cgit v1.2.3 From 39766010cd35b1c58ce8f03b3679b20398eacb1b Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 16:21:21 +0000 Subject: Revert "r300: Gracefully exit after GART memory is exhausted." This reverts commit 9457bf62bbba3b9226ebbbea5dc7798ca22485f6. Causes the X server to die with Compiz and Beryl. --- src/mesa/drivers/dri/r300/r300_mem.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_mem.c b/src/mesa/drivers/dri/r300/r300_mem.c index a66508bdcdb..f8f9d4fcdf1 100644 --- a/src/mesa/drivers/dri/r300/r300_mem.c +++ b/src/mesa/drivers/dri/r300/r300_mem.c @@ -208,10 +208,23 @@ int r300_mem_alloc(r300ContextPtr rmesa, int alignment, int size) drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc, sizeof(alloc)); if (ret) { +#if 0 + WARN_ONCE("Ran out of mem!\n"); + r300FlushCmdBuf(rmesa, __FUNCTION__); + //usleep(100); + tries2++; + tries = 0; + if (tries2 > 100) { + WARN_ONCE("Ran out of GART memory!\n"); + exit(1); + } + goto again; +#else WARN_ONCE ("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n", size); - exit(1); + return 0; +#endif } i = free; -- cgit v1.2.3 From 15f1609922d727f722a6d319c7df579b3ef77ed2 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 19:09:29 +0000 Subject: r300: More vertprog rework; give each opcode it's own function. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 368 ++++++++++++++++++++---------- 1 file changed, 250 insertions(+), 118 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index da2c6dbcd5b..781c5602aa4 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -29,6 +29,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * \file * * \author Aapo Tahkola + * + * \author Oliver McFadden */ #include "glheader.h" @@ -360,36 +362,6 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp, (src->RelAddr << 4); } -static unsigned long t_opcode(enum prog_opcode opcode) -{ - - switch (opcode) { - /* *INDENT-OFF* */ - case OPCODE_ARL: return R300_VPI_OUT_OP_ARL; - case OPCODE_DST: return R300_VPI_OUT_OP_DST; - case OPCODE_EX2: return R300_VPI_OUT_OP_EX2; - case OPCODE_EXP: return R300_VPI_OUT_OP_EXP; - case OPCODE_FRC: return R300_VPI_OUT_OP_FRC; - case OPCODE_LG2: return R300_VPI_OUT_OP_LG2; - case OPCODE_LOG: return R300_VPI_OUT_OP_LOG; - case OPCODE_MAX: return R300_VPI_OUT_OP_MAX; - case OPCODE_MIN: return R300_VPI_OUT_OP_MIN; - case OPCODE_MUL: return R300_VPI_OUT_OP_MUL; - case OPCODE_RCP: return R300_VPI_OUT_OP_RCP; - case OPCODE_RSQ: return R300_VPI_OUT_OP_RSQ; - case OPCODE_SGE: return R300_VPI_OUT_OP_SGE; - case OPCODE_SLT: return R300_VPI_OUT_OP_SLT; - case OPCODE_DP4: return R300_VPI_OUT_OP_DOT; - /* *INDENT-ON* */ - - default: - fprintf(stderr, "%s: Should not be called with opcode %d!", - __FUNCTION__, opcode); - } - _mesa_exit(-1); - return 0; -} - static unsigned long op_operands(enum prog_opcode opcode) { int i; @@ -512,7 +484,13 @@ static void t_opcode_add(struct r300_vertex_program *vp, #endif } -/* TODO: ARL */ +static void t_opcode_arl(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + assert(0); +} static void t_opcode_dp3(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -549,7 +527,20 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, o_inst->src[2] = ZERO_SRC_1; } -/* TODO: DP4 */ +static void t_opcode_dp4(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} static void t_opcode_dph(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -575,11 +566,50 @@ static void t_opcode_dph(struct r300_vertex_program *vp, o_inst->src[2] = ZERO_SRC_1; } -/* TODO: DST */ +static void t_opcode_dst(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} -/* TODO: EX2 */ +static void t_opcode_ex2(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); -/* TODO: EXP */ + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} + +static void t_opcode_exp(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} static void t_opcode_flr(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -618,7 +648,20 @@ static void t_opcode_flr(struct r300_vertex_program *vp, (*u_temp_i)--; } -/* TODO: FRC */ +static void t_opcode_frc(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} static void t_opcode_lg2(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -687,7 +730,20 @@ static void t_opcode_lit(struct r300_vertex_program *vp, RelAddr << 4); } -/* TODO: LOG */ +static void t_opcode_log(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} static void t_opcode_mad(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -711,9 +767,35 @@ static void t_opcode_mad(struct r300_vertex_program *vp, o_inst->src[2] = t_src(vp, &src[2]); } -/* TODO: MAX */ +static void t_opcode_max(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} + +static void t_opcode_min(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); -/* TODO: MIN */ + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} static void t_opcode_mov(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -784,13 +866,65 @@ static void t_opcode_pow(struct r300_vertex_program *vp, o_inst->src[2] = t_src_scalar(vp, &src[1]); } -/* TODO: RCP */ +static void t_opcode_rcp(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} + +static void t_opcode_rsq(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src_scalar(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +} + +static void t_opcode_sge(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); -/* TODO: RSQ */ + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} -/* TODO: SGE */ +static void t_opcode_slt(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); -/* TODO: SLT */ + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = t_src(vp, &src[1]); + o_inst->src[2] = ZERO_SRC_1; +} static void t_opcode_sub(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -844,7 +978,36 @@ static void t_opcode_sub(struct r300_vertex_program *vp, #endif } -/* TODO: SWZ */ +static void t_opcode_swz(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3]) +{ + //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} + +#if 1 + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +#else + hw_op = + (src[0].File == + PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : + R300_VPI_OUT_OP_MAD; + + o_inst->opcode = + MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ONE_SRC_0; + o_inst->src[2] = ZERO_SRC_0; +#endif +} static void t_opcode_xpd(struct r300_vertex_program *vp, struct prog_instruction *vpi, @@ -928,55 +1091,6 @@ static void t_opcode_rcc(struct r300_vertex_program *vp, _mesa_exit(-1); } -static void t_opcode_default(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], - int num_operands, int are_srcs_scalar) -{ - o_inst->opcode = - MAKE_VSF_OP(t_opcode(vpi->Opcode), - t_dst_index(vp, &vpi->DstReg), - t_dst_mask(vpi->DstReg.WriteMask), - t_dst_class(vpi->DstReg.File)); - - switch (num_operands) { - case 1: - if (are_srcs_scalar) { - o_inst->src[0] = t_src_scalar(vp, &src[0]); - } else { - o_inst->src[0] = t_src(vp, &src[0]); - } - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - break; - case 2: - if (are_srcs_scalar) { - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = t_src_scalar(vp, &src[1]); - } else { - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - } - o_inst->src[2] = ZERO_SRC_1; - break; - case 3: - if (are_srcs_scalar) { - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = t_src_scalar(vp, &src[1]); - o_inst->src[2] = t_src_scalar(vp, &src[2]); - } else { - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = t_src(vp, &src[2]); - } - break; - default: - assert(0); - break; - } -} - static void t_inputs_outputs(struct r300_vertex_program *vp) { int i; @@ -1053,8 +1167,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, t_inputs_outputs(vp); - o_inst = vp->program.body.i; - for (; vpi->Opcode != OPCODE_END; vpi++, o_inst++) { + for (o_inst = vp->program.body.i; vpi->Opcode != OPCODE_END; + vpi++, o_inst++) { FREE_TEMPS(); @@ -1136,34 +1250,52 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, case OPCODE_ADD: t_opcode_add(vp, vpi, o_inst, src); break; - /* TODO: ARL */ + case OPCODE_ARL: + t_opcode_arl(vp, vpi, o_inst, src); + break; case OPCODE_DP3: t_opcode_dp3(vp, vpi, o_inst, src); break; - /* TODO: DP4 */ + case OPCODE_DP4: + t_opcode_dp4(vp, vpi, o_inst, src); + break; case OPCODE_DPH: t_opcode_dph(vp, vpi, o_inst, src); break; - /* TODO: DST */ - /* TODO: EX2 */ - /* TODO: EXP */ + case OPCODE_DST: + t_opcode_dst(vp, vpi, o_inst, src); + break; + case OPCODE_EX2: + t_opcode_ex2(vp, vpi, o_inst, src); + break; + case OPCODE_EXP: + t_opcode_exp(vp, vpi, o_inst, src); + break; case OPCODE_FLR: /* FIXME */ t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); break; - /* TODO: FRC */ + case OPCODE_FRC: + t_opcode_frc(vp, vpi, o_inst, src); + break; case OPCODE_LG2: t_opcode_lg2(vp, vpi, o_inst, src); break; case OPCODE_LIT: t_opcode_lit(vp, vpi, o_inst, src); break; - /* TODO: LOG */ + case OPCODE_LOG: + t_opcode_log(vp, vpi, o_inst, src); + break; case OPCODE_MAD: t_opcode_mad(vp, vpi, o_inst, src); break; - /* TODO: MAX */ - /* TODO: MIN */ + case OPCODE_MAX: + t_opcode_max(vp, vpi, o_inst, src); + break; + case OPCODE_MIN: + t_opcode_min(vp, vpi, o_inst, src); + break; case OPCODE_MOV: t_opcode_mov(vp, vpi, o_inst, src); break; @@ -1173,33 +1305,33 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, case OPCODE_POW: t_opcode_pow(vp, vpi, o_inst, src); break; - /* TODO: RCP */ - /* TODO: RSQ */ - /* TODO: SGE */ - /* TODO: SLT */ + case OPCODE_RCP: + t_opcode_rcp(vp, vpi, o_inst, src); + break; + case OPCODE_RSQ: + t_opcode_rsq(vp, vpi, o_inst, src); + break; + case OPCODE_SGE: + t_opcode_sge(vp, vpi, o_inst, src); + break; + case OPCODE_SLT: + t_opcode_slt(vp, vpi, o_inst, src); + break; case OPCODE_SUB: t_opcode_sub(vp, vpi, o_inst, src); break; case OPCODE_SWZ: - t_opcode_mov(vp, vpi, o_inst, src); + t_opcode_swz(vp, vpi, o_inst, src); break; - /* TODO: SWZ */ case OPCODE_XPD: /* FIXME */ t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); break; - case OPCODE_RCC: t_opcode_rcc(vp, vpi, o_inst, src); break; - - case OPCODE_END: - /* empty */ - break; - default: - t_opcode_default(vp, vpi, o_inst, src, - num_operands, are_srcs_scalar); + assert(0); break; } } -- cgit v1.2.3 From b89a5c6e064d42e54c8748a35069b46460e4a6a9 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 19:10:13 +0000 Subject: r300: Removed broken RCC vertprog opcode. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 781c5602aa4..c7234e923ae 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -144,7 +144,6 @@ static struct { OPN(SUB, 2), OPN(SWZ, 1), OPN(XPD, 2), - OPN(RCC, 0), //extra OPN(PRINT, 0), OPN(END, 0) /* *INDENT-ON* */ @@ -1081,16 +1080,6 @@ static void t_opcode_xpd(struct r300_vertex_program *vp, } -static void t_opcode_rcc(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) -{ - fprintf(stderr, "Dont know how to handle op %d yet\n", - vpi->Opcode); - _mesa_exit(-1); -} - static void t_inputs_outputs(struct r300_vertex_program *vp) { int i; @@ -1327,9 +1316,6 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, /* FIXME */ t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); break; - case OPCODE_RCC: - t_opcode_rcc(vp, vpi, o_inst, src); - break; default: assert(0); break; -- cgit v1.2.3 From 611674ed692c219baeb6005373fe0fbf3c111ab4 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 19:13:46 +0000 Subject: r300: Don't need vertprog scalar flag anymore; it's handled explicitly... --- src/mesa/drivers/dri/r300/r300_vertprog.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index c7234e923ae..3cba075e796 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -106,8 +106,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \ } while (0) -#define SCALAR_FLAG (1<<31) -#define FLAG_MASK (1<<31) #define OP_MASK (0xf) /* we are unlikely to have more than 15 */ #define OPN(operator, ip) {#operator, OPCODE_##operator, ip} @@ -119,26 +117,26 @@ static struct { /* *INDENT-OFF* */ OPN(ABS, 1), OPN(ADD, 2), - OPN(ARL, 1 | SCALAR_FLAG), + OPN(ARL, 1), OPN(DP3, 2), OPN(DP4, 2), OPN(DPH, 2), OPN(DST, 2), - OPN(EX2, 1 | SCALAR_FLAG), - OPN(EXP, 1 | SCALAR_FLAG), + OPN(EX2, 1), + OPN(EXP, 1), OPN(FLR, 1), OPN(FRC, 1), - OPN(LG2, 1 | SCALAR_FLAG), + OPN(LG2, 1), OPN(LIT, 1), - OPN(LOG, 1 | SCALAR_FLAG), + OPN(LOG, 1), OPN(MAD, 3), OPN(MAX, 2), OPN(MIN, 2), OPN(MOV, 1), OPN(MUL, 2), - OPN(POW, 2 | SCALAR_FLAG), - OPN(RCP, 1 | SCALAR_FLAG), - OPN(RSQ, 1 | SCALAR_FLAG), + OPN(POW, 2), + OPN(RCP, 1), + OPN(RSQ, 1), OPN(SGE, 2), OPN(SLT, 2), OPN(SUB, 2), @@ -1141,7 +1139,6 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, int i; struct r300_vertprog_instruction *o_inst; unsigned long num_operands; - int are_srcs_scalar; /* Initial value should be last tmp reg that hw supports. Strangely enough r300 doesnt mind even though these would be out of range. Smart enough to realize that it doesnt need it? */ @@ -1168,7 +1165,6 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, } num_operands = op_operands(vpi->Opcode) & OP_MASK; - are_srcs_scalar = op_operands(vpi->Opcode) & SCALAR_FLAG; /* copy the sources (src) from mesa into a local variable... is this needed? */ for (i = 0; i < num_operands; i++) { -- cgit v1.2.3 From 3eba764df8b2b61588244e1e5457926062df065d Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 19:20:32 +0000 Subject: r300: Added code for vertprog opcode ARL. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 3cba075e796..b41a60953a0 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -486,7 +486,14 @@ static void t_opcode_arl(struct r300_vertex_program *vp, struct r300_vertprog_instruction *o_inst, struct prog_src_register src[3]) { - assert(0); + o_inst->opcode = + MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg), + t_dst_mask(vpi->DstReg.WriteMask), + t_dst_class(vpi->DstReg.File)); + + o_inst->src[0] = t_src(vp, &src[0]); + o_inst->src[1] = ZERO_SRC_0; + o_inst->src[2] = ZERO_SRC_0; } static void t_opcode_dp3(struct r300_vertex_program *vp, -- cgit v1.2.3 From f66775184b0be00cd0ac1163d2e9d4d656746af2 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 20:07:30 +0000 Subject: r300: Corrected vertprog FLR and XPD instruction regression. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index b41a60953a0..ea8acb84677 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -615,10 +615,11 @@ static void t_opcode_exp(struct r300_vertex_program *vp, o_inst->src[2] = ZERO_SRC_0; } -static void t_opcode_flr(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], int *u_temp_i) +static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], + int *u_temp_i) { /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ @@ -650,6 +651,8 @@ static void t_opcode_flr(struct r300_vertex_program *vp, o_inst->src[2] = ZERO_SRC_0; (*u_temp_i)--; + + return o_inst; } static void t_opcode_frc(struct r300_vertex_program *vp, @@ -1013,10 +1016,11 @@ static void t_opcode_swz(struct r300_vertex_program *vp, #endif } -static void t_opcode_xpd(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], int *u_temp_i) +static struct r300_vertprog_instruction *t_opcode_xpd(struct r300_vertex_program *vp, + struct prog_instruction *vpi, + struct r300_vertprog_instruction *o_inst, + struct prog_src_register src[3], + int *u_temp_i) { /* mul r0, r1.yzxw, r2.zxyw mad r0, -r2.yzxw, r1.zxyw, r0 @@ -1083,6 +1087,7 @@ static void t_opcode_xpd(struct r300_vertex_program *vp, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, VSF_FLAG_NONE); + return o_inst; } static void t_inputs_outputs(struct r300_vertex_program *vp) @@ -1265,7 +1270,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, break; case OPCODE_FLR: /* FIXME */ - t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); + o_inst = t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); break; case OPCODE_FRC: t_opcode_frc(vp, vpi, o_inst, src); @@ -1317,7 +1322,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, break; case OPCODE_XPD: /* FIXME */ - t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); + o_inst = t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); break; default: assert(0); -- cgit v1.2.3 From 8a016d213029ff4714a79e03a3b4922d70f54e80 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 20:24:41 +0000 Subject: r300: Use _mesa_num_inst_src_regs for number of arguments. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 59 +------------------------------ 1 file changed, 1 insertion(+), 58 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index ea8acb84677..9184ee7abf7 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -106,49 +106,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \ } while (0) -#define OP_MASK (0xf) /* we are unlikely to have more than 15 */ -#define OPN(operator, ip) {#operator, OPCODE_##operator, ip} - -static struct { - char *name; - int opcode; - unsigned long ip; /* number of input operands and flags */ -} op_names[] = { - /* *INDENT-OFF* */ - OPN(ABS, 1), - OPN(ADD, 2), - OPN(ARL, 1), - OPN(DP3, 2), - OPN(DP4, 2), - OPN(DPH, 2), - OPN(DST, 2), - OPN(EX2, 1), - OPN(EXP, 1), - OPN(FLR, 1), - OPN(FRC, 1), - OPN(LG2, 1), - OPN(LIT, 1), - OPN(LOG, 1), - OPN(MAD, 3), - OPN(MAX, 2), - OPN(MIN, 2), - OPN(MOV, 1), - OPN(MUL, 2), - OPN(POW, 2), - OPN(RCP, 1), - OPN(RSQ, 1), - OPN(SGE, 2), - OPN(SLT, 2), - OPN(SUB, 2), - OPN(SWZ, 1), - OPN(XPD, 2), - OPN(PRINT, 0), - OPN(END, 0) - /* *INDENT-ON* */ -}; - -#undef OPN - int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_program_cont *vp, float *dst) @@ -359,20 +316,6 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp, (src->RelAddr << 4); } -static unsigned long op_operands(enum prog_opcode opcode) -{ - int i; - - /* Can we trust mesas opcodes to be in order ? */ - for (i = 0; i < sizeof(op_names) / sizeof(*op_names); i++) - if (op_names[i].opcode == opcode) - return op_names[i].ip; - - fprintf(stderr, "op %d not found in op_names\n", opcode); - _mesa_exit(-1); - return 0; -} - static GLboolean valid_dst(struct r300_vertex_program *vp, struct prog_dst_register *dst) { @@ -1176,7 +1119,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, vpi->DstReg.Index = u_temp_i; } - num_operands = op_operands(vpi->Opcode) & OP_MASK; + num_operands = _mesa_num_inst_src_regs(vpi->Opcode); /* copy the sources (src) from mesa into a local variable... is this needed? */ for (i = 0; i < num_operands; i++) { -- cgit v1.2.3 From 7b410f366fa117a03a7e838562215d2dca3f8cbc Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Mon, 16 Jul 2007 21:43:39 +0000 Subject: r300: Corrected some progs/fp/* regressions from the BFC patch. I'm not completely sure this is correct; it restores the old behaviour. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 9184ee7abf7..0fb6110494b 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1497,6 +1497,24 @@ void r300SelectVertexShader(r300ContextPtr r300) } wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead; wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten; + + wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS; + + if (InputsRead & FRAG_BIT_COL0) { + wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL0; + } + + if ((InputsRead & FRAG_BIT_COL1)) { + wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1; + } + + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (InputsRead & (FRAG_BIT_TEX0 << i)) { + wanted_key.OutputsWritten |= + 1 << (VERT_RESULT_TEX0 + i); + } + } + if (vpc->mesa_program.IsPositionInvariant) { /* we wan't position don't we ? */ wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS); -- cgit v1.2.3 From fb4e071beda6e3b9e68a21bbc7649b6c4733c485 Mon Sep 17 00:00:00 2001 From: Tommy Schultz Lassen Date: Wed, 18 Jul 2007 00:37:43 +0000 Subject: r300: Corrected texcoord start when BFC1 is enabled. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 0fb6110494b..4f36e818ff3 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1073,7 +1073,7 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; - cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; + cur_reg = vp->outputs[VERT_RESULT_BFC1] + 2; } #if 0 if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { -- cgit v1.2.3 From 86ece0a920d8afa870608a25745be8d03b7cccb6 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 18 Jul 2007 02:49:26 +0000 Subject: r300: Cleaned up vertprog construction. Construct the vertprog instruction in the 4 DWORD parts... DWORD 0: Opcode and Output. DWORD 1: First Argument. DWORD 2: Second Argument. DWORD 3: Third Argument. Allow the opcode translation functions to generate more than one instruction; useful for when an instruction must be emulated. FLR, XPD, etc. --- src/mesa/drivers/dri/r300/r300_context.h | 2 +- src/mesa/drivers/dri/r300/r300_state.c | 29 +- src/mesa/drivers/dri/r300/r300_vertprog.c | 716 +++++++++++++++--------------- src/mesa/drivers/dri/r300/r300_vertprog.h | 5 - 4 files changed, 383 insertions(+), 369 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 0349bac9a26..be6909724a3 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -568,7 +568,7 @@ struct r300_vertex_shader_fragment { union { GLuint d[VSF_MAX_FRAGMENT_LENGTH]; float f[VSF_MAX_FRAGMENT_LENGTH]; - struct r300_vertprog_instruction i[VSF_MAX_FRAGMENT_LENGTH / 4]; + GLuint i[VSF_MAX_FRAGMENT_LENGTH]; } body; }; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index 6789efd4281..a790acacfef 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -1566,30 +1566,31 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa) for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) { if (rmesa->state.sw_tcl_inputs[i] != -1) { - prog->program.body.i[program_end].opcode = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); - prog->program.body.i[program_end].src[0] = VSF_REG(rmesa->state.sw_tcl_inputs[i]); - prog->program.body.i[program_end].src[1] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]); - prog->program.body.i[program_end].src[2] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]); - program_end++; + prog->program.body.i[program_end + 0] = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT); + prog->program.body.i[program_end + 1] = VSF_REG(rmesa->state.sw_tcl_inputs[i]); + prog->program.body.i[program_end + 2] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]); + prog->program.body.i[program_end + 3] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]); + program_end += 4; } } - prog->program.length = program_end * 4; + prog->program.length = program_end; - r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program)); + r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, + &(prog->program)); inst_count = (prog->program.length / 4) - 1; R300_STATECHANGE(rmesa, pvs); rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] = - (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | - (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) | - (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); + (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) | + (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) | + (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_2] = - (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | - (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); + (0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT) | + (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT); rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] = - (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | - (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) | + (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT); } static void r300SetupRealVertexProgram(r300ContextPtr rmesa) diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 4f36e818ff3..c6b4fc60249 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -31,6 +31,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * \author Aapo Tahkola * * \author Oliver McFadden + * + * For a description of the vertex program instruction set see r300_reg.h. */ #include "glheader.h" @@ -366,20 +368,19 @@ static GLboolean valid_dst(struct r300_vertex_program *vp, * component. */ -static void t_opcode_abs(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_abs(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + inst[1] = t_src(vp, &src[0]); + inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), @@ -389,13 +390,14 @@ static void t_opcode_abs(struct r300_vertex_program *vp, (!src[0]. NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[2] = 0; + inst[3] = 0; + + return inst; } -static void t_opcode_add(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_add(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -405,53 +407,55 @@ static void t_opcode_add(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = ONE_SRC_0; - o_inst->src[1] = t_src(vp, &src[0]); - o_inst->src[2] = t_src(vp, &src[1]); + inst[1] = ONE_SRC_0; + inst[2] = t_src(vp, &src[0]); + inst[3] = t_src(vp, &src[1]); #else - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; #endif + + return inst; } -static void t_opcode_arl(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_arl(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_dp3(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dp3(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO} - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), @@ -461,7 +465,7 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = + inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 0)), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), @@ -471,36 +475,38 @@ static void t_opcode_dp3(struct r300_vertex_program *vp, NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[1].RelAddr << 4); - o_inst->src[2] = ZERO_SRC_1; + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_dp4(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dp4(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_dph(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dph(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W} - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), @@ -509,81 +515,84 @@ static void t_opcode_dph(struct r300_vertex_program *vp, src[0]. NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_dst(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_dst(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_ex2(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_ex2(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_exp(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_exp(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], - int *u_temp_i) +static GLuint *t_opcode_flr(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3], int *u_temp_i) { /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W} ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */ - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - o_inst++; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + inst += 4; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + inst[1] = t_src(vp, &src[0]); + inst[2] = MAKE_VSF_SOURCE(*u_temp_i, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, @@ -592,40 +601,40 @@ static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE /*VSF_FLAG_ALL */ ); - o_inst->src[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; (*u_temp_i)--; - return o_inst; + return inst; } -static void t_opcode_frc(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_frc(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_lg2(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_lg2(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X} - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), @@ -635,70 +644,70 @@ static void t_opcode_lg2(struct r300_vertex_program *vp, src[0]. NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_lit(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_lit(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W} - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); /* NOTE: Users swizzling might not work. */ - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - VSF_IN_COMPONENT_ZERO, // z - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + inst[3] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + VSF_IN_COMPONENT_ZERO, // z + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + + return inst; } -static void t_opcode_log(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_log(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_mad(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_mad(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -708,80 +717,84 @@ static void t_opcode_mad(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = t_src(vp, &src[2]); + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = t_src(vp, &src[2]); + + return inst; } -static void t_opcode_max(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_max(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_min(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_min(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_mov(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_mov(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} #if 1 - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; #else hw_op = (src[0].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ONE_SRC_0; + inst[3] = ZERO_SRC_0; #endif + + return inst; } -static void t_opcode_mul(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_mul(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -792,94 +805,100 @@ static void t_opcode_mul(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + + inst[3] = ZERO_SRC_1; - o_inst->src[2] = ZERO_SRC_1; + return inst; } -static void t_opcode_pow(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_pow(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = t_src_scalar(vp, &src[1]); + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = t_src_scalar(vp, &src[1]); + + return inst; } -static void t_opcode_rcp(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_rcp(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_rsq(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_rsq(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src_scalar(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src_scalar(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + + return inst; } -static void t_opcode_sge(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_sge(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_slt(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_slt(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = t_src(vp, &src[1]); - o_inst->src[2] = ZERO_SRC_1; + inst[1] = t_src(vp, &src[0]); + inst[2] = t_src(vp, &src[1]); + inst[3] = ZERO_SRC_1; + + return inst; } -static void t_opcode_sub(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_sub(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { unsigned long hw_op; @@ -891,13 +910,13 @@ static void t_opcode_sub(struct r300_vertex_program *vp, PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = + inst[1] = t_src(vp, &src[0]); + inst[2] = ONE_SRC_0; + inst[3] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 0)), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), @@ -908,13 +927,13 @@ static void t_opcode_sub(struct r300_vertex_program *vp, NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4); #else - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = + inst[1] = t_src(vp, &src[0]); + inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 0)), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), @@ -924,113 +943,110 @@ static void t_opcode_sub(struct r300_vertex_program *vp, (!src[1]. NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) | (src[1].RelAddr << 4); - o_inst->src[2] = 0; + inst[3] = 0; #endif + + return inst; } -static void t_opcode_swz(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3]) +static GLuint *t_opcode_swz(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3]) { //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO} #if 1 - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; #else hw_op = (src[0].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = t_src(vp, &src[0]); - o_inst->src[1] = ONE_SRC_0; - o_inst->src[2] = ZERO_SRC_0; + inst[1] = t_src(vp, &src[0]); + inst[2] = ONE_SRC_0; + inst[3] = ZERO_SRC_0; #endif + + return inst; } -static struct r300_vertprog_instruction *t_opcode_xpd(struct r300_vertex_program *vp, - struct prog_instruction *vpi, - struct r300_vertprog_instruction *o_inst, - struct prog_src_register src[3], - int *u_temp_i) +static GLuint *t_opcode_xpd(struct r300_vertex_program *vp, + struct prog_instruction *vpi, GLuint * inst, + struct prog_src_register src[3], int *u_temp_i) { /* mul r0, r1.yzxw, r2.zxyw mad r0, -r2.yzxw, r1.zxyw, r0 NOTE: might need MAD_2 */ - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i, t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP); - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - - o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w - t_src_class(src[1].File), - src[1]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[1]. - RelAddr << 4); - - o_inst->src[2] = ZERO_SRC_1; - o_inst++; + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + + inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w + t_src_class(src[1].File), + src[1]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[1].RelAddr << 4); + + inst[3] = ZERO_SRC_1; + inst += 4; (*u_temp_i)--; - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg), t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File)); - o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w - t_src_class(src[1].File), - (!src[1]. - NegateBase) ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[1]. - RelAddr << 4); - - o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z - t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x - t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y - t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w - t_src_class(src[0].File), - src[0]. - NegateBase ? VSF_FLAG_ALL : - VSF_FLAG_NONE) | (src[0]. - RelAddr << 4); - - o_inst->src[2] = + inst[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w + t_src_class(src[1].File), + (!src[1]. + NegateBase) ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[1].RelAddr << 4); + + inst[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z + t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x + t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y + t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w + t_src_class(src[0].File), + src[0]. + NegateBase ? VSF_FLAG_ALL : + VSF_FLAG_NONE) | (src[0].RelAddr << 4); + + inst[3] = MAKE_VSF_SOURCE(*u_temp_i + 1, VSF_IN_COMPONENT_X, VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z, VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP, VSF_FLAG_NONE); - return o_inst; + return inst; } static void t_inputs_outputs(struct r300_vertex_program *vp) @@ -1092,7 +1108,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, struct prog_instruction *vpi) { int i; - struct r300_vertprog_instruction *o_inst; + GLuint *inst; unsigned long num_operands; /* Initial value should be last tmp reg that hw supports. Strangely enough r300 doesnt mind even though these would be out of range. @@ -1108,8 +1124,8 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, t_inputs_outputs(vp); - for (o_inst = vp->program.body.i; vpi->Opcode != OPCODE_END; - vpi++, o_inst++) { + for (inst = vp->program.body.i; vpi->Opcode != OPCODE_END; + vpi++, inst += 4) { FREE_TEMPS(); @@ -1129,12 +1145,12 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, if (num_operands == 3) { /* TODO: scalars */ if (CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2])) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index (vp, &src[2]), SWIZZLE_X, SWIZZLE_Y, @@ -1144,9 +1160,9 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, VSF_FLAG_NONE) | (src[2].RelAddr << 4); - o_inst->src[1] = ZERO_SRC_2; - o_inst->src[2] = ZERO_SRC_2; - o_inst++; + inst[2] = ZERO_SRC_2; + inst[3] = ZERO_SRC_2; + inst += 4; src[2].File = PROGRAM_TEMPORARY; src[2].Index = u_temp_i; @@ -1157,12 +1173,12 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, if (num_operands >= 2) { if (CMP_SRCS(src[1], src[0])) { - o_inst->opcode = + inst[0] = MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i, VSF_FLAG_ALL, VSF_OUT_CLASS_TMP); - o_inst->src[0] = + inst[1] = MAKE_VSF_SOURCE(t_src_index (vp, &src[0]), SWIZZLE_X, SWIZZLE_Y, @@ -1172,9 +1188,9 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, VSF_FLAG_NONE) | (src[0].RelAddr << 4); - o_inst->src[1] = ZERO_SRC_0; - o_inst->src[2] = ZERO_SRC_0; - o_inst++; + inst[2] = ZERO_SRC_0; + inst[3] = ZERO_SRC_0; + inst += 4; src[0].File = PROGRAM_TEMPORARY; src[0].Index = u_temp_i; @@ -1185,87 +1201,89 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, switch (vpi->Opcode) { case OPCODE_ABS: - t_opcode_abs(vp, vpi, o_inst, src); + inst = t_opcode_abs(vp, vpi, inst, src); break; case OPCODE_ADD: - t_opcode_add(vp, vpi, o_inst, src); + inst = t_opcode_add(vp, vpi, inst, src); break; case OPCODE_ARL: - t_opcode_arl(vp, vpi, o_inst, src); + inst = t_opcode_arl(vp, vpi, inst, src); break; case OPCODE_DP3: - t_opcode_dp3(vp, vpi, o_inst, src); + inst = t_opcode_dp3(vp, vpi, inst, src); break; case OPCODE_DP4: - t_opcode_dp4(vp, vpi, o_inst, src); + inst = t_opcode_dp4(vp, vpi, inst, src); break; case OPCODE_DPH: - t_opcode_dph(vp, vpi, o_inst, src); + inst = t_opcode_dph(vp, vpi, inst, src); break; case OPCODE_DST: - t_opcode_dst(vp, vpi, o_inst, src); + inst = t_opcode_dst(vp, vpi, inst, src); break; case OPCODE_EX2: - t_opcode_ex2(vp, vpi, o_inst, src); + inst = t_opcode_ex2(vp, vpi, inst, src); break; case OPCODE_EXP: - t_opcode_exp(vp, vpi, o_inst, src); + inst = t_opcode_exp(vp, vpi, inst, src); break; case OPCODE_FLR: - /* FIXME */ - o_inst = t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i); + inst = + t_opcode_flr(vp, vpi, inst, src, /* FIXME */ + &u_temp_i); break; case OPCODE_FRC: - t_opcode_frc(vp, vpi, o_inst, src); + inst = t_opcode_frc(vp, vpi, inst, src); break; case OPCODE_LG2: - t_opcode_lg2(vp, vpi, o_inst, src); + inst = t_opcode_lg2(vp, vpi, inst, src); break; case OPCODE_LIT: - t_opcode_lit(vp, vpi, o_inst, src); + inst = t_opcode_lit(vp, vpi, inst, src); break; case OPCODE_LOG: - t_opcode_log(vp, vpi, o_inst, src); + inst = t_opcode_log(vp, vpi, inst, src); break; case OPCODE_MAD: - t_opcode_mad(vp, vpi, o_inst, src); + inst = t_opcode_mad(vp, vpi, inst, src); break; case OPCODE_MAX: - t_opcode_max(vp, vpi, o_inst, src); + inst = t_opcode_max(vp, vpi, inst, src); break; case OPCODE_MIN: - t_opcode_min(vp, vpi, o_inst, src); + inst = t_opcode_min(vp, vpi, inst, src); break; case OPCODE_MOV: - t_opcode_mov(vp, vpi, o_inst, src); + inst = t_opcode_mov(vp, vpi, inst, src); break; case OPCODE_MUL: - t_opcode_mul(vp, vpi, o_inst, src); + inst = t_opcode_mul(vp, vpi, inst, src); break; case OPCODE_POW: - t_opcode_pow(vp, vpi, o_inst, src); + inst = t_opcode_pow(vp, vpi, inst, src); break; case OPCODE_RCP: - t_opcode_rcp(vp, vpi, o_inst, src); + inst = t_opcode_rcp(vp, vpi, inst, src); break; case OPCODE_RSQ: - t_opcode_rsq(vp, vpi, o_inst, src); + inst = t_opcode_rsq(vp, vpi, inst, src); break; case OPCODE_SGE: - t_opcode_sge(vp, vpi, o_inst, src); + inst = t_opcode_sge(vp, vpi, inst, src); break; case OPCODE_SLT: - t_opcode_slt(vp, vpi, o_inst, src); + inst = t_opcode_slt(vp, vpi, inst, src); break; case OPCODE_SUB: - t_opcode_sub(vp, vpi, o_inst, src); + inst = t_opcode_sub(vp, vpi, inst, src); break; case OPCODE_SWZ: - t_opcode_swz(vp, vpi, o_inst, src); + inst = t_opcode_swz(vp, vpi, inst, src); break; case OPCODE_XPD: - /* FIXME */ - o_inst = t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i); + inst = + t_opcode_xpd(vp, vpi, inst, src, /* FIXME */ + &u_temp_i); break; default: assert(0); @@ -1273,7 +1291,7 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp, } } - vp->program.length = (o_inst - vp->program.body.i) * 4; + vp->program.length = (inst - vp->program.body.i); if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) { vp->program.length = 0; vp->native = GL_FALSE; diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h index 2d399e243a8..3df0eee7991 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.h +++ b/src/mesa/drivers/dri/r300/r300_vertprog.h @@ -3,11 +3,6 @@ #include "r300_reg.h" -struct r300_vertprog_instruction { - GLuint opcode; - GLuint src[3]; -}; - #define VSF_FLAG_X 1 #define VSF_FLAG_Y 2 #define VSF_FLAG_Z 4 -- cgit v1.2.3 From 0b48ce450eef91a9fcf6681260beb1090e0ef9d1 Mon Sep 17 00:00:00 2001 From: Oliver McFadden Date: Wed, 18 Jul 2007 02:59:08 +0000 Subject: r300: Oops, made a mistake on commit fb4e071beda6e3b9e68a21bbc7649b6c4733c485. --- src/mesa/drivers/dri/r300/r300_vertprog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index c6b4fc60249..7d4e8c95112 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -1083,13 +1083,13 @@ static void t_inputs_outputs(struct r300_vertex_program *vp) if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) { vp->outputs[VERT_RESULT_BFC0] = vp->outputs[VERT_RESULT_COL0] + 2; - cur_reg = vp->outputs[VERT_RESULT_BFC0] + 1; + cur_reg = vp->outputs[VERT_RESULT_BFC0] + 2; } if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) { vp->outputs[VERT_RESULT_BFC1] = vp->outputs[VERT_RESULT_COL0] + 3; - cur_reg = vp->outputs[VERT_RESULT_BFC1] + 2; + cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1; } #if 0 if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) { -- cgit v1.2.3 From b9f2cf9a4e0a5ec89b27371210846942c93cb412 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 12:56:30 +0200 Subject: increase MAX_RELOCS so never run out before batch buffer is full (fixes xdemos/shape) --- src/mesa/drivers/dri/i915tex/intel_batchbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h index 59261f72741..212f1301012 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.h @@ -9,7 +9,7 @@ struct intel_context; #define BATCH_SZ 16384 #define BATCH_RESERVED 16 -#define MAX_RELOCS 400 +#define MAX_RELOCS 4096 #define INTEL_BATCH_NO_CLIPRECTS 0x1 #define INTEL_BATCH_CLIPRECTS 0x2 -- cgit v1.2.3 From dbfb375805d94cb80262b8816c67a8adc778bec5 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 17 Jul 2007 17:29:55 +0200 Subject: fix mesa fb binding Make sure that we bind the right buffer (draw or read) when rebinding the window framebuffer (the api doesn't allow binding different draw and read buffers at the same time, but the default window framebuffer is basically 2 fb objects, one for read, one for write, which can be different). Pass both of these two down the driver api (no driver uses this right now). --- src/mesa/drivers/dri/i915tex/intel_fbo.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 7 +++++-- src/mesa/main/dd.h | 2 +- src/mesa/main/fbobject.c | 8 +++++--- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c index 349912ffecd..6f99f401c7c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.c +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c @@ -488,7 +488,7 @@ intel_new_renderbuffer(GLcontext * ctx, GLuint name) */ static void intel_bind_framebuffer(GLcontext * ctx, GLenum target, - struct gl_framebuffer *fb) + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { intel_draw_buffer(ctx, fb); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index f98d6665635..d498f616c90 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -390,9 +390,12 @@ nouveauNewRenderbuffer(GLcontext *ctx, GLuint name) } static void -nouveauBindFramebuffer(GLcontext *ctx, GLenum target, struct gl_framebuffer *fb) +nouveauBindFramebuffer(GLcontext *ctx, GLenum target, + struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { - nouveau_build_framebuffer(ctx, fb); + if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { + nouveau_build_framebuffer(ctx, fb); + } } static void diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 88f33943b31..caa50dd6826 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -782,7 +782,7 @@ struct dd_function_table { struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name); struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name); void (*BindFramebuffer)(GLcontext *ctx, GLenum target, - struct gl_framebuffer *fb); + struct gl_framebuffer *fb, struct gl_framebuffer *fbread); void (*FramebufferRenderbuffer)(GLcontext *ctx, struct gl_framebuffer *fb, GLenum attachment, diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index e3bada5ae89..5345310ca1f 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -924,7 +924,7 @@ check_end_texture_render(GLcontext *ctx, struct gl_framebuffer *fb) void GLAPIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) { - struct gl_framebuffer *newFb; + struct gl_framebuffer *newFb, *newFbread; GLboolean bindReadBuf, bindDrawBuf; GET_CURRENT_CONTEXT(ctx); @@ -984,12 +984,14 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); } + newFbread = newFb; } else { /* Binding the window system framebuffer (which was originally set * with MakeCurrent). */ newFb = ctx->WinSysDrawBuffer; + newFbread = ctx->WinSysReadBuffer; } ASSERT(newFb); @@ -1000,7 +1002,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) */ if (bindReadBuf) { - _mesa_reference_framebuffer(&ctx->ReadBuffer, newFb); + _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); } if (bindDrawBuf) { @@ -1015,7 +1017,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } if (ctx->Driver.BindFramebuffer) { - ctx->Driver.BindFramebuffer(ctx, target, newFb); + ctx->Driver.BindFramebuffer(ctx, target, newFb, newFbread); } } -- cgit v1.2.3 From f9ac01eac511aa9ea0b8b48774022a08d0fc2f3b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 19 Jul 2007 17:58:21 +0200 Subject: fix up mesa's probably bogus framebuffer updates with different read/write fbs Conflicts: src/mesa/main/framebuffer.c --- src/mesa/main/framebuffer.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index dc10d9ffbc8..2ff067164bf 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -654,6 +654,27 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) } +static void +update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) +{ + /* Completeness only matters for user-created framebuffers */ + if (fb->Name != 0) { + /* XXX: EXT_framebuffer_blit: + framebuffer must still be complete wrt read/draw? */ + _mesa_test_framebuffer_completeness(ctx, fb); + _mesa_update_framebuffer_visual(fb); + } + + /* update_color_draw/read_buffers not needed for + read/draw only fb, but shouldn't hurt ??? */ + update_color_draw_buffers(ctx, fb); + update_color_read_buffer(ctx, fb); + _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); + _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); + + compute_depth_max(fb); +} + /** * Update state related to the current draw/read framebuffers. * Specifically, update these framebuffer fields: @@ -671,19 +692,12 @@ void _mesa_update_framebuffer(GLcontext *ctx) { struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_framebuffer *fbread = ctx->ReadBuffer; - /* Completeness only matters for user-created framebuffers */ - if (fb->Name != 0) { - _mesa_test_framebuffer_completeness(ctx, fb); - _mesa_update_framebuffer_visual(fb); - } - - update_color_draw_buffers(ctx, fb); - update_color_read_buffer(ctx, fb); - _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); - _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL); - - compute_depth_max(fb); + update_framebuffer(ctx, fb); + if (fbread != fb && fbread != NULL /* can happen at make_current - + core/driver circular dependencies, should be fixed up */) + update_framebuffer(ctx, fbread); } -- cgit v1.2.3 From 6075df53b5435ddada989d776d989132def363a6 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 18:07:12 +0200 Subject: more fixes for mesa's fbo handling (fixes tests/fbotest1/2) --- src/mesa/main/buffers.c | 5 ++--- src/mesa/main/context.c | 5 +++++ src/mesa/main/fbobject.c | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index c280f89e1d1..68a0575d93d 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -557,9 +557,8 @@ _mesa_ReadBuffer(GLenum buffer) } } - if (fb->Name == 0) { - ctx->Pixel.ReadBuffer = buffer; - } + ctx->Pixel.ReadBuffer = buffer; + fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2ad1badac70..4e6732dc7ac 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1499,6 +1499,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, if the DRIdrawable changes, and someone may rely on them. */ /* What a mess!?! */ + /* XXX this is still not quite correct. Imagine a user-created fbo + bound on a context. Now rebind with a completely new drawable. + Upon rebinding to the window-framebuffer, we have no idea what + the read and write buffers should be (front, back, ...) - that + information was only available in the previously used drawable... */ int i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 5345310ca1f..f300e481ce0 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1003,13 +1003,20 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); + /* set context value */ + ctx->Pixel.ReadBuffer = newFbread->ColorReadBuffer; } if (bindDrawBuf) { + GLuint i; /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); + /* set context value */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + ctx->Color.DrawBuffer[i] = newFb->ColorDrawBuffer[i]; + } if (newFb->Name != 0) { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); -- cgit v1.2.3 From a1bc0d0f51c2aa248a349283c3b86ae2c72af4aa Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 18 Jul 2007 20:17:14 +0200 Subject: fix mesa's handling of fbo's / window fb (again) Make sure the relevant fields in window fbs get updated at appropriate time (those are NOT the same as fbos!!!), and fix up related code accordingly. This is a bit ugly, but there's a reason the issues section in EXT_fbo is a couple hundred pages long... Hopefully correct now. --- src/mesa/main/attrib.c | 4 +++ src/mesa/main/buffers.c | 72 ++++++++++++++++++++++++++++++--------------- src/mesa/main/buffers.h | 3 ++ src/mesa/main/context.c | 12 ++------ src/mesa/main/fbobject.c | 24 ++++++++++----- src/mesa/main/framebuffer.c | 3 +- 6 files changed, 77 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 1aa0a02fc78..b422198f929 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -98,9 +98,13 @@ _mesa_PushAttrib(GLbitfield mask) } if (mask & GL_COLOR_BUFFER_BIT) { + GLuint i; struct gl_colorbuffer_attrib *attr; attr = MALLOC_STRUCT( gl_colorbuffer_attrib ); MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) ); + /* push the Draw FBO's DrawBuffer[] state, not ctx->Color.DrawBuffer[] */ + for (i = 0; i < ctx->Const.MaxDrawBuffers; i ++) + attr->DrawBuffer[i] = ctx->DrawBuffer->ColorDrawBuffer[i]; newnode = new_attrib_node( GL_COLOR_BUFFER_BIT ); newnode->data = attr; newnode->next = head; diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 68a0575d93d..7764a5d3b2e 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -370,6 +370,14 @@ _mesa_DrawBuffer(GLenum buffer) /* if we get here, there's no error so set new state */ _mesa_drawbuffers(ctx, 1, &buffer, &destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, 1, &buffer); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffer); } @@ -435,6 +443,14 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers) /* OK, if we get here, there were no errors so set the new state */ _mesa_drawbuffers(ctx, n, buffers, destMask); + + /* + * Call device driver function. + */ + if (ctx->Driver.DrawBuffers) + ctx->Driver.DrawBuffers(ctx, n, buffers); + else if (ctx->Driver.DrawBuffer) + ctx->Driver.DrawBuffer(ctx, buffers[0]); } @@ -463,14 +479,15 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, /* not really needed, will be set later */ fb->_NumColorDrawBuffers[output] = 0; + if (fb->Name == 0) /* Set traditional state var */ - ctx->Color.DrawBuffer[output] = buffer; + ctx->Color.DrawBuffer[output] = buffer; } /** * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and - * _mesa_PopAttrib to set drawbuffer state. + * other places (window fbo fixup) to set fbo (and the old ctx) fields. * All error checking will have been done prior to calling this function * so nothing should go wrong at this point. * \param ctx current context @@ -479,6 +496,7 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param destMask array[n] of BUFFER_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). + * \param callDriver call driver or not (bad idea sometimes this is called) */ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, @@ -509,30 +527,15 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, } ctx->NewState |= _NEW_COLOR; - - /* - * Call device driver function. - */ - if (ctx->Driver.DrawBuffers) - ctx->Driver.DrawBuffers(ctx, n, buffers); - else if (ctx->Driver.DrawBuffer) - ctx->Driver.DrawBuffer(ctx, buffers[0]); } - -/** - * Called by glReadBuffer to set the source renderbuffer for reading pixels. - * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - */ -void GLAPIENTRY -_mesa_ReadBuffer(GLenum buffer) +GLboolean +_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) { struct gl_framebuffer *fb; GLbitfield supportedMask; GLint srcBuffer; - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); fb = ctx->ReadBuffer; @@ -548,20 +551,43 @@ _mesa_ReadBuffer(GLenum buffer) srcBuffer = read_buffer_enum_to_index(buffer); if (srcBuffer == -1) { _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer=0x%x)", buffer); - return; + return GL_FALSE; } supportedMask = supported_buffer_bitmask(ctx, fb); if (((1 << srcBuffer) & supportedMask) == 0) { _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer=0x%x)", buffer); - return; + return GL_FALSE; } } - ctx->Pixel.ReadBuffer = buffer; - + if (fb->Name == 0) { + ctx->Pixel.ReadBuffer = buffer; + } fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; + return GL_TRUE; +} + + + +/** + * Called by glReadBuffer to set the source renderbuffer for reading pixels. + * \param mode color buffer such as GL_FRONT, GL_BACK, etc. + * \param callDriver call driver or not (bad idea sometimes this is called) + */ +void GLAPIENTRY +_mesa_ReadBuffer(GLenum buffer) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); + + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + + if (!_mesa_readbuffer_update_fields(ctx, buffer)) + return; + ctx->NewState |= _NEW_PIXEL; /* diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h index fcc21523421..208e7af2b93 100644 --- a/src/mesa/main/buffers.h +++ b/src/mesa/main/buffers.h @@ -56,6 +56,9 @@ extern void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, const GLbitfield *destMask); +extern GLboolean +_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer); + extern void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 4e6732dc7ac..00e4c8328e5 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1496,14 +1496,8 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); /* fix up the fb fields - these will end up wrong otherwise - if the DRIdrawable changes, and someone may rely on them. - */ - /* What a mess!?! */ - /* XXX this is still not quite correct. Imagine a user-created fbo - bound on a context. Now rebind with a completely new drawable. - Upon rebinding to the window-framebuffer, we have no idea what - the read and write buffers should be (front, back, ...) - that - information was only available in the previously used drawable... */ + if the DRIdrawable changes, and everything relies on them. + This is a bit messy (same as needed in _mesa_BindFramebufferEXT) */ int i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { @@ -1513,7 +1507,7 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); - _mesa_ReadBuffer(newCtx->Pixel.ReadBuffer); + _mesa_readbuffer_update_fields(newCtx, newCtx->Pixel.ReadBuffer); } newCtx->NewState |= _NEW_BUFFERS; diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index f300e481ce0..6f7effcce70 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -29,6 +29,7 @@ */ +#include "buffers.h" #include "context.h" #include "fbobject.h" #include "framebuffer.h" @@ -1001,23 +1002,32 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) * XXX check if re-binding same buffer and skip some of this code. */ + /* for window-framebuffers, re-initialize the fbo values, as they + could be wrong (makecurrent with a new drawable while still a fbo + was bound will lead to default init fbo values). + note that therefore the context ReadBuffer/DrawBuffer values are not + valid while fbo's are bound!!! */ if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); - /* set context value */ - ctx->Pixel.ReadBuffer = newFbread->ColorReadBuffer; + if (!newFbread->Name) { + _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer); + } } if (bindDrawBuf) { - GLuint i; /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); - /* set context value */ - for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - ctx->Color.DrawBuffer[i] = newFb->ColorDrawBuffer[i]; + if (!newFb->Name) { + GLuint i; + GLenum buffers[MAX_DRAW_BUFFERS]; + for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) { + buffers[i] = ctx->Color.DrawBuffer[i]; + } + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL); } - if (newFb->Name != 0) { + else { /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 2ff067164bf..c9b30d32528 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -695,8 +695,7 @@ _mesa_update_framebuffer(GLcontext *ctx) struct gl_framebuffer *fbread = ctx->ReadBuffer; update_framebuffer(ctx, fb); - if (fbread != fb && fbread != NULL /* can happen at make_current - - core/driver circular dependencies, should be fixed up */) + if (fbread != fb) update_framebuffer(ctx, fbread); } -- cgit v1.2.3 From 82fceba231a03b3b7284d5356d7bc1d10c366026 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 20 Jul 2007 11:34:26 +0200 Subject: fix bogus recently introduced function param comments --- src/mesa/main/buffers.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 7764a5d3b2e..0e6ca8ea1c2 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -496,7 +496,6 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, * \param destMask array[n] of BUFFER_* bitmasks which correspond to the * colorbuffer names. (i.e. GL_FRONT_AND_BACK => * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT). - * \param callDriver call driver or not (bad idea sometimes this is called) */ void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, @@ -574,7 +573,6 @@ _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) /** * Called by glReadBuffer to set the source renderbuffer for reading pixels. * \param mode color buffer such as GL_FRONT, GL_BACK, etc. - * \param callDriver call driver or not (bad idea sometimes this is called) */ void GLAPIENTRY _mesa_ReadBuffer(GLenum buffer) -- cgit v1.2.3 From af2aa8e9cf88a9ee3ec338eddc9a47bf2f142cb7 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 21 Jul 2007 10:06:18 -0600 Subject: Remove ctx->Point._Size and ctx->Line._Width. The clamping for these values depends on whether we're drawing AA or non-AA points, lines. Defer clamping until drawing time. Drivers could compute and keep clamped AA and clamped non-AA values if desired. --- src/mesa/drivers/dri/i810/i810state.c | 10 ++++++++-- src/mesa/drivers/dri/i810/i810tris.c | 4 +++- src/mesa/drivers/dri/i965/brw_sf_state.c | 6 ++++-- src/mesa/drivers/dri/mach64/mach64_native_vb.c | 2 +- src/mesa/drivers/dri/mach64/mach64_tris.c | 13 ++++++++----- src/mesa/drivers/dri/mga/mgatris.c | 10 +++++++--- src/mesa/drivers/dri/r200/r200_state.c | 4 +++- src/mesa/drivers/dri/r300/r300_state.c | 9 +++++---- src/mesa/drivers/dri/savage/savagetris.c | 16 ++++++++++++---- src/mesa/drivers/dri/tdfx/tdfx_tris.c | 2 +- src/mesa/main/lines.c | 8 ++------ src/mesa/main/mtypes.h | 2 -- src/mesa/main/points.c | 5 ----- src/mesa/main/state.c | 4 ++-- src/mesa/swrast/s_aalinetemp.h | 4 +++- src/mesa/swrast/s_lines.c | 16 +++++++++------- src/mesa/swrast/s_points.c | 8 ++++---- src/mesa/tnl/t_vertex.c | 2 +- src/mesa/tnl_dd/t_dd_vb.c | 2 +- 19 files changed, 74 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c index 3ad25282d90..e0d5b2b4876 100644 --- a/src/mesa/drivers/dri/i810/i810state.c +++ b/src/mesa/drivers/dri/i810/i810state.c @@ -380,7 +380,10 @@ static void i810CullFaceFrontFace(GLcontext *ctx, GLenum unused) static void i810LineWidth( GLcontext *ctx, GLfloat widthf ) { i810ContextPtr imesa = I810_CONTEXT( ctx ); - int width = (int)ctx->Line._Width; + /* AA, non-AA limits are same */ + const int width = (int) CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); imesa->LcsLineWidth = 0; if (width & 1) imesa->LcsLineWidth |= LCS_LINEWIDTH_1_0; @@ -396,7 +399,10 @@ static void i810LineWidth( GLcontext *ctx, GLfloat widthf ) static void i810PointSize( GLcontext *ctx, GLfloat sz ) { i810ContextPtr imesa = I810_CONTEXT( ctx ); - int size = (int)ctx->Point._Size; + /* AA, non-AA limits are same */ + const int size = (int) CLAMP(ctx->Point.Size, + ctx->Const.MinPointSize, + ctx->Const.MaxPointSize); imesa->LcsPointSize = 0; if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0; diff --git a/src/mesa/drivers/dri/i810/i810tris.c b/src/mesa/drivers/dri/i810/i810tris.c index 3e09427bb94..2c4ee06633d 100644 --- a/src/mesa/drivers/dri/i810/i810tris.c +++ b/src/mesa/drivers/dri/i810/i810tris.c @@ -112,7 +112,9 @@ static __inline__ void i810_draw_quad( i810ContextPtr imesa, static __inline__ void i810_draw_point( i810ContextPtr imesa, i810VertexPtr tmp ) { - GLfloat sz = imesa->glCtx->Point._Size * .5; + GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, + imesa->glCtx->Const.MinPointSize, + imesa->glCtx->Const.MaxPointSize); int vertsize = imesa->vertex_size; GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize ); int j; diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index bfac52d765b..9a6e5f5f192 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -173,7 +173,8 @@ static void upload_sf_unit( struct brw_context *brw ) /* _NEW_LINE */ - sf.sf6.line_width = brw->attribs.Line->_Width * (1<<1); + /* XXX use ctx->Const.Min/MaxLineWidth here */ + sf.sf6.line_width = CLAMP(brw->attribs.Line->Width, 1.0, 5.0) * (1<<1); sf.sf6.line_endcap_aa_region_width = 1; if (brw->attribs.Line->SmoothFlag) @@ -183,7 +184,8 @@ static void upload_sf_unit( struct brw_context *brw ) /* _NEW_POINT */ sf.sf6.point_rast_rule = 1; /* opengl conventions */ - sf.sf7.point_size = brw->attribs.Point->_Size * (1<<3); + /* XXX clamp max depends on AA vs. non-AA */ + sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 3.0) * (1<<3); sf.sf7.use_point_size_state = !brw->attribs.Point->_Attenuated; /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons: diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vb.c b/src/mesa/drivers/dri/mach64/mach64_native_vb.c index 75cf0e2ed2d..248fa2a9a29 100644 --- a/src/mesa/drivers/dri/mach64/mach64_native_vb.c +++ b/src/mesa/drivers/dri/mach64/mach64_native_vb.c @@ -103,7 +103,7 @@ void TAG(translate_vertex)(GLcontext *ctx, assert( p + 1 - (CARD32 *)src == 10 ); - dst->pointSize = ctx->Point._Size; + dst->pointSize = ctx->Point.Size; } diff --git a/src/mesa/drivers/dri/mach64/mach64_tris.c b/src/mesa/drivers/dri/mach64/mach64_tris.c index 08cc1849a12..369f6104428 100644 --- a/src/mesa/drivers/dri/mach64/mach64_tris.c +++ b/src/mesa/drivers/dri/mach64/mach64_tris.c @@ -673,7 +673,10 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa, #if MACH64_NATIVE_VTXFMT GLcontext *ctx = mmesa->glCtx; const GLuint vertsize = mmesa->vertex_size; - GLint width = (GLint)(mmesa->glCtx->Line._Width * 2.0); /* 2 fractional bits for hardware */ + /* 2 fractional bits for hardware: */ + const int width = (int) (2.0 * CLAMP(mmesa->glCtx->Line.Width, + mmesa->glCtx->Const.MinLineWidth, + mmesa->glCtx->Const.MaxLineWidth)); GLfloat ooa; GLuint *pxy0, *pxy1; GLuint xy0old, xy0, xy1old, xy1; @@ -691,9 +694,6 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa, mach64_print_vertex( ctx, v1 ); } - if( !width ) - width = 1; /* round to the nearest supported width */ - pxy0 = &v0->ui[xyoffset]; xy0old = *pxy0; xy0 = LE32_IN( &xy0old ); @@ -961,7 +961,10 @@ static __inline void mach64_draw_point( mach64ContextPtr mmesa, #if MACH64_NATIVE_VTXFMT GLcontext *ctx = mmesa->glCtx; const GLuint vertsize = mmesa->vertex_size; - GLint sz = (GLint)(mmesa->glCtx->Point._Size * 2.0); /* 2 fractional bits for hardware */ + /* 2 fractional bits for hardware: */ + GLint sz = (GLint) (2.0 * CLAMP(mmesa->glCtx->Point.Size, + ctx->Const.MinPointSize, + ctx->Const.MaxPointSize)); GLfloat ooa; GLuint *pxy; GLuint xyold, xy; diff --git a/src/mesa/drivers/dri/mga/mgatris.c b/src/mesa/drivers/dri/mga/mgatris.c index 2b7ea05b142..91b413ae760 100644 --- a/src/mesa/drivers/dri/mga/mgatris.c +++ b/src/mesa/drivers/dri/mga/mgatris.c @@ -104,8 +104,10 @@ static void __inline__ mga_draw_quad( mgaContextPtr mmesa, static __inline__ void mga_draw_point( mgaContextPtr mmesa, mgaVertexPtr tmp ) { - GLfloat sz = mmesa->glCtx->Point._Size * .5; - int vertex_size = mmesa->vertex_size; + const GLfloat sz = 0.5 * CLAMP(mmesa->glCtx->Point.Size, + mmesa->glCtx->Const.MinPointSize, + mmesa->glCtx->Const.MaxPointSize); + const int vertex_size = mmesa->vertex_size; GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size ); int j; @@ -165,7 +167,9 @@ static __inline__ void mga_draw_line( mgaContextPtr mmesa, GLuint vertex_size = mmesa->vertex_size; GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size ); GLfloat dx, dy, ix, iy; - GLfloat width = mmesa->glCtx->Line._Width; + const GLfloat width = CLAMP(mmesa->glCtx->Line.Width, + mmesa->glCtx->Const.MinLineWidth, + mmesa->glCtx->Const.MaxLineWidth); GLint j; #if 0 diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c index 2115799b9b6..1d975ecd57d 100644 --- a/src/mesa/drivers/dri/r200/r200_state.c +++ b/src/mesa/drivers/dri/r200/r200_state.c @@ -772,9 +772,11 @@ static void r200LineWidth( GLcontext *ctx, GLfloat widthf ) R200_STATECHANGE( rmesa, set ); /* Line width is stored in U6.4 format. + * Same min/max limits for AA, non-AA lines. */ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] &= ~0xffff; - rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint)(ctx->Line._Width * 16.0); + rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint) + (CLAMP(widthf, ctx->Const.MinLineWidth, ctx->Const.MaxLineWidth) * 16.0); if ( widthf > 1.0 ) { rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_WIDELINE_ENABLE; diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index a790acacfef..088216c76ee 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -733,8 +733,8 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param) static void r300PointSize(GLcontext * ctx, GLfloat size) { r300ContextPtr r300 = R300_CONTEXT(ctx); - - size = ctx->Point._Size; + /* same size limits for AA, non-AA points */ + size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); R300_STATECHANGE(r300, ps); r300->hw.ps.cmd[R300_PS_POINTSIZE] = @@ -749,8 +749,9 @@ static void r300LineWidth(GLcontext * ctx, GLfloat widthf) { r300ContextPtr r300 = R300_CONTEXT(ctx); - widthf = ctx->Line._Width; - + widthf = CLAMP(widthf, + ctx->Const.MinPointSize, + ctx->Const.MaxPointSize); R300_STATECHANGE(r300, lcntl); r300->hw.lcntl.cmd[1] = R300_LINE_CNT_HO | R300_LINE_CNT_VE | (int)(widthf * 6.0); diff --git a/src/mesa/drivers/dri/savage/savagetris.c b/src/mesa/drivers/dri/savage/savagetris.c index 3dd821a4d39..4ce2f60b4f3 100644 --- a/src/mesa/drivers/dri/savage/savagetris.c +++ b/src/mesa/drivers/dri/savage/savagetris.c @@ -131,7 +131,9 @@ static __inline__ void savage_draw_point (savageContextPtr imesa, u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); const GLfloat x = tmp->v.x; const GLfloat y = tmp->v.y; - const GLfloat sz = imesa->glCtx->Point._Size * .5; + const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, + imesa->glCtx->Const.MinPointSize, + imesa->glCtx->Const.MaxPointSize); GLuint j; *(float *)&vb[0] = x - sz; @@ -164,7 +166,9 @@ static __inline__ void savage_draw_line (savageContextPtr imesa, savageVertexPtr v1 ) { GLuint vertsize = imesa->HwVertexSize; u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - GLfloat width = imesa->glCtx->Line._Width; + const GLfloat width = CLAMP(imesa->glCtx->Line.Width, + imesa->glCtx->Const.MinLineWidth, + imesa->glCtx->Const.MaxLineWidth); GLfloat dx, dy, ix, iy; GLuint j; @@ -234,7 +238,9 @@ static __inline__ void savage_ptex_line (savageContextPtr imesa, savageVertexPtr v1 ) { GLuint vertsize = imesa->HwVertexSize; u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); - GLfloat width = imesa->glCtx->Line._Width; + const GLfloat width = CLAMP(imesa->glCtx->Line.Width, + imesa->glCtx->Const.MinLineWidth, + imesa->glCtx->Const.MaxLineWidth); GLfloat dx, dy, ix, iy; savageVertex tmp0, tmp1; GLuint j; @@ -281,7 +287,9 @@ static __inline__ void savage_ptex_point (savageContextPtr imesa, u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize); const GLfloat x = v0->v.x; const GLfloat y = v0->v.y; - const GLfloat sz = imesa->glCtx->Point._Size * .5; + const GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size, + imesa->glCtx->Const.MinPointSize, + imesa->glCtx->Const.MaxPointSize); savageVertex tmp; GLuint j; diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/src/mesa/drivers/dri/tdfx/tdfx_tris.c index 96f9ae27fc1..7252a7e7dc6 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_tris.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_tris.c @@ -184,7 +184,7 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst) } } - dst->pointSize = ctx->Point._Size; + dst->pointSize = ctx->Point.Size; } diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c index dc7195d4ebf..0c2dbf915a1 100644 --- a/src/mesa/main/lines.c +++ b/src/mesa/main/lines.c @@ -55,9 +55,6 @@ _mesa_LineWidth( GLfloat width ) FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.Width = width; - ctx->Line._Width = CLAMP(width, - ctx->Const.MinLineWidth, - ctx->Const.MaxLineWidth); if (ctx->Driver.LineWidth) ctx->Driver.LineWidth(ctx, width); @@ -105,13 +102,12 @@ _mesa_LineStipple( GLint factor, GLushort pattern ) * Initializes __GLcontextRec::Line and line related constants in * __GLcontextRec::Const. */ -void GLAPIENTRY _mesa_init_line( GLcontext * ctx ) +void GLAPIENTRY +_mesa_init_line( GLcontext * ctx ) { - /* Line group */ ctx->Line.SmoothFlag = GL_FALSE; ctx->Line.StippleFlag = GL_FALSE; ctx->Line.Width = 1.0; - ctx->Line._Width = 1.0; ctx->Line.StipplePattern = 0xffff; ctx->Line.StippleFactor = 1; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 709b88d2ef5..a5fdd88262e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -917,7 +917,6 @@ struct gl_line_attrib GLushort StipplePattern; /**< Stipple pattern */ GLint StippleFactor; /**< Stipple repeat factor */ GLfloat Width; /**< Line width */ - GLfloat _Width; /**< Clamped Line width */ }; @@ -1063,7 +1062,6 @@ struct gl_point_attrib { GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */ GLfloat Size; /**< User-specified point size */ - GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */ GLfloat Params[3]; /**< GL_EXT_point_parameters */ GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */ GLfloat Threshold; /**< GL_EXT_point_parameters */ diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 0f562420b08..e83db5de78d 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -57,10 +57,6 @@ _mesa_PointSize( GLfloat size ) FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.Size = size; - /* XXX correct clamp limits? */ - ctx->Point._Size = CLAMP(ctx->Point.Size, - ctx->Point.MinSize, - ctx->Point.MaxSize); if (ctx->Driver.PointSize) ctx->Driver.PointSize(ctx, size); @@ -253,7 +249,6 @@ _mesa_init_point(GLcontext *ctx) ctx->Point.SmoothFlag = GL_FALSE; ctx->Point.Size = 1.0; - ctx->Point._Size = 1.0; ctx->Point.Params[0] = 1.0; ctx->Point.Params[1] = 0.0; ctx->Point.Params[2] = 0.0; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 66f8ac64088..444f2277601 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1068,7 +1068,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state) if (1/*new_state & _NEW_POINT*/) { if (ctx->Point.SmoothFlag) ctx->_TriangleCaps |= DD_POINT_SMOOTH; - if (ctx->Point._Size != 1.0F) + if (ctx->Point.Size != 1.0F) ctx->_TriangleCaps |= DD_POINT_SIZE; if (ctx->Point._Attenuated) ctx->_TriangleCaps |= DD_POINT_ATTEN; @@ -1082,7 +1082,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state) ctx->_TriangleCaps |= DD_LINE_SMOOTH; if (ctx->Line.StippleFlag) ctx->_TriangleCaps |= DD_LINE_STIPPLE; - if (ctx->Line._Width != 1.0) + if (ctx->Line.Width != 1.0) ctx->_TriangleCaps |= DD_LINE_WIDTH; } diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 69a1f0cd396..e7911fec3b5 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -132,7 +132,9 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) line.dx = line.x1 - line.x0; line.dy = line.y1 - line.y0; line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); - line.halfWidth = 0.5F * ctx->Line._Width; + line.halfWidth = 0.5F * CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidthAA, + ctx->Const.MaxLineWidthAA); if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) return; diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 781146e67f9..15ef6233eda 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -63,12 +63,13 @@ compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] ) static void draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) { - GLint width, start; + const GLint width = (GLint) CLAMP(ctx->Line.Width, + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); + GLint start; ASSERT(span->end < MAX_WIDTH); - width = (GLint) CLAMP( ctx->Line._Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH ); - if (width & 1) start = width / 2; else @@ -143,7 +144,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -161,7 +162,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -180,7 +181,7 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor ) span.arrayMask |= SPAN_MASK; \ compute_stipple_mask(ctx, span.end, span.array->mask); \ } \ - if (ctx->Line._Width > 1.0) { \ + if (ctx->Line.Width > 1.0) { \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ } \ else { \ @@ -274,7 +275,7 @@ _swrast_choose_line( GLcontext *ctx ) USE(general_line); } else if (ctx->Depth.Test - || ctx->Line._Width != 1.0 + || ctx->Line.Width != 1.0 || ctx->Line.StippleFlag) { /* no texture, but Z, fog, width>1, stipple, etc. */ if (rgbmode) @@ -284,6 +285,7 @@ _swrast_choose_line( GLcontext *ctx ) } else { ASSERT(!ctx->Depth.Test); + ASSERT(ctx->Line.Width == 1.0); /* simple lines */ if (rgbmode) USE(simple_no_z_rgba_line); diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 8eba53c8076..4768fbea972 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -76,7 +76,7 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) } else { /* use constant point size */ - size = ctx->Point._Size; /* already clamped to user range */ + size = ctx->Point.Size; } /* clamp to non-AA implementation limits */ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); @@ -227,7 +227,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert) } else { /* use constant point size */ - size = ctx->Point._Size; /* this is already clamped */ + size = ctx->Point.Size; } /* clamp to AA implementation limits */ size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA); @@ -361,7 +361,7 @@ large_point(GLcontext *ctx, const SWvertex *vert) } else { /* use constant point size */ - size = ctx->Point._Size; /* already clamped to user range */ + size = ctx->Point.Size; } /* clamp to non-AA implementation limits */ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); @@ -550,7 +550,7 @@ _swrast_choose_point(GLcontext *ctx) else if (ctx->Point.SmoothFlag) { swrast->Point = smooth_point; } - else if (ctx->Point._Size > 1.0 || + else if (ctx->Point.Size > 1.0 || ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) { swrast->Point = large_point; diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index 6aae6020375..a6728c318fe 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -233,7 +233,7 @@ void _tnl_get_attr( GLcontext *ctx, const void *vin, /* If the hardware vertex doesn't have point size then use size from * GLcontext. XXX this will be wrong if drawing attenuated points! */ - dest[0] = ctx->Point._Size; + dest[0] = ctx->Point.Size; } else { _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat)); diff --git a/src/mesa/tnl_dd/t_dd_vb.c b/src/mesa/tnl_dd/t_dd_vb.c index ab3bb37631b..3cedd901190 100644 --- a/src/mesa/tnl_dd/t_dd_vb.c +++ b/src/mesa/tnl_dd/t_dd_vb.c @@ -184,7 +184,7 @@ void TAG(translate_vertex)(GLcontext *ctx, } } - dst->pointSize = ctx->Point._Size; + dst->pointSize = ctx->Point.Size; } -- cgit v1.2.3 From 76fb8089103e9dba9aaa7232c86d864d5874a08f Mon Sep 17 00:00:00 2001 From: Zhang Date: Sat, 21 Jul 2007 11:28:06 -0600 Subject: Fix a number of MINGW32 issues --- Makefile | 1 + Makefile.mgw | 11 +- configs/config.mgw | 42 +++++ docs/README.MINGW32 | 49 ++++++ include/GL/gl.h | 17 +- include/GL/glut.h | 9 +- include/GL/mesa_wgl.h | 59 ++++--- progs/samples/Makefile.mgw | 33 +++- src/glu/sgi/Makefile.mgw | 229 +++++++++++++++++++++++++++ src/glu/sgi/libnurbs/interface/glcurveval.h | 2 +- src/glu/sgi/libnurbs/interface/glsurfeval.cc | 7 +- src/glu/sgi/libnurbs/interface/glsurfeval.h | 2 +- src/glut/glx/Makefile.mgw | 198 +++++++++++++++++++++++ src/glut/glx/glut_fbc.c | 4 +- src/glut/glx/glutint.h | 3 + src/glut/glx/win32_winproc.c | 3 + src/mesa/Makefile.mgw | 51 ++++-- src/mesa/drivers/windows/gdi/wgl.c | 57 ++++--- src/mesa/drivers/windows/gdi/wmesa.c | 7 +- src/mesa/drivers/windows/gdi/wmesadef.h | 4 +- src/mesa/main/glheader.h | 2 +- src/mesa/main/imports.c | 4 + src/mesa/main/imports.h | 4 + src/mesa/main/shaders.c | 8 +- src/mesa/main/texcompress_fxt1.c | 5 + 25 files changed, 719 insertions(+), 92 deletions(-) create mode 100644 configs/config.mgw create mode 100644 src/glu/sgi/Makefile.mgw create mode 100644 src/glut/glx/Makefile.mgw (limited to 'src') diff --git a/Makefile b/Makefile index 31acb630e25..9a6557571c5 100644 --- a/Makefile +++ b/Makefile @@ -317,6 +317,7 @@ SGI_GLU_FILES = \ $(DIRECTORY)/src/glu/Makefile \ $(DIRECTORY)/src/glu/descrip.mms \ $(DIRECTORY)/src/glu/sgi/Makefile \ + $(DIRECTORY)/src/glu/sgi/Makefile.mgw \ $(DIRECTORY)/src/glu/sgi/Makefile.win \ $(DIRECTORY)/src/glu/sgi/Makefile.DJ \ $(DIRECTORY)/src/glu/sgi/glu.def \ diff --git a/Makefile.mgw b/Makefile.mgw index 948860890c0..3dc9f626438 100644 --- a/Makefile.mgw +++ b/Makefile.mgw @@ -53,11 +53,13 @@ # MinGW core makefile updated for Mesa 7.0 # -# updated : by Heromyth, 2007-6-25 +# Updated : by Heromyth, on 2007-7-21 # Email : zxpmyth@yahoo.com.cn -# Bug : All the default settings work fine. But the setting X86=1 can't work. +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. # The others havn't been tested yet. - +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) MAlthough more tests are needed, it can be used individually! .PHONY : all libgl clean realclean @@ -73,13 +75,14 @@ CFLAGS += -O2 -ffast-math export CFLAGS + ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) UNLINK = del $(subst /,\,$(1)) else UNLINK = $(RM) $(1) endif -all: libgl libglu libglut +all: libgl libglu libglut example libgl: lib $(MAKE) -f Makefile.mgw -C src/mesa diff --git a/configs/config.mgw b/configs/config.mgw new file mode 100644 index 00000000000..b961eb965cb --- /dev/null +++ b/configs/config.mgw @@ -0,0 +1,42 @@ +# MinGW config include file updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + +# The generated DLLs by MingW with STDCALL are not totally compatible +# with the ones linked by Microsoft's compilers. +# +# xxx_USING_STDCALL = 1 Compiling MESA with __stdcall. This is default! +# +# xxx_USING_STDCALL = 0 Compiling MESA without __stdcall. I like this:) +# + +# In fact, GL_USING_STDCALL and GLUT_USING_STDCALL can be +# different. For example: +# +# GL_USING_STDCALL = 0 +# GLUT_USING_STDCALL = 1 +# +# Suggested setting: +# +# ALL_USING_STDCALL = 1 +# +# That's default! +# + + +ALL_USING_STDCALL = 1 + + +ifeq ($(ALL_USING_STDCALL),1) + GL_USING_STDCALL = 1 + GLUT_USING_STDCALL = 1 +else + GL_USING_STDCALL = 0 + GLUT_USING_STDCALL = 0 +endif diff --git a/docs/README.MINGW32 b/docs/README.MINGW32 index 2b39f120908..138dd43eacc 100644 --- a/docs/README.MINGW32 +++ b/docs/README.MINGW32 @@ -88,3 +88,52 @@ Running the Build: Paul G. Daniel Borca + + + +*******************This section is added by Heromyth***************************** +Updated on 2007-7-21, by Heromyth + + +Notice: + 1) The generated DLLs are *not* compatible with the ones built +with the other compilers like VC8, especially for GLUT. + + 2) Although more tests are needed, it can be used individually! + + 3) You can set the options about whether using STDCALL to build MESA. The +config file is \configs\config.mgw. The default setting is that: + ALL_USING_STDCALL = 1 +, which means using STDCALL to build MESA. + + 4) Of course, you can MESA without using STDCALL,I like this:) +The setting is : + ALL_USING_STDCALL = 0 +To do this, however, you must modify wingdi.h which is in MingW's include dir. +For example, run: + notepad C:\MingW\include\wingdi.h +, and delete all the lines where all the wgl*() functions are. Because they would +be conflicted with the ones in \include\GL\mesa_wgl.h. + +======= Conflicted Functions List ====== +WINGDIAPI BOOL WINAPI wglCopyContext(HGLRC,HGLRC,UINT); +WINGDIAPI HGLRC WINAPI wglCreateContext(HDC); +WINGDIAPI HGLRC WINAPI wglCreateLayerContext(HDC,int); +WINGDIAPI BOOL WINAPI wglDeleteContext(HGLRC); +WINGDIAPI BOOL WINAPI wglDescribeLayerPlane(HDC,int,int,UINT,LPLAYERPLANEDESCRIPTOR); +WINGDIAPI HGLRC WINAPI wglGetCurrentContext(void); +WINGDIAPI HDC WINAPI wglGetCurrentDC(void); +WINGDIAPI int WINAPI wglGetLayerPaletteEntries(HDC,int,int,int,COLORREF*); +WINGDIAPI PROC WINAPI wglGetProcAddress(LPCSTR); +WINGDIAPI BOOL WINAPI wglMakeCurrent(HDC,HGLRC); +WINGDIAPI BOOL WINAPI wglRealizeLayerPalette(HDC,int,BOOL); +WINGDIAPI int WINAPI wglSetLayerPaletteEntries(HDC,int,int,int,const COLORREF*); +WINGDIAPI BOOL WINAPI wglShareLists(HGLRC,HGLRC); +WINGDIAPI BOOL WINAPI wglSwapLayerBuffers(HDC,UINT); +WINGDIAPI BOOL WINAPI wglUseFontBitmapsA(HDC,DWORD,DWORD,DWORD); +WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC,DWORD,DWORD,DWORD); +WINGDIAPI BOOL WINAPI wglUseFontOutlinesA(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT); +WINGDIAPI BOOL WINAPI wglUseFontOutlinesW(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT); +=================== + +********************************************************************************* \ No newline at end of file diff --git a/include/GL/gl.h b/include/GL/gl.h index a388de36e49..09195aa1361 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -58,7 +58,11 @@ # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern # endif /* _STATIC_MESA support */ -# define GLAPIENTRY __stdcall +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif #elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern # define GLAPIENTRY __stdcall @@ -84,7 +88,8 @@ #include #endif -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) \ + && !defined(OPENSTEP) && !defined(__CYGWIN__) || defined(__MINGW32__) #include #endif @@ -2161,11 +2166,11 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLsh #define GL_DEBUG_PRINT_MESA 0x875A #define GL_DEBUG_ASSERT_MESA 0x875B -GLAPI GLhandleARB APIENTRY glCreateDebugObjectMESA (void); -GLAPI void APIENTRY glClearDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType); -GLAPI void APIENTRY glGetDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType, GLsizei maxLength, +GLAPI GLhandleARB GLAPIENTRY glCreateDebugObjectMESA (void); +GLAPI void GLAPIENTRY glClearDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType); +GLAPI void GLAPIENTRY glGetDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType, GLsizei maxLength, GLsizei *length, GLcharARB *debugLog); -GLAPI GLsizei APIENTRY glGetDebugLogLengthMESA (GLhandleARB obj, GLenum logType, GLenum shaderType); +GLAPI GLsizei GLAPIENTRY glGetDebugLogLengthMESA (GLhandleARB obj, GLenum logType, GLenum shaderType); #endif /* GL_MESA_shader_debug */ diff --git a/include/GL/glut.h b/include/GL/glut.h index e0fad6e5cb0..e286349f9b0 100644 --- a/include/GL/glut.h +++ b/include/GL/glut.h @@ -10,6 +10,10 @@ #include #include +#if defined(__MINGW32__) +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -108,7 +112,7 @@ extern _CRTIMP void __cdecl exit(int); and redifinition of Windows system defs, also removes requirement of pretty much any standard windows header from this file */ -#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__) +#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__) # define GLUTAPIENTRY __stdcall #else # define GLUTAPIENTRY @@ -130,8 +134,9 @@ extern _CRTIMP void __cdecl exit(int); # pragma message( "----: being multiply defined you should include WINDOWS.H priot to gl/glut.h" ) # endif # define CALLBACK __stdcall -typedef int (GLUTAPIENTRY *PROC)(); + #if !defined(__MINGW32__) + typedef int (GLUTAPIENTRY *PROC)(); typedef void *HGLRC; typedef void *HDC; #endif diff --git a/include/GL/mesa_wgl.h b/include/GL/mesa_wgl.h index acc7eac2a71..1d774571d94 100644 --- a/include/GL/mesa_wgl.h +++ b/include/GL/mesa_wgl.h @@ -26,11 +26,12 @@ /* prototypes for the Mesa WGL functions */ /* relocated here so that I could make GLUT get them properly */ -#define _mesa_wgl_h_ - #ifndef _mesa_wgl_h_ #define _mesa_wgl_h_ +#if defined(__MINGW32__) +# define __W32API_USE_DLLIMPORT__ +#endif #include @@ -39,23 +40,16 @@ extern "C" { #endif -#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN32__)) -# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define GLAPI __declspec(dllexport) -# define WGLAPI __declspec(dllexport) -# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define GLAPI __declspec(dllimport) -# define WGLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define GLAPI extern -# define WGLAPI __declspec(dllimport) -# endif /* _STATIC_MESA support */ -# define GLAPIENTRY __stdcall -#else -/* non-Windows compilation */ -# define GLAPI extern -# define GLAPIENTRY -#endif /* WIN32 / CYGWIN32 bracket */ +#ifndef WGLAPI +#define WGLAPI GLAPI +#endif + +#if defined(__MINGW32__) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN 1 +# endif +# include +#endif #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) @@ -80,23 +74,25 @@ typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESC # pragma warning( disable : 4273 ) /* 'function' : inconsistent DLL linkage. dllexport assumed. */ #endif -WGLAPI int GLAPIENTRY wglDeleteContext(HGLRC); -WGLAPI int GLAPIENTRY wglMakeCurrent(HDC,HGLRC); + WGLAPI int GLAPIENTRY wglSetPixelFormat(HDC, int, const PIXELFORMATDESCRIPTOR *); WGLAPI int GLAPIENTRY wglSwapBuffers(HDC hdc); -WGLAPI HDC GLAPIENTRY wglGetCurrentDC(void); -WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC); -WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int); -WGLAPI HGLRC GLAPIENTRY wglGetCurrentContext(void); -WGLAPI PROC GLAPIENTRY wglGetProcAddress(const char*); WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *); +WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR); +WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc); + + +#if defined(GL_NO_STDCALL) || !defined(__MINGW32__) WGLAPI int GLAPIENTRY wglCopyContext(HGLRC, HGLRC, unsigned int); +WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC); +WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int); WGLAPI int GLAPIENTRY wglDeleteContext(HGLRC); WGLAPI int GLAPIENTRY wglDescribeLayerPlane(HDC, int, int, unsigned int,LPLAYERPLANEDESCRIPTOR); -WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR); +WGLAPI HGLRC GLAPIENTRY wglGetCurrentContext(void); +WGLAPI HDC GLAPIENTRY wglGetCurrentDC(void); WGLAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC, int, int, int,COLORREF *); -WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc); -WGLAPI int GLAPIENTRY wglMakeCurrent(HDC, HGLRC); +WGLAPI PROC GLAPIENTRY wglGetProcAddress(const char*); +WGLAPI int GLAPIENTRY wglMakeCurrent(HDC,HGLRC); WGLAPI int GLAPIENTRY wglRealizeLayerPalette(HDC, int, int); WGLAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC, int, int, int,const COLORREF *); WGLAPI int GLAPIENTRY wglShareLists(HGLRC, HGLRC); @@ -105,12 +101,15 @@ WGLAPI int GLAPIENTRY wglUseFontBitmapsA(HDC, unsigned long, unsigned long, un WGLAPI int GLAPIENTRY wglUseFontBitmapsW(HDC, unsigned long, unsigned long, unsigned long); WGLAPI int GLAPIENTRY wglUseFontOutlinesA(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT); WGLAPI int GLAPIENTRY wglUseFontOutlinesW(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT); +#endif + +#ifndef __MINGW32__ WGLAPI int GLAPIENTRY SwapBuffers(HDC); WGLAPI int GLAPIENTRY ChoosePixelFormat(HDC,const PIXELFORMATDESCRIPTOR *); WGLAPI int GLAPIENTRY DescribePixelFormat(HDC,int,unsigned int,LPPIXELFORMATDESCRIPTOR); WGLAPI int GLAPIENTRY GetPixelFormat(HDC); WGLAPI int GLAPIENTRY SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR *); - +#endif #ifndef WGL_ARB_extensions_string #define WGL_ARB_extensions_string 1 diff --git a/progs/samples/Makefile.mgw b/progs/samples/Makefile.mgw index 11935405783..3b2fd785def 100644 --- a/progs/samples/Makefile.mgw +++ b/progs/samples/Makefile.mgw @@ -26,6 +26,15 @@ # Email : dborca@users.sourceforge.net # Web : http://www.geocities.com/dborca +# MinGW samples makefile updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! # # Available options: @@ -44,15 +53,31 @@ TOP = ../.. +include $(TOP)/configs/config.mgw +ALL_USING_STDCALL ?= 1 +GL_USING_STDCALL ?= 1 +GLUT_USING_STDCALL ?= 1 + CC = mingw32-gcc -CFLAGS = -Wall -W -pedantic +CFLAGS = -Wall -pedantic CFLAGS += -O2 -ffast-math CFLAGS += -I$(TOP)/include -I../util ifeq ($(FX),1) -CFLAGS += -DFX + CFLAGS += -DFX +endif + +CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK + +ifeq ($(GL_USING_STDCALL),0) + CFLAGS += -DGL_NO_STDCALL +endif + +ifeq ($(GLUT_USING_STDCALL),1) + CFLAGS += -D_STDCALL_SUPPORTED +else + CFLAGS += -DGLUT_NO_STDCALL endif -CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK -D_STDCALL_SUPPORTED -CFLAGS += -D_WINDEF_ -D_WINGDI_ + LD = mingw32-g++ LDFLAGS = -s -L$(TOP)/lib diff --git a/src/glu/sgi/Makefile.mgw b/src/glu/sgi/Makefile.mgw new file mode 100644 index 00000000000..43b421e737a --- /dev/null +++ b/src/glu/sgi/Makefile.mgw @@ -0,0 +1,229 @@ +# 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. + +# MinGW core makefile v1.4 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca + +# MinGW core-glu makefile updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + +# +# Available options: +# +# Environment variables: +# CFLAGS +# +# GLIDE path to Glide3 SDK; used with FX. +# default = $(TOP)/glide3 +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most WMesa code and requires fxMesa. +# As a consequence, you'll need the Win32 Glide3 +# library to build any application. +# default = no +# ICD=1 build the installable client driver interface +# (windows opengl driver interface) +# default = no +# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow). +# default = no +# +# Targets: +# all: build GL +# clean: remove object files +# + + + +.PHONY: all clean +.INTERMEDIATE: x86/gen_matypes.exe +.SUFFIXES: .rc .res + +# Set this to the prefix of your build tools, i.e. mingw32- +TOOLS_PREFIX = mingw32- + +TOP = ../../.. + +LIBDIR = $(TOP)/lib + +GLU_DLL = glu32.dll +GLU_IMP = libglu32.a +GLU_DEF = glu.def + +include $(TOP)/configs/config.mgw +GL_USING_STDCALL ?= 1 + +LDLIBS = -L$(LIBDIR) -lopengl32 +LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLU_IMP) -Wl,--output-def=$(LIBDIR)/$(GLU_DEF) + +CFLAGS += -DBUILD_GLU32 -D_DLL + +ifeq ($(GL_USING_STDCALL),1) + LDFLAGS += -Wl,--add-stdcall-alias +else + CFLAGS += -DGL_NO_STDCALL +endif + +CC = gcc +CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude +CXX = g++ +CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess + +AR = ar +ARFLAGS = crus + +UNLINK = del $(subst /,\,$(1)) +ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif +ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif + +C_SOURCES = \ + libutil/error.c \ + libutil/glue.c \ + libutil/mipmap.c \ + libutil/project.c \ + libutil/quad.c \ + libutil/registry.c \ + libtess/dict.c \ + libtess/geom.c \ + libtess/memalloc.c \ + libtess/mesh.c \ + libtess/normal.c \ + libtess/priorityq.c \ + libtess/render.c \ + libtess/sweep.c \ + libtess/tess.c \ + libtess/tessmono.c + +CC_SOURCES = \ + libnurbs/interface/bezierEval.cc \ + libnurbs/interface/bezierPatch.cc \ + libnurbs/interface/bezierPatchMesh.cc \ + libnurbs/interface/glcurveval.cc \ + libnurbs/interface/glinterface.cc \ + libnurbs/interface/glrenderer.cc \ + libnurbs/interface/glsurfeval.cc \ + libnurbs/interface/incurveeval.cc \ + libnurbs/interface/insurfeval.cc \ + libnurbs/internals/arc.cc \ + libnurbs/internals/arcsorter.cc \ + libnurbs/internals/arctess.cc \ + libnurbs/internals/backend.cc \ + libnurbs/internals/basiccrveval.cc \ + libnurbs/internals/basicsurfeval.cc \ + libnurbs/internals/bin.cc \ + libnurbs/internals/bufpool.cc \ + libnurbs/internals/cachingeval.cc \ + libnurbs/internals/ccw.cc \ + libnurbs/internals/coveandtiler.cc \ + libnurbs/internals/curve.cc \ + libnurbs/internals/curvelist.cc \ + libnurbs/internals/curvesub.cc \ + libnurbs/internals/dataTransform.cc \ + libnurbs/internals/displaylist.cc \ + libnurbs/internals/flist.cc \ + libnurbs/internals/flistsorter.cc \ + libnurbs/internals/hull.cc \ + libnurbs/internals/intersect.cc \ + libnurbs/internals/knotvector.cc \ + libnurbs/internals/mapdesc.cc \ + libnurbs/internals/mapdescv.cc \ + libnurbs/internals/maplist.cc \ + libnurbs/internals/mesher.cc \ + libnurbs/internals/monoTriangulationBackend.cc \ + libnurbs/internals/monotonizer.cc \ + libnurbs/internals/mycode.cc \ + libnurbs/internals/nurbsinterfac.cc \ + libnurbs/internals/nurbstess.cc \ + libnurbs/internals/patch.cc \ + libnurbs/internals/patchlist.cc \ + libnurbs/internals/quilt.cc \ + libnurbs/internals/reader.cc \ + libnurbs/internals/renderhints.cc \ + libnurbs/internals/slicer.cc \ + libnurbs/internals/sorter.cc \ + libnurbs/internals/splitarcs.cc \ + libnurbs/internals/subdivider.cc \ + libnurbs/internals/tobezier.cc \ + libnurbs/internals/trimline.cc \ + libnurbs/internals/trimregion.cc \ + libnurbs/internals/trimvertpool.cc \ + libnurbs/internals/uarray.cc \ + libnurbs/internals/varray.cc \ + libnurbs/nurbtess/directedLine.cc \ + libnurbs/nurbtess/gridWrap.cc \ + libnurbs/nurbtess/monoChain.cc \ + libnurbs/nurbtess/monoPolyPart.cc \ + libnurbs/nurbtess/monoTriangulation.cc \ + libnurbs/nurbtess/partitionX.cc \ + libnurbs/nurbtess/partitionY.cc \ + libnurbs/nurbtess/polyDBG.cc \ + libnurbs/nurbtess/polyUtil.cc \ + libnurbs/nurbtess/primitiveStream.cc \ + libnurbs/nurbtess/quicksort.cc \ + libnurbs/nurbtess/rectBlock.cc \ + libnurbs/nurbtess/sampleComp.cc \ + libnurbs/nurbtess/sampleCompBot.cc \ + libnurbs/nurbtess/sampleCompRight.cc \ + libnurbs/nurbtess/sampleCompTop.cc \ + libnurbs/nurbtess/sampleMonoPoly.cc \ + libnurbs/nurbtess/sampledLine.cc \ + libnurbs/nurbtess/searchTree.cc + +SOURCES = $(C_SOURCES) $(CC_SOURCES) + +OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +.cc.o: + $(CXX) -o $@ $(CXXFLAGS) -c $< + + +all: $(LIBDIR) $(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP) + +$(LIBDIR): + mkdir -p $(LIBDIR) + +$(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP): $(OBJECTS) + g++ -shared -fPIC -o $(LIBDIR)/$(GLU_DLL) $(LDFLAGS) \ + $^ $(LDLIBS) + + + +clean: + -$(call UNLINK,libutil/*.o) + -$(call UNLINK,libtess/*.o) + -$(call UNLINK,libnurbs/interface/*.o) + -$(call UNLINK,libnurbs/internals/*.o) + -$(call UNLINK,libnurbs/nurbtess/*.o) diff --git a/src/glu/sgi/libnurbs/interface/glcurveval.h b/src/glu/sgi/libnurbs/interface/glcurveval.h index 4b44f6e847e..a09a74d04c3 100644 --- a/src/glu/sgi/libnurbs/interface/glcurveval.h +++ b/src/glu/sgi/libnurbs/interface/glcurveval.h @@ -93,7 +93,7 @@ public: output_triangles = flag; } #ifdef _WIN32 - void putCallBack(GLenum which, void (APIENTRY *fn)() ); + void putCallBack(GLenum which, void (GLAPIENTRY *fn)() ); #else void putCallBack(GLenum which, _GLUfuncptr fn ); #endif diff --git a/src/glu/sgi/libnurbs/interface/glsurfeval.cc b/src/glu/sgi/libnurbs/interface/glsurfeval.cc index a36b304508c..b5bfab1e281 100644 --- a/src/glu/sgi/libnurbs/interface/glsurfeval.cc +++ b/src/glu/sgi/libnurbs/interface/glsurfeval.cc @@ -1184,8 +1184,11 @@ return; } -void -OpenGLSurfaceEvaluator::putCallBack(GLenum which, _GLUfuncptr fn ) +#ifdef _WIN32 +void OpenGLSurfaceEvaluator::putCallBack(GLenum which, void (GLAPIENTRY *fn)() ) +#else +void OpenGLSurfaceEvaluator::putCallBack(GLenum which, _GLUfuncptr fn ) +#endif { switch(which) { diff --git a/src/glu/sgi/libnurbs/interface/glsurfeval.h b/src/glu/sgi/libnurbs/interface/glsurfeval.h index c34a58cb9b9..b7a88069f5a 100644 --- a/src/glu/sgi/libnurbs/interface/glsurfeval.h +++ b/src/glu/sgi/libnurbs/interface/glsurfeval.h @@ -145,7 +145,7 @@ public: void newtmeshvert( long, long ); #ifdef _WIN32 - void putCallBack(GLenum which, void (APIENTRY *fn)() ); + void putCallBack(GLenum which, void (GLAPIENTRY *fn)() ); #else void putCallBack(GLenum which, _GLUfuncptr fn ); #endif diff --git a/src/glut/glx/Makefile.mgw b/src/glut/glx/Makefile.mgw new file mode 100644 index 00000000000..ae4eb6addc5 --- /dev/null +++ b/src/glut/glx/Makefile.mgw @@ -0,0 +1,198 @@ +# 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. + +# MinGW core makefile v1.4 for Mesa +# +# Copyright (C) 2002 - Daniel Borca +# Email : dborca@users.sourceforge.net +# Web : http://www.geocities.com/dborca + +# MinGW core-glut makefile updated for Mesa 7.0 +# +# Updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + + +# +# Available options: +# +# Environment variables: +# CFLAGS +# +# GLIDE path to Glide3 SDK; used with FX. +# default = $(TOP)/glide3 +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most WMesa code and requires fxMesa. +# As a consequence, you'll need the Win32 Glide3 +# library to build any application. +# default = no +# ICD=1 build the installable client driver interface +# (windows opengl driver interface) +# default = no +# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow). +# default = no +# +# Targets: +# all: build GL +# clean: remove object files +# + + + +.PHONY: all clean +.INTERMEDIATE: x86/gen_matypes.exe +.SUFFIXES: .rc .res + +# Set this to the prefix of your build tools, i.e. mingw32- +TOOLS_PREFIX = mingw32- + +TOP = ../../.. + +LIBDIR = $(TOP)/lib + +GLUT_DLL = glut32.dll +GLUT_IMP = libglut32.a +GLUT_DEF = glut.def + +include $(TOP)/configs/config.mgw +GLUT_USING_STDCALL ?= 1 + + + +LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32 +LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLUT_IMP) -Wl,--output-def=$(LIBDIR)/$(GLUT_DEF) + +CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL + +ifeq ($(GL_USING_STDCALL),0) + CFLAGS += -DGL_NO_STDCALL +endif + +ifeq ($(GLUT_USING_STDCALL),1) + CFLAGS += -D_STDCALL_SUPPORTED + LDFLAGS += -Wl,--add-stdcall-alias +else + CFLAGS += -DGLUT_NO_STDCALL +endif + +CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include + +CC = gcc +CXX = g++ +CXXFLAGS = $(CFLAGS) + +AR = ar +ARFLAGS = crus + +UNLINK = del $(subst /,\,$(1)) +ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif +ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),) +UNLINK = $(RM) $(1) +endif + +HDRS = glutint.h glutstroke.h glutbitmap.h glutwin32.h stroke.h win32_glx.h win32_x11.h + +SRCS = \ + glut_bitmap.c \ + glut_bwidth.c \ + glut_cindex.c \ + glut_cmap.c \ + glut_cursor.c \ + glut_dials.c \ + glut_dstr.c \ + glut_event.c \ + glut_ext.c \ + glut_fbc.c \ + glut_fullscrn.c \ + glut_gamemode.c \ + glut_get.c \ + glut_init.c \ + glut_input.c \ + glut_joy.c \ + glut_key.c \ + glut_keyctrl.c \ + glut_keyup.c \ + glut_mesa.c \ + glut_modifier.c \ + glut_overlay.c \ + glut_shapes.c \ + glut_space.c \ + glut_stroke.c \ + glut_swap.c \ + glut_swidth.c \ + glut_tablet.c \ + glut_teapot.c \ + glut_util.c \ + glut_vidresize.c \ + glut_warp.c \ + glut_win.c \ + glut_winmisc.c \ + win32_glx.c \ + win32_menu.c \ + win32_util.c \ + win32_winproc.c \ + win32_x11.c + + +SRCSSEMIGENS = \ + glut_8x13.c \ + glut_9x15.c \ + glut_hel10.c \ + glut_hel12.c \ + glut_hel18.c \ + glut_mroman.c \ + glut_roman.c \ + glut_tr10.c \ + glut_tr24.c + + + +SOURCES = $(SRCS) $(SRCSSEMIGENS) + +OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) + +.c.o: + $(CC) -o $@ $(CFLAGS) -c $< +.cc.o: + $(CXX) -o $@ $(CXXFLAGS) -c $< + + +all: $(LIBDIR) $(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP) + +$(LIBDIR): + mkdir -p $(LIBDIR) + +$(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS) + $(CXX) -shared -fPIC -o $(LIBDIR)/$(GLUT_DLL) $(LDFLAGS) \ + $^ $(LDLIBS) + + + +clean: + -$(call UNLINK,*.o) \ No newline at end of file diff --git a/src/glut/glx/glut_fbc.c b/src/glut/glx/glut_fbc.c index deb46c3d8db..e93188b8622 100644 --- a/src/glut/glx/glut_fbc.c +++ b/src/glut/glx/glut_fbc.c @@ -18,7 +18,7 @@ /* Set a Fortran callback function. */ -void GLUTAPIENTRY +void APIENTRY __glutSetFCB(int which, void *func) { #ifdef SUPPORT_FORTRAN @@ -100,7 +100,7 @@ __glutSetFCB(int which, void *func) /* Get a Fortran callback function. */ -void* GLUTAPIENTRY +void* APIENTRY __glutGetFCB(int which) { #ifdef SUPPORT_FORTRAN diff --git a/src/glut/glx/glutint.h b/src/glut/glx/glutint.h index 6fe09ffe7e7..a962c780238 100644 --- a/src/glut/glx/glutint.h +++ b/src/glut/glx/glutint.h @@ -26,7 +26,10 @@ #include #endif +#ifndef GLUT_BUILDING_LIB #define GLUT_BUILDING_LIB /* Building the GLUT library itself. */ +#endif + #include #if defined(MESA) && defined(_WIN32) && !defined(__CYGWIN32__) diff --git a/src/glut/glx/win32_winproc.c b/src/glut/glx/win32_winproc.c index a54bac75fa0..e1fc785ebb7 100644 --- a/src/glut/glx/win32_winproc.c +++ b/src/glut/glx/win32_winproc.c @@ -9,6 +9,9 @@ #include "glutint.h" #include +#ifdef __MINGW32__ +#include +#endif #if defined(_WIN32) && !defined(__CYGWIN32__) #include /* Win32 Multimedia API header. */ diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw index ebec5c055a8..3b52834bd1c 100644 --- a/src/mesa/Makefile.mgw +++ b/src/mesa/Makefile.mgw @@ -1,5 +1,5 @@ # Mesa 3-D graphics library -# Version: 5.1 +# Version: 7.0 # # Copyright (C) 1999-2003 Brian Paul All Rights Reserved. # @@ -26,6 +26,16 @@ # Email : dborca@users.sourceforge.net # Web : http://www.geocities.com/dborca +# MinGW core-gl makefile updated for Mesa 7.0 +# +# updated : by Heromyth, on 2007-7-21 +# Email : zxpmyth@yahoo.com.cn +# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work. +# The others havn't been tested yet. +# 2) The generated DLLs are *not* compatible with the ones built +# with the other compilers like VC8, especially for GLUT. +# 3) Although more tests are needed, it can be used individually! + # # Available options: @@ -52,7 +62,6 @@ # - .PHONY: all clean .INTERMEDIATE: x86/gen_matypes.exe .SUFFIXES: .rc .res @@ -60,6 +69,8 @@ # Set this to the prefix of your build tools, i.e. mingw32- TOOLS_PREFIX = mingw32- + + TOP = ../.. GLIDE ?= $(TOP)/glide3 LIBDIR = $(TOP)/lib @@ -71,11 +82,25 @@ else GL_IMP = libopengl32.a endif -LDLIBS = -lgdi32 +GL_DEF = gl.def + +include $(TOP)/configs/config.mgw +GL_USING_STDCALL ?= 1 + +MESA_LIB = libmesa.a + +LDLIBS = -lgdi32 -luser32 -liberty +LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GL_IMP) -Wl,--output-def=$(LIBDIR)/gl.def CC = $(TOOLS_PREFIX)gcc -CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -CFLAGS += $(INCLUDE_DIRS) +CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_DLL -DMESA_MINWARN -DNDEBUG -D_USRDLL -DGDI_EXPORTS + +ifeq ($(GL_USING_STDCALL),1) + LDFLAGS += -Wl,--add-stdcall-alias +else + CFLAGS += -DGL_NO_STDCALL +endif + CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1 ifeq ($(FX),1) CFLAGS += -I$(GLIDE)/include -DFX @@ -104,6 +129,8 @@ endif include sources +CFLAGS += $(INCLUDE_DIRS) + ifeq ($(X86),1) CFLAGS += -DUSE_X86_ASM CFLAGS += -DUSE_MMX_ASM @@ -140,10 +167,9 @@ RESOURCE = $(GL_RES:.rc=.res) .c.o: $(CC) -o $@ $(CFLAGS) -c $< -.S.o: - $(CC) -o $@ $(CFLAGS) -c $< .s.o: $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $< + .rc.res: windres -o $@ -Irc -Ocoff $< @@ -153,9 +179,8 @@ $(LIBDIR): mkdir -p $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE) - $(TOOLS_PREFIX)dllwrap -o $(LIBDIR)/$(GL_DLL) --output-lib $(LIBDIR)/$(GL_IMP) \ - --target i386-mingw32 --def $(GL_DEF) -Wl,-enable-stdcall-fixup \ - $^ $(LDLIBS) + $(CC) -shared -fPIC -o $(LIBDIR)/$(GL_DLL) $(LDFLAGS) \ + $^ $(LDLIBS) $(X86_OBJECTS): x86/matypes.h @@ -187,17 +212,21 @@ tnl/t_vtx_x86_gcc.o: tnl/t_vtx_x86_gcc.S $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $< clean: - -$(call UNLINK,array_cache/*.o) -$(call UNLINK,glapi/*.o) -$(call UNLINK,main/*.o) -$(call UNLINK,math/*.o) + -$(call UNLINK,vbo/*.o) -$(call UNLINK,shader/*.o) + -$(call UNLINK,shader/slang/*.o) + -$(call UNLINK,shader/grammar/*.o) -$(call UNLINK,sparc/*.o) -$(call UNLINK,ppc/*.o) -$(call UNLINK,swrast/*.o) -$(call UNLINK,swrast_setup/*.o) -$(call UNLINK,tnl/*.o) -$(call UNLINK,x86/*.o) + -$(call UNLINK,x86/rtasm/*.o) + -$(call UNLINK,x86-64/*.o) -$(call UNLINK,drivers/common/*.o) -$(call UNLINK,drivers/glide/*.o) -$(call UNLINK,drivers/windows/fx/*.o) diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index fb23d210db7..dad3dc11604 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -33,15 +33,30 @@ /* We're essentially building part of GDI here, so define this so that * we get the right export linkage. */ #ifdef __MINGW32__ -#include + +#include +#include +#include +#include + +# if defined(BUILD_GL32) +# define WINGDIAPI __declspec(dllexport) +# else +# define __W32API_USE_DLLIMPORT__ +# endif + +#include +#include "GL/mesa_wgl.h" #include + #else + #define _GDI32_ -#endif #include -#include "glapi.h" +#endif +#include "glapi.h" #include "GL/wmesa.h" /* protos for wmesa* functions */ /* @@ -339,7 +354,7 @@ WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc) } WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat, - const PIXELFORMATDESCRIPTOR *ppfd) + const PIXELFORMATDESCRIPTOR *ppfd) { (void) hdc; @@ -392,12 +407,12 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, bitDevice = CreateCompatibleDC(fontDevice); - // Swap fore and back colors so the bitmap has the right polarity + /* Swap fore and back colors so the bitmap has the right polarity */ tempColor = GetBkColor(bitDevice); SetBkColor(bitDevice, GetTextColor(bitDevice)); SetTextColor(bitDevice, tempColor); - // Place chars based on base line + /* Place chars based on base line */ VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0); for(i = 0; i < (int)numChars; i++) { @@ -410,36 +425,36 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, curChar = (char)(i + firstChar); - // Find how high/wide this character is + /* Find how high/wide this character is */ VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size)); - // Create the output bitmap + /* Create the output bitmap */ charWidth = size.cx; charHeight = size.cy; - // Round up to the next multiple of 32 bits + /* Round up to the next multiple of 32 bits */ bmapWidth = ((charWidth + 31) / 32) * 32; bmapHeight = charHeight; bitObject = CreateCompatibleBitmap(bitDevice, bmapWidth, bmapHeight); - //VERIFY(bitObject); + /* VERIFY(bitObject); */ - // Assign the output bitmap to the device + /* Assign the output bitmap to the device */ origBmap = SelectObject(bitDevice, bitObject); (void) VERIFY(origBmap); VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) ); - // Use our source font on the device + /* Use our source font on the device */ VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT))); - // Draw the character + /* Draw the character */ VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1)); - // Unselect our bmap object + /* Unselect our bmap object */ VERIFY(SelectObject(bitDevice, origBmap)); - // Convert the display dependant representation to a 1 bit deep DIB + /* Convert the display dependant representation to a 1 bit deep DIB */ numBytes = (bmapWidth * bmapHeight) / 8; bmap = malloc(numBytes); dibInfo->bmiHeader.biWidth = bmapWidth; @@ -447,24 +462,24 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap, dibInfo, DIB_RGB_COLORS); - //VERIFY(res); + /* VERIFY(res); */ - // Create the GL object + /* Create the GL object */ glNewList(i + listBase, GL_COMPILE); glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent, (GLfloat)charWidth, 0.0, bmap); glEndList(); - // CheckGL(); + /* CheckGL(); */ - // Destroy the bmap object + /* Destroy the bmap object */ DeleteObject(bitObject); - // Deallocate the bitmap data + /* Deallocate the bitmap data */ free(bmap); } - // Destroy the DC + /* Destroy the DC */ VERIFY(DeleteDC(bitDevice)); free(dibInfo); diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 2eec188912e..5b67439f0f2 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -6,6 +6,7 @@ #include "wmesadef.h" #include "colors.h" #include +#include #include "context.h" #include "extensions.h" #include "framebuffer.h" @@ -114,7 +115,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) { pwfb->cColorBits = GetDeviceCaps(hDC, BITSPIXEL); - // Only 16 and 32 bit targets are supported now + /* Only 16 and 32 bit targets are supported now */ assert(pwfb->cColorBits == 0 || pwfb->cColorBits == 16 || pwfb->cColorBits == 32); @@ -1171,7 +1172,7 @@ WMesaContext WMesaCreateContext(HDC hDC, /* I do not understand this contributed code */ /* Support memory and device contexts */ if(WindowFromDC(hDC) != NULL) { - c->hDC = GetDC(WindowFromDC(hDC)); // huh ???? + c->hDC = GetDC(WindowFromDC(hDC)); /* huh ???? */ } else { c->hDC = hDC; @@ -1404,6 +1405,7 @@ void WMesaSwapBuffers( HDC hdc ) * table entries. Hopefully, I'll find a better solution. The * dispatch table generation scripts ought to be making these dummy * stubs as well. */ +#if !defined(__MINGW32__) || !defined(GL_NO_STDCALL) void gl_dispatch_stub_543(void){} void gl_dispatch_stub_544(void){} void gl_dispatch_stub_545(void){} @@ -1471,3 +1473,4 @@ void gl_dispatch_stub_769(void){} void gl_dispatch_stub_770(void){} void gl_dispatch_stub_771(void){} +#endif diff --git a/src/mesa/drivers/windows/gdi/wmesadef.h b/src/mesa/drivers/windows/gdi/wmesadef.h index 97b063a8bab..83a42e60824 100644 --- a/src/mesa/drivers/windows/gdi/wmesadef.h +++ b/src/mesa/drivers/windows/gdi/wmesadef.h @@ -1,6 +1,8 @@ #ifndef WMESADEF_H #define WMESADEF_H - +#ifdef __MINGW32__ +#include +#endif #include "context.h" diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 63dd002a412..fd4127558a8 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -92,7 +92,7 @@ #endif #ifdef WGLAPI -#undef WGLAPI +# undef WGLAPI #endif #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 8a5dfdb4b80..3ae56c8b0b6 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -575,7 +575,11 @@ _mesa_ffs(int i) * if no bits set. */ int +#ifdef __MINGW32__ +_mesa_ffsll(long val) +#else _mesa_ffsll(long long val) +#endif { #ifdef ffsll return ffsll(val); diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 9be8014a131..ebdfc452a7a 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -700,7 +700,11 @@ extern int _mesa_ffs(int i); extern int +#ifdef __MINGW32__ +_mesa_ffsll(long i); +#else _mesa_ffsll(long long i); +#endif extern unsigned int _mesa_bitcount(unsigned int n); diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index 58be1f46e57..7bf88087670 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -83,7 +83,7 @@ _mesa_CreateShader(GLenum type) } -GLhandleARB APIENTRY +GLhandleARB GLAPIENTRY _mesa_CreateShaderObjectARB(GLenum type) { GET_CURRENT_CONTEXT(ctx); @@ -99,7 +99,7 @@ _mesa_CreateProgram(void) } -GLhandleARB APIENTRY +GLhandleARB GLAPIENTRY _mesa_CreateProgramObjectARB(void) { GET_CURRENT_CONTEXT(ctx); @@ -319,7 +319,7 @@ _mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint * params) #if 0 -GLint APIENTRY +GLint GLAPIENTRY _mesa_GetUniformLocation(GLuint program, const GLcharARB *name) { GET_CURRENT_CONTEXT(ctx); @@ -336,7 +336,7 @@ _mesa_GetHandleARB(GLenum pname) } -GLint APIENTRY +GLint GLAPIENTRY _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name) { GET_CURRENT_CONTEXT(ctx); diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 411d51cfcc6..b6991f45ed8 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -302,7 +302,12 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = { #define FX64_NATIVE 1 +#ifdef __MINGW32__ +typedef unsigned long Fx64; +#else typedef unsigned long long Fx64; +#endif + #define FX64_MOV32(a, b) a = b #define FX64_OR32(a, b) a |= b -- cgit v1.2.3 From da2f1e88bc63403a95b89706905c070b7c894863 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 23 Jul 2007 16:51:57 -0600 Subject: fix GLX_STEREO handling (bug 11705) --- src/mesa/drivers/x11/fakeglx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 1587df66bcd..7a170b4d3d1 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -296,6 +296,11 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, } } + if (stereoFlag) { + /* stereo not supported */ + return NULL; + } + /* Comparing IDs uses less memory but sometimes fails. */ /* XXX revisit this after 3.0 is finished. */ if (_mesa_getenv("MESA_GLX_VISUAL_HACK")) @@ -1079,7 +1084,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) else { stereo_flag = GL_TRUE; } - return NULL; /* stereo not supported */ + break; case GLX_AUX_BUFFERS: parselist++; numAux = *parselist++; -- cgit v1.2.3 From 5b6858c023fca9d8eefce78121aabd9aad108e09 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 24 Jul 2007 09:56:44 -0600 Subject: call ctx->Driver.NewProgram() instead of _mesa_new_program() --- src/mesa/shader/program.c | 2 +- src/mesa/shader/slang/slang_compile.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 42059198282..1f227390afd 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -333,7 +333,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog) { struct gl_program *clone; - clone = _mesa_new_program(ctx, prog->Target, prog->Id); + clone = ctx->Driver.NewProgram(ctx, prog->Target, prog->Id); if (!clone) return NULL; diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 70f5aac16d4..4e29e8dcc90 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -2135,7 +2135,7 @@ _slang_compile(GLcontext *ctx, struct gl_shader *shader) progTarget = GL_FRAGMENT_PROGRAM_ARB; shader->Programs = (struct gl_program **) malloc(sizeof(struct gl_program*)); - shader->Programs[0] = _mesa_new_program(ctx, progTarget, 1); + shader->Programs[0] = ctx->Driver.NewProgram(ctx, progTarget, 1); shader->NumPrograms = 1; shader->Programs[0]->Parameters = _mesa_new_parameter_list(); -- cgit v1.2.3 From 03ec41ddc51e539c989a546f33d22daa2af69095 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 24 Jul 2007 17:45:14 -0600 Subject: remove unused MAX_3D_TEXTURE_SIZE, reformattting --- src/mesa/main/mtypes.h | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a5fdd88262e..3e4c49249a0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1131,13 +1131,13 @@ struct gl_stencil_attrib * An index for each type of texture object */ /*@{*/ -#define TEXTURE_1D_INDEX 0 -#define TEXTURE_2D_INDEX 1 -#define TEXTURE_3D_INDEX 2 -#define TEXTURE_CUBE_INDEX 3 -#define TEXTURE_RECT_INDEX 4 -#define TEXTURE_1D_ARRAY_INDEX 5 -#define TEXTURE_2D_ARRAY_INDEX 6 +#define TEXTURE_1D_INDEX 0 +#define TEXTURE_2D_INDEX 1 +#define TEXTURE_3D_INDEX 2 +#define TEXTURE_CUBE_INDEX 3 +#define TEXTURE_RECT_INDEX 4 +#define TEXTURE_1D_ARRAY_INDEX 5 +#define TEXTURE_2D_ARRAY_INDEX 6 /*@}*/ /** @@ -1145,13 +1145,13 @@ struct gl_stencil_attrib * Used for Texture.Unit[]._ReallyEnabled flags. */ /*@{*/ -#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) -#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) -#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) -#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) -#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) -#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) -#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) +#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX) +#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX) +#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX) +#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX) +#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX) +#define TEXTURE_1D_ARRAY_BIT (1 << TEXTURE_1D_ARRAY_INDEX) +#define TEXTURE_2D_ARRAY_BIT (1 << TEXTURE_2D_ARRAY_INDEX) /*@}*/ @@ -1325,8 +1325,6 @@ struct gl_texture_format }; -#define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1)) - /** * Texture image state. Describes the dimensions of a texture image, * the texel format and pointers to Texel Fetch functions. @@ -1391,7 +1389,7 @@ struct gl_texture_image #define FACE_NEG_Y 3 #define FACE_POS_Z 4 #define FACE_NEG_Z 5 -#define MAX_FACES 6 +#define MAX_FACES 6 /*@}*/ @@ -2191,12 +2189,11 @@ struct gl_shared_state * \todo Improve the granularity of locking. */ /*@{*/ - _glthread_Mutex TexMutex; /**< texobj thread safety */ - GLuint TextureStateStamp; /**< state notification for shared tex */ + _glthread_Mutex TexMutex; /**< texobj thread safety */ + GLuint TextureStateStamp; /**< state notification for shared tex */ /*@}*/ - /** * \name Vertex/fragment programs */ -- cgit v1.2.3 From efda5cb6263631175aa2efe46df9322b3c5775ee Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 08:22:09 -0600 Subject: don't use rgba_line() if CHAN_BITS==32 --- src/mesa/swrast/s_lines.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c index 15ef6233eda..3de438760b5 100644 --- a/src/mesa/swrast/s_lines.c +++ b/src/mesa/swrast/s_lines.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -279,7 +279,11 @@ _swrast_choose_line( GLcontext *ctx ) || ctx->Line.StippleFlag) { /* no texture, but Z, fog, width>1, stipple, etc. */ if (rgbmode) +#if CHAN_BITS == 32 + USE(general_line); +#else USE(rgba_line); +#endif else USE(ci_line); } -- cgit v1.2.3 From 51b728cf9aff383142a2a1e220a7d8963d1ca189 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 08:22:28 -0600 Subject: fix color interpolation for CHAN_BITS==32 --- src/mesa/swrast/s_span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index f23272c2bee..cfc65bee87f 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1358,7 +1358,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) #if CHAN_BITS == 32 if ((span->arrayAttribs & FRAG_BIT_COL0) == 0) { - interpolate_int_colors(ctx, span); + interpolate_active_attribs(ctx, span, FRAG_BIT_COL0); } #else if ((span->arrayMask & SPAN_RGBA) == 0) { -- cgit v1.2.3 From 9ed040c3c9afe06a8f6b28bc223751e3b2d65fe3 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 11:39:11 -0600 Subject: generate error upon writing to varying var in fragment program (bug 11733) --- src/mesa/shader/slang/slang_codegen.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 35e80e04523..c1664a5ccbc 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2236,7 +2236,9 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper) } if (var->type.qualifier == SLANG_QUAL_CONST || var->type.qualifier == SLANG_QUAL_ATTRIBUTE || - var->type.qualifier == SLANG_QUAL_UNIFORM) { + var->type.qualifier == SLANG_QUAL_UNIFORM || + (var->type.qualifier == SLANG_QUAL_VARYING && + A->program->Target == GL_FRAGMENT_PROGRAM_ARB)) { slang_info_log_error(A->log, "illegal assignment to read-only variable '%s'", (char *) oper->children[0].a_id); @@ -2264,10 +2266,11 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper) lhs = _slang_gen_operation(A, &oper->children[0]); if (lhs) { - if (lhs->Store->File != PROGRAM_OUTPUT && - lhs->Store->File != PROGRAM_TEMPORARY && - lhs->Store->File != PROGRAM_VARYING && - lhs->Store->File != PROGRAM_UNDEFINED) { + if (!(lhs->Store->File == PROGRAM_OUTPUT || + lhs->Store->File == PROGRAM_TEMPORARY || + (lhs->Store->File == PROGRAM_VARYING && + A->program->Target == GL_VERTEX_PROGRAM_ARB) || + lhs->Store->File == PROGRAM_UNDEFINED)) { slang_info_log_error(A->log, "illegal assignment to read-only l-value"); return NULL; -- cgit v1.2.3 From e3cef5887540016a6d198598cb50bebe09e3f4cf Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 15:32:02 -0600 Subject: Fix function call bug 11731. Also, fix up IR_CALL/IR_FUNC confusion. --- src/mesa/shader/slang/slang_codegen.c | 27 +++++++++++++++++++-------- src/mesa/shader/slang/slang_emit.c | 16 +++++++++------- src/mesa/shader/slang/slang_ir.c | 2 +- src/mesa/shader/slang/slang_ir.h | 2 -- 4 files changed, 29 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index c1664a5ccbc..8b2bdd74b59 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -536,7 +536,7 @@ new_not(slang_ir_node *n) static slang_ir_node * new_inlined_function_call(slang_ir_node *code, slang_label *name) { - slang_ir_node *n = new_node1(IR_FUNC, code); + slang_ir_node *n = new_node1(IR_CALL, code); assert(name); if (n) n->Label = name; @@ -1202,17 +1202,29 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun, /* non-assembly function */ inlined = slang_inline_function_call(A, fun, oper, dest); if (inlined && _slang_find_node_type(inlined, SLANG_OPER_RETURN)) { - /* This inlined function has one or more 'return' statements. + slang_operation *callOper; + /* The function we're calling has one or more 'return' statements. * So, we can't truly inline this function because we need to * implement 'return' with RET (and CAL). + * Nevertheless, we performed "inlining" to make a new instance + * of the function body to deal with static register allocation. + * * XXX check if there's one 'return' and if it's the very last * statement in the function - we can optimize that case. */ assert(inlined->type == SLANG_OPER_BLOCK_NEW_SCOPE || inlined->type == SLANG_OPER_SEQUENCE); - inlined->type = SLANG_OPER_INLINED_CALL; - inlined->fun = fun; - inlined->label = _slang_label_new_unique((char*) fun->header.a_name); + if (_slang_function_has_return_value(fun) && !dest) { + assert(inlined->children[0].type == SLANG_OPER_VARIABLE_DECL); + assert(inlined->children[2].type == SLANG_OPER_IDENTIFIER); + callOper = &inlined->children[1]; + } + else { + callOper = inlined; + } + callOper->type = SLANG_OPER_INLINED_CALL; + callOper->fun = fun; + callOper->label = _slang_label_new_unique((char*) fun->header.a_name); } } @@ -1949,8 +1961,7 @@ static slang_ir_node * _slang_gen_return(slang_assemble_ctx * A, slang_operation *oper) { const GLboolean haveReturnValue - = (oper->num_children == 1 && - oper->children[0].type != SLANG_OPER_VOID); + = (oper->num_children == 1 && oper->children[0].type != SLANG_OPER_VOID); /* error checking */ assert(A->CurFunction); @@ -1960,7 +1971,7 @@ _slang_gen_return(slang_assemble_ctx * A, slang_operation *oper) return NULL; } else if (!haveReturnValue && - A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) { + A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) { slang_info_log_error(A->log, "return statement requires an expression"); return NULL; } diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 02c74095a9e..fe13f2865cd 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -780,16 +780,18 @@ emit_label(slang_emit_info *emitInfo, const slang_ir_node *n) /** - * Emit code for an inlined function call (subroutine). + * Emit code for a function call. + * Note that for each time a function is called, we emit the function's + * body code again because the set of available registers may be different. */ static struct prog_instruction * -emit_func(slang_emit_info *emitInfo, slang_ir_node *n) +emit_fcall(slang_emit_info *emitInfo, slang_ir_node *n) { struct gl_program *progSave; struct prog_instruction *inst; GLuint subroutineId; - assert(n->Opcode == IR_FUNC); + assert(n->Opcode == IR_CALL); assert(n->Label); /* save/push cur program */ @@ -1687,10 +1689,10 @@ emit(slang_emit_info *emitInfo, slang_ir_node *n) case IR_KILL: return emit_kill(emitInfo); - case IR_FUNC: - /* new variable scope for subroutines/function calls*/ + case IR_CALL: + /* new variable scope for subroutines/function calls */ _slang_push_var_table(emitInfo->vt); - inst = emit_func(emitInfo, n); + inst = emit_fcall(emitInfo, n); _slang_pop_var_table(emitInfo->vt); return inst; @@ -1782,7 +1784,7 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo) emitInfo->NumSubroutines = 0; /* Examine CAL instructions. - * At this point, the BranchTarget field of the CAL instructions is + * At this point, the BranchTarget field of the CAL instruction is * the number/id of the subroutine to call (an index into the * emitInfo->Subroutines list). * Translate that into an actual instruction location now. diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c index a29f3026873..92e8d0345ee 100644 --- a/src/mesa/shader/slang/slang_ir.c +++ b/src/mesa/shader/slang/slang_ir.c @@ -311,7 +311,7 @@ _slang_print_ir_tree(const slang_ir_node *n, int indent) printf("RETURN\n"); break; case IR_CALL: - printf("CALL\n"); + printf("CALL %s\n", n->Label->Name); break; case IR_LOOP: diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index 69db4b5451e..c7c0ddbf9a6 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -62,8 +62,6 @@ typedef enum IR_RETURN, /* return from subroutine */ IR_CALL, /* call subroutine */ - IR_FUNC, /* inlined function code */ - IR_LOOP, /* high-level loop-begin / loop-end */ /* Children[0] = loop body */ /* Children[1] = loop tail code, or NULL */ -- cgit v1.2.3 From 0fb0d9715c9bcdcc3437a64a0f03c1c1153e9f29 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 26 Jul 2007 16:42:05 -0600 Subject: fix-up inlined/non-inlined function inconsistencies --- src/mesa/shader/slang/slang_codegen.c | 19 +++++++++++-------- src/mesa/shader/slang/slang_compile_operation.h | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 8b2bdd74b59..24185cf6770 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -491,6 +491,9 @@ new_node0(slang_ir_opcode op) } +/** + * Create sequence of two nodes. + */ static slang_ir_node * new_seq(slang_ir_node *left, slang_ir_node *right) { @@ -531,10 +534,10 @@ new_not(slang_ir_node *n) /** - * Inlined subroutine. + * Non-inlined function call. */ static slang_ir_node * -new_inlined_function_call(slang_ir_node *code, slang_label *name) +new_function_call(slang_ir_node *code, slang_label *name) { slang_ir_node *n = new_node1(IR_CALL, code); assert(name); @@ -1222,7 +1225,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun, else { callOper = inlined; } - callOper->type = SLANG_OPER_INLINED_CALL; + callOper->type = SLANG_OPER_NON_INLINED_CALL; callOper->fun = fun; callOper->label = _slang_label_new_unique((char*) fun->header.a_name); } @@ -2585,7 +2588,7 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper) _slang_free_ir_tree(tree); return NULL; /* error must have occured */ } - tree = tree ? new_seq(tree, n) : n; + tree = new_seq(tree, n); } #if 00 @@ -2813,17 +2816,17 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper) return n; } - case SLANG_OPER_INLINED_CALL: + case SLANG_OPER_NON_INLINED_CALL: case SLANG_OPER_SEQUENCE: { slang_ir_node *tree = NULL; GLuint i; for (i = 0; i < oper->num_children; i++) { slang_ir_node *n = _slang_gen_operation(A, &oper->children[i]); - tree = tree ? new_seq(tree, n) : n; + tree = new_seq(tree, n); } - if (oper->type == SLANG_OPER_INLINED_CALL) { - tree = new_inlined_function_call(tree, oper->label); + if (oper->type == SLANG_OPER_NON_INLINED_CALL) { + tree = new_function_call(tree, oper->label); } return tree; } diff --git a/src/mesa/shader/slang/slang_compile_operation.h b/src/mesa/shader/slang/slang_compile_operation.h index d497b6f66f7..d5cbe779a6c 100644 --- a/src/mesa/shader/slang/slang_compile_operation.h +++ b/src/mesa/shader/slang/slang_compile_operation.h @@ -93,7 +93,7 @@ typedef enum slang_operation_type_ SLANG_OPER_NOT, /* "!" [expr] */ SLANG_OPER_SUBSCRIPT, /* [expr] "[" [expr] "]" */ SLANG_OPER_CALL, /* [func name] [param] [param] [...] */ - SLANG_OPER_INLINED_CALL, /* inlined function call */ + SLANG_OPER_NON_INLINED_CALL, /* a real function call */ SLANG_OPER_FIELD, /* i.e.: ".next" or ".xzy" or ".xxx" etc */ SLANG_OPER_POSTINCREMENT, /* [var] "++" */ SLANG_OPER_POSTDECREMENT /* [var] "--" */ -- cgit v1.2.3 From 35f35294cd5cc3ca32354b1de0e398ad73c70716 Mon Sep 17 00:00:00 2001 From: Zhang Date: Fri, 27 Jul 2007 11:19:35 -0600 Subject: more Mingw32 fixes --- docs/README.MINGW32 | 22 ++++++++++++++++---- include/GL/gl.h | 6 +----- include/GL/glut.h | 2 +- include/GL/mesa_wgl.h | 3 --- progs/samples/Makefile.mgw | 21 +++---------------- src/glu/sgi/Makefile.mgw | 35 ++++++++++++++++--------------- src/glut/glx/Makefile.mgw | 41 +++++++++++++++--------------------- src/mesa/Makefile.mgw | 52 +++++++++++++++++++++++----------------------- 8 files changed, 84 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/docs/README.MINGW32 b/docs/README.MINGW32 index 138dd43eacc..9477b2bd318 100644 --- a/docs/README.MINGW32 +++ b/docs/README.MINGW32 @@ -91,9 +91,11 @@ Running the Build: -*******************This section is added by Heromyth***************************** -Updated on 2007-7-21, by Heromyth +******This section is added by Heromyth ************* +==================== +Updated on 2007-7-21 +==================== Notice: 1) The generated DLLs are *not* compatible with the ones built @@ -115,7 +117,7 @@ For example, run: , and delete all the lines where all the wgl*() functions are. Because they would be conflicted with the ones in \include\GL\mesa_wgl.h. -======= Conflicted Functions List ====== +>>>>>>>>>> Conflicted Functions List >>>>>>>>>> WINGDIAPI BOOL WINAPI wglCopyContext(HGLRC,HGLRC,UINT); WINGDIAPI HGLRC WINAPI wglCreateContext(HDC); WINGDIAPI HGLRC WINAPI wglCreateLayerContext(HDC,int); @@ -134,6 +136,18 @@ WINGDIAPI BOOL WINAPI wglUseFontBitmapsA(HDC,DWORD,DWORD,DWORD); WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC,DWORD,DWORD,DWORD); WINGDIAPI BOOL WINAPI wglUseFontOutlinesA(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT); WINGDIAPI BOOL WINAPI wglUseFontOutlinesW(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT); -=================== +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +==================== +Updated on 2007-7-22 +==================== + I havn't thought that I would find a better way to solve my problems so soon. +I changed the method in which the import-libs and DLLs are made. After this update, +the DLLs of MESA are more optimized and more compatible. + It seems that there is no need to keep the building way of 'NO-STDCALL'.The +way of USING_STDCALL is so nice! The file \configs\config.mgw is +also not needed, and can be deleted safely! + + ********************************************************************************* \ No newline at end of file diff --git a/include/GL/gl.h b/include/GL/gl.h index 09195aa1361..3891a718751 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -58,11 +58,7 @@ # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern # endif /* _STATIC_MESA support */ -# if defined(__MINGW32__) && defined(GL_NO_STDCALL) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ -# define GLAPIENTRY -# else -# define GLAPIENTRY __stdcall -# endif +# define GLAPIENTRY __stdcall #elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern # define GLAPIENTRY __stdcall diff --git a/include/GL/glut.h b/include/GL/glut.h index e286349f9b0..137b8efa13a 100644 --- a/include/GL/glut.h +++ b/include/GL/glut.h @@ -112,7 +112,7 @@ extern _CRTIMP void __cdecl exit(int); and redifinition of Windows system defs, also removes requirement of pretty much any standard windows header from this file */ -#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__) +#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__) # define GLUTAPIENTRY __stdcall #else # define GLUTAPIENTRY diff --git a/include/GL/mesa_wgl.h b/include/GL/mesa_wgl.h index 1d774571d94..57147232b7f 100644 --- a/include/GL/mesa_wgl.h +++ b/include/GL/mesa_wgl.h @@ -81,8 +81,6 @@ WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *) WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR); WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc); - -#if defined(GL_NO_STDCALL) || !defined(__MINGW32__) WGLAPI int GLAPIENTRY wglCopyContext(HGLRC, HGLRC, unsigned int); WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC); WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int); @@ -101,7 +99,6 @@ WGLAPI int GLAPIENTRY wglUseFontBitmapsA(HDC, unsigned long, unsigned long, un WGLAPI int GLAPIENTRY wglUseFontBitmapsW(HDC, unsigned long, unsigned long, unsigned long); WGLAPI int GLAPIENTRY wglUseFontOutlinesA(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT); WGLAPI int GLAPIENTRY wglUseFontOutlinesW(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT); -#endif #ifndef __MINGW32__ WGLAPI int GLAPIENTRY SwapBuffers(HDC); diff --git a/progs/samples/Makefile.mgw b/progs/samples/Makefile.mgw index 3b2fd785def..8bb975be9da 100644 --- a/progs/samples/Makefile.mgw +++ b/progs/samples/Makefile.mgw @@ -53,14 +53,9 @@ TOP = ../.. -include $(TOP)/configs/config.mgw -ALL_USING_STDCALL ?= 1 -GL_USING_STDCALL ?= 1 -GLUT_USING_STDCALL ?= 1 - CC = mingw32-gcc CFLAGS = -Wall -pedantic -CFLAGS += -O2 -ffast-math +CFLAGS += -O2 -ffast-math -D_DLL CFLAGS += -I$(TOP)/include -I../util ifeq ($(FX),1) CFLAGS += -DFX @@ -68,17 +63,6 @@ endif CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK -ifeq ($(GL_USING_STDCALL),0) - CFLAGS += -DGL_NO_STDCALL -endif - -ifeq ($(GLUT_USING_STDCALL),1) - CFLAGS += -D_STDCALL_SUPPORTED -else - CFLAGS += -DGLUT_NO_STDCALL -endif - - LD = mingw32-g++ LDFLAGS = -s -L$(TOP)/lib @@ -87,7 +71,8 @@ LDLIBS = -lglut32 -lglu32 -lopengl32 .c.o: $(CC) -o $@ $(CFLAGS) -c $< %.exe: ../util/readtex.o ../util/showbuffer.o %.o - $(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) + $(LD) -o $@ $(LDFLAGS) $(LDLIBS) $^ + all: $(error Must specify to build) diff --git a/src/glu/sgi/Makefile.mgw b/src/glu/sgi/Makefile.mgw index 43b421e737a..d00d97a3b61 100644 --- a/src/glu/sgi/Makefile.mgw +++ b/src/glu/sgi/Makefile.mgw @@ -70,30 +70,31 @@ TOOLS_PREFIX = mingw32- TOP = ../../.. - LIBDIR = $(TOP)/lib -GLU_DLL = glu32.dll -GLU_IMP = libglu32.a -GLU_DEF = glu.def +LIB_NAME = glu32 +DLL_EXT = .dll +IMP_EXT = .a +LIB_PRE = lib +STRIP = -s + +AR = ar +ARFLAGS = crus +DLLTOOL = dlltool -include $(TOP)/configs/config.mgw -GL_USING_STDCALL ?= 1 +GLU_DLL = $(LIB_NAME)$(DLL_EXT) +GLU_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT) +GLU_DEF = $(LIB_NAME).def LDLIBS = -L$(LIBDIR) -lopengl32 -LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLU_IMP) -Wl,--output-def=$(LIBDIR)/$(GLU_DEF) +LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at CFLAGS += -DBUILD_GLU32 -D_DLL -ifeq ($(GL_USING_STDCALL),1) - LDFLAGS += -Wl,--add-stdcall-alias -else - CFLAGS += -DGL_NO_STDCALL -endif -CC = gcc +CC = $(TOOLS_PREFIX)gcc CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude -CXX = g++ +CXX = $(TOOLS_PREFIX)g++ CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess AR = ar @@ -216,9 +217,9 @@ $(LIBDIR): mkdir -p $(LIBDIR) $(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP): $(OBJECTS) - g++ -shared -fPIC -o $(LIBDIR)/$(GLU_DLL) $(LDFLAGS) \ - $^ $(LDLIBS) - + $(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLU_DLL) $^ $(LDLIBS) + $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLU_DEF) $^ + $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLU_IMP) --def $(LIBDIR)/$(GLU_DEF) clean: diff --git a/src/glut/glx/Makefile.mgw b/src/glut/glx/Makefile.mgw index ae4eb6addc5..9fff2e1503d 100644 --- a/src/glut/glx/Makefile.mgw +++ b/src/glut/glx/Makefile.mgw @@ -74,35 +74,29 @@ TOP = ../../.. LIBDIR = $(TOP)/lib -GLUT_DLL = glut32.dll -GLUT_IMP = libglut32.a -GLUT_DEF = glut.def +LIB_NAME = glut32 -include $(TOP)/configs/config.mgw -GLUT_USING_STDCALL ?= 1 +DLL_EXT = .dll +IMP_EXT = .a +LIB_PRE = lib +STRIP = -s +AR = ar +ARFLAGS = crus +DLLTOOL = dlltool +GLUT_DLL = $(LIB_NAME)$(DLL_EXT) +GLUT_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT) +GLUT_DEF = $(LIB_NAME).def LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32 -LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GLUT_IMP) -Wl,--output-def=$(LIBDIR)/$(GLUT_DEF) +LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL - -ifeq ($(GL_USING_STDCALL),0) - CFLAGS += -DGL_NO_STDCALL -endif - -ifeq ($(GLUT_USING_STDCALL),1) - CFLAGS += -D_STDCALL_SUPPORTED - LDFLAGS += -Wl,--add-stdcall-alias -else - CFLAGS += -DGLUT_NO_STDCALL -endif - CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -CC = gcc -CXX = g++ +CC = $(TOOLS_PREFIX)gcc +CXX = $(TOOLS_PREFIX)g++ CXXFLAGS = $(CFLAGS) AR = ar @@ -189,10 +183,9 @@ $(LIBDIR): mkdir -p $(LIBDIR) $(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS) - $(CXX) -shared -fPIC -o $(LIBDIR)/$(GLUT_DLL) $(LDFLAGS) \ - $^ $(LDLIBS) - - + $(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLUT_DLL) $^ $(LDLIBS) + $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLUT_DEF) $^ + $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLUT_IMP) --def $(LIBDIR)/$(GLUT_DEF) clean: -$(call UNLINK,*.o) \ No newline at end of file diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw index 3b52834bd1c..6244ded8768 100644 --- a/src/mesa/Makefile.mgw +++ b/src/mesa/Makefile.mgw @@ -69,39 +69,37 @@ # Set this to the prefix of your build tools, i.e. mingw32- TOOLS_PREFIX = mingw32- +ifeq ($(ICD),1) + LIB_NAME = mesa32 +else + LIB_NAME = opengl32 +endif +DLL_EXT = .dll +IMP_EXT = .a +LIB_PRE = lib +STRIP = -s + +AR = ar +ARFLAGS = crus +DLLTOOL = dlltool TOP = ../.. GLIDE ?= $(TOP)/glide3 LIBDIR = $(TOP)/lib -ifeq ($(ICD),1) - GL_DLL = mesa32.dll - GL_IMP = libmesa32.a -else - GL_DLL = opengl32.dll - GL_IMP = libopengl32.a -endif - -GL_DEF = gl.def -include $(TOP)/configs/config.mgw -GL_USING_STDCALL ?= 1 +GL_DLL = $(LIB_NAME)$(DLL_EXT) +GL_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT) MESA_LIB = libmesa.a +CC = $(TOOLS_PREFIX)gcc LDLIBS = -lgdi32 -luser32 -liberty -LDFLAGS = -Wl,--out-implib=$(LIBDIR)/$(GL_IMP) -Wl,--output-def=$(LIBDIR)/gl.def - -CC = $(TOOLS_PREFIX)gcc -CFLAGS += -DBUILD_GL32 -D_OPENGL32_ -D_DLL -DMESA_MINWARN -DNDEBUG -D_USRDLL -DGDI_EXPORTS +LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at -ifeq ($(GL_USING_STDCALL),1) - LDFLAGS += -Wl,--add-stdcall-alias -else - CFLAGS += -DGL_NO_STDCALL -endif +CFLAGS += -DBUILD_GL32 -D_DLL -DMESA_MINWARN +CFLAGS += -DNDEBUG -DUSE_EXTERNAL_DXTN_LIB=1 -CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1 ifeq ($(FX),1) CFLAGS += -I$(GLIDE)/include -DFX LDLIBS += -L$(GLIDE)/lib -lglide3x @@ -112,12 +110,11 @@ else CFLAGS += -DUSE_MGL_NAMESPACE GL_DEF = drivers/windows/icd/mesa.def else - GL_DEF = drivers/windows/gdi/mesa.def + GL_DEF = $(LIB_NAME).def endif endif -AR = ar -ARFLAGS = crus + UNLINK = del $(subst /,\,$(1)) ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),) @@ -173,14 +170,17 @@ RESOURCE = $(GL_RES:.rc=.res) .rc.res: windres -o $@ -Irc -Ocoff $< + all: $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP) $(LIBDIR): mkdir -p $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE) - $(CC) -shared -fPIC -o $(LIBDIR)/$(GL_DLL) $(LDFLAGS) \ - $^ $(LDLIBS) + $(CC) $(LDFLAGS) -o $(LIBDIR)/$(GL_DLL) $^ $(LDLIBS) + $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GL_DEF) $^ + $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GL_IMP) --def $(LIBDIR)/$(GL_DEF) + $(X86_OBJECTS): x86/matypes.h -- cgit v1.2.3 From a188ba4bf9364df24842d8727f4c7ddb2f894a2c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 29 Jul 2007 18:04:28 +0200 Subject: Fix crashes when the frag prog can't be handled in hardware (#11131) Must not change to/from swrast after Render.Start or bad things will happen. (Driver will still somewhat incorrectly report an implementation error, and apps can't really figure out if a prog is natively supported as validation is later - could try doing it earlier to give some hint at least, even though native status may still change later due to fog etc.) --- src/mesa/drivers/dri/i915tex/i830_vtbl.c | 6 ++++++ src/mesa/drivers/dri/i915tex/i915_vtbl.c | 8 +++++++- src/mesa/drivers/dri/i915tex/intel_context.h | 1 + src/mesa/drivers/dri/i915tex/intel_render.c | 2 ++ 4 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c index e432648ada0..a3db6c0c0cd 100644 --- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c @@ -60,6 +60,11 @@ do { \ #define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2)) #define TEXBIND_SET(n, x) ((x)<<((n)*4)) +static void +i830_render_prevalidate(struct intel_context *intel) +{ +} + static void i830_render_start(struct intel_context *intel) { @@ -657,5 +662,6 @@ i830InitVtbl(struct i830_context *i830) i830->intel.vtbl.update_texture_state = i830UpdateTextureState; i830->intel.vtbl.flush_cmd = i830_flush_cmd; i830->intel.vtbl.render_start = i830_render_start; + i830->intel.vtbl.render_prevalidate = i830_render_prevalidate; i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty; } diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index ad333b490b7..9de35d8e297 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -44,13 +44,18 @@ #include "i915_context.h" static void -i915_render_start(struct intel_context *intel) +i915_render_prevalidate(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); i915ValidateFragmentProgram(i915); } +static void +i915_render_start(struct intel_context *intel) +{ +} + static void i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) @@ -546,6 +551,7 @@ i915InitVtbl(struct i915_context *i915) i915->intel.vtbl.lost_hardware = i915_lost_hardware; i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state; i915->intel.vtbl.render_start = i915_render_start; + i915->intel.vtbl.render_prevalidate = i915_render_prevalidate; i915->intel.vtbl.set_draw_region = i915_set_draw_region; i915->intel.vtbl.update_texture_state = i915UpdateTextureState; i915->intel.vtbl.flush_cmd = i915_flush_cmd; diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index 9d060eb866f..ddd1439b004 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -131,6 +131,7 @@ struct intel_context void (*update_texture_state) (struct intel_context * intel); void (*render_start) (struct intel_context * intel); + void (*render_prevalidate) (struct intel_context * intel); void (*set_draw_region) (struct intel_context * intel, struct intel_region * draw_region, struct intel_region * depth_region); diff --git a/src/mesa/drivers/dri/i915tex/intel_render.c b/src/mesa/drivers/dri/i915tex/intel_render.c index f9fa55051ea..c8b6d308d96 100644 --- a/src/mesa/drivers/dri/i915tex/intel_render.c +++ b/src/mesa/drivers/dri/i915tex/intel_render.c @@ -202,6 +202,8 @@ intel_run_render(GLcontext * ctx, struct tnl_pipeline_stage *stage) struct vertex_buffer *VB = &tnl->vb; GLuint i; + intel->vtbl.render_prevalidate( intel ); + /* Don't handle clipping or indexed vertices. */ if (intel->RenderIndex != 0 || -- cgit v1.2.3 From 10f5a6ac85fb5f78069b7314e40a2a23e2636192 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 29 Jul 2007 18:31:36 +0200 Subject: fix fallback crashes when driver can't handle frag prog for i915 driver too (untested) --- src/mesa/drivers/dri/i915/i830_vtbl.c | 6 ++++++ src/mesa/drivers/dri/i915/i915_vtbl.c | 8 +++++++- src/mesa/drivers/dri/i915/intel_context.h | 1 + src/mesa/drivers/dri/i915/intel_render.c | 2 ++ src/mesa/drivers/dri/i915tex/i915_context.h | 6 ------ 5 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index d40cf705a35..cf1d0b0c1e3 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -59,6 +59,11 @@ do { \ #define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2)) #define TEXBIND_SET(n, x) ((x)<<((n)*4)) + static void +i830_render_prevalidate(struct intel_context *intel) +{ +} + static void i830_render_start( intelContextPtr intel ) { GLcontext *ctx = &intel->ctx; @@ -531,4 +536,5 @@ void i830InitVtbl( i830ContextPtr i830 ) i830->intel.vtbl.update_texture_state = i830UpdateTextureState; i830->intel.vtbl.emit_flush = i830_emit_flush; i830->intel.vtbl.render_start = i830_render_start; + i830->intel.vtbl.render_prevalidate = i830_render_prevalidate; } diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index cc8a605e505..4ad95cf4e36 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -41,7 +41,8 @@ #include "i915_reg.h" #include "i915_context.h" -static void i915_render_start( intelContextPtr intel ) +static void +i915_render_prevalidate(struct intel_context *intel) { GLcontext *ctx = &intel->ctx; i915ContextPtr i915 = I915_CONTEXT(intel); @@ -54,6 +55,10 @@ static void i915_render_start( intelContextPtr intel ) } } +static void i915_render_start( intelContextPtr intel ) +{ +} + static void i915_reduced_primitive_state( intelContextPtr intel, GLenum rprim ) @@ -454,6 +459,7 @@ void i915InitVtbl( i915ContextPtr i915 ) i915->intel.vtbl.lost_hardware = i915_lost_hardware; i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state; i915->intel.vtbl.render_start = i915_render_start; + i915->intel.vtbl.render_prevalidate = i915_render_prevalidate; i915->intel.vtbl.set_color_region = i915_set_color_region; i915->intel.vtbl.set_z_region = i915_set_z_region; i915->intel.vtbl.update_color_z_regions = i915_update_color_z_regions; diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h index 3b50107d73f..914533d11be 100644 --- a/src/mesa/drivers/dri/i915/intel_context.h +++ b/src/mesa/drivers/dri/i915/intel_context.h @@ -112,6 +112,7 @@ struct intel_context void (*update_texture_state)( intelContextPtr intel ); void (*render_start)( intelContextPtr intel ); + void (*render_prevalidate) (struct intel_context * intel); void (*set_color_region)( intelContextPtr intel, const intelRegion *reg ); void (*set_z_region)( intelContextPtr intel, const intelRegion *reg ); void (*update_color_z_regions)(intelContextPtr intel, diff --git a/src/mesa/drivers/dri/i915/intel_render.c b/src/mesa/drivers/dri/i915/intel_render.c index d9438ba0fd8..7bc02ba8073 100644 --- a/src/mesa/drivers/dri/i915/intel_render.c +++ b/src/mesa/drivers/dri/i915/intel_render.c @@ -199,6 +199,8 @@ static GLboolean intel_run_render( GLcontext *ctx, struct vertex_buffer *VB = &tnl->vb; GLuint i; + intel->vtbl.render_prevalidate( intel ); + /* Don't handle clipping or indexed vertices. */ if (intel->RenderIndex != 0 || diff --git a/src/mesa/drivers/dri/i915tex/i915_context.h b/src/mesa/drivers/dri/i915tex/i915_context.h index d2713e88f96..3a41d66c148 100644 --- a/src/mesa/drivers/dri/i915tex/i915_context.h +++ b/src/mesa/drivers/dri/i915tex/i915_context.h @@ -308,12 +308,6 @@ extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, void *sharedContextPrivate); -/*====================================================================== - * i915_texprog.c - */ -extern void i915ValidateTextureProgram(struct i915_context *i915); - - /*====================================================================== * i915_debug.c */ -- cgit v1.2.3 From dde814776c1feee30e986858782c14d9b0feeaea Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 29 Jul 2007 19:40:50 +0200 Subject: fix range reduction for sin/cos in i915tex (#11609) --- src/mesa/drivers/dri/i915tex/i915_fragprog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c index a4b22a0c32c..95ec50490a2 100644 --- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c @@ -320,7 +320,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0 / (M_PI)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -329,7 +329,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (M_PI)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 @@ -642,7 +642,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - src0, i915_emit_const1f(p, 1.0 / (M_PI * 2)), 0); + src0, i915_emit_const1f(p, 1.0 / (M_PI)), 0); i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); @@ -651,7 +651,7 @@ upload_program(struct i915_fragment_program *p) i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, - tmp, i915_emit_const1f(p, (M_PI * 2)), 0); + tmp, i915_emit_const1f(p, (M_PI)), 0); /* * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 -- cgit v1.2.3 From ab02552cdddf9322bfaf874f85d74e7c174a0f3b Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sun, 29 Jul 2007 19:44:55 +0200 Subject: fix cos/sin range reduction for i915 driver too --- src/mesa/drivers/dri/i915/i915_fragprog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c index 702b8788282..abca0bbffea 100644 --- a/src/mesa/drivers/dri/i915/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c @@ -304,7 +304,7 @@ static void upload_program( struct i915_fragment_program *p ) A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, src0, - i915_emit_const1f(p, 1.0/(M_PI * 2)), + i915_emit_const1f(p, 1.0/(M_PI)), 0); i915_emit_arith( p, @@ -319,7 +319,7 @@ static void upload_program( struct i915_fragment_program *p ) A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, tmp, - i915_emit_const1f(p, (M_PI * 2)), + i915_emit_const1f(p, (M_PI)), 0); /* @@ -645,7 +645,7 @@ static void upload_program( struct i915_fragment_program *p ) A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, src0, - i915_emit_const1f(p, 1.0/(M_PI * 2)), + i915_emit_const1f(p, 1.0/(M_PI)), 0); i915_emit_arith( p, @@ -660,7 +660,7 @@ static void upload_program( struct i915_fragment_program *p ) A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, tmp, - i915_emit_const1f(p, (M_PI * 2)), + i915_emit_const1f(p, (M_PI)), 0); /* -- cgit v1.2.3 From eefb04a2b8599d4c5ec033539c1348cbe46154f9 Mon Sep 17 00:00:00 2001 From: Jan Dvorak Date: Sun, 29 Jul 2007 18:26:22 -0600 Subject: fix glPointParameteriv bug 11754 --- src/mesa/main/points.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index e83db5de78d..88e49894055 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -5,7 +5,7 @@ /* * Mesa 3-D graphics library - * Version: 7.0 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -82,8 +82,13 @@ _mesa_PointParameteriNV( GLenum pname, GLint param ) void GLAPIENTRY _mesa_PointParameterivNV( GLenum pname, const GLint *params ) { - const GLfloat value = (GLfloat) params[0]; - _mesa_PointParameterfvEXT(pname, &value); + GLfloat p[3]; + p[0] = (GLfloat) params[0]; + if (pname == GL_DISTANCE_ATTENUATION_EXT) { + p[1] = (GLfloat) params[1]; + p[2] = (GLfloat) params[2]; + } + _mesa_PointParameterfvEXT(pname, p); } -- cgit v1.2.3 From 60179434d15989b81e2d4757f34033009184a678 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Mon, 30 Jul 2007 10:18:11 +0800 Subject: ARB sprite point support on i965 --- src/mesa/drivers/dri/i965/brw_sf.c | 15 ++++-- src/mesa/drivers/dri/i965/brw_sf.h | 9 +++- src/mesa/drivers/dri/i965/brw_sf_emit.c | 80 +++++++++++++++++++++++++++++++ src/mesa/drivers/dri/i965/intel_context.c | 5 ++ 4 files changed, 105 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index d5175399d6c..73232b3c7c8 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -74,6 +74,11 @@ static void compile_sf_prog( struct brw_context *brw, if (c.key.attrs & (1<= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) { + c.point_attrs[i].CoordReplace = + brw->attribs.Point->CoordReplace[i - VERT_RESULT_TEX0]; + } else + c.point_attrs[i].CoordReplace = GL_FALSE; idx++; } @@ -90,7 +95,10 @@ static void compile_sf_prog( struct brw_context *brw, break; case SF_POINTS: c.nr_verts = 1; - brw_emit_point_setup( &c ); + if (key->do_point_sprite) + brw_emit_point_sprite_setup( &c ); + else + brw_emit_point_setup( &c ); break; case SF_UNFILLED_TRIS: c.nr_verts = 3; @@ -162,7 +170,8 @@ static void upload_sf_prog( struct brw_context *brw ) break; } - + key.do_point_sprite = brw->attribs.Point->PointSprite; + key.SpriteOrigin = brw->attribs.Point->SpriteOrigin; /* _NEW_LIGHT */ key.do_flat_shading = (brw->attribs.Light->ShadeModel == GL_FLAT); key.do_twoside_color = (brw->attribs.Light->Enabled && brw->attribs.Light->Model.TwoSide); @@ -179,7 +188,7 @@ static void upload_sf_prog( struct brw_context *brw ) const struct brw_tracked_state brw_sf_prog = { .dirty = { - .mesa = (_NEW_LIGHT|_NEW_POLYGON), + .mesa = (_NEW_LIGHT|_NEW_POLYGON|_NEW_POINT), .brw = (BRW_NEW_REDUCED_PRIMITIVE), .cache = CACHE_NEW_VS_PROG }, diff --git a/src/mesa/drivers/dri/i965/brw_sf.h b/src/mesa/drivers/dri/i965/brw_sf.h index fb72b84ba8a..e374e372bb0 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.h +++ b/src/mesa/drivers/dri/i965/brw_sf.h @@ -50,9 +50,14 @@ struct brw_sf_prog_key { GLuint do_flat_shading:1; GLuint attrs:16; GLuint frontface_ccw:1; - GLuint pad:11; + GLuint do_point_sprite:1; + GLuint pad:10; + GLenum SpriteOrigin; }; +struct brw_sf_point_tex { + GLboolean CoordReplace; +}; struct brw_sf_compile { struct brw_compile func; @@ -94,12 +99,14 @@ struct brw_sf_compile { GLubyte attr_to_idx[VERT_RESULT_MAX]; GLubyte idx_to_attr[VERT_RESULT_MAX]; + struct brw_sf_point_tex point_attrs[VERT_RESULT_MAX]; }; void brw_emit_tri_setup( struct brw_sf_compile *c ); void brw_emit_line_setup( struct brw_sf_compile *c ); void brw_emit_point_setup( struct brw_sf_compile *c ); +void brw_emit_point_sprite_setup( struct brw_sf_compile *c ); void brw_emit_anyprim_setup( struct brw_sf_compile *c ); #endif diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c index cbaf018c44a..7ecf9bb560d 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_emit.c +++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c @@ -497,6 +497,86 @@ void brw_emit_line_setup( struct brw_sf_compile *c ) } } +void brw_emit_point_sprite_setup( struct brw_sf_compile *c ) +{ + struct brw_compile *p = &c->func; + GLuint i; + + c->nr_verts = 1; + alloc_regs(c); + copy_z_inv_w(c); + for (i = 0; i < c->nr_setup_regs; i++) + { + struct brw_sf_point_tex *tex = &c->point_attrs[c->idx_to_attr[2*i]]; + struct brw_reg a0 = offset(c->vert[0], i); + GLushort pc, pc_persp, pc_linear; + GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear); + + if (pc_persp) + { + if (!tex->CoordReplace) { + brw_set_predicate_control_flag_value(p, pc_persp); + brw_MUL(p, a0, a0, c->inv_w[0]); + } + } + + if (tex->CoordReplace) { + /* Caculate 1.0/PointWidth */ + brw_math(&c->func, + c->tmp, + BRW_MATH_FUNCTION_INV, + BRW_MATH_SATURATE_NONE, + 0, + c->dx0, + BRW_MATH_DATA_SCALAR, + BRW_MATH_PRECISION_FULL); + + if (c->key.SpriteOrigin == GL_UPPER_LEFT) { + brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]); + brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0)); + brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0])); + brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0)); + } else { + brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]); + brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0)); + brw_MUL(p, c->m2Cy, c->tmp, c->inv_w[0]); + brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0)); + } + } else { + brw_MOV(p, c->m1Cx, brw_imm_ud(0)); + brw_MOV(p, c->m2Cy, brw_imm_ud(0)); + } + + { + brw_set_predicate_control_flag_value(p, pc); + if (tex->CoordReplace) { + if (c->key.SpriteOrigin == GL_UPPER_LEFT) { + brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0)); + brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0)); + } + else + brw_MOV(p, c->m3C0, brw_imm_f(0.0)); + } else { + brw_MOV(p, c->m3C0, a0); /* constant value */ + } + + /* Copy m0..m3 to URB. + */ + brw_urb_WRITE(p, + brw_null_reg(), + 0, + brw_vec8_grf(0, 0), + 0, /* allocate */ + 1, /* used */ + 4, /* msg len */ + 0, /* response len */ + last, /* eot */ + last, /* writes complete */ + i*4, /* urb destination offset */ + BRW_URB_SWIZZLE_TRANSPOSE); + } + } +} /* Points setup - several simplifications as all attributes are * constant across the face of the point (point sprites excluded!) diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 4f51fefe0f6..a8204ee4b81 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -66,6 +66,7 @@ int INTEL_DEBUG = (0); #endif +#define need_GL_NV_point_sprite #define need_GL_ARB_multisample #define need_GL_ARB_point_parameters #define need_GL_ARB_texture_compression @@ -81,6 +82,7 @@ int INTEL_DEBUG = (0); #define need_GL_EXT_fog_coord #define need_GL_EXT_multi_draw_arrays #define need_GL_EXT_secondary_color +#define need_GL_EXT_point_parameters #include "extension_helper.h" #ifndef VERBOSE @@ -146,6 +148,7 @@ const struct dri_extension card_extensions[] = { "GL_ARB_multisample", GL_ARB_multisample_functions }, { "GL_ARB_multitexture", NULL }, { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, + { "GL_NV_point_sprite", GL_NV_point_sprite_functions }, { "GL_ARB_texture_border_clamp", NULL }, { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, { "GL_ARB_texture_cube_map", NULL }, @@ -158,6 +161,8 @@ const struct dri_extension card_extensions[] = { "GL_NV_texture_rectangle", NULL }, { "GL_EXT_texture_rectangle", NULL }, { "GL_ARB_texture_rectangle", NULL }, + { "GL_ARB_point_sprite", NULL}, + { "GL_ARB_point_parameters", NULL }, { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, { "GL_ARB_window_pos", GL_ARB_window_pos_functions }, -- cgit v1.2.3 From 775ebb696dffaf6fddc170862ecb375e6cdfcb9c Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Mon, 30 Jul 2007 16:17:40 +0800 Subject: Fix an error related to glPolygonStipple. As glPixelStore(GL_UNPACK) affect the bits into a stipple pattern, hence 128 bytes used to store the pattern in a display list aren't enough sometimes. --- src/mesa/main/dlist.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 293ee5fa349..f50c19f2ceb 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -2723,15 +2723,17 @@ static void GLAPIENTRY save_PolygonStipple(const GLubyte * pattern) { GET_CURRENT_CONTEXT(ctx); + GLvoid *image = unpack_image(2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, + pattern, &ctx->Unpack); Node *n; ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_STIPPLE, 1); if (n) { - void *data; - n[1].data = _mesa_malloc(32 * 4); - data = n[1].data; /* This needed for Acorn compiler */ - MEMCPY(data, pattern, 32 * 4); + n[1].data = image; + } else if (image) { + _mesa_free(image); } + if (ctx->ExecuteFlag) { CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); } @@ -6169,7 +6171,12 @@ execute_list(GLcontext *ctx, GLuint list) CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e)); break; case OPCODE_POLYGON_STIPPLE: - CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); + { + const struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = ctx->DefaultPacking; + CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data)); + ctx->Unpack = save; /* restore */ + } break; case OPCODE_POLYGON_OFFSET: CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f)); -- cgit v1.2.3 From 501b5305b939ac38177dcd73ec72f4a39296e0c4 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Mon, 30 Jul 2007 16:30:32 +0800 Subject: handle LSB_FIRST in _mesa_pack_bitmap by the way used in _mesa_unpack_bitmap --- src/mesa/main/image.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ba46cdc1b17..8fccd44f211 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -850,7 +850,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, return NULL; } - if (packing->SkipPixels == 0) { + if ((packing->SkipPixels & 7) == 0) { _mesa_memcpy( dst, src, width_in_bytes ); if (packing->LsbFirst) { flip_bytes( dst, width_in_bytes ); @@ -942,7 +942,7 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, if (!dst) return; - if (packing->SkipPixels == 0) { + if ((packing->SkipPixels & 7) == 0) { _mesa_memcpy( dst, src, width_in_bytes ); if (packing->LsbFirst) { flip_bytes( dst, width_in_bytes ); @@ -961,20 +961,20 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, if (*s & srcMask) { *d |= dstMask; } - if (srcMask == 128) { - srcMask = 1; + if (srcMask == 1) { + srcMask = 128; s++; } else { - srcMask = srcMask << 1; + srcMask = srcMask >> 1; } - if (dstMask == 1) { - dstMask = 128; + if (dstMask == 128) { + dstMask = 1; d++; *d = 0; } else { - dstMask = dstMask >> 1; + dstMask = dstMask << 1; } } } -- cgit v1.2.3 From baac66cb0519cb85373fb079696d44e42d382577 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 30 Jul 2007 08:13:40 -0600 Subject: remove old comment, minor formatting fixes --- src/mesa/main/dlist.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index f50c19f2ceb..be2f438a941 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -2716,9 +2716,6 @@ save_PolygonMode(GLenum face, GLenum mode) } -/* - * Polygon stipple must have been upacked already! - */ static void GLAPIENTRY save_PolygonStipple(const GLubyte * pattern) { @@ -2730,10 +2727,10 @@ save_PolygonStipple(const GLubyte * pattern) n = ALLOC_INSTRUCTION(ctx, OPCODE_POLYGON_STIPPLE, 1); if (n) { n[1].data = image; - } else if (image) { - _mesa_free(image); } - + else if (image) { + _mesa_free(image); + } if (ctx->ExecuteFlag) { CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern)); } -- cgit v1.2.3 From 2394d20dafdfa308d494fc739c63c6a4e91c8185 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Mon, 30 Jul 2007 23:50:52 +0800 Subject: Fix an error in _mesa_validate_DrawElements The field 'Data' in an obj is NULL in some dri drivers(such as i965). Use mapped pointer instead. --- src/mesa/main/api_validate.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 841c6a53026..18dead61c3a 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -35,6 +35,7 @@ _mesa_validate_DrawElements(GLcontext *ctx, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { + GLboolean mapped = GL_FALSE; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); if (count <= 0) { @@ -67,13 +68,19 @@ _mesa_validate_DrawElements(GLcontext *ctx, /* Vertex buffer object tests */ if (ctx->Array.ElementArrayBufferObj->Name) { GLuint indexBytes; + const GLvoid *map = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, + ctx->Array.ElementArrayBufferObj); /* use indices in the buffer object */ - if (!ctx->Array.ElementArrayBufferObj->Data) { + if (!map) { _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!"); return GL_FALSE; } + mapped = GL_TRUE; + /* make sure count doesn't go outside buffer bounds */ if (type == GL_UNSIGNED_INT) { indexBytes = count * sizeof(GLuint); @@ -86,18 +93,18 @@ _mesa_validate_DrawElements(GLcontext *ctx, indexBytes = count * sizeof(GLushort); } - if ((GLubyte *) indices + indexBytes > - ctx->Array.ElementArrayBufferObj->Data + - ctx->Array.ElementArrayBufferObj->Size) { + if (ADD_POINTERS(map, indices) + indexBytes > + (GLubyte *)map + ctx->Array.ElementArrayBufferObj->Size) { _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); + ctx->Driver.UnmapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); return GL_FALSE; } /* Actual address is the sum of pointers. Indices may be used below. */ if (ctx->Const.CheckArrayBounds) { - indices = (const GLvoid *) - ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, - (const GLubyte *) indices); + indices = ADD_POINTERS(map, indices); } } else { @@ -126,12 +133,25 @@ _mesa_validate_DrawElements(GLcontext *ctx, if (((GLubyte *) indices)[i] > max) max = ((GLubyte *) indices)[i]; } + if (max >= ctx->Array._MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ + if (mapped) { + ctx->Driver.UnmapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); + } + return GL_FALSE; } } + if (mapped) { + ctx->Driver.UnmapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); + } + return GL_TRUE; } -- cgit v1.2.3 From 982dcb74fd19b88208d127b8019e2a2af979cac2 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 31 Jul 2007 00:11:22 +0800 Subject: Fix an error in _save_OBE_DrawElements In the case that a buffer object is bound to ELEMENT_ARRARY_BUFFER, it is invalid to directly dereference indices passed to glDrawElements. --- src/mesa/vbo/vbo_save_api.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index aded7381436..f62be5c14cf 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -864,6 +864,9 @@ static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum _ae_map_vbos( ctx ); + if (ctx->Array.ElementArrayBufferObj->Name) + indices = ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Pointer, indices); + vbo_save_NotifyBegin( ctx, mode | VBO_SAVE_PRIM_WEAK ); switch (type) { -- cgit v1.2.3 From 69337ed098bdf0def6820ccdb121b08c0e139085 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 31 Jul 2007 09:10:31 +0800 Subject: i965: Use I16_UNORM instead of L16_UNORM (bug 11742) --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index d24c618a668..d54623175b7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -114,7 +114,7 @@ static GLuint translate_tex_format( GLuint mesa_format ) return BRW_SURFACEFORMAT_FXT1; case MESA_FORMAT_Z16: - return BRW_SURFACEFORMAT_L16_UNORM; + return BRW_SURFACEFORMAT_I16_UNORM; case MESA_FORMAT_RGBA_DXT1: case MESA_FORMAT_RGB_DXT1: -- cgit v1.2.3 From e66757c8babe6968ea2e506d1214c8063cbd0760 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 31 Jul 2007 22:40:42 +0800 Subject: i965: fix bad casts in do_blit_bitmap to support WindowPos correctly --- src/mesa/drivers/dri/i965/intel_pixel_bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c index 421fcc5e511..f3f062e6517 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c @@ -226,10 +226,10 @@ do_blit_bitmap( GLcontext *ctx, dsty = dPriv->y + (dPriv->h - dsty - height); dstx = dPriv->x + dstx; - dest_rect.x1 = dstx; - dest_rect.y1 = dsty; - dest_rect.x2 = dstx + width; - dest_rect.y2 = dsty + height; + dest_rect.x1 = dstx < 0 ? 0 : dstx; + dest_rect.y1 = dsty < 0 ? 0 : dsty; + dest_rect.x2 = dstx + width < 0 ? 0 : dstx + width; + dest_rect.y2 = dsty + height < 0 ? 0 : dsty + height; for (i = 0; i < nbox; i++) { drm_clip_rect_t rect; -- cgit v1.2.3 From 59b1233e7075ff54a2cd183234f2a092eef5cc75 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 31 Jul 2007 09:31:41 -0600 Subject: glGetAttribLocation always returned 1 (bug 11774) --- src/mesa/shader/slang/slang_link.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index eaa29ba094e..c8457fc483d 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -329,8 +329,10 @@ _slang_resolve_attributes(struct gl_shader_program *shProg, * glVertex/position. */ for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) { - if (((1 << attr) & usedAttributes) == 0) + if (((1 << attr) & usedAttributes) == 0) { + usedAttributes |= (1 << attr); break; + } } if (attr == MAX_VERTEX_ATTRIBS) { /* too many! XXX record error log */ -- cgit v1.2.3 From 8410b3f8f9d7041440db0f178c31a5819b16495c Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 31 Jul 2007 09:43:57 -0600 Subject: fix failure caused by undeclared variable (bug 11783) --- src/mesa/shader/slang/slang_codegen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 24185cf6770..d368009ca50 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2059,7 +2059,8 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper) } /* XXX make copy of this initializer? */ rhs = _slang_gen_operation(A, &oper->children[0]); - assert(rhs); + if (!rhs) + return NULL; /* must have found an error */ init = new_node2(IR_MOVE, var, rhs); /*assert(rhs->Opcode != IR_SEQ);*/ n = new_seq(varDecl, init); -- cgit v1.2.3 From 6fae66715be216f03f1f418d963ae6db8c83885a Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 31 Jul 2007 14:57:37 -0600 Subject: fix some FreeBSD issues --- configs/freebsd | 2 +- configs/freebsd-dri | 2 +- src/glut/glx/glut_event.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/configs/freebsd b/configs/freebsd index db7dd3b78a0..447faf9f4cf 100644 --- a/configs/freebsd +++ b/configs/freebsd @@ -13,7 +13,7 @@ OPT_FLAGS = -O2 PIC_FLAGS = -fPIC DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM \ - -DHZ=100 -DHAVE_POSIX_MEMALIGN + -DHZ=100 X11_INCLUDES = -I/usr/X11R6/include diff --git a/configs/freebsd-dri b/configs/freebsd-dri index 402883d1de0..5a9310a04ed 100644 --- a/configs/freebsd-dri +++ b/configs/freebsd-dri @@ -15,7 +15,7 @@ EXPAT_INCLUDES = -I/usr/local/include X11_INCLUDES = -I/usr/X11R6/include DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \ -DGLX_DIRECT_RENDERING -DGLX_INDIRECT_RENDERING \ - -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN + -DHAVE_ALIAS CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) -Wmissing-prototypes -std=c99 -Wundef -ffast-math \ $(ASM_FLAGS) $(X11_INCLUDES) $(DEFINES) diff --git a/src/glut/glx/glut_event.c b/src/glut/glx/glut_event.c index 4e67da674ed..0a96e8cf71d 100644 --- a/src/glut/glx/glut_event.c +++ b/src/glut/glx/glut_event.c @@ -24,7 +24,7 @@ # ifdef __sgi # include /* prototype for bzero used by FD_ZERO */ # endif -# if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE) +# if (defined(__FreeBSD__) || defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE) # include /* select system call interface */ # ifdef luna # include -- cgit v1.2.3 From a6dad044e24358af9fe5764ca7b342f4ed4804db Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Wed, 1 Aug 2007 11:08:05 +0800 Subject: fix fd.o bug #11788, max point size --- src/mesa/drivers/dri/i965/brw_sf_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 9a6e5f5f192..307fb637851 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -185,7 +185,7 @@ static void upload_sf_unit( struct brw_context *brw ) /* _NEW_POINT */ sf.sf6.point_rast_rule = 1; /* opengl conventions */ /* XXX clamp max depends on AA vs. non-AA */ - sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 3.0) * (1<<3); + sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 255.0) * (1<<3); sf.sf7.use_point_size_state = !brw->attribs.Point->_Attenuated; /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons: -- cgit v1.2.3 From e9fbf69aeab590d5f292a7ca6bdeb5d2791f9918 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 08:40:49 -0600 Subject: fix mem leak (bug 11791) --- src/glut/glx/glut_dstr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/glut/glx/glut_dstr.c b/src/glut/glx/glut_dstr.c index ec9386f3e50..2513af45394 100644 --- a/src/glut/glx/glut_dstr.c +++ b/src/glut/glx/glut_dstr.c @@ -291,6 +291,7 @@ loadVisuals(int *nitems_return) fbmodes = (FrameBufferMode *) malloc(n * sizeof(FrameBufferMode)); if (fbmodes == NULL) { *nitems_return = -1; + free(vlist); return NULL; } for (i = 0; i < n; i++) { -- cgit v1.2.3 From f761c99d25aa71c4c761c1f876782a81c795fd5c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 08:41:51 -0600 Subject: fix mem leak (bug 11793) --- src/mesa/drivers/dri/common/dri_drmpool.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/dri_drmpool.c b/src/mesa/drivers/dri/common/dri_drmpool.c index 878a148b397..592ac105428 100644 --- a/src/mesa/drivers/dri/common/dri_drmpool.c +++ b/src/mesa/drivers/dri/common/dri_drmpool.c @@ -51,6 +51,7 @@ pool_create(struct _DriBufferPool *pool, return NULL; if ((alignment > pageSize) && (alignment % pageSize)) { + free(buf); return NULL; } -- cgit v1.2.3 From 394e7575a3e5694ee63008c7a7e0e4b891c181f6 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 11:27:29 -0600 Subject: fix error code test limit (bug 11795) --- src/glu/sgi/libutil/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/glu/sgi/libutil/error.c b/src/glu/sgi/libutil/error.c index 3d1ce9b2101..c2000569427 100644 --- a/src/glu/sgi/libutil/error.c +++ b/src/glu/sgi/libutil/error.c @@ -82,7 +82,7 @@ gluErrorString(GLenum errorCode) if ((errorCode >= GLU_NURBS_ERROR1) && (errorCode <= GLU_NURBS_ERROR37)) { return (const GLubyte *) __gluNURBSErrorString(errorCode - (GLU_NURBS_ERROR1 - 1)); } - if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR8)) { + if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR6)) { return (const GLubyte *) __gluTessErrorString(errorCode - (GLU_TESS_ERROR1 - 1)); } return (const GLubyte *) 0; -- cgit v1.2.3 From 6bf81a5edfa287a396f30188b107ff1761039f3f Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Thu, 2 Aug 2007 14:26:12 +0800 Subject: EXT_texture_sRGB support on i965 --- src/mesa/drivers/dri/i965/brw_tex.c | 19 +++++++++++++++++ src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 5 +++++ src/mesa/drivers/dri/i965/intel_context.c | 1 + src/mesa/main/texcompress_s3tc.c | 26 ++++++++++++++++++++++++ src/mesa/main/texformat.h | 2 ++ 5 files changed, 53 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c index 9d4b9867d24..f8d0c3fb6fd 100644 --- a/src/mesa/drivers/dri/i965/brw_tex.c +++ b/src/mesa/drivers/dri/i965/brw_tex.c @@ -168,6 +168,25 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_DEPTH_COMPONENT32: return &_mesa_texformat_z16; + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + return &_mesa_texformat_srgb_dxt1; + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return &_mesa_texformat_srgb_dxt1; + default: fprintf(stderr, "unexpected texture format %s in %s\n", _mesa_lookup_enum_by_nr(internalFormat), diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index d54623175b7..acf5771e779 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -120,6 +120,11 @@ static GLuint translate_tex_format( GLuint mesa_format ) case MESA_FORMAT_RGB_DXT1: return BRW_SURFACEFORMAT_DXT1_RGB; + case MESA_FORMAT_SRGBA8: + return BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB; + case MESA_FORMAT_SRGB_DXT1: + return BRW_SURFACEFORMAT_BC1_UNORM_SRGB; + default: assert(0); return 0; diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index a8204ee4b81..eafe809d3ad 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -182,6 +182,7 @@ const struct dri_extension card_extensions[] = { "GL_EXT_texture_env_dot3", NULL }, { "GL_EXT_texture_filter_anisotropic", NULL }, { "GL_EXT_texture_lod_bias", NULL }, + { "GL_EXT_texture_sRGB", NULL }, { "GL_3DFX_texture_compression_FXT1", NULL }, { "GL_APPLE_client_storage", NULL }, { "GL_MESA_pack_invert", NULL }, diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index c48063d9192..4f329cdf59b 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -577,6 +577,32 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = { NULL /* StoreTexel */ }; +#if FEATURE_EXT_texture_sRGB +const struct gl_texture_format _mesa_texformat_srgb_dxt1 = { + MESA_FORMAT_SRGB_DXT1, /* MesaFormat */ + GL_RGB, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 0, /* TexelBytes */ + texstore_rgb_dxt1, /* StoreTexImageFunc */ + NULL, /*impossible*/ /* FetchTexel1D */ + fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */ + NULL, /*impossible*/ /* FetchTexel3D */ + NULL, /*impossible*/ /* FetchTexel1Df */ + fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */ + NULL, /*impossible*/ /* FetchTexel3Df */ + NULL /* StoreTexel */ +}; +#endif + const struct gl_texture_format _mesa_texformat_rgba_dxt1 = { MESA_FORMAT_RGBA_DXT1, /* MesaFormat */ GL_RGBA, /* BaseFormat */ diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h index 55851db7016..82023b946d5 100644 --- a/src/mesa/main/texformat.h +++ b/src/mesa/main/texformat.h @@ -97,6 +97,7 @@ enum _format { MESA_FORMAT_SRGBA8, MESA_FORMAT_SL8, MESA_FORMAT_SLA8, + MESA_FORMAT_SRGB_DXT1, /*@}*/ #endif @@ -168,6 +169,7 @@ extern const struct gl_texture_format _mesa_texformat_srgb8; extern const struct gl_texture_format _mesa_texformat_srgba8; extern const struct gl_texture_format _mesa_texformat_sl8; extern const struct gl_texture_format _mesa_texformat_sla8; +extern const struct gl_texture_format _mesa_texformat_srgb_dxt1; /*@}*/ #endif -- cgit v1.2.3 From 246d1d2522858a1bcf525d64ad165f9af11a2b4d Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Thu, 2 Aug 2007 14:35:59 +0800 Subject: Fix previous commit --- src/mesa/drivers/dri/i965/brw_tex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c index f8d0c3fb6fd..a62395a4327 100644 --- a/src/mesa/drivers/dri/i965/brw_tex.c +++ b/src/mesa/drivers/dri/i965/brw_tex.c @@ -180,7 +180,7 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_COMPRESSED_SRGB_ALPHA_EXT: case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - return &_mesa_texformat_srgb_dxt1; + return &_mesa_texformat_srgba8; case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: -- cgit v1.2.3 From 505453a04e8ba5e394c34401bd9ec320ffce2423 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Thu, 2 Aug 2007 15:27:13 +0800 Subject: fix fd.o bug #11804 glPolygonMode with point sprite on i965 --- src/mesa/drivers/dri/i965/brw_defines.h | 2 ++ src/mesa/drivers/dri/i965/brw_sf_emit.c | 9 +++++++++ src/mesa/drivers/dri/i965/brw_sf_state.c | 2 ++ 3 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index e8f878a7018..9bb7d2f703d 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -240,6 +240,8 @@ #define BRW_FRONTWINDING_CW 0 #define BRW_FRONTWINDING_CCW 1 +#define BRW_SPRITE_POINT_ENABLE 16 + #define BRW_INDEX_BYTE 0 #define BRW_INDEX_WORD 1 #define BRW_INDEX_DWORD 2 diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c index 7ecf9bb560d..22911a46494 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_emit.c +++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c @@ -641,6 +641,7 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) struct brw_compile *p = &c->func; struct brw_reg ip = brw_ip_reg(); struct brw_reg payload_prim = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0); + struct brw_reg payload_attr = get_element_ud(brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0), 0); struct brw_reg primmask; struct brw_instruction *jmp; struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD)); @@ -681,6 +682,14 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) } brw_land_fwd_jump(p, jmp); + brw_set_conditionalmod(p, BRW_CONDITIONAL_Z); + brw_AND(p, v1_null_ud, payload_attr, brw_imm_ud(1<attribs.Point->PointSprite; sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 255.0) * (1<<3); sf.sf7.use_point_size_state = !brw->attribs.Point->_Attenuated; -- cgit v1.2.3 From 46ac4531966e0edf802919def935c4125342e8bf Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 2 Aug 2007 11:37:57 +0100 Subject: Fix typo in logic for unalias2() --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 6eb11b19ad2..d00f0c71a8f 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -201,7 +201,7 @@ static void unalias2( struct brw_vs_compile *c, struct brw_reg, struct brw_reg )) { - if ((dst.file == arg0.file && dst.nr == arg0.nr) && + if ((dst.file == arg0.file && dst.nr == arg0.nr) || (dst.file == arg1.file && dst.nr == arg1.nr)) { struct brw_compile *p = &c->func; struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask); -- cgit v1.2.3 From c3e6bfc9e27038172fff47f9cc5a8a53ff7038a3 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 08:29:55 -0600 Subject: Remove some code that was never hit (bug 11811). Also added an assertion to check that NR_MAT_ATTRIBS == MAT_ATTRIB_MAX. In the unlikely event this ever changes, maybe restore the code. --- src/mesa/vbo/vbo_context.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index ad4556c500b..656b27f28cc 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -112,6 +112,8 @@ static void init_mat_currval(GLcontext *ctx) struct gl_client_array *arrays = vbo->mat_currval; GLuint i; + ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX); + memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS); /* Set up a constant (StrideB == 0) array for each current @@ -137,11 +139,7 @@ static void init_mat_currval(GLcontext *ctx) break; } - if (i < MAT_ATTRIB_MAX) - cl->Ptr = (const void *)ctx->Light.Material.Attrib[i]; - else - cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]; - + cl->Ptr = (const void *)ctx->Light.Material.Attrib[i]; cl->Type = GL_FLOAT; cl->Stride = 0; cl->StrideB = 0; -- cgit v1.2.3 From 6dae3f8c881ae90664fa826032402efb6de1bb8b Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 08:31:44 -0600 Subject: move code to prevent NULL ptr dereference (bug 11810) --- src/mesa/drivers/dri/i915tex/intel_span.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_span.c b/src/mesa/drivers/dri/i915tex/intel_span.c index ab0874e4fd6..d1f8ef06beb 100644 --- a/src/mesa/drivers/dri/i915tex/intel_span.c +++ b/src/mesa/drivers/dri/i915tex/intel_span.c @@ -198,9 +198,9 @@ intel_map_unmap_buffers(struct intel_context *intel, GLboolean map) intel_region_map(intel->intelScreen, irb->region); else intel_region_unmap(intel->intelScreen, irb->region); + irb->pfMap = irb->region->map; + irb->pfPitch = irb->region->pitch; } - irb->pfMap = irb->region->map; - irb->pfPitch = irb->region->pitch; } } } -- cgit v1.2.3 From 6e6a02261a7c0fcfdf9fbf17199aff4278c8e5b7 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 08:35:13 -0600 Subject: s/MAX_TEXTURE_LEVELS/SIS_MAX_TEXTURE_LEVELS/ and add assertion (bug 11806) --- src/mesa/drivers/dri/sis/sis_tex.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/sis/sis_tex.c b/src/mesa/drivers/dri/sis/sis_tex.c index be87f16e298..8fd7b26ba55 100644 --- a/src/mesa/drivers/dri/sis/sis_tex.c +++ b/src/mesa/drivers/dri/sis/sis_tex.c @@ -130,6 +130,8 @@ sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level, static void sisFreeTexImage( sisContextPtr smesa, sisTexObjPtr t, int level ) { + assert(level >= 0); + assert(level < SIS_MAX_TEXTURE_LEVELS); if (t->image[level].Data == NULL) return; @@ -213,7 +215,7 @@ sisDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj ) */ return; } - for (i = 0; i < MAX_TEXTURE_LEVELS; i++) { + for (i = 0; i < SIS_MAX_TEXTURE_LEVELS; i++) { sisFreeTexImage( smesa, t, i ); } -- cgit v1.2.3 From 89cad79b4186166f4420317472801b73410402f4 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 08:38:01 -0600 Subject: fix double free()s (bug 11808) --- src/glu/sgi/libnurbs/interface/insurfeval.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/glu/sgi/libnurbs/interface/insurfeval.cc b/src/glu/sgi/libnurbs/interface/insurfeval.cc index b314699c7af..e4ee3ef6a29 100644 --- a/src/glu/sgi/libnurbs/interface/insurfeval.cc +++ b/src/glu/sgi/libnurbs/interface/insurfeval.cc @@ -1533,8 +1533,8 @@ void OpenGLSurfaceEvaluator::inEvalVStrip(int n_left, REAL u_left, REAL* left_va } //clean up free(leftXYZ); - free(leftXYZ); - free(rightNormal); + free(rightXYZ); + free(leftNormal); free(rightNormal); } -- cgit v1.2.3 From 85421351e65c45249b038214fe8d1ca6b0d69884 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 08:40:29 -0600 Subject: fix invalid pointer usage in bezierPatchDeleteList(), bug 11807 --- src/glu/sgi/libnurbs/interface/bezierPatch.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/glu/sgi/libnurbs/interface/bezierPatch.cc b/src/glu/sgi/libnurbs/interface/bezierPatch.cc index 836ae94e0a6..5b7bda1a001 100644 --- a/src/glu/sgi/libnurbs/interface/bezierPatch.cc +++ b/src/glu/sgi/libnurbs/interface/bezierPatch.cc @@ -111,8 +111,11 @@ void bezierPatchDelete(bezierPatch *b) void bezierPatchDeleteList(bezierPatch *b) { bezierPatch *temp; - for(temp = b; temp != NULL; temp = temp->next) - bezierPatchDelete(temp); + while (b != NULL) { + temp = b; + b = b->next; + bezierPatchDelete(temp); + } } bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b) -- cgit v1.2.3 From e2556b7487cb383e285f6b21c5513edd8c5d37e6 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 08:44:34 -0600 Subject: remove unnecessary null check (bug 11814) --- src/mesa/drivers/dri/r300/r300_texmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c index 38f0da8b7c0..723601ac4a6 100644 --- a/src/mesa/drivers/dri/r300/r300_texmem.c +++ b/src/mesa/drivers/dri/r300/r300_texmem.c @@ -505,7 +505,7 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face) t->base.lastLevel); } - if (!t || t->base.totalSize == 0) + if (t->base.totalSize == 0) return 0; if (RADEON_DEBUG & DEBUG_SYNC) { -- cgit v1.2.3 From 2c3cb693ccb760b7b1b7bb9f37491d1499c97938 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 2 Aug 2007 09:08:29 -0600 Subject: fix stencil value masking bug 11805, and fix sizeof() bug --- src/mesa/main/image.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 8fccd44f211..9760e5f8d24 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3733,7 +3733,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, switch (dstType) { case GL_UNSIGNED_BYTE: - if (sizeof(GLstencil) == 8) { + if (sizeof(GLstencil) == 1) { _mesa_memcpy( dest, source, n ); } else { @@ -3745,14 +3745,11 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, } break; case GL_BYTE: - if (sizeof(GLstencil) == 8) { - _mesa_memcpy( dest, source, n ); - } - else { + { GLbyte *dst = (GLbyte *) dest; GLuint i; for (i=0;i Date: Tue, 7 Aug 2007 01:00:29 +0200 Subject: nouveau: update to DRM API patchlevel 10 Finally let DRI build for nouveau. --- src/mesa/drivers/dri/nouveau/nouveau_fifo.c | 4 ++-- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 21 ++++++++++----------- src/mesa/drivers/dri/nouveau/nouveau_sync.h | 14 +++++++------- 4 files changed, 20 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c index 7b5e96b4c26..4208819d025 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c @@ -98,7 +98,7 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa) // here we call the fifo initialization ioctl and fill in stuff accordingly GLboolean nouveauFifoInit(nouveauContextPtr nmesa) { - struct drm_nouveau_fifo_alloc fifo_init; + struct drm_nouveau_channel_alloc fifo_init; int i, ret; #ifdef NOUVEAU_RING_DEBUG @@ -107,7 +107,7 @@ GLboolean nouveauFifoInit(nouveauContextPtr nmesa) fifo_init.fb_ctxdma_handle = NvDmaFB; fifo_init.tt_ctxdma_handle = NvDmaTT; - ret=drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_FIFO_ALLOC, &fifo_init, sizeof(fifo_init)); + ret=drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_CHANNEL_ALLOC, &fifo_init, sizeof(fifo_init)); if (ret) { FATAL("Fifo initialization ioctl failed (returned %d)\n",ret); return GL_FALSE; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 69b0691bb7b..053680be8d1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc static const __DRIversion ddx_expected = { 1, 2, 0 }; static const __DRIversion dri_expected = { 4, 0, 0 }; static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL }; -#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 9 +#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 10 #error nouveau_drm.h version doesn't match expected version #endif dri_interface = interface; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index 8abc847e1e2..3f5f6d54e9b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -39,25 +39,24 @@ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \ volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset -struct drm_nouveau_notifier_alloc * +struct drm_nouveau_notifierobj_alloc * nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - struct drm_nouveau_notifier_alloc *notifier; + struct drm_nouveau_notifierobj_alloc *notifier; int ret; #ifdef NOUVEAU_RING_DEBUG return NULL; #endif - - notifier = CALLOC_STRUCT(drm_nouveau_notifier_alloc); + notifier = CALLOC_STRUCT(drm_nouveau_notifierobj_alloc); if (!notifier) return NULL; notifier->channel = nmesa->fifo.channel; notifier->handle = handle; notifier->count = count; - ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIER_ALLOC, + ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC, notifier, sizeof(*notifier)); if (ret) { MESSAGE("Failed to create notifier 0x%08x: %d\n", handle, ret); @@ -70,7 +69,7 @@ nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) void nouveau_notifier_destroy(GLcontext *ctx, - struct drm_nouveau_notifier_alloc *notifier) + struct drm_nouveau_notifierobj_alloc *notifier) { /*XXX: free notifier object.. */ FREE(notifier); @@ -78,7 +77,7 @@ nouveau_notifier_destroy(GLcontext *ctx, void nouveau_notifier_reset(GLcontext *ctx, - struct drm_nouveau_notifier_alloc *notifier, + struct drm_nouveau_notifierobj_alloc *notifier, GLuint id) { NOTIFIER(n); @@ -96,7 +95,7 @@ nouveau_notifier_reset(GLcontext *ctx, GLuint nouveau_notifier_status(GLcontext *ctx, - struct drm_nouveau_notifier_alloc *notifier, + struct drm_nouveau_notifierobj_alloc *notifier, GLuint id) { NOTIFIER(n); @@ -106,7 +105,7 @@ nouveau_notifier_status(GLcontext *ctx, GLuint nouveau_notifier_return_val(GLcontext *ctx, - struct drm_nouveau_notifier_alloc *notifier, + struct drm_nouveau_notifierobj_alloc *notifier, GLuint id) { NOTIFIER(n); @@ -116,7 +115,7 @@ nouveau_notifier_return_val(GLcontext *ctx, GLboolean nouveau_notifier_wait_status(GLcontext *ctx, - struct drm_nouveau_notifier_alloc *notifier, + struct drm_nouveau_notifierobj_alloc *notifier, GLuint id, GLuint status, GLuint timeout) { NOTIFIER(n); @@ -150,7 +149,7 @@ nouveau_notifier_wait_status(GLcontext *ctx, void nouveau_notifier_wait_nop(GLcontext *ctx, - struct drm_nouveau_notifier_alloc *notifier, + struct drm_nouveau_notifierobj_alloc *notifier, GLuint subc) { NOTIFIER(n); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h index b76af172762..1ff4eca3258 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.h @@ -47,24 +47,24 @@ #define NV_NOTIFY 0x00000104 #define NV_NOTIFY_STYLE_WRITE_ONLY 0 -extern struct drm_nouveau_notifier_alloc * +extern struct drm_nouveau_notifierobj_alloc * nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count); extern void -nouveau_notifier_destroy(GLcontext *, struct drm_nouveau_notifier_alloc *); +nouveau_notifier_destroy(GLcontext *, struct drm_nouveau_notifierobj_alloc *); extern void -nouveau_notifier_reset(GLcontext *, struct drm_nouveau_notifier_alloc *, +nouveau_notifier_reset(GLcontext *, struct drm_nouveau_notifierobj_alloc *, GLuint id); extern GLuint -nouveau_notifier_status(GLcontext *, struct drm_nouveau_notifier_alloc *, +nouveau_notifier_status(GLcontext *, struct drm_nouveau_notifierobj_alloc *, GLuint id); extern GLuint -nouveau_notifier_return_val(GLcontext *, struct drm_nouveau_notifier_alloc *, +nouveau_notifier_return_val(GLcontext *, struct drm_nouveau_notifierobj_alloc *, GLuint id); extern GLboolean -nouveau_notifier_wait_status(GLcontext *, struct drm_nouveau_notifier_alloc *, +nouveau_notifier_wait_status(GLcontext *, struct drm_nouveau_notifierobj_alloc *, GLuint id, GLuint status, GLuint timeout); extern void -nouveau_notifier_wait_nop(GLcontext *ctx, struct drm_nouveau_notifier_alloc *, +nouveau_notifier_wait_nop(GLcontext *ctx, struct drm_nouveau_notifierobj_alloc *, GLuint subc); extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx); -- cgit v1.2.3 From d05b72154319041dad38f24696638396753e0da3 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 7 Aug 2007 08:21:28 +0800 Subject: fix vbo_split_copy related bug 9962 --- src/mesa/vbo/vbo_split_copy.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index e5c4429350e..685cc0fdf6e 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -129,6 +129,13 @@ static GLuint attr_size( const struct gl_client_array *array ) */ static GLboolean check_flush( struct copy_context *copy ) { + GLenum mode = copy->dstprim[copy->dstprim_nr].mode; + + if (GL_TRIANGLE_STRIP == mode && + copy->dstelt_nr & 1) { /* see bug9962 */ + return GL_FALSE; + } + if (copy->dstbuf_nr + 4 > copy->dstbuf_size) return GL_TRUE; @@ -458,7 +465,7 @@ static void replay_init( struct copy_context *copy ) dst->StrideB = copy->vertex_size; dst->Ptr = copy->dstbuf + offset; dst->Enabled = GL_TRUE; - dst->Normalized = GL_TRUE; + dst->Normalized = src->Normalized; dst->BufferObj = ctx->Array.NullBufferObj; dst->_MaxElement = copy->dstbuf_size; /* may be less! */ -- cgit v1.2.3 From 0ed3ff5011442facdaccdb84518d7712833f9dab Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 08:17:02 +0100 Subject: fix even-sized point positioning (bug 11874) --- src/mesa/swrast/s_points.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 4768fbea972..21316372e80 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -172,9 +172,9 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) } else { /* even size */ - xmin = (GLint) x - iRadius + 1; + xmin = (GLint) x - iRadius; xmax = xmin + iSize - 1; - ymin = (GLint) y - iRadius + 1; + ymin = (GLint) y - iRadius; ymax = ymin + iSize - 1; } @@ -418,9 +418,9 @@ large_point(GLcontext *ctx, const SWvertex *vert) } else { /* even size */ - xmin = (GLint) x - iRadius + 1; + xmin = (GLint) x - iRadius; xmax = xmin + iSize - 1; - ymin = (GLint) y - iRadius + 1; + ymin = (GLint) y - iRadius; ymax = ymin + iSize - 1; } -- cgit v1.2.3 From 872d1791414cd39df03f35330c1e7e9d88f229b3 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 21:42:34 +0100 Subject: fix swizzle error test (bug 11881) --- src/mesa/shader/atifragshader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index 4727c1a4365..854c9118741 100644 --- a/src/mesa/shader/atifragshader.c +++ b/src/mesa/shader/atifragshader.c @@ -440,7 +440,7 @@ _mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle) _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(coord)"); return; } - if ((swizzle < GL_SWIZZLE_STR_ATI) && (swizzle > GL_SWIZZLE_STQ_DQ_ATI)) { + if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(swizzle)"); return; } @@ -513,7 +513,7 @@ _mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle) _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(interp)"); return; } - if ((swizzle < GL_SWIZZLE_STR_ATI) && (swizzle > GL_SWIZZLE_STQ_DQ_ATI)) { + if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(swizzle)"); return; } -- cgit v1.2.3 From 237b985356b4d791ee2f184a201de9704614b9b1 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 21:48:31 +0100 Subject: fix potential NULL dereference (bug 11880) --- src/mesa/shader/shader_api.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 1a931326afa..a1e73ef125c 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -377,7 +377,7 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader) struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program); struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); - const GLuint n = shProg->NumShaders; + GLuint n; GLuint i; if (!shProg || !sh) { @@ -386,6 +386,8 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader) return; } + n = shProg->NumShaders; + for (i = 0; i < n; i++) { if (shProg->Shaders[i] == sh) { /* already attached */ @@ -547,7 +549,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader) { struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program); - const GLuint n = shProg->NumShaders; + GLuint n; GLuint i, j; if (!shProg) { @@ -556,6 +558,8 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader) return; } + n = shProg->NumShaders; + for (i = 0; i < n; i++) { if (shProg->Shaders[i]->Name == shader) { /* found it */ -- cgit v1.2.3 From 90cc31f31bbc9039fcd9acab7d6e72f2c9a186bb Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 21:57:29 +0100 Subject: fix potential NULL dereference (bug 11879) --- src/mesa/drivers/dri/unichrome/via_context.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 4d25d328e33..7c738777209 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -733,14 +733,15 @@ void viaXMesaWindowMoved(struct via_context *vmesa) { __DRIdrawablePrivate *const drawable = vmesa->driDrawable; __DRIdrawablePrivate *const readable = vmesa->driReadable; - struct via_renderbuffer *const draw_buffer = - (struct via_renderbuffer *) drawable->driverPrivate; - struct via_renderbuffer *const read_buffer = - (struct via_renderbuffer *) readable->driverPrivate; + struct via_renderbuffer * draw_buffer; + struct via_renderbuffer * read_buffer; GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; if (!drawable) return; + + draw_buffer = (struct via_renderbuffer *) drawable->driverPrivate; + read_buffer = (struct via_renderbuffer *) readable->driverPrivate; switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) { case BUFFER_BIT_BACK_LEFT: -- cgit v1.2.3 From 3973d1ad3353cd66c69e5170908a9e9ae03477fb Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 22:06:08 +0100 Subject: move free() after dereference (bug 11878) --- src/mesa/drivers/dri/i810/i810screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c index f64c10a9ae0..f8cf050d7e4 100644 --- a/src/mesa/drivers/dri/i810/i810screen.c +++ b/src/mesa/drivers/dri/i810/i810screen.c @@ -288,8 +288,8 @@ i810InitDriver(__DRIscreenPrivate *sPriv) i810Screen->depth.handle, i810Screen->depth.size, (drmAddress *)&i810Screen->depth.map) != 0) { - FREE(i810Screen); drmUnmap(i810Screen->back.map, i810Screen->back.size); + FREE(i810Screen); sPriv->private = NULL; __driUtilMessage("i810InitDriver: drmMap (2) failed"); return GL_FALSE; -- cgit v1.2.3 From 6a78221a10d1c97f84e4c47e10b721aa4777d761 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Wed, 8 Aug 2007 14:49:37 +0200 Subject: nouveau: Missing notifier -> notifierobj migration I missed this in the original migration. --- src/mesa/drivers/dri/nouveau/nouveau_context.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 9a0be2cb2a5..fdbde51a728 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -109,12 +109,12 @@ typedef struct nouveau_context { uint64_t gart_size; /* Channel synchronisation */ - struct drm_nouveau_notifier_alloc *syncNotifier; + struct drm_nouveau_notifierobj_alloc *syncNotifier; /* ARB_occlusion_query / EXT_timer_query */ GLuint query_object_max; GLboolean * query_alloc; - struct drm_nouveau_notifier_alloc *queryNotifier; + struct drm_nouveau_notifierobj_alloc *queryNotifier; /* Additional hw-specific functions */ nouveau_hw_func hw_func; -- cgit v1.2.3 From 48c37a29fa527aabcec76731de0bee508869e835 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 9 Aug 2007 08:47:05 +0100 Subject: fix byte swap bug for GLint stencil indexes (bug 11909) --- src/mesa/main/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 9760e5f8d24..347cec66ef4 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -3794,7 +3794,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, GLint *dst = (GLint *) dest; GLuint i; for (i=0;iSwapBytes) { _mesa_swap4( (GLuint *) dst, n ); -- cgit v1.2.3 From 2cafd749b8e4fa44863c176389f7201c7f74eca9 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 10 Aug 2007 15:14:12 +0800 Subject: i965: set mt->cpp differently with compressed texture --- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 2 +- src/mesa/drivers/dri/i965/intel_tex_validate.c | 36 +++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 8486086b274..d7b1946ce34 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -75,7 +75,7 @@ struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel, mt->width0 = width0; mt->height0 = height0; mt->depth0 = depth0; - mt->cpp = compressed ? 2 : cpp; + mt->cpp = cpp; mt->compressed = compressed; switch (intel->intelScreen->deviceID) { diff --git a/src/mesa/drivers/dri/i965/intel_tex_validate.c b/src/mesa/drivers/dri/i965/intel_tex_validate.c index 44ee94614d5..8c05e7cdabc 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_validate.c +++ b/src/mesa/drivers/dri/i965/intel_tex_validate.c @@ -122,6 +122,29 @@ static void intel_texture_invalidate_cb( struct intel_context *intel, intel_texture_invalidate( (struct intel_texture_object *) ptr ); } +#include "texformat.h" +static GLuint intel_compressed_num_bytes(GLenum mesaFormat) +{ + GLuint bytes = 0; + + switch (mesaFormat) { + case MESA_FORMAT_RGB_FXT1: + case MESA_FORMAT_RGBA_FXT1: + case MESA_FORMAT_RGB_DXT1: + case MESA_FORMAT_RGBA_DXT1: + bytes = 2; + break; + + case MESA_FORMAT_RGBA_DXT3: + case MESA_FORMAT_RGBA_DXT5: + bytes = 4; + + default: + break; + } + + return bytes; +} /* */ @@ -132,7 +155,8 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint face, i; GLuint nr_faces = 0; struct gl_texture_image *firstImage; - + GLuint cpp = 0; + if( tObj == intel->frame_buffer_texobj ) return GL_FALSE; @@ -165,6 +189,12 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, + if (firstImage->IsCompressed) { + cpp = intel_compressed_num_bytes(firstImage->TexFormat->MesaFormat); + } else { + cpp = firstImage->TexFormat->TexelBytes; + } + /* Check tree can hold all active levels. Check tree matches * target, imageFormat, etc. */ @@ -176,7 +206,7 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, intelObj->mt->width0 != firstImage->Width || intelObj->mt->height0 != firstImage->Height || intelObj->mt->depth0 != firstImage->Depth || - intelObj->mt->cpp != firstImage->TexFormat->TexelBytes || + intelObj->mt->cpp != cpp || intelObj->mt->compressed != firstImage->IsCompressed)) { intel_miptree_destroy(intel, intelObj->mt); @@ -199,7 +229,7 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, firstImage->Width, firstImage->Height, firstImage->Depth, - firstImage->TexFormat->TexelBytes, + cpp, firstImage->IsCompressed); /* Tell the buffer manager that we will manage the backing -- cgit v1.2.3 From 8ea66fa2ec9eeb6a7e869ff08d713f5e77d795e0 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 10 Aug 2007 16:23:14 +0800 Subject: i965/i915tex: applying right alignment to compressed texture, which make small textures(4x4,2x2,1x1) work well. --- src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c | 9 ++++-- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 16 ++++++++-- src/mesa/drivers/dri/intel/intel_tex_layout.c | 38 +++++++++++++++++++++--- src/mesa/drivers/dri/intel/intel_tex_layout.h | 1 + 4 files changed, 55 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c index 843a78eb82b..fc38a28290d 100644 --- a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c @@ -325,6 +325,7 @@ intel_miptree_image_data(struct intel_context *intel, } } +extern GLuint intel_compressed_alignment(GLenum); /* Copy mipmap image between trees */ void @@ -342,8 +343,12 @@ intel_miptree_image_copy(struct intel_context *intel, const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level); GLuint i; - if (dst->compressed) - height /= 4; + if (dst->compressed) { + GLuint alignment = intel_compressed_alignment(dst->internal_format); + height = (height + 3) / 4; + width = ((width + alignment - 1) & ~(alignment - 1)); + } + for (i = 0; i < depth; i++) { intel_region_copy(intel->intelScreen, dst->region, dst_offset + dst_depth_offset[i], diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index d7b1946ce34..f24f2346822 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -211,7 +211,7 @@ GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt, - +extern GLuint intel_compressed_alignment(GLenum); /* Upload data for a particular image. */ GLboolean intel_miptree_image_data(struct intel_context *intel, @@ -226,6 +226,16 @@ GLboolean intel_miptree_image_data(struct intel_context *intel, GLuint dst_offset = intel_miptree_image_offset(dst, face, level); const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level); GLuint i; + GLuint width, height, alignment; + + width = dst->level[level].width; + height = dst->level[level].height; + + if (dst->compressed) { + alignment = intel_compressed_alignment(dst->internal_format); + width = ((width + alignment - 1) & ~(alignment - 1)); + height = (height + 3) / 4; + } DBG("%s\n", __FUNCTION__); for (i = 0; i < depth; i++) { @@ -237,8 +247,8 @@ GLboolean intel_miptree_image_data(struct intel_context *intel, src, src_row_pitch, 0, 0, /* source x,y */ - dst->level[level].width, - dst->level[level].height)) + width, + height)) return GL_FALSE; src += src_image_pitch; } diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c index fcb5cc39068..fdecd3e1868 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.c +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -40,6 +40,23 @@ static int align(int value, int alignment) return (value + alignment - 1) & ~(alignment - 1); } +GLuint intel_compressed_alignment(GLenum internalFormat) +{ + GLuint alignment = 4; + + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + alignment = 8; + break; + + default: + break; + } + + return alignment; +} + void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ) { GLint align_h = 2, align_w = 4; @@ -51,17 +68,30 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ) mt->pitch = mt->width0; + if (mt->compressed) { + align_w = intel_compressed_alignment(mt->internal_format); + mt->pitch = align(mt->width0, align_w); + } + /* May need to adjust pitch to accomodate the placement of * the 2nd mipmap. This occurs when the alignment * constraints of mipmap placement push the right edge of the * 2nd mipmap out past the width of its parent. */ if (mt->first_level != mt->last_level) { - GLuint mip1_width = align(minify(mt->width0), align_w) - + minify(minify(mt->width0)); + GLuint mip1_width; + + if (mt->compressed) { + mip1_width = align(minify(mt->width0), align_w) + + align(minify(minify(mt->width0)), align_w); + } else { + mip1_width = align(minify(mt->width0), align_w) + + minify(minify(mt->width0)); + } - if (mip1_width > mt->width0) - mt->pitch = mip1_width; + if (mip1_width > mt->pitch) { + mt->pitch = mip1_width; + } } /* Pitch must be a whole number of dwords, even though we diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.h b/src/mesa/drivers/dri/intel/intel_tex_layout.h index 1e37f8f525f..99d41c3629e 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.h +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.h @@ -39,3 +39,4 @@ static GLuint minify( GLuint d ) } extern void i945_miptree_layout_2d( struct intel_mipmap_tree *mt ); +extern GLuint intel_compressed_alignment(GLenum); -- cgit v1.2.3 From db928291dcbda2a820dbb1668c43d2fb4266be7c Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 10 Aug 2007 16:37:30 +0800 Subject: i965: roland's DXTn format texture patch(bug10347) --- src/mesa/drivers/dri/i965/brw_tex.c | 12 +++++++++--- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c index a62395a4327..ad29316a42a 100644 --- a/src/mesa/drivers/dri/i965/brw_tex.c +++ b/src/mesa/drivers/dri/i965/brw_tex.c @@ -154,13 +154,19 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat, case GL_RGB_S3TC: case GL_RGB4_S3TC: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return &_mesa_texformat_rgb_dxt1; + + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return &_mesa_texformat_rgba_dxt1; + case GL_RGBA_S3TC: case GL_RGBA4_S3TC: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return &_mesa_texformat_rgba_dxt3; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return &_mesa_texformat_rgb_dxt1; /* there is no rgba support? */ + return &_mesa_texformat_rgba_dxt5; case GL_DEPTH_COMPONENT: case GL_DEPTH_COMPONENT16: diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index acf5771e779..0a45164a0fd 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -116,9 +116,17 @@ static GLuint translate_tex_format( GLuint mesa_format ) case MESA_FORMAT_Z16: return BRW_SURFACEFORMAT_I16_UNORM; - case MESA_FORMAT_RGBA_DXT1: case MESA_FORMAT_RGB_DXT1: - return BRW_SURFACEFORMAT_DXT1_RGB; + return BRW_SURFACEFORMAT_DXT1_RGB; + + case MESA_FORMAT_RGBA_DXT1: + return BRW_SURFACEFORMAT_BC1_UNORM; + + case MESA_FORMAT_RGBA_DXT3: + return BRW_SURFACEFORMAT_BC2_UNORM; + + case MESA_FORMAT_RGBA_DXT5: + return BRW_SURFACEFORMAT_BC3_UNORM; case MESA_FORMAT_SRGBA8: return BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB; -- cgit v1.2.3 From 4a789e408dbba7891f1436b2f42e7c0824e5ba7a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 10 Aug 2007 19:17:35 +0100 Subject: Better debugging --- src/mesa/drivers/dri/i915tex/Makefile | 1 + src/mesa/drivers/dri/i915tex/i915_debug.c | 614 +++++++++++++---------- src/mesa/drivers/dri/i915tex/i915_debug.h | 55 ++ src/mesa/drivers/dri/i915tex/i915_debug_fp.c | 331 ++++++++++++ src/mesa/drivers/dri/i915tex/i915_vtbl.c | 9 +- src/mesa/drivers/dri/i915tex/intel_batchbuffer.c | 12 +- 6 files changed, 760 insertions(+), 262 deletions(-) create mode 100644 src/mesa/drivers/dri/i915tex/i915_debug.h create mode 100644 src/mesa/drivers/dri/i915tex/i915_debug_fp.c (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/Makefile b/src/mesa/drivers/dri/i915tex/Makefile index b218929dce7..445327f243e 100644 --- a/src/mesa/drivers/dri/i915tex/Makefile +++ b/src/mesa/drivers/dri/i915tex/Makefile @@ -37,6 +37,7 @@ DRIVER_SOURCES = \ i915_texstate.c \ i915_context.c \ i915_debug.c \ + i915_debug_fp.c \ i915_fragprog.c \ i915_metaops.c \ i915_program.c \ diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.c b/src/mesa/drivers/dri/i915tex/i915_debug.c index 974527e14cc..e22d79b1670 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug.c @@ -25,310 +25,414 @@ * **************************************************************************/ +#include "imports.h" + #include "i915_reg.h" #include "i915_context.h" -#include - - -static const char *opcodes[0x20] = { - "NOP", - "ADD", - "MOV", - "MUL", - "MAD", - "DP2ADD", - "DP3", - "DP4", - "FRC", - "RCP", - "RSQ", - "EXP", - "LOG", - "CMP", - "MIN", - "MAX", - "FLR", - "MOD", - "TRC", - "SGE", - "SLT", - "TEXLD", - "TEXLDP", - "TEXLDB", - "TEXKILL", - "DCL", - "0x1a", - "0x1b", - "0x1c", - "0x1d", - "0x1e", - "0x1f", -}; - - -static const int args[0x20] = { - 0, /* 0 nop */ - 2, /* 1 add */ - 1, /* 2 mov */ - 2, /* 3 m ul */ - 3, /* 4 mad */ - 3, /* 5 dp2add */ - 2, /* 6 dp3 */ - 2, /* 7 dp4 */ - 1, /* 8 frc */ - 1, /* 9 rcp */ - 1, /* a rsq */ - 1, /* b exp */ - 1, /* c log */ - 3, /* d cmp */ - 2, /* e min */ - 2, /* f max */ - 1, /* 10 flr */ - 1, /* 11 mod */ - 1, /* 12 trc */ - 2, /* 13 sge */ - 2, /* 14 slt */ - 1, - 1, - 1, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, -}; - - -static const char *regname[0x8] = { - "R", - "T", - "CONST", - "S", - "OC", - "OD", - "U", - "UNKNOWN", -}; - -static void -print_reg_type_nr(GLuint type, GLuint nr) +#include "i915_debug.h" + + + +static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len ) { - switch (type) { - case REG_TYPE_T: - switch (nr) { - case T_DIFFUSE: - fprintf(stderr, "T_DIFFUSE"); - return; - case T_SPECULAR: - fprintf(stderr, "T_SPECULAR"); - return; - case T_FOG_W: - fprintf(stderr, "T_FOG_W"); - return; - default: - fprintf(stderr, "T_TEX%d", nr); - return; - } - case REG_TYPE_OC: - if (nr == 0) { - fprintf(stderr, "oC"); - return; - } - break; - case REG_TYPE_OD: - if (nr == 0) { - fprintf(stderr, "oD"); - return; - } - break; - default: - break; + GLuint i; + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + + if (len == 0) { + _mesa_printf("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + assert(0); + return GL_FALSE; } - fprintf(stderr, "%s[%d]", regname[type], nr); -} + if (stream->print_addresses) + _mesa_printf("%08x: ", stream->offset); -#define REG_SWIZZLE_MASK 0x7777 -#define REG_NEGATE_MASK 0x8888 -#define REG_SWIZZLE_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \ - (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \ - (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \ - (SRC_W << A2_SRC2_CHANNEL_W_SHIFT)) + _mesa_printf("%s (%d dwords):\n", name, len); + for (i = 0; i < len; i++) + _mesa_printf("\t\t0x%08x\n", ptr[i]); + _mesa_printf("\n"); + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; +} -static void -print_reg_neg_swizzle(GLuint reg) + +static const char *get_prim_name( GLuint val ) { - int i; - - if ((reg & REG_SWIZZLE_MASK) == REG_SWIZZLE_XYZW && - (reg & REG_NEGATE_MASK) == 0) - return; - - fprintf(stderr, "."); - - for (i = 3; i >= 0; i--) { - if (reg & (1 << ((i * 4) + 3))) - fprintf(stderr, "-"); - - switch ((reg >> (i * 4)) & 0x7) { - case 0: - fprintf(stderr, "x"); - break; - case 1: - fprintf(stderr, "y"); - break; - case 2: - fprintf(stderr, "z"); - break; - case 3: - fprintf(stderr, "w"); - break; - case 4: - fprintf(stderr, "0"); - break; - case 5: - fprintf(stderr, "1"); - break; - default: - fprintf(stderr, "?"); - break; - } + switch (val & PRIM3D_MASK) { + case PRIM3D_TRILIST: return "TRILIST"; break; + case PRIM3D_TRISTRIP: return "TRISTRIP"; break; + case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break; + case PRIM3D_TRIFAN: return "TRIFAN"; break; + case PRIM3D_POLY: return "POLY"; break; + case PRIM3D_LINELIST: return "LINELIST"; break; + case PRIM3D_LINESTRIP: return "LINESTRIP"; break; + case PRIM3D_RECTLIST: return "RECTLIST"; break; + case PRIM3D_POINTLIST: return "POINTLIST"; break; + case PRIM3D_DIB: return "DIB"; break; + case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break; + case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break; + default: return "????"; break; } } - -static void -print_src_reg(GLuint dword) +static GLboolean debug_prim( struct debug_stream *stream, const char *name, + GLboolean dump_floats, + GLuint len ) { - GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK; - GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr(type, nr); - print_reg_neg_swizzle(dword); + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + const char *prim = get_prim_name( ptr[0] ); + GLuint i; + + + + _mesa_printf("%s %s (%d dwords):\n", name, prim, len); + _mesa_printf("\t\t0x%08x\n", ptr[0]); + for (i = 1; i < len; i++) { + if (dump_floats) + _mesa_printf("\t\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + else + _mesa_printf("\t\t0x%08x\n", ptr[i]); + } + + + _mesa_printf("\n"); + + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; } + -void -i915_print_ureg(const char *msg, GLuint ureg) + + +static GLboolean debug_program( struct debug_stream *stream, const char *name, GLuint len ) { - fprintf(stderr, "%s: ", msg); - print_src_reg(ureg >> 8); - fprintf(stderr, "\n"); + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + + if (len == 0) { + _mesa_printf("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + assert(0); + return GL_FALSE; + } + + if (stream->print_addresses) + _mesa_printf("%08x: ", stream->offset); + + _mesa_printf("%s (%d dwords):\n", name, len); + i915_disassemble_program( ptr, len ); + + stream->offset += len * sizeof(GLuint); + return GL_TRUE; } -static void -print_dest_reg(GLuint dword) + +static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLuint len ) { - GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK; - GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr(type, nr); - if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) - return; - fprintf(stderr, "."); - if (dword & A0_DEST_CHANNEL_X) - fprintf(stderr, "x"); - if (dword & A0_DEST_CHANNEL_Y) - fprintf(stderr, "y"); - if (dword & A0_DEST_CHANNEL_Z) - fprintf(stderr, "z"); - if (dword & A0_DEST_CHANNEL_W) - fprintf(stderr, "w"); -} + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint old_offset = stream->offset + len * sizeof(GLuint); + GLuint i; + + _mesa_printf("%s (%d dwords):\n", name, len); + for (i = 0; i < len; i++) + _mesa_printf("\t\t0x%08x\n", ptr[i]); + stream->offset = ptr[1] & ~0x3; + + if (stream->offset < old_offset) + _mesa_printf("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", + old_offset, stream->offset ); + else + _mesa_printf("\n... skipping from 0x%x --> 0x%x ...\n\n", + old_offset, stream->offset ); -#define GET_SRC0_REG(r0, r1) ((r0<<14)|(r1>>A1_SRC0_CHANNEL_W_SHIFT)) -#define GET_SRC1_REG(r0, r1) ((r0<<8)|(r1>>A2_SRC1_CHANNEL_W_SHIFT)) -#define GET_SRC2_REG(r) (r) + + return GL_TRUE; +} -static void -print_arith_op(GLuint opcode, const GLuint * program) +static GLboolean debug_variable_length_prim( struct debug_stream *stream ) { - if (opcode != A0_NOP) { - print_dest_reg(program[0]); - if (program[0] & A0_DEST_SATURATE) - fprintf(stderr, " = SATURATE "); - else - fprintf(stderr, " = "); - } + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + const char *prim = get_prim_name( ptr[0] ); + GLuint i, len; - fprintf(stderr, "%s ", opcodes[opcode]); + GLushort *idx = (GLushort *)(ptr+1); + for (i = 0; idx[i] != 0xffff; i++) + ; + + len = 1+(i+2)/2; + + _mesa_printf("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); + for (i = 0; i < len; i++) + _mesa_printf("\t\t0x%08x\n", ptr[i]); + _mesa_printf("\n"); + + stream->offset += len * sizeof(GLuint); + return GL_TRUE; +} - print_src_reg(GET_SRC0_REG(program[0], program[1])); - if (args[opcode] == 1) { - fprintf(stderr, "\n"); - return; - } - fprintf(stderr, ", "); - print_src_reg(GET_SRC1_REG(program[1], program[2])); - if (args[opcode] == 2) { - fprintf(stderr, "\n"); - return; +static GLboolean debug_load_immediate( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint bits = (ptr[0] >> 4) & 0xff; + GLuint i, j = 0; + + _mesa_printf("%s (%d dwords, flags: %x):\n", name, len, bits); + _mesa_printf("\t\t0x%08x\n", ptr[j++]); + + for (i = 0; i < 8; i++) { + if (bits & (1<offset += len * sizeof(GLuint); + + return GL_TRUE; } + -static void -print_tex_op(GLuint opcode, const GLuint * program) +static GLboolean debug_load_indirect( struct debug_stream *stream, + const char *name, + GLuint len ) { - print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - fprintf(stderr, " = "); + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint bits = (ptr[0] >> 8) & 0x3f; + GLuint i, j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t\t0x%08x\n", ptr[j++]); + + for (i = 0; i < 6; i++) { + if (bits & (1<> T1_ADDRESS_REG_TYPE_SHIFT) & - REG_TYPE_MASK, - (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - fprintf(stderr, "\n"); + stream->offset += len * sizeof(GLuint); + + return GL_TRUE; } + -static void -print_dcl_op(GLuint opcode, const GLuint * program) +static GLboolean i915_debug_packet( struct debug_stream *stream ) { - fprintf(stderr, "%s ", opcodes[opcode]); - print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - fprintf(stderr, "\n"); + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + GLuint cmd = *ptr; + + switch (((cmd >> 29) & 0x7)) { + case 0x0: + switch ((cmd >> 23) & 0x3f) { + case 0x0: + return debug(stream, "MI_NOOP", 1); + case 0x3: + return debug(stream, "MI_WAIT_FOR_EVENT", 1); + case 0x4: + return debug(stream, "MI_FLUSH", 1); + case 0xA: + debug(stream, "MI_BATCH_BUFFER_END", 1); + return GL_FALSE; + case 0x22: + return debug(stream, "MI_LOAD_REGISTER_IMM", 3); + case 0x31: + return debug_chain(stream, "MI_BATCH_BUFFER_START", 2); + default: + break; + } + break; + case 0x1: + break; + case 0x2: + switch ((cmd >> 22) & 0xff) { + case 0x50: + return debug(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2); + case 0x53: + return debug(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2); + default: + return debug(stream, "blit command", (cmd & 0xff) + 2); + } + break; + case 0x3: + switch ((cmd >> 24) & 0x1f) { + case 0x6: + return debug(stream, "3DSTATE_ANTI_ALIASING", 1); + case 0x7: + return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1); + case 0x8: + return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2); + case 0x9: + return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1); + case 0xb: + return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1); + case 0xc: + return debug(stream, "3DSTATE_MODES5", 1); + case 0xd: + return debug(stream, "3DSTATE_MODES4", 1); + case 0x15: + return debug(stream, "3DSTATE_FOG_COLOR", 1); + case 0x16: + return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1); + case 0x1c: + /* 3DState16NP */ + switch((cmd >> 19) & 0x1f) { + case 0x10: + return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1); + case 0x11: + return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1); + default: + break; + } + break; + case 0x1d: + /* 3DStateMW */ + switch ((cmd >> 16) & 0xff) { + case 0x0: + return debug(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2); + case 0x1: + return debug(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2); + case 0x4: + return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2); + case 0x5: + return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2); + case 0x6: + return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2); + case 0x7: + return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2); + case 0x80: + return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2); + case 0x81: + return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2); + case 0x83: + return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2); + case 0x85: + return debug(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2); + case 0x88: + return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2); + case 0x89: + return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2); + case 0x8e: + return debug(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2); + case 0x97: + return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2); + case 0x98: + return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2); + case 0x99: + return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2); + case 0x9a: + return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2); + case 0x9c: + return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2); + default: + assert(0); + return 0; + } + break; + case 0x1e: + if (cmd & (1 << 23)) + return debug(stream, "???", (cmd & 0xffff) + 1); + else + return debug(stream, "", 1); + break; + case 0x1f: + if ((cmd & (1 << 23)) == 0) + return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2); + else if (cmd & (1 << 17)) + { + if ((cmd & 0xffff) == 0) + return debug_variable_length_prim(stream); + else + return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1); + } + else + return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2); + break; + default: + return debug(stream, "", 0); + } + default: + assert(0); + return 0; + } + + assert(0); + return 0; } + void -i915_disassemble_program(const GLuint * program, GLuint sz) +i915_dump_batchbuffer( GLuint *start, + GLuint *end ) { - GLuint size = program[0] & 0x1ff; - GLint i; + struct debug_stream stream; + GLuint bytes = (end - start) * 4; + GLboolean done = GL_FALSE; - fprintf(stderr, "BEGIN\n"); + fprintf(stderr, "\n\nBATCH: (%d)\n", bytes / 4); - if (size + 2 != sz) { - fprintf(stderr, "%s: program size mismatch %d/%d\n", __FUNCTION__, - size + 2, sz); - exit(1); - } + stream.offset = 0; + stream.ptr = (char *)start; + stream.print_addresses = 0; - program++; - for (i = 1; i < sz; i += 3, program += 3) { - GLuint opcode = program[0] & (0x1f << 24); + while (!done && + stream.offset < bytes && + stream.offset >= 0) + { + if (!i915_debug_packet( &stream )) + break; - if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) - print_arith_op(opcode >> 24, program); - else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL) - print_tex_op(opcode >> 24, program); - else if (opcode == D0_DCL) - print_dcl_op(opcode >> 24, program); - else - fprintf(stderr, "Unknown opcode 0x%x\n", opcode); + assert(stream.offset <= bytes && + stream.offset >= 0); } - fprintf(stderr, "END\n\n"); + fprintf(stderr, "END-BATCH\n\n\n"); } + + diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.h b/src/mesa/drivers/dri/i915tex/i915_debug.h new file mode 100644 index 00000000000..0643a8c631c --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/i915_debug.h @@ -0,0 +1,55 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN 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. + * + **************************************************************************/ + +/* Authors: Keith Whitwell + */ + +#ifndef I915_DEBUG_H +#define I915_DEBUG_H + +struct i915_context; + +struct debug_stream +{ + unsigned offset; /* current gtt offset */ + char *ptr; /* pointer to gtt offset zero */ + char *end; /* pointer to gtt offset zero */ + unsigned print_addresses; +}; + + + +extern void i915_disassemble_program(const unsigned *program, unsigned sz); +extern void i915_print_ureg(const char *msg, unsigned ureg); + + +void +i915_dump_batchbuffer( unsigned *start, + unsigned *end ); + + +#endif diff --git a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c new file mode 100644 index 00000000000..f4e8ae95ade --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c @@ -0,0 +1,331 @@ +/************************************************************************** + * + * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN 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 "i915_reg.h" +#include "i915_debug.h" +//#include "i915_fpc.h" +#include "shader/program.h" +#include "shader/prog_instruction.h" +#include "shader/prog_print.h" + +static const char *opcodes[0x20] = { + "NOP", + "ADD", + "MOV", + "MUL", + "MAD", + "DP2ADD", + "DP3", + "DP4", + "FRC", + "RCP", + "RSQ", + "EXP", + "LOG", + "CMP", + "MIN", + "MAX", + "FLR", + "MOD", + "TRC", + "SGE", + "SLT", + "TEXLD", + "TEXLDP", + "TEXLDB", + "TEXKILL", + "DCL", + "0x1a", + "0x1b", + "0x1c", + "0x1d", + "0x1e", + "0x1f", +}; + + +static const int args[0x20] = { + 0, /* 0 nop */ + 2, /* 1 add */ + 1, /* 2 mov */ + 2, /* 3 m ul */ + 3, /* 4 mad */ + 3, /* 5 dp2add */ + 2, /* 6 dp3 */ + 2, /* 7 dp4 */ + 1, /* 8 frc */ + 1, /* 9 rcp */ + 1, /* a rsq */ + 1, /* b exp */ + 1, /* c log */ + 3, /* d cmp */ + 2, /* e min */ + 2, /* f max */ + 1, /* 10 flr */ + 1, /* 11 mod */ + 1, /* 12 trc */ + 2, /* 13 sge */ + 2, /* 14 slt */ + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +}; + + +static const char *regname[0x8] = { + "R", + "T", + "CONST", + "S", + "OC", + "OD", + "U", + "UNKNOWN", +}; + +static void +print_reg_type_nr(GLuint type, GLuint nr) +{ + switch (type) { + case REG_TYPE_T: + switch (nr) { + case T_DIFFUSE: + _mesa_printf("T_DIFFUSE"); + return; + case T_SPECULAR: + _mesa_printf("T_SPECULAR"); + return; + case T_FOG_W: + _mesa_printf("T_FOG_W"); + return; + default: + _mesa_printf("T_TEX%d", nr); + return; + } + case REG_TYPE_OC: + if (nr == 0) { + _mesa_printf("oC"); + return; + } + break; + case REG_TYPE_OD: + if (nr == 0) { + _mesa_printf("oD"); + return; + } + break; + default: + break; + } + + _mesa_printf("%s[%d]", regname[type], nr); +} + +#define REG_SWIZZLE_MASK 0x7777 +#define REG_NEGATE_MASK 0x8888 + +#define REG_SWIZZLE_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \ + (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \ + (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \ + (SRC_W << A2_SRC2_CHANNEL_W_SHIFT)) + + +static void +print_reg_neg_swizzle(GLuint reg) +{ + int i; + + if ((reg & REG_SWIZZLE_MASK) == REG_SWIZZLE_XYZW && + (reg & REG_NEGATE_MASK) == 0) + return; + + _mesa_printf("."); + + for (i = 3; i >= 0; i--) { + if (reg & (1 << ((i * 4) + 3))) + _mesa_printf("-"); + + switch ((reg >> (i * 4)) & 0x7) { + case 0: + _mesa_printf("x"); + break; + case 1: + _mesa_printf("y"); + break; + case 2: + _mesa_printf("z"); + break; + case 3: + _mesa_printf("w"); + break; + case 4: + _mesa_printf("0"); + break; + case 5: + _mesa_printf("1"); + break; + default: + _mesa_printf("?"); + break; + } + } +} + + +static void +print_src_reg(GLuint dword) +{ + GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK; + GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK; + print_reg_type_nr(type, nr); + print_reg_neg_swizzle(dword); +} + + +static void +print_dest_reg(GLuint dword) +{ + GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK; + GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK; + print_reg_type_nr(type, nr); + if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) + return; + _mesa_printf("."); + if (dword & A0_DEST_CHANNEL_X) + _mesa_printf("x"); + if (dword & A0_DEST_CHANNEL_Y) + _mesa_printf("y"); + if (dword & A0_DEST_CHANNEL_Z) + _mesa_printf("z"); + if (dword & A0_DEST_CHANNEL_W) + _mesa_printf("w"); +} + + +#define GET_SRC0_REG(r0, r1) ((r0<<14)|(r1>>A1_SRC0_CHANNEL_W_SHIFT)) +#define GET_SRC1_REG(r0, r1) ((r0<<8)|(r1>>A2_SRC1_CHANNEL_W_SHIFT)) +#define GET_SRC2_REG(r) (r) + + +static void +print_arith_op(GLuint opcode, const GLuint * program) +{ + if (opcode != A0_NOP) { + print_dest_reg(program[0]); + if (program[0] & A0_DEST_SATURATE) + _mesa_printf(" = SATURATE "); + else + _mesa_printf(" = "); + } + + _mesa_printf("%s ", opcodes[opcode]); + + print_src_reg(GET_SRC0_REG(program[0], program[1])); + if (args[opcode] == 1) { + _mesa_printf("\n"); + return; + } + + _mesa_printf(", "); + print_src_reg(GET_SRC1_REG(program[1], program[2])); + if (args[opcode] == 2) { + _mesa_printf("\n"); + return; + } + + _mesa_printf(", "); + print_src_reg(GET_SRC2_REG(program[2])); + _mesa_printf("\n"); + return; +} + + +static void +print_tex_op(GLuint opcode, const GLuint * program) +{ + print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); + _mesa_printf(" = "); + + _mesa_printf("%s ", opcodes[opcode]); + + _mesa_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); + _mesa_printf("\n"); +} + +static void +print_dcl_op(GLuint opcode, const GLuint * program) +{ + _mesa_printf("%s ", opcodes[opcode]); + print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); + _mesa_printf("\n"); +} + + +void +i915_disassemble_program(const GLuint * program, GLuint sz) +{ + GLuint size = program[0] & 0x1ff; + GLint i; + + _mesa_printf("\t\tBEGIN\n"); + + assert(size + 2 == sz); + + program++; + for (i = 1; i < sz; i += 3, program += 3) { + GLuint opcode = program[0] & (0x1f << 24); + + _mesa_printf("\t\t"); + + if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) + print_arith_op(opcode >> 24, program); + else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL) + print_tex_op(opcode >> 24, program); + else if (opcode == D0_DCL) + print_dcl_op(opcode >> 24, program); + else + _mesa_printf("Unknown opcode 0x%x\n", opcode); + } + + _mesa_printf("\t\tEND\n\n"); +} + + diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index 9de35d8e297..ff99721769e 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -203,7 +203,7 @@ i915_emit_invarient_state(struct intel_context *intel) /* Need to initialize this to zero. */ - OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (1)); + OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (0)); OUT_BATCH(0); /* XXX: Use this */ @@ -221,6 +221,7 @@ i915_emit_invarient_state(struct intel_context *intel) /* Don't support twosided stencil yet */ OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0); + OUT_BATCH(0); ADVANCE_BATCH(); } @@ -252,6 +253,9 @@ get_state_size(struct i915_hw_state *state) GLuint i; GLuint sz = 0; + if (dirty & I915_UPLOAD_INVARIENT) + sz += 30 * 4; + if (dirty & I915_UPLOAD_CTX) sz += sizeof(state->Ctx); @@ -307,6 +311,7 @@ i915_emit_state(struct intel_context *intel) * causing more state to be dirty! */ dirty = get_dirty(state); + state->emitted |= dirty; if (INTEL_DEBUG & DEBUG_STATE) fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty); @@ -429,7 +434,7 @@ i915_emit_state(struct intel_context *intel) i915_disassemble_program(state->Program, state->ProgramSize); } - state->emitted |= dirty; + assert(get_dirty(state) == 0); } static void diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index c92b83bcb3a..5d0fd53961e 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -27,6 +27,7 @@ #include "intel_batchbuffer.h" #include "intel_ioctl.h" +#include "i915_debug.h" /* Relocations in kernel space: * - pass dma buffer seperately @@ -71,9 +72,8 @@ intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint count) { int i; fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count / 4); - for (i = 0; i < count / 4; i += 4) - fprintf(stderr, "0x%x:\t0x%08x 0x%08x 0x%08x 0x%08x\n", - offset + i * 4, ptr[i], ptr[i + 1], ptr[i + 2], ptr[i + 3]); + for (i = 0; i < count / 4; i += 1) + fprintf(stderr, "\t0x%08x\n", ptr[i]); fprintf(stderr, "END BATCH\n\n\n"); } @@ -186,8 +186,10 @@ do_flush_locked(struct intel_batchbuffer *batch, ptr[r->offset / 4] = driBOOffset(r->buf) + r->delta; } - if (INTEL_DEBUG & DEBUG_BATCH) - intel_dump_batchbuffer(0, ptr, used); + + i915_dump_batchbuffer(ptr, ptr + used/4); + + intel_dump_batchbuffer(0, ptr, used); driBOUnmap(batch->buffer); batch->map = NULL; -- cgit v1.2.3 From c60113cd41ac84f8737005ca1d7a1114e3725ae5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 11 Aug 2007 13:40:22 +0100 Subject: Improve debugging further. Pull apart some key packets into individual fields and print sanely. --- src/mesa/drivers/dri/i915tex/i915_debug.c | 445 ++++++++++++++++++++++- src/mesa/drivers/dri/i915tex/i915_debug_fp.c | 2 +- src/mesa/drivers/dri/i915tex/intel_batchbuffer.c | 7 +- 3 files changed, 430 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.c b/src/mesa/drivers/dri/i915tex/i915_debug.c index e22d79b1670..d5e4ff7ae09 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug.c @@ -50,7 +50,7 @@ static GLboolean debug( struct debug_stream *stream, const char *name, GLuint le _mesa_printf("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t\t0x%08x\n", ptr[i]); + _mesa_printf("\t0x%08x\n", ptr[i]); _mesa_printf("\n"); stream->offset += len * sizeof(GLuint); @@ -89,12 +89,12 @@ static GLboolean debug_prim( struct debug_stream *stream, const char *name, _mesa_printf("%s %s (%d dwords):\n", name, prim, len); - _mesa_printf("\t\t0x%08x\n", ptr[0]); + _mesa_printf("\t0x%08x\n", ptr[0]); for (i = 1; i < len; i++) { if (dump_floats) - _mesa_printf("\t\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + _mesa_printf("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); else - _mesa_printf("\t\t0x%08x\n", ptr[i]); + _mesa_printf("\t0x%08x\n", ptr[i]); } @@ -137,7 +137,7 @@ static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLu _mesa_printf("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t\t0x%08x\n", ptr[i]); + _mesa_printf("\t0x%08x\n", ptr[i]); stream->offset = ptr[1] & ~0x3; @@ -167,7 +167,7 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) _mesa_printf("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); for (i = 0; i < len; i++) - _mesa_printf("\t\t0x%08x\n", ptr[i]); + _mesa_printf("\t0x%08x\n", ptr[i]); _mesa_printf("\n"); stream->offset += len * sizeof(GLuint); @@ -175,23 +175,127 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) } +#define BITS( dw, hi, lo, ... ) \ +do { \ + unsigned himask = ~0UL >> (31 - (hi)); \ + _mesa_printf("\t\t "); \ + _mesa_printf(__VA_ARGS__); \ + _mesa_printf(": 0x%x\n", ((dw) & himask) >> (lo)); \ +} while (0) + +#define MBZ( dw, hi, lo) do { \ + unsigned x = (dw) >> (lo); \ + unsigned lomask = (1 << (lo)) - 1; \ + unsigned himask; \ + himask = (1UL << (hi)) - 1; \ + assert ((x & himask & ~lomask) == 0); \ +} while (0) + +#define FLAG( dw, bit, ... ) \ +do { \ + if (((dw) >> (bit)) & 1) { \ + _mesa_printf("\t\t "); \ + _mesa_printf(__VA_ARGS__); \ + _mesa_printf("\n"); \ + } \ +} while (0) + static GLboolean debug_load_immediate( struct debug_stream *stream, const char *name, GLuint len ) { GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); GLuint bits = (ptr[0] >> 4) & 0xff; - GLuint i, j = 0; + GLuint j = 0; _mesa_printf("%s (%d dwords, flags: %x):\n", name, len, bits); - _mesa_printf("\t\t0x%08x\n", ptr[j++]); + _mesa_printf("\t0x%08x\n", ptr[j++]); - for (i = 0; i < 8; i++) { - if (bits & (1<> (i * 4)) & 0xf; +// if (tc != 0xf) + BITS(tc, 3, 0, "tex coord %d", i); } + j++; + } + if (bits & (1<<3)) { + _mesa_printf("\t LIS3: 0x%08x\n", ptr[j]); + j++; + } + if (bits & (1<<4)) { + _mesa_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"); + FLAG(ptr[j], 17, "fog flatshade"); + FLAG(ptr[j], 16, "spec flatshade"); + FLAG(ptr[j], 15, "rgb flatshade"); + BITS(ptr[j], 14, 13, "cull mode"); + FLAG(ptr[j], 12, "vfmt: point width"); + FLAG(ptr[j], 11, "vfmt: specular/fog"); + FLAG(ptr[j], 10, "vfmt: rgba"); + FLAG(ptr[j], 9, "vfmt: depth offset"); + BITS(ptr[j], 8, 6, "vfmt: position (2==xyzw)"); + FLAG(ptr[j], 5, "force dflt diffuse"); + FLAG(ptr[j], 4, "force dflt specular"); + FLAG(ptr[j], 3, "local depth offset enable"); + FLAG(ptr[j], 2, "vfmt: fp32 fog coord"); + FLAG(ptr[j], 1, "sprite point"); + FLAG(ptr[j], 0, "antialiasing"); + j++; + } + if (bits & (1<<5)) { + _mesa_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"); + FLAG(ptr[j], 25, "global z offset enable"); + FLAG(ptr[j], 24, "fog enable"); + BITS(ptr[j], 23, 16, "stencil ref"); + BITS(ptr[j], 15, 13, "stencil test"); + BITS(ptr[j], 12, 10, "stencil fail op"); + BITS(ptr[j], 9, 7, "stencil pass z fail op"); + BITS(ptr[j], 6, 4, "stencil pass z pass op"); + FLAG(ptr[j], 3, "stencil write enable"); + FLAG(ptr[j], 2, "stencil test enable"); + FLAG(ptr[j], 1, "color dither enable"); + FLAG(ptr[j], 0, "logiop enable"); + j++; + } + if (bits & (1<<6)) { + _mesa_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"); + FLAG(ptr[j], 19, "depth test enable"); + BITS(ptr[j], 18, 16, "depth func"); + FLAG(ptr[j], 15, "blend enable"); + BITS(ptr[j], 14, 12, "blend func"); + BITS(ptr[j], 11, 8, "blend src factor"); + BITS(ptr[j], 7, 4, "blend dst factor"); + FLAG(ptr[j], 3, "depth write enable"); + FLAG(ptr[j], 2, "color write enable"); + BITS(ptr[j], 1, 0, "provoking vertex"); + j++; } + _mesa_printf("\n"); assert(j == len); @@ -212,7 +316,7 @@ static GLboolean debug_load_indirect( struct debug_stream *stream, GLuint i, j = 0; _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t\t0x%08x\n", ptr[j++]); + _mesa_printf("\t0x%08x\n", ptr[j++]); for (i = 0; i < 6; i++) { if (bits & (1<ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t0x%08x\n", ptr[j++]); + + BR13(stream, ptr[j++]); + BR22(stream, ptr[j++]); + BR23(stream, ptr[j++]); + BR09(stream, ptr[j++]); + BR26(stream, ptr[j++]); + BR11(stream, ptr[j++]); + BR12(stream, ptr[j++]); + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_color_blit( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t0x%08x\n", ptr[j++]); + + BR13(stream, ptr[j++]); + BR22(stream, ptr[j++]); + BR23(stream, ptr[j++]); + BR09(stream, ptr[j++]); + BR16(stream, ptr[j++]); + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_modes4( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_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"); + BITS(ptr[j], 15, 8, "stencil test mask"); + BITS(ptr[j], 7, 0, "stencil write mask"); + j++; + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_map_state( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t0x%08x\n", ptr[j++]); + + { + _mesa_printf("\t0x%08x\n", ptr[j]); + BITS(ptr[j], 15, 0, "map mask"); + j++; + } + + while (j < len) { + { + _mesa_printf("\t TMn.0: 0x%08x\n", ptr[j]); + _mesa_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++; + } + + { + _mesa_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"); + BITS(ptr[j], 6, 3, "texel format"); + FLAG(ptr[j], 2, "use fence regs"); + FLAG(ptr[j], 1, "tiled surface"); + FLAG(ptr[j], 0, "tile walk ymajor"); + j++; + } + { + _mesa_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"); + FLAG(ptr[j], 8, "mip layout right"); + BITS(ptr[j], 7, 0, "depth"); + j++; + } + } + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_sampler_state( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t0x%08x\n", ptr[j++]); + + { + _mesa_printf("\t0x%08x\n", ptr[j]); + BITS(ptr[j], 15, 0, "sampler mask"); + j++; + } + + while (j < len) { + { + _mesa_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"); + BITS(ptr[j], 28, 27, "chromakey index"); + BITS(ptr[j], 26, 22, "base mip level"); + BITS(ptr[j], 21, 20, "mip mode filter"); + BITS(ptr[j], 19, 17, "mag mode filter"); + BITS(ptr[j], 16, 14, "min mode filter"); + BITS(ptr[j], 13, 5, "lod bias (s4.4)"); + FLAG(ptr[j], 4, "shadow enable"); + FLAG(ptr[j], 3, "max-aniso-4"); + BITS(ptr[j], 2, 0, "shadow func"); + j++; + } + + { + _mesa_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"); + FLAG(ptr[j], 16, "keyed tex filter mode"); + FLAG(ptr[j], 15, "chromakey enable"); + BITS(ptr[j], 14, 12, "tcx wrap mode"); + BITS(ptr[j], 11, 9, "tcy wrap mode"); + BITS(ptr[j], 8, 6, "tcz wrap mode"); + FLAG(ptr[j], 5, "normalized coords"); + BITS(ptr[j], 4, 1, "map (surface) index"); + FLAG(ptr[j], 0, "EAST deinterlacer enable"); + j++; + } + { + _mesa_printf("\t TSn.2: 0x%08x (default color)\n", ptr[j]); + j++; + } + } + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_dest_vars( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t0x%08x\n", ptr[j++]); + + { + _mesa_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"); + FLAG(ptr[j], 28, "lod preclamp"); + BITS(ptr[j], 27, 26, "dither pattern"); + FLAG(ptr[j], 25, "linear gamma blend"); + FLAG(ptr[j], 24, "debug dither"); + BITS(ptr[j], 23, 20, "dstorg x"); + BITS(ptr[j], 19, 16, "dstorg y"); + MBZ (ptr[j], 15, 15 ); + BITS(ptr[j], 14, 12, "422 write select"); + BITS(ptr[j], 11, 8, "cbuf format"); + BITS(ptr[j], 3, 2, "zbuf format"); + FLAG(ptr[j], 1, "vert line stride"); + FLAG(ptr[j], 1, "vert line stride offset"); + j++; + } + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} + +static GLboolean debug_buf_info( struct debug_stream *stream, + const char *name, + GLuint len ) +{ + GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); + int j = 0; + + _mesa_printf("%s (%d dwords):\n", name, len); + _mesa_printf("\t0x%08x\n", ptr[j++]); + + { + _mesa_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"); + FLAG(ptr[j], 22, "tiled surface"); + FLAG(ptr[j], 21, "tile walk ymajor"); + MBZ (ptr[j], 20, 14); + BITS(ptr[j], 13, 2, "dword pitch"); + MBZ (ptr[j], 2, 0); + j++; + } + + _mesa_printf("\t0x%08x -- buffer base address\n", ptr[j++]); + + stream->offset += len * sizeof(GLuint); + assert(j == len); + return GL_TRUE; +} static GLboolean i915_debug_packet( struct debug_stream *stream ) { @@ -292,9 +697,9 @@ static GLboolean i915_debug_packet( struct debug_stream *stream ) case 0x2: switch ((cmd >> 22) & 0xff) { case 0x50: - return debug(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2); + return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2); case 0x53: - return debug(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2); + return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2); default: return debug(stream, "blit command", (cmd & 0xff) + 2); } @@ -314,7 +719,7 @@ static GLboolean i915_debug_packet( struct debug_stream *stream ) case 0xc: return debug(stream, "3DSTATE_MODES5", 1); case 0xd: - return debug(stream, "3DSTATE_MODES4", 1); + return debug_modes4(stream, "3DSTATE_MODES4", 1); case 0x15: return debug(stream, "3DSTATE_FOG_COLOR", 1); case 0x16: @@ -334,9 +739,9 @@ static GLboolean i915_debug_packet( struct debug_stream *stream ) /* 3DStateMW */ switch ((cmd >> 16) & 0xff) { case 0x0: - return debug(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2); + return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2); case 0x1: - return debug(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2); + return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2); case 0x4: return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2); case 0x5: @@ -352,13 +757,13 @@ static GLboolean i915_debug_packet( struct debug_stream *stream ) case 0x83: return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2); case 0x85: - return debug(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2); + return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2); case 0x88: return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2); case 0x89: return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2); case 0x8e: - return debug(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2); + return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2); case 0x97: return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2); case 0x98: diff --git a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c index f4e8ae95ade..0e70b32b9e7 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c @@ -29,7 +29,7 @@ #include "i915_reg.h" #include "i915_debug.h" -//#include "i915_fpc.h" +#include "main/imports.h" #include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_print.h" diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index 5d0fd53961e..6665629d034 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -186,10 +186,11 @@ do_flush_locked(struct intel_batchbuffer *batch, ptr[r->offset / 4] = driBOOffset(r->buf) + r->delta; } + if (INTEL_DEBUG & DEBUG_BATCH) { + if (0) i915_dump_batchbuffer(ptr, ptr + used/4); + intel_dump_batchbuffer(0, ptr, used); + } - i915_dump_batchbuffer(ptr, ptr + used/4); - - intel_dump_batchbuffer(0, ptr, used); driBOUnmap(batch->buffer); batch->map = NULL; -- cgit v1.2.3 From 6ea55d35254b7769c65f064170d8965c0bf34a27 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 11 Aug 2007 13:48:19 +0100 Subject: Make it easier to compare against the pipe driver debug code. --- src/mesa/drivers/dri/i915tex/i915_debug.c | 180 +++++++++++++-------------- src/mesa/drivers/dri/i915tex/i915_debug_fp.c | 80 ++++++------ 2 files changed, 131 insertions(+), 129 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.c b/src/mesa/drivers/dri/i915tex/i915_debug.c index d5e4ff7ae09..c0e1242a0ea 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug.c @@ -31,7 +31,7 @@ #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 ) { @@ -39,19 +39,19 @@ static GLboolean debug( struct debug_stream *stream, const char *name, GLuint le GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { - _mesa_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) - _mesa_printf("%08x: ", stream->offset); + PRINTF("%08x: ", stream->offset); - _mesa_printf("%s (%d dwords):\n", name, len); + PRINTF("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t0x%08x\n", ptr[i]); - _mesa_printf("\n"); + PRINTF("\t0x%08x\n", ptr[i]); + PRINTF("\n"); stream->offset += len * sizeof(GLuint); @@ -88,17 +88,17 @@ static GLboolean debug_prim( struct debug_stream *stream, const char *name, - _mesa_printf("%s %s (%d dwords):\n", name, prim, len); - _mesa_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) - _mesa_printf("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + PRINTF("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); else - _mesa_printf("\t0x%08x\n", ptr[i]); + PRINTF("\t0x%08x\n", ptr[i]); } - _mesa_printf("\n"); + PRINTF("\n"); stream->offset += len * sizeof(GLuint); @@ -113,15 +113,15 @@ static GLboolean debug_program( struct debug_stream *stream, const char *name, G GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { - _mesa_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) - _mesa_printf("%08x: ", stream->offset); + PRINTF("%08x: ", stream->offset); - _mesa_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 +135,17 @@ static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLu GLuint old_offset = stream->offset + len * sizeof(GLuint); GLuint i; - _mesa_printf("%s (%d dwords):\n", name, len); + PRINTF("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t0x%08x\n", ptr[i]); + PRINTF("\t0x%08x\n", ptr[i]); stream->offset = ptr[1] & ~0x3; if (stream->offset < old_offset) - _mesa_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 - _mesa_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 +165,10 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) len = 1+(i+2)/2; - _mesa_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++) - _mesa_printf("\t0x%08x\n", ptr[i]); - _mesa_printf("\n"); + PRINTF("\t0x%08x\n", ptr[i]); + PRINTF("\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE; @@ -178,9 +178,9 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) #define BITS( dw, hi, lo, ... ) \ do { \ unsigned himask = ~0UL >> (31 - (hi)); \ - _mesa_printf("\t\t "); \ - _mesa_printf(__VA_ARGS__); \ - _mesa_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 +194,9 @@ do { \ #define FLAG( dw, bit, ... ) \ do { \ if (((dw) >> (bit)) & 1) { \ - _mesa_printf("\t\t "); \ - _mesa_printf(__VA_ARGS__); \ - _mesa_printf("\n"); \ + PRINTF("\t\t "); \ + PRINTF(__VA_ARGS__); \ + PRINTF("\n"); \ } \ } while (0) @@ -208,17 +208,17 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, GLuint bits = (ptr[0] >> 4) & 0xff; GLuint j = 0; - _mesa_printf("%s (%d dwords, flags: %x):\n", name, len, bits); - _mesa_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)) { - _mesa_printf("\t LIS0: 0x%08x\n", ptr[j]); - _mesa_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)) { - _mesa_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,20 +226,20 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, } if (bits & (1<<2)) { int i; - _mesa_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) + if (tc != 0xf) BITS(tc, 3, 0, "tex coord %d", i); } j++; } if (bits & (1<<3)) { - _mesa_printf("\t LIS3: 0x%08x\n", ptr[j]); + PRINTF("\t LIS3: 0x%08x\n", ptr[j]); j++; } if (bits & (1<<4)) { - _mesa_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 +261,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<5)) { - _mesa_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 +279,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<6)) { - _mesa_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 +296,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, } - _mesa_printf("\n"); + PRINTF("\n"); assert(j == len); @@ -315,34 +315,34 @@ static GLboolean debug_load_indirect( struct debug_stream *stream, GLuint bits = (ptr[0] >> 8) & 0x3f; GLuint i, j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_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; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR22(stream, ptr[j++]); @@ -455,8 +455,8 @@ static GLboolean debug_color_blit( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR22(stream, ptr[j++]); @@ -476,8 +476,8 @@ static GLboolean debug_modes4( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_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"); @@ -497,26 +497,26 @@ static GLboolean debug_map_state( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "map mask"); j++; } while (j < len) { { - _mesa_printf("\t TMn.0: 0x%08x\n", ptr[j]); - _mesa_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++; } { - _mesa_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"); @@ -527,7 +527,7 @@ static GLboolean debug_map_state( struct debug_stream *stream, j++; } { - _mesa_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"); @@ -549,18 +549,18 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "sampler mask"); j++; } while (j < len) { { - _mesa_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"); @@ -577,7 +577,7 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, } { - _mesa_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"); @@ -592,7 +592,7 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, j++; } { - _mesa_printf("\t TSn.2: 0x%08x (default color)\n", ptr[j]); + PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); j++; } } @@ -609,11 +609,11 @@ static GLboolean debug_dest_vars( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_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"); @@ -644,11 +644,11 @@ static GLboolean debug_buf_info( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_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"); @@ -660,7 +660,7 @@ static GLboolean debug_buf_info( struct debug_stream *stream, j++; } - _mesa_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); @@ -820,7 +820,7 @@ i915_dump_batchbuffer( GLuint *start, GLuint bytes = (end - start) * 4; GLboolean done = GL_FALSE; - fprintf(stderr, "\n\nBATCH: (%d)\n", bytes / 4); + PRINTF("\n\nBATCH: (%d)\n", bytes / 4); stream.offset = 0; stream.ptr = (char *)start; @@ -837,7 +837,7 @@ i915_dump_batchbuffer( GLuint *start, stream.offset >= 0); } - fprintf(stderr, "END-BATCH\n\n\n"); + PRINTF("END-BATCH\n\n\n"); } diff --git a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c index 0e70b32b9e7..84347a01efe 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c @@ -34,6 +34,8 @@ #include "shader/prog_instruction.h" #include "shader/prog_print.h" +#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) + static const char *opcodes[0x20] = { "NOP", "ADD", @@ -124,27 +126,27 @@ print_reg_type_nr(GLuint type, GLuint nr) case REG_TYPE_T: switch (nr) { case T_DIFFUSE: - _mesa_printf("T_DIFFUSE"); + PRINTF("T_DIFFUSE"); return; case T_SPECULAR: - _mesa_printf("T_SPECULAR"); + PRINTF("T_SPECULAR"); return; case T_FOG_W: - _mesa_printf("T_FOG_W"); + PRINTF("T_FOG_W"); return; default: - _mesa_printf("T_TEX%d", nr); + PRINTF("T_TEX%d", nr); return; } case REG_TYPE_OC: if (nr == 0) { - _mesa_printf("oC"); + PRINTF("oC"); return; } break; case REG_TYPE_OD: if (nr == 0) { - _mesa_printf("oD"); + PRINTF("oD"); return; } break; @@ -152,7 +154,7 @@ print_reg_type_nr(GLuint type, GLuint nr) break; } - _mesa_printf("%s[%d]", regname[type], nr); + PRINTF("%s[%d]", regname[type], nr); } #define REG_SWIZZLE_MASK 0x7777 @@ -173,33 +175,33 @@ print_reg_neg_swizzle(GLuint reg) (reg & REG_NEGATE_MASK) == 0) return; - _mesa_printf("."); + PRINTF("."); for (i = 3; i >= 0; i--) { if (reg & (1 << ((i * 4) + 3))) - _mesa_printf("-"); + PRINTF("-"); switch ((reg >> (i * 4)) & 0x7) { case 0: - _mesa_printf("x"); + PRINTF("x"); break; case 1: - _mesa_printf("y"); + PRINTF("y"); break; case 2: - _mesa_printf("z"); + PRINTF("z"); break; case 3: - _mesa_printf("w"); + PRINTF("w"); break; case 4: - _mesa_printf("0"); + PRINTF("0"); break; case 5: - _mesa_printf("1"); + PRINTF("1"); break; default: - _mesa_printf("?"); + PRINTF("?"); break; } } @@ -224,15 +226,15 @@ print_dest_reg(GLuint dword) print_reg_type_nr(type, nr); if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) return; - _mesa_printf("."); + PRINTF("."); if (dword & A0_DEST_CHANNEL_X) - _mesa_printf("x"); + PRINTF("x"); if (dword & A0_DEST_CHANNEL_Y) - _mesa_printf("y"); + PRINTF("y"); if (dword & A0_DEST_CHANNEL_Z) - _mesa_printf("z"); + PRINTF("z"); if (dword & A0_DEST_CHANNEL_W) - _mesa_printf("w"); + PRINTF("w"); } @@ -247,29 +249,29 @@ print_arith_op(GLuint opcode, const GLuint * program) if (opcode != A0_NOP) { print_dest_reg(program[0]); if (program[0] & A0_DEST_SATURATE) - _mesa_printf(" = SATURATE "); + PRINTF(" = SATURATE "); else - _mesa_printf(" = "); + PRINTF(" = "); } - _mesa_printf("%s ", opcodes[opcode]); + PRINTF("%s ", opcodes[opcode]); print_src_reg(GET_SRC0_REG(program[0], program[1])); if (args[opcode] == 1) { - _mesa_printf("\n"); + PRINTF("\n"); return; } - _mesa_printf(", "); + PRINTF(", "); print_src_reg(GET_SRC1_REG(program[1], program[2])); if (args[opcode] == 2) { - _mesa_printf("\n"); + PRINTF("\n"); return; } - _mesa_printf(", "); + PRINTF(", "); print_src_reg(GET_SRC2_REG(program[2])); - _mesa_printf("\n"); + PRINTF("\n"); return; } @@ -278,24 +280,24 @@ static void print_tex_op(GLuint opcode, const GLuint * program) { print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - _mesa_printf(" = "); + PRINTF(" = "); - _mesa_printf("%s ", opcodes[opcode]); + PRINTF("%s ", opcodes[opcode]); - _mesa_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); - _mesa_printf("\n"); + PRINTF("\n"); } static void print_dcl_op(GLuint opcode, const GLuint * program) { - _mesa_printf("%s ", opcodes[opcode]); + PRINTF("%s ", opcodes[opcode]); print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - _mesa_printf("\n"); + PRINTF("\n"); } @@ -305,7 +307,7 @@ i915_disassemble_program(const GLuint * program, GLuint sz) GLuint size = program[0] & 0x1ff; GLint i; - _mesa_printf("\t\tBEGIN\n"); + PRINTF("\t\tBEGIN\n"); assert(size + 2 == sz); @@ -313,7 +315,7 @@ i915_disassemble_program(const GLuint * program, GLuint sz) for (i = 1; i < sz; i += 3, program += 3) { GLuint opcode = program[0] & (0x1f << 24); - _mesa_printf("\t\t"); + PRINTF("\t\t"); if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) print_arith_op(opcode >> 24, program); @@ -322,10 +324,10 @@ i915_disassemble_program(const GLuint * program, GLuint sz) else if (opcode == D0_DCL) print_dcl_op(opcode >> 24, program); else - _mesa_printf("Unknown opcode 0x%x\n", opcode); + PRINTF("Unknown opcode 0x%x\n", opcode); } - _mesa_printf("\t\tEND\n\n"); + PRINTF("\t\tEND\n\n"); } -- cgit v1.2.3 From 21b37b9687b078297935062e3ad9f379b6f36519 Mon Sep 17 00:00:00 2001 From: Dan Torop Date: Sun, 12 Aug 2007 13:41:13 +0200 Subject: fix spantmp2 READ_RGBA inline asm (#11931) --- src/mesa/drivers/dri/common/spantmp2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/common/spantmp2.h b/src/mesa/drivers/dri/common/spantmp2.h index 50f3cf55816..53f5f846a0b 100644 --- a/src/mesa/drivers/dri/common/spantmp2.h +++ b/src/mesa/drivers/dri/common/spantmp2.h @@ -114,7 +114,7 @@ do { \ GLuint p = *(volatile GLuint *) GET_PTR(_x, _y); \ __asm__ __volatile__( "bswap %0; rorl $8, %0" \ - : "=r" (p) : "r" (p) ); \ + : "=r" (p) : "0" (p) ); \ ((GLuint *)rgba)[0] = p; \ } while (0) # elif defined( MESA_BIG_ENDIAN ) -- cgit v1.2.3 From c9e4aa2b303f9056564724ece0e2733a54d9f569 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Mon, 13 Aug 2007 11:43:37 +0800 Subject: i915: satisfy certain alignment restrictions for small compressed texture --- src/mesa/drivers/dri/i915/i915_texstate.c | 57 ++++++++++++++++++++++++++++--- src/mesa/drivers/dri/i915/intel_tex.c | 6 ++-- 2 files changed, 57 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c index a19d4b65840..2b806cc36ef 100644 --- a/src/mesa/drivers/dri/i915/i915_texstate.c +++ b/src/mesa/drivers/dri/i915/i915_texstate.c @@ -60,6 +60,33 @@ static GLint step_offsets[6][2] = { {0,2}, #define I915_TEX_UNIT_ENABLED(unit) (1<> 1); +} + static void i915LayoutTextureImages( i915ContextPtr i915, struct gl_texture_object *tObj ) { @@ -161,8 +188,15 @@ static void i915LayoutTextureImages( i915ContextPtr i915, break; } default: - pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes; - pitch = (pitch + 3) & ~3; + if (baseImage->IsCompressed) { + GLuint alignment = i915_compressed_alignment(baseImage->InternalFormat); + + pitch = align(tObj->Image[0][firstLevel]->Width, alignment) * t->intel.texelBytes; + } else { + pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes; + pitch = (pitch + 3) & ~3; + } + t->intel.base.dirty_images[0] = ~0; for ( total_height = i = 0 ; i < numLevels ; i++ ) { @@ -343,8 +377,23 @@ static void i945LayoutTextureImages( i915ContextPtr i915, break; } default: - pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes; - pitch = (pitch + 3) & ~3; + if (baseImage->IsCompressed) { + GLuint alignment = i915_compressed_alignment(baseImage->InternalFormat); + + pitch = align(tObj->Image[0][firstLevel]->Width, alignment); + if (numLevels > 2) { + GLint width0 = align(minify(tObj->Image[0][firstLevel]->Width), alignment) + + + align(minify(minify(tObj->Image[0][firstLevel]->Width)), alignment); + + if (width0 > pitch) + pitch = width0; + } + pitch = pitch * t->intel.texelBytes; + } else { + pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes; + pitch = (pitch + 3) & ~3; + } + t->intel.base.dirty_images[0] = ~0; max_offset = 0; diff --git a/src/mesa/drivers/dri/i915/intel_tex.c b/src/mesa/drivers/dri/i915/intel_tex.c index 5bd280652af..978945f26b5 100644 --- a/src/mesa/drivers/dri/i915/intel_tex.c +++ b/src/mesa/drivers/dri/i915/intel_tex.c @@ -643,17 +643,19 @@ static void intelUploadTexImage( intelContextPtr intel, switch (image->InternalFormat) { case GL_COMPRESSED_RGB_FXT1_3DFX: case GL_COMPRESSED_RGBA_FXT1_3DFX: + row_len = ((image->Width + 7) & ~7) * 2; + break; case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - row_len = (image->Width * 2 + 7) & ~7; + row_len = ((image->Width + 3) & ~3) * 2; break; case GL_RGBA_S3TC: case GL_RGBA4_S3TC: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - row_len = (image->Width * 4 + 15) & ~15; + row_len = ((image->Width + 3) & ~3) * 4; break; default: fprintf(stderr,"Internal Compressed format not supported %d\n", image->InternalFormat); -- cgit v1.2.3 From 88451b04e9cd39db9cc9315aaf69e074614f22f9 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Mon, 13 Aug 2007 17:16:27 +0800 Subject: i965: fix projtex_mask projtex_mask is only an 8bit field, and wm.input_size_masks includes other attributes' information, therefore right shift is needed. --- src/mesa/drivers/dri/i965/brw_wm.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_fp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 1497dc79687..904c00bef87 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -285,7 +285,7 @@ static void brw_wm_populate_key( struct brw_context *brw, /* BRW_NEW_WM_INPUT_DIMENSIONS */ - key->projtex_mask = brw->wm.input_size_masks[4-1]; + key->projtex_mask = brw->wm.input_size_masks[4-1] >> (FRAG_ATTRIB_TEX0 - FRAG_ATTRIB_WPOS); /* _NEW_LIGHT */ key->flat_shade = (brw->attribs.Light->ShadeModel == GL_FLAT); diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index ff97d87dc45..62bb0812062 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -660,7 +660,7 @@ static GLboolean projtex( struct brw_wm_compile *c, return 0; /* ut2004 gun rendering !?! */ else if (src.File == PROGRAM_INPUT && GET_SWZ(src.Swizzle, W) == W && - (c->key.projtex_mask & (1<key.projtex_mask & (1<<(src.Index + FRAG_ATTRIB_WPOS - FRAG_ATTRIB_TEX0))) == 0) return 0; else return 1; -- cgit v1.2.3 From 6f4725088842fbc0069aeb51f41907b87e0a8f08 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 13 Aug 2007 11:09:48 +0100 Subject: added some missing Default1D/2DArray texture code --- src/mesa/main/context.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 00e4c8328e5..6fa32b320a9 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -552,6 +552,10 @@ alloc_shared_state( GLcontext *ctx ) (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultCubeMap); if (ss->DefaultRect) (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultRect); + if (ss->Default1DArray) + (*ctx->Driver.DeleteTexture)(ctx, ss->Default1DArray); + if (ss->Default2DArray) + (*ctx->Driver.DeleteTexture)(ctx, ss->Default2DArray); if (ss) _mesa_free(ss); return GL_FALSE; @@ -676,6 +680,9 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) ctx->Driver.DeleteTexture(ctx, ss->Default3D); ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap); ctx->Driver.DeleteTexture(ctx, ss->DefaultRect); + ctx->Driver.DeleteTexture(ctx, ss->Default1DArray); + ctx->Driver.DeleteTexture(ctx, ss->Default2DArray); + /* all other textures */ _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx); _mesa_DeleteHashTable(ss->TexObjects); -- cgit v1.2.3 From 9e01b915f1243a3f551cb795b7124bd1e52ca15f Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 13 Aug 2007 11:29:46 +0100 Subject: Implement mutex/locking around texture object reference counting. Use new _mesa_reference_texobj() function for referencing/unreferencing textures. Add new assertions/tests to try to detect invalid usage of deleted textures. --- src/mesa/main/attrib.c | 1 + src/mesa/main/context.c | 14 +-- src/mesa/main/fbobject.c | 22 ++-- src/mesa/main/framebuffer.c | 13 +-- src/mesa/main/mtypes.h | 1 + src/mesa/main/texobj.c | 252 +++++++++++++++++++++++--------------------- src/mesa/main/texobj.h | 4 + src/mesa/main/texstate.c | 89 ++++++---------- 8 files changed, 184 insertions(+), 212 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index b422198f929..36e438a53cc 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -355,6 +355,7 @@ _mesa_PushAttrib(GLbitfield mask) ctx->Texture.Unit[u].Current1DArray->RefCount++; ctx->Texture.Unit[u].Current2DArray->RefCount++; } + attr = MALLOC_STRUCT( gl_texture_attrib ); MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); /* copy state of the currently bound texture objects */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 6fa32b320a9..f360eac1e77 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -475,19 +475,12 @@ alloc_shared_state( GLcontext *ctx ) if (!ss->Default2DArray) goto cleanup; - /* Effectively bind the default textures to all texture units */ - ss->Default1D->RefCount += MAX_TEXTURE_IMAGE_UNITS; - ss->Default2D->RefCount += MAX_TEXTURE_IMAGE_UNITS; - ss->Default3D->RefCount += MAX_TEXTURE_IMAGE_UNITS; - ss->DefaultCubeMap->RefCount += MAX_TEXTURE_IMAGE_UNITS; - ss->DefaultRect->RefCount += MAX_TEXTURE_IMAGE_UNITS; - ss->Default1DArray->RefCount += MAX_TEXTURE_IMAGE_UNITS; - ss->Default2DArray->RefCount += MAX_TEXTURE_IMAGE_UNITS; + /* sanity check */ + assert(ss->Default1D->RefCount == 1); _glthread_INIT_MUTEX(ss->TexMutex); ss->TextureStateStamp = 0; - #if FEATURE_EXT_framebuffer_object ss->FrameBuffers = _mesa_NewHashTable(); if (!ss->FrameBuffers) @@ -497,10 +490,9 @@ alloc_shared_state( GLcontext *ctx ) goto cleanup; #endif - return GL_TRUE; - cleanup: +cleanup: /* Ran out of memory at some point. Free everything and return NULL */ if (ss->DisplayList) _mesa_DeleteHashTable(ss->DisplayList); diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 6f7effcce70..fcb620b39d8 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -151,22 +151,18 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att) { if (att->Type == GL_TEXTURE) { ASSERT(att->Texture); - att->Texture->RefCount--; - if (att->Texture->RefCount == 0) { - ctx->Driver.DeleteTexture(ctx, att->Texture); + if (ctx->Driver.FinishRenderTexture) { + /* tell driver we're done rendering to this texobj */ + ctx->Driver.FinishRenderTexture(ctx, att); } - else { - /* tell driver that we're done rendering to this texture. */ - if (ctx->Driver.FinishRenderTexture) { - ctx->Driver.FinishRenderTexture(ctx, att); - } - } - att->Texture = NULL; + _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ + ASSERT(!att->Texture); } if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { ASSERT(att->Renderbuffer); ASSERT(!att->Texture); - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); + _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */ + ASSERT(!att->Renderbuffer); } att->Type = GL_NONE; att->Complete = GL_TRUE; @@ -192,8 +188,8 @@ _mesa_set_texture_attachment(GLcontext *ctx, /* new attachment */ _mesa_remove_attachment(ctx, att); att->Type = GL_TEXTURE; - att->Texture = texObj; - texObj->RefCount++; + assert(!att->Texture); + _mesa_reference_texobj(&att->Texture, texObj); } /* always update these fields */ diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index c9b30d32528..0a6de12fb85 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -38,6 +38,7 @@ #include "fbobject.h" #include "framebuffer.h" #include "renderbuffer.h" +#include "texobj.h" @@ -192,17 +193,11 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb) _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); } if (att->Texture) { - /* render to texture */ - att->Texture->RefCount--; - if (att->Texture->RefCount == 0) { - GET_CURRENT_CONTEXT(ctx); - if (ctx) { - ctx->Driver.DeleteTexture(ctx, att->Texture); - } - } + _mesa_reference_texobj(&att->Texture, NULL); } + ASSERT(!att->Renderbuffer); + ASSERT(!att->Texture); att->Type = GL_NONE; - att->Texture = NULL; } /* unbind _Depth/_StencilBuffer to decr ref counts */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 3e4c49249a0..989d199a103 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1400,6 +1400,7 @@ struct gl_texture_image */ struct gl_texture_object { + _glthread_Mutex Mutex; /**< for thread safety */ GLint RefCount; /**< reference count */ GLuint Name; /**< the user-visible texture object ID */ GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */ diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index df64002f994..ac70e5a22ec 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -106,6 +106,7 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj, _mesa_bzero(obj, sizeof(*obj)); /* init the non-zero fields */ + _glthread_INIT_MUTEX(obj->Mutex); obj->RefCount = 1; obj->Name = name; obj->Target = target; @@ -151,8 +152,17 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) { GLuint i, face; + /* + printf("TEX DELETE %p (%u)\n", (void*) texObj, texObj->Name); + */ + (void) ctx; + /* Set Target to an invalid value. With some assertions elsewhere + * we can try to detect possible use of deleted textures. + */ + texObj->Target = 0x99; + _mesa_free_colortable_data(&texObj->Palette); /* free the texture images */ @@ -164,6 +174,9 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) } } + /* destroy the mutex -- it may have allocated memory (eg on bsd) */ + _glthread_DESTROY_MUTEX(texObj->Mutex); + /* free this object */ _mesa_free(texObj); } @@ -213,6 +226,98 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, } +/** + * Check if the given texture object is valid by examining its Target field. + * For debugging only. + */ +static GLboolean +valid_texture_object(const struct gl_texture_object *tex) +{ + switch (tex->Target) { + case 0: + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_TEXTURE_RECTANGLE_NV: + case GL_TEXTURE_1D_ARRAY_EXT: + case GL_TEXTURE_2D_ARRAY_EXT: + return GL_TRUE; + case 0x99: + _mesa_problem(NULL, "invalid reference to a deleted texture object"); + return GL_FALSE; + default: + _mesa_problem(NULL, "invalid texture object Target value"); + return GL_FALSE; + } +} + + +/** + * Reference (or unreference) a texture object. + * If '*ptr', decrement *ptr's refcount (and delete if it becomes zero). + * If 'tex' is non-null, increment its refcount. + */ +void +_mesa_reference_texobj(struct gl_texture_object **ptr, + struct gl_texture_object *tex) +{ + assert(ptr); + if (*ptr == tex) { + /* no change */ + return; + } + + if (*ptr) { + /* Unreference the old texture */ + GLboolean deleteFlag = GL_FALSE; + struct gl_texture_object *oldTex = *ptr; + + assert(valid_texture_object(oldTex)); + + _glthread_LOCK_MUTEX(oldTex->Mutex); + ASSERT(oldTex->RefCount > 0); + oldTex->RefCount--; + /* + printf("TEX DECR %p (%u) to %d\n", + (void*) oldTex, oldTex->Name, oldTex->RefCount); + */ + deleteFlag = (oldTex->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldTex->Mutex); + + if (deleteFlag) { + GET_CURRENT_CONTEXT(ctx); + ctx->Driver.DeleteTexture(ctx, oldTex); + } + + *ptr = NULL; + } + assert(!*ptr); + + if (tex) { + /* reference new texture */ + assert(valid_texture_object(tex)); + _glthread_LOCK_MUTEX(tex->Mutex); + if (tex->RefCount == 0) { + /* this texture's being deleted (look just above) */ + /* Not sure this can every really happen. Warn if it does. */ + _mesa_problem(NULL, "referencing deleted texture object"); + *ptr = NULL; + } + else { + tex->RefCount++; + /* + printf("TEX INCR %p (%u) to %d\n", + (void*) tex, tex->Name, tex->RefCount); + */ + *ptr = tex; + } + _glthread_UNLOCK_MUTEX(tex->Mutex); + } +} + + + /** * Report why a texture object is incomplete. * @@ -609,8 +714,7 @@ unbind_texobj_from_fbo(GLcontext *ctx, struct gl_texture_object *texObj) /** * Check if the given texture object is bound to any texture image units and - * unbind it if so. - * XXX all RefCount accesses should be protected by a mutex. + * unbind it if so (revert to default textures). */ static void unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) @@ -619,42 +723,26 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - struct gl_texture_object **curr = NULL; - if (texObj == unit->Current1D) { - curr = &unit->Current1D; - unit->Current1D = ctx->Shared->Default1D; + _mesa_reference_texobj(&unit->Current1D, ctx->Shared->Default1D); } else if (texObj == unit->Current2D) { - curr = &unit->Current2D; - unit->Current2D = ctx->Shared->Default2D; + _mesa_reference_texobj(&unit->Current2D, ctx->Shared->Default2D); } else if (texObj == unit->Current3D) { - curr = &unit->Current3D; - unit->Current3D = ctx->Shared->Default3D; + _mesa_reference_texobj(&unit->Current3D, ctx->Shared->Default3D); } else if (texObj == unit->CurrentCubeMap) { - curr = &unit->CurrentCubeMap; - unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; + _mesa_reference_texobj(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); } else if (texObj == unit->CurrentRect) { - curr = &unit->CurrentRect; - unit->CurrentRect = ctx->Shared->DefaultRect; + _mesa_reference_texobj(&unit->CurrentRect, ctx->Shared->DefaultRect); } else if (texObj == unit->Current1DArray) { - curr = &unit->Current1DArray; - unit->CurrentRect = ctx->Shared->Default1DArray; + _mesa_reference_texobj(&unit->Current1DArray, ctx->Shared->Default1DArray); } else if (texObj == unit->Current2DArray) { - curr = &unit->Current1DArray; - unit->CurrentRect = ctx->Shared->Default2DArray; - } - - if (curr) { - (*curr)->RefCount++; - texObj->RefCount--; - if (texObj == unit->_Current) - unit->_Current = *curr; + _mesa_reference_texobj(&unit->Current2DArray, ctx->Shared->Default2DArray); } } } @@ -690,8 +778,6 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) = _mesa_lookup_texture(ctx, textures[i]); if (delObj) { - GLboolean deleted; - _mesa_lock_texture(ctx, delObj); /* Check if texture is bound to any framebuffer objects. @@ -701,10 +787,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) unbind_texobj_from_fbo(ctx, delObj); /* Check if this texture is currently bound to any texture units. - * If so, unbind it and decrement the reference count. + * If so, unbind it. */ unbind_texobj_from_texunits(ctx, delObj); + _mesa_unlock_texture(ctx, delObj); + ctx->NewState |= _NEW_TEXTURE; /* The texture _name_ is now free for re-use. @@ -714,23 +802,10 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - /* The actual texture object will not be freed until it's no - * longer bound in any context. - * XXX all RefCount accesses should be protected by a mutex. + /* Unrefernce the texobj. If refcount hits zero, the texture + * will be deleted. */ - delObj->RefCount--; - deleted = (delObj->RefCount == 0); - _mesa_unlock_texture(ctx, delObj); - - /* We know that refcount went to zero above, so this is - * the only pointer left to delObj, so we don't have to - * worry about locking any more: - */ - if (deleted) { - ASSERT(delObj->Name != 0); /* Never delete default tex objs */ - ASSERT(ctx->Driver.DeleteTexture); - (*ctx->Driver.DeleteTexture)(ctx, delObj); - } + _mesa_reference_texobj(&delObj, NULL); } } } @@ -758,7 +833,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) GET_CURRENT_CONTEXT(ctx); const GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - struct gl_texture_object *oldTexObj; struct gl_texture_object *newTexObj = NULL; ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -766,62 +840,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) _mesa_debug(ctx, "glBindTexture %s %d\n", _mesa_lookup_enum_by_nr(target), (GLint) texName); - /* - * Get pointer to currently bound texture object (oldTexObj) - */ - switch (target) { - case GL_TEXTURE_1D: - oldTexObj = texUnit->Current1D; - break; - case GL_TEXTURE_2D: - oldTexObj = texUnit->Current2D; - break; - case GL_TEXTURE_3D: - oldTexObj = texUnit->Current3D; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); - return; - } - oldTexObj = texUnit->CurrentCubeMap; - break; - case GL_TEXTURE_RECTANGLE_NV: - if (!ctx->Extensions.NV_texture_rectangle) { - _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); - return; - } - oldTexObj = texUnit->CurrentRect; - break; - case GL_TEXTURE_1D_ARRAY_EXT: - if (!ctx->Extensions.MESA_texture_array) { - _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); - return; - } - oldTexObj = texUnit->Current1DArray; - break; - case GL_TEXTURE_2D_ARRAY_EXT: - if (!ctx->Extensions.MESA_texture_array) { - _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); - return; - } - oldTexObj = texUnit->Current2DArray; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); - return; - } - - if (oldTexObj->Name == texName) { - /* XXX this might be wrong. If the texobj is in use by another - * context and a texobj parameter was changed, this might be our - * only chance to update this context's hardware state. - * Note that some applications re-bind the same texture a lot so we - * want to handle that case quickly. - */ - return; /* rebinding the same texture- no change */ - } - /* * Get pointer to new texture object (newTexObj) */ @@ -896,28 +914,30 @@ _mesa_BindTexture( GLenum target, GLuint texName ) newTexObj->Target = target; } - /* XXX all RefCount accesses should be protected by a mutex. */ - newTexObj->RefCount++; + assert(valid_texture_object(newTexObj)); - /* do the actual binding, but first flush outstanding vertices: - */ + /* flush before changing binding */ FLUSH_VERTICES(ctx, _NEW_TEXTURE); + /* Do the actual binding. The refcount on the previously bound + * texture object will be decremented. It'll be deleted if the + * count hits zero. + */ switch (target) { case GL_TEXTURE_1D: - texUnit->Current1D = newTexObj; + _mesa_reference_texobj(&texUnit->Current1D, newTexObj); break; case GL_TEXTURE_2D: - texUnit->Current2D = newTexObj; + _mesa_reference_texobj(&texUnit->Current2D, newTexObj); break; case GL_TEXTURE_3D: - texUnit->Current3D = newTexObj; + _mesa_reference_texobj(&texUnit->Current3D, newTexObj); break; case GL_TEXTURE_CUBE_MAP_ARB: - texUnit->CurrentCubeMap = newTexObj; + _mesa_reference_texobj(&texUnit->CurrentCubeMap, newTexObj); break; case GL_TEXTURE_RECTANGLE_NV: - texUnit->CurrentRect = newTexObj; + _mesa_reference_texobj(&texUnit->CurrentRect, newTexObj); break; case GL_TEXTURE_1D_ARRAY_EXT: texUnit->Current1DArray = newTexObj; @@ -933,18 +953,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) /* Pass BindTexture call to device driver */ if (ctx->Driver.BindTexture) (*ctx->Driver.BindTexture)( ctx, target, newTexObj ); - - /* Decrement the reference count on the old texture and check if it's - * time to delete it. - */ - /* XXX all RefCount accesses should be protected by a mutex. */ - oldTexObj->RefCount--; - ASSERT(oldTexObj->RefCount >= 0); - if (oldTexObj->RefCount == 0) { - ASSERT(oldTexObj->Name != 0); - ASSERT(ctx->Driver.DeleteTexture); - (*ctx->Driver.DeleteTexture)( ctx, oldTexObj ); - } } diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h index 2a2bde36017..d5374c5d6c4 100644 --- a/src/mesa/main/texobj.h +++ b/src/mesa/main/texobj.h @@ -57,6 +57,10 @@ extern void _mesa_copy_texture_object( struct gl_texture_object *dest, const struct gl_texture_object *src ); +extern void +_mesa_reference_texobj(struct gl_texture_object **ptr, + struct gl_texture_object *tex); + extern void _mesa_test_texobj_completeness( const GLcontext *ctx, struct gl_texture_object *obj ); diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index c9f8a0656e8..08d083d201b 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -63,31 +63,6 @@ static const struct gl_tex_env_combine_state default_combine_state = { }; -/** - * Copy a texture binding. Helper used by _mesa_copy_texture_state(). - */ -static void -copy_texture_binding(const GLcontext *ctx, - struct gl_texture_object **dst, - struct gl_texture_object *src) -{ - /* only copy if names differ (per OpenGL SI) */ - if ((*dst)->Name != src->Name) { - /* unbind/delete dest binding which we're changing */ - (*dst)->RefCount--; - if ((*dst)->RefCount == 0) { - /* time to delete this texture object */ - ASSERT((*dst)->Name != 0); - ASSERT(ctx->Driver.DeleteTexture); - /* XXX cast-away const, unfortunately */ - (*ctx->Driver.DeleteTexture)((GLcontext *) ctx, *dst); - } - /* make new binding, incrementing ref count */ - *dst = src; - src->RefCount++; - } -} - /** * Used by glXCopyContext to copy texture state from one context to another. @@ -144,20 +119,20 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) /* copy texture object bindings, not contents of texture objects */ _mesa_lock_context_textures(dst); - copy_texture_binding(src, &dst->Texture.Unit[i].Current1D, - src->Texture.Unit[i].Current1D); - copy_texture_binding(src, &dst->Texture.Unit[i].Current2D, - src->Texture.Unit[i].Current2D); - copy_texture_binding(src, &dst->Texture.Unit[i].Current3D, - src->Texture.Unit[i].Current3D); - copy_texture_binding(src, &dst->Texture.Unit[i].CurrentCubeMap, - src->Texture.Unit[i].CurrentCubeMap); - copy_texture_binding(src, &dst->Texture.Unit[i].CurrentRect, - src->Texture.Unit[i].CurrentRect); - copy_texture_binding(src, &dst->Texture.Unit[i].Current1DArray, - src->Texture.Unit[i].Current1DArray); - copy_texture_binding(src, &dst->Texture.Unit[i].Current2DArray, - src->Texture.Unit[i].Current2DArray); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D, + src->Texture.Unit[i].Current1D); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D, + src->Texture.Unit[i].Current2D); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D, + src->Texture.Unit[i].Current3D); + _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap, + src->Texture.Unit[i].CurrentCubeMap); + _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect, + src->Texture.Unit[i].CurrentRect); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current1DArray, + src->Texture.Unit[i].Current1DArray); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current2DArray, + src->Texture.Unit[i].Current2DArray); _mesa_unlock_context_textures(dst); } @@ -3113,6 +3088,8 @@ alloc_proxy_textures( GLcontext *ctx ) if (!ctx->Texture.Proxy2DArray) goto cleanup; + assert(ctx->Texture.Proxy1D->RefCount == 1); + return GL_TRUE; cleanup: @@ -3172,13 +3149,14 @@ init_texture_unit( GLcontext *ctx, GLuint unit ) ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 ); ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 ); - texUnit->Current1D = ctx->Shared->Default1D; - texUnit->Current2D = ctx->Shared->Default2D; - texUnit->Current3D = ctx->Shared->Default3D; - texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; - texUnit->CurrentRect = ctx->Shared->DefaultRect; - texUnit->Current1DArray = ctx->Shared->Default1DArray; - texUnit->Current2DArray = ctx->Shared->Default2DArray; + /* initialize current texture object ptrs to the shared default objects */ + _mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D); + _mesa_reference_texobj(&texUnit->Current2D, ctx->Shared->Default2D); + _mesa_reference_texobj(&texUnit->Current3D, ctx->Shared->Default3D); + _mesa_reference_texobj(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); + _mesa_reference_texobj(&texUnit->CurrentRect, ctx->Shared->DefaultRect); + _mesa_reference_texobj(&texUnit->Current1DArray, ctx->Shared->Default1DArray); + _mesa_reference_texobj(&texUnit->Current2DArray, ctx->Shared->Default2DArray); } @@ -3193,23 +3171,20 @@ _mesa_init_texture(GLcontext *ctx) assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); - /* Effectively bind the default textures to all texture units */ - ctx->Shared->Default1D->RefCount += MAX_TEXTURE_UNITS; - ctx->Shared->Default2D->RefCount += MAX_TEXTURE_UNITS; - ctx->Shared->Default3D->RefCount += MAX_TEXTURE_UNITS; - ctx->Shared->DefaultCubeMap->RefCount += MAX_TEXTURE_UNITS; - ctx->Shared->DefaultRect->RefCount += MAX_TEXTURE_UNITS; - ctx->Shared->Default1DArray->RefCount += MAX_TEXTURE_UNITS; - ctx->Shared->Default2DArray->RefCount += MAX_TEXTURE_UNITS; - /* Texture group */ ctx->Texture.CurrentUnit = 0; /* multitexture */ ctx->Texture._EnabledUnits = 0; - for (i=0; iTexture.SharedPalette = GL_FALSE; _mesa_init_colortable(&ctx->Texture.Palette); + for (i = 0; i < MAX_TEXTURE_UNITS; i++) + init_texture_unit( ctx, i ); + + /* After we're done initializing the context's texture state the default + * texture objects' refcounts should be at least MAX_TEXTURE_UNITS + 1. + */ + assert(ctx->Shared->Default1D->RefCount >= MAX_TEXTURE_UNITS + 1); + _mesa_TexEnvProgramCacheInit( ctx ); /* Allocate proxy textures */ -- cgit v1.2.3 From b7a9222dc7492181588cedd62b94482fab8e9c95 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Mon, 13 Aug 2007 13:22:43 +0200 Subject: i915tex: Make sure pitch is aligned properly for render-to-texture. Just always align texture pitch to multiples of 64 bytes for now, pending a more sophisticated scheme to do it only when really necessary. --- src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c index fc38a28290d..74f6b2d8515 100644 --- a/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i915tex/intel_mipmap_tree.c @@ -97,9 +97,19 @@ intel_miptree_create(struct intel_context *intel, break; } - if (ok) + if (ok) { + if (!mt->compressed) { + /* XXX: Align pitch to multiple of 64 bytes for now to allow + * render-to-texture to work in all cases. This should probably be + * replaced at some point by some scheme to only do this when really + * necessary. + */ + mt->pitch = ((mt->pitch * cpp + 63) & ~63) / cpp; + } + mt->region = intel_region_alloc(intel->intelScreen, mt->cpp, mt->pitch, mt->total_height); + } if (!mt->region) { free(mt); -- cgit v1.2.3 From 393a6255381f019586bd9acc49fbf2fd431e534e Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 13 Aug 2007 17:37:30 +0100 Subject: free any render/framebuffers left in hash tables when freeing shared state --- src/mesa/main/context.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index f360eac1e77..5fbc69693ef 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -640,6 +640,27 @@ delete_shader_cb(GLuint id, void *data, void *userData) } } +/** + * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll() + */ +static void +delete_framebuffer_cb(GLuint id, void *data, void *userData) +{ + struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + fb->Delete(fb); +} + +/** + * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll() + */ +static void +delete_renderbuffer_cb(GLuint id, void *data, void *userData) +{ + struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; + rb->Delete(rb); +} + + /** * Deallocate a shared state object and all children structures. @@ -710,7 +731,9 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) #endif #if FEATURE_EXT_framebuffer_object + _mesa_HashDeleteAll(ss->FrameBuffers, delete_framebuffer_cb, ctx); _mesa_DeleteHashTable(ss->FrameBuffers); + _mesa_HashDeleteAll(ss->RenderBuffers, delete_renderbuffer_cb, ctx); _mesa_DeleteHashTable(ss->RenderBuffers); #endif -- cgit v1.2.3 From dc73217294efcba83c46183ed2f208250217486f Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 14 Aug 2007 11:56:59 +0100 Subject: Fix a few more problems with freeing FBOs/textures during context destruction. Free FBOs before textures since the later may be referenced by the former. Need to bind the context we're destroying if there isn't a current context so that ctx->DeleteTexture() etc can be used. --- src/mesa/main/context.c | 66 +++++++++++++++++++++++++++++-------------------- src/mesa/main/texobj.c | 5 +++- 2 files changed, 43 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 5fbc69693ef..37a14d30042 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -647,6 +647,11 @@ static void delete_framebuffer_cb(GLuint id, void *data, void *userData) { struct gl_framebuffer *fb = (struct gl_framebuffer *) data; + /* The fact that the framebuffer is in the hashtable means its refcount + * is one, but we're removing from the hashtable now. So clear refcount. + */ + /*assert(fb->RefCount == 1);*/ + fb->RefCount = 0; fb->Delete(fb); } @@ -657,6 +662,7 @@ static void delete_renderbuffer_cb(GLuint id, void *data, void *userData) { struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data; + rb->RefCount = 0; /* see comment for FBOs above */ rb->Delete(rb); } @@ -683,23 +689,6 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) _mesa_HashDeleteAll(ss->DisplayList, delete_displaylist_cb, ctx); _mesa_DeleteHashTable(ss->DisplayList); - /* - * Free texture objects - */ - ASSERT(ctx->Driver.DeleteTexture); - /* the default textures */ - ctx->Driver.DeleteTexture(ctx, ss->Default1D); - ctx->Driver.DeleteTexture(ctx, ss->Default2D); - ctx->Driver.DeleteTexture(ctx, ss->Default3D); - ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap); - ctx->Driver.DeleteTexture(ctx, ss->DefaultRect); - ctx->Driver.DeleteTexture(ctx, ss->Default1DArray); - ctx->Driver.DeleteTexture(ctx, ss->Default2DArray); - - /* all other textures */ - _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx); - _mesa_DeleteHashTable(ss->TexObjects); - #if defined(FEATURE_NV_vertex_program) || defined(FEATURE_NV_fragment_program) _mesa_HashDeleteAll(ss->Programs, delete_program_cb, ctx); _mesa_DeleteHashTable(ss->Programs); @@ -737,6 +726,23 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) _mesa_DeleteHashTable(ss->RenderBuffers); #endif + /* + * Free texture objects (after FBOs since some textures might have + * been bound to FBOs). + */ + ASSERT(ctx->Driver.DeleteTexture); + /* the default textures */ + ctx->Driver.DeleteTexture(ctx, ss->Default1D); + ctx->Driver.DeleteTexture(ctx, ss->Default2D); + ctx->Driver.DeleteTexture(ctx, ss->Default3D); + ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap); + ctx->Driver.DeleteTexture(ctx, ss->DefaultRect); + ctx->Driver.DeleteTexture(ctx, ss->Default1DArray); + ctx->Driver.DeleteTexture(ctx, ss->Default2DArray); + /* all other textures */ + _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx); + _mesa_DeleteHashTable(ss->TexObjects); + _glthread_DESTROY_MUTEX(ss->Mutex); _mesa_free(ss); @@ -1190,18 +1196,19 @@ _mesa_create_context(const GLvisual *visual, void _mesa_free_context_data( GLcontext *ctx ) { - /* if we're destroying the current context, unbind it first */ - if (ctx == _mesa_get_current_context()) { - _mesa_make_current(NULL, NULL, NULL); - } - else { - /* unreference WinSysDraw/Read buffers */ - _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer); - _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer); - _mesa_unreference_framebuffer(&ctx->DrawBuffer); - _mesa_unreference_framebuffer(&ctx->ReadBuffer); + if (!_mesa_get_current_context()){ + /* No current context, but we may need one in order to delete + * texture objs, etc. So temporarily bind the context now. + */ + _mesa_make_current(ctx, NULL, NULL); } + /* unreference WinSysDraw/Read buffers */ + _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer); + _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer); + _mesa_unreference_framebuffer(&ctx->DrawBuffer); + _mesa_unreference_framebuffer(&ctx->ReadBuffer); + _mesa_free_lighting_data( ctx ); _mesa_free_eval_data( ctx ); _mesa_free_texture_data( ctx ); @@ -1233,6 +1240,11 @@ _mesa_free_context_data( GLcontext *ctx ) if (ctx->Extensions.String) _mesa_free((void *) ctx->Extensions.String); + + /* unbind the context if it's currently bound */ + if (ctx == _mesa_get_current_context()) { + _mesa_make_current(NULL, NULL, NULL); + } } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index ac70e5a22ec..ea3328a047e 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -287,7 +287,10 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, if (deleteFlag) { GET_CURRENT_CONTEXT(ctx); - ctx->Driver.DeleteTexture(ctx, oldTex); + if (ctx) + ctx->Driver.DeleteTexture(ctx, oldTex); + else + _mesa_problem(NULL, "Unable to delete texture, no context"); } *ptr = NULL; -- cgit v1.2.3 From 553f5759a6587d7fe77a62d4d1159ad786b336ee Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 16:46:27 +1000 Subject: nouveau: Lets only do private buffers. --- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 52 ++++++++++++--------------- 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 053680be8d1..4d22ecc83e5 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -154,36 +154,30 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv, nouveauSpanSetFunctions(nrb, mesaVis); _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &nrb->mesa); - if (0 /* unified buffers if we choose to support them.. */) { - } else { - if (mesaVis->doubleBufferMode) { - nrb = nouveau_renderbuffer_new(color_format, NULL, - 0, 0, - NULL); - nouveauSpanSetFunctions(nrb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &nrb->mesa); - } + if (mesaVis->doubleBufferMode) { + nrb = nouveau_renderbuffer_new(color_format, NULL, 0, 0, NULL); + nouveauSpanSetFunctions(nrb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &nrb->mesa); + } - if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { - nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT, NULL, - 0, 0, - NULL); - nouveauSpanSetFunctions(nrb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &nrb->mesa); - } else if (mesaVis->depthBits == 24) { - nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT24, NULL, - 0, 0, - NULL); - nouveauSpanSetFunctions(nrb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); - } else if (mesaVis->depthBits == 16) { - nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16, NULL, - 0, 0, - NULL); - nouveauSpanSetFunctions(nrb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); - } + if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { + nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT, NULL, + 0, 0, NULL); + nouveauSpanSetFunctions(nrb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); + _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &nrb->mesa); + } else + if (mesaVis->depthBits == 24) { + nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT24, NULL, + 0, 0, NULL); + nouveauSpanSetFunctions(nrb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); + } else + if (mesaVis->depthBits == 16) { + nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16, NULL, + 0, 0, NULL); + nouveauSpanSetFunctions(nrb, mesaVis); + _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); } _mesa_add_soft_renderbuffers(fb, -- cgit v1.2.3 From 386a70eeb5982976239a2d37b63cde307cfbc22c Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 17:02:20 +1000 Subject: nouveau: reindent nouveau_buffers.c --- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 673 +++++++++++++------------ 1 file changed, 339 insertions(+), 334 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index d498f616c90..5c5c7932bb2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -14,423 +14,428 @@ /* Unstrided blit using NV_MEMORY_TO_MEMORY_FORMAT */ GLboolean -nouveau_memformat_flat_emit(GLcontext *ctx, - nouveau_mem *dst, nouveau_mem *src, +nouveau_memformat_flat_emit(GLcontext * ctx, + nouveau_mem * dst, nouveau_mem * src, GLuint dst_offset, GLuint src_offset, GLuint size) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t src_handle, dst_handle; - GLuint count; - - if (src_offset + size > src->size) { - MESSAGE("src out of nouveau_mem bounds\n"); - return GL_FALSE; - } - if (dst_offset + size > dst->size) { - MESSAGE("dst out of nouveau_mem bounds\n"); - return GL_FALSE; - } - - src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; - dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; - src_offset += nouveau_mem_gpu_offset_get(ctx, src); - dst_offset += nouveau_mem_gpu_offset_get(ctx, dst); - - BEGIN_RING_SIZE(NvSubMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2); - OUT_RING (src_handle); - OUT_RING (dst_handle); - - count = (size / MAX_MEMFMT_LENGTH) + ((size % MAX_MEMFMT_LENGTH) ? 1 : 0); - - while (count--) { - GLuint length = (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size; - - BEGIN_RING_SIZE(NvSubMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8); - OUT_RING (src_offset); - OUT_RING (dst_offset); - OUT_RING (0); /* pitch in */ - OUT_RING (0); /* pitch out */ - OUT_RING (length); /* line length */ - OUT_RING (1); /* number of lines */ - OUT_RING ((1 << 8) /* dst_inc */ | (1 << 0) /* src_inc */); - OUT_RING (0); /* buffer notify? */ - FIRE_RING(); - - src_offset += length; - dst_offset += length; - size -= length; - } - - return GL_TRUE; + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + uint32_t src_handle, dst_handle; + GLuint count; + + if (src_offset + size > src->size) { + MESSAGE("src out of nouveau_mem bounds\n"); + return GL_FALSE; + } + if (dst_offset + size > dst->size) { + MESSAGE("dst out of nouveau_mem bounds\n"); + return GL_FALSE; + } + + src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; + dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; + src_offset += nouveau_mem_gpu_offset_get(ctx, src); + dst_offset += nouveau_mem_gpu_offset_get(ctx, dst); + + BEGIN_RING_SIZE(NvSubMemFormat, + NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2); + OUT_RING(src_handle); + OUT_RING(dst_handle); + + count = (size / MAX_MEMFMT_LENGTH) + + ((size % MAX_MEMFMT_LENGTH) ? 1 : 0); + + while (count--) { + GLuint length = + (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size; + + BEGIN_RING_SIZE(NvSubMemFormat, + NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8); + OUT_RING(src_offset); + OUT_RING(dst_offset); + OUT_RING(0); /* pitch in */ + OUT_RING(0); /* pitch out */ + OUT_RING(length); /* line length */ + OUT_RING(1); /* number of lines */ + OUT_RING((1 << 8) /* dst_inc */ |(1 << 0) /* src_inc */ ); + OUT_RING(0); /* buffer notify? */ + FIRE_RING(); + + src_offset += length; + dst_offset += length; + size -= length; + } + + return GL_TRUE; } -void -nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem) +void nouveau_mem_free(GLcontext * ctx, nouveau_mem * mem) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - struct drm_nouveau_mem_free memf; - - if (NOUVEAU_DEBUG & DEBUG_MEM) { - fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n", - __func__, mem->type, (GLuint)mem->offset, (GLuint)mem->size); - } - - if (mem->map) - drmUnmap(mem->map, mem->size); - memf.flags = mem->type; - memf.offset = mem->offset; - drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, sizeof(memf)); - FREE(mem); + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + struct drm_nouveau_mem_free memf; + + if (NOUVEAU_DEBUG & DEBUG_MEM) { + fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n", + __func__, mem->type, (GLuint) mem->offset, + (GLuint) mem->size); + } + + if (mem->map) + drmUnmap(mem->map, mem->size); + memf.flags = mem->type; + memf.offset = mem->offset; + drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, + sizeof(memf)); + FREE(mem); } -nouveau_mem * -nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align) +nouveau_mem *nouveau_mem_alloc(GLcontext * ctx, int type, GLuint size, + GLuint align) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - struct drm_nouveau_mem_alloc mema; - nouveau_mem *mem; - int ret; - - if (NOUVEAU_DEBUG & DEBUG_MEM) { - fprintf(stderr, "%s: requested: type=0x%x, size=0x%x, align=0x%x\n", - __func__, type, (GLuint)size, align); - } - - mem = CALLOC(sizeof(nouveau_mem)); - if (!mem) - return NULL; - - mema.flags = type; - mema.size = mem->size = size; - mema.alignment = align; - mem->map = NULL; - ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC, - &mema, sizeof(mema)); - if (ret) { - FREE(mem); - return NULL; - } - mem->offset = mema.offset; - mem->type = mema.flags; - - if (NOUVEAU_DEBUG & DEBUG_MEM) { - fprintf(stderr, "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n", - __func__, mem->type, (GLuint)mem->offset, (GLuint)mem->size); - } - - if (type & NOUVEAU_MEM_MAPPED) - ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, &mem->map); - if (ret) { - mem->map = NULL; - nouveau_mem_free(ctx, mem); - mem = NULL; - } - - return mem; + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + struct drm_nouveau_mem_alloc mema; + nouveau_mem *mem; + int ret; + + if (NOUVEAU_DEBUG & DEBUG_MEM) { + fprintf(stderr, + "%s: requested: type=0x%x, size=0x%x, align=0x%x\n", + __func__, type, (GLuint) size, align); + } + + mem = CALLOC(sizeof(nouveau_mem)); + if (!mem) + return NULL; + + mema.flags = type; + mema.size = mem->size = size; + mema.alignment = align; + mem->map = NULL; + ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC, + &mema, sizeof(mema)); + if (ret) { + FREE(mem); + return NULL; + } + mem->offset = mema.offset; + mem->type = mema.flags; + + if (NOUVEAU_DEBUG & DEBUG_MEM) { + fprintf(stderr, + "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n", + __func__, mem->type, (GLuint) mem->offset, + (GLuint) mem->size); + } + + if (type & NOUVEAU_MEM_MAPPED) + ret = + drmMap(nmesa->driFd, mema.map_handle, mem->size, + &mem->map); + if (ret) { + mem->map = NULL; + nouveau_mem_free(ctx, mem); + mem = NULL; + } + + return mem; } -uint32_t -nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem) +uint32_t nouveau_mem_gpu_offset_get(GLcontext * ctx, nouveau_mem * mem) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - return mem->offset; + return mem->offset; } static GLboolean -nouveau_renderbuffer_pixelformat(nouveau_renderbuffer *nrb, - GLenum internalFormat) +nouveau_renderbuffer_pixelformat(nouveau_renderbuffer * nrb, + GLenum internalFormat) { - nrb->mesa.InternalFormat = internalFormat; - - /*TODO: We probably want to extend this a bit, and maybe make - * card-specific? - */ - switch (internalFormat) { - case GL_RGBA: - case GL_RGBA8: - nrb->mesa._BaseFormat = GL_RGBA; - nrb->mesa._ActualFormat= GL_RGBA8; - nrb->mesa.DataType = GL_UNSIGNED_BYTE; - nrb->mesa.RedBits = 8; - nrb->mesa.GreenBits = 8; - nrb->mesa.BlueBits = 8; - nrb->mesa.AlphaBits = 8; - nrb->cpp = 4; - break; - case GL_RGB: - case GL_RGB5: - nrb->mesa._BaseFormat = GL_RGB; - nrb->mesa._ActualFormat= GL_RGB5; - nrb->mesa.DataType = GL_UNSIGNED_BYTE; - nrb->mesa.RedBits = 5; - nrb->mesa.GreenBits = 6; - nrb->mesa.BlueBits = 5; - nrb->mesa.AlphaBits = 0; - nrb->cpp = 2; - break; - case GL_DEPTH_COMPONENT16: - nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; - nrb->mesa._ActualFormat= GL_DEPTH_COMPONENT16; - nrb->mesa.DataType = GL_UNSIGNED_SHORT; - nrb->mesa.DepthBits = 16; - nrb->cpp = 2; - break; - case GL_DEPTH_COMPONENT24: - nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; - nrb->mesa._ActualFormat= GL_DEPTH24_STENCIL8_EXT; - nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; - nrb->mesa.DepthBits = 24; - nrb->cpp = 4; - break; - case GL_STENCIL_INDEX8_EXT: - nrb->mesa._BaseFormat = GL_STENCIL_INDEX; - nrb->mesa._ActualFormat= GL_DEPTH24_STENCIL8_EXT; - nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; - nrb->mesa.StencilBits = 8; - nrb->cpp = 4; - break; - case GL_DEPTH24_STENCIL8_EXT: - nrb->mesa._BaseFormat = GL_DEPTH_STENCIL_EXT; - nrb->mesa._ActualFormat= GL_DEPTH24_STENCIL8_EXT; - nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; - nrb->mesa.DepthBits = 24; - nrb->mesa.StencilBits = 8; - nrb->cpp = 4; - break; - default: - return GL_FALSE; - break; - } - - return GL_TRUE; + nrb->mesa.InternalFormat = internalFormat; + + /*TODO: We probably want to extend this a bit, and maybe make + * card-specific? + */ + switch (internalFormat) { + case GL_RGBA: + case GL_RGBA8: + nrb->mesa._BaseFormat = GL_RGBA; + nrb->mesa._ActualFormat = GL_RGBA8; + nrb->mesa.DataType = GL_UNSIGNED_BYTE; + nrb->mesa.RedBits = 8; + nrb->mesa.GreenBits = 8; + nrb->mesa.BlueBits = 8; + nrb->mesa.AlphaBits = 8; + nrb->cpp = 4; + break; + case GL_RGB: + case GL_RGB5: + nrb->mesa._BaseFormat = GL_RGB; + nrb->mesa._ActualFormat = GL_RGB5; + nrb->mesa.DataType = GL_UNSIGNED_BYTE; + nrb->mesa.RedBits = 5; + nrb->mesa.GreenBits = 6; + nrb->mesa.BlueBits = 5; + nrb->mesa.AlphaBits = 0; + nrb->cpp = 2; + break; + case GL_DEPTH_COMPONENT16: + nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; + nrb->mesa._ActualFormat = GL_DEPTH_COMPONENT16; + nrb->mesa.DataType = GL_UNSIGNED_SHORT; + nrb->mesa.DepthBits = 16; + nrb->cpp = 2; + break; + case GL_DEPTH_COMPONENT24: + nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; + nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; + nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; + nrb->mesa.DepthBits = 24; + nrb->cpp = 4; + break; + case GL_STENCIL_INDEX8_EXT: + nrb->mesa._BaseFormat = GL_STENCIL_INDEX; + nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; + nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; + nrb->mesa.StencilBits = 8; + nrb->cpp = 4; + break; + case GL_DEPTH24_STENCIL8_EXT: + nrb->mesa._BaseFormat = GL_DEPTH_STENCIL_EXT; + nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; + nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; + nrb->mesa.DepthBits = 24; + nrb->mesa.StencilBits = 8; + nrb->cpp = 4; + break; + default: + return GL_FALSE; + break; + } + + return GL_TRUE; } static GLboolean -nouveau_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, - GLuint height) +nouveau_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) { - nouveau_renderbuffer *nrb = (nouveau_renderbuffer*)rb; - - if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) { - fprintf(stderr, "%s: unknown internalFormat\n", __func__); - return GL_FALSE; - } - - /* If this buffer isn't statically alloc'd, we may need to ask the - * drm for more memory */ - if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) { - GLuint pitch; - - /* align pitches to 64 bytes */ - pitch = ((width * nrb->cpp) + 63) & ~63; - - if (nrb->mem) - nouveau_mem_free(ctx, nrb->mem); - nrb->mem = nouveau_mem_alloc(ctx, - NOUVEAU_MEM_FB | NOUVEAU_MEM_MAPPED, - pitch*height, - 0); - if (!nrb->mem) - return GL_FALSE; - - /* update nouveau_renderbuffer info */ - nrb->offset = nouveau_mem_gpu_offset_get(ctx, nrb->mem); - nrb->pitch = pitch; - } - - rb->Width = width; - rb->Height = height; - rb->InternalFormat = internalFormat; - return GL_TRUE; + nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; + + if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) { + fprintf(stderr, "%s: unknown internalFormat\n", __func__); + return GL_FALSE; + } + + /* If this buffer isn't statically alloc'd, we may need to ask the + * drm for more memory */ + if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) { + GLuint pitch; + + /* align pitches to 64 bytes */ + pitch = ((width * nrb->cpp) + 63) & ~63; + + if (nrb->mem) + nouveau_mem_free(ctx, nrb->mem); + nrb->mem = nouveau_mem_alloc(ctx, + NOUVEAU_MEM_FB | + NOUVEAU_MEM_MAPPED, + pitch * height, 0); + if (!nrb->mem) + return GL_FALSE; + + /* update nouveau_renderbuffer info */ + nrb->offset = nouveau_mem_gpu_offset_get(ctx, nrb->mem); + nrb->pitch = pitch; + } + + rb->Width = width; + rb->Height = height; + rb->InternalFormat = internalFormat; + return GL_TRUE; } -static void -nouveau_renderbuffer_delete(struct gl_renderbuffer *rb) +static void nouveau_renderbuffer_delete(struct gl_renderbuffer *rb) { - GET_CURRENT_CONTEXT(ctx); - nouveau_renderbuffer *nrb = (nouveau_renderbuffer*)rb; + GET_CURRENT_CONTEXT(ctx); + nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; - if (nrb->mem) - nouveau_mem_free(ctx, nrb->mem); - FREE(nrb); + if (nrb->mem) + nouveau_mem_free(ctx, nrb->mem); + FREE(nrb); } -nouveau_renderbuffer * -nouveau_renderbuffer_new(GLenum internalFormat, GLvoid *map, - GLuint offset, GLuint pitch, - __DRIdrawablePrivate *dPriv) +nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, + GLvoid * map, GLuint offset, + GLuint pitch, + __DRIdrawablePrivate * + dPriv) { - nouveau_renderbuffer *nrb; + nouveau_renderbuffer *nrb; - nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); - if (nrb) { - _mesa_init_renderbuffer(&nrb->mesa, 0); + nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); + if (nrb) { + _mesa_init_renderbuffer(&nrb->mesa, 0); - nouveau_renderbuffer_pixelformat(nrb, internalFormat); + nouveau_renderbuffer_pixelformat(nrb, internalFormat); - nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; - nrb->mesa.Delete = nouveau_renderbuffer_delete; + nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; + nrb->mesa.Delete = nouveau_renderbuffer_delete; - nrb->dPriv = dPriv; - nrb->offset = offset; - nrb->pitch = pitch; - nrb->map = map; - } + nrb->dPriv = dPriv; + nrb->offset = offset; + nrb->pitch = pitch; + nrb->map = map; + } - return nrb; + return nrb; } static void nouveau_cliprects_drawable_set(nouveauContextPtr nmesa, - nouveau_renderbuffer *nrb) + nouveau_renderbuffer * nrb) { - __DRIdrawablePrivate *dPriv = nrb->dPriv; - - nmesa->numClipRects = dPriv->numClipRects; - nmesa->pClipRects = dPriv->pClipRects; - nmesa->drawX = dPriv->x; - nmesa->drawY = dPriv->y; - nmesa->drawW = dPriv->w; - nmesa->drawH = dPriv->h; + __DRIdrawablePrivate *dPriv = nrb->dPriv; + + nmesa->numClipRects = dPriv->numClipRects; + nmesa->pClipRects = dPriv->pClipRects; + nmesa->drawX = dPriv->x; + nmesa->drawY = dPriv->y; + nmesa->drawW = dPriv->w; + nmesa->drawH = dPriv->h; } static void nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, - nouveau_renderbuffer *nrb) + nouveau_renderbuffer * nrb) { - nmesa->numClipRects = 1; - nmesa->pClipRects = &nmesa->osClipRect; - nmesa->osClipRect.x1 = 0; - nmesa->osClipRect.y1 = 0; - nmesa->osClipRect.x2 = nrb->mesa.Width; - nmesa->osClipRect.y2 = nrb->mesa.Height; - nmesa->drawX = 0; - nmesa->drawY = 0; - nmesa->drawW = nrb->mesa.Width; - nmesa->drawH = nrb->mesa.Height; + nmesa->numClipRects = 1; + nmesa->pClipRects = &nmesa->osClipRect; + nmesa->osClipRect.x1 = 0; + nmesa->osClipRect.y1 = 0; + nmesa->osClipRect.x2 = nrb->mesa.Width; + nmesa->osClipRect.y2 = nrb->mesa.Height; + nmesa->drawX = 0; + nmesa->drawY = 0; + nmesa->drawW = nrb->mesa.Width; + nmesa->drawH = nrb->mesa.Height; } -void -nouveau_window_moved(GLcontext *ctx) +void nouveau_window_moved(GLcontext * ctx) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_renderbuffer *nrb; - - nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0]; - if (!nrb) - return; - - if (!nrb->dPriv) - nouveau_cliprects_renderbuffer_set(nmesa, nrb); - else - nouveau_cliprects_drawable_set(nmesa, nrb); - - /* Viewport depends on window size/position, nouveauCalcViewport - * will take care of calling the hw-specific WindowMoved - */ - ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height); - /* Scissor depends on window position */ - ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + nouveau_renderbuffer *nrb; + + nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0]; + if (!nrb) + return; + + if (!nrb->dPriv) + nouveau_cliprects_renderbuffer_set(nmesa, nrb); + else + nouveau_cliprects_drawable_set(nmesa, nrb); + + /* Viewport depends on window size/position, nouveauCalcViewport + * will take care of calling the hw-specific WindowMoved + */ + ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height); + /* Scissor depends on window position */ + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); } GLboolean -nouveau_build_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) +nouveau_build_framebuffer(GLcontext * ctx, struct gl_framebuffer *fb) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_renderbuffer *color[MAX_DRAW_BUFFERS]; - nouveau_renderbuffer *depth; + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + nouveau_renderbuffer *color[MAX_DRAW_BUFFERS]; + nouveau_renderbuffer *depth; - _mesa_update_framebuffer(ctx); - _mesa_update_draw_buffer_bounds(ctx); + _mesa_update_framebuffer(ctx); + _mesa_update_draw_buffer_bounds(ctx); - color[0] = (nouveau_renderbuffer *)fb->_ColorDrawBuffers[0][0]; - if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) - depth = (nouveau_renderbuffer *)fb->_DepthBuffer->Wrapped; - else - depth = (nouveau_renderbuffer *)fb->_DepthBuffer; + color[0] = (nouveau_renderbuffer *) fb->_ColorDrawBuffers[0][0]; + if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) + depth = (nouveau_renderbuffer *) fb->_DepthBuffer->Wrapped; + else + depth = (nouveau_renderbuffer *) fb->_DepthBuffer; - if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth)) - return GL_FALSE; - nouveau_window_moved(ctx); + if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth)) + return GL_FALSE; + nouveau_window_moved(ctx); - return GL_TRUE; + return GL_TRUE; } -static void -nouveauDrawBuffer(GLcontext *ctx, GLenum buffer) +static void nouveauDrawBuffer(GLcontext * ctx, GLenum buffer) { - nouveau_build_framebuffer(ctx, ctx->DrawBuffer); + nouveau_build_framebuffer(ctx, ctx->DrawBuffer); } -static struct gl_framebuffer * -nouveauNewFramebuffer(GLcontext *ctx, GLuint name) +static struct gl_framebuffer *nouveauNewFramebuffer(GLcontext * ctx, + GLuint name) { - return _mesa_new_framebuffer(ctx, name); + return _mesa_new_framebuffer(ctx, name); } -static struct gl_renderbuffer * -nouveauNewRenderbuffer(GLcontext *ctx, GLuint name) +static struct gl_renderbuffer *nouveauNewRenderbuffer(GLcontext * ctx, + GLuint name) { - nouveau_renderbuffer *nrb; + nouveau_renderbuffer *nrb; - nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); - if (nrb) { - _mesa_init_renderbuffer(&nrb->mesa, name); + nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); + if (nrb) { + _mesa_init_renderbuffer(&nrb->mesa, name); - nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; - nrb->mesa.Delete = nouveau_renderbuffer_delete; - } - return &nrb->mesa; + nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; + nrb->mesa.Delete = nouveau_renderbuffer_delete; + } + return &nrb->mesa; } static void -nouveauBindFramebuffer(GLcontext *ctx, GLenum target, - struct gl_framebuffer *fb, struct gl_framebuffer *fbread) +nouveauBindFramebuffer(GLcontext * ctx, GLenum target, + struct gl_framebuffer *fb, + struct gl_framebuffer *fbread) { - if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { - nouveau_build_framebuffer(ctx, fb); - } + if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { + nouveau_build_framebuffer(ctx, fb); + } } static void -nouveauFramebufferRenderbuffer(GLcontext *ctx, - struct gl_framebuffer *fb, - GLenum attachment, +nouveauFramebufferRenderbuffer(GLcontext * ctx, + struct gl_framebuffer *fb, + GLenum attachment, struct gl_renderbuffer *rb) { - _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); - nouveau_build_framebuffer(ctx, fb); + _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); + nouveau_build_framebuffer(ctx, fb); } static void -nouveauRenderTexture(GLcontext *ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att) +nouveauRenderTexture(GLcontext * ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att) { } static void -nouveauFinishRenderTexture(GLcontext *ctx, - struct gl_renderbuffer_attachment *att) +nouveauFinishRenderTexture(GLcontext * ctx, + struct gl_renderbuffer_attachment *att) { } -void -nouveauInitBufferFuncs(struct dd_function_table *func) +void nouveauInitBufferFuncs(struct dd_function_table *func) { - func->DrawBuffer = nouveauDrawBuffer; - - func->NewFramebuffer = nouveauNewFramebuffer; - func->NewRenderbuffer = nouveauNewRenderbuffer; - func->BindFramebuffer = nouveauBindFramebuffer; - func->FramebufferRenderbuffer = nouveauFramebufferRenderbuffer; - func->RenderTexture = nouveauRenderTexture; - func->FinishRenderTexture = nouveauFinishRenderTexture; + func->DrawBuffer = nouveauDrawBuffer; + + func->NewFramebuffer = nouveauNewFramebuffer; + func->NewRenderbuffer = nouveauNewRenderbuffer; + func->BindFramebuffer = nouveauBindFramebuffer; + func->FramebufferRenderbuffer = nouveauFramebufferRenderbuffer; + func->RenderTexture = nouveauRenderTexture; + func->FinishRenderTexture = nouveauFinishRenderTexture; } - -- cgit v1.2.3 From 40e8ce700b0e1711e08e9f33c297d495c43598b1 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 17:21:02 +1000 Subject: nouveau: reindent nouveau_buffers.h --- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 15 ++++---- src/mesa/drivers/dri/nouveau/nouveau_buffers.h | 50 ++++++++++++++------------ 2 files changed, 34 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c index 5c5c7932bb2..7cf739fe47b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c @@ -89,7 +89,7 @@ void nouveau_mem_free(GLcontext * ctx, nouveau_mem * mem) FREE(mem); } -nouveau_mem *nouveau_mem_alloc(GLcontext * ctx, int type, GLuint size, +nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, uint32_t flags, GLuint size, GLuint align) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); @@ -99,15 +99,15 @@ nouveau_mem *nouveau_mem_alloc(GLcontext * ctx, int type, GLuint size, if (NOUVEAU_DEBUG & DEBUG_MEM) { fprintf(stderr, - "%s: requested: type=0x%x, size=0x%x, align=0x%x\n", - __func__, type, (GLuint) size, align); + "%s: requested: flags=0x%x, size=0x%x, align=0x%x\n", + __func__, flags, (GLuint) size, align); } mem = CALLOC(sizeof(nouveau_mem)); if (!mem) return NULL; - mema.flags = type; + mema.flags = flags; mema.size = mem->size = size; mema.alignment = align; mem->map = NULL; @@ -127,10 +127,9 @@ nouveau_mem *nouveau_mem_alloc(GLcontext * ctx, int type, GLuint size, (GLuint) mem->size); } - if (type & NOUVEAU_MEM_MAPPED) - ret = - drmMap(nmesa->driFd, mema.map_handle, mem->size, - &mem->map); + if (flags & NOUVEAU_MEM_MAPPED) + ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, + &mem->map); if (ret) { mem->map = NULL; nouveau_mem_free(ctx, mem); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h b/src/mesa/drivers/dri/nouveau/nouveau_buffers.h index d86455184c2..f0987d2aa7d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_buffers.h @@ -7,42 +7,46 @@ #include "renderbuffer.h" typedef struct nouveau_mem_t { - int type; - uint64_t offset; - uint64_t size; - void* map; + int type; + uint64_t offset; + uint64_t size; + void *map; } nouveau_mem; -extern nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, int type, - GLuint size, GLuint align); -extern void nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem); -extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem); +extern nouveau_mem *nouveau_mem_alloc(GLcontext *, uint32_t flags, + GLuint size, GLuint align); +extern void nouveau_mem_free(GLcontext *, nouveau_mem *); +extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *, nouveau_mem *); -extern GLboolean nouveau_memformat_flat_emit(GLcontext *ctx, - nouveau_mem *dst, +extern GLboolean nouveau_memformat_flat_emit(GLcontext *, + nouveau_mem *dst, nouveau_mem *src, GLuint dst_offset, GLuint src_offset, GLuint size); typedef struct nouveau_renderbuffer_t { - struct gl_renderbuffer mesa; /* must be first! */ - __DRIdrawablePrivate *dPriv; + struct gl_renderbuffer mesa; /* must be first! */ + __DRIdrawablePrivate *dPriv; - nouveau_mem *mem; - void * map; + nouveau_mem *mem; + void *map; - int cpp; - uint32_t offset; - uint32_t pitch; + int cpp; + uint32_t offset; + uint32_t pitch; } nouveau_renderbuffer; extern nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, - GLvoid *map, GLuint offset, GLuint pitch, __DRIdrawablePrivate *dPriv); -extern void nouveau_window_moved(GLcontext *ctx); -extern GLboolean nouveau_build_framebuffer(GLcontext *, struct gl_framebuffer *); -extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *ctx); - -extern void nouveauInitBufferFuncs(struct dd_function_table *func); + GLvoid *map, + GLuint offset, + GLuint pitch, + __DRIdrawablePrivate *); +extern void nouveau_window_moved(GLcontext *); +extern GLboolean nouveau_build_framebuffer(GLcontext *, + struct gl_framebuffer *); +extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *); + +extern void nouveauInitBufferFuncs(struct dd_function_table *); #endif -- cgit v1.2.3 From b7c93de6d798d7ccfc7bfa12b9c8f474de955d55 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 20:02:04 +1000 Subject: nouveau: Split nouveau_buffers into nouveau_mem and nouveau_fbo --- src/mesa/drivers/dri/nouveau/Makefile | 3 +- src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c | 4 +- src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h | 2 +- src/mesa/drivers/dri/nouveau/nouveau_buffers.c | 440 ----------------------- src/mesa/drivers/dri/nouveau/nouveau_buffers.h | 52 --- src/mesa/drivers/dri/nouveau/nouveau_context.h | 4 +- src/mesa/drivers/dri/nouveau/nouveau_fbo.c | 304 ++++++++++++++++ src/mesa/drivers/dri/nouveau/nouveau_fbo.h | 35 ++ src/mesa/drivers/dri/nouveau/nouveau_mem.c | 144 ++++++++ src/mesa/drivers/dri/nouveau/nouveau_mem.h | 23 ++ src/mesa/drivers/dri/nouveau/nouveau_span.h | 2 +- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 6 +- src/mesa/drivers/dri/nouveau/nouveau_sync.h | 2 - 13 files changed, 517 insertions(+), 504 deletions(-) delete mode 100644 src/mesa/drivers/dri/nouveau/nouveau_buffers.c delete mode 100644 src/mesa/drivers/dri/nouveau/nouveau_buffers.h create mode 100644 src/mesa/drivers/dri/nouveau/nouveau_fbo.c create mode 100644 src/mesa/drivers/dri/nouveau/nouveau_fbo.h create mode 100644 src/mesa/drivers/dri/nouveau/nouveau_mem.c create mode 100644 src/mesa/drivers/dri/nouveau/nouveau_mem.h (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile index 20d2de5eefb..6ea4594f1e6 100644 --- a/src/mesa/drivers/dri/nouveau/Makefile +++ b/src/mesa/drivers/dri/nouveau/Makefile @@ -9,12 +9,13 @@ MINIGLX_SOURCES = DRIVER_SOURCES = \ nouveau_bufferobj.c \ - nouveau_buffers.c \ nouveau_card.c \ nouveau_context.c \ nouveau_driver.c \ + nouveau_fbo.c \ nouveau_fifo.c \ nouveau_lock.c \ + nouveau_mem.c \ nouveau_object.c \ nouveau_screen.c \ nouveau_span.c \ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c index fc14060c049..be6455a01ed 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c @@ -2,11 +2,11 @@ #include "enums.h" #include "nouveau_bufferobj.h" -#include "nouveau_buffers.h" #include "nouveau_context.h" #include "nouveau_drm.h" -#include "nouveau_object.h" +#include "nouveau_mem.h" #include "nouveau_msg.h" +#include "nouveau_object.h" #define NOUVEAU_MEM_FREE(mem) do { \ nouveau_mem_free(ctx, (mem)); \ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h index 3439a35e7c8..cbc89a151da 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h @@ -2,7 +2,7 @@ #define __NOUVEAU_BUFFEROBJ_H__ #include "mtypes.h" -#include "nouveau_buffers.h" +#include "nouveau_mem.h" #define NOUVEAU_BO_VRAM_OK (NOUVEAU_MEM_FB | NOUVEAU_MEM_FB_ACCEPTABLE) #define NOUVEAU_BO_GART_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c deleted file mode 100644 index 7cf739fe47b..00000000000 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c +++ /dev/null @@ -1,440 +0,0 @@ -#include "utils.h" -#include "framebuffer.h" -#include "renderbuffer.h" -#include "fbobject.h" - -#include "nouveau_context.h" -#include "nouveau_buffers.h" -#include "nouveau_object.h" -#include "nouveau_fifo.h" -#include "nouveau_reg.h" -#include "nouveau_msg.h" - -#define MAX_MEMFMT_LENGTH 32768 - -/* Unstrided blit using NV_MEMORY_TO_MEMORY_FORMAT */ -GLboolean -nouveau_memformat_flat_emit(GLcontext * ctx, - nouveau_mem * dst, nouveau_mem * src, - GLuint dst_offset, GLuint src_offset, - GLuint size) -{ - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t src_handle, dst_handle; - GLuint count; - - if (src_offset + size > src->size) { - MESSAGE("src out of nouveau_mem bounds\n"); - return GL_FALSE; - } - if (dst_offset + size > dst->size) { - MESSAGE("dst out of nouveau_mem bounds\n"); - return GL_FALSE; - } - - src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; - dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; - src_offset += nouveau_mem_gpu_offset_get(ctx, src); - dst_offset += nouveau_mem_gpu_offset_get(ctx, dst); - - BEGIN_RING_SIZE(NvSubMemFormat, - NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2); - OUT_RING(src_handle); - OUT_RING(dst_handle); - - count = (size / MAX_MEMFMT_LENGTH) + - ((size % MAX_MEMFMT_LENGTH) ? 1 : 0); - - while (count--) { - GLuint length = - (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size; - - BEGIN_RING_SIZE(NvSubMemFormat, - NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8); - OUT_RING(src_offset); - OUT_RING(dst_offset); - OUT_RING(0); /* pitch in */ - OUT_RING(0); /* pitch out */ - OUT_RING(length); /* line length */ - OUT_RING(1); /* number of lines */ - OUT_RING((1 << 8) /* dst_inc */ |(1 << 0) /* src_inc */ ); - OUT_RING(0); /* buffer notify? */ - FIRE_RING(); - - src_offset += length; - dst_offset += length; - size -= length; - } - - return GL_TRUE; -} - -void nouveau_mem_free(GLcontext * ctx, nouveau_mem * mem) -{ - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - struct drm_nouveau_mem_free memf; - - if (NOUVEAU_DEBUG & DEBUG_MEM) { - fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n", - __func__, mem->type, (GLuint) mem->offset, - (GLuint) mem->size); - } - - if (mem->map) - drmUnmap(mem->map, mem->size); - memf.flags = mem->type; - memf.offset = mem->offset; - drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, - sizeof(memf)); - FREE(mem); -} - -nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, uint32_t flags, GLuint size, - GLuint align) -{ - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - struct drm_nouveau_mem_alloc mema; - nouveau_mem *mem; - int ret; - - if (NOUVEAU_DEBUG & DEBUG_MEM) { - fprintf(stderr, - "%s: requested: flags=0x%x, size=0x%x, align=0x%x\n", - __func__, flags, (GLuint) size, align); - } - - mem = CALLOC(sizeof(nouveau_mem)); - if (!mem) - return NULL; - - mema.flags = flags; - mema.size = mem->size = size; - mema.alignment = align; - mem->map = NULL; - ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC, - &mema, sizeof(mema)); - if (ret) { - FREE(mem); - return NULL; - } - mem->offset = mema.offset; - mem->type = mema.flags; - - if (NOUVEAU_DEBUG & DEBUG_MEM) { - fprintf(stderr, - "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n", - __func__, mem->type, (GLuint) mem->offset, - (GLuint) mem->size); - } - - if (flags & NOUVEAU_MEM_MAPPED) - ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, - &mem->map); - if (ret) { - mem->map = NULL; - nouveau_mem_free(ctx, mem); - mem = NULL; - } - - return mem; -} - -uint32_t nouveau_mem_gpu_offset_get(GLcontext * ctx, nouveau_mem * mem) -{ - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - - return mem->offset; -} - -static GLboolean -nouveau_renderbuffer_pixelformat(nouveau_renderbuffer * nrb, - GLenum internalFormat) -{ - nrb->mesa.InternalFormat = internalFormat; - - /*TODO: We probably want to extend this a bit, and maybe make - * card-specific? - */ - switch (internalFormat) { - case GL_RGBA: - case GL_RGBA8: - nrb->mesa._BaseFormat = GL_RGBA; - nrb->mesa._ActualFormat = GL_RGBA8; - nrb->mesa.DataType = GL_UNSIGNED_BYTE; - nrb->mesa.RedBits = 8; - nrb->mesa.GreenBits = 8; - nrb->mesa.BlueBits = 8; - nrb->mesa.AlphaBits = 8; - nrb->cpp = 4; - break; - case GL_RGB: - case GL_RGB5: - nrb->mesa._BaseFormat = GL_RGB; - nrb->mesa._ActualFormat = GL_RGB5; - nrb->mesa.DataType = GL_UNSIGNED_BYTE; - nrb->mesa.RedBits = 5; - nrb->mesa.GreenBits = 6; - nrb->mesa.BlueBits = 5; - nrb->mesa.AlphaBits = 0; - nrb->cpp = 2; - break; - case GL_DEPTH_COMPONENT16: - nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; - nrb->mesa._ActualFormat = GL_DEPTH_COMPONENT16; - nrb->mesa.DataType = GL_UNSIGNED_SHORT; - nrb->mesa.DepthBits = 16; - nrb->cpp = 2; - break; - case GL_DEPTH_COMPONENT24: - nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; - nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; - nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; - nrb->mesa.DepthBits = 24; - nrb->cpp = 4; - break; - case GL_STENCIL_INDEX8_EXT: - nrb->mesa._BaseFormat = GL_STENCIL_INDEX; - nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; - nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; - nrb->mesa.StencilBits = 8; - nrb->cpp = 4; - break; - case GL_DEPTH24_STENCIL8_EXT: - nrb->mesa._BaseFormat = GL_DEPTH_STENCIL_EXT; - nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; - nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; - nrb->mesa.DepthBits = 24; - nrb->mesa.StencilBits = 8; - nrb->cpp = 4; - break; - default: - return GL_FALSE; - break; - } - - return GL_TRUE; -} - -static GLboolean -nouveau_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, GLuint height) -{ - nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; - - if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) { - fprintf(stderr, "%s: unknown internalFormat\n", __func__); - return GL_FALSE; - } - - /* If this buffer isn't statically alloc'd, we may need to ask the - * drm for more memory */ - if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) { - GLuint pitch; - - /* align pitches to 64 bytes */ - pitch = ((width * nrb->cpp) + 63) & ~63; - - if (nrb->mem) - nouveau_mem_free(ctx, nrb->mem); - nrb->mem = nouveau_mem_alloc(ctx, - NOUVEAU_MEM_FB | - NOUVEAU_MEM_MAPPED, - pitch * height, 0); - if (!nrb->mem) - return GL_FALSE; - - /* update nouveau_renderbuffer info */ - nrb->offset = nouveau_mem_gpu_offset_get(ctx, nrb->mem); - nrb->pitch = pitch; - } - - rb->Width = width; - rb->Height = height; - rb->InternalFormat = internalFormat; - return GL_TRUE; -} - -static void nouveau_renderbuffer_delete(struct gl_renderbuffer *rb) -{ - GET_CURRENT_CONTEXT(ctx); - nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; - - if (nrb->mem) - nouveau_mem_free(ctx, nrb->mem); - FREE(nrb); -} - -nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, - GLvoid * map, GLuint offset, - GLuint pitch, - __DRIdrawablePrivate * - dPriv) -{ - nouveau_renderbuffer *nrb; - - nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); - if (nrb) { - _mesa_init_renderbuffer(&nrb->mesa, 0); - - nouveau_renderbuffer_pixelformat(nrb, internalFormat); - - nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; - nrb->mesa.Delete = nouveau_renderbuffer_delete; - - nrb->dPriv = dPriv; - nrb->offset = offset; - nrb->pitch = pitch; - nrb->map = map; - } - - return nrb; -} - -static void -nouveau_cliprects_drawable_set(nouveauContextPtr nmesa, - nouveau_renderbuffer * nrb) -{ - __DRIdrawablePrivate *dPriv = nrb->dPriv; - - nmesa->numClipRects = dPriv->numClipRects; - nmesa->pClipRects = dPriv->pClipRects; - nmesa->drawX = dPriv->x; - nmesa->drawY = dPriv->y; - nmesa->drawW = dPriv->w; - nmesa->drawH = dPriv->h; -} - -static void -nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, - nouveau_renderbuffer * nrb) -{ - nmesa->numClipRects = 1; - nmesa->pClipRects = &nmesa->osClipRect; - nmesa->osClipRect.x1 = 0; - nmesa->osClipRect.y1 = 0; - nmesa->osClipRect.x2 = nrb->mesa.Width; - nmesa->osClipRect.y2 = nrb->mesa.Height; - nmesa->drawX = 0; - nmesa->drawY = 0; - nmesa->drawW = nrb->mesa.Width; - nmesa->drawH = nrb->mesa.Height; -} - -void nouveau_window_moved(GLcontext * ctx) -{ - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_renderbuffer *nrb; - - nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0]; - if (!nrb) - return; - - if (!nrb->dPriv) - nouveau_cliprects_renderbuffer_set(nmesa, nrb); - else - nouveau_cliprects_drawable_set(nmesa, nrb); - - /* Viewport depends on window size/position, nouveauCalcViewport - * will take care of calling the hw-specific WindowMoved - */ - ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y, - ctx->Viewport.Width, ctx->Viewport.Height); - /* Scissor depends on window position */ - ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, - ctx->Scissor.Width, ctx->Scissor.Height); -} - -GLboolean -nouveau_build_framebuffer(GLcontext * ctx, struct gl_framebuffer *fb) -{ - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_renderbuffer *color[MAX_DRAW_BUFFERS]; - nouveau_renderbuffer *depth; - - _mesa_update_framebuffer(ctx); - _mesa_update_draw_buffer_bounds(ctx); - - color[0] = (nouveau_renderbuffer *) fb->_ColorDrawBuffers[0][0]; - if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) - depth = (nouveau_renderbuffer *) fb->_DepthBuffer->Wrapped; - else - depth = (nouveau_renderbuffer *) fb->_DepthBuffer; - - if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth)) - return GL_FALSE; - nouveau_window_moved(ctx); - - return GL_TRUE; -} - -static void nouveauDrawBuffer(GLcontext * ctx, GLenum buffer) -{ - nouveau_build_framebuffer(ctx, ctx->DrawBuffer); -} - -static struct gl_framebuffer *nouveauNewFramebuffer(GLcontext * ctx, - GLuint name) -{ - return _mesa_new_framebuffer(ctx, name); -} - -static struct gl_renderbuffer *nouveauNewRenderbuffer(GLcontext * ctx, - GLuint name) -{ - nouveau_renderbuffer *nrb; - - nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); - if (nrb) { - _mesa_init_renderbuffer(&nrb->mesa, name); - - nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; - nrb->mesa.Delete = nouveau_renderbuffer_delete; - } - return &nrb->mesa; -} - -static void -nouveauBindFramebuffer(GLcontext * ctx, GLenum target, - struct gl_framebuffer *fb, - struct gl_framebuffer *fbread) -{ - if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { - nouveau_build_framebuffer(ctx, fb); - } -} - -static void -nouveauFramebufferRenderbuffer(GLcontext * ctx, - struct gl_framebuffer *fb, - GLenum attachment, - struct gl_renderbuffer *rb) -{ - _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); - nouveau_build_framebuffer(ctx, fb); -} - -static void -nouveauRenderTexture(GLcontext * ctx, - struct gl_framebuffer *fb, - struct gl_renderbuffer_attachment *att) -{ -} - -static void -nouveauFinishRenderTexture(GLcontext * ctx, - struct gl_renderbuffer_attachment *att) -{ -} - -void nouveauInitBufferFuncs(struct dd_function_table *func) -{ - func->DrawBuffer = nouveauDrawBuffer; - - func->NewFramebuffer = nouveauNewFramebuffer; - func->NewRenderbuffer = nouveauNewRenderbuffer; - func->BindFramebuffer = nouveauBindFramebuffer; - func->FramebufferRenderbuffer = nouveauFramebufferRenderbuffer; - func->RenderTexture = nouveauRenderTexture; - func->FinishRenderTexture = nouveauFinishRenderTexture; -} diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h b/src/mesa/drivers/dri/nouveau/nouveau_buffers.h deleted file mode 100644 index f0987d2aa7d..00000000000 --- a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __NOUVEAU_BUFFERS_H__ -#define __NOUVEAU_BUFFERS_H__ - -#include -#include "mtypes.h" -#include "utils.h" -#include "renderbuffer.h" - -typedef struct nouveau_mem_t { - int type; - uint64_t offset; - uint64_t size; - void *map; -} nouveau_mem; - -extern nouveau_mem *nouveau_mem_alloc(GLcontext *, uint32_t flags, - GLuint size, GLuint align); -extern void nouveau_mem_free(GLcontext *, nouveau_mem *); -extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *, nouveau_mem *); - -extern GLboolean nouveau_memformat_flat_emit(GLcontext *, - nouveau_mem *dst, - nouveau_mem *src, - GLuint dst_offset, - GLuint src_offset, - GLuint size); - -typedef struct nouveau_renderbuffer_t { - struct gl_renderbuffer mesa; /* must be first! */ - __DRIdrawablePrivate *dPriv; - - nouveau_mem *mem; - void *map; - - int cpp; - uint32_t offset; - uint32_t pitch; -} nouveau_renderbuffer; - -extern nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, - GLvoid *map, - GLuint offset, - GLuint pitch, - __DRIdrawablePrivate *); -extern void nouveau_window_moved(GLcontext *); -extern GLboolean nouveau_build_framebuffer(GLcontext *, - struct gl_framebuffer *); -extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *); - -extern void nouveauInitBufferFuncs(struct dd_function_table *); - -#endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index fdbde51a728..03f778a13c4 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -36,10 +36,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "mtypes.h" #include "tnl/t_vertex.h" +#include "nouveau_fbo.h" #include "nouveau_screen.h" -#include "nouveau_state_cache.h" -#include "nouveau_buffers.h" #include "nouveau_shader.h" +#include "nouveau_state_cache.h" #include "nouveau_sync.h" #include "xmlconfig.h" diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c new file mode 100644 index 00000000000..54c0c26d083 --- /dev/null +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c @@ -0,0 +1,304 @@ +#include "utils.h" +#include "framebuffer.h" +#include "renderbuffer.h" +#include "fbobject.h" + +#include "nouveau_context.h" +#include "nouveau_fbo.h" +#include "nouveau_fifo.h" +#include "nouveau_msg.h" +#include "nouveau_object.h" +#include "nouveau_reg.h" + +static GLboolean +nouveau_renderbuffer_pixelformat(nouveau_renderbuffer * nrb, + GLenum internalFormat) +{ + nrb->mesa.InternalFormat = internalFormat; + + /*TODO: We probably want to extend this a bit, and maybe make + * card-specific? + */ + switch (internalFormat) { + case GL_RGBA: + case GL_RGBA8: + nrb->mesa._BaseFormat = GL_RGBA; + nrb->mesa._ActualFormat = GL_RGBA8; + nrb->mesa.DataType = GL_UNSIGNED_BYTE; + nrb->mesa.RedBits = 8; + nrb->mesa.GreenBits = 8; + nrb->mesa.BlueBits = 8; + nrb->mesa.AlphaBits = 8; + nrb->cpp = 4; + break; + case GL_RGB: + case GL_RGB5: + nrb->mesa._BaseFormat = GL_RGB; + nrb->mesa._ActualFormat = GL_RGB5; + nrb->mesa.DataType = GL_UNSIGNED_BYTE; + nrb->mesa.RedBits = 5; + nrb->mesa.GreenBits = 6; + nrb->mesa.BlueBits = 5; + nrb->mesa.AlphaBits = 0; + nrb->cpp = 2; + break; + case GL_DEPTH_COMPONENT16: + nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; + nrb->mesa._ActualFormat = GL_DEPTH_COMPONENT16; + nrb->mesa.DataType = GL_UNSIGNED_SHORT; + nrb->mesa.DepthBits = 16; + nrb->cpp = 2; + break; + case GL_DEPTH_COMPONENT24: + nrb->mesa._BaseFormat = GL_DEPTH_COMPONENT; + nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; + nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; + nrb->mesa.DepthBits = 24; + nrb->cpp = 4; + break; + case GL_STENCIL_INDEX8_EXT: + nrb->mesa._BaseFormat = GL_STENCIL_INDEX; + nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; + nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; + nrb->mesa.StencilBits = 8; + nrb->cpp = 4; + break; + case GL_DEPTH24_STENCIL8_EXT: + nrb->mesa._BaseFormat = GL_DEPTH_STENCIL_EXT; + nrb->mesa._ActualFormat = GL_DEPTH24_STENCIL8_EXT; + nrb->mesa.DataType = GL_UNSIGNED_INT_24_8_EXT; + nrb->mesa.DepthBits = 24; + nrb->mesa.StencilBits = 8; + nrb->cpp = 4; + break; + default: + return GL_FALSE; + break; + } + + return GL_TRUE; +} + +static GLboolean +nouveau_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) +{ + nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; + + if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) { + fprintf(stderr, "%s: unknown internalFormat\n", __func__); + return GL_FALSE; + } + + /* If this buffer isn't statically alloc'd, we may need to ask the + * drm for more memory */ + if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) { + GLuint pitch; + + /* align pitches to 64 bytes */ + pitch = ((width * nrb->cpp) + 63) & ~63; + + if (nrb->mem) + nouveau_mem_free(ctx, nrb->mem); + nrb->mem = nouveau_mem_alloc(ctx, + NOUVEAU_MEM_FB | + NOUVEAU_MEM_MAPPED, + pitch * height, 0); + if (!nrb->mem) + return GL_FALSE; + + /* update nouveau_renderbuffer info */ + nrb->offset = nouveau_mem_gpu_offset_get(ctx, nrb->mem); + nrb->pitch = pitch; + } + + rb->Width = width; + rb->Height = height; + rb->InternalFormat = internalFormat; + return GL_TRUE; +} + +static void nouveau_renderbuffer_delete(struct gl_renderbuffer *rb) +{ + GET_CURRENT_CONTEXT(ctx); + nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; + + if (nrb->mem) + nouveau_mem_free(ctx, nrb->mem); + FREE(nrb); +} + +nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, + GLvoid * map, GLuint offset, + GLuint pitch, + __DRIdrawablePrivate * + dPriv) +{ + nouveau_renderbuffer *nrb; + + nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); + if (nrb) { + _mesa_init_renderbuffer(&nrb->mesa, 0); + + nouveau_renderbuffer_pixelformat(nrb, internalFormat); + + nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; + nrb->mesa.Delete = nouveau_renderbuffer_delete; + + nrb->dPriv = dPriv; + nrb->offset = offset; + nrb->pitch = pitch; + nrb->map = map; + } + + return nrb; +} + +static void +nouveau_cliprects_drawable_set(nouveauContextPtr nmesa, + nouveau_renderbuffer * nrb) +{ + __DRIdrawablePrivate *dPriv = nrb->dPriv; + + nmesa->numClipRects = dPriv->numClipRects; + nmesa->pClipRects = dPriv->pClipRects; + nmesa->drawX = dPriv->x; + nmesa->drawY = dPriv->y; + nmesa->drawW = dPriv->w; + nmesa->drawH = dPriv->h; +} + +static void +nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, + nouveau_renderbuffer * nrb) +{ + nmesa->numClipRects = 1; + nmesa->pClipRects = &nmesa->osClipRect; + nmesa->osClipRect.x1 = 0; + nmesa->osClipRect.y1 = 0; + nmesa->osClipRect.x2 = nrb->mesa.Width; + nmesa->osClipRect.y2 = nrb->mesa.Height; + nmesa->drawX = 0; + nmesa->drawY = 0; + nmesa->drawW = nrb->mesa.Width; + nmesa->drawH = nrb->mesa.Height; +} + +void nouveau_window_moved(GLcontext * ctx) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + nouveau_renderbuffer *nrb; + + nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0]; + if (!nrb) + return; + + if (!nrb->dPriv) + nouveau_cliprects_renderbuffer_set(nmesa, nrb); + else + nouveau_cliprects_drawable_set(nmesa, nrb); + + /* Viewport depends on window size/position, nouveauCalcViewport + * will take care of calling the hw-specific WindowMoved + */ + ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height); + /* Scissor depends on window position */ + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); +} + +GLboolean +nouveau_build_framebuffer(GLcontext * ctx, struct gl_framebuffer *fb) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + nouveau_renderbuffer *color[MAX_DRAW_BUFFERS]; + nouveau_renderbuffer *depth; + + _mesa_update_framebuffer(ctx); + _mesa_update_draw_buffer_bounds(ctx); + + color[0] = (nouveau_renderbuffer *) fb->_ColorDrawBuffers[0][0]; + if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) + depth = (nouveau_renderbuffer *) fb->_DepthBuffer->Wrapped; + else + depth = (nouveau_renderbuffer *) fb->_DepthBuffer; + + if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth)) + return GL_FALSE; + nouveau_window_moved(ctx); + + return GL_TRUE; +} + +static void nouveauDrawBuffer(GLcontext * ctx, GLenum buffer) +{ + nouveau_build_framebuffer(ctx, ctx->DrawBuffer); +} + +static struct gl_framebuffer *nouveauNewFramebuffer(GLcontext * ctx, + GLuint name) +{ + return _mesa_new_framebuffer(ctx, name); +} + +static struct gl_renderbuffer *nouveauNewRenderbuffer(GLcontext * ctx, + GLuint name) +{ + nouveau_renderbuffer *nrb; + + nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); + if (nrb) { + _mesa_init_renderbuffer(&nrb->mesa, name); + + nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; + nrb->mesa.Delete = nouveau_renderbuffer_delete; + } + return &nrb->mesa; +} + +static void +nouveauBindFramebuffer(GLcontext * ctx, GLenum target, + struct gl_framebuffer *fb, + struct gl_framebuffer *fbread) +{ + if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) { + nouveau_build_framebuffer(ctx, fb); + } +} + +static void +nouveauFramebufferRenderbuffer(GLcontext * ctx, + struct gl_framebuffer *fb, + GLenum attachment, + struct gl_renderbuffer *rb) +{ + _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); + nouveau_build_framebuffer(ctx, fb); +} + +static void +nouveauRenderTexture(GLcontext * ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att) +{ +} + +static void +nouveauFinishRenderTexture(GLcontext * ctx, + struct gl_renderbuffer_attachment *att) +{ +} + +void nouveauInitBufferFuncs(struct dd_function_table *func) +{ + func->DrawBuffer = nouveauDrawBuffer; + + func->NewFramebuffer = nouveauNewFramebuffer; + func->NewRenderbuffer = nouveauNewRenderbuffer; + func->BindFramebuffer = nouveauBindFramebuffer; + func->FramebufferRenderbuffer = nouveauFramebufferRenderbuffer; + func->RenderTexture = nouveauRenderTexture; + func->FinishRenderTexture = nouveauFinishRenderTexture; +} diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.h b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h new file mode 100644 index 00000000000..757a784f8f8 --- /dev/null +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h @@ -0,0 +1,35 @@ +#ifndef __NOUVEAU_BUFFERS_H__ +#define __NOUVEAU_BUFFERS_H__ + +#include +#include "mtypes.h" +#include "utils.h" +#include "renderbuffer.h" + +#include "nouveau_mem.h" + +typedef struct nouveau_renderbuffer_t { + struct gl_renderbuffer mesa; /* must be first! */ + __DRIdrawablePrivate *dPriv; + + nouveau_mem *mem; + void *map; + + int cpp; + uint32_t offset; + uint32_t pitch; +} nouveau_renderbuffer; + +extern nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, + GLvoid *map, + GLuint offset, + GLuint pitch, + __DRIdrawablePrivate *); +extern void nouveau_window_moved(GLcontext *); +extern GLboolean nouveau_build_framebuffer(GLcontext *, + struct gl_framebuffer *); +extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *); + +extern void nouveauInitBufferFuncs(struct dd_function_table *); + +#endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_mem.c b/src/mesa/drivers/dri/nouveau/nouveau_mem.c new file mode 100644 index 00000000000..35c53268b06 --- /dev/null +++ b/src/mesa/drivers/dri/nouveau/nouveau_mem.c @@ -0,0 +1,144 @@ +#include "mtypes.h" + +#include "nouveau_context.h" +#include "nouveau_fifo.h" +#include "nouveau_mem.h" +#include "nouveau_msg.h" +#include "nouveau_object.h" +#include "nouveau_reg.h" + +#define MAX_MEMFMT_LENGTH 32768 + +/* Unstrided blit using NV_MEMORY_TO_MEMORY_FORMAT */ +GLboolean +nouveau_memformat_flat_emit(GLcontext * ctx, + nouveau_mem * dst, nouveau_mem * src, + GLuint dst_offset, GLuint src_offset, + GLuint size) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + uint32_t src_handle, dst_handle; + GLuint count; + + if (src_offset + size > src->size) { + MESSAGE("src out of nouveau_mem bounds\n"); + return GL_FALSE; + } + if (dst_offset + size > dst->size) { + MESSAGE("dst out of nouveau_mem bounds\n"); + return GL_FALSE; + } + + src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; + dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT; + src_offset += nouveau_mem_gpu_offset_get(ctx, src); + dst_offset += nouveau_mem_gpu_offset_get(ctx, dst); + + BEGIN_RING_SIZE(NvSubMemFormat, + NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2); + OUT_RING(src_handle); + OUT_RING(dst_handle); + + count = (size / MAX_MEMFMT_LENGTH) + + ((size % MAX_MEMFMT_LENGTH) ? 1 : 0); + + while (count--) { + GLuint length = + (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size; + + BEGIN_RING_SIZE(NvSubMemFormat, + NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8); + OUT_RING(src_offset); + OUT_RING(dst_offset); + OUT_RING(0); /* pitch in */ + OUT_RING(0); /* pitch out */ + OUT_RING(length); /* line length */ + OUT_RING(1); /* number of lines */ + OUT_RING((1 << 8) /* dst_inc */ |(1 << 0) /* src_inc */ ); + OUT_RING(0); /* buffer notify? */ + FIRE_RING(); + + src_offset += length; + dst_offset += length; + size -= length; + } + + return GL_TRUE; +} + +void nouveau_mem_free(GLcontext * ctx, nouveau_mem * mem) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + struct drm_nouveau_mem_free memf; + + if (NOUVEAU_DEBUG & DEBUG_MEM) { + fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n", + __func__, mem->type, (GLuint) mem->offset, + (GLuint) mem->size); + } + + if (mem->map) + drmUnmap(mem->map, mem->size); + memf.flags = mem->type; + memf.offset = mem->offset; + drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, + sizeof(memf)); + FREE(mem); +} + +nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, uint32_t flags, GLuint size, + GLuint align) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + struct drm_nouveau_mem_alloc mema; + nouveau_mem *mem; + int ret; + + if (NOUVEAU_DEBUG & DEBUG_MEM) { + fprintf(stderr, + "%s: requested: flags=0x%x, size=0x%x, align=0x%x\n", + __func__, flags, (GLuint) size, align); + } + + mem = CALLOC(sizeof(nouveau_mem)); + if (!mem) + return NULL; + + mema.flags = flags; + mema.size = mem->size = size; + mema.alignment = align; + mem->map = NULL; + ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC, + &mema, sizeof(mema)); + if (ret) { + FREE(mem); + return NULL; + } + mem->offset = mema.offset; + mem->type = mema.flags; + + if (NOUVEAU_DEBUG & DEBUG_MEM) { + fprintf(stderr, + "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n", + __func__, mem->type, (GLuint) mem->offset, + (GLuint) mem->size); + } + + if (flags & NOUVEAU_MEM_MAPPED) + ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, + &mem->map); + if (ret) { + mem->map = NULL; + nouveau_mem_free(ctx, mem); + mem = NULL; + } + + return mem; +} + +uint32_t nouveau_mem_gpu_offset_get(GLcontext * ctx, nouveau_mem * mem) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + + return mem->offset; +} diff --git a/src/mesa/drivers/dri/nouveau/nouveau_mem.h b/src/mesa/drivers/dri/nouveau/nouveau_mem.h new file mode 100644 index 00000000000..6db73f4708e --- /dev/null +++ b/src/mesa/drivers/dri/nouveau/nouveau_mem.h @@ -0,0 +1,23 @@ +#ifndef __NOUVEAU_MEM_H__ +#define __NOUVEAU_MEM_H__ + +typedef struct nouveau_mem_t { + int type; + uint64_t offset; + uint64_t size; + void *map; +} nouveau_mem; + +extern nouveau_mem *nouveau_mem_alloc(GLcontext *, uint32_t flags, + GLuint size, GLuint align); +extern void nouveau_mem_free(GLcontext *, nouveau_mem *); +extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *, nouveau_mem *); + +extern GLboolean nouveau_memformat_flat_emit(GLcontext *, + nouveau_mem *dst, + nouveau_mem *src, + GLuint dst_offset, + GLuint src_offset, + GLuint size); + +#endif diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.h b/src/mesa/drivers/dri/nouveau/nouveau_span.h index bc39ecd17b5..c4142a10ef4 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.h @@ -30,7 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define __NOUVEAU_SPAN_H__ #include "drirenderbuffer.h" -#include "nouveau_buffers.h" +#include "nouveau_fbo.h" extern void nouveauSpanInitFunctions( GLcontext *ctx ); extern void nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index 3f5f6d54e9b..abb3088032b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -28,11 +28,11 @@ #include "vblank.h" /* for DO_USLEEP */ #include "nouveau_context.h" -#include "nouveau_buffers.h" -#include "nouveau_object.h" #include "nouveau_fifo.h" -#include "nouveau_reg.h" +#include "nouveau_mem.h" #include "nouveau_msg.h" +#include "nouveau_object.h" +#include "nouveau_reg.h" #include "nouveau_sync.h" #define NOTIFIER(__v) \ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h index 1ff4eca3258..fc37efbe6b2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.h @@ -28,8 +28,6 @@ #ifndef __NOUVEAU_SYNC_H__ #define __NOUVEAU_SYNC_H__ -#include "nouveau_buffers.h" - #define NV_NOTIFIER_SIZE 32 #define NV_NOTIFY_TIME_0 0x00000000 #define NV_NOTIFY_TIME_1 0x00000004 -- cgit v1.2.3 From fef3dcbee60b041df64a12511c8aa3c304a04652 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 20:38:10 +1000 Subject: nouveau: Always render offscreen, emulate front buffer rendering. --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 25 +++-- src/mesa/drivers/dri/nouveau/nouveau_context.h | 7 +- src/mesa/drivers/dri/nouveau/nouveau_driver.c | 4 + src/mesa/drivers/dri/nouveau/nouveau_fbo.c | 126 +++++++++++-------------- src/mesa/drivers/dri/nouveau/nouveau_fbo.h | 13 +-- src/mesa/drivers/dri/nouveau/nouveau_screen.c | 27 ++---- src/mesa/drivers/dri/nouveau/nouveau_span.c | 8 +- src/mesa/drivers/dri/nouveau/nouveau_span.h | 4 +- src/mesa/drivers/dri/nouveau/nv04_state.c | 4 +- src/mesa/drivers/dri/nouveau/nv10_state.c | 4 +- src/mesa/drivers/dri/nouveau/nv20_state.c | 4 +- src/mesa/drivers/dri/nouveau/nv30_state.c | 6 +- src/mesa/drivers/dri/nouveau/nv50_state.c | 6 +- 13 files changed, 109 insertions(+), 129 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 44392c0267c..9b92f2001d9 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -315,19 +315,23 @@ GLboolean nouveauUnbindContext( __DRIcontextPrivate *driContextPriv ) return GL_TRUE; } -static void nouveauDoSwapBuffers(nouveauContextPtr nmesa, - __DRIdrawablePrivate *dPriv) +void +nouveauDoSwapBuffers(nouveauContextPtr nmesa, __DRIdrawablePrivate *dPriv) { struct gl_framebuffer *fb; - nouveau_renderbuffer *src, *dst; + nouveauScreenPtr screen = dPriv->driScreenPriv->private; + nouveau_renderbuffer_t *src; drm_clip_rect_t *box; int nbox, i; fb = (struct gl_framebuffer *)dPriv->driverPrivate; - dst = (nouveau_renderbuffer*) - fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; - src = (nouveau_renderbuffer*) - fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer; + if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) { + src = (nouveau_renderbuffer_t *) + fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; + } else { + src = (nouveau_renderbuffer_t *) + fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer; + } #ifdef ALLOW_MULTI_SUBCHANNEL LOCK_HARDWARE(nmesa); @@ -341,9 +345,10 @@ static void nouveauDoSwapBuffers(nouveauContextPtr nmesa, OUT_RING (6); /* X8R8G8B8 */ else OUT_RING (4); /* R5G6B5 */ - OUT_RING ((dst->pitch << 16) | src->pitch); - OUT_RING (src->offset); - OUT_RING (dst->offset); + OUT_RING(((screen->frontPitch * screen->fbFormat) << 16) | + src->pitch); + OUT_RING(src->offset); + OUT_RING(screen->frontOffset); } for (i=0; iDrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) + nouveauDoSwapBuffers(nmesa, nmesa->driDrawable); FIRE_RING(); } @@ -124,6 +127,7 @@ static void nouveauFlush( GLcontext *ctx ) static void nouveauFinish( GLcontext *ctx ) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + nouveauFlush( ctx ); nouveauWaitForIdle( nmesa ); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c index 54c0c26d083..cc3da8b9bde 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.c @@ -11,7 +11,7 @@ #include "nouveau_reg.h" static GLboolean -nouveau_renderbuffer_pixelformat(nouveau_renderbuffer * nrb, +nouveau_renderbuffer_pixelformat(nouveau_renderbuffer_t * nrb, GLenum internalFormat) { nrb->mesa.InternalFormat = internalFormat; @@ -84,7 +84,7 @@ nouveau_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { - nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; + nouveau_renderbuffer_t *nrb = (nouveau_renderbuffer_t *) rb; if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) { fprintf(stderr, "%s: unknown internalFormat\n", __func__); @@ -93,7 +93,7 @@ nouveau_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, /* If this buffer isn't statically alloc'd, we may need to ask the * drm for more memory */ - if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) { + if (rb->Width != width || rb->Height != height) { GLuint pitch; /* align pitches to 64 bytes */ @@ -116,62 +116,48 @@ nouveau_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; rb->InternalFormat = internalFormat; + + nouveauSpanSetFunctions(nrb); + return GL_TRUE; } -static void nouveau_renderbuffer_delete(struct gl_renderbuffer *rb) +static void +nouveau_renderbuffer_delete(struct gl_renderbuffer *rb) { GET_CURRENT_CONTEXT(ctx); - nouveau_renderbuffer *nrb = (nouveau_renderbuffer *) rb; + nouveau_renderbuffer_t *nrb = (nouveau_renderbuffer_t *) rb; if (nrb->mem) nouveau_mem_free(ctx, nrb->mem); FREE(nrb); } -nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, - GLvoid * map, GLuint offset, - GLuint pitch, - __DRIdrawablePrivate * - dPriv) +nouveau_renderbuffer_t * +nouveau_renderbuffer_new(GLenum internalFormat) { - nouveau_renderbuffer *nrb; + nouveau_renderbuffer_t *nrb; - nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); - if (nrb) { - _mesa_init_renderbuffer(&nrb->mesa, 0); - - nouveau_renderbuffer_pixelformat(nrb, internalFormat); + nrb = CALLOC_STRUCT(nouveau_renderbuffer); + if (!nrb) + return NULL; - nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; - nrb->mesa.Delete = nouveau_renderbuffer_delete; + _mesa_init_renderbuffer(&nrb->mesa, 0); - nrb->dPriv = dPriv; - nrb->offset = offset; - nrb->pitch = pitch; - nrb->map = map; + if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) { + fprintf(stderr, "%s: unknown internalFormat\n", __func__); + return GL_FALSE; } - return nrb; -} + nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; + nrb->mesa.Delete = nouveau_renderbuffer_delete; -static void -nouveau_cliprects_drawable_set(nouveauContextPtr nmesa, - nouveau_renderbuffer * nrb) -{ - __DRIdrawablePrivate *dPriv = nrb->dPriv; - - nmesa->numClipRects = dPriv->numClipRects; - nmesa->pClipRects = dPriv->pClipRects; - nmesa->drawX = dPriv->x; - nmesa->drawY = dPriv->y; - nmesa->drawW = dPriv->w; - nmesa->drawH = dPriv->h; + return nrb; } static void nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, - nouveau_renderbuffer * nrb) + nouveau_renderbuffer_t * nrb) { nmesa->numClipRects = 1; nmesa->pClipRects = &nmesa->osClipRect; @@ -185,19 +171,18 @@ nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa, nmesa->drawH = nrb->mesa.Height; } -void nouveau_window_moved(GLcontext * ctx) +void +nouveau_window_moved(GLcontext * ctx) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_renderbuffer *nrb; + nouveau_renderbuffer_t *nrb; - nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0]; + nrb = (nouveau_renderbuffer_t *) + ctx->DrawBuffer->_ColorDrawBuffers[0][0]; if (!nrb) return; - if (!nrb->dPriv) - nouveau_cliprects_renderbuffer_set(nmesa, nrb); - else - nouveau_cliprects_drawable_set(nmesa, nrb); + nouveau_cliprects_renderbuffer_set(nmesa, nrb); /* Viewport depends on window size/position, nouveauCalcViewport * will take care of calling the hw-specific WindowMoved @@ -210,20 +195,20 @@ void nouveau_window_moved(GLcontext * ctx) } GLboolean -nouveau_build_framebuffer(GLcontext * ctx, struct gl_framebuffer *fb) +nouveau_build_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - nouveau_renderbuffer *color[MAX_DRAW_BUFFERS]; - nouveau_renderbuffer *depth; + nouveau_renderbuffer_t *color[MAX_DRAW_BUFFERS]; + nouveau_renderbuffer_t *depth; _mesa_update_framebuffer(ctx); _mesa_update_draw_buffer_bounds(ctx); - color[0] = (nouveau_renderbuffer *) fb->_ColorDrawBuffers[0][0]; + color[0] = (nouveau_renderbuffer_t *) fb->_ColorDrawBuffers[0][0]; if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) - depth = (nouveau_renderbuffer *) fb->_DepthBuffer->Wrapped; + depth = (nouveau_renderbuffer_t *) fb->_DepthBuffer->Wrapped; else - depth = (nouveau_renderbuffer *) fb->_DepthBuffer; + depth = (nouveau_renderbuffer_t *) fb->_DepthBuffer; if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth)) return GL_FALSE; @@ -232,34 +217,36 @@ nouveau_build_framebuffer(GLcontext * ctx, struct gl_framebuffer *fb) return GL_TRUE; } -static void nouveauDrawBuffer(GLcontext * ctx, GLenum buffer) +static void +nouveauDrawBuffer(GLcontext *ctx, GLenum buffer) { nouveau_build_framebuffer(ctx, ctx->DrawBuffer); } -static struct gl_framebuffer *nouveauNewFramebuffer(GLcontext * ctx, - GLuint name) +static struct gl_framebuffer * +nouveauNewFramebuffer(GLcontext *ctx, GLuint name) { return _mesa_new_framebuffer(ctx, name); } -static struct gl_renderbuffer *nouveauNewRenderbuffer(GLcontext * ctx, - GLuint name) +static struct gl_renderbuffer * +nouveauNewRenderbuffer(GLcontext *ctx, GLuint name) { - nouveau_renderbuffer *nrb; + nouveau_renderbuffer_t *nrb; - nrb = CALLOC_STRUCT(nouveau_renderbuffer_t); - if (nrb) { - _mesa_init_renderbuffer(&nrb->mesa, name); + nrb = CALLOC_STRUCT(nouveau_renderbuffer); + if (!nrb) + return NULL; - nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; - nrb->mesa.Delete = nouveau_renderbuffer_delete; - } + _mesa_init_renderbuffer(&nrb->mesa, name); + + nrb->mesa.AllocStorage = nouveau_renderbuffer_storage; + nrb->mesa.Delete = nouveau_renderbuffer_delete; return &nrb->mesa; } static void -nouveauBindFramebuffer(GLcontext * ctx, GLenum target, +nouveauBindFramebuffer(GLcontext *ctx, GLenum target, struct gl_framebuffer *fb, struct gl_framebuffer *fbread) { @@ -269,18 +256,15 @@ nouveauBindFramebuffer(GLcontext * ctx, GLenum target, } static void -nouveauFramebufferRenderbuffer(GLcontext * ctx, - struct gl_framebuffer *fb, - GLenum attachment, - struct gl_renderbuffer *rb) +nouveauFramebufferRenderbuffer(GLcontext *ctx, struct gl_framebuffer *fb, + GLenum attachment, struct gl_renderbuffer *rb) { _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb); nouveau_build_framebuffer(ctx, fb); } static void -nouveauRenderTexture(GLcontext * ctx, - struct gl_framebuffer *fb, +nouveauRenderTexture(GLcontext * ctx, struct gl_framebuffer *fb, struct gl_renderbuffer_attachment *att) { } @@ -291,7 +275,8 @@ nouveauFinishRenderTexture(GLcontext * ctx, { } -void nouveauInitBufferFuncs(struct dd_function_table *func) +void +nouveauInitBufferFuncs(struct dd_function_table *func) { func->DrawBuffer = nouveauDrawBuffer; @@ -302,3 +287,4 @@ void nouveauInitBufferFuncs(struct dd_function_table *func) func->RenderTexture = nouveauRenderTexture; func->FinishRenderTexture = nouveauFinishRenderTexture; } + diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fbo.h b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h index 757a784f8f8..787af4e9e4b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fbo.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_fbo.h @@ -8,9 +8,8 @@ #include "nouveau_mem.h" -typedef struct nouveau_renderbuffer_t { +typedef struct nouveau_renderbuffer { struct gl_renderbuffer mesa; /* must be first! */ - __DRIdrawablePrivate *dPriv; nouveau_mem *mem; void *map; @@ -18,17 +17,13 @@ typedef struct nouveau_renderbuffer_t { int cpp; uint32_t offset; uint32_t pitch; -} nouveau_renderbuffer; +} nouveau_renderbuffer_t; -extern nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat, - GLvoid *map, - GLuint offset, - GLuint pitch, - __DRIdrawablePrivate *); +extern nouveau_renderbuffer_t *nouveau_renderbuffer_new(GLenum internalFormat); extern void nouveau_window_moved(GLcontext *); extern GLboolean nouveau_build_framebuffer(GLcontext *, struct gl_framebuffer *); -extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *); +extern nouveau_renderbuffer_t *nouveau_current_draw_buffer(GLcontext *); extern void nouveauInitBufferFuncs(struct dd_function_table *); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c index 4d22ecc83e5..065aa81746c 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c @@ -132,10 +132,11 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv, GLboolean isPixmap) { nouveauScreenPtr screen = (nouveauScreenPtr) driScrnPriv->private; - nouveau_renderbuffer *nrb; + nouveau_renderbuffer_t *nrb; struct gl_framebuffer *fb; const GLboolean swAccum = mesaVis->accumRedBits > 0; - const GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24; + const GLboolean swStencil = (mesaVis->stencilBits > 0 && + mesaVis->depthBits != 24); GLenum color_format = screen->fbFormat == 4 ? GL_RGBA8 : GL_RGB5; if (isPixmap) @@ -146,37 +147,25 @@ nouveauCreateBuffer(__DRIscreenPrivate *driScrnPriv, return GL_FALSE; /* Front buffer */ - nrb = nouveau_renderbuffer_new(color_format, - driScrnPriv->pFB + screen->frontOffset, - screen->frontOffset, - screen->frontPitch * screen->fbFormat, - driDrawPriv); - nouveauSpanSetFunctions(nrb, mesaVis); + nrb = nouveau_renderbuffer_new(color_format); _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &nrb->mesa); if (mesaVis->doubleBufferMode) { - nrb = nouveau_renderbuffer_new(color_format, NULL, 0, 0, NULL); - nouveauSpanSetFunctions(nrb, mesaVis); + nrb = nouveau_renderbuffer_new(color_format); _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &nrb->mesa); } if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) { - nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT, NULL, - 0, 0, NULL); - nouveauSpanSetFunctions(nrb, mesaVis); + nrb = nouveau_renderbuffer_new(GL_DEPTH24_STENCIL8_EXT); _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &nrb->mesa); } else if (mesaVis->depthBits == 24) { - nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT24, NULL, - 0, 0, NULL); - nouveauSpanSetFunctions(nrb, mesaVis); + nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT24); _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); } else if (mesaVis->depthBits == 16) { - nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16, NULL, - 0, 0, NULL); - nouveauSpanSetFunctions(nrb, mesaVis); + nrb = nouveau_renderbuffer_new(GL_DEPTH_COMPONENT16); _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &nrb->mesa); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c index 6e3f9fadf4e..453bc5f6c49 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c @@ -37,8 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define HAVE_HW_STENCIL_SPANS 0 #define HAVE_HW_STENCIL_PIXELS 0 -static char *fake_span[1280*1024*4]; - #define HW_CLIPLOOP() \ do { \ int _nc = nmesa->numClipRects; \ @@ -50,11 +48,10 @@ static char *fake_span[1280*1024*4]; #define LOCAL_VARS \ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \ - nouveau_renderbuffer *nrb = (nouveau_renderbuffer *)rb; \ + nouveau_renderbuffer_t *nrb = (nouveau_renderbuffer_t *)rb; \ GLuint height = nrb->mesa.Height; \ GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) + \ (nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp); \ - map = fake_span; \ GLuint p; \ (void) p; @@ -119,10 +116,11 @@ void nouveauSpanInitFunctions( GLcontext *ctx ) * Plug in the Get/Put routines for the given driRenderbuffer. */ void -nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis) +nouveauSpanSetFunctions(nouveau_renderbuffer_t *nrb) { if (nrb->mesa._ActualFormat == GL_RGBA8) nouveauInitPointers_ARGB8888(&nrb->mesa); else // if (nrb->mesa._ActualFormat == GL_RGB5) nouveauInitPointers_RGB565(&nrb->mesa); } + diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.h b/src/mesa/drivers/dri/nouveau/nouveau_span.h index c4142a10ef4..d3f31c9cb23 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.h @@ -32,8 +32,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "drirenderbuffer.h" #include "nouveau_fbo.h" -extern void nouveauSpanInitFunctions( GLcontext *ctx ); -extern void nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis); +extern void nouveauSpanInitFunctions(GLcontext *ctx); +extern void nouveauSpanSetFunctions(nouveau_renderbuffer_t *nrb); #endif /* __NOUVEAU_SPAN_H__ */ diff --git a/src/mesa/drivers/dri/nouveau/nv04_state.c b/src/mesa/drivers/dri/nouveau/nv04_state.c index 25df3d2a624..d3031aa5b19 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_state.c +++ b/src/mesa/drivers/dri/nouveau/nv04_state.c @@ -451,8 +451,8 @@ static GLboolean nv04InitCard(nouveauContextPtr nmesa) /* Update buffer offset/pitch/format */ static GLboolean nv04BindBuffers(nouveauContextPtr nmesa, int num_color, - nouveau_renderbuffer **color, - nouveau_renderbuffer *depth) + nouveau_renderbuffer_t **color, + nouveau_renderbuffer_t *depth) { GLuint x, y, w, h; uint32_t depth_pitch=(depth?depth->pitch:0+15)&~15+16; diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 47c4b14ba6b..0e1637015fd 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -709,8 +709,8 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) /* Update buffer offset/pitch/format */ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, - nouveau_renderbuffer **color, - nouveau_renderbuffer *depth) + nouveau_renderbuffer_t **color, + nouveau_renderbuffer_t *depth) { GLuint x, y, w, h; GLuint pitch, format, depth_pitch; diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index ccf2f6148b4..6b583980a49 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -728,8 +728,8 @@ static GLboolean nv20InitCard(nouveauContextPtr nmesa) /* Update buffer offset/pitch/format */ static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color, - nouveau_renderbuffer **color, - nouveau_renderbuffer *depth) + nouveau_renderbuffer_t **color, + nouveau_renderbuffer_t *depth) { GLuint x, y, w, h; GLuint pitch, format, depth_pitch; diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index 9b010954b33..cd3ee986880 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -905,9 +905,9 @@ static GLboolean nv40InitCard(nouveauContextPtr nmesa) return GL_TRUE; } -static GLboolean nv30BindBuffers(nouveauContextPtr nmesa, int num_color, - nouveau_renderbuffer **color, - nouveau_renderbuffer *depth) +static GLboolean +nv30BindBuffers(nouveauContextPtr nmesa, int num_color, + nouveau_renderbuffer_t **color, nouveau_renderbuffer_t *depth) { GLuint x, y, w, h; diff --git a/src/mesa/drivers/dri/nouveau/nv50_state.c b/src/mesa/drivers/dri/nouveau/nv50_state.c index 818e268615c..a9236f093c3 100644 --- a/src/mesa/drivers/dri/nouveau/nv50_state.c +++ b/src/mesa/drivers/dri/nouveau/nv50_state.c @@ -584,9 +584,9 @@ static GLboolean nv50InitCard(nouveauContextPtr nmesa) return GL_FALSE; } -static GLboolean nv50BindBuffers(nouveauContextPtr nmesa, int num_color, - nouveau_renderbuffer **color, - nouveau_renderbuffer *depth) +static GLboolean +nv50BindBuffers(nouveauContextPtr nmesa, int num_color, + nouveau_renderbuffer_t **color, nouveau_renderbuffer_t *depth) { return GL_FALSE; } -- cgit v1.2.3 From fcbd06d201754bf4f69a0262dcd04b4c287a173b Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 22:05:15 +1000 Subject: nouveau: Remove ALLOW_MULTI_SUBCHANNEL hack Irrelevant, since we depend on working context switching now. --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 -- src/mesa/drivers/dri/nouveau/nouveau_object.c | 2 -- src/mesa/drivers/dri/nouveau/nouveau_object.h | 2 -- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 2 -- 4 files changed, 8 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 9b92f2001d9..1e13324b983 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -333,7 +333,6 @@ nouveauDoSwapBuffers(nouveauContextPtr nmesa, __DRIdrawablePrivate *dPriv) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer; } -#ifdef ALLOW_MULTI_SUBCHANNEL LOCK_HARDWARE(nmesa); nbox = dPriv->numClipRects; box = dPriv->pClipRects; @@ -362,7 +361,6 @@ nouveauDoSwapBuffers(nouveauContextPtr nmesa, __DRIdrawablePrivate *dPriv) FIRE_RING(); UNLOCK_HARDWARE(nmesa); -#endif } void nouveauSwapBuffers(__DRIdrawablePrivate *dPriv) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index a143488e8d5..f6ff37848af 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -45,7 +45,6 @@ void nouveauObjectInit(nouveauContextPtr nmesa) } nouveauCreateContextObject(nmesa, NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT); -#ifdef ALLOW_MULTI_SUBCHANNEL nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf2D, NvCtxSurf2D); BEGIN_RING_SIZE(NvSubCtxSurf2D, NV10_CONTEXT_SURFACES_2D_SET_DMA_IN_MEMORY0, 2); OUT_RING(NvDmaFB); @@ -58,7 +57,6 @@ void nouveauObjectInit(nouveauContextPtr nmesa) OUT_RING(3); /* SRCCOPY */ nouveauObjectOnSubchannel(nmesa, NvSubMemFormat, NvMemFormat); -#endif nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D); } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.h b/src/mesa/drivers/dri/nouveau/nouveau_object.h index 8c72d014daa..730738ad34b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.h @@ -3,8 +3,6 @@ #include "nouveau_context.h" -#define ALLOW_MULTI_SUBCHANNEL - void nouveauObjectInit(nouveauContextPtr nmesa); enum DMAObjects { diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index abb3088032b..e7abdd60eeb 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -188,11 +188,9 @@ GLboolean nouveauSyncInitFuncs(GLcontext *ctx) */ BEGIN_RING_CACHE(NvSub3D, 0x180, 1); OUT_RING_CACHE (NvSyncNotify); -#ifdef ALLOW_MULTI_SUBCHANNEL BEGIN_RING_SIZE(NvSubMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1); OUT_RING (NvSyncNotify); -#endif return GL_TRUE; } -- cgit v1.2.3 From 3cc4e9815d4962e5f5e7b23bae1cf9b82092bb52 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 13 Aug 2007 23:12:04 +1000 Subject: nouveau: reindent nouveau_span.c --- src/mesa/drivers/dri/nouveau/nouveau_span.c | 45 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c index 453bc5f6c49..d62830ff53e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_span.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_span.c @@ -67,7 +67,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Color buffers */ -/* RGB565 */ +/* RGB565 */ #define SPANTMP_PIXEL_FMT GL_RGB #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5 @@ -86,41 +86,38 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp) #include "spantmp2.h" -static void -nouveauSpanRenderStart( GLcontext *ctx ) +static void nouveauSpanRenderStart(GLcontext * ctx) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - FIRE_RING(); - LOCK_HARDWARE(nmesa); - nouveauWaitForIdleLocked( nmesa ); + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + FIRE_RING(); + LOCK_HARDWARE(nmesa); + nouveauWaitForIdleLocked(nmesa); } -static void -nouveauSpanRenderFinish( GLcontext *ctx ) +static void nouveauSpanRenderFinish(GLcontext * ctx) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - _swrast_flush( ctx ); - nouveauWaitForIdleLocked( nmesa ); - UNLOCK_HARDWARE( nmesa ); + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + _swrast_flush(ctx); + nouveauWaitForIdleLocked(nmesa); + UNLOCK_HARDWARE(nmesa); } -void nouveauSpanInitFunctions( GLcontext *ctx ) +void nouveauSpanInitFunctions(GLcontext * ctx) { - struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx); - swdd->SpanRenderStart = nouveauSpanRenderStart; - swdd->SpanRenderFinish = nouveauSpanRenderFinish; + struct swrast_device_driver *swdd = + _swrast_GetDeviceDriverReference(ctx); + swdd->SpanRenderStart = nouveauSpanRenderStart; + swdd->SpanRenderFinish = nouveauSpanRenderFinish; } /** * Plug in the Get/Put routines for the given driRenderbuffer. */ -void -nouveauSpanSetFunctions(nouveau_renderbuffer_t *nrb) +void nouveauSpanSetFunctions(nouveau_renderbuffer_t * nrb) { - if (nrb->mesa._ActualFormat == GL_RGBA8) - nouveauInitPointers_ARGB8888(&nrb->mesa); - else // if (nrb->mesa._ActualFormat == GL_RGB5) - nouveauInitPointers_RGB565(&nrb->mesa); + if (nrb->mesa._ActualFormat == GL_RGBA8) + nouveauInitPointers_ARGB8888(&nrb->mesa); + else // if (nrb->mesa._ActualFormat == GL_RGB5) + nouveauInitPointers_RGB565(&nrb->mesa); } - -- cgit v1.2.3 From ecfa3e4d0aa93ca597a19693c30532655795e9d8 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 15 Aug 2007 14:26:15 +1000 Subject: nouveau: Keep drm channel alloc struct around. --- src/mesa/drivers/dri/nouveau/nouveau_context.h | 29 ++++++++------------ src/mesa/drivers/dri/nouveau/nouveau_fifo.c | 37 +++++++++++++------------- src/mesa/drivers/dri/nouveau/nouveau_fifo.h | 10 +++---- src/mesa/drivers/dri/nouveau/nouveau_object.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_sync.c | 5 ++-- 5 files changed, 39 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 37c8f40d098..dc904ad6b35 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -44,17 +44,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xmlconfig.h" -typedef struct nouveau_fifo_t{ - int channel; - u_int32_t* buffer; - u_int32_t* mmio; - u_int32_t put_base; - u_int32_t current; - u_int32_t put; - u_int32_t free; - u_int32_t max; -} -nouveau_fifo; +typedef struct nouveau_fifo { + struct drm_nouveau_channel_alloc drm; + uint32_t *pushbuf; + uint32_t *mmio; + uint32_t *notifier_block; + uint32_t current; + uint32_t put; + uint32_t free; + uint32_t max; +} nouveau_fifo_t; #define TAG(x) nouveau##x #include "tnl_dd/t_dd_vertex.h" @@ -94,13 +93,7 @@ typedef struct nouveau_context { GLcontext *glCtx; /* The per-context fifo */ - nouveau_fifo fifo; - - /* The read-only regs */ - volatile unsigned char* mmio; - - /* The per-channel notifier block */ - volatile void *notifier_block; + nouveau_fifo_t fifo; /* Physical addresses of AGP/VRAM apertures */ uint64_t vram_phys; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c index 4208819d025..5dc94e0520a 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c @@ -57,7 +57,8 @@ void WAIT_RING(nouveauContextPtr nmesa,u_int32_t size) if(nmesa->fifo.put >= fifo_get) { nmesa->fifo.free = nmesa->fifo.max - nmesa->fifo.current; if(nmesa->fifo.free < size+1) { - OUT_RING(NV03_FIFO_CMD_JUMP | nmesa->fifo.put_base); + OUT_RING(NV03_FIFO_CMD_JUMP | + nmesa->fifo.drm.put_base); if(fifo_get <= RING_SKIPS) { if(nmesa->fifo.put <= RING_SKIPS) /* corner case - will be idle */ NV_FIFO_WRITE_PUT(RING_SKIPS + 1); @@ -98,54 +99,54 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa) // here we call the fifo initialization ioctl and fill in stuff accordingly GLboolean nouveauFifoInit(nouveauContextPtr nmesa) { - struct drm_nouveau_channel_alloc fifo_init; int i, ret; #ifdef NOUVEAU_RING_DEBUG return GL_TRUE; #endif - fifo_init.fb_ctxdma_handle = NvDmaFB; - fifo_init.tt_ctxdma_handle = NvDmaTT; - ret=drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_CHANNEL_ALLOC, &fifo_init, sizeof(fifo_init)); + nmesa->fifo.drm.fb_ctxdma_handle = NvDmaFB; + nmesa->fifo.drm.tt_ctxdma_handle = NvDmaTT; + ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_CHANNEL_ALLOC, + &nmesa->fifo.drm, sizeof(nmesa->fifo.drm)); if (ret) { - FATAL("Fifo initialization ioctl failed (returned %d)\n",ret); + FATAL("Fifo initialization ioctl failed (returned %d)\n", ret); return GL_FALSE; } - ret = drmMap(nmesa->driFd, fifo_init.cmdbuf, fifo_init.cmdbuf_size, &nmesa->fifo.buffer); + ret = drmMap(nmesa->driFd, nmesa->fifo.drm.cmdbuf, + nmesa->fifo.drm.cmdbuf_size, &nmesa->fifo.pushbuf); if (ret) { - FATAL("Unable to map the fifo (returned %d)\n",ret); + FATAL("Unable to map the fifo (returned %d)\n", ret); return GL_FALSE; } - ret = drmMap(nmesa->driFd, fifo_init.ctrl, fifo_init.ctrl_size, &nmesa->fifo.mmio); + ret = drmMap(nmesa->driFd, nmesa->fifo.drm.ctrl, + nmesa->fifo.drm.ctrl_size, &nmesa->fifo.mmio); if (ret) { - FATAL("Unable to map the control regs (returned %d)\n",ret); + FATAL("Unable to map the control regs (returned %d)\n", ret); return GL_FALSE; } - ret = drmMap(nmesa->driFd, fifo_init.notifier, - fifo_init.notifier_size, - &nmesa->notifier_block); + ret = drmMap(nmesa->driFd, nmesa->fifo.drm.notifier, + nmesa->fifo.drm.notifier_size, + &nmesa->fifo.notifier_block); if (ret) { - FATAL("Unable to map the notifier block (returned %d)\n",ret); + FATAL("Unable to map the notifier block (returned %d)\n", ret); return GL_FALSE; } /* Setup our initial FIFO tracking params */ - nmesa->fifo.channel = fifo_init.channel; - nmesa->fifo.put_base = fifo_init.put_base; nmesa->fifo.current = 0; nmesa->fifo.put = 0; - nmesa->fifo.max = (fifo_init.cmdbuf_size >> 2) - 1; + nmesa->fifo.max = (nmesa->fifo.drm.cmdbuf_size >> 2) - 1; nmesa->fifo.free = nmesa->fifo.max - nmesa->fifo.current; for (i=0; ififo.free -= RING_SKIPS; - MESSAGE("Fifo init ok. Using context %d\n", fifo_init.channel); + MESSAGE("Fifo init ok. Using context %d\n", nmesa->fifo.drm.channel); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.h b/src/mesa/drivers/dri/nouveau/nouveau_fifo.h index 23325dcea53..956dd549dca 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.h @@ -48,14 +48,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define NV_FIFO_READ(reg) *(volatile u_int32_t *)(nmesa->fifo.mmio + (reg/4)) #define NV_FIFO_WRITE(reg,value) *(volatile u_int32_t *)(nmesa->fifo.mmio + (reg/4)) = value; -#define NV_FIFO_READ_GET() ((NV_FIFO_READ(NV03_FIFO_REGS_DMAGET) - nmesa->fifo.put_base) >> 2) +#define NV_FIFO_READ_GET() ((NV_FIFO_READ(NV03_FIFO_REGS_DMAGET) - nmesa->fifo.drm.put_base) >> 2) #define NV_FIFO_WRITE_PUT(val) do { \ if (NOUVEAU_RING_TRACE) {\ printf("FIRE_RING : 0x%08x\n", nmesa->fifo.current << 2); \ fflush(stdout); \ sleep(1); \ } \ - NV_FIFO_WRITE(NV03_FIFO_REGS_DMAPUT, ((val)<<2) + nmesa->fifo.put_base); \ + NV_FIFO_WRITE(NV03_FIFO_REGS_DMAPUT, ((val)<<2) + nmesa->fifo.drm.put_base); \ } while(0) /* @@ -110,20 +110,20 @@ nouveau_fifo_remaining-=sz; \ uint32_t* p=(uint32_t*)(ptr); \ int i; printf("OUT_RINGp: (size 0x%x dwords) (%s)\n",sz, __func__); for(i=0;ififo.current+i) << 2, *(p+i), *((float*)(p+i))); \ } \ - memcpy(nmesa->fifo.buffer+nmesa->fifo.current,ptr,(sz)*4); \ + memcpy(nmesa->fifo.pushbuf+nmesa->fifo.current,ptr,(sz)*4); \ nmesa->fifo.current+=(sz); \ }while(0) #define OUT_RING(n) do { \ if (NOUVEAU_RING_TRACE) \ printf("OUT_RINGn: [0x%08x] 0x%08x (%s)\n", nmesa->fifo.current << 2, n, __func__); \ -nmesa->fifo.buffer[nmesa->fifo.current++]=(n); \ +nmesa->fifo.pushbuf[nmesa->fifo.current++]=(n); \ }while(0) #define OUT_RINGf(n) do { \ if (NOUVEAU_RING_TRACE) \ printf("OUT_RINGf: [0x%08x] %.04f (%s)\n", nmesa->fifo.current << 2, n, __func__); \ -*((float*)(nmesa->fifo.buffer+nmesa->fifo.current++))=(n); \ +*((float*)(nmesa->fifo.pushbuf+nmesa->fifo.current++))=(n); \ }while(0) #define BEGIN_RING_SIZE(subchannel,tag,size) do { \ diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index f6ff37848af..aff6954f066 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -10,7 +10,7 @@ GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa, struct drm_nouveau_grobj_alloc cto; int ret; - cto.channel = nmesa->fifo.channel; + cto.channel = nmesa->fifo.drm.channel; cto.handle = handle; cto.class = class; ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_GROBJ_ALLOC, diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c index e7abdd60eeb..2ca038f4f8e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c @@ -37,7 +37,8 @@ #define NOTIFIER(__v) \ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \ - volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset + volatile uint32_t *__v = (void*)nmesa->fifo.notifier_block + \ + notifier->offset struct drm_nouveau_notifierobj_alloc * nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) @@ -53,7 +54,7 @@ nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count) if (!notifier) return NULL; - notifier->channel = nmesa->fifo.channel; + notifier->channel = nmesa->fifo.drm.channel; notifier->handle = handle; notifier->count = count; ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIEROBJ_ALLOC, -- cgit v1.2.3 From c2ac825e67f0c2da4385eadb3e01eeb295ccc8a2 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 15 Aug 2007 14:27:46 +1000 Subject: nouveau: Use half the notifier block for query objects. --- src/mesa/drivers/dri/nouveau/nouveau_query.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_query.c b/src/mesa/drivers/dri/nouveau/nouveau_query.c index 01541400690..e5c1750a8ec 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_query.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_query.c @@ -167,7 +167,8 @@ nouveauQueryInitFuncs(GLcontext *ctx) if (nmesa->screen->card->type < NV_20) return; - nmesa->query_object_max = (0x4000 / 32); + /* Reserve half the notifier block for use as query objects */ + nmesa->query_object_max = (nmesa->fifo.drm.notifier_size / 2) / 32; nmesa->queryNotifier = nouveau_notifier_new(ctx, NvQueryNotify, nmesa->query_object_max); -- cgit v1.2.3 From ab999608582534bb5187a786b2ea437167f2d8a4 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 15 Aug 2007 13:28:00 +0800 Subject: i965: use BRW_TEXCOORDMODE_CLAMP instead of BRW_TEXCOORDMODE_CLAMP_BORDER to implement GL_CLAMP --- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 93d4cfc3a5f..83a4b02e483 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -54,7 +54,7 @@ static GLuint translate_wrap_mode( GLenum wrap ) case GL_REPEAT: return BRW_TEXCOORDMODE_WRAP; case GL_CLAMP: - return BRW_TEXCOORDMODE_CLAMP_BORDER; /* conform likes it this way */ + return BRW_TEXCOORDMODE_CLAMP; case GL_CLAMP_TO_EDGE: return BRW_TEXCOORDMODE_CLAMP; /* conform likes it this way */ case GL_CLAMP_TO_BORDER: -- cgit v1.2.3 From a6d4dddb38e2342a6f80d7a241f23900b8b4c633 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 16 Aug 2007 02:41:03 +0200 Subject: suppress warning about ncon visuals (bug #6689) --- src/glx/x11/glxext.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index af3a5166dc6..8fe10338a80 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -672,8 +672,11 @@ filter_modes( __GLcontextModes ** server_modes, if ( do_delete && (m->visualID != 0) ) { do_delete = GL_FALSE; - fprintf(stderr, "libGL warning: 3D driver claims to not support " - "visual 0x%02x\n", m->visualID); + /* don't warn for this visual (Novell #247471 / X.Org #6689) */ + if (m->visualRating != GLX_NON_CONFORMANT_CONFIG) { + fprintf(stderr, "libGL warning: 3D driver claims to not " + "support visual 0x%02x\n", m->visualID); + } } if ( do_delete ) { -- cgit v1.2.3 From 2193c4de83acfc3268ccca7b54b00543307e0baa Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 16 Aug 2007 08:45:16 +0200 Subject: i915tex: Unreference texture buffers on context destruction. Not doing this could cause the buffers to leak under some circumstances. --- src/mesa/drivers/dri/i915tex/i830_vtbl.c | 10 ++++++++++ src/mesa/drivers/dri/i915tex/i915_vtbl.c | 10 ++++++++++ 2 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c index a3db6c0c0cd..b2a1ba0ce34 100644 --- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c @@ -524,6 +524,16 @@ i830_emit_state(struct intel_context *intel) static void i830_destroy_context(struct intel_context *intel) { + GLuint i; + struct i830_context *i830 = i830_context(&intel->ctx); + + for (i = 0; i < I830_TEX_UNITS; i++) { + if (i830->state.tex_buffer[i] != NULL) { + driBOUnReference(i830->state.tex_buffer[i]); + i830->state.tex_buffer[i] = NULL; + } + } + _tnl_free_vertices(&intel->ctx); } diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c index ff99721769e..1d651a40d75 100644 --- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c @@ -440,6 +440,16 @@ i915_emit_state(struct intel_context *intel) static void i915_destroy_context(struct intel_context *intel) { + GLuint i; + struct i915_context *i915 = i915_context(&intel->ctx); + + for (i = 0; i < I915_TEX_UNITS; i++) { + if (i915->state.tex_buffer[i] != NULL) { + driBOUnReference(i915->state.tex_buffer[i]); + i915->state.tex_buffer[i] = NULL; + } + } + _tnl_free_vertices(&intel->ctx); } -- cgit v1.2.3 From 145d762044f795bf9d68f28079cc5e5d3056920e Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 10:05:00 +0100 Subject: Bring over the texobj refcounting changes from mesa_7_0_branch --- src/mesa/main/attrib.c | 236 +++++++++++++++++++++++++++++++---------------- src/mesa/main/attrib.h | 20 ++-- src/mesa/main/context.c | 5 +- src/mesa/main/texobj.c | 20 +--- src/mesa/main/texstate.c | 46 +++++---- 5 files changed, 202 insertions(+), 125 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 36e438a53cc..52e3f22adcf 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -51,6 +51,36 @@ #include "math/m_xform.h" +/** + * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) + */ +struct texture_state +{ + struct gl_texture_attrib Texture; /**< The usual context state */ + + /** to save per texture object state (wrap modes, filters, etc): */ + struct gl_texture_object Saved1D[MAX_TEXTURE_UNITS]; + struct gl_texture_object Saved2D[MAX_TEXTURE_UNITS]; + struct gl_texture_object Saved3D[MAX_TEXTURE_UNITS]; + struct gl_texture_object SavedCube[MAX_TEXTURE_UNITS]; + struct gl_texture_object SavedRect[MAX_TEXTURE_UNITS]; + struct gl_texture_object Saved1DArray[MAX_TEXTURE_UNITS]; + struct gl_texture_object Saved2DArray[MAX_TEXTURE_UNITS]; + + /** + * To save references to texture objects (so they don't get accidentally + * deleted while saved in the attribute stack). + */ + struct gl_texture_object *SavedRef1D[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedRef2D[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedRef3D[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedRefCube[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedRefRect[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedRef1DArray[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedRef2DArray[MAX_TEXTURE_UNITS]; +}; + + /** * Allocate a new attribute state node. These nodes have a * "kind" value and a pointer to a struct of state data. @@ -339,47 +369,54 @@ _mesa_PushAttrib(GLbitfield mask) } if (mask & GL_TEXTURE_BIT) { - struct gl_texture_attrib *attr; + struct texture_state *texstate = CALLOC_STRUCT(texture_state); GLuint u; + if (!texstate) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); + goto end; + } + _mesa_lock_context_textures(ctx); - /* Bump the texture object reference counts so that they don't - * inadvertantly get deleted. + + /* copy/save the bulk of texture state here */ + _mesa_memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); + + /* Save references to the currently bound texture objects so they don't + * accidentally get deleted while referenced in the attribute stack. */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - ctx->Texture.Unit[u].Current1D->RefCount++; - ctx->Texture.Unit[u].Current2D->RefCount++; - ctx->Texture.Unit[u].Current3D->RefCount++; - ctx->Texture.Unit[u].CurrentCubeMap->RefCount++; - ctx->Texture.Unit[u].CurrentRect->RefCount++; - ctx->Texture.Unit[u].Current1DArray->RefCount++; - ctx->Texture.Unit[u].Current2DArray->RefCount++; + _mesa_reference_texobj(&texstate->SavedRef1D[u], ctx->Texture.Unit[u].Current1D); + _mesa_reference_texobj(&texstate->SavedRef2D[u], ctx->Texture.Unit[u].Current2D); + _mesa_reference_texobj(&texstate->SavedRef3D[u], ctx->Texture.Unit[u].Current3D); + _mesa_reference_texobj(&texstate->SavedRefCube[u], ctx->Texture.Unit[u].CurrentCubeMap); + _mesa_reference_texobj(&texstate->SavedRefRect[u], ctx->Texture.Unit[u].CurrentRect); + _mesa_reference_texobj(&texstate->SavedRef1DArray[u], ctx->Texture.Unit[u].Current1DArray); + _mesa_reference_texobj(&texstate->SavedRef2DArray[u], ctx->Texture.Unit[u].Current2DArray); } - attr = MALLOC_STRUCT( gl_texture_attrib ); - MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); - /* copy state of the currently bound texture objects */ + /* copy state/contents of the currently bound texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_copy_texture_object(&attr->Unit[u].Saved1D, - attr->Unit[u].Current1D); - _mesa_copy_texture_object(&attr->Unit[u].Saved2D, - attr->Unit[u].Current2D); - _mesa_copy_texture_object(&attr->Unit[u].Saved3D, - attr->Unit[u].Current3D); - _mesa_copy_texture_object(&attr->Unit[u].SavedCubeMap, - attr->Unit[u].CurrentCubeMap); - _mesa_copy_texture_object(&attr->Unit[u].SavedRect, - attr->Unit[u].CurrentRect); - _mesa_copy_texture_object(&attr->Unit[u].Saved1DArray, - attr->Unit[u].Current1DArray); - _mesa_copy_texture_object(&attr->Unit[u].Saved2DArray, - attr->Unit[u].Current2DArray); + _mesa_copy_texture_object(&texstate->Saved1D[u], + ctx->Texture.Unit[u].Current1D); + _mesa_copy_texture_object(&texstate->Saved2D[u], + ctx->Texture.Unit[u].Current2D); + _mesa_copy_texture_object(&texstate->Saved3D[u], + ctx->Texture.Unit[u].Current3D); + _mesa_copy_texture_object(&texstate->SavedCube[u], + ctx->Texture.Unit[u].CurrentCubeMap); + _mesa_copy_texture_object(&texstate->SavedRect[u], + ctx->Texture.Unit[u].CurrentRect); + _mesa_copy_texture_object(&texstate->Saved1DArray[u], + ctx->Texture.Unit[u].Current1DArray); + _mesa_copy_texture_object(&texstate->Saved2DArray[u], + ctx->Texture.Unit[u].Current2DArray); } _mesa_unlock_context_textures(ctx); newnode = new_attrib_node( GL_TEXTURE_BIT ); - newnode->data = attr; + newnode->data = texstate; newnode->next = head; head = newnode; } @@ -415,6 +452,7 @@ _mesa_PushAttrib(GLbitfield mask) head = newnode; } +end: ctx->AttribStack[ctx->AttribStackDepth] = head; ctx->AttribStackDepth++; } @@ -624,14 +662,19 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) } +/** + * Pop/restore texture attribute/group state. + */ static void -pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) +pop_texture_group(GLcontext *ctx, struct texture_state *texstate) { GLuint u; + _mesa_lock_context_textures(ctx); + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - const struct gl_texture_unit *unit = &texAttrib->Unit[u]; - GLuint i; + const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; + GLuint tgt; _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); _mesa_set_enable(ctx, GL_TEXTURE_1D, @@ -724,53 +767,56 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) 1 << unit->Combine.ScaleShiftA); } - /* Restore texture object state */ - for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { - GLenum target = 0; + /* Restore texture object state for each target */ + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { const struct gl_texture_object *obj = NULL; GLfloat bordColor[4]; + GLenum target; - switch (i) { - case 0: - target = GL_TEXTURE_1D; - obj = &unit->Saved1D; + switch (tgt) { + case TEXTURE_1D_INDEX: + obj = &texstate->Saved1D[u]; + ASSERT(obj->Target == GL_TEXTURE_1D); break; - case 1: - target = GL_TEXTURE_2D; - obj = &unit->Saved2D; + case TEXTURE_2D_INDEX: + obj = &texstate->Saved2D[u]; + ASSERT(obj->Target == GL_TEXTURE_2D); break; - case 2: - target = GL_TEXTURE_3D; - obj = &unit->Saved3D; + case TEXTURE_3D_INDEX: + obj = &texstate->Saved3D[u]; + ASSERT(obj->Target == GL_TEXTURE_3D); break; - case 3: + case TEXTURE_CUBE_INDEX: if (!ctx->Extensions.ARB_texture_cube_map) continue; - target = GL_TEXTURE_CUBE_MAP_ARB; - obj = &unit->SavedCubeMap; + obj = &texstate->SavedCube[u]; + ASSERT(obj->Target == GL_TEXTURE_CUBE_MAP_ARB); break; - case 4: + case TEXTURE_RECT_INDEX: if (!ctx->Extensions.NV_texture_rectangle) continue; - target = GL_TEXTURE_RECTANGLE_NV; - obj = &unit->SavedRect; + obj = &texstate->SavedRect[u]; + ASSERT(obj->Target == GL_TEXTURE_RECTANGLE_NV); break; - case 5: + case TEXTURE_1D_ARRAY_INDEX: if (!ctx->Extensions.MESA_texture_array) continue; - target = GL_TEXTURE_1D_ARRAY_EXT; - obj = &unit->Saved1DArray; + obj = &texstate->Saved1DArray[u]; + ASSERT(obj->Target == GL_TEXTURE_1D_ARRAY_EXT); break; - case 6: + case TEXTURE_2D_ARRAY_INDEX: if (!ctx->Extensions.MESA_texture_array) continue; - target = GL_TEXTURE_2D_ARRAY_EXT; - obj = &unit->Saved2DArray; + obj = &texstate->Saved2DArray[u]; + ASSERT(obj->Target == GL_TEXTURE_2D_ARRAY_EXT); break; default: - ; /* silence warnings */ + _mesa_problem(ctx, "bad texture index in pop_texture_group"); + continue; } + target = obj->Target; + _mesa_BindTexture(target, obj->Name); bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]); @@ -778,8 +824,8 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) bordColor[2] = CHAN_TO_FLOAT(obj->BorderColor[2]); bordColor[3] = CHAN_TO_FLOAT(obj->BorderColor[3]); - _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, bordColor); + _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, obj->WrapR); @@ -805,25 +851,21 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX, obj->ShadowAmbient); } - } - } - _mesa_ActiveTextureARB(GL_TEXTURE0_ARB - + texAttrib->CurrentUnit); - /* "un-bump" the texture object reference counts. We did that so they - * wouldn't inadvertantly get deleted while they were still referenced - * inside the attribute state stack. - */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - ctx->Texture.Unit[u].Current1D->RefCount--; - ctx->Texture.Unit[u].Current2D->RefCount--; - ctx->Texture.Unit[u].Current3D->RefCount--; - ctx->Texture.Unit[u].CurrentCubeMap->RefCount--; - ctx->Texture.Unit[u].CurrentRect->RefCount--; - ctx->Texture.Unit[u].Current1DArray->RefCount--; - ctx->Texture.Unit[u].Current2DArray->RefCount--; + /* remove saved references to the texture objects */ + _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL); + _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL); + _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef1DArray[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef2DArray[u], NULL); } + + _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); + + _mesa_unlock_context_textures(ctx); } @@ -1202,9 +1244,9 @@ _mesa_PopAttrib(void) case GL_TEXTURE_BIT: /* Take care of texture object reference counters */ { - const struct gl_texture_attrib *texture; - texture = (const struct gl_texture_attrib *) attr->data; - pop_texture_group(ctx, texture); + struct texture_state *texstate + = (struct texture_state *) attr->data; + pop_texture_group(ctx, texstate); ctx->NewState |= _NEW_TEXTURE; } break; @@ -1426,6 +1468,46 @@ _mesa_PopClientAttrib(void) } +/** + * Free any attribute state data that might be attached to the context. + */ +void +_mesa_free_attrib_data(GLcontext *ctx) +{ + while (ctx->AttribStackDepth > 0) { + struct gl_attrib_node *attr, *next; + + ctx->AttribStackDepth--; + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { + if (attr->kind == GL_TEXTURE_BIT) { + struct texture_state *texstate = (struct texture_state*)attr->data; + GLuint u; + /* clear references to the saved texture objects */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL); + _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL); + _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef1DArray[u], NULL); + _mesa_reference_texobj(&texstate->SavedRef2DArray[u], NULL); + } + } + else { + /* any other chunks of state that requires special handling? */ + } + + next = attr->next; + _mesa_free(attr->data); + _mesa_free(attr); + attr = next; + } + } +} + + void _mesa_init_attrib( GLcontext *ctx ) { /* Renderer and client attribute stacks */ diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h index 09d75196b23..2cf8fe69345 100644 --- a/src/mesa/main/attrib.h +++ b/src/mesa/main/attrib.h @@ -1,18 +1,8 @@ -/** - * \file attrib.h - * Attribute stacks. - * - * \if subset - * (No-op) - * - * \endif - */ - /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 7.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -32,8 +22,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - - #ifndef ATTRIB_H #define ATTRIB_H @@ -58,10 +46,14 @@ _mesa_PopClientAttrib( void ); extern void _mesa_init_attrib( GLcontext *ctx ); +extern void +_mesa_free_attrib_data( GLcontext *ctx ); + #else /** No-op */ #define _mesa_init_attrib( c ) ((void)0) +#define _mesa_free_attrib_data( c ) ((void)0) #endif diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 37a14d30042..f3141fe63e8 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -6,9 +6,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -1209,6 +1209,7 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_unreference_framebuffer(&ctx->DrawBuffer); _mesa_unreference_framebuffer(&ctx->ReadBuffer); + _mesa_free_attrib_data(ctx); _mesa_free_lighting_data( ctx ); _mesa_free_eval_data( ctx ); _mesa_free_texture_data( ctx ); diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index ea3328a047e..3e017c1eda1 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -152,10 +152,6 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) { GLuint i, face; - /* - printf("TEX DELETE %p (%u)\n", (void*) texObj, texObj->Name); - */ - (void) ctx; /* Set Target to an invalid value. With some assertions elsewhere @@ -195,6 +191,7 @@ void _mesa_copy_texture_object( struct gl_texture_object *dest, const struct gl_texture_object *src ) { + dest->Target = src->Target; dest->Name = src->Name; dest->Priority = src->Priority; dest->BorderColor[0] = src->BorderColor[0]; @@ -278,10 +275,7 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, _glthread_LOCK_MUTEX(oldTex->Mutex); ASSERT(oldTex->RefCount > 0); oldTex->RefCount--; - /* - printf("TEX DECR %p (%u) to %d\n", - (void*) oldTex, oldTex->Name, oldTex->RefCount); - */ + deleteFlag = (oldTex->RefCount == 0); _glthread_UNLOCK_MUTEX(oldTex->Mutex); @@ -309,10 +303,6 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, } else { tex->RefCount++; - /* - printf("TEX INCR %p (%u) to %d\n", - (void*) tex, tex->Name, tex->RefCount); - */ *ptr = tex; } _glthread_UNLOCK_MUTEX(tex->Mutex); @@ -805,7 +795,7 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - /* Unrefernce the texobj. If refcount hits zero, the texture + /* Unreference the texobj. If refcount hits zero, the texture * will be deleted. */ _mesa_reference_texobj(&delObj, NULL); diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 08d083d201b..91ee6513dcf 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -119,20 +119,20 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) /* copy texture object bindings, not contents of texture objects */ _mesa_lock_context_textures(dst); - _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D, - src->Texture.Unit[i].Current1D); - _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D, - src->Texture.Unit[i].Current2D); - _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D, - src->Texture.Unit[i].Current3D); - _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap, - src->Texture.Unit[i].CurrentCubeMap); - _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect, - src->Texture.Unit[i].CurrentRect); - _mesa_reference_texobj(&dst->Texture.Unit[i].Current1DArray, - src->Texture.Unit[i].Current1DArray); - _mesa_reference_texobj(&dst->Texture.Unit[i].Current2DArray, - src->Texture.Unit[i].Current2DArray); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D, + src->Texture.Unit[i].Current1D); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D, + src->Texture.Unit[i].Current2D); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D, + src->Texture.Unit[i].Current3D); + _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap, + src->Texture.Unit[i].CurrentCubeMap); + _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect, + src->Texture.Unit[i].CurrentRect); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current1DArray, + src->Texture.Unit[i].Current1DArray); + _mesa_reference_texobj(&dst->Texture.Unit[i].Current2DArray, + src->Texture.Unit[i].Current2DArray); _mesa_unlock_context_textures(dst); } @@ -3201,7 +3201,19 @@ _mesa_init_texture(GLcontext *ctx) void _mesa_free_texture_data(GLcontext *ctx) { - GLuint i; + GLuint u; + + /* unreference current textures */ + for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { + struct gl_texture_unit *unit = ctx->Texture.Unit + u; + _mesa_reference_texobj(&unit->Current1D, NULL); + _mesa_reference_texobj(&unit->Current2D, NULL); + _mesa_reference_texobj(&unit->Current3D, NULL); + _mesa_reference_texobj(&unit->CurrentCubeMap, NULL); + _mesa_reference_texobj(&unit->CurrentRect, NULL); + _mesa_reference_texobj(&unit->Current1DArray, NULL); + _mesa_reference_texobj(&unit->Current2DArray, NULL); + } /* Free proxy texture objects */ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D ); @@ -3212,8 +3224,8 @@ _mesa_free_texture_data(GLcontext *ctx) (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray ); (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray ); - for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++) - _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable ); + for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) + _mesa_free_colortable_data( &ctx->Texture.Unit[u].ColorTable ); _mesa_TexEnvProgramCacheDestroy( ctx ); } -- cgit v1.2.3 From b3e3e72e25247a48c4f154e2971eff48ecb9d9ef Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 10:27:24 +0100 Subject: remove old Saved1D/2D/etc fields --- src/mesa/main/mtypes.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 989d199a103..0f578c5616d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1536,17 +1536,6 @@ struct gl_texture_unit struct gl_texture_object *_Current; /**< Points to really enabled tex obj */ - /** These are used for glPush/PopAttrib */ - /*@{*/ - struct gl_texture_object Saved1D; - struct gl_texture_object Saved2D; - struct gl_texture_object Saved3D; - struct gl_texture_object SavedCubeMap; - struct gl_texture_object SavedRect; - struct gl_texture_object Saved1DArray; - struct gl_texture_object Saved2DArray; - /*@}*/ - /** GL_SGI_texture_color_table */ /*@{*/ struct gl_color_table ColorTable; -- cgit v1.2.3 From 0135ff512d25b221d1a4cf9a5d344420d4ad3341 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 10:28:23 +0100 Subject: replace separate 1D/2D/etc fields with an array indexed by texture target --- src/mesa/main/attrib.c | 128 ++++++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 52e3f22adcf..3199c9b426b 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -59,25 +59,13 @@ struct texture_state struct gl_texture_attrib Texture; /**< The usual context state */ /** to save per texture object state (wrap modes, filters, etc): */ - struct gl_texture_object Saved1D[MAX_TEXTURE_UNITS]; - struct gl_texture_object Saved2D[MAX_TEXTURE_UNITS]; - struct gl_texture_object Saved3D[MAX_TEXTURE_UNITS]; - struct gl_texture_object SavedCube[MAX_TEXTURE_UNITS]; - struct gl_texture_object SavedRect[MAX_TEXTURE_UNITS]; - struct gl_texture_object Saved1DArray[MAX_TEXTURE_UNITS]; - struct gl_texture_object Saved2DArray[MAX_TEXTURE_UNITS]; + struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; /** * To save references to texture objects (so they don't get accidentally * deleted while saved in the attribute stack). */ - struct gl_texture_object *SavedRef1D[MAX_TEXTURE_UNITS]; - struct gl_texture_object *SavedRef2D[MAX_TEXTURE_UNITS]; - struct gl_texture_object *SavedRef3D[MAX_TEXTURE_UNITS]; - struct gl_texture_object *SavedRefCube[MAX_TEXTURE_UNITS]; - struct gl_texture_object *SavedRefRect[MAX_TEXTURE_UNITS]; - struct gl_texture_object *SavedRef1DArray[MAX_TEXTURE_UNITS]; - struct gl_texture_object *SavedRef2DArray[MAX_TEXTURE_UNITS]; + struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; }; @@ -386,30 +374,37 @@ _mesa_PushAttrib(GLbitfield mask) * accidentally get deleted while referenced in the attribute stack. */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_reference_texobj(&texstate->SavedRef1D[u], ctx->Texture.Unit[u].Current1D); - _mesa_reference_texobj(&texstate->SavedRef2D[u], ctx->Texture.Unit[u].Current2D); - _mesa_reference_texobj(&texstate->SavedRef3D[u], ctx->Texture.Unit[u].Current3D); - _mesa_reference_texobj(&texstate->SavedRefCube[u], ctx->Texture.Unit[u].CurrentCubeMap); - _mesa_reference_texobj(&texstate->SavedRefRect[u], ctx->Texture.Unit[u].CurrentRect); - _mesa_reference_texobj(&texstate->SavedRef1DArray[u], ctx->Texture.Unit[u].Current1DArray); - _mesa_reference_texobj(&texstate->SavedRef2DArray[u], ctx->Texture.Unit[u].Current2DArray); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_INDEX], + ctx->Texture.Unit[u].Current1D); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_INDEX], + ctx->Texture.Unit[u].Current2D); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_3D_INDEX], + ctx->Texture.Unit[u].Current3D); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_CUBE_INDEX], + ctx->Texture.Unit[u].CurrentCubeMap); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_RECT_INDEX], + ctx->Texture.Unit[u].CurrentRect); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_ARRAY_INDEX], + ctx->Texture.Unit[u].Current1DArray); + _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_ARRAY_INDEX], + ctx->Texture.Unit[u].Current2DArray); } /* copy state/contents of the currently bound texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_copy_texture_object(&texstate->Saved1D[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_INDEX], ctx->Texture.Unit[u].Current1D); - _mesa_copy_texture_object(&texstate->Saved2D[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_INDEX], ctx->Texture.Unit[u].Current2D); - _mesa_copy_texture_object(&texstate->Saved3D[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_3D_INDEX], ctx->Texture.Unit[u].Current3D); - _mesa_copy_texture_object(&texstate->SavedCube[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_CUBE_INDEX], ctx->Texture.Unit[u].CurrentCubeMap); - _mesa_copy_texture_object(&texstate->SavedRect[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_RECT_INDEX], ctx->Texture.Unit[u].CurrentRect); - _mesa_copy_texture_object(&texstate->Saved1DArray[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_ARRAY_INDEX], ctx->Texture.Unit[u].Current1DArray); - _mesa_copy_texture_object(&texstate->Saved2DArray[u], + _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_ARRAY_INDEX], ctx->Texture.Unit[u].Current2DArray); } @@ -773,45 +768,22 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate) GLfloat bordColor[4]; GLenum target; - switch (tgt) { - case TEXTURE_1D_INDEX: - obj = &texstate->Saved1D[u]; - ASSERT(obj->Target == GL_TEXTURE_1D); - break; - case TEXTURE_2D_INDEX: - obj = &texstate->Saved2D[u]; - ASSERT(obj->Target == GL_TEXTURE_2D); - break; - case TEXTURE_3D_INDEX: - obj = &texstate->Saved3D[u]; - ASSERT(obj->Target == GL_TEXTURE_3D); - break; - case TEXTURE_CUBE_INDEX: - if (!ctx->Extensions.ARB_texture_cube_map) - continue; - obj = &texstate->SavedCube[u]; - ASSERT(obj->Target == GL_TEXTURE_CUBE_MAP_ARB); - break; - case TEXTURE_RECT_INDEX: - if (!ctx->Extensions.NV_texture_rectangle) - continue; - obj = &texstate->SavedRect[u]; - ASSERT(obj->Target == GL_TEXTURE_RECTANGLE_NV); - break; - case TEXTURE_1D_ARRAY_INDEX: - if (!ctx->Extensions.MESA_texture_array) - continue; - obj = &texstate->Saved1DArray[u]; - ASSERT(obj->Target == GL_TEXTURE_1D_ARRAY_EXT); - break; - case TEXTURE_2D_ARRAY_INDEX: - if (!ctx->Extensions.MESA_texture_array) - continue; - obj = &texstate->Saved2DArray[u]; - ASSERT(obj->Target == GL_TEXTURE_2D_ARRAY_EXT); - break; - default: - _mesa_problem(ctx, "bad texture index in pop_texture_group"); + obj = &texstate->SavedObj[u][tgt]; + + /* don't restore state for unsupported targets to prevent + * raising GL errors. + */ + if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB && + !ctx->Extensions.ARB_texture_cube_map) { + continue; + } + else if (obj->Target == GL_TEXTURE_RECTANGLE_NV && + !ctx->Extensions.NV_texture_rectangle) { + continue; + } + else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT || + obj->Target == GL_TEXTURE_2D_ARRAY_EXT) && + !ctx->Extensions.MESA_texture_array) { continue; } @@ -854,13 +826,9 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate) } /* remove saved references to the texture objects */ - _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL); - _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL); - _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef1DArray[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef2DArray[u], NULL); + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + } } _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); @@ -1483,16 +1451,12 @@ _mesa_free_attrib_data(GLcontext *ctx) while (attr) { if (attr->kind == GL_TEXTURE_BIT) { struct texture_state *texstate = (struct texture_state*)attr->data; - GLuint u; + GLuint u, tgt; /* clear references to the saved texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL); - _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL); - _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef1DArray[u], NULL); - _mesa_reference_texobj(&texstate->SavedRef2DArray[u], NULL); + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); + } } } else { -- cgit v1.2.3 From fe469007037d9d5cdbe1677d8ff7368b276e9e7c Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 11:06:13 +0100 Subject: Replace Proxy1D/2D/etc with ProxyTex[] indexed by TEXTURE_x_INDEX. Simplification in colortab.c too. --- src/mesa/drivers/dri/tdfx/tdfx_tex.c | 2 +- src/mesa/main/colortab.c | 306 +++++++++++------------------------ src/mesa/main/mtypes.h | 4 + src/mesa/main/teximage.c | 58 +++---- src/mesa/main/texstate.c | 81 ++++------ 5 files changed, 154 insertions(+), 297 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c index 89865d96379..64946385b6d 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c @@ -1822,7 +1822,7 @@ tdfxTestProxyTexImage(GLcontext *ctx, GLenum target, tdfxTexInfo *ti; int memNeeded; - tObj = ctx->Texture.Proxy2D; + tObj = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; if (!tObj->DriverData) tObj->DriverData = fxAllocTexObjData(fxMesa); ti = TDFX_TEXTURE_DATA(tObj); diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c index 610acba3068..97120398f9b 100644 --- a/src/mesa/main/colortab.c +++ b/src/mesa/main/colortab.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -30,6 +30,7 @@ #include "image.h" #include "macros.h" #include "state.h" +#include "teximage.h" /** @@ -305,49 +306,6 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */ switch (target) { - case GL_TEXTURE_1D: - texObj = texUnit->Current1D; - table = &texObj->Palette; - break; - case GL_TEXTURE_2D: - texObj = texUnit->Current2D; - table = &texObj->Palette; - break; - case GL_TEXTURE_3D: - texObj = texUnit->Current3D; - table = &texObj->Palette; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); - return; - } - texObj = texUnit->CurrentCubeMap; - table = &texObj->Palette; - break; - case GL_PROXY_TEXTURE_1D: - texObj = ctx->Texture.Proxy1D; - table = &texObj->Palette; - proxy = GL_TRUE; - break; - case GL_PROXY_TEXTURE_2D: - texObj = ctx->Texture.Proxy2D; - table = &texObj->Palette; - proxy = GL_TRUE; - break; - case GL_PROXY_TEXTURE_3D: - texObj = ctx->Texture.Proxy3D; - table = &texObj->Palette; - proxy = GL_TRUE; - break; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); - return; - } - texObj = ctx->Texture.ProxyCubeMap; - table = &texObj->Palette; - break; case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; @@ -396,8 +354,19 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, proxy = GL_TRUE; break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); - return; + /* try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj) { + table = &texobj->Palette; + proxy = _mesa_is_proxy_texture(target); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); + return; + } + } } assert(table); @@ -499,26 +468,6 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { - case GL_TEXTURE_1D: - texObj = texUnit->Current1D; - table = &texObj->Palette; - break; - case GL_TEXTURE_2D: - texObj = texUnit->Current2D; - table = &texObj->Palette; - break; - case GL_TEXTURE_3D: - texObj = texUnit->Current3D; - table = &texObj->Palette; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); - return; - } - texObj = texUnit->CurrentCubeMap; - table = &texObj->Palette; - break; case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; @@ -547,8 +496,15 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); - return; + /* try texture targets */ + texObj = _mesa_select_tex_object(ctx, texUnit, target); + if (texObj && !_mesa_is_proxy_texture(target)) { + table = &texObj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); + return; + } } assert(table); @@ -636,22 +592,6 @@ _mesa_GetColorTable( GLenum target, GLenum format, } switch (target) { - case GL_TEXTURE_1D: - table = &texUnit->Current1D->Palette; - break; - case GL_TEXTURE_2D: - table = &texUnit->Current2D->Palette; - break; - case GL_TEXTURE_3D: - table = &texUnit->Current3D->Palette; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); - return; - } - table = &texUnit->CurrentCubeMap->Palette; - break; case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; @@ -672,8 +612,18 @@ _mesa_GetColorTable( GLenum target, GLenum format, table = &ctx->ColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); - return; + /* try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj && !_mesa_is_proxy_texture(target)) { + table = &texobj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); + return; + } + } } ASSERT(table); @@ -781,65 +731,41 @@ _mesa_GetColorTable( GLenum target, GLenum format, void GLAPIENTRY _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) { + GLfloat *scale, *bias; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); switch (target) { - case GL_COLOR_TABLE_SGI: - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION], params); - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION], params); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); - return; - } - break; - case GL_TEXTURE_COLOR_TABLE_SGI: - if (!ctx->Extensions.SGI_texture_color_table) { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); - return; - } - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(ctx->Pixel.TextureColorTableScale, params); - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(ctx->Pixel.TextureColorTableBias, params); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); - return; - } - break; - case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION], params); - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION], params); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); - return; - } - break; - case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: - if (pname == GL_COLOR_TABLE_SCALE_SGI) { - COPY_4V(ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX], params); - } - else if (pname == GL_COLOR_TABLE_BIAS_SGI) { - COPY_4V(ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX], params); - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); - return; - } - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); - return; + case GL_COLOR_TABLE_SGI: + scale = ctx->Pixel.ColorTableScale[COLORTABLE_PRECONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_PRECONVOLUTION]; + break; + case GL_TEXTURE_COLOR_TABLE_SGI: + scale = ctx->Pixel.TextureColorTableScale; + bias = ctx->Pixel.TextureColorTableBias; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCONVOLUTION]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCONVOLUTION]; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + scale = ctx->Pixel.ColorTableScale[COLORTABLE_POSTCOLORMATRIX]; + bias = ctx->Pixel.ColorTableBias[COLORTABLE_POSTCOLORMATRIX]; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); + return; + } + + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + COPY_4V(scale, params); + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + COPY_4V(bias, params); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; } ctx->NewState |= _NEW_PIXEL; @@ -879,40 +805,6 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) ASSERT_OUTSIDE_BEGIN_END(ctx); switch (target) { - case GL_TEXTURE_1D: - table = &texUnit->Current1D->Palette; - break; - case GL_TEXTURE_2D: - table = &texUnit->Current2D->Palette; - break; - case GL_TEXTURE_3D: - table = &texUnit->Current3D->Palette; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetColorTableParameterfv(target)"); - return; - } - table = &texUnit->CurrentCubeMap->Palette; - break; - case GL_PROXY_TEXTURE_1D: - table = &ctx->Texture.Proxy1D->Palette; - break; - case GL_PROXY_TEXTURE_2D: - table = &ctx->Texture.Proxy2D->Palette; - break; - case GL_PROXY_TEXTURE_3D: - table = &ctx->Texture.Proxy3D->Palette; - break; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetColorTableParameterfv(target)"); - return; - } - table = &ctx->Texture.ProxyCubeMap->Palette; - break; case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; @@ -981,8 +873,19 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); - return; + /* try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj) { + table = &texobj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetColorTableParameterfv(target)"); + return; + } + } } assert(table); @@ -1029,40 +932,6 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) ASSERT_OUTSIDE_BEGIN_END(ctx); switch (target) { - case GL_TEXTURE_1D: - table = &texUnit->Current1D->Palette; - break; - case GL_TEXTURE_2D: - table = &texUnit->Current2D->Palette; - break; - case GL_TEXTURE_3D: - table = &texUnit->Current3D->Palette; - break; - case GL_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetColorTableParameteriv(target)"); - return; - } - table = &texUnit->CurrentCubeMap->Palette; - break; - case GL_PROXY_TEXTURE_1D: - table = &ctx->Texture.Proxy1D->Palette; - break; - case GL_PROXY_TEXTURE_2D: - table = &ctx->Texture.Proxy2D->Palette; - break; - case GL_PROXY_TEXTURE_3D: - table = &ctx->Texture.Proxy3D->Palette; - break; - case GL_PROXY_TEXTURE_CUBE_MAP_ARB: - if (!ctx->Extensions.ARB_texture_cube_map) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glGetColorTableParameteriv(target)"); - return; - } - table = &ctx->Texture.ProxyCubeMap->Palette; - break; case GL_SHARED_TEXTURE_PALETTE_EXT: table = &ctx->Texture.Palette; break; @@ -1161,8 +1030,19 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) table = &ctx->ProxyColorTable[COLORTABLE_POSTCOLORMATRIX]; break; default: - _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); - return; + /* Try texture targets */ + { + struct gl_texture_object *texobj + = _mesa_select_tex_object(ctx, texUnit, target); + if (texobj) { + table = &texobj->Palette; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetColorTableParameteriv(target)"); + return; + } + } } assert(table); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 0f578c5616d..a04815a021c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1576,6 +1576,7 @@ struct gl_texture_attrib struct gl_texture_unit Unit[MAX_TEXTURE_UNITS]; +#if 0 struct gl_texture_object *Proxy1D; struct gl_texture_object *Proxy2D; struct gl_texture_object *Proxy3D; @@ -1583,6 +1584,9 @@ struct gl_texture_attrib struct gl_texture_object *ProxyRect; struct gl_texture_object *Proxy1DArray; struct gl_texture_object *Proxy2DArray; +#else + struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; +#endif /** GL_EXT_shared_texture_palette */ GLboolean SharedPalette; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3420d8e2baf..56322f87af1 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -760,15 +760,15 @@ _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit, case GL_TEXTURE_1D: return texUnit->Current1D; case GL_PROXY_TEXTURE_1D: - return ctx->Texture.Proxy1D; + return ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; case GL_TEXTURE_2D: return texUnit->Current2D; case GL_PROXY_TEXTURE_2D: - return ctx->Texture.Proxy2D; + return ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; case GL_TEXTURE_3D: return texUnit->Current3D; case GL_PROXY_TEXTURE_3D: - return ctx->Texture.Proxy3D; + return ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: @@ -780,25 +780,25 @@ _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit, ? texUnit->CurrentCubeMap : NULL; case GL_PROXY_TEXTURE_CUBE_MAP_ARB: return ctx->Extensions.ARB_texture_cube_map - ? ctx->Texture.ProxyCubeMap : NULL; + ? ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX] : NULL; case GL_TEXTURE_RECTANGLE_NV: return ctx->Extensions.NV_texture_rectangle ? texUnit->CurrentRect : NULL; case GL_PROXY_TEXTURE_RECTANGLE_NV: return ctx->Extensions.NV_texture_rectangle - ? ctx->Texture.ProxyRect : NULL; + ? ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX] : NULL; case GL_TEXTURE_1D_ARRAY_EXT: return ctx->Extensions.MESA_texture_array ? texUnit->Current1DArray : NULL; case GL_PROXY_TEXTURE_1D_ARRAY_EXT: return ctx->Extensions.MESA_texture_array - ? ctx->Texture.Proxy1DArray : NULL; + ? ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX] : NULL; case GL_TEXTURE_2D_ARRAY_EXT: return ctx->Extensions.MESA_texture_array ? texUnit->Current2DArray : NULL; case GL_PROXY_TEXTURE_2D_ARRAY_EXT: return ctx->Extensions.MESA_texture_array - ? ctx->Texture.Proxy2DArray : NULL; + ? ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX] : NULL; default: _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); return NULL; @@ -924,106 +924,106 @@ _mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level) case GL_PROXY_TEXTURE_1D: if (level >= ctx->Const.MaxTextureLevels) return NULL; - texImage = ctx->Texture.Proxy1D->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.Proxy1D->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.Proxy1D; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_1D_INDEX]; } return texImage; case GL_PROXY_TEXTURE_2D: if (level >= ctx->Const.MaxTextureLevels) return NULL; - texImage = ctx->Texture.Proxy2D->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.Proxy2D->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.Proxy2D; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]; } return texImage; case GL_PROXY_TEXTURE_3D: if (level >= ctx->Const.Max3DTextureLevels) return NULL; - texImage = ctx->Texture.Proxy3D->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.Proxy3D->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.Proxy3D; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_3D_INDEX]; } return texImage; case GL_PROXY_TEXTURE_CUBE_MAP: if (level >= ctx->Const.MaxCubeTextureLevels) return NULL; - texImage = ctx->Texture.ProxyCubeMap->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.ProxyCubeMap->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.ProxyCubeMap; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_CUBE_INDEX]; } return texImage; case GL_PROXY_TEXTURE_RECTANGLE_NV: if (level > 0) return NULL; - texImage = ctx->Texture.ProxyRect->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.ProxyRect->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.ProxyRect; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_RECT_INDEX]; } return texImage; case GL_PROXY_TEXTURE_1D_ARRAY_EXT: if (level >= ctx->Const.MaxTextureLevels) return NULL; - texImage = ctx->Texture.Proxy1DArray->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.Proxy1DArray->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.Proxy1DArray; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_1D_ARRAY_INDEX]; } return texImage; case GL_PROXY_TEXTURE_2D_ARRAY_EXT: if (level >= ctx->Const.MaxTextureLevels) return NULL; - texImage = ctx->Texture.Proxy2DArray->Image[0][level]; + texImage = ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX]->Image[0][level]; if (!texImage) { texImage = ctx->Driver.NewTextureImage(ctx); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation"); return NULL; } - ctx->Texture.Proxy2DArray->Image[0][level] = texImage; + ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX]->Image[0][level] = texImage; /* Set the 'back' pointer */ - texImage->TexObject = ctx->Texture.Proxy2DArray; + texImage->TexObject = ctx->Texture.ProxyTex[TEXTURE_2D_ARRAY_INDEX]; } return texImage; default: @@ -2591,7 +2591,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, 1, border)) { /* when error, clear all proxy texture image parameters */ if (texImage) - clear_teximage_fields(ctx->Texture.Proxy2D->Image[0][level]); + clear_teximage_fields(ctx->Texture.ProxyTex[TEXTURE_2D_INDEX]->Image[0][level]); } else { /* no error, set the tex image parameters */ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 91ee6513dcf..020e3eef4c0 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -3060,54 +3060,32 @@ _mesa_update_texture( GLcontext *ctx, GLuint new_state ) static GLboolean alloc_proxy_textures( GLcontext *ctx ) { - ctx->Texture.Proxy1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D); - if (!ctx->Texture.Proxy1D) - goto cleanup; - - ctx->Texture.Proxy2D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_2D); - if (!ctx->Texture.Proxy2D) - goto cleanup; - - ctx->Texture.Proxy3D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_3D); - if (!ctx->Texture.Proxy3D) - goto cleanup; - - ctx->Texture.ProxyCubeMap = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_CUBE_MAP_ARB); - if (!ctx->Texture.ProxyCubeMap) - goto cleanup; - - ctx->Texture.ProxyRect = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_RECTANGLE_NV); - if (!ctx->Texture.ProxyRect) - goto cleanup; - - ctx->Texture.Proxy1DArray = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D_ARRAY_EXT); - if (!ctx->Texture.Proxy1DArray) - goto cleanup; - - ctx->Texture.Proxy2DArray = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_2D_ARRAY_EXT); - if (!ctx->Texture.Proxy2DArray) - goto cleanup; - - assert(ctx->Texture.Proxy1D->RefCount == 1); + static const GLenum targets[] = { + GL_TEXTURE_1D, + GL_TEXTURE_2D, + GL_TEXTURE_3D, + GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_RECTANGLE_NV, + GL_TEXTURE_1D_ARRAY_EXT, + GL_TEXTURE_2D_ARRAY_EXT + }; + GLint tgt; + + ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS); + + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + if (!(ctx->Texture.ProxyTex[tgt] + = ctx->Driver.NewTextureObject(ctx, 0, targets[tgt]))) { + /* out of memory, free what we did allocate */ + while (--tgt >= 0) { + ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); + } + return GL_FALSE; + } + } + assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */ return GL_TRUE; - - cleanup: - if (ctx->Texture.Proxy1D) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D); - if (ctx->Texture.Proxy2D) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D); - if (ctx->Texture.Proxy3D) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy3D); - if (ctx->Texture.ProxyCubeMap) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap); - if (ctx->Texture.ProxyRect) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect); - if (ctx->Texture.Proxy1DArray) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray); - if (ctx->Texture.Proxy2DArray) - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray); - return GL_FALSE; } @@ -3201,7 +3179,7 @@ _mesa_init_texture(GLcontext *ctx) void _mesa_free_texture_data(GLcontext *ctx) { - GLuint u; + GLuint u, tgt; /* unreference current textures */ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { @@ -3216,13 +3194,8 @@ _mesa_free_texture_data(GLcontext *ctx) } /* Free proxy texture objects */ - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D ); - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D ); - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy3D ); - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap ); - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect ); - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1DArray ); - (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2DArray ); + for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) + ctx->Driver.DeleteTexture(ctx, ctx->Texture.ProxyTex[tgt]); for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) _mesa_free_colortable_data( &ctx->Texture.Unit[u].ColorTable ); -- cgit v1.2.3 From 09867b53a9add9c1a392ad46f850d40d50bbc536 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 11:06:39 +0100 Subject: replace Proxy1D/2D/etc fields with ProxyTex[] array --- src/mesa/main/mtypes.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a04815a021c..1145f361b13 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1576,17 +1576,8 @@ struct gl_texture_attrib struct gl_texture_unit Unit[MAX_TEXTURE_UNITS]; -#if 0 - struct gl_texture_object *Proxy1D; - struct gl_texture_object *Proxy2D; - struct gl_texture_object *Proxy3D; - struct gl_texture_object *ProxyCubeMap; - struct gl_texture_object *ProxyRect; - struct gl_texture_object *Proxy1DArray; - struct gl_texture_object *Proxy2DArray; -#else + /** Proxy texture objects */ struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS]; -#endif /** GL_EXT_shared_texture_palette */ GLboolean SharedPalette; -- cgit v1.2.3 From c5a5d12743b4921ab9c01ee69fa6a06b6b4d716a Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 16:43:31 +0100 Subject: remove reference to ctx->Color.DrawBuffer --- src/mesa/swrast/s_span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index cfc65bee87f..bbde0025f45 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -873,7 +873,7 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span) #endif /* we have to wait until after occlusion to do this test */ - if (ctx->Color.DrawBuffer == GL_NONE || ctx->Color.IndexMask == 0) { + if (ctx->Color.IndexMask == 0) { /* write no pixels */ span->arrayMask = origArrayMask; return; -- cgit v1.2.3 From c033ccc36d08c669dcdfbfc1cf89e472e8211c5f Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 16:49:35 +0100 Subject: update comments, etc related to Read/DrawBuffer state --- src/mesa/main/buffers.c | 7 +++++-- src/mesa/main/framebuffer.c | 46 +++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 0e6ca8ea1c2..82dd059e4b2 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -479,9 +479,12 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, /* not really needed, will be set later */ fb->_NumColorDrawBuffers[output] = 0; - if (fb->Name == 0) - /* Set traditional state var */ + if (fb->Name == 0) { + /* Only set the per-context DrawBuffer state if we're currently + * drawing to a window system framebuffer. + */ ctx->Color.DrawBuffer[output] = buffer; + } } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 0a6de12fb85..72d85f6f892 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -138,7 +138,7 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual) /* save the visual */ fb->Visual = *visual; - /* Init glRead/DrawBuffer state */ + /* Init read/draw renderbuffer state */ if (visual->doubleBufferMode) { fb->ColorDrawBuffer[0] = GL_BACK; fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT; @@ -649,6 +649,22 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) } +/** + * Update a gl_framebuffer's derived state. + * + * Specifically, update these framebuffer fields: + * _ColorDrawBuffers + * _NumColorDrawBuffers + * _ColorReadBuffer + * _DepthBuffer + * _StencilBuffer + * + * If the framebuffer is user-created, make sure it's complete. + * + * The following functions (at least) can effect framebuffer state: + * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, + * glRenderbufferStorageEXT. + */ static void update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) { @@ -660,8 +676,11 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) _mesa_update_framebuffer_visual(fb); } - /* update_color_draw/read_buffers not needed for - read/draw only fb, but shouldn't hurt ??? */ + /* Strictly speaking, we don't need to update the draw-state + * if this FB is bound as ctx->ReadBuffer (and conversely, the + * read-state if this FB is bound as ctx->DrawBuffer), but no + * harm. + */ update_color_draw_buffers(ctx, fb); update_color_read_buffer(ctx, fb); _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH); @@ -670,28 +689,19 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) compute_depth_max(fb); } + /** * Update state related to the current draw/read framebuffers. - * Specifically, update these framebuffer fields: - * _ColorDrawBuffers - * _NumColorDrawBuffers - * _ColorReadBuffer - * _DepthBuffer - * _StencilBuffer - * If the current framebuffer is user-created, make sure it's complete. - * The following functions can effect this state: glReadBuffer, - * glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT, - * glRenderbufferStorageEXT. */ void _mesa_update_framebuffer(GLcontext *ctx) { - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_framebuffer *fbread = ctx->ReadBuffer; + struct gl_framebuffer *drawFb = ctx->DrawBuffer; + struct gl_framebuffer *readFb = ctx->ReadBuffer; - update_framebuffer(ctx, fb); - if (fbread != fb) - update_framebuffer(ctx, fbread); + update_framebuffer(ctx, drawFb); + if (readFb != drawFb) + update_framebuffer(ctx, readFb); } -- cgit v1.2.3 From 32d86eb28aedd01a03ceab746214a8db2a4cbbab Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 16 Aug 2007 18:52:48 +0100 Subject: Rework the GL_READ_BUFFER, GL_DRAW_BUFFER state repairs that Roland previously did. Basically, in update_framebuffer() (which should be called after an FBO is bound with MakeCurrent or BindFramebuffer) we check if the FBO is a window-system FBO. If it is, update the FBO's GL_READ/DRAW_BUFFER state according to the context state. Old code still in place but disabled with #if 0 / #endif. --- src/mesa/main/buffers.c | 86 ++++++++++++++++++++++++++++++++++++++++++--- src/mesa/main/buffers.h | 9 +++-- src/mesa/main/context.c | 7 ++++ src/mesa/main/fbobject.c | 21 ++++++++--- src/mesa/main/framebuffer.c | 26 ++++++++++---- 5 files changed, 131 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 82dd059e4b2..94b4be54d50 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -336,6 +336,20 @@ read_buffer_enum_to_index(GLenum buffer) * \sa _mesa_DrawBuffersARB * * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc. + * + * Note that the behaviour of this function depends on whether the + * current ctx->DrawBuffer is a window-system framebuffer (Name=0) or + * a user-created framebuffer object (Name!=0). + * In the former case, we update the per-context ctx->Color.DrawBuffer + * state var _and_ the FB's ColorDrawBuffer state. + * In the later case, we update the FB's ColorDrawBuffer state only. + * + * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the + * new FB is a window system FB, we need to re-update the FB's + * ColorDrawBuffer state to match the context. This is handled in + * _mesa_update_framebuffer(). + * + * See the GL_EXT_framebuffer_object spec for more info. */ void GLAPIENTRY _mesa_DrawBuffer(GLenum buffer) @@ -489,10 +503,12 @@ set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, /** - * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and - * other places (window fbo fixup) to set fbo (and the old ctx) fields. + * Helper function to set the GL_DRAW_BUFFER state in the context and + * current FBO. + * * All error checking will have been done prior to calling this function * so nothing should go wrong at this point. + * * \param ctx current context * \param n number of color outputs to set * \param buffers array[n] of colorbuffer names, like GL_LEFT. @@ -532,6 +548,7 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, } +#if 0 GLboolean _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) { @@ -563,13 +580,45 @@ _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) } if (fb->Name == 0) { + /* Only update the per-context GL_READ_BUFFER state if we're bound to + * a window-system framebuffer. + */ ctx->Pixel.ReadBuffer = buffer; } + + /* Set the FBO's GL_READ_BUFFER state */ fb->ColorReadBuffer = buffer; fb->_ColorReadBufferIndex = srcBuffer; return GL_TRUE; } +#endif + + +/** + * Like \sa _mesa_drawbuffers(), this is a helper function for setting + * GL_READ_BUFFER state in the context and current FBO. + * \param ctx the rendering context + * \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc. + * \param bufferIndex the numerical index corresponding to 'buffer' + */ +void +_mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex) +{ + struct gl_framebuffer *fb = ctx->ReadBuffer; + + if (fb->Name == 0) { + /* Only update the per-context READ_BUFFER state if we're bound to + * a window-system framebuffer. + */ + ctx->Pixel.ReadBuffer = buffer; + } + + fb->ColorReadBuffer = buffer; + fb->_ColorReadBufferIndex = bufferIndex; + + ctx->NewState |= _NEW_PIXEL; +} @@ -580,16 +629,43 @@ _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) void GLAPIENTRY _mesa_ReadBuffer(GLenum buffer) { + struct gl_framebuffer *fb; + GLbitfield supportedMask; + GLint srcBuffer; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - if (!_mesa_readbuffer_update_fields(ctx, buffer)) - return; + fb = ctx->ReadBuffer; - ctx->NewState |= _NEW_PIXEL; + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); + + if (fb->Name > 0 && buffer == GL_NONE) { + /* This is legal for user-created framebuffer objects */ + srcBuffer = -1; + } + else { + /* general case / window-system framebuffer */ + srcBuffer = read_buffer_enum_to_index(buffer); + if (srcBuffer == -1) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glReadBuffer(buffer=0x%x)", buffer); + return; + } + supportedMask = supported_buffer_bitmask(ctx, fb); + if (((1 << srcBuffer) & supportedMask) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glReadBuffer(buffer=0x%x)", buffer); + return; + } + } + + /* OK, all error checking has been completed now */ + + _mesa_readbuffer(ctx, buffer, srcBuffer); /* * Call device driver function. diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h index 208e7af2b93..e7228a6da6b 100644 --- a/src/mesa/main/buffers.h +++ b/src/mesa/main/buffers.h @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -56,8 +56,13 @@ extern void _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, const GLbitfield *destMask); +extern void +_mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex); + +#if 0 extern GLboolean _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer); +#endif extern void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index f3141fe63e8..9ee7b4bec72 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1530,6 +1530,7 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); +#if 000 /* fix up the fb fields - these will end up wrong otherwise if the DRIdrawable changes, and everything relies on them. This is a bit messy (same as needed in _mesa_BindFramebufferEXT) */ @@ -1539,12 +1540,18 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, buffers[i] = newCtx->Color.DrawBuffer[i]; } _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL); +#endif } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); +#if 00 _mesa_readbuffer_update_fields(newCtx, newCtx->Pixel.ReadBuffer); +#endif } + /* XXX only set this flag if we're really changing the draw/read + * framebuffer bindings. + */ newCtx->NewState |= _NEW_BUFFERS; #if 1 diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index fcb620b39d8..5cd18d02872 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -962,9 +962,11 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) } FLUSH_VERTICES(ctx, _NEW_BUFFERS); + if (ctx->Driver.Flush) { ctx->Driver.Flush(ctx); } + if (framebuffer) { /* Binding a user-created framebuffer object */ newFb = _mesa_lookup_framebuffer(ctx, framebuffer); @@ -998,34 +1000,43 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) * XXX check if re-binding same buffer and skip some of this code. */ +#if 000 /* for window-framebuffers, re-initialize the fbo values, as they could be wrong (makecurrent with a new drawable while still a fbo was bound will lead to default init fbo values). note that therefore the context ReadBuffer/DrawBuffer values are not valid while fbo's are bound!!! */ +#endif if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); +#if 000 if (!newFbread->Name) { _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer); } +#endif } if (bindDrawBuf) { /* check if old FB had any texture attachments */ check_end_texture_render(ctx, ctx->DrawBuffer); + /* check if time to delete this framebuffer */ _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); - if (!newFb->Name) { + + if (newFb->Name != 0) { + /* check if newly bound framebuffer has any texture attachments */ + check_begin_texture_render(ctx, newFb); + } + else { + /* XXX try to remove this: */ +#if 000 GLuint i; GLenum buffers[MAX_DRAW_BUFFERS]; for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) { buffers[i] = ctx->Color.DrawBuffer[i]; } _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL); - } - else { - /* check if newly bound framebuffer has any texture attachments */ - check_begin_texture_render(ctx, newFb); +#endif } } diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 72d85f6f892..3e36197d884 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -32,6 +32,7 @@ #include "glheader.h" #include "imports.h" +#include "buffers.h" #include "context.h" #include "depthstencil.h" #include "mtypes.h" @@ -583,7 +584,7 @@ _mesa_update_stencil_buffer(GLcontext *ctx, /** - * Update the list of color drawing renderbuffer pointers. + * Update the (derived) list of color drawing renderbuffer pointers. * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers * writing colors. */ @@ -627,7 +628,7 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb) /** - * Update the color read renderbuffer pointer. + * Update the (derived) color read renderbuffer pointer. * Unlike the DrawBuffer, we can only read from one (or zero) color buffers. */ static void @@ -668,10 +669,23 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb) static void update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb) { - /* Completeness only matters for user-created framebuffers */ - if (fb->Name != 0) { - /* XXX: EXT_framebuffer_blit: - framebuffer must still be complete wrt read/draw? */ + if (fb->Name == 0) { + /* This is a window-system framebuffer */ + /* Need to update the FB's GL_DRAW_BUFFER state to match the + * context state (GL_READ_BUFFER too). + */ + if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { + _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, + ctx->Color.DrawBuffer, NULL); + } + if (fb->ColorReadBuffer != ctx->Pixel.ReadBuffer) { + + } + } + else { + /* This is a user-created framebuffer. + * Completeness only matters for user-created framebuffers. + */ _mesa_test_framebuffer_completeness(ctx, fb); _mesa_update_framebuffer_visual(fb); } -- cgit v1.2.3 From f5ed049655d214a8828d5ce68651741c3dff0c66 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 16 Aug 2007 20:53:29 +0200 Subject: nouveau: nv10: create objects needed to clear buffer --- src/mesa/drivers/dri/nouveau/nouveau_object.c | 33 +++++++++++++++++++++++++++ src/mesa/drivers/dri/nouveau/nouveau_object.h | 6 +++++ 2 files changed, 39 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index aff6954f066..4169530be67 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -43,6 +43,11 @@ void nouveauObjectInit(nouveauContextPtr nmesa) } else { nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT); } + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->typescreen->card->type>=NV_10) && (nmesa->screen->card->type Date: Thu, 16 Aug 2007 21:28:40 +0200 Subject: nouveau: store render buffer pointers in context, to access them when clearing buffer --- src/mesa/drivers/dri/nouveau/nouveau_context.h | 4 ++++ src/mesa/drivers/dri/nouveau/nv10_state.c | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index dc904ad6b35..65ecf21cab8 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -123,6 +123,10 @@ typedef struct nouveau_context { struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; GLuint vertex_attr_count; + /* Color and depth renderbuffers */ + nouveau_renderbuffer_t *color_buffer[2]; + nouveau_renderbuffer_t *depth_buffer; + /* Color buffer clear value */ uint32_t clear_color_value; diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 0e1637015fd..2183fc1577c 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -715,6 +715,11 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, GLuint x, y, w, h; GLuint pitch, format, depth_pitch; + /* Store buffer pointers in context */ + nmesa->color_buffer[0] = color[0]; + nmesa->color_buffer[1] = color[1]; + nmesa->depth_buffer = depth; + w = color[0]->mesa.Width; h = color[0]->mesa.Height; x = nmesa->drawX; -- cgit v1.2.3 From a60695ebafcdf048ce13d5195e74f8b7d1fff8d8 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 16 Aug 2007 21:31:30 +0200 Subject: nouveau: nv10: add function to clear a buffer --- src/mesa/drivers/dri/nouveau/nv10_state.c | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 2183fc1577c..0c746325c6f 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -111,11 +111,41 @@ static void nv10BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfac OUT_RING_CACHE(dfactorRGB); } -static void nv10Clear(GLcontext *ctx, GLbitfield mask) +static void nv10ClearBuffer(GLcontext *ctx, nouveau_renderbuffer_t *buffer, int fill, int mask) { + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + + if (!buffer) { + return; + } + /* TODO */ } +static void nv10Clear(GLcontext *ctx, GLbitfield mask) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + + if (mask & (BUFFER_BIT_FRONT_LEFT)) { + nv10ClearBuffer(ctx, nmesa->color_buffer[0], + nmesa->clear_color_value, 0xffffffff); + } + if (mask & (BUFFER_BIT_BACK_LEFT)) { + nv10ClearBuffer(ctx, nmesa->color_buffer[1], + nmesa->clear_color_value, 0xffffffff); + } + /* FIXME: check depth bits */ + if (mask & (BUFFER_BIT_DEPTH)) { + nv10ClearBuffer(ctx, nmesa->depth_buffer, + nmesa->clear_value, 0xffffff00); + } + /* FIXME: check about stencil? */ + if (mask & (BUFFER_BIT_STENCIL)) { + nv10ClearBuffer(ctx, nmesa->depth_buffer, + nmesa->clear_value, 0x000000ff); + } +} + static void nv10ClearColor(GLcontext *ctx, const GLfloat color[4]) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); -- cgit v1.2.3 From b902a223c461c804cee5cabd6440a934835803bd Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 16 Aug 2007 21:50:34 +0200 Subject: nouveau: nv10: clear a buffer --- src/mesa/drivers/dri/nouveau/nv10_state.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 0c746325c6f..4a3646ea4f1 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -114,12 +114,35 @@ static void nv10BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfac static void nv10ClearBuffer(GLcontext *ctx, nouveau_renderbuffer_t *buffer, int fill, int mask) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + int dimensions; if (!buffer) { return; } - /* TODO */ + /* Surface that we will work on */ + nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf2D, NvCtxSurf2D); + + BEGIN_RING_SIZE(NvSubCtxSurf2D, NV10_CONTEXT_SURFACES_2D_FORMAT, 4); + OUT_RING(0x0b); /* Y32 color format */ + OUT_RING((buffer->pitch<<16)|buffer->pitch); + OUT_RING(buffer->offset); + OUT_RING(buffer->offset); + + /* Now clear a rectangle */ + dimensions = ((buffer->mesa.Height)<<16) | (buffer->mesa.Width); + + nouveauObjectOnSubchannel(nmesa, NvSubGdiRectText, NvGdiRectText); + + BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1); + OUT_RING(3); /* SRCCOPY */ + + BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL1_TL, 5); + OUT_RING(0); /* top left */ + OUT_RING(dimensions); /* bottom right */ + OUT_RING(fill); + OUT_RING(0); /* top left */ + OUT_RING(dimensions); /* bottom right */ } static void nv10Clear(GLcontext *ctx, GLbitfield mask) -- cgit v1.2.3 From 00b86ecf6f2f936bad6d628622ea5546c780ab8d Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 17 Aug 2007 12:42:52 -0400 Subject: i965: align width/height for volume texture --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 46 +++++++++++++++++++-------- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 1 + 2 files changed, 34 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index af1ad0f1ef1..2094a1c8ad7 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -37,6 +37,7 @@ #include "intel_tex_layout.h" #include "macros.h" +#define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1)) GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt ) { @@ -53,11 +54,20 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt ) GLuint pack_x_pitch, pack_x_nr; GLuint pack_y_pitch; GLuint level; + GLuint align_h = 2; + GLuint align_w = 4; - mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; mt->total_height = 0; + + if (mt->compressed) { + align_w = intel_compressed_alignment(mt->internal_format); + mt->pitch = ALIGN(width, align_w); + pack_y_pitch = (height + 3) / 4; + } else { + mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp; + pack_y_pitch = ALIGN(mt->height0, align_h); + } - pack_y_pitch = MAX2(mt->height0, 2); pack_x_pitch = mt->pitch; pack_x_nr = 1; @@ -83,20 +93,30 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt ) mt->total_height += y; - - if (pack_x_pitch > 4) { - pack_x_pitch >>= 1; - pack_x_nr <<= 1; - assert(pack_x_pitch * pack_x_nr <= mt->pitch); - } - - if (pack_y_pitch > 2) { - pack_y_pitch >>= 1; - } - width = minify(width); height = minify(height); depth = minify(depth); + + if (mt->compressed) { + pack_y_pitch = (height + 3) / 4; + + if (pack_x_pitch > ALIGN(width, align_w)) { + pack_x_pitch = ALIGN(width, align_w); + pack_x_nr <<= 1; + } + } else { + if (pack_x_pitch > 4) { + pack_x_pitch >>= 1; + pack_x_nr <<= 1; + assert(pack_x_pitch * pack_x_nr <= mt->pitch); + } + + if (pack_y_pitch > 2) { + pack_y_pitch >>= 1; + pack_y_pitch = ALIGN(pack_y_pitch, align_h); + } + } + } break; } diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index f24f2346822..0fb33e27f47 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -233,6 +233,7 @@ GLboolean intel_miptree_image_data(struct intel_context *intel, if (dst->compressed) { alignment = intel_compressed_alignment(dst->internal_format); + src_row_pitch = ((src_row_pitch + alignment - 1) & ~(alignment - 1)); width = ((width + alignment - 1) & ~(alignment - 1)); height = (height + 3) / 4; } -- cgit v1.2.3 From dcfdb63b9fde8134562cb3a4e779a36e0abb4ae5 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 17 Aug 2007 13:36:13 -0400 Subject: Brian's fix for bug9829 --- src/mesa/main/texenvprogram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 72b54b27d9a..9c84da985e0 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -38,7 +38,7 @@ * According to Glean's texCombine test, no more than 21 instructions * are needed. Allow a few extra just in case. */ -#define MAX_INSTRUCTIONS 24 +#define MAX_INSTRUCTIONS ((MAX_TEXTURE_UNITS * 6) + 10) /* see bug 9829 */ #define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM) -- cgit v1.2.3 From 95e84a09ce3f35f59465be28026e83c1bc40ae8a Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 18 Aug 2007 16:10:25 +0100 Subject: remove dead code left over after fixing GL_READ/DRAW_BUFFER state issues --- src/mesa/main/buffers.c | 47 ----------------------------------------------- src/mesa/main/buffers.h | 5 ----- src/mesa/main/context.c | 14 -------------- src/mesa/main/fbobject.c | 23 ----------------------- 4 files changed, 89 deletions(-) (limited to 'src') diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 94b4be54d50..cbbe3e8698b 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -548,53 +548,6 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, } -#if 0 -GLboolean -_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer) -{ - struct gl_framebuffer *fb; - GLbitfield supportedMask; - GLint srcBuffer; - - fb = ctx->ReadBuffer; - - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer)); - - if (fb->Name > 0 && buffer == GL_NONE) { - /* This is legal for user-created framebuffer objects */ - srcBuffer = -1; - } - else { - /* general case / window-system framebuffer */ - srcBuffer = read_buffer_enum_to_index(buffer); - if (srcBuffer == -1) { - _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer=0x%x)", buffer); - return GL_FALSE; - } - supportedMask = supported_buffer_bitmask(ctx, fb); - if (((1 << srcBuffer) & supportedMask) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer=0x%x)", buffer); - return GL_FALSE; - } - } - - if (fb->Name == 0) { - /* Only update the per-context GL_READ_BUFFER state if we're bound to - * a window-system framebuffer. - */ - ctx->Pixel.ReadBuffer = buffer; - } - - /* Set the FBO's GL_READ_BUFFER state */ - fb->ColorReadBuffer = buffer; - fb->_ColorReadBufferIndex = srcBuffer; - - return GL_TRUE; -} -#endif - - /** * Like \sa _mesa_drawbuffers(), this is a helper function for setting * GL_READ_BUFFER state in the context and current FBO. diff --git a/src/mesa/main/buffers.h b/src/mesa/main/buffers.h index e7228a6da6b..9c0070e00f1 100644 --- a/src/mesa/main/buffers.h +++ b/src/mesa/main/buffers.h @@ -59,11 +59,6 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers, extern void _mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex); -#if 0 -extern GLboolean -_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer); -#endif - extern void GLAPIENTRY _mesa_ReadBuffer( GLenum mode ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 9ee7b4bec72..bb481093170 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1530,23 +1530,9 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, */ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->DrawBuffer, drawBuffer); -#if 000 - /* fix up the fb fields - these will end up wrong otherwise - if the DRIdrawable changes, and everything relies on them. - This is a bit messy (same as needed in _mesa_BindFramebufferEXT) */ - int i; - GLenum buffers[MAX_DRAW_BUFFERS]; - for(i = 0; i < newCtx->Const.MaxDrawBuffers; i++) { - buffers[i] = newCtx->Color.DrawBuffer[i]; - } - _mesa_drawbuffers(newCtx, newCtx->Const.MaxDrawBuffers, buffers, NULL); -#endif } if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) { _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer); -#if 00 - _mesa_readbuffer_update_fields(newCtx, newCtx->Pixel.ReadBuffer); -#endif } /* XXX only set this flag if we're really changing the draw/read diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 5cd18d02872..db04c785de4 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1000,20 +1000,8 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) * XXX check if re-binding same buffer and skip some of this code. */ -#if 000 - /* for window-framebuffers, re-initialize the fbo values, as they - could be wrong (makecurrent with a new drawable while still a fbo - was bound will lead to default init fbo values). - note that therefore the context ReadBuffer/DrawBuffer values are not - valid while fbo's are bound!!! */ -#endif if (bindReadBuf) { _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread); -#if 000 - if (!newFbread->Name) { - _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer); - } -#endif } if (bindDrawBuf) { @@ -1027,17 +1015,6 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) /* check if newly bound framebuffer has any texture attachments */ check_begin_texture_render(ctx, newFb); } - else { - /* XXX try to remove this: */ -#if 000 - GLuint i; - GLenum buffers[MAX_DRAW_BUFFERS]; - for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) { - buffers[i] = ctx->Color.DrawBuffer[i]; - } - _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL); -#endif - } } if (ctx->Driver.BindFramebuffer) { -- cgit v1.2.3 From 53cf87be1b93c760228e6a9af8115d2a9ff99337 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 18 Aug 2007 16:25:16 +0100 Subject: some fixes for compressed cube maps (bug 11986) --- src/mesa/main/mipmap.c | 7 ++++--- src/mesa/main/teximage.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 9f3db22b75c..a9260c847b0 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.2 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -957,7 +957,8 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, GLint components, size; GLchan *dst; - assert(texObj->Target == GL_TEXTURE_2D); + assert(texObj->Target == GL_TEXTURE_2D || + texObj->Target == GL_TEXTURE_CUBE_MAP_ARB); if (srcImage->_BaseFormat == GL_RGB) { convertFormat = &_mesa_texformat_rgb; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 56322f87af1..1bc52d220ab 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1998,7 +1998,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, } if (is_compressed_format(ctx, internalFormat)) { - if (target != GL_TEXTURE_2D) { + if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%d(target)", dimensions); return GL_TRUE; @@ -2181,7 +2181,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions, } if (teximage->IsCompressed) { - if (target != GL_TEXTURE_2D) { + if (!target_can_be_compressed(ctx, target)) { _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%d(target)", dimensions); return GL_TRUE; -- cgit v1.2.3 From ef71a0fd4536363e578c49a05b6f1161f907c150 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sun, 19 Aug 2007 20:12:26 +0200 Subject: nouveau: nv10: only one color buffer atm --- src/mesa/drivers/dri/nouveau/nouveau_context.h | 2 +- src/mesa/drivers/dri/nouveau/nv10_state.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 65ecf21cab8..778c4401e42 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -124,7 +124,7 @@ typedef struct nouveau_context { GLuint vertex_attr_count; /* Color and depth renderbuffers */ - nouveau_renderbuffer_t *color_buffer[2]; + nouveau_renderbuffer_t *color_buffer; nouveau_renderbuffer_t *depth_buffer; /* Color buffer clear value */ diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 4a3646ea4f1..0e48784084b 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -149,12 +149,8 @@ static void nv10Clear(GLcontext *ctx, GLbitfield mask) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - if (mask & (BUFFER_BIT_FRONT_LEFT)) { - nv10ClearBuffer(ctx, nmesa->color_buffer[0], - nmesa->clear_color_value, 0xffffffff); - } - if (mask & (BUFFER_BIT_BACK_LEFT)) { - nv10ClearBuffer(ctx, nmesa->color_buffer[1], + if (mask & (BUFFER_BIT_FRONT_LEFT|BUFFER_BIT_BACK_LEFT)) { + nv10ClearBuffer(ctx, nmesa->color_buffer, nmesa->clear_color_value, 0xffffffff); } /* FIXME: check depth bits */ @@ -769,8 +765,7 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, GLuint pitch, format, depth_pitch; /* Store buffer pointers in context */ - nmesa->color_buffer[0] = color[0]; - nmesa->color_buffer[1] = color[1]; + nmesa->color_buffer = color[0]; nmesa->depth_buffer = depth; w = color[0]->mesa.Width; -- cgit v1.2.3 From a3c3bc9ece7e7c55c8832dbc8c50ab1c34f5bfe9 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 20 Aug 2007 12:55:34 +0100 Subject: don't map buffer in _mesa_validate_DrawElements() unless needed --- src/mesa/main/api_validate.c | 51 +++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 18dead61c3a..ab8c3e19bac 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.0.1 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -35,7 +35,6 @@ _mesa_validate_DrawElements(GLcontext *ctx, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { - GLboolean mapped = GL_FALSE; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); if (count <= 0) { @@ -68,19 +67,14 @@ _mesa_validate_DrawElements(GLcontext *ctx, /* Vertex buffer object tests */ if (ctx->Array.ElementArrayBufferObj->Name) { GLuint indexBytes; - const GLvoid *map = ctx->Driver.MapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_READ_ONLY, - ctx->Array.ElementArrayBufferObj); /* use indices in the buffer object */ - if (!map) { - _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!"); + if (!ctx->Array.ElementArrayBufferObj->Size) { + _mesa_warning(ctx, + "glDrawElements called with empty array elements buffer"); return GL_FALSE; } - mapped = GL_TRUE; - /* make sure count doesn't go outside buffer bounds */ if (type == GL_UNSIGNED_INT) { indexBytes = count * sizeof(GLuint); @@ -93,19 +87,10 @@ _mesa_validate_DrawElements(GLcontext *ctx, indexBytes = count * sizeof(GLushort); } - if (ADD_POINTERS(map, indices) + indexBytes > - (GLubyte *)map + ctx->Array.ElementArrayBufferObj->Size) { + if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) { _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - ctx->Array.ElementArrayBufferObj); return GL_FALSE; } - - /* Actual address is the sum of pointers. Indices may be used below. */ - if (ctx->Const.CheckArrayBounds) { - indices = ADD_POINTERS(map, indices); - } } else { /* not using a VBO */ @@ -115,8 +100,18 @@ _mesa_validate_DrawElements(GLcontext *ctx, if (ctx->Const.CheckArrayBounds) { /* find max array index */ + const GLubyte *map; GLuint max = 0; GLint i; + + map = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, + ctx->Array.ElementArrayBufferObj); + + /* Actual address is the sum of pointers */ + indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); + if (type == GL_UNSIGNED_INT) { for (i = 0; i < count; i++) if (((GLuint *) indices)[i] > max) @@ -134,24 +129,16 @@ _mesa_validate_DrawElements(GLcontext *ctx, max = ((GLubyte *) indices)[i]; } + ctx->Driver.UnmapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); + if (max >= ctx->Array._MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ - if (mapped) { - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - ctx->Array.ElementArrayBufferObj); - } - return GL_FALSE; } } - if (mapped) { - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - ctx->Array.ElementArrayBufferObj); - } - return GL_TRUE; } -- cgit v1.2.3 From d8c6719f95b1543296ac954f95d13b048ae48634 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 20 Aug 2007 13:12:20 +0100 Subject: refactor bounds checking code --- src/mesa/main/api_validate.c | 148 +++++++++++++++++++++++-------------------- 1 file changed, 81 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index ab8c3e19bac..3e4fe46b1df 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -30,6 +30,55 @@ #include "state.h" +/** + * Find the max index in the given element/index buffer + */ +static GLuint +max_buffer_index(GLcontext *ctx, GLuint count, GLenum type, + const void *indices, + struct gl_buffer_object *elementBuf) +{ + const GLubyte *map = NULL; + GLuint max = 0; + GLint i; + + if (elementBuf->Name) { + /* elements are in a user-defined buffer object. need to map it */ + map = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, + elementBuf); + /* Actual address is the sum of pointers */ + indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); + } + + if (type == GL_UNSIGNED_INT) { + for (i = 0; i < count; i++) + if (((GLuint *) indices)[i] > max) + max = ((GLuint *) indices)[i]; + } + else if (type == GL_UNSIGNED_SHORT) { + for (i = 0; i < count; i++) + if (((GLushort *) indices)[i] > max) + max = ((GLushort *) indices)[i]; + } + else { + ASSERT(type == GL_UNSIGNED_BYTE); + for (i = 0; i < count; i++) + if (((GLubyte *) indices)[i] > max) + max = ((GLubyte *) indices)[i]; + } + + if (map) { + ctx->Driver.UnmapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Array.ElementArrayBufferObj); + } + + return max; +} + + GLboolean _mesa_validate_DrawElements(GLcontext *ctx, GLenum mode, GLsizei count, GLenum type, @@ -61,21 +110,15 @@ _mesa_validate_DrawElements(GLcontext *ctx, /* Always need vertex positions */ if (!ctx->Array.ArrayObj->Vertex.Enabled - && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) + && !(ctx->VertexProgram._Enabled + && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) return GL_FALSE; /* Vertex buffer object tests */ if (ctx->Array.ElementArrayBufferObj->Name) { - GLuint indexBytes; - /* use indices in the buffer object */ - if (!ctx->Array.ElementArrayBufferObj->Size) { - _mesa_warning(ctx, - "glDrawElements called with empty array elements buffer"); - return GL_FALSE; - } + GLuint indexBytes; - /* make sure count doesn't go outside buffer bounds */ if (type == GL_UNSIGNED_INT) { indexBytes = count * sizeof(GLuint); } @@ -87,6 +130,7 @@ _mesa_validate_DrawElements(GLcontext *ctx, indexBytes = count * sizeof(GLushort); } + /* make sure count doesn't go outside buffer bounds */ if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) { _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); return GL_FALSE; @@ -100,39 +144,8 @@ _mesa_validate_DrawElements(GLcontext *ctx, if (ctx->Const.CheckArrayBounds) { /* find max array index */ - const GLubyte *map; - GLuint max = 0; - GLint i; - - map = ctx->Driver.MapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_READ_ONLY, - ctx->Array.ElementArrayBufferObj); - - /* Actual address is the sum of pointers */ - indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); - - if (type == GL_UNSIGNED_INT) { - for (i = 0; i < count; i++) - if (((GLuint *) indices)[i] > max) - max = ((GLuint *) indices)[i]; - } - else if (type == GL_UNSIGNED_SHORT) { - for (i = 0; i < count; i++) - if (((GLushort *) indices)[i] > max) - max = ((GLushort *) indices)[i]; - } - else { - ASSERT(type == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) - if (((GLubyte *) indices)[i] > max) - max = ((GLubyte *) indices)[i]; - } - - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - ctx->Array.ElementArrayBufferObj); - + GLuint max = max_buffer_index(ctx, count, type, indices, + ctx->Array.ElementArrayBufferObj); if (max >= ctx->Array._MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ return GL_FALSE; @@ -179,41 +192,41 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, /* Always need vertex positions */ if (!ctx->Array.ArrayObj->Vertex.Enabled - && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) + && !(ctx->VertexProgram._Enabled + && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) return GL_FALSE; /* Vertex buffer object tests */ if (ctx->Array.ElementArrayBufferObj->Name) { - /* XXX re-use code from above? */ + /* use indices in the buffer object */ + GLuint indexBytes; + + if (type == GL_UNSIGNED_INT) { + indexBytes = count * sizeof(GLuint); + } + else if (type == GL_UNSIGNED_BYTE) { + indexBytes = count * sizeof(GLubyte); + } + else { + ASSERT(type == GL_UNSIGNED_SHORT); + indexBytes = count * sizeof(GLushort); + } + + /* make sure count doesn't go outside buffer bounds */ + if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) { + _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); + return GL_FALSE; + } } else { - /* not using VBO */ + /* not using a VBO */ if (!indices) return GL_FALSE; } if (ctx->Const.CheckArrayBounds) { - /* Find max array index. - * We don't trust the user's start and end values. - */ - GLuint max = 0; - GLint i; - if (type == GL_UNSIGNED_INT) { - for (i = 0; i < count; i++) - if (((GLuint *) indices)[i] > max) - max = ((GLuint *) indices)[i]; - } - else if (type == GL_UNSIGNED_SHORT) { - for (i = 0; i < count; i++) - if (((GLushort *) indices)[i] > max) - max = ((GLushort *) indices)[i]; - } - else { - ASSERT(type == GL_UNSIGNED_BYTE); - for (i = 0; i < count; i++) - if (((GLubyte *) indices)[i] > max) - max = ((GLubyte *) indices)[i]; - } + GLuint max = max_buffer_index(ctx, count, type, indices, + ctx->Array.ElementArrayBufferObj); if (max >= ctx->Array._MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ return GL_FALSE; @@ -248,7 +261,8 @@ _mesa_validate_DrawArrays(GLcontext *ctx, _mesa_update_state(ctx); /* Always need vertex positions */ - if (!ctx->Array.ArrayObj->Vertex.Enabled && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) + if (!ctx->Array.ArrayObj->Vertex.Enabled + && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) return GL_FALSE; if (ctx->Const.CheckArrayBounds) { -- cgit v1.2.3 From 07b7e97fb49585d18beaacc12063127501e5407b Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Mon, 20 Aug 2007 19:35:31 +0200 Subject: Use correct object for GART --- src/mesa/drivers/dri/nouveau/nv10_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 0e48784084b..62911d40f35 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -736,7 +736,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY0, 2); OUT_RING(NvDmaFB); /* 184 dma_in_memory0 */ - OUT_RING(NvDmaFB); /* 188 dma_in_memory1 */ + OUT_RING(NvDmaTT); /* 188 dma_in_memory1 */ BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY2, 2); OUT_RING(NvDmaFB); /* 194 dma_in_memory2 */ OUT_RING(NvDmaFB); /* 198 dma_in_memory3 */ -- cgit v1.2.3 From c6e729377cd1b1e7b5a1a22c40cee80b15a799f7 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Tue, 21 Aug 2007 16:52:10 +0200 Subject: nouveau: nv10: Remove commented, unsupported by hw command --- src/mesa/drivers/dri/nouveau/nv10_state.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 62911d40f35..8bfe20c6c00 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -790,13 +790,6 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, OUT_RING_CACHE(color[0]->offset); OUT_RING_CACHE(depth ? depth->offset : color[0]->offset); - /* Always set to bottom left of buffer */ - /*BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4); - OUT_RING_CACHEf (0.0); - OUT_RING_CACHEf ((GLfloat) h); - OUT_RING_CACHEf (0.0); - OUT_RING_CACHEf (0.0);*/ - return GL_TRUE; } -- cgit v1.2.3 From a6d35694c4570368f718f78bd85a21a626b7cdc9 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Tue, 21 Aug 2007 16:53:13 +0200 Subject: nouveau: Use proper notifier object --- src/mesa/drivers/dri/nouveau/nouveau_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index 4169530be67..83867574d32 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -73,12 +73,12 @@ void nouveauObjectInit(nouveauContextPtr nmesa) nouveauObjectOnSubchannel(nmesa, NvSubRasterOp, NvRasterOp); BEGIN_RING_SIZE(NvSubRasterOp, NV03_PRIMITIVE_RASTER_OP_DMA_NOTIFY, 1); - OUT_RING(NvDmaFB); + OUT_RING(NvSyncNotify); nouveauObjectOnSubchannel(nmesa, NvSubGdiRectText, NvGdiRectText); BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_SET_DMA_NOTIFY, 1); - OUT_RING(NvDmaFB); + OUT_RING(NvSyncNotify); BEGIN_RING_SIZE(NvSubGdiRectText, NV04_GDI_RECTANGLE_TEXT_PATTERN, 2); OUT_RING(NvPattern); OUT_RING(NvRasterOp); -- cgit v1.2.3 From 3d508a5d7bd67c915f9f9403570189d1a60ded5f Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Tue, 21 Aug 2007 16:55:42 +0200 Subject: nouveau: nv10: Move some initialization stuff --- src/mesa/drivers/dri/nouveau/nv10_state.c | 36 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 8bfe20c6c00..d246daea876 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -701,30 +701,17 @@ static void nv10WindowMoved(nouveauContextPtr nmesa) GLuint h = ctx->Viewport.Height; GLuint x = ctx->Viewport.X + nmesa->drawX; GLuint y = ctx->Viewport.Y + nmesa->drawY; - int i; BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2); OUT_RING_CACHE((w << 16) | x); OUT_RING_CACHE((h << 16) | y); - /* something to do with clears, possibly doesn't belong here */ - BEGIN_RING_SIZE(NvSub3D, 0x02b4, 1); - OUT_RING(0); - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1); OUT_RING_CACHE(((w+x-1) << 16) | x | 0x08000800); BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1); OUT_RING_CACHE(((h+y-1) << 16) | y | 0x08000800); - for (i=1; i<8; i++) { - BEGIN_RING_CACHE(NvSub3D, - NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 1); - OUT_RING_CACHE(0); - BEGIN_RING_CACHE(NvSub3D, - NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(i), 1); - OUT_RING_CACHE(0); - } nv10ViewportScale(nmesa); } @@ -732,6 +719,8 @@ static void nv10WindowMoved(nouveauContextPtr nmesa) /* Initialise any card-specific non-GL related state */ static GLboolean nv10InitCard(nouveauContextPtr nmesa) { + int i; + nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D); BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY0, 2); @@ -741,6 +730,27 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) OUT_RING(NvDmaFB); /* 194 dma_in_memory2 */ OUT_RING(NvDmaFB); /* 198 dma_in_memory3 */ + /* 0x0 viewport size */ + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2); + OUT_RING(0); + OUT_RING(0); + + /* Clipping regions */ + BEGIN_RING_SIZE(NvSub3D, + NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1); + OUT_RING(0x07ff0800); + BEGIN_RING_SIZE(NvSub3D, + NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1); + OUT_RING(0x07ff0800); + for (i=1; i<8; i++) { + BEGIN_RING_SIZE(NvSub3D, + NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 1); + OUT_RING(0); + BEGIN_RING_SIZE(NvSub3D, + NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(i), 1); + OUT_RING(0); + } + BEGIN_RING_SIZE(NvSub3D, 0x0290, 1); OUT_RING(0x00100001); BEGIN_RING_SIZE(NvSub3D, 0x03f4, 1); -- cgit v1.2.3 From 24746d0e3219b333fdbbb0026191fc735036ac8c Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 22 Aug 2007 10:28:13 +0200 Subject: nouveau: nv10: initialize more of nv10 tcl engine --- src/mesa/drivers/dri/nouveau/nv10_state.c | 102 ++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index d246daea876..1d2994e5105 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -720,6 +720,7 @@ static void nv10WindowMoved(nouveauContextPtr nmesa) static GLboolean nv10InitCard(nouveauContextPtr nmesa) { int i; + GLfloat projection[16]; nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D); @@ -736,6 +737,8 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) OUT_RING(0); /* Clipping regions */ + BEGIN_RING_SIZE(NvSub3D, 0x2b4, 1); /* clip_mode */ + OUT_RING (0); BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1); OUT_RING(0x07ff0800); @@ -761,8 +764,106 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) OUT_RING(0); OUT_RING(1); OUT_RING(2); + + BEGIN_RING_SIZE(NvSubImageBlit, 0x120, 3); + OUT_RING(0); + OUT_RING(1); + OUT_RING(2); } + /* Set state for stuff not initialized in nouveau_state.c */ + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_TX_ENABLE(0), 2); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_RC_IN_ALPHA(0), 12); + OUT_RING (0x30141010); + OUT_RING (0); + OUT_RING (0x20040000); + OUT_RING (0); + OUT_RING (0); + OUT_RING (0); + OUT_RING (0x00000c00); + OUT_RING (0); + OUT_RING (0x00000c00); + OUT_RING (0x18000000); + OUT_RING (0x300e0300); + OUT_RING (0x0c091c80); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_WEIGHT_ENABLE, 1); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE, 1); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_MODEL, 1); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_CONTROL, 1); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POINT_SIZE, 1); + OUT_RING (8); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POINT_PARAMETERS_ENABLE, 1); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LINE_WIDTH, 1); + OUT_RING (8); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(0), 8); + for (i=0;i<8;i++) { + OUT_RING (0); + } + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT, 3); + OUT_RINGf (-1.50); + OUT_RINGf (-0.09); + OUT_RINGf ( 0.00); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_FOG_MODE, 2); + OUT_RING (0x802); + OUT_RING (2); + + /* Projection matrix */ + memset(projection, 0, sizeof(projection)); + projection[0*4+0] = 1.0; + projection[1*4+1] = 1.0; + projection[2*4+2] = 1.0; + projection[3*4+3] = 1.0; + + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEW_MATRIX_ENABLE, 1); + OUT_RING (6); /* enable projection and modelview0 matrix */ + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); + for (i=0; i<16; i++) { + OUT_RINGf (projection[i]); + } + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2); + OUT_RINGf (0.0); + OUT_RINGf (1.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4); + OUT_RINGf (1.0); + OUT_RINGf (1.0); + OUT_RINGf (1.0); + OUT_RINGf (1.0); + + /* Set per-vertex component */ + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_COL_4F_R, 4); + OUT_RINGf (1.0); + OUT_RINGf (1.0); + OUT_RINGf (1.0); + OUT_RINGf (1.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_R, 3); + OUT_RING (0); + OUT_RING (0); + OUT_RING (0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_X, 3); + OUT_RINGf (0.0); + OUT_RINGf (0.0); + OUT_RINGf (1.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_S, 4); + OUT_RINGf (0.0); + OUT_RINGf (0.0); + OUT_RINGf (0.0); + OUT_RINGf (1.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_S, 4); + OUT_RINGf (0.0); + OUT_RINGf (0.0); + OUT_RINGf (0.0); + OUT_RINGf (1.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_FOG_1F, 1); + OUT_RINGf (0.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_EDGEFLAG_ENABLE, 1); + OUT_RING (1); + return GL_TRUE; } @@ -800,6 +901,7 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, OUT_RING_CACHE(color[0]->offset); OUT_RING_CACHE(depth ? depth->offset : color[0]->offset); + nv10ViewportScale(nmesa); return GL_TRUE; } -- cgit v1.2.3 From a3750c989b7330cc08942c9e0959ebfcdfcb9306 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 22 Aug 2007 11:01:59 +0200 Subject: nouveau: nv10: set projection matrix from viewport size --- src/mesa/drivers/dri/nouveau/nv10_state.c | 51 ++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 1d2994e5105..5d512b13c41 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -37,29 +37,43 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static void nv10ViewportScale(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; - GLuint w = ctx->Viewport.Width; - GLuint h = ctx->Viewport.Height; - + GLuint w = ((GLfloat) ctx->Viewport.Width) * 0.5; + GLuint h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; -/* if (ctx->DrawBuffer) { - switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { - case 16: - max_depth *= 32767.0; - break; - case 24: - max_depth *= 16777215.0; - break; - } - } else {*/ - /* Default to 24 bits range */ - max_depth *= 16777215.0; -/* }*/ + GLfloat projection[16]; + int i; + + if (!ctx->DrawBuffer) { + return; + } + if (!ctx->DrawBuffer->_DepthBuffer) { + return; + } + + switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { + case 16: + max_depth *= 32767.0; + break; + case 24: + max_depth *= 16777215.0; + break; + } BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4); - OUT_RING_CACHEf ((((GLfloat) w) * 0.5) - 2048.0); - OUT_RING_CACHEf ((((GLfloat) h) * 0.5) - 2048.0); + OUT_RING_CACHEf (w - 2048.0); + OUT_RING_CACHEf (h - 2048.0); OUT_RING_CACHEf (max_depth); OUT_RING_CACHEf (0.0); + + memset(projection, 0, sizeof(projection)); + projection[0*4+0] = w; + projection[1*4+1] = h; + projection[2*4+2] = max_depth; + projection[3*4+3] = 1.0; + BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); + for (i=0; i<16; i++) { + OUT_RING_CACHEf (projection[i]); + } } static void nv10AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) @@ -774,6 +788,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) /* Set state for stuff not initialized in nouveau_state.c */ BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_TX_ENABLE(0), 2); OUT_RING (0); + OUT_RING (0); BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_RC_IN_ALPHA(0), 12); OUT_RING (0x30141010); OUT_RING (0); -- cgit v1.2.3 From dbef6158c6c19a28dc96a96357c9ed9bd9422b88 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 23 Aug 2007 08:16:52 +0100 Subject: remove unneeded CallStack array --- src/mesa/main/dlist.c | 4 ---- src/mesa/main/mtypes.h | 1 - 2 files changed, 5 deletions(-) (limited to 'src') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index be2f438a941..5b9391096a0 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -5737,8 +5737,6 @@ execute_list(GLcontext *ctx, GLuint list) if (!dlist) return; - ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist; - if (ctx->Driver.BeginCallList) ctx->Driver.BeginCallList(ctx, dlist); @@ -6625,8 +6623,6 @@ execute_list(GLcontext *ctx, GLuint list) if (ctx->Driver.EndCallList) ctx->Driver.EndCallList(ctx); - - ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 1145f361b13..f5a8c970e48 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2866,7 +2866,6 @@ struct mesa_display_list */ struct gl_dlist_state { - struct mesa_display_list *CallStack[MAX_LIST_NESTING]; GLuint CallDepth; /**< Current recursion calling depth */ struct mesa_display_list *CurrentList; -- cgit v1.2.3 From 4b654d41da08b3b5475144c027e97a3ae7ab5696 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 23 Aug 2007 08:53:43 +0100 Subject: For _mesa_share_state(), update the context's references to the new share group's objects (Shane Blackett) --- src/mesa/drivers/windows/gdi/wgl.c | 4 +- src/mesa/drivers/windows/gdi/wmesa.c | 5 ++ src/mesa/main/bufferobj.c | 170 ++++++++++++++++++++--------------- src/mesa/main/bufferobj.h | 3 + src/mesa/main/context.c | 36 +++++++- src/mesa/main/texstate.c | 24 +++++ src/mesa/main/texstate.h | 3 + src/mesa/shader/program.c | 43 +++++++++ src/mesa/shader/program.h | 3 + 9 files changed, 214 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index dad3dc11604..17eed1dc329 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -601,8 +601,8 @@ WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc, WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, HGLRC hglrc2) { - (void) hglrc1; (void) hglrc2; - return(TRUE); + WMesaShareLists(hglrc1, hglrc2); + return(TRUE); } diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 5b67439f0f2..ea3f1780d3c 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -1401,6 +1401,11 @@ void WMesaSwapBuffers( HDC hdc ) } } +void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx) +{ + _mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx); +} + /* This is hopefully a temporary hack to define some needed dispatch * table entries. Hopefully, I'll find a better solution. The * dispatch table generation scripts ought to be making these dummy diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 009055a6ab6..9ad2dccc124 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -409,6 +409,101 @@ _mesa_init_buffer_objects( GLcontext *ctx ) ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj; } +/** + * Bind the specified target to buffer for the specified context. + */ +static void +bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer) +{ + struct gl_buffer_object *oldBufObj; + struct gl_buffer_object *newBufObj = NULL; + struct gl_buffer_object **bindTarget = NULL; + + switch (target) { + case GL_ARRAY_BUFFER_ARB: + bindTarget = &ctx->Array.ArrayBufferObj; + break; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + bindTarget = &ctx->Array.ElementArrayBufferObj; + break; + case GL_PIXEL_PACK_BUFFER_EXT: + bindTarget = &ctx->Pack.BufferObj; + break; + case GL_PIXEL_UNPACK_BUFFER_EXT: + bindTarget = &ctx->Unpack.BufferObj; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target)"); + return; + } + + /* Get pointer to old buffer object (to be unbound) */ + oldBufObj = get_buffer(ctx, target); + if (oldBufObj && oldBufObj->Name == buffer) + return; /* rebinding the same buffer object- no change */ + + /* + * Get pointer to new buffer object (newBufObj) + */ + if (buffer == 0) { + /* The spec says there's not a buffer object named 0, but we use + * one internally because it simplifies things. + */ + newBufObj = ctx->Array.NullBufferObj; + } + else { + /* non-default buffer object */ + newBufObj = _mesa_lookup_bufferobj(ctx, buffer); + if (!newBufObj) { + /* if this is a new buffer object id, allocate a buffer object now */ + ASSERT(ctx->Driver.NewBufferObject); + newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target); + if (!newBufObj) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); + return; + } + _mesa_save_buffer_object(ctx, newBufObj); + } + } + + /* Make new binding */ + *bindTarget = newBufObj; + newBufObj->RefCount++; + + /* Pass BindBuffer call to device driver */ + if (ctx->Driver.BindBuffer && newBufObj) + ctx->Driver.BindBuffer( ctx, target, newBufObj ); + + /* decr ref count on old buffer obj, delete if needed */ + if (oldBufObj) { + oldBufObj->RefCount--; + assert(oldBufObj->RefCount >= 0); + if (oldBufObj->RefCount == 0) { + assert(oldBufObj->Name != 0); + ASSERT(ctx->Driver.DeleteBuffer); + ctx->Driver.DeleteBuffer( ctx, oldBufObj ); + } + } +} + + +/** + * Update the default buffer objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_buffer_objects(GLcontext *ctx) +{ + /* Bind the NullBufferObj to remove references to those + * in the shared context hash table. + */ + bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0); + bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + bind_buffer_object( ctx, GL_PIXEL_PACK_BUFFER_ARB, 0); + bind_buffer_object( ctx, GL_PIXEL_UNPACK_BUFFER_ARB, 0); +} + /** * When we're about to read pixel data out of a PBO (via glDrawPixels, @@ -493,76 +588,9 @@ void GLAPIENTRY _mesa_BindBufferARB(GLenum target, GLuint buffer) { GET_CURRENT_CONTEXT(ctx); - struct gl_buffer_object *oldBufObj; - struct gl_buffer_object *newBufObj = NULL; - struct gl_buffer_object **bindTarget = NULL; ASSERT_OUTSIDE_BEGIN_END(ctx); - switch (target) { - case GL_ARRAY_BUFFER_ARB: - bindTarget = &ctx->Array.ArrayBufferObj; - break; - case GL_ELEMENT_ARRAY_BUFFER_ARB: - bindTarget = &ctx->Array.ElementArrayBufferObj; - break; - case GL_PIXEL_PACK_BUFFER_EXT: - bindTarget = &ctx->Pack.BufferObj; - break; - case GL_PIXEL_UNPACK_BUFFER_EXT: - bindTarget = &ctx->Unpack.BufferObj; - break; - default: - _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target)"); - return; - } - - /* Get pointer to old buffer object (to be unbound) */ - oldBufObj = get_buffer(ctx, target); - if (oldBufObj && oldBufObj->Name == buffer) - return; /* rebinding the same buffer object- no change */ - - /* - * Get pointer to new buffer object (newBufObj) - */ - if (buffer == 0) { - /* The spec says there's not a buffer object named 0, but we use - * one internally because it simplifies things. - */ - newBufObj = ctx->Array.NullBufferObj; - } - else { - /* non-default buffer object */ - newBufObj = _mesa_lookup_bufferobj(ctx, buffer); - if (!newBufObj) { - /* if this is a new buffer object id, allocate a buffer object now */ - ASSERT(ctx->Driver.NewBufferObject); - newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target); - if (!newBufObj) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB"); - return; - } - _mesa_save_buffer_object(ctx, newBufObj); - } - } - - /* Make new binding */ - *bindTarget = newBufObj; - newBufObj->RefCount++; - - /* Pass BindBuffer call to device driver */ - if (ctx->Driver.BindBuffer && newBufObj) - ctx->Driver.BindBuffer( ctx, target, newBufObj ); - - /* decr ref count on old buffer obj, delete if needed */ - if (oldBufObj) { - oldBufObj->RefCount--; - assert(oldBufObj->RefCount >= 0); - if (oldBufObj->RefCount == 0) { - assert(oldBufObj->Name != 0); - ASSERT(ctx->Driver.DeleteBuffer); - ctx->Driver.DeleteBuffer( ctx, oldBufObj ); - } - } + bind_buffer_object(ctx, target, buffer); } @@ -658,9 +686,9 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) _mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 ); } - /* The ID is immediately freed for re-use */ - _mesa_remove_buffer_object(ctx, bufObj); - _mesa_unbind_buffer_object(ctx, bufObj); + /* The ID is immediately freed for re-use */ + _mesa_remove_buffer_object(ctx, bufObj); + _mesa_unbind_buffer_object(ctx, bufObj); } } diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index f54f9e9ff00..1d2715da846 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -38,6 +38,9 @@ extern void _mesa_init_buffer_objects( GLcontext *ctx ); +extern void +_mesa_update_default_objects_buffer_objects(GLcontext *ctx); + extern struct gl_buffer_object * _mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target ); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index bb481093170..d988ef2d215 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -998,6 +998,28 @@ init_attrib_groups(GLcontext *ctx) } +/** + * Update default objects in a GL context with respect to shared state. + * + * \param ctx GL context. + * + * Removes references to old default objects, (texture objects, program + * objects, etc.) and changes to reference those from the current shared + * state. + */ +static GLboolean +update_default_objects(GLcontext *ctx) +{ + assert(ctx); + + _mesa_update_default_objects_program(ctx); + _mesa_update_default_objects_texture(ctx); + _mesa_update_default_objects_buffer_objects(ctx); + + return GL_TRUE; +} + + /** * This is the default function we plug into all dispatch table slots * This helps prevents a segfault when someone calls a GL function without @@ -1605,12 +1627,18 @@ GLboolean _mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare) { if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) { - ctx->Shared->RefCount--; - if (ctx->Shared->RefCount == 0) { - free_shared_state(ctx, ctx->Shared); - } + struct gl_shared_state *oldSharedState = ctx->Shared; + ctx->Shared = ctxToShare->Shared; ctx->Shared->RefCount++; + + update_default_objects(ctx); + + oldSharedState->RefCount--; + if (oldSharedState->RefCount == 0) { + free_shared_state(ctx, oldSharedState); + } + return GL_TRUE; } else { diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 020e3eef4c0..288b334eaf6 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -3202,3 +3202,27 @@ _mesa_free_texture_data(GLcontext *ctx) _mesa_TexEnvProgramCacheDestroy( ctx ); } + + +/** + * Update the default texture objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_texture(GLcontext *ctx) +{ + GLuint i; + + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + + _mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D); + _mesa_reference_texobj(&texUnit->Current2D, ctx->Shared->Default2D); + _mesa_reference_texobj(&texUnit->Current3D, ctx->Shared->Default3D); + _mesa_reference_texobj(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); + _mesa_reference_texobj(&texUnit->CurrentRect, ctx->Shared->DefaultRect); + _mesa_reference_texobj(&texUnit->Current1DArray, ctx->Shared->Default1DArray); + _mesa_reference_texobj(&texUnit->Current2DArray, ctx->Shared->Default2DArray); + } +} diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index 60145691b8c..b978654116e 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -148,6 +148,9 @@ _mesa_init_texture( GLcontext *ctx ); extern void _mesa_free_texture_data( GLcontext *ctx ); +extern void +_mesa_update_default_objects_texture(GLcontext *ctx); + /*@}*/ #endif diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 1f227390afd..2097c395918 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -118,6 +118,49 @@ _mesa_free_program_data(GLcontext *ctx) } +/** + * Update the default program objects in the given context to reference those + * specified in the shared state and release those referencing the old + * shared state. + */ +void +_mesa_update_default_objects_program(GLcontext *ctx) +{ +#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program + if (ctx->VertexProgram.Current) { + ctx->VertexProgram.Current->Base.RefCount--; + if (ctx->VertexProgram.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base)); + } + ctx->VertexProgram.Current = (struct gl_vertex_program *) ctx->Shared->DefaultVertexProgram; + assert(ctx->VertexProgram.Current); + ctx->VertexProgram.Current->Base.RefCount++; +#endif + +#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program + if (ctx->FragmentProgram.Current) { + ctx->FragmentProgram.Current->Base.RefCount--; + if (ctx->FragmentProgram.Current->Base.RefCount <= 0) + ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base)); + } + ctx->FragmentProgram.Current = (struct gl_fragment_program *) ctx->Shared->DefaultFragmentProgram; + assert(ctx->FragmentProgram.Current); + ctx->FragmentProgram.Current->Base.RefCount++; +#endif + + /* XXX probably move this stuff */ +#if FEATURE_ATI_fragment_shader + if (ctx->ATIFragmentShader.Current) { + ctx->ATIFragmentShader.Current->RefCount--; + if (ctx->ATIFragmentShader.Current->RefCount <= 0) { + _mesa_free(ctx->ATIFragmentShader.Current); + } + } + ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader; + assert(ctx->ATIFragmentShader.Current); + ctx->ATIFragmentShader.Current->RefCount++; +#endif +} /** diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 52704856ab0..ea2c8c30508 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -56,6 +56,9 @@ _mesa_init_program(GLcontext *ctx); extern void _mesa_free_program_data(GLcontext *ctx); +extern void +_mesa_update_default_objects_program(GLcontext *ctx); + extern void _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string); -- cgit v1.2.3 From f8e4cf716a3656faa08086ee80d04b36a5266d65 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 24 Aug 2007 08:43:58 +0100 Subject: remove CallDepth++/-- accidentally removed in prev commit --- src/mesa/main/dlist.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 5b9391096a0..b881b12ff35 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -5737,6 +5737,8 @@ execute_list(GLcontext *ctx, GLuint list) if (!dlist) return; + ctx->ListState.CallDepth++; + if (ctx->Driver.BeginCallList) ctx->Driver.BeginCallList(ctx, dlist); @@ -6623,6 +6625,8 @@ execute_list(GLcontext *ctx, GLuint list) if (ctx->Driver.EndCallList) ctx->Driver.EndCallList(ctx); + + ctx->ListState.CallDepth--; } -- cgit v1.2.3 From 1a911aad0a31b2d043a524e5d6f766fbb38142d7 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 25 Aug 2007 11:39:04 +0200 Subject: nouveau: nv10: properly set viewport and projection --- src/mesa/drivers/dri/nouveau/nv10_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 5d512b13c41..6d9ddd55d45 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -37,8 +37,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static void nv10ViewportScale(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; - GLuint w = ((GLfloat) ctx->Viewport.Width) * 0.5; - GLuint h = ((GLfloat) ctx->Viewport.Height) * 0.5; + GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; + GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; GLfloat projection[16]; int i; @@ -67,7 +67,7 @@ static void nv10ViewportScale(nouveauContextPtr nmesa) memset(projection, 0, sizeof(projection)); projection[0*4+0] = w; - projection[1*4+1] = h; + projection[1*4+1] = -h; projection[2*4+2] = max_depth; projection[3*4+3] = 1.0; BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); -- cgit v1.2.3 From 40ecc4a359fb587627fee44a13192a0c20b03b8e Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 25 Aug 2007 12:36:03 +0200 Subject: nouveau: nv10: add a scissor func, do not cache viewport settings --- src/mesa/drivers/dri/nouveau/nv10_state.c | 96 ++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 6d9ddd55d45..d3331ac9702 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -59,20 +59,21 @@ static void nv10ViewportScale(nouveauContextPtr nmesa) break; } - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4); - OUT_RING_CACHEf (w - 2048.0); - OUT_RING_CACHEf (h - 2048.0); - OUT_RING_CACHEf (max_depth); - OUT_RING_CACHEf (0.0); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4); + OUT_RINGf (w - 2048.0); + OUT_RINGf (h - 2048.0); + OUT_RINGf (max_depth); + OUT_RINGf (0.0); + /* FIXME: should multiply by gl projection and modelview ? */ memset(projection, 0, sizeof(projection)); projection[0*4+0] = w; projection[1*4+1] = -h; projection[2*4+2] = max_depth; projection[3*4+3] = 1.0; - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); for (i=0; i<16; i++) { - OUT_RING_CACHEf (projection[i]); + OUT_RINGf (projection[i]); } } @@ -637,9 +638,52 @@ void (*ReadBuffer)( GLcontext *ctx, GLenum buffer ); /** Set rasterization mode */ void (*RenderMode)(GLcontext *ctx, GLenum mode ); +/* Translate GL coords to window coords, clamping w/h to the + * dimensions of the window. + */ +static void nv10WindowCoords(nouveauContextPtr nmesa, + GLuint x, GLuint y, GLuint w, GLuint h, + GLuint *wX, GLuint *wY, GLuint *wW, GLuint *wH) +{ + if ((x+w) > nmesa->drawW) + w = nmesa->drawW - x; + (*wX) = x + nmesa->drawX; + (*wW) = w; + + if ((y+h) > nmesa->drawH) + h = nmesa->drawH - y; + (*wY) = (nmesa->drawH - y) - h + nmesa->drawY; + (*wH) = h; +} + /** Define the scissor box */ static void nv10Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + GLuint wX, wY, wW, wH; + + /* There's no scissor enable bit, so adjust the scissor to cover the + * maximum draw buffer bounds + */ + if (!ctx->Scissor.Enabled) { + wX = nmesa->drawX; + wY = nmesa->drawY; + wW = nmesa->drawW; + wH = nmesa->drawH; + } else { + nv10WindowCoords(nmesa, x, y, w, h, &wX, &wY, &wW, &wH); + } + + if (!wW || !wH) { + return; + } + + BEGIN_RING_SIZE(NvSub3D, + NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1); + OUT_RING(((wW+wX-1) << 16) | wX | 0x08000800); + BEGIN_RING_SIZE(NvSub3D, + NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1); + OUT_RING(((wH+wY-1) << 16) | wY | 0x08000800); } /** Select flat or smooth shading */ @@ -711,23 +755,20 @@ static void nv10WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; GLfloat *v = nmesa->viewport.m; - GLuint w = ctx->Viewport.Width; - GLuint h = ctx->Viewport.Height; - GLuint x = ctx->Viewport.X + nmesa->drawX; - GLuint y = ctx->Viewport.Y + nmesa->drawY; + GLuint wX, wY, wW, wH; - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2); - OUT_RING_CACHE((w << 16) | x); - OUT_RING_CACHE((h << 16) | y); + nv10WindowCoords(nmesa, ctx->Viewport.X, ctx->Viewport.Y, + ctx->Viewport.Width, ctx->Viewport.Height, + &wX, &wY, &wW, &wH); - BEGIN_RING_CACHE(NvSub3D, - NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1); - OUT_RING_CACHE(((w+x-1) << 16) | x | 0x08000800); - BEGIN_RING_CACHE(NvSub3D, - NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1); - OUT_RING_CACHE(((h+y-1) << 16) | y | 0x08000800); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2); + OUT_RING((wW << 16) | wX); + OUT_RING((wH << 16) | wY); nv10ViewportScale(nmesa); + + ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y, + ctx->Scissor.Width, ctx->Scissor.Height); } /* Initialise any card-specific non-GL related state */ @@ -902,21 +943,20 @@ static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color, if (num_color != 1) return GL_FALSE; - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 6); - OUT_RING_CACHE((w << 16) | x); - OUT_RING_CACHE((h << 16) | y); + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 6); + OUT_RING((w << 16) | x); + OUT_RING((h << 16) | y); depth_pitch = (depth ? depth->pitch : color[0]->pitch); pitch = (depth_pitch<<16) | color[0]->pitch; format = 0x108; if (color[0]->mesa._ActualFormat != GL_RGBA8) { format = 0x103; /* R5G6B5 color buffer */ } - OUT_RING_CACHE(format); - OUT_RING_CACHE(pitch); - OUT_RING_CACHE(color[0]->offset); - OUT_RING_CACHE(depth ? depth->offset : color[0]->offset); + OUT_RING(format); + OUT_RING(pitch); + OUT_RING(color[0]->offset); + OUT_RING(depth ? depth->offset : color[0]->offset); - nv10ViewportScale(nmesa); return GL_TRUE; } -- cgit v1.2.3 From 24967c8646b496b0e6f2735374528fe93ac3e0a4 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 25 Aug 2007 17:46:53 +0200 Subject: nouveau: nv10: also set modelview0 matrix to identity --- src/mesa/drivers/dri/nouveau/nv10_state.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index d3331ac9702..79d567b25d7 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -869,7 +869,7 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) OUT_RING (0x802); OUT_RING (2); - /* Projection matrix */ + /* Projection and modelview matrix */ memset(projection, 0, sizeof(projection)); projection[0*4+0] = 1.0; projection[1*4+1] = 1.0; @@ -882,6 +882,10 @@ static GLboolean nv10InitCard(nouveauContextPtr nmesa) for (i=0; i<16; i++) { OUT_RINGf (projection[i]); } + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_MODELVIEW0_MATRIX(0), 16); + for (i=0; i<16; i++) { + OUT_RINGf (projection[i]); + } BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2); OUT_RINGf (0.0); OUT_RINGf (1.0); -- cgit v1.2.3 From c28ea5573d1e0249083c90d53890c2ec4e61f08c Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Mon, 27 Aug 2007 11:45:30 +0200 Subject: nouveau: nv10: set total stride of vertex array for POS attribute --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 611469b6e41..e31faf21a78 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -455,27 +455,33 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) * Tell the hardware about the vertex format */ if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) { - int size; + int total_stride = 0; #define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2 #define NV10_SET_VERTEX_ATTRIB(i,j) \ do { \ + int size; \ + int stride = attr_size[j] << 2; \ + if (i==0) { \ + stride += total_stride; \ + } \ size = attr_size[j] << 4; \ - size |= (attr_size[j]*4) << 8; \ + size |= stride << 8; \ size |= NV_VERTEX_ATTRIBUTE_TYPE_FLOAT; \ BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR(i),1); \ OUT_RING_CACHE(size); \ + total_stride += stride; \ } while (0) - NV10_SET_VERTEX_ATTRIB(0, _TNL_ATTRIB_POS); - NV10_SET_VERTEX_ATTRIB(1, _TNL_ATTRIB_COLOR0); - NV10_SET_VERTEX_ATTRIB(2, _TNL_ATTRIB_COLOR1); - NV10_SET_VERTEX_ATTRIB(3, _TNL_ATTRIB_TEX0); - NV10_SET_VERTEX_ATTRIB(4, _TNL_ATTRIB_TEX1); - NV10_SET_VERTEX_ATTRIB(5, _TNL_ATTRIB_NORMAL); - NV10_SET_VERTEX_ATTRIB(6, _TNL_ATTRIB_WEIGHT); NV10_SET_VERTEX_ATTRIB(7, _TNL_ATTRIB_FOG); + NV10_SET_VERTEX_ATTRIB(6, _TNL_ATTRIB_WEIGHT); + NV10_SET_VERTEX_ATTRIB(5, _TNL_ATTRIB_NORMAL); + NV10_SET_VERTEX_ATTRIB(4, _TNL_ATTRIB_TEX1); + NV10_SET_VERTEX_ATTRIB(3, _TNL_ATTRIB_TEX0); + NV10_SET_VERTEX_ATTRIB(2, _TNL_ATTRIB_COLOR1); + NV10_SET_VERTEX_ATTRIB(1, _TNL_ATTRIB_COLOR0); + NV10_SET_VERTEX_ATTRIB(0, _TNL_ATTRIB_POS); BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_VALIDATE,1); OUT_RING_CACHE(0); -- cgit v1.2.3 From f0a036bad91d5f281f8007e8cddefb3f648f1684 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 27 Aug 2007 10:36:11 -0600 Subject: new __gluInvertMatrix() function (Mesa bug 6748) --- src/glu/sgi/libutil/project.c | 115 ++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/glu/sgi/libutil/project.c b/src/glu/sgi/libutil/project.c index 2b20ad4fb33..d22989c3855 100644 --- a/src/glu/sgi/libutil/project.c +++ b/src/glu/sgi/libutil/project.c @@ -168,74 +168,57 @@ static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4], } /* -** inverse = invert(src) -** New, faster implementation by Shan Hao Bo, April 2006. +** Invert 4x4 matrix. +** Contributed by David Moore (See Mesa bug #6748) */ -static int __gluInvertMatrixd(const GLdouble src[16], GLdouble inverse[16]) +static int __gluInvertMatrixd(const GLdouble m[16], GLdouble inv[16]) { - int i, j, k; - double t; - GLdouble temp[4][4]; - - for (i=0; i<4; i++) { - for (j=0; j<4; j++) { - temp[i][j] = src[i*4+j]; - } - } - __gluMakeIdentityd(inverse); - - for (i = 0; i < 4; i++) { - if (temp[i][i] == 0.0f) { - /* - ** Look for non-zero element in column - */ - for (j = i + 1; j < 4; j++) { - if (temp[j][i] != 0.0f) { - break; - } - } - - if (j != 4) { - /* - ** Swap rows. - */ - for (k = 0; k < 4; k++) { - t = temp[i][k]; - temp[i][k] = temp[j][k]; - temp[j][k] = t; - - t = inverse[i*4+k]; - inverse[i*4+k] = inverse[j*4+k]; - inverse[j*4+k] = t; - } - } - else { - /* - ** No non-zero pivot. The matrix is singular, -which shouldn't - ** happen. This means the user gave us a bad -matrix. - */ - return GL_FALSE; - } - } - - t = 1.0f / temp[i][i]; - for (k = 0; k < 4; k++) { - temp[i][k] *= t; - inverse[i*4+k] *= t; - } - for (j = 0; j < 4; j++) { - if (j != i) { - t = temp[j][i]; - for (k = 0; k < 4; k++) { - temp[j][k] -= temp[i][k]*t; - inverse[j*4+k] -= inverse[i*4+k]*t; - } - } - } - } - return GL_TRUE; + double det; + int i; + + inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15] + + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10]; + inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15] + - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10]; + inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15] + + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9]; + inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14] + - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9]; + inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15] + - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10]; + inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15] + + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10]; + inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15] + - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9]; + inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14] + + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9]; + inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15] + + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6]; + inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15] + - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6]; + inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15] + + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5]; + inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14] + - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5]; + inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11] + - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6]; + inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11] + + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6]; + inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11] + - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5]; + inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10] + + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5]; + + det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12]; + if (det == 0) + return GL_FALSE; + + det = 1.0 / det; + + for (i = 0; i < 16; i++) + inv[i] *= det; + + return GL_TRUE; } static void __gluMultMatricesd(const GLdouble a[16], const GLdouble b[16], -- cgit v1.2.3 From d62be3d4cac4228a74fd93a5588717b8b8468cc6 Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Mon, 27 Aug 2007 10:47:32 -0600 Subject: fixed problem with big glDrawArrays (see bug 12141) --- src/glx/x11/indirect_vertex_array.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/glx/x11/indirect_vertex_array.c b/src/glx/x11/indirect_vertex_array.c index 90ec277c41b..120fd826c3a 100644 --- a/src/glx/x11/indirect_vertex_array.c +++ b/src/glx/x11/indirect_vertex_array.c @@ -527,7 +527,7 @@ static GLubyte * emit_DrawArrays_header_old( __GLXcontext * gc, struct array_state_vector * arrays, size_t * elements_per_request, - size_t * total_requests, + unsigned int * total_requests, GLenum mode, GLsizei count ) { size_t command_size; @@ -640,7 +640,7 @@ emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count ) GLubyte * pc; size_t elements_per_request; - size_t total_requests = 0; + unsigned total_requests = 0; unsigned i; size_t total_sent = 0; @@ -770,9 +770,10 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, GLubyte * pc; size_t elements_per_request; - size_t total_requests = 0; + unsigned total_requests = 0; unsigned i; unsigned req; + unsigned req_element=0; pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request, @@ -790,7 +791,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, switch( type ) { case GL_UNSIGNED_INT: { - const GLuint * ui_ptr = (const GLuint *) indices; + const GLuint * ui_ptr = (const GLuint *) indices + req_element; for ( i = 0 ; i < elements_per_request ; i++ ) { const GLint index = (GLint) *(ui_ptr++); @@ -799,7 +800,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, break; } case GL_UNSIGNED_SHORT: { - const GLushort * us_ptr = (const GLushort *) indices; + const GLushort * us_ptr = (const GLushort *) indices + req_element; for ( i = 0 ; i < elements_per_request ; i++ ) { const GLint index = (GLint) *(us_ptr++); @@ -808,7 +809,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, break; } case GL_UNSIGNED_BYTE: { - const GLubyte * ub_ptr = (const GLubyte *) indices; + const GLubyte * ub_ptr = (const GLubyte *) indices + req_element; for ( i = 0 ; i < elements_per_request ; i++ ) { const GLint index = (GLint) *(ub_ptr++); @@ -826,6 +827,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, } count -= elements_per_request; + req_element += elements_per_request; } -- cgit v1.2.3 From c235cc71a296e63f65cafcc95839119cf3cf2a63 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 28 Aug 2007 11:35:52 -0400 Subject: i965: flush batch buffer when getting the maximum. This makes some 3D programs such as pymol work well. --- src/mesa/drivers/dri/i965/brw_draw.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 0c64d7e756d..5ca9b2f549a 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -331,6 +331,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, else { /* Otherwise, explicitly do the cliprects at this point: */ + GLuint nprims = 0; for (j = 0; j < brw->intel.numClipRects; j++) { brw_emit_cliprect(brw, &brw->intel.pClipRects[j]); @@ -338,6 +339,11 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, */ for (i = 0; i < nr_prims; i++) { brw_emit_prim(brw, &prim[i]); + + if (++nprims == VBO_MAX_PRIM) { + intel_batchbuffer_flush(brw->intel.batch); + nprims = 0; + } } } } -- cgit v1.2.3 From 500193dca8cee7d8b609bd20cb60d20c96d77de3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 28 Aug 2007 12:27:51 -0700 Subject: Add register defines for hw binning --- src/mesa/drivers/dri/i915tex/i915_reg.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_reg.h b/src/mesa/drivers/dri/i915tex/i915_reg.h index 34c68214056..a9fa56e8a60 100644 --- a/src/mesa/drivers/dri/i915tex/i915_reg.h +++ b/src/mesa/drivers/dri/i915tex/i915_reg.h @@ -112,6 +112,20 @@ /* 3DSTATE_CHROMA_KEY */ /* 3DSTATE_CLEAR_PARAMETERS, p150 */ +/* + * Sets the color, depth and stencil clear values used by the + * CLEAR_RECT and ZONE_INIT primitive types, respectively. These + * primitives set override most 3d state and only take a minimal x/y + * vertex. The color/z/stencil information is supplied here and + * therefore cannot vary per vertex. + */ +#define _3DSTATE_CLEAR_PARAMETERS (CMD_3D | (0x1d<<24) | (0x9c<<16) | 5) +/* Dword 1 */ +#define CLEARPARAM_CLEAR_RECT (1 << 16) +#define CLEARPARAM_ZONE_INIT (0 << 16) +#define CLEARPARAM_WRITE_COLOR (1 << 2) +#define CLEARPARAM_WRITE_DEPTH (1 << 1) +#define CLEARPARAM_WRITE_STENCIL (1 << 0) /* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */ #define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16)) @@ -424,6 +438,17 @@ #define S7_DEPTH_OFFSET_CONST_MASK ~0 + +/* Helper macros for blend factors + */ +#define DST_BLND_FACT(f) ((f)< Date: Wed, 29 Aug 2007 10:13:10 -0400 Subject: i965: samplers group in fours in WM_STATE. fix bug#9415 --- src/mesa/drivers/dri/i965/brw_wm_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index ff5cb31bdd1..5b4f2abd0e2 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -117,7 +117,7 @@ static void upload_wm_unit(struct brw_context *brw ) wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754; /* CACHE_NEW_SAMPLER */ - wm.wm4.sampler_count = brw->wm.sampler_count; + wm.wm4.sampler_count = (brw->wm.sampler_count + 1) / 4; wm.wm4.sampler_state_pointer = brw->wm.sampler_gs_offset >> 5; /* BRW_NEW_FRAGMENT_PROGRAM */ -- cgit v1.2.3 From f6a89e1884535a6136900febc163ee930c1d2179 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 29 Aug 2007 13:03:34 -0400 Subject: i965: check NULL pointer. fix bug#12193 --- src/mesa/drivers/dri/i965/intel_pixel_bitmap.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c index f3f062e6517..23f381fe917 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c @@ -174,6 +174,8 @@ do_blit_bitmap( GLcontext *ctx, GLubyte ub[4]; } color; + if (!dst) + return GL_FALSE; if (unpack->BufferObj->Name) { bitmap = map_pbo(ctx, width, height, unpack, bitmap); -- cgit v1.2.3 From bad6e175cf59cce630c37d73f6e71f3a4de50ae6 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 29 Aug 2007 15:11:10 -0400 Subject: i965: store read drawable info in intel_context. Some OpenGL operations are based on read drawable. fix bug#10136. --- src/mesa/drivers/dri/i965/intel_context.c | 4 ++++ src/mesa/drivers/dri/i965/intel_context.h | 1 + src/mesa/drivers/dri/i965/intel_pixel_copy.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index eafe809d3ad..1fbf571184e 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -576,6 +576,10 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv, if (driContextPriv) { struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; + if (intel->driReadDrawable != driReadPriv) { + intel->driReadDrawable = driReadPriv; + } + if ( intel->driDrawable != driDrawPriv ) { /* Shouldn't the readbuffer be stored also? */ driDrawableInitVBlank( driDrawPriv, intel->vblank_flags, diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h index 406f8483dce..ae255929089 100644 --- a/src/mesa/drivers/dri/i965/intel_context.h +++ b/src/mesa/drivers/dri/i965/intel_context.h @@ -234,6 +234,7 @@ struct intel_context int driFd; __DRIdrawablePrivate *driDrawable; + __DRIdrawablePrivate *driReadDrawable; __DRIscreenPrivate *driScreen; intelScreenPrivate *intelScreen; volatile drmI830Sarea *sarea; diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c index 58dc49505fe..3bdf2fb4790 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c @@ -231,6 +231,7 @@ do_blit_copypixels(GLcontext * ctx, if (intel->driDrawable->numClipRects) { __DRIdrawablePrivate *dPriv = intel->driDrawable; + __DRIdrawablePrivate *dReadPriv = intel->driReadDrawable; drm_clip_rect_t *box = dPriv->pClipRects; drm_clip_rect_t dest_rect; GLint nbox = dPriv->numClipRects; @@ -262,8 +263,8 @@ do_blit_copypixels(GLcontext * ctx, srcy = dPriv->h - srcy - height; dstx += dPriv->x; dsty += dPriv->y; - srcx += dPriv->x; - srcy += dPriv->y; + srcx += dReadPriv->x; + srcy += dReadPriv->y; /* Clip against the source region. This is the only source * clipping we do. Dst is clipped with cliprects below. -- cgit v1.2.3 From 3b7df51eb5f5e2f980248f5e8c547869ea93ac78 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 30 Aug 2007 08:41:38 -0600 Subject: s/movaps/movups/ (see bug 12216) --- src/mesa/x86-64/xform4.S | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S index 65328f6666e..4f7f914eeaf 100644 --- a/src/mesa/x86-64/xform4.S +++ b/src/mesa/x86-64/xform4.S @@ -1,10 +1,8 @@ -/* $Id: xform4.S,v 1.2 2006/04/17 18:58:24 krh Exp $ */ - /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 7.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 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"), @@ -64,7 +62,7 @@ _mesa_x86_64_transform_points4_general: p4_general_loop: - movaps (%rdx), %xmm8 /* ox | oy | oz | ow */ + movups (%rdx), %xmm8 /* ox | oy | oz | ow */ prefetchw 16(%rdi) pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */ -- cgit v1.2.3 From 74e1d0996d109ce6426507f9ca64cf38d3b83acf Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 30 Aug 2007 18:04:49 +0200 Subject: fix another occurence of movaps which might not be aligned --- src/mesa/x86-64/xform4.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S index 4f7f914eeaf..3f9c9d56ab7 100644 --- a/src/mesa/x86-64/xform4.S +++ b/src/mesa/x86-64/xform4.S @@ -147,7 +147,7 @@ _mesa_x86_64_transform_points4_3d: p4_3d_loop: - movaps (%rdx), %xmm8 /* ox | oy | oz | ow */ + movups (%rdx), %xmm8 /* ox | oy | oz | ow */ prefetchw 16(%rdi) pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */ -- cgit v1.2.3 From 1dd94a63ace0c6133f80191ba3b3e5f56f86c8fe Mon Sep 17 00:00:00 2001 From: David Moore Date: Thu, 30 Aug 2007 14:43:30 -0700 Subject: Bug #10571: Fix 965 line clipping when neither vertex needs clipping. --- src/mesa/drivers/dri/i965/brw_clip_line.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c b/src/mesa/drivers/dri/i965/brw_clip_line.c index 83182270eac..0103be43458 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_line.c +++ b/src/mesa/drivers/dri/i965/brw_clip_line.c @@ -130,6 +130,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c ) struct brw_instruction *plane_loop; struct brw_instruction *plane_active; struct brw_instruction *is_negative; + struct brw_instruction *is_neg2; struct brw_instruction *not_culled; struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), BRW_REGISTER_TYPE_UD); @@ -183,13 +184,20 @@ static void clip_and_emit_line( struct brw_clip_compile *c ) /* Coming back in. We know that both cannot be negative * because the line would have been culled in that case. */ - brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1)); - brw_math_invert(p, c->reg.t, c->reg.t); - brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0); - brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 ); - brw_MOV(p, c->reg.t0, c->reg.t); - brw_set_predicate_control(p, BRW_PREDICATE_NONE); + /* If both are positive, do nothing */ + brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.dp0, brw_imm_f(0.0)); + is_neg2 = brw_IF(p, BRW_EXECUTE_1); + { + brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1)); + brw_math_invert(p, c->reg.t, c->reg.t); + brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0); + + brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 ); + brw_MOV(p, c->reg.t0, c->reg.t); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + } + brw_ENDIF(p, is_neg2); } brw_ENDIF(p, is_negative); } -- cgit v1.2.3 From 22bc3cdd49eb81d48ad4b8f06be0b9a9de624c91 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 31 Aug 2007 12:51:36 +0800 Subject: i965: Take the upper limitation on LOD into account. --- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 83a4b02e483..81fc9ef2f0c 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -192,8 +192,8 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit, */ sampler->ss0.base_level = U_FIXED(0, 1); - sampler->ss1.max_lod = U_FIXED(MAX2(texObj->MaxLod, 0), 6); - sampler->ss1.min_lod = U_FIXED(MAX2(texObj->MinLod, 0), 6); + sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(texObj->MaxLod, 0), 13), 6); + sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(texObj->MinLod, 0), 13), 6); sampler->ss2.default_color_pointer = sdc_gs_offset >> 5; } -- cgit v1.2.3 From b47c9f8c915ae4ca8c7fa5ee3b6b64f17c38b569 Mon Sep 17 00:00:00 2001 From: Zou Nan hai Date: Fri, 31 Aug 2007 13:42:20 +0800 Subject: optimize 965 clip 1. increase clip thread number to 2 2. do cliptest for -rhw --- src/mesa/drivers/dri/i965/brw_clip_line.c | 7 ++ src/mesa/drivers/dri/i965/brw_clip_state.c | 2 +- src/mesa/drivers/dri/i965/brw_clip_tri.c | 107 +++++++++++++++++++++++++++-- src/mesa/drivers/dri/i965/brw_clip_util.c | 12 +--- 4 files changed, 113 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c b/src/mesa/drivers/dri/i965/brw_clip_line.c index 0103be43458..9ad00676d4b 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_line.c +++ b/src/mesa/drivers/dri/i965/brw_clip_line.c @@ -147,6 +147,13 @@ static void clip_and_emit_line( struct brw_clip_compile *c ) brw_clip_init_planes(c); brw_clip_init_clipmask(c); + /* -ve rhw workaround */ + brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ); + brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2), + brw_imm_ud(1<<20)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + plane_loop = brw_DO(p, BRW_EXECUTE_1); { /* if (planemask & 1) diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index 1e6d6fa1762..ae46d7a86e0 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -55,7 +55,7 @@ static void upload_clip_unit( struct brw_context *brw ) /* BRW_NEW_URB_FENCE */ clip.thread4.nr_urb_entries = brw->urb.nr_clip_entries; clip.thread4.urb_entry_allocation_size = brw->urb.vsize - 1; - clip.thread4.max_threads = 0; /* Hmm, maybe the max is 1 or 2 threads */ + clip.thread4.max_threads = 1; /* 2 threads */ if (INTEL_DEBUG & DEBUG_STATS) clip.thread4.stats_enable = 1; diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c index f62b02cedfd..506ab3712d0 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_tri.c +++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c @@ -42,6 +42,20 @@ #include "brw_util.h" #include "brw_clip.h" +static struct brw_reg get_tmp( struct brw_clip_compile *c ) +{ + struct brw_reg tmp = brw_vec4_grf(c->last_tmp, 0); + + if (++c->last_tmp > c->prog_data.total_grf) + c->prog_data.total_grf = c->last_tmp; + + return tmp; +} + +static void release_tmps( struct brw_clip_compile *c ) +{ + c->last_tmp = c->first_tmp; +} void brw_clip_tri_alloc_regs( struct brw_clip_compile *c, @@ -435,15 +449,103 @@ static void maybe_do_clip_tri( struct brw_clip_compile *c ) brw_ENDIF(p, do_clip); } - +static void brw_clip_test( struct brw_clip_compile *c ) +{ + struct brw_reg t = retype(get_tmp(c), BRW_REGISTER_TYPE_UD); + struct brw_reg t1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD); + struct brw_reg t2 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD); + struct brw_reg t3 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD); + + struct brw_reg v0 = get_tmp(c); + struct brw_reg v1 = get_tmp(c); + struct brw_reg v2 = get_tmp(c); + + struct brw_indirect vt0 = brw_indirect(0, 0); + struct brw_indirect vt1 = brw_indirect(1, 0); + struct brw_indirect vt2 = brw_indirect(2, 0); + + struct brw_compile *p = &c->func; + + brw_MOV(p, get_addr_reg(vt0), brw_address(c->reg.vertex[0])); + brw_MOV(p, get_addr_reg(vt1), brw_address(c->reg.vertex[1])); + brw_MOV(p, get_addr_reg(vt2), brw_address(c->reg.vertex[2])); + brw_MOV(p, v0, deref_4f(vt0, c->offset[VERT_RESULT_HPOS])); + brw_MOV(p, v1, deref_4f(vt1, c->offset[VERT_RESULT_HPOS])); + brw_MOV(p, v2, deref_4f(vt2, c->offset[VERT_RESULT_HPOS])); + brw_AND(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(~0x3f)); + + /* test nearz, xmin, ymin plane */ + brw_CMP(p, t1, BRW_CONDITIONAL_LE, negate(v0), get_element(v0, 3)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, t2, BRW_CONDITIONAL_LE, negate(v1), get_element(v1, 3)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, t3, BRW_CONDITIONAL_LE, negate(v2), get_element(v2, 3)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_XOR(p, t, t1, t2); + brw_XOR(p, t1, t2, t3); + brw_OR(p, t, t, t1); + + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, + get_element(t, 0), brw_imm_ud(0)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<5))); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, + get_element(t, 1), brw_imm_ud(0)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<3))); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, + get_element(t, 2), brw_imm_ud(0)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<1))); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + + /* test farz, xmax, ymax plane */ + brw_CMP(p, t1, BRW_CONDITIONAL_L, v0, get_element(v0, 3)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, t2, BRW_CONDITIONAL_L, v1, get_element(v1, 3)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, t3, BRW_CONDITIONAL_L, v2, get_element(v2, 3)); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + + brw_XOR(p, t, t1, t2); + brw_XOR(p, t1, t2, t3); + brw_OR(p, t, t, t1); + + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, + get_element(t, 0), brw_imm_ud(0)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<4))); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, + get_element(t, 1), brw_imm_ud(0)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<2))); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, + get_element(t, 2), brw_imm_ud(0)); + brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<0))); + brw_set_predicate_control(p, BRW_PREDICATE_NONE); + + release_tmps(c); +} void brw_emit_tri_clip( struct brw_clip_compile *c ) { + struct brw_instruction *neg_rhw; + struct brw_compile *p = &c->func; brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6); brw_clip_tri_init_vertices(c); brw_clip_init_clipmask(c); + /* if -ve rhw workaround bit is set, + do cliptest */ + brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ); + brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2), + brw_imm_ud(1<<20)); + neg_rhw = brw_IF(p, BRW_EXECUTE_1); + { + brw_clip_test(c); + } + brw_ENDIF(p, neg_rhw); + /* Can't push into do_clip_tri because with polygon (or quad) * flatshading, need to apply the flatshade here because we don't * respect the PV when converting to trifan for emit: @@ -462,6 +564,3 @@ void brw_emit_tri_clip( struct brw_clip_compile *c ) */ brw_clip_kill_thread(c); } - - - diff --git a/src/mesa/drivers/dri/i965/brw_clip_util.c b/src/mesa/drivers/dri/i965/brw_clip_util.c index 19bef19801a..c37bfeb1ce6 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_util.c +++ b/src/mesa/drivers/dri/i965/brw_clip_util.c @@ -272,6 +272,7 @@ void brw_clip_kill_thread(struct brw_clip_compile *c) + struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c ) { return brw_address(c->reg.fixed_planes); @@ -327,8 +328,7 @@ void brw_clip_init_clipmask( struct brw_clip_compile *c ) /* Shift so that lowest outcode bit is rightmost: */ - brw_MOV(p, c->reg.planemask, incoming); - brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(26)); + brw_SHR(p, c->reg.planemask, incoming, brw_imm_ud(26)); if (c->key.nr_userclip) { struct brw_reg tmp = retype(vec1(get_tmp(c)), BRW_REGISTER_TYPE_UD); @@ -342,13 +342,5 @@ void brw_clip_init_clipmask( struct brw_clip_compile *c ) release_tmp(c, tmp); } - - /* Test for -ve rhw workaround - */ - brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ); - brw_AND(p, vec1(brw_null_reg()), incoming, brw_imm_ud(1<<20)); - brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f)); - brw_set_predicate_control(p, BRW_PREDICATE_NONE); - } -- cgit v1.2.3 From 214347fdb4c30dc8bac5d4b9a823458709bc53ea Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 31 Aug 2007 16:50:48 +0800 Subject: i965: Calculate the positional light in homogeneous coordinates. fix bug#11009 --- src/mesa/drivers/dri/i965/brw_vs_tnl.c | 5 +++++ src/mesa/tnl/t_vp_build.c | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c index b69be350a92..339a3304483 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c +++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c @@ -1003,6 +1003,11 @@ static void build_lighting( struct tnl_program *p ) VPpli = get_temp(p); half = get_temp(p); + + /* In homogeneous object coordinates + */ + emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); + emit_op2(p, OPCODE_MUL, Ppli, 0, Ppli, dist); /* Calulate VPpli vector */ diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index ee1a2498b32..336f3c7a2a2 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -960,6 +960,11 @@ static void build_lighting( struct tnl_program *p ) VPpli = get_temp(p); half = get_temp(p); + /* In homogeneous object coordinates + */ + emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); + emit_op2(p, OPCODE_MUL, Ppli, 0, Ppli, dist); + /* Calulate VPpli vector */ emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); -- cgit v1.2.3 From b0a1e81887a831f72ffbec4fe005e1837c81018c Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Fri, 31 Aug 2007 19:43:16 +0200 Subject: nouveau: add hw-dependent function to update modelview*projection matrix --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 + src/mesa/drivers/dri/nouveau/nouveau_context.h | 6 ++++ src/mesa/drivers/dri/nouveau/nouveau_state.c | 17 ++++++++++ src/mesa/drivers/dri/nouveau/nv10_state.c | 46 ++++++++++++++++++++++++++ src/mesa/drivers/dri/nouveau/nv20_state.c | 5 +++ src/mesa/drivers/dri/nouveau/nv30_state.c | 5 +++ src/mesa/drivers/dri/nouveau/nv50_state.c | 5 +++ 7 files changed, 85 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 1e13324b983..ae0a6d5c9e7 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -210,6 +210,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, _swsetup_CreateContext( ctx ); _math_matrix_ctr(&nmesa->viewport); + _math_matrix_ctr(&nmesa->model_proj); nouveauDDInitStateFuncs( ctx ); nouveauSpanInitFunctions( ctx ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 778c4401e42..94d729daef1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -86,6 +86,9 @@ typedef struct nouveau_hw_func_t { nouveau_renderbuffer_t *depth); /* Update anything that depends on the window position/size */ void (*WindowMoved)(struct nouveau_context *); + + /* Update projection matrix */ + void (*UpdateModelProjMatrix)(struct nouveau_context *); } nouveau_hw_func; typedef struct nouveau_context { @@ -117,6 +120,9 @@ typedef struct nouveau_context { GLuint color_offset; GLuint specular_offset; + /* Projection*modelview matrix */ + GLmatrix model_proj; + /* Vertex state */ GLuint vertex_size; GLubyte *verts; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index f618dcfc99b..6c63b12c469 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -100,6 +100,16 @@ static void nouveauDepthRange(GLcontext *ctx, GLclampd near, GLclampd far) nouveauCalcViewport(ctx); } +static void nouveauUpdateModelProjMatrix(GLcontext *ctx) +{ + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + + _math_matrix_mul_matrix(&(nmesa->model_proj), &(ctx->_ModelProjectMatrix), + ctx->ModelviewMatrixStack.Top); + + nmesa->hw_func.UpdateModelProjMatrix(nmesa); +} + static void nouveauDDUpdateHWState(GLcontext *ctx) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); @@ -141,6 +151,13 @@ static void nouveauDDUpdateHWState(GLcontext *ctx) static void nouveauDDInvalidateState(GLcontext *ctx, GLuint new_state) { + if ( new_state & _NEW_PROJECTION ) { + nouveauUpdateModelProjMatrix(ctx); + } + if ( new_state & _NEW_MODELVIEW ) { + nouveauUpdateModelProjMatrix(ctx); + } + _swrast_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state ); _vbo_InvalidateState( ctx, new_state ); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 79d567b25d7..9c63bd118a4 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -750,6 +750,51 @@ static void nv10TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } +static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ + GLcontext *ctx = nmesa->glCtx; + GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; + GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; + GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; + GLfloat projection[16]; + int i; + + if (ctx->DrawBuffer) { + if (ctx->DrawBuffer->_DepthBuffer) { + switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { + case 16: + max_depth *= 32767.0; + break; + case 24: + max_depth *= 16777215.0; + break; + } + } + } + + /* Rescale for viewport */ + for (i=0; i<4; i++) { + projection[i] = w * nmesa->model_proj.m[i]; + } + for (i=0; i<4; i++) { + projection[i+4] = -h * nmesa->model_proj.m[i+4]; + } + for (i=0; i<4; i++) { + projection[i+8] = max_depth * nmesa->model_proj.m[i+8]; + } + for (i=0; i<4; i++) { + projection[i+12] = nmesa->model_proj.m[i+12]; + } + + for (i=0; i<16; i++) { + printf("%d\t%.3f\t%.3f\n", i, + nmesa->model_proj.m[i], projection[i]); + } + + BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); + OUT_RINGp(projection, 16); +} + /* Update anything that depends on the window position/size */ static void nv10WindowMoved(nouveauContextPtr nmesa) { @@ -1011,4 +1056,5 @@ void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv10InitCard; nmesa->hw_func.BindBuffers = nv10BindBuffers; nmesa->hw_func.WindowMoved = nv10WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv10UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index 6b583980a49..c6efa6b72c9 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -636,6 +636,10 @@ static void nv20TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } +static void nv20UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ +} + /* Update anything that depends on the window position/size */ static void nv20WindowMoved(nouveauContextPtr nmesa) { @@ -820,5 +824,6 @@ void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv20InitCard; nmesa->hw_func.BindBuffers = nv20BindBuffers; nmesa->hw_func.WindowMoved = nv20WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv20UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index cd3ee986880..ebd9e1c5145 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -767,6 +767,10 @@ static void nv30TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) } } +static void nv30UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ +} + static void nv30WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -998,5 +1002,6 @@ void nv30InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv30InitCard; nmesa->hw_func.BindBuffers = nv30BindBuffers; nmesa->hw_func.WindowMoved = nv30WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv30UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv50_state.c b/src/mesa/drivers/dri/nouveau/nv50_state.c index a9236f093c3..66a18c4a156 100644 --- a/src/mesa/drivers/dri/nouveau/nv50_state.c +++ b/src/mesa/drivers/dri/nouveau/nv50_state.c @@ -520,6 +520,10 @@ static void nv50TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) /* Only with shaders */ } +static void nv50UpdateModelProjMatrix(nouveauContextPtr nmesa) +{ +} + static void nv50WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -638,4 +642,5 @@ void nv50InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv50InitCard; nmesa->hw_func.BindBuffers = nv50BindBuffers; nmesa->hw_func.WindowMoved = nv50WindowMoved; + nmesa->hw_func.UpdateModelProjMatrix = nv50UpdateModelProjMatrix; } -- cgit v1.2.3 From 47768ce0e59a76cbe367fe3b66be4150cd4ea3a8 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Fri, 31 Aug 2007 19:45:14 +0200 Subject: nouveau: nv10: remove setting projection matrix when scaling viewport --- src/mesa/drivers/dri/nouveau/nv10_state.c | 41 +++++++++---------------------- 1 file changed, 11 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 9c63bd118a4..bdfc75b8750 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -43,20 +43,17 @@ static void nv10ViewportScale(nouveauContextPtr nmesa) GLfloat projection[16]; int i; - if (!ctx->DrawBuffer) { - return; - } - if (!ctx->DrawBuffer->_DepthBuffer) { - return; - } - - switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { - case 16: - max_depth *= 32767.0; - break; - case 24: - max_depth *= 16777215.0; - break; + if (ctx->DrawBuffer) { + if (ctx->DrawBuffer->_DepthBuffer) { + switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) { + case 16: + max_depth *= 32767.0; + break; + case 24: + max_depth *= 16777215.0; + break; + } + } } BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4); @@ -64,17 +61,6 @@ static void nv10ViewportScale(nouveauContextPtr nmesa) OUT_RINGf (h - 2048.0); OUT_RINGf (max_depth); OUT_RINGf (0.0); - - /* FIXME: should multiply by gl projection and modelview ? */ - memset(projection, 0, sizeof(projection)); - projection[0*4+0] = w; - projection[1*4+1] = -h; - projection[2*4+2] = max_depth; - projection[3*4+3] = 1.0; - BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); - for (i=0; i<16; i++) { - OUT_RINGf (projection[i]); - } } static void nv10AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref) @@ -786,11 +772,6 @@ static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) projection[i+12] = nmesa->model_proj.m[i+12]; } - for (i=0; i<16; i++) { - printf("%d\t%.3f\t%.3f\n", i, - nmesa->model_proj.m[i], projection[i]); - } - BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); OUT_RINGp(projection, 16); } -- cgit v1.2.3 From 6dd98e9853a6984150aa47467112e016c40a4ab4 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 31 Aug 2007 16:42:05 -0600 Subject: Fix problem introduced in previous commit in which a state variable (uniform) is written to. (see bug 12239) Also, added some assertions to the emit_arg() and emit_dst() functions to catch this kind of error in the future. --- src/mesa/tnl/t_vp_build.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c index 336f3c7a2a2..63f7890205d 100644 --- a/src/mesa/tnl/t_vp_build.c +++ b/src/mesa/tnl/t_vp_build.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 2006 Tungsten Graphics All Rights Reserved. + * Copyright (C) 2007 Tungsten Graphics 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"), @@ -457,9 +457,13 @@ static void register_matrix_param5( struct tnl_program *p, } +/** + * Convert a ureg source register to a prog_src_register. + */ static void emit_arg( struct prog_src_register *src, struct ureg reg ) { + assert(reg.file != PROGRAM_OUTPUT); src->File = reg.file; src->Index = reg.idx; src->Swizzle = reg.swz; @@ -469,9 +473,18 @@ static void emit_arg( struct prog_src_register *src, src->RelAddr = 0; } +/** + * Convert a ureg dest register to a prog_dst_register. + */ static void emit_dst( struct prog_dst_register *dst, struct ureg reg, GLuint mask ) { + /* Check for legal output register type. UNDEFINED will occur in + * instruction that don't produce a result (like END). + */ + assert(reg.file == PROGRAM_TEMPORARY || + reg.file == PROGRAM_OUTPUT || + reg.file == PROGRAM_UNDEFINED); dst->File = reg.file; dst->Index = reg.idx; /* allow zero as a shorthand for xyzw */ @@ -956,18 +969,19 @@ static void build_lighting( struct tnl_program *p ) STATE_POSITION); struct ureg V = get_eye_position(p); struct ureg dist = get_temp(p); + struct ureg tmpPpli = get_temp(p); VPpli = get_temp(p); half = get_temp(p); - /* In homogeneous object coordinates - */ - emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); - emit_op2(p, OPCODE_MUL, Ppli, 0, Ppli, dist); + /* In homogeneous object coordinates + */ + emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); + emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist); - /* Calulate VPpli vector + /* Calculate VPpli vector */ - emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); + emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); /* Normalize VPpli. The dist value also used in * attenuation below. @@ -999,6 +1013,7 @@ static void build_lighting( struct tnl_program *p ) emit_normalize_vec3(p, half, half); release_temp(p, dist); + release_temp(p, tmpPpli); } /* Calculate dot products: -- cgit v1.2.3 From cb7da3f09655f9c66eabb6a38f581c9176980cd2 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Sat, 1 Sep 2007 15:43:15 +0800 Subject: i965: Correct build_lighting in i965 driver according to commit 6dd98e9853a6984150aa47467112e016c40a4ab4. --- src/mesa/drivers/dri/i965/brw_vs_tnl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c index 339a3304483..2ed80dc36e9 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c +++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c @@ -1000,6 +1000,7 @@ static void build_lighting( struct tnl_program *p ) STATE_POSITION); struct ureg V = get_eye_position(p); struct ureg dist = get_temp(p); + struct ureg tmpPpli = get_temp(p); VPpli = get_temp(p); half = get_temp(p); @@ -1007,11 +1008,11 @@ static void build_lighting( struct tnl_program *p ) /* In homogeneous object coordinates */ emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); - emit_op2(p, OPCODE_MUL, Ppli, 0, Ppli, dist); + emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist); /* Calulate VPpli vector */ - emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); + emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); /* Normalize VPpli. The dist value also used in * attenuation below. @@ -1043,6 +1044,7 @@ static void build_lighting( struct tnl_program *p ) emit_normalize_vec3(p, half, half); release_temp(p, dist); + release_temp(p, tmpPpli); } /* Calculate dot products: -- cgit v1.2.3 From c45bb05b3c0b65981b6ddeaf1bb043b9a6f7f3fc Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Mon, 3 Sep 2007 23:08:57 +0200 Subject: nouveau: separate modelview and projection matrix updates --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_context.h | 9 ++++++--- src/mesa/drivers/dri/nouveau/nouveau_state.c | 22 ++++++++++++++-------- src/mesa/drivers/dri/nouveau/nv10_state.c | 18 +++++++++++------- src/mesa/drivers/dri/nouveau/nv20_state.c | 5 ----- src/mesa/drivers/dri/nouveau/nv30_state.c | 5 ----- src/mesa/drivers/dri/nouveau/nv50_state.c | 5 ----- 7 files changed, 32 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index ae0a6d5c9e7..0f7bd4aa074 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -210,7 +210,7 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, _swsetup_CreateContext( ctx ); _math_matrix_ctr(&nmesa->viewport); - _math_matrix_ctr(&nmesa->model_proj); + _math_matrix_ctr(&nmesa->projection); nouveauDDInitStateFuncs( ctx ); nouveauSpanInitFunctions( ctx ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 94d729daef1..51666ef91c2 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -88,7 +88,10 @@ typedef struct nouveau_hw_func_t { void (*WindowMoved)(struct nouveau_context *); /* Update projection matrix */ - void (*UpdateModelProjMatrix)(struct nouveau_context *); + void (*UpdateProjectionMatrix)(GLcontext *); + + /* Update modelview matrix (used for lighting and vertex weight) */ + void (*UpdateModelviewMatrix)(GLcontext *); } nouveau_hw_func; typedef struct nouveau_context { @@ -120,8 +123,8 @@ typedef struct nouveau_context { GLuint color_offset; GLuint specular_offset; - /* Projection*modelview matrix */ - GLmatrix model_proj; + /* Projection matrix */ + GLmatrix projection; /* Vertex state */ GLuint vertex_size; diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 6c63b12c469..9e64a7010ef 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -100,14 +100,12 @@ static void nouveauDepthRange(GLcontext *ctx, GLclampd near, GLclampd far) nouveauCalcViewport(ctx); } -static void nouveauUpdateModelProjMatrix(GLcontext *ctx) +static void nouveauUpdateProjectionMatrix(GLcontext *ctx) { - nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - - _math_matrix_mul_matrix(&(nmesa->model_proj), &(ctx->_ModelProjectMatrix), - ctx->ModelviewMatrixStack.Top); +} - nmesa->hw_func.UpdateModelProjMatrix(nmesa); +static void nouveauUpdateModelviewMatrix(GLcontext *ctx) +{ } static void nouveauDDUpdateHWState(GLcontext *ctx) @@ -151,11 +149,13 @@ static void nouveauDDUpdateHWState(GLcontext *ctx) static void nouveauDDInvalidateState(GLcontext *ctx, GLuint new_state) { + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + if ( new_state & _NEW_PROJECTION ) { - nouveauUpdateModelProjMatrix(ctx); + nmesa->hw_func.UpdateProjectionMatrix(ctx); } if ( new_state & _NEW_MODELVIEW ) { - nouveauUpdateModelProjMatrix(ctx); + nmesa->hw_func.UpdateModelviewMatrix(ctx); } _swrast_InvalidateState( ctx, new_state ); @@ -203,6 +203,8 @@ void nouveauDDInitState(nouveauContextPtr nmesa) /* Initialize the driver's state functions */ void nouveauDDInitStateFuncs(GLcontext *ctx) { + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); + ctx->Driver.UpdateState = nouveauDDInvalidateState; ctx->Driver.ClearIndex = NULL; @@ -253,6 +255,10 @@ void nouveauDDInitStateFuncs(GLcontext *ctx) ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; + + /* Matrix updates */ + nmesa->hw_func.UpdateProjectionMatrix = nouveauUpdateProjectionMatrix; + nmesa->hw_func.UpdateModelviewMatrix = nouveauUpdateModelviewMatrix; } #define STATE_INIT(a) if (ctx->Driver.a) ctx->Driver.a diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index bdfc75b8750..f9a83567724 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -736,9 +736,9 @@ static void nv10TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } -static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) +static void nv10UpdateProjectionMatrix(GLcontext *ctx) { - GLcontext *ctx = nmesa->glCtx; + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; @@ -758,18 +758,22 @@ static void nv10UpdateModelProjMatrix(nouveauContextPtr nmesa) } } + /* Calc projection * modelview */ + _math_matrix_mul_matrix(&(nmesa->projection), &(ctx->_ModelProjectMatrix), + ctx->ModelviewMatrixStack.Top); + /* Rescale for viewport */ for (i=0; i<4; i++) { - projection[i] = w * nmesa->model_proj.m[i]; + projection[i] = w * nmesa->projection.m[i]; } for (i=0; i<4; i++) { - projection[i+4] = -h * nmesa->model_proj.m[i+4]; + projection[i+4] = -h * nmesa->projection.m[i+4]; } for (i=0; i<4; i++) { - projection[i+8] = max_depth * nmesa->model_proj.m[i+8]; + projection[i+8] = max_depth * nmesa->projection.m[i+8]; } for (i=0; i<4; i++) { - projection[i+12] = nmesa->model_proj.m[i+12]; + projection[i+12] = nmesa->projection.m[i+12]; } BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); @@ -1037,5 +1041,5 @@ void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv10InitCard; nmesa->hw_func.BindBuffers = nv10BindBuffers; nmesa->hw_func.WindowMoved = nv10WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv10UpdateModelProjMatrix; + nmesa->hw_func.UpdateProjectionMatrix = nv10UpdateProjectionMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c index c6efa6b72c9..6b583980a49 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state.c @@ -636,10 +636,6 @@ static void nv20TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) OUT_RING_CACHEp(mat->m, 16); } -static void nv20UpdateModelProjMatrix(nouveauContextPtr nmesa) -{ -} - /* Update anything that depends on the window position/size */ static void nv20WindowMoved(nouveauContextPtr nmesa) { @@ -824,6 +820,5 @@ void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv20InitCard; nmesa->hw_func.BindBuffers = nv20BindBuffers; nmesa->hw_func.WindowMoved = nv20WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv20UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c index ebd9e1c5145..cd3ee986880 100644 --- a/src/mesa/drivers/dri/nouveau/nv30_state.c +++ b/src/mesa/drivers/dri/nouveau/nv30_state.c @@ -767,10 +767,6 @@ static void nv30TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) } } -static void nv30UpdateModelProjMatrix(nouveauContextPtr nmesa) -{ -} - static void nv30WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -1002,6 +998,5 @@ void nv30InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv30InitCard; nmesa->hw_func.BindBuffers = nv30BindBuffers; nmesa->hw_func.WindowMoved = nv30WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv30UpdateModelProjMatrix; } diff --git a/src/mesa/drivers/dri/nouveau/nv50_state.c b/src/mesa/drivers/dri/nouveau/nv50_state.c index 66a18c4a156..a9236f093c3 100644 --- a/src/mesa/drivers/dri/nouveau/nv50_state.c +++ b/src/mesa/drivers/dri/nouveau/nv50_state.c @@ -520,10 +520,6 @@ static void nv50TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat) /* Only with shaders */ } -static void nv50UpdateModelProjMatrix(nouveauContextPtr nmesa) -{ -} - static void nv50WindowMoved(nouveauContextPtr nmesa) { GLcontext *ctx = nmesa->glCtx; @@ -642,5 +638,4 @@ void nv50InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.InitCard = nv50InitCard; nmesa->hw_func.BindBuffers = nv50BindBuffers; nmesa->hw_func.WindowMoved = nv50WindowMoved; - nmesa->hw_func.UpdateModelProjMatrix = nv50UpdateModelProjMatrix; } -- cgit v1.2.3 From 2f8ff58c0e8fbb60974be9c2412db8610b2152e2 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Mon, 3 Sep 2007 23:42:33 +0200 Subject: nouveau: nv10: forgot function to set modelview matrix --- src/mesa/drivers/dri/nouveau/nv10_state.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index f9a83567724..93fc4ff9364 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -40,7 +40,6 @@ static void nv10ViewportScale(nouveauContextPtr nmesa) GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; - GLfloat projection[16]; int i; if (ctx->DrawBuffer) { @@ -780,6 +779,16 @@ static void nv10UpdateProjectionMatrix(GLcontext *ctx) OUT_RINGp(projection, 16); } +static void nv10UpdateModelviewMatrix(GLcontext *ctx) +{ + /* TODO update modelview if lighting or vertex weight enabled + update inverse modelview if lighting enabled + or update projection if lighting and vertex weight disabled + */ + + nv10UpdateProjectionMatrix(ctx); +} + /* Update anything that depends on the window position/size */ static void nv10WindowMoved(nouveauContextPtr nmesa) { @@ -1042,4 +1051,5 @@ void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func) nmesa->hw_func.BindBuffers = nv10BindBuffers; nmesa->hw_func.WindowMoved = nv10WindowMoved; nmesa->hw_func.UpdateProjectionMatrix = nv10UpdateProjectionMatrix; + nmesa->hw_func.UpdateModelviewMatrix = nv10UpdateModelviewMatrix; } -- cgit v1.2.3 From c2e1ee08b083638a7306e15ca48e9ea516d42dc4 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 3 Sep 2007 16:20:05 -0600 Subject: Use temporary matrix in __gluInvertMatrixd() to fix aliasing problem (see bugs 12269, 6748) --- src/glu/sgi/libutil/project.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/glu/sgi/libutil/project.c b/src/glu/sgi/libutil/project.c index d22989c3855..356b46b8992 100644 --- a/src/glu/sgi/libutil/project.c +++ b/src/glu/sgi/libutil/project.c @@ -171,9 +171,9 @@ static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4], ** Invert 4x4 matrix. ** Contributed by David Moore (See Mesa bug #6748) */ -static int __gluInvertMatrixd(const GLdouble m[16], GLdouble inv[16]) +static int __gluInvertMatrixd(const GLdouble m[16], GLdouble invOut[16]) { - double det; + double inv[16], det; int i; inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15] @@ -216,7 +216,7 @@ static int __gluInvertMatrixd(const GLdouble m[16], GLdouble inv[16]) det = 1.0 / det; for (i = 0; i < 16; i++) - inv[i] *= det; + invOut[i] = inv[i] * det; return GL_TRUE; } -- cgit v1.2.3 From ece08b7fd9af5ba67afa0a5d8e0a11f688ab4b0f Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Tue, 4 Sep 2007 19:13:07 +0200 Subject: nouveau: nv10: need to transpose mesa model+proj matrix for hw --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 1 - src/mesa/drivers/dri/nouveau/nouveau_context.h | 3 --- src/mesa/drivers/dri/nouveau/nv10_state.c | 15 +++++---------- 3 files changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 0f7bd4aa074..1e13324b983 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -210,7 +210,6 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, _swsetup_CreateContext( ctx ); _math_matrix_ctr(&nmesa->viewport); - _math_matrix_ctr(&nmesa->projection); nouveauDDInitStateFuncs( ctx ); nouveauSpanInitFunctions( ctx ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h index 51666ef91c2..77fe13a9cdc 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h @@ -123,9 +123,6 @@ typedef struct nouveau_context { GLuint color_offset; GLuint specular_offset; - /* Projection matrix */ - GLmatrix projection; - /* Vertex state */ GLuint vertex_size; GLubyte *verts; diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 93fc4ff9364..94525ba2a80 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -40,7 +40,6 @@ static void nv10ViewportScale(nouveauContextPtr nmesa) GLfloat w = ((GLfloat) ctx->Viewport.Width) * 0.5; GLfloat h = ((GLfloat) ctx->Viewport.Height) * 0.5; GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5; - int i; if (ctx->DrawBuffer) { if (ctx->DrawBuffer->_DepthBuffer) { @@ -757,22 +756,18 @@ static void nv10UpdateProjectionMatrix(GLcontext *ctx) } } - /* Calc projection * modelview */ - _math_matrix_mul_matrix(&(nmesa->projection), &(ctx->_ModelProjectMatrix), - ctx->ModelviewMatrixStack.Top); - - /* Rescale for viewport */ + /* Transpose and rescale for viewport */ for (i=0; i<4; i++) { - projection[i] = w * nmesa->projection.m[i]; + projection[i] = w * ctx->_ModelProjectMatrix.m[i*4]; } for (i=0; i<4; i++) { - projection[i+4] = -h * nmesa->projection.m[i+4]; + projection[i+4] = -h * ctx->_ModelProjectMatrix.m[i*4+1]; } for (i=0; i<4; i++) { - projection[i+8] = max_depth * nmesa->projection.m[i+8]; + projection[i+8] = max_depth * ctx->_ModelProjectMatrix.m[i*4+2]; } for (i=0; i<4; i++) { - projection[i+12] = nmesa->projection.m[i+12]; + projection[i+12] = ctx->_ModelProjectMatrix.m[i*4+3]; } BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX(0), 16); -- cgit v1.2.3 From 8752a20decab59de4dd5feb9672b8299126eb7eb Mon Sep 17 00:00:00 2001 From: Stephane Marchesin Date: Tue, 4 Sep 2007 23:21:21 +0200 Subject: nouveau: who needs nv03 ? --- src/mesa/drivers/dri/nouveau/nouveau_card_list.h | 7 ------- src/mesa/drivers/dri/nouveau/nouveau_context.c | 3 --- src/mesa/drivers/dri/nouveau/nouveau_state.c | 3 --- 3 files changed, 13 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_card_list.h b/src/mesa/drivers/dri/nouveau/nouveau_card_list.h index 8ec5c4a188a..c2600bc5328 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_card_list.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_card_list.h @@ -1,7 +1,4 @@ static nouveau_card nouveau_card_list[]={ -{0x0008, "EDGE 3D", 0, NV_03, 0}, -{0x0009, "EDGE 3D", 0, NV_03, 0}, -{0x0010, "Mutara V08", 0, NV_03, 0}, {0x0020, "RIVA TNT", NV04_DX5_TEXTURED_TRIANGLE, NV_04, 0}, {0x0028, "RIVA TNT2/TNT2 Pro", NV04_DX5_TEXTURED_TRIANGLE, NV_04, 0}, {0x0029, "RIVA TNT2 Ultra", NV04_DX5_TEXTURED_TRIANGLE, NV_04, 0}, @@ -220,10 +217,6 @@ static nouveau_card nouveau_card_list[]={ {0x03D1, "GeForce 6100 nForce 405", NV30_TCL_PRIMITIVE_3D|0x4400, NV_44, 0}, {0x03D2, "GeForce 6100 nForce 400", NV30_TCL_PRIMITIVE_3D|0x4400, NV_44, 0}, {0x03D5, "GeForce 6100 nForce 420", NV30_TCL_PRIMITIVE_3D|0x4400, NV_44, 0}, -{0x0008, "NV1", 0, NV_03, 0}, -{0x0009, "DAC64", 0, NV_03, 0}, -{0x0018, "Riva128", 0, NV_03, 0}, -{0x0019, "Riva128ZX", 0, NV_03, 0}, {0x0020, "TNT", NV04_DX5_TEXTURED_TRIANGLE, NV_04, 0}, {0x0028, "TNT2", NV04_DX5_TEXTURED_TRIANGLE, NV_04, 0}, {0x0029, "UTNT2", NV04_DX5_TEXTURED_TRIANGLE, NV_04, 0}, diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 1e13324b983..f9f33eceeb1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -216,9 +216,6 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual, nouveauDDInitState( nmesa ); switch(nmesa->screen->card->type) { - case NV_03: - //nv03TriInitFunctions( ctx ); - break; case NV_04: case NV_05: nv04TriInitFunctions( ctx ); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 9e64a7010ef..1cfcc314865 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -171,9 +171,6 @@ void nouveauDDInitState(nouveauContextPtr nmesa) uint32_t type = nmesa->screen->card->type; switch(type) { - case NV_03: - /* Unimplemented */ - break; case NV_04: case NV_05: nv04InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver); -- cgit v1.2.3 From 1a15b2169ba6cb100627eb525a20a00537cfb6f0 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 5 Sep 2007 13:31:01 +0800 Subject: i965: only take non-varying attribute into account when compiling sf_prog. fix bug#11378 (which is introduced by commit d619cceea47dc3070ebb7f7ea4f8b6b31a672d38) --- src/mesa/drivers/dri/i965/brw_sf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index 73232b3c7c8..a655b010fdb 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -43,7 +43,7 @@ #include "brw_sf.h" #include "brw_state.h" -#define DO_SETUP_BITS ((1< Date: Wed, 5 Sep 2007 23:35:52 +0200 Subject: nouveau: nv10: emit vertex data in proper order for nv1x hw --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 78 ++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index e31faf21a78..be351df8f67 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -417,31 +417,65 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) /* * Tell t_vertex about the vertex format */ - for(i=0;i<16;i++) - { - if (RENDERINPUTS_TEST(index, i)) + if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) { + +#define NV10_EMIT_VERTEX_ATTRIB(i) \ + do { \ + if (RENDERINPUTS_TEST(index, i)) { \ + switch(attr_size[i]) \ + { \ + case 1: \ + EMIT_ATTR(i,EMIT_1F); \ + break; \ + case 2: \ + EMIT_ATTR(i,EMIT_2F); \ + break; \ + case 3: \ + EMIT_ATTR(i,EMIT_3F); \ + break; \ + case 4: \ + EMIT_ATTR(i,EMIT_4F); \ + break; \ + } \ + total_size+=attr_size[i]; \ + } \ + } while (0) + + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_FOG); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_WEIGHT); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_NORMAL); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_TEX1); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_TEX0); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_COLOR1); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_COLOR0); + NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_POS); + } else { + for(i=0;i<16;i++) { - slots=i+1; - switch(attr_size[i]) + if (RENDERINPUTS_TEST(index, i)) { - case 1: - EMIT_ATTR(i,EMIT_1F); - break; - case 2: - EMIT_ATTR(i,EMIT_2F); - break; - case 3: - EMIT_ATTR(i,EMIT_3F); - break; - case 4: - EMIT_ATTR(i,EMIT_4F); - break; + slots=i+1; + switch(attr_size[i]) + { + case 1: + EMIT_ATTR(i,EMIT_1F); + break; + case 2: + EMIT_ATTR(i,EMIT_2F); + break; + case 3: + EMIT_ATTR(i,EMIT_3F); + break; + case 4: + EMIT_ATTR(i,EMIT_4F); + break; + } + if (i==_TNL_ATTRIB_COLOR0) + nmesa->color_offset=total_size; + if (i==_TNL_ATTRIB_COLOR1) + nmesa->specular_offset=total_size; + total_size+=attr_size[i]; } - if (i==_TNL_ATTRIB_COLOR0) - nmesa->color_offset=total_size; - if (i==_TNL_ATTRIB_COLOR1) - nmesa->specular_offset=total_size; - total_size+=attr_size[i]; } } -- cgit v1.2.3 From a956184f70733bd22e2bbee515386da12302963f Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 6 Sep 2007 19:12:58 +0200 Subject: Disable an assert for hw that do not emit POS as first vertex attrib, like nv1x --- src/mesa/tnl/t_vertex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index a6728c318fe..da32be9a179 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -294,7 +294,7 @@ GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map, GLuint i, j; assert(nr < _TNL_ATTRIB_MAX); - assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS); +/* assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS);*/ vtx->new_inputs = ~0; vtx->need_viewport = GL_FALSE; -- cgit v1.2.3 From 8f9b9ac387b1ffcecdca749b22d59eef5604bc6f Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 6 Sep 2007 19:58:59 +0200 Subject: nouveau: need parenthesis around macro params, generator should be fixed --- src/mesa/drivers/dri/nouveau/nouveau_reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_reg.h b/src/mesa/drivers/dri/nouveau/nouveau_reg.h index 8758b538c85..b5e40dd6c64 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_reg.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_reg.h @@ -502,7 +502,7 @@ Object NV11_TCL_PRIMITIVE_3D used on: NV15 # define NV10_TCL_PRIMITIVE_3D_VERTEX_FOG_1F 0x00000ce0 # define NV10_TCL_PRIMITIVE_3D_VERTEX_WGH_1F 0x00000ce4 # define NV10_TCL_PRIMITIVE_3D_EDGEFLAG_ENABLE 0x00000cec -# define NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR( d) (0x00000d04 + d * 0x0008) /* Parameters: stride fields type */ +# define NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR( d) (0x00000d04 + ((d) * 0x0008)) /* Parameters: stride fields type */ # define NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_VALIDATE 0x00000cf0 # define NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_POS 0x00000d00 # define NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_POS 0x00000d04 /* Parameters: stride fields type */ -- cgit v1.2.3 From 7307ff80c9141aa9730c17f500e99d3d983840b8 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 6 Sep 2007 20:00:25 +0200 Subject: nouveau: nv10: replace macros by loop to set vertex attributes --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 95 +++++++++++++------------------ 1 file changed, 41 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index be351df8f67..a9bcc5df17a 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -389,6 +389,12 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) struct vertex_buffer *VB = &tnl->vb; int attr_size[16]; int default_attr_size[8]={3,3,3,4,3,1,4,4}; + const int nv10_vtx_attribs[8]={ + _TNL_ATTRIB_FOG, _TNL_ATTRIB_WEIGHT, + _TNL_ATTRIB_NORMAL, _TNL_ATTRIB_TEX1, + _TNL_ATTRIB_TEX0, _TNL_ATTRIB_COLOR1, + _TNL_ATTRIB_COLOR0, _TNL_ATTRIB_POS + }; int i; int slots=0; int total_size=0; @@ -418,37 +424,27 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) * Tell t_vertex about the vertex format */ if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) { - -#define NV10_EMIT_VERTEX_ATTRIB(i) \ - do { \ - if (RENDERINPUTS_TEST(index, i)) { \ - switch(attr_size[i]) \ - { \ - case 1: \ - EMIT_ATTR(i,EMIT_1F); \ - break; \ - case 2: \ - EMIT_ATTR(i,EMIT_2F); \ - break; \ - case 3: \ - EMIT_ATTR(i,EMIT_3F); \ - break; \ - case 4: \ - EMIT_ATTR(i,EMIT_4F); \ - break; \ - } \ - total_size+=attr_size[i]; \ - } \ - } while (0) - - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_FOG); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_WEIGHT); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_NORMAL); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_TEX1); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_TEX0); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_COLOR1); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_COLOR0); - NV10_EMIT_VERTEX_ATTRIB(_TNL_ATTRIB_POS); + for(i=0;i<8;i++) { + int j = nv10_vtx_attribs[i]; + if (RENDERINPUTS_TEST(index, j)) { + switch(attr_size[j]) + { + case 1: + EMIT_ATTR(j,EMIT_1F); + break; + case 2: + EMIT_ATTR(j,EMIT_2F); + break; + case 3: + EMIT_ATTR(j,EMIT_3F); + break; + case 4: + EMIT_ATTR(j,EMIT_4F); + break; + } + total_size+=attr_size[j]; + } + } } else { for(i=0;i<16;i++) { @@ -493,29 +489,20 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) #define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2 -#define NV10_SET_VERTEX_ATTRIB(i,j) \ - do { \ - int size; \ - int stride = attr_size[j] << 2; \ - if (i==0) { \ - stride += total_stride; \ - } \ - size = attr_size[j] << 4; \ - size |= stride << 8; \ - size |= NV_VERTEX_ATTRIBUTE_TYPE_FLOAT; \ - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR(i),1); \ - OUT_RING_CACHE(size); \ - total_stride += stride; \ - } while (0) - - NV10_SET_VERTEX_ATTRIB(7, _TNL_ATTRIB_FOG); - NV10_SET_VERTEX_ATTRIB(6, _TNL_ATTRIB_WEIGHT); - NV10_SET_VERTEX_ATTRIB(5, _TNL_ATTRIB_NORMAL); - NV10_SET_VERTEX_ATTRIB(4, _TNL_ATTRIB_TEX1); - NV10_SET_VERTEX_ATTRIB(3, _TNL_ATTRIB_TEX0); - NV10_SET_VERTEX_ATTRIB(2, _TNL_ATTRIB_COLOR1); - NV10_SET_VERTEX_ATTRIB(1, _TNL_ATTRIB_COLOR0); - NV10_SET_VERTEX_ATTRIB(0, _TNL_ATTRIB_POS); + for(i=0;i<8;i++) { + int j = nv10_vtx_attribs[i]; + int size; + int stride = attr_size[j] << 2; + if (j==_TNL_ATTRIB_POS) { + stride += total_stride; + } + size = attr_size[j] << 4; + size |= stride << 8; + size |= NV_VERTEX_ATTRIBUTE_TYPE_FLOAT; + BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR((7-i)),1); + OUT_RING_CACHE(size); + total_stride += stride; + } BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_VALIDATE,1); OUT_RING_CACHE(0); -- cgit v1.2.3 From 15a6bf9118937e1e705e64e36fbceafbb3ad70ed Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 6 Sep 2007 22:33:22 +0200 Subject: nouveau: init depth range --- src/mesa/drivers/dri/nouveau/nouveau_state.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 1cfcc314865..e2f9fb869a1 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -296,6 +296,7 @@ void nouveauInitState(GLcontext *ctx) STATE_INIT(CullFace)( ctx, ctx->Polygon.CullFaceMode ); STATE_INIT(DepthFunc)( ctx, ctx->Depth.Func ); STATE_INIT(DepthMask)( ctx, ctx->Depth.Mask ); + STATE_INIT(DepthRange)( ctx, ctx->Viewport.Near, ctx->Viewport.Far ); STATE_INIT(Enable)( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled ); STATE_INIT(Enable)( ctx, GL_BLEND, ctx->Color.BlendEnabled ); -- cgit v1.2.3 From 249ca55555beea76c63a5f5dd09d35aa45efa180 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 6 Sep 2007 22:36:12 +0200 Subject: nouveau: nv10: check NULL pointers --- src/mesa/drivers/dri/nouveau/nv10_state.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 94525ba2a80..b63893d05c4 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -253,8 +253,12 @@ static void nv10DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval) nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); GLfloat depth_scale = 16777216.0; - if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 16) { - depth_scale = 32768.0; + if (ctx->DrawBuffer) { + if (ctx->DrawBuffer->_DepthBuffer) { + if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 16) { + depth_scale = 32768.0; + } + } } BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2); -- cgit v1.2.3 From 241b7bc0a3e6277e15bb45887ad5533ffe692428 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 11 Sep 2007 16:49:02 +0800 Subject: i965: limit on LOD Bias, fix#11987 --- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 81fc9ef2f0c..8afefdd4353 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -178,7 +178,7 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit, /* Set LOD bias: */ - sampler->ss0.lod_bias = S_FIXED(texUnit->LodBias + texObj->LodBias, 6); + sampler->ss0.lod_bias = S_FIXED(CLAMP(texUnit->LodBias + texObj->LodBias, -16, 15), 6); sampler->ss0.lod_preclamp = 1; /* OpenGL mode */ sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */ -- cgit v1.2.3 From 0aedb9a2042bef9c13358500f93acaf8459a74cb Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 11 Sep 2007 16:57:07 +0800 Subject: i965: take the secondary color into account when drawing bitmap. fix#10688 --- src/mesa/drivers/dri/i965/intel_pixel_bitmap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c index 23f381fe917..79c1fee9c07 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c @@ -168,7 +168,8 @@ do_blit_bitmap( GLcontext *ctx, { struct intel_context *intel = intel_context(ctx); struct intel_region *dst = intel_drawbuf_region(intel); - + GLfloat tmpColor[4]; + union { GLuint ui; GLubyte ub[4]; @@ -183,10 +184,16 @@ do_blit_bitmap( GLcontext *ctx, return GL_TRUE; /* even though this is an error, we're done */ } - UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], ctx->Current.RasterColor[2]); - UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], ctx->Current.RasterColor[1]); - UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], ctx->Current.RasterColor[0]); - UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], ctx->Current.RasterColor[3]); + COPY_4V(tmpColor, ctx->Current.RasterColor); + + if (NEED_SECONDARY_COLOR(ctx)) { + ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor); + } + + UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], tmpColor[2]); + UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], tmpColor[1]); + UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], tmpColor[0]); + UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], tmpColor[3]); /* Does zoom apply to bitmaps? */ -- cgit v1.2.3 From 78b7e49c846c535f6907c18a9982d07c9e9feabb Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Tue, 11 Sep 2007 03:54:34 -0700 Subject: intel: disentangle planes & pipes This is the Mesa portion of the pipe & plane disambiguation. Mesa needs to use the new assumptions about plane vs. pipe mappings and should use the new SAREA field names to avoid confusion. --- src/mesa/drivers/dri/i915/intel_context.c | 20 ++++----- src/mesa/drivers/dri/i915/server/i830_common.h | 19 ++++---- src/mesa/drivers/dri/i915tex/intel_buffers.c | 54 +++++++++++------------ src/mesa/drivers/dri/i915tex/intel_fbo.h | 2 +- src/mesa/drivers/dri/i915tex/server/i830_common.h | 19 ++++---- 5 files changed, 60 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index 11c23f24a1b..07bee4ef9f9 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -564,16 +564,16 @@ void intelWindowMoved( intelContextPtr intel ) drmI830Sarea *sarea = intel->sarea; drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h }; - drm_clip_rect_t pipeA_rect = { .x1 = sarea->pipeA_x, - .x2 = sarea->pipeA_x + sarea->pipeA_w, - .y1 = sarea->pipeA_y, - .y2 = sarea->pipeA_y + sarea->pipeA_h }; - drm_clip_rect_t pipeB_rect = { .x1 = sarea->pipeB_x, - .x2 = sarea->pipeB_x + sarea->pipeB_w, - .y1 = sarea->pipeB_y, - .y2 = sarea->pipeB_y + sarea->pipeB_h }; - GLint areaA = driIntersectArea( drw_rect, pipeA_rect ); - GLint areaB = driIntersectArea( drw_rect, pipeB_rect ); + drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, + .x2 = sarea->planeA_x + sarea->planeA_w, + .y1 = sarea->planeA_y, + .y2 = sarea->planeA_y + sarea->planeA_h }; + drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, + .x2 = sarea->planeB_x + sarea->planeB_w, + .y1 = sarea->planeB_y, + .y2 = sarea->planeB_y + sarea->planeB_h }; + GLint areaA = driIntersectArea( drw_rect, planeA_rect ); + GLint areaB = driIntersectArea( drw_rect, planeB_rect ); GLuint flags = intel->vblank_flags; if (areaB > areaA || (areaA == areaB && areaB > 0)) { diff --git a/src/mesa/drivers/dri/i915/server/i830_common.h b/src/mesa/drivers/dri/i915/server/i830_common.h index fb6ceaa52d4..a5d2598849b 100644 --- a/src/mesa/drivers/dri/i915/server/i830_common.h +++ b/src/mesa/drivers/dri/i915/server/i830_common.h @@ -119,14 +119,17 @@ typedef struct { unsigned int rotated_tiled; unsigned int rotated2_tiled; - int pipeA_x; - int pipeA_y; - int pipeA_w; - int pipeA_h; - int pipeB_x; - int pipeB_y; - int pipeB_w; - int pipeB_h; + int planeA_x; + int planeA_y; + int planeA_w; + int planeA_h; + int planeB_x; + int planeB_y; + int planeB_w; + int planeB_h; + + int planeA_pipe; + int planeB_pipe; } drmI830Sarea; /* Flags for perf_boxes diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 15d02f8e2cf..40f93dac912 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -50,7 +50,7 @@ #define DRM_VBLANK_FLIP 0x8000000 typedef struct drm_i915_flip { - int pipes; + int planes; } drm_i915_flip_t; #undef DRM_IOCTL_I915_FLIP @@ -235,34 +235,34 @@ intelWindowMoved(struct intel_context *intel) drmI830Sarea *sarea = intel->sarea; drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h }; - drm_clip_rect_t pipeA_rect = { .x1 = sarea->pipeA_x, .y1 = sarea->pipeA_y, - .x2 = sarea->pipeA_x + sarea->pipeA_w, - .y2 = sarea->pipeA_y + sarea->pipeA_h }; - drm_clip_rect_t pipeB_rect = { .x1 = sarea->pipeB_x, .y1 = sarea->pipeB_y, - .x2 = sarea->pipeB_x + sarea->pipeB_w, - .y2 = sarea->pipeB_y + sarea->pipeB_h }; - GLint areaA = driIntersectArea( drw_rect, pipeA_rect ); - GLint areaB = driIntersectArea( drw_rect, pipeB_rect ); + drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y, + .x2 = sarea->planeA_x + sarea->planeA_w, + .y2 = sarea->planeA_y + sarea->planeA_h }; + drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, .y1 = sarea->planeB_y, + .x2 = sarea->planeB_x + sarea->planeB_w, + .y2 = sarea->planeB_y + sarea->planeB_h }; + GLint areaA = driIntersectArea( drw_rect, planeA_rect ); + GLint areaB = driIntersectArea( drw_rect, planeB_rect ); GLuint flags = intel_fb->vblank_flags; GLboolean pf_active; - GLint pf_pipes; + GLint pf_planes; /* Update page flipping info */ - pf_pipes = 0; + pf_planes = 0; if (areaA > 0) - pf_pipes |= 1; + pf_planes |= 1; if (areaB > 0) - pf_pipes |= 2; + pf_planes |= 2; intel_fb->pf_current_page = (intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3; + (intel_fb->pf_planes & 0x2)) & 0x3; intel_fb->pf_num_pages = intel->intelScreen->third.handle ? 3 : 2; - pf_active = pf_pipes && (pf_pipes & intel->sarea->pf_active) == pf_pipes; + pf_active = pf_planes && (pf_planes & intel->sarea->pf_active) == pf_planes; if (INTEL_DEBUG & DEBUG_LOCK) if (pf_active != intel_fb->pf_active) @@ -270,8 +270,8 @@ intelWindowMoved(struct intel_context *intel) pf_active ? "" : "in"); if (pf_active) { - /* Sync pages between pipes if we're flipping on both at the same time */ - if (pf_pipes == 0x3 && pf_pipes != intel_fb->pf_pipes && + /* Sync pages between planes if flipping on both at the same time */ + if (pf_planes == 0x3 && pf_planes != intel_fb->pf_planes && (intel->sarea->pf_current_page & 0x3) != (((intel->sarea->pf_current_page) >> 2) & 0x3)) { drm_i915_flip_t flip; @@ -287,7 +287,7 @@ intelWindowMoved(struct intel_context *intel) ((intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) % intel_fb->pf_num_pages) << 2; - flip.pipes = 0x2; + flip.planes = 0x2; } else { intel->sarea->pf_current_page = intel->sarea->pf_current_page & (0x3 << 2); @@ -295,13 +295,13 @@ intelWindowMoved(struct intel_context *intel) (intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) % intel_fb->pf_num_pages; - flip.pipes = 0x1; + flip.planes = 0x1; } drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip)); } - intel_fb->pf_pipes = pf_pipes; + intel_fb->pf_planes = pf_planes; } intel_fb->pf_active = pf_active; @@ -715,14 +715,14 @@ intel_wait_flips(struct intel_context *intel, GLuint batch_flags) BUFFER_BACK_LEFT); if (intel_fb->Base.Name == 0 && intel_rb->pf_pending == intel_fb->pf_seq) { - GLint pf_pipes = intel_fb->pf_pipes; + GLint pf_planes = intel_fb->pf_planes; BATCH_LOCALS; /* Wait for pending flips to take effect */ BEGIN_BATCH(2, batch_flags); - OUT_BATCH(pf_pipes & 0x1 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP) + OUT_BATCH(pf_planes & 0x1 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP) : 0); - OUT_BATCH(pf_pipes & 0x2 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_B_FLIP) + OUT_BATCH(pf_planes & 0x2 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_B_FLIP) : 0); ADVANCE_BATCH(); @@ -761,7 +761,7 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv) if (dPriv->numClipRects && intel_fb->pf_active) { drm_i915_flip_t flip; - flip.pipes = intel_fb->pf_pipes; + flip.planes = intel_fb->pf_planes; ret = drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip)); } @@ -776,7 +776,7 @@ intelPageFlip(const __DRIdrawablePrivate * dPriv) } intel_fb->pf_current_page = (intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3; + (intel_fb->pf_planes & 0x2)) & 0x3; if (dPriv->numClipRects != 0) { intel_get_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT)->pf_pending = @@ -860,7 +860,7 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) swap.seqtype |= DRM_VBLANK_FLIP; intel_fb->pf_current_page = (((intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3) + 1) % + (intel_fb->pf_planes & 0x2)) & 0x3) + 1) % intel_fb->pf_num_pages; } @@ -884,7 +884,7 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target) } else { if (swap.seqtype & DRM_VBLANK_FLIP) { intel_fb->pf_current_page = ((intel->sarea->pf_current_page >> - (intel_fb->pf_pipes & 0x2)) & 0x3) % + (intel_fb->pf_planes & 0x2)) & 0x3) % intel_fb->pf_num_pages; } diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.h b/src/mesa/drivers/dri/i915tex/intel_fbo.h index 963f5e706f4..411d6342317 100644 --- a/src/mesa/drivers/dri/i915tex/intel_fbo.h +++ b/src/mesa/drivers/dri/i915tex/intel_fbo.h @@ -44,7 +44,7 @@ struct intel_framebuffer /* Drawable page flipping state */ GLboolean pf_active; GLuint pf_seq; - GLint pf_pipes; + GLint pf_planes; GLint pf_current_page; GLint pf_num_pages; diff --git a/src/mesa/drivers/dri/i915tex/server/i830_common.h b/src/mesa/drivers/dri/i915tex/server/i830_common.h index d4d58886ce0..07cc63f6631 100644 --- a/src/mesa/drivers/dri/i915tex/server/i830_common.h +++ b/src/mesa/drivers/dri/i915tex/server/i830_common.h @@ -121,14 +121,17 @@ typedef struct { unsigned int rotated_tiled; unsigned int rotated2_tiled; - int pipeA_x; - int pipeA_y; - int pipeA_w; - int pipeA_h; - int pipeB_x; - int pipeB_y; - int pipeB_w; - int pipeB_h; + int planeA_x; + int planeA_y; + int planeA_w; + int planeA_h; + int planeB_x; + int planeB_y; + int planeB_w; + int planeB_h; + + int planeA_pipe; + int planeB_pipe; /* Triple buffering */ drm_handle_t third_handle; -- cgit v1.2.3 From 0c43ab6fbcd43f611170885f2068dd3a06bc6cea Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 11 Sep 2007 09:20:48 -0600 Subject: fix comment --- src/mesa/drivers/dri/i915tex/i915_metaops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/i915_metaops.c b/src/mesa/drivers/dri/i915tex/i915_metaops.c index 3ab62bc806b..397ff75b6f1 100644 --- a/src/mesa/drivers/dri/i915tex/i915_metaops.c +++ b/src/mesa/drivers/dri/i915tex/i915_metaops.c @@ -95,7 +95,7 @@ meta_depth_replace(struct intel_context *intel) i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE | S6_DEPTH_WRITE_ENABLE); - /* ctx->Driver.DepthFunc( ctx, GL_REPLACE ) + /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS ) */ i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK; i915->meta.Ctx[I915_CTXREG_LIS6] |= -- cgit v1.2.3 From 995e01a6bcfe280149a2a076b5ea66ee94d0721c Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 11 Sep 2007 09:21:34 -0600 Subject: Update depth test state when binding new framebuffer object --- src/mesa/drivers/dri/i915tex/intel_buffers.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c index 40f93dac912..cb151ab94d8 100644 --- a/src/mesa/drivers/dri/i915tex/intel_buffers.c +++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c @@ -1124,6 +1124,15 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled); } + /* + * Update depth test state + */ + if (ctx->Depth.Test && fb->Visual.depthBits > 0) { + ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_TRUE); + } + else { + ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_FALSE); + } /** ** Release old regions, reference new regions -- cgit v1.2.3 From a614877592e8526d997242ce336fb455dd3f5bdb Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 11 Sep 2007 10:56:35 -0600 Subject: In _mesa_make_current(), don't unbind FBOs from the old context. This fixes the X server crash reported by KeithP on Aug 29. The old context's FBOs will be unreferenced during context destruction so there's no memleak with this change. --- src/mesa/main/context.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index d988ef2d215..08db12b1b67 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1499,8 +1499,6 @@ void _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer ) { - GET_CURRENT_CONTEXT(oldCtx); - if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(newCtx, "_mesa_make_current()\n"); @@ -1525,13 +1523,6 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, _glapi_set_context((void *) newCtx); ASSERT(_mesa_get_current_context() == newCtx); - if (oldCtx) { - _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer); - _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer); - _mesa_unreference_framebuffer(&oldCtx->DrawBuffer); - _mesa_unreference_framebuffer(&oldCtx->ReadBuffer); - } - if (!newCtx) { _glapi_set_dispatch(NULL); /* none current */ } -- cgit v1.2.3 From acfeb3b6ea93bcb5b18e6f51a0727e39da608d76 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 11 Sep 2007 10:57:37 -0600 Subject: Fix-up #includes to remove some -I options. eg: #include "shader/program.h" and remove -I$(TOP)/src/mesa/program --- src/mesa/drivers/dri/Makefile.template | 5 ----- src/mesa/drivers/dri/i915/i915_fragprog.c | 11 ++++++----- src/mesa/drivers/dri/i915tex/i915_fragprog.c | 11 ++++++----- src/mesa/drivers/dri/i965/brw_program.c | 10 +++++----- src/mesa/drivers/dri/i965/brw_sf.h | 2 +- src/mesa/drivers/dri/i965/brw_vs.h | 2 +- src/mesa/drivers/dri/i965/brw_vs_emit.c | 4 ++-- src/mesa/drivers/dri/i965/brw_wm.h | 2 +- src/mesa/drivers/dri/r200/r200_fragshader.c | 10 +++++----- src/mesa/drivers/dri/r200/r200_vertprog.c | 8 ++++---- src/mesa/drivers/dri/r300/r300_shader.c | 7 +++---- src/mesa/drivers/dri/r300/r300_swtcl.c | 1 + src/mesa/drivers/dri/r300/r300_vertprog.c | 8 ++++---- src/mesa/drivers/dri/radeon/radeon_context.c | 17 +++++++++-------- 14 files changed, 48 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 6f2314ee8cb..adf30ef41e6 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -49,11 +49,6 @@ SHARED_INCLUDES = \ -I$(TOP)/src/mesa \ -I$(TOP)/src/mesa/main \ -I$(TOP)/src/mesa/glapi \ - -I$(TOP)/src/mesa/math \ - -I$(TOP)/src/mesa/transform \ - -I$(TOP)/src/mesa/shader \ - -I$(TOP)/src/mesa/swrast \ - -I$(TOP)/src/mesa/swrast_setup \ -I$(TOP)/src/egl/main \ -I$(TOP)/src/egl/drivers/dri \ $(LIBDRM_CFLAGS) diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c index abca0bbffea..c839bbdea5c 100644 --- a/src/mesa/drivers/dri/i915/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c @@ -29,19 +29,20 @@ #include "macros.h" #include "enums.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/program.h" +#include "shader/programopt.h" + #include "tnl/tnl.h" #include "tnl/t_context.h" + #include "intel_batchbuffer.h" #include "i915_reg.h" #include "i915_context.h" #include "i915_program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "program.h" -#include "programopt.h" - /* 1, -1/3!, 1/5!, -1/7! */ diff --git a/src/mesa/drivers/dri/i915tex/i915_fragprog.c b/src/mesa/drivers/dri/i915tex/i915_fragprog.c index 95ec50490a2..4c3f2236e5e 100644 --- a/src/mesa/drivers/dri/i915tex/i915_fragprog.c +++ b/src/mesa/drivers/dri/i915tex/i915_fragprog.c @@ -29,19 +29,20 @@ #include "macros.h" #include "enums.h" +#include "shader/prog_instruction.h" +#include "shader/prog_parameter.h" +#include "shader/program.h" +#include "shader/programopt.h" + #include "tnl/tnl.h" #include "tnl/t_context.h" + #include "intel_batchbuffer.h" #include "i915_reg.h" #include "i915_context.h" #include "i915_program.h" -#include "prog_instruction.h" -#include "prog_parameter.h" -#include "program.h" -#include "programopt.h" - /* 1, -1/3!, 1/5!, -1/7! */ diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 752fe49bcbf..f7b1d318105 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -29,15 +29,15 @@ * Keith Whitwell */ +#include "main/imports.h" +#include "main/enums.h" #include "shader/prog_parameter.h" +#include "shader/program.h" +#include "tnl/tnl.h" + #include "brw_context.h" #include "brw_aub.h" #include "brw_util.h" -#include "program.h" -#include "imports.h" -#include "enums.h" -#include "tnl/tnl.h" - static void brwBindProgram( GLcontext *ctx, GLenum target, diff --git a/src/mesa/drivers/dri/i965/brw_sf.h b/src/mesa/drivers/dri/i965/brw_sf.h index e374e372bb0..e8946511dd4 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.h +++ b/src/mesa/drivers/dri/i965/brw_sf.h @@ -34,9 +34,9 @@ #define BRW_SF_H +#include "shader/program.h" #include "brw_context.h" #include "brw_eu.h" -#include "program.h" #define SF_POINTS 0 diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index fdb5785d67d..8843f816f9c 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -36,7 +36,7 @@ #include "brw_context.h" #include "brw_eu.h" -#include "program.h" +#include "shader/program.h" struct brw_vs_prog_key { diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index d00f0c71a8f..8733b470c25 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -30,8 +30,8 @@ */ -#include "program.h" -#include "macros.h" +#include "main/macros.h" +#include "shader/program.h" #include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "brw_context.h" diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index f5fddfdb68a..6dcf4732a9f 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -34,9 +34,9 @@ #define BRW_WM_H +#include "shader/prog_instruction.h" #include "brw_context.h" #include "brw_eu.h" -#include "prog_instruction.h" /* A big lookup table is used to figure out which and how many * additional regs will inserted before the main payload in the WM diff --git a/src/mesa/drivers/dri/r200/r200_fragshader.c b/src/mesa/drivers/dri/r200/r200_fragshader.c index 5dd3adaef69..d514b28219a 100644 --- a/src/mesa/drivers/dri/r200/r200_fragshader.c +++ b/src/mesa/drivers/dri/r200/r200_fragshader.c @@ -24,13 +24,13 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/ -#include "glheader.h" -#include "macros.h" -#include "enums.h" +#include "main/glheader.h" +#include "main/macros.h" +#include "main/enums.h" #include "tnl/t_context.h" -#include "atifragshader.h" -#include "program.h" +#include "shader/atifragshader.h" +#include "shader/program.h" #include "r200_context.h" #include "r200_ioctl.h" #include "r200_tex.h" diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c index 6089d617c6b..604b9c6caec 100644 --- a/src/mesa/drivers/dri/r200/r200_vertprog.c +++ b/src/mesa/drivers/dri/r200/r200_vertprog.c @@ -30,10 +30,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Aapo Tahkola * Roland Scheidegger */ -#include "glheader.h" -#include "macros.h" -#include "enums.h" -#include "program.h" +#include "main/glheader.h" +#include "main/macros.h" +#include "main/enums.h" +#include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" #include "shader/prog_statevars.h" diff --git a/src/mesa/drivers/dri/r300/r300_shader.c b/src/mesa/drivers/dri/r300/r300_shader.c index 5f5ac7c4c71..77abf86a8ee 100644 --- a/src/mesa/drivers/dri/r300/r300_shader.c +++ b/src/mesa/drivers/dri/r300/r300_shader.c @@ -1,8 +1,7 @@ -#include "glheader.h" -#include "macros.h" -#include "enums.h" -#include "program.h" +#include "main/glheader.h" + +#include "shader/program.h" #include "tnl/tnl.h" #include "r300_context.h" #include "r300_fragprog.h" diff --git a/src/mesa/drivers/dri/r300/r300_swtcl.c b/src/mesa/drivers/dri/r300/r300_swtcl.c index c949f33bf33..a732bdb5598 100644 --- a/src/mesa/drivers/dri/r300/r300_swtcl.c +++ b/src/mesa/drivers/dri/r300/r300_swtcl.c @@ -40,6 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "enums.h" #include "image.h" #include "imports.h" +#include "light.h" #include "macros.h" #include "swrast/s_context.h" diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 7d4e8c95112..4dd3fd6a673 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -35,10 +35,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * For a description of the vertex program instruction set see r300_reg.h. */ -#include "glheader.h" -#include "macros.h" -#include "enums.h" -#include "program.h" +#include "main/glheader.h" +#include "main/macros.h" +#include "main/enums.h" +#include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" #include "shader/prog_statevars.h" diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 9451ec4aa5b..b302275c714 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -35,14 +35,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell */ -#include "glheader.h" -#include "api_arrayelt.h" -#include "context.h" -#include "simple_list.h" -#include "imports.h" -#include "matrix.h" -#include "extensions.h" -#include "framebuffer.h" +#include "main/glheader.h" +#include "main/api_arrayelt.h" +#include "main/context.h" +#include "main/simple_list.h" +#include "main/imports.h" +#include "main/matrix.h" +#include "main/extensions.h" +#include "main/framebuffer.h" +#include "main/state.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" -- cgit v1.2.3 From 9944174abc546fe1845c26ce496edd747ad34347 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 11 Sep 2007 15:24:43 -0600 Subject: prefix some include filenames with shader/ --- src/mesa/drivers/common/driverfuncs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 9b1c3f1e060..1e7c279875e 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -25,11 +25,10 @@ #include "glheader.h" #include "imports.h" +#include "arrayobj.h" #include "buffers.h" #include "context.h" #include "framebuffer.h" -#include "program.h" -#include "prog_execute.h" #include "queryobj.h" #include "renderbuffer.h" #include "texcompress.h" @@ -44,9 +43,10 @@ #include "fbobject.h" #include "texrender.h" #endif -#include "shader_api.h" -#include "arrayobj.h" +#include "shader/program.h" +#include "shader/prog_execute.h" +#include "shader/shader_api.h" #include "driverfuncs.h" #include "tnl/tnl.h" #include "swrast/swrast.h" -- cgit v1.2.3 From ae078e1a0abae58e325ed3ebcb1884867847826b Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Wed, 12 Sep 2007 15:13:06 +0800 Subject: i965: revert commit 1a15b2169ba6cb100627eb525a20a00537cfb6f0, and keep the instruction state unchanged after calling brw_emit_tri_setup/brw_emit_line_setup when building setup thread for SF_UNFILLED_TRIS. --- src/mesa/drivers/dri/i965/brw_sf.c | 2 +- src/mesa/drivers/dri/i965/brw_sf_emit.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index a655b010fdb..738ceb0552e 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -43,7 +43,7 @@ #include "brw_sf.h" #include "brw_state.h" -#define DO_SETUP_BITS ((1<<(FRAG_ATTRIB_MAX - MAX_VARYING))-1) +#define DO_SETUP_BITS ((1<<(FRAG_ATTRIB_MAX)) - 1) static void compile_sf_prog( struct brw_context *brw, struct brw_sf_prog_key *key ) diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c index 22911a46494..5e86e428fa8 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_emit.c +++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c @@ -663,7 +663,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) (1<<_3DPRIM_TRIFAN_NOSTIPPLE))); jmp = brw_JMPI(p, ip, ip, brw_imm_w(0)); { + brw_push_insn_state(p); brw_emit_tri_setup( c ); + brw_pop_insn_state(p); /* note - thread killed in subroutine */ } brw_land_fwd_jump(p, jmp); @@ -677,7 +679,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) (1<<_3DPRIM_LINESTRIP_CONT_BF))); jmp = brw_JMPI(p, ip, ip, brw_imm_w(0)); { + brw_push_insn_state(p); brw_emit_line_setup( c ); + brw_pop_insn_state(p); /* note - thread killed in subroutine */ } brw_land_fwd_jump(p, jmp); @@ -686,7 +690,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) brw_AND(p, v1_null_ud, payload_attr, brw_imm_ud(1< Date: Wed, 12 Sep 2007 16:51:45 +0800 Subject: i965: translate shadow compare function into correct internal function to match the EXT_shadow_funs spec. fix bug#11925 --- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 2 +- src/mesa/drivers/dri/i965/intel_context.h | 2 +- src/mesa/drivers/dri/i965/intel_state.c | 25 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index 8afefdd4353..3c0952acf0d 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -173,7 +173,7 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit, * message (sample_c). So need to recompile WM program when * shadow comparison is enabled on each/any texture unit. */ - sampler->ss0.shadow_function = intel_translate_compare_func(texObj->CompareFunc); + sampler->ss0.shadow_function = intel_translate_shadow_compare_func(texObj->CompareFunc); } /* Set LOD bias: diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h index ae255929089..053d93a82b3 100644 --- a/src/mesa/drivers/dri/i965/intel_context.h +++ b/src/mesa/drivers/dri/i965/intel_context.h @@ -464,7 +464,7 @@ extern void intelInitStateFuncs( struct dd_function_table *functions ); #define BLENDFACT_INV_CONST_ALPHA 0x0f #define BLENDFACT_MASK 0x0f - +extern int intel_translate_shadow_compare_func( GLenum func ); extern int intel_translate_compare_func( GLenum func ); extern int intel_translate_stencil_op( GLenum op ); extern int intel_translate_blend_factor( GLenum factor ); diff --git a/src/mesa/drivers/dri/i965/intel_state.c b/src/mesa/drivers/dri/i965/intel_state.c index 2e442db6198..2f5467a4e46 100644 --- a/src/mesa/drivers/dri/i965/intel_state.c +++ b/src/mesa/drivers/dri/i965/intel_state.c @@ -38,6 +38,31 @@ #include "intel_regions.h" #include "swrast/swrast.h" +int intel_translate_shadow_compare_func( GLenum func ) +{ + switch(func) { + case GL_NEVER: + return COMPAREFUNC_ALWAYS; + case GL_LESS: + return COMPAREFUNC_LEQUAL; + case GL_LEQUAL: + return COMPAREFUNC_LESS; + case GL_GREATER: + return COMPAREFUNC_GEQUAL; + case GL_GEQUAL: + return COMPAREFUNC_GREATER; + case GL_NOTEQUAL: + return COMPAREFUNC_EQUAL; + case GL_EQUAL: + return COMPAREFUNC_NOTEQUAL; + case GL_ALWAYS: + return COMPAREFUNC_NEVER; + } + + fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func); + return COMPAREFUNC_NEVER; +} + int intel_translate_compare_func( GLenum func ) { switch(func) { -- cgit v1.2.3 From f5557c3a528fbad3750aaa18595dc3548b600609 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 12 Sep 2007 09:57:53 -0600 Subject: DESTDIR support. --- docs/install.html | 10 +++++++++- src/glu/Makefile | 4 ++-- src/glut/fbdev/Makefile | 8 ++++---- src/glut/glx/Makefile | 8 ++++---- src/glw/Makefile | 8 ++++---- src/mesa/Makefile | 14 +++++++------- src/mesa/drivers/dri/Makefile.template | 4 ++-- 7 files changed, 32 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/docs/install.html b/docs/install.html index 804dee59b5a..0a361430697 100644 --- a/docs/install.html +++ b/docs/install.html @@ -287,7 +287,15 @@ already installed, you'll have to choose different directories, like To install Mesa's headers and libraries, run make install. But first, check the Mesa/configs/default file and examine the values of the INSTALL_DIR and DRI_DRIVER_INSTALL_DIR variables. -Change them if needed, then run make install +Change them if needed, then run make install. +

+ +

+The variable +DESTDIR may also be used to install the contents to a temporary +staging directory. +This can be useful for package management. +For example: make install DESTDIR=/somepath/

diff --git a/src/glu/Makefile b/src/glu/Makefile index 5ddc50946aa..b8c55db6d0a 100644 --- a/src/glu/Makefile +++ b/src/glu/Makefile @@ -14,8 +14,8 @@ default: $(TOP)/configs/current done install: - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) clean: @for dir in $(SUBDIRS) ; do \ diff --git a/src/glut/fbdev/Makefile b/src/glut/fbdev/Makefile index 254ff8c098f..d84d52ec48f 100644 --- a/src/glut/fbdev/Makefile +++ b/src/glut/fbdev/Makefile @@ -69,10 +69,10 @@ $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) $(MKLIB_OPTIONS) $(OBJECTS) install: - $(INSTALL) -d $(INSTALL_DIR)/include/GL - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) # Run 'make -f Makefile.solo dep' to update the dependencies if you change # what's included by any source file. diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index 7e1d56b3278..b236c6fad35 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -97,10 +97,10 @@ $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) install: - $(INSTALL) -d $(INSTALL_DIR)/include/GL - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) clean: diff --git a/src/glw/Makefile b/src/glw/Makefile index 5228cbbb721..778ffb02189 100644 --- a/src/glw/Makefile +++ b/src/glw/Makefile @@ -26,10 +26,10 @@ OBJECTS = $(GLW_SOURCES:.c=.o) default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME) install: - $(INSTALL) -d $(INSTALL_DIR)/include/GL - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 *.h $(INSTALL_DIR)/include/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) clean: -rm depend depend.bak diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 6943219036d..a50e826701b 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -149,22 +149,22 @@ subdirs: install: default - $(INSTALL) -d $(INSTALL_DIR)/include/GL - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ + $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ fi @if [ -e $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \ + $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ fi @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ cd drivers/dri ; $(MAKE) install ; \ fi ## NOT INSTALLED YET: -## $(INSTALL) -d $(INSTALL_DIR)/include/GLES -## $(INSTALL) -m 644 include/GLES/*.h $(INSTALL_DIR)/include/GLES +## $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES +## $(INSTALL) -m 644 include/GLES/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES # Emacs tags diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index adf30ef41e6..3576d0bac8f 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -95,8 +95,8 @@ clean: install: $(LIBNAME) - $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) include depend -- cgit v1.2.3 From 94617bc6d505b056b028dc0978ef4a94ee47fa7d Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 12 Sep 2007 10:03:05 -0600 Subject: pkg-config support --- .gitignore | 1 + src/glu/Makefile | 12 +++++++++++- src/glu/glu.pc.in | 11 +++++++++++ src/glut/glx/Makefile | 12 +++++++++++- src/glut/glx/glut.pc.in | 11 +++++++++++ src/glw/Makefile | 12 +++++++++++- src/glw/glw.pc.in | 11 +++++++++++ src/mesa/Makefile | 13 ++++++++++++- src/mesa/gl.pc.in | 11 +++++++++++ 9 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 src/glu/glu.pc.in create mode 100644 src/glut/glx/glut.pc.in create mode 100644 src/glw/glw.pc.in create mode 100644 src/mesa/gl.pc.in (limited to 'src') diff --git a/.gitignore b/.gitignore index 033e6e10bde..c128ba86092 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.o *.so *.sw[a-z] +*.pc *~ depend depend.bak diff --git a/src/glu/Makefile b/src/glu/Makefile index b8c55db6d0a..836baa684cb 100644 --- a/src/glu/Makefile +++ b/src/glu/Makefile @@ -13,9 +13,19 @@ default: $(TOP)/configs/current (cd $$dir ; $(MAKE)) ; \ done -install: +# GLU pkg-config file +pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@LIB_DIR@,$(LIB_DIR),' \ + -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' +glu.pc: glu.pc.in + $(pcedit) $< > $@ + +install: glu.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig clean: @for dir in $(SUBDIRS) ; do \ diff --git a/src/glu/glu.pc.in b/src/glu/glu.pc.in new file mode 100644 index 00000000000..5d6e52a75e4 --- /dev/null +++ b/src/glu/glu.pc.in @@ -0,0 +1,11 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=${exec_prefix}/@LIB_DIR@ +includedir=${prefix}/include + +Name: glu +Description: Mesa OpenGL Utility library +Requires: gl +Version: @VERSION@ +Libs: -L${libdir} -lGLU +Cflags: -I${includedir} diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index b236c6fad35..5a224c9af59 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -96,11 +96,21 @@ $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS) $(GLUT_LIB_DEPS) $(OBJECTS) -install: +# glut pkgconfig file +pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@LIB_DIR@,$(LIB_DIR),' \ + -e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),' +glut.pc: glut.pc.in + $(pcedit) $< > $@ + +install: glut.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_DIR)/include/GL $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig clean: diff --git a/src/glut/glx/glut.pc.in b/src/glut/glx/glut.pc.in new file mode 100644 index 00000000000..f732f2990d0 --- /dev/null +++ b/src/glut/glx/glut.pc.in @@ -0,0 +1,11 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=${exec_prefix}/@LIB_DIR@ +includedir=${prefix}/include + +Name: glut +Description: Mesa OpenGL Utility Toolkit library +Requires: gl glu +Version: @VERSION@ +Libs: -L${libdir} -lglut +Cflags: -I${includedir} diff --git a/src/glw/Makefile b/src/glw/Makefile index 778ffb02189..c32fc0ccad8 100644 --- a/src/glw/Makefile +++ b/src/glw/Makefile @@ -25,11 +25,21 @@ OBJECTS = $(GLW_SOURCES:.c=.o) default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME) -install: +# GLU pkg-config file +pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@LIB_DIR@,$(LIB_DIR),' \ + -e 's,@VERSION@,$(MAJOR).$(MINOR).$(TINY),' +glw.pc: glw.pc.in + $(pcedit) $< > $@ + +install: glw.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig clean: -rm depend depend.bak diff --git a/src/glw/glw.pc.in b/src/glw/glw.pc.in new file mode 100644 index 00000000000..951e2dc2af5 --- /dev/null +++ b/src/glw/glw.pc.in @@ -0,0 +1,11 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=${exec_prefix}/@LIB_DIR@ +includedir=${prefix}/include + +Name: glw +Description: Mesa OpenGL widget library +Requires: gl +Version: @VERSION@ +Libs: -L${libdir} -lGLU +Cflags: -I${includedir} diff --git a/src/mesa/Makefile b/src/mesa/Makefile index a50e826701b..c05b1959575 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -133,6 +133,15 @@ $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECT fi +###################################################################### +# libGL pkg-config file +pcedit = sed \ + -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ + -e 's,@LIB_DIR@,$(LIB_DIR),' \ + -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' +gl.pc: gl.pc.in + $(pcedit) $< > $@ + ###################################################################### # Generic stuff @@ -148,13 +157,15 @@ subdirs: @ (cd x86-64 ; $(MAKE)) -install: default +install: default gl.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ fi + $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig @if [ -e $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) ]; then \ $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ fi diff --git a/src/mesa/gl.pc.in b/src/mesa/gl.pc.in new file mode 100644 index 00000000000..4b144ffa4b2 --- /dev/null +++ b/src/mesa/gl.pc.in @@ -0,0 +1,11 @@ +prefix=@INSTALL_DIR@ +exec_prefix=${prefix} +libdir=${exec_prefix}/@LIB_DIR@ +includedir=${prefix}/include + +Name: gl +Description: Mesa OpenGL library +Requires: +Version: @VERSION@ +Libs: -L${libdir} -lGL +Cflags: -I${includedir} -- cgit v1.2.3 From ba5290e836d5fd6e80dc460f75f6b032e2510382 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Wed, 12 Sep 2007 09:03:44 -0700 Subject: Remove unused plane->pipe mapping fields from SAREA private. --- src/mesa/drivers/dri/i915/server/i830_common.h | 3 --- src/mesa/drivers/dri/i915tex/server/i830_common.h | 3 --- 2 files changed, 6 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/server/i830_common.h b/src/mesa/drivers/dri/i915/server/i830_common.h index a5d2598849b..2962ecc68ae 100644 --- a/src/mesa/drivers/dri/i915/server/i830_common.h +++ b/src/mesa/drivers/dri/i915/server/i830_common.h @@ -127,9 +127,6 @@ typedef struct { int planeB_y; int planeB_w; int planeB_h; - - int planeA_pipe; - int planeB_pipe; } drmI830Sarea; /* Flags for perf_boxes diff --git a/src/mesa/drivers/dri/i915tex/server/i830_common.h b/src/mesa/drivers/dri/i915tex/server/i830_common.h index 07cc63f6631..8735f93d146 100644 --- a/src/mesa/drivers/dri/i915tex/server/i830_common.h +++ b/src/mesa/drivers/dri/i915tex/server/i830_common.h @@ -130,9 +130,6 @@ typedef struct { int planeB_w; int planeB_h; - int planeA_pipe; - int planeB_pipe; - /* Triple buffering */ drm_handle_t third_handle; int third_offset; -- cgit v1.2.3 From 642267b2d8c9848c5c1a11ba2b598dc313a2737a Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 12 Sep 2007 13:37:10 -0600 Subject: Rename. "fcb" = fortran call back --- src/glut/glx/glut_fcb.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/glut/glx/glut_fcb.c (limited to 'src') diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c new file mode 100644 index 00000000000..e93188b8622 --- /dev/null +++ b/src/glut/glx/glut_fcb.c @@ -0,0 +1,164 @@ + +/* Copyright (c) Mark J. Kilgard, 1998. */ + +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or + implied. This program is -not- in the public domain. */ + +/* I appreciate the guidance from William Mitchell + (mitchell@cam.nist.gov) in developing this friend interface + for use by the f90gl package. See ../../README.fortran */ + +#include "glutint.h" + +/* FCB stands for Fortran CallBack. */ + +/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they + can be saved in the wrappers for Fortran rather than the C structures. */ + +/* Set a Fortran callback function. */ + +void APIENTRY +__glutSetFCB(int which, void *func) +{ +#ifdef SUPPORT_FORTRAN + switch (which) { + case GLUT_FCB_DISPLAY: + __glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func; + break; + case GLUT_FCB_RESHAPE: + __glutCurrentWindow->freshape = (GLUTreshapeFCB) func; + break; + case GLUT_FCB_MOUSE: + __glutCurrentWindow->fmouse = (GLUTmouseFCB) func; + break; + case GLUT_FCB_MOTION: + __glutCurrentWindow->fmotion = (GLUTmotionFCB) func; + break; + case GLUT_FCB_PASSIVE: + __glutCurrentWindow->fpassive = (GLUTpassiveFCB) func; + break; + case GLUT_FCB_ENTRY: + __glutCurrentWindow->fentry = (GLUTentryFCB) func; + break; + case GLUT_FCB_KEYBOARD: + __glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func; + break; + case GLUT_FCB_KEYBOARD_UP: + __glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func; + break; + case GLUT_FCB_WINDOW_STATUS: + __glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func; + break; + case GLUT_FCB_VISIBILITY: + __glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func; + break; + case GLUT_FCB_SPECIAL: + __glutCurrentWindow->fspecial = (GLUTspecialFCB) func; + break; + case GLUT_FCB_SPECIAL_UP: + __glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func; + break; + case GLUT_FCB_BUTTON_BOX: + __glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func; + break; + case GLUT_FCB_DIALS: + __glutCurrentWindow->fdials = (GLUTdialsFCB) func; + break; + case GLUT_FCB_SPACE_MOTION: + __glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func; + break; + case GLUT_FCB_SPACE_ROTATE: + __glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func; + break; + case GLUT_FCB_SPACE_BUTTON: + __glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func; + break; + case GLUT_FCB_TABLET_MOTION: + __glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func; + break; + case GLUT_FCB_TABLET_BUTTON: + __glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func; + break; +#ifdef _WIN32 + case GLUT_FCB_JOYSTICK: + __glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func; + break; +#endif + case GLUT_FCB_OVERLAY_DISPLAY: + __glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func; + break; + case GLUT_FCB_SELECT: + __glutCurrentMenu->fselect = (GLUTselectFCB) func; + break; + case GLUT_FCB_TIMER: + __glutNewTimer->ffunc = (GLUTtimerFCB) func; + break; + } +#endif +} + +/* Get a Fortran callback function. */ + +void* APIENTRY +__glutGetFCB(int which) +{ +#ifdef SUPPORT_FORTRAN + switch (which) { + case GLUT_FCB_DISPLAY: + return (void *) __glutCurrentWindow->fdisplay; + case GLUT_FCB_RESHAPE: + return (void *) __glutCurrentWindow->freshape; + case GLUT_FCB_MOUSE: + return (void *) __glutCurrentWindow->fmouse; + case GLUT_FCB_MOTION: + return (void *) __glutCurrentWindow->fmotion; + case GLUT_FCB_PASSIVE: + return (void *) __glutCurrentWindow->fpassive; + case GLUT_FCB_ENTRY: + return (void *) __glutCurrentWindow->fentry; + case GLUT_FCB_KEYBOARD: + return (void *) __glutCurrentWindow->fkeyboard; + case GLUT_FCB_KEYBOARD_UP: + return (void *) __glutCurrentWindow->fkeyboardUp; + case GLUT_FCB_WINDOW_STATUS: + return (void *) __glutCurrentWindow->fwindowStatus; + case GLUT_FCB_VISIBILITY: + return (void *) __glutCurrentWindow->fvisibility; + case GLUT_FCB_SPECIAL: + return (void *) __glutCurrentWindow->fspecial; + case GLUT_FCB_SPECIAL_UP: + return (void *) __glutCurrentWindow->fspecialUp; + case GLUT_FCB_BUTTON_BOX: + return (void *) __glutCurrentWindow->fbuttonBox; + case GLUT_FCB_DIALS: + return (void *) __glutCurrentWindow->fdials; + case GLUT_FCB_SPACE_MOTION: + return (void *) __glutCurrentWindow->fspaceMotion; + case GLUT_FCB_SPACE_ROTATE: + return (void *) __glutCurrentWindow->fspaceRotate; + case GLUT_FCB_SPACE_BUTTON: + return (void *) __glutCurrentWindow->fspaceButton; + case GLUT_FCB_TABLET_MOTION: + return (void *) __glutCurrentWindow->ftabletMotion; + case GLUT_FCB_TABLET_BUTTON: + return (void *) __glutCurrentWindow->ftabletButton; + case GLUT_FCB_JOYSTICK: +#ifdef _WIN32 + return (void *) __glutCurrentWindow->fjoystick; +#else + return NULL; +#endif + case GLUT_FCB_OVERLAY_DISPLAY: + return (void *) __glutCurrentWindow->overlay->fdisplay; + case GLUT_FCB_SELECT: + return (void *) __glutCurrentMenu->fselect; + case GLUT_FCB_TIMER: + return (void *) __glutTimerList->ffunc; + default: + return NULL; + } +#else + return NULL; +#endif +} -- cgit v1.2.3 From ae0dd620fec580b77b0901ed1376e6a6b2569c7e Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 12 Sep 2007 13:40:15 -0600 Subject: Add glut_fcb.c to the build and update to fix warnings (see bug 12405) --- include/GL/glutf90.h | 4 ++-- src/glut/glx/Makefile | 1 + src/glut/glx/glut_fcb.c | 50 ++++++++++++++++++++++++------------------------- 3 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/include/GL/glutf90.h b/include/GL/glutf90.h index 7ba3e19ef9e..8a3a86727cf 100644 --- a/include/GL/glutf90.h +++ b/include/GL/glutf90.h @@ -75,7 +75,7 @@ typedef void (GLUTCALLBACK *GLUTmenuStatusFCB) (int *, int *, int *); typedef void (GLUTCALLBACK *GLUTidleFCB) (void); /* Functions that set and return Fortran callback functions. */ -GLUTAPI void* APIENTRY __glutGetFCB(int which); -GLUTAPI void APIENTRY __glutSetFCB(int which, void *func); +GLUTAPI GLUTproc APIENTRY __glutGetFCB(int which); +GLUTAPI void APIENTRY __glutSetFCB(int which, GLUTproc func); #endif /* __glutf90_h__ */ diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index 5a224c9af59..f73158ad385 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -36,6 +36,7 @@ SOURCES = \ glut_dstr.c \ glut_event.c \ glut_ext.c \ + glut_fcb.c \ glut_fullscrn.c \ glut_gamemode.c \ glut_get.c \ diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c index e93188b8622..b272d0e2278 100644 --- a/src/glut/glx/glut_fcb.c +++ b/src/glut/glx/glut_fcb.c @@ -19,7 +19,7 @@ /* Set a Fortran callback function. */ void APIENTRY -__glutSetFCB(int which, void *func) +__glutSetFCB(int which, GLUTproc func) { #ifdef SUPPORT_FORTRAN switch (which) { @@ -100,61 +100,61 @@ __glutSetFCB(int which, void *func) /* Get a Fortran callback function. */ -void* APIENTRY +GLUTproc APIENTRY __glutGetFCB(int which) { #ifdef SUPPORT_FORTRAN switch (which) { case GLUT_FCB_DISPLAY: - return (void *) __glutCurrentWindow->fdisplay; + return __glutCurrentWindow->fdisplay; case GLUT_FCB_RESHAPE: - return (void *) __glutCurrentWindow->freshape; + return __glutCurrentWindow->freshape; case GLUT_FCB_MOUSE: - return (void *) __glutCurrentWindow->fmouse; + return __glutCurrentWindow->fmouse; case GLUT_FCB_MOTION: - return (void *) __glutCurrentWindow->fmotion; + return __glutCurrentWindow->fmotion; case GLUT_FCB_PASSIVE: - return (void *) __glutCurrentWindow->fpassive; + return __glutCurrentWindow->fpassive; case GLUT_FCB_ENTRY: - return (void *) __glutCurrentWindow->fentry; + return __glutCurrentWindow->fentry; case GLUT_FCB_KEYBOARD: - return (void *) __glutCurrentWindow->fkeyboard; + return __glutCurrentWindow->fkeyboard; case GLUT_FCB_KEYBOARD_UP: - return (void *) __glutCurrentWindow->fkeyboardUp; + return __glutCurrentWindow->fkeyboardUp; case GLUT_FCB_WINDOW_STATUS: - return (void *) __glutCurrentWindow->fwindowStatus; + return __glutCurrentWindow->fwindowStatus; case GLUT_FCB_VISIBILITY: - return (void *) __glutCurrentWindow->fvisibility; + return __glutCurrentWindow->fvisibility; case GLUT_FCB_SPECIAL: - return (void *) __glutCurrentWindow->fspecial; + return __glutCurrentWindow->fspecial; case GLUT_FCB_SPECIAL_UP: - return (void *) __glutCurrentWindow->fspecialUp; + return __glutCurrentWindow->fspecialUp; case GLUT_FCB_BUTTON_BOX: - return (void *) __glutCurrentWindow->fbuttonBox; + return __glutCurrentWindow->fbuttonBox; case GLUT_FCB_DIALS: - return (void *) __glutCurrentWindow->fdials; + return __glutCurrentWindow->fdials; case GLUT_FCB_SPACE_MOTION: - return (void *) __glutCurrentWindow->fspaceMotion; + return __glutCurrentWindow->fspaceMotion; case GLUT_FCB_SPACE_ROTATE: - return (void *) __glutCurrentWindow->fspaceRotate; + return __glutCurrentWindow->fspaceRotate; case GLUT_FCB_SPACE_BUTTON: - return (void *) __glutCurrentWindow->fspaceButton; + return __glutCurrentWindow->fspaceButton; case GLUT_FCB_TABLET_MOTION: - return (void *) __glutCurrentWindow->ftabletMotion; + return __glutCurrentWindow->ftabletMotion; case GLUT_FCB_TABLET_BUTTON: - return (void *) __glutCurrentWindow->ftabletButton; + return __glutCurrentWindow->ftabletButton; case GLUT_FCB_JOYSTICK: #ifdef _WIN32 - return (void *) __glutCurrentWindow->fjoystick; + return __glutCurrentWindow->fjoystick; #else return NULL; #endif case GLUT_FCB_OVERLAY_DISPLAY: - return (void *) __glutCurrentWindow->overlay->fdisplay; + return __glutCurrentWindow->overlay->fdisplay; case GLUT_FCB_SELECT: - return (void *) __glutCurrentMenu->fselect; + return __glutCurrentMenu->fselect; case GLUT_FCB_TIMER: - return (void *) __glutTimerList->ffunc; + return __glutTimerList->ffunc; default: return NULL; } -- cgit v1.2.3 From 5fdeb52e5d21bfb7feff2253c7d9e18e6b3cb252 Mon Sep 17 00:00:00 2001 From: Jonathan Bestien-Filiatrault Date: Wed, 12 Sep 2007 16:21:13 -0600 Subject: check return value of invert_matrix() --- src/glu/mesa/Makefile | 2 +- src/glu/mesa/project.c | 6 ++++-- src/glu/mini/project.c | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/glu/mesa/Makefile b/src/glu/mesa/Makefile index 47f95ef0240..611d7a630c8 100644 --- a/src/glu/mesa/Makefile +++ b/src/glu/mesa/Makefile @@ -23,7 +23,7 @@ C_SOURCES = \ OBJECTS = $(C_SOURCES:.c=.o) -INCLUDES = -I. -I- -I$(TOP)/include +INCLUDES = -I. -I$(TOP)/include ##### RULES ##### diff --git a/src/glu/mesa/project.c b/src/glu/mesa/project.c index 6fa03267e53..2e79cdf0840 100644 --- a/src/glu/mesa/project.c +++ b/src/glu/mesa/project.c @@ -346,7 +346,8 @@ gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz, /* calcul transformation inverse */ matmul(A, proj, model); - invert_matrix(A, m); + if (!invert_matrix(A, m)) + return GL_FALSE; /* d'ou les coordonnees objets */ transform_point(out, m, in); @@ -386,7 +387,8 @@ gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw, /* calcul transformation inverse */ matmul(A, projMatrix, modelMatrix); - invert_matrix(A, m); + if (!invert_matrix(A, m)) + return GL_FALSE; /* d'ou les coordonnees objets */ transform_point(out, m, in); diff --git a/src/glu/mini/project.c b/src/glu/mini/project.c index a2747de55f2..71279947cf9 100644 --- a/src/glu/mini/project.c +++ b/src/glu/mini/project.c @@ -347,7 +347,8 @@ gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz, /* calcul transformation inverse */ matmul(A, proj, model); - invert_matrix(A, m); + if (!invert_matrix(A, m)) + return GL_FALSE; /* d'ou les coordonnees objets */ transform_point(out, m, in); @@ -387,7 +388,8 @@ gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw, /* calcul transformation inverse */ matmul(A, projMatrix, modelMatrix); - invert_matrix(A, m); + if (!invert_matrix(A, m)) + return GL_FALSE; /* d'ou les coordonnees objets */ transform_point(out, m, in); -- cgit v1.2.3 From 20b331c2f6fa4e16f0c473f27914644e2bcd2b39 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 13 Sep 2007 09:26:27 -0600 Subject: added null ptr check --- src/glut/glx/glut_fcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c index b272d0e2278..c8a3422b360 100644 --- a/src/glut/glx/glut_fcb.c +++ b/src/glut/glx/glut_fcb.c @@ -154,7 +154,7 @@ __glutGetFCB(int which) case GLUT_FCB_SELECT: return __glutCurrentMenu->fselect; case GLUT_FCB_TIMER: - return __glutTimerList->ffunc; + return __glutTimerList ? __glutTimerList->ffunc : NULL; default: return NULL; } -- cgit v1.2.3 From d799b7a7ecbe3e773decfcc2ebd1b23f53fc48a7 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 13 Sep 2007 11:29:00 -0600 Subject: Fix state.texgen parsing error (bug 12313). Replace *(*inst++) with *(*inst)++ in a few places. --- src/mesa/shader/arbprogparse.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 9a5290d920e..737194d3b65 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1226,10 +1226,10 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, state_tokens[1] = coord; /* EYE or OBJECT */ - type = *(*inst++); + type = *(*inst)++; /* 0 - s, 1 - t, 2 - r, 3 - q */ - coord = *(*inst++); + coord = *(*inst)++; if (type == TEX_GEN_EYE) { switch (coord) { @@ -1245,6 +1245,9 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case COMPONENT_W: state_tokens[2] = STATE_TEXGEN_EYE_Q; break; + default: + _mesa_problem(ctx, "bad texgen component in " + "parse_state_single_item()"); } } else { @@ -1261,6 +1264,9 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, case COMPONENT_W: state_tokens[2] = STATE_TEXGEN_OBJECT_Q; break; + default: + _mesa_problem(ctx, "bad texgen component in " + "parse_state_single_item()"); } } } @@ -1283,7 +1289,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, break; case STATE_POINT: - switch (*(*inst++)) { + switch (*(*inst)++) { case POINT_SIZE: state_tokens[0] = STATE_POINT_SIZE; break; @@ -2454,8 +2460,9 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst, Program->Position = parse_position (inst); if (!found) { - program_error(ctx, Program->Position, - "2: Undefined variable"); /* src->name */ + char s[1000]; + sprintf(s, "Undefined variable: %s", src->name); + program_error(ctx, Program->Position, s); return 1; } -- cgit v1.2.3 From ab31a3a7647ca1b1567dbc58c6093c523173c988 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 13 Sep 2007 11:41:49 -0600 Subject: added program_error2() function for better error reporting --- src/mesa/shader/arbprogparse.c | 107 +++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 737194d3b65..3360fef5851 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -633,6 +633,41 @@ program_error(GLcontext *ctx, GLint position, const char *descrip) } +/** + * As above, but with an extra string parameter for more info. + */ +static void +program_error2(GLcontext *ctx, GLint position, const char *descrip, + const char *var) +{ + if (descrip) { + const char *prefix = "glProgramString(", *suffix = ")"; + char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) + + _mesa_strlen(": ") + + _mesa_strlen(var) + + _mesa_strlen(prefix) + + _mesa_strlen(suffix) + 1); + if (str) { + _mesa_sprintf(str, "%s%s: %s%s", prefix, descrip, var, suffix); + _mesa_error(ctx, GL_INVALID_OPERATION, str); + _mesa_free(str); + } + } + { + char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) + + _mesa_strlen(": ") + + _mesa_strlen(var) + 1); + if (str) { + _mesa_sprintf(str, "%s: %s", descrip, var); + } + _mesa_set_program_error(ctx, position, str); + if (str) { + _mesa_free(str); + } + } +} + + /** * constructs an integer from 4 GLubytes in LE format @@ -1693,18 +1728,14 @@ parse_attrib (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head struct arb_program *Program) { GLuint found; - char *error_msg; struct var_cache *attrib_var; attrib_var = parse_string (inst, vc_head, Program, &found); Program->Position = parse_position (inst); if (found) { - error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) attrib_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", - attrib_var->name); - program_error(ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Duplicate variable declaration", + (char *) attrib_var->name); return 1; } @@ -1882,12 +1913,9 @@ parse_param (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, Program->Position = parse_position (inst); if (found) { - char *error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) param_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", - param_var->name); - program_error (ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Duplicate variable declaration", + (char *) param_var->name); return 1; } @@ -1982,12 +2010,9 @@ parse_temp (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, temp_var = parse_string (inst, vc_head, Program, &found); Program->Position = parse_position (inst); if (found) { - char *error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", - temp_var->name); - program_error(ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Duplicate variable declaration", + (char *) temp_var->name); return 1; } @@ -2028,12 +2053,9 @@ parse_output (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head output_var = parse_string (inst, vc_head, Program, &found); Program->Position = parse_position (inst); if (found) { - char *error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) output_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", - output_var->name); - program_error (ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Duplicate variable declaration", + (char *) output_var->name); return 1; } @@ -2059,12 +2081,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, Program->Position = parse_position (inst); if (found) { - char *error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", - temp_var->name); - program_error(ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Duplicate variable declaration", + (char *) temp_var->name); return 1; } @@ -2074,12 +2093,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, if (!found) { - char *error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Alias value %s is not defined", - temp_var->alias_binding->name); - program_error (ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Undefined alias value", + (char *) temp_var->alias_binding->name); return 1; } @@ -2102,12 +2118,9 @@ parse_address (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_hea temp_var = parse_string (inst, vc_head, Program, &found); Program->Position = parse_position (inst); if (found) { - char *error_msg = (char *) - _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); - _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", - temp_var->name); - program_error (ctx, Program->Position, error_msg); - _mesa_free (error_msg); + program_error2(ctx, Program->Position, + "Duplicate variable declaration", + (char *) temp_var->name); return 1; } @@ -2460,9 +2473,9 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst, Program->Position = parse_position (inst); if (!found) { - char s[1000]; - sprintf(s, "Undefined variable: %s", src->name); - program_error(ctx, Program->Position, s); + program_error2(ctx, Program->Position, + "Undefined variable", + (char *) src->name); return 1; } -- cgit v1.2.3 From 3a2559a1e9989655591b7faf93ea6bfa21dbff1b Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Thu, 13 Sep 2007 22:13:39 +0200 Subject: nouveau : diable broken light enable on nv10 --- src/mesa/drivers/dri/nouveau/nv10_state.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index b63893d05c4..154ba3cce12 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -323,6 +323,11 @@ static void nv10Enable(GLcontext *ctx, GLenum cap, GLboolean state) break; // case GL_HISTOGRAM: // case GL_INDEX_LOGIC_OP: +#if 0 + /* light is broken, the hardware seem to only allow to use light + * in order : ie GL_LIGHT0 & GL_LIGHT2 is invalid + * In this case the blob remap GL_LIGHT2 to hw light 1 + */ case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: @@ -333,7 +338,11 @@ static void nv10Enable(GLcontext *ctx, GLenum cap, GLboolean state) case GL_LIGHT7: { uint32_t mask=1<<(2*(cap-GL_LIGHT0)); - nmesa->enabled_lights=((nmesa->enabled_lights&mask)|(mask*state)); + if (state) + nmesa->enabled_lights |= mask; + else + nmesa->enabled_lights &= ~mask; + if (nmesa->lighting_enabled) { BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1); @@ -349,6 +358,7 @@ static void nv10Enable(GLcontext *ctx, GLenum cap, GLboolean state) else OUT_RING_CACHE(0x0); break; +#endif case GL_LINE_SMOOTH: BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE, 1); OUT_RING_CACHE(state); -- cgit v1.2.3 From 885a95f4fa6d8adba2bfc1839b99f404b473f646 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 13 Sep 2007 14:42:23 -0600 Subject: Fix timer problem when using Fortran bindings (submitted by Bill Mitchell) Also, add some comments about what's going on. --- src/glut/glx/glut_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/glut/glx/glut_event.c b/src/glut/glx/glut_event.c index 0a96e8cf71d..b5df7b23119 100644 --- a/src/glut/glx/glut_event.c +++ b/src/glut/glx/glut_event.c @@ -172,10 +172,14 @@ handleTimeouts(void) GETTIMEOFDAY(&now); while (IS_AT_OR_AFTER(__glutTimerList->timeout, now)) { timer = __glutTimerList; - __glutTimerList = timer->next; + /* call the timer function */ timer->func(timer->value); + /* remove from the linked list */ + __glutTimerList = timer->next; + /* put this timer on the "free" list */ timer->next = freeTimerList; freeTimerList = timer; + if (!__glutTimerList) break; } -- cgit v1.2.3 From ea07a0df9a2f689b8f5acaf92c40bbbd602cab3c Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 14 Sep 2007 11:10:23 +0800 Subject: i965: align the address of the first element within the index buffer. (fix#11910) --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 6150cac4aa3..dc289ca9ae7 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -593,6 +593,28 @@ void brw_upload_indices( struct brw_context *brw, ib_size, index_buffer->ptr, bufferobj); + } else { + if (((1 << get_index_type(index_buffer->type)) - 1) & offset) { + struct gl_buffer_object *vbo; + GLuint voffset; + GLubyte *map = ctx->Driver.MapBuffer(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_DYNAMIC_DRAW_ARB, + bufferobj); + map += offset; + get_space(brw, ib_size, &vbo, &voffset); + + ctx->Driver.BufferSubData(ctx, + GL_ELEMENT_ARRAY_BUFFER_ARB, + voffset, + ib_size, + map, + vbo); + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, bufferobj); + + bufferobj = vbo; + offset = voffset; + } } /* Emit the indexbuffer packet: -- cgit v1.2.3 From e04c58e06842e5157231f1bd4ba79ccbbaad8f1c Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Fri, 14 Sep 2007 16:26:56 +0800 Subject: mesa: bind VBO_ATTRIB_XXX to correct input array when executing a display list. fix #10604 --- src/mesa/vbo/vbo_save_draw.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 3c6f0fccd98..da7bc765b7e 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -132,9 +132,11 @@ static void vbo_bind_vertex_list( GLcontext *ctx, } for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { - if (node->attrsz[attr]) { + GLuint src = map[attr]; + + if (node->attrsz[src]) { arrays[attr].Ptr = (const GLubyte *)data; - arrays[attr].Size = node->attrsz[attr]; + arrays[attr].Size = node->attrsz[src]; arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat); arrays[attr].Stride = node->vertex_size * sizeof(GLfloat); arrays[attr].Type = GL_FLOAT; -- cgit v1.2.3 From 032707eeca2e6a0fd931ebd9ef4831bf30baf183 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 14 Sep 2007 09:57:57 -0600 Subject: fix copypixels overlap test bug (#12417) --- src/mesa/swrast/s_copypix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index bbe1081860d..218a3b5590b 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -71,13 +71,20 @@ regions_overlap(GLint srcx, GLint srcy, } else { /* add one pixel of slop when zooming, just to be safe */ - if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) { + if (srcx > (dstx + ((zoomX > 0.0F) ? (width * zoomX + 1.0F) : 0.0F))) { + /* src is completely right of dest */ + return GL_FALSE; + } + else if (srcx + width + 1.0F < dstx + ((zoomX > 0.0F) ? 0.0F : (width * zoomX))) { + /* src is completely left of dest */ return GL_FALSE; } else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) { + /* src is completely below dest */ return GL_FALSE; } else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) { + /* src is completely above dest */ return GL_FALSE; } else { -- cgit v1.2.3 From 63147344e422aa2b00b6b22d76fdea801c38b2ea Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Fri, 14 Sep 2007 22:07:34 +0200 Subject: nouveau : fix NV10_TCL_PRIMITIVE_3D_CLIP_PLANE --- src/mesa/drivers/dri/nouveau/nouveau_reg.h | 4 ++-- src/mesa/drivers/dri/nouveau/nv10_state.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_reg.h b/src/mesa/drivers/dri/nouveau/nouveau_reg.h index b5e40dd6c64..e08a5e4f7bd 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_reg.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_reg.h @@ -393,7 +393,7 @@ Object NV11_TCL_PRIMITIVE_3D used on: NV15 # define NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_A 0x000003b4 # define NV10_TCL_PRIMITIVE_3D_COLOR_CONTROL 0x000003b8 /* Parameters: color_control */ # define NV10_TCL_PRIMITIVE_3D_ENABLED_LIGHTS 0x000003bc /* Parameters: light 7 light 6 light 5 light 4 light 3 light 2 light 1 light 0 */ -# define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE( d) (0x000003c0 + d * 0x0004) +# define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE( d) (0x000003c0 + (d) * 0x0004) # define NV10_TCL_PRIMITIVE_3D_VIEW_MATRIX_ENABLE 0x000003e8 /* Parameters: projection modelview0 modelview1 */ # define NV10_TCL_PRIMITIVE_3D_POINT_SIZE 0x000003ec # define NV10_TCL_PRIMITIVE_3D_MODELVIEW0_MATRIX( d) (0x00000400 + d * 0x0004) @@ -401,7 +401,7 @@ Object NV11_TCL_PRIMITIVE_3D used on: NV15 # define NV10_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW0_MATRIX( d) (0x00000480 + d * 0x0004) # define NV10_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW1_MATRIX( d) (0x000004c0 + d * 0x0004) # define NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX( d) (0x00000500 + d * 0x0004) -# define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_A(d) (0x00000600 + d * 0x0010) +# define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_A(d) (0x00000600 + (d) * 0x0010) # define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_B(d) (0x00000604 + d * 0x0010) # define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_C(d) (0x00000608 + d * 0x0010) # define NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_D(d) (0x0000060c + d * 0x0010) diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 154ba3cce12..2ba5d79684a 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -200,7 +200,7 @@ static void nv10ClearStencil(GLcontext *ctx, GLint s) static void nv10ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation) { nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_A(plane), 4); + BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_A(plane - GL_CLIP_PLANE0), 4); OUT_RING_CACHEf(equation[0]); OUT_RING_CACHEf(equation[1]); OUT_RING_CACHEf(equation[2]); -- cgit v1.2.3 From 5e7835625912e5b64c1c0f76c7614367bec40039 Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Fri, 14 Sep 2007 22:13:52 +0200 Subject: nouveau : check for nmesa->state_cache.atoms overflow --- src/mesa/drivers/dri/nouveau/nouveau_fifo.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.h b/src/mesa/drivers/dri/nouveau/nouveau_fifo.h index 956dd549dca..08058820257 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.h @@ -149,6 +149,7 @@ extern void nouveau_state_cache_init(nouveauContextPtr nmesa); #define BEGIN_RING_CACHE(subchannel,tag,size) do { \ nmesa->state_cache.dirty=1; \ nmesa->state_cache.current_pos=((tag)/4); \ + assert(nmesa->state_cache.current_pos + size <= NOUVEAU_STATE_CACHE_ENTRIES); \ }while(0) #define OUT_RING_CACHE(n) do { \ -- cgit v1.2.3 From 8d9d990cb2d20074e188df4ddaa8e4e235e87b0e Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sat, 15 Sep 2007 00:25:09 +0200 Subject: nouveau : use new nouveau_reg.h with correct Bracket in macro --- src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 +- src/mesa/drivers/dri/nouveau/nouveau_object.c | 6 +- src/mesa/drivers/dri/nouveau/nouveau_reg.h | 4219 ++++++++++++++++++++++-- src/mesa/drivers/dri/nouveau/nv10_state.c | 2 +- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 4 +- 5 files changed, 3863 insertions(+), 370 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index f9f33eceeb1..f36483a3d49 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -348,7 +348,7 @@ nouveauDoSwapBuffers(nouveauContextPtr nmesa, __DRIdrawablePrivate *dPriv) } for (i=0; iy1 - dPriv->y) << 16) | (box->x1 - dPriv->x)); OUT_RING ((box->y1 << 16) | box->x1); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c index 83867574d32..8f33093f1a5 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_object.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c @@ -39,7 +39,7 @@ void nouveauObjectInit(nouveauContextPtr nmesa) nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D); } if (nmesa->screen->card->type>=NV_11) { - nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT); + nouveauCreateContextObject(nmesa, NvImageBlit, NV11_IMAGE_BLIT); } else { nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT); } @@ -56,9 +56,9 @@ void nouveauObjectInit(nouveauContextPtr nmesa) OUT_RING(NvDmaFB); nouveauObjectOnSubchannel(nmesa, NvSubImageBlit, NvImageBlit); - BEGIN_RING_SIZE(NvSubImageBlit, NV10_IMAGE_BLIT_SET_CONTEXT_SURFACES_2D, 1); + BEGIN_RING_SIZE(NvSubImageBlit, NV_IMAGE_BLIT_SET_SURFACES_2D, 1); OUT_RING(NvCtxSurf2D); - BEGIN_RING_SIZE(NvSubImageBlit, NV10_IMAGE_BLIT_SET_OPERATION, 1); + BEGIN_RING_SIZE(NvSubImageBlit, NV_IMAGE_BLIT_OPERATION, 1); OUT_RING(3); /* SRCCOPY */ if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->typescreen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -516,7 +516,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) } else { BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DO_VERTICES, 1); OUT_RING(0); - BEGIN_RING_CACHE(NvSub3D,NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR0_POS,slots); + BEGIN_RING_CACHE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR8_TX0,slots); for(i=0;i Date: Sun, 16 Sep 2007 16:13:55 +0200 Subject: nouveau : nv1x pos vertex attribute need to be the first in mesa. Swap it latter in order it match hw format. --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 72 +++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 0a42acefd67..22144b66117 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -54,6 +54,50 @@ static void nv10RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim ); static void nv10RenderPrimitive( GLcontext *ctx, GLenum prim ); static void nv10ResetLineStipple( GLcontext *ctx ); +static const int default_attr_size[8]={3,3,3,4,3,1,4,4}; + +/* Mesa requires us to put pos attribute as the first attribute of the + * vertex, but on NV10 it is the last attribute. + * To fix that we put the pos attribute first, and we swap the pos + * attribute before sending it to the card. + * Speed cost of the swap seems negligeable + */ +#if 0 +/* old stuff where pos attribute isn't put first for mesa. + * Usefull for speed comparaison + */ +#define INV_VERT(i) i +#define OUT_RING_VERTp(nmesa, ptr,sz, vertex_size) OUT_RINGp(ptr,sz) +#define OUT_RING_VERT(nmesa, ptr, vertex_size) OUT_RINGp(ptr,vertex_size) +#else + +#define INV_VERT(i) (i==0?7:i-1) + +#define OUT_RING_VERT_RAW(ptr,vertex_size) do{ \ + /* if the vertex size is not null, we have at least pos attribute */ \ + OUT_RINGp((ptr) + default_attr_size[_TNL_ATTRIB_POS], (vertex_size) - default_attr_size[_TNL_ATTRIB_POS]); \ + OUT_RINGp((ptr), default_attr_size[_TNL_ATTRIB_POS]); \ +}while(0) + +#define OUT_RING_VERT(nmesa,ptr,vertex_size) do{ \ + if (nmesa->screen->card->type>=NV_20) \ + OUT_RINGp(ptr, vertex_size); \ + else \ + OUT_RING_VERT_RAW(ptr, vertex_size); \ +}while(0) + + +#define OUT_RING_VERTp(nmesa, ptr,sz, vertex_size) do{ \ + int nb_vert; \ + if (nmesa->screen->card->type>=NV_20) \ + OUT_RINGp(ptr, sz); \ + else \ + for (nb_vert = 0; nb_vert < (sz)/(vertex_size); nb_vert++) { \ + OUT_RING_VERT_RAW((uint32_t*)(ptr)+nb_vert*(vertex_size), vertex_size); \ + } \ +}while(0) + +#endif static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size) @@ -109,7 +153,7 @@ static inline void nv10_render_generic_primitive_verts(GLcontext *ctx,GLuint sta nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,prim+1,size_dword); - OUT_RINGp((nouveauVertex*)(vertptr+(start*vertsize)),size_dword); + OUT_RING_VERTp(nmesa, (nouveauVertex*)(vertptr+(start*vertsize)),size_dword, (vertsize/4)); nv10FinishPrimitive(nmesa); } @@ -198,7 +242,7 @@ static inline void nv10_render_generic_primitive_elts(GLcontext *ctx,GLuint star nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,prim+1,size_dword); for (j=start; jvb; int attr_size[16]; - int default_attr_size[8]={3,3,3,4,3,1,4,4}; const int nv10_vtx_attribs[8]={ _TNL_ATTRIB_FOG, _TNL_ATTRIB_WEIGHT, _TNL_ATTRIB_NORMAL, _TNL_ATTRIB_TEX1, @@ -425,7 +469,7 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) */ if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) { for(i=0;i<8;i++) { - int j = nv10_vtx_attribs[i]; + int j = nv10_vtx_attribs[INV_VERT(i)]; if (RENDERINPUTS_TEST(index, j)) { switch(attr_size[j]) { -- cgit v1.2.3 From 3d17cdf55acc2b452b9f2b57a9823595615c4806 Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 16 Sep 2007 16:15:13 +0200 Subject: revert a956184f70733bd22e2bbee515386da12302963f --- src/mesa/tnl/t_vertex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index da32be9a179..a6728c318fe 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -294,7 +294,7 @@ GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map, GLuint i, j; assert(nr < _TNL_ATTRIB_MAX); -/* assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS);*/ + assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS); vtx->new_inputs = ~0; vtx->need_viewport = GL_FALSE; -- cgit v1.2.3 From e605f2828fb2e5d38a1f68ed78300f441c86dfa5 Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 16 Sep 2007 18:57:03 +0200 Subject: nouveau : opps I introduce a bug when cleaning vertex pos attribute swap patch --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 22144b66117..545600af647 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -75,8 +75,8 @@ static const int default_attr_size[8]={3,3,3,4,3,1,4,4}; #define OUT_RING_VERT_RAW(ptr,vertex_size) do{ \ /* if the vertex size is not null, we have at least pos attribute */ \ - OUT_RINGp((ptr) + default_attr_size[_TNL_ATTRIB_POS], (vertex_size) - default_attr_size[_TNL_ATTRIB_POS]); \ - OUT_RINGp((ptr), default_attr_size[_TNL_ATTRIB_POS]); \ + OUT_RINGp((uint32_t *)(ptr) + default_attr_size[_TNL_ATTRIB_POS], (vertex_size) - default_attr_size[_TNL_ATTRIB_POS]); \ + OUT_RINGp((uint32_t *)(ptr), default_attr_size[_TNL_ATTRIB_POS]); \ }while(0) #define OUT_RING_VERT(nmesa,ptr,vertex_size) do{ \ -- cgit v1.2.3 From 2616b206895d0e4e3ba1a5b981708ce3d37670ef Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 16 Sep 2007 19:37:27 +0200 Subject: nouveau : fix nv10_render functions use _tnl_RenderClipped helper functions that will call the right driver callback clean nv10_render_generic_primitive_elts to match nv10_render style --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 52 +++++++++---------------------- 1 file changed, 15 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 545600af647..4172afbb16c 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -233,16 +233,16 @@ static void (*nv10_render_tab_verts[GL_POLYGON+2])(GLcontext *, static inline void nv10_render_generic_primitive_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags,GLuint prim) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - GLubyte *vertptr = (GLubyte *)nmesa->verts; - GLuint vertsize = nmesa->vertex_size; - GLuint size_dword = vertsize*(count-start)/4; + uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLuint vertsize = nmesa->vertex_size / 4; + GLuint size_dword = vertsize*(count-start); const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; GLuint j; nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,prim+1,size_dword); for (j=start; jvertex_attr_count++; \ } while (0) -static void nv10_render_clipped_line(GLcontext *ctx,GLuint ii,GLuint jj) -{ - /* FIXME do something here */ - WARN_ONCE("Unimplemented %s\n", __func__); -} - -static void nv10_render_clipped_poly(GLcontext *ctx,const GLuint *elts,GLuint n) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - nv10_render_generic_primitive_elts( ctx, 0, n, PRIM_BEGIN|PRIM_END,GL_POLYGON ); - VB->Elts = tmp; -} - static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last) { WARN_ONCE("Unimplemented\n"); @@ -356,12 +340,10 @@ static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last) static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - GLubyte *vertptr = (GLubyte *)nmesa->verts; - GLuint vertsize = nmesa->vertex_size; - GLuint size_dword = vertsize*(2)/4; - + uint32_t *vertptr = (GLubyte *)nmesa->verts; /* OUT_RINGp wants size in DWORDS */ - vertsize >>= 2; + GLuint vertsize = nmesa->vertex_size / 4; + GLuint size_dword = vertsize*2; nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,GL_LINES+1,size_dword); @@ -373,12 +355,10 @@ static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2) static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - GLubyte *vertptr = (GLubyte *)nmesa->verts; - GLuint vertsize = nmesa->vertex_size; - GLuint size_dword = vertsize*(3)/4; - + uint32_t *vertptr = (GLubyte *)nmesa->verts; /* OUT_RINGp wants size in DWORDS */ - vertsize >>= 2; + GLuint vertsize = nmesa->vertex_size / 4; + GLuint size_dword = vertsize*3; nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,GL_TRIANGLES+1,size_dword); @@ -391,12 +371,10 @@ static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuin static inline void nv10_render_quad(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3,GLuint v4) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - GLubyte *vertptr = (GLubyte *)nmesa->verts; - GLuint vertsize = nmesa->vertex_size; - GLuint size_dword = vertsize*(4)/4; - + uint32_t *vertptr = (GLubyte *)nmesa->verts; /* OUT_RINGp wants size in DWORDS */ - vertsize >>= 2; + GLuint vertsize = nmesa->vertex_size / 4; + GLuint size_dword = vertsize*4; nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,GL_QUADS+1,size_dword); @@ -416,8 +394,8 @@ static void nv10ChooseRenderState(GLcontext *ctx) tnl->Driver.Render.PrimTabVerts = nv10_render_tab_verts; tnl->Driver.Render.PrimTabElts = nv10_render_tab_elts; - tnl->Driver.Render.ClippedLine = nv10_render_clipped_line; - tnl->Driver.Render.ClippedPolygon = nv10_render_clipped_poly; + tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; + tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; tnl->Driver.Render.Points = nv10_render_points; tnl->Driver.Render.Line = nv10_render_line; tnl->Driver.Render.Triangle = nv10_render_triangle; -- cgit v1.2.3 From 7356dac1b69ca76706439bb7c51ef37fee6588a2 Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 16 Sep 2007 23:01:56 +0200 Subject: nouveau : implement nv10_render_points --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 4172afbb16c..14c1351aa11 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -332,9 +332,36 @@ do { \ nmesa->vertex_attr_count++; \ } while (0) +static inline void nv10_render_point(GLcontext *ctx, GLubyte *vertptr) +{ + struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); + GLuint vertsize = nmesa->vertex_size / 4; + GLuint size_dword = vertsize; + + nv10ExtendPrimitive(nmesa, size_dword); + nv10StartPrimitive(nmesa,GL_POINTS+1,size_dword); + OUT_RING_VERT(nmesa, (nouveauVertex*)(vertptr),vertsize); + nv10FinishPrimitive(nmesa); +} + static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last) { - WARN_ONCE("Unimplemented\n"); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); + uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLuint vertsize = nmesa->vertex_size / 4; + GLuint i; + + if (VB->Elts) { + for (i = first; i < last; i++) + if (VB->ClipMask[VB->Elts[i]] == 0) + nv10_render_point(ctx, vertptr + (VB->Elts[i]*vertsize)); + } + else { + for (i = first; i < last; i++) + if (VB->ClipMask[i] == 0) + nv10_render_point(ctx, vertptr + (i*vertsize)); + } } static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2) -- cgit v1.2.3 From 7cc4d31ed9ff0e7f428b9ab05fc69b4e037c0a3a Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 16 Sep 2007 23:19:22 +0200 Subject: nouveau : use GLfloat instead of uint32_t. After all, our vertex attributes are float. --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index 14c1351aa11..e3f869d1f7f 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -75,8 +75,8 @@ static const int default_attr_size[8]={3,3,3,4,3,1,4,4}; #define OUT_RING_VERT_RAW(ptr,vertex_size) do{ \ /* if the vertex size is not null, we have at least pos attribute */ \ - OUT_RINGp((uint32_t *)(ptr) + default_attr_size[_TNL_ATTRIB_POS], (vertex_size) - default_attr_size[_TNL_ATTRIB_POS]); \ - OUT_RINGp((uint32_t *)(ptr), default_attr_size[_TNL_ATTRIB_POS]); \ + OUT_RINGp((GLfloat *)(ptr) + default_attr_size[_TNL_ATTRIB_POS], (vertex_size) - default_attr_size[_TNL_ATTRIB_POS]); \ + OUT_RINGp((GLfloat *)(ptr), default_attr_size[_TNL_ATTRIB_POS]); \ }while(0) #define OUT_RING_VERT(nmesa,ptr,vertex_size) do{ \ @@ -93,14 +93,14 @@ static const int default_attr_size[8]={3,3,3,4,3,1,4,4}; OUT_RINGp(ptr, sz); \ else \ for (nb_vert = 0; nb_vert < (sz)/(vertex_size); nb_vert++) { \ - OUT_RING_VERT_RAW((uint32_t*)(ptr)+nb_vert*(vertex_size), vertex_size); \ + OUT_RING_VERT_RAW((GLfloat*)(ptr)+nb_vert*(vertex_size), vertex_size); \ } \ }while(0) #endif -static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size) +static inline void nv10StartPrimitive(struct nouveau_context* nmesa,GLuint primitive,GLuint size) { if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1); @@ -233,7 +233,7 @@ static void (*nv10_render_tab_verts[GL_POLYGON+2])(GLcontext *, static inline void nv10_render_generic_primitive_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags,GLuint prim) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLfloat *vertptr = (GLfloat *)nmesa->verts; GLuint vertsize = nmesa->vertex_size / 4; GLuint size_dword = vertsize*(count-start); const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; @@ -332,7 +332,7 @@ do { \ nmesa->vertex_attr_count++; \ } while (0) -static inline void nv10_render_point(GLcontext *ctx, GLubyte *vertptr) +static inline void nv10_render_point(GLcontext *ctx, GLfloat *vertptr) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); GLuint vertsize = nmesa->vertex_size / 4; @@ -348,7 +348,7 @@ static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLfloat *vertptr = (GLfloat *)nmesa->verts; GLuint vertsize = nmesa->vertex_size / 4; GLuint i; @@ -367,7 +367,7 @@ static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last) static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLfloat *vertptr = (GLfloat *)nmesa->verts; /* OUT_RINGp wants size in DWORDS */ GLuint vertsize = nmesa->vertex_size / 4; GLuint size_dword = vertsize*2; @@ -382,7 +382,7 @@ static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2) static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLfloat *vertptr = (GLfloat *)nmesa->verts; /* OUT_RINGp wants size in DWORDS */ GLuint vertsize = nmesa->vertex_size / 4; GLuint size_dword = vertsize*3; @@ -398,7 +398,7 @@ static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuin static inline void nv10_render_quad(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3,GLuint v4) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - uint32_t *vertptr = (GLubyte *)nmesa->verts; + GLfloat *vertptr = (GLfloat *)nmesa->verts; /* OUT_RINGp wants size in DWORDS */ GLuint vertsize = nmesa->vertex_size / 4; GLuint size_dword = vertsize*4; -- cgit v1.2.3 From c29886718ac8389b526b3eb5947c286b7fe00a88 Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 16 Sep 2007 23:33:10 +0200 Subject: nouveau : avoid vertex_size / 4 for each vertex ops --- src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c index e3f869d1f7f..42b3d666fb9 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c @@ -147,13 +147,13 @@ static inline void nv10ExtendPrimitive(struct nouveau_context* nmesa, int size) static inline void nv10_render_generic_primitive_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags,GLuint prim) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - GLubyte *vertptr = (GLubyte *)nmesa->verts; + GLfloat *vertptr = (GLfloat *)nmesa->verts; GLuint vertsize = nmesa->vertex_size; - GLuint size_dword = vertsize*(count-start)/4; + GLuint size_dword = vertsize*(count-start); nv10ExtendPrimitive(nmesa, size_dword); nv10StartPrimitive(nmesa,prim+1,size_dword); - OUT_RING_VERTp(nmesa, (nouveauVertex*)(vertptr+(start*vertsize)),size_dword, (vertsize/4)); + OUT_RING_VERTp(nmesa, (nouveauVertex*)(vertptr+(start*vertsize)),size_dword, vertsize); nv10FinishPrimitive(nmesa); } @@ -234,7 +234,7 @@ static inline void nv10_render_generic_primitive_elts(GLcontext *ctx,GLuint star { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); GLfloat *vertptr = (GLfloat *)nmesa->verts; - GLuint vertsize = nmesa->vertex_size / 4; + GLuint vertsize = nmesa->vertex_size; GLuint size_dword = vertsize*(count-start); const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; GLuint j; @@ -335,7 +335,7 @@ do { \ static inline void nv10_render_point(GLcontext *ctx, GLfloat *vertptr) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); - GLuint vertsize = nmesa->vertex_size / 4; + GLuint vertsize = nmesa->vertex_size; GLuint size_dword = vertsize; nv10ExtendPrimitive(nmesa, size_dword); @@ -349,7 +349,7 @@ static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last) struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); GLfloat *vertptr = (GLfloat *)nmesa->verts; - GLuint vertsize = nmesa->vertex_size / 4; + GLuint vertsize = nmesa->vertex_size; GLuint i; if (VB->Elts) { @@ -368,8 +368,7 @@ static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2) { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); GLfloat *vertptr = (GLfloat *)nmesa->verts; - /* OUT_RINGp wants size in DWORDS */ - GLuint vertsize = nmesa->vertex_size / 4; + GLuint vertsize = nmesa->vertex_size; GLuint size_dword = vertsize*2; nv10ExtendPrimitive(nmesa, size_dword); @@ -383,8 +382,7 @@ static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuin { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); GLfloat *vertptr = (GLfloat *)nmesa->verts; - /* OUT_RINGp wants size in DWORDS */ - GLuint vertsize = nmesa->vertex_size / 4; + GLuint vertsize = nmesa->vertex_size; GLuint size_dword = vertsize*3; nv10ExtendPrimitive(nmesa, size_dword); @@ -399,8 +397,7 @@ static inline void nv10_render_quad(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3 { struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx); GLfloat *vertptr = (GLfloat *)nmesa->verts; - /* OUT_RINGp wants size in DWORDS */ - GLuint vertsize = nmesa->vertex_size / 4; + GLuint vertsize = nmesa->vertex_size; GLuint size_dword = vertsize*4; nv10ExtendPrimitive(nmesa, size_dword); @@ -528,7 +525,9 @@ static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa) nmesa->vertex_attrs, nmesa->vertex_attr_count, NULL, 0 ); - assert(nmesa->vertex_size==total_size*4); + /* OUT_RINGp wants size in DWORDS */ + nmesa->vertex_size = nmesa->vertex_size / 4; + assert(nmesa->vertex_size==total_size); /* * Tell the hardware about the vertex format -- cgit v1.2.3 From e21d2c6ef300c7661f49c50b4c68b4f205795f4a Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 18 Sep 2007 09:32:44 +0800 Subject: mesa: Always use the original mask to update stencil buffer in stencil_and_ztest_pixels. fix #12263 --- src/mesa/swrast/s_stencil.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index d0cbdd6917d..cae1e09929b 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -923,6 +923,8 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) ASSERT(rb->DataType == GL_UNSIGNED_BYTE); _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte)); + _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); + (void) do_stencil_test(ctx, face, n, stencil, mask); if (ctx->Depth.Test == GL_FALSE) { @@ -930,11 +932,12 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) n, stencil, mask); } else { - _mesa_memcpy(origMask, mask, n * sizeof(GLubyte)); + GLubyte tmpMask[MAX_WIDTH]; + _mesa_memcpy(tmpMask, mask, n * sizeof(GLubyte)); _swrast_depth_test_span(ctx, span); - compute_pass_fail_masks(n, origMask, mask, passMask, failMask); + compute_pass_fail_masks(n, tmpMask, mask, passMask, failMask); if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) { apply_stencil_op(ctx, ctx->Stencil.ZFailFunc[face], face, -- cgit v1.2.3 From 3800599bd4f6185c1eefc5d44794525ec4a3e406 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 19 Sep 2007 19:08:56 +0200 Subject: nouveau: nv10: color logic op only for nv11+ --- src/mesa/drivers/dri/nouveau/nv10_state.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c index 148f9fdd5ec..36084f3554e 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state.c @@ -297,8 +297,10 @@ static void nv10Enable(GLcontext *ctx, GLenum cap, GLboolean state) OUT_RING_CACHE(state); break; case GL_COLOR_LOGIC_OP: - BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE, 1); - OUT_RING_CACHE(state); + if (nmesa->screen->card->type >= NV_11) { + BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE, 1); + OUT_RING_CACHE(state); + } break; // case GL_COLOR_MATERIAL: // case GL_COLOR_SUM_EXT: @@ -583,6 +585,10 @@ static void nv10LineWidth(GLcontext *ctx, GLfloat width) static void nv10LogicOpcode(GLcontext *ctx, GLenum opcode) { + if (nmesa->screen->card->type < NV_11) { + return; + } + nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP, 1); OUT_RING_CACHE(opcode); -- cgit v1.2.3 From 9070e6b9970a6aeabfff07b259e0e1660980cc59 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 19 Jun 2007 15:15:40 -0700 Subject: i915: Quiet valgrind by initializing the seq value the kernel writes into. Also, add a couple of comments to the wait/emit IRQ functions. --- src/mesa/drivers/dri/i915/intel_ioctl.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.c b/src/mesa/drivers/dri/i915/intel_ioctl.c index ede3b6378fe..ddd92782db0 100644 --- a/src/mesa/drivers/dri/i915/intel_ioctl.c +++ b/src/mesa/drivers/dri/i915/intel_ioctl.c @@ -53,6 +53,10 @@ u_int32_t intelGetLastFrame (intelContextPtr intel) return frame; } +/** + * Emits a marker in the command stream, numbered from 0x00000001 to + * 0x7fffffff. + */ int intelEmitIrqLocked( intelContextPtr intel ) { drmI830IrqEmit ie; @@ -61,6 +65,10 @@ int intelEmitIrqLocked( intelContextPtr intel ) assert(((*(int *)intel->driHwLock) & ~DRM_LOCK_CONT) == (DRM_LOCK_HELD|intel->hHWContext)); + /* Valgrind can't tell that the kernel will have copyout()ed onto this + * value, so initialize it now to prevent false positives. + */ + seq = 0; ie.irq_seq = &seq; ret = drmCommandWriteRead( intel->driFd, DRM_I830_IRQ_EMIT, @@ -76,6 +84,7 @@ int intelEmitIrqLocked( intelContextPtr intel ) return seq; } +/** Blocks on a marker returned by intelEitIrqLocked(). */ void intelWaitIrq( intelContextPtr intel, int seq ) { int ret; -- cgit v1.2.3 From f843dcb844c4b1000f3b98a85f622b6929c19eea Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Sep 2007 09:02:24 -0700 Subject: Enable building the debug (env INTEL_DEBUG=list) code by default. --- src/mesa/drivers/dri/i915tex/intel_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/intel_context.h b/src/mesa/drivers/dri/i915tex/intel_context.h index ddd1439b004..3bb34796b1c 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.h +++ b/src/mesa/drivers/dri/i915tex/intel_context.h @@ -354,7 +354,7 @@ __memcpy(void *to, const void *from, size_t n) /* ================================================================ * Debugging: */ -#define DO_DEBUG 0 +#define DO_DEBUG 1 #if DO_DEBUG extern int INTEL_DEBUG; #else -- cgit v1.2.3 From b91791a85c1098e7a0210d7b9f186db20106ba3b Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 19 Sep 2007 09:56:43 -0700 Subject: Replace i915tex batchbuffer printout with a pretty-printed version. --- src/mesa/drivers/dri/i915tex/Makefile | 1 + src/mesa/drivers/dri/i915tex/intel_batchbuffer.c | 18 +- src/mesa/drivers/dri/i915tex/intel_decode.c | 832 +++++++++++++++++++++++ src/mesa/drivers/dri/i915tex/intel_decode.h | 29 + 4 files changed, 865 insertions(+), 15 deletions(-) create mode 100644 src/mesa/drivers/dri/i915tex/intel_decode.c create mode 100644 src/mesa/drivers/dri/i915tex/intel_decode.h (limited to 'src') diff --git a/src/mesa/drivers/dri/i915tex/Makefile b/src/mesa/drivers/dri/i915tex/Makefile index 445327f243e..ed8483a028c 100644 --- a/src/mesa/drivers/dri/i915tex/Makefile +++ b/src/mesa/drivers/dri/i915tex/Makefile @@ -44,6 +44,7 @@ DRIVER_SOURCES = \ i915_state.c \ i915_vtbl.c \ intel_context.c \ + intel_decode.c \ intel_ioctl.c \ intel_rotate.c \ intel_screen.c \ diff --git a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c index 6665629d034..c740c3d7f62 100644 --- a/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i915tex/intel_batchbuffer.c @@ -27,6 +27,7 @@ #include "intel_batchbuffer.h" #include "intel_ioctl.h" +#include "intel_decode.h" #include "i915_debug.h" /* Relocations in kernel space: @@ -67,16 +68,6 @@ * modifying cliprects ??? */ -static void -intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint count) -{ - int i; - fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count / 4); - for (i = 0; i < count / 4; i += 1) - fprintf(stderr, "\t0x%08x\n", ptr[i]); - fprintf(stderr, "END BATCH\n\n\n"); -} - void intel_batchbuffer_reset(struct intel_batchbuffer *batch) { @@ -186,11 +177,8 @@ do_flush_locked(struct intel_batchbuffer *batch, ptr[r->offset / 4] = driBOOffset(r->buf) + r->delta; } - if (INTEL_DEBUG & DEBUG_BATCH) { - if (0) i915_dump_batchbuffer(ptr, ptr + used/4); - intel_dump_batchbuffer(0, ptr, used); - } - + if (INTEL_DEBUG & DEBUG_BATCH) + intel_decode(ptr, used / 4, 0); driBOUnmap(batch->buffer); batch->map = NULL; diff --git a/src/mesa/drivers/dri/i915tex/intel_decode.c b/src/mesa/drivers/dri/i915tex/intel_decode.c new file mode 100644 index 00000000000..6fc02c999c3 --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/intel_decode.c @@ -0,0 +1,832 @@ +/* -*- c-basic-offset: 4 -*- */ +/* + * Copyright © 2007 Intel Corporation + * + * 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 AUTHORS OR COPYRIGHT HOLDERS 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: + * Eric Anholt + * + */ + +/** @file intel_decode.c + * This file contains code to print out batchbuffer contents in a + * human-readable format. + * + * The current version only supports i915 packets, and only pretty-prints a + * subset of them. The intention is for it to make just a best attempt to + * decode, but never crash in the process. + */ + +#include +#include +#include + +#include "intel_decode.h" +#include "i915_reg.h" + +#define BUFFER_FAIL(_count, _len, _name) do { \ + fprintf(out, "Buffer size too small in %s (%d < %d)\n", \ + (_name), (_count), (_len)); \ + (*failures)++; \ + return count; \ +} while (0) + +static FILE *out; +static uint32_t saved_s2 = 0, saved_s4 = 0; +static char saved_s2_set = 0, saved_s4_set = 0; + +static float +int_as_float(uint32_t intval) +{ + union intfloat { + uint32_t i; + float f; + } uval; + + uval.i = intval; + return uval.f; +} + +static void +instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index, + char *fmt, ...) +{ + va_list va; + + fprintf(out, "0x%08x: 0x%08x: ", hw_offset + index * 4, data[index]); + va_start(va, fmt); + vfprintf(out, fmt, va); + va_end(va); +} + + +static int +decode_mi(uint32_t *data, int count, uint32_t hw_offset, int *failures) +{ + unsigned int opcode; + + struct { + uint32_t opcode; + int min_len; + int max_len; + char *name; + } opcodes_mi[] = { + { 0x08, 1, 1, "MI_ARB_ON_OFF" }, + { 0x0a, 1, 1, "MI_BATCH_BUFFER_END" }, + { 0x31, 2, 2, "MI_BATCH_BUFFER_START" }, + { 0x14, 3, 3, "MI_DISPLAY_BUFFER_INFO" }, + { 0x04, 1, 1, "MI_FLUSH" }, + { 0x22, 3, 3, "MI_LOAD_REGISTER_IMM" }, + { 0x13, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" }, + { 0x12, 2, 2, "MI_LOAD_SCAN_LINES_INCL" }, + { 0x00, 1, 1, "MI_NOOP" }, + { 0x11, 2, 2, "MI_OVERLAY_FLIP" }, + { 0x07, 1, 1, "MI_REPORT_HEAD" }, + { 0x18, 2, 2, "MI_SET_CONTEXT" }, + { 0x20, 3, 4, "MI_STORE_DATA_IMM" }, + { 0x21, 3, 4, "MI_STORE_DATA_INDEX" }, + { 0x24, 3, 3, "MI_STORE_REGISTER_MEM" }, + { 0x02, 1, 1, "MI_USER_INTERRUPT" }, + { 0x03, 1, 1, "MI_WAIT_FOR_EVENT" }, + }; + + + for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]); + opcode++) { + if ((data[0] & 0x1e000000) >> 23 == opcodes_mi[opcode].opcode) { + unsigned int len = 1, i; + + instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name); + if (opcodes_mi[opcode].max_len > 1) { + len = (data[0] & 0x000000ff) + 2; + if (len < opcodes_mi[opcode].min_len || + len > opcodes_mi[opcode].max_len) + { + fprintf(out, "Bad length in %s\n", + opcodes_mi[opcode].name); + } + } + + for (i = 1; i < len; i++) { + if (i >= count) + BUFFER_FAIL(count, len, opcodes_mi[opcode].name); + instr_out(data, hw_offset, i, "dword %d\n", i); + } + + return len; + } + } + + instr_out(data, hw_offset, 0, "MI UNKNOWN\n"); + (*failures)++; + return 1; +} + +static int +decode_2d(uint32_t *data, int count, uint32_t hw_offset, int *failures) +{ + unsigned int opcode, len; + char *format; + + struct { + uint32_t opcode; + int min_len; + int max_len; + char *name; + } opcodes_2d[] = { + { 0x40, 5, 5, "COLOR_BLT" }, + { 0x43, 6, 6, "SRC_COPY_BLT" }, + { 0x01, 8, 8, "XY_SETUP_BLT" }, + { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" }, + { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" }, + { 0x24, 2, 2, "XY_PIXEL_BLT" }, + { 0x25, 3, 3, "XY_SCANLINES_BLT" }, + { 0x26, 4, 4, "Y_TEXT_BLT" }, + { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" }, + { 0x50, 6, 6, "XY_COLOR_BLT" }, + { 0x51, 6, 6, "XY_PAT_BLT" }, + { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" }, + { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" }, + { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" }, + { 0x52, 9, 9, "XY_MONO_PAT_BLT" }, + { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" }, + { 0x53, 8, 8, "XY_SRC_COPY_BLT" }, + { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" }, + { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" }, + { 0x55, 9, 9, "XY_FULL_BLT" }, + { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" }, + { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" }, + { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" }, + { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" }, + { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT" }, + }; + + switch ((data[0] & 0x1fc00000) >> 22) { + case 0x50: + instr_out(data, hw_offset, 0, + "XY_COLOR_BLT (rgb %sabled, alpha %sabled)\n", + (data[0] & (1 << 20)) ? "en" : "dis", + (data[0] & (1 << 21)) ? "en" : "dis"); + + len = (data[0] & 0x000000ff) + 2; + if (len != 6) + fprintf(out, "Bad count in XY_COLOR_BLT\n"); + if (count < 6) + BUFFER_FAIL(count, len, "XY_COLOR_BLT"); + + switch ((data[1] >> 24) & 0x3) { + case 0: + format="8"; + break; + case 1: + format="565"; + break; + case 2: + format="1555"; + break; + case 3: + format="8888"; + break; + } + + instr_out(data, hw_offset, 1, "format %s, pitch %d, " + "clipping %sabled\n", format, + data[1] & 0xffff, data[1] & (1 << 30) ? "en" : "dis"); + instr_out(data, hw_offset, 2, "(%d,%d)\n", + data[2] & 0xffff, data[2] >> 16); + instr_out(data, hw_offset, 3, "(%d,%d)\n", + data[2] & 0xffff, data[2] >> 16); + instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]); + instr_out(data, hw_offset, 5, "color\n"); + return len; + case 0x53: + instr_out(data, hw_offset, 0, + "XY_SRC_COPY_BLT (rgb %sabled, alpha %sabled)\n", + (data[0] & (1 << 20)) ? "en" : "dis", + (data[0] & (1 << 21)) ? "en" : "dis"); + + len = (data[0] & 0x000000ff) + 2; + if (len != 8) + fprintf(out, "Bad count in XY_SRC_COPY_BLT\n"); + if (count < 8) + BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT"); + + switch ((data[1] >> 24) & 0x3) { + case 0: + format="8"; + break; + case 1: + format="565"; + break; + case 2: + format="1555"; + break; + case 3: + format="8888"; + break; + } + + instr_out(data, hw_offset, 1, "format %s, dst pitch %d, " + "clipping %sabled\n", format, + data[1] & 0xffff, data[1] & (1 << 30) ? "en" : "dis"); + instr_out(data, hw_offset, 2, "dst (%d,%d)\n", + data[2] & 0xffff, data[2] >> 16); + instr_out(data, hw_offset, 3, "dst (%d,%d)\n", + data[2] & 0xffff, data[2] >> 16); + instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]); + instr_out(data, hw_offset, 5, "src (%d,%d)\n", + data[5] & 0xffff, data[5] >> 16); + instr_out(data, hw_offset, 6, "src pitch %d\n", + data[6] & 0xffff); + instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]); + return len; + } + + for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]); + opcode++) { + if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) { + unsigned int i; + + len = 1; + instr_out(data, hw_offset, 0, "%s\n", opcodes_2d[opcode].name); + if (opcodes_2d[opcode].max_len > 1) { + len = (data[0] & 0x000000ff) + 2; + if (len < opcodes_2d[opcode].min_len || + len > opcodes_2d[opcode].max_len) + { + fprintf(out, "Bad count in %s\n", opcodes_2d[opcode].name); + } + } + + for (i = 1; i < len; i++) { + if (i >= count) + BUFFER_FAIL(count, len, opcodes_2d[opcode].name); + instr_out(data, hw_offset, i, "dword %d\n", i); + } + + return len; + } + } + + instr_out(data, hw_offset, 0, "2D UNKNOWN\n"); + (*failures)++; + return 1; +} + +static int +decode_3d_1c(uint32_t *data, int count, uint32_t hw_offset, int *failures) +{ + switch ((data[0] & 0x00f80000) >> 19) { + case 0x11: + instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\n"); + return 1; + case 0x10: + instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE\n"); + return 1; + } + + instr_out(data, hw_offset, 0, "3D UNKNOWN\n"); + (*failures)++; + return 1; +} + +static int +decode_3d_1d(uint32_t *data, int count, uint32_t hw_offset, int *failures) +{ + unsigned int len, i, c, opcode, word, map, sampler, instr; + + struct { + uint32_t opcode; + int min_len; + int max_len; + char *name; + } opcodes_3d_1d[] = { + { 0x8e, 3, 3, "3DSTATE_BUFFER_INFO" }, + { 0x86, 4, 4, "3DSTATE_CHROMA_KEY" }, + { 0x9c, 1, 1, "3DSTATE_CLEAR_PARAMETERS" }, + { 0x88, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" }, + { 0x99, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" }, + { 0x9a, 2, 2, "3DSTATE_DEFAULT_SPECULAR" }, + { 0x98, 2, 2, "3DSTATE_DEFAULT_Z" }, + { 0x97, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" }, + { 0x85, 2, 2, "3DSTATE_DEST_BUFFER_VARIABLES" }, + { 0x80, 5, 5, "3DSTATE_DRAWING_RECTANGLE" }, + { 0x8e, 3, 3, "3DSTATE_BUFFER_INFO" }, + { 0x9d, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" }, + { 0x9e, 4, 4, "3DSTATE_MONO_FILTER" }, + { 0x89, 4, 4, "3DSTATE_FOG_MODE" }, + { 0x8f, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" }, + { 0x81, 3, 3, "3DSTATE_SCISSOR_RECTANGLE" }, + { 0x83, 2, 2, "3DSTATE_SPAN_STIPPLE" }, + }; + + switch ((data[0] & 0x00ff0000) >> 16) { + case 0x07: + /* This instruction is unusual. A 0 length means just 1 DWORD instead of + * 2. The 0 length is specified in one place to be unsupported, but + * stated to be required in another, and 0 length LOAD_INDIRECTs appear + * to cause no harm at least. + */ + instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n"); + len = (data[0] & 0x000000ff) + 1; + i = 1; + if (data[0] & (0x01 << 8)) { + if (i + 2 >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT"); + instr_out(data, hw_offset, i++, "SIS.0\n"); + instr_out(data, hw_offset, i++, "SIS.1\n"); + } + if (data[0] & (0x02 << 8)) { + if (i + 1 >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT"); + instr_out(data, hw_offset, i++, "DIS.0\n"); + } + if (data[0] & (0x04 << 8)) { + if (i + 2 >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT"); + instr_out(data, hw_offset, i++, "SSB.0\n"); + instr_out(data, hw_offset, i++, "SSB.1\n"); + } + if (data[0] & (0x08 << 8)) { + if (i + 2 >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT"); + instr_out(data, hw_offset, i++, "MSB.0\n"); + instr_out(data, hw_offset, i++, "MSB.1\n"); + } + if (data[0] & (0x10 << 8)) { + if (i + 2 >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT"); + instr_out(data, hw_offset, i++, "PSP.0\n"); + instr_out(data, hw_offset, i++, "PSP.1\n"); + } + if (data[0] & (0x20 << 8)) { + if (i + 2 >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT"); + instr_out(data, hw_offset, i++, "PSC.0\n"); + instr_out(data, hw_offset, i++, "PSC.1\n"); + } + if (len != i) { + fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n"); + (*failures)++; + return len; + } + return len; + case 0x04: + instr_out(data, hw_offset, 0, "3DSTATE_LOAD_STATE_IMMEDIATE_1\n"); + len = (data[0] & 0x0000000f) + 2; + i = 1; + for (word = 0; word <= 7; word++) { + if (data[0] & (1 << (4 + word))) { + if (i >= count) + BUFFER_FAIL(count, len, "3DSTATE_LOAD_STATE_IMMEDIATE_1"); + + /* save vertex state for decode */ + if (word == 2) { + saved_s2_set = 1; + saved_s2 = data[i]; + } + if (word == 4) { + saved_s4_set = 1; + saved_s4 = data[i]; + } + + instr_out(data, hw_offset, i++, "S%d\n", word); + } + } + if (len != i) { + fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n"); + (*failures)++; + } + return len; + case 0x00: + instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n"); + len = (data[0] & 0x0000003f) + 2; + + i = 1; + for (map = 0; map <= 15; map++) { + if (data[1] & (1 << map)) { + if (i + 3 >= count) + BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE"); + instr_out(data, hw_offset, i++, "map %d MS2\n", map); + instr_out(data, hw_offset, i++, "map %d MS3\n", map); + instr_out(data, hw_offset, i++, "map %d MS4\n", map); + } + } + if (len != i) { + fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n"); + (*failures)++; + return len; + } + return len; + case 0x06: + instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_CONSTANTS\n"); + len = (data[0] & 0x000000ff) + 2; + + i = 1; + for (c = 0; c <= 31; c++) { + if (data[1] & (1 << c)) { + if (i + 4 >= count) + BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_CONSTANTS"); + instr_out(data, hw_offset, i, "C%d.X = %f\n", + c, int_as_float(data[i])); + i++; + instr_out(data, hw_offset, i, "C%d.Y = %f\n", + c, int_as_float(data[i])); + i++; + instr_out(data, hw_offset, i, "C%d.Z = %f\n", + c, int_as_float(data[i])); + i++; + instr_out(data, hw_offset, i, "C%d.W = %f\n", + c, int_as_float(data[i])); + i++; + } + } + if (len != i) { + fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n"); + (*failures)++; + } + return len; + case 0x05: + instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n"); + len = (data[0] & 0x000000ff) + 2; + if ((len - 1) % 3 != 0 || len > 370) { + fprintf(out, "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n"); + (*failures)++; + } + i = 1; + for (instr = 0; instr < (len - 1) / 3; instr++) { + if (i + 3 >= count) + BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE"); + instr_out(data, hw_offset, i++, "PS%03x\n", instr); + instr_out(data, hw_offset, i++, "PS%03x\n", instr); + instr_out(data, hw_offset, i++, "PS%03x\n", instr); + } + return len; + case 0x01: + instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n"); + len = (data[0] & 0x0000003f) + 2; + i = 1; + for (sampler = 0; sampler <= 15; sampler++) { + if (data[1] & (1 << sampler)) { + if (i + 3 >= count) + BUFFER_FAIL(count, len, "3DSTATE_SAMPLER_STATE"); + instr_out(data, hw_offset, i++, "sampler %d SS2\n", + sampler); + instr_out(data, hw_offset, i++, "sampler %d SS3\n", + sampler); + instr_out(data, hw_offset, i++, "sampler %d SS4\n", + sampler); + } + } + if (len != i) { + fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n"); + (*failures)++; + } + return len; + } + + for (opcode = 0; opcode < sizeof(opcodes_3d_1d) / sizeof(opcodes_3d_1d[0]); + opcode++) + { + if (((data[0] & 0x00ff0000) >> 16) == opcodes_3d_1d[opcode].opcode) { + len = 1; + + instr_out(data, hw_offset, 0, "%s\n", opcodes_3d_1d[opcode].name); + if (opcodes_3d_1d[opcode].max_len > 1) { + len = (data[0] & 0x0000ffff) + 2; + if (len < opcodes_3d_1d[opcode].min_len || + len > opcodes_3d_1d[opcode].max_len) + { + fprintf(out, "Bad count in %s\n", + opcodes_3d_1d[opcode].name); + (*failures)++; + } + } + + for (i = 1; i < len; i++) { + if (i >= count) + BUFFER_FAIL(count, len, opcodes_3d_1d[opcode].name); + instr_out(data, hw_offset, i, "dword %d\n", i); + } + + return len; + } + } + + instr_out(data, hw_offset, 0, "3D UNKNOWN\n"); + (*failures)++; + return 1; +} + +static int +decode_3d_primitive(uint32_t *data, int count, uint32_t hw_offset, + int *failures) +{ + char immediate = (data[0] & (1 << 23)) == 0; + unsigned int len, i; + char *primtype; + + switch ((data[0] >> 18) & 0xf) { + case 0x0: primtype = "TRILIST"; break; + case 0x1: primtype = "TRISTRIP"; break; + case 0x2: primtype = "TRISTRIP_REVERSE"; break; + case 0x3: primtype = "TRIFAN"; break; + case 0x4: primtype = "POLYGON"; break; + case 0x5: primtype = "LINELIST"; break; + case 0x6: primtype = "LINESTRIP"; break; + case 0x7: primtype = "RECTLIST"; break; + case 0x8: primtype = "POINTLIST"; break; + case 0x9: primtype = "DIB"; break; + case 0xa: primtype = "CLEAR_RECT"; break; + default: primtype = "unknown"; break; + } + + /* XXX: 3DPRIM_DIB not supported */ + if (immediate) { + len = (data[0] & 0x0003ffff) + 2; + instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n", primtype); + if (count < len) + BUFFER_FAIL(count, len, "3DPRIMITIVE inline"); + if (!saved_s2_set || !saved_s4_set) { + fprintf(out, "unknown vertex format\n"); + for (i = 1; i < len; i++) { + instr_out(data, hw_offset, i, + " vertex data (%f float)\n", + int_as_float(data[i])); + } + } else { + unsigned int vertex = 0; + for (i = 1; i < len;) { + unsigned int tc; + +#define VERTEX_OUT(fmt, ...) do { \ + if (i < len) \ + instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \ + else \ + fprintf(out, " missing data in V%d\n", vertex); \ + i++; \ +} while (0) + + VERTEX_OUT("X = %f", int_as_float(data[i])); + VERTEX_OUT("Y = %f", int_as_float(data[i])); + switch (saved_s4 >> 6 & 0x7) { + case 0x1: + VERTEX_OUT("Z = %f", int_as_float(data[i])); + break; + case 0x2: + VERTEX_OUT("Z = %f", int_as_float(data[i])); + VERTEX_OUT("W = %f", int_as_float(data[i])); + break; + case 0x3: + break; + case 0x4: + VERTEX_OUT("W = %f", int_as_float(data[i])); + break; + default: + fprintf(out, "bad S4 position mask\n"); + } + + if (saved_s4 & (1 << 10)) { + VERTEX_OUT("color = (A=0x%02x, R=0x%02x, G=0x%02x, " + "B=0x%02x)", + data[i] >> 24, + (data[i] >> 16) & 0xff, + (data[i] >> 8) & 0xff, + data[i] & 0xff); + } + if (saved_s4 & (1 << 11)) { + VERTEX_OUT("spec = (A=0x%02x, R=0x%02x, G=0x%02x, " + "B=0x%02x)", + data[i] >> 24, + (data[i] >> 16) & 0xff, + (data[i] >> 8) & 0xff, + data[i] & 0xff); + } + if (saved_s4 & (1 << 12)) + VERTEX_OUT("width = 0x%08x)", data[i]); + + for (tc = 0; tc <= 7; tc++) { + switch ((saved_s2 >> (tc * 4)) & 0xf) { + case 0x0: + VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i])); + VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i])); + break; + case 0x1: + VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i])); + VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i])); + VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i])); + break; + case 0x2: + VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i])); + VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i])); + VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i])); + VERTEX_OUT("T%d.W = %f", tc, int_as_float(data[i])); + break; + case 0x3: + VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i])); + break; + case 0x4: + VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]); + break; + case 0x5: + VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]); + VERTEX_OUT("T%d.ZW = 0x%08x half-float", tc, data[i]); + break; + case 0xf: + break; + default: + fprintf(out, "bad S2.T%d format\n", tc); + } + } + vertex++; + } + } + } else { + /* indirect vertices */ + len = data[0] & 0x0000ffff; /* index count */ + if (data[0] & (1 << 17)) { + /* random vertex access */ + if (count < (len + 1) / 2 + 1) { + BUFFER_FAIL(count, (len + 1) / 2 + 1, + "3DPRIMITIVE random indirect"); + } + instr_out(data, hw_offset, 0, + "3DPRIMITIVE random indirect %s (%d)\n", primtype, len); + if (len == 0) { + /* vertex indices continue until 0xffff is found */ + for (i = 1; i < count; i++) { + if ((data[i] & 0xffff) == 0xffff) { + instr_out(data, hw_offset, i, + " indices: (terminator)\n"); + return i; + } else if ((data[i] >> 16) == 0xffff) { + instr_out(data, hw_offset, i, + " indices: 0x%04x, " + "(terminator)\n", + data[i] & 0xffff); + return i; + } else { + instr_out(data, hw_offset, i, + " indices: 0x%04x, 0x%04x\n", + data[i] & 0xffff, data[i] >> 16); + } + } + fprintf(out, + "3DPRIMITIVE: no terminator found in index buffer\n"); + (*failures)++; + return count; + } else { + /* fixed size vertex index buffer */ + for (i = 0; i < len; i += 2) { + if (i * 2 == len - 1) { + instr_out(data, hw_offset, i, + " indices: 0x%04x\n", + data[i] & 0xffff); + } else { + instr_out(data, hw_offset, i, + " indices: 0x%04x, 0x%04x\n", + data[i] & 0xffff, data[i] >> 16); + } + } + } + return (len + 1) / 2 + 1; + } else { + /* sequential vertex access */ + if (count < 2) + BUFFER_FAIL(count, 2, "3DPRIMITIVE seq indirect"); + instr_out(data, hw_offset, 0, + "3DPRIMITIVE sequential indirect %s, %d starting from " + "%d\n", primtype, len, data[1] & 0xffff); + instr_out(data, hw_offset, 1, " start\n"); + return 2; + } + } + + return len; +} + +static int +decode_3d(uint32_t *data, int count, uint32_t hw_offset, int *failures) +{ + unsigned int opcode; + + struct { + uint32_t opcode; + int min_len; + int max_len; + char *name; + } opcodes_3d[] = { + { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" }, + { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" }, + { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" }, + { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" }, + { 0x15, 1, 1, "3DSTATE_FOG_COLOR" }, + { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" }, + { 0x0d, 1, 1, "3DSTATE_MODES_4" }, + { 0x0c, 1, 1, "3DSTATE_MODES_5" }, + { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" }, + }; + + switch ((data[0] & 0x1f000000) >> 24) { + case 0x1f: + return decode_3d_primitive(data, count, hw_offset, failures); + case 0x1d: + return decode_3d_1d(data, count, hw_offset, failures); + case 0x1c: + return decode_3d_1c(data, count, hw_offset, failures); + } + + for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]); + opcode++) { + if ((data[0] & 0x1f000000) >> 24 == opcodes_3d[opcode].opcode) { + unsigned int len = 1, i; + + instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name); + if (opcodes_3d[opcode].max_len > 1) { + len = (data[0] & 0xff) + 2; + if (len < opcodes_3d[opcode].min_len || + len > opcodes_3d[opcode].max_len) + { + fprintf(out, "Bad count in %s\n", opcodes_3d[opcode].name); + } + } + + for (i = 1; i < len; i++) { + if (i >= count) + BUFFER_FAIL(count, len, opcodes_3d[opcode].name); + instr_out(data, hw_offset, i, "dword %d\n", i); + } + return len; + } + } + + instr_out(data, hw_offset, 0, "3D UNKNOWN\n"); + (*failures)++; + return 1; +} + +/** + * Decodes an i830-i915 batch buffer, writing the output to stdout. + * + * \param data batch buffer contents + * \param count number of DWORDs to decode in the batch buffer + * \param hw_offset hardware address for the buffer + */ +int +intel_decode(uint32_t *data, int count, uint32_t hw_offset) +{ + int index = 0; + int failures = 0; + + out = stdout; + + while (index < count) { + switch ((data[index] & 0xe0000000) >> 29) { + case 0x0: + index += decode_mi(data + index, count - index, + hw_offset + index * 4, &failures); + break; + case 0x2: + index += decode_2d(data + index, count - index, + hw_offset + index * 4, &failures); + break; + case 0x3: + index += decode_3d(data + index, count - index, + hw_offset + index * 4, &failures); + break; + default: + instr_out(data, hw_offset, index, "UNKNOWN\n"); + failures++; + index++; + break; + } + fflush(out); + } + + return failures; +} + +void intel_disasm_context_reset() +{ + saved_s2_set = 0; + saved_s4_set = 1; +} + diff --git a/src/mesa/drivers/dri/i915tex/intel_decode.h b/src/mesa/drivers/dri/i915tex/intel_decode.h new file mode 100644 index 00000000000..ef0cba153c7 --- /dev/null +++ b/src/mesa/drivers/dri/i915tex/intel_decode.h @@ -0,0 +1,29 @@ +/* + * Copyright © 2007 Intel Corporation + * + * 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 AUTHORS OR COPYRIGHT HOLDERS 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: + * Eric Anholt + * + */ + +int intel_decode(uint32_t *data, int count, uint32_t hw_offset); +void intel_decode_context_reset(); -- cgit v1.2.3