1.4.0: Cg program too complex for driver

Hi all,

I’m running a program with a few shaders, which work fine, but the weird thing is, when I add a camera for water reflections and a water shader, I get these errors:

:gobj(error): Cg program too complex for driver:/home/pro-rsoft/docs/Programmeren/Programs/heartseed/trunk/main/src/cg/lighting.sha
:gobj(error): Cg program too complex for driver:/home/pro-rsoft/docs/Programmeren/Programs/heartseed/trunk/main/src/cg/terrain.sha

And now my terrain shader and dynamic lighting doesnt work anymore :frowning:.
This is very odd, since it has worked in Panda3D version 1.3.2 without any problems.

Any ideas?

So maybe you want to rename the topic and add a 1.4.0-problem-ish content to it? :slight_smile:

Sorry, can’t help you in detail, but with that being added, folks dealing with the Panda3D development might look into it earlier. :wink:

Regards, Bigfoot29

same thing here…

Could you go ahead and send me a copy of the “.sha” files?

BTW, there are a couple possible explanations:

  1. We switched from Cg 1.4 to Cg 1.5. Maybe there’s a bug in 1.5?

  2. The way it chooses Cg profiles is now slightly different. Maybe there’s a bug in that code, and it’s choosing the wrong profile?

  3. The code to compile shaders has been rearranged. Maybe I introduced a bug in that?

Also, do this:

  1. Enable debugging by putting this in your config.prc:

notify-level-glgsg debug

  1. Search the output to find out which Cg profile it is using.

it’s enn0x’s nature shaders :
discourse.panda3d.org/viewtopic.php?t=2385

:display:gsg:glgsg(debug): GL_VENDOR = NVIDIA Corporation
:display:gsg:glgsg(debug): GL_RENDERER = GeForce FX 5200/AGP/SSE2
:display:gsg:glgsg(debug): GL_VERSION = 2.0.3
Cg vertex profile = vp30 id = 6148
Cg pixel profile = fp30 id = 6149
shader model = 3
:display:gsg:glgsg(debug): loading uncompressed texture clouds
:display:gsg:glgsg(debug): loading uncompressed texture waterBuffer
:display:gsg:glgsg(debug): loading uncompressed texture water
:display:gsg:glgsg(debug): loading uncompressed texture watermap
:gobj(error): Cg program too complex for driver:/i/PROGRAMMING/Panda3D/- Panda3D
forum/- new/Demo-Nature/terrainClipped.sha
:display:gsg:glgsg(debug): loading uncompressed texture dirt
:display:gsg:glgsg(debug): loading uncompressed texture fungus
:display:gsg:glgsg(debug): loading uncompressed texture grass
:gobj(error): Cg program too complex for driver:/i/PROGRAMMING/Panda3D/- Panda3D
forum/- new/Demo-Nature/grass.sha
:display:gsg:glgsg(debug): loading uncompressed texture grassPack
:gobj(error): Cg program too complex for driver:/i/PROGRAMMING/Panda3D/- Panda3D
forum/- new/Demo-Nature/terrainNormal.sha

ynjh_jo and I use the same card, but I have some newer drivers I think.

Here is my output:

:display:gsg:glgsg(debug): GL_VENDOR = NVIDIA Corporation
:display:gsg:glgsg(debug): GL_RENDERER = GeForce FX 5200/AGP/SSE/3DNOW!
:display:gsg:glgsg(debug): GL_VERSION = 2.1.0 NVIDIA 97.46
:display:gsg:glgsg(debug): GL_VERSION = 2.1.0 NVIDIA 97.46, decoded to 2.1.0
:display:gsg:glgsg(debug): GLX_VENDOR (client) = NVIDIA Corporation
:display:gsg:glgsg(debug): GLX_VERSION (client) = 1.4
:display:gsg:glgsg(debug): GLX_VENDOR (server) = NVIDIA Corporation
:display:gsg:glgsg(debug): GLX_VERSION (server) = 1.4
:display:gsg:glgsg(debug): GLX_VERSION = 1.3
:display:gsg:glgsg(debug): GL Extensions:
:display:gsg:glgsg(debug): GLX_ARB_get_proc_address
:display:gsg:glgsg(debug): GLX_ARB_multisample
:display:gsg:glgsg(debug): GLX_EXT_texture_from_pixmap
:display:gsg:glgsg(debug): GLX_EXT_visual_info
:display:gsg:glgsg(debug): GLX_EXT_visual_rating
:display:gsg:glgsg(debug): GLX_NV_float_buffer
:display:gsg:glgsg(debug): GLX_SGIX_fbconfig
:display:gsg:glgsg(debug): GLX_SGIX_pbuffer
:display:gsg:glgsg(debug): GLX_SGI_swap_control
:display:gsg:glgsg(debug): GLX_SGI_video_sync
:display:gsg:glgsg(debug): GL_ARB_depth_texture
:display:gsg:glgsg(debug): GL_ARB_fragment_program
:display:gsg:glgsg(debug): GL_ARB_fragment_program_shadow
:display:gsg:glgsg(debug): GL_ARB_fragment_shader
:display:gsg:glgsg(debug): GL_ARB_half_float_pixel
:display:gsg:glgsg(debug): GL_ARB_imaging
:display:gsg:glgsg(debug): GL_ARB_multisample
:display:gsg:glgsg(debug): GL_ARB_multitexture
:display:gsg:glgsg(debug): GL_ARB_occlusion_query
:display:gsg:glgsg(debug): GL_ARB_pixel_buffer_object
:display:gsg:glgsg(debug): GL_ARB_point_parameters
:display:gsg:glgsg(debug): GL_ARB_point_sprite
:display:gsg:glgsg(debug): GL_ARB_shader_objects
:display:gsg:glgsg(debug): GL_ARB_shading_language_100
:display:gsg:glgsg(debug): GL_ARB_shadow
:display:gsg:glgsg(debug): GL_ARB_texture_border_clamp
:display:gsg:glgsg(debug): GL_ARB_texture_compression
:display:gsg:glgsg(debug): GL_ARB_texture_cube_map
:display:gsg:glgsg(debug): GL_ARB_texture_env_add
:display:gsg:glgsg(debug): GL_ARB_texture_env_combine
:display:gsg:glgsg(debug): GL_ARB_texture_env_dot3
:display:gsg:glgsg(debug): GL_ARB_texture_mirrored_repeat
:display:gsg:glgsg(debug): GL_ARB_texture_rectangle
:display:gsg:glgsg(debug): GL_ARB_transpose_matrix
:display:gsg:glgsg(debug): GL_ARB_vertex_buffer_object
:display:gsg:glgsg(debug): GL_ARB_vertex_program
:display:gsg:glgsg(debug): GL_ARB_vertex_shader
:display:gsg:glgsg(debug): GL_ARB_window_pos
:display:gsg:glgsg(debug): GL_EXT_Cg_shader
:display:gsg:glgsg(debug): GL_EXT_abgr
:display:gsg:glgsg(debug): GL_EXT_bgra
:display:gsg:glgsg(debug): GL_EXT_blend_color
:display:gsg:glgsg(debug): GL_EXT_blend_func_separate
:display:gsg:glgsg(debug): GL_EXT_blend_minmax
:display:gsg:glgsg(debug): GL_EXT_blend_subtract
:display:gsg:glgsg(debug): GL_EXT_compiled_vertex_array
:display:gsg:glgsg(debug): GL_EXT_draw_range_elements
:display:gsg:glgsg(debug): GL_EXT_fog_coord
:display:gsg:glgsg(debug): GL_EXT_framebuffer_blit
:display:gsg:glgsg(debug): GL_EXT_framebuffer_multisample
:display:gsg:glgsg(debug): GL_EXT_framebuffer_object
:display:gsg:glgsg(debug): GL_EXT_gpu_program_parameters
:display:gsg:glgsg(debug): GL_EXT_multi_draw_arrays
:display:gsg:glgsg(debug): GL_EXT_packed_depth_stencil
:display:gsg:glgsg(debug): GL_EXT_packed_pixels
:display:gsg:glgsg(debug): GL_EXT_paletted_texture
:display:gsg:glgsg(debug): GL_EXT_pixel_buffer_object
:display:gsg:glgsg(debug): GL_EXT_point_parameters
:display:gsg:glgsg(debug): GL_EXT_rescale_normal
:display:gsg:glgsg(debug): GL_EXT_secondary_color
:display:gsg:glgsg(debug): GL_EXT_separate_specular_color
:display:gsg:glgsg(debug): GL_EXT_shadow_funcs
:display:gsg:glgsg(debug): GL_EXT_shared_texture_palette
:display:gsg:glgsg(debug): GL_EXT_stencil_two_side
:display:gsg:glgsg(debug): GL_EXT_stencil_wrap
:display:gsg:glgsg(debug): GL_EXT_texture3D
:display:gsg:glgsg(debug): GL_EXT_texture_compression_s3tc
:display:gsg:glgsg(debug): GL_EXT_texture_cube_map
:display:gsg:glgsg(debug): GL_EXT_texture_edge_clamp
:display:gsg:glgsg(debug): GL_EXT_texture_env_add
:display:gsg:glgsg(debug): GL_EXT_texture_env_combine
:display:gsg:glgsg(debug): GL_EXT_texture_env_dot3
:display:gsg:glgsg(debug): GL_EXT_texture_filter_anisotropic
:display:gsg:glgsg(debug): GL_EXT_texture_lod
:display:gsg:glgsg(debug): GL_EXT_texture_lod_bias
:display:gsg:glgsg(debug): GL_EXT_texture_object
:display:gsg:glgsg(debug): GL_EXT_texture_sRGB
:display:gsg:glgsg(debug): GL_EXT_timer_query
:display:gsg:glgsg(debug): GL_EXT_vertex_array
:display:gsg:glgsg(debug): GL_IBM_rasterpos_clip
:display:gsg:glgsg(debug): GL_IBM_texture_mirrored_repeat
:display:gsg:glgsg(debug): GL_KTX_buffer_region
:display:gsg:glgsg(debug): GL_NV_blend_square
:display:gsg:glgsg(debug): GL_NV_copy_depth_to_color
:display:gsg:glgsg(debug): GL_NV_depth_clamp
:display:gsg:glgsg(debug): GL_NV_fence
:display:gsg:glgsg(debug): GL_NV_float_buffer
:display:gsg:glgsg(debug): GL_NV_fog_distance
:display:gsg:glgsg(debug): GL_NV_fragment_program
:display:gsg:glgsg(debug): GL_NV_fragment_program_option
:display:gsg:glgsg(debug): GL_NV_framebuffer_multisample_coverage
:display:gsg:glgsg(debug): GL_NV_half_float
:display:gsg:glgsg(debug): GL_NV_light_max_exponent
:display:gsg:glgsg(debug): GL_NV_multisample_filter_hint
:display:gsg:glgsg(debug): GL_NV_occlusion_query
:display:gsg:glgsg(debug): GL_NV_packed_depth_stencil
:display:gsg:glgsg(debug): GL_NV_pixel_data_range
:display:gsg:glgsg(debug): GL_NV_point_sprite
:display:gsg:glgsg(debug): GL_NV_primitive_restart
:display:gsg:glgsg(debug): GL_NV_register_combiners
:display:gsg:glgsg(debug): GL_NV_register_combiners2
:display:gsg:glgsg(debug): GL_NV_texgen_reflection
:display:gsg:glgsg(debug): GL_NV_texture_compression_vtc
:display:gsg:glgsg(debug): GL_NV_texture_env_combine4
:display:gsg:glgsg(debug): GL_NV_texture_expand_normal
:display:gsg:glgsg(debug): GL_NV_texture_rectangle
:display:gsg:glgsg(debug): GL_NV_texture_shader
:display:gsg:glgsg(debug): GL_NV_texture_shader2
:display:gsg:glgsg(debug): GL_NV_texture_shader3
:display:gsg:glgsg(debug): GL_NV_vertex_array_range
:display:gsg:glgsg(debug): GL_NV_vertex_array_range2
:display:gsg:glgsg(debug): GL_NV_vertex_program
:display:gsg:glgsg(debug): GL_NV_vertex_program1_1
:display:gsg:glgsg(debug): GL_NV_vertex_program2
:display:gsg:glgsg(debug): GL_NV_vertex_program2_option
:display:gsg:glgsg(debug): GL_S3_s3tc
:display:gsg:glgsg(debug): GL_SGIS_generate_mipmap
:display:gsg:glgsg(debug): GL_SGIS_texture_lod
:display:gsg:glgsg(debug): GL_SGIX_depth_texture
:display:gsg:glgsg(debug): GL_SGIX_shadow
:display:gsg:glgsg(debug): GL_SUN_slice_accum
:display:gsg:glgsg(debug): HAS EXT GLX_ARB_get_proc_address 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_point_sprite 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_vertex_blend 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_matrix_palette 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_depth_texture 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_packed_depth_stencil 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_cube_map 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_bgra 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_rescale_normal 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_multisample 1
:display:gsg:glgsg(debug): HAS EXT GL_SGIS_generate_mipmap 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_non_power_of_two 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_depth_texture 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_shadow 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_fragment_program_shadow 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_env_combine 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_env_crossbar 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_env_dot3 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_framebuffer_object 1
:display:gsg:glgsg(debug): Occlusion query counter provides 32 bits.
:display:gsg:glgsg(debug): HAS EXT GL_SGIS_texture_edge_clamp 0
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_border_clamp 1
:display:gsg:glgsg(debug): HAS EXT GL_ARB_texture_mirrored_repeat 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_texture_mirror_clamp 0
:display:gsg:glgsg(debug): max texture dimension = 4096, max 3d texture = 512, max cube map = 4096
:display:gsg:glgsg(debug): max_elements_vertices = 4096, max_elements_indices = 4096
:display:gsg:glgsg(debug): vertex buffer objects are supported.
:display:gsg:glgsg(debug): Supported compressed texture formats:
  GL_COMPRESSED_RGB_S3TC_DXT1_EXT
  GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
  GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
