Commit Graph

89497 Commits

Author SHA1 Message Date
Tomasz Figa 06758c1e8a mesa: Use _mesa_has_OES_geometry_shader() when validating draws
In validate_DrawElements_common() we need to check for OES_geometry_shader
extension to determine if we should fail if transform feedback is
unpaused. However current code reads ctx->Extensions.OES_geometry_shader
directly, which does not take context version into account. This means
that if the context is GLES 3.0, which makes the OES_geometry_shader
inapplicable, we would not validate the draw properly. To fix it, let's
replace the check with a call to _mesa_has_OES_geometry_shader().

Fixes following dEQP tests on i965 with a GLES 3.0 context:

dEQP-GLES3.functional.negative_api.vertex_array#draw_elements
dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_incomplete_primitive
dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_instanced
dEQP-GLES3.functional.negative_api.vertex_array#draw_elements_instanced_incomplete_primitive
dEQP-GLES3.functional.negative_api.vertex_array#draw_range_elements
dEQP-GLES3.functional.negative_api.vertex_array#draw_range_elements_incomplete_primitive

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-02 00:37:17 -08:00
Kenneth Graunke 58793e514b i965: Replace BRW_SURFACEFORMAT_* with ISL_FORMAT_*.
One less set of enums.  Dropped the #defines from brw_defines.h and ran:

$ for file in *.cpp *.c *.h; do sed -i \
      -e 's/BRW_SURFACEFORMAT_/ISL_FORMAT_/g' \
      -e 's/ISL_FORMAT_ASTC_[A-Zxs0-9_]*/\U&/g' $file; \
  done

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-02 00:30:45 -08:00
Chris Wilson 92281b2c7f i965: Only flush the batchbuffer if we need to zero the SO offsets
If we don't have pipelined register access (e.g. Haswell before kernel
v4.2), then we can only implement EXT_transform_feedback by reseting the
SO offsets *between* batches. However, if we do have pipelined access to
the SO registers on gen7, we can simply emit an inline reset of the SO
registers without a full batch flush.

v2 [by Ken]: Simplify after recent kernel feature detection changes.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-02 00:30:41 -08:00
Iago Toral Quiroga 7ad692d8e2 anv: do not subtract the base layer to compute depth in 3DSTATE_DEPTH_BUFFER
According to the PRM description of the Depth field:

  "This field specifies the total number of levels for a volume texture
   or the number of array elements allowed to be accessed starting at the
   Minimum Array Element for arrayed surfaces"

However, ISL defines array_len as the length of the range
[base_array_layer, base_array_layer + array_len], so it already represents
a value relative to the base array layer like the hardware expects.

v2: Depth is defined as a U11-1 field, so subtract 1 from
    the actual value (Jason)

This fixes a number of new CTS tests that would crash otherwise:
dEQP-VK.pipeline.render_to_image.*

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-02 09:04:03 +01:00
Iago Toral Quiroga 64bf78270d isl: document the meaning of the array_len field in isl_view
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2017-03-02 09:03:42 +01:00
Jacob Lifshay 3d8feb38e8 vulkan/wsi: Improve the DRI3 error message
This commit improves the message by telling them that they could probably
enable DRI3.  More importantly, it includes a little heuristic to check
to see if we're running on AMD or NVIDIA's proprietary X11 drivers and,
if we are, doesn't emit the warning.  This way, users with both a discrete
card and Intel graphics don't get the warning when they're just running
on the discrete card.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99715
Co-authored-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Kai Wasserbäch <kai@dev.carbon-project.org>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Tested-by: Rene Lindsay <rjklindsay@hotmail.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Cc: "17.0" <mesa-dev@lists.freedesktop.org>
2017-03-01 19:11:47 -08:00
Jason Ekstrand 424ac809bf i965: Do int64 lowering in NIR
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand 074f5ba0b5 nir: Add a simple int64 lowering pass
The algorithms used by this pass, especially for division, are heavily
based on the work Ian Romanick did for the similar int64 lowering pass
in the GLSL compiler.

