mesa.git
8 years agomesa/extensions: Fix NVX_gpu_memory_info lexicographical order.
Vinson Lee [Sat, 6 Feb 2016 07:16:31 +0000 (23:16 -0800)]
mesa/extensions: Fix NVX_gpu_memory_info lexicographical order.

Fixes MesaExtensionsTest.AlphabeticallySorted.

Fixes: 1d79b9958090 ("mesa: implement GL_NVX_gpu_memory_info (v2)")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94016
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoglsl: return cloned signature, not the builtin one
Ilia Mirkin [Sat, 6 Feb 2016 22:08:29 +0000 (17:08 -0500)]
glsl: return cloned signature, not the builtin one

The builtin data can get released with a glReleaseShaderCompiler call.
We're careful everywhere to clone everything that comes out of builtins
except here, where we accidentally return the signature belonging to the
builtin version, rather than the locally-cloned one.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Tested-by: Rob Herring <robh@kernel.org>
Cc: mesa-stable@lists.freedesktop.org
8 years agoglsl: make sure builtins are initialized before getting the shader
Ilia Mirkin [Sat, 6 Feb 2016 22:07:59 +0000 (17:07 -0500)]
glsl: make sure builtins are initialized before getting the shader

The builtin function shader is part of the builtin state, released
when glReleaseShaderCompiler is called. We must ensure that the
builtins have been (re)initialized before attempting to link with the
builtin shader.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Tested-by: Rob Herring <robh@kernel.org>
Cc: mesa-stable@lists.freedesktop.org
8 years agotgsi: use TGSI_WRITEMASK_XYZW instead of hardcoding the mask
Samuel Pitoiset [Sat, 6 Feb 2016 19:24:41 +0000 (20:24 +0100)]
tgsi: use TGSI_WRITEMASK_XYZW instead of hardcoding the mask

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Serge Martin <edb+mesa@sigluy.net>
8 years agoglsl: don't generate transform feedback candidate when not required
Timothy Arceri [Tue, 2 Feb 2016 22:46:56 +0000 (09:46 +1100)]
glsl: don't generate transform feedback candidate when not required

If we are not even looking for one don't bother generating a candidate
list.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agoglsl: replace unreachable code with an assert()
Timothy Arceri [Tue, 2 Feb 2016 22:39:10 +0000 (09:39 +1100)]
glsl: replace unreachable code with an assert()

All interface blocks will have been lowered by this point so just
use an assert. Returning false would have caused all sorts of
problems if they were not lowered yet and there is an assert to
catch this later anyway.

We also update the tests to reflect this change.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
8 years agor600, compute: Do not overwrite pipe_resource.screen
Jan Vesely [Fri, 5 Feb 2016 22:54:57 +0000 (17:54 -0500)]
r600, compute: Do not overwrite pipe_resource.screen

found by inspection.

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
8 years agor600g: Ignore format for PIPE_BUFFER targets
Jan Vesely [Fri, 5 Feb 2016 17:01:13 +0000 (12:01 -0500)]
r600g: Ignore format for PIPE_BUFFER targets

Fixes compute since 7dd31b81fee7fe40bd09cf3fbc324fcc32782479
gallium/radeon: support PIPE_CAP_SURFACE_REINTERPRET_BLOCKS

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa/get: fix a breakage after rebase
Marek Olšák [Fri, 5 Feb 2016 18:38:40 +0000 (19:38 +0100)]
mesa/get: fix a breakage after rebase

trivial.

8 years agoi965/vec4: don't copy ATTR into 3src instructions with complex swizzles
Matt Turner [Mon, 18 Jan 2016 01:30:14 +0000 (20:30 -0500)]
i965/vec4: don't copy ATTR into 3src instructions with complex swizzles

