Automated Combination Of Real-Time Shader Programs Matthias Trapp :: Jürgen Döllner + =
Outline <ul><li>1. Motivation </li></ul><ul><li>2. Concept </li></ul><ul><li>3. Tagging Shader Source Code </li></ul><ul><...
1. Motivation <ul><li>Problem: </li></ul><ul><li>Fixed-function pipeline is obsolete </li></ul><ul><li>Functionality is pr...
1. Motivation <ul><li>Example Scenegraph </li></ul>
2. Concept - Overview <ul><li>Modular principle for each shader type: </li></ul><ul><li>Basically: Dynamic uber-shader con...
2. Concept - Decomposition <ul><li>Shader functionality is split into handler with  predefined semantics </li></ul>
2. Concept - Combination
2. Concept – Decompostion Details <ul><li>Shader: set of shader handler ( SH ) </li></ul><ul><li>Prototype ( P ) </li></ul...
3. Tagging Shader Source Code <ul><li>Extend shading language grammar (here GLSL) </li></ul><ul><li>Shader Handler Example...
4. Preprocessing Step <ul><li>Transforms tagged source into: </li></ul><ul><ul><li>Intermediate source code (language spec...
5. Shader Combination <ul><li>During Pre-traversal by Shader Management System (SMS) </li></ul><ul><ul><li>Create priority...
6. Conclusion <ul><li>Summary </li></ul><ul><li>Combination of shader programs </li></ul><ul><li>Generic uber-shader const...
Thank You. [email_address] [email_address] :: www.vrs3d.org :: www.hpi.uni-potsdam.de ::
Thank You. [email_address] [email_address] :: www.vrs3d.org :: www.hpi.uni-potsdam.de ::
2. Concept – Interfaces <ul><li>Properties </li></ul><ul><li>Shared state between shader handler </li></ul><ul><li>Depend ...
2. Concept – Execution Modes <ul><li>Control shader handler execution </li></ul><ul><ul><li>Propagate active state of prog...
2. Concept – Execution Modes <ul><li>Example Scenegraph </li></ul>
Upcoming SlideShare
Loading in …5
×

Automated Combination of Real Time Shader Programs (EG 2007)

1,013 views
943 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,013
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Automated Combination of Real Time Shader Programs (EG 2007)

  1. 1. Automated Combination Of Real-Time Shader Programs Matthias Trapp :: Jürgen Döllner + =
  2. 2. Outline <ul><li>1. Motivation </li></ul><ul><li>2. Concept </li></ul><ul><li>3. Tagging Shader Source Code </li></ul><ul><li>4. Preprocessing Step </li></ul><ul><li>5. Shader Combination </li></ul><ul><li>6. Conclusions </li></ul>
  3. 3. 1. Motivation <ul><li>Problem: </li></ul><ul><li>Fixed-function pipeline is obsolete </li></ul><ul><li>Functionality is provided by shader programs </li></ul><ul><li>Combine functionality  combine programs </li></ul><ul><li>Goals: </li></ul><ul><li>Minimize shader permutations </li></ul><ul><li>Dynamic configuration of combined programs </li></ul><ul><li>Keep functionality of individual shaders </li></ul><ul><li>Enable nesting of shader programs </li></ul><ul><li>Applications </li></ul><ul><li>Shader-driven rendering engines </li></ul><ul><li>Emulate orthogonal fixed function pipeline features </li></ul><ul><li>Dynamic material systems </li></ul>
  4. 4. 1. Motivation <ul><li>Example Scenegraph </li></ul>
  5. 5. 2. Concept - Overview <ul><li>Modular principle for each shader type: </li></ul><ul><li>Basically: Dynamic uber-shader construction </li></ul><ul><li>Exploits static branching to control execution paths </li></ul><ul><li>Main phases: </li></ul><ul><ul><li>Decomposition shader into shader handler (next) </li></ul></ul><ul><ul><li>Preprocessing of shader handler to intermediate shader source </li></ul></ul><ul><ul><li>Combination of intermediate shaders to a single uber-shader </li></ul></ul>= +
  6. 6. 2. Concept - Decomposition <ul><li>Shader functionality is split into handler with predefined semantics </li></ul>
  7. 7. 2. Concept - Combination
  8. 8. 2. Concept – Decompostion Details <ul><li>Shader: set of shader handler ( SH ) </li></ul><ul><li>Prototype ( P ) </li></ul><ul><ul><li>Represents an atomic functionality </li></ul></ul><ul><ul><li>Assigned to a shader handler: P = prototype(SH) </li></ul></ul><ul><li>Prototype List ( PL ) </li></ul><ul><ul><li>Defines explicit order upon prototypes </li></ul></ul><ul><ul><li>Important for handler combination </li></ul></ul><ul><li>P & PL </li></ul><ul><ul><li>Defined by developer in advance </li></ul></ul><ul><ul><li>Differs for each shader type (vertex, fragment, …) </li></ul></ul>
  9. 9. 3. Tagging Shader Source Code <ul><li>Extend shading language grammar (here GLSL) </li></ul><ul><li>Shader Handler Example: </li></ul>handler [ local | global | optional | explicite | ignore ] hName ( interface iName ) handler local onLighting ( interface context ) { vec3 fragNormal = normalize ( context.us_Frag Normal ); vec3 fragView = normalize ( context.us_Frag View ); vec3 fragLight = normalize ( context.us_Frag Light ); vec3 reflection = normalize (reflect(-phongLight, phongNormal)); float NdotL = max (0.0, dot (fragNormal, fragLight)); float VdotR = dot (fragView, reflection); float VdotRExp = pow ( max (0.0, VdotR), context.us _FrontMaterial.shininess ); context.us_FragColor = context.us _FrontMaterial.ambient * ( gl_LightSource[0].ambient + gl_LightModel.ambient ) + NdotL * gl_LightSource[0].diffuse * context.us _FrontMaterial.diffuse + VdotRExp * context.us _FrontMaterial.specular * gl_LightSource[0].specular ; return ; }
  10. 10. 4. Preprocessing Step <ul><li>Transforms tagged source into: </li></ul><ul><ul><li>Intermediate source code (language specific) </li></ul></ul><ul><ul><li>Mapping: Shader Handler  Prototype </li></ul></ul><ul><li>Basically via token substitution: </li></ul><ul><ul><li>Insert specific interface source code </li></ul></ul><ul><li>Result is ready for API shading language front-end compiler </li></ul>
  11. 11. 5. Shader Combination <ul><li>During Pre-traversal by Shader Management System (SMS) </li></ul><ul><ul><li>Create priority program list ( PPL ) </li></ul></ul><ul><ul><li>Create controller for each shader type: </li></ul></ul><ul><li>Generated controller configured by an invoker table </li></ul><ul><ul><li>Array of Boolean variables represents activity-state of handler </li></ul></ul><ul><ul><li>Passed to the controller as uniform shader state </li></ul></ul><ul><li>During evaluation of a shader program: </li></ul><ul><ul><li>Activate/deactivate shader handler by modify invoker tables </li></ul></ul><ul><ul><li>With respect to the handler execution modes </li></ul></ul>foreach prototype P  PL do foreach shader program SP  PPL do foreach shader handler SH  SP do if ( prototype(SH) = P ) do appendIfStatement(SH)
  12. 12. 6. Conclusion <ul><li>Summary </li></ul><ul><li>Combination of shader programs </li></ul><ul><li>Generic uber-shader construction </li></ul><ul><li>Parameters to control execution logic </li></ul><ul><li>Drawbacks </li></ul><ul><li>No automatic shader decomposition </li></ul><ul><li>Future Work </li></ul><ul><li>Resource management for shader state </li></ul><ul><li>Enable the usage of LoD shader handler </li></ul><ul><li>Integration into FX formats (CG, Collada,…) </li></ul>
  13. 13. Thank You. [email_address] [email_address] :: www.vrs3d.org :: www.hpi.uni-potsdam.de ::
  14. 14. Thank You. [email_address] [email_address] :: www.vrs3d.org :: www.hpi.uni-potsdam.de ::
  15. 15. 2. Concept – Interfaces <ul><li>Properties </li></ul><ul><li>Shared state between shader handler </li></ul><ul><li>Depend on shader type </li></ul><ul><li>Must be defined in advance </li></ul><ul><li>Deposited as source code in specific shading language </li></ul><ul><li>GLSL Examples </li></ul><ul><li>struct us_VertContext </li></ul><ul><li>{ </li></ul><ul><li>vec4 us_Position; </li></ul><ul><li>vec3 us_Normal; </li></ul><ul><li>float us_PointSize; </li></ul><ul><li>vec4 us_ClipVertex; </li></ul><ul><li>} vertContext; </li></ul>Vertex Handler Interface <ul><li>struct us_FragContext </li></ul><ul><li>{ </li></ul><ul><li>vec4 us_FragColor; </li></ul><ul><li>vec3 us_FragNormal; </li></ul><ul><li>vec3 us_FragView; </li></ul><ul><li>vec3 us_FragLight; </li></ul><ul><li>gl_MaterialParameters us_FrontMaterial; </li></ul><ul><li>float us_FragDepth; </li></ul><ul><li>} fragContext; </li></ul>Fragment Handler Interface
  16. 16. 2. Concept – Execution Modes <ul><li>Control shader handler execution </li></ul><ul><ul><li>Propagate active state of program </li></ul></ul><ul><ul><li>  Activate handler according to execution modes </li></ul></ul><ul><li>Can be configured at runtime for each handler </li></ul><ul><li>Handler execution modes: </li></ul><ul><ul><li>Local : handler is invoked only if the program object is active </li></ul></ul><ul><ul><li>Global : handler will always be invoked </li></ul></ul><ul><ul><li>Optional : invoke handler if no handler of resp. prototype is active </li></ul></ul><ul><ul><li>Explicit: all other handler of this prototype will be disabled </li></ul></ul><ul><ul><li>Ignore : handler will never be invoked </li></ul></ul>
  17. 17. 2. Concept – Execution Modes <ul><li>Example Scenegraph </li></ul>

×