summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: fix error message when validating tcs output declsIlia Mirkin2015-08-211-1/+1
| | | | | Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* i965: allow image_size on float imagesMartin Peres2015-08-211-1/+2
| | | | | | | | | | | | This got missed because the piglit test only tested int images to avoid a combinatiorial explosion of format, targets, stages and sizes which takes more than 5 minutes to test on nvidia's driver. This patch also drops the IMAGE_FUNCTION_AVAIL_ATOMIC which is not applicable to the image_size codepath but was not hurting in any way. Signed-off-by: Martin Peres <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: fix binding validation for interface blocksTimothy Arceri2015-08-211-12/+18
| | | | | | V2: rebase on SSBO changes Reviewed-by: Ian Romanick <[email protected]>
* glsl: interleave constant propagation and foldingTimothy Arceri2015-08-211-2/+43
| | | | | | | | | | | The constant folding pass can take a long time to complete so rather than running through the entire pass each time a new constant is propagated (and vice versa) interleave them. This change helps ES31-CTS.arrays_of_arrays.InteractionFunctionCalls1 go from around 2 min -> 23 sec. Reviewed-by: Ian Romanick <[email protected]>
* glsl: expose textureQueryLod in GLSL 4.00+ fragment shadersIlia Mirkin2015-08-201-37/+82
| | | | | | | | | | | | | | | See issue from the ARB_texture_query_lod spec for LOD vs Lod confusion: (3) The core specification uses the "Lod" spelling, not "LOD". Should this extension be modified to use "Lod"? RESOLVED: The "Lod" spelling is the correct spelling for the core specification and the preferred spelling for use. However, use of "LOD" also exists, as the extension predated the core specification, so this extension won't remove use of "LOD". Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: check if return_deref in lower_subroutine_visitor::visit_leave isn't NULLKai Wasserbäch2015-08-211-1/+1
| | | | | | | | | Fixes a crash in Piglit's spec@arb_shader_subroutine@[email protected] for me. Signed-off-by: Kai Wasserbäch <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* nir: convert the glsl intrinsic image_size to nir_intrinsic_image_sizeMartin Peres2015-08-202-6/+17
| | | | | | | | | | | | | | | | | v2, review from Francisco Jerez: - make the destination variable as large as what the nir instrinsic defines (4) instead of the size of the return variable of glsl. This is still safe for the already existing code because all the intrinsics affected returned the same amount of components as expected by glsl IR. In the case of image_size, it is not possible to do so because the returned number of component depends on the image type and this case is not well handled by nir. v3: - Style fix Signed-off-by: Martin Peres <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* glsl: add support for the imageSize builtinMartin Peres2015-08-201-16/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code is heavily inspired from Francisco Jerez's code supporting the image_load_store extension. Backends willing to support this builtin should handle __intrinsic_image_size. v2: Based on the review of Ilia Mirkin - Enable the extension for GLES 3.1 - Fix indentation - Fix the return type (float to int, number of components for CubeImages) - Add a warning related to GLES 3.1 v3: Based on the review of Francisco Jerez - Refactor the code to share both add_image_function and _image with the other image-related functions v4: Based on Topi Pohjolainen's comments - Do not add parenthesis for the return value v5: based on Francisco Jerez's comments: - Fix a few indent issues - Reduce the size of a condition by testing the dimension and array properties instead of enumerating all the formats. Signed-off-by: Martin Peres <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* main: add extension GL_ARB_shader_image_sizeMartin Peres2015-08-203-0/+6
| | | | | | Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Signed-off-by: Martin Peres <[email protected]>
* glsl: Parse the allowed image format qualifiers in GLSL ES 3.1.Francisco Jerez2015-08-201-41/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes the minimum required desktop/ES GLSL version in the format qualifier table in anticipation of new GLSL versions extending the set of supported image formats. According to section 4.4.7 of the GLSL ES 3.1 spec: "The format layout qualifier identifiers for image variable declarations are: [...] rgba32f rgba16f r32f rgba8 rgba8_snorm [...] rgba32i rgba16i rgba8i r32i [...] rgba32ui rgba16ui rgba8ui r32ui" Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Recognise image memory qualifiers in GLSL ES 3.1.Francisco Jerez2015-08-201-5/+5
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Define image-related built-in constants required by GLSL ES 3.1.Francisco Jerez2015-08-201-7/+15
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Remove duplicate definition of gl_MaxTess*ImageUniforms built-in ↵Francisco Jerez2015-08-201-2/+0
| | | | | | | | | | | constants. These seem to have been re-added at some point during the ARB_tessellation_shader implementation work. AFAICT the second (correct) definition of each constant would have had no effect because the symbols were already defined. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Accept atomic_uint type in GLSL ES 3.1.Francisco Jerez2015-08-201-1/+1
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Accept supported image types in GLSL ES 3.1.Francisco Jerez2015-08-202-24/+24
| | | | | | | | These are a subset of the image types supported by desktop GL, excluding 1D, 1D array, rectangle, buffer, cube array, 2D MS and 2D MS array texture targets. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Expose image load and store built-ins in GLSL ES 3.1.Francisco Jerez2015-08-201-1/+1
| | | | Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Use a separate availability class for image atomic built-ins.Francisco Jerez2015-08-201-11/+23
| | | | | | | These are not part of unextended GLSL ES 3.1. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Allow precision qualifiers on general opaque types.Francisco Jerez2015-08-201-4/+6
| | | | | | | | | | From the GLSL ES 3.1 spec, section 4.7.3: "Any floating point, integer, opaque type declaration can have the type preceded by one of these precision qualifiers: [...] highp [...], mediump [...], lowp [...]." Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Implement GLSL ES restriction on images being either readonly or ↵Francisco Jerez2015-08-201-0/+18
| | | | | | writeonly. Reviewed-by: Tapani Pälli <[email protected]>
* glsl: Require that all image uniforms have a format qualifier in GLSL ES.Francisco Jerez2015-08-201-4/+10
| | | | | | | | | | | | | | | | | | | | Note that this is slightly more permissive than the spec language requires: "Any image variable must specify a format layout qualifier." The GLSL ES spec seems really sketchy regarding format layout qualifiers on function formal parameters -- On the one hand they are required, but on the other hand it doesn't provide any syntax to specify them (see section 6.1.1), they don't participate in parameter type matching for overload resolution, and are in fact explictly forbidden ("Layout qualifiers cannot be used on formal function parameters"). Of course none of the image built-in functions defined by the spec specify format layout qualifiers (and they probably couldn't sensibly), to contradict its own requirement. This probably qualifies for a spec bug, but in the meantime do the sensible thing and require layout qualifiers on uniforms *only*. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Add support for image binding qualifiers.Francisco Jerez2015-08-202-8/+33
| | | | | | | | Support for binding an image to an image unit explicitly in the shader source is required by both GLSL 4.2 and GLSL ES 3.1, but not by the original ARB_shader_image_load_store extension. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Forbid non-constant image array indexing in GLSL ES 3.1.Francisco Jerez2015-08-201-0/+15
| | | | Reviewed-by: Timothy Arceri <[email protected]>
* mesa: Rename MaxCombinedImageUnitsAndFragmentOutputs to ↵Francisco Jerez2015-08-204-4/+4
| | | | | | | | | | | | | MaxCombinedShaderOutputResources. The name of both the GLSL built-in variable and the glGetInteger param with the same value changed in GLSL ES 3.1 and GL 4.5. Its semantics also changed slightly, since the limit now also takes into account the number of SSBs in use. Switch our internal data structures to the up-to-date name. Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* nir: Use nir_builder in nir_lower_io's get_io_offset().Kenneth Graunke2015-08-191-28/+14
| | | | | | | Much more readable. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Pull nir_lower_io's load_op selection into a helper function.Kenneth Graunke2015-08-191-17/+22
| | | | | | | Makes the function a bit smaller. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* glsl: Fix up GL_ARB_compute_shader for GLSL ES 3.1Marta Lofstedt2015-08-192-3/+7
| | | | | | | | | | GL_ARB_compute_shader is limited for GLSL version 430. This enables for GLSL ES version 310. V2: Updated error string to also include GLSL 3.10 Signed-off-by: Marta Lofstedt <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: enable textureSize and texelFetch on GLSL ES 3.10 with MS samplersTapani Pälli2015-08-191-6/+13
| | | | | | | | Patch separates array samplers from the texture_multisample check so that we can enable only [iu]sampler2DMS, [iu]sampler2DMSArray are not supported. Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: Move varying slots and FS output names to shader_enums.hEric Anholt2015-08-181-0/+98
| | | | | | | | | | They're used by glsl_to_nir.cpp, and I want to use them in TGSI-to-NIR as well (our use of the var->index slot to store slot properties no longer works since it got truncated). The *_MAX defines are left in mtypes.h, because they depend on config.h. Acked-by: Kenneth Graunke <[email protected]>
* nir: Simplify feq(fneg(a), a)) -> feq(a, 0.0)Thomas Helland2015-08-181-0/+1
| | | | | | | | | | The positive and negative value of a float can only be equal to each other if it is -0.0f and 0.0f. This is safe for Nan and Inf, as -Nan != Nan, and -Inf != Inf This gives no changes in my shader-db Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* nir: Simplify fne(fneg(a), a) -> fne(a, 0.0)Thomas Helland2015-08-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | -NaN != NaN, and -Inf != Inf, so this should be safe. Found while working on my VRP pass. Shader-db results on my IVB: total instructions in shared programs: 1698267 -> 1698067 (-0.01%) instructions in affected programs: 15785 -> 15585 (-1.27%) helped: 36 HURT: 0 GAINED: 0 LOST: 0 Some shaders was found to have the following pattern in NIR: vec1 ssa_26 = fneg ssa_21 vec1 ssa_27 = fne ssa_21, ssa_26 Make that: vec1 ssa_27 = fne ssa_21, 0.0f This is found in Dota2 and Brutal Legend. One shader is cut by 8%, from 323 -> 296 instructons in SIMD8 Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* glsl: add missing MS sampler builtin types for GLSL ES 3.10Tapani Pälli2015-08-172-6/+7
| | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* nir: Add a glsl_uint_type() wrapper.Kenneth Graunke2015-08-162-0/+7
| | | | | Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add support for CSE on textures.Eric Anholt2015-08-141-4/+39
| | | | | | | | | | | | NIR instruction count results on i965: total instructions in shared programs: 1261954 -> 1261937 (-0.00%) instructions in affected programs: 455 -> 438 (-3.74%) One in yofrankie, two in tropics. Apparently i965 had also optimized all of these out anyway. Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Zero out texture instructions when creating them.Eric Anholt2015-08-141-1/+1
| | | | | | | | There are so many flags in textures, that the CSE pass would have a hard time referencing the correct set when figuring out if two texture ops are the same. By zeroing, we can avoid that fragility. Reviewed-by: Jason Ekstrand <[email protected]>
* nir: Don't try to scalarize unpack ops.Eric Anholt2015-08-141-0/+15
| | | | | | | | | Avoids regressions in vc4 when trying to do our blending in NIR. v2: Add the other unpack ops I meant to when writing the original commit message. Reviewed-by: Matt Turner <[email protected]>
* nir: Add a nir_opt_undef() to handle csels with undef.Eric Anholt2015-08-143-0/+107
| | | | | | | | | | | | | | | | | | | We may find a cause to do more undef optimization in the future, but for now this fixes up things after if flattening. vc4 was handling this internally most of the time, but a GLB2.7 shader that did a conditional discard and assign gl_FragColor in the else was still emitting some extra code. total instructions in shared programs: 100809 -> 100795 (-0.01%) instructions in affected programs: 37 -> 23 (-37.84%) v2: Use nir_instr_rewrite_src() to update def/use on src[0] (by Thomas Helland). v3: Make sure to flag metadata dirties, and copy the swizzle and abs/neg over to src[0], too (by anholt). Reviewed-by: Thomas Helland <[email protected]> (v2) Tested-by: Thomas Helland <[email protected]> (v2)
* glsl: make linker error message more informativeTimothy Arceri2015-08-131-2/+3
| | | | Reviewed-by: Ilia Mirkin <[email protected]>
* glsl: Add missing spec quote about atomic counter in structsTimothy Arceri2015-08-111-4/+4
| | | | Reviewed-by: Thomas Helland <[email protected]>
* glsl: remove stage ref generation for transform feedbackTimothy Arceri2015-08-071-6/+4
| | | | | | | | | Stage ref cannot be queried for transform feedback. Also simplify the build_stageref function by passing the correct mode for uniforms. Reviewed-by: Tapani Pälli <[email protected]>
* mesa: save which transform feedback buffer is associated with which streamMarek Olšák2015-08-061-0/+1
| | | | Reviewed-by: Dave Airlie <[email protected]>
* glsl: Initialize patch member of glsl_struct_fieldMichel Dänzer2015-08-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is apparently a subtle difference in C++ between F f; and F f(); The former will use the default constructor. If there is no default constructor specified, the compiler provides one that simply invokes the default constructor for each field. For built-in basic types, the default constructor does nothing. The later will, according to http://stackoverflow.com/questions/2417065/does-the-default-constructor-initialize-built-in-types) perform value-initialization of the type. For built-in types this means initializing to zero. The per_vertex_accumulator constructor is: per_vertex_accumulator::per_vertex_accumulator() : fields(), num_fields(0) { } This is the second form of constructor, so the glsl_struct_field objects were previously zero initialized. With the addition of an empty default constructor in commit 7ac946e5, per_vertex_accumulator::fields receive no initialization. Fixes a bunch of random (mostly tessellation related) piglit failures since commit 7ac946e5 ("glsl: Add constuctors for the common cases of glsl_struct_field"). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91544 Reviewed-by: Ian Romanick <[email protected]>
* nir: add missing type to type_size_vec4()Timothy Arceri2015-08-051-0/+2
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* glsl: add variable mode check to build_stagerefTapani Pälli2015-08-051-4/+13
| | | | | | | | | | | | | Currently stage reference mask is built using the variable name only. However it can happen that input of one stage has same name as output from another stage. Adding check of variable mode makes sure we do not pick wrong variable. Fixes some subcases from ES31-CTS.program_interface_query.no-locations Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* nir: Add a nir_lower_load_const_to_scalar() pass.Eric Anholt2015-08-043-0/+105
| | | | | | | | This is useful to increase the CSE opportunities for a scalar backend. It avoids regressions when dropping vc4's custom CSE implementation. v2: Cleanups by Matt (decl in the for loop, and unreachable()). Reviewed-by: Matt Turner <[email protected]>
* nir: Add algebraic opt for no-op iand.Eric Anholt2015-08-041-0/+1
| | | | | | I lazily generated some of these in VC4 NIR lowering. Reviewed-by: Iago Toral Quiroga <[email protected]>
* Revert "nir: Use a single bit for the dual-source blend index"Eric Anholt2015-08-041-6/+2
| | | | | This reverts commit ab5b7a0fe659ff6f9c1885d5cb047b6531959506. We use more than one bit of value in tgsi_to_nir.
* mesa: Use _mesa_lroundevenf() in some more places.Matt Turner2015-08-041-10/+4
|
* glsl: replace old hash table with new and faster oneAlejandro Seguí2015-08-041-7/+11
| | | | | | | | The util/hash_table was intended to be a fast hash table replacement for the program/hash_table see 35fd61bd99c1 and 72e55bb6888ff. Reviewed-by: Timothy Arceri <[email protected]>
* glsl: Add constuctors for the common cases of glsl_struct_fieldIan Romanick2015-08-034-56/+53
| | | | | | | | | | | | | | | | | | | | | | | | Fixes a giant pile of GCC warnings: builtin_types.cpp:60:1: warning: missing initializer for member 'glsl_struct_field::stream' [-Wmissing-field-initializers] I had to add a default constructor because a non-default constructor was added. Otherwise the only constructor would be the one with parameters, and all the plases like glsl_struct_field foo; would fail to compile. I wanted to do this in two patches. All of the initializers of glsl_struct_field structures had to be converted to use the constructor because C++ apparently forces you to do one or the other: builtin_types.cpp:61:1: error: could not convert '{glsl_type::float_type, "near", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0, -1}' from '<brace-enclosed initializer list>' to 'glsl_struct_field' Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Reviewed-by: Juha-Pekka Heikkila <[email protected]>
* nir: Fix output swizzle in get_mul_for_srcSamuel Iglesias Gonsalvez2015-08-031-1/+12
| | | | | | | | | | | | | | | Avoid copying an overwritten swizzle, use the original values. Example: Former swizzle[] = xyzw src->swizzle[] = zyxx The expected output swizzle = zyxx but if we reuse swizzle in the loop, then output swizzle would be zyzz. Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>