aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniform_query.cpp
Commit message (Collapse)AuthorAgeFilesLines
* mesa|mapi: replace _mesa_[v]snprintf with [v]snprintfDylan Baker2020-04-211-1/+1
| | | | | | | | | | MSVC 2015 and newer has perfectly valid snprintf and vsnprintf implementations, let's just use those. Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Matt Turner <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
* mesa: include mtypes.h lessMarek Olšák2018-04-121-1/+1
| | | | | | | | | | - remove mtypes.h from most header files - add main/menums.h for often used definitions - remove main/core.h v2: fix radv build Reviewed-by: Brian Paul <[email protected]>
* mesa: add packing support for setting uniform handlesTimothy Arceri2018-03-201-3/+13
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: add packing support for setting uniformsTimothy Arceri2018-03-201-19/+53
| | | | Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: create copy uniform to storage helpersTimothy Arceri2018-03-201-63/+91
| | | | | | | | These will be used in the following patch to allow copying directly to the param list when packing is enabled. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* mesa: rework ParameterList to allow packingTimothy Arceri2018-03-201-6/+8
| | | | | | | | | | | | | | Currently everything is padded to 4 components. Making the list more flexible will allow us to do uniform packing. V2 (suggestions from Nicolai): - always pass existing calls to _mesa_add_parameter() true for padd_and_align - fix bindless param value offsets - remove left over wip logic from pad and align code - zero out param value padding - whitespace fix Reviewed-by: Marek Olšák <[email protected]>
* mesa: fix mismatch when returning 64-bit bindless uniform handlesSamuel Pitoiset2017-07-281-1/+2
| | | | | | | | | | | | | The slower convert-and-copy process performs a bad conversion because it converts the value to signed 64-bit integer, but bindless uniform handles are considered unsigned 64-bit. This fixes "Check glUniform*() with mixed texture units/handles" from arb_bindless_texture-uniform piglit. Signed-off-by: Samuel Pitoiset <[email protected]> Cc: "17.2" <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
* mesa: skip FLUSH_VERTICES() if no samplers were changedTimothy Arceri2017-06-271-1/+6
| | | | Reviewed-by: Marek Olšák <[email protected]>
* mesa: don't set _NEW_PROGRAM_CONSTANTS for non-bindless opaque uniformsTimothy Arceri2017-06-271-0/+6
| | | | | | v2: rebase on new _mesa_flush_vertices_for_uniforms() helper Reviewed-by: Marek Olšák <[email protected]>
* mesa: don't flag _NEW_PROGRAM_CONSTANTS for GLSL programs for st/mesaMarek Olšák2017-06-221-3/+20
| | | | | | | | | v2: also update _mesa_uniform_handle for bindless textures Reviewed-by: Nicolai Hähnle <[email protected]> (v1) Reviewed-by: Brian Paul <[email protected]> (v1) Reviewed-by: Timothy Arceri <[email protected]> (v1) Reviewed-by: Samuel Pitoiset <[email protected]>
* mesa: add KHR_no_error support for gl*UniformHandleui64*ARBSamuel Pitoiset2017-06-181-19/+39
| | | | | | | | Similar to _mesa_uniform() except that we have to call validate_uniform_parameters() instead of validate_uniform(). Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: fix setting uniform variables for bindless samplers/imagesSamuel Pitoiset2017-06-141-6/+19
| | | | | | | | | This fixes a 64-bit vs 32-bit mismatch when setting an array of bindless samplers. Also, we need to unconditionally set size_mul to 2 when the underlying uniform is bindless. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: handle bindless uniforms bound to texture/image unitsSamuel Pitoiset2017-06-141-6/+116
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: add support for glUniformHandleui64*ARB()Samuel Pitoiset2017-06-141-0/+64
| | | | | | | | | | | | | | Bindless sampler/image handles are represented using 64-bit unsigned integers. The ARB_bindless_texture spec says: "The error INVALID_OPERATION is generated by UniformHandleui64{v}ARB if the sampler or image uniform being updated has the "bound_sampler" or "bound_image" layout qualifier"." Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa/main: replace remaining uses of IROUND() in GetUniform*() by round()Iago Toral Quiroga2017-06-011-2/+2
| | | | | | | | | These were correct since they were used only in conversions to signed integers, however this makes the implementation a bit more is more consistent and reduces chances of propagating use of these macros to unsigned cases in the future, which would not be correct. Reviewed-by: Matt Turner <[email protected]>
* mesa/main: conversion from float in GetUniformi64v requires rounding to nearestIago Toral Quiroga2017-06-011-1/+1
| | | | | | | | As we do for all other cases of float/double conversions to integers. v2: use round() instead of IROUND() macros (Iago) Reviewed-by: Matt Turner <[email protected]>
* mesa/main: Add conversion from double to uint64/int64 in GetUniform*i64v()Iago Toral Quiroga2017-06-011-0/+14
| | | | | | | | v2: - need unsigned rounding for double->uint64 conversion (Nicolai) - use round() instead of IROUND() macros (Iago) Reviewed-by: Matt Turner <[email protected]>
* mesa/main: Clamp GetUniformui64v values to be >= 0Iago Toral Quiroga2017-06-011-1/+45
| | | | | | | | | | Like we do for the 32-bit case. v2: - need unsigned rounding for float->uint64 conversion (Nicolai) - use roundf() instead of IROUND() macros (Iago) Reviewed-by: Matt Turner <[email protected]>
* mesa/main: Clamp GetUniformuiv values to be >= 0Kenneth Graunke2017-06-011-11/+51
| | | | | | | | | | | | | | | | | | | | | | | | Section 2.2.2 (Data Conversions For State Query Commands) of the OpenGL 4.5 October 24th 2016 specification says: "If a command returning unsigned integer data is called, such as GetSamplerParameterIuiv, negative values are clamped to zero." v2: uint to int conversion should clamp to INT_MAX (Nicolai) v3 (Iago) - Add conversions conversions from 64-bit integer paths - Rebase on master v4: - need unsigned rounding for float/double->uint conversions (Nicolai) - use round{f}() instead of IROUND() macros (Iago) Fixes: KHR-GL45.gpu_shader_fp64.state_query Reviewed-by: Nicolai Hähnle <[email protected]> (v2) Reviewed-by: Matt Turner <[email protected]>
* mesa/main: fix indentation in _mesa_get_uniform()Iago Toral Quiroga2017-06-011-98/+101
| | | | | | | v2: also change the style of the large conditional in that function to follow the style from most other parts of Mesa (Nicolai) Reviewed-by: Matt Turner <[email protected]>
* mesa: unify _mesa_uniform() for image uniformsSamuel Pitoiset2017-05-161-6/+8
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Elie Tournier <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: fix indentation in _mesa_uniform()Samuel Pitoiset2017-05-161-18/+19
| | | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Elie Tournier <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: don't crash in KHR_no_error uniform variants when location == -1Timothy Arceri2017-05-161-0/+9
| | | | | | | | | | From Seciton 7.6 (UNIFORM VARIABLES) of the OpenGL 4.5 spec: "If the value of location is -1, the Uniform* commands will silently ignore the data passed in, and the current uniform values will not be changed. Reviewed-by: Samuel Pitoiset <[email protected]>
* glsl: make sampler/image types as 64-bitSamuel Pitoiset2017-05-061-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | The ARB_bindless_texture spec says: "Samplers are represented using 64-bit integer handles." and, "Images are represented using 64-bit integer handles." It seems simpler to always consider sampler and image types as 64-bit unsigned integer. This introduces a temporary workaround in _mesa_get_uniform() because at this point no flag are used to distinguish between bound and bindless samplers. This is going to be removed in a separate series. This avoids breaking arb_shader_image_load_store-state. v3: - update the comment slightly Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: set vector_elements to 1 for samplersSamuel Pitoiset2017-05-021-10/+5
| | | | | | | | | | | | | | | | I don't see any reasons why vector_elements is 1 for images and 0 for samplers. This increases consistency and allows to clean up some code a bit. This will also help for ARB_bindless_texture. No piglit regressions with RadeonSI. This time the Intel CI system doesn't report any failures. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* Revert "glsl: set vector_elements to 1 for samplers"Matt Turner2017-04-281-5/+10
| | | | | | This reverts commit 75a31a20af269c047661af33e28f793269537b79. This breaks thousands of tests on i965 with malloc corruption.
* glsl: set vector_elements to 1 for samplersSamuel Pitoiset2017-04-271-10/+5
| | | | | | | | | | | | | | I don't see any reasons why vector_elements is 1 for images and 0 for samplers. This increases consistency and allows to clean up some code a bit. This will also help for ARB_bindless_texture. No piglit regressions with RadeonSI. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: validate sampler type across the whole programTimothy Arceri2017-04-221-0/+2
| | | | | | | | | | | Currently we were only making sure types were the same within a single stage. This looks to have regressed with 953a0af8e3f73. Fixes: 953a0af8e3f73 ("mesa: validate sampler uniforms during gluniform calls") Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Tapani Pälli <[email protected]> https://bugs.freedesktop.org/show_bug.cgi?id=97524
* mesa: add KHR_no_error support to glUniform*() functionsTimothy Arceri2017-04-191-23/+50
| | | | | | | V2: restore lost comment, add static to validate_uniform(), simplify array offset logic. Reviewed-by: Nicolai Hähnle <[email protected]>
* mesa: split _NEW_TEXTURE into _NEW_TEXTURE_OBJECT & _NEW_TEXTURE_STATEMarek Olšák2017-03-291-1/+1
| | | | | | | | | | | | No performance testing has been done, because it makes sense to make this change regardless of that. Also, _NEW_TEXTURE is still used in many places, but the obvious occurences are replaced here. It's now possible to split _NEW_TEXTURE_OBJECT further. Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
* glsl: use is_sampler() anywhere it's possibleSamuel Pitoiset2017-02-271-1/+1
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* glsl: use is_image() anywhere it's possibleSamuel Pitoiset2017-02-271-1/+1
| | | | | Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: (trivial) include <inttypes.h> for PRIx64 macrosRoland Scheidegger2017-02-081-0/+1
| | | | Fixes a compile error with mingw.
* mesa: use PRId64/PRIu64 when printing 64-bit intsTimothy Arceri2017-02-081-2/+2
| | | | | | V2: actually use PRIu64 Reviewed-by: Dave Airlie <[email protected]>
* mesa/uniform: fix strict aliasing issues with int64 code.Dave Airlie2017-02-081-12/+26
| | | | | | | This fixes these like the double version does. Reviewed-by: Timothy Arceri <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* mesa: Arrange validate_uniform_parameters parameters to match call sitesIan Romanick2017-01-261-11/+11
| | | | | | | | | | | | | | | Saves a measly 20 bytes on IA32 and nothing on x64. Depending on exactly when this is applied, a lot of variation is possible due to function alignment. text data bss dec hex filename 6670131 228340 22552 6921023 699b3f lib/i965_dri.so before 6670111 228340 22552 6921003 699b2b lib/i965_dri.so after 6342932 293872 29880 6666684 65b9bc lib64/i965_dri.so before 6342932 293872 29880 6666684 65b9bc lib64/i965_dri.so after Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa: Arrange _mesa_uniform parameters to match the call sitesIan Romanick2017-01-261-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By putting the parameters first that match the parameters to the call site, 4 (of 14) instructions are saved at _mesa_Uniform4fv on x64. On IA32, the details of the instructions change, but it is the same count and mix of instructions. Before: 0000000000000830 <_mesa_Uniform4fv>: 830: 48 83 ec 10 sub $0x10,%rsp 834: 49 89 d0 mov %rdx,%r8 837: 48 8b 15 00 00 00 00 mov 0x0(%rip),%rdx # 83e <_mesa_Uniform4fv+0xe> 83e: 89 f8 mov %edi,%eax 840: 89 f1 mov %esi,%ecx 842: 41 b9 02 00 00 00 mov $0x2,%r9d 848: 64 48 8b 3a mov %fs:(%rdx),%rdi 84c: 48 8b 97 c8 01 02 00 mov 0x201c8(%rdi),%rdx 853: 48 8b 72 70 mov 0x70(%rdx),%rsi 857: 6a 04 pushq $0x4 859: 89 c2 mov %eax,%edx 85b: e8 00 00 00 00 callq 860 <_mesa_Uniform4fv+0x30> 860: 48 83 c4 18 add $0x18,%rsp 864: c3 retq After: 00000000000007f0 <_mesa_Uniform4fv>: 7f0: 48 83 ec 10 sub $0x10,%rsp 7f4: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 7fb <_mesa_Uniform4fv+0xb> 7fb: 41 b9 02 00 00 00 mov $0x2,%r9d 801: 64 48 8b 08 mov %fs:(%rax),%rcx 805: 48 8b 81 c8 01 02 00 mov 0x201c8(%rcx),%rax 80c: 6a 04 pushq $0x4 80e: 4c 8b 40 70 mov 0x70(%rax),%r8 812: e8 00 00 00 00 callq 817 <_mesa_Uniform4fv+0x27> 817: 48 83 c4 18 add $0x18,%rsp 81b: c3 retq Saves a measly 416 bytes of text on x64. Depending on exactly when this is applied, a lot of variation is possible due to function alignment. text data bss dec hex filename 6670131 228340 22552 6921023 699b3f lib/i965_dri.so before 6670131 228340 22552 6921023 699b3f lib/i965_dri.so after 6343348 293872 29880 6667100 65bb5c lib64/i965_dri.so before 6342932 293872 29880 6666684 65b9bc lib64/i965_dri.so after There is likely to be no performance change with just this patch. _mesa_uniform immediately calls validate_uniform_parameters with parameters in the "wrong" (different from the call site) order. v2: Rebase on GL_ARB_gpu_shader_fp64. v3: Rebase on GL_ARB_gpu_shader_int64. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa: Arrange _mesa_uniform_matrix parameters to match the call sitesIan Romanick2017-01-261-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By putting the parameters first that match the parameters to the call site, 4 (of 16) instructions are saved at _mesa_UniformMatrix4fv on x64. On IA32, the details of the instructions change, but it is the same count and mix of instructions. Before: 0000000000001380 <_mesa_UniformMatrix4fv>: 1380: 48 83 ec 10 sub $0x10,%rsp 1384: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 138b <_mesa_UniformMatrix4fv+0xb> 138b: 41 89 f8 mov %edi,%r8d 138e: 41 89 f1 mov %esi,%r9d 1391: 0f b6 d2 movzbl %dl,%edx 1394: 64 48 8b 38 mov %fs:(%rax),%rdi 1398: 48 8b b7 c8 01 02 00 mov 0x201c8(%rdi),%rsi 139f: 48 8b 76 70 mov 0x70(%rsi),%rsi 13a3: 68 06 14 00 00 pushq $0x1406 13a8: 51 push %rcx 13a9: 52 push %rdx 13aa: b9 04 00 00 00 mov $0x4,%ecx 13af: ba 04 00 00 00 mov $0x4,%edx 13b4: e8 00 00 00 00 callq 13b9 <_mesa_UniformMatrix4fv+0x39> 13b9: 48 83 c4 28 add $0x28,%rsp 13bd: c3 retq After: 0000000000001360 <_mesa_UniformMatrix4fv>: 1360: 48 83 ec 10 sub $0x10,%rsp 1364: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # 136b <_mesa_UniformMatrix4fv+0xb> 136b: 0f b6 d2 movzbl %dl,%edx 136e: 64 4c 8b 00 mov %fs:(%rax),%r8 1372: 49 8b 80 c8 01 02 00 mov 0x201c8(%r8),%rax 1379: 68 06 14 00 00 pushq $0x1406 137e: 6a 04 pushq $0x4 1380: 6a 04 pushq $0x4 1382: 4c 8b 48 70 mov 0x70(%rax),%r9 1386: e8 00 00 00 00 callq 138b <_mesa_UniformMatrix4fv+0x2b> 138b: 48 83 c4 28 add $0x28,%rsp 138f: c3 retq Saves a measly 576 bytes of text on x64. text data bss dec hex filename 6670131 228340 22552 6921023 699b3f lib/i965_dri.so before 6670131 228340 22552 6921023 699b3f lib/i965_dri.so after 6343924 293872 29880 6667676 65bd9c lib64/i965_dri.so before 6343348 293872 29880 6667100 65bb5c lib64/i965_dri.so after v2: Rebase on GL_ARB_gpu_shader_fp64. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa: Trivial clean-ups in uniform_query.cppIan Romanick2017-01-261-8/+4
| | | | | | | | | This is C++, so we can mix code and declarations. Doing so allows constification. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Plamena Manolova <[email protected]> Reviewed-by: Jordan Justen <[email protected]>
* mesa: use gl_program for CurrentProgram rather than gl_shader_programTimothy Arceri2017-01-231-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes much more sense and should be more performant in some critical paths such as SSO validation which is called at draw time. Previously the CurrentProgram array could have contained multiple pointers to the same struct which was confusing and we would often need to fish out the information we were really after from the gl_program anyway. Also it was error prone to depend on the _LinkedShader array for programs in current use because a failed linking attempt will lose the infomation about the current program in use which is still valid. V2: fix validate_io() to compare linked_stages rather than the consumer and producer to decide if we are looking at inward facing shader interfaces which don't need validation. Acked-by: Edward O'Callaghan <[email protected]> To avoid build regressions the following 2 patches were squashed in to this commit: mesa/meta: rewrite _mesa_shader_program_use() and _mesa_program_use() These are rewritten to do what the function name suggests, that is _mesa_shader_program_use() sets the use of all stage and _mesa_program_use() sets the use of a single stage. Reviewed-by: Lionel Landwerlin <[email protected]> Acked-by: Edward O'Callaghan <[email protected]> mesa: update active relinked program This likely fixes a subroutine bug were _mesa_shader_program_init_subroutine_defaults() would never have been called for the relinked program as we previously just set _NEW_PROGRAM as dirty and never called the _mesa_use* functions when linking. Acked-by: Edward O'Callaghan <[email protected]>
* mesa: Add support for 64-bit integer uniformsDave Airlie2017-01-201-3/+79
| | | | | | | | | | This hooks up the API to the internals for 64-bit integer uniforms. v2: update to use non-strict aliased alternatives Signed-off-by: Dave Airlie <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* st/mesa/glsl: move SamplerTargets to gl_programTimothy Arceri2017-01-061-1/+1
| | | | | | | | This will help allow us to simplify the handling of samplers by storing them in a single location rather than duplicating them in both gl_linked_shader and gl_program. Reviewed-by: Eric Anholt <[email protected]>
* mesa/glsl: set sampler units directly in gl_programTimothy Arceri2017-01-061-5/+3
| | | | | | | Now that we create gl_program earlier there is no need to mess about copying things to gl_linked_shader then to gl_program. Reviewed-by: Eric Anholt <[email protected]>
* mesa: simplify sampler setting codeTimothy Arceri2017-01-061-22/+11
| | | | | | | | There is no need to loop over active samplers the code above this would have already exited if the sampler was inactive, or errored if the count was larger than the uniforms array size. Reviewed-by: Eric Anholt <[email protected]>
* mesa/glsl: set num_textures per stage directly in shader_infoTimothy Arceri2017-01-061-1/+1
| | | | Reviewed-by: Eric Anholt <[email protected]>
* st/mesa/glsl/i965: move ImageUnits and ImageAccess fields to gl_programTimothy Arceri2017-01-061-1/+1
| | | | | | | | | | | | | | | Having it here rather than in gl_linked_shader allows us to simplify the code. Also it is error prone to depend on the gl_linked_shader for programs in current use because a failed linking attempt will free infomation about the current program. In i965 we could be trying to recompile a shader variant but may have lost some required fields. We drop the memset on ImageUnits because gl_program is already created using rzalloc(). Reviewed-by: Lionel Landwerlin <[email protected]>
* st/mesa/glsl/nir/i965: make use of new gl_shader_program_data in ↵Timothy Arceri2016-11-191-4/+4
| | | | | | gl_shader_program Reviewed-by: Emil Velikov <[email protected]>
* mesa: Remove unused hash table includesThomas Helland2016-09-121-1/+0
| | | | | | | This should prevent us from rebuilding the world. Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* mesa: Avoid aliasing violation in uniform_query.cpp.Matt Turner2016-07-261-14/+31
| | | | | Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
* 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 <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>