:display:gsg:glgsg(debug): HAS EXT GL_EXT_stencil_wrap 1
:display:gsg:glgsg(debug): HAS EXT GL_EXT_stencil_two_side 1
:display:gsg:glgsg(debug): max lights = 8
:display:gsg:glgsg(debug): max clip planes = 6
:display:gsg:glgsg(debug): max texture stages = 4
:display:gsg:glgsg(debug): 
Cg vertex profile = vp30  id = 6148
Cg pixel profile = fp30  id = 6149
shader model = 3
:display:gsg:glgsg(debug): HAS EXT GLX_SGI_swap_control 1
:display:gsg:glgsg(debug): loading uncompressed texture Nimbus Sans L Regular Condensed_0
:display:gsg:glgsg(debug): loading uncompressed texture heartseed
:display:gsg:glgsg(debug): loading uncompressed texture heartseed_glow
:display:gsg:glgsg(debug): loading uncompressed texture alpha_scale_map
:pgraph(warning): Using deprecated ClipPlaneAttrib interface.
:08-02-2007 08:07:38 TaskManager(warning): task ivalLoop ran for 13.87 seconds
:display:gsg:glgsg(debug): loading uncompressed texture sky1
:display:gsg:glgsg(debug): loading uncompressed texture sky5
:display:gsg:glgsg(debug): loading uncompressed texture sky0
:display:gsg:glgsg(debug): loading uncompressed texture sky4
:display:gsg:glgsg(debug): loading uncompressed texture sky3
:display:gsg:glgsg(debug): loading uncompressed texture sky2
:display:gsg:glgsg(debug): loading uncompressed texture waterBuffer
:display:gsg:glgsg(debug): loading uncompressed texture ralph
:display:gsg:glgsg(debug): loading uncompressed texture 
:display:gsg:glgsg(debug): loading uncompressed texture Nimbus Sans L Regular Condensed_0
:display:gsg:glgsg(debug): loading uncompressed texture heartseed-A00_c0
:display:gsg:glgsg(debug): loading uncompressed texture greenT
:display:gsg:glgsg(debug): loading uncompressed texture minimap
:display:gsg:glgsg(debug): loading uncompressed texture Nimbus Sans L Regular Condensed_0
:gobj(error): Cg program too complex for driver:/home/pro-rsoft/docs/Programmeren/Programs/heartseed/trunk/main/src/cg/terrain.sha
:display:gsg:glgsg(debug): loading uncompressed texture testIsland_d0
:display:gsg:glgsg(debug): loading uncompressed texture dBnMCOB
:display:gsg:glgsg(debug): loading uncompressed texture testIsland_c0
:display:gsg:glgsg(debug): loading uncompressed texture Nimbus Sans L Regular Condensed_0

