diff options
author | fukubayashi.akio <fukubayashi.akio@genetec.co.jp> | 2019-06-04 10:27:24 +0900 |
---|---|---|
committer | fukubayashi.akio <fukubayashi.akio@genetec.co.jp> | 2019-06-04 10:27:24 +0900 |
commit | 3354b93c4a12caa2a32d2309ec12e98755aed057 (patch) | |
tree | 61d7341b76f7af82ffb80b76c584051d7989f93c | |
parent | cedb66b0e7dceae01b8c3d10b56ebefa10aaf885 (diff) |
Add intel drmbuf
Signed-off-by: fukubayashi.akio <fukubayashi.akio@genetec.co.jp>
-rw-r--r-- | waltham-transmitter/waltham-renderer/waltham-renderer.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/waltham-transmitter/waltham-renderer/waltham-renderer.c b/waltham-transmitter/waltham-renderer/waltham-renderer.c index 12b8d84..47ba9ce 100644 --- a/waltham-transmitter/waltham-renderer/waltham-renderer.c +++ b/waltham-transmitter/waltham-renderer/waltham-renderer.c @@ -243,7 +243,53 @@ static void waltham_renderer_repaint_output(struct weston_transmitter_output *ou allocator = gst_dmabuf_allocator_new(); mem = gst_dmabuf_allocator_alloc(allocator, output->renderer->dmafd, stride * output->renderer->surface_height); + +#if defined(__x86_64__) + /* per-texture constants (Intel X-major tile layout) */ + uint tileW = 512; /* 32 * 16B OWord colomns */ + uint tileH = 8; /* 8 Rows */ + uint tilePitch = 8; /* Pitch = 8tiles */ + uint tileSize = tileW * tileH; + uint widthInTiles = (stride + tileW-1) / tileW; + + /* convert linear format to tile format */ + GstMapInfo infosrc, infodst; + GstMemory *memsrc = gst_memory_copy(mem, 0, stride * output->renderer->surface_height); + if (gst_memory_map(memsrc, &infosrc, GST_MAP_READ) == FALSE) + return; + + GstMemory *memdst = gst_allocator_alloc(NULL, stride * output->renderer->surface_height, NULL); + if (gst_memory_map(memdst, &infodst, GST_MAP_WRITE) == FALSE) { + gst_memory_unmap(memsrc, &infosrc); + return; + } + + int y = 0, x = 0; + uint tileX, tileY, inTileX, inTileY, idx; + for (y = 0; y < output->renderer->surface_height; y++) { + for (x = 0; x < stride; x++) { + // actual addressing + tileX = x / tileW; + tileY = y / tileH; + inTileX = x % tileW; + inTileY = y % tileH; + idx = (tileY * widthInTiles + tileX) * (tileSize) + + (inTileY * tileW) + (inTileX); + + if (idx >= stride * output->renderer->surface_height) { + fprintf(stderr, "index not in scope: idx=%d x=%d y=%d \n",idx, x, y); + break; + } + infodst.data[y * stride + x] = infosrc.data[idx]; + } + } + + gst_memory_unmap(memsrc, &infosrc); + gst_memory_unmap(memdst, &infodst); + gst_buffer_append_memory(gstbuffer, memdst); +#else gst_buffer_append_memory(gstbuffer, mem); +#endif gst_buffer_add_video_meta_full(gstbuffer, GST_VIDEO_FRAME_FLAG_NONE, GST_VIDEO_FORMAT_BGRx, |