Design of a Programmable Vertex Processing Unit for Mobile Platforms

Similar documents
Design of a Programmable Vertex Processing Unit for Mobile Platforms

Rasterization Overview

Vertex Shader Design I

Tutorial on GPU Programming. Joong-Youn Lee Supercomputing Center, KISTI

Basics of GPU-Based Programming

Introduction to Shaders.

Tutorial on GPU Programming #2. Joong-Youn Lee Supercomputing Center, KISTI

University of Toronto: CSC467F Compilers and Interpreters, Fall 2009

1.2.3 The Graphics Hardware Pipeline

Rendering Subdivision Surfaces Efficiently on the GPU

Real-Time Rendering (Echtzeitgraphik) Michael Wimmer

Real - Time Rendering. Graphics pipeline. Michal Červeňanský Juraj Starinský

Advanced Computer Graphics (CS & SE ) Lecture 7

X. GPU Programming. Jacobs University Visualization and Computer Graphics Lab : Advanced Graphics - Chapter X 1

Graphics Hardware. Instructor Stephen J. Guy

Shaders (some slides taken from David M. course)

PROFESSIONAL. WebGL Programming DEVELOPING 3D GRAPHICS FOR THE WEB. Andreas Anyuru WILEY. John Wiley & Sons, Ltd.

Graphics Processing Unit Architecture (GPU Arch)

Graphics Hardware, Graphics APIs, and Computation on GPUs. Mark Segal

Automatic Tuning Matrix Multiplication Performance on Graphics Hardware

Shading Languages. Ari Silvennoinen Apri 12, 2004

Rendering Grass with Instancing in DirectX* 10

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

CS451Real-time Rendering Pipeline

COMPUTER ORGANIZATION & ARCHITECTURE

Lecture 2. Shaders, GLSL and GPGPU

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

Introduction to the OpenGL Shading Language

Hardware-driven visibility culling

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

CS GPU and GPGPU Programming Lecture 3: GPU Architecture 2. Markus Hadwiger, KAUST

CS130 : Computer Graphics. Tamar Shinar Computer Science & Engineering UC Riverside

Shading Languages for Graphics Hardware

Supplement to Lecture 22

Rendering Objects. Need to transform all geometry then

The Application Stage. The Game Loop, Resource Management and Renderer Design

CS GPU and GPGPU Programming Lecture 7: Shading and Compute APIs 1. Markus Hadwiger, KAUST

Canonical Shaders for Optimal Performance. Sébastien Dominé Manager of Developer Technology Tools

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Graphics Performance Optimisation. John Spitzer Director of European Developer Technology

2.11 Particle Systems

Graphics Hardware. Graphics Processing Unit (GPU) is a Subsidiary hardware. With massively multi-threaded many-core. Dedicated to 2D and 3D graphics

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Why modern versions of OpenGL should be used Some useful API commands and extensions

Computer graphics 2: Graduate seminar in computational aesthetics

On the impact of using mixed real number representations in a graphics pipeline

Getting fancy with texture mapping (Part 2) CS559 Spring Apr 2017

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

Models and Architectures

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

A Low Power Multimedia SoC with Fully Programmable 3D Graphics and MPEG4/H.264/JPEG for Mobile Devices

Spring 2009 Prof. Hyesoon Kim

OpenGL Programmable Shaders

Hardware Shading: State-of-the-Art and Future Challenges

CS GPU and GPGPU Programming Lecture 3: GPU Architecture 2. Markus Hadwiger, KAUST

Spring 2011 Prof. Hyesoon Kim

Next-Generation Graphics on Larrabee. Tim Foley Intel Corp

Design and Applications of a Real-Time Shading System Master s Thesis

Hardware-Assisted Relief Texture Mapping

frame buffer depth buffer stencil buffer

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Windowing System on a 3D Pipeline. February 2005

Dave Shreiner, ARM March 2009

Hardware-driven Visibility Culling Jeong Hyun Kim

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Spring 2010 Prof. Hyesoon Kim. AMD presentations from Richard Huddy and Michael Doggett

