PVRTrace API

Hi, I’ve just received an Android device with a PowerVR GPU [Asus fonepad 7 (atom Z3530 + PowerVR 6430)], to be able test my work on all kind of devices, and … of course … it doesn’t work.



The first thing that doesn’t work is related to update (each frame) a small R8UI texture using glMapBuffer( GL_PIXEL_UNPACK_BUFFER), filling the memory located at the returned pointer, UnMap, then call glTexSubImage2D to transfer to the texture.

(it’s so basic that it works on all GPU/drivers from scratch, until now)



I’ve got different results (wrong, empty, pseudo-random) trying all of these :

// glBufferData( GL_PIXEL_UNPACK_BUFFER, u32_DataSize, NULL, GL_STATIC_DRAW );

glBufferData( GL_PIXEL_UNPACK_BUFFER, u32_DataSize, NULL, GL_STREAM_DRAW );

// pLock = glMapBufferRange( GL_PIXEL_UNPACK_BUFFER, 0, u32_DataSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT );

// pLock = glMapBufferRange( GL_PIXEL_UNPACK_BUFFER, 0, u32_DataSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT );

// pLock = glMapBufferRange( GL_PIXEL_UNPACK_BUFFER, 0, u32_DataSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT );

pLock = glMapBufferRange( GL_PIXEL_UNPACK_BUFFER, 0, u32_DataSize, GL_MAP_WRITE_BIT );

all of these working (with different speed) on Windows with AMD, NVidia, Intel GPU, and on Android with Intel, Adreno, Mali GPU



I took a look at the PVRTrace tool (my device is NOT rooted)(didn’t find a way to root it), and I would like to know if it’s possible to call (C++ code) some functions that Start and Stop the profile (from inside the APP) ? Because dumb results are not at the beginning of the timeline of my code. So I would like to be able to launch a capture when I want to do it.

Moreover, I’m using several dynamic textures (updated by the CPU), lots of big textures, so the amount of data of a frame capture is quite huge. (it takes several minutes to upload to the debugger using Adreno profiler with a compatible device)


The following steps should help you get a trace recording without having to root the device and let you start the recording from any point you wish:


  1. Install the PVRHub.apk (from the PowerVR SDK) to your device.
  2. In PVRHub tap the ‘Home’ button in the top left.
  3. Open the PVRTrace Record options screen.
  4. Tick the ‘Enable Network’ option.
  5. Tick ‘Network Wait’.
  6. Go back to the ‘Home’ screen to ensure settings are saved.
  7. Connect the device to a computer and from a terminal enter the command ‘adb forward tcp:54321 tcp:54321’.
  8. Start your application on the device. At this point your device should just have a blank screen while it searches for a connection.
  9. Start PVRTraceGUI on your computer.
  10. From the ‘Tools’ menu -> ‘Remote Controller…’
  11. Enter 127.0.0.1 and ‘Go’
  12. Click ‘Start Recording’ from the point you want to start writing out a trace file from.



    We’re still investigating the glMapBuffer issue. If you’re able to take a trace it may help us to reproduce the issue more quickly. You can send the trace file by creating a ticket on pvrsupport.imgtec.com/new-ticket with a link back to this discussion.



    Thanks,

    Paul.

Thank you very much for your help Paul :smiley:



To be able to instrument my code, since it’s pure C++ code (no Java at all), I add before loading the .so that uses OpenGL, 3 calls to dlopen to load PVRTrace.so, GLESv2_PVRTRACE.so, EGL_PVRTRACE.so



Now launching results in waiting to connect msg in the logcat



Connection with PVRtraceGUI running on my PC was successful

Hitting “Start recording” started recording (…)

but my APP crashed displaying this in the logcat without writing any file.



Would you have an idea of how to make it work till the end of the capture please ?



(now I go to sleep, I will try tomorrow to change the write path to set it to an already existing folder ?)

(I don’t understand why the file is noted as already existing as I can’t find it on my device)



12-09 23:45:30.695: I/PVRTrace(I)(4724): Opening trace file ‘/data/data/com.powervr.PVRHub/files/rec/com.example.fromdust.pvrt’ for recording.

12-09 23:45:30.695: I/PVRTrace(I)(4724): ‘/data/data/com.powervr.PVRHub/files/rec/com.example.fromdust.pvrt’ already exists so will be overwritten.

12-09 23:45:30.695: I/PVRTrace(I)(4724): Recorder Version: 3.4@3188797

12-09 23:45:30.695: I/PVRTrace(I)(4724): Start Recording

12-09 23:45:30.695: I/PVRTrace(I)(4724):

12-09 23:45:30.705: I/PVRTrace(I)(4724): Finished saving Render State

12-09 23:45:30.735: A/libc(4724): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 4754 (xample.fromdust)

12-09 23:45:30.795: I/DEBUG(241): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

