Name EXT_Cg_shader Name Strings GL_EXT_Cg_shader Contact Mark J. Kilgard, NVIDIA Corporation (mjk 'at' nvidia.com) Notice Copyright NVIDIA Corporation, 2003. Status not done yet Version $Id: //sw/docs/gpu/drivers/OpenGL/specs/GL_EXT_Cg_shader.txt#1 $ Number UNASSIGNED Dependencies Written based on the OpenGL 1.5 specification. The ARB_shader_objects extension is required. Written assuming support for the ARB_fragment_shader and ARB_vertex_shader extensions. Overview Based on the ARB_shader_objects interface, this extension allows Cg programs to be compiled into a shader object, linked into a program object, and used. With this extension, you are free to combine GLSL and Cg programs in the same application and even use a GLSL vertex shader with a Cg fragment program and vice versa. Issues Do we need a way to specify a profile? I think yes. Makes sure you can compile a program for older hardware without having to try the older hardware. Default profile should be the hardware's "best" profile. Need to provide an API mechanism to specify the profile and query supported profiles. Do we need to specify command line options? I think so. I think we should have another "generic" extension of ARB_shader_objects for this that worked with GLSL and Cg program. Should we have a way to query assembly back (mainly for debugging)? I think so. Again, that should probably part of a "generic" extension of ARB_shader_objects. How does this interact with subshaders? I don't know. Might need some API. New Procedures and Functions None New Tokens Accepted by the argument of CreateShaderObjectARB: CG_VERTEX_SHADER_EXT 0x890E CG_FRAGMENT_SHADER_EXT 0x890F Additions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation) Section 2.15.1 Creating and Using a Vertex Shader In order to create a vertex shader, use CreateShaderObjectARB with a of VERTEX_SHADER_ARB or CG_VERTEX_SHADER_EXT. The source code for the vertex shader can be specified in one call using the ShaderSourceARB command. A vertex shader is compiled by issuing CompileShaderARB and attached to a program object by calling AttachObjectARB. When LinkProgramARB is issued, all of the attached shader objects of type VERTEX_SHADER_ARB or CG_VERTEX_SHADER_ARB are linked together to create an executable program that can be used to process vertex values and their associated data. However, all the attached fragment shaders must either all be of type VERTEX_SHADER_ARB or all be of type CG_VERTEX_SHADER_EXT; otherwise, a INVALID_OPERATION error is generated. This executable program will become part of current state and used to process subsequent vertex data when UseProgramObjectARB is called. CreateShaderObjectARB will set the object specific parameter OBJECT_SUBTYPE_ARB to VERTEX_SHADER_ARB or CG_VERTEX_SHADER_ARB based on the shaderType parameter. Additions to Chapter 3 of the OpenGL 1.5 Specification (Rasterization) Section 3.11.1 Creating and Using a Fragment Shader In order to create a fragment shader, call CreateShaderObjectARB with a of FRAGMENT_SHADER_ARB or CG_FRAGMENT_SHADER_EXT. The source code for the fragment shader can be specified using the ShaderSourceARB command. A fragment shader created with the FRAGMENT_SHADER_ARB shader type is parsed and compiled assuming the source code is OpenGL Shading Language (GLSL) source text. A fragment shader created with the CG_FRAGMENT_PROGRAM shader type is parsed and compiled assuming the source code is Cg source text. A fragment shader is compiled by calling CompileShaderARB and attached to a program object by calling AttachObjectARB. When LinkProgramARB is issued, all of the attached shader objects of type FRAGMENT_SHADER_ARB or CG_FRAGMENT_SHADER_EXT are linked together to create an executable program that can be used to process fragments that arise from rasterizing points, line segments, polygons, pixel rectangles or bitmpas. However, all the attached fragment shaders must either all be of type FRAGMENT_SHADER_ARB or all be of type CG_FRAGMENT_SHADER_EXT; otherwise, a INVALID_OPERATION error is generated. This executable program will become part of current state when UseProgramObjectARB is issued. CreateShaderObjectARB will set the object specific parameter OBJECT_SUBTYPE_ARB to FRAGMENT_SHADER_ARB or CG_FRAGMENT_SHADER_EXT based on the shaderType parameter. Additions to Chapter 6 of the OpenGL 1.4 Specification (State and State Requests) Modify Section 6.1.2, Data Conversions (p. 205) If is OBJECT_SUBTYPE_ARB, GetObjectParameter{if}vARB returns VERTEX_SHADER_ARB or CG_VERTEX_SHADER_EXT if references a vertex shader object. If is OBJECT_SUBTYPE_ARB, GetObjectParameter{if}vARB returns FRAGMENT_SHADER_ARB or CG_FRAGMENT_SHADER_EXT if references a fragment shader object, depending on the shader type specified when the shader object was created. If is not of type SHADER_OBJECT_ARB, the error INVALID_OPERATION is generated. New State Initial Get Value Type Get Command Value Description Sec. Attribute --------- ---- ----------------------- --------------- ------------------ ------ --------- OBJECT_SUBTYPE_ARB Z4 GetObjectParameterivARB create value Sub type of object 3.11.1 - Revision History None