<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - ProgramBinary does not switch program correctly when using transform feedback"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=106810">106810</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ProgramBinary does not switch program correctly when using transform feedback
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/i965
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>xinghua.cao@intel.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Steps:
1. Download chrome and install it on your Ubuntu,
<a href="https://www.google.com/chrome/?platform=linux&extra=devchannel">https://www.google.com/chrome/?platform=linux&extra=devchannel</a>.
2. Open the link,
<a href="https://www.khronos.org/registry/webgl/sdk/tests/deqp/functional/gles3/negativeshaderapi.html?webglVersion=2&quiet=0">https://www.khronos.org/registry/webgl/sdk/tests/deqp/functional/gles3/negativeshaderapi.html?webglVersion=2&quiet=0</a>
3. some cases fail, if not, please continuously press the "refresh"
button.(Because this issue happens when using ProgramBinary, not LinkProgram) 

Note:
This case only tests that "A INVALID_OPERATION error is generated by
LinkProgram if program is being used by one or more transform feedback
objects".
List main code of a case as below, with simple vertex shader and pixel shader,
and one output "gl_Position" of vertex shader, which used for transform
feedback.

var program = new gluShaderProgram.ShaderProgram(gl,
gluShaderProgram.makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
var buf;
var tfID;
var tfVarying = ['gl_Position'];
tfID = gl.createTransformFeedback();
buf = gl.createBuffer();
gl.useProgram(program.getProgram());
gl.transformFeedbackVaryings(program.getProgram(), tfVarying,
gl.INTERLEAVED_ATTRIBS);
gl.linkProgram(program.getProgram());
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, tfID);
gl.bindBuffer(gl.TRANSFORM_FEEDBACK_BUFFER, buf);
gl.bufferData(gl.TRANSFORM_FEEDBACK_BUFFER, 32, gl.DYNAMIC_DRAW);
gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buf);
gl.beginTransformFeedback(gl.TRIANGLES);
this.expectError(gl.NO_ERROR);            

gl.linkProgram(program.getProgram());
this.expectError(gl.INVALID_OPERATION);

ShaderProgram construct function also calls linkProgram to generate "program "
object. Above code totally calls linkProgram three times.
The first time runs this case, could pass.
In order to improve performance, chromium had cached program binary after
calling this first two linkProgram calls, so would cache two program binary
objects (programBinary1 and ProgramBinary2), programBinary1 without transform
feedback, programBinary2 with transform feedback. The second time run this
case, the code maybe as below,

gl.programBinary(programBinary1...);
var buf;
var tfID;
var tfVarying = ['gl_Position'];
tfID = gl.createTransformFeedback();
buf = gl.createBuffer();
gl.useProgram(program.getProgram());
gl.transformFeedbackVaryings(program.getProgram(), tfVarying,
gl.INTERLEAVED_ATTRIBS);
gl.programBinary(programBinary2...);
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, tfID);
gl.bindBuffer(gl.TRANSFORM_FEEDBACK_BUFFER, buf);
gl.bufferData(gl.TRANSFORM_FEEDBACK_BUFFER, 32, gl.DYNAMIC_DRAW);
gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buf);
gl.beginTransformFeedback(gl.TRIANGLES);
this.expectError(gl.NO_ERROR);       //!!!!!!! Error happens here,
glBeginTransformFeedback(no varyings to record)
gl.linkProgram(program.getProgram());
this.expectError(gl.INVALID_OPERATION);

When calling gl.programBinary(programBinary2...), Mesa did not implicitly call
useProgram to swich "gl_program" from programBinary1 to programBinary2, make
"gl_program" object of programBinary2 as current program, even these two
"gl_program" object shared the same "gl_shader_program".
Please help check whether this investigation is correct. Thank you.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>