SlideShare a Scribd company logo
High Performance
Graphics and Compute
OpenGLES and RenderScript

Arvind Devaraj
Agenda
●

Introduction : Graphics terms

●

Graphics on GPU

●

OpenGL Android Graphics

●

Graphics Pipeline

●

Shaders

●

High Performance Compute on GPU

●

RenderScript
Graphics Terms
●

●

●

OpenGLES : Graphics API for doing 3D operations on GPU /
CPU
Primitives : lines, point, triangles
Texture : make the image
realistic by adding bitmap
CPU versus GPU
●

CPU
–

good at executing sequential code

–

●

Handles branches well

–

Same code, multiple data

GPU

–

Parallelism (ideal for image rendering)
Graphics on GPU
Graphics Pipeline
OpenGLES Android Graphics
●

Graphics Library for 3D
Android Graphics Classes
GLSurfaceView
GLSurfaceView.Renderer

View

➢

- connects SurfaceView to OpenGLES library

Renderer - responsible for making OpenGL calls to render a frame

➢
GLSurfaceView
    

    GLSurfaceView view = new GLSurfaceView(this);

    view.setRenderer(new SquareRenderer());
GLSurfaceView.Renderer

●

The renderer is responsible for making OpenGL calls to
render a frame.
–

onDrawFrame() responsible for drawing the
current frame

–

OnSurfaceChanged() called when surface size
changes

–

OnSurfaceCreated() called when surface is
created
GLSurfaceView.Renderer
public class SquareRenderer implements GLSurfaceView.Renderer {
    public void onSurfaceCreated(GL10 unused, EGLConfig config) {
   
        Code when surface is created
    }
    public void onDrawFrame(GL10 unused) {
Code for drawing the frame ( Square )

    }
    public void onSurfaceChanged(GL10 unused, int width, int height)   {
        When surface is changed (rotated etc)
    }
}
Drawing a Square
draw() {
 

float coords[] = { ....     };
vertex 'buffer' created with the coords
glVertexPointer(buffer) :

}

glDrawArrays(TRIANGLE_STRIP ...);
,
Drawing a Square
draw() {
 

float squareCoords[] = { ....     };
ByteBuffer vbb = ....
  squareVB = vbb.asFloatBuffer(); 
 
squareVB.put(squareCoords); 
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);

}

gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP 0, vertices.length / 3);
,

Full code:
https://github.com/arvind-devaraj/androidopengles/blob/master/3_SquareRenderer/src/com/example/graphics1/Square.java
OpenGL Rendering Pipeline
Shaders
●

Shaders are programs that execute on the GPU

●

Shader programs operate on
–

Each vertex

–

Each pixel
Shader Programs
• Vertex Shader – operates on each vertex
• Fragment Shader – operates on each pixel
• Shaders are compiled and linked ( like any program )
• Executable is sent to the GPU
High performance graphics and computation - OpenGL ES and RenderScript
Vertex Shader
attribute vec4 vertexPosition;
void main(){
     gl_Position = vertexPosition;
 

}

Fragment Shader
precision mediump float;
void main(){
  
 gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0);
}
High performance graphics and computation - OpenGL ES and RenderScript
CPU – GPU communication
GPU for General Programs
●

Graphics is accelerated by the GPU

●

Can GPU accelerate other programs ?
–

●

e.g. Matrix multiply, encryption

OpenCL, CUDA, Renderscript are API
–

used for general purpose GPU
RenderScript
●

A high level API to access GPU

●

Provides high performance Compute

●

Provides uniform API across multiple SoC

●

Alternative is NDK (but NDK is platform
specific)
RenderScript – Use cases
●

What functions can be accelerated
–

Graphics

–

Image Processing

–

Encryption

–

Signal processing

–

Mathematical functions
RenderScript - Flow
RenderScript – CPU side
Class Hello extends Activity {
Allocation input;
Allocation output;
RenderScript rs = new RenderScript()
ScriptC_func script = new ScriptC_func(...)
}

