Presentation is loading. Please wait.

Presentation is loading. Please wait.

ARB Fragment Program in GPULib. Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL.

Similar presentations


Presentation on theme: "ARB Fragment Program in GPULib. Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL."— Presentation transcript:

1 ARB Fragment Program in GPULib

2 Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL State Compiler status

3 Fragment program architecture What fragment programs bypass:  Replaces multitexturing pipe: Replaces this calculations:  Texture blending  Color sum  Fog What not (is preserved):  Coverage application  Alpha Test  Stencil and depth test  Blending

4 Fragment program architecture (II) User-defined Fragment Processing frame-buffer ops Color Sum setup Texture Fetch and Application rasterizer Fog

5 Fragment program architecture (III) Attributes Fragment Program Result Registers Temporary Variables Program Local Parameters Program Environment Parameters Address Variables

6 Fragment program architecture(IV) Input attributes (called fragment attributes):  color (primary and secondary)  vector of texture coordinates (for multitexturing)  fog coordinate  position (window position + z) Output attributes:  2 attributes to write: color (r,g,b,a) depth (*,*,d,*)

7 Fragment program architecture(V) Program local and environment parameters:  Like vertex programs: local: private for each fragment program env: shared for all programs (including vertex programs). Limits (the implementation has to guarantee equal or higher limits):  Total Number of instructions: 72 ALU instructions: 48 Texture instructions: 24  Texture indirections: 4  Temporaries: 16  Program parameters: 24

8 New instructions The same instructions as vertex programs:  Except: ARL: Now, no address registers to load LOG, EXP: Remain LG2 and EX2 instructions.  Plus: SIN, COS, SCS(leave sinus on.x and cosinus on.y) LRP (Linear Interpolation instruction) CMP (Compare instruction) Note about ALU instructions:  Implementations may be able to perform fragment program computations at more than one precision:  New program option directives: OPTION ARB_precision_hint_fastest; # Minimize execution time OPTION ARB_precision_hint_nicest; # Maximize execution time

9 New instructions (II) And... the Texture instructions:  Gets texture coordinates of fragment and samples the texture color corresponding to the fragment. TEX myTexel, fragment.texcoord[1], texture[2], 3D;  Extended texture fetches: TXP and TXB

10 Texture indirections A texture dependency occurs when a texture instruction depends on the result of a previous instruction (ALU or texture) for use as its texture coordinate. A fragment program with no dependencies has 1 texture indirections: !!ARBfp1.0 # No texture instructions, but always 1 indirection MOV result.color, fragment.color; END Texture dependencies sums indirection !!ARBfp1.0 # A simple dependent texture instruction, 2 indirections TEMP myColor; MUL myColor, fragment.texcoord[0], fragment.texcoord[1]; TEX result.color, myColor, texture[0], 2D; END

11 New instructions (III) KIL instruction: KIL vectorSrcReg;  Prevents a fragment from receiving any future processing if any component of its source vector is negative  ARB instruction takes a vector operand rather than a condition code (NVIDIA) Saturation Flag:  Optional clamping of each component of the destination register to the range [0,1] is controlled by an opcode modifier.  There is a clamped version of each instruction: ADD_SAT, TEX_SAT, CMP_SAT, LRP_SAT.

12 Instruction emulation SIN, COS, TEX, TXP, TXB supported directly by GPU. SCS:  Emulated using the separate SIN and COS LRP: LPR result, op0, op1, op2; ADD result, op0, -op2; MAD result, result, op1, op2;

13 Instruction emulation CMP: CMP dst, src0, src1, src2; SLT tmp, src0, {0,0,0,0}; LRP dst, tmp, src1, src2;

14 New GLState GLState shared with vertex programs:  Material Properties: material ambient, diffuse, specular (for front and back faces)  Light and Lightmodel Properties: ambient, diffuse, specular, attenuation, spot direction, spot cut-off (for each GL_LIGHTX).  Matrix Properties: Modelview, MVP, projection matrices with.transpose,.inverse,.invtrans modifiers. New GLState:  Texture Environment Color Property: state.texenv[n].color ( n = 0 to #texture units)  Fog Properties: RGB fog color Params (fog density, linear start and end, and 1/(end-start))  Depth Properties: Depth range near, far, and (far-near)

15 Compiler Status !!ARBfp1.0 # Simple program to show how to code up # the default texture environment ATTRIB tex = fragment.texcoord; #first set of texture # coordinates ATTRIB col = fragment.color.primary; OUTPUT outColor = result.color; TEMP tmp; TXP tmp, tex, texture, 2D; #sample the texture MUL outColor, tmp, col; #perform the modulation END Flex + Bison (Completed) !!ARBvp1.0 IR Code Generation Específico GPU Generic + TEX,CMP,... Line:By0By1By2By3By4By5By6By7By8By9ByAByBByByDByEByF 011: 16 00 03 28 00 01 00 08 26 1b 6a 00 0f 1b 04 78 012: 09 00 03 00 00 00 02 08 24 1b 1b 00 08 1b 14 18 013: 09 00 04 00 00 00 02 08 24 1b 1b 00 04 1b 14 b8 014: 09 00 05 00 00 00 02 08 24 1b 1b 00 02 1b 04 58 015: 09 00 06 00 00 00 02 08 24 1b 1b 00 01 1b 04 f8 016: 16 00 01 00 00 00 02 30 24 1b 1b 00 08 1b 14 98 017: 16 00 02 00 00 01 02 30 24 1b 1b 00 08 1b 04 38 018: 16 00 00 00 00 00 03 30 24 00 1b 00 02 1b 04 d8 019: 16 00 01 00 00 00 03 30 24 00 1b 00 01 1b 14 78 020: 01 00 08 00 00 08 18 08 24 04 ae 00 0c 1b 04 18 021: 17 00 00 00 00 00 13 30 24 00 00 00 08 1b 04 b8 022: 17 00 01 00 00 00 13 30 24 00 00 00 04 1b 14 58 023: 01 00 08 00 00 09 18 08 24 04 04 00 0c 1b 14 f8 024: 01 00 08 00 00 0a 18 08 26 04 ae 00 0c 1b 04 98 025: 01 00 08 00 00 0b 18 08 26 04 04 00 0c 1b 14 38 (Completed) Current work:

16 Compiler Status Lexical and Syntactical: Complete Translation of generic to GPU instructions: Complete Current Work:  Generating new IR for the fragment program grammar.  Semantic Parse and Code generation parse


Download ppt "ARB Fragment Program in GPULib. Summary Fragment program arquitecture New instructions.  Emulating instructions not supported directly New Required GL."

Similar presentations


Ads by Google