Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality...

22
Sylwester Bala Senior Software Engineer [email protected]

Transcript of Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality...

Page 1: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Sylwester Bala

Senior Software Engineer

[email protected]

Page 2: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Agenda

Fur

EGLImage

Thread synchronisation

High Quality Text Rendering

Simple Text Rendering

Particle system

Shadow mapping

Page 3: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Fur Real-Time Rendering

Technique using OpenGL® ES 2.0

Page 4: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Shell Rendering

5 passes

15 passes

20 passes

10 passes

Noise texture

Each rendering pass

scales the object and

uses less alpha

1 pass

Page 5: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

EGLImage Updating a Texture without

copying memory under Android

Page 6: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

OpenGL® ES

EGLImage: Saving resources

EGLImage

OpenGL® ES

glTexImage2D

Page 7: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Texture

Updated

EGLImage extension with NDK

Graphic

Buffer

GBuffer

Library

EGLImage

Extension

eglCreateImageKHR

Create 2D Texture

Update

Buffer

Lock

GBuffer

Unlock

GBuffer

Texture EGLImage

Extension

glEGLImageTargetTexture2DOES

Application

Page 8: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Thread Synchronization Using OpenGL® ES 3.0 Sync Objects in a Multithreading

Environment

Page 9: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Sync objects

OpenGL ES 3.0

Sync objects are

available as part

of the API !

We can synchronize

to specific point in

the command

stream

GLsync glFenceSync(GLenum condition, GLbitfield flags);

GLenum glClientWaitSync(GLsync sync, Glbitfield flags,

GLuint64 timeout);

void glWaitSync(Glsync sync, GLbitfield flags,

GLuint64 timeout);

Create a sync object in

unsignaled state

Block CPU until sync

object is signaled

GPU will wait until sync

object is signaled

GLES command 1

GLES command 2

GLES command 3

syncObj = glfenceSync

Command queue Execution

GLES command 1

GLES command 2

GLES command 3

syncObj = glfenceSync

Page 10: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Thread Synchronization

Application

Main Thread while (rendering)

{

/* Wait for secondary thread’s sync obj. */

glWaitSync(syncObj2, 0, timeout);

/* Draw scene. */

glDrawElements(…);

/* Create sync object 1. */

syncObj1= glFenceSync(condition, flags);

}

Secondary Thread while (updating texture)

{

/* Change texture. */

updateTextureFunc();

/* Wait for main thread’s sync object. */

glWaitSync(syncObj1, 0, timeout);

/* Upload texture. */

glBindtexture(…);

glTexImage2D(…);

/* Create sync object 2. */

syncObj2= glFenceSync(condition, flags);

}

Context 1 Context 2

S

H

A

R

E

D

O

B

J

E

C

T

S

Page 11: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

ThreadSync example running on Nexus 10. (Cortex-A15 dual core CPU and ARM Mali-T604 GPU)

Fencing on. Fencing off.

Page 12: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

High Quality Text Rendering Improving Quality for textured

Text under Android

Page 13: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Text

transformations

negatively

affect

text

quality

Text Rendering

text

Create the Bitmap

Width = calculated width

Height = calculated height

Clear color = ARGB(0, 255, 255, 255)

Paint color = ARGB(255, 255, 255, 255)

Blending:

glBlendFunc(GL_ONE,

GL_ONE_MINUS_SRC_ALPHA)

Find the font

size that

gives the

closest

matching of

texels onto

screen

pixels

Page 14: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Simple Text Rendering Improving Quality and

Performance

Page 15: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Text

transformations

negatively

affect

text

quality

Simple Text Rendering

text Single atlas per

font face

approach as a

simple and

effective solution

Create an atlas for each font face

Define the mapping of each glyph

Page 16: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Particle System Realtime smoke rendering with

OpenGL® ES 2.0

Page 17: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Particle Systems

Particle Systems

Point sprites are rendered efficiently as GL_POINT

Rendering

x, v, a, etc. are calculated

Simulation

The Emitter: defines where the particles are created and their initial properties

Particle Creation

Page 18: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Shadow Mapping Real-time Shadow Rendering

with OpenGL® ES 2.0

Page 19: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Shadow mapping process.

P P P

Shadow

Map ZL

ZN

3D Scene Light Pass

Image

Plane

Final Pass

Render scene to texture

from light’s point of view to

store fragments’ depth.

Render scene from camera’s point of

view. Additionally calculate position

of fragments’ in light’s space.

If ZN > ZL the fragment is in shadow.

Shadow

Caster

Shadow

Receivers

Page 20: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

All these samples and more are available on:

malideveloper.arm.com

Page 21: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time

Thank you

Any questions?

Page 22: Senior Software Engineer Sylwester.Bala@arm€¦ · EGLImage Thread synchronisation High Quality Text Rendering Simple Text Rendering Particle system Shadow mapping . Fur Real-Time