gfxGLCardProfiler.cpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "gfx/gl/gfxGLCardProfiler.h"
  23. #include "gfx/gl/gfxGLDevice.h"
  24. #include "gfx/gl/gfxGLEnumTranslate.h"
  25. void GFXGLCardProfiler::init()
  26. {
  27. mChipSet = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
  28. mRendererString = "OpenGL";
  29. mCardDescription = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
  30. mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
  31. mVideoMemory = static_cast<GFXGLDevice*>(GFX)->getTotalVideoMemory();
  32. Parent::init();
  33. }
  34. void GFXGLCardProfiler::setupCardCapabilities()
  35. {
  36. GLint maxTexSize;
  37. glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
  38. // OpenGL doesn't have separate maximum width/height.
  39. setCapability("maxTextureWidth", maxTexSize);
  40. setCapability("maxTextureHeight", maxTexSize);
  41. setCapability("maxTextureSize", maxTexSize);
  42. // Check for anisotropic filtering support.
  43. setCapability("GL_EXT_texture_filter_anisotropic", gglHasExtension(EXT_texture_filter_anisotropic));
  44. // Check for buffer storage
  45. #ifdef TORQUE_NSIGHT_WORKAROUND
  46. setCapability("GL_ARB_buffer_storage", false);
  47. #else
  48. setCapability("GL_ARB_buffer_storage", gglHasExtension(ARB_buffer_storage));
  49. #endif
  50. // Check for texture storage
  51. setCapability("GL_ARB_texture_storage", gglHasExtension(ARB_texture_storage));
  52. // Check for copy image support
  53. setCapability("GL_ARB_copy_image", gglHasExtension(ARB_copy_image));
  54. // Check for vertex attrib binding
  55. setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
  56. //check for KHR debug
  57. setCapability("GL_KHR_debug", gglHasExtension(KHR_debug));
  58. //check for KHR debug
  59. setCapability("GL_EXT_debug_marker", gglHasExtension(EXT_debug_marker));
  60. }
  61. bool GFXGLCardProfiler::_queryCardCap(const String& query, U32& foundResult)
  62. {
  63. // Just doing what the D3D11 layer does
  64. return 0;
  65. }
  66. bool GFXGLCardProfiler::_queryFormat(const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips)
  67. {
  68. // We assume if the format is valid that we can use it for any purpose.
  69. // This may not be the case, but we have no way to check short of in depth
  70. // testing of every format for every purpose. And by testing, I mean sitting
  71. // down and doing it by hand, because there is no OpenGL API to check these
  72. // things.
  73. return GFXGLTextureInternalFormat[fmt] != GL_ZERO;
  74. }