mesa.git
7 years agomesa/glsl: move uses_gl_fragcoord to gl_shader
Timothy Arceri [Tue, 22 Nov 2016 07:37:06 +0000 (18:37 +1100)]
mesa/glsl: move uses_gl_fragcoord to gl_shader

This is only used by gl_linked_shader as a temp during linking
so use a temp there instead.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agomesa/glsl: move redeclares_gl_fragcoord to gl_shader
Timothy Arceri [Tue, 22 Nov 2016 07:25:20 +0000 (18:25 +1100)]
mesa/glsl: move redeclares_gl_fragcoord to gl_shader

This is never used in gl_linked_shader other than as a temp
during linking so just use a temp instead.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agomesa/glsl: move ARB_fragment_coord_conventions_enable field
Timothy Arceri [Tue, 22 Nov 2016 07:17:37 +0000 (18:17 +1100)]
mesa/glsl: move ARB_fragment_coord_conventions_enable field

This is only used by gl_shader not gl_linked_shader so move it
there.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agost/mesa/glsl: set early_fragment_tests directly in shader_info
Timothy Arceri [Tue, 22 Nov 2016 02:10:18 +0000 (13:10 +1100)]
st/mesa/glsl: set early_fragment_tests directly in shader_info

We also move EarlyFragmentTests out of the gl_shader_info struct
as it is now only used by gl_shader.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agomesa/glsl/i965: set and use tcs vertices_out directly
Timothy Arceri [Tue, 22 Nov 2016 02:10:18 +0000 (13:10 +1100)]
mesa/glsl/i965: set and use tcs vertices_out directly

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoi965: get outputs_written from gl_program
Timothy Arceri [Fri, 18 Nov 2016 05:46:27 +0000 (16:46 +1100)]
i965: get outputs_written from gl_program

There is no need to go via the pointer in nir_shader. This change
is required for the shader cache as we don't create a nir_shader.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agogallivm: use #ifdef not #if for PIPE_ARCH_BIG_ENDIAN
Dave Airlie [Thu, 19 Jan 2017 04:39:10 +0000 (14:39 +1000)]
gallivm: use #ifdef not #if for PIPE_ARCH_BIG_ENDIAN

This fixes the build on ppc/s390.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Cc: "17.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agomesa: don't always set _NEW_PROGRAM when linking
Timothy Arceri [Mon, 9 Jan 2017 05:13:27 +0000 (16:13 +1100)]
mesa: don't always set _NEW_PROGRAM when linking

We only need to set it when linking was successful and the program
being linked is currently active.

The programs_in_use mask is just used as a flag for now but in
a future change we will use it to update the CurrentProgram array.

V2: make sure to flush vertices before linking (suggested by Marek)

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
7 years agomesa: change init subroutine defaults helper to work per gl_program
Timothy Arceri [Mon, 9 Jan 2017 05:13:28 +0000 (16:13 +1100)]
mesa: change init subroutine defaults helper to work per gl_program

A later patch will result in SSO programs calling this helper
per gl_program rather than per gl_shader_program.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agomesa/glsl: move ProgramResourceList to gl_shader_program_data
Timothy Arceri [Thu, 10 Nov 2016 08:46:11 +0000 (19:46 +1100)]
mesa/glsl: move ProgramResourceList to gl_shader_program_data

We also move NumProgramResourceList at the same time.

GLES does interface validation on SSO at runtime so we need to move
this to be able to switch to storing gl_program pointers in
CurrentProgram.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
7 years agoglsl: store number of explicit uniform loactions in gl_shader_program
Timothy Arceri [Sun, 4 Dec 2016 11:47:17 +0000 (22:47 +1100)]
glsl: store number of explicit uniform loactions in gl_shader_program

This allows us to cleanup the functions that pass this count around,
but more importantly we will be able to call the uniform linking
functions from that backends linker without having to pass this
information to the backend directly via Driver.LinkShader().

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoglsl: create a new link_and_validate_uniforms() helper
Timothy Arceri [Sun, 4 Dec 2016 10:42:14 +0000 (21:42 +1100)]
glsl: create a new link_and_validate_uniforms() helper

Currently this just breaks up the linking code a bit but in the
future i965 will call this from the backend via Driver.LinkShader()
so that we can do NIR optimisations before assigning uniform
locations.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoglsl: make a bunch of varying linking functions static
Timothy Arceri [Sun, 4 Dec 2016 10:28:41 +0000 (21:28 +1100)]
glsl: make a bunch of varying linking functions static

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoglsl: move more varying linking code to link_varyings.cpp
Timothy Arceri [Sun, 4 Dec 2016 10:11:13 +0000 (21:11 +1100)]
glsl: move more varying linking code to link_varyings.cpp

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
7 years agoi965/blorp: Make post draw flush more explicit
Topi Pohjolainen [Tue, 17 Jan 2017 10:00:37 +0000 (12:00 +0200)]
i965/blorp: Make post draw flush more explicit

Blits do not need any special treatment as the target buffer
object is added to render cache just as one does for normal draw.
Color clears and resolves in turn require explicit "end of pipe
synchronization". It is not clear what this means exactly but the
assumption is that render cache flush with command stream stall
should be sufficient.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoi965/gen6: Issue direct depth stall and flush after depth clear
Topi Pohjolainen [Tue, 17 Jan 2017 09:48:49 +0000 (11:48 +0200)]
i965/gen6: Issue direct depth stall and flush after depth clear

instead of calling unconditionally brw_emit_mi_flush() which
does:

   brw_emit_pipe_control_flush(brw,
                                PIPE_CONTROL_DEPTH_CACHE_FLUSH |
                                PIPE_CONTROL_RENDER_TARGET_FLUSH |
                                PIPE_CONTROL_CS_STALL);

   brw_emit_pipe_control_flush(brw,
                                PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
                                PIPE_CONTROL_CONST_CACHE_INVALIDATE);

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoi965: Make depth clear flushing more explicit
Topi Pohjolainen [Tue, 17 Jan 2017 09:44:52 +0000 (11:44 +0200)]
i965: Make depth clear flushing more explicit

