summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa: Remove unused hash table includesThomas Helland2016-09-121-1/+0
| | | | | | | This should prevent us from rebuilding the world. Signed-off-by: Thomas Helland <thomashelland90@gmail.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
* mesa: Avoid aliasing violation in uniform_query.cpp.Matt Turner2016-07-261-14/+31
| | | | | Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* main: memcpy larger chunks in _mesa_propagate_uniforms_to_driver_storageNils Wallménius2016-07-251-6/+23
| | | | | | | | | | | | | | | | When possible, do the memcpy on larger blocks. This reduces cycles spent in _mesa_propagate_uniforms_to_driver_storage from 1.51 % to 0.62% according to perf during the Unigine Heaven benchmark. It did not affect the framerate of the benchmark. The system used for testing was an i5 6600K with a Radeon R9 380. Piglit hangs randomly on this system both with and without the patch so i could not make a comparison. v2: fixed whitespace Signed-off-by: Nils Wallménius <nils.wallmenius@gmail.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
* mesa: stop copying SamplerUnits twiceTimothy Arceri2016-07-051-4/+0
| | | | | | | The call to _mesa_update_shader_textures_used() already takes care of copying for us. Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
* mesa: fix build errorTimothy Arceri2016-07-051-1/+1
| | | | Fix build error cased by 6a524c76f5.
* mesa: faster validation of sampler unit mapping for SSOGregory Hainaut2016-07-051-38/+31
| | | | | | | | | | | | | | | | Code was inspired from _mesa_update_shader_textures_used However unlike _mesa_update_shader_textures_used that only check for a single stage, it will check all stages. It avoids to loop on all uniforms, only active samplers are checked. For my use case: high FS frequency switches with few samplers. Perf event (relative to nouveau_dri.so) goes from 5.01% to 1.68% for the _mesa_sampler_uniforms_pipeline_are_valid function. Signed-off-by: Gregory Hainaut <gregory.hainaut@gmail.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
* glsl/mesa: split gl_shader in twoTimothy Arceri2016-06-301-2/+2
| | | | | | | | | | | | | | | | | There are two distinctly different uses of this struct. The first is to store GL shader objects. The second is to store information about a shader stage thats been linked. The two uses actually share few fields and there is clearly confusion about their use. For example the linked shaders map one to one with a program so can simply be destroyed along with the program. However previously we were calling reference counting on the linked shaders. We were also creating linked shaders with a name even though it is always 0 and called the driver version of the _mesa_new_shader() function unnecessarily for GL shader objects. Acked-by: Iago Toral Quiroga <itoral@igalia.com>
* mesa: Use bitmask/ffs to iterate the active_samplers bitmask.Mathias Fröhlich2016-06-161-3/+5
| | | | | | | | | | | Replaces an iterate and test bit in a bitmask loop by a loop only iterating over the bits set in the bitmask. v2: Use _mesa_bit_scan{,64} instead of open coding. v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}. Reviewed-by: Brian Paul <brianp@vmware.com> Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
* mesa: use new 64-bit checks instead of explicit double checks.Dave Airlie2016-06-091-4/+4
| | | | | | | This just moves to the new interfaces in advance of int64. Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: Dave Airlie <airlied@redhat.com>
* mesa/main: handle double uniform matrices properlyJuan A. Suarez Romero2016-05-041-1/+1
| | | | | | | | When computing the offset in the uniform storage table, take into account the size multiplier so double precision matrices are handled correctly. Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* mesa: remove initialized field from uniform storageTimothy Arceri2016-03-291-4/+0
| | | | | | | | The only place this was used was in a gallium debug function that had to be manually enabled. Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Brian Paul <brianp@vmware.com>
* glsl: move to compiler/Emil Velikov2016-01-261-4/+4
| | | | | | Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Acked-by: Matt Turner <mattst88@gmail.com> Acked-by: Jose Fonseca <jfonseca@vmware.com>
* mesa/uniform_query: add IROUNDD and use for doubles->ints (v2)Dave Airlie2016-01-111-1/+1
| | | | | | | | | | | | For the case where we convert a double to an int, we should round the same as we do for floats. This fixes GL41-CTS.gpu_shader_fp64.state_query v2: add IROUNDD (Ilia) Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: Dave Airlie <airlied@redhat.com>
* glsl: re-validate program pipeline after sampler changeTimothy Arceri2015-12-071-0/+4
| | | | | | | Cc: "11.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Cc: Kenneth Graunke <kenneth@whitecape.org> https://bugs.freedesktop.org/show_bug.cgi?id=93180
* mesa/uniforms: fix get_uniform for doubles (v2)Dave Airlie2015-10-121-16/+37
| | | | | | | | | | | | | | | The initial glGetUniformdv support didn't cover all the casting cases that are apparantly legal, and cts seems to test for them. I've updated the piglit test to cover these cases now. v2: fix indentation - it's all broken in this file (Ilia) fix src/dst index tracking in light of fp64 support (Ilia) cc: "11.0" <mesa-stable@lists.freedesktop.org> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Signed-off-by: Dave Airlie <airlied@redhat.com>
* glsl: reduce memory footprint of uniform_storage structTimothy Arceri2015-10-051-4/+4
| | | | | | | | The uniform will only be of a single type so store the data for opaque types in a single array. Cc: Francisco Jerez <currojerez@riseup.net> Cc: Ilia Mirkin <imirkin@alum.mit.edu>
* mesa: clean up #includes in uniform_query.cppBrian Paul2015-10-011-7/+6
| | | | Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Don't allow wrong type setters for matrix uniformsIan Romanick2015-09-021-0/+25
| | | | | | | | | | | | | Previously we would allow glUniformMatrix4fv on a dmat4 and glUniformMatrix4dv on a mat4. Both are illegal. That later also overwrites the storage for the mat4 and causes bad things to happen. Should fix the (new) arb_gpu_shader_fp64-wrong-type-setter piglit test. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au> Cc: Dave Airlie <airlied@redhat.com> Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
* mesa: Pass the type to _mesa_uniform_matrix as a glsl_base_typeIan Romanick2015-09-021-5/+5
| | | | | | | | | | | | This matches _mesa_uniform, and it enables the bug fix in the next patch. v2: s/type/basicType/ in the assert in _mesa_uniform_matrix. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au> [v1] Cc: Dave Airlie <airlied@redhat.com> Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org>
* mesa/arb_gpu_shader_fp64: add support for glGetUniformdvDave Airlie2015-08-231-7/+14
| | | | | | | | | This was missed when I did fp64, I've sent a piglit test to cover the case as well. Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au> Cc: "11.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
* mesa: Refuse to bind image uniforms using glUniform in GLES.Francisco Jerez2015-08-201-1/+3
| | | | | | | | The GLES 3.1 spec removed support for updating the image unit bound to an image uniform using glUniform1i() calls. Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* mesa: remove now unused _mesa_get_uniform_locationTimothy Arceri2015-07-301-75/+0
| | | | | Cc: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: fix active sampler conflict validationTimothy Arceri2015-07-221-7/+13
| | | | | | | | | The type stored in gl_uniform_storage is the type of a single array element not the array type so size was always 1. V2: Dont validate sampler units pointing to 0 Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
* mesa: reference built-in uniforms into gl_uniform_storageMartin Peres2015-06-041-2/+13
| | | | | | | | | | | | | | | This change introduces a new field in gl_uniform_storage to explicitely say that a uniform is built-in. In the case where it is, no storage is defined to make it clear that it is read-only from the mesa side. I fixed all the places in the code that made use of the structure that I changed. Any place making a wrong assumption and using the storage straight away will just crash. This patch seems to implement the path of least resistance towards listing built-in uniforms in GL_ACTIVE_UNIFORM (and other APIs). Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
* mesa: Implement image uniform queries.Francisco Jerez2015-05-041-1/+3
| | | | Reviewed-by: Matt Turner <mattst88@gmail.com>
* mesa: fix glGetActiveUniformsiv regressionTapani Pälli2015-04-241-4/+16
| | | | | | | | | | | Commit 7519ddb caused regression to glGetActiveUniformsiv. Patch adds back validation loop of all given uniforms before writing any values, not touching params in case of errors is tested by the conformance suite. Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90149 Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
* mesa: refactor GetActiveUniformTapani Pälli2015-04-161-17/+16
| | | | | Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
* mesa: refactor GetActiveUniformsiv, use _mesa_program_resource_propTapani Pälli2015-04-161-70/+39
| | | | | Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
* mesa: use more descriptive error messages for glUniform errorsBrian Paul2015-03-191-4/+65
| | | | | | | | Different errors for type mismatches, size mismatches and matrix/ non-matrix mismatches. Use a common format of "uniformName"@location in the messags. Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
* mesa/main: replace Elements() with ARRAY_SIZE()Brian Paul2015-03-021-1/+1
| | | | | | | | We've been using a mix of these two macros for a while now. Let's just use the later everywhere. It seems to be the convention used by other open-source projects. Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
* mesa: add double uniform support. (v5)Dave Airlie2015-02-191-11/+35
| | | | | | | | | | | | | | | | This adds support for the new uniform interfaces from ARB_gpu_shader_fp64. v2: support ARB_separate_shader_objects ProgramUniform*d* (Ian) don't allow boolean uniforms to be updated (issue 15) (Ian) v3: fix size_mul v4: Teach uniform update to take into account double precision (Topi) v5: add transpose for double case (Ilia) Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
* mesa: Returns a GL_INVALID_VALUE error on several APIs when buffer size is ↵Eduardo Lima Mitev2015-02-031-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | negative Section 2.3.1 (Errors) of the OpenGL 4.5 spec says: "If a negative number is provided where an argument of type sizei or sizeiptr is specified, an INVALID_VALUE error is generated. This patch adds checks for negative buffer size values passed to different APIs. It also moves up the check on other APIs that already had it, making it the first error check performed in the function, for consistency. While there may be other APIs throughtout the code lacking this check (or at least not at the beginning of the function), this patch focuses on the cases that break the dEQP tests listed below. It could be a good excersize for the future to check all other cases, and improve consistency in the order of the checks throughout the whole Mesa code base. This fixes 5 dEQP test: * dEQP-GLES3.functional.negative_api.state.get_attached_shaders * dEQP-GLES3.functional.negative_api.state.get_shader_source * dEQP-GLES3.functional.negative_api.state.get_active_uniform * dEQP-GLES3.functional.negative_api.state.get_active_attrib * dEQP-GLES3.functional.negative_api.shader.program_binary Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* mesa: Uniform logging is very, very unlikelyIan Romanick2014-11-101-2/+2
| | | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Don't check for API_OPENGLES in _mesa_uniform_matrixIan Romanick2014-11-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | There are no uniforms in OpenGL ES 1.x, so we can't even get to this code in that API. Also, reorder the checks. First check that transpose is true, then check whether or not that is legal in the current API. transpose should never be true in an ES2 context, so this gets one check (the more expensive one) out of the main path. Valgrind callgrind results for a trace of Tesseract: _mesa_UniformMatrix4fv _mesa_UniformMatrix3fv Before (64-bit): 96,119,025 24,240,510 After (64-bit): 90,726,569 22,926,662 _mesa_UniformMatrix4fv _mesa_UniformMatrix3fv Before (32-bit): 132,434,452 29,051,808 After (32-bit): 126,658,112 27,989,316 Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Rework array error checks in validate_uniform_parametersIan Romanick2014-11-101-19/+22
| | | | | | | | | | | | | | | | | | | | | | Before ARB_explicit_uniform_location, Mesa's location encoding allowed locations for non-array types that had non-zero array indices. Basically, part of the location was the uniform and part was the array index. This meant that some checks had to occur for arrays and non-arrays. This is no longer possible, we the checks can be split up. Valgrind callgrind results for a trace of Tesseract: _mesa_Uniform4fv _mesa_Uniform4f _mesa_Uniform1i Before (64-bit): 50,499,557 17,487,316 686,227 After (64-bit): 50,023,791 17,274,432 684,293 _mesa_Uniform4fv _mesa_Uniform4f _mesa_Uniform1i Before (32-bit): 62,968,039 21,732,380 828,147 After (32-bit): 62,373,967 21,490,756 826,223 Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Get some gl_shader_program::LinkStatus checking out of the main pathIan Romanick2014-11-101-6/+19
| | | | | | | | | | I really wanted to remove 'shProg != NULL' as well, but that would have required adding a dummy program as the default program. That seemed like more churn than removing one test was worth. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Rework location == -1 error checkingIan Romanick2014-11-101-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | Only one caller wanted to generate an error when location == -1, so move the error generation to that caller. There will be more callers in the future that do not want to generate errors. Move the location == -1 check later in validate_uniform_parameters. As currently implemented, glUniform1iv(-1, -1, data) would not generate an error, but it should due to count being < 0. The location that I have moved it to will make more sense with the next commit. Valgrind callgrind results for a trace of Tesseract: _mesa_Uniform4fv _mesa_Uniform4f _mesa_Uniform1i Before (64-bit): 51,241,217 17,740,162 689,181 After (64-bit): 50,499,557 17,487,316 686,227 _mesa_Uniform4fv _mesa_Uniform4f _mesa_Uniform1i Before (32-bit): 63,940,605 21,987,918 831,065 After (32-bit): 62,968,039 21,732,380 828,147 Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Minor clean ups in _mesa_uniformIan Romanick2014-11-101-23/+9
| | | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Remove GLSL_TYPE_SAMPLER checkIan Romanick2014-11-101-2/+1
| | | | | | | | | Noting the assertion just a few lines earlier, returnType cannot be GLSL_TYPE_SAMPLER. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa/main: Pass the data that _mesa_uniform actually wantsIan Romanick2014-11-101-70/+3
| | | | | | | | | | The GL_ enums were previously used because glsl_types.h couldn't be used in C code. That was fixed some time ago (and uniforms.c already includes glsl_types.h), so this is no longer necessary. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
* mesa: Silence unused parameter warning in _mesa_init_shader_programIan Romanick2014-10-241-2/+1
| | | | | | | | | | | Just remove the parameter. Silences: ../../src/mesa/main/uniform_query.cpp:1062:1: warning: unused parameter 'ctx' [-Wunused-parameter] Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* glsl: Delete unused gl_uniform_driver_format enum values.Kenneth Graunke2014-10-211-25/+2
| | | | | | | | | | | | | | A while back, Matt made the uniform upload functions simply upload ctx->Const.UniformBooleanTrue for boolean values instead of 0/1, which removed the need to convert it later. We also set UniformBooleanTrue to 1.0f for drivers which want to treat booleans as 0.0/1.0f. Nothing ever sets these, so they are dead. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* mesa: validate sampler uniforms during gluniform callsTapani Pälli2014-10-201-35/+9
| | | | | | | | | | | | | | | | | Patch fixes 'glsl-2types-of-textures-on-same-unit' in WebGL conformance test suite. No Piglit regressions, fixes gl-2.0-active-sampler-conflict. To avoid adding potentially heavy check during draw (valid_to_render), check is done during uniform updates by inspecting TexturesUsed mask. A new boolean variable is introduced to cache validation state. v2: take into account case where 2 uniforms use same unit (curro) also do the check only when SSO is not in use, SSO has own path for sampler validation. Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Francisco Jerez <currojerez@riseup.net>
* mesa: check that uniform exists in glUniform* functionsTapani Pälli2014-09-151-8/+8
| | | | | | | | | | | | | Remap table for uniforms may contain empty entries when using explicit uniform locations. If no active/inactive variable exists with given location, remap table contains NULL. v2: move remap table bounds check before existence check (Ian Romanick) Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Tested-by: Erik Faye-Lund <kusmabite@gmail.com> (v1) Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83574
* mesa: Upload boolean uniforms using UniformBooleanTrue.Matt Turner2014-08-181-2/+2
| | | | Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
* mesa: Fold _mesa_uniform_merge_location_offset into its only callerIan Romanick2014-08-071-3/+1
| | | | | | | | Also delete the comment before that function. Everything in that comment was either stale, wrong, or captured elsewhere. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* mesa: Fold _mesa_uniform_split_location_offset into its only callerIan Romanick2014-08-071-3/+6
| | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* mesa: Use MAX2 to calculate maximum uniform elementIan Romanick2014-08-071-3/+1
| | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* mesa: Have validate_uniform_parameters return the gl_uniform_storage pointerIan Romanick2014-08-071-31/+30
| | | | | | | | This simplifies all the callers, and it enables the removal of one of the function parameters. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
* mesa: Fix the name in the error messageIan Romanick2014-07-231-1/+1
| | | | | | | Obvious copy-and-paste bug. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>