Introduction to OpenGL

Programmable Graphics Hardware

E.Order of Operations

A Bandwidth Effective Rendering Scheme for 3D Texture-based Volume Visualization on GPU

Programming Guide. Aaftab Munshi Dan Ginsburg Dave Shreiner. TT r^addison-wesley

The Ultimate Developers Toolkit. Jonathan Zarge Dan Ginsburg

Introduction to Computer Graphics with WebGL

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico

Programming Graphics Hardware

Programmable GPUS. Last Time? Reading for Today. Homework 4. Planar Shadows Projective Texture Shadows Shadow Maps Shadow Volumes

Optimizing DirectX Graphics. Richard Huddy European Developer Relations Manager

Feeding the Beast: How to Satiate Your GoForce While Differentiating Your Game

GPU-Based Volume Rendering of. Unstructured Grids. João L. D. Comba. Fábio F. Bernardon UFRGS

Could you make the XNA functions yourself?

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

The Graphics Pipeline and OpenGL I: Transformations!

Chapter 7 - Light, Materials, Appearance

Per-pixel Rendering of Terrain Data

Shaders. Slide credit to Prof. Zwicker

Understanding Shaders and WebGL. Chris Dalton & Olli Etuaho

Introduction to Modern GPU Hardware

Architectures. Michael Doggett Department of Computer Science Lund University 2009 Tomas Akenine-Möller and Michael Doggett 1

CS427 Multicore Architecture and Parallel Computing

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

CS 4620 Program 3: Pipeline

Threading Hardware in G80

Grafica Computazionale: Lezione 30. Grafica Computazionale. Hiding complexity... ;) Introduction to OpenGL. lezione30 Introduction to OpenGL

OpenGL Status - November 2013 G-Truc Creation

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Evolution of GPUs Chris Seitz

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2014

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

GoForce 3D: Coming to a Pixel Near You

Transcription:

Design of a Programmable Vertex Processing Unit for Mobile Platforms Tae-Young Kim 1 and Kyoung-Su Oh 2 1 Dept of Computer Engineering, Seokyeong University 136704 Seoul, Korea tykim@skunivackr 2 Dept of Media, Soongsil University 156743 Seoul, Korea oks@ssuackr Abstract Programmable vertex processing unit increases the programmability and enables customizations of transformation and lighting in the graphics pipeline Furthermore, it offers various effects such as procedural vertex animation and deformation, which were impossible to handle in fixed vertex processing Since it is hard to find a programmable graphics hardware for the embedded systems such as mobile phones, we ve designed and implemented a programmable vertex processing unit based on the OpenGL ES 20 specification In this paper, we explain the architecture, instruction format, implementation and test results of our vertex processing unit 1 Introduction In last a few decades, much research has been done to enhance the functionality and efficiency of graphics hardware [1] Recently, there has been a great deal of advances in functionality of graphics hardware One of them is the programmable graphics pipeline It provides a programmer with the full control of the vertex and fragment processes Various effects such as procedural vertex animation which were impossible with the fixed pipeline can be implemented using the programmable graphics hardware [2-4] Fig 1 shows a typical graphics pipeline and also fig 2 shows the vertex processing operations in detail The vertex processing in the programmable pipeline does not use the fixed functions T&L (Transformation & Lighting) in fig 2 but a vertex program written by a programmer It gives the programmer total control of vertex processing Even though the programmable graphics hardware is common in the desktop environments, it is true that mobile phones with such solutions are rare or not yet released Therfore we have designed and implemented a programmable vertex processing unit for the embedded systems Our vertex processing unit is designed based on the OpenGL ES 20 [5] and GL_ARB_vertex_program [6] The GL_ARB_vertex_program is the specification of assembly shading language for programmable graphics processor in the general computing systems OpenGL ES is a graphics APIs standard for the embedded systems OpenGL ES 20 specifies graphics APIs and high level shading language for the X Zhou et al (Eds): EUC Workshops 2006, LNCS 4097, pp 805 814, 2006 IFIP International Federation for Information Processing 2006

