View Issue Details

IDProjectCategoryView StatusLast Update
0033607Open CASCADEOCCT:Visualizationpublic2024-09-04 23:58
Reporterhossamali Assigned Tohossamali  
PrioritynormalSeveritymajor 
Status assignedResolutionopen 
Product Version7.8.0 
Target Version7.8.1 
Summary0033607: Visualization - Implementation of hardware occlusion queries
DescriptionHardware occlusion queries makes it possible for an application to ask the 3D API whether or not any pixels would be drawn. This is very useful in applications as instance optimizing rendering performance in rendering complex scenes, if the objects bounds are occluded, the application can skip drawing those objects.
Steps To ReproduceTest case shows the results of occlusion query on two occluded boxes from two perpendicular orthographic projections
steps to produce as follows
1- launch DRAWEXE
2- source tests/v3d/occlusion/ boxes
TagsNo tags attached.
Test case number

Attached Files

  • image.png (938,521 bytes)

Relationships

related to 0033209 assignedhossamali Visualization - No possibility to select only objects visible to user using API of AIS_InteractiveContext 

Activities

git

2024-02-22 20:47

administrator   ~0115156

Branch CR33607 has been created by hossamali.

SHA-1: f286953d85c4177f5b62c8ce135a54d1e69e14f5


No new revisions were added by this update.

dpasukhi

2024-02-23 00:48

administrator   ~0115157

@hossamali what is the empty branch? Please do no create a not used branch

git

2024-02-23 14:46

administrator   ~0115160

Branch CR33607 has been updated by hossamali.

SHA-1: cb40079206890750c4b43032add33605f70bf55a


Detailed log of new commits:

Author: hossamali
Date: Fri Feb 23 11:45:34 2024 +0000

    0033607: Visualization - Implementation of hardware occlusion queries
    
    Occlusion query provides answer to how many pixels samples have passed the rendering pipeline.
    Graphic3d_OcclusionQuery provides convenient access to occlusion query functionality.

git

2024-02-23 20:11

administrator   ~0115163

Branch CR33607 has been updated by hossamali.

SHA-1: 736bac95a7d588055547049659b274d57a5704c6


Detailed log of new commits:

Author: hossamali
Date: Fri Feb 23 16:44:33 2024 +0000

    Opengl implementation for occlusion query

git

2024-02-25 18:20

administrator   ~0115166

Branch CR33607 has been updated by hossamali.

SHA-1: 4138da1e9ba2b7c70c9b991d1157844f1426f530


Detailed log of new commits:

Author: hossamali
Date: Sun Feb 25 15:19:55 2024 +0000

    Graphic3d_ViewOcclusionMask : Provide way to update occlusion query status in specified view
    of the viewer

git

2024-02-25 18:34

administrator   ~0115167

Branch CR33607 has been updated by hossamali.

SHA-1: c90dbe6bd1320da2faae90d61ac2751615816866


Detailed log of new commits:

Author: hossamali
Date: Sun Feb 25 15:34:03 2024 +0000

    add support of view occlusion mask in PrsMgr_PresentableObject

git

2024-02-25 18:41

administrator   ~0115168

Branch CR33607 has been updated by hossamali.

SHA-1: dc4e7428711030babfd7dfcd6c92186a7862a9b3


Detailed log of new commits:

Author: hossamali
Date: Sun Feb 25 15:41:26 2024 +0000

    reset view occlusion mask in new loaded objects in AIS_InteractiveContext

git

2024-02-26 14:30

administrator   ~0115169

Branch CR33607 has been updated by hossamali.

SHA-1: 532aa6215f9219f73b3ebcd16b1672555ce839dc


Detailed log of new commits:

Author: hossamali
Date: Mon Feb 26 11:30:02 2024 +0000

    Enable, disable state for occlusion query in
    Graphic3d_RenderingParams

git

2024-02-26 16:49

administrator   ~0115170

Branch CR33607 has been updated by hossamali.

SHA-1: cc9762c29f4c13a1ea7958c8abe516cc8235f5c8


Detailed log of new commits:

Author: hossamali
Date: Mon Feb 26 13:49:12 2024 +0000

     Generation and destruction of occlusion query resource opengl resources

git

2024-02-28 16:23

administrator   ~0115188

Branch CR33607 has been updated by hossamali.

SHA-1: df0d881d163008b975e2eb53fbb232add1e0d531


Detailed log of new commits:

Author: hossamali
Date: Wed Feb 28 13:23:25 2024 +0000

     Invalidiate occlusion query if camera has changed.

git

2024-02-28 21:02

administrator   ~0115191

Branch CR33607 has been updated by hossamali.

SHA-1: 99f33e21138b0fd4bb08b337ef9f603040a1d19c


Detailed log of new commits:

Author: hossamali
Date: Wed Feb 28 18:02:08 2024 +0000

    mark structures as occluded in specific view

git

2024-02-29 12:07

administrator   ~0115195

Branch CR33607 has been updated by hossamali.

SHA-1: 635e1b949cf4e607f5d631a85198777899f31ec8


Detailed log of new commits:

Author: hossamali
Date: Wed Feb 28 20:59:27 2024 +0000

    passing occlusion mask handle to underlaying
    graphic strcutures

git

2024-02-29 14:45

administrator   ~0115199

Branch CR33607 has been updated by hossamali.

SHA-1: 431824f13a0f767c0b5f4c95b5fea89d9e29ce3f


Detailed log of new commits:

Author: hossamali
Date: Thu Feb 29 11:44:42 2024 +0000

    base case tcl setup

git

2024-02-29 20:09

administrator   ~0115207

Branch CR33607 has been updated by hossamali.

SHA-1: 2bffad2ebf4deaeeecd89fd1d3fe40161d91177b


Detailed log of new commits:

Author: hossamali
Date: Thu Feb 29 17:09:03 2024 +0000

    occlusion query DRAW test command

git

2024-03-04 12:48

administrator   ~0115222

Branch CR33607 has been updated by hossamali.

SHA-1: 42a16d75a9d35736c81ca20789a4e9b5737a793b


Detailed log of new commits:

Author: hossamali
Date: Mon Mar 4 09:48:08 2024 +0000

    cview utility func OccludedStructures() returns map of occluded structs handles

git

2024-03-04 14:16

administrator   ~0115224

Branch CR33607 has been updated by hossamali.

SHA-1: be667f4bcb1f5a45f09be69eb68068ee66950142


Detailed log of new commits:

Author: hossamali
Date: Mon Mar 4 11:16:11 2024 +0000

    force view repaint before test query

git

2024-03-04 19:58

administrator   ~0115226

Branch CR33607 has been updated by hossamali.

SHA-1: 2a10c6467a91432c5037a3a8336578b6b2c8cc0e


Detailed log of new commits:

Author: hossamali
Date: Mon Mar 4 16:57:50 2024 +0000

    add occlusion mask for auxiliaries graphic presenations ( shadows, Trihedron, ..)

git

2024-03-06 16:17

administrator   ~0115246

Branch CR33607 has been updated by hossamali.

SHA-1: a221e284be7c7544fe4f0956ffda89f58c1c6c06


Detailed log of new commits:

Author: hossamali
Date: Wed Mar 6 13:16:02 2024 +0000

    dedeciated func to render occluder presenation

Author: hossamali
Date: Tue Mar 5 17:00:09 2024 +0000

    move query after frustum culling

git

2024-03-06 17:40

administrator   ~0115247

Branch CR33607 has been updated by hossamali.

SHA-1: 3274cbfdc402b932e22389b8ba92867b9639ef45


Detailed log of new commits:

Author: hossamali
Date: Wed Mar 6 14:30:05 2024 +0000

    add computional cost occlusion culling in framestats

git

2024-03-06 18:09

administrator   ~0115249

Branch CR33607 has been updated by hossamali.

SHA-1: 6646056a446335d116341a958c4e1c46edc5396e


Detailed log of new commits:

Author: hossamali
Date: Wed Mar 6 15:09:15 2024 +0000

    validate occlusion state flag after update occlusion test

git

2024-03-06 18:35

administrator   ~0115252

Branch CR33607 has been updated by hossamali.

SHA-1: 1efad574b47902d04d3491e1cf3683e4149e48e0


Detailed log of new commits:

Author: hossamali
Date: Wed Mar 6 15:35:13 2024 +0000

    move occlusion test to opengl_layerlist

git

2024-03-07 10:40

administrator   ~0115254

Branch CR33607 has been updated by hossamali.

SHA-1: 1ef7108b25a8e964842b2b1e9603456b1cdc6f37


Detailed log of new commits:

Author: hossamali
Date: Thu Mar 7 07:39:56 2024 +0000

    restore opengl context state before query

git

2024-03-07 11:27

administrator   ~0115255

Branch CR33607 has been updated by hossamali.

SHA-1: 0c06fb72e8ce63880c30f1b2ac0a08bfc8f60cd5


Detailed log of new commits:

Author: hossamali
Date: Thu Mar 7 08:27:39 2024 +0000

    exclude entire layer culled with view frustum

