summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2014-09-10 13:17:13 +0200
committerIlia Mirkin <imirkin@alum.mit.edu>2014-09-11 23:17:52 -0400
commitf6afed7076a6ef446dbec7cb10c8f8c60efafccd (patch)
tree7db2c8e4e7c2f8d5fe1adf1026f26637208931f1 /src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
parent1187dbdd104b08ae2d465e87bfb68bc1550d224c (diff)
nouveau: re-allocate bo's on overflow
The BSP bo might be too small to contain all of the bsp data, bump its size on overflow. Also bump inter_bo when this happens, it might be too small otherwise. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Cc: "10.2 10.3" <mesa-stable@lists.freedesktop.org>
Diffstat (limited to 'src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c')
-rw-r--r--src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c b/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
index 40696fa779f..9139bc1c911 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c
@@ -42,8 +42,8 @@ nvc0_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
struct nouveau_pushbuf *push = dec->pushbuf[0];
enum pipe_video_format codec = u_reduce_video_profile(dec->base.profile);
uint32_t bsp_addr, comm_addr, inter_addr;
- uint32_t slice_size, bucket_size, ring_size;
- uint32_t caps;
+ uint32_t slice_size, bucket_size, ring_size, bsp_size;
+ uint32_t caps, i;
int ret;
struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH];
struct nouveau_bo *inter_bo = dec->inter_bo[comm_seq & 1];
@@ -65,6 +65,49 @@ nvc0_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
fence_extra = 4;
#endif
+ bsp_size = NOUVEAU_VP3_BSP_RESERVED_SIZE;
+ for (i = 0; i < num_buffers; i++)
+ bsp_size += num_bytes[i];
+ bsp_size += 256; /* the 4 end markers */
+
+ if (!bsp_bo || bsp_size > bsp_bo->size) {
+ union nouveau_bo_config cfg;
+ struct nouveau_bo *tmp_bo = NULL;
+
+ cfg.nvc0.tile_mode = 0x10;
+ cfg.nvc0.memtype = 0xfe;
+
+ /* round up to the nearest mb */
+ bsp_size += (1 << 20) - 1;
+ bsp_size &= ~((1 << 20) - 1);
+
+ ret = nouveau_bo_new(dec->bitplane_bo->device, NOUVEAU_BO_VRAM, 0, bsp_size, &cfg, &tmp_bo);
+ if (ret) {
+ debug_printf("reallocating bsp %u -> %u failed with %i\n",
+ bsp_bo ? (unsigned)bsp_bo->size : 0, bsp_size, ret);
+ return -1;
+ }
+ nouveau_bo_ref(NULL, &bsp_bo);
+ bo_refs[0].bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH] = bsp_bo = tmp_bo;
+ }
+
+ if (!inter_bo || bsp_bo->size * 4 > inter_bo->size) {
+ union nouveau_bo_config cfg;
+ struct nouveau_bo *tmp_bo = NULL;
+
+ cfg.nvc0.tile_mode = 0x10;
+ cfg.nvc0.memtype = 0xfe;
+
+ ret = nouveau_bo_new(dec->bitplane_bo->device, NOUVEAU_BO_VRAM, 0, bsp_bo->size * 4, &cfg, &tmp_bo);
+ if (ret) {
+ debug_printf("reallocating inter %u -> %u failed with %i\n",
+ inter_bo ? (unsigned)inter_bo->size : 0, (unsigned)bsp_bo->size * 4, ret);
+ return -1;
+ }
+ nouveau_bo_ref(NULL, &inter_bo);
+ bo_refs[1].bo = dec->inter_bo[comm_seq & 1] = inter_bo = tmp_bo;
+ }
+
ret = nouveau_bo_map(bsp_bo, NOUVEAU_BO_WR, dec->client);
if (ret) {
debug_printf("map failed: %i %s\n", ret, strerror(-ret));