1 / 17

ARBVP10 FrameWork in GLLib

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. ProgramObject. Assembles source code to GPU binary code. !!ARBvp1.0 ...

ruby
Télécharger la présentation

ARBVP10 FrameWork in GLLib

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ARBVP10 FrameWork in GLLib

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

  3. ProgramObject Assembles source code to GPU binary code !!ARBvp1.0 ... END • 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. 0x09 0x00 0x00 0x03 ... 0x09 0x00 0x00 0x02 ... 0x16 0x10 0x00 0x00.... compile() getClusterBank() ARBVP10 FrameWork in GLLib • Basic Object Class to encapsulate a vertex program: the ProgramObject.

  4. 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.

  5. 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<float>& b); public: VSLoader(); void setDriver(GPUDriver* driver); u32bit emulateFixedPipe(); u32bit initVP(ProgramObject& po); };

  6. 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 ); It uses a GLState class to resolve actual values of the OpenGL State required for the vertex program. u32bit initVP(ProgramObject& po); VSLoader class class VSLoader { private: ProgramObject* tl; // t&l program GPUDriver* driver; // current driver void resolveBank(ProgramObject& po, RBank<float>& b); public: VSLoader(); void setDriver(GPUDriver* driver); u32bit emulateFixedPipe(); u32bit initVP(ProgramObject& po); };

  7. 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.

  8. 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.

  9. 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.

  10. 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 !!!.

  11. Vertex Attributes management through GPUDriver

  12. 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()

  13. Vertex Attributes management • Send vertices implies: • 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.

  14. 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().

  15. 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().

  16. 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)

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

More Related