Embed presentation
Downloaded 899 times





















































































![86What is computer architecture?What is computer architecture?• Architecture: “the minimal set ofproperties that determine what programswill run and what results they will produce”• Implementation: “the logicalorganization of the [computer’s] dataflowand controls”• Realization: “the physical structureembodying the implementation”](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-86-2048.jpg&f=jpg&w=240)






























![117Scene Representation• Each rectangle specified by following RectInfo structure:• Array of RectInfo structures describes “scene”• Simplistic scene for sake of teachingtypedef struct {GLfloat x, y, width, height;GLfloat depth_order;GLfloat left_side_color[3]; // red, green, thenblueGLfloat right_side_color[3]; // red, green, thenblue} RectInfo;](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-117-2048.jpg&f=jpg&w=240)
![118Example Scene and Rendering Result• Scene of 4 rectangles:RectInfo rect_list[4] = {{ 10, 20, 180, 140, 0.5,{ 1, 1, 1 }, { 1, 0, 1 } },{ 30, 40, 100, 60, 0.5,{ 1, 0, 0 }, { 0, 0, 1 } },{ 140, 60, 100, 80, 0.5,{ 0, 0, 1 }, { 0, 1, 0 } },{ 70, 120, 80, 60, 0.7,{ 1, 1, 0 }, { 0, 1, 1 } },};• OpenGL-rendered result](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-118-2048.jpg&f=jpg&w=240)
![119Immediate Mode Rectangle Rendering• Given sized RectInfo array, render vertices of quads1stvertex2ndvertex3rdvertex4thvertexvoid drawRectangles(int count, const RectInfo *list){glBegin(GL_QUADS);for (int i=0; i<count; i++) {const RectInfo *r = &list[i];glColor3fv(r->left_side_color);glVertex3f(r->x, r->y, r->depth_order);glColor3fv(r->right_side_color);glVertex3f(r->x+r->width, r->y, r->depth_order);// right_side_color “sticks”glVertex3f(r->x+r->width, r->y+r->height, r->depth_order);glColor3fv(r->left_side_color);glVertex3f(r->x, r->y+r->height, r->depth_order);}glEnd();}Foreachrectangle](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-119-2048.jpg&f=jpg&w=240)



![123Step 1:Copy Rectangle Attributes to Vertex Arraysvoid *initVarrayRectangles(int count, const RectInfo *list){void *varray = (char*) malloc(sizeof(GLfloat)*6*4*count);GLfloat *p = varray;for (int i=0; i<count; i++, p+=24) {const RectInfo *r = &list[i];// quad vertex #1memcpy(&p[0], r->left_side_color, sizeof(GLfloat)*3);p[3] = r->x; p[4] = r->y; p[5] = r->depth_order;// quad vertex #2memcpy(&p[6], r->right_side_color, sizeof(GLfloat)*3);p[9] = r->x+r->width; p[10] = r->y; p[11] = r->depth_order;// quad vertex #3memcpy(&p[12], r->right_side_color, sizeof(GLfloat)*3);p[15] = r->x+r->width; p[16] = r->y+r->height; p[17] = r->depth_order;// quad vertex #4memcpy(&p[18], r-> left_side_color, sizeof(GLfloat)*3);p[21] = r->x; p[22] = r->y+r->height; p[23] = r->depth_order;}return varray;}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-123-2048.jpg&f=jpg&w=240)






















![146Consider an OpenGL texture fetch• Seems very simple• Input: texture coordinates (s,t,r,q)• Output: some color (r,g,b,a)• Just a simple function, written in Cg/HLSL:uniform sampler2D decal : TEXUNIT2;float4 texcoord : TEXCOORD3;float4 rgba = tex2D(decal, texcoordset.st);• Compiles to single instruction:TEX o[COLR], f[TEX3], TEX2, 2D;• Implementation is much more involved!](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-146-2048.jpg&f=jpg&w=240)







![154What really happens?• Let’s consider a simple tri-linear mip-mapped 2Dprojective texture fetch• Logically just one instructionTXP o[COLR], f[TEX3], TEX2, 2D;• Logically• Texel selection• Texel combination• How many operations are involved?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-154-2048.jpg&f=jpg&w=240)

![156Interpolation• First we need to interpolate (s,t,r,q)• This is the f[TEX3] part of the TXP instruction• Projective texturing means we want (s/q, t/q)• And possible r/q if shadow mapping• In order to correct for perspective, hardware actually interpolates• (s/w, t/w, r/w, q/w)• If not projective texturing, could linearly interpolate inverse w (or 1/w)• Then compute its reciprocal to get w• Since 1/(1/w) equals w• Then multiply (s/w,t/w,r/w,q/w) times w• To get (s,t,r,q)• If projective texturing, we can instead• Compute reciprocal of q/w to get w/q• Then multiple (s/w,t/w,r/w) by w/q to get (s/q, t/q, r/q)Observe projectivetexturing is samecost as perspectivecorrection](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-156-2048.jpg&f=jpg&w=240)





















![178Tessellation Not New to OpenGL• At least three different bi-variate patch tessellation schemes havebeen added to OpenGL• Evaluators (OpenGL 1.0)• NV_evaluators (GeForce 3)• water-tight• adaptive level-of-detail• forward differencing approach• ATI_pn_triangles Curved PN Triangles (Radeon)• tessellated triangle based on positions+normals• None succeeded• Hard to integrate into art pipelines• Didn’t offer enough performance advantageGLUT’s wire-frameteapot[Moreton 20001][Vlachos 20001]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-178-2048.jpg&f=jpg&w=240)







![186Relaxed Vertex Index and Command Order• OpenGL today always executes commands “in order”• Sequentially requirement• Provide compile-time specification of re-ordering allowances• Allows GL implementation to re-order• Vertex indices within display list’s vertex batch• Commands within display list• Key rule: state vector rendering command executes in mustmatch the state if command was rendered sequentially• Allow static or dynamic re-ordering• Static re-ordering needed for multi-pass invariances• Past practice• IRIS Performer would sort rendering by state changes forperformance• [Sander 2007] show substantial benefit for vertex ordering](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-186-2048.jpg&f=jpg&w=240)




![191Direct3D vs. OpenGLCoordinate System Conventions• Window origin conventions• Direct3D = upper-left origin• OpenGL = lower-left origin• Pixel center conventions• Direct3D9 = pixel centers at integer locations• OpenGL (and Direct3D 10) = pixel centers at half-pixel locations• Clip space conventions• Direct3D = [-1,+1] for XY, [0,1] for Z• OpenGL = [-1,+1] range for XYZ• Affects• How projection matrix is loaded• Fragment shaders that access the window position• Point sprites have upper-left texture coordinate origin• OpenGL already lets application choose lower-left or upper-left](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-191-2048.jpg&f=jpg&w=240)
















The document discusses the design and evolution of Modern OpenGL, detailing its history from Iris GL to OpenGL 3.0 and beyond. It features contributions from key figures like Kurt Akeley and Mark Kilgard, who played significant roles in its development at companies such as Silicon Graphics and NVIDIA. The document highlights OpenGL's competitive strengths, design philosophy, and the introduction of new features across various versions.





















































































![86What is computer architecture?What is computer architecture?• Architecture: “the minimal set ofproperties that determine what programswill run and what results they will produce”• Implementation: “the logicalorganization of the [computer’s] dataflowand controls”• Realization: “the physical structureembodying the implementation”](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-86-2048.jpg&f=jpg&w=240)






























![117Scene Representation• Each rectangle specified by following RectInfo structure:• Array of RectInfo structures describes “scene”• Simplistic scene for sake of teachingtypedef struct {GLfloat x, y, width, height;GLfloat depth_order;GLfloat left_side_color[3]; // red, green, thenblueGLfloat right_side_color[3]; // red, green, thenblue} RectInfo;](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-117-2048.jpg&f=jpg&w=240)
![118Example Scene and Rendering Result• Scene of 4 rectangles:RectInfo rect_list[4] = {{ 10, 20, 180, 140, 0.5,{ 1, 1, 1 }, { 1, 0, 1 } },{ 30, 40, 100, 60, 0.5,{ 1, 0, 0 }, { 0, 0, 1 } },{ 140, 60, 100, 80, 0.5,{ 0, 0, 1 }, { 0, 1, 0 } },{ 70, 120, 80, 60, 0.7,{ 1, 1, 0 }, { 0, 1, 1 } },};• OpenGL-rendered result](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-118-2048.jpg&f=jpg&w=240)
![119Immediate Mode Rectangle Rendering• Given sized RectInfo array, render vertices of quads1stvertex2ndvertex3rdvertex4thvertexvoid drawRectangles(int count, const RectInfo *list){glBegin(GL_QUADS);for (int i=0; i<count; i++) {const RectInfo *r = &list[i];glColor3fv(r->left_side_color);glVertex3f(r->x, r->y, r->depth_order);glColor3fv(r->right_side_color);glVertex3f(r->x+r->width, r->y, r->depth_order);// right_side_color “sticks”glVertex3f(r->x+r->width, r->y+r->height, r->depth_order);glColor3fv(r->left_side_color);glVertex3f(r->x, r->y+r->height, r->depth_order);}glEnd();}Foreachrectangle](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-119-2048.jpg&f=jpg&w=240)



![123Step 1:Copy Rectangle Attributes to Vertex Arraysvoid *initVarrayRectangles(int count, const RectInfo *list){void *varray = (char*) malloc(sizeof(GLfloat)*6*4*count);GLfloat *p = varray;for (int i=0; i<count; i++, p+=24) {const RectInfo *r = &list[i];// quad vertex #1memcpy(&p[0], r->left_side_color, sizeof(GLfloat)*3);p[3] = r->x; p[4] = r->y; p[5] = r->depth_order;// quad vertex #2memcpy(&p[6], r->right_side_color, sizeof(GLfloat)*3);p[9] = r->x+r->width; p[10] = r->y; p[11] = r->depth_order;// quad vertex #3memcpy(&p[12], r->right_side_color, sizeof(GLfloat)*3);p[15] = r->x+r->width; p[16] = r->y+r->height; p[17] = r->depth_order;// quad vertex #4memcpy(&p[18], r-> left_side_color, sizeof(GLfloat)*3);p[21] = r->x; p[22] = r->y+r->height; p[23] = r->depth_order;}return varray;}](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-123-2048.jpg&f=jpg&w=240)






















![146Consider an OpenGL texture fetch• Seems very simple• Input: texture coordinates (s,t,r,q)• Output: some color (r,g,b,a)• Just a simple function, written in Cg/HLSL:uniform sampler2D decal : TEXUNIT2;float4 texcoord : TEXCOORD3;float4 rgba = tex2D(decal, texcoordset.st);• Compiles to single instruction:TEX o[COLR], f[TEX3], TEX2, 2D;• Implementation is much more involved!](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-146-2048.jpg&f=jpg&w=240)







![154What really happens?• Let’s consider a simple tri-linear mip-mapped 2Dprojective texture fetch• Logically just one instructionTXP o[COLR], f[TEX3], TEX2, 2D;• Logically• Texel selection• Texel combination• How many operations are involved?](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-154-2048.jpg&f=jpg&w=240)

![156Interpolation• First we need to interpolate (s,t,r,q)• This is the f[TEX3] part of the TXP instruction• Projective texturing means we want (s/q, t/q)• And possible r/q if shadow mapping• In order to correct for perspective, hardware actually interpolates• (s/w, t/w, r/w, q/w)• If not projective texturing, could linearly interpolate inverse w (or 1/w)• Then compute its reciprocal to get w• Since 1/(1/w) equals w• Then multiply (s/w,t/w,r/w,q/w) times w• To get (s,t,r,q)• If projective texturing, we can instead• Compute reciprocal of q/w to get w/q• Then multiple (s/w,t/w,r/w) by w/q to get (s/q, t/q, r/q)Observe projectivetexturing is samecost as perspectivecorrection](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-156-2048.jpg&f=jpg&w=240)





















![178Tessellation Not New to OpenGL• At least three different bi-variate patch tessellation schemes havebeen added to OpenGL• Evaluators (OpenGL 1.0)• NV_evaluators (GeForce 3)• water-tight• adaptive level-of-detail• forward differencing approach• ATI_pn_triangles Curved PN Triangles (Radeon)• tessellated triangle based on positions+normals• None succeeded• Hard to integrate into art pipelines• Didn’t offer enough performance advantageGLUT’s wire-frameteapot[Moreton 20001][Vlachos 20001]](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-178-2048.jpg&f=jpg&w=240)







![186Relaxed Vertex Index and Command Order• OpenGL today always executes commands “in order”• Sequentially requirement• Provide compile-time specification of re-ordering allowances• Allows GL implementation to re-order• Vertex indices within display list’s vertex batch• Commands within display list• Key rule: state vector rendering command executes in mustmatch the state if command was rendered sequentially• Allow static or dynamic re-ordering• Static re-ordering needed for multi-pass invariances• Past practice• IRIS Performer would sort rendering by state changes forperformance• [Sander 2007] show substantial benefit for vertex ordering](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-186-2048.jpg&f=jpg&w=240)




![191Direct3D vs. OpenGLCoordinate System Conventions• Window origin conventions• Direct3D = upper-left origin• OpenGL = lower-left origin• Pixel center conventions• Direct3D9 = pixel centers at integer locations• OpenGL (and Direct3D 10) = pixel centers at half-pixel locations• Clip space conventions• Direct3D = [-1,+1] for XY, [0,1] for Z• OpenGL = [-1,+1] range for XYZ• Affects• How projection matrix is loaded• Fragment shaders that access the window position• Point sprites have upper-left texture coordinate origin• OpenGL already lets application choose lower-left or upper-left](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fsa2008modernopengl-1231549184153966-1%2f75%2fSIGGRAPH-Asia-2008-Modern-OpenGL-191-2048.jpg&f=jpg&w=240)














