Your SlideShare is downloading. ×
0
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

OWF12/PAUG Conf Days Render script, sylvain galand, software engineer at genymobile

375

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
375
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Renderscript Sylvain Galand
  • 2. Renderscript ?Rendu ?Scripts ?Ni lun, ni lautre!
  • 3. Histoire 1/2Embellir Android !● Animations, fonds décran animés, animation de démarrage...Un outil contre la "diversification"● "Write once, run anywhere"● Tous les GPUs (extensions OpenGL)● Introduction en interne dans Android 2.xEvolution vers les calculs● Exécution optimale partout.● Publique avec Android 3.x
  • 4. Histoire 2/2Dépréciation de la partie rendu graphique● Annoncée avec Jelly Bean (Android 4.1)Une note dans la documentation● Deprecation Notice: Earlier versions of Renderscript included an experimental graphics engine component. This component is now deprecated as of Android 4.1 [...] If you have apps that render graphics with Renderscript, we highly recommend you convert your code to another Android graphics rendering option.Pourquoi ce changement ?● Les développeurs préfèrent OpenGL● OpenGL plus utilisé en interne aussi.
  • 5. Renderscript, cestUn outil pour les calculs● Ne remplace ni le SDK, ni le NDK.● Répond à des problématiques spécifiquesPortabilité● Android 3.0 +Performance● CPU (architecture, coeurs, instructions)● GPU, bientôt... (ARM Mali-T604 GPU)Simplicité dutilisation● Génération de code
  • 6. Au coeur de RS code.rsCode: script.rs● Langage C99● API pour le calculs APK bytecode RSCompilations via LLVM● Compilation en bytecode● Compilation (JIT) sur le client Client binaireExecution partout RS GPU● Runtime Renderscript● Coeurs CPU + GPU CPU CPU #1 #2
  • 7. IntégrationGénération de "glue code" Renderscript Java ScriptC_my_script.javamy_script.rs /res/raw/my_script.bctypedef struct My_Struct ScriptField_My_Struct.javaMy_Struct_t* my_struct; .bind_my_struct(...); .set_entier(int i)int entier; .get_entier();void my_function(); .invoke_my_function();
  • 8. Utilisation
  • 9. ExemplePar exemple, un exemple● Application de filtres sur des photos/images● Traitement du signal, calcul matriciel● (Rappel : Cette application vaut dans les 1 milliards)Un peu de code● Améliorons les temps de calcul grâce à Renderscript !
  • 10. Code : filter.rs#pragma version(1)#pragma rs java_package_name(com.genymobile.owf)rs_matrix3x3 filter;void init() { { rsMatrixLoadIdentity(&filter);}void root(const uchar4 *in, uchar4 *out) { float3 pixel = convert_float4(in[0]).rgb; pixel = rsMatrixMultiply(&filter, pixel); pixel = clamp(pixel, 0.f, 255.f); out->a = in->a; out->rgb = convert_uchar3(pixel);}
  • 11. // Création du script Code : Filter.javamRS = RenderScript.create(mContext);mScript = new ScriptC_filter(mRS, mContext.getResources(), R.raw.filter);// Allocation de la mémoire contenant le bitmapmInAllocation = Allocation.createFromBitmap( mRS, inputBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);// Allocation de la mémoire pour récupérer limage généréemOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType());// Mise en place des paramètresMatrix3f sepiaMatrix = new Matrix3f(mMatrix);mScript.set_filter(sepiaMatrix);// Appel du script (rsForEach)mScript.forEach_root(mInAllocation, mOutAllocation);// Copie du résultat dans le bitmap de sortiemOutAllocation.copyTo(outputBitmap);
  • 12. Résultats 1/2
  • 13. Résultats 2/2 Appareil (matériel) Java RS GainNexus S 960 ms 280 ms x 3.4(Exynos 1 GHz Cortex A8)Galaxy Nexus 360 ms 80 ms x 4.5(OMAP 4460 1,2 GHz dual-core)Samsung Galaxy S2 340 ms 48 ms x 7.0(1.2 GHz dual-core ARM Cortex-A9)Samsung Galaxy S3 325 ms 49 ms x 6.6(1.4 GHz quad-core ARM Cortex-A9)Motorola Xoom 210 ms 26 ms x 8.0(Tegra 2: 1GHz dual-core)Nexus 7 180 ms 22 ms x 8.2(Tegra 3: 1.3 GHz quad-core)Intel AZ210 - Intel Orange San Diego 293 ms 59 ms x 4.9(Intel Atom 1.6 Ghz Z2460 with HT - x86)
  • 14. Android 4.0.3+
  • 15. ConclusionEn bref● La solution pour les problèmes de performance sur les calculs● Intégration simplifiéePour la suite● Calculs dans le GPU ?● Meilleurs outils ?● Maintenance par Google ?
  • 16. Merci !Merci !● twitter : @sylvaingaland● google plus : http://slvn.fr/+● Code dispo sur : http://github.com/sgaland
  • 17. Questions ?@sylvaingaland http://slvn.fr/+

×