summaryrefslogtreecommitdiffstats
path: root/src/mesa/program
Commit message (Collapse)AuthorAgeFilesLines
* program: add _mesa_reserve_parameter_storageMarek Olšák2016-01-022-15/+36
| | | | | | | The next commit will use this. Reviewed-by: Brian Paul <[email protected]> Cc: 11.0 11.1 <[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]>
* glsl: Remove ir_unop_any.Matt Turner2015-12-181-26/+0
| | | | | | | The GLSL IR to TGSI/Mesa IR paths for any_nequal have the same optimizations the ir_unop_any paths had. Reviewed-by: Ian Romanick <[email protected]>
* program: fix comment about the fog formulaMiklós Máté2015-12-171-1/+1
| | | | Reviewed-by: Ian Romanick <[email protected]>
* ir_to_mesa: Skip useless comparison instructions.Matt Turner2015-12-161-1/+7
| | | | | Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa/program: remove dead function declarationsEmil Velikov2015-11-292-5/+0
| | | | | | | | | | | | Dead since 5e9aa9926b9 (2011) - _mesa_ir_compile_shader 69e07bdeb42 (2009) - _mesa_get_program_register Cc: Kenneth Graunke <[email protected]> Cc: Brian Paul <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: Add ir_samples_identical opcodeIan Romanick2015-11-191-0/+2
| | | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Forbes <[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: remove dependency on glslRob Clark2015-10-163-2/+3
| | | | | | | | | | | | | | | Move glsl_types into NIR, now that the dependency on glsl_symbol_table has been split out. Possibly makes sense to rename things at this point, but if we do that I'd like to keep it split out into a separate patch to make git history easier to follow (IMHO). v2: fix android build v3: I f***ing hate scons.. but at least it builds Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Rob Clark <[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]>
* program: convert _mesa_init_gl_program() to take struct gl_program *Emil Velikov2015-10-152-30/+27
| | | | | | | | Rather than accepting a void pointer, only to down and up cast around it, convert the function to take the base (struct gl_program) pointer. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* mesa: remove unused functions in program.cBrian Paul2015-10-141-51/+0
| | | | | | replace_registers() and adjust_param_indexes() were unused. Reviewed-by: Matt Turner <[email protected]>
* program: remove _mesa_init_*_program wrappersMarek Olšák2015-10-092-143/+19
| | | | | | | They didn't do anything useful. Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* program: remove other unused functionsMarek Olšák2015-10-092-143/+0
| | | | | Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* program: remove unused cloning and combining functionsMarek Olšák2015-10-092-294/+0
| | | | | Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* program: remove unused function _mesa_find_line_columnMarek Olšák2015-10-092-48/+0
| | | | | Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: reduce memory footprint of uniform_storage structTimothy Arceri2015-10-052-4/+5
| | | | | | | | The uniform will only be of a single type so store the data for opaque types in a single array. Cc: Francisco Jerez <[email protected]> Cc: Ilia Mirkin <[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]>
* mesa: avoid leaking closure when iterating over a string_to_uint_mapIlia Mirkin2015-10-021-0/+1
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: clean up #includes in sampler.cppBrian Paul2015-10-011-6/+5
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* mesa: clean up #includes in ir_to_mesa.cppBrian Paul2015-10-011-12/+10
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* mesa: Add locking to programs.Matt Turner2015-09-251-8/+11
| | | | | Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* mesa: Remove debugging code from _mesa_reference_*.Matt Turner2015-09-251-14/+0
| | | | | Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* glsl: Add parser/compiler support for unsized array's length()Samuel Iglesias Gonsalvez2015-09-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unsized array length is computed with the following formula: array.length() = max((buffer_object_size - offset_of_array) / stride_of_array, 0) Of these, only the buffer size needs to be provided by the backends, the frontend already knows the values of the two other variables. This patch identifies the cases where we need to get the length of an unsized array, injecting ir_unop_ssbo_unsized_array_length expressions that will be lowered (in a later patch) to inject the formula mentioned above. It also adds the ir_unop_get_buffer_size expression that drivers will implement to provide the buffer length. v2: - Do not define a triop that will force backends to implement the entire formula, they should only need to provide the buffer size since the other values are known by the frontend (Curro). v3: - Call state->has_shader_storage_buffer_objects() in ast_function.cpp instead of using state->ARB_shader_storage_buffer_object_enable (Tapani). Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Kristian Høgsberg <[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]>
* glsl: add ir_texture_samples texture opcodeIlia Mirkin2015-09-101-0/+2
| | | | | | | | Will be used for textureSamples() Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Ian Romanick <[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]>
* glsl: Silence unused parameter warningsIan Romanick2015-09-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | builtin_variables.cpp:1062:53: warning: unused parameter 'name_as_gs_input' [-Wunused-parameter] const char *name_as_gs_input) ^ builtin_functions.cpp:4774:47: warning: unused parameter 'intrinsic_name' [-Wunused-parameter] const char *intrinsic_name, ^ builtin_functions.cpp:4907:66: warning: unused parameter 'state' [-Wunused-parameter] _mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state, ^ builtin_functions.cpp:4915:49: warning: unused parameter 'num_arguments' [-Wunused-parameter] unsigned num_arguments, ^ builtin_functions.cpp:4916:49: warning: unused parameter 'flags' [-Wunused-parameter] unsigned flags) ^ ir_print_visitor.cpp:589:37: warning: unused parameter 'ir' [-Wunused-parameter] ir_print_visitor::visit(ir_barrier *ir) ^ linker.cpp:3212:48: warning: unused parameter 'ctx' [-Wunused-parameter] build_program_resource_list(struct gl_context *ctx, ^ standalone_scaffolding.cpp:65:57: warning: unused parameter ‘id’ [-Wunused-parameter] _mesa_shader_debug(struct gl_context *, GLenum, GLuint *id, ^ v2: Rebase on top of GL_ARB_shader_image_size work (especially 58a86897). Silence more warnings added by that work. v3: Remove mention of the removed parameter from comments. Suggested by Iago. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> [v1] Reviewed-by: Iago Toral Quiroga <[email protected]> Cc: "Martin Peres <[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]>
* program: Avoid double promotion.Matt Turner2015-07-291-15/+15
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* program: Use exp2(x) instead of pow(2.0, x).Matt Turner2015-07-291-2/+2
|
* program: add subroutine uniform support (v1.1)Dave Airlie2015-07-231-0/+3
| | | | | | | | | Add support for the subroutine uniform type ir->mesa.cpp v1.1: add subroutine to int to switch Acked-by: Kenneth Graunke <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: don't lower variable indexing on non-patch tessellation inputs/outputsMarek Olšák2015-07-231-1/+1
| | | | | | | | | | | | There is no way to lower them, because the array sizes are unknown at compile time. Based on a patch from: Fabian Bieler <[email protected]> v2: add comments Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
* glsl: add tessellation shader defines and built-in variables.Fabian Bieler2015-07-231-0/+4
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: add misc tessellation shader supportFabian Bieler2015-07-232-1/+88
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: add tessellation shader init functions.Fabian Bieler2015-07-232-0/+42
| | | | | | | | Signed-off-by: Chris Forbes <[email protected]> Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: add tessellation shader enumsFabian Bieler2015-07-232-0/+14
| | | | | | | Reviewed-by: Jordan Justen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* program: Allow redundant OPTION ARB_fog_* directives.Kenneth Graunke2015-07-161-13/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A fragment program from "Pixel Piracy" contains redundant OPTION directives: !!ARBfp1.0 OPTION ARB_precision_hint_fastest; OPTION ARB_fog_exp2; OPTION ARB_precision_hint_fastest; OPTION ARB_fog_exp2; ... We already allow redundant ARB_precision_hint_fastest directives, but disallow the redundant (yet consistent) ARB_fog_exp2 directives, failing to compile the program. The specification seems to contradict itself - the main text says that only one fog application option may be specified, but then backpedals, indicating the intent is to disallow /contradictory/ flags. One of the issues suggests that specifying contradictory ones is stupid, but allowed, and only the last one should take effect. Accepting multiple redundant (but consistent) directives seems harmless, and like a reasonable interpretation of the specification. It also fixes a fragment program found in the wild. Cc: [email protected] Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* mesa: rename is_in_uniform_block to is_in_buffer_blockIago Toral Quiroga2015-07-141-1/+1
| | | | | | | Since this now checks if a variable is inside a uniform or a shader storage block. Reviewed-by: Jordan Justen <[email protected]>
* mesa/prog: relative offsets into constbufs are not constantIlia Mirkin2015-07-021-0/+2
| | | | | | | | | | | The optimization logic relies on being able to read out constbuf values from program parameters. However that only works if there's no relative addressing involved. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91173 Signed-off-by: Ilia Mirkin <[email protected]> Cc: "10.5 10.6" <[email protected]> Reviewed-by: Chris Forbes <[email protected]>
* glsl: create program resource list after LinkShaderTapani Pälli2015-07-011-0/+2
| | | | | | | | | Resource list can be created properly only after LinkShader hook has been called to make sure all dead variables have been removed. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Martin Peres <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90925
* glsl: Add ir node for barrierChris Forbes2015-06-121-0/+7
| | | | | | | | | v2: * Changes suggested by mattst88 [[email protected]: Add nir support] Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Ben Widawsky <[email protected]>