1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgName 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org MESA_program_debug 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgName Strings 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GL_MESA_program_debug 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgContact 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Brian Paul (brian.paul 'at' tungstengraphics.com) 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgStatus 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org XXX - Not complete yet!!! 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgVersion 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Last Modified Date: July 20, 2003 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Author Revision: 1.0 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgNumber 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org TBD 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgDependencies 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org OpenGL 1.4 is required 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The extension is written against the OpenGL 1.4 specification. 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ARB_vertex_program or ARB_fragment_program or NV_vertex_program 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org or NV_fragment_program is required. 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgOverview 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The extension provides facilities for implementing debuggers for 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org vertex and fragment programs. 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The concept is that vertex and fragment program debuggers will be 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org implemented outside of the GL as a utility package. This extension 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org only provides the minimal hooks required to implement a debugger. 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org There are facilities to do the following: 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1. Have the GL call a user-specified function prior to executing 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org each vertex or fragment instruction. 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2. Query the current program string's execution position. 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3. Query the current values of intermediate program values. 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The main feature is the ProgramCallbackMESA function. It allows the 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org user to register a callback function with the GL. The callback will 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org be called prior to executing each vertex or fragment program instruction. 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org From within the callback, the user may issue Get* commands to 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org query current GL state. The GetProgramRegisterfvMESA function allows 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org current program values to be queried (such as temporaries, input 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org attributes, and result registers). 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org There are flags for enabling/disabling the program callbacks. 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The current execution position (as an offset from the start of the 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org program string) can be queried with 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos) or 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos). 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgIP Status 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgIssues 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1. Is this the right model for a debugger? 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org It seems prudent to minimize the scope of this extension and leave 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org it up to the developer (or developer community) to write debuggers 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org that layer on top of this extension. 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org If the debugger were fully implemented within the GL it's not 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org clear how terminal and GUI-based interfaces would work, for 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org example. 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2. There aren't any other extensions that register callbacks with 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org the GL. Isn't there another solution? 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org If we want to be able to single-step through vertex/fragment 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org programs I don't see another way to do it. 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 3. How do we prevent the user from doing something crazy in the 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org callback function, like trying to call glBegin (leading to 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org recursion)? 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The rule is that the callback function can only issue glGet*() 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions and no other GL commands. It could be difficult to 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org enforce this, however. Therefore, calling any non-get GL 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org command from within the callback will result in undefined 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org results. 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 4. Is this extension amenable to hardware implementation? 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Hopefully, but if not, the GL implementation will have to fall 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org back to a software path when debugging. This may be acceptable 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for debugging. 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 5. What's the <data> parameter to ProgramCallbackMESA for? 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org It's a common programming practice to associate a user-supplied 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org value with callback functions. 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 6. Debuggers often allow one to modify intermediate program values, 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org then continue. Does this extension support that? 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org No. 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgNew Procedures and Functions (and datatypes) 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef void (*programcallbackMESA)(enum target, void *data) 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void ProgramCallbackMESA(enum target, programcallbackMESA callback, 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void *data) 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void GetProgramRegisterfvMESA(enum target, sizei len, 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const ubyte *registerName, float *v) 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgNew Tokens 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Accepted by the <cap> parameter of Enable, Disable, IsEnabled, 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetBooleanv, GetDoublev, GetFloatv and GetIntegerv: 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_CALLBACK_MESA 0x8bb1 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_CALLBACK_MESA 0x8bb4 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Accepted by the <pname> parameter GetBooleanv, GetDoublev, 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetFloatv and GetIntegerv: 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_POSITION_MESA 0x8bb0 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_POSITION_MESA 0x8bb4 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Accepted by the <pname> parameter of GetPointerv: 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8bb2 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8bb3 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8bb6 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8bb7 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation) 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None. 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to Chapter 3 of the OpenGL 1.4 Specification (Rasterization) 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None. 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgOperations and the Frame Buffer) 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None. 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions) 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org In section 5.4 "Display Lists", page 202, add the following command 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org to the list of those that are not compiled into display lists: 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ProgramCallbackMESA. 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Add a new section 5.7 "Callback Functions" 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The function 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void ProgramCallbackMESA(enum target, programcallbackMESA callback, 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void *data) 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org registers a user-defined callback function with the GL. <target> 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org may be FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB. The enabled 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org callback functions registered with these targets will be called 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org prior to executing each instruction in the current fragment or 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org vertex program, respectively. The callbacks are enabled and 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org disabled by calling Enable or Disable with <cap> 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB. 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The callback function's signature must match the typedef 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org typedef void (*programcallbackMESA)(enum target, void *data) 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org When the callback function is called, <target> will either be 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB to indicate which 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org program is currently executing and <data> will be the value 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org specified when ProgramCallbackMESA was called. 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org From within the callback function, only the following GL commands 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org may be called: 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetBooleanv 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetDoublev 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetFloatv 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetIntegerv 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetProgramLocalParameter 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetProgramEnvParameter 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetProgramRegisterfvMESA 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetProgramivARB 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetProgramStringARB 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetError 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Calling any other command from within the callback results in 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org undefined behaviour. 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to Chapter 6 of the OpenGL 1.4 Specification (State and 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgState Requests) 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Add a new section 6.1.3 "Program Value Queries": 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The command 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void GetProgramRegisterfvMESA(enum target, sizei len, 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const ubyte *registerName, 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org float *v) 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Is used to query the value of program variables and registers 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org during program execution. GetProgramRegisterfvMESA may only be 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org called from within a callback function registered with 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ProgramCallbackMESA. 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org <registerName> and <len> specify the name a variable, input 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org attribute, temporary, or result register in the program string. 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The current value of the named variable is returned as four 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org values in <v>. If <name> doesn't exist in the program string, 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org the error INVALID_OPERATION is generated. 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to Appendix A of the OpenGL 1.4 Specification (Invariance) 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None. 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgAdditions to the AGL/GLX/WGL Specifications 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None. 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgGLX Protocol 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org XXX TBD 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgDependencies on NV_vertex_program and NV_fragment_program 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org If NV_vertex_program and/or NV_fragment_program are supported, 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org vertex and/or fragment programs defined by those extensions may 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org be debugged as well. Register queries will use the syntax used 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org by those extensions (i.e. "v[X]" to query vertex attributes, 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org "o[X]" for vertex outputs, etc.) 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgErrors 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org INVALID_OPERATION is generated if ProgramCallbackMESA is called 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org between Begin and End. 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org INVALID_ENUM is generated by ProgramCallbackMESA if <target> is not 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org a supported vertex or fragment program type. 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Note: INVALID_OPERAION IS NOT generated by GetProgramRegisterfvMESA, 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetBooleanv, GetDoublev, GetFloatv, or GetIntegerv if called between 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Begin and End when a vertex or fragment program is currently executing. 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org INVALID_ENUM is generated by ProgramCallbackMESA, 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GetProgramRegisterfvMESA if <target> is not a program target supported 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org by ARB_vertex_program, ARB_fragment_program (or NV_vertex_program or 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org NV_fragment_program). 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org INVALID_VALUE is generated by GetProgramRegisterfvMESA if <registerName> 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org does not name a known program register or variable. 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org INVALID_OPERATION is generated by GetProgramRegisterfvMESA when a 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org register query is attempted for a program target that's not currently 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org being executed. 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgNew State 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org XXX finish 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org(table 6.N, p. ###) 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Initial 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Get Value Type Get Command Value Description Sec. Attribute 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org --------- ---- ----------- ----- ----------- ---- --------- 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX enable 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX enable 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_POSITION_MESA Z+ GetIntegerv -1 XXX XXX - 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_POSITION_MESA Z+ GetIntegerv -1 XXX XXX - 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX - 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX - 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FRAGMENT_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX - 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VERTEX_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX - 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org XXX more? 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgNew Implementation Dependent State 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org None. 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgRevision History 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 8 July 2003 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Initial draft. (Brian Paul) 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 11 July 2003 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Second draft. (Brian Paul) 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 20 July 2003 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Third draft. Lots of fundamental changes. (Brian Paul) 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 23 July 2003 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Added chapter 5 and 6 spec language. (Brian Paul) 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgExample Usage 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org The following is a very simple example of how this extension may 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org be used to print the values of R0, R1, R2 and R3 while executing 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org vertex programs. 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* This is called by the GL when the vertex program is executing. 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * We can only make glGet* calls from within this function! 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void DebugCallback(GLenum target, GLvoid *data) 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint pos; 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint i; 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Get PC and current instruction string */ 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_ARB, &pos); 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("Current position: %d\n", pos); 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("Current temporary registers:\n"); 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < 4; i++) { 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat v[4]; 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org char s[10]; 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sprintf(s, "R%d", i); 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_ARB, strlen(s), s, v); 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("R%d = %g, %g, %g, %g\n", i, v[0], v[1], v[2], v[3]); 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * elsewhere... 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Register our debugger callback function */ 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glProgramCallbackMESA(GL_VERTEX_PROGRAM_ARB, DebugCallback, NULL); 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glEnable(GL_VERTEX_PROGRAM_CALLBACK_MESA); 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* define/bind a vertex program */ 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glEnable(GL_VERTEX_PROGRAM); 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* render something */ 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glBegin(GL_POINTS); 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glVertex2f(0, 0); 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org glEnd(); 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 357