Tuesday, January 28, 2014
opengl es 2.0/opengl4 porting
ES 2.0 is a subset of GL 3/4. We know there is no geometry shader in ES. When I tried to porting my GL4 code to ES 2.0. I found another problem. There is no glVertexAttribIPointer or glVertexAttribLPointer to pass integer buffer to the vertex shaders. All the vertex buffers have to be passed with glVertexAttribPointer with different types. In my code, ivec3/ivec4 will not get correct values from glVertexAttribPointer. I have to use vec3/vec4 to get buffers. And then, cast them to int to use, like int(foo[0]). So far, it works fine, but I am not sure if there is any performance overhead while type casting from float to int, or there is any better solution.
understanding clang cross-compiing
I try to unify the dev environment to clang as I might work on IOS where gcc might not available. So far, clang works for most of my porting. Usually, libs work with gcc by default. clang can replace gcc in most of cases of native compiling, with some minor patches some times. However, crossing compie with clang is not trivial.
I dug into the android-cmake log to find the way of cross-compiling. The procedure seems that clang compile the source code to some bitcode, and then ndk/gcc/as compiles the bitcode to arm binary. clang can not work along to get arm binary.
Maybe I just use gcc for everything to save my live, as I might not work on IOS in a short time.
Update:
I try to manually compile arm binary on x86_64 with following commands:
clang -target armv7a-none-eabi -mcpu=cortex-a8 --sysroot=/opt/android-ndk/platforms/android-19/arch-arm/ -S hello.c
/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as -mfpu=neon -mfloat-abi=softfp -march=armv7-a -mfpu=vfpv3-d16 hello.s -o hello.o
/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld hello.o -o hello -L $ANDROID_NDK/platforms/android-19/arch-arm/usr/lib/ -lc -lm
I got an arm binary, but I can not test it, as my tablet does not allow binary to run natively.
I dug into the android-cmake log to find the way of cross-compiling. The procedure seems that clang compile the source code to some bitcode, and then ndk/gcc/as compiles the bitcode to arm binary. clang can not work along to get arm binary.
Maybe I just use gcc for everything to save my live, as I might not work on IOS in a short time.
Update:
I try to manually compile arm binary on x86_64 with following commands:
clang -target armv7a-none-eabi -mcpu=cortex-a8 --sysroot=/opt/android-ndk/platforms/android-19/arch-arm/ -S hello.c
/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as -mfpu=neon -mfloat-abi=softfp -march=armv7-a -mfpu=vfpv3-d16 hello.s -o hello.o
/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld hello.o -o hello -L $ANDROID_NDK/platforms/android-19/arch-arm/usr/lib/ -lc -lm
I got an arm binary, but I can not test it, as my tablet does not allow binary to run natively.
Sunday, January 26, 2014
porting freetype to android
UPDATE: 2.5.3 works with r9d clang4.4 out of box.
//=============Deprecated=======================
I need freetype as libRocket depends on it. The problem is freetype does not compile with clang3.3 in ndk-r9c.
I got these errors:
"/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/as" -mfpu=neon -mfloat-abi=softfp -march=armv7-a -mfpu=vfpv3-d16 -o CMakeFiles/freetype.dir/src/autofit/autofit.c.o /tmp/autofit-tnCFeA.s
/tmp/autofit-tnCFeA.s: Assembler messages:
/tmp/autofit-tnCFeA.s:1145: Error: width suffixes are invalid in ARM mode -- `add.w r5,r5,#0x8000'
4.8 and 4.6 work fine. However it works with x86_64 clang on my PC. I hold it will with clang in IOS.
Update
uncomment the following line in "freetype-2.5.2/devel/ftoption.h" and "freetype-2.5.2/include/config/ftoption.h",
#define FT_CONFIG_OPTION_NO_ASSEMBLER
clang will compile, both freetype and libRocket then. I have to test if there is any running risks.
//=============Deprecated=======================
I need freetype as libRocket depends on it. The problem is freetype does not compile with clang3.3 in ndk-r9c.
I got these errors:
"/opt/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/as" -mfpu=neon -mfloat-abi=softfp -march=armv7-a -mfpu=vfpv3-d16 -o CMakeFiles/freetype.dir/src/autofit/autofit.c.o /tmp/autofit-tnCFeA.s
/tmp/autofit-tnCFeA.s: Assembler messages:
/tmp/autofit-tnCFeA.s:1145: Error: width suffixes are invalid in ARM mode -- `add.w r5,r5,#0x8000'
4.8 and 4.6 work fine. However it works with x86_64 clang on my PC. I hold it will with clang in IOS.
Update
uncomment the following line in "freetype-2.5.2/devel/ftoption.h" and "freetype-2.5.2/include/config/ftoption.h",
#define FT_CONFIG_OPTION_NO_ASSEMBLER
clang will compile, both freetype and libRocket then. I have to test if there is any running risks.
Monday, January 20, 2014
archlinux on android/arm, ssh normal user chroot
I tried chroot to use archlinux on an android tablet. The normal user will get socket error while using ssh, but root works fine. In order to use ssh, add a grp and add your user into it.
groupadd -g 3003 aid_inet
gpasswd -a $USER aid_inet
groupadd -g 3003 aid_inet
gpasswd -a $USER aid_inet
Wednesday, January 15, 2014
c++ log libs
I am considering port a c++ log lib to android ndk. On linux and windows, I use log4cxx in my projects. It works fine. However porting it to android is not trivial. Then, I also searched for some other options.
boost.log
log4cxx, BSD, configure/make, not for android
log4cplus, BSD/MIT, cmake, android setting
google glog, BSD, configure/make, no android
muduo, BSD, cmake, not sure on android
pantheios, BSD, configure, not ready for android
The options might be log4cplus and muduo so far. I have not started trying. My second thought is it is worth porting, as it take time to port and learn the api.
I just leave a note here, and use dummy i/o for logging in my dummy project. Maybe I am back some time.
boost.log
log4cxx, BSD, configure/make, not for android
log4cplus, BSD/MIT, cmake, android setting
google glog, BSD, configure/make, no android
muduo, BSD, cmake, not sure on android
pantheios, BSD, configure, not ready for android
The options might be log4cplus and muduo so far. I have not started trying. My second thought is it is worth porting, as it take time to port and learn the api.
I just leave a note here, and use dummy i/o for logging in my dummy project. Maybe I am back some time.
Sunday, January 12, 2014
android emulator with opengl es 2.0
I googled around, and found a perfect emulator, "Genymotion". It emulates arm android on your windows/mac/linux. You can even install google play on it. I tried angry birds with nvidia 420m (integrated graphics card is slow), and it worked flawless. Then I tested my own arm projects, and they ran again. It is so far a perfect emulator.
PS
Before I found Genymotion, I tried stock emulator, which is said to support es 2.0 on x86 images. But, I can not got it work. Even if I could, it will be x86 with poor performance. I have to re-set up my projects. Android-x86 is another choice, but it is said there is no es 2.0.
PS
Before I found Genymotion, I tried stock emulator, which is said to support es 2.0 on x86 images. But, I can not got it work. Even if I could, it will be x86 with poor performance. I have to re-set up my projects. Android-x86 is another choice, but it is said there is no es 2.0.
Saturday, January 11, 2014
There exists no unified memory access for GPU so far.
I heard that, embedded systems like arm have only one memory pool. CPU and GPU share it. I though there might be some unified memory access there. But I am wrong. Arm (android/ios) GPUs work in the same way as integrated graphic cards in PC. RAM and VRAM are still separated logically. At least there is not such an API to let GPU access main memory directly. Data copying is still required.
AMD kaveri APU seems to break this rules on Jan 14 2014. Let us see.
AMD kaveri APU seems to break this rules on Jan 14 2014. Let us see.
Subscribe to:
Posts (Atom)