script.forEach_root(input, output)
RenderScript – GPU side
Hello.rs
void root (char *in , char *out) {
*out = *in * 2
}
RenderScript
●

●

Advantages : Compared to NDK, provides an easy device
agnostic way to accelerate performance on GPU
Disadvantages : C99 standard, debugging is restricted
Renderscipt - Summary
●

Renderscript is an API to access GPU

●

Used for High Performance

●

High Performance Compute / Graphics

●

Compute, Math , FFT, convolution, Signal processing

●

Support Graphics – but not a replacement for OpenGL

●

Works on all GPUs ( if supported by SoC ) otherwise on CPU

●

●

More Related Content

PPTX
RenderScript
PDF
Android High performance in GPU using opengles and renderscript
PPTX
Android RenderScript
PDF
OpenGLES Android Graphics
PPTX
What is OpenGL ?
PPTX
Migrating from OpenGL to Vulkan
PPTX
OpenGL 4.5 Update for NVIDIA GPUs
PDF
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...
RenderScript
Android High performance in GPU using opengles and renderscript
Android RenderScript
OpenGLES Android Graphics
What is OpenGL ?
Migrating from OpenGL to Vulkan
OpenGL 4.5 Update for NVIDIA GPUs
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...

What's hot (20)

PPTX
Sig13 ce future_gfx
PPTX
Qt Qml
PDF
PT-4053, Advanced OpenCL - Debugging and Profiling Using AMD CodeXL, by Uri S...
PDF
PSGL (PlayStation Graphics Library)
PDF
QtQuick Day 4
PDF
Qt and QML performance tips & tricks for Qt 4.7
PDF
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
PDF
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
PPTX
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
PDF
PL-4042, Wholly Graal: Accelerating GPU offload for Java/Sumatra using the Op...
PDF
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
PDF
Basics of Model/View Qt programming
 
PDF
Qt on Real Time Operating Systems
PDF
Best Practices in Qt Quick/QML - Part 3
 
PDF
mloc.js 2014 - JavaScript and the browser as a platform for game development
PDF
Design Summit - Automate roadmap - Madhu Kanoor
PDF
Qt Internationalization
 
PPTX
Hello, QML
PDF
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
Sig13 ce future_gfx
Qt Qml
PT-4053, Advanced OpenCL - Debugging and Profiling Using AMD CodeXL, by Uri S...
PSGL (PlayStation Graphics Library)
QtQuick Day 4
Qt and QML performance tips & tricks for Qt 4.7
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
WT-4072, Rendering Web Content at 60fps, by Vangelis Kokkevis, Antoine Labour...
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
PL-4042, Wholly Graal: Accelerating GPU offload for Java/Sumatra using the Op...
WT-4064, Build Rich Applications with HTML5 and WebGL, by Tony Parisi
Basics of Model/View Qt programming
 
Qt on Real Time Operating Systems
Best Practices in Qt Quick/QML - Part 3
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
Design Summit - Automate roadmap - Madhu Kanoor
Qt Internationalization
 
Hello, QML
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
Ad

Similar to High performance graphics and computation - OpenGL ES and RenderScript (20)

PPT
Advanced Graphics Workshop - GFX2011
PDF
Gpu Programming With GPUImage and Metal
PPT
Hardware Shaders
PDF
GPU Programming: Chicago CocoaConf 2015
PPTX
Getting started with open gl es 2
PDF
GPU Programming: CocoaConf Atlanta
PDF
GPU Programming 360iDev
PDF
Computer Graphics - Lecture 01 - 3D Programming I
PPT
OpenGL ES based UI Development on TI Platforms
PPTX
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
PPT
NVIDIA CUDA
PPT
Programmable Piplelines
PPTX
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
PDF
PDF
The Explanation the Pipeline design strategy.pdf
PDF
GPU - how can we use it?
PPTX
GFX Part 7 - Introduction to Rendering Targets in OpenGL ES
PDF
Shaders in Unity
PPTX
Cg shaders with Unity3D
PDF
Embedded Graphics Drivers in Mesa (ELCE 2019)
Advanced Graphics Workshop - GFX2011
Gpu Programming With GPUImage and Metal
Hardware Shaders
GPU Programming: Chicago CocoaConf 2015
Getting started with open gl es 2
GPU Programming: CocoaConf Atlanta
GPU Programming 360iDev
Computer Graphics - Lecture 01 - 3D Programming I
OpenGL ES based UI Development on TI Platforms
GFX Part 1 - Introduction to GPU HW and OpenGL ES specifications
NVIDIA CUDA
Programmable Piplelines
[Unite Seoul 2019] Mali GPU Architecture and Mobile Studio
The Explanation the Pipeline design strategy.pdf
GPU - how can we use it?
GFX Part 7 - Introduction to Rendering Targets in OpenGL ES
Shaders in Unity
Cg shaders with Unity3D
Embedded Graphics Drivers in Mesa (ELCE 2019)
Ad

