summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2009-07-14 14:05:13 -0400
committerAlex Deucher <alexdeucher@gmail.com>2009-07-14 14:05:13 -0400
commit5473eeeb45468fd200fec49a8506281628a5e4b5 (patch)
tree03fe2eb2dc8d6c60f229855f57567c11108bdb19
parent0485f27bc3d75cb6ab320e8164dbe6ea2713c78e (diff)
R3/4/5xx: only upload the bicubic texture once
Upload the bicubic texture once during textured video init rather than once per frame. Suggested by Michel Daenzer on IRC.
-rw-r--r--src/radeon.h4
-rw-r--r--src/radeon_textured_video.c89
-rw-r--r--src/radeon_textured_videofuncs.c12
-rw-r--r--src/radeon_video.c4
-rw-r--r--src/radeon_video.h3
5 files changed, 66 insertions, 46 deletions
diff --git a/src/radeon.h b/src/radeon.h
index ad9a9088..3c62fd93 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -999,6 +999,10 @@ typedef struct {
Bool cs;
#endif
+ /* Xv bicubic filtering */
+ struct radeon_bo *bicubic_bo;
+ void *bicubic_memory;
+ int bicubic_offset;
} RADEONInfoRec, *RADEONInfoPtr;
#define RADEONWaitForFifo(pScrn, entries) \
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index 617f359f..d034c336 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -332,16 +332,10 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
}
/* Bicubic filter loading */
- if (pPriv->bicubic_memory == NULL && pPriv->bicubic_enabled) {
- pPriv->bicubic_offset = radeon_legacy_allocate_memory(pScrn,
- &pPriv->bicubic_memory,
- sizeof(bicubic_tex_512), 64);
- pPriv->bicubic_src_offset = pPriv->bicubic_offset;
- if (pPriv->bicubic_offset == 0)
- pPriv->bicubic_enabled = FALSE;
-
- if (info->cs)
- pPriv->bicubic_bo = pPriv->bicubic_memory;
+ if (pPriv->bicubic_enabled) {
+ if (info->bicubic_offset == 0)
+ pPriv->bicubic_enabled = FALSE;
+ pPriv->bicubic_src_offset = info->bicubic_offset;
}
if (pDraw->type == DRAWABLE_WINDOW)
@@ -375,9 +369,9 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
int ret;
radeon_bo_wait(pPriv->src_bo);
ret = radeon_bo_map(pPriv->src_bo, 1);
- if (ret)
+ if (ret)
return BadAlloc;
-
+
pPriv->src_addr = pPriv->src_bo->ptr;
} else {
pPriv->src_addr = (uint8_t *)(info->FB + pPriv->video_offset);
@@ -448,27 +442,6 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
break;
}
- /* Upload bicubic filter tex */
- if (pPriv->bicubic_enabled) {
- if (info->ChipFamily < CHIP_FAMILY_R600) {
- uint8_t *bicubic_addr;
- int ret;
- if (info->cs) {
- radeon_bo_wait(pPriv->bicubic_bo);
- ret = radeon_bo_map(pPriv->bicubic_bo, 1);
- if (ret)
- return BadAlloc;
-
- bicubic_addr = pPriv->bicubic_bo->ptr;
- } else
- bicubic_addr = (uint8_t *)(info->FB + pPriv->bicubic_offset);
-
- RADEONCopyData(pScrn, (uint8_t *)bicubic_tex_512, bicubic_addr, 1024, 1024, 1, 512, 2);
- if (info->cs)
- radeon_bo_unmap(pPriv->bicubic_bo);
- }
- }
-
/* update cliplist */
if (!REGION_EQUAL(pScrn->pScreen, &pPriv->clip, clipBoxes)) {
REGION_COPY(pScrn->pScreen, &pPriv->clip, clipBoxes);
@@ -698,6 +671,53 @@ RADEONSetTexPortAttribute(ScrnInfoPtr pScrn,
return Success;
}
+static Bool radeon_load_bicubic_texture(ScrnInfoPtr pScrn)
+{
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+
+ /* Bicubic filter loading */
+ info->bicubic_offset = radeon_legacy_allocate_memory(pScrn,
+ &info->bicubic_memory,
+ sizeof(bicubic_tex_512), 64);
+ if (info->bicubic_offset == 0)
+ return FALSE;
+
+ if (info->cs)
+ info->bicubic_bo = info->bicubic_memory;
+
+ /* Upload bicubic filter tex */
+ if (info->ChipFamily < CHIP_FAMILY_R600) {
+ uint8_t *bicubic_addr;
+ int ret;
+ if (info->cs) {
+ radeon_bo_wait(info->bicubic_bo);
+ ret = radeon_bo_map(info->bicubic_bo, 1);
+ if (ret)
+ return FALSE;
+
+ bicubic_addr = info->bicubic_bo->ptr;
+ } else
+ bicubic_addr = (uint8_t *)(info->FB + info->bicubic_offset);
+
+ RADEONCopyData(pScrn, (uint8_t *)bicubic_tex_512, bicubic_addr, 1024, 1024, 1, 512, 2);
+ if (info->cs)
+ radeon_bo_unmap(info->bicubic_bo);
+ }
+ return TRUE;
+}
+
+/* XXX */
+static void radeon_unload_bicubic_texture(ScrnInfoPtr pScrn)
+{
+ RADEONInfoPtr info = RADEONPTR(pScrn);
+
+ if (info->bicubic_memory != NULL) {
+ radeon_legacy_free_memory(pScrn, info->bicubic_memory);
+ info->bicubic_memory = NULL;
+ }
+
+}
+
XF86VideoAdaptorPtr
RADEONSetupImageTexturedVideo(ScreenPtr pScreen)
{
@@ -795,6 +815,9 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen)
adapt->pPortPrivates[i].ptr = (pointer) (pPriv);
}
+ if (IS_R500_3D || IS_R300_3D)
+ radeon_load_bicubic_texture(pScrn);
+
return adapt;
}
diff --git a/src/radeon_textured_videofuncs.c b/src/radeon_textured_videofuncs.c
index 280a7990..95db7d5a 100644
--- a/src/radeon_textured_videofuncs.c
+++ b/src/radeon_textured_videofuncs.c
@@ -110,7 +110,7 @@ FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv
radeon_cs_space_add_persistent_bo(info->cs, pPriv->src_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
if (pPriv->bicubic_enabled)
- radeon_cs_space_add_persistent_bo(info->cs, pPriv->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ radeon_cs_space_add_persistent_bo(info->cs, info->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
driver_priv = exaGetPixmapDriverPrivate(pPixmap);
radeon_cs_space_add_persistent_bo(info->cs, driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
@@ -499,7 +499,7 @@ FUNC_NAME(R200DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
radeon_cs_space_add_persistent_bo(info->cs, pPriv->src_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
if (pPriv->bicubic_enabled)
- radeon_cs_space_add_persistent_bo(info->cs, pPriv->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ radeon_cs_space_add_persistent_bo(info->cs, info->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
driver_priv = exaGetPixmapDriverPrivate(pPixmap);
radeon_cs_space_add_persistent_bo(info->cs, driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
@@ -1041,7 +1041,7 @@ FUNC_NAME(R300DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
radeon_cs_space_add_persistent_bo(info->cs, pPriv->src_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
if (pPriv->bicubic_enabled)
- radeon_cs_space_add_persistent_bo(info->cs, pPriv->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ radeon_cs_space_add_persistent_bo(info->cs, info->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
driver_priv = exaGetPixmapDriverPrivate(pPixmap);
radeon_cs_space_add_persistent_bo(info->cs, driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
@@ -1227,7 +1227,7 @@ FUNC_NAME(R300DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
OUT_ACCEL_REG(R300_TX_FORMAT0_1, txformat0);
OUT_ACCEL_REG(R300_TX_FORMAT1_1, txformat1);
OUT_ACCEL_REG(R300_TX_FORMAT2_1, txpitch);
- OUT_TEXTURE_REG(R300_TX_OFFSET_1, bicubic_offset, pPriv->bicubic_bo);
+ OUT_TEXTURE_REG(R300_TX_OFFSET_1, bicubic_offset, info->bicubic_bo);
FINISH_ACCEL();
/* Enable tex 1 */
@@ -2492,7 +2492,7 @@ FUNC_NAME(R500DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
radeon_cs_space_add_persistent_bo(info->cs, pPriv->src_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
if (pPriv->bicubic_enabled)
- radeon_cs_space_add_persistent_bo(info->cs, pPriv->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
+ radeon_cs_space_add_persistent_bo(info->cs, info->bicubic_bo, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0);
driver_priv = exaGetPixmapDriverPrivate(pPixmap);
radeon_cs_space_add_persistent_bo(info->cs, driver_priv->bo, 0, RADEON_GEM_DOMAIN_VRAM);
@@ -2681,7 +2681,7 @@ FUNC_NAME(R500DisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
OUT_ACCEL_REG(R300_TX_FORMAT0_1, txformat0);
OUT_ACCEL_REG(R300_TX_FORMAT1_1, txformat1);
OUT_ACCEL_REG(R300_TX_FORMAT2_1, txpitch);
- OUT_TEXTURE_REG(R300_TX_OFFSET_1, bicubic_offset, pPriv->bicubic_bo);
+ OUT_TEXTURE_REG(R300_TX_OFFSET_1, bicubic_offset, info->bicubic_bo);
FINISH_ACCEL();
/* Enable tex 1 */
diff --git a/src/radeon_video.c b/src/radeon_video.c
index 58b9d46a..f1fe72b2 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -1648,10 +1648,6 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
if (pPriv->textured) {
if (cleanup) {
- if (pPriv->bicubic_memory != NULL) {
- radeon_legacy_free_memory(pScrn, pPriv->bicubic_memory);
- pPriv->bicubic_memory = NULL;
- }
if (pPriv->video_memory != NULL) {
radeon_legacy_free_memory(pScrn, pPriv->video_memory);
pPriv->video_memory = NULL;
diff --git a/src/radeon_video.h b/src/radeon_video.h
index aeb6441f..989942c5 100644
--- a/src/radeon_video.h
+++ b/src/radeon_video.h
@@ -94,8 +94,6 @@ typedef struct {
int planev_offset;
/* bicubic filtering */
- void *bicubic_memory;
- int bicubic_offset;
Bool bicubic_enabled;
uint32_t bicubic_src_offset;
int bicubic_state;
@@ -122,7 +120,6 @@ typedef struct {
int vsync;
struct radeon_bo *src_bo;
- struct radeon_bo *bicubic_bo;
} RADEONPortPrivRec, *RADEONPortPrivPtr;
/* Reference color space transform data */