v2: Properly handle vectors

v3: Get rid of log2_denom stuff.  Since we're using bcsel, we do all the
    calculations anyway and this is just extra instructions.

v4:
 - Add back in the log2_denom stuff since it's needed for ensuring that
   the shifts don't overflow.
 - Rework the looping part of the pass to be easier to expand.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand 86e749b1ad spirv: Use nir_builder for control flow
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand 95972cd4fd nir/lower_indirect: Use nir_builder control-flow helpers
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand 3ce8eeb5a1 nir/lower_gs_intrinsics: Use nir_builder control-flow helpers
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand c75f965ab7 glsl/nir: Use nir_builder's new control-flow helpers
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand e27c716ad7 nir/builder: Add support for easily building control-flow
Each of the pop functions (and push_else) take a control flow parameter as
their second argument.  If NULL, it assumes that the builder is in a block
that's a direct child of the control-flow node you want to pop off the
virtual stack.  This is what 90% of consumers will want.  The SPIR-V pass,
however, is a bit more "creative" about how it walks the CFG and it needs
to be able to pop multiple levels at a time, hence the argument.

Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
2017-03-01 17:00:20 -08:00
Jason Ekstrand d5b355ce5f i965: Move intel_debug.h to intel/common/gen_debug.h
This is shared between the Vulkan and GL drivers as it's a requirement
of the back-end compiler.  However, it doesn't really belong in the
compiler.  We rename the file to match the prefix of the other stuff in
common and because libdrm defines an intel_debug.h and this avoids a
pile of possible name conflicts.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:14:03 -08:00
Jason Ekstrand 8048c1953c i965: Reduce cross-pollination between the DRI driver and compiler
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:03 -08:00
Jason Ekstrand a2195e561a i965: Move select_clip_planes to brw_vs.c
Reviewed-by: Matt Turner <mattst88@gmail.com>
2017-03-01 16:14:03 -08:00
Jason Ekstrand 818bfdfa15 i965: Delete brw_do_cubemap_normalize
This hasn't been used for quite some time now but we never bothered to
get rid of it when we dropped GLSL IR support for vec4.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:03 -08:00
Jason Ekstrand 7ac47b1af7 i965: Add a header for brw_vec4_vs_visitor
brw_vs.h is not a compiler file but brw_vec4_visitor is definitely a
compiler thing.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 1c318af743 i965: Move a bunch of pre-compile and link stuff to brw_program.h
It's all GL-specific and brw_program.h is not part of i965_compiler.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand fbb9171968 i965: Move image uniform setup to brw_nir_uniforms.cpp
It's the only thing that's using it.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 820ae39725 i965: Move channel_expressions and vector_splitting to brw_program.h
They're GL-specific.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 760c8a1d95 i965: Make mark_surface_used a static inline in brw_compiler.h
One of these days, I'd like to see this function go away all together
but for now, let's at least put it near the struct it updates.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand f33d2b5d05 i965: Move BRW_ATTRIB_WA_* defines to brw_compiler.h
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 4e274bcf66 i965: Move BRW_MAX_DRAW_BUFFERS to brw_compiler.h
It does sort-of go with MAX_UBO and friends but MAX_DRAW_BUFFERS is an
actual hardware constant based on the number of things we can blend
rather than an arbitrary "number of things allowed in GL" like some of
the other maximums are.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 2523241660 i965/inst: Stop using fi_type
It's a mesa define that's trivial to inline.  This removes a dependence
on main/imports.h.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand ffeb738112 i965: Move brw_register_blocks to brw_fs.cpp
Its one and only caller is brw_compile_fs which lives there.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 5b87c7e0e3 i965: Move SHADER_TIME_STRIDE to brw_compiler.h
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand f85ef11501 i965: Move SOL binding #defines to brw_compiler.h
While we're at it, we also change the GEN6 binding macro to be a start
index that gets added to the binding.  This makes things a bit more
explicit.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:02 -08:00
Jason Ekstrand 81e5bdf072 i964/gs: Move MAX_GS_INPUT_VERTICES to brw_vec4_gs_visitor.h
It's only users are in brw_vec4_gs_visitor and gen6_vec4_gs_visitor.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:01 -08:00
Jason Ekstrand c6a719b64f i965/gs: Add the gl_prim_to_hw_prim table to vec4_gs_visitor.cpp
It's currently in brw_util.c but that's the only bit of brw_util.c
that's shared between the compiler and the rest of the GL driver.
It's just a fairly obvious table so the duplication isn't bad.  It's
certainly less pain than trying to figure out how to share the code.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:01 -08:00
Jason Ekstrand 035616cb8e i965: Don't use MAX_SURFACES in mark_surface_used
Vulkan doesn't respect MAX_SURFACES so this assert isn't valid in that
case.  It should, however, assert that it isn't insanely large.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:01 -08:00
Jason Ekstrand 0d2c9ce1ce i965: Get rid of BRW_PRIM_OFFSET
This is a relic of when we wired up meta to be able to use RECTLIST
primitives.  It's no longer needed.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2017-03-01 16:14:01 -08:00
Jason Ekstrand 406321caeb i965/vue_map: Stop using GLbitfield types
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:13:58 -08:00
Jason Ekstrand 45d3dbebb2 i965: Move assign_common_binding_table_offsets to brw_program
This isn't used by Vulkan and is specific to the way the GL driver
works.  There's no reason to have it in common compiler code.  Also, it
relies on BRW_MAX_* defines which are defined in brw_context.h

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:13:55 -08:00
Jason Ekstrand 8123402fd1 i965: Move some gen4 WM defines to brw_compiler.h
These go in wm_prog_key so they're part of the compiler interface.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:13:27 -08:00
Jason Ekstrand 34ede38194 i965: Move brw_disassemble_inst to brw_eu.h
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:13:26 -08:00
Jason Ekstrand f9c9d551ea i965: Move some helpers from brw_context.h to brw_shader.h
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:13:24 -08:00
Jason Ekstrand b97782c364 i965: Move a couple of #defines from brw_context to brw_compiler
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
2017-03-01 16:13:09 -08:00
Jason Ekstrand 2c58709023 glsl/int64: Fix a typo in imod64
The zy swizzle gives us one component of quotient and one component of
remainder.  What we wanted was zw for the remainder.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2017-03-01 15:31:44 -08:00
Jason Ekstrand e647c4fbd9 util/build-id: Return a pointer rather than copying the data
We're about to use the build-id as the starting point for another SHA1
hash in the Intel Vulkan driver, and returning a pointer is far more
convenient.

