NvBufferTransform() on NvDrmFB

NvDrmRenderer* r = NvDrmRenderer::createDrmRenderer(...);
NvDrmFB ui_fb[2];  
uint32_t w = 1920;
uint32_t h = 1080;
r->createDumbFB(w, h, DRM_FORMAT_ARGB8888, &ui_fb[0]);
r->createDumbFB(w, h, DRM_FORMAT_ARGB8888, &ui_fb[1]);
NvBufferTransformParams transform_params;
// Setup params...

int ret = NvBufferTransform(ui_fb[0].bo->bo_handle, ui_fb[1].bo->bo_handle, &params);

I.e. I would like to do a transform on frame buffers created by NvDrmRenderer::createDumbFB(). When running the above code I get the error:

dmabuf_fd 4000 mapped entry not found

I guess that the frame buffer must be mapped for DMA, but I cannot find any example on how to map a NvDrmFB and from other examples, such as;

ret = NvBufferCreateEx(&source_dmabuf_fd, &input_params);

it is not clear to me how to do this for a NvDrmFB. How do I setup NvDrmFB for use with NvBufferTransform()?

Hi,
This function calls are not supported. Please create NvBuffer, call NvBufferTransform(), and render NvBuffer.

How do I render the transformed NvBuffer to a plane?

I have been using:

NvDrmRenderer::setPlane(uint32_t pl_index, uint32_t fb_id, ...);

But with a NvBuffer I do not have a fb_id. I am using it to provide an overlay on top of other graphics and do not want to render to plane 0.

Looking at NvDrmRenderer.cpp I find the private method:

NvDrmRenderer::renderInternal(int fd){ ... }

and perhaps adding a public method:

NvDrmRenderer::render(int fd, int plane){ ... }

would facilitate this use-case?

Hi,
For rendering NvBuffer, we call the function:

                /* Queue render_fd to renderer */
                ctx->drm_renderer->enqueBuffer(render_fd);

You may have several NvBuffer for rendering, once all are queued in, you can dequeue for re-using the buffers:

render_fd = ctx->drm_renderer->dequeBuffer();

How do I get the NvBuffer to render to a plane other than plane 0 using this call?

Hi,
If you have multiple NvBuffer, please composite the buffers into single buffer by calling NvBufferComposite(), and do rendering.

I am using it to provide a transparent overlay. I am trying to use a NvBuffer with ARGB32 format and feed it into NvDrmRenderer::enqueBuffer(render_fd). However I can not get the transparency to work. Is it expected to work? Should I use some other buffer format?

i want to use drm for 4 cam display,composite is a method,but reference to the “video_dec_drm.cpp”,how can id use
“createDumbFB” api to render dmabuf_fd

Hi,
Please check source code of NvDrmRender in

/usr/src/jetson_multimedia_api/samples/common/classes/NvDrmRenderer.cpp

It is implemented through libdrm APIs, and there are different handling for video plane and ui plane. If the default implementation does not fit your usecase, please check the source code and see if you can customize it through libdrm APIs.

For applying transparency to a ABGR32 NvBuffer, you can modify alpha channel of the buffer through CUDA and then copy to another NvBuffer by calling NvBufferTransform, the effect will be applied to another buffer.