gfxGLCardProfiler.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // get the major and minor parts of the GL version. These are defined to be
  29. // in the order "[major].[minor] [other]|[major].[minor].[release] [other] in the spec
  30. const char *versionStart = reinterpret_cast<const char*>(glGetString(GL_VERSION));
  31. const char *versionEnd = versionStart;
  32. // get the text for the version "x.x.xxxx "
  33. for( S32 tok = 0; tok < 2; ++tok )
  34. {
  35. char *text = dStrdup( versionEnd );
  36. dStrtok(text, ". ");
  37. versionEnd += dStrlen( text ) + 1;
  38. dFree( text );
  39. }
  40. mRendererString = "GL";
  41. mRendererString += String::SpanToString(versionStart, versionEnd - 1);
  42. mCardDescription = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
  43. mVersionString = reinterpret_cast<const char*>(glGetString(GL_VERSION));
  44. mVideoMemory = static_cast<GFXGLDevice*>(GFX)->getTotalVideoMemory();
  45. Parent::init();
  46. }
  47. void GFXGLCardProfiler::setupCardCapabilities()
  48. {
  49. GLint maxTexSize;
  50. glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
  51. // OpenGL doesn't have separate maximum width/height.
  52. setCapability("maxTextureWidth", maxTexSize);
  53. setCapability("maxTextureHeight", maxTexSize);
  54. setCapability("maxTextureSize", maxTexSize);
  55. // Check for anisotropic filtering support.
  56. setCapability("GL_EXT_texture_filter_anisotropic", gglHasExtension(EXT_texture_filter_anisotropic));
  57. // Check for buffer storage
  58. setCapability("GL_ARB_buffer_storage", gglHasExtension(ARB_buffer_storage));
  59. // Check for shader model 5.0
  60. setCapability("GL_ARB_gpu_shader5", gglHasExtension(ARB_gpu_shader5));
  61. // Check for texture storage
  62. setCapability("GL_ARB_texture_storage", gglHasExtension(ARB_texture_storage));
  63. // Check for sampler objects
  64. setCapability("GL_ARB_sampler_objects", gglHasExtension(ARB_sampler_objects));
  65. // Check for copy image support
  66. setCapability("GL_ARB_copy_image", gglHasExtension(ARB_copy_image));
  67. // Check for vertex attrib binding
  68. setCapability("GL_ARB_vertex_attrib_binding", gglHasExtension(ARB_vertex_attrib_binding));
  69. }
  70. bool GFXGLCardProfiler::_queryCardCap(const String& query, U32& foundResult)
  71. {
  72. // Just doing what the D3D9 layer does
  73. return 0;
  74. }
  75. bool GFXGLCardProfiler::_queryFormat(const GFXFormat fmt, const GFXTextureProfile *profile, bool &inOutAutogenMips)
  76. {
  77. // We assume if the format is valid that we can use it for any purpose.
  78. // This may not be the case, but we have no way to check short of in depth
  79. // testing of every format for every purpose. And by testing, I mean sitting
  80. // down and doing it by hand, because there is no OpenGL API to check these
  81. // things.
  82. return GFXGLTextureInternalFormat[fmt] != GL_ZERO;
  83. }