Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: skeggsb/xf86-video-nouveau
base: 6acbb9046c
...
head fork: skeggsb/xf86-video-nouveau
compare: fb3a36b1e5
  • 8 commits
  • 35 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 13, 2012
Ben Skeggs WIP: port to new libdrm
calim: nv50,nvc0/xv: fix src_w/h width/height confusion
e70d801
Ben Skeggs nvc0: replace direct inline m2mf with inline helper to do the same
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
180d877
Ben Skeggs nvc0: do tic/tsc binding only once, at startup
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
1c76515
Ben Skeggs nvc0: punt shaders out to a header file
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
007dd62
Ben Skeggs nvc0: tidy and cull a heap of fermi init (stuff in default grctx)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4225b48
Ben Skeggs nvc0: switch to kepler's subchannel assignments (see note)
This will bust for kernels with nouveau ABI version < 1.0.0... It should
be possible to add compat for 0.0.16 however...

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
4896c87
Ben Skeggs nvc0: create scratch buffer before initialising m2mf
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
95be16d
Ben Skeggs nve0: initial exa/xv acceleration for kepler chipsets
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
fb3a36b
Showing with 4,345 additions and 4,255 deletions.
  1. +1 −1  configure.ac
  2. +1 −1  src/Makefile.am
  3. +11 −19 src/drmmode_display.c
  4. +15 −15 src/nouveau_dri2.c
  5. +13 −16 src/nouveau_exa.c
  6. +131 −55 src/nouveau_local.h
  7. +2 −2 src/nouveau_wfb.c
  8. +8 −18 src/nouveau_xv.c
  9. +34 −0 src/nv04_accel.h
  10. +244 −280 src/nv04_exa.c
  11. +124 −138 src/nv04_xv_blit.c
  12. +293 −320 src/nv10_exa.c
  13. +263 −300 src/nv30_exa.c
  14. +40 −42 src/nv30_shaders.c
  15. +105 −106 src/nv30_xv_tex.c
  16. +184 −207 src/nv40_exa.c
  17. +92 −86 src/nv40_xv_tex.c
  18. +352 −314 src/nv50_accel.c
  19. +26 −15 src/nv50_accel.h
  20. +326 −402 src/nv50_exa.c
  21. +151 −216 src/nv50_xv.c
  22. +272 −294 src/nv_accel_common.c
  23. +45 −32 src/nv_dma.c
  24. +2 −2 src/nv_dma.h
  25. +21 −22 src/nv_driver.c
  26. +2 −9 src/nv_include.h
  27. +6 −0 src/nv_proto.h
  28. +1 −2  src/nv_shadow.c
  29. +22 −24 src/nv_type.h
  30. +193 −650 src/nvc0_accel.c
  31. +78 −39 src/nvc0_accel.h
  32. +361 −412 src/nvc0_exa.c
  33. +388 −0 src/nvc0_shader.h
  34. +134 −216 src/nvc0_xv.c
  35. +404 −0 src/nve0_shader.h
