freedreno/ir3: make texture instruction construction more dynamic

This will make life a lot easier as we add support for additional
instructions.

v2: shadow reference value is always .z or .w

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/ir3: fix TXB/TXL to actually pull the bias/lod argument

Previously we would get a potentially computed post-swizzle coord based
on the texture target info, which would not include the bias/lod in the
last argument.

The second argument does not have to be adjacent, so adjusting the order
array did not make sense.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/ir3: add TXQ support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/ir3: add TXB2 support

Handles texture(samplerCubeShadow, bias), part of GLES3 and GL3

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
ilo: make gen6_pipeline_update_max_svbi() static

We do not need to call it from GEN7 pipeline anymore since software
PIPE_QUERY_PRIMITIVES_EMITTED is gone.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
ilo: remove handle_invalid_batch_bo()

It was used to set has_gen6_wa_pipe_control to false when the batch buffer
changed.  When called from emit_flush() and others, it also unset
ILO_3D_PIPELINE_INVALIDATE_BATCH_BO so that the following emit_draw() will not
set has_gen6_wa_pipe_control to false again.  It sounded error-prone and was
just ugly.

We should be able to achieve the same goal by reset has_gen6_wa_pipe_control
in ilo_3d_pipeline_invalidate().  With handle_invalid_batch_bo() gone, the
emit functions can also be inlined.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
ilo: rework pipeline workarounds

Add current_pipe_control_dw1 and deferred_pipe_control_dw1 to track what have
been done since lsat 3DPRIMITIVE and what need to be done before next
3DPRIMITIVE.  Based on them, we can emit WAs more smartly.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
glsl: Fix memory leak in glsl_lexer.ll

Running fast clear glClear with SNB caused Valgrind to
complain about this.

v2: line 237 fixed glClear from leaking memory, other
strdups are also now changed to ralloc_strdups but I
don't know what effect those have. At least no changes in
my Piglit quick run.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
i965: in set_read_rb_tex_image() check _mesa_meta_bind_rb_as_tex_image() did succeed

Check if _mesa_meta_bind_rb_as_tex_image() did give the texture.
If no texture was given there is already either
GL_INVALID_VALUE or GL_OUT_OF_MEMORY error set in context.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
glsl: add missing null check in tfeedback_decl::init()

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa: add null checks in symbol_table.c

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
i965: Avoid null access in intelMakeCurrent()

separate two null checks connected with && to their own if branches.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
glsl: Check calloc return value in link_intrastage_shaders()

Check calloc return value while adding build-in functions.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
loader: Check dlsym() did not fail in libudev_get_device_name_for_fd()

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
glsl: Check realloc return value in ir_function::matching_signature()

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
mesa/main: Check allocations success in _mesa_one_time_init_extension_overrides()

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
i965: Add extra null check in intel_bufferobj_alloc()

Check calloc returned requested memory.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
meta: Avoid null access on setup_glsl_msaa_blit_shader()

On default fallback path there was null access on src_rb

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
meta: Fix error paths in meta_copy_image.c

If _mesa_get_tex_image() return NULL there is already error
set in context. Other error pats free allocated texture.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
egl: extra null checks for get_xcb_screen() return values

verify get_xcb_screen() returned pointer before using it.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>