Reviewed-by: Chad Versace <chadversary@chromium.org>
2017-03-01 15:31:44 -08:00
Jason Ekstrand e3d33a23e6 anv: Properly handle destroying NULL devices and instances
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: "17.0 13.0" <mesa-dev@lists.freedesktop.org>
2017-03-01 15:31:44 -08:00
Robert Bragg f3ec9d33c6 mesa: Fix performance query id check
The queryid_valid() function asserts that an ID given by an application
isn't zero since the spec explicitly reserves an ID of zero as invalid.

The implementation was written as if the ID was a signed integer and
based on the assumption that queryid_to_index() is simply subtracting
one from the ID. It was broken because in fact the ID was stored in an
unsigned int and testing for an index >= 0 would always succeed.

This adds a spec quote to clarify why zero is considered invalid and
checks for zero before even passing the ID to queryid_to_index() for
then checking the upper bound.

This is a v2 of a patch originally posted by Juha-Pekka (thanks)

Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Signed-off-by: Robert Bragg <robert@sixbynine.org>
Reviewed-by: Plamena Manolova <plamena.manolova@intel.com>
2017-03-01 23:01:48 +00:00
Tobias Klausmann 6d600cf632 amd/common: Fix build with new ac_add_function_attr()
Fix usage of ac_add_function_attr() and make it known!

