c++ - glTexImage2D take long time in some PCs -


background:

  1. use dxva2 decode 4k 30fps video,then pass decoded frames directly opengl render.
  2. the framework gpu decode(dxva2) gpu render(opengl),without copy cpu.

problem:

  1. i found in pcs glteximage2d take long time(140ms).one pc's gpu intel hd 5500 + nivida gefoce 940m.
  2. but in pcs takes 16ms.one pc's gpu intel hd 5500 + amd r7 m260.
  3. all pcs have latest gpu driver updated.

sourcecode:

below dxva2 decode source code.

static int dxva2_retrieve_data(avcodeccontext *s, avframe *frame) {     lpdirect3dsurface9 surface =  (lpdirect3dsurface9)frame->data[3];     inputstream        *ist = (inputstream *)s->opaque;     dxva2context       *ctx = (dxva2context*)ist->hwaccel_ctx;     d3dsurface_desc    surfacedesc;     d3dlocked_rect     lockedrect;     hresult            hr;     int                ret;      idirect3dsurface9_getdesc(surface, &surfacedesc);      hr = idirect3dsurface9_lockrect(surface, &lockedrect, null, d3dlock_readonly);     if (failed(hr)) {         av_log(null, av_log_error, "unable lock dxva2 surface\n");         return averror_unknown;     }      picture->data[0] = (uint8_t*)lockedrect.pbits;     picture->data[1] = (uint8_t*)lockedrect.pbits + lockedrect.pitch * surfacedesc.height;     framewidth = frame->width;     frameheight = frame->height;     //glfinish() <---- commentee suggestion     dword start = gettickcount();//test time     draw();//opengl draw             //glfinish() <---- commentee suggestion     dword end = gettickcount();//test time     printf("draw time:%d\n", end - start);//test time     start = end - start;     picture->data[0] = nullptr;     picture->data[1] = nullptr;      idirect3dsurface9_unlockrect(surface);     return 0; fail:     return ret; } 

below draw function's code.

void draw() {     glclearcolor(1.0f, 1.0f, 1.0f, 1.0f);     glcleardepth(1.0f);     glclear(gl_color_buffer_bit);     glshademodel(gl_smooth);      glclearcolor(0.0, 255, 0.0, 0.0);     glclear(gl_color_buffer_bit);      gluseprogram(g_program);     glactivetexture(gl_texture0);     glbindtexture(gl_texture_2d, g_texture[0]);     glteximage2d(gl_texture_2d, 0, gl_red, framewidth, frameheight, 0, gl_red, gl_unsigned_byte, picture->data[0]);     gluniform1i(y, 0);      glactivetexture(gl_texture1);     glbindtexture(gl_texture_2d, g_texture[1]);     glteximage2d(gl_texture_2d, 0, gl_luminance_alpha, framewidth / 2, frameheight / 2, 0, gl_luminance_alpha, gl_unsigned_byte, picture->data[1]);     gluniform1i(uv, 1);      drawhorizontal();      glbindvertexarray(0);     gluseprogram(0);     glbindtexture(gl_texture_2d, 0); } 

question:

who can tell me why same code have different result @ different pcs? or give me advices?


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -