srg-categories.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Copyright (c) Contributors to the Open 3D Engine Project.
  5. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  6. SPDX-License-Identifier: Apache-2.0 OR MIT
  7. """
  8. import sys
  9. import os
  10. sys.path.append("..")
  11. sys.path.append("../..")
  12. from clr import *
  13. import testfuncs
  14. def verifySrgCategories (thefile, compilerPath, silent):
  15. j, ok = testfuncs.buildAndGetJson(thefile, compilerPath, silent, ["--srg"])
  16. if ok:
  17. predicates = []
  18. predicates.append(lambda: j["ShaderResourceGroups"][0]["inputsForBufferViews"][0]["id"] == "scene")
  19. predicates.append(lambda: j["ShaderResourceGroups"][0]["inputsForBufferViews"][1]["id"] == "buf")
  20. predicates.append(lambda: j["ShaderResourceGroups"][0]["inputsForImageViews"][0]["id"] == "tex")
  21. if not silent: print (fg.CYAN+ style.BRIGHT+ "input assembler semantics verification..."+ style.RESET_ALL)
  22. ok = testfuncs.verifyAllPredicates(predicates, j)
  23. return True if ok else False
  24. result = 0 # to define for sub-tests
  25. resultFailed = 0
  26. def doTests(compiler, silent, azdxcpath):
  27. global result
  28. global resultFailed
  29. # Working directory should have been set to this script's directory by the calling parent
  30. # You can get it once doTests() is called, but not during initialization of the module,
  31. # because at that time it will still be set to the working directory of the calling script
  32. workDir = os.getcwd()
  33. if verifySrgCategories(os.path.join(workDir, "srg-categories.azsl"), compiler, silent) : result += 1
  34. else: resultFailed += 1
  35. if __name__ == "__main__":
  36. print ("please call from testapp.py")