summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_builder.h
Commit message (Collapse)AuthorAgeFilesLines
* nir: Add nir_builder support for individual system value loads.Eric Anholt2016-08-191-0/+15
| | | | | | | | | | The previous nir_load_system_value(b, nir_intrinsic_load_whatever), 0) was rather verbose, when system values should be easy to generate. The index is left out because only one system value had an index included in it. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* nir/builder: Add bany_inequal and bany helpers.Kenneth Graunke2016-08-181-0/+19
| | | | | | | | | | The first simply picks the bany_inequal[234] opcodes based on the SSA def's number of components. The latter implicitly compares with zero to achieve the same semantics of GLSL's any(). Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
* nir: Add new intrinsics for fragment shader input interpolation.Kenneth Graunke2016-07-201-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backends can normally handle shader inputs solely by looking at load_input intrinsics, and ignore the nir_variables in nir->inputs. One exception is fragment shader inputs. load_input doesn't capture the necessary interpolation information - flat, smooth, noperspective mode, and centroid, sample, or pixel for the location. This means that backends have to interpolate based on the nir_variables, then associate those with the load_input intrinsics (say, by storing a map of which variables are at which locations). With GL_ARB_enhanced_layouts, we're going to have multiple varyings packed into a single vec4 location. The intrinsics make this easy: simply load N components from location <loc, component>. However, working with variables and correlating the two is very awkward; we'd much rather have intrinsics capture all the necessary information. Fragment shader input interpolation typically works by producing a set of barycentric coordinates, then using those to do a linear interpolation between the values at the triangle's corners. We represent this by introducing five new load_barycentric_* intrinsics: - load_barycentric_pixel (ordinary variable) - load_barycentric_centroid (centroid qualified variable) - load_barycentric_sample (sample qualified variable) - load_barycentric_at_sample (ARB_gpu_shader5's interpolateAtSample()) - load_barycentric_at_offset (ARB_gpu_shader5's interpolateAtOffset()) Each of these take the interpolation mode (smooth or noperspective only) as a const_index, and produce a vec2. The last two also take a sample or offset source. We then introduce a new load_interpolated_input intrinsic, which is like a normal load_input intrinsic, but with an additional barycentric coordinate source. The intention is that flat inputs will still use regular load_input intrinsics. This makes them distinguishable from normal inputs that need fancy interpolation, while also providing all the necessary data. This nicely unifies regular inputs and interpolateAt functions. Qualifiers and variables become irrelevant; there are just load_barycentric intrinsics that determine the interpolation. v2: Document the interp_mode const_index value, define a new BARYCENTRIC() helper rather than using SYSTEM_VALUE() for some of them (requested by Jason Ekstrand). Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Chris Forbes <chrisforbes@google.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir/builder: Add a helper for grabbing multiple channels from an ssa defJason Ekstrand2016-05-141-0/+14
| | | | | | | This is similar to nir_channel except that it lets you grab more than one channel by providing a mask. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* nir/builder: Generate the alu helpers directly in pythonJason Ekstrand2016-05-141-30/+0
| | | | | | | | | There's no reason for having a macro *and* a python generator. We can easily just do the whole thing in python. This has the advantage that we are no longer definining ALU# macros which conflict with the ones in brw_fs_builder.h. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* nir: glsl_get_bit_size() should take glsl_typeRob Clark2016-05-121-1/+1
| | | | | | | | It's what all the call-sites once, so gets rid of a bunch of inlined glsl_get_base_type() at the call-sites. Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir: Avoid C99 field initializers.Jose Fonseca2016-04-281-3/+6
| | | | | | | | | As they are not standard C++ and are not supported by MSVC C++ compiler. Just have nir_imm_double match nir_imm_float above. Reviewed-by: Connor Abbott <cwabbott0@gmail.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com>
* nir/builder: add nir_imm_double()Connor Abbott2016-04-281-0/+8
| | | | Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir/builder: Add bit_size info to nir_build_imm()Samuel Iglesias Gonsálvez2016-04-281-6/+7
| | | | | | | | v2: - Group num_components and bit_size together (Jason) Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir/builder: const'ify swiz paramRob Clark2016-04-191-1/+1
| | | | | | | | No need for it not to be const, and lets caller declare it const if desired. Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Eric Anholt <eric@anholt.net>
* nir: only dereference undef after NULL check. (v2)Dave Airlie2016-04-181-1/+0
| | | | | | | Pointed out by coverity. v2: nuke line, Jason pointed out the constructor does it. Signed-off-by: Dave Airlie <airlied@redhat.com>
* nir: add bit_size info to nir_load_const_instr_create()Samuel Iglesias Gonsálvez2016-04-111-1/+1
| | | | Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir: add bit_size info to nir_ssa_undef_instr_create()Samuel Iglesias Gonsálvez2016-04-111-1/+1
| | | | | | | | v2: - Make the users to give the right bit_sizes as arguments (Jason). Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir/builder: Add a helper for creating undefsJason Ekstrand2016-03-281-0/+14
| | | | Reviewed-by: Rob Clark <robdclark@gmail.com>
* nir/builder: Add a helper for storing to variable derefsJason Ekstrand2016-03-281-0/+16
| | | | Reviewed-by: Rob Clark <robdclark@gmail.com>
* nir/builder: Add a helper for building fdot instructionsJason Ekstrand2016-03-281-0/+17
| | | | Reviewed-by: Rob Clark <robdclark@gmail.com>
* nir/builder: Add helpers for easily inserting copy_var intrinsicsJason Ekstrand2016-03-241-0/+23
| | | | Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* nir/builder: Add a helper for inserting jump instructionsJason Ekstrand2016-03-241-0/+7
| | | | Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
* nir/builder: Add a flag for setting exactJason Ekstrand2016-03-231-0/+9
| | | | Reviewed-by: Francisco Jerez <currojerez@riseup.net>
* nir: add a bit_size parameter to nir_ssa_dest_initConnor Abbott2016-03-171-5/+28
| | | | | | | | | | | | | | | | | | | | | | v2: Squash multiple commits addressing the new parameter in different files so we don't break the build (Iago) v3: Fix tgsi (Samuel) v4: Fix nir_clone.c (Samuel) v5: Fix vc4 and freedreno (Iago) v6 (Sam) - Fix build errors in nir_lower_indirect_derefs - Use helper to get type size from nir_alu_type. Signed-off-by: Iago Toral Quiroga <itoral@igalia.com> Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Tested-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
* nir: rename nir_const_value fields to include bitsize informationIago Toral Quiroga2016-03-171-10/+10
| | | | | Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
* nir: use const_index helpersRob Clark2016-02-091-1/+1
| | | | | Signed-off-by: Rob Clark <robclark@freedesktop.org> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
* nir: move to compiler/Emil Velikov2016-01-261-0/+364
Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Acked-by: Matt Turner <mattst88@gmail.com> Acked-by: Jose Fonseca <jfonseca@vmware.com>