From patchwork Sun Sep 20 00:30:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 48884 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8K0VI5p010152 for ; Sun, 20 Sep 2009 00:31:18 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C40F9EF74; Sat, 19 Sep 2009 17:31:18 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id 13FB59EF6D for ; Sat, 19 Sep 2009 17:31:15 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 7FC22760238; Sat, 19 Sep 2009 17:31:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from keithp.com ([127.0.0.1]) by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qXFOdnkJS7fs; Sat, 19 Sep 2009 17:31:12 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1033) id 138AC760239; Sat, 19 Sep 2009 17:31:12 -0700 (PDT) Received: from koto.keithp.com (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 11517760238; Sat, 19 Sep 2009 17:31:12 -0700 (PDT) Received: by koto.keithp.com (Postfix, from userid 1488) id B261A40C411; Sat, 19 Sep 2009 17:31:11 -0700 (PDT) From: Keith Packard To: intel-gfx@lists.freedesktop.org Date: Sat, 19 Sep 2009 17:30:57 -0700 Message-Id: <1253406657-22770-2-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1253406657-22770-1-git-send-email-keithp@keithp.com> References: <1253406657-22770-1-git-send-email-keithp@keithp.com> Cc: dri-devel@lists.sourceforge.net Subject: [Intel-gfx] [PATCH] i8xx: Format projective texture coordinates correctly. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org 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]); } }