More from BlrDroid (20)

PDF
Post I/O 2014 Meetup : Google I/O '14 recap- Amrit Sanjeev
PDF
June 2014 - Android wear
PDF
June 2014 - IPC in android
PDF
June 2014 - Building Rabbit MQ based chat on Android
PDF
Challenges in writing roboelectric tests
PDF
How to leverage cloud for QA process
PDF
Usability Testing Made Easy
PDF
How Mobile Developers Could Leverage On Big Data and Data Points to understan...
PDF
Internals of AsyncTask
PDF
Increasing downloads, ratings and revenues
PDF
March 2014 Meetup - Nokia X Tech Session
PPTX
March 2014 Meetup Baug Android and Google App Engine
PDF
Android Security - Common Security Pitfalls in Android Applications
PPTX
Dexetra Labs - Building Apps that can get featured
PDF
July 2013 Meetup : Introduction To App Publish - Ujjwal Kabra
PPTX
July2013 Meetup : App Store Optimization - Shankar soma
PDF
June2013 Meetup : Activity Recognition API - Walkmeter - Michal Depa
PDF
June2013 Meetup : In-App Billing by Soham & Senthil
PDF
June2013 Meetup : IO13 Deep Dive-Location_api_AmritSanjeev
PPTX
IO13 Recap
Post I/O 2014 Meetup : Google I/O '14 recap- Amrit Sanjeev
June 2014 - Android wear
June 2014 - IPC in android
June 2014 - Building Rabbit MQ based chat on Android
Challenges in writing roboelectric tests
How to leverage cloud for QA process
Usability Testing Made Easy
How Mobile Developers Could Leverage On Big Data and Data Points to understan...
Internals of AsyncTask
Increasing downloads, ratings and revenues
March 2014 Meetup - Nokia X Tech Session
March 2014 Meetup Baug Android and Google App Engine
Android Security - Common Security Pitfalls in Android Applications
Dexetra Labs - Building Apps that can get featured
July 2013 Meetup : Introduction To App Publish - Ujjwal Kabra
July2013 Meetup : App Store Optimization - Shankar soma
June2013 Meetup : Activity Recognition API - Walkmeter - Michal Depa
June2013 Meetup : In-App Billing by Soham & Senthil
June2013 Meetup : IO13 Deep Dive-Location_api_AmritSanjeev
IO13 Recap

Recently uploaded (20)

PPTX
A Presentation on Artificial Intelligence
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Modernizing your data center with Dell and AMD
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
A Presentation on Artificial Intelligence
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
The AUB Centre for AI in Media Proposal.docx
Unlocking AI with Model Context Protocol (MCP)
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Monthly Chronicles - July 2025
Review of recent advances in non-invasive hemoglobin estimation
Understanding_Digital_Forensics_Presentation.pptx
Electronic commerce courselecture one. Pdf
Modernizing your data center with Dell and AMD
“AI and Expert System Decision Support & Business Intelligence Systems”
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

