Bug 44339 - [GLSL 1.30]ivec2 textureSize(gsampler2D sampler, int lod) return with wrong value in vertex shader
Summary: [GLSL 1.30]ivec2 textureSize(gsampler2D sampler, int lod) return with wrong v...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: All Linux (All)
: medium normal
Assignee: Kenneth Graunke
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-31 00:05 UTC by Ouping Zhang
Modified: 2012-01-12 13:49 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Ouping Zhang 2011-12-31 00:05:57 UTC
System Environment:
--------------------------
Libdrm:         (master)2.4.29-3-gef20301a11afae50bfe127002913dbd0b81ddccc
Mesa:           (master)b50d250e02457f367c195ee1808b061e0dfe2d00
Xf86_video_intel:   (master)2.17.0-237-g8fc21328a0bdf87fde35d68d2b27834011acde7b

Bug detailed description:
-------------------------
run this piglit case:
[require]
GLSL >= 1.30

[fragment shader]
#version 130
precision mediump float;
void main() { gl_FragColor = gl_Color; }

[vertex shader]
#version 130
precision mediump float;
uniform sampler2D tex;
void main()
{
        gl_Position = gl_Vertex;
        gl_FrontColor = vec4(0,(textureSize(tex, 0)==ivec2(1024, 1024)),0,1);
}

[test]
texture checkerboard 0 0 (1024, 1024) (0.0, 0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 0.0)
uniform int tex 0
draw rect -1 -1 2 2
relative probe rgb (0.75, 0.75) (0.0, 1.0, 0.0)

but the result as below: 
Expected: 0.000000 1.000000 0.000000
Observed: 0.000000 0.000000 0.000000

run this piglit case:
[require]
GLSL >= 1.30

[vertex shader]
#version 130
precision mediump float;
void main() { gl_Position = gl_Vertex; }

[fragment shader]
#version 130
precision mediump float;
uniform sampler2D tex;
void main()
{
        gl_FragColor = vec4(0,(textureSize(tex, 0)==ivec2(1024, 1024)),0,1);
}

[test]
texture checkerboard 0 0 (1024, 1024) (0.0, 0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 0.0)
uniform int tex 0
draw rect -1 -1 2 2
relative probe rgb (0.75, 0.75) (0.0, 1.0, 0.0)

the result as below:
PIGLIT: {'result': 'pass' }

ivec2 textureSize(gsampler2D sampler, int lod) return with wrong value in vertex shader, but it works well in fragment shader.
Comment 1 Kenneth Graunke 2012-01-04 02:12:28 UTC
Confirmed.  Looks like a bug in the i965 vertex shader backend.

I have a patch that fixes the issue, and a lot of other oglconform tests, but it breaks a few, and I haven't yet figured out why.  Similar but subtly different patches fix and break different sets of tests.  It's been very confusing.

For now, marking this assigned.  Thanks for the piglit test!
Comment 2 Kenneth Graunke 2012-01-04 04:06:03 UTC
Patch on mailing list:
[PATCH] i965/vs: Use the proper dimensionality for the sampler result register.
Comment 3 Kenneth Graunke 2012-01-10 16:48:50 UTC
commit fbbbc8c04e2462a0ae272d81e61eee5f85f08aa6
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Mon Jan 2 15:51:58 2012 -0800

    i965/vs: Use the proper dimensionality for the sampler result register.
    
    textureSize() returns an int, ivec2, or ivec3, but never an ivec4.
    Creating the destination register as an ivec4 triggered later failures,
    even though the register did hold the proper values.
    
    For example, piglit test vs-textureSize-compare calls textureSize on a
    2D texture and compares the result to an expected value.  Unfortunately,
    our generated code also tried to compare the third and fourth components
    which were undefined, and failed.
    
    Fixes piglit test vs-textureSize-compare as well as 19 subcases of
    oglconform's glsl-bif-tex-size test.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44339
    Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
    Reviewed-by: Eric Anholt <eric@anholt.net>
Comment 4 Gordon Jin 2012-01-12 00:40:33 UTC
Ken, do you think Ouping's case should be added into piglit?
Comment 5 Kenneth Graunke 2012-01-12 13:49:04 UTC
Yes, definitely.  I sent it out to the list a while ago, but hadn't received any comments.  I just pushed it today.  Thanks!


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.