Current blorp logic issues unconditional "flush everything"
(see brw_emit_mi_flush()) after each render. For example, all
blits issue this unconditionally which shouldn't be needed if
they set render cache properly so that subsequent renders do
necessary flushing before drawing.

In case of piglit:

ext_framebuffer_multisample-accuracy all_samples depth_draw small

intel_hiz_exec() is always preceded by blorb blit and the
unconditional flush looks to hide the lack of stall and flushes
in depth clears. By removing the brw_emit_mi_flush() I get gpu
hangs.

This patch adds the stalls and flushes mandated by the spec
and gets rid of those hangs.

v2 (Jason, Ken): Document the rational for separating
                 depth cache flush and stall on Gen7.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoi965/blorp: Use the render cache mechanism instead of explicit flushing
Topi Pohjolainen [Tue, 17 Jan 2017 09:04:22 +0000 (11:04 +0200)]
i965/blorp: Use the render cache mechanism instead of explicit flushing

by replacing brw_emit_mi_flush() with brw_render_cache_set_check_flush().
The latter splits the flush in two:

   brw_emit_pipe_control_flush(brw,
                               PIPE_CONTROL_DEPTH_CACHE_FLUSH |
                               PIPE_CONTROL_RENDER_TARGET_FLUSH |
                               PIPE_CONTROL_CS_STALL);

   brw_emit_pipe_control_flush(brw,
                               PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
                               PIPE_CONTROL_CONST_CACHE_INVALIDATE);

instead of

   int flags = PIPE_CONTROL_NO_WRITE | PIPE_CONTROL_RENDER_TARGET_FLUSH;
   if (brw->gen >= 6) {
      flags |= PIPE_CONTROL_INSTRUCTION_INVALIDATE |
               PIPE_CONTROL_CONST_CACHE_INVALIDATE |
               PIPE_CONTROL_DEPTH_CACHE_FLUSH |
               PIPE_CONTROL_VF_CACHE_INVALIDATE |
               PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
               PIPE_CONTROL_CS_STALL;
   }
   brw_emit_pipe_control_flush(brw, flags);

v2 (Jason): Check that destination exists before trying to add to
            render cache. Depth clears and resolves don't have it.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoutils: really remove the __END_DECLS macro
Emil Velikov [Wed, 18 Jan 2017 19:48:37 +0000 (19:48 +0000)]
utils: really remove the __END_DECLS macro

Fixes: d1efa09d342 "util: import sha1 implementation from OpenBSD"
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoutils: build sha1/disk cache only with Android/Autoconf
Emil Velikov [Wed, 18 Jan 2017 19:40:31 +0000 (19:40 +0000)]
utils: build sha1/disk cache only with Android/Autoconf

Earlier commit imported a SHA1 implementation and relaxed the SHA1 and
disk cache handling, broking the Windows builds.

Restrict things for now until we get to a proper fix.

Fixes: d1efa09d342 "util: import sha1 implementation from OpenBSD"
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoutil: import sha1 implementation from OpenBSD
Emil Velikov [Fri, 13 Jan 2017 16:51:31 +0000 (16:51 +0000)]
util: import sha1 implementation from OpenBSD

At the moment we support 5+ different implementations each with varying
amount of bugs - from thread safely problems [1], to outright broken
implementation(s) [2]

In order to accommodate these we have 150+ lines of configure script and
extra two configure toggles. Whist an actual implementation being
~200loc and our current compat wrapping ~250.

Let's not forget that different people use different code paths, thus
effectively makes it harder to test and debug since the default
implementation is automatically detected.

To minimise all these lovely experiences, import the "100% Public
Domain" OpenBSD sha1 implementation. Clearly document any changes needed
to get building correctly, since many/most of those can be upstreamed
making future syncs easier.

As an added bonus this will avoid all the 'fun' experiences trying to
integrate it with the Android and SCons builds.

v2: Manually expand __BEGIN_DECLS/__END_DECLS and document (Tapani).

Furthermore it seems that some games (or surrounding runtime) static
link against OpenSSL resulting in conflicts. For more information see
the discussion thread [3]

Bugzilla [1]: https://bugs.freedesktop.org/show_bug.cgi?id=94904
Bugzilla [2]: https://bugs.freedesktop.org/show_bug.cgi?id=97967
[3] https://lists.freedesktop.org/archives/mesa-dev/2017-January/140748.html
Cc: Mark Janes <mark.a.janes@intel.com>
Cc: Vinson Lee <vlee@freedesktop.org>
Cc: Tapani Pälli <tapani.palli@intel.com>
Cc: Jonathan Gray <jsg@jsg.id.au>
Tested-by: Jonathan Gray <jsg@jsg.id.au>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Tapani Pälli <tapani.palli@intel.com> (v1)
Acked-by: Jason Ekstrand <jason@jlekstrand.net> (v1)
7 years agoi965: Make brw_cache_item structure private to brw_program_cache.c.
Kenneth Graunke [Fri, 11 Nov 2016 22:52:36 +0000 (14:52 -0800)]
i965: Make brw_cache_item structure private to brw_program_cache.c.

struct brw_cache_item is an implementation detail of the program cache.
We don't need to make those internals available to the entire driver.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
7 years agoradeonsi: determine in advance which VBOs should be added to the buffer list
Marek Olšák [Tue, 17 Jan 2017 21:03:23 +0000 (22:03 +0100)]
radeonsi: determine in advance which VBOs should be added to the buffer list

v2: now it should be correct

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: use fewer pointer dereferences in upload_vertex_buffer_descriptors
Marek Olšák [Tue, 17 Jan 2017 20:55:59 +0000 (21:55 +0100)]
radeonsi: use fewer pointer dereferences in upload_vertex_buffer_descriptors

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: reject invalid vertex buffer indices at state creation
Marek Olšák [Tue, 17 Jan 2017 20:49:50 +0000 (21:49 +0100)]
radeonsi: reject invalid vertex buffer indices at state creation

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: use a global dirty mask for shader pointers
Marek Olšák [Tue, 17 Jan 2017 20:30:23 +0000 (21:30 +0100)]
radeonsi: use a global dirty mask for shader pointers