12-09 23:45:30.795: I/DEBUG(241): Build fingerprint: 'asus/WW_K019/K019_2:4.4.2/KVT49L/WW_fonepad-11.10.1.38-20141020:user/release-keys’

12-09 23:45:30.795: I/DEBUG(241): Revision: '0’

12-09 23:45:30.795: I/DEBUG(241): pid: 4724, tid: 4754, name: xample.fromdust >>> com.example.fromdust <<<

12-09 23:45:30.795: I/DEBUG(241): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000

Could you double-check that you are loading the libraries in the same order as in this blog post: withimagination.imgtec.com/powervr-developers/pvrtrace-and-rootless-recording-on-android



If that doesn’t help, create a support ticket here and send your .apk, and link back to this conversation, then we can investigate why the trace is crashing.



Otherwise, it may be possible for you to capture a trace but without controlling the start point (it will just capture the entire application run).


  1. In PVRHub, tap the ‘Home’ button.
  2. Open the PVRTrace Record options screen.
  3. Untick the ‘Enable Network’ option.
  4. Run your application (logcat should indicate the trace is being captured here).
  5. Stop your application.
  6. Open PVRHub.
  7. Select “File manager”.
  8. Select “Copy to ‘Downloads’”.



    This folder should be accessible without root access, so you can use an ‘adb pull’ command to copy the trace file to your computer.



    Kind regards,

    Paul.

Hi Paul.

I finally found a way to produce a dump file. (setting the output location to my app storage folder)

Opening the file (700KB) in PVRTraceGUI gives me 44 Error “Shader failed to compile” in the Static Analysis window.

Then I used “Export data” => file.txt



[let’s say my APP has a Frame(0) which performs loading & init, then other frames perform rendering]



it seems to contain all GL calls from the first frame(0), beginning with



eglGetDisplay(0) ==> EGLDisplay(1) Error: EGL_SUCCESS

eglInitialize(EGLDisplay(1),NULL,NULL) ==> EGL_TRUE Error: EGL_SUCCESS

eglCreateWindowSurface(EGLDisplay(1),EGLConfig(15)



it’s ending with a sequence of code dealing with a texture creation (the code has not already draw something at this point, it’s still loading & initialisation)



glGenTextures(1,70001) Error: GL_NO_ERROR

glBindTexture(GL_TEXTURE_2D,70001) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_BASE_LEVEL,0) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_FUNC,GL_ALWAYS) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_MODE,GL_NONE) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_LOD,-1000) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LOD,1000) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAX_LEVEL,0) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_SWIZZLE_R,GL_RED) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_SWIZZLE_G,GL_GREEN) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_SWIZZLE_B,GL_BLUE) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_SWIZZLE_A,GL_ALPHA) Error: GL_NO_ERROR

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_R,GL_REPEAT) Error: GL_NO_ERROR

glTexStorage2D(GL_TEXTURE_2D,1,GL_RGBA8,256,256) Error: GL_NO_ERROR

glPixelStorei(GL_UNPACK_ALIGNMENT,4) Error: GL_NO_ERROR

glPixelStorei(GL_UNPACK_ROW_LENGTH,0) Error: GL_NO_ERROR

glPixelStorei(GL_UNPACK_SKIP_ROWS,0) Error: GL_NO_ERROR

glPixelStorei(GL_UNPACK_SKIP_PIXELS,0) Error: GL_NO_ERROR

[end of dump file]



which matches in my code with



mpo_GLInterface->BindTexture( GL_TEXTURE_2D, ui_Texture );

mpo_GLInterface->ReportError( “BindTexture” );

mpo_GLInterface->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);

mpo_GLInterface->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(_po_Header->GetMipNum() - 1));

mpo_GLInterface->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);

mpo_GLInterface->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

mpo_GLInterface->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);

mpo_GLInterface->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

mpo_GLInterface->ReportError( “TexParameteri” );

mpo_GLInterface->TexStorage2D( GL_TEXTURE_2D, _po_Header->GetMipNum(), iInternalFormat, _po_Header->GetWidth(), _po_Header->GetHeight() );

mpo_GLInterface->ReportError( “TexStorage2D” );



which should be followed by texture contents setup



mpo_GLInterface->TexSubImage2D(

GL_TEXTURE_2D,

j,

0,

0,

_po_Header->GetWidth() >> j,

_po_Header->GetHeight() >> j,

iComponentFormat,

iComponentType,

pData );

mpo_GLInterface->ReportError( “TexSubImage2D” );

}



mpo_GLInterface->BindTexture( GL_TEXTURE_2D, 0 );


Great, we’re making progress.



Could you please send up the PVRTrace file? If you can’t send it publically please create a support ticket on pvrsupport.imgtec.com/new-ticket, and attach the PVRTrace file. We can investigate further from there.

Hi Paul.

BTW I’ve just found some RootZenFone tool to root my device.

Tracing is easier (don’t have to add the Trace .so in the APK), but in my case it is still crashing during capture.