806 T-Y Kim and K-S Oh programmable vertex and fragment programs [6-7] But it does not include low level specification such as assembly language or machine code of the shading language [8] We tested the feasibility of using assembly language instructions specified in GL_ARB_vertex_program with a DirectX high level shading language compiler And we found out the fact that most of high level shading language features specified in OpenGL ES 20 can be compiled into assembly language instructions specified in GL_ARB_vertex_program We modified GL_ARB_vertex_program assembly language to fully support OpenGL ES 20 In other words, we added some instructions and substituted an instruction with several other primitive instructions to encode/decode an instruction efficiently These are our main contributions Fig 1 A typical graphics pipeline (a) GG Fig 2 Operation of traditional fixed T&L engine (a) coordinate transform (b) lighting (b) In this paper, we present the architecture of our vertex processing We define 28 instructions and 3 macro instructions, and design 64bit machine code to encode the assembly language instructions Our instruction design and operand encoding scheme can be used as an interface standard between low-level and high-level shader language In section 2 we present the structure of our vertex processing unit And in section 3 we explain the instruction format Our implementation and results are in the next section We conclude in section 5

Design of a Programmable Vertex Processing Unit for Mobile Platforms 807 2 The Vertex Processing Unit Architecture A vertex program is a sequence of floating-point 4-component vector operations that determines how a set of program parameters and a set of per-vertex input parameters are transformed to a set of per-vertex result parameters Fig 3 shows the architecture of our vertex processing unit, based on the GL_ARB_vertex_program 0x0000 0x0016 0x0032 0x0048 0xA000 0xA016 0xA032 0xA048 Vertex Data (16) Machine Codes (128) 0x0000 Vertex Processing Unit Instruction code 0xA000 Code fetch & decode Temporary Registers (16) Address Register (1) 0xF000 0xF008 0xF016 0xF024 Constant Registers (96) Instruction Operation 0xF000 Output Registers(16) Fig 3 The Vertex Processing Unit Architecture Machine code: Binary codes to be executed in vertex processing unit Up to 128 machine codes can be handled Vertex Processing Unit: A processing engine that fetches, decodes and operates each machine code, respectively It reads vertex data and writes the processing results such as position, color, and texture coordinates to vertex output registers Vertex data: A set of 16 read-only registers containing 4-component floating point vector Each register are for position, colors, normal of vertex and user-defined vertex parameters The data is passed through normal OpenGL mechanisms (pervertex API or vertex arrays) Constant Registers: A set of 96 read-only registers containing 4-component floating point vector It stores parameters such as matrices, lighting parameters and constants required by vertex programs They are modifiable only outside of glbegin/glend pair Temporary Registers: A set of 16 readable and writable registers containing 4- component floating point vector to hold temporary results that can be read or written during the execution of a vertex program Address Register: A register containing an integer that can be used as an index to perform indirect accesses to constant data during the execution of a vertex program Output Registers: A set of 16 write-only registers containing 4-component floating point vectors to hold the final results of a vertex program Vertex program outputs are passed to the remaining graphics pipelines These outputs correspond to the set of vertex attributes, ie homogeneous clip space position, primary, secondary

808 T-Y Kim and K-S Oh colors, fog coordinates, point size, texture coordinates, used during primitive assembly and rasterization 3 Instruction Format A vertex program is programmed using low-level assembly language and assembled into machine codes which can be executable by the vertex processing unit In the GL_ARB_vertex_program specification, 27 assembly language instructions are presented [6] In this paper, we define 28 primitive instructions and 3 macro instructions based on the operation processing method, as shown tables 1 and 2 Since macro instruction means an instruction which can be replaced by a series of primitive instructions, each one is translated into multiple primitive instructions in assembling time Therefore our vertex processing unit handles only the primitive instructions In table 1, the instructions in shadowed parts are additional instructions which are not included in the GL_ARB_vertex_program instruction set We added them in order to implement the macro instructions in table 2 Table 1 Primitive instructions