View
2  configure.ac
@@ -67,7 +67,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto)
XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
# Checks for pkg-config packages
-PKG_CHECK_MODULES(LIBDRM_NOUVEAU, libdrm_nouveau)
+PKG_CHECK_MODULES(LIBDRM_NOUVEAU, [libdrm_nouveau >= 2.4.25])
AC_SUBST(LIBDRM_NOUVEAU_CFLAGS)
AC_SUBST(LIBDRM_NOUVEAU_LIBS)
View
2  src/Makefile.am
@@ -33,7 +33,7 @@ nouveau_drv_la_SOURCES = \
nouveau_class.h nouveau_local.h \
nouveau_exa.c nouveau_xv.c nouveau_dri2.c \
nouveau_wfb.c \
- nv_accel_common.c \
+ nv_accel_common.c nv04_accel.h \
nv_const.h \
nv_dma.c \
nv_dma.h \
View
30 src/drmmode_display.c
@@ -226,7 +226,7 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
if (!fbcon_id)
goto fallback;
- fb = drmModeGetFB(nouveau_device(pNv->dev)->fd, fbcon_id);
+ fb = drmModeGetFB(pNv->dev->fd, fbcon_id);
if (!fb) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Failed to retrieve fbcon fb: id %d\n", fbcon_id);
@@ -272,13 +272,12 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
exa->PrepareCopy(pspix, pdpix, 0, 0, GXcopy, ~0);
exa->Copy(pdpix, 0, 0, 0, 0, w, h);
exa->DoneCopy(pdpix);
- FIRE_RING (pNv->chan);
+ PUSH_KICK(pNv->pushbuf);
/* wait for completion before continuing, avoids seeing a momentary
* flash of "corruption" on occasion
*/
- nouveau_bo_map(pNv->scanout, NOUVEAU_BO_RDWR);
- nouveau_bo_unmap(pNv->scanout);
+ nouveau_bo_wait(pNv->scanout, NOUVEAU_BO_RDWR, pNv->client);
pScreen->DestroyPixmap(pdpix);
pScreen->DestroyPixmap(pspix);
@@ -287,10 +286,9 @@ drmmode_fbcon_copy(ScreenPtr pScreen)
fallback:
#endif
- if (nouveau_bo_map(pNv->scanout, NOUVEAU_BO_WR))
+ if (nouveau_bo_map(pNv->scanout, NOUVEAU_BO_WR, pNv->client))
return;
memset(pNv->scanout->map, 0x00, pNv->scanout->size);
- nouveau_bo_unmap(pNv->scanout);
}
static Bool
@@ -410,9 +408,8 @@ drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)
struct nouveau_bo *cursor = drmmode_crtc->cursor;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
- nouveau_bo_map(cursor, NOUVEAU_BO_WR);
+ nouveau_bo_map(cursor, NOUVEAU_BO_WR, pNv->client);
convert_cursor(cursor->map, image, 64, nv_cursor_width(pNv));
- nouveau_bo_unmap(cursor);
if (drmmode_crtc->cursor_visible) {
drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
@@ -462,7 +459,8 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
return NULL;
}
- ret = nouveau_bo_map(drmmode_crtc->rotate_bo, NOUVEAU_BO_RDWR);
+ ret = nouveau_bo_map(drmmode_crtc->rotate_bo, NOUVEAU_BO_RDWR,
+ NVPTR(scrn)->client);
if (ret) {
xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
"Couldn't get virtual address of shadow scanout\n");
@@ -470,7 +468,6 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
return NULL;
}
virtual = drmmode_crtc->rotate_bo->map;
- nouveau_bo_unmap(drmmode_crtc->rotate_bo);
ret = drmModeAddFB(drmmode->fd, width, height, crtc->scrn->depth,
crtc->scrn->bitsPerPixel, drmmode_crtc->rotate_pitch,
@@ -571,7 +568,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
drmmode_crtc->drmmode = drmmode;
ret = nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, 0,
- 64*64*4, &drmmode_crtc->cursor);
+ 64*64*4, NULL, &drmmode_crtc->cursor);
assert(ret == 0);
crtc->driver_private = drmmode_crtc;
@@ -1112,15 +1109,13 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
scrn->virtualY = height;
scrn->displayWidth = pitch / (scrn->bitsPerPixel >> 3);
- nouveau_bo_map(pNv->scanout, NOUVEAU_BO_RDWR);
+ nouveau_bo_map(pNv->scanout, NOUVEAU_BO_RDWR, pNv->client);
ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth,
scrn->bitsPerPixel, pitch, pNv->scanout->handle,
&drmmode->fb_id);
- if (ret) {
- nouveau_bo_unmap(pNv->scanout);
+ if (ret)
goto fail;
- }
if (pNv->ShadowPtr) {
free(pNv->ShadowPtr);
@@ -1139,17 +1134,14 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
#endif
if (!pNv->NoAccel) {
- nouveau_bo_unmap(pNv->scanout);
pNv->EXADriverPtr->PrepareSolid(ppix, GXcopy, ~0, 0);
pNv->EXADriverPtr->Solid(ppix, 0, 0, width, height);
pNv->EXADriverPtr->DoneSolid(ppix);
- nouveau_bo_map(pNv->scanout, NOUVEAU_BO_RDWR);
+ nouveau_bo_map(pNv->scanout, NOUVEAU_BO_RDWR, pNv->client);
} else {
memset(pNv->scanout->map, 0x00, pNv->scanout->size);
}
- nouveau_bo_unmap(pNv->scanout);
-
for (i = 0; i < xf86_config->num_crtc; i++) {
xf86CrtcPtr crtc = xf86_config->crtc[i];
View
30 src/nouveau_dri2.c
@@ -5,7 +5,6 @@
#include "xorg-server.h"
#include "nv_include.h"
-#include "nouveau_pushbuf.h"
#ifdef DRI2
#include "dri2.h"
#endif
@@ -82,7 +81,7 @@ nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
nvpix = nouveau_pixmap(ppix);
if (!nvpix || !nvpix->bo ||
- nouveau_bo_handle_get(nvpix->bo, &nvbuf->base.name)) {
+ nouveau_bo_name_get(nvpix->bo, &nvbuf->base.name)) {
pScreen->DestroyPixmap(nvbuf->ppix);
free(nvbuf);
return NULL;
@@ -164,7 +163,7 @@ update_front(DrawablePtr draw, DRI2BufferPtr front)
pixmap->refcnt++;
exaMoveInPixmap(pixmap);
- r = nouveau_bo_handle_get(nouveau_pixmap_bo(pixmap), &front->name);
+ r = nouveau_bo_name_get(nouveau_pixmap_bo(pixmap), &front->name);
if (r) {
(*draw->pScreen->DestroyPixmap)(pixmap);
return FALSE;
@@ -226,7 +225,7 @@ nouveau_wait_vblank(DrawablePtr draw, int type, CARD64 msc,
vbl.request.sequence = msc;
vbl.request.signal = (unsigned long)data;
- ret = drmWaitVBlank(nouveau_device(pNv->dev)->fd, &vbl);
+ ret = drmWaitVBlank(pNv->dev->fd, &vbl);
if (ret) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"Wait for VBlank failed: %s\n", strerror(errno));
@@ -278,7 +277,7 @@ nouveau_dri2_finish_swap(DrawablePtr draw, unsigned int frame,
PixmapPtr src_pix = nouveau_dri2_buffer(s->src)->ppix;
struct nouveau_bo *dst_bo;
struct nouveau_bo *src_bo = nouveau_pixmap_bo(src_pix);
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
RegionRec reg;
int type, ret;
Bool front_updated;
@@ -308,21 +307,21 @@ nouveau_dri2_finish_swap(DrawablePtr draw, unsigned int frame,
dst_bo = nouveau_pixmap_bo(dst_pix);
/* Throttle on the previous frame before swapping */
- nouveau_bo_map(dst_bo, NOUVEAU_BO_RD);
- nouveau_bo_unmap(dst_bo);
+ nouveau_bo_wait(dst_bo, NOUVEAU_BO_RD, push->client);
if (can_sync_to_vblank(draw)) {
/* Reference the back buffer to sync it to vblank */
- WAIT_RING(chan, 1);
- OUT_RELOC(chan, src_bo, 0,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_RD, 0, 0);
+ nouveau_pushbuf_refn(push, &(struct nouveau_pushbuf_refn) {
+ src_bo,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_RD
+ }, 1);
if (pNv->Architecture >= NV_ARCH_50)
NV50SyncToVBlank(dst_pix, REGION_EXTENTS(0, &reg));
else
NV11SyncToVBlank(dst_pix, REGION_EXTENTS(0, &reg));
- FIRE_RING(chan);
+ nouveau_pushbuf_kick(push, push->channel);
}
if (front_updated && can_exchange(draw, dst_pix, src_pix)) {
@@ -351,9 +350,10 @@ nouveau_dri2_finish_swap(DrawablePtr draw, unsigned int frame,
/* Reference the front buffer to let throttling work
* on occluded drawables. */
- WAIT_RING(chan, 1);
- OUT_RELOC(chan, dst_bo, 0,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_RD, 0, 0);
+ nouveau_pushbuf_refn(push, &(struct nouveau_pushbuf_refn) {
+ dst_bo,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_RD
+ }, 1);
REGION_TRANSLATE(0, &reg, -draw->x, -draw->y);
nouveau_dri2_copy_region(draw, &reg, s->dst, s->src);
@@ -678,7 +678,7 @@ nouveau_dri2_init(ScreenPtr pScreen)
dri2.numDrivers = 2;
dri2.driverName = dri2.driverNames[0];
- dri2.fd = nouveau_device(pNv->dev)->fd;
+ dri2.fd = pNv->dev->fd;
dri2.deviceName = pNv->drm_device_name;
dri2.version = DRI2INFOREC_VERSION;
View
29 src/nouveau_exa.c
@@ -47,6 +47,11 @@ NVAccelM2MF(NVPtr pNv, int w, int h, int cpp, uint32_t srcoff, uint32_t dstoff,
struct nouveau_bo *src, int sd, int sp, int sh, int sx, int sy,
struct nouveau_bo *dst, int dd, int dp, int dh, int dx, int dy)
{
+ if (pNv->Architecture >= NV_ARCH_E0)
+ return NVE0EXARectCopy(pNv, w, h, cpp,
+ src, srcoff, sd, sp, sh, sx, sy,
+ dst, dstoff, dd, dp, dh, dx, dy);
+ else
if (pNv->Architecture >= NV_ARCH_C0)
return NVC0EXARectM2MF(pNv, w, h, cpp,
src, srcoff, sd, sp, sh, sx, sy,
@@ -82,7 +87,7 @@ nouveau_exa_prepare_access(PixmapPtr ppix, int index)
if (nv50_style_tiled_pixmap(ppix) && !pNv->wfb_enabled)
return FALSE;
- if (nouveau_bo_map(bo, NOUVEAU_BO_RDWR))
+ if (nouveau_bo_map(bo, NOUVEAU_BO_RDWR, pNv->client))
return FALSE;
ppix->devPrivate.ptr = bo->map;
return TRUE;
@@ -91,9 +96,6 @@ nouveau_exa_prepare_access(PixmapPtr ppix, int index)
static void
nouveau_exa_finish_access(PixmapPtr ppix, int index)
{
- struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
-
- nouveau_bo_unmap(bo);
}
static Bool
@@ -114,8 +116,7 @@ nouveau_exa_create_pixmap(ScreenPtr pScreen, int width, int height, int depth,
if (!width || !height)
return calloc(1, sizeof(*nvpix));
- if (!pNv->exa_force_cp &&
- pNv->dev->vm_vram_size <= 32*1024*1024)
+ if (!pNv->exa_force_cp && pNv->dev->vram_size <= 32 * 1024 * 1024)
return NULL;
nvpix = calloc(1, sizeof(*nvpix));
@@ -151,8 +152,7 @@ nv50_style_tiled_pixmap(PixmapPtr ppix)
NVPtr pNv = NVPTR(pScrn);
return pNv->Architecture >= NV_ARCH_50 &&
- (nouveau_pixmap_bo(ppix)->tile_flags &
- NOUVEAU_BO_TILE_LAYOUT_MASK);
+ nouveau_pixmap_bo(ppix)->config.nv50.memtype;
}
static Bool
@@ -188,7 +188,7 @@ nouveau_exa_download_from_screen(PixmapPtr pspix, int x, int y, int w, int h,
lines, 0, 0))
goto memcpy;
- nouveau_bo_map(pNv->GART, NOUVEAU_BO_RD);
+ nouveau_bo_map(pNv->GART, NOUVEAU_BO_RD, pNv->client);
if (src_pitch == tmp_pitch) {
memcpy(dst, pNv->GART->map, dst_pitch * lines);
dst += dst_pitch * lines;
@@ -200,7 +200,6 @@ nouveau_exa_download_from_screen(PixmapPtr pspix, int x, int y, int w, int h,
dst += dst_pitch;
}
}
- nouveau_bo_unmap(pNv->GART);
/* next! */
h -= lines;
@@ -209,11 +208,10 @@ nouveau_exa_download_from_screen(PixmapPtr pspix, int x, int y, int w, int h,
memcpy:
bo = nouveau_pixmap_bo(pspix);
- if (nouveau_bo_map(bo, NOUVEAU_BO_RD))
+ if (nouveau_bo_map(bo, NOUVEAU_BO_RD, pNv->client))
return FALSE;
src = (char *)bo->map + offset;
ret = NVAccelMemcpyRect(dst, src, h, dst_pitch, src_pitch, w*cpp);
- nouveau_bo_unmap(bo);
return ret;
}
@@ -268,7 +266,7 @@ nouveau_exa_upload_to_screen(PixmapPtr pdpix, int x, int y, int w, int h,
if (lines > h)
lines = h;
- nouveau_bo_map(pNv->GART, NOUVEAU_BO_WR);
+ nouveau_bo_map(pNv->GART, NOUVEAU_BO_WR, pNv->client);
if (src_pitch == tmp_pitch) {
memcpy(pNv->GART->map, src, src_pitch * lines);
src += src_pitch * lines;
@@ -280,7 +278,6 @@ nouveau_exa_upload_to_screen(PixmapPtr pdpix, int x, int y, int w, int h,
dst += tmp_pitch;
}
}
- nouveau_bo_unmap(pNv->GART);
if (!NVAccelM2MF(pNv, w, lines, cpp, 0, 0, pNv->GART,
NOUVEAU_BO_GART, tmp_pitch, lines, 0, 0,
@@ -299,11 +296,10 @@ nouveau_exa_upload_to_screen(PixmapPtr pdpix, int x, int y, int w, int h,
/* fallback to memcpy-based transfer */
memcpy:
bo = nouveau_pixmap_bo(pdpix);
- if (nouveau_bo_map(bo, NOUVEAU_BO_WR))
+ if (nouveau_bo_map(bo, NOUVEAU_BO_WR, pNv->client))
return FALSE;
dst = (char *)bo->map + (y * dst_pitch) + (x * cpp);
ret = NVAccelMemcpyRect(dst, src, h, dst_pitch, src_pitch, w*cpp);
- nouveau_bo_unmap(bo);
return ret;
}
@@ -422,6 +418,7 @@ nouveau_exa_init(ScreenPtr pScreen)
exa->DoneComposite = NV50EXADoneComposite;
break;
case NV_ARCH_C0:
+ case NV_ARCH_E0:
exa->CheckComposite = NVC0EXACheckComposite;
exa->PrepareComposite = NVC0EXAPrepareComposite;
exa->Composite = NVC0EXAComposite;
View
186 src/nouveau_local.h
@@ -26,7 +26,7 @@
#include "compiler.h"
#include "xf86_OSproc.h"
-#include "nouveau_pushbuf.h"
+#include <nouveau.h>
/* Debug output */
#define NOUVEAU_MSG(fmt,args...) ErrorF(fmt, ##args)
@@ -45,6 +45,8 @@
#define NOUVEAU_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
+#define NV50_TILE_PITCH(m) (64 << ((m) & 0xf))
+#define NV50_TILE_HEIGHT(m) (4 << ((m) >> 4))
#define NVC0_TILE_PITCH(m) (64 << ((m) & 0xf))
#define NVC0_TILE_HEIGHT(m) (8 << ((m) >> 4))
@@ -93,84 +95,158 @@ static inline int round_up_pow2(int x)
(y) = __z; \
} while (0)
+static inline uint32_t
+PUSH_AVAIL(struct nouveau_pushbuf *push)
+{
+ return push->end - push->cur;
+}
+
+static inline Bool
+PUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size)
+{
+ if (PUSH_AVAIL(push) < size)
+ return nouveau_pushbuf_space(push, size, 0, 0) == 0;
+ return TRUE;
+}
+
+static inline void
+PUSH_DATA(struct nouveau_pushbuf *push, uint32_t data)
+{
+ *push->cur++ = data;
+}
+
static inline void
-BEGIN_NV04(struct nouveau_channel *chan, int subc, int mthd, int size)
+PUSH_DATAp(struct nouveau_pushbuf *push, const void *data, uint32_t size)
{
- WAIT_RING(chan, size + 1);
- OUT_RING (chan, 0x00000000 | (size << 18) | (subc << 13) | mthd);
+ memcpy(push->cur, data, size * 4);
+ push->cur += size;
}
static inline void
-BEGIN_NI04(struct nouveau_channel *chan, int subc, int mthd, int size)
+PUSH_RELOC(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t offset,
+ uint32_t flags, uint32_t vor, uint32_t tor)
{
- WAIT_RING(chan, size + 1);
- OUT_RING (chan, 0x40000000 | (size << 18) | (subc << 13) | mthd);
+ nouveau_pushbuf_reloc(push, bo, offset, flags, vor, tor);
}
static inline void
-BEGIN_NVC0(struct nouveau_channel *chan, int subc, int mthd, int size)
+PUSH_KICK(struct nouveau_pushbuf *push)
{
- WAIT_RING(chan, size + 1);
- OUT_RING (chan, 0x20000000 | (size << 16) | (subc << 13) | (mthd >> 2));
+ nouveau_pushbuf_kick(push, push->channel);
+}
+
+static inline struct nouveau_bufctx *
+BUFCTX(struct nouveau_pushbuf *push)
+{
+ return push->user_priv;
}
static inline void
-BEGIN_NIC0(struct nouveau_channel *chan, int subc, int mthd, int size)
+PUSH_RESET(struct nouveau_pushbuf *push)
{
- WAIT_RING(chan, size + 1);
- OUT_RING (chan, 0x60000000 | (size << 16) | (subc << 13) | (mthd >> 2));
+ nouveau_bufctx_reset(BUFCTX(push), 0);
}
static inline void
-BEGIN_IMC0(struct nouveau_channel *chan, int subc, int mthd, int data)
+PUSH_REFN(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t access)
{
- WAIT_RING(chan, 1);
- OUT_RING (chan, 0x80000000 | (data << 16) | (subc << 13) | (mthd >> 2));
+ nouveau_bufctx_refn(BUFCTX(push), 0, bo, access);
}
static inline void
-BEGIN_1IC0(struct nouveau_channel *chan, int subc, int mthd, int size)
+PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd,
+ struct nouveau_bo *bo, uint32_t offset, uint32_t access)
{
- WAIT_RING(chan, size + 1);
- OUT_RING (chan, 0xa0000000 | (size << 16) | (subc << 13) | (mthd >> 2));
+ nouveau_bufctx_mthd(BUFCTX(push), 0, (1 << 18) | (subc << 13) | mthd,
+ bo, offset, access | NOUVEAU_BO_LOW, 0, 0);
+ PUSH_DATA (push, bo->offset + offset);
}
-/* subchannel assignment */
-#define SUBC_M2MF(mthd) 0, (mthd) /* nv04: */
-#define NV03_M2MF(mthd) SUBC_M2MF(NV03_M2MF_##mthd)
-#define NV50_M2MF(mthd) SUBC_M2MF(NV50_M2MF_##mthd)
-#define NVC0_M2MF(mthd) SUBC_M2MF(NVC0_M2MF_##mthd)
-#define SUBC_NVSW(mthd) 1, (mthd)
-#define SUBC_SF2D(mthd) 2, (mthd) /* nv04:nv50 */
-#define SUBC_2D(mthd) 2, (mthd) /* nv50: */
-#define NV04_SF2D(mthd) SUBC_SF2D(NV04_SURFACE_2D_##mthd)
-#define NV10_SF2D(mthd) SUBC_SF2D(NV10_SURFACE_2D_##mthd)
-#define NV50_2D(mthd) SUBC_2D(NV50_2D_##mthd)
-#define NVC0_2D(mthd) SUBC_2D(NVC0_2D_##mthd)
-#define SUBC_RECT(mthd) 3, (mthd) /* nv04:nv50 */
-#define NV04_RECT(mthd) SUBC_RECT(NV04_GDI_##mthd)
-#define SUBC_BLIT(mthd) 4, (mthd) /* nv04:nv50 */
-#define NV01_BLIT(mthd) SUBC_BLIT(NV01_BLIT_##mthd)
-#define NV04_BLIT(mthd) SUBC_BLIT(NV04_BLIT_##mthd)
-#define NV15_BLIT(mthd) SUBC_BLIT(NV15_BLIT_##mthd)
-#define SUBC_IFC(mthd) 5, (mthd) /* nv04:nv50 */
-#define NV01_IFC(mthd) SUBC_IFC(NV01_IFC_##mthd)
-#define NV04_IFC(mthd) SUBC_IFC(NV04_IFC_##mthd)
-#define SUBC_MISC(mthd) 6, (mthd) /* nv04:nv50 */
-#define NV03_SIFM(mthd) SUBC_MISC(NV03_SIFM_##mthd)
-#define NV05_SIFM(mthd) SUBC_MISC(NV05_SIFM_##mthd)
-#define NV01_BETA(mthd) SUBC_MISC(NV01_BETA_##mthd)
-#define NV04_BETA4(mthd) SUBC_MISC(NV04_BETA4_##mthd)
-#define NV01_PATT(mthd) SUBC_MISC(NV01_PATTERN_##mthd)
-#define NV04_PATT(mthd) SUBC_MISC(NV04_PATTERN_##mthd)
-#define NV01_ROP(mthd) SUBC_MISC(NV01_ROP_##mthd)
-#define NV01_CLIP(mthd) SUBC_MISC(NV01_CLIP_##mthd)
-#define SUBC_3D(mthd) 7, (mthd) /* nv10: */
-#define NV10_3D(mthd) SUBC_3D(NV10_3D_##mthd)
-#define NV30_3D(mthd) SUBC_3D(NV30_3D_##mthd)
-#define NV40_3D(mthd) SUBC_3D(NV40_3D_##mthd)
-#define NV50_3D(mthd) SUBC_3D(NV50_3D_##mthd)
-#define NVC0_3D(mthd) SUBC_3D(NVC0_3D_##mthd)
+static inline void
+PUSH_MTHDo(struct nouveau_pushbuf *push, int subc, int mthd,
+ struct nouveau_bo *bo, uint32_t access, uint32_t vor, uint32_t tor)
+{
+ nouveau_bufctx_mthd(BUFCTX(push), 0, (1 << 18) | (subc << 13) | mthd,
+ bo, 0, access | NOUVEAU_BO_OR, vor, tor);
+ if (bo->flags & NOUVEAU_BO_VRAM)
+ PUSH_DATA (push, vor);
+ else
+ PUSH_DATA (push, tor);
+}
+
+static inline void
+PUSH_MTHDs(struct nouveau_pushbuf *push, int subc, int mthd,
+ struct nouveau_bo *bo, uint32_t data, uint32_t access,
+ uint32_t vor, uint32_t tor)
+{
+ nouveau_bufctx_mthd(BUFCTX(push), 0, (1 << 18) | (subc << 13) | mthd,
+ bo, data, access | NOUVEAU_BO_OR, vor, tor);
+ if (bo->flags & NOUVEAU_BO_VRAM)
+ PUSH_DATA (push, data | vor);
+ else
+ PUSH_DATA (push, data | tor);
+}
+
+static inline void
+PUSH_MTHD(struct nouveau_pushbuf *push, int subc, int mthd,
+ struct nouveau_bo *bo, uint32_t data, uint32_t access,
+ uint32_t vor, uint32_t tor)
+{
+ nouveau_bufctx_mthd(BUFCTX(push), 0, (1 << 18) | (subc << 13) | mthd,
+ bo, data, access | NOUVEAU_BO_OR, vor, tor);
+ if (access & NOUVEAU_BO_LOW)
+ data += bo->offset;
+ if (access & NOUVEAU_BO_OR) {
+ if (bo->flags & NOUVEAU_BO_VRAM)
+ data |= vor;
+ else
+ data |= tor;
+ }
+ PUSH_DATA (push, data);
+}
+
+static inline void
+PUSH_DATAf(struct nouveau_pushbuf *push, float v)
+{
+ union { float f; uint32_t i; } d = { .f = v };
+ PUSH_DATA (push, d.i);
+}
+
+static inline void
+BEGIN_NV04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
+{
+ PUSH_DATA (push, 0x00000000 | (size << 18) | (subc << 13) | mthd);
+}
+
+static inline void
+BEGIN_NI04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
+{
+ PUSH_DATA (push, 0x40000000 | (size << 18) | (subc << 13) | mthd);
+}
+
+static inline void
+BEGIN_NVC0(struct nouveau_pushbuf *push, int subc, int mthd, int size)
+{
+ PUSH_DATA (push, 0x20000000 | (size << 16) | (subc << 13) | (mthd / 4));
+}
+
+static inline void
+BEGIN_NIC0(struct nouveau_pushbuf *push, int subc, int mthd, int size)
+{
+ PUSH_DATA (push, 0x60000000 | (size << 16) | (subc << 13) | (mthd / 4));
+}
+
+static inline void
+BEGIN_IMC0(struct nouveau_pushbuf *push, int subc, int mthd, int data)
+{
+ PUSH_DATA (push, 0x80000000 | (data << 16) | (subc << 13) | (mthd / 4));
+}
+
+static inline void
+BEGIN_1IC0(struct nouveau_pushbuf *push, int subc, int mthd, int size)
+{
+ PUSH_DATA (push, 0xa0000000 | (size << 16) | (subc << 13) | (mthd / 4));
+}
#define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
#define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))
View
4 src/nouveau_wfb.c
@@ -178,9 +178,9 @@ nouveau_wfb_setup_wrap(ReadMemoryProcPtr *pRead, WriteMemoryProcPtr *pWrite,
/* 8192x8192x4 is 28 bits max, 64 - 28 == 36. */
wfb->multiply_factor = (((1ULL << 36) - 1) / wfb->pitch) + 1;
if (bo->device->chipset < 0xc0)
- wfb->tile_height = bo->tile_mode + 2;
+ wfb->tile_height = (bo->config.nv50.tile_mode >> 4) + 2;
else
- wfb->tile_height = (bo->tile_mode >> 4) + 3;
+ wfb->tile_height = (bo->config.nv50.tile_mode >> 4) + 3;
wfb->horiz_tiles = wfb->pitch / 64;
have_tiled = 1;
}
View
26 src/nouveau_xv.c
@@ -243,9 +243,8 @@ static int
nouveau_xv_bo_realloc(ScrnInfoPtr pScrn, unsigned flags, unsigned size,
struct nouveau_bo **pbo)
{
+ union nouveau_bo_config config = {};
NVPtr pNv = NVPTR(pScrn);
- uint32_t tile_flags;
- int ret;
if (*pbo) {
if ((*pbo)->size >= size)
@@ -253,21 +252,16 @@ nouveau_xv_bo_realloc(ScrnInfoPtr pScrn, unsigned flags, unsigned size,
nouveau_bo_ref(NULL, pbo);
}
- tile_flags = 0;
if (flags & NOUVEAU_BO_VRAM) {
if (pNv->Architecture == NV_ARCH_50)
- tile_flags = 0x7000;
+ config.nv50.memtype = 0x70;
else
- if (pNv->Architecture == NV_ARCH_C0)
- tile_flags = 0xfe00;
+ if (pNv->Architecture >= NV_ARCH_C0)
+ config.nvc0.memtype = 0xfe;
}
+ flags |= NOUVEAU_BO_MAP;
- ret = nouveau_bo_new_tile(pNv->dev, flags | NOUVEAU_BO_MAP, 0,
- size, 0, tile_flags, pbo);
- if (ret)
- return ret;
-
- return 0;
+ return nouveau_bo_new(pNv->dev, flags, 0, size, &config, pbo);
}
/**
@@ -1080,7 +1074,7 @@ NVPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x,
int i = 0;
/* Upload to GART */
- nouveau_bo_map(destination_buffer, NOUVEAU_BO_WR);
+ nouveau_bo_map(destination_buffer, NOUVEAU_BO_WR, pNv->client);
dst = destination_buffer->map;
if (action_flags & IS_YV12) {
@@ -1116,8 +1110,6 @@ NVPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x,
}
}
- nouveau_bo_unmap(destination_buffer);
-
if (uv_offset) {
NVAccelM2MF(pNv, line_len, nlines / 2, 1,
line_len * nlines, uv_offset,
@@ -1135,7 +1127,7 @@ NVPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x,
} else {
CPU_copy:
- nouveau_bo_map(pPriv->video_mem, NOUVEAU_BO_WR);
+ nouveau_bo_map(pPriv->video_mem, NOUVEAU_BO_WR, pNv->client);
map = pPriv->video_mem->map + offset;
if (action_flags & IS_YV12) {
@@ -1201,8 +1193,6 @@ NVPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, short drw_x,
buf += srcPitch - (npixels << 1);
}
}
-
- nouveau_bo_unmap(pPriv->video_mem);
}
if (skip)
View
34 src/nv04_accel.h
@@ -0,0 +1,34 @@
+#ifndef __NV04_ACCEL_H__
+#define __NV04_ACCEL_H__
+
+/* subchannel assignments */
+#define SUBC_M2MF(mthd) 0, (mthd)
+#define NV03_M2MF(mthd) SUBC_M2MF(NV03_M2MF_##mthd)
+#define SUBC_NVSW(mthd) 1, (mthd)
+#define SUBC_SF2D(mthd) 2, (mthd)
+#define NV04_SF2D(mthd) SUBC_SF2D(NV04_SURFACE_2D_##mthd)
+#define NV10_SF2D(mthd) SUBC_SF2D(NV10_SURFACE_2D_##mthd)
+#define SUBC_RECT(mthd) 3, (mthd)
+#define NV04_RECT(mthd) SUBC_RECT(NV04_GDI_##mthd)
+#define SUBC_BLIT(mthd) 4, (mthd)
+#define NV01_BLIT(mthd) SUBC_BLIT(NV01_BLIT_##mthd)
+#define NV04_BLIT(mthd) SUBC_BLIT(NV04_BLIT_##mthd)
+#define NV15_BLIT(mthd) SUBC_BLIT(NV15_BLIT_##mthd)
+#define SUBC_IFC(mthd) 5, (mthd)
+#define NV01_IFC(mthd) SUBC_IFC(NV01_IFC_##mthd)
+#define NV04_IFC(mthd) SUBC_IFC(NV04_IFC_##mthd)
+#define SUBC_MISC(mthd) 6, (mthd)
+#define NV03_SIFM(mthd) SUBC_MISC(NV03_SIFM_##mthd)
+#define NV05_SIFM(mthd) SUBC_MISC(NV05_SIFM_##mthd)
+#define NV01_BETA(mthd) SUBC_MISC(NV01_BETA_##mthd)
+#define NV04_BETA4(mthd) SUBC_MISC(NV04_BETA4_##mthd)
+#define NV01_PATT(mthd) SUBC_MISC(NV01_PATTERN_##mthd)
+#define NV04_PATT(mthd) SUBC_MISC(NV04_PATTERN_##mthd)
+#define NV01_ROP(mthd) SUBC_MISC(NV01_ROP_##mthd)
+#define NV01_CLIP(mthd) SUBC_MISC(NV01_CLIP_##mthd)
+#define SUBC_3D(mthd) 7, (mthd)
+#define NV10_3D(mthd) SUBC_3D(NV10_3D_##mthd)
+#define NV30_3D(mthd) SUBC_3D(NV30_3D_##mthd)
+#define NV40_3D(mthd) SUBC_3D(NV40_3D_##mthd)
+
+#endif
View
524 src/nv04_exa.c
@@ -23,229 +23,206 @@
#include "nv_include.h"
#include "nv_rop.h"
-
#include "hwdefs/nv_object.xml.h"
#include "hwdefs/nv_m2mf.xml.h"
#include "hwdefs/nv01_2d.xml.h"
+#include "nv04_accel.h"
static void
-NV04EXASetPattern(ScrnInfoPtr pScrn, CARD32 clr0, CARD32 clr1,
- CARD32 pat0, CARD32 pat1)
+NV04EXASetPattern(NVPtr pNv, CARD32 clr0, CARD32 clr1, CARD32 pat0, CARD32 pat1)
{
- NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
-
- BEGIN_NV04(chan, NV01_SUBC(MISC, OBJECT), 1);
- OUT_RING (chan, pNv->NvImagePattern->handle);
- BEGIN_NV04(chan, NV01_PATT(MONOCHROME_COLOR(0)), 4);
- OUT_RING (chan, clr0);
- OUT_RING (chan, clr1);
- OUT_RING (chan, pat0);
- OUT_RING (chan, pat1);
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+
+ BEGIN_NV04(push, NV01_SUBC(MISC, OBJECT), 1);
+ PUSH_DATA (push, pNv->NvImagePattern->handle);
+ BEGIN_NV04(push, NV01_PATT(MONOCHROME_COLOR(0)), 4);
+ PUSH_DATA (push, clr0);
+ PUSH_DATA (push, clr1);
+ PUSH_DATA (push, pat0);
+ PUSH_DATA (push, pat1);
}
-static void
-NV04EXASetROP(ScrnInfoPtr pScrn, CARD32 alu, CARD32 planemask)
+static Bool
+NV04EXASetROP(PixmapPtr ppix, int subc, int mthd, int alu, Pixel planemask)
{
+ ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
-
- if (planemask != ~0) {
- NV04EXASetPattern(pScrn, 0, planemask, ~0, ~0);
- if (pNv->currentRop != (alu + 32)) {
- BEGIN_NV04(chan, NV01_SUBC(MISC, OBJECT), 1);
- OUT_RING (chan, pNv->NvRop->handle);
- BEGIN_NV04(chan, NV01_ROP(ROP), 1);
- OUT_RING (chan, NVROP[alu].copy_planemask);
- pNv->currentRop = alu + 32;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+
+ planemask |= ~0 << ppix->drawable.bitsPerPixel;
+ if (planemask != ~0 || alu != GXcopy) {
+ if (ppix->drawable.bitsPerPixel == 32)
+ return FALSE;
+ if (planemask != ~0) {
+ NV04EXASetPattern(pNv, 0, planemask, ~0, ~0);
+ if (pNv->currentRop != (alu + 32)) {
+ BEGIN_NV04(push, NV01_SUBC(MISC, OBJECT), 1);
+ PUSH_DATA (push, pNv->NvRop->handle);
+ BEGIN_NV04(push, NV01_ROP(ROP), 1);
+ PUSH_DATA (push, NVROP[alu].copy_planemask);
+ pNv->currentRop = alu + 32;
+ }
+ } else
+ if (pNv->currentRop != alu) {
+ if(pNv->currentRop >= 16)
+ NV04EXASetPattern(pNv, ~0, ~0, ~0, ~0);
+ BEGIN_NV04(push, NV01_SUBC(MISC, OBJECT), 1);
+ PUSH_DATA (push, pNv->NvRop->handle);
+ BEGIN_NV04(push, NV01_ROP(ROP), 1);
+ PUSH_DATA (push, NVROP[alu].copy);
+ pNv->currentRop = alu;
}
- } else
- if (pNv->currentRop != alu) {
- if(pNv->currentRop >= 16)
- NV04EXASetPattern(pScrn, ~0, ~0, ~0, ~0);
- BEGIN_NV04(chan, NV01_SUBC(MISC, OBJECT), 1);
- OUT_RING (chan, pNv->NvRop->handle);
- BEGIN_NV04(chan, NV01_ROP(ROP), 1);
- OUT_RING (chan, NVROP[alu].copy);
- pNv->currentRop = alu;
- }
-}
-static void
-NV04EXAStateSolidResubmit(struct nouveau_channel *chan)
-{
- ScrnInfoPtr pScrn = chan->user_private;
- NVPtr pNv = NVPTR(pScrn);
+ BEGIN_NV04(push, subc, mthd, 1);
+ PUSH_DATA (push, 1); /* ROP_AND */
+ } else {
+ BEGIN_NV04(push, subc, mthd, 1);
+ PUSH_DATA (push, 3); /* SRCCOPY */
+ }
- NV04EXAPrepareSolid(pNv->pdpix, pNv->alu, pNv->planemask, pNv->fg_colour);
+ return TRUE;
}
Bool
-NV04EXAPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)
+NV04EXAPrepareSolid(PixmapPtr ppix, int alu, Pixel planemask, Pixel fg)
{
- ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86Screens[ppix->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
- struct nouveau_bo *bo = nouveau_pixmap_bo(pPixmap);
- unsigned int fmt, pitch, fmt2 = NV04_GDI_COLOR_FORMAT_A8R8G8B8;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+ struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
+ unsigned pitch = exaGetPixmapPitch(ppix);
+ unsigned surf_fmt, rect_fmt;
- if (MARK_RING(chan, 64, 2))
+ /* When SURFACE_FORMAT_A8R8G8B8 is used with GDI_RECTANGLE_TEXT, the
+ * alpha channel gets forced to 0xFF for some reason. We're using
+ * SURFACE_FORMAT_Y32 as a workaround
+ */
+ if (!NVAccelGetCtxSurf2DFormatFromPixmap(ppix, (int*)&surf_fmt))
return FALSE;
-
- planemask |= ~0 << pPixmap->drawable.bitsPerPixel;
- if (planemask != ~0 || alu != GXcopy) {
- if (pPixmap->drawable.bitsPerPixel == 32)
- return FALSE;
- BEGIN_NV04(chan, NV04_RECT(OPERATION), 1);
- OUT_RING (chan, 1); /* ROP_AND */
- NV04EXASetROP(pScrn, alu, planemask);
- } else {
- BEGIN_NV04(chan, NV04_RECT(OPERATION), 1);
- OUT_RING (chan, 3); /* SRCCOPY */
+ if (surf_fmt == NV04_SURFACE_2D_FORMAT_A8R8G8B8)
+ surf_fmt = NV04_SURFACE_2D_FORMAT_Y32;
+
+ rect_fmt = NV04_GDI_COLOR_FORMAT_A8R8G8B8;
+ if (ppix->drawable.bitsPerPixel == 16) {
+ if (ppix->drawable.depth == 16)
+ rect_fmt = NV04_GDI_COLOR_FORMAT_A16R5G6B5;
+ else
+ rect_fmt = NV04_GDI_COLOR_FORMAT_X16A1R5G5B5;
}
- if (!NVAccelGetCtxSurf2DFormatFromPixmap(pPixmap, (int*)&fmt))
+ if (!PUSH_SPACE(push, 64))
return FALSE;
- pitch = exaGetPixmapPitch(pPixmap);
+ PUSH_RESET(push);
- if (pPixmap->drawable.bitsPerPixel == 16) {
- if (pPixmap->drawable.depth == 16) {
- fmt2 = NV04_GDI_COLOR_FORMAT_A16R5G6B5;
- } else if (pPixmap->drawable.depth == 15) {
- fmt2 = NV04_GDI_COLOR_FORMAT_X16A1R5G5B5;
- }
- }
+ if (!NV04EXASetROP(ppix, NV04_RECT(OPERATION), alu, planemask))
+ return FALSE;
- /* When SURFACE_FORMAT_A8R8G8B8 is used with GDI_RECTANGLE_TEXT, the
- * alpha channel gets forced to 0xFF for some reason. We're using
- * SURFACE_FORMAT_Y32 as a workaround
- */
- if (fmt == NV04_SURFACE_2D_FORMAT_A8R8G8B8)
- fmt = NV04_SURFACE_2D_FORMAT_Y32;
-
- BEGIN_NV04(chan, NV04_SF2D(FORMAT), 4);
- OUT_RING (chan, fmt);
- OUT_RING (chan, (pitch << 16) | pitch);
- if (OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR) ||
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR)) {
- MARK_UNDO(chan);
+ BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
+ PUSH_DATA (push, surf_fmt);
+ PUSH_DATA (push, (pitch << 16) | pitch);
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_SOURCE), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_DESTIN), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ BEGIN_NV04(push, NV04_RECT(COLOR_FORMAT), 1);
+ PUSH_DATA (push, rect_fmt);
+
+ nouveau_pushbuf_bufctx(push, pNv->bufctx);
+ if (nouveau_pushbuf_validate(push)) {
+ nouveau_pushbuf_bufctx(push, NULL);
return FALSE;
}
- BEGIN_NV04(chan, NV04_RECT(COLOR_FORMAT), 1);
- OUT_RING (chan, fmt2);
- BEGIN_NV04(chan, NV04_RECT(COLOR1_A), 1);
- OUT_RING (chan, fg);
-
- pNv->pdpix = pPixmap;
- pNv->alu = alu;
- pNv->planemask = planemask;
pNv->fg_colour = fg;
- chan->flush_notify = NV04EXAStateSolidResubmit;
return TRUE;
}
void
-NV04EXASolid (PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
+NV04EXASolid (PixmapPtr pPixmap, int x, int y, int x2, int y2)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
- int width = x2-x1;
- int height = y2-y1;
-
- BEGIN_NV04(chan, NV04_RECT(UNCLIPPED_RECTANGLE_POINT(0)), 2);
- OUT_RING (chan, (x1 << 16) | y1);
- OUT_RING (chan, (width << 16) | height);
-
- if((width * height) >= 512)
- FIRE_RING (chan);
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+ int w = x2 - x;
+ int h = y2 - y;
+
+ if (!PUSH_SPACE(push, 5))
+ return;
+
+ BEGIN_NV04(push, NV04_RECT(COLOR1_A), 1);
+ PUSH_DATA (push, pNv->fg_colour);
+ BEGIN_NV04(push, NV04_RECT(UNCLIPPED_RECTANGLE_POINT(0)), 2);
+ PUSH_DATA (push, (x << 16) | y);
+ PUSH_DATA (push, (w << 16) | h);
+ if ((w * h) >= 512)
+ PUSH_KICK(push);
}
void
NV04EXADoneSolid (PixmapPtr pPixmap)
{
ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
- NVPtr pNv = NVPTR(pScrn);
-
- pNv->chan->flush_notify = NULL;
-}
-
-static void
-NV04EXAStateCopyResubmit(struct nouveau_channel *chan)
-{
- ScrnInfoPtr pScrn = chan->user_private;
- NVPtr pNv = NVPTR(pScrn);
-
- NV04EXAPrepareCopy(pNv->pspix, pNv->pdpix, 0, 0, pNv->alu,
- pNv->planemask);
+ nouveau_pushbuf_bufctx(NVPTR(pScrn)->pushbuf, NULL);
}
Bool
-NV04EXAPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy,
+NV04EXAPrepareCopy(PixmapPtr pspix, PixmapPtr pdpix, int dx, int dy,
int alu, Pixel planemask)
{
- ScrnInfoPtr pScrn = xf86Screens[pSrcPixmap->drawable.pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86Screens[pspix->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
- struct nouveau_bo *src_bo = nouveau_pixmap_bo(pSrcPixmap);
- struct nouveau_bo *dst_bo = nouveau_pixmap_bo(pDstPixmap);
- int fmt;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+ struct nouveau_bo *src_bo = nouveau_pixmap_bo(pspix);
+ struct nouveau_bo *dst_bo = nouveau_pixmap_bo(pdpix);
+ int surf_fmt;
- if (pSrcPixmap->drawable.bitsPerPixel !=
- pDstPixmap->drawable.bitsPerPixel)
+ if (pspix->drawable.bitsPerPixel != pdpix->drawable.bitsPerPixel)
return FALSE;
- if (!NVAccelGetCtxSurf2DFormatFromPixmap(pDstPixmap, &fmt))
+ if (!NVAccelGetCtxSurf2DFormatFromPixmap(pdpix, &surf_fmt))
return FALSE;
- if (MARK_RING(chan, 64, 2))
+ if (!PUSH_SPACE(push, 64))
return FALSE;
+ PUSH_RESET(push);
- planemask |= ~0 << pDstPixmap->drawable.bitsPerPixel;
- if (planemask != ~0 || alu != GXcopy) {
- if (pDstPixmap->drawable.bitsPerPixel == 32) {
- MARK_UNDO(chan);
- return FALSE;
- }
-
- BEGIN_NV04(chan, NV01_BLIT(OPERATION), 1);
- OUT_RING (chan, 1); /* ROP_AND */
-
- NV04EXASetROP(pScrn, alu, planemask);
- } else {
- BEGIN_NV04(chan, NV01_BLIT(OPERATION), 1);
- OUT_RING (chan, 3); /* SRCCOPY */
- }
+ if (!NV04EXASetROP(pdpix, NV01_BLIT(OPERATION), alu, planemask))
+ return FALSE;
- BEGIN_NV04(chan, NV04_SF2D(FORMAT), 4);
- OUT_RING (chan, fmt);
- OUT_RING (chan, (exaGetPixmapPitch(pDstPixmap) << 16) |
- (exaGetPixmapPitch(pSrcPixmap)));
- if (OUT_RELOCl(chan, src_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD) ||
- OUT_RELOCl(chan, dst_bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR)) {
- MARK_UNDO(chan);
+ BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
+ PUSH_DATA (push, surf_fmt);
+ PUSH_DATA (push, (exaGetPixmapPitch(pdpix) << 16) |
+ exaGetPixmapPitch(pspix));
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_SOURCE), src_bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_DESTIN), dst_bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+
+ nouveau_pushbuf_bufctx(push, pNv->bufctx);
+ if (nouveau_pushbuf_validate(push)) {
+ nouveau_pushbuf_bufctx(push, NULL);
return FALSE;
}
- pNv->pspix = pSrcPixmap;
- pNv->pdpix = pDstPixmap;
- pNv->alu = alu;
- pNv->planemask = planemask;
- chan->flush_notify = NV04EXAStateCopyResubmit;
+ pNv->pspix = pspix;
+ pNv->pmpix = NULL;
+ pNv->pdpix = pdpix;
return TRUE;
}
void
-NV04EXACopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
+NV04EXACopy(PixmapPtr pdpix, int srcX, int srcY, int dstX, int dstY,
int width, int height)
{
- ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+ ScrnInfoPtr pScrn = xf86Screens[pdpix->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
int split_dstY = NOUVEAU_ALIGN(dstY + 1, 64);
int split_height = split_dstY - dstY;
+ if (nouveau_pushbuf_space(push, 16, 1, 0))
+ return;
+
if ((width * height) >= 200000 && pNv->pspix != pNv->pdpix &&
(dstY > srcY || dstX > srcX) && split_height < height) {
/*
@@ -257,90 +234,59 @@ NV04EXACopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY,
* different (not nicer) trick to achieve the same
* effect.
*/
- struct nouveau_bo *dst_bo = nouveau_pixmap_bo(pNv->pdpix);
- unsigned dst_pitch = exaGetPixmapPitch(pNv->pdpix);
-
- if (MARK_RING(chan, 10, 1))
- return;
-
- BEGIN_NV04(chan, NV01_BLIT(POINT_IN), 3);
- OUT_RING (chan, (srcY << 16) | srcX);
- OUT_RING (chan, (dstY << 16) | dstX);
- OUT_RING (chan, (split_height << 16) | width);
+ struct nouveau_bo *dst_bo = nouveau_pixmap_bo(pdpix);
+ unsigned dst_pitch = exaGetPixmapPitch(pdpix);
- BEGIN_NV04(chan, NV04_SF2D(OFFSET_DESTIN), 1);
- OUT_RELOCl(chan, dst_bo, split_dstY * dst_pitch,
- NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ BEGIN_NV04(push, NV01_BLIT(POINT_IN), 3);
+ PUSH_DATA (push, (srcY << 16) | srcX);
+ PUSH_DATA (push, (dstY << 16) | dstX);
+ PUSH_DATA (push, (split_height << 16) | width);
+ BEGIN_NV04(push, NV04_SF2D(OFFSET_DESTIN), 1);
+ PUSH_RELOC(push, dst_bo, split_dstY * dst_pitch,
+ NOUVEAU_BO_LOW, 0, 0);
srcY += split_height;
height -= split_height;
dstY = 0;
+ pNv->pmpix = pdpix;
+ } else
+ if (pNv->pmpix) {
+ struct nouveau_bo *dst_bo = nouveau_pixmap_bo(pdpix);
+
+ BEGIN_NV04(push, NV04_SF2D(OFFSET_DESTIN), 1);
+ PUSH_RELOC(push, dst_bo, 0, NOUVEAU_BO_LOW, 0, 0);
+ pNv->pmpix = NULL;
}
- BEGIN_NV04(chan, NV01_BLIT(POINT_IN), 3);
- OUT_RING (chan, (srcY << 16) | srcX);
- OUT_RING (chan, (dstY << 16) | dstX);
- OUT_RING (chan, (height << 16) | width);
+ BEGIN_NV04(push, NV01_BLIT(POINT_IN), 3);
+ PUSH_DATA (push, (srcY << 16) | srcX);
+ PUSH_DATA (push, (dstY << 16) | dstX);
+ PUSH_DATA (push, (height << 16) | width);
- if((width * height) >= 512)
- FIRE_RING (chan);
+ if ((width * height) >= 512)
+ PUSH_KICK(push);
}
void
-NV04EXADoneCopy(PixmapPtr pDstPixmap)
+NV04EXADoneCopy(PixmapPtr pdpix)
{
- ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
- NVPtr pNv = NVPTR(pScrn);
-
- pNv->chan->flush_notify = NULL;
-}
-
-static Bool
-NV04EXAStateIFCSubmit(struct nouveau_channel *chan)
-{
- ScrnInfoPtr pScrn = chan->user_private;
- NVPtr pNv = NVPTR(pScrn);
- struct nouveau_bo *bo = nouveau_pixmap_bo(pNv->pdpix);
- int surf_fmt;
-
- NVAccelGetCtxSurf2DFormatFromPixmap(pNv->pdpix, &surf_fmt);
-
- if (MARK_RING(chan, 64, 2))
- return FALSE;
-
- BEGIN_NV04(chan, NV04_SF2D(FORMAT), 4);
- OUT_RING (chan, surf_fmt);
- OUT_RING (chan, (exaGetPixmapPitch(pNv->pdpix) << 16) |
- exaGetPixmapPitch(pNv->pdpix));
- if (OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR) ||
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR)) {
- MARK_UNDO(chan);
- return FALSE;
- }
- BEGIN_NV04(chan, NV01_IFC(POINT), 3);
- OUT_RING (chan, (pNv->point_y << 16) | pNv->point_x);
- OUT_RING (chan, (pNv->height_out << 16) | pNv->width_out);
- OUT_RING (chan, (pNv->height_in << 16) | pNv->width_in);
-
- return TRUE;
-}
-
-static void
-NV04EXAStateIFCResubmit(struct nouveau_channel *chan)
-{
- NV04EXAStateIFCSubmit(chan);
+ ScrnInfoPtr pScrn = xf86Screens[pdpix->drawable.pScreen->myNum];
+ nouveau_pushbuf_bufctx(NVPTR(pScrn)->pushbuf, NULL);
}
Bool
NV04EXAUploadIFC(ScrnInfoPtr pScrn, const char *src, int src_pitch,
- PixmapPtr pDst, int x, int y, int w, int h, int cpp)
+ PixmapPtr pdpix, int x, int y, int w, int h, int cpp)
{
NVPtr pNv = NVPTR(pScrn);
- ScreenPtr pScreen = pDst->drawable.pScreen;
- struct nouveau_channel *chan = pNv->chan;
+ ScreenPtr pScreen = pdpix->drawable.pScreen;
+ struct nouveau_bo *bo = nouveau_pixmap_bo(pdpix);
+ struct nouveau_pushbuf *push = pNv->pushbuf;
int line_len = w * cpp;
- int iw, id, surf_fmt, ifc_fmt;
+ int surf_fmt, ifc_fmt;
+ int iw, id, py, ph;
int padbytes;
+ Bool ret = FALSE;
if (pNv->Architecture >= NV_ARCH_50)
return FALSE;
@@ -348,7 +294,7 @@ NV04EXAUploadIFC(ScrnInfoPtr pScrn, const char *src, int src_pitch,
if (h > 1024)
return FALSE;
- if (line_len<4)
+ if (line_len < 4)
return FALSE;
switch (cpp) {
@@ -358,7 +304,7 @@ NV04EXAUploadIFC(ScrnInfoPtr pScrn, const char *src, int src_pitch,
return FALSE;
}
- if (!NVAccelGetCtxSurf2DFormatFromPixmap(pDst, &surf_fmt))
+ if (!NVAccelGetCtxSurf2DFormatFromPixmap(pdpix, &surf_fmt))
return FALSE;
/* Pad out input width to cover both COLORA() and COLORB() */
@@ -371,49 +317,67 @@ NV04EXAUploadIFC(ScrnInfoPtr pScrn, const char *src, int src_pitch,
if (id > 1792)
return FALSE;
- BEGIN_NV04(chan, NV01_SUBC(MISC, OBJECT), 1);
- OUT_RING (chan, pNv->NvClipRectangle->handle);
- BEGIN_NV04(chan, NV01_CLIP(POINT), 2);
- OUT_RING (chan, (y << 16) | x);
- OUT_RING (chan, (h << 16) | w);
- BEGIN_NV04(chan, NV01_IFC(OPERATION), 2);
- OUT_RING (chan, NV01_IFC_OPERATION_SRCCOPY);
- OUT_RING (chan, ifc_fmt);
-
- pNv->point_x = x;
- pNv->point_y = y;
- pNv->height_in = pNv->height_out = h;
- pNv->width_in = iw;
- pNv->width_out = w;
- pNv->pdpix = pDst;
- chan->flush_notify = NV04EXAStateIFCResubmit;
- if (!NV04EXAStateIFCSubmit(chan))
+ if (!PUSH_SPACE(push, 16))
return FALSE;
+ PUSH_RESET(push);
+
+ BEGIN_NV04(push, NV01_SUBC(MISC, OBJECT), 1);
+ PUSH_DATA (push, pNv->NvClipRectangle->handle);
+ BEGIN_NV04(push, NV01_CLIP(POINT), 2);
+ PUSH_DATA (push, (y << 16) | x);
+ PUSH_DATA (push, (h << 16) | w);
+
+ BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
+ PUSH_DATA (push, surf_fmt);
+ PUSH_DATA (push, (exaGetPixmapPitch(pdpix) << 16) |
+ exaGetPixmapPitch(pdpix));
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_SOURCE), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_DESTIN), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+
+ nouveau_pushbuf_bufctx(push, pNv->bufctx);
+ if (nouveau_pushbuf_validate(push))
+ goto out;
+
+ py = y;
+ ph = h;
+ while (ph--) {
+ if (PUSH_AVAIL(push) < id + 1 || (py == y)) {
+ if (!PUSH_SPACE(push, id + 8))
+ goto out;
+ BEGIN_NV04(push, NV01_IFC(OPERATION), 2);
+ PUSH_DATA (push, NV01_IFC_OPERATION_SRCCOPY);
+ PUSH_DATA (push, ifc_fmt);
+ BEGIN_NV04(push, NV01_IFC(POINT), 3);
+ PUSH_DATA (push, (py << 16) | x);
+ PUSH_DATA (push, (h << 16) | w);
+ PUSH_DATA (push, (h << 16) | iw);
+ }
- if (padbytes)
- h--;
- while (h--) {
/* send a line */
- BEGIN_NV04(chan, NV01_IFC(COLOR(0)), id);
- OUT_RINGp (chan, src, id);
+ if (ph > 0 || !padbytes) {
+ BEGIN_NV04(push, NV01_IFC(COLOR(0)), id);
+ PUSH_DATAp(push, src, id);
+ } else {
+ char padding[8];
+ int aux = (padbytes + 7) >> 2;
+ memcpy(padding, src + (id - aux) * 4, padbytes);
+ BEGIN_NV04(push, NV01_IFC(COLOR(0)), id);
+ PUSH_DATAp(push, src, id - aux);
+ PUSH_DATAp(push, padding, aux);
+ }
src += src_pitch;
- pNv->point_y++;
+ py++;
}
- if (padbytes) {
- char padding[8];
- int aux = (padbytes + 7) >> 2;
- BEGIN_NV04(chan, NV01_IFC(COLOR(0)), id);
- OUT_RINGp (chan, src, id - aux);
- memcpy(padding, src + (id - aux) * 4, padbytes);
- OUT_RINGp (chan, padding, aux);
- }
-
- chan->flush_notify = NULL;
- if (pDst == pScreen->GetScreenPixmap(pScreen))
- FIRE_RING(chan);
- return TRUE;
+ ret = TRUE;
+out:
+ nouveau_pushbuf_bufctx(push, NULL);
+ if (pdpix == pScreen->GetScreenPixmap(pScreen))
+ PUSH_KICK(push);
+ return ret;
}
Bool
@@ -423,7 +387,12 @@ NV04EXARectM2MF(NVPtr pNv, int w, int h, int cpp,
struct nouveau_bo *dst, uint32_t dst_off, int dst_dom,
int dst_pitch, int dst_h, int dst_x, int dst_y)
{
- struct nouveau_channel *chan = pNv->chan;
+ struct nv04_fifo *fifo = pNv->channel->data;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+ struct nouveau_pushbuf_refn refs[] = {
+ { src, src_dom | NOUVEAU_BO_RD },
+ { dst, dst_dom | NOUVEAU_BO_WR },
+ };
src_off += src_y * src_pitch + src_x * cpp;
dst_off += dst_y * dst_pitch + dst_x * cpp;
@@ -434,31 +403,26 @@ NV04EXARectM2MF(NVPtr pNv, int w, int h, int cpp,
line_count = 2047;
h -= line_count;
- if (MARK_RING (chan, 16, 4))
+ if (nouveau_pushbuf_space(push, 16, 4, 0) ||
+ nouveau_pushbuf_refn (push, refs, 2))
return FALSE;
- BEGIN_NV04(chan, NV03_M2MF(DMA_BUFFER_IN), 2);
- if (OUT_RELOCo(chan, src, src_dom | NOUVEAU_BO_RD) ||
- OUT_RELOCo(chan, dst, dst_dom | NOUVEAU_BO_WR)) {
- MARK_UNDO(chan);
- return FALSE;
- }
- BEGIN_NV04(chan, NV03_M2MF(OFFSET_IN), 8);
- if (OUT_RELOCl(chan, src, src_off, src_dom | NOUVEAU_BO_RD) ||
- OUT_RELOCl(chan, dst, dst_off, dst_dom | NOUVEAU_BO_WR)) {
- MARK_UNDO(chan);
- return FALSE;
- }
- OUT_RING (chan, src_pitch);
- OUT_RING (chan, dst_pitch);
- OUT_RING (chan, w * cpp);
- OUT_RING (chan, line_count);
- OUT_RING (chan, 0x00000101);
- OUT_RING (chan, 0x00000000);
- BEGIN_NV04(chan, NV04_GRAPH(M2MF, NOP), 1);
- OUT_RING (chan, 0x00000000);
- BEGIN_NV04(chan, NV03_M2MF(OFFSET_OUT), 1);
- OUT_RING (chan, 0x00000000);
+ BEGIN_NV04(push, NV03_M2MF(DMA_BUFFER_IN), 2);
+ PUSH_RELOC(push, src, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
+ PUSH_RELOC(push, dst, 0, NOUVEAU_BO_OR, fifo->vram, fifo->gart);
+ BEGIN_NV04(push, NV03_M2MF(OFFSET_IN), 8);
+ PUSH_RELOC(push, src, src_off, NOUVEAU_BO_LOW, 0, 0);
+ PUSH_RELOC(push, dst, dst_off, NOUVEAU_BO_LOW, 0, 0);
+ PUSH_DATA (push, src_pitch);
+ PUSH_DATA (push, dst_pitch);
+ PUSH_DATA (push, w * cpp);
+ PUSH_DATA (push, line_count);
+ PUSH_DATA (push, 0x00000101);
+ PUSH_DATA (push, 0x00000000);
+ BEGIN_NV04(push, NV04_GRAPH(M2MF, NOP), 1);
+ PUSH_DATA (push, 0x00000000);
+ BEGIN_NV04(push, NV03_M2MF(OFFSET_OUT), 1);
+ PUSH_DATA (push, 0x00000000);
src_off += src_pitch * line_count;
dst_off += dst_pitch * line_count;
View
262 src/nv04_xv_blit.c
@@ -36,6 +36,7 @@
#include "hwdefs/nv_object.xml.h"
#include "hwdefs/nv01_2d.xml.h"
+#include "nv04_accel.h"
#define FOURCC_RGB 0x0000003
@@ -43,140 +44,125 @@
extern Atom xvSetDefaults, xvSyncToVBlank;
-/**
- * NVPutBlitImage
- *
- * @param pScrn screen
- * @param src_offset offset of image data in VRAM
- * @param id pixel format
- * @param src_pitch source pitch
- * @param dstBox
- * @param x1
- * @param y1
- * @param x2
- * @param y2
- * @param width
- * @param height
- * @param src_w
- * @param src_h
- * @param drw_w
- * @param drw_h
- * @param clipBoxes
- * @param pDraw
- */
Bool
NVPutBlitImage(ScrnInfoPtr pScrn, struct nouveau_bo *src, int src_offset,
int id, int src_pitch, BoxPtr dstBox,
- int x1, int y1, int x2, int y2,
- short width, short height,
- short src_w, short src_h,
- short drw_w, short drw_h,
- RegionPtr clipBoxes, PixmapPtr ppix)
+ int x1, int y1, int x2, int y2,
+ short width, short height,
+ short src_w, short src_h,
+ short drw_w, short drw_h,
+ RegionPtr clipBoxes, PixmapPtr ppix)
{
- NVPtr pNv = NVPTR(pScrn);
- NVPortPrivPtr pPriv = GET_BLIT_PRIVATE(pNv);
- BoxPtr pbox;
- int nbox;
- CARD32 dsdx, dtdy;
- CARD32 dst_size, dst_point;
- CARD32 src_point, src_format;
- struct nouveau_channel *chan = pNv->chan;
+ NVPtr pNv = NVPTR(pScrn);
+ NVPortPrivPtr pPriv = GET_BLIT_PRIVATE(pNv);
+ BoxPtr pbox;
+ int nbox;
+ CARD32 dsdx, dtdy;
+ CARD32 dst_size, dst_point;
+ CARD32 src_point, src_format;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
struct nouveau_bo *bo = nouveau_pixmap_bo(ppix);
- int dst_format;
+ struct nv04_fifo *fifo = pNv->channel->data;
+ int dst_format;
- if (!NVAccelGetCtxSurf2DFormatFromPixmap(ppix, &dst_format))
+ if (!NVAccelGetCtxSurf2DFormatFromPixmap(ppix, &dst_format))
return BadImplementation;
- if (MARK_RING(chan, 64, 4))
- return BadImplementation;
+ pbox = REGION_RECTS(clipBoxes);
+ nbox = REGION_NUM_RECTS(clipBoxes);
+
+ dsdx = (src_w << 20) / drw_w;
+ dtdy = (src_h << 20) / drw_h;
+
+ dst_size = ((dstBox->y2 - dstBox->y1) << 16) |
+ (dstBox->x2 - dstBox->x1);
+ dst_point = (dstBox->y1 << 16) | dstBox->x1;
+
+ src_point = ((y1 << 4) & 0xffff0000) | (x1 >> 12);
+
+ switch(id) {
+ case FOURCC_RGB:
+ src_format = NV03_SIFM_COLOR_FORMAT_X8R8G8B8;
+ break;
+ case FOURCC_UYVY:
+ src_format = NV03_SIFM_COLOR_FORMAT_YB8V8YA8U8;
+ break;
+ default:
+ src_format = NV03_SIFM_COLOR_FORMAT_V8YB8U8YA8;
+ break;
+ }
- BEGIN_NV04(chan, NV04_SF2D(FORMAT), 4);
- OUT_RING (chan, dst_format);
- OUT_RING (chan, (exaGetPixmapPitch(ppix) << 16) | exaGetPixmapPitch(ppix));
- if (OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR) ||
- OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR)) {
- MARK_UNDO(chan);
+ if (!PUSH_SPACE(push, 128))
return BadImplementation;
+ PUSH_RESET(push);
+
+ BEGIN_NV04(push, NV04_SF2D(FORMAT), 4);
+ PUSH_DATA (push, dst_format);
+ PUSH_DATA (push, (exaGetPixmapPitch(ppix) << 16) |
+ exaGetPixmapPitch(ppix));
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_SOURCE), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+ PUSH_MTHDl(push, NV04_SF2D(OFFSET_DESTIN), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
+
+ BEGIN_NV04(push, NV01_SUBC(MISC, OBJECT), 1);
+ PUSH_DATA (push, pNv->NvScaledImage->handle);
+ BEGIN_NV04(push, NV03_SIFM(DMA_IMAGE), 1);
+ PUSH_MTHDo(push, NV03_SIFM(DMA_IMAGE), src, NOUVEAU_BO_RD |
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_GART,
+ fifo->vram, fifo->gart);
+ if (pNv->dev->chipset >= 0x05) {
+ BEGIN_NV04(push, NV03_SIFM(COLOR_FORMAT), 2);
+ PUSH_DATA (push, src_format);
+ PUSH_DATA (push, NV03_SIFM_OPERATION_SRCCOPY);
+ } else {
+ BEGIN_NV04(push, NV03_SIFM(COLOR_FORMAT), 1);
+ PUSH_DATA (push, src_format);
+ }
+
+ nouveau_pushbuf_bufctx(push, pNv->bufctx);
+ if (nouveau_pushbuf_validate(push)) {
+ nouveau_pushbuf_bufctx(push, NULL);
+ return BadAlloc;
}
- pbox = REGION_RECTS(clipBoxes);
- nbox = REGION_NUM_RECTS(clipBoxes);
-
- dsdx = (src_w << 20) / drw_w;
- dtdy = (src_h << 20) / drw_h;
-
- dst_size = ((dstBox->y2 - dstBox->y1) << 16) |
- (dstBox->x2 - dstBox->x1);
- dst_point = (dstBox->y1 << 16) | dstBox->x1;
-
- src_pitch |= (NV03_SIFM_FORMAT_ORIGIN_CENTER |
- NV03_SIFM_FORMAT_FILTER_BILINEAR);
- src_point = ((y1 << 4) & 0xffff0000) | (x1 >> 12);
-
- switch(id) {
- case FOURCC_RGB:
- src_format = NV03_SIFM_COLOR_FORMAT_X8R8G8B8;
- break;
- case FOURCC_UYVY:
- src_format = NV03_SIFM_COLOR_FORMAT_YB8V8YA8U8;
- break;
- default:
- src_format = NV03_SIFM_COLOR_FORMAT_V8YB8U8YA8;
- break;
- }
-
- if(pPriv->SyncToVBlank) {
- FIRE_RING(chan);
+ if (pPriv->SyncToVBlank)
NV11SyncToVBlank(ppix, dstBox);
- }
-
- BEGIN_NV04(chan, NV01_SUBC(MISC, OBJECT), 1);
- OUT_RING (chan, pNv->NvScaledImage->handle);
- if (pNv->dev->chipset >= 0x05) {
- BEGIN_NV04(chan, NV03_SIFM(COLOR_FORMAT), 2);
- OUT_RING (chan, src_format);
- OUT_RING (chan, NV03_SIFM_OPERATION_SRCCOPY);
- } else {
- BEGIN_NV04(chan, NV03_SIFM(COLOR_FORMAT), 1);
- OUT_RING (chan, src_format);
- }
-
-
- BEGIN_NV04(chan, NV03_SIFM(DMA_IMAGE), 1);
- OUT_RELOCo(chan, src, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
- NOUVEAU_BO_RD);
- while (nbox--) {
- BEGIN_NV04(chan, NV04_RECT(COLOR1_A), 1);
- OUT_RING (chan, 0);
-
- BEGIN_NV04(chan, NV03_SIFM(CLIP_POINT), 6);
- OUT_RING (chan, (pbox->y1 << 16) | pbox->x1);
- OUT_RING (chan, ((pbox->y2 - pbox->y1) << 16) |
- (pbox->x2 - pbox->x1));
- OUT_RING (chan, dst_point);
- OUT_RING (chan, dst_size);
- OUT_RING (chan, dsdx);
- OUT_RING (chan, dtdy);
-
- BEGIN_NV04(chan, NV03_SIFM(SIZE), 4);
- OUT_RING (chan, (height << 16) | width);
- OUT_RING (chan, src_pitch);
- if (OUT_RELOCl(chan, src, src_offset, NOUVEAU_BO_VRAM |
- NOUVEAU_BO_GART | NOUVEAU_BO_RD)) {
- MARK_UNDO(chan);
+
+ while (nbox--) {
+ if (!PUSH_SPACE(push, 16)) {
+ nouveau_pushbuf_bufctx(push, NULL);
return BadImplementation;
}
- OUT_RING (chan, src_point);
- pbox++;
- }
- FIRE_RING (chan);
+ BEGIN_NV04(push, NV04_RECT(COLOR1_A), 1);
+ PUSH_DATA (push, 0);
+
+ BEGIN_NV04(push, NV03_SIFM(CLIP_POINT), 6);
+ PUSH_DATA (push, (pbox->y1 << 16) | pbox->x1);
+ PUSH_DATA (push, (pbox->y2 - pbox->y1) << 16 |
+ (pbox->x2 - pbox->x1));
+ PUSH_DATA (push, dst_point);
+ PUSH_DATA (push, dst_size);
+ PUSH_DATA (push, dsdx);
+ PUSH_DATA (push, dtdy);
+ BEGIN_NV04(push, NV03_SIFM(SIZE), 4);
+ PUSH_DATA (push, (height << 16) | width);
+ PUSH_DATA (push, NV03_SIFM_FORMAT_FILTER_BILINEAR |
+ NV03_SIFM_FORMAT_ORIGIN_CENTER | src_pitch);
+ PUSH_RELOC(push, src, src_offset, NOUVEAU_BO_LOW, 0, 0);
+ PUSH_DATA (push, src_point);
+
+ pbox++;
+ }
- exaMarkSync(pScrn->pScreen);
+ nouveau_pushbuf_bufctx(push, NULL);
+ PUSH_KICK(push);
+ exaMarkSync(pScrn->pScreen);
- pPriv->videoStatus = FREE_TIMER;
- pPriv->videoTime = currentTime.milliseconds + FREE_DELAY;
- extern void NVVideoTimerCallback(ScrnInfoPtr, Time);
+ pPriv->videoStatus = FREE_TIMER;
+ pPriv->videoTime = currentTime.milliseconds + FREE_DELAY;
+ extern void NVVideoTimerCallback(ScrnInfoPtr, Time);
pNv->VideoTimerCallback = NVVideoTimerCallback;
return Success;
}
@@ -199,22 +185,22 @@ NVPutBlitImage(ScrnInfoPtr pScrn, struct nouveau_bo *src, int src_offset,
*/
int
NVSetBlitPortAttribute(ScrnInfoPtr pScrn, Atom attribute,
- INT32 value, pointer data)
+ INT32 value, pointer data)
{
- NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
- NVPtr pNv = NVPTR(pScrn);
-
- if ((attribute == xvSyncToVBlank) && VSYNC_POSSIBLE) {
- if ((value < 0) || (value > 1))
- return BadValue;
- pPriv->SyncToVBlank = value;
- } else
- if (attribute == xvSetDefaults) {
- pPriv->SyncToVBlank = VSYNC_POSSIBLE;
- } else
- return BadMatch;
-
- return Success;
+ NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
+ NVPtr pNv = NVPTR(pScrn);
+
+ if ((attribute == xvSyncToVBlank) && VSYNC_POSSIBLE) {
+ if ((value < 0) || (value > 1))
+ return BadValue;
+ pPriv->SyncToVBlank = value;
+ } else
+ if (attribute == xvSetDefaults) {
+ pPriv->SyncToVBlank = VSYNC_POSSIBLE;
+ } else
+ return BadMatch;
+
+ return Success;
}
/**
@@ -230,16 +216,16 @@ NVSetBlitPortAttribute(ScrnInfoPtr pScrn, Atom attribute,
*/
int
NVGetBlitPortAttribute(ScrnInfoPtr pScrn, Atom attribute,
- INT32 *value, pointer data)
+ INT32 *value, pointer data)
{
- NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
+ NVPortPrivPtr pPriv = (NVPortPrivPtr)data;
- if(attribute == xvSyncToVBlank)
- *value = (pPriv->SyncToVBlank) ? 1 : 0;
- else
- return BadMatch;
+ if(attribute == xvSyncToVBlank)
+ *value = (pPriv->SyncToVBlank) ? 1 : 0;
+ else
+ return BadMatch;
- return Success;
+ return Success;
}
/**
View
613 src/nv10_exa.c
@@ -31,6 +31,7 @@
#include "hwdefs/nv_object.xml.h"
#include "hwdefs/nv10_3d.xml.h"
+#include "nv04_accel.h"
/* Texture/Render target formats. */
static struct pict_format {
@@ -374,73 +375,63 @@ NV10EXACheckComposite(int op, PicturePtr src, PicturePtr mask, PicturePtr dst)
static Bool
setup_texture(NVPtr pNv, int unit, PicturePtr pict, PixmapPtr pixmap)
{
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
struct nouveau_bo *bo = nouveau_pixmap_bo(pixmap);
- unsigned tex_reloc = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
- long w = pict->pDrawable->width,
- h = pict->pDrawable->height;
- unsigned int txfmt =
- NV10_3D_TEX_FORMAT_WRAP_T_CLAMP_TO_EDGE |
- NV10_3D_TEX_FORMAT_WRAP_S_CLAMP_TO_EDGE |
- log2i(w) << 20 | log2i(h) << 16 |
- 1 << 12 | /* lod == 1 */
- get_tex_format(pict) |
- 0x50 /* UNK */;
-
- BEGIN_NV04(chan, NV10_3D(TEX_OFFSET(unit)), 1);
- if (OUT_RELOCl(chan, bo, 0, tex_reloc))
- return FALSE;
-
- if (pict->repeat == RepeatNone) {
- /* NPOT_SIZE expects an even number for width, we can
- * round up uneven numbers here because EXA always
- * gives 64 byte aligned pixmaps and for all formats
- * we support 64 bytes represents an even number of
- * pixels
- */
+ unsigned reloc = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
+ unsigned h = pict->pDrawable->height;
+ unsigned w = pict->pDrawable->width;
+ unsigned format;
+
+ format = NV10_3D_TEX_FORMAT_WRAP_T_CLAMP_TO_EDGE |
+ NV10_3D_TEX_FORMAT_WRAP_S_CLAMP_TO_EDGE |
+ log2i(w) << 20 | log2i(h) << 16 |
+ 1 << 12 | /* lod == 1 */
+ get_tex_format(pict) |
+ 0x50 /* UNK */;
+
+ /* NPOT_SIZE expects an even number for width, we can round up uneven
+ * numbers here because EXA always gives 64 byte aligned pixmaps and
+ * for all formats we support 64 bytes represents an even number of
+ * pixels
+ */
+// if (pict->repeat == RepeatNone)
w = (w + 1) &~ 1;
- BEGIN_NV04(chan, NV10_3D(TEX_NPOT_PITCH(unit)), 1);
- OUT_RING (chan, exaGetPixmapPitch(pixmap) << 16);
-
- BEGIN_NV04(chan, NV10_3D(TEX_NPOT_SIZE(unit)), 1);
- OUT_RING (chan, w << 16 | h);
- }
-
- BEGIN_NV04(chan, NV10_3D(TEX_FORMAT(unit)), 1 );
- if (OUT_RELOCd(chan, bo, txfmt, tex_reloc | NOUVEAU_BO_OR,
- NV10_3D_TEX_FORMAT_DMA0, NV10_3D_TEX_FORMAT_DMA1))
- return FALSE;
- BEGIN_NV04(chan, NV10_3D(TEX_ENABLE(unit)), 1 );
- OUT_RING (chan, NV10_3D_TEX_ENABLE_ENABLE);
-
- BEGIN_NV04(chan, NV10_3D(TEX_FILTER(unit)), 1);
+ BEGIN_NV04(push, NV10_3D(TEX_OFFSET(unit)), 1);
+ PUSH_MTHDl(push, NV10_3D(TEX_OFFSET(unit)), bo, 0, reloc);
+ BEGIN_NV04(push, NV10_3D(TEX_FORMAT(unit)), 1);
+ PUSH_MTHDs(push, NV10_3D(TEX_FORMAT(unit)), bo, format, reloc,
+ NV10_3D_TEX_FORMAT_DMA0,
+ NV10_3D_TEX_FORMAT_DMA1);
+ BEGIN_NV04(push, NV10_3D(TEX_ENABLE(unit)), 1 );
+ PUSH_DATA (push, NV10_3D_TEX_ENABLE_ENABLE);
+ BEGIN_NV04(push, NV10_3D(TEX_NPOT_PITCH(unit)), 1);
+ PUSH_DATA (push, exaGetPixmapPitch(pixmap) << 16);
+ BEGIN_NV04(push, NV10_3D(TEX_NPOT_SIZE(unit)), 1);
+ PUSH_DATA (push, (w << 16) | h);
+ BEGIN_NV04(push, NV10_3D(TEX_FILTER(unit)), 1);
if (pict->filter == PictFilterNearest)
- OUT_RING(chan, (NV10_3D_TEX_FILTER_MAGNIFY_NEAREST |
- NV10_3D_TEX_FILTER_MINIFY_NEAREST));
+ PUSH_DATA(push, NV10_3D_TEX_FILTER_MAGNIFY_NEAREST |
+ NV10_3D_TEX_FILTER_MINIFY_NEAREST);
else
- OUT_RING(chan, (NV10_3D_TEX_FILTER_MAGNIFY_LINEAR |
- NV10_3D_TEX_FILTER_MINIFY_LINEAR));
-
+ PUSH_DATA(push, NV10_3D_TEX_FILTER_MAGNIFY_LINEAR |
+ NV10_3D_TEX_FILTER_MINIFY_LINEAR);
return TRUE;
}
static Bool
setup_render_target(NVPtr pNv, PicturePtr pict, PixmapPtr pixmap)
{
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
struct nouveau_bo *bo = nouveau_pixmap_bo(pixmap);
- BEGIN_NV04(chan, NV10_3D(RT_FORMAT), 2);
- OUT_RING (chan, get_rt_format(pict));
- OUT_RING (chan, (exaGetPixmapPitch(pixmap) << 16 |
+ BEGIN_NV04(push, NV10_3D(RT_FORMAT), 3);
+ PUSH_DATA (push, get_rt_format(pict));
+ PUSH_DATA (push, (exaGetPixmapPitch(pixmap) << 16 |
exaGetPixmapPitch(pixmap)));
-
- BEGIN_NV04(chan, NV10_3D(COLOR_OFFSET), 1);
- if (OUT_RELOCl(chan, bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR))
- return FALSE;
-
+ PUSH_MTHDl(push, NV10_3D(COLOR_OFFSET), bo, 0,
+ NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
return TRUE;
}
@@ -482,9 +473,9 @@ setup_render_target(NVPtr pNv, PicturePtr pict, PixmapPtr pixmap)
NV10_3D_RC_IN_RGB_##input##_COMPONENT_USAGE_##chan)
static void
-setup_combiners(NVPtr pNv, PicturePtr src, PicturePtr mask)
+setup_combiners(NVPtr pNv, PicturePtr src, PicturePtr mask, int alu)
{
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
uint32_t rc_in_alpha = 0, rc_in_rgb = 0;
if (PICT_FORMAT_A(src->format))
@@ -498,7 +489,7 @@ setup_combiners(NVPtr pNv, PicturePtr src, PicturePtr mask)
rc_in_alpha |= RC_IN_ONE(B);
if (effective_component_alpha(mask)) {
- if (!needs_src_alpha(pNv->alu)) {
+ if (!needs_src_alpha(alu)) {
/* The alpha channels won't be used for blending. Drop
* them, as our pixels only have 4 components...
* output_i = src_i * mask_i
@@ -528,22 +519,22 @@ setup_combiners(NVPtr pNv, PicturePtr src, PicturePtr mask)
rc_in_rgb |= RC_IN_ONE(B);
}
- BEGIN_NV04(chan, NV10_3D(RC_IN_ALPHA(0)), 1);
- OUT_RING (chan, rc_in_alpha);
- BEGIN_NV04(chan, NV10_3D(RC_IN_RGB(0)), 1);
- OUT_RING (chan, rc_in_rgb);
+ BEGIN_NV04(push, NV10_3D(RC_IN_ALPHA(0)), 1);
+ PUSH_DATA (push, rc_in_alpha);
+ BEGIN_NV04(push, NV10_3D(RC_IN_RGB(0)), 1);
+ PUSH_DATA (push, rc_in_rgb);
}
static void
-setup_blend_function(NVPtr pNv)
+setup_blend_function(NVPtr pNv, PicturePtr pdpict, int alu)
{
- struct nouveau_channel *chan = pNv->chan;
- struct pict_op *op = &nv10_pict_op[pNv->alu];
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+ struct pict_op *op = &nv10_pict_op[alu];
int src_factor = op->src;
int dst_factor = op->dst;
if (src_factor == SF(ONE_MINUS_DST_ALPHA) &&
- !PICT_FORMAT_A(pNv->pdpict->format))
+ !PICT_FORMAT_A(pdpict->format))
/* ONE_MINUS_DST_ALPHA doesn't always do the right thing for
* framebuffers without alpha channel. But it's the same as
* ZERO in that case.
@@ -557,21 +548,11 @@ setup_blend_function(NVPtr pNv)
dst_factor = DF(ONE_MINUS_SRC_COLOR);
}
- BEGIN_NV04(chan, NV10_3D(BLEND_FUNC_SRC), 2);
- OUT_RING (chan, src_factor);
- OUT_RING (chan, dst_factor);
- BEGIN_NV04(chan, NV10_3D(BLEND_FUNC_ENABLE), 1);
- OUT_RING (chan, 1);
-}
-
-static void
-NV10StateCompositeReemit(struct nouveau_channel *chan)
-{
- ScrnInfoPtr pScrn = chan->user_private;
- NVPtr pNv = NVPTR(pScrn);
-
- NV10EXAPrepareComposite(pNv->alu, pNv->pspict, pNv->pmpict, pNv->pdpict,
- pNv->pspix, pNv->pmpix, pNv->pdpix);
+ BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 2);
+ PUSH_DATA (push, src_factor);
+ PUSH_DATA (push, dst_factor);
+ BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1);
+ PUSH_DATA (push, 1);
}
Bool
@@ -585,46 +566,39 @@ NV10EXAPrepareComposite(int op,
{
ScrnInfoPtr pScrn = xf86Screens[dst->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
- if (MARK_RING(chan, 128, 5))
+ if (!PUSH_SPACE(push, 128))
return FALSE;
-
- pNv->alu = op;
- pNv->pspict = pict_src;
- pNv->pmpict = pict_mask;
- pNv->pdpict = pict_dst;
- pNv->pspix = src;
- pNv->pmpix = mask;
- pNv->pdpix = dst;
+ PUSH_RESET(push);
/* Set dst format */
if (!setup_render_target(pNv, pict_dst, dst))
- goto fail;
+ return FALSE;
/* Set src format */
if (!setup_texture(pNv, 0, pict_src, src))
- goto fail;
+ return FALSE;
/* Set mask format */
- if (mask &&
- !setup_texture(pNv, 1, pict_mask, mask))
- goto fail;
+ if (mask && !setup_texture(pNv, 1, pict_mask, mask))
+ return FALSE;
/* Set the register combiners up. */
- setup_combiners(pNv, pict_src, pict_mask);
+ setup_combiners(pNv, pict_src, pict_mask, op);
/* Set PictOp */
- setup_blend_function(pNv);
+ setup_blend_function(pNv, pict_dst, op);
- chan->flush_notify = NV10StateCompositeReemit;
+ nouveau_pushbuf_bufctx(push, pNv->bufctx);
+ if (nouveau_pushbuf_validate(push)) {
+ nouveau_pushbuf_bufctx(push, NULL);
+ return FALSE;
+ }
+ pNv->pspict = pict_src;
+ pNv->pmpict = pict_mask;
return TRUE;
-
-fail:
- MARK_UNDO(chan);
-
- return FALSE;
}
#define QUAD(x, y, w, h) \
@@ -642,29 +616,29 @@ NV10EXAPrepareComposite(int op,
#define xFixedToFloat(v) \
((float)xFixedToInt((v)) + ((float)xFixedFrac(v) / 65536.0))
-#define OUT_RINGi(chan, v, i) \
- OUT_RINGf(chan, xFixedToFloat((v).vector[i]))
+#define PUSH_DATAi(push, v, i) \
+ PUSH_DATAf(push, xFixedToFloat((v).vector[i]))
static inline void
emit_vertex(NVPtr pNv, int i, PictVector pos[],
PictVector tex0[], PictVector tex1[])
{
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
- BEGIN_NV04(chan, NV10_3D(VERTEX_TX0_2F_S), 2);
- OUT_RINGi (chan, tex0[i], 0);
- OUT_RINGi (chan, tex0[i], 1);
+ BEGIN_NV04(push, NV10_3D(VERTEX_TX0_2F_S), 2);
+ PUSH_DATAi(push, tex0[i], 0);
+ PUSH_DATAi(push, tex0[i], 1);
if (tex1) {
- BEGIN_NV04(chan, NV10_3D(VERTEX_TX1_2F_S), 2);
- OUT_RINGi (chan, tex1[i], 0);
- OUT_RINGi (chan, tex1[i], 1);
+ BEGIN_NV04(push, NV10_3D(VERTEX_TX1_2F_S), 2);
+ PUSH_DATAi(push, tex1[i], 0);
+ PUSH_DATAi(push, tex1[i], 1);
}
- BEGIN_NV04(chan, NV10_3D(VERTEX_POS_3F_X), 3);
- OUT_RINGi (chan, pos[i], 0);
- OUT_RINGi (chan, pos[i], 1);
- OUT_RINGf (chan, 0);
+ BEGIN_NV04(push, NV10_3D(VERTEX_POS_3F_X), 3);
+ PUSH_DATAi(push, pos[i], 0);
+ PUSH_DATAi(push, pos[i], 1);
+ PUSH_DATAf(push, 0.0);
}
static inline void
@@ -683,7 +657,7 @@ NV10EXAComposite(PixmapPtr pix_dst,
{
ScrnInfoPtr pScrn = xf86Screens[pix_dst->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
PicturePtr mask = pNv->pmpict,
src = pNv->pspict;
PictVector dstq[4] = QUAD(dstX, dstY, width, height),
@@ -694,31 +668,29 @@ NV10EXAComposite(PixmapPtr pix_dst,
if (mask)
MAP(transform_vertex, mask->transform, maskq);
- WAIT_RING (chan, 64);
- BEGIN_NV04(chan, NV10_3D(VERTEX_BEGIN_END), 1);
- OUT_RING (chan, NV10_3D_VERTEX_BEGIN_END_QUADS);
+ if (!PUSH_SPACE(push, 64))
+ return;
+ BEGIN_NV04(push, NV10_3D(VERTEX_BEGIN_END), 1);
+ PUSH_DATA (push, NV10_3D_VERTEX_BEGIN_END_QUADS);
MAP(emit_vertex, pNv, dstq, srcq, mask ? maskq : NULL);
-
- BEGIN_NV04(chan, NV10_3D(VERTEX_BEGIN_END), 1);
- OUT_RING (chan, NV10_3D_VERTEX_BEGIN_END_STOP);
+ BEGIN_NV04(push, NV10_3D(VERTEX_BEGIN_END), 1);
+ PUSH_DATA (push, NV10_3D_VERTEX_BEGIN_END_STOP);
}
void
NV10EXADoneComposite(PixmapPtr dst)
{
ScrnInfoPtr pScrn = xf86Screens[dst->drawable.pScreen->myNum];
- NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
-
- chan->flush_notify = NULL;
+ nouveau_pushbuf_bufctx(NVPTR(pScrn)->pushbuf, NULL);
}
Bool
NVAccelInitNV10TCL(ScrnInfoPtr pScrn)
{
NVPtr pNv = NVPTR(pScrn);
- struct nouveau_channel *chan = pNv->chan;
+ struct nouveau_pushbuf *push = pNv->pushbuf;
+ struct nv04_fifo *fifo = pNv->channel->data;
uint32_t class = 0;
int i;
@@ -735,233 +707,234 @@ NVAccelInitNV10TCL(ScrnInfoPtr pScrn)
else
class = NV10_3D_CLASS;
- if (!pNv->Nv3D) {
- if (nouveau_grobj_alloc(pNv->chan, Nv3D, class, &pNv->Nv3D))
- return FALSE;
- }
+ if (nouveau_object_new(pNv->channel, Nv3D, class, NULL, 0, &pNv->Nv3D))
+ return FALSE;
+
+ if (!PUSH_SPACE(push, 256))
+ return FALSE;
- BEGIN_NV04(chan, NV01_SUBC(3D, OBJECT), 1);
- OUT_RING (chan, pNv->Nv3D->handle);
- BEGIN_NV04(chan, NV10_3D(DMA_NOTIFY), 1);
- OUT_RING (chan, chan->nullobj->handle);
+ BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
+ PUSH_DATA (push, pNv->Nv3D->handle);
+ BEGIN_NV04(push, NV10_3D(DMA_NOTIFY), 1);
+ PUSH_DATA (push, pNv->NvNull->handle);
- BEGIN_NV04(chan, NV10_3D(DMA_TEXTURE0), 2);
- OUT_RING (chan, pNv->chan->vram->handle);
- OUT_RING (chan, pNv->chan->gart->handle);
+ BEGIN_NV04(push, NV10_3D(DMA_TEXTURE0), 2);
+ PUSH_DATA (push, fifo->vram);
+ PUSH_DATA (push, fifo->gart);
- BEGIN_NV04(chan, NV10_3D(DMA_COLOR), 2);
- OUT_RING (chan, pNv->chan->vram->handle);
- OUT_RING (chan, pNv->chan->vram->handle);
+ BEGIN_NV04(push, NV10_3D(DMA_COLOR), 2);
+ PUSH_DATA (push, fifo->vram);
+ PUSH_DATA (push, fifo->vram);
- BEGIN_NV04(chan, NV04_GRAPH(3D, NOP), 1);
- OUT_RING (chan, 0);
+ BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
+ PUSH_DATA (push, 0);
- BEGIN_NV04(chan, NV10_3D(RT_HORIZ), 2);
- OUT_RING (chan, 2048 << 16 | 0);
- OUT_RING (chan, 2048 << 16 | 0);
+ BEGIN_NV04(push, NV10_3D(RT_HORIZ), 2);
+ PUSH_DATA (push, 2048 << 16 | 0);
+ PUSH_DATA (push, 2048 << 16 | 0);
- BEGIN_NV04(chan, NV10_3D(ZETA_OFFSET), 1);
- OUT_RING (chan, 0);
+ BEGIN_NV04(push, NV10_3D(ZETA_OFFSET), 1);
+ PUSH_DATA (push, 0);
- BEGIN_NV04(chan, NV10_3D(VIEWPORT_CLIP_MODE), 1);
- OUT_RING (chan, 0);
+ BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_MODE), 1);
+ PUSH_DATA (push, 0);
- BEGIN_NV04(chan, NV10_3D(VIEWPORT_CLIP_HORIZ(0)), 1);
- OUT_RING (chan, 0x7ff << 16 | 0x800800);
- BEGIN_NV04(chan, NV10_3D(VIEWPORT_CLIP_VERT(0)), 1);
- OUT_RING (chan, 0x7ff << 16 | 0x800800);
+ BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(0)), 1);
+ PUSH_DATA (push, 0x7ff << 16 | 0x800800);
+ BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(0)), 1);
+ PUSH_DATA (push, 0x7ff << 16 | 0x800800);
for (i = 1; i < 8; i++) {
- BEGIN_NV04(chan, NV10_3D(VIEWPORT_CLIP_HORIZ(i)), 1);
- OUT_RING (chan, 0);
- BEGIN_NV04(chan, NV10_3D(VIEWPORT_CLIP_VERT(i)), 1);
- OUT_RING (chan, 0);
+ BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_HORIZ(i)), 1);
+ PUSH_DATA (push, 0);
+ BEGIN_NV04(push, NV10_3D(VIEWPORT_CLIP_VERT(i)), 1);
+ PUSH_DATA (push, 0);
}
- BEGIN_NV04(chan, SUBC_3D(0x290), 1);
- OUT_RING (chan, (0x10<<16)|1);
- BEGIN_NV04(chan, SUBC_3D(0x3f4), 1);
- OUT_RING (chan, 0);
+ BEGIN_NV04(push, SUBC_3D(0x290), 1);
+ PUSH_DATA (push, (0x10<<16)|1);
+ BEGIN_NV04(push, SUBC_3D(0x3f4), 1);
+ PUSH_DATA (push, 0);
- BEGIN_NV04(chan, NV04_GRAPH(3D, NOP), 1);
- OUT_RING (chan, 0);
+ BEGIN_NV04(push, NV04_GRAPH(3D, NOP), 1);
+ PUSH_DATA (push, 0);
if (class != NV10_3D_CLASS) {
/* For nv11, nv17 */
- BEGIN_NV04(chan, SUBC_3D(0x120), 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
- OUT_RING (chan, 2);
-
- BEGIN_NV04(chan, SUBC_BLIT(0x120), 3);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
- OUT_RING (chan, 2);
-
- BEGIN_NV04(chan, NV04_GRAPH(3D, NOP), 1);