High performance graphics and computation - OpenGL ES and RenderScript

  • 1. High Performance Graphics and Compute OpenGLES and RenderScript Arvind Devaraj
  • 2. Agenda ● Introduction : Graphics terms ● Graphics on GPU ● OpenGL Android Graphics ● Graphics Pipeline ● Shaders ● High Performance Compute on GPU ● RenderScript
  • 3. Graphics Terms ● ● ● OpenGLES : Graphics API for doing 3D operations on GPU / CPU Primitives : lines, point, triangles Texture : make the image realistic by adding bitmap
  • 4. CPU versus GPU ● CPU – good at executing sequential code – ● Handles branches well – Same code, multiple data GPU – Parallelism (ideal for image rendering)
  • 8. Android Graphics Classes GLSurfaceView GLSurfaceView.Renderer View ➢ - connects SurfaceView to OpenGLES library Renderer - responsible for making OpenGL calls to render a frame ➢
  • 9. GLSurfaceView          GLSurfaceView view = new GLSurfaceView(this);     view.setRenderer(new SquareRenderer());
  • 10. GLSurfaceView.Renderer ● The renderer is responsible for making OpenGL calls to render a frame. – onDrawFrame() responsible for drawing the current frame – OnSurfaceChanged() called when surface size changes – OnSurfaceCreated() called when surface is created
  • 11. GLSurfaceView.Renderer public class SquareRenderer implements GLSurfaceView.Renderer {     public void onSurfaceCreated(GL10 unused, EGLConfig config) {             Code when surface is created     }     public void onDrawFrame(GL10 unused) { Code for drawing the frame ( Square )     }     public void onSurfaceChanged(GL10 unused, int width, int height)   {         When surface is changed (rotated etc)     } }
  • 12. Drawing a Square draw() {   float coords[] = { ....     }; vertex 'buffer' created with the coords glVertexPointer(buffer) : } glDrawArrays(TRIANGLE_STRIP ...); ,
  • 13. Drawing a Square draw() {   float squareCoords[] = { ....     }; ByteBuffer vbb = ....   squareVB = vbb.asFloatBuffer();    squareVB.put(squareCoords);  gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer); } gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP 0, vertices.length / 3); , Full code: https://github.com/arvind-devaraj/androidopengles/blob/master/3_SquareRenderer/src/com/example/graphics1/Square.java
  • 15. Shaders ● Shaders are programs that execute on the GPU ● Shader programs operate on – Each vertex – Each pixel
  • 16. Shader Programs • Vertex Shader – operates on each vertex • Fragment Shader – operates on each pixel • Shaders are compiled and linked ( like any program ) • Executable is sent to the GPU
  • 18. Vertex Shader attribute vec4 vertexPosition; void main(){      gl_Position = vertexPosition;   } Fragment Shader precision mediump float; void main(){     gl_FragColor = vec4(0.5, 0.5, 0.5, 1.0); }
  • 20. CPU – GPU communication
  • 21. GPU for General Programs ● Graphics is accelerated by the GPU ● Can GPU accelerate other programs ? – ● e.g. Matrix multiply, encryption OpenCL, CUDA, Renderscript are API – used for general purpose GPU
  • 22. RenderScript ● A high level API to access GPU ● Provides high performance Compute ● Provides uniform API across multiple SoC ● Alternative is NDK (but NDK is platform specific)
  • 23. RenderScript – Use cases ● What functions can be accelerated – Graphics – Image Processing – Encryption – Signal processing – Mathematical functions
  • 25. RenderScript – CPU side Class Hello extends Activity { Allocation input; Allocation output; RenderScript rs = new RenderScript() ScriptC_func script = new ScriptC_func(...) } script.forEach_root(input, output)
  • 26. RenderScript – GPU side Hello.rs void root (char *in , char *out) { *out = *in * 2 }
  • 27. RenderScript ● ● Advantages : Compared to NDK, provides an easy device agnostic way to accelerate performance on GPU Disadvantages : C99 standard, debugging is restricted
  • 28. Renderscipt - Summary ● Renderscript is an API to access GPU ● Used for High Performance ● High Performance Compute / Graphics ● Compute, Math , FFT, convolution, Signal processing ● Support Graphics – but not a replacement for OpenGL ● Works on all GPUs ( if supported by SoC ) otherwise on CPU ● ●