Browse Source

Remove NVIDIA Cg Toolkit, it is no longer needed for Cg shaders

We compile all Cg shaders through glslang's DX9 HLSL support plus a special preamble to remap some types.
rdb 5 years ago
parent
commit
06c6bbec1a
35 changed files with 51 additions and 2920 deletions
  1. 0 175
      cmake/modules/FindCg.cmake
  2. 0 1
      doc/INSTALL
  3. 1 29
      dtool/Package.cmake
  4. 0 3
      dtool/dtool_config.h.in
  5. 0 30
      dtool/src/parser-inc/Cg/cg.h
  6. 0 23
      dtool/src/parser-inc/Cg/cgGL.h
  7. 0 7
      makepanda/config.in
  8. 1 4
      makepanda/makepackage.py
  9. 27 42
      makepanda/makepanda.py
  10. 0 2
      panda/src/display/graphicsStateGuardian.h
  11. 1 1
      panda/src/display/standardMunger.cxx
  12. 1 1
      panda/src/dxgsg9/CMakeLists.txt
  13. 0 111
      panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx
  14. 0 9
      panda/src/dxgsg9/dxGraphicsStateGuardian9.h
  15. 1 1
      panda/src/glgsg/CMakeLists.txt
  16. 0 12
      panda/src/glstuff/glCgShaderContext_src.I
  17. 0 1095
      panda/src/glstuff/glCgShaderContext_src.cxx
  18. 0 111
      panda/src/glstuff/glCgShaderContext_src.h
  19. 0 65
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx
  20. 0 8
      panda/src/glstuff/glGraphicsStateGuardian_src.h
  21. 0 3
      panda/src/glstuff/glmisc_src.cxx
  22. 0 1
      panda/src/glstuff/glstuff_src.cxx
  23. 0 1
      panda/src/glstuff/glstuff_src.h
  24. 1 1
      panda/src/gobj/CMakeLists.txt
  25. 0 16
      panda/src/gobj/config_gobj.cxx
  26. 0 2
      panda/src/gobj/config_gobj.h
  27. 0 26
      panda/src/gobj/shader.I
  28. 14 863
      panda/src/gobj/shader.cxx
  29. 4 68
      panda/src/gobj/shader.h
  30. 0 2
      panda/src/shaderpipeline/config_shaderpipeline.cxx
  31. 0 1
      panda/src/shaderpipeline/p3shaderpipeline_composite1.cxx
  32. 0 140
      panda/src/shaderpipeline/shaderCompilerCg.cxx
  33. 0 59
      panda/src/shaderpipeline/shaderCompilerCg.h
  34. 0 3
      panda/src/shaderpipeline/shaderModuleSpirV.h
  35. 0 4
      tests/shaderpipeline/test_shadercompilerregistry.py

+ 0 - 175
cmake/modules/FindCg.cmake

@@ -1,175 +0,0 @@
-# Filename: FindCg.cmake
-# Author: kestred (8 Dec, 2013)
-#
-# Usage:
-#   find_package(Cg [REQUIRED] [QUIET])
-#
-# Once done this will define:
-#   CG_FOUND         - system has NvidiaCg
-#   CG_INCLUDE_DIR   - the NvidiaCg include directory
-#   CG_INCLUDE_DIRS  - directories for all NvidiaCg components
-#   CG_LIBRARY_DIR   - the NvidiaCg library directory
-#   CG_LIBRARY       - the path to the library binary
-#   CG_LIBRARIES     - the paths to the Cg library and each library below.
-#
-#   CGGL_FOUND       - system has CgGL
-#   CGGL_INCLUDE_DIR - the CgGL include directory
-#   CGGL_LIBRARY_DIR - the CgGL library directory
-#   CGGL_LIBRARY     - the path to the library binary
-#
-
-
-### Define macros to find each sublibrary ###
-
-# Find Cg for OpenGL
-macro(find_cggl)
-  if(APPLE)
-    # GL support is built-in on Apple
-    set(CGGL_LIBRARY "${CG_LIBRARY}")
-    set(CGGL_LIBRARY_DIR "${CG_LIBRARY_DIR}")
-    set(CGGL_INCLUDE_DIR "${CG_INCLUDE_DIR}")
-  endif()
-
-  if(Cg_FIND_QUIETLY)
-    set(CgGL_FIND_QUIETLY TRUE)
-  endif()
-  if(NOT CGGL_LIBRARY_DIR OR NOT CGGL_INCLUDE_DIR)
-    # Find the include directory
-    find_path(CGGL_INCLUDE_DIR
-      NAMES "cgGL.h"
-      PATHS "C:/Program Files/Cg"
-            "C:/Program Files/NVIDIA Corporation/Cg/include"
-            "/usr/include"
-            "/usr/local/include"
-            "/opt/Cg"
-            "/opt/nvidia-cg-toolkit/include" # Gentoo
-      PATH_SUFFIXES "" "Cg" "cg"
-      DOC "The path to NvidiaCgGL's include directory."
-    )
-
-    # Find the library directory
-    find_library(CGGL_LIBRARY
-      NAMES "CgGL" "libCgGL"
-      PATHS "C:/Program Files/Cg"
-            "C:/Program Files/NVIDIA Corporation/Cg"
-            "/usr"
-            "/usr/lib/x86_64-linux-gnu"
-            "/usr/local"
-            "/opt/Cg"
-            "/opt/nvidia-cg-toolkit" # Gentoo
-      PATH_SUFFIXES "" "lib" "lib32" "lib64"
-      DOC "The filepath to NvidiaCgGL's libary binary."
-    )
-    get_filename_component(CGGL_LIBRARY_DIR "${CGGL_LIBRARY}" PATH)
-    set(CGGL_LIBRARY_DIR "${CGGL_LIBRARY_DIR}" CACHE PATH "The path to the CgGL library directory.") # Library path
-
-    mark_as_advanced(CGGL_INCLUDE_DIR)
-    mark_as_advanced(CGGL_LIBRARY_DIR)
-    mark_as_advanced(CGGL_LIBRARY)
-  endif()
-
-  find_package_handle_standard_args(CgGL DEFAULT_MSG CGGL_LIBRARY CGGL_INCLUDE_DIR CGGL_LIBRARY_DIR)
-
-endmacro()
-
-
-# Find Cg for Direct3D 9
-macro(find_cgd3d9)
-  if(Cg_FIND_QUIETLY)
-    set(CgD3D9_FIND_QUIETLY TRUE)
-  endif()
-  if(NOT CGD3D9_LIBRARY_DIR OR NOT CGD3D9_INCLUDE_DIR)
-    # Find the include directory
-    find_path(CGD3D9_INCLUDE_DIR
-      NAMES "cgD3D9.h"
-      PATHS "C:/Program Files/Cg"
-            "C:/Program Files/NVIDIA Corporation/Cg/include"
-            "/usr/include"
-            "/usr/local/include"
-            "/opt/Cg"
-            "/opt/nvidia-cg-toolkit/include" # Gentoo
-      PATH_SUFFIXES "" "Cg" "cg"
-      DOC "The path to NvidiaCgD3D9's include directory."
-    )
-
-    # Find the library directory
-    find_library(CGD3D9_LIBRARY
-      NAMES "CgD3D9" "libCgD3D9"
-      PATHS "C:/Program Files/Cg"
-            "C:/Program Files/NVIDIA Corporation/Cg"
-            "/usr"
-            "/usr/lib/x86_64-linux-gnu"
-            "/usr/local"
-            "/opt/Cg"
-            "/opt/nvidia-cg-toolkit" # Gentoo
-      PATH_SUFFIXES "" "lib" "lib32" "lib64"
-      DOC "The filepath to NvidiaCgD3D9's libary binary."
-    )
-    get_filename_component(CGD3D9_LIBRARY_DIR "${CGD3D9_LIBRARY}" PATH)
-    set(CGD3D9_LIBRARY_DIR "${CGD3D9_LIBRARY_DIR}" CACHE PATH "The path to the CgD3D9 library directory.") # Library path
-
-    mark_as_advanced(CGD3D9_INCLUDE_DIR)
-    mark_as_advanced(CGD3D9_LIBRARY_DIR)
-    mark_as_advanced(CGD3D9_LIBRARY)
-  endif()
-
-  find_package_handle_standard_args(CgD3D9 DEFAULT_MSG CGD3D9_LIBRARY CGD3D9_INCLUDE_DIR CGD3D9_LIBRARY_DIR)
-
-endmacro()
-
-
-
-# Find base Nvidia Cg
-if(NOT CG_LIBRARY_DIR OR NOT CG_INCLUDE_DIRS)
-  # Find the include directory
-  find_path(CG_INCLUDE_DIR
-    NAMES "Cg/cg.h"
-    PATHS "C:/Program Files/Cg"
-          "C:/Program Files/NVIDIA Corporation/Cg/include"
-          "/usr/include"
-          "/usr/local/include"
-          "/opt/Cg"
-          "/opt/nvidia-cg-toolkit/include" # Gentoo
-    PATH_SUFFIXES "" "Cg" "cg"
-    DOC "The path to NvidiaCg's include directory."
-  )
-
-  # Find the library directory
-  find_library(CG_LIBRARY
-    NAMES "Cg" "libCg"
-    PATHS "C:/Program Files/Cg"
-          "C:/Program Files/NVIDIA Corporation/Cg"
-          "/usr"
-          "/usr/lib/x86_64-linux-gnu"
-          "/usr/local"
-          "/opt/Cg"
-          "/opt/nvidia-cg-toolkit" # Gentoo
-    PATH_SUFFIXES "" "lib" "lib32" "lib64"
-  )
-  get_filename_component(CG_LIBRARY_DIR "${CG_LIBRARY}" PATH)
-  set(CG_LIBRARY_DIR "${CG_LIBRARY_DIR}" CACHE PATH "The path to NvidiaCG's library directory.") # Library path
-
-  string(REGEX REPLACE "/Cg$" "" CG_BASE_INCLUDE_DIR "${CG_INCLUDE_DIR}")
-  set(CG_INCLUDE_DIRS ${CG_BASE_INCLUDE_DIR} ${CG_INCLUDE_DIR})
-
-  mark_as_advanced(CG_INCLUDE_DIRS)
-  mark_as_advanced(CG_INCLUDE_DIR)
-  mark_as_advanced(CG_LIBRARY_DIR)
-  mark_as_advanced(CG_LIBRARY)
-endif()
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Cg DEFAULT_MSG CG_LIBRARY CG_INCLUDE_DIRS CG_LIBRARY_DIR)
-
-if(CG_INCLUDE_DIR AND CG_LIBRARY_DIR)
-  find_cggl()
-  find_cgd3d9()
-
-  set(CG_LIBRARIES ${CG_LIBRARY})
-  if(CGGL_LIBRARY)
-    list(APPEND CG_LIBRARIES "${CGGL_LIBRARY}")
-  endif()
-  if(CGD3D9_LIBRARY)
-    list(APPEND CG_LIBRARIES "${CGD3D9_LIBRARY}")
-  endif()
-endif()

+ 0 - 1
doc/INSTALL

@@ -136,7 +136,6 @@ it will show you the available command-line options:
   --use-gles2       --no-gles2     (enable/disable use of GLES2)
   --use-dx9         --no-dx9       (enable/disable use of DX9)
   --use-tinydisplay   --no-tinydisplay (enable/disable use of TINYDISPLAY)
-  --use-nvidiacg    --no-nvidiacg  (enable/disable use of NVIDIACG)
   --use-egl         --no-egl       (enable/disable use of EGL)
   --use-eigen       --no-eigen     (enable/disable use of EIGEN)
   --use-openal      --no-openal    (enable/disable use of OPENAL)

+ 1 - 29
dtool/Package.cmake

@@ -63,7 +63,6 @@ if(THIRDPARTY_DIRECTORY)
     ARToolKit
     Assimp
     Bullet
-    Cg
     Eigen3
     FCollada
     FFMPEG
@@ -92,9 +91,7 @@ if(THIRDPARTY_DIRECTORY)
 
     # Some packages in the thirdparty dir have different subdirectory names from
     # the name of the CMake package
-    if(_package STREQUAL "cg")
-      set(_package "nvidiacg")
-    elseif(_package STREQUAL "eigen3")
+    if(_package STREQUAL "eigen3")
       set(_package "eigen")
     elseif(_package STREQUAL "ogg")
       set(_package "vorbis") # It's in the same install dir here
