Index: r200_context.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_context.c,v retrieving revision 1.52 diff -u -r1.52 r200_context.c --- r200_context.c 5 Oct 2005 16:15:16 -0000 1.52 +++ r200_context.c 7 Oct 2005 17:26:51 -0000 @@ -74,6 +74,7 @@ #define need_GL_EXT_blend_equation_separate #define need_GL_EXT_blend_func_separate #define need_GL_NV_vertex_program +#define need_GL_ARB_point_parameters #include "extension_helper.h" #define DRIVER_DATE "20050831" @@ -182,6 +183,12 @@ { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions } }; +const struct dri_extension point_extensions[] = { + { "GL_ARB_point_sprite", NULL }, + { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, + { NULL, NULL } +}; + extern const struct tnl_pipeline_stage _r200_render_stage; extern const struct tnl_pipeline_stage _r200_tcl_stage; @@ -199,9 +206,9 @@ &_tnl_fog_coordinate_stage, &_tnl_texgen_stage, &_tnl_texture_transform_stage, + &_tnl_point_attenuation_stage, &_tnl_arb_vertex_program_stage, &_tnl_vertex_program_stage, - /* Try again to go to tcl? * - no good for asymmetric-twoside (do with multipass) * - no good for asymmetric-unfilled (do with multipass) @@ -480,6 +487,8 @@ if ((ctx->Const.MaxTextureUnits == 6) && rmesa->r200Screen->drmSupportsFragShader) driInitSingleExtension( ctx, ATI_fs_extension ); + if (rmesa->r200Screen->drmSupportsPointSprites) + driInitExtensions( ctx, point_extensions, GL_FALSE ); #if 0 r200InitDriverFuncs( ctx ); r200InitIoctlFuncs( ctx ); Index: r200_context.h =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_context.h,v retrieving revision 1.35 diff -u -r1.35 r200_context.h --- r200_context.h 5 Oct 2005 20:28:31 -0000 1.35 +++ r200_context.h 7 Oct 2005 17:26:52 -0000 @@ -399,9 +399,27 @@ /* SPR - point sprite state */ -#define SPR_CMD_0 0 -#define SPR_POINT_SPRITE_CNTL 1 -#define SPR_STATE_SIZE 2 +#define SPR_CMD_0 0 +#define SPR_POINT_SPRITE_CNTL 1 +#define SPR_CMD_1 2 +#define SPR_VPORT_SCALE_0 3 +#define SPR_VPORT_SCALE_1 4 +#define SPR_VPORT_SCALE_PTSIZE 5 +#define SPR_VPORT_SCALE_3 6 +#define SPR_CMD_2 7 +#define SPR_ATT_CONST_QUAD 8 +#define SPR_ATT_CONST_LIN 9 +#define SPR_ATT_CONST_CON 10 +#define SPR_ATT_CONST_3 11 +#define SPR_EYE_X 12 +#define SPR_EYE_Y 13 +#define SPR_EYE_Z 14 +#define SPR_EYE_3 15 +#define SPR_CLAMP_MIN 16 +#define SPR_CLAMP_MAX 17 +#define SPR_CLAMP_2 18 +#define SPR_CLAMP_3 19 +#define SPR_STATE_SIZE 20 #define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\ R200_VTX_COLOR_MASK) Index: r200_reg.h =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_reg.h,v retrieving revision 1.14 diff -u -r1.14 r200_reg.h --- r200_reg.h 10 Sep 2005 00:11:27 -0000 1.14 +++ r200_reg.h 7 Oct 2005 17:26:53 -0000 @@ -658,7 +658,23 @@ #define R200_CULL_FRONT (1<<29) #define R200_CULL_BACK (1<<30) #define R200_SE_TCL_POINT_SPRITE_CNTL 0x22c4 -#define R200_POINTSIZE_SEL_STATE (1<<16) +#define R200_PS_MULT_PVATTENCONST (0<<0) +#define R200_PS_MULT_PVATTEN (1<<0) +#define R200_PS_MULT_ATTENCONST (2<<0) +#define R200_PS_MULT_PVCONST (3<<0) +#define R200_PS_MULT_CONST (4<<0) +#define R200_PS_MULT_MASK (7<<0) +#define R200_PS_LIN_ATT_ZERO (1<<3) +#define R200_PS_USE_MODEL_EYE_VEC (1<<4) +#define R200_PS_ATT_ALPHA (1<<5) +#define R200_PS_UCP_MODE_MASK (3<<6) +#define R200_PS_GEN_TEX_0 (1<<8) +#define R200_PS_GEN_TEX_1 (1<<9) +#define R200_PS_GEN_TEX_2 (1<<10) +#define R200_PS_GEN_TEX_3 (1<<11) +#define R200_PS_GEN_TEX_4 (1<<12) +#define R200_PS_GEN_TEX_5 (1<<13) +#define R200_PS_SE_SEL_STATE (1<<16) /* gap */ #define R200_SE_VTX_ST_POS_0_X_4 0x2300 #define R200_SE_VTX_ST_POS_0_Y_4 0x2304 Index: r200_screen.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_screen.c,v retrieving revision 1.50 diff -u -r1.50 r200_screen.c --- r200_screen.c 5 Oct 2005 16:15:16 -0000 1.50 +++ r200_screen.c 7 Oct 2005 17:26:53 -0000 @@ -95,6 +95,7 @@ extern const struct dri_extension ARB_vp_extension[]; extern const struct dri_extension NV_vp_extension[]; extern const struct dri_extension ATI_fs_extension[]; +extern const struct dri_extension point_extensions[]; #if 1 /* Including xf86PciInfo.h introduces a bunch of errors... @@ -715,6 +716,7 @@ driInitSingleExtension( NULL, ARB_vp_extension ); driInitSingleExtension( NULL, NV_vp_extension ); driInitSingleExtension( NULL, ATI_fs_extension ); + driInitExtensions( NULL, point_extensions, GL_FALSE ); } return (void *) psp; Index: r200_state.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_state.c,v retrieving revision 1.40 diff -u -r1.40 r200_state.c --- r200_state.c 5 Oct 2005 22:40:09 -0000 1.40 +++ r200_state.c 7 Oct 2005 17:26:55 -0000 @@ -690,10 +690,80 @@ static void r200PointSize( GLcontext *ctx, GLfloat size ) { r200ContextPtr rmesa = R200_CONTEXT(ctx); + GLfloat *fcmd = (GLfloat *)rmesa->hw.spr.cmd; R200_STATECHANGE( rmesa, cst ); + R200_STATECHANGE( rmesa, spr ); rmesa->hw.cst.cmd[CST_RE_POINTSIZE] &= ~0xffff; rmesa->hw.cst.cmd[CST_RE_POINTSIZE] |= ((GLuint)(ctx->Point.Size * 16.0)); +/* this is the size param of the point size calculation (point size reg value + is not used when calculation is active). */ + fcmd[SPR_VPORT_SCALE_PTSIZE] = ctx->Point.Size; +} + +static void r200PointParameter( GLcontext *ctx, GLenum pname, const GLfloat *params) +{ + r200ContextPtr rmesa = R200_CONTEXT(ctx); + GLfloat *fcmd = (GLfloat *)rmesa->hw.spr.cmd; + + switch (pname) { + case GL_POINT_SIZE_MIN: + /* Not sure why there are 2 sets of clamping values, since when calculation + is in use both sets seem to take effect. Just set both (as does fglrx) */ + R200_STATECHANGE( rmesa, lin ); + R200_STATECHANGE( rmesa, spr ); + rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] &= 0xffff; + rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint)(ctx->Point.MinSize * 16.0) << 16; + fcmd[SPR_CLAMP_MIN] = ctx->Point.MinSize; + break; + case GL_POINT_SIZE_MAX: + R200_STATECHANGE( rmesa, cst ); + R200_STATECHANGE( rmesa, spr ); + rmesa->hw.cst.cmd[CST_RE_POINTSIZE] &= 0xffff; + rmesa->hw.cst.cmd[CST_RE_POINTSIZE] |= (GLuint)(ctx->Point.MaxSize * 16.0) << 16; + fcmd[SPR_CLAMP_MAX] = ctx->Point.MaxSize; + break; + case GL_POINT_DISTANCE_ATTENUATION: + R200_STATECHANGE( rmesa, vtx ); + R200_STATECHANGE( rmesa, spr ); + GLfloat *fcmd = (GLfloat *)rmesa->hw.spr.cmd; + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] &= + ~(R200_PS_MULT_MASK | R200_PS_LIN_ATT_ZERO | R200_PS_SE_SEL_STATE); + /* can't rely on ctx->Point._Attenuated here and test for NEW_POINT in + r200ValidateState looks like overkill */ + if (ctx->Point.Params[0] != 1.0 || + ctx->Point.Params[1] != 0.0 || + ctx->Point.Params[2] != 0.0) { + fcmd[SPR_ATT_CONST_QUAD] = ctx->Point.Params[2]; + fcmd[SPR_ATT_CONST_LIN] = ctx->Point.Params[1]; + fcmd[SPR_ATT_CONST_CON] = ctx->Point.Params[0]; + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= R200_PS_MULT_ATTENCONST; + if (ctx->Point.Params[1] == 0.0) + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= R200_PS_LIN_ATT_ZERO; +/* FIXME: setting this here doesn't look quite ok - we only want to do + that if we're actually drawing points probably */ + rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_PT_SIZE; + rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |= R200_VTX_POINT_SIZE; + } + else { + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= + R200_PS_SE_SEL_STATE | R200_PS_MULT_CONST; +/* FIXME: same as above */ + rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] &= ~R200_OUTPUT_PT_SIZE; + rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] &= ~R200_VTX_POINT_SIZE; + } + break; + case GL_POINT_FADE_THRESHOLD_SIZE: + /* don't support multisampling, so don't need this */ + break; + /* not implemented - r200 probably can't do r_mode_nv, + no clue how you'd do coord_origin + case GL_POINT_SPRITE_R_MODE_NV: + case GL_POINT_SPRITE_COORD_ORIGIN: */ + default: + fprintf(stderr, "bad pname parameter in r200PointParameter\n"); + return; + } } /* ============================================================= @@ -2441,6 +2512,7 @@ functions->PolygonMode = r200PolygonMode; functions->PolygonOffset = r200PolygonOffset; functions->PolygonStipple = r200PolygonStipple; + functions->PointParameterfv = r200PointParameter; functions->PointSize = r200PointSize; functions->RenderMode = r200RenderMode; functions->Scissor = r200Scissor; Index: r200_state_init.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_state_init.c,v retrieving revision 1.25 diff -u -r1.25 r200_state_init.c --- r200_state_init.c 5 Oct 2005 16:15:16 -0000 1.25 +++ r200_state_init.c 7 Oct 2005 17:26:55 -0000 @@ -490,6 +490,11 @@ cmdvec( R200_VS_UCP_ADDR + i, 1, 4 ); } + rmesa->hw.spr.cmd[SPR_CMD_1] = + cmdvec( R200_VS_PNT_SPRITE_VPORT_SCALE, 1, 4 ); + rmesa->hw.spr.cmd[SPR_CMD_2] = + cmdvec( R200_VS_PNT_SPRITE_ATT_CONST, 1, 12 ); + /* Initial Harware state: */ rmesa->hw.ctx.cmd[CTX_PP_MISC] = (R200_ALPHA_TEST_PASS @@ -875,7 +880,31 @@ rmesa->hw.eye.cmd[EYE_Z] = IEEE_ONE; rmesa->hw.eye.cmd[EYE_RESCALE_FACTOR] = IEEE_ONE; - rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] = R200_POINTSIZE_SEL_STATE; + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] = + R200_PS_SE_SEL_STATE | R200_PS_MULT_CONST; + + /* spr_eye is presumably used to calculate the attenuation wrt a different + location? In any case, since point attenuation triggers _needeyecoords, + it is constant. Probably ignored as long as R200_PS_USE_MODEL_EYE_VEC + isn't set */ + rmesa->hw.spr.cmd[SPR_EYE_X] = 0; + rmesa->hw.spr.cmd[SPR_EYE_Y] = 0; + rmesa->hw.spr.cmd[SPR_EYE_Z] = IEEE_ONE | 0x80000000; /* -1.0 */ + rmesa->hw.spr.cmd[SPR_EYE_3] = 0; + /* no idea what the spr_vport_scale values are good for, except the + PTSIZE one - hopefully doesn't matter */ + rmesa->hw.spr.cmd[SPR_VPORT_SCALE_0] = IEEE_ONE; + rmesa->hw.spr.cmd[SPR_VPORT_SCALE_1] = IEEE_ONE; + rmesa->hw.spr.cmd[SPR_VPORT_SCALE_PTSIZE] = IEEE_ONE; + rmesa->hw.spr.cmd[SPR_VPORT_SCALE_3] = IEEE_ONE; + rmesa->hw.spr.cmd[SPR_ATT_CONST_QUAD] = 0; + rmesa->hw.spr.cmd[SPR_ATT_CONST_LIN] = 0; + rmesa->hw.spr.cmd[SPR_ATT_CONST_CON] = IEEE_ONE; + rmesa->hw.spr.cmd[SPR_ATT_CONST_3] = 0; + rmesa->hw.spr.cmd[SPR_CLAMP_MIN] = IEEE_ONE; + rmesa->hw.spr.cmd[SPR_CLAMP_MAX] = 0x44ffe000; /* 2047 */ + rmesa->hw.spr.cmd[SPR_CLAMP_2] = 0; + rmesa->hw.spr.cmd[SPR_CLAMP_3] = 0; r200LightingSpaceChange( ctx ); Index: r200_swtcl.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c,v retrieving revision 1.28 diff -u -r1.28 r200_swtcl.c --- r200_swtcl.c 5 Oct 2005 16:15:16 -0000 1.28 +++ r200_swtcl.c 7 Oct 2005 17:26:56 -0000 @@ -115,6 +115,12 @@ offset = 3; } + /* ??? */ + if (index & _TNL_BIT_POINTSIZE) { + EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, R200_VTX_POINT_SIZE ); + offset += 1; + } + rmesa->swtcl.coloroffset = offset; #if MESA_LITTLE_ENDIAN EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) ); @@ -344,7 +350,7 @@ { switch (prim) { case GL_POINTS: - return (ctx->_TriangleCaps & DD_POINT_SIZE) ? + return (ctx->_TriangleCaps & (DD_POINT_SIZE | DD_POINT_ATTEN)) ? R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS; case GL_LINES: /* fallthrough */ Index: r200_tcl.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c,v retrieving revision 1.23 diff -u -r1.23 r200_tcl.c --- r200_tcl.c 5 Oct 2005 16:15:16 -0000 1.23 +++ r200_tcl.c 7 Oct 2005 17:26:56 -0000 @@ -68,7 +68,7 @@ #define HAVE_ELTS 1 -#define HW_POINTS ((ctx->_TriangleCaps & DD_POINT_SIZE) ? \ +#define HW_POINTS ((ctx->_TriangleCaps & (DD_POINT_SIZE | DD_POINT_ATTEN)) ? \ R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS) #define HW_LINES R200_VF_PRIM_LINES #define HW_LINE_LOOP 0 Index: r200_tex.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_tex.c,v retrieving revision 1.20 diff -u -r1.20 r200_tex.c --- r200_tex.c 7 Oct 2004 23:30:30 -0000 1.20 +++ r200_tex.c 7 Oct 2005 17:26:57 -0000 @@ -983,7 +983,14 @@ } break; } - + case GL_COORD_REPLACE_ARB: + R200_STATECHANGE( rmesa, spr ); + if ((GLenum)param[0]) { + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= R200_PS_GEN_TEX_0 << unit; + } else { + rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] &= ~(R200_PS_GEN_TEX_0 << unit); + } + break; default: return; } Index: r200_texstate.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c,v retrieving revision 1.22 diff -u -r1.22 r200_texstate.c --- r200_texstate.c 12 Sep 2005 21:20:10 -0000 1.22 +++ r200_texstate.c 7 Oct 2005 17:26:58 -0000 @@ -352,7 +352,28 @@ /* FYI: r200UploadTexImages( rmesa, t ) used to be called here */ } - +#if 0 +static void print_texenv( GLcontext *ctx, GLuint k ) { + int j; + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[k]; + const GLuint numColorArgs = texUnit->_CurrentCombine->_NumArgsRGB; + const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA; + fprintf(stderr, "%d %sabled ", k, texUnit->_ReallyEnabled ? "en" : "dis"); + fprintf(stderr, "comb RGB %x ", texUnit->_CurrentCombine->ModeRGB); + fprintf(stderr, "comb A %x ", texUnit->_CurrentCombine->ModeA); + fprintf(stderr, "RGB args/ops "); + for (j = 0; j < numColorArgs; j++) { + fprintf(stderr, "%x ", texUnit->_CurrentCombine->SourceRGB[j]); + fprintf(stderr, "%d ", texUnit->_CurrentCombine->OperandRGB[j] - GL_SRC_COLOR); + } + fprintf(stderr, "A args/ops "); + for (j = 0; j < numAlphaArgs; j++) { + fprintf(stderr, "%x ", texUnit->_CurrentCombine->SourceA[j]); + fprintf(stderr, "%d ", texUnit->_CurrentCombine->OperandA[j] - GL_SRC_ALPHA); + } + fprintf(stderr, "\n"); +} +#endif /* ================================================================ * Texture combine functions