The vec4 backend, at the end, does this:

    if (inst->is_3src()) {
       for (int i = 0; i < 3; i++) {
          if (inst->src[i].vstride == BRW_VERTICAL_STRIDE_0)
             assert(brw_is_single_value_swizzle(inst->src[i].swizzle));

So make sure that we use the same conditions when trying to
copy-propagate. UNIFORMs will be converted to vstride 0 in
convert_to_hw_regs, but so will ATTRs when interleaved (as will happen
in a GS with multiple attributes). Since the vstride is not set at
copy-prop time, infer it by inspecting dispatch_mode and reject ATTRs if
they have non-scalar swizzles and are interleaved.

Fixes assertion errors in dolphin-generated geometry shaders (or
misrendering on opt builds) on Sandybridge or on IVB/HSW with
INTEL_DEBUG=nodualobj.

Co-authored-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93418
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
8 years agodocs/relnotes: document memory info extensions
Marek Olšák [Fri, 5 Feb 2016 16:47:13 +0000 (17:47 +0100)]
docs/relnotes: document memory info extensions

8 years agogallium/radeon: implement query_memory_info (v2)
Marek Olšák [Tue, 2 Feb 2016 01:09:36 +0000 (02:09 +0100)]
gallium/radeon: implement query_memory_info (v2)

v2: don't use DIV_ROUND_UP (no so useful)
    also return eviction stats

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
8 years agost/mesa: implement and enable memory info extensions (v2)
Marek Olšák [Tue, 2 Feb 2016 00:27:55 +0000 (01:27 +0100)]
st/mesa: implement and enable memory info extensions (v2)

v2: assert and return if query_memory_info is not set
    rebase

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
8 years agomesa: implement GL_ATI_meminfo (v2)
Marek Olšák [Tue, 2 Feb 2016 00:26:59 +0000 (01:26 +0100)]
mesa: implement GL_ATI_meminfo (v2)

v2: rebase

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
8 years agomesa: implement GL_NVX_gpu_memory_info (v2)
Marek Olšák [Tue, 2 Feb 2016 00:22:52 +0000 (01:22 +0100)]
mesa: implement GL_NVX_gpu_memory_info (v2)

v2: implement eviction queries properly
    add gl_memory_info structure

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
8 years agogallium: add interface for querying memory usage and sizes (v2)
Marek Olšák [Mon, 1 Feb 2016 20:56:50 +0000 (21:56 +0100)]
gallium: add interface for querying memory usage and sizes (v2)

If you're worried about the duplication of some CAPs, we can remove them
later.

v2: add fields for memory eviction stats

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
8 years agogallium/radeon: remove radeon_info::r600_tiling_config
Marek Olšák [Sat, 30 Jan 2016 01:54:47 +0000 (02:54 +0100)]
gallium/radeon: remove radeon_info::r600_tiling_config

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agogallium/radeon: get pipe_interleave_bytes AKA group_bytes from the winsys
Marek Olšák [Sat, 30 Jan 2016 01:50:34 +0000 (02:50 +0100)]
gallium/radeon: get pipe_interleave_bytes AKA group_bytes from the winsys

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agogallium/radeon: set num_banks in the winsys
Marek Olšák [Sat, 30 Jan 2016 01:29:32 +0000 (02:29 +0100)]
gallium/radeon: set num_banks in the winsys

amdgpu doesn't have to set this, because radeonsi gets it from tile mode
arrays by default.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agogallium/radeon: just get num_tile_pipes from the winsys
Marek Olšák [Sat, 30 Jan 2016 00:52:58 +0000 (01:52 +0100)]
gallium/radeon: just get num_tile_pipes from the winsys

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agowinsys/amdgpu: add an assertion to cik_get_num_tile_pipes (v2)
Marek Olšák [Sat, 30 Jan 2016 00:44:26 +0000 (01:44 +0100)]
winsys/amdgpu: add an assertion to cik_get_num_tile_pipes (v2)

v2: print an error to stderr

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agowinsys/amdgpu: remove an r600-only setting
Marek Olšák [Sat, 30 Jan 2016 00:37:17 +0000 (01:37 +0100)]
winsys/amdgpu: remove an r600-only setting

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agogallium/radeon: rename & reorder members of radeon_info
Marek Olšák [Sat, 30 Jan 2016 00:27:46 +0000 (01:27 +0100)]
gallium/radeon: rename & reorder members of radeon_info

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
8 years agomesa: Fix locking of GLsync objects.
Steinar H. Gunderson [Tue, 2 Feb 2016 00:16:51 +0000 (01:16 +0100)]
mesa: Fix locking of GLsync objects.

GLsync objects had a race condition when used from multiple threads
(which is the main point of the extension, really); it could be
validated as a sync object at the beginning of the function, and then
deleted by another thread before use, causing crashes. Fix this by
changing all casts from GLsync to struct gl_sync_object to a new
function _mesa_get_and_ref_sync() that validates and increases
the refcount.

In a similar vein, validation itself uses _mesa_set_search(), which
requires synchronization -- it was called without a mutex held, causing
spurious error returns and other issues. Since _mesa_get_and_ref_sync()
now takes the shared context mutex, this problem is also resolved.

Fixes bug #92757, found while developing Nageru, my live video mixer
(due for release at FOSDEM 2016).

v2: Marek: silence warnings, fix declaration after code

Signed-off-by: Steinar H. Gunderson <sesse@google.com>
Cc: "11.0 11.1" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
8 years agoradeonsi: add placeholder MC and SRBM performance counter groups
Nicolai Hähnle [Fri, 11 Dec 2015 21:03:56 +0000 (16:03 -0500)]
radeonsi: add placeholder MC and SRBM performance counter groups

Yet another change motivated by AMD GPUPerfStudio compatibility. These groups
are not directly accessible from userspace, and AMD GPUPerfStudio does not
actually query them - it just requires them to be there. Hence, adding
a placeholder for now.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
8 years agoradeonsi: re-order the SQ_xx performance counter blocks
Nicolai Hähnle [Fri, 11 Dec 2015 20:58:11 +0000 (15:58 -0500)]
radeonsi: re-order the SQ_xx performance counter blocks

This is yet another change motivated by appeasing AMD GPUPerfStudio's
hardcoding of performance counter group numbers.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
8 years agoradeonsi: re-order the perfcounter hardware blocks
Nicolai Hähnle [Fri, 11 Dec 2015 20:42:44 +0000 (15:42 -0500)]
radeonsi: re-order the perfcounter hardware blocks

As documented in the comment, AMD GPUPerfStudio unfortunately hardcodes the
order of performance counter groups. Let's do the pragmatic thing and present
the same order as Catalyst/Crimson.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
8 years agogallium/radeon: add GPIN driver query group
Nicolai Hähnle [Fri, 11 Dec 2015 20:39:23 +0000 (15:39 -0500)]
gallium/radeon: add GPIN driver query group

This group was used by older versions of AMD GPUPerfStudio (via
AMD_performance_monitor) to identify the GPU family, and GPUPerfStudio
still complains when it isn't available.

Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Acked-by: Marek Olšák <marek.olsak@amd.com>
8 years agoradeonsi: Allow dumping LLVM IR before optimization passes
Nicolai Hähnle [Thu, 4 Feb 2016 07:59:39 +0000 (08:59 +0100)]
radeonsi: Allow dumping LLVM IR before optimization passes

Set R600_DEBUG=preoptir to dump the LLVM IR before optimization passes,
to allow diagnosing problems caused by optimization passes.

Note that in order to compile the resulting IR with llc, you will first
have to run at least the mem2reg pass, e.g.

opt -mem2reg -S < shader.ll | llc -march=amdgcn -mcpu=bonaire

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> (original patch)
Signed-off-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (w/ debug flag)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agogallium/radeon: emit LLVM `ret void` before radeon_llvm_finalize_module
Nicolai Hähnle [Thu, 4 Feb 2016 07:51:52 +0000 (08:51 +0100)]
gallium/radeon: emit LLVM `ret void` before radeon_llvm_finalize_module

This allows dumping a consumable LLVM module before the initial optimization
passes are run.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agost/mesa: bail out of try_pbo_upload_common when constant upload fails
Nicolai Hähnle [Wed, 3 Feb 2016 17:02:55 +0000 (18:02 +0100)]
st/mesa: bail out of try_pbo_upload_common when constant upload fails

Also fixes a resource leak when an upload_mgr is used for constants.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agost/mesa: bail out of try_pbo_upload_common when vertex upload fails
Nicolai Hähnle [Wed, 3 Feb 2016 17:00:47 +0000 (18:00 +0100)]
st/mesa: bail out of try_pbo_upload_common when vertex upload fails

At the same time, fix a memory leak noticed by Ilia Mirkin.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agost/mesa: reduce the scope of sampler_view in try_pbo_upload_common
Nicolai Hähnle [Wed, 3 Feb 2016 16:58:40 +0000 (17:58 +0100)]
st/mesa: reduce the scope of sampler_view in try_pbo_upload_common

We can get rid of our reference immediately, since the driver will hold
onto it for us.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agost/mesa: do uploads earlier in try_pbo_upload_common
Nicolai Hähnle [Wed, 3 Feb 2016 16:54:33 +0000 (17:54 +0100)]
st/mesa: do uploads earlier in try_pbo_upload_common

While rather unlikely, uploads _can_ fail. Doing them earlier means
we'll have to restore less state when they do fail, and it's slightly
easier to check the restore code.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomain: Use a derived value for the default sample count
Neil Roberts [Thu, 4 Feb 2016 16:12:07 +0000 (16:12 +0000)]
main: Use a derived value for the default sample count

Previously the framebuffer default sample count was taken directly
from the value given by the application. On the i965 driver on HSW if
the value wasn't one that is supported by the hardware it would hit an
assert when it tried to program the state for it. This patch fixes it
by adding a derived sample count to the state for the default
framebuffer. The driver can then quantize this to one of the valid
values in its UpdateState handler when the _NEW_BUFFERS state changes.
_mesa_geometric_samples is changed to use the new derived value.

Fixes the piglit test arb_framebuffer_no_attachments-query

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93957
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agoprogram: Use _mesa_geometric_samples to calculate gl_NumSamples
Neil Roberts [Thu, 4 Feb 2016 16:12:06 +0000 (16:12 +0000)]
program: Use _mesa_geometric_samples to calculate gl_NumSamples

Otherwise it won't take into account the default samples for
framebuffers with no attachments.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agomain: Use _mesa_geometric_samples to calculate GL_SAMPLE_BUFFERS
Neil Roberts [Thu, 4 Feb 2016 16:12:05 +0000 (16:12 +0000)]
main: Use _mesa_geometric_samples to calculate GL_SAMPLE_BUFFERS

Otherwise it won't take into account the default samples for
framebuffers with no attachments.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agomain: Use _mesa_geometric_samples to calculate the value of GL_SAMPLES
Neil Roberts [Thu, 4 Feb 2016 16:12:04 +0000 (16:12 +0000)]
main: Use _mesa_geometric_samples to calculate the value of GL_SAMPLES

Otherwise it won't take into account the default samples for
framebuffers with no attachments.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agonvc0: avoid negatives in PUSH_SPACE argument
Ilia Mirkin [Fri, 5 Feb 2016 05:47:03 +0000 (00:47 -0500)]
nvc0: avoid negatives in PUSH_SPACE argument

Fixup to commit 03b3eb90d - the number of buffers could be larger than
the number of elements, in which case we'd pass a negative argument to
PUSH_SPACE, which would be bad. While we're at it, merge it with the
other PUSH_SPACE at the top of the function.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
8 years agonvc0: add some missing PUSH_SPACE's
Ilia Mirkin [Fri, 5 Feb 2016 05:36:03 +0000 (00:36 -0500)]
nvc0: add some missing PUSH_SPACE's

nvc0_vbo has explicit push space checking enabled, so we must run
PUSH_SPACE by hand. A few spots missed that.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
8 years agonvc0/ir: fix converting between predicate and gpr
Ilia Mirkin [Fri, 5 Feb 2016 03:58:48 +0000 (22:58 -0500)]
nvc0/ir: fix converting between predicate and gpr

The spill logic will insert convert ops when moving between files. It
seems like the emission logic wasn't quite ready for these converts.

Tested on fermi, and visually looked at nvdisasm output for maxwell.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: mesa-stable@lists.freedesktop.org
8 years agonvc0: add support for ARB_query_buffer_object
Ilia Mirkin [Sun, 31 Jan 2016 20:18:23 +0000 (15:18 -0500)]
nvc0: add support for ARB_query_buffer_object

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
8 years agost/mesa: add query buffer support
Ilia Mirkin [Sat, 9 May 2015 16:31:48 +0000 (12:31 -0400)]
st/mesa: add query buffer support

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agogallium: add PIPE_CAP_QUERY_BUFFER_OBJECT
Ilia Mirkin [Sun, 10 Jan 2016 04:30:16 +0000 (23:30 -0500)]
gallium: add PIPE_CAP_QUERY_BUFFER_OBJECT

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agogallium: add a way to store query result into buffer
Ilia Mirkin [Sun, 3 May 2015 00:28:11 +0000 (20:28 -0400)]
gallium: add a way to store query result into buffer

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa: add core implementation of ARB_query_buffer_object
Ilia Mirkin [Wed, 6 May 2015 02:58:12 +0000 (22:58 -0400)]
mesa: add core implementation of ARB_query_buffer_object

Forwards query result writes to drivers.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa: add driver interface for writing query results to buffers
Ilia Mirkin [Wed, 6 May 2015 02:57:41 +0000 (22:57 -0400)]
mesa: add driver interface for writing query results to buffers

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa: Handle QUERY_BUFFER_BINDING in GetIntegerv
Rafal Mielniczuk [Thu, 27 Mar 2014 20:59:05 +0000 (21:59 +0100)]
mesa: Handle QUERY_BUFFER_BINDING in GetIntegerv

Signed-off-by: Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
[imirkin: move to GL/GL_CORE section]
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa: Add QueryBuffer to context
Rafal Mielniczuk [Thu, 27 Mar 2014 20:59:04 +0000 (21:59 +0100)]
mesa: Add QueryBuffer to context

Add QueryBuffer and initialise it to NullBufferObj on start

Signed-off-by: Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
[imirkin: also release QueryBuffer on free]
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agomesa: Add ARB_query_buffer_object extension flag
Rafal Mielniczuk [Thu, 27 Mar 2014 20:59:03 +0000 (21:59 +0100)]
mesa: Add ARB_query_buffer_object extension flag

Signed-off-by: Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
[imirkin: add string to extensions.c]
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoglapi: Add xml infrastructure for ARB_query_buffer_object
Rafal Mielniczuk [Thu, 27 Mar 2014 20:59:02 +0000 (21:59 +0100)]
glapi: Add xml infrastructure for ARB_query_buffer_object

Signed-off-by: Rafal Mielniczuk <rafal.mielniczuk2@gmail.com>
[imirkin: move definition to gl_API.xml as it is very short]
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
8 years agoglsl: simplify setting of image access qualifiers
Timothy Arceri [Thu, 4 Feb 2016 00:08:43 +0000 (11:08 +1100)]
glsl: simplify setting of image access qualifiers

Cc: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agomesa: remove dead program parameter functions
Timothy Arceri [Thu, 4 Feb 2016 10:50:39 +0000 (21:50 +1100)]
mesa: remove dead program parameter functions

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
8 years agost/nine: Use align_free when needed
Axel Davy [Thu, 28 Jan 2016 21:32:43 +0000 (22:32 +0100)]
st/nine: Use align_free when needed

Use align_free to free memory allocated
with align_malloc.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Disallow non-argb8888 cursors
Axel Davy [Tue, 26 Jan 2016 15:40:30 +0000 (16:40 +0100)]
st/nine: Disallow non-argb8888 cursors

Only argb8888 cursors are allowed.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Enforce centroid for color input when multisampling is on
Axel Davy [Sat, 9 Jan 2016 13:16:15 +0000 (14:16 +0100)]
st/nine: Enforce centroid for color input when multisampling is on

The color inputs must automatically use centroid whether
multisampling is used or not.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Fix centroid flag
Axel Davy [Thu, 28 Jan 2016 21:44:42 +0000 (22:44 +0100)]
st/nine: Fix centroid flag

sem.reg.mod & NINED3DSPDM_CENTROID is worth 4 when
centroid is requested, whereas
TGSI_INTERPOLATE_LOC_CENTROID is worth 1.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Use fast clears more often for MRTs
Axel Davy [Mon, 4 Jan 2016 15:15:18 +0000 (16:15 +0100)]
st/nine: Use fast clears more often for MRTs

This enables to use fast clears in the following
case:

pixel shader renders to 1 RT
4 RT bound
clear
new pixel shader bound that renders to 4 RTs

Previously the fast clear path wouldn't be hit,
because when trying the fast clear path,
the framebuffer state would be configured for 1 RT,
instead of 4.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Use linear filtering for shadow mapping
Axel Davy [Mon, 4 Jan 2016 15:13:07 +0000 (16:13 +0100)]
st/nine: Use linear filtering for shadow mapping

Some docs say linear filtering is always used when
app does shadow mapping.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Respect block alignment on surface lock
Patrick Rudolph [Thu, 22 Oct 2015 13:46:16 +0000 (15:46 +0200)]
st/nine: Respect block alignment on surface lock

Respect block alignment for ATI1/ATI2 format when trying to lock a
surface using LockRect().
Fixes failing WINE tests device.c test_surface_blocks() tests.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Add Render state validation layer
Axel Davy [Sat, 16 May 2015 12:28:41 +0000 (14:28 +0200)]
st/nine: Add Render state validation layer

Testing Win behaviour seems to show wrong states
are accepted, but then depending on the states
some specific 'good' behaviours happen.

This adds some validation to catch invalid
states and have these 'good' behaviours
when it happens.

Also reorders SetRenderState to match the expected
optimisation:
(Value == previous Value) => return immediately,
which affects D3D9 hacks too.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
8 years agoDRI_CONFIG: Add option to override vendor id
Patrick Rudolph [Mon, 25 May 2015 11:06:58 +0000 (13:06 +0200)]
DRI_CONFIG: Add option to override vendor id

Add config option override_vendorid to report a fake card in d3dadapter9 drm.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Implement NineDevice9_GetAvailableTextureMem
Patrick Rudolph [Wed, 30 Sep 2015 14:42:10 +0000 (16:42 +0200)]
st/nine: Implement NineDevice9_GetAvailableTextureMem

Implement a device private memory counter similar to Win 7.

Only textures and surfaces increment vidmem and may return
ERR_OUTOFVIDEOMEMORY. Vertexbuffers and indexbuffers creation always
succeedes, even when out of video memory.

Fixes "Vampire: The Masquerade - Bloodlines" allocating resources until crash.
Fixes "Age of Conan" allocating resources until crash.
Fixes failing WINE test device.c test_vidmem_accounting().

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Handle Window Occlusion
Patrick Rudolph [Sat, 20 Jun 2015 18:06:11 +0000 (20:06 +0200)]
st/nine: Handle Window Occlusion

Apps can know if the window is occluded by checking for
specific error messages. The behaviour is different
for Device9 and Device9Ex.

This allow games to release the mouse and stop rendering
until the focus is restored.

In case of multiple swapchain we do care only of the device one.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Store minor version num
Patrick Rudolph [Sun, 23 Aug 2015 06:42:34 +0000 (08:42 +0200)]
st/nine: Store minor version num

To keep compatible with older ID3DPresent interfaces (used to talk
with Wine), store the minor version num accessible to all
statetracker functions (in the NineDevice9 structure).

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Call flush_resource before flush
Axel Davy [Thu, 8 Oct 2015 22:08:43 +0000 (00:08 +0200)]
st/nine: Call flush_resource before flush

flush_resource needs to be called before flush (for
fast clear resolve, etc).

Removes useless computation of resource (it is
already set correctly).

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Fix remaining swapchain tests
Patrick Rudolph [Thu, 22 Oct 2015 15:00:35 +0000 (17:00 +0200)]
st/nine: Fix remaining swapchain tests

Return D3DERR_INVALIDCALL instead of E_POINTER.
On error set ppBackBuffer to NULL.

Multiple swapchains can only be created in windowed mode as
windowed swapchain.

Set backbuffer to NULL in NineDevice9_GetBackBuffer, but not
in NineSwapChain9_GetBackBuffer.

This fixes all WINE's device.c test_swapchain() tests.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix crash NineDevice9_CreateAdditionalSwapChain
Axel Davy [Wed, 11 Nov 2015 09:13:58 +0000 (10:13 +0100)]
st/nine: Fix crash NineDevice9_CreateAdditionalSwapChain

When no window is specified, we should revert to the focus window.

This deserves more tests however (what if the device swapchain is
already using the focus window ?)

Fixes crash for FFXIV

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Fix possible crash on error
Patrick Rudolph [Thu, 22 Oct 2015 15:02:16 +0000 (17:02 +0200)]
st/nine: Fix possible crash on error

In case swapchain creation fails This->swapchains[i] might be NULL and
causes a crash.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Test more presentation params
Patrick Rudolph [Thu, 22 Oct 2015 14:02:14 +0000 (16:02 +0200)]
st/nine: Test more presentation params

Return errors in case of invalid presentation parameters.
Fixes failing WINE tests device.c test_swapchain_parameters().

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix resource9 private data
Patrick Rudolph [Sat, 14 Nov 2015 12:02:43 +0000 (13:02 +0100)]
st/nine: Fix resource9 private data

Store a copy of GUID in the header that is under our control and use it
as key for the hashtable instead of using the application provided pointer.
The application might change the memory after leaving the function.

Fixes a crash for issue https://github.com/iXit/Mesa-3D/issues/130

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Print GUID instead of pointer
Patrick Rudolph [Sat, 14 Nov 2015 11:59:46 +0000 (12:59 +0100)]
st/nine: Print GUID instead of pointer

To ease debugging print the GUID instead of the pointer to it.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix use of uninitialized memory
Patrick Rudolph [Thu, 24 Sep 2015 17:57:51 +0000 (19:57 +0200)]
st/nine: Fix use of uninitialized memory

The values of box.z and box.depth weren't set and lead to a crash.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix clear for multisample mismatch depth-stencil
Patrick Rudolph [Wed, 23 Sep 2015 14:30:37 +0000 (16:30 +0200)]
st/nine: Fix clear for multisample mismatch depth-stencil

Tests show in case of multisample mismatch between the depth-stencil
buffer and the render target, then it is not cleared.

Fixes failing WINE test visual.c test_multisample_mismatch().

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix Volumetexture9_LockBox
Patrick Rudolph [Mon, 31 Aug 2015 17:17:13 +0000 (19:17 +0200)]
st/nine: Fix Volumetexture9_LockBox

Check for valid locked box dimensions.

Fixes failing wine tests device.c test_lockbox_invalid.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix ATI2 pitch for non-square
Axel Davy [Sat, 22 Aug 2015 23:09:44 +0000 (01:09 +0200)]
st/nine: Fix ATI2 pitch for non-square

Fixes crash for non-square textures.
We were using the height instead of the
width for some calculations.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Support D3DFMT_R8G8B8
Patrick Rudolph [Mon, 9 Nov 2015 18:30:13 +0000 (19:30 +0100)]
st/nine: Support D3DFMT_R8G8B8

Add support for D3DFMT_R8G8B8. It allows format conversion for
surfaces of pool scratch.

Usually gallium formats equivalents for d3d9 formats
have their names reversed.

The gallium format PIPE_FORMAT_R8G8B8_UNORM is the right
equivalent here, and its name is likely wrong (reversed).

Fixes a crash in TmNationsForever.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Use cso for viewport
Patrick Rudolph [Sat, 19 Dec 2015 06:43:08 +0000 (07:43 +0100)]
st/nine: Use cso for viewport

Use CSO to catch redundant viewport changes.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix shade mode flat
Patrick Rudolph [Sat, 12 Dec 2015 09:22:12 +0000 (10:22 +0100)]
st/nine: Fix shade mode flat

Shade mode flat is only working if pixelshaders have interpolate
set to TGSI_INTERPOLATE_COLOR on color inputs.

Fixes failing WINE tests visual.c test_shademode().

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Clear rendertarget on creation
Patrick Rudolph [Thu, 10 Dec 2015 19:08:03 +0000 (20:08 +0100)]
st/nine: Clear rendertarget on creation

Clear every rendertarget on creation.
Fixes https://github.com/iXit/Mesa-3D/issues/139

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Allow ColorFill on D3DFMT_NULL surfaces
Patrick Rudolph [Sat, 5 Dec 2015 13:14:38 +0000 (14:14 +0100)]
st/nine: Allow ColorFill on D3DFMT_NULL surfaces

Report success instead of failing as there's no resource for those surfaces.
Fixes a crash in Crysis: Warhead.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Introduce STREAMFREQ state
Axel Davy [Sat, 12 Dec 2015 18:20:28 +0000 (19:20 +0100)]
st/nine: Introduce STREAMFREQ state

Previous vertex elements code update
was protected by
'if ((group & (NINE_STATE_VDECL | NINE_STATE_VS)) ||
state->changed.stream_freq & ~1)'
itself protected by
'if (group & (NINE_STATE_COMMON | NINE_STATE_VS))'

If no state is changed except the stream frequency,
no update would happen.

This patch solves the problem by adding a new
NINE_STATE_STREAMFREQ state.
Another way would be to add state->changed.stream_freq & ~1
check to the main test.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Catch redundant SetStreamSourceFreq calls
Axel Davy [Sat, 12 Dec 2015 18:11:10 +0000 (19:11 +0100)]
st/nine: Catch redundant SetStreamSourceFreq calls

Some apps do redundant SetStreamSourceFreq calls.
Catch them to improve performance.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Squash indexbuffer9 and vertexbuffer9
Patrick Rudolph [Sun, 15 Nov 2015 10:26:25 +0000 (11:26 +0100)]
st/nine: Squash indexbuffer9 and vertexbuffer9

The indexbuffer9 codebase was lagging behind the one of vertexbuffer9.

Add buffer9 as common code base for indexbuffer9 and vertexbuffer9.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Unset vtxbuf on reset
Axel Davy [Sun, 15 Nov 2015 16:10:40 +0000 (17:10 +0100)]
st/nine: Unset vtxbuf on reset

We forgot to reset vtxbuf.
This fixes some crashes.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Use pipe_resource_reference for vtxbuf
Axel Davy [Sat, 30 Jan 2016 10:39:21 +0000 (11:39 +0100)]
st/nine: Use pipe_resource_reference for vtxbuf

This seems cleaner to actually reference the resources for vtxbuf,
rather than relying on the fact the bound d3d streams do.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Use ff vertex shader when position_t is used
Axel Davy [Sat, 7 Nov 2015 16:47:06 +0000 (17:47 +0100)]
st/nine: Use ff vertex shader when position_t is used

When an application sets a vertex shader, we are supposed
to use it, and when no vertex shader are set, we are supposed
to revert to fixed function vertex shader.

It seems there is an exception: when the vertex declaration
has a position_t index, we should revert to fixed function
vertex shader.

Up to know we were checking if device->state.vs is set
to know whether to use programmable shader or not.

With this commit we determine whether we use programmable shader
or not when vertex shader/declaration are set, but
stateblocks do complicate things a bit.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Don't increment refcount on VertexDeclaration creation failure
Patrick Rudolph [Thu, 28 May 2015 18:45:01 +0000 (20:45 +0200)]
st/nine: Don't increment refcount on VertexDeclaration creation failure

NineUnknown_ctor increments the refcount even in case of an error.
Restructure the code to prevent refcount increments.
Fixes a couple of wine tests.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Change StretchRect check order
Axel Davy [Mon, 24 Aug 2015 17:36:55 +0000 (19:36 +0200)]
st/nine: Change StretchRect check order

Textures in SYSTEMMEM don't have resources attached.
Instead of returning an error for them, StretchRect
was crashing.
This changes the check order to fix that case.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Initialize lights in stateblocks
Axel Davy [Sun, 16 Aug 2015 19:39:42 +0000 (21:39 +0200)]
st/nine: Initialize lights in stateblocks

This fixes a crash.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Fix fixed-function blendweights
Patrick Rudolph [Tue, 22 Sep 2015 14:10:40 +0000 (16:10 +0200)]
st/nine: Fix fixed-function blendweights

The last weighted element is one minus the sum of all previous weights.
Fixes WINE test visual.c test_vertex_blending.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Always normalize hitDir
Patrick Rudolph [Tue, 22 Sep 2015 12:30:35 +0000 (14:30 +0200)]
st/nine: Always normalize hitDir

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Replace r[0] with tmp
Patrick Rudolph [Tue, 22 Sep 2015 11:24:08 +0000 (13:24 +0200)]
st/nine: Replace r[0] with tmp

Replace r[0] with tmp to ease code reading.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix ff calculation of midVec
Patrick Rudolph [Mon, 28 Sep 2015 17:44:26 +0000 (19:44 +0200)]
st/nine: Fix ff calculation of midVec

In case of non local viewer the value has to be subtracted.
Fixes failing WINE tests in test_specular_lighting() (visual.c)

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Implement D3DRS_SPECULARENABLE
Patrick Rudolph [Tue, 22 Sep 2015 10:57:37 +0000 (12:57 +0200)]
st/nine: Implement D3DRS_SPECULARENABLE

Implement fixed function D3DRS_SPECULARENABLE.
Fixes failing WINE tests in test_specular_lighting() (visual.c)

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix D3DRS_LOCALVIEWER being ignored
Patrick Rudolph [Tue, 22 Sep 2015 15:29:42 +0000 (17:29 +0200)]
st/nine: Fix D3DRS_LOCALVIEWER being ignored

Set key->localviewer to D3DRS_LOCALVIEWER.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agost/nine: Fix rounding issue with vs1.1 a0 reg
Axel Davy [Wed, 11 Nov 2015 09:15:19 +0000 (10:15 +0100)]
st/nine: Fix rounding issue with vs1.1 a0 reg

vs1.1 rounds a0 to lowest integer, while
other versions do round to closest.

To use the same path as the other versions (with ARR),
we were substracting 0.5 for vs1.1 to get round to lowest.

This gives wrong result if a0 is set to 0:
round(0 - 0.5) = -1

Instead just use ARL for vs1.1

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Fix D3DPMISCCAPS_FOGANDSPECULARALPHA support
Axel Davy [Sat, 17 Oct 2015 11:54:18 +0000 (13:54 +0200)]
st/nine: Fix D3DPMISCCAPS_FOGANDSPECULARALPHA support

The documentation of the flag doesn't make sense.
To sum up the doc, if not set, specular alpha contains fog,
and if set specular alpha contains 0 (except for ff).

However in practice when the flag is there, apps do use specular alpha
as if it could be used normally, which makes much more sense than the doc.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
8 years agost/nine: Fix AlphaCmpCaps
Patrick Rudolph [Thu, 24 Dec 2015 10:32:37 +0000 (11:32 +0100)]
st/nine: Fix AlphaCmpCaps

AlphaCmpCaps should advertise D3DPCMPCAPS_NEVER as well.

Fixes https://github.com/iXit/Mesa-3D/issues/142

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
8 years agoradeonsi: implement PK2H and UP2H opcodes
Marek Olšák [Fri, 29 Jan 2016 23:30:02 +0000 (00:30 +0100)]
radeonsi: implement PK2H and UP2H opcodes

Based on a gallivm patch by Ilia Mirkin.

+8 piglit regressions due to precision issues (I blame the tests)

The benefit is that we'll get v_cvt_f32_f16 and v_cvt_f16_f32 instead
of emulation with integer instructions. They are GLSL 4.00 intrinsics.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>