@@ -649,31 +646,6 @@ package_option(DX9
 
 package_status(DX9 "Direct3D 9.x")
 
-# Nvidia Cg
-find_package(Cg QUIET)
-
-package_option(CG
-  "Enable support for Nvidia Cg Shading Language"
-  LICENSE "Nvidia")
-package_option(CGGL
-  "Enable support for Nvidia Cg's OpenGL API."
-  LICENSE "Nvidia")
-package_option(CGD3D9
-  "Enable support for Nvidia Cg's Direct3D 9 API."
-  LICENSE "Nvidia")
-
-if(HAVE_CGGL AND HAVE_CGD3D9)
-  set(cg_apis "supporting OpenGL and Direct3D 9")
-elseif(HAVE_CGGL)
-  set(cg_apis "supporting OpenGL")
-elseif(HAVE_CGDX9)
-  set(cg_apis "supporting Direct3D 9")
-else()
-  set(cg_apis "WITHOUT rendering backend support")
-endif()
-package_status(CG "Nvidia Cg Shading Language" "${cg_apis}")
-
-
 #
 # ------------ Display APIs ------------
 #

+ 0 - 3
dtool/dtool_config.h.in

@@ -62,9 +62,6 @@
 #cmakedefine HAVE_BMP
 #cmakedefine HAVE_PNM
 
-/* Define if we have CG installed.  */
-#cmakedefine HAVE_CG
-
 /* Define if we have zlib installed.  */
 #cmakedefine HAVE_ZLIB
 

+ 0 - 30
dtool/src/parser-inc/Cg/cg.h

@@ -1,30 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file cg.h
- * @author drose
- * @date 2004-07-22
- */
-
-// This file, and all the other files in this directory, aren't
-// intended to be compiled--they're just parsed by CPPParser (and
-// interrogate) in lieu of the actual system headers, to generate the
-// interrogate database.
-
-#ifndef CG_H
-#define CG_H
-
-typedef struct _CGcontext *CGcontext;
-typedef struct _CGcontext *CGcontext;
-typedef struct _CGprogram *CGprogram;
-typedef struct _CGparameter *CGparameter;
-
-typedef enum {} CGprofile;
-typedef enum {} CGerror;
-
-#endif

+ 0 - 23
dtool/src/parser-inc/Cg/cgGL.h

@@ -1,23 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file cgGL.h
- * @author sshodhan
- * @date 2004-07-22
- */
-
-// This file, and all the other files in this directory, aren't
-// intended to be compiled--they're just parsed by CPPParser (and
-// interrogate) in lieu of the actual system headers, to generate the
-// interrogate database.
-
-#ifndef CGGL_H
-#define CGGL_H
-
-#endif
-

+ 0 - 7
makepanda/config.in

@@ -91,10 +91,3 @@ hardware-animated-vertices #f
 
 model-cache-dir $XDG_CACHE_HOME/panda3d
 model-cache-textures #f
-
-# This option specifies the default profiles for Cg shaders.
-# Setting it to #t makes them arbvp1 and arbfp1, since these
-# seem to be most reliable. Setting it to #f makes Panda use
-# the latest profile available.
-
-basic-shaders-only #f

+ 1 - 4
makepanda/makepackage.py

@@ -302,9 +302,6 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1,
             recommends += ", python-pmw, python3-tk (>= %s)" % (python3_ver)
             provides += ", python3-panda3d"
 
-        if not PkgSkip("NVIDIACG"):
-            depends += ", nvidia-cg-toolkit"
-
         # Write back the dependencies, and delete the dummy set-up.
         txt = txt.replace("DEPENDS", depends.strip(', '))
         txt = txt.replace("RECOMMENDS", recommends.strip(', '))
@@ -994,7 +991,7 @@ if __name__ == "__main__":
 
     # Read out whether we should set PkgSkip("PYTHON") and some others.
     # Temporary hack; needs better solution.
-    pkg_list = "PYTHON", "NVIDIACG", "FFMPEG", "OPENAL", "FMODEX", "PVIEW", "NVIDIACG", "VORBIS", "OPUS"
+    pkg_list = "PYTHON", "FFMPEG", "OPENAL", "FMODEX", "PVIEW", "VORBIS", "OPUS"
     PkgListSet(pkg_list)
     for pkg in pkg_list:
         dat_path = "dtool_have_%s.dat" % (pkg.lower())

+ 27 - 42
makepanda/makepanda.py

@@ -72,7 +72,7 @@ if "MACOSX_DEPLOYMENT_TARGET" in os.environ:
     OSXTARGET=os.environ["MACOSX_DEPLOYMENT_TARGET"]
 
 PkgListSet(["PYTHON", "DIRECT",                        # Python support
-  "GL", "GLES", "GLES2"] + DXVERSIONS + ["TINYDISPLAY", "NVIDIACG", # 3D graphics
+  "GL", "GLES", "GLES2"] + DXVERSIONS + ["TINYDISPLAY",# 3D graphics
   "EGL",                                               # OpenGL (ES) integration
   "EIGEN",                                             # Linear algebra acceleration
   "OPENAL", "FMODEX",                                  # Audio playback
@@ -168,7 +168,8 @@ def parseopts(args):
     # Options for which to display a deprecation warning.
     removedopts = [
         "use-touchinput", "no-touchinput", "no-awesomium", "no-directscripts",
-        "no-carbon", "universal", "no-physx", "no-rocket", "host"
+        "no-carbon", "universal", "no-physx", "no-rocket", "host",
+        "no-nvidiacg", "no-cggl",
         ]
 
     # All recognized options.
@@ -242,7 +243,7 @@ def parseopts(args):
             elif (option[2:] in removedopts):
                 Warn("Ignoring removed option %s" % (option))
             else:
-                for pkg in PkgListGet() + ['CGGL']:
+                for pkg in PkgListGet():
                     if option == "--use-" + pkg.lower():
                         PkgEnable(pkg)
                         break
@@ -640,9 +641,6 @@ if (COMPILER == "MSVC"):
     if (PkgSkip("ZLIB")==0):     LibName("ZLIB",     GetThirdpartyDir() + "zlib/lib/zlibstatic.lib")
     if (PkgSkip("VRPN")==0):     LibName("VRPN",     GetThirdpartyDir() + "vrpn/lib/vrpn.lib")
     if (PkgSkip("VRPN")==0):     LibName("VRPN",     GetThirdpartyDir() + "vrpn/lib/quat.lib")
-    if (PkgSkip("NVIDIACG")==0): LibName("CGGL",     GetThirdpartyDir() + "nvidiacg/lib/cgGL.lib")
-    if (PkgSkip("NVIDIACG")==0): LibName("CGDX9",    GetThirdpartyDir() + "nvidiacg/lib/cgD3D9.lib")
-    if (PkgSkip("NVIDIACG")==0): LibName("NVIDIACG", GetThirdpartyDir() + "nvidiacg/lib/cg.lib")
     if (PkgSkip("FREETYPE")==0): LibName("FREETYPE", GetThirdpartyDir() + "freetype/lib/freetype.lib")
     if (PkgSkip("HARFBUZZ")==0):
         LibName("HARFBUZZ", GetThirdpartyDir() + "harfbuzz/lib/harfbuzz.lib")
@@ -808,7 +806,6 @@ if (COMPILER=="GCC"):
     SmartPkgEnable("GLES",      "glesv1_cm", ("GLESv1_CM"), ("GLES/gl.h"), framework = "OpenGLES")
     SmartPkgEnable("GLES2",     "glesv2",    ("GLESv2"), ("GLES2/gl2.h")) #framework = "OpenGLES"?
     SmartPkgEnable("EGL",       "egl",       ("EGL"), ("EGL/egl.h"))
-    SmartPkgEnable("NVIDIACG",  "",          ("Cg"), "Cg/cg.h", framework = "Cg")
     SmartPkgEnable("ODE",       "",          ("ode"), "ode/ode.h", tool = "ode-config")
     SmartPkgEnable("OPENAL",    "openal",    ("openal"), "AL/al.h", framework = "OpenAL")
     SmartPkgEnable("SQUISH",    "",          ("squish"), "squish.h")
@@ -954,9 +951,6 @@ if (COMPILER=="GCC"):
         LibName("OPENSSL", "-Wl,--exclude-libs,libcrypto.a")
 
     if GetTarget() != 'darwin':
-        # CgGL is covered by the Cg framework, and we don't need X11 components on OSX
-        if not PkgSkip("NVIDIACG"):
-            SmartPkgEnable("CGGL", "", ("CgGL"), "Cg/cgGL.h", thirdparty_dir = "nvidiacg")
         SmartPkgEnable("X11", "x11", "X11", ("X11", "X11/Xlib.h", "X11/XKBlib.h"))
 
     if GetHost() != "darwin":
@@ -2320,9 +2314,6 @@ DTOOL_CONFIG=[
     ("HAVE_NET",                       'UNDEF',                  'UNDEF'),
     ("WANT_NATIVE_NET",                '1',                      '1'),
     ("SIMULATE_NETWORK_DELAY",         'UNDEF',                  'UNDEF'),
-    ("HAVE_CG",                        'UNDEF',                  'UNDEF'),
-    ("HAVE_CGGL",                      'UNDEF',                  'UNDEF'),
-    ("HAVE_CGDX9",                     'UNDEF',                  'UNDEF'),
     ("HAVE_ARTOOLKIT",                 'UNDEF',                  'UNDEF'),
     ("HAVE_DIRECTCAM",                 'UNDEF',                  'UNDEF'),
     ("HAVE_SQUISH",                    'UNDEF',                  'UNDEF'),
@@ -2375,11 +2366,6 @@ def WriteConfigSettings():
 
     dtool_config["HAVE_NET"] = '1'
 
-    if (PkgSkip("NVIDIACG")==0):
-        dtool_config["HAVE_CG"] = '1'
-        dtool_config["HAVE_CGGL"] = '1'
-        dtool_config["HAVE_CGDX9"] = '1'
-
     if GetTarget() not in ("linux", "android"):
         dtool_config["HAVE_PROC_SELF_EXE"] = 'UNDEF'
         dtool_config["HAVE_PROC_SELF_MAPS"] = 'UNDEF'
@@ -3661,13 +3647,12 @@ TargetAdd('libp3pstatclient.in', opts=['IMOD:panda3d.core', 'ILIB:libp3pstatclie
 # DIRECTORY: panda/src/gobj/
 #
 
-OPTS=['DIR:panda/src/gobj', 'BUILDING:PANDA',  'NVIDIACG', 'ZLIB', 'SQUISH']
+OPTS=['DIR:panda/src/gobj', 'BUILDING:PANDA',  'ZLIB', 'SQUISH']
 TargetAdd('p3gobj_composite1.obj', opts=OPTS, input='p3gobj_composite1.cxx')
 TargetAdd('p3gobj_composite2.obj', opts=OPTS+['BIGOBJ'], input='p3gobj_composite2.cxx')
 
-OPTS=['DIR:panda/src/gobj', 'NVIDIACG', 'ZLIB', 'SQUISH']
+OPTS=['DIR:panda/src/gobj', 'ZLIB', 'SQUISH']
 IGATEFILES=GetDirectoryContents('panda/src/gobj', ["*.h", "*_composite*.cxx"])
-if ("cgfx_states.h" in IGATEFILES): IGATEFILES.remove("cgfx_states.h")
 TargetAdd('libp3gobj.in', opts=OPTS, input=IGATEFILES)
 TargetAdd('libp3gobj.in', opts=['IMOD:panda3d.core', 'ILIB:libp3gobj', 'SRCDIR:panda/src/gobj'])
 PyTargetAdd('p3gobj_ext_composite.obj', opts=OPTS, input='p3gobj_ext_composite.cxx')
@@ -3955,7 +3940,7 @@ TargetAdd('libp3dxml.in', opts=['IMOD:panda3d.core', 'ILIB:libp3dxml', 'SRCDIR:p
 
 OPTS=['DIR:panda/metalibs/panda', 'BUILDING:PANDA', 'JPEG', 'PNG', 'HARFBUZZ',
     'TIFF', 'OPENEXR', 'ZLIB', 'FREETYPE', 'FFTW', 'ADVAPI', 'WINSOCK2',
-    'SQUISH', 'NVIDIACG', 'VORBIS', 'OPUS', 'WINUSER', 'WINMM', 'WINGDI', 'IPHLPAPI',
+    'SQUISH', 'VORBIS', 'OPUS', 'WINUSER', 'WINMM', 'WINGDI', 'IPHLPAPI',
     'SETUPAPI', 'IOKIT', 'GLSLANG', 'SPIRV-TOOLS']
 
 TargetAdd('panda_panda.obj', opts=OPTS, input='panda.cxx')
@@ -4219,7 +4204,7 @@ if (PkgSkip('PANDAFX')==0):
   OPTS=['DIR:panda/src/distort', 'BUILDING:PANDAFX']
   TargetAdd('p3distort_composite1.obj', opts=OPTS, input='p3distort_composite1.cxx')
 
-  OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG']
+  OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort']
   IGATEFILES=GetDirectoryContents('panda/src/distort', ["*.h", "*_composite*.cxx"])
   TargetAdd('libp3distort.in', opts=OPTS, input=IGATEFILES)
   TargetAdd('libp3distort.in', opts=['IMOD:panda3d.fx', 'ILIB:libp3distort', 'SRCDIR:panda/src/distort'])
@@ -4229,15 +4214,15 @@ if (PkgSkip('PANDAFX')==0):
 #
 
 if (PkgSkip('PANDAFX')==0):
-  OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'BUILDING:PANDAFX',  'NVIDIACG']
+  OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'BUILDING:PANDAFX']
   TargetAdd('pandafx_pandafx.obj', opts=OPTS, input='pandafx.cxx')
 
   TargetAdd('libpandafx.dll', input='pandafx_pandafx.obj')
   TargetAdd('libpandafx.dll', input='p3distort_composite1.obj')
   TargetAdd('libpandafx.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandafx.dll', opts=['ADVAPI',  'NVIDIACG'])
+  TargetAdd('libpandafx.dll', opts=['ADVAPI'])
 
-  OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort', 'NVIDIACG']
+  OPTS=['DIR:panda/metalibs/pandafx', 'DIR:panda/src/distort']
   PyTargetAdd('fx_module.obj', input='libp3distort.in')
   PyTargetAdd('fx_module.obj', opts=OPTS)
   PyTargetAdd('fx_module.obj', opts=['IMOD:panda3d.fx', 'ILIB:fx', 'IMPORT:panda3d.core'])
@@ -4367,17 +4352,17 @@ if (GetTarget() == 'windows'):
 #
 
 if GetTarget() == 'windows' and PkgSkip("DX9")==0:
-  OPTS=['DIR:panda/src/dxgsg9', 'BUILDING:PANDADX', 'DX9',  'NVIDIACG', 'CGDX9', 'SPIRV-CROSS-HLSL']
+  OPTS=['DIR:panda/src/dxgsg9', 'BUILDING:PANDADX', 'DX9', 'SPIRV-CROSS-HLSL']
   TargetAdd('p3dxgsg9_dxGraphicsStateGuardian9.obj', opts=OPTS, input='dxGraphicsStateGuardian9.cxx')
   TargetAdd('p3dxgsg9_composite1.obj', opts=OPTS, input='p3dxgsg9_composite1.cxx')
-  OPTS=['DIR:panda/metalibs/pandadx9', 'BUILDING:PANDADX', 'DX9',  'NVIDIACG', 'CGDX9']
+  OPTS=['DIR:panda/metalibs/pandadx9', 'BUILDING:PANDADX', 'DX9']
   TargetAdd('pandadx9_pandadx9.obj', opts=OPTS, input='pandadx9.cxx')
   TargetAdd('libpandadx9.dll', input='pandadx9_pandadx9.obj')
   TargetAdd('libpandadx9.dll', input='p3dxgsg9_dxGraphicsStateGuardian9.obj')
   TargetAdd('libpandadx9.dll', input='p3dxgsg9_composite1.obj')
   TargetAdd('libpandadx9.dll', input='libp3windisplay.dll')
   TargetAdd('libpandadx9.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandadx9.dll', opts=['MODULE', 'ADVAPI', 'WINGDI', 'WINKERNEL', 'WINUSER', 'WINMM', 'DX9',  'NVIDIACG', 'CGDX9', 'SPIRV-CROSS-HLSL'])
+  TargetAdd('libpandadx9.dll', opts=['MODULE', 'ADVAPI', 'WINGDI', 'WINKERNEL', 'WINUSER', 'WINMM', 'DX9', 'SPIRV-CROSS-HLSL'])
 
 #
 # DIRECTORY: panda/src/egg/
@@ -4439,7 +4424,7 @@ TargetAdd('libp3framework.dll', opts=['ADVAPI'])
 #
 
 if (PkgSkip("GL")==0):
-  OPTS=['DIR:panda/src/glgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'GL', 'NVIDIACG', 'SPIRV-CROSS-GLSL', 'GLSLANG']
+  OPTS=['DIR:panda/src/glgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'GL', 'SPIRV-CROSS-GLSL', 'GLSLANG']
   TargetAdd('p3glgsg_config_glgsg.obj', opts=OPTS, input='config_glgsg.cxx')
   TargetAdd('p3glgsg_glgsg.obj', opts=OPTS, input='glgsg.cxx')
 
@@ -4506,10 +4491,10 @@ if (GetTarget() not in ['windows', 'darwin'] and PkgSkip("X11")==0):
 #
 
 if (GetTarget() not in ['windows', 'darwin'] and PkgSkip("GL")==0 and PkgSkip("X11")==0):
-  OPTS=['DIR:panda/src/glxdisplay', 'BUILDING:PANDAGL',  'GL', 'NVIDIACG', 'CGGL']
+  OPTS=['DIR:panda/src/glxdisplay', 'BUILDING:PANDAGL', 'GL']
   TargetAdd('p3glxdisplay_composite1.obj', opts=OPTS, input='p3glxdisplay_composite1.cxx')
 
-  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL',  'GL', 'NVIDIACG', 'CGGL', 'SPIRV-CROSS-GLSL']
+  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL', 'GL', 'SPIRV-CROSS-GLSL']
   TargetAdd('pandagl_pandagl.obj', opts=OPTS, input='pandagl.cxx')
   TargetAdd('libpandagl.dll', input='p3x11display_composite1.obj')
   TargetAdd('libpandagl.dll', input='pandagl_pandagl.obj')
@@ -4517,16 +4502,16 @@ if (GetTarget() not in ['windows', 'darwin'] and PkgSkip("GL")==0 and PkgSkip("X
   TargetAdd('libpandagl.dll', input='p3glgsg_glgsg.obj')
   TargetAdd('libpandagl.dll', input='p3glxdisplay_composite1.obj')
   TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'NVIDIACG', 'CGGL', 'X11', 'SPIRV-CROSS-GLSL'])
+  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'X11', 'SPIRV-CROSS-GLSL'])
 
 #
 # DIRECTORY: panda/src/cocoadisplay/
 #
 
 if (GetTarget() == 'darwin' and PkgSkip("COCOA")==0 and PkgSkip("GL")==0):
-  OPTS=['DIR:panda/src/cocoadisplay', 'BUILDING:PANDAGL', 'GL', 'NVIDIACG', 'CGGL']
+  OPTS=['DIR:panda/src/cocoadisplay', 'BUILDING:PANDAGL', 'GL']
   TargetAdd('p3cocoadisplay_composite1.obj', opts=OPTS, input='p3cocoadisplay_composite1.mm')
-  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL', 'GL', 'NVIDIACG', 'CGGL']
+  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL', 'GL']
   TargetAdd('pandagl_pandagl.obj', opts=OPTS, input='pandagl.cxx')
   TargetAdd('libpandagl.dll', input='pandagl_pandagl.obj')
   TargetAdd('libpandagl.dll', input='p3glgsg_config_glgsg.obj')
@@ -4535,16 +4520,16 @@ if (GetTarget() == 'darwin' and PkgSkip("COCOA")==0 and PkgSkip("GL")==0):
   if (PkgSkip('PANDAFX')==0):
     TargetAdd('libpandagl.dll', input='libpandafx.dll')
   TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'NVIDIACG', 'CGGL', 'COCOA', 'CARBON', 'QUARTZ'])
+  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'COCOA', 'CARBON', 'QUARTZ'])
 
 #
 # DIRECTORY: panda/src/wgldisplay/
 #
 
 if (GetTarget() == 'windows' and PkgSkip("GL")==0):
-  OPTS=['DIR:panda/src/wgldisplay', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL',  'NVIDIACG', 'CGGL', 'GLSLANG']
+  OPTS=['DIR:panda/src/wgldisplay', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'GLSLANG']
   TargetAdd('p3wgldisplay_composite1.obj', opts=OPTS, input='p3wgldisplay_composite1.cxx')
-  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL',  'NVIDIACG', 'CGGL']
+  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL']
   TargetAdd('pandagl_pandagl.obj', opts=OPTS, input='pandagl.cxx')
   TargetAdd('libpandagl.dll', input='pandagl_pandagl.obj')
   TargetAdd('libpandagl.dll', input='p3glgsg_config_glgsg.obj')
@@ -4554,7 +4539,7 @@ if (GetTarget() == 'windows' and PkgSkip("GL")==0):
   if (PkgSkip('PANDAFX')==0):
     TargetAdd('libpandagl.dll', input='libpandafx.dll')
   TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandagl.dll', opts=['MODULE', 'WINGDI', 'GL', 'WINKERNEL', 'WINOLDNAMES', 'WINUSER', 'WINMM',  'NVIDIACG', 'CGGL', 'SPIRV-CROSS-GLSL', 'GLSLANG'])
+  TargetAdd('libpandagl.dll', opts=['MODULE', 'WINGDI', 'GL', 'WINKERNEL', 'WINOLDNAMES', 'WINUSER', 'WINMM', 'SPIRV-CROSS-GLSL', 'GLSLANG'])
 
 #
 # DIRECTORY: panda/src/egldisplay/
@@ -4573,7 +4558,7 @@ if not PkgSkip("EGL") and not PkgSkip("GL") and PkgSkip("X11") and GetTarget() n
   TargetAdd('libpandagl.dll', input='p3glgsg_glgsg.obj')
   TargetAdd('libpandagl.dll', input='pandagl_egldisplay_composite1.obj')
   TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'EGL', 'CGGL'])
+  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'EGL'])
 
 #
 # DIRECTORY: panda/src/egldisplay/
@@ -4778,9 +4763,9 @@ if (PkgSkip("SPEEDTREE")==0):
   TargetAdd('libpandaspeedtree.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libpandaspeedtree.dll', opts=['SPEEDTREE'])
   if SDK["SPEEDTREEAPI"] == 'OpenGL':
-      TargetAdd('libpandaspeedtree.dll', opts=['GL', 'NVIDIACG', 'CGGL'])
+      TargetAdd('libpandaspeedtree.dll', opts=['GL'])
   elif SDK["SPEEDTREEAPI"] == 'DirectX9':
-      TargetAdd('libpandaspeedtree.dll', opts=['DX9',  'NVIDIACG', 'CGDX9'])
+      TargetAdd('libpandaspeedtree.dll', opts=['DX9'])
 
 #
 # DIRECTORY: panda/src/testbed/

+ 0 - 2
panda/src/display/graphicsStateGuardian.h

@@ -648,8 +648,6 @@ protected:
 
   static PT(TextureStage) _alpha_scale_texture_stage;
 
-  Shader::ShaderCaps _shader_caps;
-
   PN_stdfloat _gamma;
   Texture::QualityLevel _texture_quality_override;
 

+ 1 - 1
panda/src/display/standardMunger.cxx

