15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ATI_text_fragment_shader 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ATI_text_fragment_shader 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Bob Beretta, Apple Computer 125bd8deadSopenharmony_ci Dan Ginsburg, AMD 135bd8deadSopenharmony_ci Evan Hart, NVIDIA 145bd8deadSopenharmony_ci Benj Lipchak, AMD 155bd8deadSopenharmony_ci James McCombe, Apple Computer 165bd8deadSopenharmony_ci Jason Mitchell 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ci and contributors to the ARB_vertex_program working group, 195bd8deadSopenharmony_ci the product of which provided the API for program specification 205bd8deadSopenharmony_ci and object management. 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciContact 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Benj Lipchak, AMD (benj.lipchak 'at' amd.com) 255bd8deadSopenharmony_ci Jeremy Sandmel, Apple Computer (jsandmel 'at' apple.com) 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciStatus 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci Shipping on MacOS X, version 10.2 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciVersion 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci Last Modified Date: November 4, 2006 345bd8deadSopenharmony_ci Author Revision: 1.0.11 (based on 1.5 of ATI_fragment_shader) 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ciNumber 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci 269 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciDependencies 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci ARB_multitexture is required by this extension. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci ARB_shadow interacts with this extension. 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci ARB_vertex_program is referred to for documentation on the 475bd8deadSopenharmony_ci program management API, but not specifically required as long 485bd8deadSopenharmony_ci as the entry points are exported by this extension. 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci ATI_fragment_shader is the architectural basis for this extension, 515bd8deadSopenharmony_ci but is not specifically required by this extension. 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci The extension is written against the OpenGL 1.2.1 Specification. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ciOverview 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci The ATI_fragment_shader extension exposes a powerful fragment 585bd8deadSopenharmony_ci processing model that provides a very general means of expressing 595bd8deadSopenharmony_ci fragment color blending and dependent texture address modification. 605bd8deadSopenharmony_ci The processing is termed a fragment shader or fragment program and 615bd8deadSopenharmony_ci is specifed using a register-based model in which there are fixed 625bd8deadSopenharmony_ci numbers of instructions, texture lookups, read/write registers, and 635bd8deadSopenharmony_ci constants. 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci ATI_fragment_shader provides a unified instruction set 665bd8deadSopenharmony_ci for operating on address or color data and eliminates the 675bd8deadSopenharmony_ci distinction between the two. That extension provides all the 685bd8deadSopenharmony_ci interfaces necessary to fully expose this programmable fragment 695bd8deadSopenharmony_ci processor in GL. 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci ATI_text_fragment_shader is a redefinition of the 725bd8deadSopenharmony_ci ATI_fragment_shader functionality, using a slightly different 735bd8deadSopenharmony_ci interface. The intent of creating ATI_text_fragment_shader is to 745bd8deadSopenharmony_ci take a step towards treating fragment programs similar to other 755bd8deadSopenharmony_ci programmable parts of the GL rendering pipeline, specifically 765bd8deadSopenharmony_ci vertex programs. This new interface is intended to appear 775bd8deadSopenharmony_ci similar to the ARB_vertex_program API, within the limits of the 785bd8deadSopenharmony_ci feature set exposed by the original ATI_fragment_shader extension. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci The most significant differences between the two extensions are: 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci (1) ATI_fragment_shader provides a procedural function call 835bd8deadSopenharmony_ci interface to specify the fragment program, whereas 845bd8deadSopenharmony_ci ATI_text_fragment_shader uses a textual string to specify 855bd8deadSopenharmony_ci the program. The fundamental syntax and constructs of the 865bd8deadSopenharmony_ci program "language" remain the same. 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ci (2) The program object managment portions of the interface, 895bd8deadSopenharmony_ci namely the routines used to create, bind, and delete program 905bd8deadSopenharmony_ci objects and set program constants are managed 915bd8deadSopenharmony_ci using the framework defined by ARB_vertex_program. 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci (3) ATI_fragment_shader refers to the description of the 945bd8deadSopenharmony_ci programmable fragment processing as a "fragment shader". 955bd8deadSopenharmony_ci In keeping with the desire to treat all programmable parts 965bd8deadSopenharmony_ci of the pipeline consistently, ATI_text_fragment_shader refers 975bd8deadSopenharmony_ci to these as "fragment programs". The name of the extension is 985bd8deadSopenharmony_ci left as ATI_text_fragment_shader instead of 995bd8deadSopenharmony_ci ATI_text_fragment_program in order to indicate the underlying 1005bd8deadSopenharmony_ci similarity between the API's of the two extensions, and to 1015bd8deadSopenharmony_ci differentiate it from any other potential extensions that 1025bd8deadSopenharmony_ci may be able to move even further in the direction of treating 1035bd8deadSopenharmony_ci fragment programs as just another programmable area of the 1045bd8deadSopenharmony_ci GL pipeline. 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci Although ATI_fragment_shader was originally conceived as a 1075bd8deadSopenharmony_ci device-independent extension that would expose the capabilities of 1085bd8deadSopenharmony_ci future generations of hardware, changing trends in programmable 1095bd8deadSopenharmony_ci hardware have affected the lifespan of this extension. For this 1105bd8deadSopenharmony_ci reason you will now find a fixed set of features and resources 1115bd8deadSopenharmony_ci exposed, and the queries to determine this set have been deprecated 1125bd8deadSopenharmony_ci in ATI_fragment_shader. Further, in ATI_text_fragment_shader, 1135bd8deadSopenharmony_ci most of these resource limits are fixed by the text grammar and 1145bd8deadSopenharmony_ci the queries have been removed altogether. 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ciIssues 1175bd8deadSopenharmony_ci 1185bd8deadSopenharmony_ci None 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ciNew Procedures and Functions 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci None. 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci NOTE: Though this extension introduces no new procedures and 1265bd8deadSopenharmony_ci functions, it relies on the program object management API from the 1275bd8deadSopenharmony_ci pending ARB_vertex_program extension with the introduction of 1285bd8deadSopenharmony_ci a new program target and program specification syntax. 1295bd8deadSopenharmony_ci See the ARB_vertex_program specification for full details on the 1305bd8deadSopenharmony_ci use of these procedures and functions. 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci ProgramStringARB 1335bd8deadSopenharmony_ci BindProgramARB 1345bd8deadSopenharmony_ci DeleteProgramsARB 1355bd8deadSopenharmony_ci GenProgramsARB 1365bd8deadSopenharmony_ci ProgramEnvParameter4{d,dv,f,fv}ARB 1375bd8deadSopenharmony_ci ProgramLocalParameter4{d,dv,f,fv}ARB 1385bd8deadSopenharmony_ci GetProgramEnvParameter{dv,fv}ARB 1395bd8deadSopenharmony_ci GetProgramLocalParameter{dv,fv}ARB 1405bd8deadSopenharmony_ci GetProgramivARB 1415bd8deadSopenharmony_ci GetProgramStringARB 1425bd8deadSopenharmony_ci IsProgramARB 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ciNew Tokens 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, 1475bd8deadSopenharmony_ci and by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, 1485bd8deadSopenharmony_ci and GetDoublev, and by the <target> parameter of ProgramStringARB, 1495bd8deadSopenharmony_ci BindProgramARB, ProgramEnvParameter4{d,dv,f,fv}ARB, 1505bd8deadSopenharmony_ci ProgramLocalParameter4{d,dv,f,fv}ARB, 1515bd8deadSopenharmony_ci GetProgramEnvParameter{dv,fv}ARB, GetProgramLocalParameter{dv,fv}ARB, 1525bd8deadSopenharmony_ci GetProgramivARB, GetProgramfvATI, and GetProgramStringARB. 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci TEXT_FRAGMENT_SHADER_ATI 0x8200 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL 1575bd8deadSopenharmony_ciOperation) 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci None 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization) 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci Add New Section 3.10, (p. 154) (subsequent sections get incremented) 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci 3.10 Fragment Programs 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci The texture application and texture environments may optionally be 1695bd8deadSopenharmony_ci replaced by an application supplied program referred to here as a 1705bd8deadSopenharmony_ci fragment program. In this case, subsequent processing is still 1715bd8deadSopenharmony_ci applied normally, including fog, color sum, and antialiasing 1725bd8deadSopenharmony_ci application. 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci The framework for specifying and managing fragment programs is 1755bd8deadSopenharmony_ci the one defined in section 5.7 of ARB_vertex_program. For fragment 1765bd8deadSopenharmony_ci programs, TEXT_FRAGMENT_SHADER_ATI is used as the <target> for these 1775bd8deadSopenharmony_ci program management entrypoints. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci A fragment program is similar in concept to a vertex program, 1805bd8deadSopenharmony_ci described in section 2.14 of ARB_vertex_program, except that its 1815bd8deadSopenharmony_ci processing is performed at a later stage in the GL pipeline. Where 1825bd8deadSopenharmony_ci a vertex program takes the current values of the vertex components 1835bd8deadSopenharmony_ci as its inputs, a fragment program takes the fragments and their 1845bd8deadSopenharmony_ci associated data, produced by rasterization, as inputs. Likewise, 1855bd8deadSopenharmony_ci while a vertex program outputs a homogeneous position and a set of 1865bd8deadSopenharmony_ci attributes, a fragment program outputs a color. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci 3.10.1 Fragment Program Grammar and Semantic Restrictions 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci Fragment programs are specified as string of ASCII characters 1915bd8deadSopenharmony_ci encoding the programs. When a program is loaded by a call to 1925bd8deadSopenharmony_ci ProgramStringARB (section 5.7.1), with a target of 1935bd8deadSopenharmony_ci TEXT_FRAGMENT_SHADER_ATI, the program string is parsed into 1945bd8deadSopenharmony_ci a set of tokens possibly separated by white space. Spaces, tabs, 1955bd8deadSopenharmony_ci newlines, carriage returns, and comments are considered whitespace. 1965bd8deadSopenharmony_ci Comments begin with the character "#" and are terminated by a 1975bd8deadSopenharmony_ci newline, a carriage return, or the end of the program array. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci The Backus-Naur Form (BNF) grammar below specifies the syntactically 2005bd8deadSopenharmony_ci valid sequences for fragment programs. The set of valid tokens can 2015bd8deadSopenharmony_ci be inferred from the grammar. The token "" represents an empty 2025bd8deadSopenharmony_ci string and is used to indicate optional rules. A program is invalid 2035bd8deadSopenharmony_ci if it contains any undefined tokens or characters. 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci A text fragment shader program is required to begin with the header 2065bd8deadSopenharmony_ci string "!!ATIfs1.0", without any preceding whitespace. This string 2075bd8deadSopenharmony_ci identifies the subsequent program text as a text fragment shader 2085bd8deadSopenharmony_ci program (version 1.0) that should be parsed according to the 2095bd8deadSopenharmony_ci following grammar and semantic rules. Program string parsing begins 2105bd8deadSopenharmony_ci with the character immediately following the header string. 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci <program> ::= <optionalConstDeclareBlock> 2135bd8deadSopenharmony_ci <optionalPrelimPassBlock> 2145bd8deadSopenharmony_ci <outputPassBlock> 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci <constDeclareBlock> ::= "" 2175bd8deadSopenharmony_ci | "StartConstants" ";" 2185bd8deadSopenharmony_ci <constDeclareSequence> 2195bd8deadSopenharmony_ci "EndConstants" ";" 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci <constDeclareSequence> ::= <constDeclareSequence> <constDeclareStatement> 2225bd8deadSopenharmony_ci | "" 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci <constDeclareStatement> ::= "CONSTANT" <programConstName> "=" <constBinding> ";" 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci <constBinding> ::= <progEnvParam> 2275bd8deadSopenharmony_ci | <programLocalParam> 2285bd8deadSopenharmony_ci | <literalConstBinding> 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ci <progEnvParam> ::= "program" "." "env" 2315bd8deadSopenharmony_ci "[" <progEnvParamNum> "]" 2325bd8deadSopenharmony_ci 2335bd8deadSopenharmony_ci <progEnvParamNum> ::= <integer> from 0 to 7 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci <progLocalParam> ::= "program" "." "local" 2365bd8deadSopenharmony_ci "[" <progLocalParamNum> "]" 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci <progLocalParamNum> ::= <integer> from 0 to 7 2395bd8deadSopenharmony_ci 2405bd8deadSopenharmony_ci <literalConstBinding> ::= "{" <normalizedFloat> "}" 2415bd8deadSopenharmony_ci | "{" <normalizedFloat> "," 2425bd8deadSopenharmony_ci <normalizedFloat> "}" 2435bd8deadSopenharmony_ci | "{" <normalizedFloat> "," 2445bd8deadSopenharmony_ci <normalizedFloat> "," 2455bd8deadSopenharmony_ci <normalizedFloat> "}" 2465bd8deadSopenharmony_ci | "{" <normalizedFloat> "," 2475bd8deadSopenharmony_ci <normalizedFloat> "," 2485bd8deadSopenharmony_ci <normalizedFloat> "," 2495bd8deadSopenharmony_ci <normalizedFloat> "}" 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci <optionalPrelimPassBlock> ::= "" 2525bd8deadSopenharmony_ci | "StartPrelimPass" ";" 2535bd8deadSopenharmony_ci <initRegSequence> 2545bd8deadSopenharmony_ci <aluSequence> 2555bd8deadSopenharmony_ci "EndPass" ";" 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci <outputPassBlock> ::= "" 2585bd8deadSopenharmony_ci | "StartOutputPass" ";" 2595bd8deadSopenharmony_ci <initRegSequence> 2605bd8deadSopenharmony_ci <aluSequence> 2615bd8deadSopenharmony_ci "EndPass" ";" 2625bd8deadSopenharmony_ci 2635bd8deadSopenharmony_ci <initRegSequence> ::= <initRegSequence> <initRegStatement> 2645bd8deadSopenharmony_ci | "" 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci <initRegStatement> ::= <initRegOp> <initRegDst> <initRegSrc> ";" 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ci <initRegOp> ::= "PassTexCoord" 2695bd8deadSopenharmony_ci | "SampleMap" 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ci <initRegDst> ::= <regName> 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci <initRegSrc> ::= <regName> <threeTupleSelect> 2745bd8deadSopenharmony_ci | <texCoordName> <threeTupleSelect> 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ci <aluSequence> ::= <aluSequence> <aluStatement> 2775bd8deadSopenharmony_ci | "" 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci <aluStatement> ::= <unaryOp> <unaryOpArgs> ";" 2805bd8deadSopenharmony_ci | <binaryOp> <binaryOpArgs> ";" 2815bd8deadSopenharmony_ci | <ternaryOp> <ternaryOpArgs> ";" 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ci <unaryOpArgs> ::= <dstInfo> <argInfo> 2845bd8deadSopenharmony_ci <binaryOpArgs> ::= <dstInfo> <argInfo> "," <argInfo> 2855bd8deadSopenharmony_ci <ternaryOpArgs> ::= <dstInfo> <argInfo> "," <argInfo> "," <argInfo> 2865bd8deadSopenharmony_ci 2875bd8deadSopenharmony_ci <dstInfo> ::= <dstName> <optionalDstMask> <optionalDstMod> 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ci <optionalDstMask> ::= "" 2905bd8deadSopenharmony_ci | "." "r" 2915bd8deadSopenharmony_ci | "." "g" 2925bd8deadSopenharmony_ci | "." "rg" 2935bd8deadSopenharmony_ci | "." "b" 2945bd8deadSopenharmony_ci | "." "rb" 2955bd8deadSopenharmony_ci | "." "gb" 2965bd8deadSopenharmony_ci | "." "rgb" 2975bd8deadSopenharmony_ci | "." "a" 2985bd8deadSopenharmony_ci | "." "ra" 2995bd8deadSopenharmony_ci | "." "ga" 3005bd8deadSopenharmony_ci | "." "rga" 3015bd8deadSopenharmony_ci | "." "ba" 3025bd8deadSopenharmony_ci | "." "rba" 3035bd8deadSopenharmony_ci | "." "gba" 3045bd8deadSopenharmony_ci | "." "rgba" 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci <optionalDstMod> ::= <dstModSetting> <optionalSaturate> 3075bd8deadSopenharmony_ci 3085bd8deadSopenharmony_ci <dstModSetting> ::= "" 3095bd8deadSopenharmony_ci | "." "2x" 3105bd8deadSopenharmony_ci | "." "4x" 3115bd8deadSopenharmony_ci | "." "8x" 3125bd8deadSopenharmony_ci | "." "half" 3135bd8deadSopenharmony_ci | "." "quarter" 3145bd8deadSopenharmony_ci | "." "eighth" 3155bd8deadSopenharmony_ci 3165bd8deadSopenharmony_ci <optionalSaturate> ::= "." "sat" 3175bd8deadSopenharmony_ci 3185bd8deadSopenharmony_ci <dstName> ::= <regName> 3195bd8deadSopenharmony_ci 3205bd8deadSopenharmony_ci <argInfo> ::= <argName> <optionalArgReplicate> <optionalArgMod> 3215bd8deadSopenharmony_ci 3225bd8deadSopenharmony_ci <argName> ::= <regName> 3235bd8deadSopenharmony_ci | <programConstantName> 3245bd8deadSopenharmony_ci | <fixedConstantName> 3255bd8deadSopenharmony_ci | <colorName> 3265bd8deadSopenharmony_ci 3275bd8deadSopenharmony_ci <optionalArgReplicate> ::= "" 3285bd8deadSopenharmony_ci | "." "r" 3295bd8deadSopenharmony_ci | "." "g" 3305bd8deadSopenharmony_ci | "." "b" 3315bd8deadSopenharmony_ci | "." "a" 3325bd8deadSopenharmony_ci 3335bd8deadSopenharmony_ci <optionalArgMod> ::= "" 3345bd8deadSopenharmony_ci | <optionalNegate> <optional2Times> <optionalBias> <optionalComplement> 3355bd8deadSopenharmony_ci 3365bd8deadSopenharmony_ci <optionalNegate> ::= "" 3375bd8deadSopenharmony_ci | "." "neg" 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci <optional2Times> ::= "" 3405bd8deadSopenharmony_ci | "." "2x" 3415bd8deadSopenharmony_ci 3425bd8deadSopenharmony_ci <optionalBias> ::= "" 3435bd8deadSopenharmony_ci | "." "bias" 3445bd8deadSopenharmony_ci 3455bd8deadSopenharmony_ci <optionalComplement> ::= "" 3465bd8deadSopenharmony_ci | "." "comp" 3475bd8deadSopenharmony_ci 3485bd8deadSopenharmony_ci <texCoordName> ::= "t0" 3495bd8deadSopenharmony_ci | "t1" 3505bd8deadSopenharmony_ci | "t2" 3515bd8deadSopenharmony_ci | "t3" 3525bd8deadSopenharmony_ci | "t4" 3535bd8deadSopenharmony_ci | "t5" 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci <threeTupleSelect> ::= "." "str" 3565bd8deadSopenharmony_ci | "." "stq" 3575bd8deadSopenharmony_ci | "." "str_dr" 3585bd8deadSopenharmony_ci | "." "stq_dq" 3595bd8deadSopenharmony_ci 3605bd8deadSopenharmony_ci <regName> ::= "r0" 3615bd8deadSopenharmony_ci | "r1" 3625bd8deadSopenharmony_ci | "r2" 3635bd8deadSopenharmony_ci | "r3" 3645bd8deadSopenharmony_ci | "r4" 3655bd8deadSopenharmony_ci | "r5" 3665bd8deadSopenharmony_ci 3675bd8deadSopenharmony_ci <programConstantName> ::= "c0" 3685bd8deadSopenharmony_ci | "c1" 3695bd8deadSopenharmony_ci | "c2" 3705bd8deadSopenharmony_ci | "c3" 3715bd8deadSopenharmony_ci | "c4" 3725bd8deadSopenharmony_ci | "c5" 3735bd8deadSopenharmony_ci | "c6" 3745bd8deadSopenharmony_ci | "c7" 3755bd8deadSopenharmony_ci 3765bd8deadSopenharmony_ci <fixedConstantName> ::= "0" 3775bd8deadSopenharmony_ci | "1" 3785bd8deadSopenharmony_ci 3795bd8deadSopenharmony_ci <colorName> ::= "color0" 3805bd8deadSopenharmony_ci | "color1" 3815bd8deadSopenharmony_ci 3825bd8deadSopenharmony_ci <unaryOp> ::= "MOV" 3835bd8deadSopenharmony_ci 3845bd8deadSopenharmony_ci <binaryOp> ::= "ADD" 3855bd8deadSopenharmony_ci | "MUL" 3865bd8deadSopenharmony_ci | "SUB" 3875bd8deadSopenharmony_ci | "DOT3" 3885bd8deadSopenharmony_ci | "DOT4" 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci <ternaryOp> ::= "MAD" 3915bd8deadSopenharmony_ci | "LERP" 3925bd8deadSopenharmony_ci | "CND" 3935bd8deadSopenharmony_ci | "CND0" 3945bd8deadSopenharmony_ci | "DOT2ADD" 3955bd8deadSopenharmony_ci 3965bd8deadSopenharmony_ci The <integer> rule matches an integer constant. The integer 3975bd8deadSopenharmony_ci consists of a sequence of one or more digits ("0" through "9"). 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci The <normalizedFloat> rule matches a floating-point constant in the 4005bd8deadSopenharmony_ci range of 0.0 to 1.0, inclusive. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci If TEXT_FRAGMENT_SHADER_ATI is enabled, but the currently bound 4035bd8deadSopenharmony_ci program is invalid, the results of drawing commands are undefined. 4045bd8deadSopenharmony_ci A program may be invalid because it specifically violates the 4055bd8deadSopenharmony_ci syntax of the above grammar or because the specified program 4065bd8deadSopenharmony_ci violates one of the additional semantic restrictions given in 4075bd8deadSopenharmony_ci summary below with details following: 4085bd8deadSopenharmony_ci 4095bd8deadSopenharmony_ci Summary of semantic restrictions: 4105bd8deadSopenharmony_ci --------------------------------- 4115bd8deadSopenharmony_ci 1. All "cX" constants used by a program must be declared in a 4125bd8deadSopenharmony_ci constant block, and program constants can be bound at most once. 4135bd8deadSopenharmony_ci 2. If an instruction refers to "cX" constants as arguments, at most 4145bd8deadSopenharmony_ci 2 different constants can be used in a single instruction. 4155bd8deadSopenharmony_ci 3. "color0" and "color1" may be used only in the output pass. 4165bd8deadSopenharmony_ci 4. A preliminary pass must contain at least one ALU operation. 4175bd8deadSopenharmony_ci 5. A maximum of 8 pairs or implicit pairs of color and alpha 4185bd8deadSopenharmony_ci instructions (not including "PassTexCoord and" "SampleMap") can 4195bd8deadSopenharmony_ci be used in a single pass. 4205bd8deadSopenharmony_ci 6. A given destination register can only be written by a SampleMap 4215bd8deadSopenharmony_ci or PassTexCoord instruction once in a given pass. 4225bd8deadSopenharmony_ci 7. The second argument to "PassTexCoord" and "SampleMap" can not be 4235bd8deadSopenharmony_ci an "rX" register in the first pass. 4245bd8deadSopenharmony_ci 8. Once a texture coordinate source is specified with a particular 4255bd8deadSopenharmony_ci choice for coordinate selection, (i.e "str" or "stq"), the 4265bd8deadSopenharmony_ci program may not refer to that same texture coordinate with a 4275bd8deadSopenharmony_ci different choice later on. The exception is that a different 4285bd8deadSopenharmony_ci projection can be specified (i.e. using both "t2.str" and 4295bd8deadSopenharmony_ci "t2.str_dr" on the same texture coordinate set is legal, but 4305bd8deadSopenharmony_ci using "t2.str" and "t2.stq" is not) 4315bd8deadSopenharmony_ci 9. The second argument to "PassTexCoord" and "SampleMap" in the 4325bd8deadSopenharmony_ci output pass can not be a register that uses "stq" or "stq_dq" 4335bd8deadSopenharmony_ci as a component choice selection. 4345bd8deadSopenharmony_ci 10. Alpha destination masks for DOT2ADD, DOT3, and DOT4 instructions 4355bd8deadSopenharmony_ci can only be specified in combination with color destination masks. 4365bd8deadSopenharmony_ci 11. If a DOT4 is specified to not write the alpha channel of it's 4375bd8deadSopenharmony_ci destination, then it is illegal to specify the next instruction 4385bd8deadSopenharmony_ci to write *only* the alpha channel of it's destination. 4395bd8deadSopenharmony_ci 12. A program can not issue an instruction which requires the 4405bd8deadSopenharmony_ci use of the alpha component of a "color1" (secondary color) 4415bd8deadSopenharmony_ci parameter. 4425bd8deadSopenharmony_ci 13. A program may not refer to a register number greater than 4435bd8deadSopenharmony_ci the number of supported texture units. 4445bd8deadSopenharmony_ci 14. A program may not refer to a texture coordinate set greater 4455bd8deadSopenharmony_ci than the number of supported texture units. 4465bd8deadSopenharmony_ci 4475bd8deadSopenharmony_ci The details of the above restrictions and usage guidelines are given 4485bd8deadSopenharmony_ci below: 4495bd8deadSopenharmony_ci 4505bd8deadSopenharmony_ci There are three types of data that can be in a fragment program: 4515bd8deadSopenharmony_ci registers, constants, and interpolators. The 6 "rX" registers 4525bd8deadSopenharmony_ci can be used as source or destination in any instruction. 4535bd8deadSopenharmony_ci The final result of the program is whatever value is in 4545bd8deadSopenharmony_ci the register "r0". This value will be the final color of the 4555bd8deadSopenharmony_ci output fragment passed by the programmable fragment processing 4565bd8deadSopenharmony_ci unit to subsequent non-programmable fragment processing. 4575bd8deadSopenharmony_ci 4585bd8deadSopenharmony_ci There are 8 constant registers available, "c0" through 4595bd8deadSopenharmony_ci "c7". To use these constants, a program must include a 4605bd8deadSopenharmony_ci constant declaration block which indicates how the constants are 4615bd8deadSopenharmony_ci to be bound. Constants can be bound to program local parameters, 4625bd8deadSopenharmony_ci program global parameters, or literal string constants. Program 4635bd8deadSopenharmony_ci locals represent per-program storage, while program environment 4645bd8deadSopenharmony_ci parameters are global to all programs. See the ARB_vertex_program 4655bd8deadSopenharmony_ci documentation for details on the use of 4665bd8deadSopenharmony_ci ProgramLocalParameter4{d,dv,f,fv}ARB, and 4675bd8deadSopenharmony_ci ProgramEnvParameter4{d,dv,f,fv}ARB to set these bound constants. 4685bd8deadSopenharmony_ci Constants can also be bound to a constant floating point vector 4695bd8deadSopenharmony_ci within the program text itself, such as "{ 1.0, 0.0, 0.2, 0.5 }". 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci "cX" constants can be used as source in any instruction, 4725bd8deadSopenharmony_ci but at most 2 different constants may be used as source arguments 4735bd8deadSopenharmony_ci in any single instruction. 4745bd8deadSopenharmony_ci 4755bd8deadSopenharmony_ci Additionally, the primary and secondary color interpolators are 4765bd8deadSopenharmony_ci available as source in any instruction, but only in 4775bd8deadSopenharmony_ci the last pass of the program (i.e., the only pass of a one-pass 4785bd8deadSopenharmony_ci program or the second pass of a two-pass program). 4795bd8deadSopenharmony_ci 4805bd8deadSopenharmony_ci Either one or two passes may be specified in a program. The 4815bd8deadSopenharmony_ci passes can be thought of as an optional preliminary 4825bd8deadSopenharmony_ci pass and a required final output pass. The passes are 4835bd8deadSopenharmony_ci delineated by the occurence of the "StartPrelimPass" and "EndPass" 4845bd8deadSopenharmony_ci tokens for the optional preliminary pass, and the 4855bd8deadSopenharmony_ci "StartOutputPass" and "EndPass" tokens for the output pass. Note 4865bd8deadSopenharmony_ci that in a two-pass shader, the preliminary pass must contain 4875bd8deadSopenharmony_ci at least one match for the <aluStatement> rule in the grammar. 4885bd8deadSopenharmony_ci Or put another way, the preliminary pass can not consist solely of 4895bd8deadSopenharmony_ci PassTexCoord and SampleMap operations. 4905bd8deadSopenharmony_ci 4915bd8deadSopenharmony_ci Each pass may use up to 8 pairs of instructions for a total of at 4925bd8deadSopenharmony_ci most 16 pairs in the shader. A pair consists of one color 4935bd8deadSopenharmony_ci instruction followed immediately by one alpha instruction. 4945bd8deadSopenharmony_ci In ATI_fragment_shader, color and alpha instructions were specified 4955bd8deadSopenharmony_ci independently through the use of ColorFragmentOp and AlphaFragmentOp. 4965bd8deadSopenharmony_ci In ATI_text_fragment_shader color instructions are identified by the 4975bd8deadSopenharmony_ci use of the "r", "g", or "b" write masks on the destination register 4985bd8deadSopenharmony_ci of the instruction. Alpha instructions are identified by the use of 4995bd8deadSopenharmony_ci the "a" write mask. If the "a" mask and at least one of "r", "g", 5005bd8deadSopenharmony_ci or "b" masks are used, or if no mask is used at all, the 5015bd8deadSopenharmony_ci instruction is considered to be an implicit pair that will apply 5025bd8deadSopenharmony_ci the same operation to the color and the alpha channels. 5035bd8deadSopenharmony_ci 5045bd8deadSopenharmony_ci For instance, the following would be considered color operations 5055bd8deadSopenharmony_ci 5065bd8deadSopenharmony_ci "DOT3 r2.rgb, r0, r3;" 5075bd8deadSopenharmony_ci "MUL r1.g, r0, r2;" 5085bd8deadSopenharmony_ci 5095bd8deadSopenharmony_ci The following would be considered alpha operations 5105bd8deadSopenharmony_ci 5115bd8deadSopenharmony_ci "MOV r2.a, r0;" 5125bd8deadSopenharmony_ci "MUL r1.a, r0, r2;" 5135bd8deadSopenharmony_ci 5145bd8deadSopenharmony_ci The following would each be considered an implicit pair of color 5155bd8deadSopenharmony_ci and alpha operations (i.e. three example pairs are given below) 5165bd8deadSopenharmony_ci 5175bd8deadSopenharmony_ci "DOT3 r2, r0, r3;" 5185bd8deadSopenharmony_ci "MUL r4.ba, r0, r2;" 5195bd8deadSopenharmony_ci "MUL r1.rgba, r0, r2;" 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci Therefore, the following examples indicate legal pairs of 5225bd8deadSopenharmony_ci instructions, each of which would count against the limit of 8 5235bd8deadSopenharmony_ci instruction pairs per pass. 5245bd8deadSopenharmony_ci 5255bd8deadSopenharmony_ci # pair #1 5265bd8deadSopenharmony_ci "DOT3 r2.rgb, r0, r3;" 5275bd8deadSopenharmony_ci "MUL r1.a, r0, r2;" 5285bd8deadSopenharmony_ci 5295bd8deadSopenharmony_ci # pair #2 5305bd8deadSopenharmony_ci "SUB r4.r, r0, r3;" 5315bd8deadSopenharmony_ci "MUL r6.a, r0, r2;" 5325bd8deadSopenharmony_ci 5335bd8deadSopenharmony_ci # (implicit) pair #3 5345bd8deadSopenharmony_ci "SUB r4.rgba, r0, r3;" 5355bd8deadSopenharmony_ci 5365bd8deadSopenharmony_ci # (implicit) pair #4 5375bd8deadSopenharmony_ci "ADD r4.ba, r0, r3;" 5385bd8deadSopenharmony_ci 5395bd8deadSopenharmony_ci # (implicit) pair #5 5405bd8deadSopenharmony_ci "DOT4 r5, r2, r3;" 5415bd8deadSopenharmony_ci 5425bd8deadSopenharmony_ci The color and alpha instructions of a pair are executed in 5435bd8deadSopenharmony_ci parallel: the result of the color instruction cannot affect the 5445bd8deadSopenharmony_ci source arguments of the alpha instruction. In other words, 5455bd8deadSopenharmony_ci if an alpha instruction refers to a temporary register ("rX") that 5465bd8deadSopenharmony_ci was written by it's paired color instruction, then the value of 5475bd8deadSopenharmony_ci that register used by the alpha instruction will be the value 5485bd8deadSopenharmony_ci before the color instruction was executed. 5495bd8deadSopenharmony_ci 5505bd8deadSopenharmony_ci For instance, consider the following color alpha pairing: 5515bd8deadSopenharmony_ci 5525bd8deadSopenharmony_ci "SUB r4.rgb, r0, r3;" 5535bd8deadSopenharmony_ci "MUL r6.a, r4, r2;" # MUL instruction will use the value 5545bd8deadSopenharmony_ci # in r4 that r4 had before SUB 5555bd8deadSopenharmony_ci # instruction was issued. 5565bd8deadSopenharmony_ci 5575bd8deadSopenharmony_ci Both a color and an alpha instruction need not be specified for 5585bd8deadSopenharmony_ci every pair; the necessary color or alpha no-op is automatically 5595bd8deadSopenharmony_ci inserted by the GL to complete each instruction pair. 5605bd8deadSopenharmony_ci 5615bd8deadSopenharmony_ci Note that a given register can only be used as a destination 5625bd8deadSopenharmony_ci at most once during the <initRegSequence> of each pass. In other 5635bd8deadSopenharmony_ci words, a program may not initialize the same register twice in 5645bd8deadSopenharmony_ci one pass using the PassTexCoord or SampleMap instructions. Writing 5655bd8deadSopenharmony_ci to the same register by the <aluSequence> instructions is quite 5665bd8deadSopenharmony_ci legal, however. 5675bd8deadSopenharmony_ci 5685bd8deadSopenharmony_ci The first instructions specified in each pass of a program are "free" 5695bd8deadSopenharmony_ci instructions in that they don't count against the 8 instructions 5705bd8deadSopenharmony_ci available in each pass. They are routing instructions that specify 5715bd8deadSopenharmony_ci from where the contents of the registers come. They are specified 5725bd8deadSopenharmony_ci with the "SampleMap" and "PassTexCoord" tokens. 5735bd8deadSopenharmony_ci 5745bd8deadSopenharmony_ci The token sequence 5755bd8deadSopenharmony_ci 5765bd8deadSopenharmony_ci "PassTexCoord <initRegDst> <initRegSrc>;" 5775bd8deadSopenharmony_ci 5785bd8deadSopenharmony_ci specifies that the value present in <initRegSrc> is passed directly 5795bd8deadSopenharmony_ci into the contents of <initRegDst> (one of the registers "rX"). 5805bd8deadSopenharmony_ci This value is then available for use as a source argument to 5815bd8deadSopenharmony_ci subsequent color and alpha instructions following in the same pass. 5825bd8deadSopenharmony_ci <initRegSrc> may either be the texture coordinates on a texture unit 5835bd8deadSopenharmony_ci ("tX"), or in the case of a two-pass program's second pass, it may 5845bd8deadSopenharmony_ci be the value of a register set in the first pass ("rX"). 5855bd8deadSopenharmony_ci 5865bd8deadSopenharmony_ci Note that in order to preserve the contents of a register from the 5875bd8deadSopenharmony_ci first pass to the second, there must be a "PassTexCoord" 5885bd8deadSopenharmony_ci instruction in the setup for the second pass that assigns that 5895bd8deadSopenharmony_ci register to itself. For example: 5905bd8deadSopenharmony_ci 5915bd8deadSopenharmony_ci "StartOutputPass;" 5925bd8deadSopenharmony_ci "PassTexCoord r1, r1.str;" 5935bd8deadSopenharmony_ci etc. 5945bd8deadSopenharmony_ci 5955bd8deadSopenharmony_ci will preserve the first 3 components of "r1" for use in the 5965bd8deadSopenharmony_ci second pass. 5975bd8deadSopenharmony_ci 5985bd8deadSopenharmony_ci The token sequence 5995bd8deadSopenharmony_ci 6005bd8deadSopenharmony_ci "SampleMapATI <initRegDst> <initRegSrc>;" 6015bd8deadSopenharmony_ci 6025bd8deadSopenharmony_ci specifies that the value present in the texture data bound on the 6035bd8deadSopenharmony_ci unit associated with <initRegDst> will be written to that register. 6045bd8deadSopenharmony_ci A value for <initRegDst> of "rX" means that the actively bound 6055bd8deadSopenharmony_ci texture on texture unit X will be sampled, and the result written to 6065bd8deadSopenharmony_ci "rX". The <initRegSrc> parameter specifies which texture coordinate 6075bd8deadSopenharmony_ci interpolator is used to sample the map. A value of "rX" for 6085bd8deadSopenharmony_ci <initRegSrc> in the second pass of a two-pass program will do 6095bd8deadSopenharmony_ci dependent texture read sampling using the value in register X. 6105bd8deadSopenharmony_ci Otherwise, specifying "tX" will sample the map using the texture 6115bd8deadSopenharmony_ci coordinates on unit X. 6125bd8deadSopenharmony_ci 6135bd8deadSopenharmony_ci Only the first 3 components of <initRegSrc> are used in 6145bd8deadSopenharmony_ci "PassTexCoord" and "SampleMap". As such, it is necessary to 6155bd8deadSopenharmony_ci identify which 3 components are to be used. To do so, one can append 6165bd8deadSopenharmony_ci a component selection operator on to the end of the <initRegSrc> 6175bd8deadSopenharmony_ci This parameter was called a swizzle in ATI_fragment_shader and is 6185bd8deadSopenharmony_ci referred to by the <threeTupleSelect> token in the 6195bd8deadSopenharmony_ci ATI_text_fragment_shader grammar. This parameter is used to select 6205bd8deadSopenharmony_ci which of the 4 original components of the source register or 6215bd8deadSopenharmony_ci texture coordinates will be mapped to the 3 available positions, 6225bd8deadSopenharmony_ci and whether or not a projection (division by the q component) will 6235bd8deadSopenharmony_ci occur. 6245bd8deadSopenharmony_ci 6255bd8deadSopenharmony_ci Table 3.20 shows the <swizzle> modes: 6265bd8deadSopenharmony_ci 6275bd8deadSopenharmony_ci 6285bd8deadSopenharmony_ci Coordinates Used for 1D or Coordinates Used for 6295bd8deadSopenharmony_ci Swizzle 2D SampleMap and PassTexCoord 3D or cubemap SampleMap 6305bd8deadSopenharmony_ci ------- ----------------------------- ----------------------- 6315bd8deadSopenharmony_ci "str" (s, t, r, undefined) (s, t, r, undefined) 6325bd8deadSopenharmony_ci "stq" (s, t, q, undefined) (s, t, q, undefined) 6335bd8deadSopenharmony_ci "str_dr" (s/r, t/r, 1/r, undefined) (undefined) 6345bd8deadSopenharmony_ci "stq_dq" (s/q, t/q, 1/q, undefined) (undefined) 6355bd8deadSopenharmony_ci 6365bd8deadSopenharmony_ci Table 3.20 Coordinate swizzles 6375bd8deadSopenharmony_ci 6385bd8deadSopenharmony_ci For example, a fragment program could specify 6395bd8deadSopenharmony_ci 6405bd8deadSopenharmony_ci "PassTexCoord r1, r1.str;" 6415bd8deadSopenharmony_ci or 6425bd8deadSopenharmony_ci "SampleMap r1, t2.stq_dq;" 6435bd8deadSopenharmony_ci 6445bd8deadSopenharmony_ci Each texture coordinate source ("tX") used as a <initRegSrc> can 6455bd8deadSopenharmony_ci only draw upon "str" or "stq" components throughout the program. 6465bd8deadSopenharmony_ci For example, if "t2" is used in a SampleMapATI as "t2.str", it 6475bd8deadSopenharmony_ci cannot be used again later as "t2.stq". The projection, however, 6485bd8deadSopenharmony_ci may vary. That is, it would be okay to later use "t2.str_dr". 6495bd8deadSopenharmony_ci 6505bd8deadSopenharmony_ci Additionally, when the <initRegSrc> is a register (in the second 6515bd8deadSopenharmony_ci pass of a two-pass program), only "str" and "str_dr" are allowed. 6525bd8deadSopenharmony_ci Note that if this is a PassTexCoord, the fourth component (alpha 6535bd8deadSopenharmony_ci channel if the register contains RGBA) is not passed along and the 6545bd8deadSopenharmony_ci fourth component of <initRegDst> becomes undefined. 6555bd8deadSopenharmony_ci 6565bd8deadSopenharmony_ci The color and alpha instructions are divided into unary, binary, and 6575bd8deadSopenharmony_ci ternary instructions depending upon the number of arguments 6585bd8deadSopenharmony_ci each instruction requires. 6595bd8deadSopenharmony_ci 6605bd8deadSopenharmony_ci Unary instructions have the form: 6615bd8deadSopenharmony_ci <op> <dst>, <a1>; 6625bd8deadSopenharmony_ci 6635bd8deadSopenharmony_ci Unary instructions include: 6645bd8deadSopenharmony_ci "MOV" 6655bd8deadSopenharmony_ci 6665bd8deadSopenharmony_ci Binary instructions have the form: 6675bd8deadSopenharmony_ci <op> <dst>, <a1>, <a2>; 6685bd8deadSopenharmony_ci 6695bd8deadSopenharmony_ci Binary instructions include: 6705bd8deadSopenharmony_ci "ADD" 6715bd8deadSopenharmony_ci "MUL" 6725bd8deadSopenharmony_ci "SUB" 6735bd8deadSopenharmony_ci "DOT3" 6745bd8deadSopenharmony_ci "DOT4" 6755bd8deadSopenharmony_ci 6765bd8deadSopenharmony_ci Ternary instructions have the form: 6775bd8deadSopenharmony_ci <op> <dst>, <a1>, <a2>, <a3>; 6785bd8deadSopenharmony_ci 6795bd8deadSopenharmony_ci Ternary instructions include: 6805bd8deadSopenharmony_ci "MAD" 6815bd8deadSopenharmony_ci "LERP" 6825bd8deadSopenharmony_ci "CND" 6835bd8deadSopenharmony_ci "CND0" 6845bd8deadSopenharmony_ci "DOT2ADD" 6855bd8deadSopenharmony_ci 6865bd8deadSopenharmony_ci Table 3.21 shows the effect of each <op>. 6875bd8deadSopenharmony_ci R(d), G(d), B(d), and A(d) are the destination component 6885bd8deadSopenharmony_ci values and a1, a2, and a3 represent the source arguments to the 6895bd8deadSopenharmony_ci instruction. 6905bd8deadSopenharmony_ci 6915bd8deadSopenharmony_ci 6925bd8deadSopenharmony_ci Op Result 6935bd8deadSopenharmony_ci -- ------ 6945bd8deadSopenharmony_ci "ADD" R(d) = R(a1) + R(a2) 6955bd8deadSopenharmony_ci G(d) = G(a1) + G(a2) 6965bd8deadSopenharmony_ci B(d) = B(a1) + B(a2) 6975bd8deadSopenharmony_ci A(d) = A(a1) + A(a2) 6985bd8deadSopenharmony_ci 6995bd8deadSopenharmony_ci "SUB" R(d) = R(a1) - R(a2) 7005bd8deadSopenharmony_ci G(d) = G(a1) - G(a2) 7015bd8deadSopenharmony_ci B(d) = B(a1) - B(a2) 7025bd8deadSopenharmony_ci A(d) = A(a1) - A(a2) 7035bd8deadSopenharmony_ci 7045bd8deadSopenharmony_ci "MUL" R(d) = R(a1) * R(a2) 7055bd8deadSopenharmony_ci G(d) = G(a1) * G(a2) 7065bd8deadSopenharmony_ci B(d) = B(a1) * B(a2) 7075bd8deadSopenharmony_ci A(d) = A(a1) * A(a2) 7085bd8deadSopenharmony_ci 7095bd8deadSopenharmony_ci "MAD" R(d) = R(a1) * R(a2) + R(a3) 7105bd8deadSopenharmony_ci G(d) = G(a1) * G(a2) + G(a3) 7115bd8deadSopenharmony_ci B(d) = B(a1) * B(a2) + B(a3) 7125bd8deadSopenharmony_ci A(d) = A(a1) * A(a2) + A(a3) 7135bd8deadSopenharmony_ci 7145bd8deadSopenharmony_ci "LERP" ** R(d) = R(a1) * R(a2) + (1 - R(a1)) * R(a3) 7155bd8deadSopenharmony_ci G(d) = G(a1) * G(a2) + (1 - G(a1)) * G(a3) 7165bd8deadSopenharmony_ci B(d) = B(a1) * B(a2) + (1 - B(a1)) * B(a3) 7175bd8deadSopenharmony_ci A(d) = A(a1) * A(a2) + (1 - A(a1)) * A(a3) 7185bd8deadSopenharmony_ci 7195bd8deadSopenharmony_ci "MOV" R(d) = R(a1) 7205bd8deadSopenharmony_ci G(d) = G(a1) 7215bd8deadSopenharmony_ci B(d) = B(a1) 7225bd8deadSopenharmony_ci A(d) = A(a1) 7235bd8deadSopenharmony_ci 7245bd8deadSopenharmony_ci "CND" R(d) = (R(a3) > 0.5) ? R(a1) : R(a2) 7255bd8deadSopenharmony_ci G(d) = (G(a3) > 0.5) ? G(a1) : G(a2) 7265bd8deadSopenharmony_ci B(d) = (B(a3) > 0.5) ? B(a1) : B(a2) 7275bd8deadSopenharmony_ci A(d) = (A(a3) > 0.5) ? A(a1) : A(a2) 7285bd8deadSopenharmony_ci 7295bd8deadSopenharmony_ci "CND0" R(d) = (R(a3) >= 0) ? R(a1) : R(a2) 7305bd8deadSopenharmony_ci G(d) = (G(a3) >= 0) ? G(a1) : G(a2) 7315bd8deadSopenharmony_ci B(d) = (B(a3) >= 0) ? B(a1) : B(a2) 7325bd8deadSopenharmony_ci A(d) = (A(a3) >= 0) ? A(a1) : A(a2) 7335bd8deadSopenharmony_ci 7345bd8deadSopenharmony_ci "DOT2ADD" * R(d) = G(d) = B(d) = A(d) = R(a1) * R(a2) + 7355bd8deadSopenharmony_ci G(a1) * G(a2) + 7365bd8deadSopenharmony_ci B(a3) 7375bd8deadSopenharmony_ci 7385bd8deadSopenharmony_ci "DOT3" * R(d) = G(d) = B(d) = A(d) = R(a1) * R(a2) + 7395bd8deadSopenharmony_ci G(a1) * G(a2) + 7405bd8deadSopenharmony_ci B(a1) * B(a2) 7415bd8deadSopenharmony_ci 7425bd8deadSopenharmony_ci "DOT4" * ** R(d) = G(d) = B(d) = A(d) = R(a1) * R(a2) + 7435bd8deadSopenharmony_ci G(a1) * G(a2) + 7445bd8deadSopenharmony_ci B(a1) * B(a2) + 7455bd8deadSopenharmony_ci A(a1) * A(a2) 7465bd8deadSopenharmony_ci 7475bd8deadSopenharmony_ci Table 3.21 Color and Alpha Fragment Shader Instructions 7485bd8deadSopenharmony_ci 7495bd8deadSopenharmony_ci Special Notes: 7505bd8deadSopenharmony_ci * - DOT2ADD/DOT3/DOT4 can use an alpha destination mask 7515bd8deadSopenharmony_ci only in combindation with a color destination mask. 7525bd8deadSopenharmony_ci That is, it is illegal to use only a ".a" mask specifier 7535bd8deadSopenharmony_ci on the destination register of these instructions 7545bd8deadSopenharmony_ci ** - If a DOT4 is specified with a destination mask that 7555bd8deadSopenharmony_ci does not include alpha (i.e. ".r", ".rb", "g", etc) 7565bd8deadSopenharmony_ci then the immediately following instruction must write 7575bd8deadSopenharmony_ci at least one color channel and can not use the 7585bd8deadSopenharmony_ci alpha only destination mask specifier ".a". 7595bd8deadSopenharmony_ci *** - The blend factor (a1) of LERP_ATI must be in the range 7605bd8deadSopenharmony_ci [0,1] or the results are undefined. 7615bd8deadSopenharmony_ci 7625bd8deadSopenharmony_ci The <dst> parameter specifies to which register ("rX") the 7635bd8deadSopenharmony_ci result of the instruction is written. 7645bd8deadSopenharmony_ci 7655bd8deadSopenharmony_ci Each <dst> parameter can optionally have a mask appended to the 7665bd8deadSopenharmony_ci "rX" name, as in "r1.r", or "r3.gb". The mask parameter 7675bd8deadSopenharmony_ci specifies which of the color components in <dst> will be written. 7685bd8deadSopenharmony_ci If there is no mask specified, everything is written, or any of the 7695bd8deadSopenharmony_ci masks "r", "g", "b", and/or "a" can be added to enable writing the 7705bd8deadSopenharmony_ci output red, green, blue, and/or alpha channels, respectively. The 7715bd8deadSopenharmony_ci masks must be specified in "rgba" order. 7725bd8deadSopenharmony_ci 7735bd8deadSopenharmony_ci Further, each <dst> parameter can optionally have appended a 7745bd8deadSopenharmony_ci modification parameter, as in "r3.2x" or "r3.half". These can 7755bd8deadSopenharmony_ci be combined with the mask parameter as in "r4.rg.8x". The result 7765bd8deadSopenharmony_ci of an instruction can be modulated by appending *one* of the 7775bd8deadSopenharmony_ci following: "2x", "4x", "8x", "half", "quarter", or "eighth". 7785bd8deadSopenharmony_ci These are all mutually exclusive. However, you can optionally add 7795bd8deadSopenharmony_ci "sat" that clamps the result after any modulation occurs. 7805bd8deadSopenharmony_ci 7815bd8deadSopenharmony_ci Table 3.22 shows the result of each modification. 7825bd8deadSopenharmony_ci 7835bd8deadSopenharmony_ci 7845bd8deadSopenharmony_ci Modifier Result 7855bd8deadSopenharmony_ci -------- ------ 7865bd8deadSopenharmony_ci "" d = d 7875bd8deadSopenharmony_ci "2x" d = 2 * d 7885bd8deadSopenharmony_ci "4x" d = 4 * d 7895bd8deadSopenharmony_ci "8x" d = 8 * d 7905bd8deadSopenharmony_ci "half" d = d / 2 7915bd8deadSopenharmony_ci "quarter" d = d / 4 7925bd8deadSopenharmony_ci "eighth" d = d / 8 7935bd8deadSopenharmony_ci "sat" d = clamp(d) to range [0, 1] 7945bd8deadSopenharmony_ci 7955bd8deadSopenharmony_ci Table 3.22 Result of destination modification 7965bd8deadSopenharmony_ci 7975bd8deadSopenharmony_ci 7985bd8deadSopenharmony_ci Note that the internal precision of the fragment program allows 7995bd8deadSopenharmony_ci values in the range [-8, 8]. 8005bd8deadSopenharmony_ci 8015bd8deadSopenharmony_ci The <a1>, <a2>, and <a3 parameters specify the source arguments. 8025bd8deadSopenharmony_ci The source can come from "rX", "cX", "0", "1", "color0", or "color1", 8035bd8deadSopenharmony_ci where "color0" is the primary fragment color and "color1" is the 8045bd8deadSopenharmony_ci secondary fragment color. Note that in a two-pass program, "color0" 8055bd8deadSopenharmony_ci and "color1" cannot be used in the first pass of the program. 8065bd8deadSopenharmony_ci 8075bd8deadSopenharmony_ci Each source argument can be given a single optional replication 8085bd8deadSopenharmony_ci parameter that specifies the replication of each component. 8095bd8deadSopenharmony_ci 8105bd8deadSopenharmony_ci Table 3.23 shows the result of each source replication modifier. 8115bd8deadSopenharmony_ci 8125bd8deadSopenharmony_ci 8135bd8deadSopenharmony_ci Replication Result 8145bd8deadSopenharmony_ci ----------- ----- 8155bd8deadSopenharmony_ci "" R(s) = R(s) 8165bd8deadSopenharmony_ci G(s) = G(s) 8175bd8deadSopenharmony_ci B(s) = B(s) 8185bd8deadSopenharmony_ci A(s) = A(s) 8195bd8deadSopenharmony_ci 8205bd8deadSopenharmony_ci "r" R(s) = R(s) 8215bd8deadSopenharmony_ci G(s) = R(s) 8225bd8deadSopenharmony_ci B(s) = R(s) 8235bd8deadSopenharmony_ci A(s) = R(s) 8245bd8deadSopenharmony_ci 8255bd8deadSopenharmony_ci "g" R(s) = G(s) 8265bd8deadSopenharmony_ci G(s) = G(s) 8275bd8deadSopenharmony_ci B(s) = G(s) 8285bd8deadSopenharmony_ci A(s) = G(s) 8295bd8deadSopenharmony_ci 8305bd8deadSopenharmony_ci "b" R(s) = B(s) 8315bd8deadSopenharmony_ci G(s) = B(s) 8325bd8deadSopenharmony_ci B(s) = B(s) 8335bd8deadSopenharmony_ci A(s) = B(s) 8345bd8deadSopenharmony_ci 8355bd8deadSopenharmony_ci "a" R(s) = A(s) 8365bd8deadSopenharmony_ci G(s) = A(s) 8375bd8deadSopenharmony_ci B(s) = A(s) 8385bd8deadSopenharmony_ci A(s) = A(s) 8395bd8deadSopenharmony_ci 8405bd8deadSopenharmony_ci Table 3.23 Result of source replication 8415bd8deadSopenharmony_ci 8425bd8deadSopenharmony_ci 8435bd8deadSopenharmony_ci Note that the GL secondary color is specified to contain red, 8445bd8deadSopenharmony_ci green, and blue components only. It is therefore illegal to specify 8455bd8deadSopenharmony_ci a program which requires the use of the alpha component of the 8465bd8deadSopenharmony_ci "color1" parameters. This means that using "color1.a" source argument 8475bd8deadSopenharmony_ci replication would be prohibited. Additionally, issuing an alpha 8485bd8deadSopenharmony_ci operation using the alpha component of "color1", either implicitly 8495bd8deadSopenharmony_ci or explicitly would also be prohibited. 8505bd8deadSopenharmony_ci 8515bd8deadSopenharmony_ci For instance, the following statements would all be illegal: 8525bd8deadSopenharmony_ci 8535bd8deadSopenharmony_ci "MOV r0, color1; # implicit alpha op in pair " 8545bd8deadSopenharmony_ci "MOV r0.ra, color1; # explicit alpha op in pair " 8555bd8deadSopenharmony_ci "MOV r0.a, color1; # explicit single alpha op " 8565bd8deadSopenharmony_ci "MOV r0.rgb, color1.a # can't replicate non-existent alpha channel " 8575bd8deadSopenharmony_ci 8585bd8deadSopenharmony_ci On the other hand, both of these are legal: 8595bd8deadSopenharmony_ci 8605bd8deadSopenharmony_ci "MOV r0.rgb, color1; # explicit color op, no alpha op specified " 8615bd8deadSopenharmony_ci "MOV r0, color1.g # non-alpha component replicated on src " 8625bd8deadSopenharmony_ci 8635bd8deadSopenharmony_ci Each argument can also be given an optional modification parameter 8645bd8deadSopenharmony_ci that specifies modifiers to each component. Any or all of the 8655bd8deadSopenharmony_ci following can be specified "neg", "comp", "bias", "2x". 8665bd8deadSopenharmony_ci 8675bd8deadSopenharmony_ci Table 3.24 shows the result of each source modifier. 8685bd8deadSopenharmony_ci 8695bd8deadSopenharmony_ci 8705bd8deadSopenharmony_ci Modifier Result 8715bd8deadSopenharmony_ci -------- ------ 8725bd8deadSopenharmony_ci "" s = s 8735bd8deadSopenharmony_ci "neg" s = -s 8745bd8deadSopenharmony_ci "comp" s = 1 - s 8755bd8deadSopenharmony_ci "bias" s = s - 0.5 8765bd8deadSopenharmony_ci "2x" s = 2 * s 8775bd8deadSopenharmony_ci 8785bd8deadSopenharmony_ci Table 3.24 Result of source modification 8795bd8deadSopenharmony_ci 8805bd8deadSopenharmony_ci 8815bd8deadSopenharmony_ci If multiple source modifiers are applied, the order of operations is 8825bd8deadSopenharmony_ci "comp", "bias", "2x", then "negate". The following equation 8835bd8deadSopenharmony_ci shows the order of operations if all modifiers were to be applied: 8845bd8deadSopenharmony_ci 8855bd8deadSopenharmony_ci s = -(2 * ((1.0 - s) - 0.5)) 8865bd8deadSopenharmony_ci 8875bd8deadSopenharmony_ci In order to set the constants that can be used by program 8885bd8deadSopenharmony_ci instructions, the following entry points (identical to those in 8895bd8deadSopenharmony_ci the pending ARB_vertex_program extension) are used: 8905bd8deadSopenharmony_ci 8915bd8deadSopenharmony_ci void ProgramLocalParameter4dARB(enum target, uint index, 8925bd8deadSopenharmony_ci double x, double y, 8935bd8deadSopenharmony_ci double z, double w); 8945bd8deadSopenharmony_ci void ProgramLocalParameter4dvARB(enum target, uint index, 8955bd8deadSopenharmony_ci const double *params); 8965bd8deadSopenharmony_ci void ProgramLocalParameter4fARB(enum target, uint index, 8975bd8deadSopenharmony_ci float x, float y, float z, float w); 8985bd8deadSopenharmony_ci void ProgramLocalParameter4fvARB(enum target, uint index, 8995bd8deadSopenharmony_ci const float *params); 9005bd8deadSopenharmony_ci void ProgramEnvParameter4dARB(enum target, uint index, 9015bd8deadSopenharmony_ci double x, double y, 9025bd8deadSopenharmony_ci double z, double w); 9035bd8deadSopenharmony_ci void ProgramEnvParameter4dvARB(enum target, uint index, 9045bd8deadSopenharmony_ci const double *params); 9055bd8deadSopenharmony_ci void ProgramEnvParameter4fARB(enum target, uint index, 9065bd8deadSopenharmony_ci float x, float y, float z, float w); 9075bd8deadSopenharmony_ci void ProgramEnvParameter4fvARB(enum target, uint index, 9085bd8deadSopenharmony_ci const float *params); 9095bd8deadSopenharmony_ci 9105bd8deadSopenharmony_ci The <target> must be TEXT_FRAGMENT_SHADER_ATI. The <index> specifies 9115bd8deadSopenharmony_ci the number of the parameter to update. For ATI_text_fragment_shader, 9125bd8deadSopenharmony_ci <index> is limited to the range 0 to 7. Note that this does *not* 9135bd8deadSopenharmony_ci necessarily correspond to the "X" in the constant named "cX", 9145bd8deadSopenharmony_ci but rather to the parameter index (env or local) to which "cX" is 9155bd8deadSopenharmony_ci bound in the constant declaration block at the beginning of the 9165bd8deadSopenharmony_ci program. For instance, if constant "c1" is bound as follows: 9175bd8deadSopenharmony_ci 9185bd8deadSopenharmony_ci "StartConstants; " 9195bd8deadSopenharmony_ci " CONSTANT c1 = program.local[3]; " 9205bd8deadSopenharmony_ci "EndConstants; " 9215bd8deadSopenharmony_ci 9225bd8deadSopenharmony_ci then to set the value of constant "c1", to the vector value of 9235bd8deadSopenharmony_ci { 0.4, 0.0, 0.5, 0.25), the application could call 9245bd8deadSopenharmony_ci 9255bd8deadSopenharmony_ci glProgramLocalParameter4dARB(TEXT_FRAGMENT_SHADER_ATI, // target 9265bd8deadSopenharmony_ci 3, // index 9275bd8deadSopenharmony_ci 0.4, // x 9285bd8deadSopenharmony_ci 0.0, // y 9295bd8deadSopenharmony_ci 0.5, // z 9305bd8deadSopenharmony_ci 0.25); // w 9315bd8deadSopenharmony_ci 9325bd8deadSopenharmony_ci The <params> pointer, must contain four floating point values in 9335bd8deadSopenharmony_ci the range [0, 1] to set the components of the constant. Similarly, 9345bd8deadSopenharmony_ci the <x>, <y>, <z>, and <w> parameters must also be in the range 9355bd8deadSopenharmony_ci [0,1]. Constant registers loaded with floating point values 9365bd8deadSopenharmony_ci outside of this range will have undefined values. 9375bd8deadSopenharmony_ci 9385bd8deadSopenharmony_ci Note that binding a program constant to a literal string constant 9395bd8deadSopenharmony_ci within the program text is roughly analogous to 9405bd8deadSopenharmony_ci ATI_fragment_shader's use of the call to SetFragmentShaderConstant 9415bd8deadSopenharmony_ci within a BeginFragmentShader/EndFragmentShader pair. That is, the 9425bd8deadSopenharmony_ci constant value can not be changed without respecifying the program 9435bd8deadSopenharmony_ci and the program constant value is local to the program. 9445bd8deadSopenharmony_ci 9455bd8deadSopenharmony_ci Binding a program constant to a program environment parameter is 9465bd8deadSopenharmony_ci roughly analogous to ATI_fragment_shader's use of a call to 9475bd8deadSopenharmony_ci SetFragmentShaderConstant outside of a BeginFragmentShader / 9485bd8deadSopenharmony_ci EndFragmentShader pair. That is, the program constant's value can 9495bd8deadSopenharmony_ci be changed without redefining the program and the program constant 9505bd8deadSopenharmony_ci value is global to all programs with a binding to that specific 9515bd8deadSopenharmony_ci program environment parameter. 9525bd8deadSopenharmony_ci 9535bd8deadSopenharmony_ci Binding a program constant to a program local parameter has no 9545bd8deadSopenharmony_ci direct analogue in ATI_fragment_shader as it represents a way 9555bd8deadSopenharmony_ci to specify a program parameter which is local to a given 9565bd8deadSopenharmony_ci fragment program object, but allows the parameter's value to 9575bd8deadSopenharmony_ci be changed without redefining the fragment program itself. 9585bd8deadSopenharmony_ci 9595bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment 9605bd8deadSopenharmony_ciOperations and the Framebuffer) 9615bd8deadSopenharmony_ci 9625bd8deadSopenharmony_ci None 9635bd8deadSopenharmony_ci 9645bd8deadSopenharmony_ci 9655bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.2.1 Specification (Special 9665bd8deadSopenharmony_ciFunctions) 9675bd8deadSopenharmony_ci 9685bd8deadSopenharmony_ci None 9695bd8deadSopenharmony_ci 9705bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.2.1 Specification (State and 9715bd8deadSopenharmony_ciState Requests) 9725bd8deadSopenharmony_ci 9735bd8deadSopenharmony_ci None 9745bd8deadSopenharmony_ci 9755bd8deadSopenharmony_ci 9765bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 1.2.1 Specification (Invariance) 9775bd8deadSopenharmony_ci 9785bd8deadSopenharmony_ci None 9795bd8deadSopenharmony_ci 9805bd8deadSopenharmony_ci 9815bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 9825bd8deadSopenharmony_ci 9835bd8deadSopenharmony_ci None 9845bd8deadSopenharmony_ci 9855bd8deadSopenharmony_ciInteractions with ARB_shadow 9865bd8deadSopenharmony_ci 9875bd8deadSopenharmony_ci The texture comparison introduced by ARB_shadow can be expressed in 9885bd8deadSopenharmony_ci terms of a fragment shader, and in fact use the same internal 9895bd8deadSopenharmony_ci resources on some implementations. Therefore, if fragment shader 9905bd8deadSopenharmony_ci mode is enabled, the GL behaves as if TEXTURE_COMPARE_MODE_ARB is 9915bd8deadSopenharmony_ci NONE. 9925bd8deadSopenharmony_ci 9935bd8deadSopenharmony_ciErrors 9945bd8deadSopenharmony_ci 9955bd8deadSopenharmony_ci 9965bd8deadSopenharmony_ci 9975bd8deadSopenharmony_ciNew State 9985bd8deadSopenharmony_ci 9995bd8deadSopenharmony_ci Initial 10005bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. Attribute 10015bd8deadSopenharmony_ci --------- ---- ----------- ------- ----------- ------ --------- 10025bd8deadSopenharmony_ci TEXT_FRAGMENT_SHADER_ATI B IsEnabled False Fragment shader enable 3.8.11 enable 10035bd8deadSopenharmony_ci 10045bd8deadSopenharmony_ci Table X.6. New Accessible State Introduced by ATI_text_fragment_shader. 10055bd8deadSopenharmony_ci 10065bd8deadSopenharmony_ci 10075bd8deadSopenharmony_ci Get Value Type Get Command Initial Value Description Sec Attribute 10085bd8deadSopenharmony_ci --------- ------ ----------- ------------- ------------------- ------ --------- 10095bd8deadSopenharmony_ci - 6xR4 - undefined temporary registers 3.8.11 - 10105bd8deadSopenharmony_ci 10115bd8deadSopenharmony_ci Table X.9. Fragment Shader Per-fragment Execution State. All per-fragment 10125bd8deadSopenharmony_ci execution state registers are uninitialized at the beginning of program 10135bd8deadSopenharmony_ci execution. 10145bd8deadSopenharmony_ci 10155bd8deadSopenharmony_ci 10165bd8deadSopenharmony_ciNew Implementation Dependent State 10175bd8deadSopenharmony_ci 10185bd8deadSopenharmony_ci None 10195bd8deadSopenharmony_ci 10205bd8deadSopenharmony_ci 10215bd8deadSopenharmony_ciDeprecated Functionality 10225bd8deadSopenharmony_ci 10235bd8deadSopenharmony_ci The original ATI_fragment_shader spec included some deprecated 10245bd8deadSopenharmony_ci functionality for determining implementation-dependent constants 10255bd8deadSopenharmony_ci and limits. Since that functionality was deprecated to the 10265bd8deadSopenharmony_ci point where those queries are specified to return fixed values, and 10275bd8deadSopenharmony_ci most of the limits are specified by the fragment program grammar, 10285bd8deadSopenharmony_ci those queries are not included in the ATI_text_fragment_shader 10295bd8deadSopenharmony_ci extension. 10305bd8deadSopenharmony_ci 10315bd8deadSopenharmony_ciSample Usage 10325bd8deadSopenharmony_ci 10335bd8deadSopenharmony_ci----------------------------------------------------- 10345bd8deadSopenharmony_ci 10355bd8deadSopenharmony_ci # The following program shows how to perform a simple modulation 10365bd8deadSopenharmony_ci # between the interpolated color and a single texture: 10375bd8deadSopenharmony_ci !!ATIfs1.0 10385bd8deadSopenharmony_ci 10395bd8deadSopenharmony_ci StartOutputPass; 10405bd8deadSopenharmony_ci SampleMap r0, t0.stq_dq; #sample the texture 10415bd8deadSopenharmony_ci 10425bd8deadSopenharmony_ci MUL r0, r0, color0; #perform the modulation 10435bd8deadSopenharmony_ci EndPass; 10445bd8deadSopenharmony_ci 10455bd8deadSopenharmony_ci----------------------------------------------------- 10465bd8deadSopenharmony_ci 10475bd8deadSopenharmony_ci # The following program shows how to use the constant 10485bd8deadSopenharmony_ci # declaration block in a fragment program. 10495bd8deadSopenharmony_ci !!ATIfs1.0 10505bd8deadSopenharmony_ci 10515bd8deadSopenharmony_ci StartConstants; 10525bd8deadSopenharmony_ci CONSTANT c0 = program.env[0]; 10535bd8deadSopenharmony_ci CONSTANT c1 = program.local[3]; 10545bd8deadSopenharmony_ci CONSTANT c2 = { 1.0, 0.0, 0.5, 0.75 }; 10555bd8deadSopenharmony_ci EndConstants; 10565bd8deadSopenharmony_ci 10575bd8deadSopenharmony_ci StartOutputPass; 10585bd8deadSopenharmony_ci MUL r2, c1, c0; # multiply global param by local param 10595bd8deadSopenharmony_ci ADD r0, c2, r0; # add constant param and put result in r0 10605bd8deadSopenharmony_ci EndPass; 10615bd8deadSopenharmony_ci 10625bd8deadSopenharmony_ci----------------------------------------------------- 10635bd8deadSopenharmony_ci 10645bd8deadSopenharmony_ci # The following is an example that performs bumped 10655bd8deadSopenharmony_ci # cubic environment mapping: 10665bd8deadSopenharmony_ci !!ATIfs1.0 10675bd8deadSopenharmony_ci 10685bd8deadSopenharmony_ci StartPrelimPass; 10695bd8deadSopenharmony_ci PassTexCoord r0, t0.str; # 1st row of 3x3 basis matrix 10705bd8deadSopenharmony_ci PassTexCoord r1, t1.str; # 2nd row of 3x3 basis matrix 10715bd8deadSopenharmony_ci PassTexCoord r2, t2.str; # 3rd row of 3x3 basis matrix 10725bd8deadSopenharmony_ci PassTexCoord r3, t3.str; # Eye vector 10735bd8deadSopenharmony_ci SampleMap r4, t5.str; # Sample normal map 10745bd8deadSopenharmony_ci 10755bd8deadSopenharmony_ci # Three dot products transform from tangent space to cube map space 10765bd8deadSopenharmony_ci DOT3 r0.r, r0, r4; 10775bd8deadSopenharmony_ci DOT3 r0.g, r1, r4; 10785bd8deadSopenharmony_ci DOT3 r0.b, r2, r4; 10795bd8deadSopenharmony_ci 10805bd8deadSopenharmony_ci DOT3 r2.2x, r0, r3; # 2 * (N dot Eye) 10815bd8deadSopenharmony_ci MUL r2, r0, r2; # 2 * N * (N dot Eye) 10825bd8deadSopenharmony_ci DOT3 r1, r0, r0; # N dot N 10835bd8deadSopenharmony_ci MAD r1, r3.neg, r1, r2; # 2 * N * (N dot Eye) - Eye * (N dot N) 10845bd8deadSopenharmony_ci EndPass; 10855bd8deadSopenharmony_ci 10865bd8deadSopenharmony_ci StartOutputPass; 10875bd8deadSopenharmony_ci SampleMap r0, r0.str; # Sample diffuse cubic env map 10885bd8deadSopenharmony_ci SampleMap r1, r1.str; # Sample specular cubic env map 10895bd8deadSopenharmony_ci SampleMap r2, t5.str; # Sample the base map (gloss in a) 10905bd8deadSopenharmony_ci 10915bd8deadSopenharmony_ci MUL r0, r0, r2; # diffuse * base 10925bd8deadSopenharmony_ci MAD r0, r0, r2.a, r1; # (diffuse * base) + (spec * gloss) 10935bd8deadSopenharmony_ci EndPass; 10945bd8deadSopenharmony_ci 10955bd8deadSopenharmony_ci----------------------------------------------------- 10965bd8deadSopenharmony_ci 10975bd8deadSopenharmony_ci # Chrome shader from ATIRadeon8500_PointLight_Shader demo 10985bd8deadSopenharmony_ci !!ATIfs1.0 10995bd8deadSopenharmony_ci 11005bd8deadSopenharmony_ci StartPrelimPass; 11015bd8deadSopenharmony_ci # get the outputs from the vertex shader 11025bd8deadSopenharmony_ci PassTexCoord r1, t1.str; # N 11035bd8deadSopenharmony_ci PassTexCoord r2, t2.str; # light to vtx vector in light space 11045bd8deadSopenharmony_ci PassTexCoord r3, t3.str; # H 11055bd8deadSopenharmony_ci SampleMap r4, t4.str; # L (sample cubemap normalizer) 11065bd8deadSopenharmony_ci 11075bd8deadSopenharmony_ci DOT3 r4, r1, r4.2x.bias; # reg4 = N.L 11085bd8deadSopenharmony_ci DOT3 r1, r1, r3; # reg1 = N.H 11095bd8deadSopenharmony_ci DOT3 r1.g, r3, r3; # reg1(green) = H.H aka |H|^2) 11105bd8deadSopenharmony_ci DOT3 r2, r2, r2; # reg2 = |light to vertex|^2 11115bd8deadSopenharmony_ci EndPass; 11125bd8deadSopenharmony_ci 11135bd8deadSopenharmony_ci StartOutputPass; 11145bd8deadSopenharmony_ci SampleMap r0, t5.str; # sample env map using eye vector 11155bd8deadSopenharmony_ci SampleMap r2, r2.str; # sample atten map 11165bd8deadSopenharmony_ci SampleMap r3, r1.str; # sample spec NHHH map = (N.H)^256 11175bd8deadSopenharmony_ci PassTexCoord r4, r4.str; # pass N.L through 11185bd8deadSopenharmony_ci 11195bd8deadSopenharmony_ci # this ensures a pixel is only lit if facing the light 11205bd8deadSopenharmony_ci # (since the spec exp makes negative N.H positive 11215bd8deadSopenharmony_ci # we must do this) 11225bd8deadSopenharmony_ci MUL r3, r3, r4; # reg3 = ((N.H)^256 * N.L) 11235bd8deadSopenharmony_ci 11245bd8deadSopenharmony_ci MUL r3, r0, r3; # reg3 = spec * env map 11255bd8deadSopenharmony_ci MUL r4, r0, r4; # reg4 = diff * env map 11265bd8deadSopenharmony_ci ADD r0, r3, r4; # reg0 = ((spec * env map) + diff * env map) 11275bd8deadSopenharmony_ci MUL r0.sat, r0, r2.r; # apply point light attenuation 11285bd8deadSopenharmony_ci EndPass; 11295bd8deadSopenharmony_ci 11305bd8deadSopenharmony_ci----------------------------------------------------- 11315bd8deadSopenharmony_ci 11325bd8deadSopenharmony_ci # Rusty shader from ATIRadeon8500_PointLight_Shader demo 11335bd8deadSopenharmony_ci !!ATIfs1.0 11345bd8deadSopenharmony_ci 11355bd8deadSopenharmony_ci StartPrelimPass; 11365bd8deadSopenharmony_ci # get the outputs from the vertex shader 11375bd8deadSopenharmony_ci SampleMap r1, t0.str; # N from bump map 11385bd8deadSopenharmony_ci PassTexCoord r2, t2.str; # light to vertex vector in light space 11395bd8deadSopenharmony_ci PassTexCoord r3, t3.str; # H 11405bd8deadSopenharmony_ci SampleMap r4, t4.str; # L (sample cubemap normalizer) 11415bd8deadSopenharmony_ci SampleMap r5, t0.str; # specular map (provides our k term for computing N.H^k) 11425bd8deadSopenharmony_ci 11435bd8deadSopenharmony_ci 11445bd8deadSopenharmony_ci DOT3 r4, r1.2x.bias, r4.2x.bias; # reg4 = N.L 11455bd8deadSopenharmony_ci DOT3 r1, r1.2x.bias, r3; # reg1 = N.H 11465bd8deadSopenharmony_ci MUL r1, r1, r1; # reg1 = N.H * N.H = (N.H)^2 11475bd8deadSopenharmony_ci DOT3 r1.b, r3, r3; # reg1(blue) = H.H = |H|^2 11485bd8deadSopenharmony_ci MUL r1.g.half, r1.b, r5; # reg1(green) = |H|^2 * 0.5 * k 11495bd8deadSopenharmony_ci DOT3 r2, r2, r2; # reg2 = |light to vertex|^2 11505bd8deadSopenharmony_ci EndPass; 11515bd8deadSopenharmony_ci 11525bd8deadSopenharmony_ci StartOutputPass; 11535bd8deadSopenharmony_ci SampleMap r0, t0.str; # base map 11545bd8deadSopenharmony_ci SampleMap r2, r2.str; # attenuation 11555bd8deadSopenharmony_ci 11565bd8deadSopenharmony_ci # note the swizzle (str_DR) because we devide by R we get the following: 11575bd8deadSopenharmony_ci # <(N.H)^2, |H|^2 * 0.5 * k> / |H|^2 = <(N.H)^2/|H>H|^2, 0.5 * k> 11585bd8deadSopenharmony_ci # note that N.H^2 / |H|^2 effectively takes care of the denormalized H term 11595bd8deadSopenharmony_ci # and reduces to N.H^2 also note that raising this to the (0.5*k) power 11605bd8deadSopenharmony_ci # results in (N.H)^k ... it's a little tricky but it works and now you 11615bd8deadSopenharmony_ci # get per pixel specular lighting with per pixel k exponents! 11625bd8deadSopenharmony_ci SampleMap r3, r1.str_dr; # (N.H)^k 11635bd8deadSopenharmony_ci PassTexCoord r4, r4.str; # N.L 11645bd8deadSopenharmony_ci 11655bd8deadSopenharmony_ci # reg3 = (N.H)^k * (N.L) 11665bd8deadSopenharmony_ci # this ensures a pixel is only lit if facing the light 11675bd8deadSopenharmony_ci # (since the specular exponent makes negative N.H look positive, 11685bd8deadSopenharmony_ci # we must do this) 11695bd8deadSopenharmony_ci MUL r3, r3, r4; 11705bd8deadSopenharmony_ci 11715bd8deadSopenharmony_ci MUL r3, r0, r3; # reg3 = specular * basemap 11725bd8deadSopenharmony_ci MUL r4, r0, r4; # reg4 = diffuse * basemap 11735bd8deadSopenharmony_ci ADD r0, r3, r4; # reg0 = specular + diffuse 11745bd8deadSopenharmony_ci MUL r0.sat, r0, r2.r; # apply attenuation 11755bd8deadSopenharmony_ci EndPass; 11765bd8deadSopenharmony_ci 11775bd8deadSopenharmony_ci----------------------------------------------------- 11785bd8deadSopenharmony_ci 11795bd8deadSopenharmony_ciRevision History 11805bd8deadSopenharmony_ci 11815bd8deadSopenharmony_ci Date: 11/4/2006 11825bd8deadSopenharmony_ci Revision: 1.0.11 11835bd8deadSopenharmony_ci - Updated contact info after ATI/AMD merger. 11845bd8deadSopenharmony_ci 11855bd8deadSopenharmony_ci Date: 9/5/2002 11865bd8deadSopenharmony_ci Revision: 1.0.10 11875bd8deadSopenharmony_ci - final version for submission to registry 11885bd8deadSopenharmony_ci - clarified contact/contributor info 11895bd8deadSopenharmony_ci - fixed a misplaced ".half" typo in the rusty shader example 11905bd8deadSopenharmony_ci code 11915bd8deadSopenharmony_ci 11925bd8deadSopenharmony_ci Date: 8/9/2002 11935bd8deadSopenharmony_ci Revision: 1.0.9 11945bd8deadSopenharmony_ci - fixed a typo which refered to "color1" and "color2" instead of 11955bd8deadSopenharmony_ci "color0" and "color1" 11965bd8deadSopenharmony_ci - clarified semantic restrictrions surrounding DOT2ADD/DOT3/DOT4 11975bd8deadSopenharmony_ci to make them slightly less restrictive and more closely aligned 11985bd8deadSopenharmony_ci with underlying hardware implementation and original 11995bd8deadSopenharmony_ci ATI_fragment_shader restrictions. 12005bd8deadSopenharmony_ci 12015bd8deadSopenharmony_ci Date: 7/9/2002 12025bd8deadSopenharmony_ci Revision: 1.0.8 12035bd8deadSopenharmony_ci - fixed a typo where constant declarations were missing the 12045bd8deadSopenharmony_ci "CONSTANT" keyword 12055bd8deadSopenharmony_ci 12065bd8deadSopenharmony_ci Date: 6/26/2002 12075bd8deadSopenharmony_ci Revision: 1.0.7 12085bd8deadSopenharmony_ci - clarified additional semantic constraints regarding 12095bd8deadSopenharmony_ci pass delimiters (prelim pass must have at least one ALU op) 12105bd8deadSopenharmony_ci - fixed a typo in the rusty shader example code 12115bd8deadSopenharmony_ci - clarified error conditions involving the use of the alpha 12125bd8deadSopenharmony_ci component of the secondary color parameter. 12135bd8deadSopenharmony_ci 12145bd8deadSopenharmony_ci Date: 6/23/2002 12155bd8deadSopenharmony_ci Revision: 1.0.6 12165bd8deadSopenharmony_ci - Very minor spec bug fixes: 12175bd8deadSopenharmony_ci - removed _ATI from several instructions 12185bd8deadSopenharmony_ci - fixed up some wrong line wrappings 12195bd8deadSopenharmony_ci - formally listed the <optionalDstMask> options to disallow 12205bd8deadSopenharmony_ci masks of the form ".r.g.b.a." which were never really legal, 12215bd8deadSopenharmony_ci but were allowed by the grammar as specified before. 12225bd8deadSopenharmony_ci - cleaned up the list of GL functions which accept 12235bd8deadSopenharmony_ci TEXT_FRAGMENT_SHADER_ATI as an enumerant. 12245bd8deadSopenharmony_ci - formally defined the value of TEXT_FRAGMENT_SHADER_ATI 12255bd8deadSopenharmony_ci - fixed 2 typos in the "simple modulation" sample shader 12265bd8deadSopenharmony_ci (SampleMap uses the r# to choose the texture unit, 12275bd8deadSopenharmony_ci and make sure to use the stq_dq source selector) 12285bd8deadSopenharmony_ci - removed an ambiguous "1.0" from the example code on 12295bd8deadSopenharmony_ci how to set a constant bound to a program local parameter. 12305bd8deadSopenharmony_ci 12315bd8deadSopenharmony_ci Date: 6/6/2002 12325bd8deadSopenharmony_ci Revision: 1.0.5 12335bd8deadSopenharmony_ci - Apple would now like the program local/env syntax added 12345bd8deadSopenharmony_ci in version 1.0.3 added back in to fit better into their 12355bd8deadSopenharmony_ci "pipeline program" based architecture and program token 12365bd8deadSopenharmony_ci stream syntax. Adding back in the changes introduced 12375bd8deadSopenharmony_ci in version 1.0.3. 12385bd8deadSopenharmony_ci - Fixed a typo in the description of constant binding syntax 12395bd8deadSopenharmony_ci where text referred to "c4" but the sample code referred 12405bd8deadSopenharmony_ci to "c1". "c1" is correct. 12415bd8deadSopenharmony_ci - Synced spec with version 1.4 and 1.5 of ATI_fragment_shader 12425bd8deadSopenharmony_ci 1.5: Added interaction with ARB_shadow. 12435bd8deadSopenharmony_ci 1.4: Specified that LERP's blend factor must be in the range 12445bd8deadSopenharmony_ci [0,1]. 12455bd8deadSopenharmony_ci 12465bd8deadSopenharmony_ci Date: 5/31/2002 12475bd8deadSopenharmony_ci Revision: 1.0.4 12485bd8deadSopenharmony_ci - To get the equivalent functionality to ATI_fragment_shader, 12495bd8deadSopenharmony_ci we only need inline constants and program env parameters, 12505bd8deadSopenharmony_ci So,based on some feedback from Apple, for simplicity, we remove 12515bd8deadSopenharmony_ci the usage of program locals that was added in 1.0.3 . 12525bd8deadSopenharmony_ci We keep program env parameters however. 12535bd8deadSopenharmony_ci 12545bd8deadSopenharmony_ci Date: 5/31/2002 12555bd8deadSopenharmony_ci Revision: 1.0.3 12565bd8deadSopenharmony_ci - added in the ability to declare constants as 12575bd8deadSopenharmony_ci program local/env parameters as in ARB_vertex_program 12585bd8deadSopenharmony_ci - added in the ability to declare constants as textual 12595bd8deadSopenharmony_ci string constants. 12605bd8deadSopenharmony_ci - above changes required additional "constant declaration" 12615bd8deadSopenharmony_ci block before the preliminary pass block, in order to 12625bd8deadSopenharmony_ci specify the program constant bindings. 12635bd8deadSopenharmony_ci - changed some tokens in the grammar to add the word 12645bd8deadSopenharmony_ci optional (they were already optional, just changed the name). 12655bd8deadSopenharmony_ci - fixed a reference in the text where "2x" was called "scale" 12665bd8deadSopenharmony_ci - fixed a bug in the grammar where it was possible to specify the 12675bd8deadSopenharmony_ci "." of a <dstMask> (now <optionalDstMask>) without specifying 12685bd8deadSopenharmony_ci the "r","g","b", or "a" mask values. 12695bd8deadSopenharmony_ci 12705bd8deadSopenharmony_ci Date: 5/26/2002 12715bd8deadSopenharmony_ci Revision: 1.0.2 12725bd8deadSopenharmony_ci - some spec language english grammatical fixes 12735bd8deadSopenharmony_ci - cleaned up description in usage guidelines to refer 12745bd8deadSopenharmony_ci to tokens named in the text grammar 12755bd8deadSopenharmony_ci - reordered semantic restriction summary to correspond to 12765bd8deadSopenharmony_ci order of explanations in following section. 12775bd8deadSopenharmony_ci - clarify that ATI_text_fragment_shader does not 12785bd8deadSopenharmony_ci replace color sum stage, (neither did ATI_fragment_shader). 12795bd8deadSopenharmony_ci - pulled "!!ATIfs1.0" header token from grammar and simply 12805bd8deadSopenharmony_ci required it to identify the subsequent language as 12815bd8deadSopenharmony_ci was done for ARB_vertex_program, version 24. 12825bd8deadSopenharmony_ci - clarified that the restriction on using a destination 12835bd8deadSopenharmony_ci register once in a singe pass applies only to 12845bd8deadSopenharmony_ci the PassTexCoord and SampleMap instructions. 12855bd8deadSopenharmony_ci 12865bd8deadSopenharmony_ci Date: 5/23/2002 12875bd8deadSopenharmony_ci Revision: 1.0.1 12885bd8deadSopenharmony_ci - added back in the concept of color/alpha pairing that was 12895bd8deadSopenharmony_ci removed in the first pass at the extension grammar 12905bd8deadSopenharmony_ci This lets color and alpha instructions be co-issued and 12915bd8deadSopenharmony_ci gives a program the opportunity to do different operations 12925bd8deadSopenharmony_ci on color and alpha components. 12935bd8deadSopenharmony_ci This feature of ATI_fragment_shader should not have been removed 12945bd8deadSopenharmony_ci in the original ATI_text_fragment_shader spec. 12955bd8deadSopenharmony_ci - add commas between instruction arguments in the grammar and 12965bd8deadSopenharmony_ci examples 12975bd8deadSopenharmony_ci - clean up some white space issues 12985bd8deadSopenharmony_ci - add a couple of references to TEXT_FRAGMENT_SHADER_ATI as 12995bd8deadSopenharmony_ci the target of the entry points shared with ARB_vertex_program. 13005bd8deadSopenharmony_ci 13015bd8deadSopenharmony_ci Date: 5/22/2002 13025bd8deadSopenharmony_ci Revision: 1.0 13035bd8deadSopenharmony_ci - first fully specified version 13045bd8deadSopenharmony_ci - based on the 1.3 version of ATI_fragment_shader specification 1305