git

2024-03-07 17:10

administrator   ~0115264

Branch CR33607 has been updated by hossamali.

SHA-1: 53f0a16a4786b5116c0c5642e142ae317a0c8b60


Detailed log of new commits:

Author: hossamali
Date: Thu Mar 7 14:10:29 2024 +0000

    Color and depth masking during query

hossamali

2024-03-07 19:58

developer   ~0115272

below diagram illustrated the main step in the implementation just as clarification for the reviewer
image.png (938,521 bytes)

git

2024-03-08 15:28

administrator   ~0115287

Branch CR33607 has been updated forcibly by hossamali.

SHA-1: 0c44ae5c8a9aa49368d46eca0125f17315773488

iko

2024-03-11 17:37

developer   ~0115304

Please folllow OCC coding rules for all of your code (https://dev.opencascade.org/doc/overview/html/occt_contribution__coding_rules.html).

iko

2024-03-11 17:40

developer   ~0115305

protected:
  unsigned int queryID; // Query object ID


It is implementation detail which should not be in high level abstraction.

iko

2024-03-11 17:45

developer   ~0115306

public:
  DEFINE_STANDARD_RTTIEXT(Graphic3d_OcclusionQuery, Standard_Transient)


All public things are better to place all together (with 'public' keyaword as separator of groups maybe) at the beginning of class.

iko

2024-03-11 17:58

developer   ~0115307

//! Gets number of samples that have passed the rendering pipeline.
unsigned int GetNumSamplesPassed() const;

//! Helper method that returns if any samples have passed the rendering
//! pipeline.
bool AnySamplesPassed() const;


All public not inline methods should be 'Standard_EXPORT'. In other case it is unavaliable after dynamic library loading. Also trivial methods can be inline.

iko

2024-03-11 18:02

developer   ~0115308

unsigned int GetNumSamplesPassed() const;


Meybe there is a sence to make it pure virtual.

iko

2024-03-11 18:07

developer   ~0115309

class Graphic3d_OcclusionQuery : public Standard_Transient {


Queries are asuncronous by its nature in almost all graphic API. The method to check avaliability of query should be in API.

iko

2024-03-11 18:12

developer   ~0115310

class Graphic3d_ViewOcclusionMask : public Standard_Transient


It is the full copy of 'Graphic3d_ViewAffinity'. Don't see any sence to create new class. The existing one can be used instead (with alias maybe).

iko

2024-03-11 18:30

developer   ~0115311

private:
  const Handle(OpenGl_Context) & aCtx;

Standard_EXPORT OpenGl_OcclusionQuery::~OpenGl_OcclusionQuery() {
  aCtx->core15->glDeleteQueries(1, &queryID);
  queryID = 0;
}


Creating and destroying OpenGl entities should be implementetd trough the 'OpenGl_Resource'.

iko

2024-03-11 18:33

developer   ~0115312

Last edited: 2024-03-11 18:39

Standard_EXPORT void OpenGl_OcclusionQuery::EndQuery() {
  aCtx->core15->glEndQuery(GL_SAMPLES_PASSED);
  aCtx->core15->glGetQueryObjectiv(queryID, GL_QUERY_RESULT, &samplesPassed);
}


This implementation just does not work in browsers and mobile devices. There is some assumptions that its does not work on some integrated GPU as well. Query is asyncronous object by it nature. It requires to check of its availiability to obtain of result. And it is asyncronous in term of rendering cycles not just in terms of time. For example in WebGL usually you need to whait 2 or 3 bufffer swap before query's result availability.

iko

2024-03-11 18:36

developer   ~0115313

aCtx->core15->glEndQuery(GL_SAMPLES_PASSED);


It does not exist in WebGL and OpenGL ES. And for occlusion mask we need only binary result so we don't need to know samples number at all. There is special type of query - GL_SAMPLES_PASSED which is crossplatform, returns boolean value and probably more performant.

ebelouso

2024-03-11 18:46

administrator   ~0115316

Dear iko,
In the future, please combine all your remarks into one comment. This is both easier to read and less spam in the timeline.

git

2024-03-19 02:22

administrator   ~0115419

Branch CR33607 has been updated by hossamali.

SHA-1: 783cdc351b2cddf98edc9fb7c64deaa95f42dbfb


Detailed log of new commits:

Author: hossamali
Date: Wed Mar 13 15:08:37 2024 +0000

    review fix

hossamali

2024-03-19 03:11

developer   ~0115420

Jenkin job
http://jenkins-test-10.nnov.opencascade.com/view/CR33607-master-hossamali/

git

2024-07-15 13:14

administrator   ~0116178

Branch CR33607 has been updated by mzernova.

SHA-1: 2ecf6008fa1f4a522fa4fefdc3cc4952182988bc


Detailed log of new commits:

Author: mzernova
Date: Mon Jul 15 11:14:36 2024 +0100

    #Fixed bug with GL_COLOR_WRITEMASK

mzernova

2024-07-19 13:37

developer   ~0116270

Please update your test because currently it's passed in any case and restart Jenkins tests

git

2024-07-19 15:37

administrator   ~0116272

Branch CR33607 has been updated by hossamali.

SHA-1: e087023876d2d5f6b7f5a6fb165520f205a9749a


Detailed log of new commits:

Author: hossamali
Date: Fri Jul 19 15:35:33 2024 +0300

    update occlusion query test

iko

2024-09-03 21:58

developer   ~0116581

//! Returns True if the structure occulded in specified view, otherwise
//! returns False.
Standard_Boolean IsOccluded(const Standard_Integer theViewId) const 
{
  return (!OcclusionMask->IsVisible(theViewId));
}

//! Marks structure as Occluded by other strcuture in specified view,!
void SetOccluionSate(const Standard_Integer theViewId, const bool theIsVisible) const 
{
  OcclusionMask->SetVisible(theViewId, !theIsVisible);
}

// =======================================================================
// function : OccludedStructures
// purpose  :
// =======================================================================
void Graphic3d_CView::OccludedStructures(Graphic3d_MapOfStructure& theStructures) const

//! Returns number of occluded strcutures in the view
Standard_EXPORT void OccludedStructures(Graphic3d_MapOfStructure& theStructures) const;

Missing spaces before non empty brackets. That is only examples. Almost all changes has it. It should be checked carefully.

Standard_EXPORT void UpdateOcclusion(const Handle(OpenGl_Workspace) & theWorkspace);

"&" should not be separate. Please look to surroundings and check all changes again.
enum { Graphic3d_FrameStatsTimer_NB = Graphic3d_FrameStatsTimer_OcclusionCulling + 1 };

Can be just last item in enum instead of being separate enum.
// Turn off writing to depth and color buffers 
aCtx->core11fwd->glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

Depth writing is not disabled.
// Start record occlusion test computational cost  
const Handle(OpenGl_FrameStats) &aStats = theWorkspace->GetGlContext()->FrameStats();

const Handle(Graphic3d_Layer) &aLayer = aLayerIter.ChangeValue();

Handle is shared pointer and should not be used by reference.
private:
  GLuint   myID;                     //!< OpenGL query ID.
  GLenum   myType;                   //!< OpenGL query Type.
  bool     inUse;                    //!< store bool answer is the query still inprogress or finished.
  bool     started;                  //!< bool answer is the query stated before or this the first time.

Should be protected. "inUse" and "started" should be "myInUse" and "myStarted".
void OpenGl_OcclusionQuery::Release(OpenGl_Context *theCtx) {
  if (myID == 0)
    return;
  if (theCtx != NULL) {
    theCtx->core15->glDeleteQueries(1, &myID);
    myID = 0;
    started = false;
  }
}

Strange position of "{" in this function.
if (myQuery->GetID()==0)
    myQuery->Create(aCtx, GL_ANY_SAMPLES_PASSED);

Missing brackets.
class OpenGl_OcclusionQuery : public OpenGl_Resource {

Bracket again.
Standard_EXPORT virtual int IsResultsReady(const Handle(OpenGl_Context) & theCtx) const;

Better to have it bool.
// function : RenderOccluder 
// purpose  : 
// =======================================================================
void OpenGl_Structure::RenderOccluder(const Handle(OpenGl_Workspace)& theWorkspace) const 
{
  const Handle(OpenGl_Context) &aCtx = theWorkspace->GetGlContext();
  aCtx->ApplyModelViewMatrix();
  renderBoundingBox(theWorkspace);
}

Missing separate line.
Handle(OpenGl_OcclusionQuery)      myQuery;             //! test the occlusion status of the structure;

No need to have it as Handle. It could be just field without dynamic memory operations.
  // re-validate occlusion results  
  myRenderParams.OcculsionQueryState = Graphic3d_RenderingParams::OcculsionQuery_On;
}
//=======================================================================
//function : renderStructs

Missing separation line.
aShadowPrs->CStructure()->OcclusionMask =new Graphic3d_ViewOcclusionMask();

Missing space.

dpasukhi

2024-09-04 23:57

administrator   ~0116588

@iko you mentioned only syntax remarks. You can move that part on me.
The main point is functionality. We need to be sure that that will works on real models. With any not trivial cases like self intersected faces and so on.

dpasukhi

2024-09-04 23:58

administrator   ~0116589

Not just boxed or simplest primitives

Issue History

Date Modified Username Field Change
2024-02-20 20:54 hossamali New Issue
2024-02-20 20:54 hossamali Assigned To => hossamali
2024-02-21 13:53 ebelouso Project Community => Open CASCADE
2024-02-21 13:54 ebelouso Relationship added related to 0033209
2024-02-21 14:39 hossamali Description Updated
2024-02-21 14:40 hossamali Description Updated
2024-02-21 14:47 hossamali Description Updated
2024-02-21 14:50 hossamali Summary Implementation of occlusion queries makes it possible for to query whether or not the Interactive objects are visible => Implementation of occlusion queries makes it possible to query whether or not the Interactive objects are visible
2024-02-21 15:33 hossamali Summary Implementation of occlusion queries makes it possible to query whether or not the Interactive objects are visible => Implementation of hardware occlusion queries
2024-02-21 15:33 hossamali Description Updated
2024-02-21 16:45 dpasukhi Target Version => Unscheduled
2024-02-21 16:45 dpasukhi Summary Implementation of hardware occlusion queries => Visualization - Implementation of hardware occlusion queries
2024-02-22 20:47 git Note Added: 0115156
2024-02-23 00:48 dpasukhi Note Added: 0115157
2024-02-23 14:46 git Note Added: 0115160
2024-02-23 20:11 git Note Added: 0115163
2024-02-25 18:20 git Note Added: 0115166
2024-02-25 18:34 git Note Added: 0115167
2024-02-25 18:41 git Note Added: 0115168
2024-02-26 14:31 git Note Added: 0115169
2024-02-26 16:49 git Note Added: 0115170
2024-02-28 16:23 git Note Added: 0115188
2024-02-28 21:02 git Note Added: 0115191
2024-02-29 12:07 git Note Added: 0115195
2024-02-29 14:45 git Note Added: 0115199
2024-02-29 20:09 git Note Added: 0115207
2024-03-04 12:48 git Note Added: 0115222
2024-03-04 14:16 git Note Added: 0115224
2024-03-04 19:58 git Note Added: 0115226
2024-03-06 16:17 git Note Added: 0115246
2024-03-06 17:40 git Note Added: 0115247
2024-03-06 18:09 git Note Added: 0115249
2024-03-06 18:35 git Note Added: 0115252
2024-03-07 10:40 git Note Added: 0115254
2024-03-07 11:27 git Note Added: 0115255
2024-03-07 17:10 git Note Added: 0115264
2024-03-07 19:58 hossamali Note Added: 0115272
2024-03-07 19:58 hossamali File Added: image.png
2024-03-08 15:28 git Note Added: 0115287
2024-03-11 17:37 iko Note Added: 0115304
2024-03-11 17:40 iko Note Added: 0115305
2024-03-11 17:45 iko Note Added: 0115306
2024-03-11 17:58 iko Note Added: 0115307
2024-03-11 18:02 iko Note Added: 0115308
2024-03-11 18:07 iko Note Added: 0115309
2024-03-11 18:12 iko Note Added: 0115310
2024-03-11 18:30 iko Note Added: 0115311
2024-03-11 18:33 iko Note Added: 0115312
2024-03-11 18:36 iko Note Added: 0115313
2024-03-11 18:39 iko Note Edited: 0115312
2024-03-11 18:46 ebelouso Note Added: 0115316
2024-03-13 13:39 ebelouso Target Version Unscheduled => 7.8.1
2024-03-19 02:22 git Note Added: 0115419
2024-03-19 03:11 hossamali Assigned To hossamali => iko
2024-03-19 03:11 hossamali Status new => resolved
2024-03-19 03:11 hossamali Steps to Reproduce Updated
2024-03-19 03:11 hossamali Note Added: 0115420
2024-06-26 13:57 ebelouso Assigned To iko => mzernova
2024-07-15 13:14 git Note Added: 0116178
2024-07-19 13:37 mzernova Assigned To mzernova => hossamali
2024-07-19 13:37 mzernova Status resolved => assigned
2024-07-19 13:37 mzernova Note Added: 0116270
2024-07-19 15:37 git Note Added: 0116272
2024-09-03 21:58 iko Note Added: 0116581
2024-09-04 23:57 dpasukhi Note Added: 0116588
2024-09-04 23:58 dpasukhi Note Added: 0116589