Bug 31986

Summary: [GLSL] matrix operation broken
Product: Mesa Reporter: jiajia <jiajia.zheng>
Component: Drivers/DRI/i965Assignee: Ian Romanick <idr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: medium CC: shuang.he, vlee
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: matrix_operation.shader_test
matrix_operation.shader_test

Description jiajia 2010-11-30 00:47:21 UTC
Below shader failed on Calpella (i965) with mesa master:
Probe at (0,0)
  Expected: 0.500000 0.500000 0.500000 0.500000
  Observed: 0.501961 0.501961 0.000000 1.000000
PIGLIT: {'result': 'fail' }


[require]
GL >= 2.0
GLSL >= 1.10

[fragment shader]


void main(void)
{
mat2 m = mat2(0.5, 0.5, 0.5, 0.5);
m[0][0] = m[0][0] + 0.3;
m[0][0] = m[0][0] - 0.3;
     gl_FragColor = vec4(m[0][0], m[0][1], m[1][0], m[1][1]);
}

[test]
draw rect -1 -1 2 2
probe all rgba 0.5 0.5 0.5 0.5
Comment 1 jiajia 2010-11-30 00:48:02 UTC
Created attachment 40659 [details]
matrix_operation.shader_test
Comment 2 jiajia 2010-11-30 00:57:55 UTC
Created attachment 40660 [details]
matrix_operation.shader_test

sorry, typo in previous attachment. Please use this one.
Comment 3 Ian Romanick 2010-12-01 15:46:52 UTC
I was only able to reproduce this using the i965 driver.  swrast and i915 do not exhibit this failure.
Comment 4 Gordon Jin 2010-12-01 16:20:41 UTC
increasing priority, as this impacts many matrix tests.
Comment 5 Ian Romanick 2010-12-01 16:46:18 UTC
I debugged this a bit more.  It looks like fs_visitor::visit(ir_constant *ir) in brw_fs.cpp isn't handling matrices, arrays, or structures correctly.  Hacking this up to handle matrices fixes this bug, but this particular problem may affect other tests.  I'll come up with a full fix soon.
Comment 6 Ian Romanick 2010-12-03 10:53:25 UTC
I added piglit tests glsl-const-initializer-0[123] to reproduce this set of errors.
Comment 7 Ian Romanick 2010-12-07 15:25:30 UTC
We could use a better for the structure case.  Right now the structures get split out, and the new code in brw_fs.cpp is never executed.

commit 6848e27e1462e98dd91826a06f96c203c9eeebd0
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Tue Dec 7 14:50:34 2010 -0800

    i965: Correctly emit constants for aggregate types (array, matrix, struct)
    
    Previously the code only handled scalars and vectors.  This new code
    is modeled somewhat after similar code in ir_to_mesa.
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
Comment 8 Ian Romanick 2010-12-07 17:24:09 UTC
*** Bug 32201 has been marked as a duplicate of this bug. ***
Comment 9 Gordon Jin 2010-12-09 20:14:11 UTC
verified
Comment 10 Shuang He 2010-12-10 16:54:50 UTC
*** Bug 30915 has been marked as a duplicate of this bug. ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.