Arbvp10 framework in gllib
Download
1 / 17

ARBVP10 FrameWork in GLLib - PowerPoint PPT Presentation


  • 98 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' ARBVP10 FrameWork in GLLib' - ruby


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Contents
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 gllib1

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.


Arbvp10 framework in gllib2
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

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);

};


Vsloader class1

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);

};


Glstate class
GLState class to GPU.

  • 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
Derived state to GPU.

  • 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
GLState class implementation to GPU.

  • 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 implementation1
GLState class implementation to GPU.

  • 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
Vertex Attributes management to GPU.

  • 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 management1
Vertex Attributes management to GPU.

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


Vertex attributes management2
Vertex Attributes management to GPU.

  • 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 management3
Vertex Attributes management to GPU.

  • 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 management4
Vertex Attributes management to GPU.

  • 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
Last tests. to GPU.

  • “Rosquillas” test

    • Fail: (panic)

      • ShaderEmulator:shIllegal => Instruction not implemented.

    • Must be revisited ;-)

    • In september


ad