@@ -122,7 +122,7 @@ munge_data_impl(const GeomVertexData *data) {
 
   GeomVertexAnimationSpec animation = new_data->get_format()->get_animation();
   if (_shader_skinning || (_auto_shader && hardware_animated_vertices &&
-      !basic_shaders_only && animation.get_animation_type() == AT_panda)) {
+      animation.get_animation_type() == AT_panda)) {
     animation.set_hardware(4, true);
 
   } else if (hardware_animated_vertices &&

+ 1 - 1
panda/src/dxgsg9/CMakeLists.txt

@@ -42,7 +42,7 @@ composite_sources(p3dxgsg9 P3DXGSG9_SOURCES)
 add_component_library(p3dxgsg9 SYMBOL BUILDING_PANDADX
   ${P3DXGSG9_HEADERS} ${P3DXGSG9_SOURCES})
 target_link_libraries(p3dxgsg9 p3windisplay panda
-  PKG::CG PKG::DX9)
+  PKG::DX9)
 target_compile_definitions(p3dxgsg9 PUBLIC USE_GENERIC_DXERR_LIBRARY) # FIXME
 
 if(NOT BUILD_METALIBS)

+ 0 - 111
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -65,9 +65,6 @@
 #include "wdxGraphicsBuffer9.h"
 #include "config_pgraph.h"
 #include "shaderGenerator.h"
-#ifdef HAVE_CG
-#include <Cg/cgD3D9.h>
-#endif
 
 #include <mmsystem.h>
 
@@ -88,10 +85,6 @@ D3DMATRIX DXGraphicsStateGuardian9::_d3d_ident_mat;
 unsigned char *DXGraphicsStateGuardian9::_temp_buffer = nullptr;
 unsigned char *DXGraphicsStateGuardian9::_safe_buffer_start = nullptr;
 
-#ifdef HAVE_CG
-LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = nullptr;
-#endif
-
 #define __D3DLIGHT_RANGE_MAX ((PN_stdfloat)sqrt(FLT_MAX))  //for some reason this is missing in dx9 hdrs
 
 #define MY_D3DRGBA(r, g, b, a) ((D3DCOLOR) D3DCOLOR_COLORVALUE(r, g, b, a))
@@ -154,10 +147,6 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) :
 
   _supports_stream_offset = false;
 
-#ifdef HAVE_CG
-  _cg_context = 0;
-#endif
-
   get_gamma_table();
   atexit (atexit_function);
 }
@@ -175,8 +164,6 @@ DXGraphicsStateGuardian9::
   if (IS_VALID_PTR(_d3d_device)) {
     _d3d_device->SetTexture(0, nullptr);  // this frees reference to the old texture
   }
-
-  free_nondx_resources();
 }
 
 /**
@@ -2331,53 +2318,6 @@ reset() {
 
   _auto_detect_shader_model = _shader_model;
 
-#ifdef HAVE_CG
-  set_cg_device(_d3d_device);
-
-  _cg_context = cgCreateContext();
-
-  if (cgD3D9IsProfileSupported(CG_PROFILE_PS_2_0) &&
-      cgD3D9IsProfileSupported(CG_PROFILE_VS_2_0)) {
-    _supports_basic_shaders = true;
-    _shader_caps._active_vprofile = (int)cgD3D9GetLatestVertexProfile();
-    _shader_caps._active_fprofile = (int)cgD3D9GetLatestPixelProfile();
-    _shader_caps._ultimate_vprofile = (int)CG_PROFILE_VS_3_0;
-    _shader_caps._ultimate_fprofile = (int)CG_PROFILE_PS_3_0;
-/*
-    _shader_caps._active_vprofile = (int)CG_PROFILE_VS_2_0;
-    _shader_caps._active_fprofile = (int)CG_PROFILE_PS_2_0;
-    _shader_caps._ultimate_vprofile = (int)CG_PROFILE_VS_2_0;
-    _shader_caps._ultimate_fprofile = (int)CG_PROFILE_PS_2_0;
-*/
-  }
-
-  if (dxgsg9_cat.is_debug()) {
-    CGprofile vertex_profile;
-    CGprofile pixel_profile;
-
-    vertex_profile = cgD3D9GetLatestVertexProfile();
-    pixel_profile = cgD3D9GetLatestPixelProfile();
-
-    const char *vertex_profile_str =
-      cgGetProfileString(vertex_profile);
-    const char *pixel_profile_str =
-      cgGetProfileString(pixel_profile);
-
-    if (vertex_profile_str == nullptr) {
-      vertex_profile_str = "(null)";
-    }
-    if (pixel_profile_str == nullptr) {
-      pixel_profile_str = "(null)";
-    }
-
-    dxgsg9_cat.debug()
-      << "\nCg latest vertex profile = " << vertex_profile_str << "  id = " << vertex_profile
-      << "\nCg latest pixel profile = " << pixel_profile_str << "  id = " << pixel_profile
-      << "\nshader model = " << _shader_model
-      << "\n";
-  }
-#endif
-
   _supports_stream_offset = (d3d_caps.DevCaps2 & D3DDEVCAPS2_STREAMOFFSET) != 0;
   _screen->_supports_dynamic_textures = ((d3d_caps.Caps2 & D3DCAPS2_DYNAMICTEXTURES) != 0);
   _screen->_supports_automatic_mipmap_generation = ((d3d_caps.Caps2 & D3DCAPS2_CANAUTOGENMIPMAP) != 0);
@@ -4040,19 +3980,6 @@ close_gsg() {
   }
 }
 
-/**
- * Frees some memory that was explicitly allocated within the dxgsg.
- */
-void DXGraphicsStateGuardian9::
-free_nondx_resources() {
-#ifdef HAVE_CG
-  if (_cg_context) {
-    cgDestroyContext(_cg_context);
-    _cg_context = 0;
-  }
-#endif
-}
-
 /**
  * setup for re-calling dx_init(), this is not the final exit cleanup routine
  * (see dx_cleanup)
@@ -4080,8 +4007,6 @@ free_d3d_device() {
     RELEASE(_d3d_device, dxgsg9, "d3dDevice", RELEASE_DOWN_TO_ZERO);
   }
 
-  free_nondx_resources();
-
   // obviously we dont release ID3D9, just ID3DDevice9
 }
 
@@ -4318,7 +4243,6 @@ set_context(DXScreenData *new_context) {
   _swap_chain = _screen->_swap_chain;   //copy this one field for speed of deref
 
   _screen->_dxgsg9 = this;
-  set_cg_device(_d3d_device);
 }
 
 /**
@@ -4533,7 +4457,6 @@ dx_cleanup() {
     return;
   }
 
-  free_nondx_resources();
   PRINT_REFCNT(dxgsg9, _d3d_device);
 
   // Do a safe check for releasing the D3DDEVICE. RefCount should be zero.  if
@@ -5438,45 +5361,11 @@ restore_gamma() {
  */
 void DXGraphicsStateGuardian9::
 atexit_function(void) {
-  set_cg_device(nullptr);
   if (_gamma_changed) {
     static_set_gamma(true, 1.0f);
   }
 }
 
-/**
- * Returns true if this particular GSG supports the specified Cg Shader
- * Profile.
- */
-bool DXGraphicsStateGuardian9::
-get_supports_cg_profile(const std::string &name) const {
-#ifndef HAVE_CG
-  return false;
-#else
-  CGprofile profile = cgGetProfile(name.c_str());
-
-  if (profile == CG_PROFILE_UNKNOWN) {
-    dxgsg9_cat.error() << name <<", unknown Cg-profile\n";
-    return false;
-  }
-  return cgD3D9IsProfileSupported(cgGetProfile(name.c_str())) != 0;
-#endif  // HAVE_CG
-}
-
-/**
- * Sets the global Cg device pointer.  TODO: make this thread-safe somehow.
- * Maybe Cg is inherently not thread-safe.
- */
-void DXGraphicsStateGuardian9::
-set_cg_device(LPDIRECT3DDEVICE9 cg_device) {
-#ifdef HAVE_CG
-  if (_cg_device != cg_device) {
-    cgD3D9SetDevice(cg_device);
-    _cg_device = cg_device;
-  }
-#endif // HAVE_CG
-}
-
 /**
  * Returns a vertex buffer containing only a full-white color.
  */

+ 0 - 9
panda/src/dxgsg9/dxGraphicsStateGuardian9.h

@@ -165,9 +165,6 @@ public:
   void restore_gamma();
   static void atexit_function(void);
 
-  static void set_cg_device(LPDIRECT3DDEVICE9 cg_device);
-  virtual bool get_supports_cg_profile(const std::string &name) const;
-
   LPDIRECT3DVERTEXBUFFER9 get_white_vbuffer();
 
 protected:
@@ -200,7 +197,6 @@ protected:
   virtual void bind_clip_plane(const NodePath &plane, int plane_id);
 
   virtual void close_gsg();
-  void free_nondx_resources();
   void free_d3d_device();
 
   void set_draw_buffer(const RenderBuffer &rb);
@@ -364,11 +360,6 @@ protected:
 
   int _supports_gamma_calibration;
 