Only vertex buffers use a separate bool flag.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: use a bitmask-based loop in si_decompress_textures
Marek Olšák [Tue, 17 Jan 2017 19:46:39 +0000 (20:46 +0100)]
radeonsi: use a bitmask-based loop in si_decompress_textures

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: skip an unnecessary mutex lock for L2 prefetches
Marek Olšák [Tue, 17 Jan 2017 19:10:15 +0000 (20:10 +0100)]
radeonsi: skip an unnecessary mutex lock for L2 prefetches

the mutex lock is inside util_range_add.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: si_cp_dma_prepare is a no-op for L2 prefetches
Marek Olšák [Tue, 17 Jan 2017 17:42:23 +0000 (18:42 +0100)]
radeonsi: si_cp_dma_prepare is a no-op for L2 prefetches

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: add SI_CPDMA_SKIP_BO_LIST_UPDATE
Marek Olšák [Tue, 17 Jan 2017 17:40:26 +0000 (18:40 +0100)]
radeonsi: add SI_CPDMA_SKIP_BO_LIST_UPDATE

the next commit will use it in a clever way, because the CP DMA prefetch
doesn't need this.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: use the correct target machine when building shader variants
Marek Olšák [Tue, 17 Jan 2017 17:04:13 +0000 (18:04 +0100)]
radeonsi: use the correct target machine when building shader variants

If the shader selector is created with a different context than
the shader variant, we should use the calling context's target machine
for the shader variant.

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

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: move shader pipe context state into a separate structure
Marek Olšák [Tue, 17 Jan 2017 16:39:16 +0000 (17:39 +0100)]
radeonsi: move shader pipe context state into a separate structure

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoi965: Fix SURFACE_STATE to handle non-zero aux offsets
Ben Widawsky [Fri, 2 Dec 2016 19:10:47 +0000 (11:10 -0800)]
i965: Fix SURFACE_STATE to handle non-zero aux offsets

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Daniel Stone <daniels@collabora.com>
7 years agoRevert "etnaviv: Fake occlusion query capability"
Christian Gmeiner [Wed, 18 Jan 2017 16:32:51 +0000 (17:32 +0100)]
Revert "etnaviv: Fake occlusion query capability"

This reverts commit b7ac0f567123c96b5cd9e3485b963a5c0a0db66a.

This is a half baked solution needs some rework to fixes issues
with reported counter bits (GL_QUERY_COUNTER_BITS_ARB).
Also it enables PIPE_CAP_QUERY_TIME_ELAPSED accidently.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
7 years agoandroid: ac/debug: move sid_tables.h generation and IB decode to amd/common
Mauro Rossi [Thu, 12 Jan 2017 00:14:12 +0000 (01:14 +0100)]
android: ac/debug: move sid_tables.h generation and IB decode to amd/common

This patch is the porting to android of the following commits:

b838f64 "ac/debug: Move sid_tables.h generation to common code."
0ef1b4d "ac/debug: Move IB decode to common code."

Fixes android building errors due to sid_tables.h
and ac_debug.c, ac_debug.h moved to amd/common

Tested by building nougat-x86

Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoandroid: gallium/auxiliary: fix building error in Android 7.0
Mauro Rossi [Tue, 10 Jan 2017 00:53:05 +0000 (01:53 +0100)]
android: gallium/auxiliary: fix building error in Android 7.0

Conditional libLLVMCore static library dependency is added,
for the case when MESA_ENABLE_LLVM is true

Fixes the following building error with Android 7.0:

In file included from
external/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp:62:
...
external/llvm/include/llvm/IR/Attributes.h:68:14: fatal error:
'llvm/IR/Attributes.inc' file not found
    #include "llvm/IR/Attributes.inc"
             ^
1 error generated.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoandroid: amd/common: fix LLVMInitializeAMDGPU* functions declaration
Mauro Rossi [Tue, 10 Jan 2017 00:53:02 +0000 (01:53 +0100)]
android: amd/common: fix LLVMInitializeAMDGPU* functions declaration

LLVMInitializeAMDGPU* functions need to be explicitly declared
and mesa expects them via <llvm-c/Target.h> header,
but LLVM needs to be instructed to invoke its own LLVM_TARGET(AMDGPU) macro,
or the functions will not be available.

A new llvm cflag (-DFORCE_BUILD_AMDGPU) serves this purpose,
the same mechanism is used also by other llvm targets e.g. FORCE_BUILD_ARM

A necessary prerequisite is to have AMDGPU target handled accordingly
in llvm config files i.e. {Target,AsmParser,AsmPrinter}.def
for llvm device build includes.

This avoids the following building errors:

external/mesa/src/amd/common/ac_llvm_util.c:43:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetInfo' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTargetInfo();
        ^
external/mesa/src/amd/common/ac_llvm_util.c:44:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTarget' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTarget();
        ^
external/mesa/src/amd/common/ac_llvm_util.c:45:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetMC' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTargetMC();
        ^
external/mesa/src/amd/common/ac_llvm_util.c:46:2: error: implicit declaration of function 'LLVMInitializeAMDGPUAsmPrinter' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUAsmPrinter();
        ^
Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoandroid: radeonsi: fix LLVMInitializeAMDGPU* functions declaration
Mauro Rossi [Tue, 10 Jan 2017 00:53:01 +0000 (01:53 +0100)]
android: radeonsi: fix LLVMInitializeAMDGPU* functions declaration

LLVMInitializeAMDGPU* functions need to be explicitly declared
and mesa expects them via <llvm-c/Target.h> header,
but LLVM needs to be instructed to invoke its own LLVM_TARGET(AMDGPU) macro,
or the functions will not be available.

A new llvm cflag (-DFORCE_BUILD_AMDGPU) serves this purpose,
the same mechanism is used also by other llvm targets e.g. FORCE_BUILD_ARM

A necessary prerequisite is to have AMDGPU target handled accordingly
in llvm config files i.e. {Target,AsmParser,AsmPrinter}.def
for llvm device build includes.

This avoids the following building errors:

external/mesa/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c:129:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetInfo' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTargetInfo();
        ^
external/mesa/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c:130:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTarget' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTarget();
        ^
external/mesa/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c:131:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetMC' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUTargetMC();
        ^
