ARBVP10 FrameWork in GLLib. Contents New GLLib FrameWork classes  ProgramObjects (and related).  VSLoader  GLState Vertex Attributes management through.

Slides:



Advertisements
Similar presentations
Normal Map Compression with ATI 3Dc™ Jonathan Zarge ATI Research Inc.
Advertisements

1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
CS-378: Game Technology Lecture #9: More Mapping Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
9/25/2001CS 638, Fall 2001 Today Shadow Volume Algorithms Vertex and Pixel Shaders.
 The success of GL lead to OpenGL (1992), a platform-independent API that was  Easy to use  Close enough to the hardware to get excellent performance.
Informationsteknologi Wednesday, December 12, 2007Computer Graphics - Class 171 Today’s class OpenGL Shading Language.
Introduction to Shader Programming
Status – Week 249 Victor Moya. Summary MemoryController. MemoryController. Streamer. Streamer. TraceDriver. TraceDriver. Statistics. Statistics.
GLSL I May 28, 2007 (Adapted from Ed Angel’s lecture slides)
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Status – Week 243 Victor Moya. Summary Current status. Current status. Tests. Tests. XBox documentation. XBox documentation. Post Vertex Shader geometry.
Atila OGL library “T&L emulated via Vertex Shaders”
Status – Week 242 Victor Moya. Summary Current status. Current status. Tests. Tests. XBox documentation. XBox documentation. Post Vertex Shader geometry.
Status – Week 248 Victor Moya. Summary Streamer. Streamer. TraceDriver. TraceDriver. bGPU bGPU Signal Traffic Analyzer. Signal Traffic Analyzer. How to.
ARB Fragment Program in GPULib. Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
Status – Week 239 Victor Moya. Summary Primitive Assembly Primitive Assembly Clipping triangle rejection. Clipping triangle rejection. Rasterization.
Mohan Sridharan Based on slides created by Edward Angel GLSL I 1 CS4395: Computer Graphics.
Status – Week 275 Victor Moya. Simulator model Boxes. Boxes. Perform the actual work. Perform the actual work. Parameters: wires in, wires out, child.
Software Development and Software Loading in Embedded Systems.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Shaders Feb 18, 2011 Creative Commons Attribution 3.0 (Except copyrighted.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Programming Concepts. Derive a new class from Activity of the framework Prepare the data beforehand, e.g., vertices, colours, normal vectors, texture.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Using Vertex Shader in DirectX 8.1 강 신 진
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
CS 450: COMPUTER GRAPHICS PORTRAIT OF AN OPENGL PROGRAM SPRING 2015 DR. MICHAEL J. REALE.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
CSE 690: GPGPU Lecture 6: Cg Tutorial Klaus Mueller Computer Science, Stony Brook University.
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
CS662 Computer Graphics Game Technologies Jim X. Chen, Ph.D. Computer Science Department George Mason University.
Review of OpenGL Basics
OpenGL Shader Language Vertex and Fragment Shading Programs.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
A User-Programmable Vertex Engine Erik Lindholm Mark Kilgard Henry Moreton NVIDIA Corporation Presented by Han-Wei Shen.
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Lab: Vertex Shading Chris Wynn Ken Hurley. Objective Hands-On vertex shader programming Start with simple programs … Part 1: Textured-Lit Teapot.
Week 3 Lecture 4: Part 2: GLSL I Based on Interactive Computer Graphics (Angel) - Chapter 9.
09/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Shadows Stage 2 outline.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Mesh Skinning Sébastien Dominé. Agenda Introduction to Mesh Skinning 2 matrix skinning 4 matrix skinning with lighting Complex skinning for character.
OpenGL Shading Language
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
Computer Science – Game DesignUC Santa Cruz Tile Engine.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
CS 480/680 Computer Graphics Programming with Open GL Part 2: Complete Programs Dr. Frederick C Harris, Jr. Fall 2011.
Chapter 7: User-Defined Functions II
Real-Time Rendering Buffers in OpenGL 3.3
GLSL I Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico.
Day 05 Shader Basics.
Chapter VI OpenGL ES and Shader
Constructors and Other Tools
Where does the Vertex Engine fit?
Programming with OpenGL Part 3: Shaders
Mickaël Sereno Shaders Mickaël Sereno 25/04/2019 Mickaël Sereno -
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
CS 480/680 Computer Graphics GLSL Overview.
Computer Graphics Shading in OpenGL
Opengl implementation
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

ARBVP10 FrameWork in GLLib

Contents New GLLib FrameWork classes  ProgramObjects (and related).  VSLoader  GLState Vertex Attributes management through GPUDriver  Streams configuration  Input and Output vertex mapping

ARBVP10 FrameWork in GLLib !!ARBvp END ProgramObject compile() getClusterBank() Basic Object Class to encapsulate a vertex program: the ProgramObject. 0x09 0x00 0x00 0x x09 0x00 0x00 0x x16 0x10 0x00 0x Assembles source code to GPU binary code Returns the parameters Bank required for the vertex program. It has to be resolved by GLLib with the GL State and sent to GPU as the constant bank.

ARBVP10 FrameWork in GLLib Now, ProgramObject used in GLLib T&L fixed function too. Now, a VSLoader class manages T&L fixed function and vertex shaders at the same manner through program objects. VSLoader has the responsibility of configure the vertex shaders to GPU via GPUDriver.

VSLoader class class VSLoader { private: ProgramObject* tl; // t&l program GPUDriver* driver; // current driver void resolveBank(ProgramObject& po, RBank & b); public: VSLoader(); void setDriver(GPUDriver* driver); u32bit emulateFixedPipe(); u32bit initVP(ProgramObject& po); }; Configures the GPU with the default T&L fixed function vertex program: if ( !tl.getSource() ) tl.setSource( "!!ARBvp1.0\ OPTION ARB_position_invariant;\ PARAM c4 = state.light[0].spot.direction;\ PARAM c5 = state.light[0].half;\ PARAM c6 = state.material.shininess;\ PARAM c7 = state.light[0].ambient;\ PARAM c8 = state.light[0].diffuse;\ PARAM c9 = state.light[0].specular;\ ATTRIB i2 = vertex.normal;\ OUTPUT o1 = result.color;\ TEMP r0, r1;\ DP3 r0.x, i2, c4;\ DP3 r0.y, i2, c5;\ MOV r0.w, c6.x;\ LIT r0, r0;\ MAD r1, r0.y, c8, c7;\ MAD o1, r0.z, c9, r1;\ END"; ) initVP(tl); u32bit emulateFixedPipe();

VSLoader class class VSLoader { private: ProgramObject* tl; // t&l program GPUDriver* driver; // current driver void resolveBank(ProgramObject& po, RBank & b); public: VSLoader(); void setDriver(GPUDriver* driver); u32bit emulateFixedPipe(); u32bit initVP(ProgramObject& po); }; Compiles de vertex program in program object and writes it to GPU. po.compile(); constants = po.getClusterBank(); resolveBank(constants,po); po.getBinary(vprogram,psize); driver->writeMemory( mdVP, vprogram, psize ); u32bit initVP(ProgramObject& po); It uses a GLState class to resolve actual values of the OpenGL State required for the vertex program.

GLState class Stores an updated copy the OpenGL State accesible to the vertex programs. OpenGL calls updates GLState values and resolveBank( ) consults the required vertex program state.

Derived state Some states has sense to be derived from others, for example:  MVP = ModelView * Projection;  Inverse MVP = inverse(MVP). In GLState all derived states are calculated only when they are required by a vertex program.

GLState class implementation Each individual matrix state in GLState has a dirty flag. When a individual matrix state is modified dirty flag in derived matrices are set. When a “dirty” derived matrix is request their values are calculated and dirty flag is reset.

GLState class implementation Advantages:  OpenGL state and derived matrices are put together in a class, preserving modularity and transparency about calculations.  Only derived state required for vertex programs are calculated.  Updates of matrix states doesn´t results in cascade update of derived matrices. For example: update of modelview matrix would result in update of inverse, transpose and transpose of inverse of modelview matrix (3) and update of the normal, inverse, transpose and transpose inverse of the mvp matrix (4). Total 7 matrices calculations for every modelview update !!!.

Vertex Attributes management through GPUDriver

Vertex Attributes management GPU vertex program is executed for each vertex. OpenGL library sends vertex information to GPU through GPUDriver. When to send the vertices to GPU is an agreement of OpenGL library specific implementation. Our implementation GLLib sends vertices in calls:  glEnd()  glDrawElements()  glDrawArrays()

Vertex Attributes management Send vertices implies: 1. Reserve GPU local memory to allocate vertices information (attributes): coordinates, colors, normals Assign at least one GPU Streamer (GPU vertex shader feeder) for each attribute → Streamer configuration.

Vertex Attributes management 1. Vertex attributes allocation in GPU  Step 1: Allocate 3 GPU mem regions for attributes: u32bit mdVertex = driver->obtainMemory( ctx->vCount*sizeof(GLfloat)*4 ); u32bit mdColor = driver->obtainMemory( ctx->vCount*sizeof(GLfloat)*4 ); u32bit mdNormal = 0; if ( IS_USENORMALS ) mdNormal = driver->obtainMemory( ctx->vCount*sizeof(GLfloat)*3 ); ctx->vCount has the number of vertices defined with gl Calls between glBegin() and glEnd().

Vertex Attributes management 1. Vertex attributes allocation in GPU  Step 2:Copy attributes to GPU mem regions: driver->writeMemory( mdVertex, (u8bit*)ctx->vertexBuffer, ctx->vCount*sizeof(GLfloat)*4 ); driver->writeMemory( mdColor, (u8bit*)ctx->colorBuffer, ctx->vCount*sizeof(GLfloat)*4 ); if ( IS_USENORMALS ) driver->writeMemory( mdNormal, (u8bit*)ctx->normalBuffer, ctx->vCount*sizeof(GLfloat)*3 ); ctx->vertexBuffer, ctx->colorBuffer and ctx->normalBuffer has the vertices attributes defined with gl Calls between glBegin() and glEnd().

Vertex Attributes management 2. Streamer configuration  configureVertexAttrib Associates a stream to feed a VS input attribute Configure the stream (enable or disable)  stride, amount of components and type, # elements  setAttributeIsWritten Set a given attribute to be written in VS output  Note: It must not be an enabled input attribute (can be produced in the vertex program itself)

Last tests. “Rosquillas” test  Fail: (panic) ShaderEmulator:shIllegal => Instruction not implemented.  Must be revisited ;-)  In september