From 9cda76bbe99661d19ca75412dbee17a2dd4eeb64 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 19 Sep 2009 17:25:34 -0700 Subject: [PATCH] i8xx: Format projective texture coordinates correctly. Projective texture coordinates must be delivered as TEXCOORDFMT_3D using TEXCOORDTYPE_HOMOGENOUS. This meant selecting the correct type in i830_texture_setup, the correct format in i830_emit_composite_state and sending only 3 coordinates in i830_emit_composite_primitive. Signed-off-by: Keith Packard --- src/i830_reg.h | 2 +- src/i830_render.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/i830_reg.h b/src/i830_reg.h index 7a8df9f..a8b82a6 100644 --- a/src/i830_reg.h +++ b/src/i830_reg.h @@ -523,7 +523,7 @@ #define VFT0_XYZW_MASK (7<<1) /* _3DSTATE_VERTEX_FORMAT_2, p206 */ -#define _3DSTATE_VFT1_CMD (CMD_3D|(0x0a<<24)) +#define _3DSTATE_VERTEX_FORMAT_2_CMD (CMD_3D|(0x0a<<24)) #define VFT1_TEX7_FMT(x) ((x)<<14) #define VFT1_TEX6_FMT(x) ((x)<<12) #define VFT1_TEX5_FMT(x) ((x)<<10) diff --git a/src/i830_render.c b/src/i830_render.c index b9bbbdb..960d42e 100644 --- a/src/i830_render.c +++ b/src/i830_render.c @@ -276,12 +276,18 @@ i830_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit) I830Ptr pI830 = I830PTR(pScrn); uint32_t format, pitch, filter; uint32_t wrap_mode; - + Bool is_affine = i830_transform_is_affine(pI830->transform[unit]); + uint32_t texcoordtype; pitch = intel_get_pixmap_pitch(pPix); pI830->scale_units[unit][0] = pPix->drawable.width; pI830->scale_units[unit][1] = pPix->drawable.height; pI830->transform[unit] = pPict->transform; + if (is_affine) + texcoordtype = TEXCOORDTYPE_CARTESIAN; + else + texcoordtype = TEXCOORDTYPE_HOMOGENEOUS; + format = i8xx_get_card_format(pPict); switch (pPict->repeatType) { @@ -334,7 +340,7 @@ i830_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit) OUT_BATCH(0); /* default color */ OUT_BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(unit) | ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL | - TEXCOORDTYPE_CARTESIAN | ENABLE_ADDR_V_CNTL | + texcoordtype | ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(wrap_mode) | ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(wrap_mode)); /* map texel stream */ @@ -526,13 +532,14 @@ i830_emit_composite_state(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); uint32_t vf2; + uint32_t texcoordfmt = 0; pI830->needs_render_state_emit = FALSE; IntelEmitInvarientState(pScrn); pI830->last_3d = LAST_3D_RENDER; - BEGIN_BATCH(22); + BEGIN_BATCH(21); OUT_BATCH(_3DSTATE_BUF_INFO_CMD); OUT_BATCH(BUF_3D_ID_COLOR_BACK| BUF_3D_USE_FENCE | @@ -559,19 +566,17 @@ i830_emit_composite_state(ScrnInfoPtr pScrn) vf2 = 2 << 12; /* 2 texture coord sets */ else vf2 = 1 << 12; - OUT_BATCH(vf2); /* TEXCOORDFMT_2D */ + OUT_BATCH(vf2); /* number of coordinate sets */ OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY); OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD | pI830->s8_blendctl | S8_ENABLE_COLOR_BUFFER_WRITE); OUT_BATCH(_3DSTATE_INDPT_ALPHA_BLEND_CMD | DISABLE_INDPT_ALPHA_BLEND); - OUT_BATCH(0); OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 | LOAD_TEXTURE_BLEND_STAGE(0)|1); OUT_BATCH(pI830->cblend); OUT_BATCH(pI830->ablend); - OUT_BATCH(0); OUT_BATCH(_3DSTATE_ENABLES_1_CMD | DISABLE_LOGIC_OP | DISABLE_STENCIL_TEST | DISABLE_DEPTH_BIAS | @@ -582,6 +587,19 @@ i830_emit_composite_state(ScrnInfoPtr pScrn) DISABLE_STENCIL_WRITE | ENABLE_TEX_CACHE | DISABLE_DITHER | ENABLE_COLOR_WRITE | DISABLE_DEPTH_WRITE); + + if (i830_transform_is_affine(pI830->transform[0])) + texcoordfmt |= (TEXCOORDFMT_2D << 0); + else + texcoordfmt |= (TEXCOORDFMT_3D << 0); + if (pI830->render_mask) { + if (i830_transform_is_affine(pI830->transform[1])) + texcoordfmt |= (TEXCOORDFMT_2D << 2); + else + texcoordfmt |= (TEXCOORDFMT_3D << 2); + } + OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD | texcoordfmt); + ADVANCE_BATCH(); i830_texture_setup(pI830->render_src_picture, pI830->render_src, 0); @@ -654,7 +672,7 @@ i830_emit_composite_primitive(PixmapPtr pDst, &src_w[2])) return; - per_vertex += 4; /* src x/y/z/w */ + per_vertex += 3; /* src x/y/w */ } } @@ -702,7 +720,7 @@ i830_emit_composite_primitive(PixmapPtr pDst, &mask_w[2])) return; - per_vertex += 4; /* mask x/y/z/w */ + per_vertex += 3; /* mask x/y/w */ } } @@ -716,14 +734,12 @@ i830_emit_composite_primitive(PixmapPtr pDst, OUT_BATCH_F(src_x[2] / pI830->scale_units[0][0]); OUT_BATCH_F(src_y[2] / pI830->scale_units[0][1]); if (!is_affine_src) { - OUT_BATCH_F(0.0); OUT_BATCH_F(src_w[2]); } if (pI830->render_mask) { OUT_BATCH_F(mask_x[2] / pI830->scale_units[1][0]); OUT_BATCH_F(mask_y[2] / pI830->scale_units[1][1]); if (!is_affine_mask) { - OUT_BATCH_F(0.0); OUT_BATCH_F(mask_w[2]); } } @@ -733,14 +749,12 @@ i830_emit_composite_primitive(PixmapPtr pDst, OUT_BATCH_F(src_x[1] / pI830->scale_units[0][0]); OUT_BATCH_F(src_y[1] / pI830->scale_units[0][1]); if (!is_affine_src) { - OUT_BATCH_F(0.0); OUT_BATCH_F(src_w[1]); } if (pI830->render_mask) { OUT_BATCH_F(mask_x[1] / pI830->scale_units[1][0]); OUT_BATCH_F(mask_y[1] / pI830->scale_units[1][1]); if (!is_affine_mask) { - OUT_BATCH_F(0.0); OUT_BATCH_F(mask_w[1]); } } @@ -750,14 +764,12 @@ i830_emit_composite_primitive(PixmapPtr pDst, OUT_BATCH_F(src_x[0] / pI830->scale_units[0][0]); OUT_BATCH_F(src_y[0] / pI830->scale_units[0][1]); if (!is_affine_src) { - OUT_BATCH_F(0.0); OUT_BATCH_F(src_w[0]); } if (pI830->render_mask) { OUT_BATCH_F(mask_x[0] / pI830->scale_units[1][0]); OUT_BATCH_F(mask_y[0] / pI830->scale_units[1][1]); if (!is_affine_mask) { - OUT_BATCH_F(0.0); OUT_BATCH_F(mask_w[0]); } } -- 1.6.3.3