need help! radeonsi si_is_format_supported yv12 buffer support

ifquant <[email protected]>
Newsgroups gmane.comp.video.mesa3d.user
Message-ID <[email protected]>

Hi,all


i am trying support yuv12 buffer for (GFX9,GFX10,  vega64,vega56,rx580) 
when i modify code  gralloc_drm_pipe.c  and try to  alloc YUV12 buffer for app.
pm->screen->is_format_supported(pm->screen, YUV12,PIPE_TEXTURE_2D) return  not support,
could you give me some help or more information about radeonsi support yv12 buffer?


attachment  is my app test code.    it will try to pipe_alloc  a yv12 buffer, and copy yv12 data to it, and swapbuffer.
but i found radeonsi (mesa drivers for amd gpu) return not support yv12 format.


the detail radeonsi code is:


input:  usage = (PIPE_BIND_SHARED|PIPE_BIND_LINEAR|PIPE_BIND_SAMPLER_VIEW)
intput: format= 0x32315659 ;(PIPE_FORMAT_YV12)


static bool si_is_format_supported(struct pipe_screen *screen,
                   enum pipe_format format,
                   enum pipe_texture_target target,
                   unsigned sample_count,
                   unsigned storage_sample_count,
                   unsigned usage)
{
    //PIPE_BIND_SAMPLER_VIEW不支持
    si_is_sampler_format_supported {
      if chip_class >= GFX10( vega56=GFX9,rx580=GFX8,vega64=GFX9)
    gfx10_format_table.h {
/* PIPE_FORMAT_YV12 is not supported */
/* PIPE_FORMAT_YV16 is not supported */
/* PIPE_FORMAT_IYUV is not supported */
/* PIPE_FORMAT_NV12 is not supported */
/* PIPE_FORMAT_NV21 is not supported */
}
     
    si_translate_texformat//return not support PIPE_BIND_SAMPLER_VIEW
}
    //PIPE_BIND_SHARED 
    si_is_colorbuffer_format_supported {
si_translate_colorformat!=V_028C70_COLOR_INVALID
si_translate_colorswap!=~0U
//} return not support PIPE_BIND_SHARED 


}










| |
ifquant
|
|
[email protected]
|
签名由网易邮箱大师定制

_______________________________________________
mesa-users mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-users
Android.mk (text/plain, 300 B)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
    test.cpp
LOCAL_SHARED_LIBRARIES := \
    libcutils \
    libutils \
    libbinder \
    libui \
    libgui \
    libstagefright_foundation  
LOCAL_MODULE:= MyShowYUV  
LOCAL_MODULE_TAGS := tests  
include $(BUILD_EXECUTABLE)
test.cpp (text/plain, 5.6 KB)
#include <cutils/memory.h>  
  
#include <unistd.h>  
#include <utils/Log.h>  
  
#include <binder/IPCThreadState.h>  
#include <binder/ProcessState.h>  
#include <binder/IServiceManager.h>  
#include <media/stagefright/foundation/ADebug.h>  
#include <gui/Surface.h>  
#include <gui/SurfaceComposerClient.h>  
#include <gui/ISurfaceComposer.h>  
#include <ui/DisplayInfo.h>  
#include <android/native_window.h>  
#include <system/window.h>  
#include <ui/GraphicBufferMapper.h>  
//ANativeWindow 就是surface,对应surface.cpp里的code  
using namespace android;  
  
//将x规整为y的倍数,也就是将x按y对齐  
static int ALIGN(int x, int y) {  
    // y must be a power of 2.  
    return (x + y - 1) & ~(y - 1);  
}  
  
void render(  
        const void *data, size_t size, const sp<ANativeWindow> &nativeWindow,int width,int height) {  
    sp<ANativeWindow> mNativeWindow = nativeWindow;  
    int err;  
    int mCropWidth = width;  
    int mCropHeight = height;  
      
    int halFormat = HAL_PIXEL_FORMAT_YV12;//颜色空间  
    int bufWidth = (mCropWidth + 1) & ~1;//按2对齐  
    int bufHeight = (mCropHeight + 1) & ~1;  
      
    CHECK_EQ(0,  
            native_window_set_usage(  
            mNativeWindow.get(),  
            GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_OFTEN  
            | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP));  
  
    CHECK_EQ(0,  
            native_window_set_scaling_mode(  
            mNativeWindow.get(),  
            NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW));  
  
    // Width must be multiple of 32???  
    //很重要,配置宽高和和指定颜色空间yuv420  
    //如果这里不配置好,下面deque_buffer只能去申请一个默认宽高的图形缓冲区  
    CHECK_EQ(0, native_window_set_buffers_geometry(  
                mNativeWindow.get(),  
                bufWidth,  
                bufHeight,  
                halFormat));  
      
      
    ANativeWindowBuffer *buf;//描述buffer  
    //申请一块空闲的图形缓冲区  
    if ((err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(),  
            &buf)) != 0) {  
        ALOGW("Surface::dequeueBuffer returned error %d", err);  
        return;  
    }  
  
    GraphicBufferMapper &mapper = GraphicBufferMapper::get();  
  
    Rect bounds(mCropWidth, mCropHeight);  
  
    void *dst;  
    CHECK_EQ(0, mapper.lock(//用来锁定一个图形缓冲区并将缓冲区映射到用户进程  
                buf->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, bounds, &dst));//dst就指向图形缓冲区首地址  
  
    if (true){  
        size_t dst_y_size = buf->stride * buf->height;  
        size_t dst_c_stride = ALIGN(buf->stride / 2, 16);//1行v/u的大小  
        size_t dst_c_size = dst_c_stride * buf->height / 2;//u/v的大小  
          
        memcpy(dst, data, dst_y_size + dst_c_size*2);//将yuv数据copy到图形缓冲区  
    }  
  
    CHECK_EQ(0, mapper.unlock(buf->handle));  
  
    if ((err = mNativeWindow->queueBuffer(mNativeWindow.get(), buf,  
            -1)) != 0) {  
        ALOGW("Surface::queueBuffer returned error %d", err);  
    }  
    buf = NULL;  
}  
  
