164da663f51ea93b1571f4932de044757e3d00b56Brian PaulName 264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 364da663f51ea93b1571f4932de044757e3d00b56Brian Paul MESA_program_debug 464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 564da663f51ea93b1571f4932de044757e3d00b56Brian PaulName Strings 664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 764da663f51ea93b1571f4932de044757e3d00b56Brian Paul GL_MESA_program_debug 864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 964da663f51ea93b1571f4932de044757e3d00b56Brian PaulContact 1064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 11d3b09fe29b112ddf114d14849e917befafd8387aBrian Paul Brian Paul (brian.paul 'at' tungstengraphics.com) 1264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 1364da663f51ea93b1571f4932de044757e3d00b56Brian PaulStatus 1464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 1564da663f51ea93b1571f4932de044757e3d00b56Brian Paul XXX - Not complete yet!!! 1664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 1764da663f51ea93b1571f4932de044757e3d00b56Brian PaulVersion 1864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 1964da663f51ea93b1571f4932de044757e3d00b56Brian Paul Last Modified Date: July 20, 2003 2064da663f51ea93b1571f4932de044757e3d00b56Brian Paul Author Revision: 1.0 2164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 2264da663f51ea93b1571f4932de044757e3d00b56Brian PaulNumber 2364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 2464da663f51ea93b1571f4932de044757e3d00b56Brian Paul TBD 2564da663f51ea93b1571f4932de044757e3d00b56Brian Paul 2664da663f51ea93b1571f4932de044757e3d00b56Brian PaulDependencies 2764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 2864da663f51ea93b1571f4932de044757e3d00b56Brian Paul OpenGL 1.4 is required 2964da663f51ea93b1571f4932de044757e3d00b56Brian Paul The extension is written against the OpenGL 1.4 specification. 3064da663f51ea93b1571f4932de044757e3d00b56Brian Paul ARB_vertex_program or ARB_fragment_program or NV_vertex_program 3164da663f51ea93b1571f4932de044757e3d00b56Brian Paul or NV_fragment_program is required. 3264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 3364da663f51ea93b1571f4932de044757e3d00b56Brian PaulOverview 3464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 3564da663f51ea93b1571f4932de044757e3d00b56Brian Paul The extension provides facilities for implementing debuggers for 3664da663f51ea93b1571f4932de044757e3d00b56Brian Paul vertex and fragment programs. 3764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 3864da663f51ea93b1571f4932de044757e3d00b56Brian Paul The concept is that vertex and fragment program debuggers will be 3964da663f51ea93b1571f4932de044757e3d00b56Brian Paul implemented outside of the GL as a utility package. This extension 4064da663f51ea93b1571f4932de044757e3d00b56Brian Paul only provides the minimal hooks required to implement a debugger. 4164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 4264da663f51ea93b1571f4932de044757e3d00b56Brian Paul There are facilities to do the following: 43d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 1. Have the GL call a user-specified function prior to executing 4464da663f51ea93b1571f4932de044757e3d00b56Brian Paul each vertex or fragment instruction. 45d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 2. Query the current program string's execution position. 46d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 3. Query the current values of intermediate program values. 4764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 4864da663f51ea93b1571f4932de044757e3d00b56Brian Paul The main feature is the ProgramCallbackMESA function. It allows the 4964da663f51ea93b1571f4932de044757e3d00b56Brian Paul user to register a callback function with the GL. The callback will 5064da663f51ea93b1571f4932de044757e3d00b56Brian Paul be called prior to executing each vertex or fragment program instruction. 5164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 52b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul From within the callback, the user may issue Get* commands to 5364da663f51ea93b1571f4932de044757e3d00b56Brian Paul query current GL state. The GetProgramRegisterfvMESA function allows 54d19b5db5dce92efd55359607006a32076dc95d12Brian Paul current program values to be queried (such as temporaries, input 55d19b5db5dce92efd55359607006a32076dc95d12Brian Paul attributes, and result registers). 5664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 5764da663f51ea93b1571f4932de044757e3d00b56Brian Paul There are flags for enabling/disabling the program callbacks. 5864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 5964da663f51ea93b1571f4932de044757e3d00b56Brian Paul The current execution position (as an offset from the start of the 6064da663f51ea93b1571f4932de044757e3d00b56Brian Paul program string) can be queried with 6164da663f51ea93b1571f4932de044757e3d00b56Brian Paul GetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos) or 6264da663f51ea93b1571f4932de044757e3d00b56Brian Paul GetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos). 6364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 6464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 6564da663f51ea93b1571f4932de044757e3d00b56Brian PaulIP Status 6664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 6764da663f51ea93b1571f4932de044757e3d00b56Brian Paul None 6864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 6964da663f51ea93b1571f4932de044757e3d00b56Brian PaulIssues 7064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 7164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 1. Is this the right model for a debugger? 7264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 7364da663f51ea93b1571f4932de044757e3d00b56Brian Paul It seems prudent to minimize the scope of this extension and leave 74b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul it up to the developer (or developer community) to write debuggers 75b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul that layer on top of this extension. 7664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 7764da663f51ea93b1571f4932de044757e3d00b56Brian Paul If the debugger were fully implemented within the GL it's not 7864da663f51ea93b1571f4932de044757e3d00b56Brian Paul clear how terminal and GUI-based interfaces would work, for 7964da663f51ea93b1571f4932de044757e3d00b56Brian Paul example. 8064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 8164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 2. There aren't any other extensions that register callbacks with 8264da663f51ea93b1571f4932de044757e3d00b56Brian Paul the GL. Isn't there another solution? 8364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 8464da663f51ea93b1571f4932de044757e3d00b56Brian Paul If we want to be able to single-step through vertex/fragment 8564da663f51ea93b1571f4932de044757e3d00b56Brian Paul programs I don't see another way to do it. 8664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 8764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 3. How do we prevent the user from doing something crazy in the 88d19b5db5dce92efd55359607006a32076dc95d12Brian Paul callback function, like trying to call glBegin (leading to 89d19b5db5dce92efd55359607006a32076dc95d12Brian Paul recursion)? 9064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 9164da663f51ea93b1571f4932de044757e3d00b56Brian Paul The rule is that the callback function can only issue glGet*() 9264da663f51ea93b1571f4932de044757e3d00b56Brian Paul functions and no other GL commands. It could be difficult to 9364da663f51ea93b1571f4932de044757e3d00b56Brian Paul enforce this, however. Therefore, calling any non-get GL 9464da663f51ea93b1571f4932de044757e3d00b56Brian Paul command from within the callback will result in undefined 9564da663f51ea93b1571f4932de044757e3d00b56Brian Paul results. 9664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 9764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 4. Is this extension amenable to hardware implementation? 9864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 99d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Hopefully, but if not, the GL implementation will have to fall 100d19b5db5dce92efd55359607006a32076dc95d12Brian Paul back to a software path when debugging. This may be acceptable 101d19b5db5dce92efd55359607006a32076dc95d12Brian Paul for debugging. 102d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 103d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 5. What's the <data> parameter to ProgramCallbackMESA for? 104d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 105d19b5db5dce92efd55359607006a32076dc95d12Brian Paul It's a common programming practice to associate a user-supplied 106d19b5db5dce92efd55359607006a32076dc95d12Brian Paul value with callback functions. 107d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 108d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 6. Debuggers often allow one to modify intermediate program values, 109d19b5db5dce92efd55359607006a32076dc95d12Brian Paul then continue. Does this extension support that? 110d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 111d19b5db5dce92efd55359607006a32076dc95d12Brian Paul No. 11264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 11364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 11464da663f51ea93b1571f4932de044757e3d00b56Brian PaulNew Procedures and Functions (and datatypes) 11564da663f51ea93b1571f4932de044757e3d00b56Brian Paul 11664da663f51ea93b1571f4932de044757e3d00b56Brian Paul typedef void (*programcallbackMESA)(enum target, void *data) 11764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 11864da663f51ea93b1571f4932de044757e3d00b56Brian Paul void ProgramCallbackMESA(enum target, programcallbackMESA callback, 11964da663f51ea93b1571f4932de044757e3d00b56Brian Paul void *data) 12064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 12164da663f51ea93b1571f4932de044757e3d00b56Brian Paul void GetProgramRegisterfvMESA(enum target, sizei len, 12264da663f51ea93b1571f4932de044757e3d00b56Brian Paul const ubyte *registerName, float *v) 12364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 12464da663f51ea93b1571f4932de044757e3d00b56Brian PaulNew Tokens 12564da663f51ea93b1571f4932de044757e3d00b56Brian Paul 12664da663f51ea93b1571f4932de044757e3d00b56Brian Paul Accepted by the <cap> parameter of Enable, Disable, IsEnabled, 12764da663f51ea93b1571f4932de044757e3d00b56Brian Paul GetBooleanv, GetDoublev, GetFloatv and GetIntegerv: 12864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 129b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul FRAGMENT_PROGRAM_CALLBACK_MESA 0x8bb1 130b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul VERTEX_PROGRAM_CALLBACK_MESA 0x8bb4 13164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 13264da663f51ea93b1571f4932de044757e3d00b56Brian Paul Accepted by the <pname> parameter GetBooleanv, GetDoublev, 13364da663f51ea93b1571f4932de044757e3d00b56Brian Paul GetFloatv and GetIntegerv: 13464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 135b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul FRAGMENT_PROGRAM_POSITION_MESA 0x8bb0 136b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul VERTEX_PROGRAM_POSITION_MESA 0x8bb4 13764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 13864da663f51ea93b1571f4932de044757e3d00b56Brian Paul Accepted by the <pname> parameter of GetPointerv: 13964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 140b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8bb2 141b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8bb3 142b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8bb6 143b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8bb7 14464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 14564da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation) 14664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 14764da663f51ea93b1571f4932de044757e3d00b56Brian Paul None. 14864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 14964da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to Chapter 3 of the OpenGL 1.4 Specification (Rasterization) 15064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 15164da663f51ea93b1571f4932de044757e3d00b56Brian Paul None. 15264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 15364da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment 15464da663f51ea93b1571f4932de044757e3d00b56Brian PaulOperations and the Frame Buffer) 15564da663f51ea93b1571f4932de044757e3d00b56Brian Paul 15664da663f51ea93b1571f4932de044757e3d00b56Brian Paul None. 15764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 15864da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions) 15964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 160d19b5db5dce92efd55359607006a32076dc95d12Brian Paul In section 5.4 "Display Lists", page 202, add the following command 161d19b5db5dce92efd55359607006a32076dc95d12Brian Paul to the list of those that are not compiled into display lists: 162b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul 163b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul ProgramCallbackMESA. 164d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 165d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 166d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Add a new section 5.7 "Callback Functions" 167d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 168d19b5db5dce92efd55359607006a32076dc95d12Brian Paul The function 169d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 170d19b5db5dce92efd55359607006a32076dc95d12Brian Paul void ProgramCallbackMESA(enum target, programcallbackMESA callback, 171d19b5db5dce92efd55359607006a32076dc95d12Brian Paul void *data) 172d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 173b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul registers a user-defined callback function with the GL. <target> 174b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul may be FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB. The enabled 175b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul callback functions registered with these targets will be called 176b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul prior to executing each instruction in the current fragment or 177b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul vertex program, respectively. The callbacks are enabled and 178b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul disabled by calling Enable or Disable with <cap> 179d19b5db5dce92efd55359607006a32076dc95d12Brian Paul FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB. 18064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 181d19b5db5dce92efd55359607006a32076dc95d12Brian Paul The callback function's signature must match the typedef 182d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 183d19b5db5dce92efd55359607006a32076dc95d12Brian Paul typedef void (*programcallbackMESA)(enum target, void *data) 184d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 185d19b5db5dce92efd55359607006a32076dc95d12Brian Paul When the callback function is called, <target> will either be 186d19b5db5dce92efd55359607006a32076dc95d12Brian Paul FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB to indicate which 187d19b5db5dce92efd55359607006a32076dc95d12Brian Paul program is currently executing and <data> will be the value 188d19b5db5dce92efd55359607006a32076dc95d12Brian Paul specified when ProgramCallbackMESA was called. 189d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 190d19b5db5dce92efd55359607006a32076dc95d12Brian Paul From within the callback function, only the following GL commands 191d19b5db5dce92efd55359607006a32076dc95d12Brian Paul may be called: 192d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 193d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetBooleanv 194d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetDoublev 195d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetFloatv 196d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetIntegerv 197d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetProgramLocalParameter 198d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetProgramEnvParameter 199d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetProgramRegisterfvMESA 200d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetProgramivARB 201d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetProgramStringARB 202d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GetError 203d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 204d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Calling any other command from within the callback results in 205d19b5db5dce92efd55359607006a32076dc95d12Brian Paul undefined behaviour. 20664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 20764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 20864da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to Chapter 6 of the OpenGL 1.4 Specification (State and 20964da663f51ea93b1571f4932de044757e3d00b56Brian PaulState Requests) 21064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 211d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Add a new section 6.1.3 "Program Value Queries": 21264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 213d19b5db5dce92efd55359607006a32076dc95d12Brian Paul The command 214d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 215d19b5db5dce92efd55359607006a32076dc95d12Brian Paul void GetProgramRegisterfvMESA(enum target, sizei len, 216d19b5db5dce92efd55359607006a32076dc95d12Brian Paul const ubyte *registerName, 217d19b5db5dce92efd55359607006a32076dc95d12Brian Paul float *v) 218d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 219d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Is used to query the value of program variables and registers 220b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul during program execution. GetProgramRegisterfvMESA may only be 221d19b5db5dce92efd55359607006a32076dc95d12Brian Paul called from within a callback function registered with 222d19b5db5dce92efd55359607006a32076dc95d12Brian Paul ProgramCallbackMESA. 223d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 224b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul <registerName> and <len> specify the name a variable, input 225b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul attribute, temporary, or result register in the program string. 226b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul The current value of the named variable is returned as four 227b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul values in <v>. If <name> doesn't exist in the program string, 228b0cde8390681c32ab48f95911813a475aec02c0cBrian Paul the error INVALID_OPERATION is generated. 22964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 23064da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to Appendix A of the OpenGL 1.4 Specification (Invariance) 23164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 23264da663f51ea93b1571f4932de044757e3d00b56Brian Paul None. 23364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 23464da663f51ea93b1571f4932de044757e3d00b56Brian PaulAdditions to the AGL/GLX/WGL Specifications 23564da663f51ea93b1571f4932de044757e3d00b56Brian Paul 23664da663f51ea93b1571f4932de044757e3d00b56Brian Paul None. 23764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 23864da663f51ea93b1571f4932de044757e3d00b56Brian PaulGLX Protocol 23964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 24064da663f51ea93b1571f4932de044757e3d00b56Brian Paul XXX TBD 24164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 24264da663f51ea93b1571f4932de044757e3d00b56Brian PaulDependencies on NV_vertex_program and NV_fragment_program 24364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 24464da663f51ea93b1571f4932de044757e3d00b56Brian Paul If NV_vertex_program and/or NV_fragment_program are supported, 24564da663f51ea93b1571f4932de044757e3d00b56Brian Paul vertex and/or fragment programs defined by those extensions may 24664da663f51ea93b1571f4932de044757e3d00b56Brian Paul be debugged as well. Register queries will use the syntax used 24764da663f51ea93b1571f4932de044757e3d00b56Brian Paul by those extensions (i.e. "v[X]" to query vertex attributes, 24864da663f51ea93b1571f4932de044757e3d00b56Brian Paul "o[X]" for vertex outputs, etc.) 24964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 25064da663f51ea93b1571f4932de044757e3d00b56Brian PaulErrors 25164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 25264da663f51ea93b1571f4932de044757e3d00b56Brian Paul INVALID_OPERATION is generated if ProgramCallbackMESA is called 25364da663f51ea93b1571f4932de044757e3d00b56Brian Paul between Begin and End. 25464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 25564da663f51ea93b1571f4932de044757e3d00b56Brian Paul INVALID_ENUM is generated by ProgramCallbackMESA if <target> is not 25664da663f51ea93b1571f4932de044757e3d00b56Brian Paul a supported vertex or fragment program type. 25764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 25864da663f51ea93b1571f4932de044757e3d00b56Brian Paul Note: INVALID_OPERAION IS NOT generated by GetProgramRegisterfvMESA, 25964da663f51ea93b1571f4932de044757e3d00b56Brian Paul GetBooleanv, GetDoublev, GetFloatv, or GetIntegerv if called between 260d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Begin and End when a vertex or fragment program is currently executing. 26164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 26264da663f51ea93b1571f4932de044757e3d00b56Brian Paul INVALID_ENUM is generated by ProgramCallbackMESA, 26364da663f51ea93b1571f4932de044757e3d00b56Brian Paul GetProgramRegisterfvMESA if <target> is not a program target supported 26464da663f51ea93b1571f4932de044757e3d00b56Brian Paul by ARB_vertex_program, ARB_fragment_program (or NV_vertex_program or 26564da663f51ea93b1571f4932de044757e3d00b56Brian Paul NV_fragment_program). 26664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 26764da663f51ea93b1571f4932de044757e3d00b56Brian Paul INVALID_VALUE is generated by GetProgramRegisterfvMESA if <registerName> 268d19b5db5dce92efd55359607006a32076dc95d12Brian Paul does not name a known program register or variable. 26964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 27064da663f51ea93b1571f4932de044757e3d00b56Brian Paul INVALID_OPERATION is generated by GetProgramRegisterfvMESA when a 27164da663f51ea93b1571f4932de044757e3d00b56Brian Paul register query is attempted for a program target that's not currently 27264da663f51ea93b1571f4932de044757e3d00b56Brian Paul being executed. 27364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 27464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 27564da663f51ea93b1571f4932de044757e3d00b56Brian PaulNew State 27664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 27764da663f51ea93b1571f4932de044757e3d00b56Brian Paul XXX finish 27864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 27964da663f51ea93b1571f4932de044757e3d00b56Brian Paul(table 6.N, p. ###) 28064da663f51ea93b1571f4932de044757e3d00b56Brian Paul Initial 28164da663f51ea93b1571f4932de044757e3d00b56Brian Paul Get Value Type Get Command Value Description Sec. Attribute 28264da663f51ea93b1571f4932de044757e3d00b56Brian Paul --------- ---- ----------- ----- ----------- ---- --------- 28364da663f51ea93b1571f4932de044757e3d00b56Brian Paul FRAGMENT_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX enable 28464da663f51ea93b1571f4932de044757e3d00b56Brian Paul VERTEX_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX enable 28564da663f51ea93b1571f4932de044757e3d00b56Brian Paul FRAGMENT_PROGRAM_POSITION_MESA Z+ GetIntegerv -1 XXX XXX - 28664da663f51ea93b1571f4932de044757e3d00b56Brian Paul VERTEX_PROGRAM_POSITION_MESA Z+ GetIntegerv -1 XXX XXX - 28764da663f51ea93b1571f4932de044757e3d00b56Brian Paul FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX - 28864da663f51ea93b1571f4932de044757e3d00b56Brian Paul VERTEX_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX - 28964da663f51ea93b1571f4932de044757e3d00b56Brian Paul FRAGMENT_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX - 29064da663f51ea93b1571f4932de044757e3d00b56Brian Paul VERTEX_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX - 29164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 29264da663f51ea93b1571f4932de044757e3d00b56Brian Paul XXX more? 29364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 29464da663f51ea93b1571f4932de044757e3d00b56Brian PaulNew Implementation Dependent State 29564da663f51ea93b1571f4932de044757e3d00b56Brian Paul 29664da663f51ea93b1571f4932de044757e3d00b56Brian Paul None. 29764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 29864da663f51ea93b1571f4932de044757e3d00b56Brian PaulRevision History 29964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 30064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 8 July 2003 30164da663f51ea93b1571f4932de044757e3d00b56Brian Paul Initial draft. (Brian Paul) 30264da663f51ea93b1571f4932de044757e3d00b56Brian Paul 11 July 2003 30364da663f51ea93b1571f4932de044757e3d00b56Brian Paul Second draft. (Brian Paul) 30464da663f51ea93b1571f4932de044757e3d00b56Brian Paul 20 July 2003 30564da663f51ea93b1571f4932de044757e3d00b56Brian Paul Third draft. Lots of fundamental changes. (Brian Paul) 306d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 23 July 2003 307d19b5db5dce92efd55359607006a32076dc95d12Brian Paul Added chapter 5 and 6 spec language. (Brian Paul) 30864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 30964da663f51ea93b1571f4932de044757e3d00b56Brian PaulExample Usage 31064da663f51ea93b1571f4932de044757e3d00b56Brian Paul 311d19b5db5dce92efd55359607006a32076dc95d12Brian Paul The following is a very simple example of how this extension may 312d19b5db5dce92efd55359607006a32076dc95d12Brian Paul be used to print the values of R0, R1, R2 and R3 while executing 313d19b5db5dce92efd55359607006a32076dc95d12Brian Paul vertex programs. 314d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 315d19b5db5dce92efd55359607006a32076dc95d12Brian Paul 316d19b5db5dce92efd55359607006a32076dc95d12Brian Paul /* This is called by the GL when the vertex program is executing. 317d19b5db5dce92efd55359607006a32076dc95d12Brian Paul * We can only make glGet* calls from within this function! 318d19b5db5dce92efd55359607006a32076dc95d12Brian Paul */ 319d19b5db5dce92efd55359607006a32076dc95d12Brian Paul void DebugCallback(GLenum target, GLvoid *data) 320d19b5db5dce92efd55359607006a32076dc95d12Brian Paul { 321d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GLint pos; 322d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GLuint i; 32364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 324d19b5db5dce92efd55359607006a32076dc95d12Brian Paul /* Get PC and current instruction string */ 325d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_ARB, &pos); 32664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 327d19b5db5dce92efd55359607006a32076dc95d12Brian Paul printf("Current position: %d\n", pos); 32864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 329d19b5db5dce92efd55359607006a32076dc95d12Brian Paul printf("Current temporary registers:\n"); 330d19b5db5dce92efd55359607006a32076dc95d12Brian Paul for (i = 0; i < 4; i++) { 331d19b5db5dce92efd55359607006a32076dc95d12Brian Paul GLfloat v[4]; 332d19b5db5dce92efd55359607006a32076dc95d12Brian Paul char s[10]; 333d19b5db5dce92efd55359607006a32076dc95d12Brian Paul sprintf(s, "R%d", i); 334d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_ARB, strlen(s), s, v); 335d19b5db5dce92efd55359607006a32076dc95d12Brian Paul printf("R%d = %g, %g, %g, %g\n", i, v[0], v[1], v[2], v[3]); 336d19b5db5dce92efd55359607006a32076dc95d12Brian Paul } 337d19b5db5dce92efd55359607006a32076dc95d12Brian Paul } 33864da663f51ea93b1571f4932de044757e3d00b56Brian Paul 33964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 340d19b5db5dce92efd55359607006a32076dc95d12Brian Paul /* 341d19b5db5dce92efd55359607006a32076dc95d12Brian Paul * elsewhere... 342d19b5db5dce92efd55359607006a32076dc95d12Brian Paul */ 34364da663f51ea93b1571f4932de044757e3d00b56Brian Paul 344d19b5db5dce92efd55359607006a32076dc95d12Brian Paul /* Register our debugger callback function */ 345d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glProgramCallbackMESA(GL_VERTEX_PROGRAM_ARB, DebugCallback, NULL); 346d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glEnable(GL_VERTEX_PROGRAM_CALLBACK_MESA); 34764da663f51ea93b1571f4932de044757e3d00b56Brian Paul 348d19b5db5dce92efd55359607006a32076dc95d12Brian Paul /* define/bind a vertex program */ 34964da663f51ea93b1571f4932de044757e3d00b56Brian Paul 350d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glEnable(GL_VERTEX_PROGRAM); 35164da663f51ea93b1571f4932de044757e3d00b56Brian Paul 352d19b5db5dce92efd55359607006a32076dc95d12Brian Paul /* render something */ 353d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glBegin(GL_POINTS); 354d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glVertex2f(0, 0); 355d19b5db5dce92efd55359607006a32076dc95d12Brian Paul glEnd(); 35664da663f51ea93b1571f4932de044757e3d00b56Brian Paul 357