nvfx: A New Shader-Effect Framework for OpenGL, DirectX and Even Compute Tristan Lorach ( tlorach@nvidia.com )



Similar documents
NVFX : A NEW SCENE AND MATERIAL EFFECT FRAMEWORK FOR OPENGL AND DIRECTX. TRISTAN LORACH Senior Devtech Engineer SIGGRAPH 2013

Optimizing AAA Games for Mobile Platforms

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

CSE 564: Visualization. GPU Programming (First Steps) GPU Generations. Klaus Mueller. Computer Science Department Stony Brook University

BRINGING UNREAL ENGINE 4 TO OPENGL Nick Penwarden Epic Games Mathias Schott, Evan Hart NVIDIA

NVPRO-PIPELINE A RESEARCH RENDERING PIPELINE MARKUS TAVENRATH MATAVENRATH@NVIDIA.COM SENIOR DEVELOPER TECHNOLOGY ENGINEER, NVIDIA

ANDROID DEVELOPER TOOLS TRAINING GTC Sébastien Dominé, NVIDIA

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

Recent Advances and Future Trends in Graphics Hardware. Michael Doggett Architect November 23, 2005

Introduction to GPGPU. Tiziano Diamanti

Vulkan on NVIDIA GPUs. Piers Daniell, Driver Software Engineer, OpenGL and Vulkan

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

GPGPU Computing. Yong Cao

Introduction GPU Hardware GPU Computing Today GPU Computing Example Outlook Summary. GPU Computing. Numerical Simulation - from Models to Software

OpenGL Insights. Edited by. Patrick Cozzi and Christophe Riccio

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

GPU Architecture. Michael Doggett ATI

Performance Optimization and Debug Tools for mobile games with PlayCanvas

Writing Applications for the GPU Using the RapidMind Development Platform

Outline. srgb DX9, DX10, XBox 360. Tone Mapping. Motion Blur

Radeon HD 2900 and Geometry Generation. Michael Doggett

GPU Christmas Tree Rendering. Evan Hart

Programming 3D Applications with HTML5 and WebGL

iz3d Stereo Driver Description (DirectX Realization)

L20: GPU Architecture and Models

The Future Of Animation Is Games

Developer Tools. Tim Purcell NVIDIA

Optimizing Unity Games for Mobile Platforms. Angelo Theodorou Software Engineer Unite 2013, 28 th -30 th August

The Evolution of Computer Graphics. SVP, Content & Technology, NVIDIA

OpenGL Performance Tuning

Image Synthesis. Transparency. computer graphics & visualization

Computer Graphics Hardware An Overview

Midgard GPU Architecture. October 2014

How To Use An Amd Graphics Card In Greece And (Amd) With Greege (Greege) With An Amd Greeper 2.2.

A Hybrid Visualization System for Molecular Models

NVIDIA GeForce GTX 580 GPU Datasheet

ATI Radeon 4800 series Graphics. Michael Doggett Graphics Architecture Group Graphics Product Group

Programmable Graphics Hardware

Advanced Graphics and Animations for ios Apps

TEGRA X1 DEVELOPER TOOLS SEBASTIEN DOMINE, SR. DIRECTOR SW ENGINEERING

How To Teach Computer Graphics

3D Stereoscopic Game Development. How to Make Your Game Look

How To Understand The Power Of Unity 3D (Pro) And The Power Behind It (Pro/Pro)

Computer Applications in Textile Engineering. Computer Applications in Textile Engineering

What is GPUOpen? Currently, we have divided console & PC development Black box libraries go against the philosophy of game development Game

Low power GPUs a view from the industry. Edvard Sørgård

Parallel Web Programming

GPU Profiling with AMD CodeXL

Overview. Lecture 1: an introduction to CUDA. Hardware view. Hardware view. hardware view software view CUDA programming

Flame On: Real-Time Fire Simulation for Video Games. Simon Green, NVIDIA Christopher Horvath, Pixar

OpenGL Shading Language Course. Chapter 5 Appendix. By Jacobo Rodriguez Villar jacobo.rodriguez@typhoonlabs.com

How To Develop For A Powergen 2.2 (Tegra) With Nsight) And Gbd (Gbd) On A Quadriplegic (Powergen) Powergen Powergen 3

AMD GPU Architecture. OpenCL Tutorial, PPAM Dominik Behr September 13th, 2009

Dynamic Resolution Rendering

Color correction in 3D environments Nicholas Blackhawk

