aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/program/prog_to_nir.c
Commit message (Collapse)AuthorAgeFilesLines
* treewide: s/comparitor/comparator/Ilia Mirkin2016-12-121-1/+1
| | | | | | | | | | git grep -l comparitor | xargs sed -i 's/comparitor/comparator/g' Just happened to notice this in a patch that was sent and included one of the tokens in question. Signed-off-by: Ilia Mirkin <[email protected]> Acked-by: Nicolai Hähnle <[email protected]>
* compiler: Add the rest of the subpassInput typesJason Ekstrand2016-11-221-0/+1
| | | | | | | There are actually 6 of them according to the GL_KHR_vulkan_glsl spec. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* compiler: Store the clip/cull distance array sizes in shader_info.Kenneth Graunke2016-11-191-1/+2
| | | | | | | We switched from a boolean to array lengths in gl_program a while back. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* st/mesa/r200/i915/i965: move ARB program fields into a unionTimothy Arceri2016-11-171-5/+7
| | | | | | | | | | | It's common for games to compile 2000 programs or more so at 32bits x 2000 programs x 22 fields x 2 (at least) stages This should give us something like 352 kilobytes in savings once we add some more glsl only fields. Reviewed-by: Emil Velikov <[email protected]>
* glsl/st/mesa: use common system values read fieldTimothy Arceri2016-10-261-1/+0
| | | | | | | | | And set system values read directly in shader_info. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* r200/glsl/st/mesa: use common outputs written fieldTimothy Arceri2016-10-261-3/+2
| | | | | | | | | And set outputs written directly in shader_info. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* r200/i915/st/mesa/compiler: use common inputs read fieldTimothy Arceri2016-10-261-3/+2
| | | | | | | | | | | | And set set inputs_read directly in shader_info. To avoid regressions between changes this change is a squashed version of the following patches. st/mesa changes where: Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* st/mesa/r200/i915/i965: eliminate gl_fragment_programTimothy Arceri2016-10-261-5/+2
| | | | | | | | | | Here we move OriginUpperLeft and PixelCenterInteger into gl_program all other fields have been replace by shader_info. V2: Don't use anonymous union/structs to hold vertex/fragment fields suggested by Ian. Reviewed-by: Jason Ekstrand <[email protected]>
* i965/mesa/st/swrast: set fs shader_info directly and switch to using itTimothy Arceri2016-10-261-6/+0
| | | | | | | Note we access shader_info from the program struct rather than the nir_shader pointer because shader cache won't create a nir_shader. Reviewed-by: Jason Ekstrand <[email protected]>
* mesa: remove unrequired codeTimothy Arceri2016-10-261-2/+0
| | | | | | InterpQualifier is never set for ARB programs so this will do nothing. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: add a shader info field to the gl_program typeTimothy Arceri2016-10-261-0/+6
| | | | | | | | | | And use this field as the source for shader info in the nir_shader this will allow us to set some of these fields from GLSL directly. It will also simplify restoring from shader cache and allow the removal of duplicate fields from GLSL. Reviewed-by: Jason Ekstrand <[email protected]>
* nir/i965/anv/radv/gallium: make shader info a pointerTimothy Arceri2016-10-261-13/+13
| | | | | | | | | | When restoring something from shader cache we won't have and don't want to create a nir_shader this change detaches the two. There are other advantages such as being able to reuse the shader info populated by GLSL IR. Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: add subpass image type (v2)Dave Airlie2016-09-161-0/+2
| | | | | | | | | | | | | | | | | | SPIR-V/Vulkan have a special image type for input attachments called the subpass type. It has different characteristics than other images types. The main one being it can only be an input image to fragment shaders and loads from it are relative to the frag coord. This adds support for it to the GLSL types. Unfortunately we've run out of space in the sampler dim in types, so we need to use another bit. v2: Fixup subpass input name (Jason) Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* util: Move _mesa_fsl/util_last_bit into util/bitscan.hMathias Fröhlich2016-08-091-3/+3
| | | | | | | | | | | As requested with the initial creation of util/bitscan.h now move other bitscan related functions into util. v2: Split into two patches. Signed-off-by: Mathias Fröhlich <[email protected]> Tested-by: Brian Paul <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* ptn: Emit mul+add for MADJason Ekstrand2016-05-111-1/+5
| | | | | | | | | | | | | | Unlike fma() in GLSL, MAD in ARB programs is 100% splittable. Just emit the split version and let the optimizer fuse them later. Shader-db results on Haswell: total instructions in shared programs: 7560379 -> 7560300 (-0.00%) instructions in affected programs: 143928 -> 143849 (-0.05%) helped: 443 HURT: 250 Reviewed-by: Kenneth Graunke <[email protected]>
* prog: Delete all remains of OPCODE_SNE, OPCODE_SEQ, OPCODE_SGT, and OPCODE_SLEIan Romanick2016-05-101-60/+0
| | | | | | | | | There is nothing left that can generate them. These used to be generated by ir_to_mesa or by the assembler for various NV extensions that have been removed. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* ptn: Fix all users of ptn_swizzleIan Romanick2016-03-311-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | None of the callers actually wanted what it did. In ptn_xpd, you only ever want a vec3 swizzle. In ptn_tex, you want a swizzle that matches the number of required texture coordinates. shader-db results: G45: total instructions in shared programs: 4011240 -> 4010911 (-0.01%) instructions in affected programs: 59232 -> 58903 (-0.56%) helped: 114 HURT: 0 total cycles in shared programs: 84314194 -> 84313220 (-0.00%) cycles in affected programs: 779150 -> 778176 (-0.13%) helped: 110 HURT: 13 Ironlake: total instructions in shared programs: 6397262 -> 6396605 (-0.01%) instructions in affected programs: 117402 -> 116745 (-0.56%) helped: 227 HURT: 0 total cycles in shared programs: 128889798 -> 128888524 (-0.00%) cycles in affected programs: 1214644 -> 1213370 (-0.10%) helped: 179 HURT: 44 Sandy Bridge: total instructions in shared programs: 8467391 -> 8467384 (-0.00%) instructions in affected programs: 3107 -> 3100 (-0.23%) helped: 10 HURT: 6 total cycles in shared programs: 117580120 -> 117573448 (-0.01%) cycles in affected programs: 103158 -> 96486 (-6.47%) helped: 84 HURT: 11 Ivy Bridge: total instructions in shared programs: 7774255 -> 7774258 (0.00%) instructions in affected programs: 1677 -> 1680 (0.18%) helped: 8 HURT: 6 total cycles in shared programs: 65743828 -> 65739190 (-0.01%) cycles in affected programs: 89312 -> 84674 (-5.19%) helped: 78 HURT: 23 Haswell: total instructions in shared programs: 7107172 -> 7107150 (-0.00%) instructions in affected programs: 2048 -> 2026 (-1.07%) helped: 16 HURT: 0 total cycles in shared programs: 64653636 -> 64647486 (-0.01%) cycles in affected programs: 86836 -> 80686 (-7.08%) helped: 85 HURT: 17 Broadwell and Skylake: total instructions in shared programs: 8447529 -> 8447507 (-0.00%) instructions in affected programs: 2038 -> 2016 (-1.08%) helped: 16 HURT: 0 total cycles in shared programs: 66418670 -> 66413416 (-0.01%) cycles in affected programs: 90110 -> 84856 (-5.83%) helped: 83 HURT: 20 Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* ptn: Silence unused parameter warningIan Romanick2016-03-311-2/+2
| | | | | | | | | | | | | | The KIL instruction doesn't have a destination, so ptn_kil never uses dest. program/prog_to_nir.c: In function ‘ptn_kil’: program/prog_to_nir.c:547:38: warning: unused parameter ‘dest’ [-Wunused-parameter] ptn_kil(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src) ^ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: add a bit_size parameter to nir_ssa_dest_initConnor Abbott2016-03-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Tested-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* program: Remove NV_fragment_program Abs support.Matt Turner2016-03-011-6/+0
| | | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Acked-by: Brian Paul <[email protected]>
* program: Remove OPCODE_TXP_NV.Matt Turner2016-03-011-7/+0
| | | | | | Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Acked-by: Brian Paul <[email protected]>
* nir: Separate texture from sampler in nir_tex_instrJason Ekstrand2016-02-091-0/+1
| | | | | | | | | | | | | This commit adds the capability to NIR to support separate textures and samplers. As it currently stands, glsl_to_nir only sets the texture deref and leaves the sampler deref alone as it did before and nir_lower_samplers assumes this. Backends can still assume that they are combined and only look at only at the texture index. Or, if they wish, they can assume that they are separate because nir_lower_samplers, tgsi_to_nir, and prog_to_nir all set both texture and sampler index whenever a sampler is required (the two indices are the same in this case). Reviewed-by: Kenneth Graunke <[email protected]>
* nir/tex_instr: Rename sampler to textureJason Ekstrand2016-02-091-1/+1
| | | | | | | | | We're about to separate the two concepts. When we do, the sampler will become optional. Doing a rename first makes the separation a bit more safe because drivers that depend on GLSL or TGSI behaviour will be fine to just use the texture index all the time. Reviewed-by: Kenneth Graunke <[email protected]>
* ptn: use const_index helpersRob Clark2016-02-091-2/+2
| | | | | Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: move to compiler/Emil Velikov2016-01-261-1/+1
| | | | | | Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>
* nir: move to compiler/Emil Velikov2016-01-261-2/+2
| | | | | | Signed-off-by: Emil Velikov <[email protected]> Acked-by: Matt Turner <[email protected]> Acked-by: Jose Fonseca <[email protected]>
* nir/builder: Add an init function that creates a simple shader for youJason Ekstrand2015-12-291-10/+3
| | | | | | | | | | | A hugely common case when using nir_builder is to have a shader with a single function called main. This adds a helper that gives you just that. This commit also makes us use it in the NIR control-flow unit tests as well as tgsi_to_nir and prog_to_nir. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Connor Abbott <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
* nir: Get rid of function overloadsJason Ekstrand2015-12-281-2/+1
| | | | | | | | | | | | | | | | | When Connor originally drafted NIR, he copied the same function+overload system that GLSL IR had with a few names changed. However, this double-indirection is not really needed and has only served to confuse people. Instead, let's just have functions which may not have unique names and may or may not have an implementation. If someone wants to do overload resolving, they can hav a hash table based function+overload system in the overload resolving pass. There's no good reason to keep it in core NIR. Reviewed-by: Connor Abbott <[email protected]> Acked-by: Kenneth Graunke <[email protected]> ir3 bits are Reviewed-by: Rob Clark <[email protected]>
* nir: Add a writemask to store intrinsics.Kenneth Graunke2015-12-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tessellation control shaders need to be careful when writing outputs. Because multiple threads can concurrently write the same output variables, we need to only write the exact components we were told. Traditionally, for sub-vector writes, we've read the whole vector, updated the temporary, and written the whole vector back. This breaks down with concurrent access. This patch prepares the way for a solution by adding a writemask field to store_var intrinsics, as well as the other store intrinsics. It then updates all produces to emit a writemask of "all channels enabled". It updates nir_lower_io to copy the writemask to output store intrinsics. Finally, it updates nir_lower_vars_to_ssa to handle partial writemasks by doing a read-modify-write cycle (which is safe, because local variables are specific to a single thread). This should have no functional change, since no one actually emits partial writemasks yet. v2: Make nir_validate momentarily assert that writemasks cover the complete value - we shouldn't have partial writemasks yet (requested by Jason Ekstrand). v3: Fix accidental SSBO change that arose from merge conflicts. v4: Don't try to handle writemasks in ir3_compiler_nir - my code for indirects was likely wrong, and TTN doesn't generate partial writemasks today anyway. Change them to asserts as requested by Rob Clark. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> [v3]
* nir: Delete bany, ball, fany, fall.Matt Turner2015-12-181-2/+2
| | | | | | | | | | | As in the previous patches, these can be implemented as any(v) -> any_nequal(v, false) all(v) -> all_equal(v, true) and their removal simplifies the code in the next patch. Reviewed-by: Ian Romanick <[email protected]>
* nir/info: Add a few bits of info for fragment shadersJason Ekstrand2015-10-191-0/+6
| | | | Reviewed-by: Topi Pohjolainen <[email protected]>
* nir/prog: Don't double-insert the fog-coord variableJason Ekstrand2015-10-151-3/+2
| | | | | | | nir_variable_create already inserts it in the right list for us so inserting it again causes a linked list corruption. Reviewed-by: Matt Turner <[email protected]>
* nir: Add helpers for creating variables and adding them to listsJason Ekstrand2015-10-151-12/+7
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir/prog: Use nir_foreach_variableJason Ekstrand2015-10-151-1/+1
| | | | | Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* nir: Add a a nir_shader_info structJason Ekstrand2015-10-021-0/+13
| | | | | | This commit also adds code to glsl_to_nir and prog_to_nir to fill it out. Reviewed-by: Kenneth Graunke <[email protected]>
* prog_to_nir: Use nir_op_dphJason Ekstrand2015-09-221-2/+1
| | | | | | | | | Shader-db results on HSW: instructions in affected programs: 72 -> 56 (-22.22%) Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Resolve GCC sign-compare warning.Rhys Kidd2015-09-101-1/+1
| | | | | | | | | | | | mesa/src/mesa/program/prog_to_nir.c: In function 'setup_registers_and_variables': /mesa/src/mesa/program/prog_to_nir.c:1059:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < c->prog->NumTemporaries; i++) { ^ Signed-off-by: Rhys Kidd <[email protected]> Reviewed-by: Thomas Helland <[email protected]> Reviewed-by: Jan Vesely <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* nir: Convert the builder to use the new NIR cursor API.Kenneth Graunke2015-08-271-1/+1
| | | | | | | | | | | | | | | | | | The NIR cursor API is exactly what we want for the builder's insertion point. This simplifies the API, the implementation, and is actually more flexible as well. This required a bit of reworking of TGSI->NIR's if/loop stack handling; we now store cursors instead of cf_node_lists, for better or worse. v2: Actually move the cursor in the after_instr case. v3: Take advantage of nir_instr_insert (suggested by Connor). v4: vc4 build fixes (thanks to Eric). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> [v1] Reviewed-by: Jason Ekstrand <[email protected]> [v4] Acked-by: Connor Abbott <[email protected]> [v4]
* prog_to_nir: Use nir_builder_insert() rather than poking at cf_list.Kenneth Graunke2015-08-251-11/+11
| | | | | | | | | I intend to remove nir_builder::cf_node_list, so I can't have this code poking at it directly. The proper way is to set the insertion point and then simply insert things there. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* nir: Store gl_shader_stage in nir_shader.Kenneth Graunke2015-08-251-1/+3
| | | | | | | | | | | | This makes it easy for NIR passes to inspect what kind of shader they're operating on. Thanks to Michel Dänzer for helping me figure out where TGSI stores the shader stage information. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* prog_to_nir: Don't allocate nir_variable with type vec4[0] for uniforms.Kenneth Graunke2015-08-251-7/+11
| | | | | | | | | | | If there are no parameters, we don't need to create a nir_variable to hold them...and allocating an array of length 0 is pretty bogus. Should avoid i965 backend assertions in future patches Jason and I are working on. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* prog_to_nir: Fix fragment depth writes.Kenneth Graunke2015-06-061-3/+19
| | | | | | | | | | | | | | | | | | | In the ARB_fragment_program specification, the result.depth output variable is treated as a vec4, where the fragment depth is stored in the .z component, and the other three components are undefined. This is different than GLSL, which uses a scalar value (gl_FragDepth). To make this consistent for driver backends, this patch makes prog_to_nir use a scalar output variable for FRAG_RESULT_DEPTH, moving result.depth.z into the first component. Fixes Glean's fragProg1 "Z-write test" subtest. Cc: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90000 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* prog_to_nir: Make RSQ properly take the absolute value of its argument.Kenneth Graunke2015-06-041-1/+2
| | | | | | | | | | | | | | | | | I just botched this when writing the original code. From the ARB_vertex_program specification: "The RSQ instruction approximates the reciprocal of the square root of the absolute value of the scalar operand and replicates it to all four components of the result vector." Fixes a Glean vertProg1 subtest: RSQ test 2 (reciprocal square root of negative value) Cc: [email protected] Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90547 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* program: Shrink and rename SaturateMode field to Saturate.Matt Turner2015-06-031-2/+2
| | | | | | | | | | | It was 2 bits to accommodate SATURATE_PLUS_MINUS_ONE (removed by commit 09b566e1). A similar change was made to TGSI recently in commit e1c4e8aa. Reducing the size from 2 bits to 1 reduces the size of the bit fields from 17 bits to 16, which is a much nicer number. Reviewed-by: Brian Paul <[email protected]>
* prog_to_nir: Remove OPCODE_MOV special case.Matt Turner2015-06-021-1/+1
| | | | | | OPCODE_MOV is in the op_trans[] array. Reviewed-by: Kenneth Graunke <[email protected]>
* prog_to_nir: Remove from op_trans[] opcodes handled in the switch.Matt Turner2015-06-021-7/+7
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* Fix an unused variable warningJason Ekstrand2015-05-251-2/+0
| | | | Trivial. Deleted the 2 unneeded lines.
* prog_to_nir: Use a variable for uniform dataJason Ekstrand2015-05-231-30/+35
| | | | | | | | | | | | | Previously, the prog_to_nir pass was directly generating uniform load/store intrinsics. This converts it to use a single giant "parameters" variable and we now depend on lowering to get the uniform load/store intrinsics. One advantage of this is that we now have one code-path after we do the initial conversion into NIR. No shader-db changes. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* prog_to_nir: OPCODE_EXP is not nir_op_fexpIan Romanick2015-05-081-1/+1
| | | | | | | | | It's a weird thing that provides some values related to 2**x. It's also already handled by a case in the switch. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* nir: Fix per-component negation in prog_to_nir's SWZ handling.Kenneth Graunke2015-04-211-7/+18
| | | | | | | | | | I missed the fact that the ARB_fragment_program SWZ instruction allows per-component negation. To fix this, move Abs/Negate handling into both the simple case and the SWZ case's per-component loop. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90000 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>