summaryrefslogtreecommitdiffstats
path: root/src/glsl
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Expose gl_MaxTess{Control,Evaluation}AtomicCounters.Matt Turner2015-09-281-8/+4
| | | | | | | | | | | | | | | | | | | | | | ... with only ARB_shader_atomic_counters. I expected to see interactions with ARB_tessellation_shader in the ARB_shader_atomic_counters spec, but they do not exist. It seems that we should unconditionally expose these variables in the presence of ARB_shader_atomic_counters: gl_MaxTessControlAtomicCounters gl_MaxTessEvaluationAtomicCounters This partially reverts commit da7adb99e8. The commit also affected gl_MaxTessControlImageUniforms and gl_MaxTessEvaluationImageUniforms similarly but the ARB_shader_image_load_store spec does list an interaction with ARB_tessellation_shader. Cc: "11.0" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92095 Reviewed-by: Kenneth Graunke <[email protected]> (cherry picked from commit d6bb46bbe8e4ef90dedc5a04c7434a8113c10a8b)
* nir: Fix a bunch of ralloc parenting errorsJason Ekstrand2015-09-2310-31/+32
| | | | | | | | | | | | | | | As of a10d4937, we would really like things associated with an instruction to be allocated out of that instruction and not out of the shader. In particular, you should be passing the instruction that will ultimately be holding the source into nir_src_copy rather than an arbitrary memory context. We also change the prototypes of nir_dest_copy and nir_alu_src/dest_copy to explicitly take an instruction so we catch this earlier in the future. Cc: "11.0" <[email protected]> Reviewed-by: Thomas Helland <[email protected]> (cherry picked from commit 8c8fc5f8336c8c79e5890265ae6c03271aa94075)
* glsl: Use hash tables for opt_constant_propagation() kill sets.Kenneth Graunke2015-09-111-18/+28
| | | | | | | | | | | | | | | | Cuts compile/link time of the fragment shader in #91857 by 19% (16.28 -> 13.05). I didn't bother with the acp sets because they're smaller, but it might be worth doing as well. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91857 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Tapani Pälli <[email protected]> (cherry picked from commit 4654439fdd766f79a78fe0d812fd916f5815e7e6) Nominated-by: Emil Velikov <[email protected]>
* glsl: Use hash tables in opt_constant_variable().Kenneth Graunke2015-09-111-18/+21
| | | | | | | | | | | | | | Cuts compile/link time of the fragment shader in bug #91857 by 31% (31.79 -> 21.64). It has over 8,000 variables so linked lists are terrible. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91857 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Tested-by: Tapani Pälli <[email protected]> (cherry picked from commit 2fc0ce293ac58237f02cc5dd2eee4e35abea06b5) Nominated-by: Emil Velikov <[email protected]>
* glsl: build: remove bogus dependencyEmil Velikov2015-09-112-3/+2
| | | | | | | | | | v2: rebase on top of the previous commit - don't touch the LOCAL_PATH prefix for nir_constant_expressions.h Cc: 11.0 <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]> (cherry picked from commit c373eaedfc09ff2af7002b64ba0ae8ba71df86a1)
* glsl: build: use makefile.sources variables when possibleEmil Velikov2015-09-113-18/+11
| | | | | | | | | | | | Rather than folding one variable within the other only to unwrap them, just use the ones we need. v2: bring back LOCAL_PATH prefix for nir_constant_expressions,h Cc: 11.0 <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]> (v1) (cherry picked from commit a3b05e04921a4fcc05cfc994e415e3ceb39fd184)
* glsl: automake: reuse $(NIR_GENERATED_FILES) where possibleEmil Velikov2015-09-111-5/+1
| | | | | | | Cc: 11.0 <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]> (cherry picked from commit da5e4559ee3b239d2483645ed54b35aa6628fbaf)
* glsl: automake: rework the sources generation rulesEmil Velikov2015-09-111-16/+22
| | | | | | | | | | | | The glsl equivalent of "mesa: automake: rework the source generation rules". Plus let's make things consistent and always explicitly provide the header name. v2: Rebase on top of reverted "remove custom AM_V_LEX/YACC" (Matt) Cc: 11.0 <[email protected]> Signed-off-by: Emil Velikov <[email protected]> (cherry picked from commit 9e0594418d8fa47e19bfe57450198d3fa7d087a0)
* glsl: Handle attribute aliasing in attribute storage limit check.Kenneth Graunke2015-09-061-28/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | In various versions of OpenGL and GLSL, it's possible to declare multiple VS input variables with aliasing attribute locations. So, when computing the storage requirements for vertex attributes, we can't simply add up the sizes. Instead, we need to look at the enabled slots. This patch begins tracking which attributes are double types that are larger than 128-bits (i.e. take up two vec4 slots). We then count normal attributes once, and count the double-size attributes a second time. Fixes deQP functional.attribute_location.bind_aliasing.max_cond_* tests on i965, which regressed with commit ad208d975a6d3aebe14f7c2c16039ee20. No Piglit changes on llvmpipe (which actually supports dvecs). Cc: "10.6 11.0" <[email protected]> Tested-by: Mark Janes <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> (cherry picked from commit c3294ca5a13cf3f0eb3d9907a46ff8ce4bc2963b)
* 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]>