nv50,nvc0: add RGBX16/32_FLOAT formats
nvc0: fix 2D engine MS2 resolve
nvc0: patch up TEX cases with 5 or 6 sources on nve4

Hackishly fixes alignment requirement of 2nd tuple for now.
nvc0: implement multisample textures
nv50/codegen: do not emitATOM() if the subOp is unknown

For debug build we'll hit the assert, for release we are going to emit random data
as subOp is used uninitilised. Spotted by gcc

codegen/nv50_ir_emit_nv50.cpp: In member function 'void nv50_ir::CodeEmitterNV50::emitATOM(const nv50_ir::Instruction*)':
codegen/nv50_ir_emit_nv50.cpp:1554:12: warning: 'subOp' may be used uninitialized in this function [-Wmaybe-uninitialized]
    uint8_t subOp;
            ^

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
nvc0: compile nve4_cache_split_name() only in debug build

As otherwise it is unused - pointed out by gcc

nve4_compute.c:586:20: warning: 'nve4_cache_split_name' defined but not used [-Wunused-function]
 static const char *nve4_cache_split_name(unsigned value)
                    ^

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
nvc0: bail out early during nve4_compute_setup()

Exit gracefully rather than trying to create a random object, whenever the
chipset is unknown

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
nvc0: set ret variable if launch desc allocation failed

Pointed out by gcc

nve4_compute.c: In function 'nve4_launch_grid':
nve4_compute.c:511:7: warning: 'ret' may be used uninitialized in
 this function [-Wmaybe-uninitialized]
    if (ret)
       ^

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>

Edit by Christoph Bumiller:
Set it to -1 to indicate failure and only when it's actually required.
r300g: Fix bug in OMOD optimization

https://bugs.freedesktop.org/show_bug.cgi?id=60503

NOTE: This is a candidate for the stable branches.
glsl: Fix hypothetical NULL dereference in ast_process_structure_or_interface_block

Fixes issue identified by Klocwork analysis:

    Pointer 'field_type' returned from call to function 'glsl_type' at
    line 4126 may be NULL and may be dereferenced at line 4139.  Also
    there are 2 similar errors on line(s) 4165, 4174.

In practice, it should be impossible to actually get NULL in here
because a syntax error would have already caused compilation to halt.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
glsl: Fix hypothetical NULL dereference related to process_array_type

Ensure that process_array_type never returns NULL, and let
process_array_type handle the case where the supplied base type is NULL.

Fixes issues identified by Klocwork analysis:

    Pointer 'type' returned from call to function 'get_type' at line
    1907 may be NULL and may be dereferenced at line 1912.

and

    Pointer 'field_type' checked for NULL at line 4160 will be
    dereferenced at line 4165. Also there is one similar error on line
    4174.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
mesa: NULL check the pointer before trying to dereference it

Duh.

Fixes issues identified by Klocwork analysis:

    Pointer 'table' returned from call to function 'calloc' at line 115
    may be NULL and will be dereferenced at line 117.

and

    Suspicious dereference of pointer 'table' before NULL check at line
    119.

NOTE: This is a candidate for the stable branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
egl/dri2: NULL check value returned by dri2_create_surface

dri2_create_surface can fail for a variety of reasons, including bad
input data.  Dereferencing the NULL pointer and crashing is not okay.

Fixes issue identified by Klocwork analysis:

    Pointer 'surf' returned from call to function 'dri2_create_surface'
    at line 285 may be NULL and will be dereferenced at line 291.

NOTE: This is a candidate for the stable branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
mesa: Don't leak shared state when context initialization fails

Back up at line 1017 (not shown in patch), we add a reference to the
shared state.  Several places after that may divert to the error
handler, but, as far as I can tell, nothing ever unreferences the shared
state.

Fixes issue identified by Klocwork analysis:

    Resource acquired to 'shared->TexMutex' at line 1012 may be lost
    here. Also there is one similar error on line 1087.

NOTE: This is a candidate for the stable branches.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
mesa: Don't leak gl_context::BeginEnd at context destruction

The other dispatch tables (Exec and Save) are freed, but BeginEnd is
never freed.  This was found by inspection why investigating the leak of
shared state in _mesa_initialize_context.

NOTE: This is a candidate for stable branches

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
i965: Fix compiler warnings since the introduction of texture multisample.

Reviewed-by: Matt Turner <mattst88@gmail.com>
mesa: Add a macro to bitset for determining bitset size.

Reviewed-by: Matt Turner <mattst88@gmail.com>
i965/fs: Add a helper function for checking for partial register updates.

These checks were all over, and every time I wrote one I had to try to
decide again what the cases were for partial updates.

v2: Fix inadvertent reladdr check removal.
Reviewed-by: Matt Turner <mattst88@gmail.com>
i965/fs: Remove incorrect note of writing attr in centroid workaround.

This instruction doesn't update its IR destination, it just moves from
payload to f0.  This caused the dead code elimination pass I'm adding to
dead-code-eliminate the first step of interpolation.

Reviewed-by: Matt Turner <mattst88@gmail.com>
i965/fs: Add basic-block-level dead code elimination.

This is a poor substitute for proper global dead code elimination that
could replace both our current paths, but it was very easy to write.  It
particularly helps with Valve's shaders that are translated out of DX
assembly, which has been register allocated and thus have a bunch of
unrelated uses of the same variable (some of which get copy-propagated
from and then left for dead).

shader-db results:
total instructions in shared programs: 1735753 -> 1731698 (-0.23%)
instructions in affected programs:     492620 -> 488565 (-0.82%)

v2: Fix comment typo

Reviewed-by: Matt Turner <mattst88@gmail.com>