-#ifdef HAVE_CG
-  CGcontext _cg_context;
-  static LPDIRECT3DDEVICE9 _cg_device;
-#endif
-
 public:
   virtual TypeHandle get_type() const {
     return get_class_type();

+ 1 - 1
panda/src/glgsg/CMakeLists.txt

@@ -15,7 +15,7 @@ composite_sources(p3glgsg P3GLGSG_SOURCES)
 add_component_library(p3glgsg SYMBOL BUILDING_PANDA_GLGSG
   ${P3GLGSG_HEADERS} ${P3GLGSG_SOURCES})
 target_link_libraries(p3glgsg p3glstuff panda
-  PKG::CG PKG::GL)
+  PKG::GL)
 
 if(NOT BUILD_METALIBS)
   install(TARGETS p3glgsg

+ 0 - 12
panda/src/glstuff/glCgShaderContext_src.I

@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file glCgShaderContext_src.I
- * @author rdb
- * @date 2014-06-27
- */

+ 0 - 1095
panda/src/glstuff/glCgShaderContext_src.cxx

@@ -1,1095 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file glCgShaderContext_src.cxx
- * @author jyelon
- * @date 2005-09-01
- * @author fperazzi, PandaSE
- * @date 2010-04-29
- *   parameter types only supported under Cg)
- */
-
-#if defined(HAVE_CG) && !defined(OPENGLES)
-
-#include <Cg/cg.h>
-#include <Cg/cgGL.h>
-
-#include "pStatGPUTimer.h"
-
-TypeHandle CLP(CgShaderContext)::_type_handle;
-
-#ifndef NDEBUG
-#define cg_report_errors() { \
-  CGerror err = cgGetError(); \
-  if (err != CG_NO_ERROR) { \
-    GLCAT.error() << __FILE__ ", line " << __LINE__ << ": " << cgGetErrorString(err) << "\n"; \
-  } }
-#else
-#define cg_report_errors()
-#endif
-
-/**
- * xyz
- */
-CLP(CgShaderContext)::
-CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext(s) {
-  _glgsg = glgsg;
-  _cg_program = 0;
-  _glsl_program = 0;
-  _color_attrib_index = CA_color;
-  _transform_table_param = 0;
-  _slider_table_param = 0;
-  _frame_number = -1;
-
-  nassertv(s->get_language() == Shader::SL_Cg);
-
-  // Get a Cg context for this GSG.
-  CGcontext context = glgsg->_cg_context;
-  if (context == 0) {
-    // The GSG doesn't have a Cg context yet.  Create one.
-    glgsg->_cg_context = context = cgCreateContext();
-
-#if CG_VERSION_NUM >= 3100
-    // This just sounds like a good thing to do.
-    cgGLSetContextGLSLVersion(context, cgGLDetectGLSLVersion());
-    if (glgsg->_shader_caps._active_vprofile == CG_PROFILE_GLSLV) {
-      cgGLSetContextOptimalOptions(context, CG_PROFILE_GLSLC);
-    }
-#endif
-  }
-
-  // Ask the shader to compile itself for us and to give us the resulting Cg
-  // program objects.
-  if (!s->cg_compile_for(_glgsg->_shader_caps, context,
-                         _cg_program, _cg_parameter_map)) {
-    return;
-  }
-
-  _transform_table_param = cgGetNamedParameter(_cg_program, "tbl_transforms");
-  if (_transform_table_param) {
-    _transform_table_size = cgGetArraySize(_transform_table_param, 0);
-  }
-
-  _slider_table_param = cgGetNamedParameter(_cg_program, "tbl_sliders");
-  if (_slider_table_param) {
-    _slider_table_size = cgGetArraySize(_slider_table_param, 0);
-  }
-
-  if (GLCAT.is_debug()) {
-    GLCAT.debug()
-      << "Loading Cg shader " << s->get_filename() << "\n";
-  }
-
-  // Load the program.
-  if (_cg_program == 0) {
-    const char *str = cgGetErrorString(cgGetError());
-    GLCAT.error()
-      << "Could not combine Cg program: " << s->get_filename()
-      << " (" << str << ")\n";
-    release_resources();
-
-  } else {
-    cgGLLoadProgram(_cg_program);
-    CGerror error = cgGetError();
-    if (error != CG_NO_ERROR) {
-      const char *str = cgGetErrorString(error);
-      GLCAT.error()
-        << "Could not load program: " << s->get_filename()
-        << " (" << str << ")\n";
-      release_resources();
-    }
-  }
-
-  if (_cg_program != 0 && _glgsg->_supports_glsl) {
-    if (cgGetProgramProfile(_cg_program) == CG_PROFILE_GLSLC) {
-      _glsl_program = cgGLGetProgramID(_cg_program);
-
-      // Sometimes it fails to link, and Cg fails to propagate the error.
-      GLint link_status;
-      _glgsg->_glGetProgramiv(_glsl_program, GL_LINK_STATUS, &link_status);
-      if (link_status != GL_TRUE) {
-        release_resources();
-      }
-    }
-  }
-
-  if (_cg_program == 0) {
-    return;
-  }
-
-  // We don't use cgGLSetParameterPointer to set the vertex attributes any
-  // longer, since it is buggy on non-NVIDIA hardware and doesn't allow
-  // explicit control over some parameters.  Instead, we have to figure out
-  // ourselves how to map the input varyings to OpenGL vertex attributes.  We
-  // use positive indices to indicate generic vertex attributes, and negative
-  // indices to indicate conventional vertex attributes (ie.
-  // glVertexPointer).
-  size_t nvarying = _shader->_var_spec.size();
-  _attributes.resize(nvarying);
-  _used_generic_attribs.clear();
-
-  for (size_t i = 0; i < nvarying; ++i) {
-    const Shader::ShaderVarSpec &bind = _shader->_var_spec[i];
-    CGparameter p = _cg_parameter_map[i];
-    if (p == 0) {
-      _attributes[i] = CA_unknown;
-      continue;
-    }
-
-    GLint loc = CA_unknown;
-    CGresource res = cgGetParameterResource(p);
-
-    if (cgGetParameterBaseResource(p) == CG_ATTR0) {
-      // The Cg toolkit claims that it is bound to a generic vertex attribute.
-      if (_glgsg->has_fixed_function_pipeline() && _glsl_program != 0) {
-        // This is where the Cg glslv compiler lies, making the stupid
-        // assumption that we're using an NVIDIA card where generic attributes
-        // are aliased with conventional vertex attributes.  Instead, it
-        // always uses conventional attributes in this case.  Correct this.
-        int index = cgGetParameterResourceIndex(p);
-        switch (index) {
-        case 0:  // gl_Vertex
-          loc = CA_vertex;
-          break;
-        case 2:  // gl_Normal
-          loc = CA_normal;
-          if (cgGetParameterColumns(p) == 4) {
-            // Don't declare vtx_normal with 4 coordinates; it results in it
-            // reading the w coordinate from random memory.
-            GLCAT.error()
-              << "Cg varying " << cgGetParameterName(p);
-            if (cgGetParameterSemantic(p)) {
-              GLCAT.error(false) << " : " << cgGetParameterSemantic(p);
-            }
-            GLCAT.error(false) << " should be declared as float4, not float3!\n";
-          }
-          break;
-        case 3:  // gl_Color
-          loc = CA_color;
-          break;
-        case 4:  // gl_SecondaryColor
-          loc = CA_secondary_color;
-          break;
-        case 1:  // glWeightPointerARB?
-        case 5:  // gl_FogCoord
-        case 6:  // PSIZE?
-        case 7:  // BLENDINDICES
-          GLCAT.error()
-            << "Cg varying " << cgGetParameterName(p) << " is bound to "
-               "unrecognized attribute " << index << "\n";
-          loc = CA_unknown;
-          break;
-        default:
-          loc = CA_texcoord + (index - 8);
-          break;
-        }
-      } else {
-        loc = cgGetParameterResourceIndex(p);
-
-        if (loc != 0 && bind._id._name->get_basename() == "vtx_position") {
-          // We really have to bind the vertex position to attribute 0, since
-          // OpenGL will hide the model if attribute 0 is not enabled, and we
-          // can only ever be sure that vtx_position is bound.
-          GLCAT.warning()
-            << "CG varying vtx_position is bound to generic attribute " << loc
-            << " instead of 0.  Use ATTR0 semantic to prevent this.\n";
-        }
-      }
-
-    } else if (res == CG_GLSL_ATTRIB || _glsl_program != 0) {
-      // With cg-glsl-version 130 and higher, no conventional attributes are
-      // used, but it instead uses specially named variables.  A bit of
-      // guesswork is involved here; Cg seems to mostly use the semantics as
-      // attribute names in GLSL, with a few exceptions.
-      const char *attribname = nullptr;
-      switch (res) {
-      case CG_POSITION0:
-        attribname = "cg_Vertex";
-        break;
-      case CG_NORMAL0:
-        attribname = "NORMAL";
-        break;
-      case CG_COLOR0:
-      case CG_DIFFUSE0:
-        attribname = "COLOR";
-        break;
-      case CG_COLOR1:
-      case CG_SPECULAR0:
-        attribname = "SPECULAR";
-        break;
-      default:
-        // Everything else appears to be named after the semantic string.
-        attribname = cgGetParameterSemantic(p);
-      }
-      loc = _glgsg->_glGetAttribLocation(_glsl_program, attribname);
-
-      if (bind._id._name->get_basename() == "vtx_color") {
-        _color_attrib_index = loc;
-      }
-
-      if (loc == -1) {
-        const char *resource = cgGetParameterResourceName(p);
-        if (!resource) {
-          resource = "unknown";
-        }
-        if (GLCAT.is_debug()) {
-          GLCAT.debug()
-            << "Could not find Cg varying " << cgGetParameterName(p);
-          if (attribname) {
-            GLCAT.debug(false) << " : " << attribname;
-          }
-          GLCAT.debug(false) << " (" << resource << ") in the compiled GLSL program.\n";
-        }
-
-      } else if (loc != 0 && bind._id._name->get_basename() == "vtx_position") {
-        // We really have to bind the vertex position to attribute 0, since
-        // OpenGL will hide the model if attribute 0 is not enabled, and we
-        // can only ever be sure that vtx_position is bound.
-        GLCAT.warning()
-          << "CG varying vtx_position is bound to generic attribute " << loc
-          << "instead of 0.  Use ATTR0 semantic to prevent this.\n";
-      }
-
-    } else if (cgGetParameterBaseResource(p) == CG_TEXCOORD0) {
-      // A conventional texture coordinate set.
-      loc = CA_texcoord + cgGetParameterResourceIndex(p);
-
-    } else if (_glgsg->has_fixed_function_pipeline()) {
-      // Some other conventional vertex attribute.
-      switch (res) {
-      case CG_POSITION0:
-        loc = CA_vertex;
-        break;
-      case CG_NORMAL0:
-        loc = CA_normal;
-        break;
-      case CG_COLOR0:
-      case CG_DIFFUSE0:
-        loc = CA_color;
-        break;
-      case CG_COLOR1:
-      case CG_SPECULAR0:
-        loc = CA_secondary_color;
-        break;
-      default:
-        GLCAT.error()
-          << "Cg varying " << cgGetParameterName(p);
-        if (cgGetParameterSemantic(p)) {
-          GLCAT.error(false) << " : " << cgGetParameterSemantic(p);
-        }
-        GLCAT.error(false) << " has an unrecognized resource";
-        if (cgGetParameterResourceName(p)) {
-          GLCAT.error(false) << " (" << cgGetParameterResourceName(p) << ")";
-        }
-        GLCAT.error(false) << ".\n";
-        loc = CA_unknown;
-      }
-    } else {
-      GLCAT.error()
-        << "Cg varying " << cgGetParameterName(p);
-      if (cgGetParameterSemantic(p)) {
-        GLCAT.error(false) << " : " << cgGetParameterSemantic(p);
-      }
-      GLCAT.error(false) << " is bound to a conventional vertex attribute, "
-                            "but the compatibility profile is not enabled.\n";
-    }
-
-#ifndef NDEBUG
-    if (GLCAT.is_debug()) {
-      GLCAT.debug()
-        << "Cg varying " << cgGetParameterName(p);
-
-      const char *semantic = cgGetParameterSemantic(p);
-      if (semantic) {
-        GLCAT.debug(false) << " : " << semantic;
-      }
-
-      if (loc == CA_unknown) {
-        GLCAT.debug(false)
-          << " is not bound to a vertex attribute\n";
-
-      } else if (loc >= 0) {
-        GLCAT.debug(false)
-          << " is bound to generic attribute " << loc << "\n";
-
-      } else {
-        const char *resource = cgGetParameterResourceName(p);
-        if (!resource) {
-          resource = "unknown";
-        }
-        GLCAT.debug(false)
-          << " is bound to a conventional attribute (" << resource << ")\n";
-      }
-      if (loc == CA_unknown) {
-        // Suggest fix to developer.
-        GLCAT.debug() << "Try using a different semantic.\n";
-      }
-    }
-#endif
-
-    _attributes[i] = loc;
-    if (loc >= 0) {
-      _used_generic_attribs.set_bit(loc);
-    }
-  }
-
-  _mat_part_cache = new LMatrix4[_shader->cp_get_mat_cache_size()];
-
-  _glgsg->report_my_gl_errors();
-}
-
-/**
- * xyz
- */
-CLP(CgShaderContext)::
-~CLP(CgShaderContext)() {
-  // Don't call release_resources; we may not have an active context.
-  delete[] _mat_part_cache;
-}
-
-/**
- * Should deallocate all system resources (such as vertex program handles or
- * Cg contexts).
- */
-void CLP(CgShaderContext)::
-release_resources() {
-  if (_cg_program != 0) {
-    cgDestroyProgram(_cg_program);
-    _cg_program = 0;
-  }
-  _cg_parameter_map.clear();
-  if (_glgsg) {
-    _glgsg->report_my_gl_errors();
-
-  } else if (glGetError() != GL_NO_ERROR) {
-    GLCAT.error() << "GL error in ShaderContext destructor\n";
-  }
-
-  if (!_glgsg) {
-    return;
-  }
-  _glgsg->report_my_gl_errors();
-}
-
-/**
- * Returns true if the shader is "valid", ie, if the compilation was
- * successful.  The compilation could fail if there is a syntax error in the
- * shader, or if the current video card isn't shader-capable, or if no shader
- * languages are compiled into panda.
- */
-bool CLP(CgShaderContext)::
-valid() {
-  if (_shader == nullptr || _shader->get_error_flag()) {
-    return false;
-  }
-  return (_cg_program != 0);
-}
-
-/**
- * This function is to be called to enable a new shader.  It also initializes
- * all of the shader's input parameters.
- */
-void CLP(CgShaderContext)::
-bind() {
-  if (_cg_program != 0) {
-    // Bind the shaders.
-    cgGLEnableProgramProfiles(_cg_program);
-    cgGLBindProgram(_cg_program);
-
-    cg_report_errors();
-    _glgsg->report_my_gl_errors();
-  }
-}
-
-/**
- * This function disables a currently-bound shader.
- */
-void CLP(CgShaderContext)::
-unbind() {
-  if (_cg_program != 0) {
-    int num_domains = cgGetNumProgramDomains(_cg_program);
-    for (int i = 0; i < num_domains; ++i) {
-      CGprofile profile = cgGetProgramDomainProfile(_cg_program, i);
-      cgGLUnbindProgram(profile);
-      cgGLDisableProfile(profile);
-    }
-
-    cg_report_errors();
-    _glgsg->report_my_gl_errors();
-  }
-}
-
-/**
- * This function gets called whenever the RenderState or TransformState has
- * changed, but the Shader itself has not changed.  It loads new values into
- * the shader's parameters.
- */
-void CLP(CgShaderContext)::
-set_state_and_transform(const RenderState *target_rs,
-                        const TransformState *modelview_transform,
-                        const TransformState *camera_transform,
-                        const TransformState *projection_transform) {
-
-  if (!valid()) {
-    return;
-  }
-
-  // Find out which state properties have changed.
-  int altered = 0;
-
-  if (_modelview_transform != modelview_transform) {
-    _modelview_transform = modelview_transform;
-    altered |= (Shader::SSD_transform & ~Shader::SSD_view_transform);
-  }
-  if (_camera_transform != camera_transform) {
-    _camera_transform = camera_transform;
-    altered |= Shader::SSD_transform;
-  }
-  if (_projection_transform != projection_transform) {
-    _projection_transform = projection_transform;
-    altered |= Shader::SSD_projection;
-  }
-
-  CPT(RenderState) state_rs = _state_rs.lock();
-  if (state_rs == nullptr) {
-    // Reset all of the state.
-    altered |= Shader::SSD_general;
-    _state_rs = target_rs;
-
-  } else if (state_rs != target_rs) {
-    // The state has changed since last time.
-    if (state_rs->get_attrib(ColorAttrib::get_class_slot()) !=
-        target_rs->get_attrib(ColorAttrib::get_class_slot())) {
-      altered |= Shader::SSD_color;
-    }
-    if (state_rs->get_attrib(ColorScaleAttrib::get_class_slot()) !=
-        target_rs->get_attrib(ColorScaleAttrib::get_class_slot())) {
-      altered |= Shader::SSD_colorscale;
-    }
-    if (state_rs->get_attrib(MaterialAttrib::get_class_slot()) !=
-        target_rs->get_attrib(MaterialAttrib::get_class_slot())) {
-      altered |= Shader::SSD_material;
-    }
-    if (state_rs->get_attrib(ShaderAttrib::get_class_slot()) !=
-        target_rs->get_attrib(ShaderAttrib::get_class_slot())) {
-      altered |= Shader::SSD_shaderinputs;
-    }
-    if (state_rs->get_attrib(FogAttrib::get_class_slot()) !=
-        target_rs->get_attrib(FogAttrib::get_class_slot())) {
-      altered |= Shader::SSD_fog;
-    }
-    if (state_rs->get_attrib(LightAttrib::get_class_slot()) !=
-        target_rs->get_attrib(LightAttrib::get_class_slot())) {
-      altered |= Shader::SSD_light;
-    }
-    if (state_rs->get_attrib(ClipPlaneAttrib::get_class_slot()) !=
-        target_rs->get_attrib(ClipPlaneAttrib::get_class_slot())) {
-      altered |= Shader::SSD_clip_planes;
-    }
-    if (state_rs->get_attrib(TexMatrixAttrib::get_class_slot()) !=
-        target_rs->get_attrib(TexMatrixAttrib::get_class_slot())) {
-      altered |= Shader::SSD_tex_matrix;
-    }
-    _state_rs = target_rs;
-  }
-
-  // Is this the first time this shader is used this frame?
-  int frame_number = ClockObject::get_global_clock()->get_frame_count();
-  if (frame_number != _frame_number) {
-     altered |= Shader::SSD_frame;
-    _frame_number = frame_number;
-  }
-
-  if (altered != 0) {
-    issue_parameters(altered);
-  }
-}
-
-/**
- * This function gets called whenever the RenderState or TransformState has
- * changed, but the Shader itself has not changed.  It loads new values into
- * the shader's parameters.
- *
- * If "altered" is false, that means you promise that the parameters for this
- * shader context have already been issued once, and that since the last time
- * the parameters were issued, no part of the render state has changed except
- * the external and internal transforms.
- */
-void CLP(CgShaderContext)::
-issue_parameters(int altered) {
-  PStatGPUTimer timer(_glgsg, _glgsg->_draw_set_state_shader_parameters_pcollector);
-
-  if (GLCAT.is_spam()) {
-    GLCAT.spam()
-      << "Setting uniforms for " << _shader->get_filename()
-      << " (altered 0x" << std::hex << altered << std::dec << ")\n";
-  }
-
-  // We have no way to track modifications to PTAs, so we assume that they are
-  // modified every frame and when we switch ShaderAttribs.
-  if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) {
-    // Iterate through _ptr parameters
-    for (int i = 0; i < (int)_shader->_ptr_spec.size(); ++i) {
-      Shader::ShaderPtrSpec &spec = _shader->_ptr_spec[i];
-
-      const Shader::ShaderPtrData *ptr_data =_glgsg->fetch_ptr_parameter(spec);
-      if (ptr_data == nullptr){ //the input is not contained in ShaderPtrData
-        release_resources();
-        return;
-      }
-
-      // Check if the size of the shader input and ptr_data match
-      size_t input_size = spec._dim[0] * spec._dim[1] * spec._dim[2];
-
-      // dimension is negative only if the parameter had the (deprecated)k_
-      // prefix.
-      if ((input_size > ptr_data->_size) && (spec._dim[0] > 0)) {
-        GLCAT.error() << spec._id._name << ": incorrect number of elements, expected "
-                      <<  input_size <<" got " <<  ptr_data->_size << "\n";
-        release_resources();
-        return;
-      }
-      CGparameter p = _cg_parameter_map[spec._id._location];
-      void *data = ptr_data->_ptr;
-
-      switch (ptr_data->_type) {
-      case ShaderType::ST_float:
-        if (spec._id._type->as_array() != nullptr) {
-          switch (spec._dim[1]) {
-          case 1: cgGLSetParameterArray1f(p, 0, spec._dim[0], (float *)data); continue;
-          case 2: cgGLSetParameterArray2f(p, 0, spec._dim[0], (float *)data); continue;
-          case 3: cgGLSetParameterArray3f(p, 0, spec._dim[0], (float *)data); continue;
-          case 4: cgGLSetParameterArray4f(p, 0, spec._dim[0], (float *)data); continue;
-          case 9: cgGLSetMatrixParameterArrayfc(p, 0, spec._dim[0], (float *)data); continue;
-          case 16: cgGLSetMatrixParameterArrayfc(p, 0, spec._dim[0], (float *)data); continue;
-          default: nassertd(false) continue;
-          }
-        } else {
-          switch (spec._dim[1]) {
-          case 1: cgSetParameter1fv(p, (float *)data); continue;
-          case 2: cgSetParameter2fv(p, (float *)data); continue;
-          case 3: cgSetParameter3fv(p, (float *)data); continue;
-          case 4: cgSetParameter4fv(p, (float *)data); continue;
-          case 9: cgGLSetMatrixParameterfc(p, (float *)data); continue;
-          case 16: cgGLSetMatrixParameterfc(p, (float *)data); continue;
-          default: nassertd(false) continue;
-          }
-        }
-        break;
-
-      case ShaderType::ST_double:
-        if (spec._id._type->as_array() != nullptr) {
-          switch (spec._dim[1]) {
-          case 1: cgGLSetParameterArray1d(p, 0, spec._dim[0], (double *)data); continue;
-          case 2: cgGLSetParameterArray2d(p, 0, spec._dim[0], (double *)data); continue;
-          case 3: cgGLSetParameterArray3d(p, 0, spec._dim[0], (double *)data); continue;
-          case 4: cgGLSetParameterArray4d(p, 0, spec._dim[0], (double *)data); continue;
-          case 9: cgGLSetMatrixParameterArraydc(p, 0, spec._dim[0], (double *)data); continue;
-          case 16: cgGLSetMatrixParameterArraydc(p, 0, spec._dim[0], (double *)data); continue;
-          default: nassertd(false) continue;
-          }
-        } else {
-          switch (spec._dim[1]) {
-          case 1: cgSetParameter1dv(p, (double *)data); continue;
-          case 2: cgSetParameter2dv(p, (double *)data); continue;
-          case 3: cgSetParameter3dv(p, (double *)data); continue;
-          case 4: cgSetParameter4dv(p, (double *)data); continue;
-          case 9: cgGLSetMatrixParameterdc(p, (double *)data); continue;
-          case 16: cgGLSetMatrixParameterdc(p, (double *)data); continue;
-          default: nassertd(false) continue;
-          }
-        }
-        break;
-
-      case ShaderType::ST_int:
-      case ShaderType::ST_uint:
-        switch (spec._dim[1]) {
-        case 1: cgSetParameter1iv(p, (int *)data); continue;
-        case 2: cgSetParameter2iv(p, (int *)data); continue;
-        case 3: cgSetParameter3iv(p, (int *)data); continue;
-        case 4: cgSetParameter4iv(p, (int *)data); continue;
-        default: nassertd(false) continue;
-        }
-        break;
-
-      default:
-        GLCAT.error() << spec._id._name << ":" << "unrecognized parameter type\n";
-        release_resources();
-        return;
-      }
-    }
-  }
-
-  if (altered & _shader->_mat_deps) {
-    _glgsg->update_shader_matrix_cache(_shader, _mat_part_cache, altered);
-
-    for (Shader::ShaderMatSpec &spec : _shader->_mat_spec) {
-      if ((altered & spec._dep) == 0) {
-        continue;
-      }
-
-      const LMatrix4 *val = _glgsg->fetch_specified_value(spec, _mat_part_cache, altered);
-      if (!val) continue;
-      const PN_stdfloat *data = val->get_data();
-
-      CGparameter p = _cg_parameter_map[spec._id._location];
-      switch (spec._piece) {
-      case Shader::SMP_whole: GLfc(cgGLSetMatrixParameter)(p, data); continue;
-      case Shader::SMP_transpose: GLfr(cgGLSetMatrixParameter)(p, data); continue;
-      case Shader::SMP_col0: GLf(cgGLSetParameter4)(p, data[0], data[4], data[ 8], data[12]); continue;
-      case Shader::SMP_col1: GLf(cgGLSetParameter4)(p, data[1], data[5], data[ 9], data[13]); continue;
-      case Shader::SMP_col2: GLf(cgGLSetParameter4)(p, data[2], data[6], data[10], data[14]); continue;
-      case Shader::SMP_col3: GLf(cgGLSetParameter4)(p, data[3], data[7], data[11], data[15]); continue;
-      case Shader::SMP_row0: GLfv(cgGLSetParameter4)(p, data+ 0); continue;
-      case Shader::SMP_row1: GLfv(cgGLSetParameter4)(p, data+ 4); continue;
-      case Shader::SMP_row2: GLfv(cgGLSetParameter4)(p, data+ 8); continue;
-      case Shader::SMP_row3: GLfv(cgGLSetParameter4)(p, data+12); continue;
-      case Shader::SMP_row3x1: GLfv(cgGLSetParameter1)(p, data+12); continue;
-      case Shader::SMP_row3x2: GLfv(cgGLSetParameter2)(p, data+12); continue;
-      case Shader::SMP_row3x3: GLfv(cgGLSetParameter3)(p, data+12); continue;
-      case Shader::SMP_upper3x3:
-        {
-          LMatrix3 upper3 = val->get_upper_3();
-          GLfc(cgGLSetMatrixParameter)(p, upper3.get_data());
-          continue;
-        }
-      case Shader::SMP_transpose3x3:
-        {
-          LMatrix3 upper3 = val->get_upper_3();
-          GLfr(cgGLSetMatrixParameter)(p, upper3.get_data());
-          continue;
-        }
-      case Shader::SMP_cell15:
-        GLf(cgGLSetParameter1)(p, data[15]);
-        continue;
-      case Shader::SMP_cell14:
-        GLf(cgGLSetParameter1)(p, data[14]);
-        continue;
-      case Shader::SMP_cell13:
-        GLf(cgGLSetParameter1)(p, data[13]);
-        continue;
-      }
-    }
-  }
-
-  cg_report_errors();
-  _glgsg->report_my_gl_errors();
-}
-
-/**
- * Changes the active transform table, used for hardware skinning.
- */
-void CLP(CgShaderContext)::
-update_transform_table(const TransformTable *table) {
-  LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64);
-
-  int i = 0;
-  if (table != nullptr) {
-    int num_transforms = std::min(_transform_table_size, (long)table->get_num_transforms());
-    for (; i < num_transforms; ++i) {
-#ifdef STDFLOAT_DOUBLE
-      LMatrix4 matrix;
-      table->get_transform(i)->get_matrix(matrix);
-      matrices[i] = LCAST(float, matrix);
-#else
-      table->get_transform(i)->get_matrix(matrices[i]);
-#endif
-    }
-  }
-  for (; i < _transform_table_size; ++i) {
-    matrices[i] = LMatrix4f::ident_mat();
-  }
-
-  cgGLSetMatrixParameterArrayfc(_transform_table_param, 0,
-                                _transform_table_size, (float *)matrices);
-}
-
-/**
- * Changes the active slider table, used for hardware skinning.
- */
-void CLP(CgShaderContext)::
-update_slider_table(const SliderTable *table) {
-  float *sliders = (float *)alloca(_slider_table_size * 4);
-  memset(sliders, 0, _slider_table_size * 4);
-
-  if (table != nullptr) {
-    int num_sliders = std::min(_slider_table_size, (long)table->get_num_sliders());
-    for (int i = 0; i < num_sliders; ++i) {
-      sliders[i] = table->get_slider(i)->get_slider();
-    }
-  }
-
-  cgGLSetParameterArray4f(_slider_table_param, 0, _slider_table_size, sliders);
-}
-
-/**
- * Disable all the vertex arrays used by this shader.
- */
-void CLP(CgShaderContext)::
-disable_shader_vertex_arrays() {
-  if (!valid()) {
-    return;
-  }
-
-  for (size_t i = 0; i < _shader->_var_spec.size(); ++i) {
-    GLint p = _attributes[i];
-
-    if (p >= 0) {
-      _glgsg->disable_vertex_attrib_array(p);
-    } else {
-#ifdef SUPPORT_FIXED_FUNCTION
-      switch (p) {
-      case CA_unknown:
-        break;
-      case CA_vertex:
-        glDisableClientState(GL_VERTEX_ARRAY);
-        break;
-      case CA_normal:
-        glDisableClientState(GL_NORMAL_ARRAY);
-        break;
-      case CA_color:
-        glDisableClientState(GL_COLOR_ARRAY);
-        break;
-      case CA_secondary_color:
-        glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
-        break;
-      default:
-        _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (p - CA_texcoord));
-        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-        break;
-      }
-#endif  // SUPPORT_FIXED_FUNCTION
-    }
-  }
-
-  cg_report_errors();
-  _glgsg->report_my_gl_errors();
-}
-
-/**
- * Disables all vertex arrays used by the previous shader, then enables all
- * the vertex arrays needed by this shader.  Extracts the relevant vertex
- * array data from the gsg.  The current implementation is inefficient,
- * because it may unnecessarily disable arrays then immediately reenable them.
- * We may optimize this someday.
- */
-bool CLP(CgShaderContext)::
-update_shader_vertex_arrays(ShaderContext *prev, bool force) {
-  if (!valid()) {
-    return true;
-  }
-
-  cg_report_errors();
-
-#ifdef SUPPORT_IMMEDIATE_MODE
-  if (_glgsg->_use_sender) {
-    GLCAT.error() << "immediate mode shaders not implemented yet\n";
-  } else
-#endif // SUPPORT_IMMEDIATE_MODE
-  {
-    const GeomVertexArrayDataHandle *array_reader;
-    Geom::NumericType numeric_type;
-    int start, stride, num_values;
-    size_t nvarying = _shader->_var_spec.size();
-
-    for (size_t i = 0; i < nvarying; ++i) {
-      const Shader::ShaderVarSpec &bind = _shader->_var_spec[i];
-      InternalName *name = bind._name;
-      int texslot = bind._append_uv;
-      if (texslot >= 0 && texslot < _glgsg->_state_texture->get_num_on_stages()) {
-        TextureStage *stage = _glgsg->_state_texture->get_on_stage(texslot);
-        InternalName *texname = stage->get_texcoord_name();
-
-        if (name == InternalName::get_texcoord()) {
-          name = texname;
-        } else if (texname != InternalName::get_texcoord()) {
-          name = name->append(texname->get_basename());
-        }
-      }
-      GLint p = _attributes[i];
-
-      // Don't apply vertex colors if they are disabled with a ColorAttrib.
-      int num_elements, element_stride, divisor;
-      bool normalized;
-      if ((p != _color_attrib_index || _glgsg->_vertex_colors_enabled) &&
-          _glgsg->_data_reader->get_array_info(name, array_reader,
-                                               num_values, numeric_type,
-                                               normalized, start, stride, divisor,
-                                               num_elements, element_stride)) {
-        const unsigned char *client_pointer;
-        if (!_glgsg->setup_array_data(client_pointer, array_reader, force)) {
-          return false;
-        }
-        client_pointer += start;
-
-        // We don't use cgGLSetParameterPointer because it is very buggy and
-        // limited in the options we can set.
-        GLenum type = _glgsg->get_numeric_type(numeric_type);
-        if (p >= 0) {
-          _glgsg->enable_vertex_attrib_array(p);
-
-          if (numeric_type == GeomEnums::NT_packed_dabc) {
-            // GL_BGRA is a special accepted value available since OpenGL 3.2.
-            // It requires us to pass GL_TRUE for normalized.
-            _glgsg->_glVertexAttribPointer(p, GL_BGRA, GL_UNSIGNED_BYTE,
-                                           GL_TRUE, stride, client_pointer);
-          } else if (bind._scalar_type == ShaderType::ST_float ||
-                     numeric_type == GeomEnums::NT_float32) {
-            _glgsg->_glVertexAttribPointer(p, num_values, type,
-                                           normalized, stride, client_pointer);
-          } else if (bind._scalar_type == ShaderType::ST_double) {
-            _glgsg->_glVertexAttribLPointer(p, num_values, type,
-                                            stride, client_pointer);
-          } else {
-            _glgsg->_glVertexAttribIPointer(p, num_values, type,
-                                            stride, client_pointer);
-          }
-
-          if (divisor > 0) {
-            _glgsg->set_vertex_attrib_divisor(p, divisor);
-          }
-
-        } else {
-          // It's a conventional vertex attribute.  Ugh.
-#ifdef SUPPORT_FIXED_FUNCTION
-          switch (p) {
-          case CA_unknown:
-            break;
-
-          case CA_vertex:
-            glVertexPointer(num_values, type, stride, client_pointer);
-            glEnableClientState(GL_VERTEX_ARRAY);
-            break;
-
-          case CA_normal:
-            glNormalPointer(type, stride, client_pointer);
-            glEnableClientState(GL_NORMAL_ARRAY);
-            break;
-
-          case CA_color:
-            if (numeric_type == GeomEnums::NT_packed_dabc) {
-              glColorPointer(GL_BGRA, GL_UNSIGNED_BYTE, stride, client_pointer);
-            } else {
-              glColorPointer(num_values, type, stride, client_pointer);
-            }
-            glEnableClientState(GL_COLOR_ARRAY);
-            break;
-
-          case CA_secondary_color:
-            _glgsg->_glSecondaryColorPointer(num_values, type,
-                                             stride, client_pointer);
-            glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
-            break;
-
-          default:
-            _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (p - CA_texcoord));
-            glTexCoordPointer(num_values, type, stride, client_pointer);
-            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-            break;
-          }
-#endif  // SUPPORT_FIXED_FUNCTION
-        }
-      } else {
-        // There is no vertex column with this name; disable the attribute
-        // array.
-        if (_glgsg->has_fixed_function_pipeline() && p == 0) {
-          // NOTE: if we disable attribute 0 in compatibility profile, the
-          // object will disappear.  In GLSL we fix this by forcing the vertex
-          // column to be at 0, but we don't have control over that with Cg.
-          // So, we work around this by just binding something silly to 0.
-          // This breaks flat colors, but it's better than invisible objects?
-          _glgsg->enable_vertex_attrib_array(0);
-          if (bind._scalar_type == ShaderType::ST_float) {
-            _glgsg->_glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
-          } else if (bind._scalar_type == ShaderType::ST_double) {
-            _glgsg->_glVertexAttribLPointer(0, 4, GL_DOUBLE, 0, 0);
-          } else {
-            _glgsg->_glVertexAttribIPointer(0, 4, GL_INT, 0, 0);
-          }
-
-        } else if (p >= 0) {
-          _glgsg->disable_vertex_attrib_array(p);
-
-          if (p == _color_attrib_index) {
-#ifdef STDFLOAT_DOUBLE
-            _glgsg->_glVertexAttrib4dv(p, _glgsg->_scene_graph_color.get_data());
-#else
-            _glgsg->_glVertexAttrib4fv(p, _glgsg->_scene_graph_color.get_data());
-#endif
-          }
-        } else {
-#ifdef SUPPORT_FIXED_FUNCTION
-          switch (p) {
-          case CA_unknown:
-            break;
-          case CA_vertex:
-            glDisableClientState(GL_VERTEX_ARRAY);
-            break;
-          case CA_normal:
-            glDisableClientState(GL_NORMAL_ARRAY);
-            break;
-          case CA_color:
-            glDisableClientState(GL_COLOR_ARRAY);
-#ifdef STDFLOAT_DOUBLE
-            glColor4dv(_glgsg->_scene_graph_color.get_data());
-#else
-            glColor4fv(_glgsg->_scene_graph_color.get_data());
-#endif
-            break;
-          case CA_secondary_color:
-            glDisableClientState(GL_SECONDARY_COLOR_ARRAY);
-            break;
-          default:
-            _glgsg->_glClientActiveTexture(GL_TEXTURE0 + (p - CA_texcoord));
-            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-            break;
-          }
-#endif  // SUPPORT_FIXED_FUNCTION
-        }
-      }
-    }
-
-    // Disable enabled attribute arrays that we don't use.
-    BitMask32 disable = _glgsg->_enabled_vertex_attrib_arrays & ~_used_generic_attribs;
-    if (!disable.is_zero()) {
-      for (GLuint p = (GLuint)disable.get_lowest_on_bit(); p <= (GLuint)disable.get_highest_on_bit(); ++p) {
-        if (disable.get_bit(p)) {
-          _glgsg->disable_vertex_attrib_array(p);
-        }
-      }
-    }
-  }
-
-  if (_transform_table_param) {
-    const TransformTable *table = _glgsg->_data_reader->get_transform_table();
-    update_transform_table(table);
-  }
-
-  if (_slider_table_param) {
-    const SliderTable *table = _glgsg->_data_reader->get_slider_table();
-    update_slider_table(table);
-  }
-
-  cg_report_errors();
-  _glgsg->report_my_gl_errors();
-
-  return true;
-}
-
-/**
- * Disable all the texture bindings used by this shader.
- */
-void CLP(CgShaderContext)::
-disable_shader_texture_bindings() {
-  if (!valid()) {
-    return;
-  }
-
-  for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) {
-    CGparameter p = _cg_parameter_map[_shader->_tex_spec[i]._id._location];
-    if (p == 0) continue;
-
-    int texunit = cgGetParameterResourceIndex(p);
-    _glgsg->set_active_texture_stage(texunit);
-
-    glBindTexture(GL_TEXTURE_1D, 0);
-    glBindTexture(GL_TEXTURE_2D, 0);
-    if (_glgsg->_supports_3d_texture) {
-      glBindTexture(GL_TEXTURE_3D, 0);
-    }
-    if (_glgsg->_supports_2d_texture_array) {
-      glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, 0);
-    }
-    if (_glgsg->_supports_cube_map) {
-      glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
-    }
-    // This is probably faster - but maybe not as safe?
-    // cgGLDisableTextureParameter(p);
-  }
-
-  cg_report_errors();
-  _glgsg->report_my_gl_errors();
-}
-
-/**
- * Disables all texture bindings used by the previous shader, then enables all
- * the texture bindings needed by this shader.  Extracts the relevant vertex
- * array data from the gsg.  The current implementation is inefficient,
- * because it may unnecessarily disable textures then immediately reenable
- * them.  We may optimize this someday.
- */
-void CLP(CgShaderContext)::
-update_shader_texture_bindings(ShaderContext *prev) {
-  // if (prev) { prev->disable_shader_texture_bindings(); }
-
-  if (!valid()) {
-    return;
-  }
-
-  // We get the TextureAttrib directly from the _target_rs, not the filtered
-  // TextureAttrib in _target_texture.
-  const TextureAttrib *texattrib;
-  _glgsg->_target_rs->get_attrib_def(texattrib);
-
-  for (int i = 0; i < (int)_shader->_tex_spec.size(); ++i) {
-    Shader::ShaderTexSpec &spec = _shader->_tex_spec[i];
-
-    CGparameter p = _cg_parameter_map[spec._id._location];
-    if (p == 0) {
-      continue;
-    }
-    int texunit = cgGetParameterResourceIndex(p);
-    int view = _glgsg->get_current_tex_view_offset();
-    SamplerState sampler;
-
-    PT(Texture) tex = _glgsg->fetch_specified_texture(spec, sampler, view);
-    if (tex.is_null()) {
-      // Apply a white texture in order to make it easier to use a shader that
-      // takes a texture on a model that doesn't have a texture applied.
-      _glgsg->apply_white_texture(i);
-      continue;
-    }
-
-    if (spec._suffix != 0) {
-      // The suffix feature is inefficient.  It is a temporary hack.
-      if (tex == 0) {
-        continue;
-      }
-      tex = tex->load_related(spec._suffix);
-    }
-    if ((tex == 0) || (tex->get_texture_type() != spec._desired_type)) {
-      continue;
-    }
-
-    _glgsg->set_active_texture_stage(texunit);
-
-    TextureContext *tc = tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg);
-    if (tc == nullptr) {
-      continue;
-    }
-
-    GLenum target = _glgsg->get_texture_target(tex->get_texture_type());
-    if (target == GL_NONE) {
-      // Unsupported texture mode.
-      continue;
-    }
-
-    if (!_glgsg->update_texture(tc, false)) {
-      continue;
-    }
-
-    CLP(TextureContext) *gtc = (CLP(TextureContext) *)tc;
-    _glgsg->apply_texture(gtc);
-    _glgsg->apply_sampler(texunit, sampler, gtc);
-  }
-
-  cg_report_errors();
-  _glgsg->report_my_gl_errors();
-}
-
-#endif  // !OPENGLES

