11 Brian Paul
(brian_e_paul 'at' yahoo.com
)
15 XXX
- Not complete yet
!!!
19 Last Modified Date
: July
20, 2003
21 $Date
: 2003/07/21 04:23:32 $ $Revision
: 1.1 $
29 OpenGL
1.4 is required
30 The extension is written against the OpenGL
1.4 specification.
31 ARB_vertex_program or ARB_fragment_program or NV_vertex_program
32 or NV_fragment_program is required.
36 The extension provides facilities
for implementing debuggers
for
37 vertex and fragment programs.
39 The concept is that vertex and fragment program debuggers will be
40 implemented outside of the GL as a utility package. This extension
41 only provides the minimal hooks required to implement a debugger.
43 There are facilities to
do the following
:
44 1. Query the current values of input
, output and temporary registers.
45 2. Query the current program position during execution.
46 3. Have the GL call a user
-specified
function prior to executing
47 each vertex or fragment instruction.
49 The main feature is the ProgramCallbackMESA
function. It allows the
50 user to register a callback
function with the GL. The callback will
51 be called prior to executing each vertex or fragment program instruction.
52 The callback
function can determine whether to
return immediately
(to
53 continue program execution
) or stop and process user commands.
55 From within the callback
, the user may issue glGet
* commands to
56 query current GL state. The GetProgramRegisterfvMESA
function allows
57 all program register values to be queried
(such as temporaries
,
58 input attributes
, and result registers
).
60 There are flags
for enabling
/disabling the program callbacks.
62 The current execution position
(as an offset from the start of the
63 program string
) can be queried with
64 GetIntegerv
(GL_FRAGMENT_PROGRAM_POSITION_MESA
, &pos
) or
65 GetIntegerv
(GL_VERTEX_PROGRAM_POSITION_MESA
, &pos
).
74 1. Is this the right model
for a debugger?
76 It seems prudent to minimize the scope of this extension and leave
77 it up to the developer
(or developer community
) to write
(a
)
78 debugger
(s
) that layer on top of this extension.
80 If the debugger were fully implemented within the GL it's not
81 clear how terminal and GUI
-based interfaces would work
, for
84 2. There aren't any other extensions that register callbacks with
85 the GL. Isn't there another solution?
87 If we want to be able to single
-step through vertex
/fragment
88 programs I don't see another way to
do it.
90 3. How
do we prevent the user from doing something crazy
in the
91 callback
function, like trying to call glBegin?
93 The rule is that the callback
function can only issue glGet
*()
94 functions and no other GL commands. It could be difficult to
95 enforce this
, however. Therefore
, calling any non
-get GL
96 command from within the callback will result
in undefined
99 4. Is this extension amenable to hardware implementation?
101 Unresolved
, but we'd hope so. Perhaps the GL implementation
102 will have to fall back to a software path when debugging.
105 New Procedures and Functions
(and datatypes
)
107 typedef void
(*programcallbackMESA
)(enum target
, void
*data
)
109 void ProgramCallbackMESA
(enum target
, programcallbackMESA callback
,
112 void GetProgramRegisterfvMESA
(enum target
, sizei len
,
113 const ubyte
*registerName
, float
*v
)
117 Accepted by the
<cap
> parameter of Enable
, Disable
, IsEnabled
,
118 GetBooleanv
, GetDoublev
, GetFloatv and GetIntegerv
:
120 FRAGMENT_PROGRAM_CALLBACK_MESA
0x????
121 VERTEX_PROGRAM_CALLBACK_MESA
0x????
123 Accepted by the
<pname
> parameter GetBooleanv
, GetDoublev
,
124 GetFloatv and GetIntegerv
:
126 FRAGMENT_PROGRAM_POSITION_MESA
0x????
127 VERTEX_PROGRAM_POSITION_MESA
0x????
129 Accepted by the
<pname
> parameter of GetPointerv
:
131 FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA
0x????
132 FRAGMENT_PROGRAM_CALLBACK_DATA_MESA
0x????
133 VERTEX_PROGRAM_CALLBACK_FUNC_MESA
0x????
134 VERTEX_PROGRAM_CALLBACK_DATA_MESA
0x????
136 Additions to Chapter
2 of the OpenGL
1.4 Specification
(OpenGL Operation
)
140 Additions to Chapter
3 of the OpenGL
1.4 Specification
(Rasterization
)
144 Additions to Chapter
4 of the OpenGL
1.4 Specification
(Per
-Fragment
145 Operations and the Frame Buffer
)
149 Additions to Chapter
5 of the OpenGL
1.4 Specification
(Special Functions
)
151 XXX Document ProgramCallbackMESA here
153 Add to the list of functions which cannot be included
in display
154 lists
: ProgramCallbackMESA.
157 Additions to Chapter
6 of the OpenGL
1.4 Specification
(State and
160 XXX document GetProgramRegisterfvMESA here
164 Additions to Appendix A of the OpenGL
1.4 Specification
(Invariance
)
168 Additions to the AGL
/GLX
/WGL Specifications
176 Dependencies on NV_vertex_program and NV_fragment_program
178 If NV_vertex_program and
/or NV_fragment_program are supported
,
179 vertex and
/or fragment programs defined by those extensions may
180 be debugged as well. Register queries will use the syntax used
181 by those extensions
(i.e. "v
[X
]" to query vertex attributes
,
182 "o
[X
]"
for vertex outputs
, etc.
)
186 INVALID_OPERATION is generated
if ProgramCallbackMESA is called
187 between Begin and End.
189 INVALID_ENUM is generated by ProgramCallbackMESA
if <target
> is not
190 a supported vertex or fragment program
type.
192 Note
: INVALID_OPERAION IS NOT generated by GetProgramRegisterfvMESA
,
193 GetBooleanv
, GetDoublev
, GetFloatv
, or GetIntegerv
if called between
195 These functions may be called from the user
-provided callback
function
196 which is called between Begin
/End.
198 INVALID_ENUM is generated by ProgramCallbackMESA
,
199 GetProgramRegisterfvMESA
if <target
> is not a program target supported
200 by ARB_vertex_program
, ARB_fragment_program
(or NV_vertex_program or
201 NV_fragment_program
).
203 INVALID_VALUE is generated by GetProgramRegisterfvMESA
if <registerName
>
204 is not a recognized program register.
206 INVALID_OPERATION is generated by GetProgramRegisterfvMESA when a
207 register query is attempted
for a program target that's not currently
217 Get Value Type Get Command Value Description Sec. Attribute
218 --------- ---- ----------- ----- ----------- ---- ---------
219 FRAGMENT_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX
enable
220 VERTEX_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX
enable
221 FRAGMENT_PROGRAM_POSITION_MESA Z
+ GetIntegerv
-1 XXX XXX
-
222 VERTEX_PROGRAM_POSITION_MESA Z
+ GetIntegerv
-1 XXX XXX
-
223 FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX
-
224 VERTEX_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX
-
225 FRAGMENT_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX
-
226 VERTEX_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX
-
230 New Implementation Dependent State
237 Initial draft.
(Brian Paul
)
239 Second draft.
(Brian Paul
)
241 Third draft. Lots of fundamental changes.
(Brian Paul
)
245 /* This is called by the GL when the vertex program is executing.
246 * We can only
make glGet
* calls from within this
function!
248 void DebugCallback
(GLenum target
, GLvoid
*data
)
253 /* Get PC and current instruction string
*/
254 glGetIntegerv
(GL_VERTEX_PROGRAM_POSITION_ARB
, &pos
);
256 printf("Current position
: %d\n"
, pos
);
258 printf("Current temporary registers
:\n"
);
259 for (i
= 0; i
< 4; i
++) {
262 sprintf
(s
, "R
%d"
, i
);
263 glGetProgramRegisterfvMESA
(GL_VERTEX_PROGRAM_ARB
, strlen
(s
), s
, v
);
264 printf("R
%d = %g, %g, %g, %g\n"
, i
, v
[0], v
[1], v
[2], v
[3]);
273 /* Register our debugger callback
function */
274 glProgramCallbackMESA
(GL_VERTEX_PROGRAM_ARB
, DebugCallback
, NULL
);
275 glEnable
(GL_VERTEX_PROGRAM_CALLBACK_MESA
);
277 /* define
/bind a vertex program
*/
279 glEnable
(GL_VERTEX_PROGRAM
);
281 /* render something
*/