test_cg_shader.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import os
  2. import platform
  3. import pytest
  4. from panda3d import core
  5. SHADERS_DIR = core.Filename.from_os_specific(os.path.dirname(__file__))
  6. def run_cg_compile_check(gsg, shader_path, expect_fail=False):
  7. """Compile supplied Cg shader path and check for errors"""
  8. shader = core.Shader.load(shader_path, core.Shader.SL_Cg)
  9. # assert shader.is_prepared(gsg.prepared_objects)
  10. if expect_fail:
  11. assert shader is None
  12. else:
  13. assert shader is not None
  14. @pytest.mark.skipif(platform.machine().lower() in ('arm64', 'aarch64'), reason="Cg not supported on arm64")
  15. def test_cg_compile_error(gsg):
  16. """Test getting compile errors from bad Cg shaders"""
  17. shader_path = core.Filename(SHADERS_DIR, 'cg_bad.sha')
  18. run_cg_compile_check(gsg, shader_path, expect_fail=True)
  19. @pytest.mark.skipif(platform.machine().lower() in ('arm64', 'aarch64'), reason="Cg not supported on arm64")
  20. def test_cg_from_file(gsg):
  21. """Test compiling Cg shaders from files"""
  22. shader_path = core.Filename(SHADERS_DIR, 'cg_simple.sha')
  23. run_cg_compile_check(gsg, shader_path)