utils.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2014 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <string>
  5. #include <fmt/format.h>
  6. #include <glad/glad.h>
  7. #include "common/common_types.h"
  8. #include "video_core/renderer_opengl/utils.h"
  9. namespace OpenGL {
  10. void LabelGLObject(GLenum identifier, GLuint handle, VAddr addr, std::string extra_info) {
  11. if (!GLAD_GL_KHR_debug) {
  12. return; // We don't need to throw an error as this is just for debugging
  13. }
  14. const std::string nice_addr = fmt::format("0x{:016x}", addr);
  15. std::string object_label;
  16. if (extra_info.empty()) {
  17. switch (identifier) {
  18. case GL_TEXTURE:
  19. object_label = "Texture@" + nice_addr;
  20. break;
  21. case GL_PROGRAM:
  22. object_label = "Shader@" + nice_addr;
  23. break;
  24. default:
  25. object_label = fmt::format("Object(0x{:x})@{}", identifier, nice_addr);
  26. break;
  27. }
  28. } else {
  29. object_label = extra_info + '@' + nice_addr;
  30. }
  31. glObjectLabel(identifier, handle, -1, static_cast<const GLchar*>(object_label.c_str()));
  32. }
  33. } // namespace OpenGL