Design of a Programmable Vertex Processing Unit for Mobile Platforms 809 Table 2 Macro instructions Macro Instruction LIT POW SUB description : Light coefficients LIT f, a, b clamp tmp, a0, b rlg2 tmpw, tmpw MUL tmpw, tmpw, tmpy rex2 tmpw, tmpw mulz f, tmp1xz1, tmpw : Power POW f, a, b ( f = a b ) LG2 tmp, a MUL tmp, tmp, b EX2 f, tmp : Subtraction SUB f, a, b (f = a b) ADD f, a, -b The instruction is composed of an opcode, a destination operand, and up to 3 source operands, respectively as shown in fig 4: opcode destination operand, source operand0 [, source operand1, source operand2]; Fig 4 Instruction format Fig 5 shows the 64bit machine code structure The low bit fields [4 th ~ 18 th bit] can be used as a source operand (Src 2 ) field or an extended swizzle field They are recognized as a source operand field in MAD instruction, and as an extended swizzle field in other cases MAD is the only instruction which have three source operands Fig 5 Machine code fomat ( : unused bit) Each field of the machine code has the following bit format: Opcode field: opcode (Fig 6) The opcode has 6 bits, so it is possible up to 64 instructions

810 T-Y Kim and K-S Oh Fig 6 Machine code format (opcode field) Destination operand field: Dest (Fig 7) The destination field (register type, index, and mask information) has 9 bits Each bit is translated as follows: T (1bit) : type / 0 (Temporary register) / 1 (Output register) index (4bits) : register index (0~15) mask (4bits) : mask flag for each component Fig 7 Machine code format (Destination operand field) Source operand(n) field: Src(n), 0 n 2 (Fig 8) The source field (register type, index, and swizzle information) has 15 bits Each bit is translated as follows: neg(1bit): negation flag type(2bits): type / 00(Temporary register) / 01(Vertex data) / 10(Constant register, absolute addressing) / 11(Constant register, relative addressing) index (4bits): register index (0~15) Src_?(2bits): component swizzle / 00(x component) 01(y component) / 10(z component) 11(w component) Fig 8 Machine code format (Source operand field)

Design of a Programmable Vertex Processing Unit for Mobile Platforms 811 Exteneded swizzle field (Fig 9) The extended swizzle field has additional swizzle information of source operand 0 With swizzle information, four components of source operand 0 can be negated or changed with other components value, zero or one For example, if the swizzle suffix is "yzzx" and the specified source register value is contains {2,8,9,0}, the swizzled operand used by the instruction is {8,9,9,2} PARAM Colr = {5, 6, 7, 8}; TEMP Tmp1, Tmp2; SWZ Tmp1, Colrxy01; // Tmp1 = { 5, 6, 0, 1}; SWZ Tmp2, Colr-x-yz1; // Tmp2 = {-5,-6,7, 1}; In this field, N? and S? mean negation and zero or one value flags for each component Fig 9 Machine code format (Extended swizzle field) Extended constant index field (Fig 10) The extended index field has 3 bits, which is used for indexing the location of constant register Totally, 7 bits indexing is possible with the 4 bits in the source operand field and the 3 bits in the extended constant index field Fig 10 Machine code format (Extended constant index field) 4 Implementation and Test Results We implemented our programmable vertex processing unit in software emulation Our implementation can be used to emulate mobile applications including vertex programs on PC We tested the performance of our work on a desktop PC with 43