common/ac_nir_to_llvm.c: In function 'create_llvm_function':
common/ac_nir_to_llvm.c:265:4: error: implicit declaration of function
'ac_add_function_attr' [-Werror=implicit-function-declaration]
    ac_add_function_attr(main_function, i + 1, AC_FUNC_ATTR_BYVAL);
    ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
2017-03-01 23:53:38 +01:00
Daniel Stone a1727aa75e egl/wayland: Don't use DRM format codes for SHM
The wl_drm interface (akin to X11's DRI2) uses the standard set of DRM
FourCC format codes. wl_shm copies this, except for ARGB8888/XRGB8888,
which use their own definitions.

Make sure we only use wl_shm format codes when we're working with
wl_shm. Otherwise, using swrast with 32bpp formats would fail with an
error.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Daniel Stone <daniels@collabora.com> (v1)
Fixes: cb5e799448 ("egl/wayland: unify dri2_wl_create_surface implementations")

v2: [Emil Velikov: move to dri2_wl_create_window_surface]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com> (IRC)
2017-03-01 18:36:55 +00:00
Kenneth Graunke c0e9e61c9a mesa: Drop unused STATE_TEXRECT_SCALE program statevars.
The last user is now gone.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
2017-03-01 10:27:38 -08:00
Kenneth Graunke f356d05393 i965: Drop unused STATE_TEXRECT_SCALE code.
In the past, we used this on Gen4-5 to transform non-normalized texture
coordinates (for sampler2DRect) to normalized ones.  We also used it on
Gen6-7.5 for sampler2DRect with GL_CLAMP.

Jason dropped this code in 6c8ba59cff
in favor of using nir_lower_tex(), which just does a textureSize()
call.  But we were still setting up these state references for
useless uniform data.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
2017-03-01 10:27:36 -08:00
Kenneth Graunke 4061bbccf2 egl: Ensure ResetNotificationStrategy matches for shared contexts.
Fixes:
dEQP-EGL.functional.robustness.negative_context.invalid_robust_shared_context_creation

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Cc: mesa-stable@lists.freedesktop.org
2017-03-01 10:26:42 -08:00
Marek Olšák 940da36a65 gallivm,ac: add function attributes at call sites instead of declarations
They can vary at call sites if the intrinsic is NOT a legacy SI intrinsic.
We need this to force readnone or inaccessiblememonly on some amdgcn
intrinsics.

This is only used with LLVM 4.0 and later. Intrinsics only used with
LLVM <= 3.9 don't need the LEGACY flag.

gallivm and ac code is in the same patch, because splitting would be
more complicated with all the LEGACY uses all over the place.

v2: don't change the prototype of lp_add_function_attr.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com> (v1)
2017-03-01 18:59:36 +01:00
Marek Olšák 408f370710 gallivm,ac: remove unused FUNC_ATTR_LAST enums
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2017-03-01 18:59:36 +01:00
Nicolai Hähnle 40c77bbf83 st/mesa: inform the driver of framebuffer changes before compute dispatches
Even though compute shaders cannot access the framebuffer, there is a
synchronization issue when a compute dispatch accesses a texture that
was previously bound and drawn to as a framebuffer.

Section 9.3 (Feedback Loops Between Textures and the Framebuffer) of
the OpenGL 4.5 spec rather implicitly clarifies that undefined behavior
results if the texture is still attached to the currently bound
framebuffer. However, the feedback loop is broken when the application
changes the framebuffer binding before a compute dispatch, and the
state tracker needs to let the driver known about this.

Fixes GL45-CTS.compute_shader.pipeline-post-fs on SI family Radeons.

Cc: mesa-stable@lists.freedesktop.org

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
2017-03-01 18:59:36 +01:00