MCPcopy Create free account
hub / github.com/defold/defold / Graphics_GetAdapterInfo

Function Graphics_GetAdapterInfo

engine/script/src/script_graphics.cpp:800–916  ·  view source on GitHub ↗

get information about the currently installed graphics adapter * * Returns a table describing the active graphics context: the adapter family, * its hardware limits, the list of driver-reported extensions, and the set of * optional context features supported by the backend. * * @name graphics.get_adapter_info * @return info [type:table] table with the following f

Source from the content-addressed store, hash-verified

798 * `graphics.CONTEXT_FEATURE_BLEND_EQUATION_MIN_MAX` min/max blend equations
799 */
800 static int Graphics_GetAdapterInfo(lua_State* L)
801 {
802 DM_LUA_STACK_CHECK(L, 1);
803
804 dmGraphics::HContext context = g_GraphicsModule.m_GraphicsContext;
805
806 lua_newtable(L);
807
808 // adapter family literal
809 {
810 const char* family_name = "none";
811 if (context)
812 {
813 family_name = AdapterFamilyToName(dmGraphics::GetInstalledAdapterFamily());
814 }
815 lua_pushstring(L, family_name);
816 lua_setfield(L, -2, "family");
817 }
818
819 // adapter API version
820 {
821 uint16_t major = 0, minor = 0;
822 if (context)
823 {
824 dmGraphics::GetAdapterVersion(context, major, minor);
825 }
826 lua_pushinteger(L, (lua_Integer) major);
827 lua_setfield(L, -2, "version_major");
828 lua_pushinteger(L, (lua_Integer) minor);
829 lua_setfield(L, -2, "version_minor");
830 }
831
832 // limits sub-table
833 {
834 lua_newtable(L);
835
836 dmGraphics::GraphicsContextLimits limits = {};
837 if (context)
838 {
839 dmGraphics::GetGraphicsContextLimits(context, limits);
840 }
841
842 // Lua numbers are doubles, so uint64_t fields can lose precision above
843 // 2^53. The buffer ranges we report fit comfortably below that today,
844 // but cast through lua_Number deliberately so a future change shows
845 // up in code review.
846 #define PUSH_LIMIT(field, key) \
847 lua_pushnumber(L, (lua_Number) limits.field); \
848 lua_setfield(L, -2, key);
849
850 // Texture limits
851 PUSH_LIMIT(m_MaxTextureSize2D, "max_texture_size_2d");
852 PUSH_LIMIT(m_MaxTextureSize3D, "max_texture_size_3d");
853 PUSH_LIMIT(m_MaxTextureSizeCube, "max_texture_size_cube");
854 PUSH_LIMIT(m_MaxTextureArrayLayers, "max_texture_array_layers");
855
856 // Framebuffer limits
857 PUSH_LIMIT(m_MaxFramebufferWidth, "max_framebuffer_width");

Callers

nothing calls this directly

Calls 13

AdapterFamilyToNameFunction · 0.85
lua_pushstringFunction · 0.85
lua_setfieldFunction · 0.85
GetAdapterVersionFunction · 0.85
lua_pushintegerFunction · 0.85
GetGraphicsContextLimitsFunction · 0.85
lua_createtableFunction · 0.85
GetSupportedExtensionFunction · 0.85
lua_rawsetiFunction · 0.85

Tested by

no test coverage detected