+ 0 - 111
panda/src/glstuff/glCgShaderContext_src.h

@@ -1,111 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file glCgShaderContext_src.h
- * @author jyelon
- * @date 2005-09-01
- */
-
-#if defined(HAVE_CG) && !defined(OPENGLES)
-
-#include "pandabase.h"
-#include "string_utils.h"
-#include "internalName.h"
-#include "shader.h"
-#include "shaderContext.h"
-#include "deletedChain.h"
-
-class CLP(GraphicsStateGuardian);
-
-/**
- * xyz
- */
-class EXPCL_GL CLP(CgShaderContext) final : public ShaderContext {
-public:
-  friend class CLP(GraphicsStateGuardian);
-
-  CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s);
-  ~CLP(CgShaderContext)();
-  ALLOC_DELETED_CHAIN(CLP(CgShaderContext));
-
-  bool valid(void) override;
-  void bind() override;
-  void unbind() override;
-
-  void set_state_and_transform(const RenderState *state,
-                               const TransformState *modelview_transform,
-                               const TransformState *camera_transform,
-                               const TransformState *projection_transform) override;
-
-  void issue_parameters(int altered) override;
-  void update_transform_table(const TransformTable *table);
-  void update_slider_table(const SliderTable *table);
-  void disable_shader_vertex_arrays() override;
-  bool update_shader_vertex_arrays(ShaderContext *prev, bool force) override;
-  void disable_shader_texture_bindings() override;
-  void update_shader_texture_bindings(ShaderContext *prev) override;
-
-  bool uses_standard_vertex_arrays(void) override { return false; }
-  bool uses_custom_vertex_arrays(void) override { return true; }
-
-  // Special values for location to indicate conventional attrib slots.
-  enum ConventionalAttrib {
-    CA_unknown = -1,
-    CA_vertex = -2,
-    CA_normal = -3,
-    CA_color = -4,
-    CA_secondary_color = -5,
-    CA_texcoord = -32,
-  };
-
-private:
-  CGprogram _cg_program;
-  GLuint _glsl_program;
-
-  pvector<GLint> _attributes;
-  BitMask32 _used_generic_attribs;
-  GLint _color_attrib_index;
-  CGparameter _transform_table_param;
-  CGparameter _slider_table_param;
-  long _transform_table_size;
-  long _slider_table_size;
-
-  LMatrix4 *_mat_part_cache = nullptr;
-  pvector<CGparameter> _cg_parameter_map;
-
-  WCPT(RenderState) _state_rs;
-  CPT(TransformState) _modelview_transform;
-  CPT(TransformState) _camera_transform;
-  CPT(TransformState) _projection_transform;
-  GLint _frame_number;
-
-  CLP(GraphicsStateGuardian) *_glgsg;
-
-  void release_resources();
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    ShaderContext::init_type();
-    register_type(_type_handle, CLASSPREFIX_QUOTED "CgShaderContext",
-                  ShaderContext::get_class_type());
-  }
-  virtual TypeHandle get_type() const override {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() override {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#include "glCgShaderContext_src.I"
-
-#endif  // OPENGLES_1

+ 0 - 65
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -67,10 +67,6 @@
 #include "samplerState.h"
 #include "displayInformation.h"
 
-#if defined(HAVE_CG) && !defined(OPENGLES)
-#include <Cg/cgGL.h>
-#endif
-
 #include <algorithm>
 
 using std::dec;
@@ -510,10 +506,6 @@ CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) :
   _shader_point_size = false;
 #endif
 
-#ifdef HAVE_CG
-  _cg_context = 0;
-#endif
-
 #ifdef DO_PSTATS
   if (gl_finish) {
     GLCAT.warning()
@@ -1841,19 +1833,6 @@ reset() {
 
   _supports_basic_shaders = _supports_glsl;
 
-#if defined(HAVE_CG) && !defined(OPENGLES)
-  if (_supports_glsl) {
-    _shader_caps._active_vprofile = (int)CG_PROFILE_GLSLV;
-    _shader_caps._active_fprofile = (int)CG_PROFILE_GLSLF;
-    if (get_supports_geometry_shaders()) {
-      _shader_caps._active_gprofile = (int)CG_PROFILE_GLSLG;
-    }
-    _shader_caps._ultimate_vprofile = (int)CG_PROFILE_GLSLV;
-    _shader_caps._ultimate_fprofile = (int)CG_PROFILE_GLSLF;
-    _shader_caps._ultimate_gprofile = (int)CG_PROFILE_GLSLG;
-  }
-#endif  // HAVE_CG
-
 #ifndef OPENGLES_1
 #ifdef OPENGLES
   if (is_at_least_gles_version(3, 1)) {
@@ -4489,13 +4468,6 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
             disable_standard_vertex_arrays();
           }
         }
-#ifdef HAVE_CG
-        else if (_vertex_array_shader_context->is_of_type(CLP(CgShaderContext)::get_class_type())) {
-          // The previous shader was a Cg shader, which can leave a messy
-          // situation.
-          _vertex_array_shader_context->disable_shader_vertex_arrays();
-        }
-#endif
       }
 #endif  // SUPPORT_FIXED_FUNCTION
       // Now update the vertex arrays for the current shader.
@@ -6296,11 +6268,6 @@ release_shader(ShaderContext *sc) {
   if (sc->is_of_type(CLP(ShaderContext)::get_class_type())) {
     ((CLP(ShaderContext) *)sc)->release_resources();
   }
-#if defined(HAVE_CG) && !defined(OPENGLES_2)
-  else if (sc->is_of_type(CLP(CgShaderContext)::get_class_type())) {
-    ((CLP(CgShaderContext) *)sc)->release_resources();
-  }
-#endif
 #endif
 
   delete sc;
@@ -11691,19 +11658,6 @@ set_state_and_transform(const RenderState *target,
   report_my_gl_errors();
 }
 
-/**
- * Frees some memory that was explicitly allocated within the glgsg.
- */
-void CLP(GraphicsStateGuardian)::
-free_pointers() {
-#if defined(HAVE_CG) && !defined(OPENGLES)
-  if (_cg_context != 0) {
-    cgDestroyContext(_cg_context);
-    _cg_context = 0;
-  }
-#endif
-}
-
 /**
  * This is called by set_state_and_transform() when the texture state has
  * changed.
@@ -14725,25 +14679,6 @@ do_point_size() {
 }
 #endif
 
-/**
- * Returns true if this particular GSG supports the specified Cg Shader
- * Profile.
- */
-bool CLP(GraphicsStateGuardian)::
-get_supports_cg_profile(const string &name) const {
-#if !defined(HAVE_CG) || defined(OPENGLES)
-  return false;
-#else
-  CGprofile profile = cgGetProfile(name.c_str());
-
-  if (profile == CG_PROFILE_UNKNOWN) {
-    GLCAT.error() << name << ", unknown Cg-profile\n";
-    return false;
-  }
-  return (cgGLIsProfileSupported(profile) != 0);
-#endif
-}
-
 /**
  * Binds a framebuffer object.
  */

+ 0 - 8
panda/src/glstuff/glGraphicsStateGuardian_src.h

@@ -436,7 +436,6 @@ public:
                                        const TransformState *transform);
 
   void bind_fbo(GLuint fbo);
-  virtual bool get_supports_cg_profile(const std::string &name) const;
   void finish();
 
 protected:
@@ -508,8 +507,6 @@ protected:
   virtual void end_bind_clip_planes();
 #endif
 
-  virtual void free_pointers();
-
 #ifndef OPENGLES_1
   INLINE void enable_vertex_attrib_array(GLuint index);
   INLINE void disable_vertex_attrib_array(GLuint index);
@@ -693,10 +690,6 @@ protected:
 
   GLfloat _max_line_width;
 
-#ifdef HAVE_CG
-  CGcontext _cg_context;
-#endif
-
 #ifdef SUPPORT_IMMEDIATE_MODE
   CLP(ImmediateModeSender) _sender;
   bool _use_sender;
@@ -1168,7 +1161,6 @@ private:
   friend class CLP(IndexBufferContext);
   friend class CLP(BufferContext);
   friend class CLP(ShaderContext);
-  friend class CLP(CgShaderContext);
   friend class CLP(GraphicsBuffer);
   friend class CLP(OcclusionQueryContext);
   friend class CLP(TimerQueryContext);

+ 0 - 3
panda/src/glstuff/glmisc_src.cxx

@@ -344,9 +344,6 @@ void CLP(init_classes)() {
   CLP(IndexBufferContext)::init_type();
 #ifndef OPENGLES_1
   CLP(ShaderContext)::init_type();
-#endif
-#if defined(HAVE_CG) && !defined(OPENGLES)
-  CLP(CgShaderContext)::init_type();
 #endif
   CLP(TextureContext)::init_type();
 #ifndef OPENGLES

+ 0 - 1
panda/src/glstuff/glstuff_src.cxx

@@ -28,7 +28,6 @@
 #include "glGeomContext_src.cxx"
 #include "glGeomMunger_src.cxx"
 #include "glShaderContext_src.cxx"
-#include "glCgShaderContext_src.cxx"
 #include "glImmediateModeSender_src.cxx"
 #include "glGraphicsBuffer_src.cxx"
 #include "glGraphicsStateGuardian_src.cxx"

+ 0 - 1
panda/src/glstuff/glstuff_src.h

@@ -40,7 +40,6 @@
 #include "glGeomContext_src.h"
 #include "glGeomMunger_src.h"
 #include "glShaderContext_src.h"
-#include "glCgShaderContext_src.h"
 #include "glImmediateModeSender_src.h"
 #include "glGraphicsBuffer_src.h"
 #include "glGraphicsStateGuardian_src.h"

+ 1 - 1
panda/src/gobj/CMakeLists.txt

@@ -177,7 +177,7 @@ composite_sources(p3gobj P3GOBJ_SOURCES)
 add_component_library(p3gobj NOINIT SYMBOL BUILDING_PANDA_GOBJ
   ${P3GOBJ_HEADERS} ${P3GOBJ_SOURCES})
 target_link_libraries(p3gobj p3gsgbase p3pnmimage
-  PKG::ZLIB PKG::SQUISH PKG::CG)
+  PKG::ZLIB PKG::SQUISH)
 target_interrogate(p3gobj ALL EXTENSIONS ${P3GOBJ_IGATEEXT})
 
 if(HAVE_SQUISH)

+ 0 - 16
panda/src/gobj/config_gobj.cxx

@@ -513,22 +513,6 @@ ConfigVariableBool stereo_lens_old_convergence
           "old, incorrect behavior, this may be set to 'true' to switch "
           "back to the old calculation."));
 
