From a00aba0b350ce978f3a727db4f2ade4f737732e0 Mon Sep 17 00:00:00 2001 From: sshutina Date: Fri, 20 Dec 2019 10:40:03 +0300 Subject: [PATCH] 0031278: Visualization - display elements above transparent area --- src/Font/Font_Rect.hxx | 11 +++ src/Graphic3d/Graphic3d_Aspects.cxx | 9 +- src/Graphic3d/Graphic3d_Group.cxx | 1 + src/Graphic3d/Graphic3d_Layer.cxx | 1 + src/OpenGl/OpenGl_Context.cxx | 95 +++++++++++++++++++ src/OpenGl/OpenGl_Context.hxx | 3 + src/OpenGl/OpenGl_Element.cxx | 11 +++ src/OpenGl/OpenGl_Element.hxx | 3 +- src/OpenGl/OpenGl_Group.cxx | 22 ++++- src/OpenGl/OpenGl_LayerList.cxx | 48 ++++++++++ src/OpenGl/OpenGl_LayerList.hxx | 3 + src/OpenGl/OpenGl_PrimitiveArray.cxx | 13 +++ src/OpenGl/OpenGl_Resource.hxx | 4 + src/OpenGl/OpenGl_Structure.cxx | 9 ++ src/OpenGl/OpenGl_Text.cxx | 88 ++++++++++++++--- src/OpenGl/OpenGl_VertexBuffer.cxx | 17 ++++ src/OpenGl/OpenGl_VertexBuffer.hxx | 3 + src/OpenGl/OpenGl_View_Redraw.cxx | 43 +++++++++ src/OpenGl/OpenGl_Workspace.cxx | 52 ++++++++++ src/OpenGl/OpenGl_Workspace.hxx | 3 + tools/MessageModel/MessageModel_Actions.cxx | 9 ++ .../VInspector_ItemOpenGlLayerList.cxx | 14 +++ .../VInspector_ItemOpenGlLayerList.hxx | 4 + 23 files changed, 445 insertions(+), 21 deletions(-) diff --git a/src/Font/Font_Rect.hxx b/src/Font/Font_Rect.hxx index 50c598a8dd..630d02fdf6 100644 --- a/src/Font/Font_Rect.hxx +++ b/src/Font/Font_Rect.hxx @@ -16,6 +16,7 @@ #define _Font_Rect_H__ #include +#include //! Auxiliary POD structure - 2D rectangle definition. struct Font_Rect @@ -76,6 +77,16 @@ struct Font_Rect return Top - Bottom; } + //! Dumps the content of me into the stream + void DumpJson (Standard_OStream& theOStream, const Standard_Integer) const + { + OCCT_DUMP_CLASS_BEGIN (theOStream, Font_Rect); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Left); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Right); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Top); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Bottom); + } }; #endif // _Font_Rect_H__ diff --git a/src/Graphic3d/Graphic3d_Aspects.cxx b/src/Graphic3d/Graphic3d_Aspects.cxx index 00f86b95f6..afbda103f6 100644 --- a/src/Graphic3d/Graphic3d_Aspects.cxx +++ b/src/Graphic3d/Graphic3d_Aspects.cxx @@ -92,11 +92,12 @@ void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_I OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextZoomable); /*Aspect_InteriorStyle myInteriorStyle; - Graphic3d_TypeOfShadingModel myShadingModel; - Graphic3d_AlphaMode myAlphaMode; - Standard_ShortReal myAlphaCutoff; + Graphic3d_TypeOfShadingModel myShadingModel;*/ - Aspect_TypeOfLine myLineType; + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlphaMode); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlphaCutoff); + + /*Aspect_TypeOfLine myLineType; Standard_ShortReal myLineWidth; Aspect_TypeOfMarker myMarkerType; diff --git a/src/Graphic3d/Graphic3d_Group.cxx b/src/Graphic3d/Graphic3d_Group.cxx index 27e4f9acff..9ddd01b1ab 100644 --- a/src/Graphic3d/Graphic3d_Group.cxx +++ b/src/Graphic3d/Graphic3d_Group.cxx @@ -456,6 +456,7 @@ void Graphic3d_Group::DumpJson (Standard_OStream& theOStream, const Standard_Int { OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Group); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, this); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsClosed); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myContainsFacet); } diff --git a/src/Graphic3d/Graphic3d_Layer.cxx b/src/Graphic3d/Graphic3d_Layer.cxx index 3859b60aad..a76723bb70 100644 --- a/src/Graphic3d/Graphic3d_Layer.cxx +++ b/src/Graphic3d/Graphic3d_Layer.cxx @@ -635,6 +635,7 @@ void Graphic3d_Layer::DumpJson (Standard_OStream& theOStream, const Standard_Int { OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Layer); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, this); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLayerId); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructures); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructuresNotCulled); diff --git a/src/OpenGl/OpenGl_Context.cxx b/src/OpenGl/OpenGl_Context.cxx index 5356a4e2bc..73c09d970c 100644 --- a/src/OpenGl/OpenGl_Context.cxx +++ b/src/OpenGl/OpenGl_Context.cxx @@ -4045,7 +4045,102 @@ void OpenGl_Context::DumpJson (Standard_OStream& theOStream, const Standard_Inte { OCCT_DUMP_CLASS_BEGIN (theOStream, OpenGl_Context) + //Handle(OpenGl_ResourcesMap) mySharedResources; + //Handle(OpenGl_DelayReleaseMap) myDelayed; + //Handle(OpenGl_ResourcesStack) myUnusedResources; + //OpenGl_Clipping myClippingState; + //void* myGlLibHandle; + //NCollection_Handle myFuncs; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAnisoMax); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTexClamp); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxTexDim); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxTexCombined); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxDumpSizeX); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxDumpSizeY); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxClipPlanes); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxMsaaSamples); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxDrawBuffers); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaxColorAttachments); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGlVerMajor); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myGlVerMinor); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsInitialized); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsStereoBuffers); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsGlNormalizeEnabled); + + //Graphic3d_TextureUnit mySpriteTexUnit; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasRayTracing); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasRayTracingTextures); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasRayTracingAdaptiveSampling); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasRayTracingAdaptiveSamplingAtomic); + + //Handle(OpenGl_ShaderManager) myShaderManager; + //Handle(Font_TextFormatter) myDefaultFormatter; + + //Handle(OpenGl_FrameStats) myFrameStats; + //Handle(OpenGl_ShaderProgram) myActiveProgram; + //Handle(OpenGl_TextureSet) myActiveTextures; + + //Handle(OpenGl_FrameBuffer) myDefaultFbo; + //Handle(OpenGl_LineAttributes) myHatchStyles; + + for (int i = 0; i < 4; i++) + { + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewport[i]); + } + + for (int i = 0; i < 4; i++) + { + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myViewportVirt[i]); + } + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPointSpriteOrig); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRenderMode); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPolygonMode); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPolygonOffset) + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToCullBackFaces); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myReadBuffer); + + //NCollection_Array1 myDrawBuffers; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDefaultVao); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myColorMask); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAllowAlphaToCov); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlphaToCoverage); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsGlDebugCtx); + + //TCollection_AsciiString myVendor; + //TColStd_PackedMapOfInteger myFilters[6]; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myResolution); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myResolutionRatio); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLineWidthScale); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLineFeather); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRenderScale); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRenderScaleInv); + + //OpenGl_Material myMatFront; + //OpenGl_Material myMatBack; + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &ModelWorldState) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &WorldViewState) OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &ProjectionState) } + +// ======================================================================= +// function : DumpJsonOpenGl +// purpose : +// ======================================================================= +void OpenGl_Context::DumpJsonOpenGl (Standard_OStream& theOStream, const Standard_Integer) +{ + GLboolean isEnableBlend = glIsEnabled (GL_BLEND); + GLboolean isEnableCullFace = glIsEnabled (GL_CULL_FACE); + GLboolean isEnableDepthTest = glIsEnabled (GL_DEPTH_TEST); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, isEnableBlend); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, isEnableCullFace); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, isEnableDepthTest); +} + diff --git a/src/OpenGl/OpenGl_Context.hxx b/src/OpenGl/OpenGl_Context.hxx index a837d63979..001fcd34c8 100644 --- a/src/OpenGl/OpenGl_Context.hxx +++ b/src/OpenGl/OpenGl_Context.hxx @@ -864,6 +864,9 @@ public: //! @name methods to alter or retrieve current state //! Dumps the content of me into the stream Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + + //! Dumps the content of openGL into the stream + static Standard_EXPORT void DumpJsonOpenGl (Standard_OStream& theOStream, const Standard_Integer theDepth = -1); private: diff --git a/src/OpenGl/OpenGl_Element.cxx b/src/OpenGl/OpenGl_Element.cxx index 0d5c53f5d5..2e708a8802 100755 --- a/src/OpenGl/OpenGl_Element.cxx +++ b/src/OpenGl/OpenGl_Element.cxx @@ -15,6 +15,8 @@ #include +#include + // ======================================================================= // function : OpenGl_Element // purpose : @@ -32,3 +34,12 @@ OpenGl_Element::~OpenGl_Element() { // } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void OpenGl_Element::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, this); +} diff --git a/src/OpenGl/OpenGl_Element.hxx b/src/OpenGl/OpenGl_Element.hxx index fe2c4e7f60..dc2aee9cb2 100644 --- a/src/OpenGl/OpenGl_Element.hxx +++ b/src/OpenGl/OpenGl_Element.hxx @@ -64,8 +64,7 @@ public: virtual void SynchronizeAspects() {} //! Dumps the content of me into the stream - virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const - { (void)theOStream; (void)theDepth; } + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; protected: diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index 93a9f91997..1fe886273f 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -28,6 +28,12 @@ #include #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif // DEBUG_INFO + IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Group,Graphic3d_Group) namespace @@ -298,12 +304,26 @@ void OpenGl_Group::AddElement (OpenGl_Element* theElem) // ======================================================================= void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { + +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + + Standard_SStream aGroupStream; + DumpJson (aGroupStream); + MESSAGE_INFO_OBJECT(this, aGroupStream, "OpenGl_Group::Render", "", &aPerfMeter, NULL) + Handle(Message_Alert) aParentAlert = OCCT_Message_Alert; + + Standard_SStream aContextStream; + theWorkspace->GetGlContext()->DumpJson (aContextStream); + MESSAGE_INFO_OBJECT(this, aContextStream, "Context", "", &aPerfMeter, aParentAlert) +#endif + // Setup aspects theWorkspace->SetAllowFaceCulling (myIsClosed && !theWorkspace->GetGlContext()->Clipping().IsClippingOrCappingOn()); const OpenGl_Aspects* aBackAspects = theWorkspace->Aspects(); const bool isAspectSet = myAspects != NULL && renderFiltered (theWorkspace, myAspects); - + // Render group elements for (OpenGl_ElementNode* aNodeIter = myFirst; aNodeIter != NULL; aNodeIter = aNodeIter->next) { diff --git a/src/OpenGl/OpenGl_LayerList.cxx b/src/OpenGl/OpenGl_LayerList.cxx index aaefd64dd5..f1188f5847 100644 --- a/src/OpenGl/OpenGl_LayerList.cxx +++ b/src/OpenGl/OpenGl_LayerList.cxx @@ -26,6 +26,12 @@ #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif + namespace { //! Auxiliary class extending sequence iterator with index. @@ -172,6 +178,38 @@ void OpenGl_LayerList::SetFrustumCullingBVHBuilder (const Handle(Select3D_BVHBui } } +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void OpenGl_LayerList::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, OpenGl_LayerList); + + for (NCollection_List::Iterator aLayersIt (myLayers); aLayersIt.More(); aLayersIt.Next()) + { + Handle(Graphic3d_Layer) aLayerId = aLayersIt.Value(); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aLayerId.get()); + } + + + /* + NCollection_List myLayers; + NCollection_DataMap myLayerIds; + Handle(Select3D_BVHBuilder3d) myBVHBuilder; //!< BVH tree builder for frustom culling + */ + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbPriorities); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructures); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myImmediateNbStructures); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myModifStateOfRaytraceable); + + /* + //! Collection of references to layers with transparency gathered during rendering pass. + mutable OpenGl_LayerStack myTransparentToProcess; + */ +} + //======================================================================= //function : InsertLayerBefore //purpose : @@ -548,6 +586,11 @@ void OpenGl_LayerList::renderLayer (const Handle(OpenGl_Workspace)& theWorkspace const OpenGl_GlobalLayerSettings& theDefaultSettings, const Graphic3d_Layer& theLayer) const { +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_LayerList::renderLayer", "", &aPerfMeter, NULL) +#endif + const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); const Graphic3d_ZLayerSettings& aLayerSettings = theLayer.LayerSettings(); @@ -856,6 +899,11 @@ void OpenGl_LayerList::renderTransparent (const Handle(OpenGl_Workspace)& theW return; } +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_LayerList::renderTransparent", "", &aPerfMeter, NULL) +#endif + const Handle(OpenGl_Context) aCtx = theWorkspace->GetGlContext(); const Handle(OpenGl_ShaderManager)& aManager = aCtx->ShaderManager(); OpenGl_View* aView = theWorkspace->View(); diff --git a/src/OpenGl/OpenGl_LayerList.hxx b/src/OpenGl/OpenGl_LayerList.hxx index 2d8c9024ff..a1205e7e7c 100644 --- a/src/OpenGl/OpenGl_LayerList.hxx +++ b/src/OpenGl/OpenGl_LayerList.hxx @@ -126,6 +126,9 @@ public: //! Assigns BVH tree builder for frustom culling. void SetFrustumCullingBVHBuilder (const Handle(Select3D_BVHBuilder3d)& theBuilder); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! Stack of references to existing layers of predefined maximum size. diff --git a/src/OpenGl/OpenGl_PrimitiveArray.cxx b/src/OpenGl/OpenGl_PrimitiveArray.cxx index 5af53c0b6c..93473710cd 100644 --- a/src/OpenGl/OpenGl_PrimitiveArray.cxx +++ b/src/OpenGl/OpenGl_PrimitiveArray.cxx @@ -29,6 +29,12 @@ #include #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif // DEBUG_INFO + namespace { //! Convert data type to GL info @@ -769,6 +775,13 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace return; } +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + Standard_SStream aGroupStream; + DumpJson (aGroupStream); + MESSAGE_INFO_STREAM(aGroupStream, "OpenGl_PrimitiveArray::Render", Standard_Dump::GetPointerInfo(this), &aPerfMeter, NULL) +#endif + const OpenGl_Aspects* anAspectFace = theWorkspace->ApplyAspects(); const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); diff --git a/src/OpenGl/OpenGl_Resource.hxx b/src/OpenGl/OpenGl_Resource.hxx index 452e0182f4..f4e15a319a 100644 --- a/src/OpenGl/OpenGl_Resource.hxx +++ b/src/OpenGl/OpenGl_Resource.hxx @@ -48,6 +48,10 @@ public: //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules. virtual Standard_Size EstimatedDataSize() const = 0; + //! Dumps the content of me into the stream + virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { (void)theOStream; (void)theDepth; }; + private: //! Copy should be performed only within Handles! diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index ec0f6282d9..f81e5eedc2 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -25,6 +25,12 @@ #include #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif + IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Structure,Graphic3d_CStructure) // ======================================================================= @@ -383,6 +389,9 @@ void OpenGl_Structure::Clear (const Handle(OpenGl_Context)& theGlCtx) void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorkspace, bool& theHasClosed) const { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_Structure::renderGeometry", "", &aPerfMeter, NULL) + if (myInstancedStructure != NULL) { myInstancedStructure->renderGeometry (theWorkspace, theHasClosed); diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index c3ddf5fec4..eaf07a1d76 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -30,6 +30,12 @@ #include #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif + namespace { static const OpenGl_Mat4d THE_IDENTITY_MATRIX; @@ -279,7 +285,25 @@ void OpenGl_Text::StringSize (const Handle(OpenGl_Context)& theCtx, // ======================================================================= void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { + +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + + Standard_SStream aGroupStream; + DumpJson (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "OpenGl_Text::Render", "", &aPerfMeter, NULL) + Handle(Message_Alert) aParentAlert = OCCT_Message_Alert; + const OpenGl_Aspects* aTextAspect = theWorkspace->ApplyAspects(); + aGroupStream.str(""); + aTextAspect->DumpJson (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "aTextAspect", "", &aPerfMeter, aParentAlert) + + aGroupStream.str(""); + OpenGl_Context::DumpJsonOpenGl (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters1", "", &aPerfMeter, aParentAlert) +#endif + const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); const Handle(OpenGl_TextureSet) aPrevTexture = aCtx->BindTextures (Handle(OpenGl_TextureSet)()); @@ -315,6 +339,12 @@ void OpenGl_Text::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { glEnable (GL_DEPTH_TEST); } + +#ifdef DEBUG_INFO + aGroupStream.str(""); + OpenGl_Context::DumpJsonOpenGl (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters2", "", &aPerfMeter, aParentAlert) +#endif } // ======================================================================= @@ -326,7 +356,7 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx, unsigned int theResolution) const { #if !defined(GL_ES_VERSION_2_0) - const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL); + const Standard_Integer aPrevPolygonMode = theCtx->SetPolygonMode (GL_FILL && GL_LINE && GL_POINT); const bool aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false); #endif @@ -613,6 +643,14 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, return; } +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + + Standard_SStream aGroupStream; + OpenGl_Context::DumpJsonOpenGl (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters3", "", &aPerfMeter, NULL) +#endif + // Note that using difference resolution in different Views in same Viewer // will lead to performance regression (for example, text will be recreated every time). const TCollection_AsciiString aFontKey = FontKey (theTextAspect, (Standard_Integer)myText->Height(), theResolution); @@ -768,10 +806,10 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, } case Aspect_TODT_SHADOW: { - BackPolygonOffsetSentry aPolygonOffsetTmp (hasDepthTest ? theCtx : Handle(OpenGl_Context)()); - theCtx->SetColor4fv (theColorSubs); - setupMatrix (theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, -1.0f, 0.0f)); - drawText (theCtx, theTextAspect); + //BackPolygonOffsetSentry aPolygonOffsetTmp (hasDepthTest ? theCtx : Handle(OpenGl_Context)()); + //theCtx->SetColor4fv (theColorSubs); + //setupMatrix (theCtx, theTextAspect, OpenGl_Vec3 (+1.0f, -1.0f, 0.0f)); + //drawText (theCtx, theTextAspect); break; } case Aspect_TODT_DIMENSION: @@ -781,6 +819,12 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, } } +#ifdef DEBUG_INFO + aGroupStream.str(""); + OpenGl_Context::DumpJsonOpenGl (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters4", "", &aPerfMeter, NULL) +#endif + // main draw call theCtx->SetColor4fv (theColorText); setupMatrix (theCtx, theTextAspect, OpenGl_Vec3 (0.0f, 0.0f, 0.0f)); @@ -792,6 +836,12 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, theCtx->ApplyProjectionMatrix(); } +#ifdef DEBUG_INFO + aGroupStream.str(""); + OpenGl_Context::DumpJsonOpenGl (aGroupStream); + MESSAGE_INFO_STREAM (aGroupStream, "openGl_parameters5", "", &aPerfMeter, NULL) +#endif + #if !defined(GL_ES_VERSION_2_0) if (theCtx->core11 != NULL) { @@ -814,16 +864,16 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx, #endif const bool aColorMaskBack = theCtx->SetColorMask (false); - glClear (GL_STENCIL_BUFFER_BIT); - glEnable (GL_STENCIL_TEST); - glStencilFunc (GL_ALWAYS, 1, 0xFF); - glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); + //glClear (GL_STENCIL_BUFFER_BIT); + //glEnable (GL_STENCIL_TEST); + //glStencilFunc (GL_ALWAYS, 1, 0xFF); + //glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); - drawRect (theCtx, theTextAspect, OpenGl_Vec4 (1.0f, 1.0f, 1.0f, 1.0f)); + //drawRect (theCtx, theTextAspect, OpenGl_Vec4 (1.0f, 1.0f, 1.0f, 1.0f)); - glStencilFunc (GL_ALWAYS, 0, 0xFF); + //glStencilFunc (GL_ALWAYS, 0, 0xFF); - theCtx->SetColorMask (aColorMaskBack); + //theCtx->SetColorMask (aColorMaskBack); } // reset OpenGL state @@ -850,13 +900,23 @@ void OpenGl_Text::DumpJson (Standard_OStream& theOStream, const Standard_Integer //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspect.get()); //OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myShadingModel); + //Handle(Graphic3d_Text) myText; //!< text parameters //mutable Handle(OpenGl_Font) myFont; + //mutable NCollection_Vector myTextures; //!< textures' IDs + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextures.Size()); + //mutable NCollection_Vector myVertsVbo; //!< VBOs of vertices - //mutable NCollection_Vector myTCrdsVbo; //!< VBOs of texture coordinates + for (NCollection_Vector::Iterator aCrdsIt (myTCrdsVbo); aCrdsIt.More(); aCrdsIt.Next()) + { + Handle(OpenGl_VertexBuffer) aVertexBuffer = aCrdsIt.Value(); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aVertexBuffer.get()); + } //mutable Handle(OpenGl_VertexBuffer) myBndVertsVbo;//!< VBOs of vertices for bounding box - //mutable Font_Rect myBndBox; + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox); + //mutable OpenGl_Mat4d myProjMatrix; //mutable OpenGl_Mat4d myModelMatrix; //mutable OpenGl_Mat4d myOrientationMatrix; diff --git a/src/OpenGl/OpenGl_VertexBuffer.cxx b/src/OpenGl/OpenGl_VertexBuffer.cxx index 560ccebd66..1d4034c3a1 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.cxx +++ b/src/OpenGl/OpenGl_VertexBuffer.cxx @@ -250,3 +250,20 @@ void OpenGl_VertexBuffer::unbindFixedColor (const Handle(OpenGl_Context)& theCtx theCtx->ShaderManager()->UpdateMaterialState(); } #endif + + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void OpenGl_VertexBuffer::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, OpenGl_VertexBuffer) + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOffset); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBufferId); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComponentsNb); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myElemsNb); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDataType); +} diff --git a/src/OpenGl/OpenGl_VertexBuffer.hxx b/src/OpenGl/OpenGl_VertexBuffer.hxx index 5f259ef7c0..5e012681fb 100644 --- a/src/OpenGl/OpenGl_VertexBuffer.hxx +++ b/src/OpenGl/OpenGl_VertexBuffer.hxx @@ -336,6 +336,9 @@ public: //! @name methods for interleaved attributes array //! Unbind all vertex attributes. Default implementation does nothing. Standard_EXPORT virtual void UnbindAllAttributes (const Handle(OpenGl_Context)& theGlCtx) const; + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: GLubyte* myOffset; //!< offset to data diff --git a/src/OpenGl/OpenGl_View_Redraw.cxx b/src/OpenGl/OpenGl_View_Redraw.cxx index 5f83913b0d..c4a54e30ba 100644 --- a/src/OpenGl/OpenGl_View_Redraw.cxx +++ b/src/OpenGl/OpenGl_View_Redraw.cxx @@ -39,6 +39,12 @@ #include #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif + namespace { //! Format Frame Buffer format for logging messages. @@ -175,6 +181,11 @@ void OpenGl_View::Redraw() return; } +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::Redraw", "", &aPerfMeter, NULL) +#endif + myWindow->SetSwapInterval(); ++myFrameCounter; @@ -614,6 +625,11 @@ void OpenGl_View::RedrawImmediate() return; } +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::RedrawImmediate", "", &aPerfMeter, NULL) +#endif + const Graphic3d_StereoMode aStereoMode = myRenderParams.StereoMode; Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType(); OpenGl_FrameBuffer* aFrameBuffer = myFBO.get(); @@ -771,6 +787,12 @@ void OpenGl_View::redraw (const Graphic3d_Camera::Projection theProjection, OpenGl_FrameBuffer* theReadDrawFbo, OpenGl_FrameBuffer* theOitAccumFbo) { + +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::redraw", "", &aPerfMeter, NULL) +#endif + Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext(); if (theReadDrawFbo != NULL) { @@ -817,6 +839,11 @@ bool OpenGl_View::redrawImmediate (const Graphic3d_Camera::Projection theProject OpenGl_FrameBuffer* theOitAccumFbo, const Standard_Boolean theIsPartialUpdate) { +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::redrawImmediate", "", &aPerfMeter, NULL) +#endif + Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext(); GLboolean toCopyBackToFront = GL_FALSE; if (theDrawFbo == theReadFbo @@ -893,6 +920,11 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection, // Step 1: Prepare for render // ================================== +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::render", "", &aPerfMeter, NULL) +#endif + const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext(); aContext->SetAllowSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage && theOutputFBO != NULL @@ -1103,6 +1135,11 @@ void OpenGl_View::renderStructs (Graphic3d_Camera::Projection theProjection, if ( myZLayers.NbStructures() <= 0 ) return; +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::renderStructs", "", &aPerfMeter, NULL) +#endif + Handle(OpenGl_Context) aCtx = myWorkspace->GetGlContext(); Standard_Boolean toRenderGL = theToDrawImmediate || myRenderParams.Method != Graphic3d_RM_RAYTRACING || @@ -1226,6 +1263,12 @@ void OpenGl_View::renderScene (Graphic3d_Camera::Projection theProjection, OpenGl_FrameBuffer* theOitAccumFbo, const Standard_Boolean theToDrawImmediate) { + +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + MESSAGE_INFO("OpenGl_View::renderScene", "", &aPerfMeter, NULL) +#endif + const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext(); // Specify clipping planes in view transformation space diff --git a/src/OpenGl/OpenGl_Workspace.cxx b/src/OpenGl/OpenGl_Workspace.cxx index adfc4902da..d05046ea25 100644 --- a/src/OpenGl/OpenGl_Workspace.cxx +++ b/src/OpenGl/OpenGl_Workspace.cxx @@ -33,6 +33,12 @@ #include #include +#define DEBUG_INFO +#ifdef DEBUG_INFO +#include +#include +#endif // DEBUG_INFO + IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient) namespace @@ -401,6 +407,14 @@ Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)& // ======================================================================= bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement) { +#ifdef DEBUG_INFO + Message_PerfMeter aPerfMeter; + + Standard_SStream aWorkspaceStream; + DumpJson (aWorkspaceStream); + MESSAGE_INFO_OBJECT(this, aWorkspaceStream, "Workspace", "", &aPerfMeter, NULL) +#endif + // render only non-raytracable elements when RayTracing is enabled if ((myRenderFilter & OpenGl_RenderFilter_NonRaytraceableOnly) != 0) { @@ -447,3 +461,41 @@ bool OpenGl_Workspace::ShouldRender (const OpenGl_Element* theElement) } return true; } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void OpenGl_Workspace::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, OpenGl_Workspace); + + //OpenGl_View* myView; + //Handle(OpenGl_Window) myWindow; + //Handle(OpenGl_Context) myGlContext; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseZBuffer); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseDepthWrite); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myNoneCulling); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myFrontCulling); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbSkippedTranspElems); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRenderFilter); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultAspects); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspectsSet); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myAspectsApplied.get()); + //Handle(Graphic3d_PresentationAttributes) myAspectFaceAppliedWithHL; + + //const OpenGl_Matrix* ViewMatrix_applied; + //const OpenGl_Matrix* StructureMatrix_applied; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToAllowFaceCulling); + //Handle(Graphic3d_PresentationAttributes) myHighlightStyle; + //OpenGl_Matrix myModelViewMatrix; + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myAspectFaceHl); + //Handle(OpenGl_TextureSet) myEnvironmentTexture; +} diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 3a6974e115..1c87f9729f 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -194,6 +194,9 @@ public: //! Returns environment texture. const Handle(OpenGl_TextureSet)& EnvironmentTexture() const { return myEnvironmentTexture; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! @name protected fields OpenGl_View* myView; diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 0b56179b08..82f9268da8 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -419,6 +419,15 @@ void MessageModel_Actions::OnTestPropertyPanel() MESSAGE_INFO_STREAM(aStream, "Quantity_Color", "", &aPerfMeter, NULL); } + // stream of some table values + { + Standard_SStream aStream; + OCCT_DUMP_FIELD_VALUES_NUMERICAL (aStream, "value_1", 1, 100); + OCCT_DUMP_FIELD_VALUES_STRING (aStream, "value_2", 2, "value_1", "value_2"); + + MESSAGE_INFO_STREAM(aStream, "Table: Name to value", "", &aPerfMeter, NULL); + } + // SHAPE messages { BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.)); diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx b/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx index 53e3e76f3c..11b2bb6551 100644 --- a/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx +++ b/tools/VInspector/VInspector_ItemOpenGlLayerList.cxx @@ -153,6 +153,20 @@ QVariant VInspector_ItemOpenGlLayerList::initValue (const int theItemRole) const } return QVariant(); } + +// ====================================================================== +// function : initStream +// purpose : +// ======================================================================= +void VInspector_ItemOpenGlLayerList::initStream (Standard_OStream& theOStream) const +{ + Standard_Boolean isDefault; + const OpenGl_LayerList& aListOfLayers = GetLayerList (isDefault); + if (isDefault) + return; + aListOfLayers.DumpJson (theOStream); +} + // ======================================================================= // function : createChild diff --git a/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx b/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx index ef020efa82..e7598b659c 100644 --- a/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx +++ b/tools/VInspector/VInspector_ItemOpenGlLayerList.hxx @@ -72,6 +72,10 @@ protected: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void initStream (Standard_OStream& theOStream) const; + protected: //! Creates a child item in the given position. -- 2.39.5