ShaderProgramBinaryDumpMain.cpp 859 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (C) 2009-2020, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <anki/shader_compiler/ShaderProgramCompiler.h>
  6. using namespace anki;
  7. static const char* USAGE = R"(Dump the shader binary to stdout
  8. Usage: %s in_file
  9. )";
  10. Error dump(const char* fname)
  11. {
  12. HeapAllocator<U8> alloc(allocAligned, nullptr);
  13. ShaderProgramBinaryWrapper bin(alloc);
  14. ANKI_CHECK(bin.deserializeFromFile(fname));
  15. StringAuto txt(alloc);
  16. dumpShaderProgramBinary(bin.getBinary(), txt);
  17. printf("%s\n", txt.cstr());
  18. return Error::NONE;
  19. }
  20. int main(int argc, char** argv)
  21. {
  22. if(argc != 2)
  23. {
  24. ANKI_LOGE(USAGE, argv[0]);
  25. return 1;
  26. }
  27. const Error err = dump(argv[1]);
  28. if(err)
  29. {
  30. ANKI_LOGE("Can't dump due to an error. Bye");
  31. return 1;
  32. }
  33. return 0;
  34. }