I discovered that it doesn’t throw the error when I switch the water shader off.
But the weird thing, If the water shader is swtiched on, it works, but the rest of the shaders don’t work, but if i switch it off, everything works except the waters shader.

That’s very weird. How big is the program that produces this bug? Or more to the point - do you think it might be realistic for me to try to reproduce this in my office? I can certainly get my hands on an FX5200. But can I use your code? Is it realistic for me to try?

Well, I could give you access to the SVN trunk of our project, but I don’t think that will be very useful to you…

Instead, you can try out the Nature Demo, which gives the same result for both ynjh_jo and me:
discourse.panda3d.org/viewtopic.php?t=2385

That sounds perfect. I just downloaded the nature demo. Later this afternoon, I’ll see if I can go borrow an FX5200.

Update: I just got the demo running successfully on my Radeon. Next step: try it with FX5200.

No, wait! On the radeon, it says: “terrainNormal.sha” - Cg program too complex for driver! So it looks like I don’t even have to swap video cards to test this. Boy, that’s a relief. I hate swapping video cards.

OK, I’ve narrowed it down. The Cg library contains a function “cgGetError”. If you do something that triggers an error, then the next time you call cgGetError, it will return an error code.

Apparently, somewhere in the code, I’m doing something that’s triggering an error, and not ever calling cgGetError. Then, later on when compiling a shader, it notices the error code — which has nothing to do with the shader, it’s left over from earlier. But the error code confuses the system into thinking that the shader is broken.

