summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* glsl: xfb_stride applies to buffers, not block membersJuan A. Suarez Romero2017-08-011-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we have an interface block like: layout (xfb_buffer = 0, xfb_offset = 0) out Block { vec4 var1; layout (xfb_stride = 48) vec4 var2; vec4 var3; }; According to ARB_enhanced_layouts spec: "The *xfb_stride* qualifier specifies how many bytes are consumed by each captured vertex. It applies to the transform feedback buffer for that declaration, whether it is inherited or explicitly declared. It can be applied to variables, blocks, block members, or just the qualifier out. [ ...] While *xfb_stride* can be declared multiple times for the same buffer, it is a compile-time or link-time error to have different values specified for the stride for the same buffer." This means xfb_stride actually applies to the buffer, and not to the individual components. In the above example, it means that var2 consumes 16 bytes, and var3 is at offset 32. This has been confirmed also by John Kessenich, the main contact for the ARB_enhanced_layouts specs, and also because this commit fixes: GL45.enhanced_layouts.xfb_block_member_stride This commit is in practice a revert of 598790e8564 (glsl: apply xfb_stride to implicit offsets for ifc block members). Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* st/mesa: get rid of st_glsl_typesNicolai Hähnle2017-07-311-1/+3
| | | | | | | It's a duplicate of glsl_type::count_attribute_slots. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* nir: add nir_lower_uniforms_to_ubo passNicolai Hähnle2017-07-313-0/+99
| | | | | | | | | | This is a further lowering of default-block uniform loads that transforms load_uniform intrinsics into load_ubo intrinsics. This simplifies the rest of the backend. v2: transform from load_uniform instead of straight from variables Reviewed-by: Eric Anholt <[email protected]>
* nir: add nir_lower_samplers_as_deref passNicolai Hähnle2017-07-315-0/+255
| | | | | | This pass is a replacement for the nir_lower_samplers pass, which has the advantage of keeping sampler references as derefs. This allows a unified treatment of texture instructions and image intrinsics in the backend.
* nir: add load_frag_coord system value intrinsicNicolai Hähnle2017-07-313-0/+6
| | | | | | | Some drivers prefer to treat gl_FragCoord as a system value rather than a fragment shader input, see Const.GLSLFragCoordIsSysVal. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: fix nir_lower_wpos_ytransform when gl_FragCoord is a system valueNicolai Hähnle2017-07-311-2/+4
| | | | Reviewed-by: Jason Ekstrand <[email protected]>
* nir: add nir_instr_rewrite_derefNicolai Hähnle2017-07-312-0/+15
| | | | | | Allows modifying a texture instruction's texture and sampler derefs. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: small builtin inline tidy upTimothy Arceri2017-07-271-4/+4
| | | | Reviewed-by: Samuel Pitoiset <[email protected]>
* compiler: move glsl_interface_packing enum to shader_enums.hTimothy Arceri2017-07-263-17/+10
| | | | | | This allows us to drop the duplicate gl_uniform_block_packing enum. Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: rework misleading block layout codeTimothy Arceri2017-07-231-4/+4
| | | | | | | | | | | From the ARB_uniform_buffer_object spec: ""shared" uniform blocks, the default layout, ..." This doesn't fix anything as the default layout is already applied at this point but fixes the misleading code/comment. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: remove placeholder commentTimothy Arceri2017-07-231-4/+0
| | | | | | | | This was added in 2d03f48a65a666 and seems like it was intended as a TODO comment in a function stub rather than a useful code comment. Reviewed-by: Samuel Pitoiset <[email protected]>
* Android: fix spirv_info.c generationChih-Wei Huang2017-07-211-5/+2
| | | | | | | | | | | | | | | | | It's incorrect to use $(LOCAL_PATH) in makefile recipes since it's changing. The typical way to handle it is to use private variable. Fortunately in this case we can just simplify them to $^. See further: https://patchwork.freedesktop.org/patch/167718/ Also simplify LOCAL_GENERATED_SOURCES. Fixes: 2dd4e2ec (spirv: Generate spirv_info.c) Signed-off-by: Chih-Wei Huang <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* android: fix libmesa_nir buildTapani Pälli2017-07-211-0/+1
| | | | | | | current build did not find required include 'spirv_info.h' Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* nir: Optimize find_lsb/imsb/umsb error checksMatt Turner2017-07-201-0/+11
| | | | | | | | Two of the ARB_shader_ballot piglit tests hit the find_lsb case, removing some of the noise allowed me to better debug the test when it was failing. Reviewed-by: Connor Abbott <[email protected]>
* nir: Reduce destination size of ballot intrinsic when possibleMatt Turner2017-07-202-0/+20
| | | | | | | | | Some hardware, like i965, doesn't support group sizes greater than 32. In that case, we can reduce the destination size of the ballot intrinsic, which will simplify our code generation. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add pass to scalarize read_invocation/read_first_invocationMatt Turner2017-07-203-1/+114
| | | | | | | i965 will want these to be scalar operations. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add system values from ARB_shader_ballotMatt Turner2017-07-205-1/+81
| | | | | | | | | | | | | We already had a channel_num system value, which I'm renaming to subgroup_invocation to match the rest of the new system values. Note that while ballotARB(true) will return zeros in the high 32-bits on systems where gl_SubGroupSizeARB <= 32, the gl_SubGroup??MaskARB variables do not consider whether channels are enabled. See issue (1) of ARB_shader_ballot. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add intrinsics from ARB_shader_ballotMatt Turner2017-07-202-0/+58
| | | | | Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Support lowering vote intrinsicsMatt Turner2017-07-202-2/+4
| | | | | | | ... trivially (as allowed by the spec!) by reusing the existing nir_opt_intrinsics code. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add pass to optimize intrinsicsMatt Turner2017-07-203-0/+98
| | | | | | | Specifically, constant fold intrinsics from ARB_shader_group_vote, but I suspect it'll be useful for other things in the future. Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add intrinsics from ARB_shader_group_voteMatt Turner2017-07-202-0/+27
| | | | | | | | These are intrinsics rather than opcodes, because they operate across channels. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Use nir_src_copy instead of direct assignments.Kenneth Graunke2017-07-183-9/+9
| | | | | | | | | | | | | | | If the source is an indirect register, there is ralloc'd data. Copying with a direct assignment will copy the pointer, but the data will still belong to the old instruction's memory context. Since we're lowering and throwing away instructions, that could free the data by mistake. Instead, use nir_src_copy, which properly handles this. This is admittedly not a common case, so I think the bug is real, but unlikely to be hit. Cc: [email protected] Reviewed-by: Matt Turner <[email protected]>
* glsl: disable array splitting for AoATimothy Arceri2017-07-191-0/+23
| | | | | | | | | | While it produces functioning code the pass creates worse code for arrays of arrays. See the comment added in this patch for more detail. V2: skip splitting of AoA of matrices too. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: fix nir_opt_copy_prop_vars() for arrays of arraysTimothy Arceri2017-07-191-6/+6
| | | | | | | | | | Previously we only incremented the guide for a single dimension/wildcard. V2: rework logic to avoid code duplication Reviewed-by: Jason Ekstrand <[email protected]> Cc: [email protected]
* nir/vars_to_ssa: Handle missing struct members in foreach_deref_nodeJason Ekstrand2017-07-191-2/+6
| | | | | | | | | This can happen if, for instance, you have an array of structs and there are both direct and wildcard references to the same struct and some members only have direct or only have indirect. Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* build: Add $(top_srcdir)/src/compiler/spirv to AM_CPPFLAGSKenneth Graunke2017-07-181-0/+1
| | | | | | | | | | Generated C files try to include spirv_info.h. For in-tree builds, the header is in the same directory, so it just works. For out-of-tree builds, we need to look for it in srcdir rather than builddir. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101831 Acked-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* compiler/spirv: Add a .gitignore and ignore spirv_info.cJason Ekstrand2017-07-181-0/+1
|
* nir/spirv: Add support for SPV_KHR_variable_pointersJason Ekstrand2017-07-185-10/+108
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/spirv: Add a helper for pushing SSA valuesJason Ekstrand2017-07-184-10/+20
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/spirv: Implement OpPtrAccessChain for buffersJason Ekstrand2017-07-183-4/+34
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* spirv/nir: Add some useful asserts for type decorationsJason Ekstrand2017-07-181-0/+4
| | | | | | | Now that vtn_type has piles of unions, we should assert sanity before setting fields that may stomp others. Reviewed-by: Iago Toral Quiroga <[email protected]>
* spirv: Add support for the StorageBuffer storage classJason Ekstrand2017-07-181-0/+4
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* spirv: Generate spirv_info.cIan Romanick2017-07-185-159/+106
| | | | | | | | | | | | | | | | | | The old table based spirv_*_to_string functions would return NULL for any values "inside" the table that didn't have entries. The tables also needed to be updated by hand each time a new spirv.h was imported. Generate the file instead. v2: Make this script work more like src/mesa/main/format_fallback.py. Suggested by Jason. Remove SCons supports. Suggested by Jason and Emil. Put all the build work in Makefile.nir.am in lieu of adding a new Makefile.spirv.am. Suggested by Emil. Add support for Android builds based on code provided by Emil. Signed-off-by: Ian Romanick <[email protected]> Suggested-by: Jason Ekstrand <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* spirv: Import the lastest 1.0.2 JSON from KhronosIan Romanick2017-07-181-0/+5792
| | | | | Signed-off-by: Ian Romanick <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* spirv: Import the latest 1.2 header from KhronosJason Ekstrand2017-07-181-4/+37
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/lower_io_to_temporaries: don't set compact on shadow varsConnor Abbott2017-07-131-0/+1
| | | | | | | | | The compact flag doesn't make sense on local variables, since the packing on them is up to the driver. This fixes nir_validate assertions in some cases, particularly when lower_io_to_temporaries is used on per-vertex inputs/outputs. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: don't segfault when printing variables with no nameConnor Abbott2017-07-131-1/+1
| | | | | | | | | | | | While normally we give variables whose name field is NULL a temporary name when called from nir_print_shader(), when we were calling from nir_print_instr() we never bothered, meaning that we just segfaulted when trying to print out instructions with such a variable. Since nir_print_instr() is meant to be called while debugging, we don't need to bother too much about giving a consistent name, but we don't want to crash in the middle of debugging. Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* spirv: Fix reaching unreachable for compare exchange on imagesJames Legg2017-07-101-0/+1
| | | | | | | | | | | | | | | We were hitting the unreachable("Invalid image opcode") near the end of vtn_handle_image when parsing the SpvOpAtomicCompareExchange opcode. v2: Add stable CC. v3: Ignore SpvOpAtomicCompareExchangeWeak. It requires the Kernel capability which is not exposed in Vulkan, and spirv_to_nir is not used for OpenCL which does support it. Reviewed-by: Jason Ekstrand <[email protected]> CC: <[email protected]>
* nir: copy front interpolation when creating fake back color inputIlia Mirkin2017-07-081-2/+6
| | | | | | | | Fixes a bunch of gl_BackColor interpolation tests that had explicit interpolation specified on the fragment shader gl_Color. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir/spirv: Remove unnecessary comment.Andres Gomez2017-07-081-5/+0
| | | | | | | | | It should have been removed after 00c47e111c. Cc: Jason Ekstrand <[email protected]> Cc: Connor Abbott <[email protected]> Signed-off-by: Andres Gomez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: check if any of the named builtins are available firstIlia Mirkin2017-07-053-4/+14
| | | | | | | | | | | | | | | | | | | | | _mesa_glsl_has_builtin_function is used to determine whether any variant of a builtin are available, for the purpose of enforcing the GLSL ES 3.00+ rule that overloads or overrides of builtins are disallowed. However the builtin_builder contains information on all builtins, irrespective of parse state, or versions, or extension enablement. As a result we would say that a builtin existed even if it was not actually available. To resolve this, first check if at least one signature is available for a builtin before returning true. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101666 Signed-off-by: Ilia Mirkin <[email protected]> Cc: [email protected] Reviewed-by: Timothy Arceri <[email protected]> Acked-by: Lionel Landwerlin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir/spirv: Rework function argument setupJason Ekstrand2017-07-053-28/+34
| | | | | | | | Now that we have proper pointer types, we can be more sensible about the way we set up function arguments and deal with the two cases of pointer vs. SSA parameters distinctly. Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Stop trying to convert pointers to SSA in glsl450Jason Ekstrand2017-07-051-1/+6
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Use real pointer typesJason Ekstrand2017-07-054-15/+60
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Stop using glsl_type for function typesJason Ekstrand2017-07-053-31/+31
| | | | | | | We're going to want the full vtn_type available to us anyway at which point glsl_type isn't really buying us anything. Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Beef up the type system a bitJason Ekstrand2017-07-052-28/+59
| | | | | | | | | This adds a vtn concept of base_type as well as a couple of other fields. This lets us be a tiny bit more efficient in some cases but, more importantly, it will eventually let us express things the GLSL type system can't. Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Compact vtn_typeJason Ekstrand2017-07-052-26/+39
| | | | | | | Use an anonymous union of structs to help keep the structure small and better organized. Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Simplify type copyingJason Ekstrand2017-07-051-7/+1
| | | | Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Compute offsets for UBOs and SSBOs up-frontJason Ekstrand2017-07-052-27/+138
| | | | | | | | | Now that we have a pointer wrapper class, we can create offsets for UBOs and SSBOs up-front instead of waiting until we have the full access chain. For push constants, we still use the old mechanism because it provides us with some nice range information. Reviewed-by: Connor Abbott <[email protected]>
* nir/spirv: Rework the way pointers get dereferencedJason Ekstrand2017-07-052-64/+88
| | | | | | | This has the advantage of moving all of the "extend an access chain" code into one place. Reviewed-by: Connor Abbott <[email protected]>