812 T-Y Kim and K-S Oh GHz Pentium processor and ATI Radeon 9800 XT graphics card We implemented only vertex processing unit Vertices that are transformed and lighted by our vertex processing unit are sent to OpenGL system installed on desktop system To test our vertex processing unit, we implemented the OpenGL ES 20 APIs related with vertex processing Using the OpenGL ES 20 APIs, vertex data are stored and passed to our vertex processing unit A vertex program written by programmers is assembled into machine codes and they are passed to the vertex processing unit by our APIs The vertex processing unit calculates the position and the color of each vertex by fetching, decoding, and executing the machine codes The outputs of our vertex processing unit are collected and are sent to the OpenGL graphics pipeline installed in our computer via the original OpenGL APIs Therefore, the vertex processing is performed by our vertex processing unit and the remaining operations, after vertex processing such as triangle setup, rasterization and fragment processing, are performed by the original OpenGL pipeline (Fig 11) Our implementation bypass Original OpenGL pipeline OpenGL API Vertex processing Unit Transform & Lighting Rasterization Fig 11 Overview of our implementation The arithmetic unit in our vertex processing unit supports 24 bit floating point format which satisfies the requirement of the OpenGL ES 20 We tested 3 vertex programs listed in fig 12 Fig 12 Test vertex programs, left: Normal value, middle: Cook-Torrance illumination [9], right: Environment map All programs use same model whose vertex count is 6,984 We compared an image rendered by our system with an image rendered by pure OpenGL system on PC In all test scenes, we could not find differences with naked eye Therefore, we computed color difference images and turned all non black pixel values into white to exaggerate the differences The result is fig 13 There were some errors near the boundary of the model due to numerical resolution differences between 32 bit floating point arithmetic unit and 24 bit unit As you can see, sample 3 shows more errors compared to samples 1 and 2 because in environment mapping,

Design of a Programmable Vertex Processing Unit for Mobile Platforms 813 Fig 13 Difference images between our system and pure PC OpenGL system small changes in normal values result in changes in texture coordinates These errors cause the difference of colors fetched from texture Comparison of frame rates among test programs is shown in table 3 We can see that the frame rate is inversely proportional to the number of assembly commands Table 3 Frame rate sample 1 sample 2 sample 3 Number of assembly commands 6 31 21 FPS 6179 1754 262 5 Conclusion Programmable vertex processing offers user defined vertex processing and provides the programmer with an opportunity to take full control of vertex processing In this paper, we design and implement a programmable vertex processing unit for the mobile environments based on the OpenGL ES 20 specification It specifies graphics APIs and high level shading language for the embedded systems Since the final draft of OpenGL ES 20 came out about September of 2005 it is hard to find software or hardware implementation based on the specificationg We present the architecture and instruction format of vertex processing unit And we define 28 primitive instructions and 3 macro instructions based on the operation processing method The vertex processing is performed by our vertex processing unit and the remaining operations, after vertex processing such as triangle setup, rasterization and fragment processing, are performed by the original OpenGL pipeline Our implementation and test results show that error is negligible and the performance is inversely proportional to the number of vertices and the number of instructions in the vertex program as we expectedg We are in the process of developing a fragment processing unit for the next part of our work on vertex processing unit Acknowledgement This work was supported by the Ministry of Culture & Tourism and KOCCA under the Culture and Content Technology Research Center (CTRC) Support Program

814 T-Y Kim and K-S Oh References [1] James D F, Andries van D, Steven K F, John F H:Computer Graphics: Principles and Practice in C Addison-Wesley Professional, Boston (2005) [2] Matt, P, Randima, F:GPU GEMS 2 Addison-Wesley Professional, Boston (2005) [3] Kyoungsu O, Keechul J: GPU implementation of neural networks, International Journal of Pattern Recognition, Vol 37, Elsevier(2004) [4] Michael M, Stefenus D T, Tiberiu P, Bryan C, Kevin M:Shader algebra, Transaction on Graphics, Vol 23, ACM Press, Newyork (2004) [5] OpenGL ES 20 specification Available at http://wwwkhronosorg/opengles/2_x/ [6] OpenGL ARB Vertex program specification Available at http://osssgicom/projects/ogl-sample/registry/arb/vertex_ programtxt [7] OpenGL ARB Fragment program specification Available at http://osssgicom/projects/ ogl-sample/registry/arb/fragment_ programtxt [8] Randi J R: OpenGL Shading Language, Addison Wesley, Boston (2004) [9] R L Cook, K E Torrance: A Reflectance model for Computer Graphics, Transaction on Graphics, Vol 1, ACM Press, Newyork (1982)