Now all I need to do is find the actual source of the error.

Since the code checks cgGetError() after compiling the shader and relies on this to detect whether the shader is valid, perhaps you should also call cgGetError() before compiling the shader, just to ensure there isn’t an error code left over from something else.

David

I’ll do that. But I also want to find out what’s actually generating an error.

OK, I found the real bug. It’s a nasty one.

Apparently, I added Cg shader support at about the same time as David added VBO support. Unfortunately, Cg and VBOs don’t mix very well. The Cg function cgGLSetParameterPointer doesn’t accept a VBO-offset instead of a pointer. I don’t know how we’ve gotten away with this for so long. Actually, the fact that we have gotten away with it for so long suggests to me that in fact, cgGLSetParameterPointer actually does accept a VBO-offset, it just complains when doing so. So I’m going to see if there’s a clean solution.

OK, disregard that previous message. I just found the real real bug.

Apparently, the water shader contains a parameter “vtx_normal.” The shader is not using this parameter. The Cg compiler is optimizing this parameter out. The panda runtime is still trying to pass data to this parameter, but the attempt fails, because there’s no parameter to pass data into anymore. The panda runtime fails to notice that this generates an error code. This error then gets noticed later, when some other shader gets compiled.

Panda 1.4.1 will fix these bugs. For now, just remove the vtx_normal parameter from the water shader.

would there be a way to use GLSL and the HLSL as a substitute for Cg (we had many many problems with cg shaders… where most random renames and rearranging makes stuff work) ?

Yeah, I agree about Cg.

I’ve been seriously thinking about GLSL/HLSL support. Now, my general philosophy is that Panda is supposed to be API agnostic. So I’m not real keen on adding an API-specific language. However, there is a tool called HLSL2GLSL. I don’t know how good it is, but it is interesting - in theory, we could support HLSL under both APIs.

Update: it looks like the HLSL2GLSL project is not seeing much life.

great hunt !

Awesome work, Josh! :smiley:
Thanks a million times! :wink: