svga: minor code reformatting

To be consistent with other functions.
llvmpipe: remove polygon stipple assertion

It's possible for us to have an unused sampler bound when the fragment
shader itself doesn't use any samplers.  So the assertion isn't valid.

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=53616
mesa: Add explicit target checking to Get[Compressed]TexImage().

Previously, they relied on _mesa_max_texture_levels() for texture target
error checking.  This was somewhat dodgy, as _mesa_max_texture_levels()
is called in seven diferent places, not all of which necessarily accept
the same list of targets.

I copied the list of legal targets from _mesa_max_texture_levels() but
removed the proxy targets, as both functions explicitly rejected those
targets.  This changes the order in which we check errors, which could
change whether we return INVALID_VALUE or INVALID_ENUM.  However, it
shouldn't change the list of accepted targets.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
mesa: Add explicit target checking to GetTexLevelParameter[if]v().

Previously, it relied on _mesa_max_texture_levels() for texture target
error checking.  This was somewhat dodgy, as _mesa_max_texture_levels()
is called in seven diferent places, not all of which necessarily accept
the same list of targets.

I copied the list of legal targets from _mesa_max_texture_levels(), so
this patch should not introduce any change in behavior.  Future patches
will cause the two to diverge.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
mesa: Add GL_TEXTURE_CUBE_MAP to _mesa_max_texture_levels(). [v2]

For cube maps, _mesa_generate_mipmap() calls this with
GL_TEXTURE_CUBE_MAP (the gl_texture_object's Target) rather than one
of the faces.  This caused _mesa_max_texture_levels() to return 0, which
resulted in maxLevels == -1 and the next line's assertion to fail.

This function is called from seven places:
- fbobject.c: framebuffer_texture()
- mipmap.c: _mesa_generate_mipmap()
- texgetimage.c:
  - getteximage_error_check()
  - getcompressedteximage_error_check()
- texparam.c: _mesa_GetTexLevelParameteriv()
- texstorage.c: tex_storage_error_check()

All of these (or their callers) now explicitly check for invalid targets
already, so this shouldn't cause invalid targets to slip through.
(Technically _mesa_generate_mipmap() doesn't check for invalid targets,
but the API-facing _mesa_GenerateMipmapEXT() function does.)

+2 oglconforms (float-texture/mipmap.automatic and mipmap.manual)

In addition to fixing the mipmap bug, it should also cause glTexStorage
to accept GL_TEXTURE_CUBE_MAP, which is explicitly allowed by the spec.

v2: Drop alterations to callers; this is now in a patch series that adds
    explicit checking to API functions.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
mesa: Split out part of glGetTexLevelParameter into a helper function.

Move the _mesa_GetTexLevelParameter[iv] functions below the helper
function so the prototype is available.

This will be useful in the next commit.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
mesa: Support GL_TEXTURE_BUFFER in GetTexLevelParameter[if]v in GL 3.1+.

The OpenGL 3.1 specification explicitly allows this.  Oddly, the
ARB_texture_buffer_object spec's issues section claims this isn't
allowed, but proceeds to explain that the extension simply doesn't edit
the underlying spec to allow it, and thus it didn't appear in the list
of legal texture targets.

Thus, this patch legalizes it only in 3.1+ contexts, but still returns
INVALID_ENUM in earlier contexts that expose ARB_texture_buffer_object.

Unfortunately, the behavior of the call is horrendously undefined.

Fixes oglconform's tbo/negative.textureParams test.

v2: Require desktop OpenGL.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
i965: Fix bug in the old FS backend's projtex() calculation.

In the old backend, we looked at any FS attribute's proj_attrib_mask bits, not
just texcoords.  Now that we have _mesa_vert_result_to_frag_attrib(), we can
fill in the other FS inputs with correct proj_attrib_mask info.

NOTE: This is a candidate for stable branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=46644
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
mesa/es: Don't generate ES1 type conversion wrappers

These are gradually going to get whittled away and eventually folded into the
source files with the native type functions.

v2: Add (speculative) SConscript changes.  These may be broken.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
mesa: querying GL_TEXTURE_COMPRESSED_IMAGE_SIZE for a buffer obj is illegal

GL_INVALID_OPERATION is to be raised when querying a non-compressed
image/buffer.  Since a buffer object can't have a compressed format this
query always generates an error.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
mesa: remove unused params, add const qualifiers

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
st/mesa: use Elements() instead of hard-coded number

And add a comment about the velems_util_draw[] array.
util: update and fix u_upload_mgr.h comments
st/mesa: fix sampler view counting

In the past, when we called pipe::set_sampler_views(n) the drivers set
samplers [n..MAX] to NULL.  We no longer do that.  The state tracker
code was already trying to set unused sampler views to NULL to cover
that case, but the logic was broken and unnoticed until now.  This patch
fixes it.

Strictly speaking, this patch shouldn't be necessary.  Drivers should simply
ignore unused samplers and sampler views.  But some drivers like llvmpipe (and
others?) count those things and they figure into state validation.  That could
be fixed in the future.

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=53617

Reviewed-by: Marek Olšák <maraeo@gmail.com>
mesa: use #if over #ifdef in the FEATURE_ES1 check to fix a build failure.

mfeatures.h will define FEATURE_ES1 to 0 if it's not defined yet.

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

Signed-off-by: Brian Paul <brianp@vmware.com>
nv50/ir/emit: don't forget saturation bit on f32 add immediate

Solved by Maxim Levitsky on IRC.
nv50/ir/tgsi: handle DP2 in tgsi Instruction srcMask

Solved by Tiziano Bacocco on IRC.
r600g: Move common compute/3D register init to its own function

Signed-off-by: Tom Stellard <thomas.stellard@amd.com>
radeon-llvm: Start multithreaded before using llvm.

This is required to make some of llvm's api calls
thread save. In particular the PassRegistry, which is
implicitly accessed while compiling shader programs.
The PassRegistry uses a mutex that is only active if
the llvm_is_multithreaded() returns true.
Calling llvm_start_multithreading() makes this happen
and by calling this function we try to make sure that
we can savely compile shaders in paralell.
Since there is also a call llvm_stop_multithreading()
in the llvm api, we cannot guarantee that this does
not get switched off while we are relying on this being
set, but for the easier use cases this fixes a race with
the radeon llvm compiler we have as of today.

Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
Signed-off-by: Tom Stellard <thomas.stellard@amd.com>
mesa/es: Remove redundant min/mag filter validation

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>