srg-semantics.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 verifyIASemantics (thefile, compilerPath, silent):
  15. j, ok = testfuncs.buildAndGetJson(thefile, compilerPath, silent, ["--ia"])
  16. if ok:
  17. predicates = []
  18. predicates.append(lambda: j["inputLayouts"][0]["streams"][0]["systemValue"] == 0)
  19. predicates.append(lambda: j["inputLayouts"][0]["streams"][1]["systemValue"] == 0)
  20. predicates.append(lambda: j["inputLayouts"][1]["streams"][0]["systemValue"] == 1) #SV_POSITION
  21. predicates.append(lambda: j["inputLayouts"][1]["streams"][1]["systemValue"] == 0)
  22. if not silent: print (fg.CYAN+ style.BRIGHT+ "input assembler semantics verification..."+ style.RESET_ALL)
  23. ok = testfuncs.verifyAllPredicates(predicates, j)
  24. return True if ok else False
  25. def verifyOMSemantics (thefile, compilerPath, silent):
  26. j, ok = testfuncs.buildAndGetJson(thefile, compilerPath, silent, ["--om"])
  27. if ok:
  28. predicates = []
  29. predicates.append(lambda: j["outputLayouts"][0]["renderTargets"][0]["systemValue"] == 1) #SV_TARGET
  30. if not silent: print (fg.CYAN+ style.BRIGHT+ "input assembler semantics verification..."+ style.RESET_ALL)
  31. ok = testfuncs.verifyAllPredicates(predicates, j)
  32. return True if ok else False
  33. result = 0 # to define for sub-tests
  34. resultFailed = 0
  35. def doTests(compiler, silent, azdxcpath):
  36. global result
  37. global resultFailed
  38. # Working directory should have been set to this script's directory by the calling parent
  39. # You can get it once doTests() is called, but not during initialization of the module,
  40. # because at that time it will still be set to the working directory of the calling script
  41. workDir = os.getcwd()
  42. if verifyIASemantics(os.path.join(workDir, "srg-semantics.azsl"), compiler, silent) : result += 1
  43. else: resultFailed += 1
  44. if verifyOMSemantics(os.path.join(workDir, "srg-semantics.azsl"), compiler, silent) : result += 1
  45. else: resultFailed += 1
  46. if __name__ == "__main__":
  47. print ("please call from testapp.py")