Game Development in Android Disgruntled Rats LLC. Sean Godinez Brian Morgan Michael Boldischar

Equalizer. Parallel OpenGL Application Framework. Stefan Eilemann, Eyescale Software GmbH

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Computer Graphics on Mobile Devices VL SS ECTS

Real-Time Realistic Rendering. Michael Doggett Docent Department of Computer Science Lund university

How To Write A Cg Toolkit Program

Finger Paint: Cross-platform Augmented Reality

Graphics Cards and Graphics Processing Units. Ben Johnstone Russ Martin November 15, 2011

Radeon GPU Architecture and the Radeon 4800 series. Michael Doggett Graphics Architecture Group June 27, 2008

AMD RenderMonkey IDE Version 1.71

Medical Image Processing on the GPU. Past, Present and Future. Anders Eklund, PhD Virginia Tech Carilion Research Institute

Workshop on Android and Applications Development

CLOUD GAMING WITH NVIDIA GRID TECHNOLOGIES Franck DIARD, Ph.D., SW Chief Software Architect GDC 2014

Advanced Visual Effects with Direct3D

NVIDIA workstation 3D graphics card upgrade options deliver productivity improvements and superior image quality

GPUs Under the Hood. Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology

Beyond 2D Monitor NVIDIA 3D Stereo

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Introduction to Computer Graphics

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

QCD as a Video Game?

Broken Shard. Alpha Report. Benjamin Schagerl, Dominik Dechamps, Eduard Reger, Markus Wesemann. TUM Computer Games Laboratory

Deferred Shading & Screen Space Effects

GPU(Graphics Processing Unit) with a Focus on Nvidia GeForce 6 Series. By: Binesh Tuladhar Clay Smith

Image Processing & Video Algorithms with CUDA

Monash University Clayton s School of Information Technology CSE3313 Computer Graphics Sample Exam Questions 2007

Game Design From Concepts To Implementation

Android and OpenGL. Android Smartphone Programming. Matthias Keil. University of Freiburg

Lecture 1 Introduction to Android

NVIDIA IndeX Enabling Interactive and Scalable Visualization for Large Data Marc Nienhaus, NVIDIA IndeX Engineering Manager and Chief Architect

Beginning Android 4. Games Development. Mario Zechner. Robert Green

Overview Motivation and applications Challenges. Dynamic Volume Computation and Visualization on the GPU. GPU feature requests Conclusions

QuickSpecs. NVIDIA Quadro K5200 8GB Graphics INTRODUCTION. NVIDIA Quadro K5200 8GB Graphics. Technical Specifications

Maximize Application Performance On the Go and In the Cloud with OpenCL* on Intel Architecture

A Crash Course on Programmable Graphics Hardware

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

Advanced Rendering for Engineering & Styling

JavaFX Session Agenda

GPU Tools Sandra Wienke

The In and Out: Making Games Play Right with Stereoscopic 3D Technologies. Samuel Gateau

QuickSpecs. NVIDIA Quadro K5200 8GB Graphics INTRODUCTION. NVIDIA Quadro K5200 8GB Graphics. Overview. NVIDIA Quadro K5200 8GB Graphics J3G90AA

Instructor. Goals. Image Synthesis Examples. Applications. Computer Graphics. Why Study 3D Computer Graphics?

Transcription:

nvfx: A New Shader-Effect Framework for OpenGL, DirectX and Even Compute Tristan Lorach ( tlorach@nvidia.com )

Plan What is an Effect How to redefine the Effect paradigm Examples More Details on concepts Conclusion

What Is An Effect? Higher level management: packages things together Of Shader Code Uniforms / Parameters Samplers, Textures and Sampler States Concept of Techniques and Passes Passes : setup Shaders and render states for a rendering pass Techniques : groups Passes NOTE : Effect is mostly CPU runtime work Maintains the Effect Database and updates/binds GPU

What Is An Effect? (Cont ) In 2002 Cg and CgFX created by NVIDIA Microsoft followed on the idea, for HLSL : HLSLFx Check out NVIDIA SDK Samples & Microsoft SDK Samples In 2013 : Game Developers often have their own shader-builders Cg 3.1 in maintenance mode not expected to evolve Why? Issues of maintenance Microsoft D3D Effect: No significant evolution