external/mesa/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c:132:2: error: implicit declaration of function 'LLVMInitializeAMDGPUAsmPrinter' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        LLVMInitializeAMDGPUAsmPrinter();
        ^

Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoandroid: radeon: fix LLVMInitializeAMDGPU* functions declaration
Mauro Rossi [Tue, 10 Jan 2017 00:53:00 +0000 (01:53 +0100)]
android: radeon: fix LLVMInitializeAMDGPU* functions declaration

LLVMInitializeAMDGPU* functions need to be explicitly declared
and mesa expects them via <llvm-c/Target.h> header,
but LLVM needs to be instructed to invoke its own LLVM_TARGET(AMDGPU) macro,
or the functions will not be available.

A new llvm cflag (-DFORCE_BUILD_AMDGPU) serves this purpose,
the same mechanism is used also by other llvm targets e.g. FORCE_BUILD_ARM

A necessary prerequisite is to have AMDGPU target handled accordingly
in llvm config files i.e. {Target,AsmParser,AsmPrinter}.def
for llvm device build includes.

This avoids the following building errors:

external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:121:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetInfo' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUTargetInfo();
  ^
external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:122:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTarget' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUTarget();
  ^
external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:123:2: error: implicit declaration of function 'LLVMInitializeAMDGPUTargetMC' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUTargetMC();
  ^
external/mesa/src/gallium/drivers/radeon/radeon_llvm_emit.c:124:2: error: implicit declaration of function 'LLVMInitializeAMDGPUAsmPrinter' [-Werror=implicit-function-declaration]
  LLVMInitializeAMDGPUAsmPrinter();
  ^

Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Acked-by: Emil Velikov <emil.velikov@collabora.com>
7 years agonouveau: remove always false argument in nouveau_fence_new()
Emil Velikov [Mon, 16 Jan 2017 16:25:19 +0000 (16:25 +0000)]
nouveau: remove always false argument in nouveau_fence_new()

No point in having the extra argument considering that it's effectively
unused since the function was introduced.

Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agoegl/wayland: resolve quirky try_damage_buffer() implementation
Emil Velikov [Fri, 13 Jan 2017 17:27:56 +0000 (17:27 +0000)]
egl/wayland: resolve quirky try_damage_buffer() implementation

The implementation was added with commit d085a5dff5b and effectively
provided a hidden dependency.

Namely: the codepath used was determined solely during build time. Thus
if we built again new wayland and then run against older (yet still
within the requirements, as per the configure) one will get undefined
symbols.

As of earlier commit 36b9976e1f9 "egl/wayland: Avoid race conditions
when on non-main thread" the required version was bumped to one which
provides the API, thus we can drop the quirky solution.

Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
7 years agoconfigure: error out when building static XOR shared
Emil Velikov [Wed, 7 Dec 2016 13:25:01 +0000 (13:25 +0000)]
configure: error out when building static XOR shared

Current code warns out in such cases and falls-back to either static or
shared. That can be easily missed amongst the volume produced by our
configure script.

Replace the warning with an error such that one gets direct feedback
when they're doing something wrong.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: explicitly require shared glapi for enable-dri
Emil Velikov [Wed, 7 Dec 2016 13:25:00 +0000 (13:25 +0000)]
configure: explicitly require shared glapi for enable-dri

We've been using and depending on it for at least a couple of years.
Make it obvious and error out, should one opt for it.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: factor out commom egl/gbm checks
Emil Velikov [Wed, 7 Dec 2016 13:24:59 +0000 (13:24 +0000)]
configure: factor out commom egl/gbm checks

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: remove HAVE_EGL_DRIVER_DRI[23]
Emil Velikov [Wed, 7 Dec 2016 13:24:58 +0000 (13:24 +0000)]
configure: remove HAVE_EGL_DRIVER_DRI[23]

We have them for local purposes in configure, where we can use their
direct dependency.

With the only remaining instance in the makefile(s) being always true,
as it can be seen in the configure snippet.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: forbid static EGL/GBM
Emil Velikov [Wed, 7 Dec 2016 13:24:57 +0000 (13:24 +0000)]
configure: forbid static EGL/GBM

Both libraries implicitly require shared GLAPI which in itself mandates
shared libraries.

Stop pretending that one can use it and error out at configure stage.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure: remove unused AC_SUBST variables
Emil Velikov [Thu, 8 Dec 2016 17:58:22 +0000 (17:58 +0000)]
configure: remove unused AC_SUBST variables

v2: Rebase.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (v1)
7 years agogallium: correctly manage libsensors link flags
Emil Velikov [Thu, 8 Dec 2016 17:58:21 +0000 (17:58 +0000)]
gallium: correctly manage libsensors link flags

We should be using LIBS rather than the LDFLAGS variable. Furthermore
try to keep the linking to the final stage, rather than intermetent
static library.

Cc: Steven Toth <stoth@kernellabs.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoegl/wayland: unify dri2_wl_create_surface implementations
Emil Velikov [Mon, 28 Nov 2016 18:25:19 +0000 (18:25 +0000)]
egl/wayland: unify dri2_wl_create_surface implementations

Rather than having two almost identical codepaths (one for HW/wl_drm and
another for SW/wl_shm), just factorise and reuse in both places.

v2: Rebase
v3: Rebase

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com> (v2)
7 years agoegl/wayland: use the destroy_window_callback for swrast
Emil Velikov [Mon, 28 Nov 2016 18:25:18 +0000 (18:25 +0000)]
egl/wayland: use the destroy_window_callback for swrast

