summaryrefslogtreecommitdiffstats
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* glsl: reindent line in ast_function.cppDave Airlie2016-05-241-1/+1
| | | | | | | This fixes a warning with gcc -Wmisleading-indentation. Acked-by: Matt Turner <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: Use correct mode for split components.Bas Nieuwenhuizen2016-05-241-1/+1
| | | | | | | | The mode should stay the same as the original struct. In particular, shared should not be changed to temporary. Reviewed-by: Jordan Justen <[email protected]> Signed-off-by: Bas Nieuwenhuizen <[email protected]>
* nir/validate: fix null deref coverity warningRob Clark2016-05-231-0/+1
| | | | | | | | CID 1265536 (#1 of 2): Explicit null dereferenced (FORWARD_NULL)6. var_deref_op: Dereferencing null pointer parent. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl/linker: dvec3/dvec4 consume twice input vertex attributesJuan A. Suarez Romero2016-05-231-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From the GL 4.5 core spec, section 11.1.1 (Vertex Attributes): "A program with more than the value of MAX_VERTEX_ATTRIBS active attribute variables may fail to link, unless device-dependent optimizations are able to make the program fit within available hardware resources. For the purposes of this test, attribute variables of the type dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3, and dmat4 may count as consuming twice as many attributes as equivalent single-precision types. While these types use the same number of generic attributes as their single-precision equivalents, implementations are permitted to consume two single-precision vectors of internal storage for each three- or four-component double-precision vector." This commits makes dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3 and dmat4 consume twice as many attributes as equivalent single-precision types. v3: count doubles as consuming two attributes (Dave Airlie) v4: make reference to spec (Michael Schellenberger Costa) Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Antia Puentes <[email protected]> Signed-off-by: Juan A. Suarez Romero <[email protected]>
* nir: handle double-precision in fsign, fsat, fnot and frcpIago Toral Quiroga2016-05-231-4/+9
| | | | | | | | I think these are not strictly necessary since the floats in them should be automatically promoted to doubles when operated with double sources, but it makes things more explicit at least. Reviewed-by: Matt Turner <[email protected]>
* nir: handle double-precision in fabs, frsq and fsqrtIago Toral Quiroga2016-05-231-3/+3
| | | | Reviewed-by: Matt Turner <[email protected]>
* glsl/parser: handle multiple layout sections with AST nodes.Dave Airlie2016-05-231-0/+2
| | | | | | | | | | | | | For geometry/compute inputs and tess control outputs, we create an AST node to keep track of some things. However if we have multiple layout sections, we don't ever link the node into the AST. This is because we create the node on the rightmost layout declaration and don't pass it back in so it gets linked at the end of the parsing of the rightmost. Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: allow layout qualifier overrides with ARB_shading_language_420packDave Airlie2016-05-231-1/+6
| | | | | | | | | | GLSL 4.20 allows overriding the layout qualifiers. This helps fix: GL45-CTS.shading_language_420pack.qualifier_override_layout Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* subroutines: handle explicit indexes properlyDave Airlie2016-05-233-15/+30
| | | | | | | | | | | | | | The code didn't deal with explicit function indexes properly. It also handed out the indexes at link time, when we really need them in the lowering pass to create the correct if ladder. So this patch moves assigning the non-explicit indexes earlier, fixes the lowering pass and the lookups to get the correct values. This fixes a few of: GL45-CTS.explicit_uniform_location.subroutine-index-* Signed-off-by: Dave Airlie <[email protected]>
* mesa/subroutines: count number subroutines properly.Dave Airlie2016-05-231-0/+1
| | | | | | | | | | | | | The code was implementing the ACTIVE_SUBROUTINE_UNIFORMS incorrectly, using the number of types not the number of uniforms. This is different than the locations as the locations may be sparsly allocated. This fixes: GL43-CTS.shader_subroutine.four_subroutines_with_two_uniforms Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/ast: for geom shaders allow stream flags in input flags.Dave Airlie2016-05-231-1/+4
| | | | | | | | | | | This fixes: GL45-CTS.shader_subroutine.subroutines_with_separate_shader_objects Since we set the stream flags earlier on all geom shaders, we shouldn't fall over later if we find one. Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: skip inactive explicit locations.Dave Airlie2016-05-231-0/+3
| | | | | | | | This fixes a crash in: GL45-CTS.explicit_uniform_location.subroutine-loc-negative-link-max-num-of-locations Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: fix subroutine uniform .length().Dave Airlie2016-05-231-0/+8
| | | | | | | | | | | | | This fixes .length() on subroutine uniform arrays, if we don't find the identifier normally, we look up the corresponding subroutine identifier instead. Fixes: GL45-CTS.shader_subroutine.arrays_of_arrays_of_uniforms GL45-CTS.shader_subroutine.arrayed_subroutine_uniforms Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: link error on too many subroutine functions.Dave Airlie2016-05-231-0/+4
| | | | | | | | This fixes: GL45-CTS.explicit_uniform_location.subroutine-index-negative-link-max-num-of-indices Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: produce a linker error for a subroutine uniform with no functions.Dave Airlie2016-05-231-0/+4
| | | | | | | | | | | If a subroutine uniform is declared with no functions backing it, that isn't legal, so we should fail to link. Fixes: GL43-CTS.shader_subroutine.subroutine_uniform_wo_matching_subroutines Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl: validate subroutine types match function signature.Dave Airlie2016-05-231-0/+18
| | | | | | | | | | | This fixes: GL43-CTS.shader_subroutine.subroutines_incompatible_with_subroutine_type It just makes sure the signatures match as well as the return types. Reviewed-by: Chris Forbes <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* nir: Fix crash in nir_lower_wpos_center().Kenneth Graunke2016-05-201-1/+1
| | | | | | | | | Otherwise we rewrote the fadd to use itself, causing crashes in validation. Instead, start after the last use like we should. A brown paper bag fix. Fixes crashes in several Vulkan tests. Signed-off-by: Kenneth Graunke <[email protected]>
* spirv: Handle the PixelCenterInteger execution mode.Kenneth Graunke2016-05-203-0/+7
| | | | | | | | | This isn't allowed by Vulkan, but might be useful someday for SPIR-V in OpenGL (if that ever becomes a thing). It's easy enough to hook up, and as precedent, we already do so for OriginLowerLeft. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Add a simple nir_lower_wpos_center() pass for Vulkan drivers.Kenneth Graunke2016-05-203-0/+109
| | | | | | | | | | | | | | | | | | | | nir_lower_wpos_ytransform() is great for OpenGL, which allows applications to choose whether their coordinate system's origin is upper left/lower left, and whether the pixel center should be on integer/half-integer boundaries. Vulkan, however, has much simpler requirements: the pixel center is always half-integer, and the origin is always upper left. No coordinate transform is needed - we just need to add <0.5, 0.5>. This means that we can avoid using (and setting up) a uniform. I thought about adding more options to nir_lower_wpos_ytransform(), but making a new pass that never even touched uniforms seemed simpler. v2: Use normal iterator rather than _safe variant (noticed by Matt). Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Rob Clark <[email protected]>
* nir: Don't use ffma in nir_lower_wpos_ytransform().Kenneth Graunke2016-05-201-12/+8
| | | | | | | | | | | ffma is an explicitly fused multiply add with higher precision. The optimizer will take care of promoting mul/add to fma when it's beneficial to do so. This fixes failures on Gen4-5 when using this pass, as those platforms don't actually implement fma(). Signed-off-by: Kenneth Graunke <[email protected]>
* nir: Handle fddy_fine and fddy_coarse in nir_lower_wpos_ytransform.Kenneth Graunke2016-05-201-1/+3
| | | | | | | These also need flipping! Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir: Make lower_wpos_ytransform_block a void function.Kenneth Graunke2016-05-201-3/+1
| | | | | | | | The return value was used for the old nir_foreach_block callback system, but at this point it no longer means anything. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir: Make nir_lower_wpos_ytransform() match FragCoord by location.Kenneth Graunke2016-05-201-1/+2
| | | | | | | | | | | | | gl_FragCoord is a shader input with location == VARYING_SLOT_POS. ARB_fragment_programs have an equivalent input at VARYING_SLOT_POS, but it isn't called gl_FragCoord. We do want to transform it. Matching by location guarantees we catch both. Fixes several fp tests on a branch which uses this pass on i965. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir: Add interp_var_at_offset flipping.Kenneth Graunke2016-05-201-0/+21
| | | | | | | The Y-offset needs flipping as well, similar to ddy. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir: Fix fddy swizzles in nir_lower_wpos_ytransform().Kenneth Graunke2016-05-201-0/+3
| | | | | | | | | | | The original value might have been swizzled. That's taken care of in the fmul source - we don't want to reswizzle it again. Fixes validation failures in glsl-derivs-varyings on a branch of mine which uses this pass in i965. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* nir: Fix wpos_ytransform lowering state_slot swizzle.Kenneth Graunke2016-05-201-0/+2
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* glsl: Guard against NULL dereferenceMark Janes2016-05-201-1/+1
| | | | | | | | | This trivially corrects mesa 3ca1c221, which introduced a check that crashes when a match is not found. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005 Fixes: piglit.spec.glsl-1_50.compiler.interface-blocks-name-reused-globally-4.vert Reviewed-by: Alejandro Piñeiro <[email protected]>
* nir/validate: assume() that hashtable entry existsRob Clark2016-05-201-0/+3
| | | | | | | | | | | | | | | At this point, it would require a logic error in nir_validate to not have already populated this hashtable entry, but coverity doesn't realize that: CID 1265547 (#1 of 1): Dereference null return value (NULL_RETURNS)3. dereference: Dereferencing a null pointer entry. CID 1271039 (#1 of 1): Dereference null return value (NULL_RETURNS)3. dereference: Dereferencing a null pointer entry. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: coverity unitialized pointer readRob Clark2016-05-201-0/+2
| | | | | | | | | Not sure how coverity arrives at the conclusion that we can read comp[j] unitialized (around line 204), other than not being aware that ncomp is greater than 1 so it won't underflow in the 'if (tex->is_array)' case. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: coverity sign-extension fixRob Clark2016-05-201-1/+1
| | | | | | | | | | | | | | | | Not 100% sure, but I think being an unsigned literal will help: CID 1358505 (#1 of 1): Unintended sign extension (SIGN_EXTENSION)sign_extension: Suspicious implicit sign extension: load1->def.num_components with type unsigned char (8 bits, unsigned) is promoted in load1->def.num_components * (load1->def.bit_size / 8) to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If load1->def.num_components * (load1->def.bit_size / 8) is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir/glsl_to_nir: quell some uninit_member coverity errorsRob Clark2016-05-201-0/+6
| | | | | Signed-off-by: Rob Clark <[email protected]> Acked-by: Matt Turner <[email protected]>
* nir/spirv: Handle the NonReadable decoration on struct membersJason Ekstrand2016-05-191-0/+1
|
* glsl: handle same struct redeclaration (v2)Dave Airlie2016-05-203-4/+11
| | | | | | | | | | | | | | | | This works around a bug in older version of UE4, where a shader defines the same structure twice. Although we aren't sure this is correct GLSL (it most likely isn't) there are enough UE4 based things out there we should deal with this. This drops the error to a warning if the struct names and contents match. v1.1: do better C++ on record_compare declaration (Rob) v2: restrict this to desktop GL only (Ian) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005 Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* glsl/linker: attempt to match anonymous structures at linkDave Airlie2016-05-191-9/+15
| | | | | | | | | | | This is my attempt at fixing at least one of the UE4 bugs with GL4.3. If we are doing intrastage matching and hit anonymous structs, then we should do a record comparison instead of using the names. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95005 Reviewed-by: Ian Romanick <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* spirv: add switch case for nir_texop_txf_ms_mcs in vtn_handle_texture()Brian Paul2016-05-181-0/+2
| | | | | | | | | | | Mark it as unreachable. Silences a compiler warning: spirv/spirv_to_nir.c:1397:4: warning: enumeration value 'nir_texop_txf_ms_mcs' not handled in switch [-Wswitch] switch (instr->op) { ^ Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Check that layout is non-null before dereferencing.Matt Turner2016-05-181-1/+1
| | | | | | | layout should only be null for structs, but it's checked everywhere else and confuses Coverity (CID 1358495). Reviewed-by: Timothy Arceri <[email protected]>
* spirv: Properly size the src[] array.Matt Turner2016-05-181-1/+1
| | | | | | | Operations like nir_op_bitfield_insert have four arguments, and Coverity isn't privy to the fact that 4-argument operations aren't possible here, so it thinks this can lead to memory corruption. Just increase the size of the array to quell any fears.
* glsl/linker: Ensure the first stage of an SSO pipeline has input locs assignedIan Romanick2016-05-181-3/+6
| | | | | | | | | | | | | | | | | | | | | Previously an SSO pipeline containing only a tessellation control shader and a tessellation evaluation shader would not get locations assigned for the TCS inputs. This would lead to assertion failures in some piglit tests, such as arb_program_interface_query-resource-query. That piglit test still fails on some tessellation related subtests. Specifically, these subtests fail: 'GL_PROGRAM_INPUT(tcs) active resources' expected 2 but got 3 'GL_PROGRAM_INPUT(tcs) max length name' expected 12 but got 16 'GL_PROGRAM_INPUT(tcs,tes) active resources' expected 2 but got 3 'GL_PROGRAM_INPUT(tcs,tes) max length name' expected 12 but got 16 'GL_PROGRAM_OUTPUT(tcs) active resources' expected 15 but got 3 'GL_PROGRAM_OUTPUT(tcs) max length name' expected 23 but got 12 Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* glsl/linker: Don't include interface name for built-in blocksIan Romanick2016-05-181-1/+2
| | | | | | | | | | | | | | Commit 11096ec introduced a regression in some piglit tests (e.g., arb_program_interface_query-resource-query). I did not notice this regression because other (unrelated) problems caused failed assertions in those same tests on my system... so they crashed before getting to the new failure. v2: Use is_gl_identifier. Suggested by Tim. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Cc: [email protected]
* glsl: Assert that inputs have a location assignedIan Romanick2016-05-181-0/+2
| | | | | | | This catches a problem previously undetected until deep in the backend. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Fix trivial typos in commentsIan Romanick2016-05-182-8/+8
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Fix some formatting to match current coding conventionsIan Romanick2016-05-181-8/+6
| | | | | Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Silence unused parameter warningIan Romanick2016-05-181-5/+3
| | | | | | | | | | | The use of the parameter was removed in d6b92028. glsl/link_varyings.cpp:1390:39: warning: unused parameter ‘separate_shader’ [-Wunused-parameter] bool separate_shader) ^ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl/linker: Silence unused parameter warningIan Romanick2016-05-181-3/+2
| | | | | | | | | | | | The parameter appears to have been unused since the function was added in commit 12ba6cfb. Remove it. glsl/linker.cpp:2886:60: warning: unused parameter ‘prog’ [-Wunused-parameter] match_explicit_outputs_to_inputs(struct gl_shader_program *prog, ^ Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir/validate: dump annotated shader with error msgsRob Clark2016-05-171-1/+62
| | | | | | | | | Log all the errors, and at the end dump the shader w/ error annotations to make it easier to see where the problems are. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/validate: assert() -> validate_assert()Rob Clark2016-05-171-126/+128
| | | | | | | Prep work for next patch. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir/print: add support for print annotationsRob Clark2016-05-172-1/+35
| | | | | | | | | | | | | | | Caller can pass a hashtable mapping NIR object (currently instr or var, but I guess others could be added as needed) to annotation msg to print inline with the shader dump. As the annotation msg is printed, it is removed from the hashtable to give the caller a way to know about any unassociated msgs. This is used in the next patch, for nir_validate to try to associate error msgs to nir_print dump. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]> Reviewed-by: Connor Abbott <[email protected]>
* nir: add double input bitmapJuan A. Suarez Romero2016-05-172-0/+3
| | | | | | This bitmap tracks which input attributes are double-precision. Reviewed-by: Kenneth Graunke <[email protected]>
* glsl: make reserved_varying_slot() staticTimothy Arceri2016-05-171-1/+1
| | | | Reviewed-by: Dave Airlie <[email protected]>
* glsl: include per-patch varyings when generating reserved slot bitfieldTimothy Arceri2016-05-171-3/+6
| | | | Reviewed-by: Dave Airlie <[email protected]>