1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0032154: Tests - include vglinfo into Tests Summary

Command testgrid now includes vglinfo into summary.
Command vinit has been extended by -virtual option creating an offscreen window.
Command vglinfo now splits long values into multiple lines.
Added test case v3d/glsl/glinfo dumping OpenGL context creation info.

OpenGl_Window - fixed initialization of OpenGL 4.6 Core Profile (was limited to 4.5).
This commit is contained in:
kgv 2021-02-22 09:58:50 +03:00 committed by bugmaster
parent 02a2beaad9
commit 72ed06442e
6 changed files with 166 additions and 54 deletions

View File

@ -559,6 +559,9 @@ proc testgrid {args} {
lappend log "Host: [info hostname]" lappend log "Host: [info hostname]"
lappend log "Started on: [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S}]" lappend log "Started on: [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S}]"
catch {lappend log "DRAW build:\n[dversion]" } catch {lappend log "DRAW build:\n[dversion]" }
catch { pload VISUALIZATION; vinit g/v/info -virtual -w 2 -h 2 }
catch { lappend log "[vglinfo -complete -lineWidth 80]" }
catch { vclose g/v/info 0 }
lappend log "Environment:" lappend log "Environment:"
foreach envar [lsort [array names env]] { foreach envar [lsort [array names env]] {
lappend log "$envar=\"$env($envar)\"" lappend log "$envar=\"$env($envar)\""

View File

@ -417,7 +417,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
// Try to create the core profile of highest OpenGL version supported by OCCT // Try to create the core profile of highest OpenGL version supported by OCCT
// (this will be done automatically by some drivers when requesting 3.2, // (this will be done automatically by some drivers when requesting 3.2,
// but some will not (e.g. AMD Catalyst) since WGL_ARB_create_context_profile specification allows both implementations). // but some will not (e.g. AMD Catalyst) since WGL_ARB_create_context_profile specification allows both implementations).
for (int aLowVer4 = 5; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4) for (int aLowVer4 = 6; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4)
{ {
aCoreCtxAttribs[1] = 4; aCoreCtxAttribs[1] = 4;
aCoreCtxAttribs[3] = aLowVer4; aCoreCtxAttribs[3] = aLowVer4;
@ -555,7 +555,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
}; };
// try to create the core profile of highest OpenGL version supported by OCCT // try to create the core profile of highest OpenGL version supported by OCCT
for (int aLowVer4 = 5; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4) for (int aLowVer4 = 6; aLowVer4 >= 0 && aGContext == NULL; --aLowVer4)
{ {
aCoreCtxAttribs[1] = 4; aCoreCtxAttribs[1] = 4;
aCoreCtxAttribs[3] = aLowVer4; aCoreCtxAttribs[3] = aLowVer4;

View File

@ -55,13 +55,15 @@ public:
//! @param theViewName name of newly created View //! @param theViewName name of newly created View
//! @oaram theDisplayName display name //! @oaram theDisplayName display name
//! @param theViewToClone when specified, the new View will copy properties of existing one //! @param theViewToClone when specified, the new View will copy properties of existing one
//! @param theIsVirtual force creation of virtual off-screen window within interactive session
Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0, Standard_EXPORT static TCollection_AsciiString ViewerInit (const Standard_Integer thePxLeft = 0,
const Standard_Integer thePxTop = 0, const Standard_Integer thePxTop = 0,
const Standard_Integer thePxWidth = 0, const Standard_Integer thePxWidth = 0,
const Standard_Integer thePxHeight = 0, const Standard_Integer thePxHeight = 0,
const TCollection_AsciiString& theViewName = "", const TCollection_AsciiString& theViewName = "",
const TCollection_AsciiString& theDisplayName = "", const TCollection_AsciiString& theDisplayName = "",
const Handle(V3d_View)& theViewToClone = Handle(V3d_View)()); const Handle(V3d_View)& theViewToClone = Handle(V3d_View)(),
const Standard_Boolean theIsVirtual = false);
Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName); Standard_EXPORT static void RemoveViewName (const TCollection_AsciiString& theName);

View File

@ -284,32 +284,72 @@ static int VGlInfo (Draw_Interpretor& theDI,
return 1; return 1;
} }
Standard_Integer anArgIter = 1;
Graphic3d_DiagnosticInfo anInfoLevel = Graphic3d_DiagnosticInfo_Basic; Graphic3d_DiagnosticInfo anInfoLevel = Graphic3d_DiagnosticInfo_Basic;
if (theArgNb == 2) Standard_Integer aLineWidth = 80;
NCollection_Sequence<TCollection_AsciiString> aKeys;
TColStd_IndexedDataMapOfStringString aDict;
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{ {
TCollection_AsciiString aName (theArgVec[1]); TCollection_AsciiString aName (theArgVec[anArgIter]);
aName.LowerCase(); aName.LowerCase();
TCollection_AsciiString aValue;
if (aName == "-short") if (aName == "-short")
{ {
++anArgIter;
anInfoLevel = Graphic3d_DiagnosticInfo_Short; anInfoLevel = Graphic3d_DiagnosticInfo_Short;
} }
else if (aName == "-basic") else if (aName == "-basic")
{ {
++anArgIter;
anInfoLevel = Graphic3d_DiagnosticInfo_Basic; anInfoLevel = Graphic3d_DiagnosticInfo_Basic;
} }
else if (aName == "-complete" else if (aName == "-complete"
|| aName == "-full") || aName == "-full")
{ {
++anArgIter;
anInfoLevel = Graphic3d_DiagnosticInfo_Complete; anInfoLevel = Graphic3d_DiagnosticInfo_Complete;
} }
else if (anArgIter + 1 < theArgNb
&& (aName == "-maxwidth"
|| aName == "-maxlinewidth"
|| aName == "-linewidth"))
{
aLineWidth = Draw::Atoi (theArgVec[++anArgIter]);
if (aLineWidth < 0)
{
aLineWidth = IntegerLast();
}
}
else if (aName.Search ("vendor") != -1)
{
aKeys.Append ("GLvendor");
}
else if (aName.Search ("renderer") != -1)
{
aKeys.Append ("GLdevice");
}
else if (aName.Search ("shading_language_version") != -1
|| aName.Search ("glsl") != -1)
{
aKeys.Append ("GLSLversion");
}
else if (aName.Search ("version") != -1)
{
aKeys.Append ("GLversion");
}
else if (aName.Search ("extensions") != -1)
{
aKeys.Append ("GLextensions");
}
else if (aName.Search ("extensions") != -1)
{
aKeys.Append ("GLextensions");
}
else
{
Message::SendFail() << "Syntax error: unknown key '" << aName << "'";
return 1;
}
} }
TColStd_IndexedDataMapOfStringString aDict; if (aKeys.IsEmpty())
if (anArgIter >= theArgNb)
{ {
aView->DiagnosticInformation (aDict, anInfoLevel); aView->DiagnosticInformation (aDict, anInfoLevel);
TCollection_AsciiString aText; TCollection_AsciiString aText;
@ -319,7 +359,42 @@ static int VGlInfo (Draw_Interpretor& theDI,
{ {
aText += "\n"; aText += "\n";
} }
aText += TCollection_AsciiString(" ") + aValueIter.Key() + ": " + aValueIter.Value(); if ((aValueIter.Key().Length() + aValueIter.Value().Length() + 4) <= aLineWidth)
{
aText += TCollection_AsciiString(" ") + aValueIter.Key() + ": " + aValueIter.Value();
continue;
}
// split into lines
aText += TCollection_AsciiString(" ") + aValueIter.Key() + ":";
TCollection_AsciiString aSubList;
for (Standard_Integer aTokenIter = 1;; ++aTokenIter)
{
TCollection_AsciiString aToken = aValueIter.Value().Token (" ", aTokenIter);
if (aToken.IsEmpty())
{
break;
}
if (!aSubList.IsEmpty()
&& (aSubList.Length() + aToken.Length() + 5) > aLineWidth)
{
aText += TCollection_AsciiString("\n ") + aSubList;
aSubList = aToken;
}
else
{
if (!aSubList.IsEmpty())
{
aSubList += " ";
}
aSubList += aToken;
}
}
if (!aSubList.IsEmpty())
{
aText += TCollection_AsciiString("\n ") + aSubList;
}
} }
theDI << "OpenGL info:\n" theDI << "OpenGL info:\n"
@ -327,41 +402,11 @@ static int VGlInfo (Draw_Interpretor& theDI,
return 0; return 0;
} }
const Standard_Boolean isList = theArgNb >= 3;
aView->DiagnosticInformation (aDict, Graphic3d_DiagnosticInfo_Complete); aView->DiagnosticInformation (aDict, Graphic3d_DiagnosticInfo_Complete);
for (; anArgIter < theArgNb; ++anArgIter) for (NCollection_Sequence<TCollection_AsciiString>::Iterator aKeyIter (aKeys); aKeyIter.More(); aKeyIter.Next())
{ {
TCollection_AsciiString aName (theArgVec[anArgIter]); TCollection_AsciiString aValue = searchInfo (aDict, aKeyIter.Value());
aName.UpperCase(); if (aKeys.Length() > 1)
TCollection_AsciiString aValue;
if (aName.Search ("VENDOR") != -1)
{
aValue = searchInfo (aDict, "GLvendor");
}
else if (aName.Search ("RENDERER") != -1)
{
aValue = searchInfo (aDict, "GLdevice");
}
else if (aName.Search ("SHADING_LANGUAGE_VERSION") != -1
|| aName.Search ("GLSL") != -1)
{
aValue = searchInfo (aDict, "GLSLversion");
}
else if (aName.Search ("VERSION") != -1)
{
aValue = searchInfo (aDict, "GLversion");
}
else if (aName.Search ("EXTENSIONS") != -1)
{
aValue = searchInfo (aDict, "GLextensions");
}
else
{
Message::SendFail() << "Syntax error: unknown key '" << aName.ToCString() << "'";
return 1;
}
if (isList)
{ {
theDI << "{" << aValue << "} "; theDI << "{" << aValue << "} ";
} }
@ -1363,10 +1408,12 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
"vimmediatefront : render immediate mode to front buffer or to back buffer", "vimmediatefront : render immediate mode to front buffer or to back buffer",
__FILE__, VImmediateFront, aGroup); __FILE__, VImmediateFront, aGroup);
theCommands.Add("vglinfo", theCommands.Add("vglinfo",
"vglinfo [-short|-basic|-complete]" "vglinfo [-short|-basic|-complete] [-lineWidth Value=80]"
"\n\t\t: [GL_VENDOR] [GL_RENDERER] [GL_VERSION]" "\n\t\t: [GL_VENDOR] [GL_RENDERER] [GL_VERSION]"
"\n\t\t: [GL_SHADING_LANGUAGE_VERSION] [GL_EXTENSIONS]" "\n\t\t: [GL_SHADING_LANGUAGE_VERSION] [GL_EXTENSIONS]"
"\n\t\t: print OpenGL info", "\n\t\t: print OpenGL info."
"\n\t\t: -lineWidth split values longer than specified value into multiple lines;"
"\n\t\t: -1 disables splitting.",
__FILE__, VGlInfo, aGroup); __FILE__, VGlInfo, aGroup);
theCommands.Add("vshader", theCommands.Add("vshader",
"vshader name -vert VertexShader -frag FragmentShader [-geom GeometryShader]" "vshader name -vert VertexShader -frag FragmentShader [-geom GeometryShader]"

View File

@ -1658,7 +1658,8 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
const Standard_Integer thePxHeight, const Standard_Integer thePxHeight,
const TCollection_AsciiString& theViewName, const TCollection_AsciiString& theViewName,
const TCollection_AsciiString& theDisplayName, const TCollection_AsciiString& theDisplayName,
const Handle(V3d_View)& theViewToClone) const Handle(V3d_View)& theViewToClone,
const Standard_Boolean theIsVirtual)
{ {
// Default position and dimension of the viewer window. // Default position and dimension of the viewer window.
// Note that left top corner is set to be sufficiently small to have // Note that left top corner is set to be sufficiently small to have
@ -1670,6 +1671,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
Standard_Integer aPxWidth = 409; Standard_Integer aPxWidth = 409;
Standard_Integer aPxHeight = 409; Standard_Integer aPxHeight = 409;
Standard_Boolean toCreateViewer = Standard_False; Standard_Boolean toCreateViewer = Standard_False;
const Standard_Boolean isVirtual = Draw_VirtualWindows || theIsVirtual;
if (!theViewToClone.IsNull()) if (!theViewToClone.IsNull())
{ {
theViewToClone->Window()->Size (aPxWidth, aPxHeight); theViewToClone->Window()->Size (aPxWidth, aPxHeight);
@ -1715,7 +1717,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
SetDisplayConnection (new Aspect_DisplayConnection ()); SetDisplayConnection (new Aspect_DisplayConnection ());
#endif #endif
if (Draw_VirtualWindows) if (isVirtual)
{ {
// don't waste the time waiting for VSync when window is not displayed on the screen // don't waste the time waiting for VSync when window is not displayed on the screen
ViewerTest_myDefaultCaps.swapInterval = 0; ViewerTest_myDefaultCaps.swapInterval = 0;
@ -1833,7 +1835,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
// Create window // Create window
#if defined(_WIN32) #if defined(_WIN32)
VT_GetWindow() = new WNT_Window (aTitle.ToCString(), WClass(), VT_GetWindow() = new WNT_Window (aTitle.ToCString(), WClass(),
Draw_VirtualWindows ? WS_POPUP : WS_OVERLAPPEDWINDOW, isVirtual ? WS_POPUP : WS_OVERLAPPEDWINDOW,
aPxLeft, aPxTop, aPxLeft, aPxTop,
aPxWidth, aPxHeight, aPxWidth, aPxHeight,
Quantity_NOC_BLACK); Quantity_NOC_BLACK);
@ -1849,7 +1851,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
aPxLeft, aPxTop, aPxLeft, aPxTop,
aPxWidth, aPxHeight); aPxWidth, aPxHeight);
#endif #endif
VT_GetWindow()->SetVirtual (Draw_VirtualWindows); VT_GetWindow()->SetVirtual (isVirtual);
// View setup // View setup
Handle(V3d_View) aView; Handle(V3d_View) aView;
@ -1927,6 +1929,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
{ {
TCollection_AsciiString aViewName, aDisplayName; TCollection_AsciiString aViewName, aDisplayName;
Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0; Standard_Integer aPxLeft = 0, aPxTop = 0, aPxWidth = 0, aPxHeight = 0;
Standard_Boolean isVirtual = false;
Handle(V3d_View) aCopyFrom; Handle(V3d_View) aCopyFrom;
TCollection_AsciiString aName, aValue; TCollection_AsciiString aName, aValue;
int is2dMode = -1; int is2dMode = -1;
@ -1964,6 +1967,16 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
{ {
aPxHeight = Draw::Atoi (theArgVec[++anArgIt]); aPxHeight = Draw::Atoi (theArgVec[++anArgIt]);
} }
else if (anArgCase == "-virtual"
|| anArgCase == "-offscreen")
{
isVirtual = true;
if (anArgIt + 1 < theArgsNb
&& Draw::ParseOnOff (theArgVec[anArgIt + 1], isVirtual))
{
++anArgIt;
}
}
else if (anArgCase == "-exitonclose") else if (anArgCase == "-exitonclose")
{ {
ViewerTest_EventManager::ToExitOnCloseView() = true; ViewerTest_EventManager::ToExitOnCloseView() = true;
@ -2081,7 +2094,7 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
} }
TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight, TCollection_AsciiString aViewId = ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight,
aViewName, aDisplayName, aCopyFrom); aViewName, aDisplayName, aCopyFrom, isVirtual);
if (is2dMode != -1) if (is2dMode != -1)
{ {
ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1); ViewerTest_V3dView::SetCurrentView2DMode (is2dMode == 1);
@ -14677,7 +14690,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
const char *group = "ZeViewer"; const char *group = "ZeViewer";
theCommands.Add("vinit", theCommands.Add("vinit",
"vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]" "vinit [-name viewName] [-left leftPx] [-top topPx] [-width widthPx] [-height heightPx]"
"\n\t\t: [-exitOnClose] [-closeOnEscape] [-cloneActive] [-2d_mode {on|off}=off]" "\n\t\t: [-exitOnClose] [-closeOnEscape] [-cloneActive] [-virtual {on|off}=off] [-2d_mode {on|off}=off]"
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
"\n\t\t: [-display displayName]" "\n\t\t: [-display displayName]"
#endif #endif
@ -14693,9 +14706,10 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
#endif #endif
"\n\t\t: -left, -top pixel position of left top corner of the window." "\n\t\t: -left, -top pixel position of left top corner of the window."
"\n\t\t: -width, -height width and height of window respectively." "\n\t\t: -width, -height width and height of window respectively."
"\n\t\t: -cloneActive floag to copy camera and dimensions of active view." "\n\t\t: -cloneActive flag to copy camera and dimensions of active view."
"\n\t\t: -exitOnClose when specified, closing the view will exit application." "\n\t\t: -exitOnClose when specified, closing the view will exit application."
"\n\t\t: -closeOnEscape when specified, view will be closed on pressing Escape." "\n\t\t: -closeOnEscape when specified, view will be closed on pressing Escape."
"\n\t\t: -virtual create an offscreen window within interactive session"
"\n\t\t: -2d_mode when on, view will not react on rotate scene events" "\n\t\t: -2d_mode when on, view will not react on rotate scene events"
"\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.", "\n\t\t: Additional commands for operations with views: vclose, vactivate, vviewlist.",
__FILE__,VInit,group); __FILE__,VInit,group);

46
tests/v3d/glsl/glinfo Normal file
View File

@ -0,0 +1,46 @@
puts "============"
puts "Print OpenGL info"
puts "============"
puts ""
set to_dump_screen 0
pload VISUALIZATION
vclose ALL 0
puts "=== Create compatible profile ==="
vgldebug 0
vcaps -core 0 -maxVersion -1 -1 -softMode 0
vinit g1/v/info
vglinfo -complete -lineWidth 80
vclose ALL 0
puts "=== Create core profile ==="
vgldebug 0
vcaps -core 1 -maxVersion -1 -1 -softMode 0
vinit g1/v/info
vglinfo -complete -lineWidth 80
vclose ALL 0
puts "=== Create version-restricted profile ==="
vgldebug 0
vcaps -core 0 -maxVersion 2 1 -softMode 0
vinit g1/v/info
vglinfo -complete -lineWidth 80
vclose ALL 0
puts "=== Create software emulated profile ==="
vgldebug 0
vcaps -core 0 -maxVersion -1 -1 -softMode 1
vinit g1/v/info
vglinfo -complete -lineWidth 80
vclose ALL 0
puts "=== Create debug profile ==="
vgldebug 1
vcaps -core 0 -maxVersion -1 -1 -softMode 0
vinit g1/v/info
vglinfo -complete -lineWidth 80
vclose ALL 0
vgldebug 0
vcaps -core 0 -maxVersion -1 -1 -softMode 0