diff options
author | Eric Anholt <anholt@FreeBSD.org> | 2006-07-17 22:32:25 -0700 |
---|---|---|
committer | Eric Anholt <anholt@FreeBSD.org> | 2006-07-18 17:11:34 -0400 |
commit | 148ef9bdd9e0ef3e7ac86b56a8662b53a3ea9168 (patch) | |
tree | 9a89d00a6220bbc6000dcb74aebd6bd20ddd1569 | |
parent | 16d6263e6518a4a05562e2842ff2d0fdb4710304 (diff) |
Convert magic numbers to symbolic names in i915 rotate code.
This doesn't cover the fragment shader yet, which we need to make a sensible
set of macros for (at least the basic bits).
Reviewed by: md5
-rw-r--r-- | src/i830_rotate.c | 149 | ||||
-rw-r--r-- | src/i915_reg.h | 17 |
2 files changed, 120 insertions, 46 deletions
diff --git a/src/i830_rotate.c b/src/i830_rotate.c index 4d7237f7..3192762d 100644 --- a/src/i830_rotate.c +++ b/src/i830_rotate.c @@ -57,6 +57,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "shadow.h" #include "i830.h" +#include "i915_reg.h" #ifdef XF86DRI #include "dri.h" @@ -267,58 +268,111 @@ I915UpdateRotate (ScreenPtr pScreen, BEGIN_LP_RING(64); /* invarient state */ OUT_RING(MI_NOOP); - OUT_RING(0x66014140); - OUT_RING(0x7d990000); + OUT_RING(_3DSTATE_AA_CMD | + AA_LINE_ECAAR_WIDTH_ENABLE | AA_LINE_ECAAR_WIDTH_1_0 | + AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); + + OUT_RING(_3DSTATE_DFLT_DIFFUSE_CMD); OUT_RING(0x00000000); - OUT_RING(0x7d9a0000); + + OUT_RING(_3DSTATE_DFLT_SPEC_CMD); OUT_RING(0x00000000); - OUT_RING(0x7d980000); + + OUT_RING(_3DSTATE_DFLT_Z_CMD); OUT_RING(0x00000000); - OUT_RING(0x76fac688); - OUT_RING(0x6700a770); - OUT_RING(0x7d040081); + + OUT_RING(_3DSTATE_COORD_SET_BINDINGS | + CSB_TCB(0, 0) | CSB_TCB(1, 1) | + CSB_TCB(2, 2) | CSB_TCB(3, 3) | + CSB_TCB(4, 4) | CSB_TCB(5, 5) | + CSB_TCB(6, 6) | CSB_TCB(7, 7)); + + OUT_RING(_3DSTATE_RASTER_RULES_CMD | + ENABLE_TRI_FAN_PROVOKE_VRTX | TRI_FAN_PROVOKE_VRTX(2) | + ENABLE_LINE_STRIP_PROVOKE_VRTX | LINE_STRIP_PROVOKE_VRTX(1) | + ENABLE_TEXKILL_3D_4D | TEXKILL_4D | + ENABLE_POINT_RASTER_RULE | OGL_POINT_RASTER_RULE); + + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | 1); OUT_RING(0x00000000); + /* flush map & render cache */ OUT_RING(MI_FLUSH | MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE); OUT_RING(0x00000000); + /* draw rect */ - OUT_RING(0x7d800003); - OUT_RING(0x00000000); - OUT_RING(0x00000000); - OUT_RING((pScrn->virtualX - 1) | (pScrn->virtualY - 1) << 16); - OUT_RING(0x00000000); - OUT_RING(0x00000000); - /* scissor */ - OUT_RING(0x7c800002); - OUT_RING(0x7d810001); - OUT_RING(0x00000000); - OUT_RING(0x00000000); - OUT_RING(0x7c000003); + OUT_RING(_3DSTATE_DRAW_RECT_CMD); + OUT_RING(DRAW_DITHER_OFS_X(0) | DRAW_DITHER_OFS_Y(0)); + OUT_RING(DRAW_XMIN(0) | DRAW_YMIN(0)); + OUT_RING(DRAW_XMAX(pScrn->virtualX - 1) | + DRAW_YMAX(pScrn->virtualY - 1)); + OUT_RING(DRAW_XORG(0) | DRAW_YORG(0)); + + OUT_RING(MI_NOOP); + + OUT_RING(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); + OUT_RING(_3DSTATE_SCISSOR_RECT_0_CMD); + OUT_RING(0x00000000); /* ymin, xmin */ + OUT_RING(0x00000000); /* ymax, xmax */ + + OUT_RING(0x7c000003); /* XXX: magic numbers */ OUT_RING(0x7d070000); OUT_RING(0x00000000); OUT_RING(0x68000002); + /* context setup */ - OUT_RING(0x6db3ffff); - OUT_RING(0x7d040744); - OUT_RING(0xfffffff0); - OUT_RING(0x00902c80); - OUT_RING(0x00000000); - OUT_RING(0x00020216); - OUT_RING(0x6ba008a1); - OUT_RING(0x7d880000); + OUT_RING(_3DSTATE_MODES_4_CMD | + ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) | + MODE4_ENABLE_STENCIL_WRITE_MASK | + MODE4_ENABLE_STENCIL_TEST_MASK); + + OUT_RING(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | + I1_LOAD_S(2) | I1_LOAD_S(4) | I1_LOAD_S(5) | I1_LOAD_S(6) | 4); + + OUT_RING(S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) | + S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) | + S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT)); + OUT_RING((1 << S4_POINT_WIDTH_SHIFT) | S4_LINE_WIDTH_ONE | + S4_CULLMODE_NONE | S4_VFMT_SPEC_FOG | S4_VFMT_COLOR | + S4_VFMT_XYZW); + OUT_RING(0x00000000); /* S5 -- enable bits */ + OUT_RING((2 << S6_DEPTH_TEST_FUNC_SHIFT) | + (2 << S6_CBUF_SRC_BLEND_FACT_SHIFT) | + (1 << S6_CBUF_DST_BLEND_FACT_SHIFT) | S6_COLOR_WRITE_ENABLE | + (2 << S6_TRISTRIP_PV_SHIFT)); + + OUT_RING(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD | + IAB_MODIFY_ENABLE | + IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) | + IAB_MODIFY_SRC_FACTOR | + (BLENDFACT_ONE << IAB_SRC_FACTOR_SHIFT) | + IAB_MODIFY_DST_FACTOR | + (BLENDFACT_ZERO << IAB_DST_FACTOR_SHIFT)); + + OUT_RING(_3DSTATE_CONST_BLEND_COLOR_CMD); OUT_RING(0x00000000); - /* dv0 */ - OUT_RING(0x7d850000); - /* dv1 */ - if (pI830->cpp == 1) - OUT_RING(0x10880000); - else if (pI830->cpp == 2) - OUT_RING(0x10880200); - else - OUT_RING(0x10880308); - /* stipple */ - OUT_RING(0x7d830000); + + OUT_RING(_3DSTATE_DST_BUF_VARS_CMD); + if (pI830->cpp == 1) { + OUT_RING(LOD_PRECLAMP_OGL | DSTORG_HORT_BIAS(0x8) | + DSTORG_VERT_BIAS(0x8) | COLR_BUF_8BIT); + } else if (pI830->cpp == 2) { + OUT_RING(LOD_PRECLAMP_OGL | DSTORG_HORT_BIAS(0x8) | + DSTORG_VERT_BIAS(0x8) | COLR_BUF_RGB565); + } else { + OUT_RING(LOD_PRECLAMP_OGL | DSTORG_HORT_BIAS(0x8) | + DSTORG_VERT_BIAS(0x8) | COLR_BUF_ARGB8888 | + DEPTH_FRMT_24_FIXED_8_OTHER); + } + + OUT_RING(_3DSTATE_STIPPLE); OUT_RING(0x00000000); + /* fragment program - texture blend replace*/ OUT_RING(0x7d050008); OUT_RING(0x19180000); @@ -330,22 +384,25 @@ I915UpdateRotate (ScreenPtr pScreen, OUT_RING(0x15200000); OUT_RING(0x01000000); OUT_RING(0x00000000); + /* texture sampler state */ - OUT_RING(0x7d010003); + OUT_RING(_3DSTATE_SAMPLER_STATE | 3); OUT_RING(0x00000001); OUT_RING(0x00000000); OUT_RING(0x00000000); OUT_RING(0x00000000); + /* front buffer, pitch, offset */ - OUT_RING(0x7d8e0001); - OUT_RING(0x03800000 | (((pI830->displayWidth * pI830->cpp) / 4) << 2)); + OUT_RING(_3DSTATE_BUF_INFO_CMD); + OUT_RING(BUF_3D_ID_COLOR_BACK | BUF_3D_USE_FENCE | + BUF_3D_PITCH(pI830->displayWidth * pI830->cpp)); if (I830IsPrimary(pScrn)) OUT_RING(pI830->FrontBuffer.Start); else OUT_RING(pI8301->FrontBuffer2.Start); /* Set the entire frontbuffer up as a texture */ - OUT_RING(0x7d000003); + OUT_RING(_3DSTATE_MAP_STATE | 3); OUT_RING(0x00000001); if (I830IsPrimary(pScrn)) @@ -359,12 +416,12 @@ I915UpdateRotate (ScreenPtr pScreen, use_fence = 4; if (pI830->cpp == 1) - use_fence |= 0x80; /* MAPSURF_8BIT */ + use_fence |= MAPSURF_8BIT; else if (pI830->cpp == 2) - use_fence |= 0x100; /* MAPSURF_16BIT */ + use_fence |= MAPSURF_16BIT; else - use_fence |= 0x180; /* MAPSURF_32BIT */ + use_fence |= MAPSURF_32BIT; OUT_RING(use_fence | (pScreen->height - 1) << 21 | (pScreen->width - 1) << 10); OUT_RING(((((pScrn->displayWidth * pI830->cpp) / 4) - 1) << 21)); ADVANCE_LP_RING(); @@ -395,7 +452,7 @@ I915UpdateRotate (ScreenPtr pScreen, OUT_RING(MI_NOOP); /* vertex data */ - OUT_RING(0x7f0c001f); + OUT_RING(PRIM3D_INLINE | PRIM3D_TRIFAN | (32 - 1)); verts[0][0] = box_x1; verts[0][1] = box_y1; verts[1][0] = box_x2; verts[1][1] = box_y1; verts[2][0] = box_x2; verts[2][1] = box_y2; diff --git a/src/i915_reg.h b/src/i915_reg.h index 886ae815..6d4f8fc0 100644 --- a/src/i915_reg.h +++ b/src/i915_reg.h @@ -233,6 +233,22 @@ #define IAB_DST_FACTOR_SHIFT 0 #define IAB_DST_FACTOR_MASK (BLENDFACT_MASK<<0) +#define BLENDFACT_ZERO 0x01 +#define BLENDFACT_ONE 0x02 +#define BLENDFACT_SRC_COLR 0x03 +#define BLENDFACT_INV_SRC_COLR 0x04 +#define BLENDFACT_SRC_ALPHA 0x05 +#define BLENDFACT_INV_SRC_ALPHA 0x06 +#define BLENDFACT_DST_ALPHA 0x07 +#define BLENDFACT_INV_DST_ALPHA 0x08 +#define BLENDFACT_DST_COLR 0x09 +#define BLENDFACT_INV_DST_COLR 0x0a +#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b +#define BLENDFACT_CONST_COLOR 0x0c +#define BLENDFACT_INV_CONST_COLOR 0x0d +#define BLENDFACT_CONST_ALPHA 0x0e +#define BLENDFACT_INV_CONST_ALPHA 0x0f +#define BLENDFACT_MASK 0x0f #define BLENDFUNC_ADD 0x0 #define BLENDFUNC_SUBTRACT 0x1 @@ -430,6 +446,7 @@ #define ENABLE_LOGIC_OP_FUNC (1<<23) #define LOGIC_OP_FUNC(x) ((x)<<18) #define LOGICOP_MASK (0xf<<18) +#define LOGICOP_COPY 0xc #define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00)) #define ENABLE_STENCIL_TEST_MASK (1<<17) #define STENCIL_TEST_MASK(x) ((x)<<8) |