-ConfigVariableBool basic_shaders_only
-("basic-shaders-only", false,
- PRC_DESC("Set this to true if you aren't interested in shader model three "
-          "and beyond.  Setting this flag will cause panda to disable "
-          "bleeding-edge shader functionality which tends to be unreliable "
-          "or broken.  At some point, when functionality that is currently "
-          "flaky becomes reliable, we may expand the definition of what "
-          "constitutes 'basic' shaders."));
-
-ConfigVariableString cg_glsl_version
-("cg-glsl-version", "",
- PRC_DESC("If this is set, it forces the Cg compiler to generate GLSL "
-          "code conforming to the given GLSL version when using the "
-          "glslv, glslf or glslg profiles.  Use this when you are having "
-          "problems with these profiles.  Example values are 120 or 150."));
-
 ConfigVariableBool glsl_preprocess
 ("glsl-preprocess", true,
  PRC_DESC("If this is enabled, Panda looks for lines starting with "

+ 0 - 2
panda/src/gobj/config_gobj.h

@@ -87,8 +87,6 @@ extern EXPCL_PANDA_GOBJ ConfigVariableDouble async_load_delay;
 extern EXPCL_PANDA_GOBJ ConfigVariableInt lens_geom_segments;
 extern EXPCL_PANDA_GOBJ ConfigVariableBool stereo_lens_old_convergence;
 
-extern EXPCL_PANDA_GOBJ ConfigVariableBool basic_shaders_only;
-extern EXPCL_PANDA_GOBJ ConfigVariableString cg_glsl_version;
 extern EXPCL_PANDA_GOBJ ConfigVariableBool glsl_preprocess;
 extern EXPCL_PANDA_GOBJ ConfigVariableInt glsl_include_recursion_limit;
 

+ 0 - 26
panda/src/gobj/shader.I

@@ -221,32 +221,6 @@ set_cache_compiled_shader(bool flag) {
   _cache_compiled_shader = flag;
 }
 
-/**
- *
- */
-INLINE Shader::ShaderCaps::
-ShaderCaps() {
-  clear();
-}
-
-/**
- *
- */
-INLINE bool Shader::ShaderCaps::
-operator == (const ShaderCaps &other) const {
-#ifdef HAVE_CG
-  if ((_active_vprofile != other._active_vprofile) ||
-      (_active_fprofile != other._active_fprofile) ||
-      (_active_gprofile != other._active_gprofile) ||
-      (_ultimate_vprofile != other._ultimate_vprofile) ||
-      (_ultimate_fprofile != other._ultimate_fprofile) ||
-      (_ultimate_gprofile != other._ultimate_gprofile)) {
-     return false;
-  }
-#endif
-  return true;
-}
-
 /**
  *
  */

+ 14 - 863
panda/src/gobj/shader.cxx

@@ -25,11 +25,6 @@
 #include "shaderModuleGlsl.h"
 #include "shaderCompilerRegistry.h"
 #include "shaderCompiler.h"
-#include "shaderCompilerCg.h"
-
-#ifdef HAVE_CG
-#include <Cg/cg.h>
-#endif
 
 using std::istream;
 using std::move;
@@ -40,14 +35,8 @@ using std::string;
 TypeHandle Shader::_type_handle;
 Shader::ShaderTable Shader::_load_table;
 Shader::ShaderTable Shader::_make_table;
-Shader::ShaderCaps Shader::_default_caps;
 int Shader::_shaders_generated;
 
-#ifdef HAVE_CG
-CGcontext Shader::_cg_context = 0;
-
-#endif
-
 /**
  * Determine whether the source file hints at being a Cg shader
  */
@@ -57,6 +46,20 @@ static bool has_cg_header(const std::string &shader_text) {
   return search_str.rfind("//Cg") != std::string::npos;
 }
 
+/**
+ * Construct a Shader that will be filled in using fillin() or read() later.
+ */
+Shader::
+Shader(ShaderLanguage lang) :
+  _error_flag(false),
+  _parse(0),
+  _loaded(false),
+  _language(lang),
+  _mat_deps(0),
+  _cache_compiled_shader(false)
+{
+}
+
 /**
  * Generate an error message including a description of the specified
  * parameter.  Always returns false.
@@ -568,824 +571,6 @@ get_compiled(unsigned int &format, string &binary) const {
   return !binary.empty();
 }
 
-/**
- * Called by the graphics back-end to specify the caps with which we will
- * likely want to be compiling our shaders.
- */
-void Shader::
-set_default_caps(const ShaderCaps &caps) {
-  _default_caps = caps;
-}
-
-#ifdef HAVE_CG
-/**
- *
- */
-::ShaderType::ScalarType Shader::
-cg_scalar_type(int type) {
-  switch (type) {
-  case CG_UINT:
-  case CG_ULONG:
-  case CG_USHORT:
-  case CG_UCHAR:
-    return ScalarType::ST_uint;
-
-  case CG_BOOL:
-    return ScalarType::ST_bool;
-
-  case CG_INT:
-  case CG_LONG:
-  case CG_SHORT:
-  case CG_CHAR:
-    return ScalarType::ST_int;
-
-  default:
-    return ScalarType::ST_float;
-  }
-  return ScalarType::ST_unknown;
-}
-
-/**
- *
- */
-const ::ShaderType *Shader::
-cg_parameter_type(CGparameter p) {
-  switch (cgGetParameterClass(p)) {
-  case CG_PARAMETERCLASS_SCALAR:
-    return ::ShaderType::register_type(::ShaderType::Scalar(
-      cg_scalar_type(cgGetParameterBaseType(p))));
-
-  case CG_PARAMETERCLASS_VECTOR:
-    return ::ShaderType::register_type(::ShaderType::Vector(
-      cg_scalar_type(cgGetParameterBaseType(p)),
-      cgGetParameterColumns(p)));
-
-  case CG_PARAMETERCLASS_MATRIX:
-    return ::ShaderType::register_type(::ShaderType::Matrix(
-      cg_scalar_type(cgGetParameterBaseType(p)),
-      cgGetParameterRows(p),
-      cgGetParameterColumns(p)));
-
-  case CG_PARAMETERCLASS_STRUCT:
-    {
-      ::ShaderType::Struct type;
-      CGparameter member = cgGetFirstStructParameter(p);
-      while (member) {
-        type.add_member(
-          cg_parameter_type(member),
-          cgGetParameterName(p)
-        );
-        member = cgGetNextParameter(member);
-      }
-      return ::ShaderType::register_type(std::move(type));
-    }
-
-  case CG_PARAMETERCLASS_ARRAY:
-    return ::ShaderType::register_type(::ShaderType::Array(
-      cg_parameter_type(cgGetArrayParameter(p, 0)),
-      cgGetArraySize(p, 0)));
-
-  case CG_PARAMETERCLASS_SAMPLER:
-    {
-      Texture::TextureType texture_type;
-      switch (cgGetParameterType(p)) {
-      case CG_SAMPLER1D:
-      case 1313: // CG_SAMPLER1DSHADOW
-        texture_type = Texture::TT_1d_texture;
-        break;
-      case CG_SAMPLER2D:
-      case 1314: // CG_SAMPLER2DSHADOW
-        texture_type = Texture::TT_2d_texture;
-        break;
-      case CG_SAMPLER3D:
-        texture_type = Texture::TT_3d_texture;
-        break;
-      case CG_SAMPLER2DARRAY:
-        texture_type = Texture::TT_2d_texture_array;
-        break;
-      case CG_SAMPLERCUBE:
-        texture_type = Texture::TT_cube_map;
-        break;
-      case CG_SAMPLERBUF:
-        texture_type = Texture::TT_buffer_texture;
-        break;
-      case CG_SAMPLERCUBEARRAY:
-        texture_type = Texture::TT_cube_map_array;
-        break;
-      default:
-        return nullptr;
-      }
-      return ::ShaderType::register_type(::ShaderType::SampledImage(texture_type, ::ShaderType::ST_float));
-    }
-
-  default:
-    break;
-  }
-
-  return nullptr;
-}
-
-/**
- * xyz
- */
-void Shader::
-cg_release_resources() {
-  if (_cg_vprogram != 0) {
-    cgDestroyProgram(_cg_vprogram);
-    _cg_vprogram = 0;
-  }
-  if (_cg_fprogram != 0) {
-    cgDestroyProgram(_cg_fprogram);
-    _cg_fprogram = 0;
-  }
-  if (_cg_gprogram != 0) {
-    cgDestroyProgram(_cg_gprogram);
-    _cg_gprogram = 0;
-  }
-}
-
-/**
- * xyz
- */
-CGprogram Shader::
-cg_compile_entry_point(const char *entry, const ShaderCaps &caps,
-                       CGcontext context, ShaderType type) {
-  CGprogram prog;
-  CGerror err;
-  const char *compiler_args[100];
-  const string text = get_text(type);
-  int nargs = 0;
-
-  int active, ultimate;
-
-  switch (type) {
-  case ST_vertex:
-    active   = caps._active_vprofile;
-    ultimate = caps._ultimate_vprofile;
-    break;
-
-  case ST_fragment:
-    active   = caps._active_fprofile;
-    ultimate = caps._ultimate_fprofile;
-    break;
-
-  case ST_geometry:
-    active   = caps._active_gprofile;
-    ultimate = caps._ultimate_gprofile;
-    break;
-
-  case ST_tess_evaluation:
-  case ST_tess_control:
-    active   = caps._active_tprofile;
-    ultimate = caps._ultimate_tprofile;
-    break;
-
-  case ST_none:
-  default:
-    active   = CG_PROFILE_UNKNOWN;
-    ultimate = CG_PROFILE_UNKNOWN;
-  };
-
-  if (type == ST_fragment && caps._bug_list.count(SBUG_ati_draw_buffers)) {
-    compiler_args[nargs++] = "-po";
-    compiler_args[nargs++] = "ATI_draw_buffers";
-  }
-
-  string version_arg;
-  if (!cg_glsl_version.empty() && active != CG_PROFILE_UNKNOWN &&
-      cgGetProfileProperty((CGprofile) active, CG_IS_GLSL_PROFILE)) {
-
-    version_arg = "version=";
-    version_arg += cg_glsl_version;
-
-    compiler_args[nargs++] = "-po";
-    compiler_args[nargs++] = version_arg.c_str();
-  }
-
-  compiler_args[nargs] = 0;
-
-  cgGetError();
-
-  if ((active != (int)CG_PROFILE_UNKNOWN) && (active != ultimate)) {
-    // Print out some debug information about what we're doing.
-    if (shader_cat.is_debug()) {
-      shader_cat.debug()
-        << "Compiling Cg shader " << get_filename(type) << " with entry point " << entry
-        << " and active profile " << cgGetProfileString((CGprofile) active) << "\n";
-
-      if (nargs > 0) {
-        shader_cat.debug() << "Using compiler arguments:";
-        for (int i = 0; i < nargs; ++i) {
-          shader_cat.debug(false) << " " << compiler_args[i];
-        }
-        shader_cat.debug(false) << "\n";
-      }
-    }
-
-    // Compile the shader with the active profile.
-    prog = cgCreateProgram(context, CG_SOURCE, text.c_str(),
-                           (CGprofile)active, entry, (const char **)compiler_args);
-    err = cgGetError();
-    if (err == CG_NO_ERROR) {
-      return prog;
-    }
-    if (prog != 0) {
-      cgDestroyProgram(prog);
-    }
-    if (shader_cat.is_debug()) {
-      shader_cat.debug()
-        << "Compilation with active profile failed: " << cgGetErrorString(err) << "\n";
-      if (err == CG_COMPILER_ERROR) {
-        const char *listing = cgGetLastListing(context);
-        if (listing != nullptr) {
-          shader_cat.debug(false) << listing;
-        }
-      }
-    }
-  }
-
-  if (shader_cat.is_debug()) {
-    shader_cat.debug()
-      << "Compiling Cg shader " << get_filename(type) << " with entry point " << entry
-      << " and ultimate profile " << cgGetProfileString((CGprofile) ultimate) << "\n";
-  }
-
-  // The active profile failed, so recompile it with the ultimate profile.
-  prog = cgCreateProgram(context, CG_SOURCE, text.c_str(),
-                         (CGprofile)ultimate, entry, nullptr);
-
-  // Extract the output listing.
-  err = cgGetError();
-  const char *listing = cgGetLastListing(context);
-
-  if (err == CG_NO_ERROR && listing != nullptr && strlen(listing) > 1) {
-    shader_cat.warning()
-      << "Encountered warnings during compilation of " << get_filename(type)
-      << ":\n" << listing;
-
-  } else if (err == CG_COMPILER_ERROR) {
-    shader_cat.error()
-      << "Failed to compile Cg shader " << get_filename(type);
-    if (listing != nullptr) {
-      shader_cat.error(false) << ":\n" << listing;
-    } else {
-      shader_cat.error(false) << "!\n";
-    }
-  }
-
-  if (err == CG_NO_ERROR) {
-    return prog;
-  }
-
-  if (shader_cat.is_debug()) {
-    shader_cat.debug()
-      << "Compilation with ultimate profile failed: " << cgGetErrorString(err) << "\n";
-  }
-
-  if (prog != 0) {
-    cgDestroyProgram(prog);
-  }
-  return 0;
-}
-
-/**
- * Compiles a Cg shader for a given set of capabilities.  If successful, the
- * shader is stored in the instance variables _cg_context, _cg_vprogram,
- * _cg_fprogram.
- */
-bool Shader::
-cg_compile_shader(const ShaderCaps &caps, CGcontext context) {
-  _cg_last_caps = caps;
-
-  if (!_text._separate || !_text._vertex.empty()) {
-    _cg_vprogram = cg_compile_entry_point("vshader", caps, context, ST_vertex);
-    if (_cg_vprogram == 0) {
-      cg_release_resources();
-      return false;
-    }
-    _cg_vprofile = cgGetProgramProfile(_cg_vprogram);
-  }
-
-  if (!_text._separate || !_text._fragment.empty()) {
-    _cg_fprogram = cg_compile_entry_point("fshader", caps, context, ST_fragment);
-    if (_cg_fprogram == 0) {
-      cg_release_resources();
-      return false;
-    }
-    _cg_fprofile = cgGetProgramProfile(_cg_fprogram);
-  }
-
-  if ((_text._separate && !_text._geometry.empty()) || (!_text._separate && _text._shared.find("gshader") != string::npos)) {
-    _cg_gprogram = cg_compile_entry_point("gshader", caps, context, ST_geometry);
-    if (_cg_gprogram == 0) {
-      cg_release_resources();
-      return false;
-    }
-    _cg_gprofile = cgGetProgramProfile(_cg_gprogram);
-  }
-
-  if (_cg_vprogram == 0 && _cg_fprogram == 0 && _cg_gprogram == 0) {
-    shader_cat.error() << "Shader must at least have one program!\n";
-    cg_release_resources();
-    return false;
-  }
-
-  // This is present to work around a bug in the Cg compiler for Direct3D 9.
-  // It generates "texld_sat" instructions that the result in an
-  // D3DXERR_INVALIDDATA error when trying to load the shader, since the _sat
-  // modifier may not be used on tex* instructions.
-  if (_cg_fprofile == CG_PROFILE_PS_2_0 ||
-      _cg_fprofile == CG_PROFILE_PS_2_X ||
-      _cg_fprofile == CG_PROFILE_PS_3_0) {
-    vector_string lines;
-    tokenize(cgGetProgramString(_cg_fprogram, CG_COMPILED_PROGRAM), lines, "\n");
-
-    ostringstream out;
-    int num_modified = 0;
-
-    for (size_t i = 0; i < lines.size(); ++i) {
-      const string &line = lines[i];
-
-      size_t space = line.find(' ');
-      if (space == string::npos) {
-        out << line << '\n';
-        continue;
-      }
-
-      string instr = line.substr(0, space);
-
-      // Look for a texld instruction with _sat modifier.
-      if (instr.compare(0, 5, "texld") == 0 &&
-          instr.compare(instr.size() - 4, 4, "_sat") == 0) {
-        // Which destination register are we operating on?
-        string reg = line.substr(space + 1, line.find(',', space) - space - 1);
-
-        // Move the saturation operation to a separate instruction.
-        instr.resize(instr.size() - 4);
-        out << instr << ' ' << line.substr(space + 1) << '\n';
-        out << "mov_sat " << reg << ", " << reg << '\n';
-        ++num_modified;
-      } else {
-        out << line << '\n';
-      }
-    }
-
-    if (num_modified > 0) {
-      string result = out.str();
-      CGprogram new_program;
-      new_program = cgCreateProgram(context, CG_OBJECT, result.c_str(),
-                                    (CGprofile)_cg_fprofile, "fshader",
-                                    nullptr);
-      if (new_program) {
-        cgDestroyProgram(_cg_fprogram);
-        _cg_fprogram = new_program;
-
-        if (shader_cat.is_debug()) {
-          shader_cat.debug()
-            << "Replaced " << num_modified << " invalid texld_sat instruction"
-            << ((num_modified == 1) ? "" : "s") << " in compiled shader\n";
-        }
-      } else {
-        shader_cat.warning()
-          << "Failed to load shader with fixed texld_sat instructions: "
-          << cgGetErrorString(cgGetError()) << "\n";
-      }
-    }
-  }
-
-  // DEBUG: output the generated program
-  if (shader_cat.is_debug()) {
-    const char *vertex_program;
-    const char *fragment_program;
-    const char *geometry_program;
-
-    if (_cg_vprogram != 0) {
-      shader_cat.debug()
-        << "Cg vertex profile: " << cgGetProfileString((CGprofile)_cg_vprofile) << "\n";
-      vertex_program = cgGetProgramString(_cg_vprogram, CG_COMPILED_PROGRAM);
-      shader_cat.spam() << vertex_program << "\n";
-    }
-    if (_cg_fprogram != 0) {
-      shader_cat.debug()
-        << "Cg fragment profile: " << cgGetProfileString((CGprofile)_cg_fprofile) << "\n";
-      fragment_program = cgGetProgramString(_cg_fprogram, CG_COMPILED_PROGRAM);
-      shader_cat.spam() << fragment_program << "\n";
-    }
-    if (_cg_gprogram != 0) {
-      shader_cat.debug()
-        << "Cg geometry profile: " << cgGetProfileString((CGprofile)_cg_gprofile) << "\n";
-      geometry_program = cgGetProgramString(_cg_gprogram, CG_COMPILED_PROGRAM);
-      shader_cat.spam() << geometry_program << "\n";
-    }
-  }
-
-  return true;
-}
-
-/**
- *
- */
-bool Shader::
-cg_analyze_entry_point(CGprogram prog, ShaderType type) {
-  bool success = true;
-
-  CGparameter parameter = cgGetFirstParameter(prog, CG_PROGRAM);
-  while (parameter) {
-    if (cgIsParameterReferenced(parameter)) {
-      const ::ShaderType *arg_type = cg_parameter_type(parameter);
-
-      CGenum vbl = cgGetParameterVariability(parameter);
-
-      if (cgGetParameterDirection(parameter) == CG_IN) {
-        CPT(InternalName) name = InternalName::make(cgGetParameterName(parameter));
-
-        if (vbl == CG_VARYING && type == ST_vertex) {
-          success &= bind_vertex_input(name, arg_type, -1);
-        }
-        else if (vbl == CG_UNIFORM) {
-          Parameter param;
-          param._name = name;
-          param._type = arg_type;
-          success &= bind_parameter(param);
-        }
-      }
-    } else if (shader_cat.is_debug()) {
-      shader_cat.debug()
-        << "Parameter " << cgGetParameterName(parameter)
-        << " is unreferenced within shader " << get_filename(type) << "\n";
-    }
-
-    parameter = cgGetNextParameter(parameter);
-  }
-
-  return success;
-}
-
-/**
- * This subroutine analyzes the parameters of a Cg shader.  The output is
- * stored in instance variables: _mat_spec, _var_spec, and _tex_spec.
- *
- * In order to do this, it is necessary to compile the shader.  It would be a
- * waste of CPU time to compile the shader, analyze the parameters, and then
- * discard the compiled shader.  This would force us to compile it again
- * later, when we need to build the ShaderContext.  Instead, we cache the
- * compiled Cg program in instance variables.  Later, a ShaderContext can pull
- * the compiled shader from these instance vars.
- *
- * To compile a shader, you need to first choose a profile.  There are two
- * contradictory objectives:
- *
- * 1. If you don't use the gsg's active profile, then the cached compiled
- * shader will not be useful to the ShaderContext.
- *
- * 2. If you use too weak a profile, then the shader may not compile.  So to
- * guarantee success, you should use the ultimate profile.
- *
- * To resolve this conflict, we try the active profile first, and if that
- * doesn't work, we try the ultimate profile.
- *
- */
-bool Shader::
-cg_analyze_shader(const ShaderCaps &caps) {
-
-  // Make sure we have a context for analyzing the shader.
-  if (_cg_context == 0) {
-    _cg_context = cgCreateContext();
-    if (_cg_context == 0) {
-      shader_cat.error()
-        << "Could not create a Cg context object: "
-        << cgGetErrorString(cgGetError()) << "\n";
-      return false;
-    }
-  }
-
-  if (!cg_compile_shader(caps, _cg_context)) {
-    return false;
-  }
-
-  if (_cg_fprogram != 0) {
-     if (!cg_analyze_entry_point(_cg_fprogram, ST_fragment)) {
-      cg_release_resources();
-      clear_parameters();
-      return false;
-    }
-  }
-
-  if (_var_spec.size() != 0) {
-    shader_cat.error() << "Cannot use vtx parameters in an fshader\n";
-    cg_release_resources();
-    clear_parameters();
-    return false;
-  }
-
-  if (_cg_vprogram != 0) {
-    if (!cg_analyze_entry_point(_cg_vprogram, ST_vertex)) {
-      cg_release_resources();
-      clear_parameters();
-      return false;
-    }
-  }
-
-  if (_cg_gprogram != 0) {
-    if (!cg_analyze_entry_point(_cg_gprogram, ST_geometry)) {
-      cg_release_resources();
-      clear_parameters();
-      return false;
-    }
-  }
-
-  // Assign locations to all parameters.  GLCgShaderContext relies on the fact
-  // that the varyings start at location 0.
-  int location = 0;
-  for (size_t i = 0; i < _var_spec.size(); ++i) {
-    _var_spec[i]._id._location = location++;
-  }
-  for (size_t i = 0; i < _mat_spec.size(); ++i) {
-    _mat_spec[i]._id._location = location++;
-  }
-  for (size_t i = 0; i < _tex_spec.size(); ++i) {
-    _tex_spec[i]._id._location = location++;
-  }
-
-  for (size_t i = 0; i < _ptr_spec.size(); ++i) {
-    _ptr_spec[i]._id._location = location++;
-  }
-
-  /*
-  // The following code is present to work around a bug in the Cg compiler.
-  // It does not generate correct code for shadow map lookups when using arbfp1.
-  // This is a particularly onerous limitation, given that arbfp1 is the only
-  // Cg target that works on radeons.  I suspect this is an intentional
-  // omission on nvidia's part.  The following code fetches the output listing,
-  // detects the error, repairs the code, and resumbits the repaired code to Cg.
-  if ((_cg_fprofile == CG_PROFILE_ARBFP1) && (gsghint->_supports_shadow_filter)) {
-    bool shadowunit[32];
-    bool anyshadow = false;
-    memset(shadowunit, 0, sizeof(shadowunit));
-    vector_string lines;
-    tokenize(cgGetProgramString(_cg_program[SHADER_type_frag],
-                                CG_COMPILED_PROGRAM), lines, "\n");
-    // figure out which texture units contain shadow maps.
-    for (int lineno=0; lineno<(int)lines.size(); lineno++) {
-      if (lines[lineno].compare(0,21,"#var sampler2DSHADOW ")) {
-        continue;
-      }
-      vector_string fields;
-      tokenize(lines[lineno], fields, ":");
-      if (fields.size()!=5) {
-        continue;
-      }
-      vector_string words;
-      tokenize(trim(fields[2]), words, " ");
-      if (words.size()!=2) {
-        continue;
-      }
-      int unit = atoi(words[1].c_str());
-      if ((unit < 0)||(unit >= 32)) {
-        continue;
-      }
-      anyshadow = true;
-      shadowunit[unit] = true;
-    }
-    // modify all TEX statements that use the relevant texture units.
-    if (anyshadow) {
-      for (int lineno=0; lineno<(int)lines.size(); lineno++) {
-        if (lines[lineno].compare(0,4,"TEX ")) {
-          continue;
-        }
-        vector_string fields;
-        tokenize(lines[lineno], fields, ",");
-        if ((fields.size()!=4)||(trim(fields[3]) != "2D;")) {
-          continue;
-        }
-        vector_string texunitf;
-        tokenize(trim(fields[2]), texunitf, "[]");
-        if ((texunitf.size()!=3)||(texunitf[0] != "texture")||(texunitf[2]!="")) {
-          continue;
-        }
-        int unit = atoi(texunitf[1].c_str());
-        if ((unit < 0) || (unit >= 32) || (shadowunit[unit]==false)) {
-          continue;
-        }
-        lines[lineno] = fields[0]+","+fields[1]+","+fields[2]+", SHADOW2D;";
-      }
-      string result = "!!ARBfp1.0\nOPTION ARB_fragment_program_shadow;\n";
-      for (int lineno=1; lineno<(int)lines.size(); lineno++) {
-        result += (lines[lineno] + "\n");
-      }
-      _cg_program[2] = _cg_program[SHADER_type_frag];
-      _cg_program[SHADER_type_frag] =
-        cgCreateProgram(_cg_context, CG_OBJECT, result.c_str(),
-                        _cg_profile[SHADER_type_frag], "fshader", (const char**)NULL);
-      cg_report_errors(s->get_name(), _cg_context);
-      if (_cg_program[SHADER_type_frag]==0) {
-        release_resources();
-        return false;
-      }
-    }
-  }
-  */
-
-  cg_release_resources();
-  return true;
-}
-
-/**
- * This routine is used by the ShaderContext constructor to compile the
- * shader.  The CGprogram objects are turned over to the ShaderContext, we no
- * longer own them.
- */
-bool Shader::
-cg_compile_for(const ShaderCaps &caps, CGcontext context,
-               CGprogram &combined_program, pvector<CGparameter> &map) {
-
-  // Initialize the return values to empty.
-  combined_program = 0;
-  map.clear();
-
-  // Make sure the shader is compiled for the target caps.  Most of the time,
-  // it will already be - this is usually a no-op.
-
-  _default_caps = caps;
-  if (!cg_compile_shader(caps, context)) {
-    return false;
-  }
-
-  // If the compile routine used the ultimate profile instead of the active
-  // one, it means the active one isn't powerful enough to compile the shader.
-  if (_cg_vprogram != 0 && _cg_vprofile != caps._active_vprofile) {
-    shader_cat.error() << "Cg vertex program not supported by profile "
-      << cgGetProfileString((CGprofile) caps._active_vprofile) << ": "
-      << get_filename(ST_vertex) << ". Try choosing a different profile.\n";
-    return false;
-  }
-  if (_cg_fprogram != 0 && _cg_fprofile != caps._active_fprofile) {
-    shader_cat.error() << "Cg fragment program not supported by profile "
-      << cgGetProfileString((CGprofile) caps._active_fprofile) << ": "
-      << get_filename(ST_fragment) << ". Try choosing a different profile.\n";
-    return false;
-  }
-  if (_cg_gprogram != 0 && _cg_gprofile != caps._active_gprofile) {
-    shader_cat.error() << "Cg geometry program not supported by profile "
-      << cgGetProfileString((CGprofile) caps._active_gprofile) << ": "
-      << get_filename(ST_geometry) << ". Try choosing a different profile.\n";
-    return false;
-  }
-
-  // Gather the programs we will be combining.
-  pvector<CGprogram> programs;
-  if (_cg_vprogram != 0) {
-    programs.push_back(_cg_vprogram);
-  }
-  if (_cg_fprogram != 0) {
-    programs.push_back(_cg_fprogram);
-  }
-  if (_cg_gprogram != 0) {
-    programs.push_back(_cg_gprogram);
-  }
-
-  // Combine the programs.  This can be more optimal than loading them
-  // individually, and it is even necessary for some profiles (particularly
-  // GLSL profiles on non-NVIDIA GPUs).
-  combined_program = cgCombinePrograms(programs.size(), &programs[0]);
-
-  // Build a parameter map.
-  size_t n_mat = _mat_spec.size();
-  size_t n_tex = _tex_spec.size();
-  size_t n_var = _var_spec.size();
-  size_t n_ptr = _ptr_spec.size();
-
-  map.resize(n_mat + n_tex + n_var + n_ptr);
-
-  // This is a bit awkward, we have to go in and seperate out the combined
-  // program, since all the parameter bindings have changed.
-  CGprogram programs_by_type[ST_COUNT];
-  for (int i = 0; i < cgGetNumProgramDomains(combined_program); ++i) {
-    // Conveniently, the CGdomain enum overlaps with ShaderType.
-    CGprogram program = cgGetProgramDomainProgram(combined_program, i);
-    programs_by_type[cgGetProgramDomain(program)] = program;
-  }
-
-  /*for (size_t i = 0; i < n_mat; ++i) {
-    const Parameter &id = _mat_spec[i]._id;
-    map[id._location] = cgGetNamedParameter(programs_by_type[id._type], id._name.c_str());
-
-    if (shader_cat.is_debug()) {
-      const char *resource = cgGetParameterResourceName(map[id._location]);
-      if (resource != nullptr) {
-        shader_cat.debug() << "Uniform parameter " << id._name
-                           << " is bound to resource " << resource << "\n";
-      }
-    }
-  }
-
-  for (size_t i = 0; i < n_tex; ++i) {
-    const Parameter &id = _tex_spec[i]._id;
-    CGparameter p = cgGetNamedParameter(programs_by_type[id._type], id._name.c_str());
-
-    if (shader_cat.is_debug()) {
-      const char *resource = cgGetParameterResourceName(p);
-      if (resource != nullptr) {
-        shader_cat.debug() << "Texture parameter " << id._name
-                          << " is bound to resource " << resource << "\n";
-      }
-    }
-    map[id._location] = p;
-  }
-
-  for (size_t i = 0; i < n_var; ++i) {
-    const Parameter &id = _var_spec[i]._id;
-    CGparameter p = cgGetNamedParameter(programs_by_type[id._type], id._name.c_str());
-
-    const char *resource = cgGetParameterResourceName(p);
-    if (shader_cat.is_debug() && resource != nullptr) {
-      if (cgGetParameterResource(p) == CG_GLSL_ATTRIB) {
-        shader_cat.debug()
-          << "Varying parameter " << id._name << " is bound to GLSL attribute "
-          << resource << "\n";
-      } else {
-        shader_cat.debug()
-          << "Varying parameter " << id._name << " is bound to resource "
-          << resource << " (" << cgGetParameterResource(p)
-          << ", index " << cgGetParameterResourceIndex(p) << ")\n";
-      }
-    }
-
-    map[id._location] = p;
-  }
-
-  for (size_t i = 0; i < n_ptr; ++i) {
-    const Parameter &id = _ptr_spec[i]._id;
-    map[id._location] = cgGetNamedParameter(programs_by_type[id._type], id._name.c_str());
-
-    if (shader_cat.is_debug()) {
-      const char *resource = cgGetParameterResourceName(map[id._location]);
-      if (resource != nullptr) {
-        shader_cat.debug() << "Uniform ptr parameter " << id._name
-                           << " is bound to resource " << resource << "\n";
-      }
-    }
-  }*/
-
-  // Transfer ownership of the compiled shader.
-  if (_cg_vprogram != 0) {
-    cgDestroyProgram(_cg_vprogram);
-    _cg_vprogram = 0;
-  }
-  if (_cg_fprogram != 0) {
-    cgDestroyProgram(_cg_fprogram);
-    _cg_fprogram = 0;
-  }
-  if (_cg_gprogram != 0) {
-    cgDestroyProgram(_cg_gprogram);
-    _cg_gprogram = 0;
-  }
-
-  _cg_last_caps.clear();
-
-  return true;
-}
-#endif  // HAVE_CG
-
-/**
- * Construct a Shader that will be filled in using fillin() or read() later.
- */
-Shader::
-Shader(ShaderLanguage lang) :
-  _error_flag(false),
-  _parse(0),
-  _loaded(false),
-  _language(lang),
-  _mat_deps(0),
-  _cache_compiled_shader(false)
-{
-#ifdef HAVE_CG
-  _cg_vprogram = 0;
-  _cg_fprogram = 0;
-  _cg_gprogram = 0;
-  _cg_vprofile = CG_PROFILE_UNKNOWN;
-  _cg_fprofile = CG_PROFILE_UNKNOWN;
-  _cg_gprofile = CG_PROFILE_UNKNOWN;
-  if (_default_caps._ultimate_vprofile == 0 || _default_caps._ultimate_vprofile == CG_PROFILE_UNKNOWN) {
-    if (basic_shaders_only) {
-      _default_caps._active_vprofile = CG_PROFILE_ARBVP1;
-      _default_caps._active_fprofile = CG_PROFILE_ARBFP1;
-      _default_caps._active_gprofile = CG_PROFILE_UNKNOWN;
-    } else {
-      _default_caps._active_vprofile = CG_PROFILE_UNKNOWN;
-      _default_caps._active_fprofile = CG_PROFILE_UNKNOWN;
-      _default_caps._active_gprofile = CG_PROFILE_UNKNOWN;
-    }
-    _default_caps._ultimate_vprofile = cgGetProfile("glslv");
-    _default_caps._ultimate_fprofile = cgGetProfile("glslf");
-    _default_caps._ultimate_gprofile = cgGetProfile("glslg");
-    if (_default_caps._ultimate_gprofile == CG_PROFILE_UNKNOWN) {
-      _default_caps._ultimate_gprofile = cgGetProfile("gp4gp");
-    }
-  }
-#endif
-}
-
 /**
  * Reads the shader from the given filename(s). Returns a boolean indicating
  * success or failure.
@@ -1641,23 +826,6 @@ do_read_source(ShaderModule::Stage stage, std::istream &in,
     return false;
   }
 
-//  if (_language == SL_Cg) {
-//#ifdef HAVE_CG
-//    ShaderCompilerCg *cg_compiler = DCAST(ShaderCompilerCg, compiler);
-//    cg_compiler->get_profile_from_header(_text._shared, _default_caps);
-//
-//    if (!cg_analyze_shader(_default_caps)) {
-//      shader_cat.error()
-//        << "Shader encountered an error.\n";
-//      return false;
-//    }
-//#else
-//    shader_cat.error()
-//      << "Tried to load Cg shader, but no Cg support is enabled.\n";
-//    return false;
-//#endif
-//  }
-
   if (!source_filename.empty()) {
     module->set_source_filename(source_filename);
   }
@@ -3691,23 +2859,6 @@ release_all() {
   return num_freed;
 }
 
-/**
- *
- */
-void Shader::ShaderCaps::
-clear() {
-  _supports_glsl = false;
-
-#ifdef HAVE_CG
-  _active_vprofile = CG_PROFILE_UNKNOWN;
-  _active_fprofile = CG_PROFILE_UNKNOWN;
-  _active_gprofile = CG_PROFILE_UNKNOWN;
-  _ultimate_vprofile = CG_PROFILE_UNKNOWN;
-  _ultimate_fprofile = CG_PROFILE_UNKNOWN;
-  _ultimate_gprofile = CG_PROFILE_UNKNOWN;
-#endif
-}
-
 /**
  * Tells the BamReader how to create objects of type Shader.
  */

+ 4 - 68
panda/src/gobj/shader.h

@@ -38,14 +38,6 @@
 #include "shaderModule.h"
 #include "copyOnWritePointer.h"
 
-#ifdef HAVE_CG
-// I don't want to include the Cg header file into panda as a whole.  Instead,
-// I'll just excerpt some opaque declarations.
-typedef struct _CGcontext   *CGcontext;
-typedef struct _CGprogram   *CGprogram;
-typedef struct _CGparameter *CGparameter;
-#endif
-
 class BamCacheRecord;
 class ShaderModuleGlsl;
 class ShaderCompiler;
@@ -93,6 +85,10 @@ PUBLISHED:
     bit_AutoShaderShadow = 4, // bit for AS_shadow
   };
 
+private:
+  Shader(ShaderLanguage lang);
+
+PUBLISHED:
   static PT(Shader) load(const Filename &file, ShaderLanguage lang = SL_none);
   static PT(Shader) make(std::string body, ShaderLanguage lang = SL_none);
   static PT(Shader) load(ShaderLanguage lang,
@@ -415,30 +411,6 @@ public:
     ScalarType        _type;
   };
 
-  class EXPCL_PANDA_GOBJ ShaderCaps {
-  public:
-    void clear();
-    INLINE bool operator == (const ShaderCaps &other) const;
-    INLINE ShaderCaps();
-
-  public:
-    bool _supports_glsl;
-
-#ifdef HAVE_CG
-    int _active_vprofile;
-    int _active_fprofile;
-    int _active_gprofile;
-    int _active_tprofile;
-
-    int _ultimate_vprofile;
-    int _ultimate_fprofile;
-    int _ultimate_gprofile;
-    int _ultimate_tprofile;
-
-    pset <ShaderBug> _bug_list;
-#endif
-  };
-
   class ShaderFile : public ReferenceCount {
   public:
     INLINE ShaderFile() {};
@@ -483,42 +455,9 @@ public:
   void set_compiled(unsigned int format, const char *data, size_t length);
   bool get_compiled(unsigned int &format, std::string &binary) const;
 
-  static void set_default_caps(const ShaderCaps &caps);
-
   INLINE PStatCollector &get_prepare_shader_pcollector();
   INLINE const std::string &get_debug_name() const;
 
-private:
-#ifdef HAVE_CG
-  ScalarType cg_scalar_type(int type);
-  const ::ShaderType *cg_parameter_type(CGparameter p);
-
-  CGprogram cg_compile_entry_point(const char *entry, const ShaderCaps &caps,
-                                   CGcontext context, ShaderType type);
-
-  bool cg_analyze_entry_point(CGprogram prog, ShaderType type);
-
-  bool cg_analyze_shader(const ShaderCaps &caps);
-  bool cg_compile_shader(const ShaderCaps &caps, CGcontext context);
-  void cg_release_resources();
-  void cg_report_errors();
-
-  ShaderCaps _cg_last_caps;
-  static CGcontext  _cg_context;
-  CGprogram  _cg_vprogram;
-  CGprogram  _cg_fprogram;
-  CGprogram  _cg_gprogram;
-
-  int _cg_vprofile;
-  int _cg_fprofile;
-  int _cg_gprofile;
-
-public:
-  bool cg_compile_for(const ShaderCaps &caps, CGcontext context,
-                      CGprogram &combined_program, pvector<CGparameter> &map);
-
-#endif
-
 public:
   pvector<ShaderPtrSpec> _ptr_spec;
   epvector<ShaderMatSpec> _mat_spec;
@@ -551,7 +490,6 @@ protected:
   unsigned int _compiled_format;
   std::string _compiled_binary;
 
-  static ShaderCaps _default_caps;
   static int _shaders_generated;
 
   typedef pmap<ShaderFile, PT(Shader)> ShaderTable;
@@ -571,8 +509,6 @@ protected:
 private:
   void clear_prepared(PreparedGraphicsObjects *prepared_objects);
 
-  Shader(ShaderLanguage lang);
-
   bool read(const ShaderFile &sfile, BamCacheRecord *record = nullptr);
   bool load(const ShaderFile &sbody, BamCacheRecord *record = nullptr);
   bool do_read_source(ShaderModule::Stage stage, const Filename &fn, BamCacheRecord *record);

+ 0 - 2
panda/src/shaderpipeline/config_shaderpipeline.cxx

@@ -16,7 +16,6 @@
 #include "shaderCompilerRegistry.h"
 #include "shaderCompilerGlslang.h"
 #include "shaderCompilerGlslPreProc.h"
-#include "shaderCompilerCg.h"
 
 #include "shaderModuleGlsl.h"
 #include "shaderModuleSpirV.h"
@@ -52,5 +51,4 @@ init_libshaderpipeline() {
   ShaderCompilerRegistry *reg = ShaderCompilerRegistry::get_global_ptr();
   reg->register_compiler(new ShaderCompilerGlslang());
   reg->register_compiler(new ShaderCompilerGlslPreProc());
-  //reg->register_compiler(new ShaderCompilerCg());
 }

+ 0 - 1
panda/src/shaderpipeline/p3shaderpipeline_composite1.cxx

@@ -4,5 +4,4 @@
 #include "shaderCompiler.cxx"
 #include "shaderCompilerGlslang.cxx"
 #include "shaderCompilerGlslPreProc.cxx"
-#include "shaderCompilerCg.cxx"
 #include "shaderCompilerRegistry.cxx"

+ 0 - 140
panda/src/shaderpipeline/shaderCompilerCg.cxx

@@ -1,140 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file shaderCompilerCg.cxx
- * @author Mitchell Stokes
- * @date 2019-02-16
- */
-
-#include "shaderCompilerCg.h"
-#include "config_shaderpipeline.h"
-
-#ifdef HAVE_CG
-#include <Cg/cg.h>
-#endif
-
-#include "dcast.h"
-
-static const std::string vertex_profiles[] = {
-  "gp4vp",
-  "gp5vp",
-  "glslv",
-  "arbvp1",
-  "vp40",
-  "vp30",
-  "vp20",
-  "vs_1_1",
-  "vs_2_0",
-  "vs_2_x",
-  "vs_3_0",
-  "vs_4_0",
-  "vs_5_0"
-};
-
-static const std::string fragment_profiles[] = {
-  "gp4fp",
-  "gp5fp",
-  "glslf",
-  "arbfp1",
-  "fp40",
-  "fp30",
-  "fp20",
-  "ps_1_1",
-  "ps_1_2",
-  "ps_1_3",
-  "ps_2_0",
-  "ps_2_x",
-  "ps_3_0",
-  "ps_4_0",
-  "ps_5_0"
-};
-
-static const std::string geometry_profiles[] = {
-  "gp4gp",
-  "gp5gp",
-  "glslg",
-  "gs_4_0",
-  "gs_5_0"
-};
-
-TypeHandle ShaderCompilerCg::_type_handle;
-
-/**
- *
- */
-ShaderCompilerCg::
-ShaderCompilerCg() {
-}
-
-/**
- * Determines the appropriate active shader profile settings based on any
- * profile directives stored within the shader header
- */
-void ShaderCompilerCg::
-get_profile_from_header(const std::string &shader_text, Shader::ShaderCaps &caps) const {
-  // Note this forces profile based on what is specified in the shader header
-  // string.  Should probably be relying on card caps eventually.
-#ifdef HAVE_CG
-  size_t last_profile_pos = 0;
-  while ((last_profile_pos = shader_text.find("//Cg profile", last_profile_pos)) != std::string::npos) {
-    size_t newline_pos = shader_text.find('\n', last_profile_pos);
-    std::string search_str = shader_text.substr(last_profile_pos, newline_pos);
-
-    // Scan the line for known cg2 vertex program profiles
-    for (const std::string &profile : vertex_profiles) {
-      if (search_str.find(profile) != std::string::npos) {
-        caps._active_vprofile = cgGetProfile(profile.c_str());
-      }
-    }
-
-    // Scan the line for known cg2 fragment program profiles
-    for (const std::string &profile : fragment_profiles) {
-      if (search_str.find(profile) != std::string::npos) {
-        caps._active_fprofile = cgGetProfile(profile.c_str());
-      }
-    }
-
-    // Scan the line for known cg2 geometry program profiles
-    for (const std::string &profile : geometry_profiles) {
-      if (search_str.find(profile) != std::string::npos) {
-        caps._active_gprofile = cgGetProfile(profile.c_str());
-      }
-    }
-
-    last_profile_pos = newline_pos;
-  }
-#endif // HAVE_CG
-}
-
-/**
- *
- */
-std::string ShaderCompilerCg::
-get_name() const {
-  return "Cg Compiler";
-}
-
-/**
- *
- */
-ShaderLanguages ShaderCompilerCg::
-get_languages() const {
-  return {
-    Shader::SL_Cg
-  };
-}
-
-/**
- * Compiles the source code from the given input stream, producing a
- * ShaderModule on success.
- */
-PT(ShaderModule) ShaderCompilerCg::
-compile_now(ShaderModule::Stage stage, std::istream &in,
-            const std::string &filename, BamCacheRecord *record) const {
-  return nullptr;
-}

+ 0 - 59
panda/src/shaderpipeline/shaderCompilerCg.h

@@ -1,59 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file shaderCompilerCg.h
- * @author Mitchell Stokes
- * @date 2019-04-03
- */
-
-#ifndef SHADERCOMPILERCG_H
-#define SHADERCOMPILERCG_H
-
-#include "pandabase.h"
-
-#include "shaderCompiler.h"
-
-
-/**
- * This defines the compiler interface to read Cg shaders
- */
-class EXPCL_PANDA_SHADERPIPELINE ShaderCompilerCg : public ShaderCompiler {
-public:
-  ShaderCompilerCg();
-
-  void get_profile_from_header(const std::string &shader_text, Shader::ShaderCaps &caps) const;
-
-PUBLISHED:
-  virtual std::string get_name() const override;
-  virtual ShaderLanguages get_languages() const override;
-  virtual PT(ShaderModule) compile_now(Stage stage, std::istream &in,
-                                       const std::string &filename = "created-shader",
-                                       BamCacheRecord *record = nullptr) const override;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    ShaderCompiler::init_type();
-    register_type(_type_handle, "ShaderCompilerCg",
-                  ShaderCompiler::get_class_type());
-  }
-  virtual TypeHandle get_type() const override {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() override {
-    init_type();
-    return get_class_type();
-  }
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#endif

+ 0 - 3
panda/src/shaderpipeline/shaderModuleSpirV.h

@@ -214,9 +214,6 @@ private:
   void remap_locations(spv::StorageClass storage_class, const pmap<int, int> &locations);
   void strip();
 
-private:
-  int _index;
-
 public:
   static TypeHandle get_class_type() {
     return _type_handle;

+ 0 - 4
tests/shaderpipeline/test_shadercompilerregistry.py

@@ -9,10 +9,6 @@ def test_shadercompilerregistry_exists(registry):
 #    assert core.ShaderCompilerGlslPreProc in [type(i) for i in registry.compilers]
 #    assert registry.get_compiler_from_language(core.Shader.SL_GLSL) is not None
 
-#def test_shadercompilerregistry_cg_loaded(registry):
-#    assert core.ShaderCompilerCg in [type(i) for i in registry.compilers]
-#    assert registry.get_compiler_from_language(core.Shader.SL_Cg) is not None
-
 #def test_shadercompilerregistry_missing_lang(registry):
 #    assert core.ShaderCompilerGlslPreProc in [type(i) for i in registry.compilers]
 #    assert registry.get_compiler_from_language(core.Shader.SL_none) is None