bool getYV12Data(const char *path,unsigned char * pYUVData,int size){  
    FILE *fp = fopen(path,"rb");  
    if(fp == NULL){  
        printf("read %s fail !!!!!!!!!!!!!!!!!!!\n",path);  
        return false;  
    }  
    fread(pYUVData,size,1,fp);  
    fclose(fp);  
    return true;  
}  
  
int main(void){  
    // set up the thread-pool  
    sp<ProcessState> proc(ProcessState::self());  
    ProcessState::self()->startThreadPool();  
      
    // create a client to surfaceflinger  
    sp<SurfaceComposerClient> client = new SurfaceComposerClient();  
    sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(  
            ISurfaceComposer::eDisplayIdMain));  
    DisplayInfo dinfo;  
    //获取屏幕的宽高等信息  
    status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);  
    printf("w=%d,h=%d,xdpi=%f,ydpi=%f,fps=%f,ds=%f\n",   
        dinfo.w, dinfo.h, dinfo.xdpi, dinfo.ydpi, dinfo.fps, dinfo.density);  
    if (status)  
        return -1;  
    //创建surface  
    sp<SurfaceControl> surfaceControl = client->createSurface(String8("testsurface"),  
            dinfo.w, dinfo.h, PIXEL_FORMAT_RGBA_8888, 0);  
              
/*************************get yuv data from file;****************************************/            
    printf("[%s][%d]\n",__FILE__,__LINE__);  
    int width,height;  
    width = 320;  
    height = 240;  
    int size = width * height * 3/2;  
    unsigned char *data = new unsigned char[size];  
    const char *path = "/data/akiyo_cif.yuv";  
    getYV12Data(path,data,size);//get yuv data from file;  
      
/*********************配置surface*******************************************************************/  
    SurfaceComposerClient::openGlobalTransaction();  
    surfaceControl->setLayer(100000);//设定Z坐标  
    surfaceControl->setPosition(100, 100);//以左上角为(0,0)设定显示位置  
    surfaceControl->setSize(width, height);//设定视频显示大小  
    SurfaceComposerClient::closeGlobalTransaction();  
    sp<Surface> surface = surfaceControl->getSurface();  
    printf("[%s][%d]\n",__FILE__,__LINE__);  
      
/**********************显示yuv数据******************************************************************/     
    render(data,size,surface,width,height);  
    printf("[%s][%d]\n",__FILE__,__LINE__);  
      
    IPCThreadState::self()->joinThreadPool();//可以保证画面一直显示,否则瞬间消失  
    IPCThreadState::self()->stopProcess();  
    return 0;  
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.