As described in commit 690ead4a135 ("egl/wayland-egl: Fix for segfault
in dri2_wl_destroy_surface.") if we attempt to destroy a EGL surface
attached to already destroyed Wayland window we'll get a segfault.

v2: set the correct callback alongside the window->private. (Dan)

Cc: Daniel Stone <daniels@collabora.com>
Cc: "12.0 13.0" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoglx: unify GLX_SGIX_pbuffer aliased declarations
Emil Velikov [Mon, 5 Dec 2016 19:52:45 +0000 (19:52 +0000)]
glx: unify GLX_SGIX_pbuffer aliased declarations

No point in having an identical code in two places.

Not to mention that the Apple one incorrectly uses GLXDrawable as pbuf
type. This change is both API and ABI safe since the header uses the
correct GLXPbufferSGIX and both types are a typedef of the same
primitive XID.

Cc: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jeremy Sequoia <jeremyhu@apple.com>
7 years agoglx: use GLX_ALIAS for glXGetProcAddress
Emil Velikov [Mon, 5 Dec 2016 19:52:44 +0000 (19:52 +0000)]
glx: use GLX_ALIAS for glXGetProcAddress

Use the macro, rather than open-coding it.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agomesa: make use of HAVE_FUNC_ATTRIBUTE_ALIAS macro
Emil Velikov [Mon, 5 Dec 2016 19:52:43 +0000 (19:52 +0000)]
mesa: make use of HAVE_FUNC_ATTRIBUTE_ALIAS macro

We must make sure that xserver has an equivalent one-line
change to its configure.ac as the glx/glapi headers get copied over.

Then again, xserver does _not_ seem to set HAVE_ALIAS to begin with so
one might want to look into that first.

Cc: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoandroid: set HAVE_FUNC_ATTRIBUTE_ALIAS
Emil Velikov [Mon, 5 Dec 2016 19:52:42 +0000 (19:52 +0000)]
android: set HAVE_FUNC_ATTRIBUTE_ALIAS

Analogous to previous two commits.

Strictly speaking it's not be applicable for Android since we don't
build GLX and related code.

Regardless keep things consistent with the other build systems.

Cc: Rob Herring <robh@kernel.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoscons: set HAVE_FUNC_ATTRIBUTE_ALIAS
Emil Velikov [Mon, 5 Dec 2016 19:52:41 +0000 (19:52 +0000)]
scons: set HAVE_FUNC_ATTRIBUTE_ALIAS

Analogoust to the previous commit were we did so for autotools

Cc: Jose Fonseca <jfonseca@vmware.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
7 years agoconfigure: use standard check for attribure alias
Emil Velikov [Mon, 5 Dec 2016 19:52:40 +0000 (19:52 +0000)]
configure: use standard check for attribure alias

Currently we have two macros - HAVE_ALIAS and GLX_ALIAS_UNSUPPORTED.
To make it even better former of which is explicitly cleared in some
cases while not in others.

Clear all that up by using a single macro properly set during configure.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoglx: remove always false ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS
Emil Velikov [Mon, 5 Dec 2016 19:52:39 +0000 (19:52 +0000)]
glx: remove always false ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS

Quick search through git history (of both mesa and xserver) hows no
instances where this was ever set.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoetnaviv: Fake occlusion query capability
Wladimir J. van der Laan [Mon, 5 Dec 2016 12:43:55 +0000 (13:43 +0100)]
etnaviv: Fake occlusion query capability

This enables the PIPE_CAP_OCCLUSION_QUERY capability without adding an
occlusion query type.

This is necessary to get Mesa to report desktop GL 2.0 support (to run
exciting things such as ioq3's OpenGL 2 renderer), and should be valid
because exposing the capability does not guarantee that any
counters are actually implemented.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
7 years agoetnaviv: add flags parameter to texture barrier
Christian Gmeiner [Wed, 18 Jan 2017 15:15:01 +0000 (16:15 +0100)]
etnaviv: add flags parameter to texture barrier

Fixes compile warning introduced by commit a1c848.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
7 years agoetnaviv: handle PIPE_CAP_TGSI_FS_FBFETCH
Christian Gmeiner [Wed, 18 Jan 2017 15:12:12 +0000 (16:12 +0100)]
etnaviv: handle PIPE_CAP_TGSI_FS_FBFETCH

Fixes compile warning introduced by commit ee3ebe.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
7 years agogallivm: (trivial) fix copy/paste bug with big endian code
Roland Scheidegger [Wed, 18 Jan 2017 15:30:50 +0000 (16:30 +0100)]
gallivm: (trivial) fix copy/paste bug with big endian code

8bd67a35c50e68c21aed043de11e095c284d151a introduced using undefined variable
on big endian archs due to copy/paste bug.
(compile hack tested only)

7 years agoconfigure.ac: Revert recent HAVE_LLVM changes.
Jose Fonseca [Wed, 18 Jan 2017 14:42:47 +0000 (14:42 +0000)]
configure.ac: Revert recent HAVE_LLVM changes.

This reverts changes 903eb09b5fb78d47d0f8a4bdf826a113ca2aff40..1a0aa468f354f0ee94dd383cd40ae915584624aa:

  Tobias Droste (5):
    configure.ac: Rename MESA_LLVM to FOUND_LLVM
    configure.ac: Only set LLVM_LIBS if LLVM is used
    configure.ac: Only define HAVE_LLVM if LLVM is used
    configure.ac: Set and use HAVE_GALLIUM_LLVM define
    configure.ac: Don't check LLVM version in gallium_require_llvm

They break scons build, and I'm not convinced this is the right fix.  In
particular changing HAVE_LLVM in the C code is something I'd rather
avoid no matter what.  So it's better to discuss without the pressure of
broken builds.

7 years agodocs: Fix GLSL compiler link
Elie TOURNIER [Wed, 18 Jan 2017 13:50:11 +0000 (13:50 +0000)]
docs: Fix GLSL compiler link

The doc wasn't update since we moved the glsl compiler to src/compiler/glsl.
I also updated the description of the standalone compiler.

v2:
 - Mention that just-log argument removes headers/separators.
 - Mention that version argument is mandatory.
Since version argument is mandatory, add --version to the command line
example.

Signed-off-by: Elie Tournier <tournier.elie@gmail.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
7 years agovulkan: automake: do not use EXTRA_DIST in a conditional
Emil Velikov [Tue, 17 Jan 2017 19:48:37 +0000 (19:48 +0000)]
vulkan: automake: do not use EXTRA_DIST in a conditional

Otherwise the file might not end up in the tarball.

Fixes: dbd677efb42 "vulkan: add API registry"
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure.ac: Respect LLVM_CFLAGS in LLVM version detection
Tomasz Figa [Wed, 14 Dec 2016 08:00:27 +0000 (17:00 +0900)]
configure.ac: Respect LLVM_CFLAGS in LLVM version detection

When compiling LLVM headers, including llvm-config.h, we need to respect
LLVM_CFLAGS. This is especially crucial if LLVM is located in a
non-standard location and it happens that llvm-config.h includes another
header. In such case the detection would fail due to missing header,
because the path is provided in LLVM_CFLAGS.

Let's add LLVM_CFLAGS to global CFLAGS for the time of detection and then
restore the original flags, as done in other places of the script.

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure.ac: Don't check LLVM version in gallium_require_llvm
Tobias Droste [Thu, 8 Dec 2016 02:03:40 +0000 (03:03 +0100)]
configure.ac: Don't check LLVM version in gallium_require_llvm

This is actually not needed because the version is checked later.

Line 2609:
if test "x$enable_gallium_llvm" == "xyes"; then
    llvm_require_version $LLVM_REQUIRED_GALLIUM "gallium"
    llvm_add_default_components "gallium"

    HAVE_GALLIUM_LLVM=xyes
    DEFINES="${DEFINES} -DHAVE_GALLIUM_LLVM"
fi

Signed-off-by: Tobias Droste <tdroste@gmx.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure.ac: Set and use HAVE_GALLIUM_LLVM define
Tobias Droste [Thu, 8 Dec 2016 02:03:38 +0000 (03:03 +0100)]
configure.ac: Set and use HAVE_GALLIUM_LLVM define

Gallium code used HAVE_LLVM to check if it needs to compile code for
LLVM in header and source files.

With the new logic HAVE_LLVM is always set. Use extra define to figure
out if LLVM is used.

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

Signed-off-by: Tobias Droste <tdroste@gmx.de>
7 years agoconfigure.ac: Only define HAVE_LLVM if LLVM is used
Tobias Droste [Thu, 8 Dec 2016 02:03:37 +0000 (03:03 +0100)]
configure.ac: Only define HAVE_LLVM if LLVM is used

Make sure that HAVE_LLVM compiler define is only set if LLVM is
actually used.

Signed-off-by: Tobias Droste <tdroste@gmx.de>
v2 [Emil] fold within the existing conditional
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoconfigure.ac: Only set LLVM_LIBS if LLVM is used
Tobias Droste [Thu, 8 Dec 2016 02:03:36 +0000 (03:03 +0100)]
configure.ac: Only set LLVM_LIBS if LLVM is used

This renames llvm_check_version_for to llvm_require_version and let it
set a variable to mark that LLVM will be used.

Use this to make a usefull configure output and to only check if the
libs are found in LLVM if it is actually used.

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

Signed-off-by: Tobias Droste <tdroste@gmx.de>
7 years agoconfigure.ac: Rename MESA_LLVM to FOUND_LLVM
Tobias Droste [Thu, 8 Dec 2016 02:03:35 +0000 (03:03 +0100)]
configure.ac: Rename MESA_LLVM to FOUND_LLVM

This renames MESA_LLVM to FOUND_LLVM and updates the config.log report
to say if LLVM is found or not, to make clear that this does not mean
that it is used.

There are no MESA_LLVM users so drop the AC_SUBST.

v2 [Emil]
 - Polish test: -a over && test, = over ==, unquiote xyes
 - other ?

Signed-off-by: Tobias Droste <tdroste@gmx.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agogallivm: Cleanup USE_MCJIT.
Jose Fonseca [Mon, 16 Jan 2017 14:19:36 +0000 (14:19 +0000)]
gallivm: Cleanup USE_MCJIT.

Split USE_MCJIT macro dual nature into a separate constant time define
and a run-time variable.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
7 years agoi965: Don't map/unmap in brw_print_program_cache on LLC platforms.
Kenneth Graunke [Sat, 12 Nov 2016 02:05:14 +0000 (18:05 -0800)]
i965: Don't map/unmap in brw_print_program_cache on LLC platforms.

We have a persistent mapping.  Don't map it a second time or try to
unmap it.  Just use the pointer.

This most likely would wreak havoc except that this code is unused
(it's only called from an if (0) debug block).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
7 years agoi965: Move program cache printing to brw_program_cache.c.
Kenneth Graunke [Fri, 11 Nov 2016 22:47:53 +0000 (14:47 -0800)]
i965: Move program cache printing to brw_program_cache.c.

It makes sense to put a function which prints out the entire contents
of the program cache in the file that implements the program cache.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
7 years agoi965: Make a helper for finding an existing shader variant.
Kenneth Graunke [Fri, 11 Nov 2016 21:31:06 +0000 (13:31 -0800)]
i965: Make a helper for finding an existing shader variant.

We had five copies of the same "walk the cache and look for an
existing shader variant for this program" code.  Now we have one
helper function that returns the key.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
7 years agoglsl: Make copy propagation not panic when it sees an intrinsic.
Kenneth Graunke [Sat, 10 Dec 2016 03:06:06 +0000 (19:06 -0800)]
glsl: Make copy propagation not panic when it sees an intrinsic.

A number of games have large arrays of constants, which we promote to
uniforms.  This introduces copies from the uniform array to the original
temporary array.  Normally, copy propagation eliminates those copies,
making everything refer to the uniform array directly.

A number of shaders in "Deus Ex: Mankind Divided" recently exposed a
limitation of copy propagation - if we had any intrinsics (i.e. image
access in a compute shader), we weren't able to get rid of these copies.

That meant that any variable indexing remained on the temporary array
rather being moved to the uniform array.  i965's scalar backend
currently doesn't support indirect addressing of temporary arrays,
which meant lowering it to if-ladders.  This was horrible.

According to Marek, on radeonsi/GCN, "F1 2015" uses 64% less
spilled-temp-array memory.

On i965/Skylake:

total instructions in shared programs: 13362954 -> 13329878 (-0.25%)
instructions in affected programs: 43745 -> 10669 (-75.61%)
helped: 12
HURT: 0

total cycles in shared programs: 248081010 -> 245949178 (-0.86%)
cycles in affected programs: 4597930 -> 2466098 (-46.37%)
helped: 12
HURT: 0

total spills in shared programs: 9493 -> 9507 (0.15%)
spills in affected programs: 25 -> 39 (56.00%)
helped: 0
HURT: 1

total fills in shared programs: 12127 -> 12197 (0.58%)
fills in affected programs: 110 -> 180 (63.64%)
helped: 0
HURT: 1

Helps Deus Ex: Mankind Divided.   The one shader with hurt spills/fills
is from Tomb Raider at Ultra settings, but that same shader has a
-39.55% reduction in instructions and -14.09% reduction in cycle counts,
so it seems like a win there as well.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoi965: Make DCE set null destinations on messages with side effects.
Kenneth Graunke [Sun, 15 Jan 2017 07:32:12 +0000 (23:32 -0800)]
i965: Make DCE set null destinations on messages with side effects.

(Co-authored by Matt Turner.)

Image atomics, for example, return a value - but the shader may not
want to use it.  We assigned a useless VGRF destination.  This seemed
harmless, but it can actually be quite harmful.  The register allocator
has to assign that VGRF to a real register.  It may assign the same
actual GRF to the destination of an instruction that follows soon after.

This results in a write-after-write (WAW) dependency, and stall.

A number of "Deus Ex: Mankind Divided" shaders use image atomics, but
don't use the return value.  Several of these were hitting WAW stalls
for nearly 14,000 (poorly estimated) cycles a pop.  Making dead code
elimination null out the destination avoids this issue.

This patch cuts one shader's estimated cycles by -98.39%!  Removing the
message response should also help with data cluster bandwidth.

On Skylake:

(instruction counts remain identical)

total cycles in shared programs: 255413890 -> 248081010 (-2.87%)
cycles in affected programs: 12019948 -> 4687068 (-61.01%)
helped: 24
HURT: 10

v2: Make can_omit_write independent of can_eliminate (Curro).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoi965: Combine some dead code elimination NOP'ing code.
Kenneth Graunke [Thu, 15 Dec 2016 01:56:35 +0000 (17:56 -0800)]
i965: Combine some dead code elimination NOP'ing code.

In theory we might have incorrectly NOP'd instructions that write the
flag, but where that flag value isn't used, and yet the instruction
either writes the accumulator or has side effects.

I don't believe any such instructions exist, so this is mostly a
code cleanup.

Curro pointed out that FS_OPCODE_FB_WRITE has a null destination and
actually writes the flag on Gen4-5 to dynamically decide whether to
write some payload data.  The hunk removed in this patch might have
NOP'd it, except that we don't actually mark flags_written() in the
IR, so it doesn't think the flag is touched at all.  That's sketchy,
but it means it wouldn't hit this today (though there are likely other
problems!).

v2: Properly replace the inst->regs_written() check in the second
    hunk with the flag being live (mistake caught by Curro).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoi965: Make DCE explicitly not eliminate any control flow instructions.
Kenneth Graunke [Wed, 18 Jan 2017 03:15:50 +0000 (19:15 -0800)]
i965: Make DCE explicitly not eliminate any control flow instructions.

According to Matt, the dead code pass explicitly avoided IF and WHILE
because on Sandybridge, these could have conditional modifiers and
null destination registers.  Normally, those instructions use BAD_FILE
for the destination register.  Nowadays, we don't do that anymore, so
we could technically drop these checks.

However, it's clearer to explicitly leave control flow instructions
alone, so change it to the more generic !inst->is_control_flow().

This should have no actual change.

[This patch implements review feedback from Curro and Matt.]

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
7 years agoradv: disable vertex reuse when writing viewport index
Dave Airlie [Tue, 17 Jan 2017 20:26:31 +0000 (06:26 +1000)]
radv: disable vertex reuse when writing viewport index

This fixes some issues we'd hit later if using viewport
indexes.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: add support for layered clears (v2)
Dave Airlie [Tue, 17 Jan 2017 00:05:07 +0000 (10:05 +1000)]
radv: add support for layered clears (v2)

Just always use the layer clear pipelines,
the overhead of emitting the layer shouldn't be
too large.

v2: Bas suggested we always use it.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv/ac: split part of llvm compile into a separate function
Dave Airlie [Mon, 16 Jan 2017 22:41:03 +0000 (08:41 +1000)]
radv/ac: split part of llvm compile into a separate function

This is needed to have common code for gs copy shader emission.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv/ac: switch an if to switch
Dave Airlie [Mon, 16 Jan 2017 22:38:14 +0000 (08:38 +1000)]
radv/ac: switch an if to switch

makes it easier to add other shader stages.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: add support for writing layer/viewport index (v2)
Dave Airlie [Mon, 16 Jan 2017 21:04:52 +0000 (07:04 +1000)]
radv: add support for writing layer/viewport index (v2)

This just adds the infrastructure to allow writing layer
and viewport index. It's just a first patch out of the geom
shader tree, and doesn't do much on its own.

v2: add missing if statement change (Bas)

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoac/debug: Decrease num_dw for type 2 NOP's.
Bas Nieuwenhuizen [Sun, 15 Jan 2017 22:01:03 +0000 (23:01 +0100)]
ac/debug: Decrease num_dw for type 2 NOP's.

Otherwise we read past the end of the buffer.

Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradeonsi: for the tess barrier, only use emit_waitcnt on SI and LLVM 3.9+
Marek Olšák [Tue, 17 Jan 2017 12:45:42 +0000 (13:45 +0100)]
radeonsi: for the tess barrier, only use emit_waitcnt on SI and LLVM 3.9+

Cc: 17.0 13.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agost/vdpau: remove the delayed rendering hack(v1.1)
Nayan Deshmukh [Wed, 11 Jan 2017 16:57:15 +0000 (22:27 +0530)]
st/vdpau: remove the delayed rendering hack(v1.1)

the hack was introduced to avoid an extra copying
but now with dri3 we don't need it anymore

v1.1: rebasing

Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Acked-by: Christian König <christian.koenig@amd.com>
7 years agost/vdpau: use dri3 to directly send the buffer to X(v2)
Nayan Deshmukh [Wed, 11 Jan 2017 16:57:14 +0000 (22:27 +0530)]
st/vdpau: use dri3 to directly send the buffer to X(v2)

this avoids an extra copy which occurs in case of dri2

v1.1: fallback to dri2 if dri3 fails to initialize
v2: add PIPE_BIND_SCANOUT to output buffers as they will
    be send to X server directly (Michel)

Suggested-by: Christian König <christian.koenig@amd.com>
Tested-by: Andy Furniss <adf.lists@gmail.com>
Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
7 years agovl/dri3: use external texture as back buffers(v4)
Nayan Deshmukh [Wed, 11 Jan 2017 16:57:13 +0000 (22:27 +0530)]
vl/dri3: use external texture as back buffers(v4)

dri3 allows us to send handle of a texture directly to X
so this patch allows a state tracker to directly send its
texture to X to be used as back buffer and avoids extra
copying

v2: use clip width/height to display a portion of the surface
v3: remove redundant variables, fix wrapping, rename variables
    handle vaapi path
v3.1: we need clip_width/height for every frame so we don't need
      to maintain it for each buffer instead use a global variable
v4: In case of single gpu we can cache the buffers as applications
    use constant number of buffer and we can avoid calls to present
    extension for every frame

Reviewed and Suggested-by: Leo Liu <leo.liu@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Tested-by: Andy Furniss <adf.lists@gmail.com>
Signed-off-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
7 years agoanv: set UAV coherence required bit when needed
Iago Toral Quiroga [Mon, 16 Jan 2017 10:51:50 +0000 (11:51 +0100)]
anv: set UAV coherence required bit when needed

The same we do in the OpenGL driver (comment copied from there).

This is required to ensure that we execute the fragment shader stage when
side-effects (such as image or ssbo stores) are present but there are no
color writes.

I found this while writing a test to check rendering to a framebuffer
without attachments where the fragment shader does not produce any
color outputs but writes to an image via imageStore(). Without this patch
the fragment shader does not execute and the image is not written,
which is not correct.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agoanv: increase ANV_MAX_STATE_SIZE_LOG2 limit to 1 MB
Samuel Iglesias Gonsálvez [Tue, 10 Jan 2017 11:44:32 +0000 (12:44 +0100)]
anv: increase ANV_MAX_STATE_SIZE_LOG2 limit to 1 MB

Fixes crash in dEQP-VK.ubo.random.all_shared_buffer.48 due to a
fragment shader code bigger than 128 kB.

This patch increases the allocation size limit to 1 MB.

v2:
- Increase it to 1 MB (Jason)
- Increase device->instruction_block_pool allocation size in
  anv_device.c (Jason)

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
7 years agonv50/ir: optimize shl + and
Ilia Mirkin [Fri, 13 Jan 2017 05:41:11 +0000 (00:41 -0500)]
nv50/ir: optimize shl + and

Address loading can often end up as shl + shr + shl combinations. The
latter two are equal shifts, which get converted into an and mask.
However if the previous shl is more than the mask is trying to remove
(in terms of low bits), we can just remove the and entirely. This
reduces some large shaders by as many as 3% of instructions (out of 2K).

total instructions in shared programs : 6495509 -> 6491076 (-0.07%)
total gprs used in shared programs    : 954621 -> 954623 (0.00%)

                local        gpr       inst      bytes
    helped           0           0        1014        1014
      hurt           0           2           0           0

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agonvc0: enable FBFETCH with a special slot for color buffer 0
Ilia Mirkin [Mon, 2 Jan 2017 05:48:51 +0000 (00:48 -0500)]
nvc0: enable FBFETCH with a special slot for color buffer 0

We don't need to support all the color buffers for advanced blend, just
cb0. For Fermi, we use the special binding slots so that we don't
overlap with user textures, while Kepler+ gets a dedicated position for
the fb handle in the driver constbuf.

This logic is only triggered when a FBFETCH is actually present so it
should be a no-op most of the time.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
7 years agost/mesa: add support for advanced blend when fb can be fetched from
Ilia Mirkin [Mon, 2 Jan 2017 04:47:25 +0000 (23:47 -0500)]
st/mesa: add support for advanced blend when fb can be fetched from

This implements support for emitting FBFETCH ops, using the existing
lowering pass for advanced blend logic, and disabling hw blend when
advanced blending is enabled.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium: add flags parameter to texture barrier
Ilia Mirkin [Mon, 2 Jan 2017 04:42:17 +0000 (23:42 -0500)]
gallium: add flags parameter to texture barrier

This is so that we can differentiate between flushing any framebuffer
reading caches from regular sampler caches.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium: add PIPE_CAP_TGSI_FS_FBFETCH
Ilia Mirkin [Mon, 2 Jan 2017 04:10:00 +0000 (23:10 -0500)]
gallium: add PIPE_CAP_TGSI_FS_FBFETCH

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agogallium: add FBFETCH opcode to retrieve the current sample value
Ilia Mirkin [Mon, 2 Jan 2017 04:02:06 +0000 (23:02 -0500)]
gallium: add FBFETCH opcode to retrieve the current sample value

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agomesa: allow BlendBarrier to be used without support for full fb fetch
Ilia Mirkin [Mon, 2 Jan 2017 04:44:25 +0000 (23:44 -0500)]
mesa: allow BlendBarrier to be used without support for full fb fetch

The extension spec is not currently published, so it's a bit premature
to require it for BlendBarrier usage.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoglsl: avoid treating fb fetches as output reads to be lowered
Ilia Mirkin [Mon, 2 Jan 2017 04:00:46 +0000 (23:00 -0500)]
glsl: avoid treating fb fetches as output reads to be lowered

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
7 years agoradv/meta: split color renderpass creation out.
Dave Airlie [Mon, 16 Jan 2017 20:44:14 +0000 (06:44 +1000)]
radv/meta: split color renderpass creation out.

This is just prep work for layered clears, it doesn't change
anything.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
7 years agoradv: Support multiple devices.
Bas Nieuwenhuizen [Mon, 16 Jan 2017 20:25:10 +0000 (21:25 +0100)]
radv: Support multiple devices.

Pretty straightforward. Also deleted the big comment block as it
is a pretty standard pattern for filling in arrays.

Also removed the error message on non-existent devices, as getting
7 errors printed to the console each time you enumerate the
devices is pretty confusing.

v2: Add constant for number of DRM devices.

Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>