<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1036</bug_id>
          
          <creation_ts>2014-07-27 23:31:08 +0200</creation_ts>
          <short_desc>Fix NVidia&apos;s Windows Driver Threaded optimization bug workaround</short_desc>
          <delta_ts>2014-08-04 14:43:38 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>windows</component>
          <version>2</version>
          <rep_platform>pc_all</rep_platform>
          <op_sys>windows</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>askinner</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>007f120cd8d33e4231ef4d207b85ed156d1e0c82
70c6a54fa2b8dec880b5808d87b31f4afb09dd3b
3ad880dfe3d5eb1eaa9db9860acdf24a3f159a58
adf8e6e40aa9513036864489642cfef252804d08
6cd0a28ff2cb3f1e249b524622abf411536be716</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4034</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-27 23:31:08 +0200</bug_when>
    <thetext>Commit 5166d6a6b617ccb15c40fcb8d4eac2800527aa7b added a workaround for
NVidia&apos;s Windows Driver Threaded optimization bug
existing in NVidia driver 260.99 for Window from 2010-12-11.

[1] The workaround sets a process affinity while JOGL initialization
to mitigate NVidia driver&apos;s &apos;Threaded optimization := On&apos; race conditions.
The process affinity is reset reset after initialization.

[2] The process affinity reset code had a bug, i.e. instead to restore the
original process&apos;s affinity mask, we restored the system&apos;s default affinity mask.

[3] Further more, there seem to be issues with changing a process affinity mask
regarding the process group.

This patch:
    - Solves issue [2] by using the original process affinity mask

    - Solves issue [3] by allowing a custom
    affinity mode via the property &apos;jogl.debug.windows.cpu_affinity_mode&apos;:

        - 0 - none (default, no affinity required for 
              Windows NV driver &gt;= 266.58 from 2011-01-24)

        - 1 - process affinity (was required w/ 
              Windows NV driver 260.99 from 2010-12-11)

        - 2 - thread affinity (experimental)

    Hence the workaround is disabled by default,
    since the crash as documented in 
    commit 5166d6a6b617ccb15c40fcb8d4eac2800527aa7b
    could not be reproduced with NV driver 266.58 from 2011-01-24.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4035</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-27 23:32:03 +0200</bug_when>
    <thetext>Fixed as described in commit 007f120cd8d33e4231ef4d207b85ed156d1e0c82</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4043</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-29 05:43:48 +0200</bug_when>
    <thetext>Re-enabled workaround w/ commit 70c6a54fa2b8dec880b5808d87b31f4afb09dd3b:

Commit 5166d6a6b617ccb15c40fcb8d4eac2800527aa7b added a workaround for
NVidia&apos;s Windows Driver Threaded optimization bug
existing in NVidia driver 260.99 for Window from 2010-12-11.

Commit 007f120cd8d33e4231ef4d207b85ed156d1e0c82
fixed the workaround and made it optional, default: turned off!

Rational of turning the workaround off was due to testing 
against the original test-case &apos;Applet and Webstart&apos;
with drivers &gt;= 266.58 from 2011-01-24,
which did not reproduce this issue.

However, our unit tests reproduced the issue,
e.g. test: com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT

Hence we have to re-enable the workaround per default.

Added the following documentation of the issue:

+++

Since NV driver 260.99 from 2010-12-11 a &apos;Threaded optimization&apos; feature has been introduced.
The driver spawns off a dedicated thread to off-load certain OpenGL tasks from the calling thread
to perform them async and off-thread.

If &apos;Threaded optimization&apos; is manually enabled &apos;on&apos;, the driver may crash with JOGL&apos;s consistent
multi-threaded usage - this is a driver bug.

If &apos;Threaded optimization&apos; is manually disabled &apos;off&apos;, the driver always works correctly.

&apos;Threaded optimization&apos; default setting is &apos;auto&apos; and the driver may crash without this workaround.

If setting the process affinity to &apos;1&apos; (1st CPU) while initialization and launching
the  SharedResourceRunner, the driver does not crash anymore in &apos;auto&apos; mode.
This might be either because the driver does not enable &apos;Threaded optimization&apos;
or because the driver&apos;s worker thread is bound to the same CPU.

Property integer value &lt;code&gt;jogl.debug.windows.cpu_affinity_mode&lt;/code&gt;:
  0 - none (no affinity, may cause driver crash with &apos;Threaded optimization&apos; = [&apos;auto&apos;, &apos;on&apos;])
  1 - process affinity (default, workaround for driver crash for &apos;Threaded optimization&apos; = &apos;auto&apos;, still crashes if set to &apos;on&apos;)

+++

Note: WindowsThreadAffinity does _not_ work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4052</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-30 16:21:45 +0200</bug_when>
    <thetext>adf8e6e40aa9513036864489642cfef252804d08:

Alternative affinity mask setting on all threads of process - Didn&apos;t work (disabled)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4065</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-08-04 14:43:38 +0200</bug_when>
    <thetext>6cd0a28ff2cb3f1e249b524622abf411536be716
  Renamed property to switch off NVidia Windows workaround &apos;jogl.windows.cpu_affinity_mode&apos; (dropping &apos;.debug&apos;)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>