summaryrefslogtreecommitdiff
path: root/driver/xf86-video-intel/src/i915_render.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2009-06-25 20:16:45 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2009-06-25 20:16:45 +0000
commit1968cea3515172a985c8cad914ead74b3621d8ff (patch)
tree14f241250ecdc59597ec213a3b8f898fd5794bb8 /driver/xf86-video-intel/src/i915_render.c
parentf3606649643e49df0add499c50a7d11e99f0d4f5 (diff)
update to xf86-video-intel 2.7.1. Tested by many.
Diffstat (limited to 'driver/xf86-video-intel/src/i915_render.c')
-rw-r--r--driver/xf86-video-intel/src/i915_render.c146
1 files changed, 103 insertions, 43 deletions
diff --git a/driver/xf86-video-intel/src/i915_render.c b/driver/xf86-video-intel/src/i915_render.c
index 4a02cf545..268dd8a1d 100644
--- a/driver/xf86-video-intel/src/i915_render.c
+++ b/driver/xf86-video-intel/src/i915_render.c
@@ -35,23 +35,6 @@
#include "i915_reg.h"
#include "i915_3d.h"
-#ifdef I830DEBUG
-#define DEBUG_I830FALLBACK 1
-#endif
-
-#ifdef DEBUG_I830FALLBACK
-#define I830FALLBACK(s, arg...) \
-do { \
- DPRINTF(PFX, "EXA fallback: " s "\n", ##arg); \
- return FALSE; \
-} while(0)
-#else
-#define I830FALLBACK(s, arg...) \
-do { \
- return FALSE; \
-} while(0)
-#endif
-
struct formatinfo {
int fmt;
uint32_t card_fmt;
@@ -155,6 +138,8 @@ static uint32_t i915_get_blend_cntl(int op, PicturePtr pMask,
static Bool i915_get_dest_format(PicturePtr pDstPicture, uint32_t *dst_format)
{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
+
switch (pDstPicture->format) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
@@ -184,6 +169,7 @@ static Bool i915_get_dest_format(PicturePtr pDstPicture, uint32_t *dst_format)
static Bool i915_check_composite_texture(PicturePtr pPict, int unit)
{
+ ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum];
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int i;
@@ -201,9 +187,8 @@ static Bool i915_check_composite_texture(PicturePtr pPict, int unit)
I830FALLBACK("Unsupported picture format 0x%x\n",
(int)pPict->format);
- if (pPict->repeat && pPict->repeatType != RepeatNormal)
- I830FALLBACK("extended repeat (%d) not supported\n",
- pPict->repeatType);
+ if (pPict->repeatType > RepeatReflect)
+ I830FALLBACK("Unsupported picture repeat %d\n", pPict->repeatType);
if (pPict->filter != PictFilterNearest &&
pPict->filter != PictFilterBilinear)
@@ -216,6 +201,7 @@ Bool
i915_check_composite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
+ ScrnInfoPtr pScrn = xf86Screens[pDstPicture->pDrawable->pScreen->myNum];
uint32_t tmp1;
/* Check for unsupported compositing operations. */
@@ -250,11 +236,10 @@ i915_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit)
{
ScrnInfoPtr pScrn = xf86Screens[pPict->pDrawable->pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
- uint32_t format, offset, pitch, filter;
+ uint32_t format, pitch, filter;
int w, h, i;
- uint32_t wrap_mode = TEXCOORDMODE_CLAMP_BORDER;
+ uint32_t wrap_mode;
- offset = intel_get_pixmap_offset(pPix);
pitch = intel_get_pixmap_pitch(pPix);
w = pPict->pDrawable->width;
h = pPict->pDrawable->height;
@@ -271,8 +256,22 @@ i915_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit)
I830FALLBACK("unknown texture format\n");
format = i915_tex_formats[i].card_fmt;
- if (pPict->repeat)
+ switch (pPict->repeatType) {
+ case RepeatNone:
+ wrap_mode = TEXCOORDMODE_CLAMP_BORDER;
+ break;
+ case RepeatNormal:
wrap_mode = TEXCOORDMODE_WRAP;
+ break;
+ case RepeatPad:
+ wrap_mode = TEXCOORDMODE_CLAMP_EDGE;
+ break;
+ case RepeatReflect:
+ wrap_mode = TEXCOORDMODE_MIRROR;
+ break;
+ default:
+ FatalError("Unkown repeat type %d\n", pPict->repeatType);
+ }
switch (pPict->filter) {
case PictFilterNearest:
@@ -288,7 +287,7 @@ i915_texture_setup(PicturePtr pPict, PixmapPtr pPix, int unit)
I830FALLBACK("Bad filter 0x%x\n", pPict->filter);
}
- pI830->mapstate[unit * 3 + 0] = offset;
+ pI830->mapstate[unit * 3 + 0] = 0; /* offset filled in at emit time */
pI830->mapstate[unit * 3 + 1] = format |
MS3_USE_FENCE_REGS |
((pPix->drawable.height - 1) << MS3_HEIGHT_SHIFT) |
@@ -316,40 +315,78 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
{
ScrnInfoPtr pScrn = xf86Screens[pSrcPicture->pDrawable->pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
- uint32_t dst_format, dst_offset, dst_pitch;
- uint32_t blendctl;
- int out_reg = FS_OC;
- FS_LOCALS(20);
- Bool is_affine_src, is_affine_mask;
- Bool is_nearest = FALSE;
+ drm_intel_bo *bo_table[] = {
+ NULL, /* batch_bo */
+ i830_get_pixmap_bo(pSrc),
+ pMask ? i830_get_pixmap_bo(pMask) : NULL,
+ i830_get_pixmap_bo(pDst),
+ };
i830_exa_check_pitch_3d(pSrc);
if (pMask)
i830_exa_check_pitch_3d(pMask);
i830_exa_check_pitch_3d(pDst);
- IntelEmitInvarientState(pScrn);
- *pI830->last_3d = LAST_3D_RENDER;
+ if (!i915_get_dest_format(pDstPicture,
+ &pI830->i915_render_state.dst_format))
+ return FALSE;
- if (!i915_get_dest_format(pDstPicture, &dst_format))
+ if (!i830_get_aperture_space(pScrn, bo_table, ARRAY_SIZE(bo_table)))
return FALSE;
- dst_offset = intel_get_pixmap_offset(pDst);
- dst_pitch = intel_get_pixmap_pitch(pDst);
+ pI830->i915_render_state.is_nearest = FALSE;
if (!i915_texture_setup(pSrcPicture, pSrc, 0))
I830FALLBACK("fail to setup src texture\n");
if (pSrcPicture->filter == PictFilterNearest)
- is_nearest = TRUE;
+ pI830->i915_render_state.is_nearest = TRUE;
if (pMask != NULL) {
if (!i915_texture_setup(pMaskPicture, pMask, 1))
I830FALLBACK("fail to setup mask texture\n");
if (pMaskPicture->filter == PictFilterNearest)
- is_nearest = TRUE;
+ pI830->i915_render_state.is_nearest = TRUE;
} else {
pI830->transform[1] = NULL;
pI830->scale_units[1][0] = -1;
pI830->scale_units[1][1] = -1;
}
+
+ pI830->i915_render_state.op = op;
+ pI830->i915_render_state.pSrcPicture = pSrcPicture;
+ pI830->i915_render_state.pMaskPicture = pMaskPicture;
+ pI830->i915_render_state.pDstPicture = pDstPicture;
+ pI830->i915_render_state.pSrc = pSrc;
+ pI830->i915_render_state.pMask = pMask;
+ pI830->i915_render_state.pDst = pDst;
+ pI830->i915_render_state.needs_emit = TRUE;
+
+ return TRUE;
+}
+
+static void
+i915_emit_composite_setup(ScrnInfoPtr pScrn)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ int op = pI830->i915_render_state.op;
+ PicturePtr pSrcPicture = pI830->i915_render_state.pSrcPicture;
+ PicturePtr pMaskPicture = pI830->i915_render_state.pMaskPicture;
+ PicturePtr pDstPicture = pI830->i915_render_state.pDstPicture;
+ PixmapPtr pSrc = pI830->i915_render_state.pSrc;
+ PixmapPtr pMask = pI830->i915_render_state.pMask;
+ PixmapPtr pDst = pI830->i915_render_state.pDst;
+ uint32_t dst_format = pI830->i915_render_state.dst_format, dst_pitch;
+ uint32_t blendctl;
+ int out_reg = FS_OC;
+ FS_LOCALS(20);
+ Bool is_affine_src, is_affine_mask;
+ Bool is_nearest = pI830->i915_render_state.is_nearest;
+
+ pI830->i915_render_state.needs_emit = FALSE;
+
+ IntelEmitInvarientState(pScrn);
+ pI830->last_3d = LAST_3D_RENDER;
+
+ dst_pitch = intel_get_pixmap_pitch(pDst);
+
is_affine_src = i830_transform_is_affine (pI830->transform[0]);
is_affine_mask = i830_transform_is_affine (pI830->transform[1]);
@@ -362,7 +399,7 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
BEGIN_BATCH(10);
OUT_BATCH(_3DSTATE_MAP_STATE | 3);
OUT_BATCH(0x00000001); /* map 0 */
- OUT_BATCH(pI830->mapstate[0]);
+ OUT_RELOC_PIXMAP(pSrc, I915_GEM_DOMAIN_SAMPLER, 0, 0);
OUT_BATCH(pI830->mapstate[1]);
OUT_BATCH(pI830->mapstate[2]);
@@ -376,10 +413,10 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
BEGIN_BATCH(16);
OUT_BATCH(_3DSTATE_MAP_STATE | 6);
OUT_BATCH(0x00000003); /* map 0,1 */
- OUT_BATCH(pI830->mapstate[0]);
+ OUT_RELOC_PIXMAP(pSrc, I915_GEM_DOMAIN_SAMPLER, 0, 0);
OUT_BATCH(pI830->mapstate[1]);
OUT_BATCH(pI830->mapstate[2]);
- OUT_BATCH(pI830->mapstate[3]);
+ OUT_RELOC_PIXMAP(pMask, I915_GEM_DOMAIN_SAMPLER, 0, 0);
OUT_BATCH(pI830->mapstate[4]);
OUT_BATCH(pI830->mapstate[5]);
@@ -400,7 +437,7 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
OUT_BATCH(BUF_3D_ID_COLOR_BACK| BUF_3D_USE_FENCE|
BUF_3D_PITCH(dst_pitch));
- OUT_BATCH(BUF_3D_ADDR(dst_offset));
+ OUT_RELOC_PIXMAP(pDst, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
OUT_BATCH(dst_format);
@@ -505,6 +542,29 @@ i915_prepare_composite(int op, PicturePtr pSrcPicture,
i915_fs_mov(FS_OC, i915_fs_operand(out_reg, W, W, W, W));
FS_END();
+}
- return TRUE;
+void
+i915_composite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
+ int dstX, int dstY, int w, int h)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ intel_batch_start_atomic(pScrn, 150);
+
+ if (pI830->i915_render_state.needs_emit)
+ i915_emit_composite_setup(pScrn);
+
+ i830_composite(pDst, srcX, srcY, maskX, maskY, dstX, dstY, w, h);
+
+ intel_batch_end_atomic(pScrn);
+}
+
+void
+i915_batch_flush_notify(ScrnInfoPtr pScrn)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ pI830->i915_render_state.needs_emit = TRUE;
}