View Issue Details

IDProjectCategoryView StatusLast Update
0030136Open CASCADEOCCT:Visualizationpublic2019-08-15 17:49
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version7.3.0 
Target Version7.4.0Fixed in Version7.4.0 
Summary0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
DescriptionEnabling Graphic3d_TOSM_FACET produces incorrect result on tested mobile devices - see attached screenshots.

Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_ShaderProgram)& theProgram,
                                                               const Standard_Integer        theBits,
                                                               const Standard_Boolean        theIsFlatNormal)
{
  #define thePhongCompLight "computeLighting (normalize (Normal), normalize (View), Position, gl_FrontFacing)"
#if defined(GL_ES_VERSION_2_0)
  const bool isFlatNormal = theIsFlatNormal
                         && (myContext->IsGlGreaterEqual (3, 0)
                          || myContext->oesStdDerivatives);
#else
  const bool isFlatNormal = theIsFlatNormal;
#endif


Note that isFlatNormal is expected to be TRUE on both devices (they report OpenGL ES 3.0 and OpenGL ES 3.2 support).
Steps To ReproduceNot required
TagsNo tags attached.
Test case numberNot required

Attached Files

  • Screenshot_20180912-162918.png (86,718 bytes)
  • Screenshot_20180912-163029_CAD Assistant.jpg (373,164 bytes)
  • FlatShadingES31.png (214,631 bytes)
  • testResults.JPG (63,809 bytes)
  • tegra4_flat_shading1_KO.jpg (861,833 bytes)
  • tegra4_flat_shading2_KO.jpg (1,526,082 bytes)

Relationships

child of 0028069 closedbugmaster Open CASCADE Visualization, TKOpenGl - handle flat shading model within GLSL programs 

Activities

kgv

2018-09-12 16:48

developer  

Screenshot_20180912-162918.png (86,718 bytes)

kgv

2018-09-12 16:48

developer  

Screenshot_20180912-163029_CAD Assistant.jpg (373,164 bytes)

mnv

2018-09-13 18:01

developer  

FlatShadingES31.png (214,631 bytes)

mnv

2018-09-13 18:02

developer   ~0079178

Problem on mobile devices with OpenGl ES 3.1+ is potentially (because tested only on devices with Adreno GPU) solved. Need to test it on more devices with different GPU.

git

2018-09-14 18:01

administrator   ~0079197

Branch CR30136 has been created by mnv.

SHA-1: 51407de00f4939fd9cc49df20102e0a13d903caa


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Fixed unexpected behaviour of gl_FrontFacing on mobile devices with Adreno GPU (OpenGl ES 3.1+).
    Added graphic3d_limit for using with OpenGl ES 3.0.

git

2018-09-17 16:54

administrator   ~0079218

Branch CR30136_1 has been created by mnv.

SHA-1: 6a1e3dcb9ca673d399da2e9913c94ccfc4062217


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Added new type of graphic3d limit Graphic3d_TypeOfLimit_HasFlatShading.
    Added workaround for unexpected behaviour of mobile devices with Adreno GPU.
    Added new complex flag hasFlatShading to OpenGl_Context for indicating support of flat shading.

git

2018-09-17 16:57

administrator   ~0079219

Branch CR30136_1 has been updated forcibly by mnv.

SHA-1: 033cb273d59b86df1c0d1f29c7eff835eed2e1d5

mnv

2018-09-18 08:29

developer   ~0079227

Patch is ready for review.

mnv

2018-09-18 08:29

developer  

testResults.JPG (63,809 bytes)

kgv

2018-09-18 09:56

developer   ~0079229

+    case Graphic3d_TypeOfLimit_HasFlatShading:
+      return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable && aCtx->hasHighp ? 1 : 0;

This code is confusing - it is expected that hasFlatShading already considers hasHighp value.

+    hasFlatShading = IsGlGreaterEqual (3, 0) ? OpenGl_FeatureInCore :
+                     CheckExtension ("GL_OES_standard_derivatives") ? OpenGl_FeatureInExtensions
+                                                                    : OpenGl_FeatureNotAvailable;

Within nested comparisons, it is better using braces:
  hasFlatShading = IsGlGreaterEqual (3, 0)
                 ? OpenGl_FeatureInCore
                 : (CheckExtension ("GL_OES_standard_derivatives")
                  ? OpenGl_FeatureInExtensions
                  : OpenGl_FeatureNotAvailable);


+  TCollection_AsciiString Vendor() const { return myVendor; }

const TCollection_AsciiString&

+  Graphic3d_TypeOfLimit_HasFlatShading,                 //!< indicates whether flat shading is supported.
...
+  OpenGl_FeatureFlag     hasFlatShading;     //!< Complex flag indicating support of Flat shading (always available on desktop; on OpenGL ES - since 3.0 or as extension GL_OES_standard_derivatives)

Please clarify associated enumeration value "Flat shading (Graphic3d_TOSM_FACET)" in comments.

+  if (myVendor.Search("Qualcomm") != -1)

Please put "Adreno" and description of observed misbehavior in comments.

+#if !defined(GL_ES_VERSION_2_0)
+  const TCollection_AsciiString aNormalCorrection = EOL"  if (!gl_FrontFacing) { Normal = -Normal; }";
+#else
+  const TCollection_AsciiString aNormalCorrection = (myContext->Vendor().Search("Qualcomm") != -1) ? EOL"  if (gl_FrontFacing) { Normal = -Normal; }"
+                                                                                                   : EOL"  if (!gl_FrontFacing) { Normal = -Normal; }";
+#endif

I would expect that this workaround should be applied to Normal computations using dFdx/dFdy (which are buggy), not to reversion gl_FrontFacing (which cannot be buggy, otherwise we would have artifacts in other programs using gl_FrontFacing).

Please also emit a TRACE message about applied workaround.

git

2018-09-18 14:14

administrator   ~0079238

Branch CR30136_2 has been created by mnv.

SHA-1: a4e77ea81b9e32b25938312202508774b7048794


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Added new type of graphic3d limit Graphic3d_TypeOfLimit_HasFlatShading.
    Added workaround for unexpected behaviour of mobile devices with Adreno GPU.
    Added new complex flag hasFlatShading to OpenGl_Context for indicating support of flat shading.

git

2018-09-18 14:14

administrator   ~0079239

Branch CR30136_1 has been updated by mnv.

SHA-1: 0201c1acc2e1a4c3b37625210100f4308b0430cc


Detailed log of new commits:

Author: mnv
Date: Tue Sep 18 14:05:33 2018 +0300

    Review comments.

kgv

2018-09-19 11:32

developer  

tegra4_flat_shading1_KO.jpg (861,833 bytes)

kgv

2018-09-19 11:32

developer  

tegra4_flat_shading2_KO.jpg (1,526,082 bytes)

git

2018-09-19 14:19

administrator   ~0079259

Branch CR30136_2 has been updated forcibly by mnv.

SHA-1: 065bd49889036e846c5abc6b2aa40dc047872ac2

mnv

2018-09-20 10:18

developer   ~0079268

Patch is ready for review.

git

2018-09-20 12:17

administrator   ~0079273

Branch CR30136_3 has been created by kgv.

SHA-1: 9b216726ec0da45e248fe3dea70030a9f4fcc29c


Detailed log of new commits:

Author: mnv
Date: Thu Sep 13 17:47:51 2018 +0300

    0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices
    
    Added new type of graphic3d limit Graphic3d_TypeOfLimit_HasFlatShading.
    Added workaround for unexpected behaviour of mobile devices with Adreno GPU.
    Added new complex flag hasFlatShading to OpenGl_Context for indicating support of flat shading.

kgv

2018-09-20 13:09

developer   ~0079276

Please take the patch CR30136_3.

git

2018-09-20 16:17

administrator   ~0079291

Branch CR30136_3 has been updated forcibly by kgv.

SHA-1: ef0a2463a8613874c9a9481df295fd81e78dfb33

bugmaster

2018-09-24 12:12

administrator   ~0079352

Checked on IR-WEEK38

Combination -
OCCT branch : IR-WEEK38 SHA - 4ba5491a5086e36ca655c2db882d37308e4ff575
Products branch : IR-WEEK38 SHA - 24d9a5880924c9569ea9ab38393ed8ce950ed8ee
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 11498.140000000229 / 11497.700000000234 [+0.00%]
Products
Total CPU difference: 7475.5500000000475 / 7467.690000000077 [+0.11%]
Windows-64-VC14:
OCCT
Total CPU difference: 17474.68601649851 / 17536.33761169853 [-0.35%]
Products
Total CPU difference: 8409.1091042 / 8382.276932199968 [+0.32%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2018-09-30 18:47

administrator   ~0079514

Branch CR30136_3 has been deleted by inv.

SHA-1: ef0a2463a8613874c9a9481df295fd81e78dfb33

git

2018-09-30 18:47

administrator   ~0079516

Branch CR30136_2 has been deleted by inv.

SHA-1: 065bd49889036e846c5abc6b2aa40dc047872ac2

git

2018-09-30 18:47

administrator   ~0079519

Branch CR30136_1 has been deleted by inv.

SHA-1: 0201c1acc2e1a4c3b37625210100f4308b0430cc

git

2018-09-30 18:48

administrator   ~0079523

Branch CR30136 has been deleted by inv.

SHA-1: 51407de00f4939fd9cc49df20102e0a13d903caa

Related Changesets

occt: master c39bb31b

2018-09-13 14:47:51

mnv


Committer: bugmaster Details Diff
0030136: Visualization, TKOpenGl - Graphic3d_TOSM_FACET does not work on mobile devices

Added new type of graphic3d limit Graphic3d_TypeOfLimit_HasFlatShading.
Added workaround for unexpected behaviour of mobile devices with Adreno GPU.
Added new complex flag hasFlatShading to OpenGl_Context for indicating support of flat shading.
Affected Issues
0030136
mod - src/Graphic3d/Graphic3d_TypeOfLimit.hxx Diff File
mod - src/OpenGl/OpenGl_Context.cxx Diff File
mod - src/OpenGl/OpenGl_Context.hxx Diff File
mod - src/OpenGl/OpenGl_GraphicDriver.cxx Diff File
mod - src/OpenGl/OpenGl_ShaderManager.cxx Diff File

Issue History

Date Modified Username Field Change
2018-09-12 16:48 kgv New Issue
2018-09-12 16:48 kgv Assigned To => mnv
2018-09-12 16:48 kgv File Added: Screenshot_20180912-162918.png
2018-09-12 16:48 kgv File Added: Screenshot_20180912-163029_CAD Assistant.jpg
2018-09-12 16:49 kgv Description Updated
2018-09-12 17:22 kgv Relationship added child of 0028069
2018-09-12 17:27 kgv Status new => assigned
2018-09-13 18:01 mnv File Added: FlatShadingES31.png
2018-09-13 18:02 mnv Note Added: 0079178
2018-09-14 18:01 git Note Added: 0079197
2018-09-17 16:54 git Note Added: 0079218
2018-09-17 16:57 git Note Added: 0079219
2018-09-18 08:29 mnv Note Added: 0079227
2018-09-18 08:29 mnv Assigned To mnv => kgv
2018-09-18 08:29 mnv Status assigned => resolved
2018-09-18 08:29 mnv Steps to Reproduce Updated
2018-09-18 08:29 mnv File Added: testResults.JPG
2018-09-18 09:56 kgv Note Added: 0079229
2018-09-18 09:56 kgv Assigned To kgv => mnv
2018-09-18 09:56 kgv Status resolved => assigned
2018-09-18 14:14 git Note Added: 0079238
2018-09-18 14:14 git Note Added: 0079239
2018-09-19 11:32 kgv File Added: tegra4_flat_shading1_KO.jpg
2018-09-19 11:32 kgv File Added: tegra4_flat_shading2_KO.jpg
2018-09-19 14:19 git Note Added: 0079259
2018-09-20 10:18 mnv Note Added: 0079268
2018-09-20 10:18 mnv Assigned To mnv => kgv
2018-09-20 10:18 mnv Status assigned => resolved
2018-09-20 12:17 git Note Added: 0079273
2018-09-20 13:09 kgv Note Added: 0079276
2018-09-20 13:09 kgv Assigned To kgv => bugmaster
2018-09-20 13:09 kgv Status resolved => reviewed
2018-09-20 16:17 git Note Added: 0079291
2018-09-24 12:12 bugmaster Note Added: 0079352
2018-09-24 12:12 bugmaster Status reviewed => tested
2018-09-30 18:26 bugmaster Changeset attached => occt master c39bb31b
2018-09-30 18:26 bugmaster Status tested => verified
2018-09-30 18:26 bugmaster Resolution open => fixed
2018-09-30 18:47 git Note Added: 0079514
2018-09-30 18:47 git Note Added: 0079516
2018-09-30 18:47 git Note Added: 0079519
2018-09-30 18:48 git Note Added: 0079523
2019-08-15 17:49 bugmaster Test case number => Not required