Anatomy Of An Effect Uniforms / Parameters somefunction(args ) { Shader code Samplers / Textures Technique mytechname { Pass mypassname { Render / Shader States someotherfunction(args ) { Shader code Pass mypassname2 { Uniforms / Parameters Technique mytechname2 {

Standard Effect design Parameters Application Shader func s Texture Samplers Textures (D3D) Effect file Initialization Effect runtime Render loop Render states Shaders GPU Samplerstates Resources /uniforms Techniques Passes Renderstates Set/Get parameters Validate passes (builds shaders) Bind textures/samplers Activate (executes) a Pass

Generic Effect Container : Motivations Revive Effect concept for today s needs & HW Be a Generic Container for GLSL, D3D, Compute, OptiX Add new concepts and features (Add resource creation; etc.) Use latest 3D API features (OpenGL 4.3 or DX11.x and >) Help to simplify applications and C++ code Runtime efficiency Multi-Platform (Windows, Linux, OSX, ios, Android) Make it Open-Source

What nvfx Can *Not* do Few cool CgFX features not in nvfx One unified language (Cg language) for all (D3D, OpenGL ) CgFx Interfaces ( ~== Abstract classes) nvfx can t modify shading languages grammar nvfx relies on GLSL, D3D, CUDA compilers nvfx shader code not unified OpenGL!= GL-ES!= D3D!= CUDA features Doesn t sort and optimize Drawcalls for you Regal could help on OpenGL <> GL-ES

Potential User Target Workstation CAD/DCC Convenient to expose some programmability to the end-user Helps for maintenance of heavy projects Labs / research (Prototype for a Siggraph paper!) Helps to perform rapid and flexible prototyping Convenient for Demos, Samples showcasing Shaders Games Helps highly combinatorial Shaders Avoids heavy pre-processor code (#ifdef/#else/#endif everywhere)

nvfx Effect Integration nvfx files Shader code code Techs/passes Techs/passes nvfx files Techs/passes Techs/passes Shader Shader code code Application nvfx runtime Application nvfx runtime nvfxcc.exe omyfx.cpp myfx.glslfx nvfx files Techs/passes Shader code Shader code Precompiled shaders Application C++ nvfx Effects nvfx runtime Precompiled shaders Make better diagram on details (loop, resource)

API Design Front-End : parser (Bison/Flex) Parses the effect Does not parse the shader/compute code in Modules! Back-End : the library to build the effect data Used by the Front-End to create parsed data Used by the application to drive the effects Works on PC, Android ios etc. Application Your Front-End Parser Front-End (nvfx parser) Custom Grammar & Token API (C++ interfaces) C++ Back-End (nvfx runtime) OpenGL DX CUDA Your Gfx API layer

Inside An nvfx Effect Uniform Parameters Constant Buffers Render state-groups Shader Code Modules GLSL D3D GLSL-Compute DXCompute CUDA Techniques Passes New Pass-states Resources description Sampler-states Texture Bind point Resources (render targets) Frame buffers CUDA/OptiX/Compute [shared] Memory nvfx file

Simple nvfx Example GLSLShader { #version 410 compatibility #extension GL_ARB_separate_shader_objects : enable GLSLShader ObjectVS { layout(location=0) in vec4 Position; layout(location=0) out vec3 v2fworldnormal; void main() { GLSLShader ObjectPS { layout(location=0) in vec3 v2fworldnormal; Main() { rasterization_state myrstates { POLYGON_MODE = FILL; sampler_state defaultsamplerstate { TEXTURE_MIN_FILTER = LINEAR_MIPMAP_LINEAR; TEXTURE_MAG_FILTER = LINEAR; Resource2D difftex { samplerstate = defaultsamplerstate; defaultfile = "gargoylemossydiffuse.dds"; technique BasicTechnique { pass p1 { rasterization_state = myrstates; samplerresource(diffsampler) = { difftex, 0 ; VertexProgram = ObjectVS; FragmentProgram = ObjectPS; Uniform(attenuation) = 0.9; CurrentTarget = backbuffer;

Simple nvfx Example : On C++ Side Initialization: Validate effect s passes (Checks errors, compile shaders ) Create/Gather any object we need for update (Uniforms to set etc.) Rendering Loop: Loop in a Technique (taken from a material id, for example) Set some Uniform values (projection matrix ) Loop in the Passes For each pass : Execute it Optionally update Uniforms/Cst Buffers afterward Render your geometry

Example : HDR Rendering With Glow 1 2 Scene Effect Render Skybox in HDR Render The Scene in HDR nvfx-managed Resources RGBA32F Texture (HDR) Scene Graph 1 2 3 775 6 4 3 4 Down-scale the texture 2x, 4x RGBA 32F Texture Material Effect 1 5 6 7 Blur texture Horizontal Then Vertical Compositing: tone-mapping And radial Blur + Backbuffer Metal Pass Material Effect 2 Plastic pass Other Effects

Example : Compute Post-Processing Scene Effect passes 1 2 Render Skybox Render The Scene Scene Graph Material Effect 1 Metal Pass Material Effect 2 Plastic pass nvfx-managed Resources RGBA Texture 3 4 Triggers CUDA / GLSL / DX-Compute Kernel Display result As a fullscreen Quad Other Effects Backbuffer

Demo Bokeh Filter Convolution

Technique nvfx-managed Resources Fire (Navier-Stokes equations) 1 Simulation passes Advect Color Advect Velocity Vorticity Confinement 2 Volume depth Volume bound 1 Volume bound 2 3 Volume depth Smoke Ray-cast Water Ray-cast Fire Ray-cast 4 Rasterize Rasterize result Emit (Gaussian ball) Fire Up-force Vel. divergence Comp. pressure Proj. Velocity Techniques Proj. Vel. edges passes

Experiment : Pure Ray Tracing With OptiX Scene Effect passes 1 2 Triggers OptiX Context Display result As a fullscreen Quad nvfx-managed Resources RGBA Texture Backbuffer Most OptiX runtime code nvfx runtime Most OptiX Shader code In nvfx files In CUDA/PTX files nvfx Needs OptiX NVIDIA SDK Few OptiX setup from the application

Hybrid Rendering : Mixing OpenGL & OptiX Scene Effect passes 1 2 Render Skybox Render The Scene Scene Graph Material Effect 1 Metal Pass nvfx-managed resources 3 Triggers OptiX Ray Tracing For Reflections and shadow Material Effect 2 Plastic pass Other Effects 4 Compositing OpenGL + reflection & shadow

Demo

Example: GS Sparkling Effect 1 Scene Effect Render Scene For 2 targets nvfx-managed resources RGBA8 Texture R32F Texture (depth) 2 Scene Graph 2 Copy Texture To Backbuffer Material Effect 1 1 3 Metal Pass 3 Render Sparkles With GS Backbuffer backbuffer Material Effect 2 Plastic pass Other Effects

Shader Code In Effect GLSL, D3D, CUDA, GLSL-Compute, DX-Compute Not Parsed We rely on existing compilers D3D Driver : for Gfx Shaders and Compute GLSL OpenGL driver : for Gfx Shaders and Compute CUDA compiler nvfx invokes APIs to compile shaders No redundant work But nvfx doesn t know what is inside (did not parse the code) nvfxcc.exe : check errors (and will generate C++ code)

Shader Code Declared within a section : GLSLShader myshader { layout(location=0) in vec4 Position; void main(void) { CUDAKernel Blur(unsigned int* data, int imgw, ) { CUDA code D3D10Shader myd3dshader { HLSL code

Shared Code sections No name == is shared by all (implicit header) GLSLShader { // used by myvshader and myfshader #version 430 compatibility vec3 somevectormath(vec3 a, vec3 b) { GLSLShader myvshader { Void Main() { GLSLShader myfshader { Void Main() { CUDACode { device float clamp(float x, float a, float b); CUDACode CUDACode1 { CUDACode CUDACode2 {

Techniques & Passes A technique hosts passes. Nothing new A Pass carries render-pipeline setup and actions References to State-Groups Or direct References to render-states (old style as CgFX) References to many Shaders (Vertex, Fragment etc.) Value assignment to uniform parameters GLSL sub-routine each pass can setup a set of default uniform values Connection of samplers/textures with resources & Sampler-states Connection of images (ARB_shader_image_load_store) with resources Lots of other special states to drive the runtime behavior Clear mode (glclear mode ) Clear color Rendering Mode Render Group Id Blit action of a resource to a target Current Target for rendering Viewport Size Swap of 2 resources Loop count (to repeat passes) Activate Pass On/Off CUDA Module; Shared Mem. Grid/Block GLSL Compute Groups

Pass example Pass mypass { RasterizationState = myrasterstate; POLYGON_MODE = {GL_FRONT_AND_BACK, GL_FILL; VertexShader = {MainVtxProg, HelperFunctions, InputAttribFunc; FragmentShader = MainFragmentShader FragmentShader< LightShaders >= {LightSpotFunc, LightDirFunc, ; Uniform(mySubroutineArray) = {sr_spot, sr_point, sr_dir; Uniform(myOtherSubroutineArray[0]) = srfunc32; Uniform(myOtherSubroutineArray[1]) = srfunc6; Uniform(mySimpleUniform) = {1.3, 2.2, 5.2; SamplerResource(quadSampler) = myrendertexture; SamplerTexUnit(quadSampler) = 0; SamplerState(quadSampler) = nearestsampler; Clarify the Pass definition

Linkage of Shader Modules Pass : Link Shader Modules to a program Object Done at Validation time In Non-Separable Shader mode : 1 Pass hosts 1 program In Separable Shader Mode: 1 Pass hosts many programs OpenGL 4.2/4.3 : nvfx uses GLSL linkage OpenGL ES: nvfx fakes linkage with concatenation VertexProgram = {VtxMain, ShaderHelpers, ShaderA, ShaderB, ; FragmentProgram = {FragMain, ShaderHelpers, ;

Linkage Of Shaders : Groups We can group shaders by name : VertexShader = myvtxshadermain; VertexShader< Lighting > = {VtxLight0, VtxLight1, Groups allows to Change some behavior at runtime Example: 1. Gather the group of shaders named Lighting 2. Remove these shaders from the Pass (Pass s program) 3. Add other shaders to this Lighting Group (for different lighting ) 4. Link the program with new Shader Objects

Attrib. passthrough abstraction Linkage Use-Case Example attributes IA attributes Same Shading design With OR without Tessellation Vertex Shader (passthrough) Hull (TCS) Attributes Abstration (a) Vertex Shader interpolators getnormal() Vtx Shader Body Fragment Shader HW Tess. Attributes Abstration (b) Domain (TES) interpolators

Resources in nvfx Visual Effects resources : often inter-dependent Example : deferred shading G-Buffer really depends on how the effect does deferred shading Compute Graphics : interaction through resources Compute reading from a rendered image and writing into a Textures Compute kernels sometimes need temporary storage nvfx allows creation of resources within an effect

Resource Creation And Use Create resources : RenderTexture myrtex1 { MSAA = {0,0; Size = ApplicationDefined;// or {800,600; Format = RGBA8; RenderTexture myrtex2 { RenderBuffer mydst { MSAA = {0,0; Size = ApplicationDefined;// or {800,600; Format = DEPTH24STENCIL8; Create Frame Buffer Object FBO myfbo { Color = { myrtex1, myrtex2 ; DST = mydst; Use this in Passes CurrentTarget = myfbo;//(can be backbuffer) BlitFBOToActiveTarget = myfbosrc; swapresources( mfbo1, myfbo2 ); samplerresource(mysampler) = myrtex1; You can query all from your Application, too

Scene-Level / Multi-Level Effects pre/post-processing are Effects, too : at scene level Scene-level Effects and material Effects must be consistent Deferred shading : Material RT s must match the G-Buffer Shadowing of the scene : must tell materials how to use Shadowing Special scene lighting to tell material Shaders how to do lighting nvfx Allows Effect (Scene-level) to override some Shader Modules of lower levels effects lower Effect s shaders code adapted for higher Effects Leads to instances of shader programs matching scene-level passes

Example of Scene-level override Scene-level Effect Pass renderscene { ClearMode = all; FragmentProgramOverride<"out > = forgbuff; FragmentProgramOverride< light > = nolight; CurrentTarget = mygbuffer; rendermode = render_scenegraph_shaded; Pass deferredlighting { VertexProgram = deferredlightingvs; FragmentProgram = deferredlightingps; rendermode = render_fullscreen_quad; CurrentTarget = backbuffer; Material Effect in the scene Pass mymatpass1 { VertexProgram = myvtxprog; FragmentProgram = {helpers, mainentry; FragmentProgram<out> = simpleoutput; FragmentProgram<light> = defaultlighting; New instance of mymatpass1 FragmentProgram = {helpers, mainentry; FragmentProgram<out> = forgbuff; FragmentProgram<light> = nolight;

GLSLShader mainentry Example of Scene-level override { void main() { Scene-level Effect lighting_compute(lightinfos, res); Pass renderscene { finalcolor(n, ClearMode = all; color, tc, p, matid); FragmentProgramOverride<"out > = forgbuff; FragmentProgramOverride< light > = nolight; CurrentTarget = mygbuffer; GLSLShader rendermode simpleoutput = render_scenegraph_shaded; { layout(location=0) Pass deferredlighting out { vec4 outcolor; void VertexProgram finalcolor(vec3 = deferredlightingvs; normal, vec4 colorsrc, FragmentProgram vec3 tc, = deferredlightingps; vec3 p, int matid) { rendermode = render_fullscreen_quad; CurrentTarget outcolor = colorsrc; = backbuffer; GLSLShader forgbuff { layout(location=0) out vec4 outcolor; layout(location=1) out vec4 outnormal; void finalcolor(vec3 normal, vec4 colorsrc, Material Effect vec3 tc, in vec3 the p, scene int matid) { Pass outnormal mymatpass1 = { VertexProgram outcolor = myvtxprog; FragmentProgram = {helpers, mainentry; FragmentProgram<out> = simpleoutput; FragmentProgram<light> = defaultlighting; GLSLShader nolight GLSLShader { defaultlighting New instance of mymatpass1 { void lighting_compute(lightinfos infos, FragmentProgram = {helpers, mainentry; void inout lighting_compute(lightinfos LIGHTRES res) {/*empty*/ infos, FragmentProgram<out> = forgbuff; inout LIGHTRES res) { FragmentProgram<light> Some OpenGL-style = nolight; lighting

State Groups The modern way to use renderstate : DX10/11 default way OpenGL : maybe extension Rasterization States Color Sample States Depth-Stencil States Remove? Define many of them in the effect : rasterization_state myrasterstate1 { POINT_SIZE=1.2; rasterization_state myrasterstate2 { CULL_FACE=FALSE; color_sample_state mycsstate1 { BLEND=TRUE; ALPHA_TEST=FALSE; dst_state mydststate { DEPTH_TEST=TRUE; DEPTH_WRITEMASK=TRUE; State groups can then used in Passes

Sampler States Sampler state is an nvfx Object Maintained by nvfx and mapped to the API Eventually translated as GLSL Samplers state (extension) Can be connected in a Pass or via Textures or Resources GLSLShader myshader { uniform sampler2d colorsampler; sampler_state mysamplerstate { MIN_FILTER = GL_LINEAR_MIPMAP_LINEAR; MAG_FILTER = GL_NEAREST; ; REMOVE? Pass mypass { SamplerState(colorSampler) = mysamplerstate ; ;

Uniforms Make them 1 SLIDE Application nvfx runtime Effect Load Effect & & initialize it createuniform() set () update () createuniform() set () update () Effect Obj. Uniform Binding point diffcol Uniform Binding point foo Target 1 Target 2 GLSLShader myfragshader { uniform vec3 diffcol; uniform sampler2d mysampler main() { using diffcol GLSLShader myvtxshader { uniform vec3 diffcol; main() { using diffcol (Other targets)

Uniforms Application nvfx runtime Effect Load Effect & & initialize it finduniform( diffcol ) set () update () Effect Obj. Uniform Binding point diffcol Target 1 Target 2 GLSLShader myfragshader { uniform vec3 diffcol ; uniform sampler2d mysampler main() { using diffcol GLSLShader myvtxshader { uniform vec3 diffcol ; main() { using diffcol : SEMDIFF;

Uniforms Application nvfx runtime Effect Load Effect & & initialize it finduniform( diffcol ) set () update () Effect Obj. Uniform Binding point diffcol Pass s uniform Binding point diffcol Target 1 uniform vec3 diffcol; GLSLShader myfshader { uniform sampler2d mysampler main() { using diffcol Technque tech1 { Pass p1 { fragmentshader = myfshader diffcol = {0.3, 0.5, 1.0;

Buffers of Uniforms (Buffer Objects) Direct mapping to OpenGL Uniform Buffer Object (UBO + GLSL std140) D3D10/11 Cst Buffers (cbuffer token in HLSL) A constant Buffer is made of uniforms Can be targeted by a Uniform Object Can have default values specified by nvfx code Two ways for buffer s resource creation : application created : pass the handle to nvfx nvfx creates the buffer for you

Performances Possible performance issues Runtime implementation Pass execution Update of Uniform / Cst. Buffer / sampler / resource More CPU optimization can be done (Open-Source helps) This first version prioritizes nvfx s proof of concept Users will always need to be careful Avoid too many pass executions Avoid too many uniform update NSight Custom Markers in nvfx

Conclusion Less code in Application More flexibility Consistency of Effect code. Helps for maintenance and creativity Updated Effect paradigm for modern API s Open-Source approach to allow developers to Easily debug it Improve it Customize it

Questions? Feedback welcome : tlorach@nvidia.com References: - http://developer.nvidia.com - https://github.com/p3/regal - https://github.com/tlorach/nvfx (Soon available)