ms-to-noms-emission-tester.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. import platform
  11. sys.path.append("..")
  12. from clr import *
  13. import os.path
  14. from os.path import join, normpath, basename
  15. import testhelper
  16. result = 0 # to define for sub-tests
  17. resultFailed = 0
  18. def doTests(compiler, silent, azdxcpath):
  19. """
  20. The purpose of this test is to validate proper functionality of the compiler option --no-ms.
  21. --no-ms is an option that triggers automatic conversion of MultiSampling related Texture variables, function calls
  22. and system semantics, to their non-MultiSampling version. Example Texture2DMS to Texture2D, Texture2DMSArray to Texture2DArray, etc.
  23. """
  24. global result
  25. global resultFailed
  26. # Working directory should have been set to this script's directory by the calling parent
  27. # You can get it once doTests() is called, but not during initialization of the module,
  28. # because at that time it will still be set to the working directory of the calling script
  29. workDir = os.getcwd().replace('\\', '/')
  30. # First let's make sure that WITHOUT --no-ms, the shader compiles fine and all the MultiSampling related variables and function call
  31. # remain unchanged.
  32. azslFile = os.path.abspath(os.path.join(workDir, "./texture2DMS-to-texture2D.azsl"))
  33. failList = []
  34. patternFile = os.path.abspath(os.path.join(workDir, "./texture2DMS-to-texture2D.txt"))
  35. if testhelper.verifyEmissionPattern(azslFile, patternFile, compiler, silent, []) : result += 1
  36. else:
  37. failList.append(patternFile)
  38. resultFailed += 1
  39. patternFile = os.path.abspath(os.path.join(workDir, "./texture2DMS-to-texture2D-noms.txt"))
  40. if testhelper.verifyEmissionPattern(azslFile, patternFile, compiler, silent, ["--no-ms"]) : result += 1
  41. else:
  42. failList.append(patternFile)
  43. resultFailed += 1
  44. if not silent and len(failList) > 0:
  45. print(style.BRIGHT + fg.RED + "failed files: " + fg.WHITE + str(failList) + style.RESET_ALL)
  46. if __name__ == "__main__":
  47. print ("please call from testapp.py")