Bug 62698

Summary: [bisected] WebGL demo "Consumed": texstate.c:628: update_texture_state: Assertion „__builtin_popcount(enabledTargets) == 1“ failed.
Product: Mesa Reporter: Pavel Ondračka <pavel.ondracka>
Component: glsl-compilerAssignee: Kenneth Graunke <kenneth>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: idr
Version: gitKeywords: regression
Hardware: Other   
OS: All   
URL: http://playground.christianwannerstedt.com/projects/consumed/
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 67224    
Attachments: full backtrace

Description Pavel Ondračka 2013-03-24 14:29:00 UTC
Created attachment 76964 [details]
full backtrace

Reproducible with swrast and i965 (GM45), gallium drivers seems fine. Just grab latest Firefox and go to http://playground.christianwannerstedt.com/projects/consumed/ 

First bad commit:
b610881317a7775a7ffe5f032099d8b2dc45eff0 is the first bad commit
commit b610881317a7775a7ffe5f032099d8b2dc45eff0
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Tue Apr 10 10:40:11 2012 -0700

    glsl: Initialize samplers to 0, propagate sampler values to the gl_program
    The spec requires that samplers be initialized to 0.  Since this
    differs from the 1-to-1 mapping of samplers to texture units assumed
    by ARB assembly shaders (and the gl_program structure), be sure to
    propagate this date from the gl_shader_program to the gl_program.
    Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
    CC: Vadim Girlin <vadimgirlin@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=49088

firefox: ../../../src/mesa/main/texstate.c:628: update_texture_state: Assertion „__builtin_popcount(enabledTargets) == 1“ failed.
[New Thread 0x7fffc157f700 (LWP 31074)]

Program received signal SIGABRT, Aborted.
0x0000003a43635ba5 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:63
63	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  0x0000003a43635ba5 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:63
#1  0x0000003a43637358 in __GI_abort () at abort.c:90
#2  0x0000003a4362e972 in __assert_fail_base (fmt=
    0x7ffff7ec56d4 "%s%s%s:%u: %s%sPředpoklad „%s“ nesplněn.\n%n", 
    0x7fffc6b534f0 "__builtin_popcount(enabledTargets) == 1", file=file@entry=
    0x7fffc6b53098 "../../../src/mesa/main/texstate.c", line=line@entry=628, 
    0x7fffc6b53650 <__PRETTY_FUNCTION__.28368> "update_texture_state")
    at assert.c:92
#3  0x0000003a4362ea22 in __GI___assert_fail (assertion=
    0x7fffc6b534f0 "__builtin_popcount(enabledTargets) == 1", file=
    0x7fffc6b53098 "../../../src/mesa/main/texstate.c", line=628, function=
    0x7fffc6b53650 <__PRETTY_FUNCTION__.28368> "update_texture_state")
    at assert.c:101
#4  0x00007fffc69549c6 in update_texture_state (ctx=0x7fffe16a8030)
    at ../../../src/mesa/main/texstate.c:628
#5  0x00007fffc6954b5e in _mesa_update_texture (ctx=0x7fffe16a8030, new_state=
    760714527) at ../../../src/mesa/main/texstate.c:685
#6  0x00007fffc6928790 in _mesa_update_state_locked (ctx=0x7fffe16a8030)
    at ../../../src/mesa/main/state.c:493
#7  0x00007fffc69289b0 in _mesa_update_state (ctx=0x7fffe16a8030)
    at ../../../src/mesa/main/state.c:588
#8  0x00007fffc6948574 in teximage (ctx=0x7fffe16a8030, compressed=0 '\000', 
    dims=2, target=3553, level=0, internalFormat=6408, width=2048, height=
    1024, depth=1, border=0, format=6408, type=5121, imageSize=0, pixels=
    0x7fffbe600000) at ../../../src/mesa/main/teximage.c:3126
#9  0x00007fffc6948896 in _mesa_TexImage2D (target=3553, level=0, 
    internalFormat=6408, width=2048, height=1024, border=0, format=6408, type=
    5121, pixels=0x7fffbe600000) at ../../../src/mesa/main/teximage.c:3188
#10 0x00007ffff782cbce in shared_dispatch_stub_183 (target=3553, level=0, 
    internalformat=6408, width=2048, height=1024, border=0, format=6408, type=
    5121, pixels=0x7fffbe600000)
    at ../../../src/mapi/shared-glapi/glapi_mapi_tmp.h:14133
#11 0x0000003a5581c5ec in mozilla::WebGLContext::CheckedTexImage2D (
    this=this@entry=0x7fffdba87c00, target=target@entry=3553, 
    level=level@entry=0, internalFormat=6408, width=width@entry=2048, 
    height=height@entry=1024, border=border@entry=0, format=format@entry=6408, 
    type=type@entry=5121, data=0x7fffbe600000)
    at /usr/src/debug/xulrunner-19.0.2/mozilla-release/content/canvas/src/WebGLContextGL.cpp:4725

Full backtrace attached.
Comment 1 Kenneth Graunke 2013-07-25 20:51:56 UTC
I mailed out a Piglit test that reproduces this:

Doesn't look too hard to fix.
Comment 2 Kenneth Graunke 2013-07-25 21:46:39 UTC
I've sent a proposed patch to mesa-dev:
Comment 3 Kenneth Graunke 2013-07-30 05:43:43 UTC
commit 07cdf426c108eca93ac8ff3c682e2c800a5f5d20
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Thu Jul 25 14:47:58 2013 -0700

    mesa: Remove broken assertion about enabled texture targets.
    For GLSL programs, enabledTargets can have more than one bit set.  For
    example, a shader that uses sampler2D and samplerCube uniforms will have
    The code that sets _ReallyEnabled already handles this, selecting the
    "highest priority" texture target.  We should simply use that.
    Fixes new Piglit test incomplete-textures-of-multiple-types.
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62698
    Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
    Reviewed-by: Brian Paul <brianp@vmware.com>

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.