mesa.git
6 years agoradeonsi: track use of bindless samplers/images from tgsi_shader_info
Samuel Pitoiset [Tue, 16 May 2017 10:25:28 +0000 (12:25 +0200)]
radeonsi: track use of bindless samplers/images from tgsi_shader_info

This adds some new helper functions to know if the current draw
call (or dispatch compute) is using bindless samplers/images,
based on TGSI analysis.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: decompress resident textures/images before graphics/compute
Samuel Pitoiset [Mon, 15 May 2017 21:50:32 +0000 (23:50 +0200)]
radeonsi: decompress resident textures/images before graphics/compute

Similar to the existing decompression code path except that it
loops over the list of resident textures/images.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: decompress DCC for resident textures/images
Samuel Pitoiset [Mon, 15 May 2017 21:48:08 +0000 (23:48 +0200)]
radeonsi: decompress DCC for resident textures/images

Analogous to bound textures/images. We should also update the
resident descriptors and disable COMPRESSION_EN for avoiding
useless DCC fetches, but I postpone this optimization for a
separate series.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: only add descriptors in presence of resident handles
Samuel Pitoiset [Thu, 18 May 2017 20:37:25 +0000 (22:37 +0200)]
radeonsi: only add descriptors in presence of resident handles

This won't help much except for applications that use a ton
of resident handles. Though, this will reduce the winsys
overhead a little bit.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: add all resident buffers to the current CS
Samuel Pitoiset [Mon, 15 May 2017 22:55:14 +0000 (00:55 +0200)]
radeonsi: add all resident buffers to the current CS

Resident buffers have to be added to every new command stream.
Though, this could be slightly improved when current shaders
don't use any bindless textures/images but usually applications
tend to use bindless for almost every draw call, and the winsys
thread might help when buffers are added early.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: implement ARB_bindless_texture
Samuel Pitoiset [Tue, 16 May 2017 08:49:20 +0000 (10:49 +0200)]
radeonsi: implement ARB_bindless_texture

This implements the Gallium interface. Decompression of resident
textures/images will follow in the next patches.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: add a slab allocator for bindless descriptors
Samuel Pitoiset [Tue, 16 May 2017 08:11:54 +0000 (10:11 +0200)]
radeonsi: add a slab allocator for bindless descriptors

For each texture/image handles, we need to allocate a new
buffer for the bindless descriptor. But when the number of
buffers added to the current CS becomes high, the overhead
in the winsys (and in the kernel) is important.

To reduce this bottleneck, the idea is to suballocate the
bindless descriptors using a slab similar to the one used
in the winsys.

Currently, a buffer can hold 1024 bindless descriptors but
this limit is arbitrary and could be changed in the future
for some reasons. Once a slab is allocated the "base" buffer
is added to a per-context list.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: add si_set_shader_image_desc() helper
Samuel Pitoiset [Mon, 15 May 2017 23:07:09 +0000 (01:07 +0200)]
radeonsi: add si_set_shader_image_desc() helper

To share some common code between bound and bindless images.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: add si_set_sampler_view_desc() helper
Samuel Pitoiset [Mon, 15 May 2017 23:53:51 +0000 (01:53 +0200)]
radeonsi: add si_set_sampler_view_desc() helper

To share some common code between bound and bindless textures.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoradeonsi: add si_init_descriptor_list() helper
Samuel Pitoiset [Fri, 31 Mar 2017 14:09:24 +0000 (16:09 +0200)]
radeonsi: add si_init_descriptor_list() helper

This will be used in order to initialize resident descriptors
for bindless textures/images.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: enable ARB_bindless_texture
Samuel Pitoiset [Fri, 31 Mar 2017 17:28:00 +0000 (19:28 +0200)]
st/mesa: enable ARB_bindless_texture

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agost/mesa: disable per-context seamless cubemap when using texture handles
Samuel Pitoiset [Fri, 19 May 2017 10:47:16 +0000 (12:47 +0200)]
st/mesa: disable per-context seamless cubemap when using texture handles

The ARB_bindless_texture spec say:

   "If ARB_seamless_cubemap (or OpenGL 4.0, which includes it) is
    supported, the per-context seamless cubemap enable is ignored
    and treated as disabled when using texture handles."

   "If AMD_seamless_cubemap_per_texture is supported, the seamless
    cube map texture parameter of the underlying texture does apply
    when texture handles are used."

The per-context seamless cubemap flag should only be enabled for
bound textures/samplers.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agost/mesa: make bindless samplers/images bound to units resident
Samuel Pitoiset [Mon, 15 May 2017 12:15:40 +0000 (14:15 +0200)]
st/mesa: make bindless samplers/images bound to units resident

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: add infrastructure for storing bound texture/image handles
Samuel Pitoiset [Fri, 12 May 2017 12:15:29 +0000 (14:15 +0200)]
st/mesa: add infrastructure for storing bound texture/image handles

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: add st_create_{texture,image}_handle_from_unit() helper
Samuel Pitoiset [Tue, 9 May 2017 12:32:06 +0000 (14:32 +0200)]
st/mesa: add st_create_{texture,image}_handle_from_unit() helper

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: add st_convert_image_from_unit() helper
Samuel Pitoiset [Fri, 12 May 2017 09:53:51 +0000 (11:53 +0200)]
st/mesa: add st_convert_image_from_unit() helper

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: make convert_sampler_from_unit() non-static
Samuel Pitoiset [Tue, 9 May 2017 12:07:24 +0000 (14:07 +0200)]
st/mesa: make convert_sampler_from_unit() non-static

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: make update_single_texture() non-static
Samuel Pitoiset [Tue, 9 May 2017 11:55:00 +0000 (13:55 +0200)]
st/mesa: make update_single_texture() non-static

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/mesa: implement ARB_bindless_texture
Samuel Pitoiset [Fri, 31 Mar 2017 17:27:41 +0000 (19:27 +0200)]
st/mesa: implement ARB_bindless_texture

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agotgsi/scan: record bindless samplers/images usage
Samuel Pitoiset [Thu, 13 Apr 2017 22:04:05 +0000 (00:04 +0200)]
tgsi/scan: record bindless samplers/images usage

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/glsl_to_tgsi: teach rename_temp_registers() about bindless samplers
Samuel Pitoiset [Fri, 5 May 2017 08:31:27 +0000 (10:31 +0200)]
st/glsl_to_tgsi: teach rename_temp_registers() about bindless samplers

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/glsl_to_tgsi: teach the DCE pass about bindless samplers/images
Samuel Pitoiset [Tue, 28 Mar 2017 23:22:47 +0000 (01:22 +0200)]
st/glsl_to_tgsi: teach the DCE pass about bindless samplers/images

When a texture (or an image) instruction uses a bindless sampler
(respectively a bindless image), make sure the DCE pass won't
remove code when the resource is a temporary variable.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/glsl_to_tgsi: add support for bindless pack/unpack operations
Samuel Pitoiset [Thu, 13 Apr 2017 09:35:03 +0000 (11:35 +0200)]
st/glsl_to_tgsi: add support for bindless pack/unpack operations

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agost/glsl_to_tgsi: add support for bindless images
Samuel Pitoiset [Thu, 13 Apr 2017 09:34:47 +0000 (11:34 +0200)]
st/glsl_to_tgsi: add support for bindless images

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agost/glsl_to_tgsi: add support for bindless samplers
Samuel Pitoiset [Wed, 19 Apr 2017 13:57:56 +0000 (15:57 +0200)]
st/glsl_to_tgsi: add support for bindless samplers

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agotgsi/ureg: accept TGSI_FILE_{CONSTANT,INPUT} for dst registers
Samuel Pitoiset [Thu, 30 Mar 2017 00:01:59 +0000 (02:01 +0200)]
tgsi/ureg: accept TGSI_FILE_{CONSTANT,INPUT} for dst registers

For example, TGSI_OPCODE_STORE for bindless images might use
a constant buffer or a shader input.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agotc: add ARB_bindless_texture support
Samuel Pitoiset [Tue, 16 May 2017 13:00:35 +0000 (15:00 +0200)]
tc: add ARB_bindless_texture support

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agotrace: add ARB_bindless_texture support
Samuel Pitoiset [Thu, 13 Apr 2017 22:54:17 +0000 (00:54 +0200)]
trace: add ARB_bindless_texture support

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoddebug: add ARB_bindless_texture support
Samuel Pitoiset [Fri, 31 Mar 2017 14:32:46 +0000 (16:32 +0200)]
ddebug: add ARB_bindless_texture support

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agogallium: add ARB_bindless_texture interface
Samuel Pitoiset [Tue, 28 Mar 2017 23:34:05 +0000 (01:34 +0200)]
gallium: add ARB_bindless_texture interface

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agogallium: add PIPE_CAP_BINDLESS_TEXTURE
Samuel Pitoiset [Thu, 16 Feb 2017 12:43:16 +0000 (13:43 +0100)]
gallium: add PIPE_CAP_BINDLESS_TEXTURE

Whether bindless texture operations are supported by the
underlying driver.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: fix setting uniform variables for bindless samplers/images
Samuel Pitoiset [Mon, 29 May 2017 20:47:24 +0000 (22:47 +0200)]
mesa: fix setting uniform variables for bindless samplers/images

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 <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: handle bindless uniforms bound to texture/image units
Samuel Pitoiset [Thu, 11 May 2017 16:42:22 +0000 (18:42 +0200)]
mesa: handle bindless uniforms bound to texture/image units

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: associate uniform storage to bindless samplers/images
Samuel Pitoiset [Thu, 11 May 2017 16:23:34 +0000 (18:23 +0200)]
mesa: associate uniform storage to bindless samplers/images

When a bindless sampler/image is bound to a texture/image unit,
we have to overwrite the constant value by the resident handle
directly in the constant buffer before the next draw.

One solution is to keep track of a pointer to the data.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: pass gl_program to _mesa_associate_uniform_storage()
Samuel Pitoiset [Thu, 11 May 2017 09:54:09 +0000 (11:54 +0200)]
mesa: pass gl_program to _mesa_associate_uniform_storage()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: update textures for bindless samplers bound to texture units
Samuel Pitoiset [Thu, 11 May 2017 15:29:53 +0000 (17:29 +0200)]
mesa: update textures for bindless samplers bound to texture units

This is analogous to the existing SamplerUnits and SamplerTargets,
but it loops over bindless samplers bound to texture units.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: add update_single_program_texture_state() helper
Samuel Pitoiset [Wed, 10 May 2017 12:15:33 +0000 (14:15 +0200)]
mesa: add update_single_program_texture_state() helper

This will also be used for looping over bindless samplers bound
to texture units.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: add update_single_shader_texture_used() helper
Samuel Pitoiset [Wed, 10 May 2017 11:24:01 +0000 (13:24 +0200)]
mesa: add update_single_shader_texture_used() helper

This will also be used for looping over bindless samplers bound
to texture units.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoglsl: add ir_variable::contains_bindless()
Samuel Pitoiset [Thu, 4 May 2017 15:34:33 +0000 (17:34 +0200)]
glsl: add ir_variable::contains_bindless()

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoglsl: set the explicit binding value for bindless samplers/images
Samuel Pitoiset [Thu, 11 May 2017 15:37:27 +0000 (17:37 +0200)]
glsl: set the explicit binding value for bindless samplers/images

This handles a situation like:

layout (bindless_sampler, binding = 7) uniform sampler2D;

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoglsl: pass the ir_variable object to set_opaque_binding()
Samuel Pitoiset [Wed, 10 May 2017 13:41:25 +0000 (15:41 +0200)]
glsl: pass the ir_variable object to set_opaque_binding()

In order to set the explicit binding value for bindless
samplers/images.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoglsl: process uniform images declared bindless
Samuel Pitoiset [Fri, 12 May 2017 09:35:43 +0000 (11:35 +0200)]
glsl: process uniform images declared bindless

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoglsl: process uniform samplers declared bindless
Samuel Pitoiset [Thu, 11 May 2017 15:26:49 +0000 (17:26 +0200)]
glsl: process uniform samplers declared bindless

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: add infrastructure for bindless samplers/images bound to units
Samuel Pitoiset [Thu, 11 May 2017 15:29:47 +0000 (17:29 +0200)]
mesa: add infrastructure for bindless samplers/images bound to units

Yes, ARB_bindless_texture allows to do this. In other words, in
a situation like:

layout (bindless_sampler) uniform sampler2D tex;

The 'tex' sampler uniform can be either set with glUniform1()
(old-style bound samplers) or with glUniformHandleui() (resident
handles).

When glUniform1() is used, we have to somehow make the texture
resident "under the hood". This is done by requesting a texture
handle to the driver, making the handle resident in the current
context and overwriting the value directly in the constant buffer.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: store bindless samplers as PROGRAM_UNIFORM
Samuel Pitoiset [Wed, 19 Apr 2017 13:54:32 +0000 (15:54 +0200)]
mesa: store bindless samplers as PROGRAM_UNIFORM

Old-style samplers (ie. bound samplers) are stored as
PROGRAM_SAMPLER, while bindless ones are PROGRAM_UNIFORM.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: keep track of the current variable in add_uniform_to_shader
Samuel Pitoiset [Wed, 19 Apr 2017 13:37:49 +0000 (15:37 +0200)]
mesa: keep track of the current variable in add_uniform_to_shader

Bindless samplers are considered PROGRAM_UNIFORM but
add_uniform_to_shader::visit_field() is based on glsl_type.

Because only ir_variable knows if the uniform variable is
bindless via ir_variable::bindless, store it instead of
adding a new parameter to visit_field().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: refuse to change tex buffers when a handle is allocated
Samuel Pitoiset [Wed, 29 Mar 2017 14:29:24 +0000 (16:29 +0200)]
mesa: refuse to change tex buffers when a handle is allocated

The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by BufferData if it is
    called to modify a buffer object bound to a buffer texture while
    that texture object is referenced by one or more texture handles."

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: refuse to change textures when a handle is allocated
Samuel Pitoiset [Mon, 24 Apr 2017 12:22:24 +0000 (14:22 +0200)]
mesa: refuse to change textures when a handle is allocated

The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by TexImage*, CopyTexImage*,
    CompressedTexImage*, TexBuffer*, TexParameter*, as well as other
    functions defined in terms of these, if the texture object to be
    modified is referenced by one or more texture or image handles."

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: refuse to update tex parameters when a handle is allocated
Samuel Pitoiset [Mon, 24 Apr 2017 12:16:15 +0000 (14:16 +0200)]
mesa: refuse to update tex parameters when a handle is allocated

The ARB_bindless_texture spec says:

   "The ARB_bindless_texture spec says: "The error INVALID_OPERATION
    is generated by TexImage*, CopyTexImage*, CompressedTexImage*,
    TexBuffer*, TexParameter*, as well as other functions defined in
    terms of these, if the texture object to be modified is referenced
    by one or more texture or image handles."

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: refuse to update sampler parameters when a handle is allocated
Samuel Pitoiset [Wed, 22 Feb 2017 22:20:03 +0000 (23:20 +0100)]
mesa: refuse to update sampler parameters when a handle is allocated

The ARB_bindless_texture spec says:

   "The error INVALID_OPERATION is generated by SamplerParameter* if
    <sampler> identifies a sampler object referenced by one or more
    texture handles."

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: add support for glUniformHandleui64*ARB()
Samuel Pitoiset [Fri, 24 Feb 2017 18:24:56 +0000 (19:24 +0100)]
mesa: add support for glUniformHandleui64*ARB()

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 <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: add support for unsigned 64-bit vertex attributes
Samuel Pitoiset [Mon, 3 Apr 2017 20:03:10 +0000 (22:03 +0200)]
mesa: add support for unsigned 64-bit vertex attributes

This adds support in the VBO and array code to handle unsigned
64-bit vertex attributes as specified by ARB_bindless_texture.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: implement ARB_bindless_texture
Samuel Pitoiset [Mon, 3 Apr 2017 20:06:27 +0000 (22:06 +0200)]
mesa: implement ARB_bindless_texture

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa/util: add a hash table wrapper which support 64-bit keys
Samuel Pitoiset [Mon, 12 Jun 2017 14:51:04 +0000 (16:51 +0200)]
mesa/util: add a hash table wrapper which support 64-bit keys

Needed for bindless handles which are represented using
64-bit unsigned integers. All hash table implementations should
be uniformized later on.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomesa: move some hash declarations to hash.h
Samuel Pitoiset [Fri, 9 Jun 2017 11:58:56 +0000 (13:58 +0200)]
mesa: move some hash declarations to hash.h

These will be used by the bindless hash tables to initialize
the default deleted key value.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
6 years agomesa/util: add new util_dynarray_delete_unordered helper
Samuel Pitoiset [Mon, 29 May 2017 15:26:30 +0000 (17:26 +0200)]
mesa/util: add new util_dynarray_delete_unordered helper

This helper function will be used for managing dynamic arrays of
resident texture/image handles.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agomapi: add GL_ARB_bindless_texture entry points
Samuel Pitoiset [Mon, 3 Apr 2017 19:57:34 +0000 (21:57 +0200)]
mapi: add GL_ARB_bindless_texture entry points

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoclover/device: Get device/host unified memory from pipe driver
Aaron Watry [Sat, 3 Jun 2017 02:51:43 +0000 (21:51 -0500)]
clover/device: Get device/host unified memory from pipe driver

clinfo no longer reports my discrete GCN card as unified memory

Signed-off-by: Aaron Watry <awatry@gmail.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
6 years agogallium/radeon: Include the family name in the renderer string if it's not equal...
Henri Verbeet [Mon, 12 Jun 2017 23:39:02 +0000 (01:39 +0200)]
gallium/radeon: Include the family name in the renderer string if it's not equal to the marketing name.

The "family" name is often more informative than the "marketing" name. More
importantly, applications, like for example Wine, may recognise GPUs based on
the existing "family" names.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
6 years agogallium/docs: clarify TGSI_SEMANTIC_SAMPLEMASK, again
Brian Paul [Mon, 12 Jun 2017 17:33:30 +0000 (11:33 -0600)]
gallium/docs: clarify TGSI_SEMANTIC_SAMPLEMASK, again

I've since discovered the fragment shader sample mask system value (which
corresponds to gl_SampleMaskIn).

v2: It's a system value, not a shader input.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agost/mesa: unmap the stream_uploader buffer before drawing
Brian Paul [Sat, 10 Jun 2017 03:21:12 +0000 (21:21 -0600)]
st/mesa: unmap the stream_uploader buffer before drawing

Some drivers require that the vertex buffers be unmapped prior to
drawing.  This change unmaps the stream_uploader buffer after we've
uploaded the zero-stride attributes (unless the driver supports
rendering with mapped buffers).

This fixes a regression in the VMware driver since 17f776c27be266f2.
Some Mesa demos such as mandelbrot and brick would display black
quads instead of the expected rendering.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agogallium/util: whitespace, formatting fixes in u_upload_mgr.c
Brian Paul [Sat, 10 Jun 2017 03:19:51 +0000 (21:19 -0600)]
gallium/util: whitespace, formatting fixes in u_upload_mgr.c

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoegl: improve dri2_fallback_swap_buffers_with_damage()
Eric Engestrom [Sun, 11 Jun 2017 22:09:44 +0000 (23:09 +0100)]
egl: improve dri2_fallback_swap_buffers_with_damage()

Let's (try to) set damages before swapping buffers.

Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
6 years agosoftpipe: Match pipe_context::render_condition prototype.
Jose Fonseca [Tue, 13 Jun 2017 10:52:16 +0000 (11:52 +0100)]
softpipe: Match pipe_context::render_condition prototype.

To silence compiler warnings.  Trivial.

6 years agollvmpipe: Match pipe_context::render_condition prototype.
Jose Fonseca [Tue, 13 Jun 2017 10:52:08 +0000 (11:52 +0100)]
llvmpipe: Match pipe_context::render_condition prototype.

To silence compiler warnings.  Trivial.

6 years agost_glsl_to_tgsi: init index to 0 before get_deref_offsets()
Samuel Pitoiset [Tue, 13 Jun 2017 08:03:52 +0000 (10:03 +0200)]
st_glsl_to_tgsi: init index to 0 before get_deref_offsets()

Fixes: 8ec4975cd83 ("st_glsl_to_tgsi: don't try and pass 32-bit values to get_deref_offsets")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101401
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
6 years agoglsl: simplify an assertion in lower_ubo_reference
Nicolai Hähnle [Mon, 15 May 2017 06:34:24 +0000 (08:34 +0200)]
glsl: simplify an assertion in lower_ubo_reference

Struct types are now equal when they're structurally equal.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: simplify validate_intrastage_arrays
Nicolai Hähnle [Mon, 15 May 2017 06:32:21 +0000 (08:32 +0200)]
glsl: simplify validate_intrastage_arrays

Struct types are now equal when they are structurally equal.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: simplify varying matching
Nicolai Hähnle [Mon, 15 May 2017 06:30:51 +0000 (08:30 +0200)]
glsl: simplify varying matching

Unnamed struct types are now equal if they have the same field.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: remove redundant record_compare check when linking globals
Nicolai Hähnle [Sun, 14 May 2017 18:06:35 +0000 (20:06 +0200)]
glsl: remove redundant record_compare check when linking globals

Unnamed struct types are now equal across stages based on the fields they
contain, so overriding the type to make sure names match has become
unnecessary.

The check was originally introduced in commit 955c93dc089f ("glsl: Match
unnamed record types across stages.")

v2: clarify the commit message

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: stop considering unnamed and named structures equal
Nicolai Hähnle [Sun, 14 May 2017 18:03:10 +0000 (20:03 +0200)]
glsl: stop considering unnamed and named structures equal

Previously, if an unnamed and a named struct contained the same fields,
they were considered the same type during linking of globals.

The discussion around commit e018ea81bf58 ("glsl: Structures must have
same name to be considered same type.") doesn't seem to have considered
this thoroughly, and I see no evidence that an unnamed struct should
ever be considered to be the same type as a named struct.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: give all unnamed structs the same name
Nicolai Hähnle [Fri, 12 May 2017 10:22:45 +0000 (12:22 +0200)]
glsl: give all unnamed structs the same name

As a result, unnamed structs defined in different places of the program
are considered the same types if they have the same fields in the same
order.

This will simplify matching of global variables whose type is an unnamed
struct.

It also fixes a memory leak when the same shader containing unnamed
structs is compiled over and over again: instead of creating a new type
each time, the existing type is re-used.

Finally, this does have the effect that some previously rejected programs
are now accepted, such as:

   struct {
      float a;
   } s1;

   struct {
      float a;
   } s2;

   s2 = s1;

C/C++ do not allow that, but GLSL does seem to want to treat unnamed
structs with the same fields as the same type at least during linking
(and apparently, some applications require it), so it seems odd to treat
them as different types elsewhere.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: do not add unnamed struct types to the symbol table
Nicolai Hähnle [Sun, 14 May 2017 17:59:27 +0000 (19:59 +0200)]
glsl: do not add unnamed struct types to the symbol table

We removed the need for lookups, and we will assign them all the same
name in the future.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: do not lookup struct types by typename
Nicolai Hähnle [Sun, 14 May 2017 17:58:53 +0000 (19:58 +0200)]
glsl: do not lookup struct types by typename

This changes the logic during the conversion of the declaration list

   struct S {
      ...
   } v;

from AST to IR, but should not change the end result.

When assigning the type of v, instead of looking `S' up in the symbol
table, we read the type from the member variable of ast_struct_specifier.

This change is necessary for the subsequent change to how anonymous types
are handled.

v2: remove a type override when redefining a structure; should be
    the same type in that case anyway

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agoglsl: fix a race condition when inserting new types
Nicolai Hähnle [Fri, 12 May 2017 10:37:00 +0000 (12:37 +0200)]
glsl: fix a race condition when inserting new types

By splitting glsl_type::mutex into two, we can avoid dropping the hash
mutex while creating the new type instance (e.g. struct/record,
interface).

This fixes a time-of-check/time-of-use race where two threads would
simultaneously attempt to create the same type but end up with different
instances of glsl_type.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
6 years agost/mesa: skip texture validation logic when nothing has changed
Timothy Arceri [Sat, 10 Jun 2017 04:52:46 +0000 (14:52 +1000)]
st/mesa: skip texture validation logic when nothing has changed

Based on the same logic in the i965 driver 2f225f61451abd51 and
16060c5adcd4.

perf reports st_finalize_texture() going from 0.60% -> 0.16% with
this change when running the Xonotic benchmark from PTS.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
6 years agoac/gpu: drop duplicated code line.
Dave Airlie [Mon, 12 Jun 2017 23:47:00 +0000 (09:47 +1000)]
ac/gpu: drop duplicated code line.

has_hw_decode is assigned twice.

Pointed out by coverity.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agoradv: move assert down in radv_bind_descriptor_set
Dave Airlie [Mon, 12 Jun 2017 23:36:15 +0000 (09:36 +1000)]
radv: move assert down in radv_bind_descriptor_set

coverity complains about the deref before NULL check.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agoradv: return correct error on invalid handle from vkAllocateMemory
Dave Airlie [Mon, 12 Jun 2017 19:48:40 +0000 (05:48 +1000)]
radv: return correct error on invalid handle from vkAllocateMemory

Coverity pointed out this was returning uninitialised.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agost_glsl_to_tgsi: don't try and pass 32-bit values to get_deref_offsets
Dave Airlie [Mon, 12 Jun 2017 19:33:19 +0000 (05:33 +1000)]
st_glsl_to_tgsi: don't try and pass 32-bit values to get_deref_offsets

Just use a temporary 16-bit index.

This fixes coverity issue, pointed to me by Ilia.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agou_dynarray: fix coverity warning about ignoring return value from reralloc
Dave Airlie [Mon, 12 Jun 2017 19:50:18 +0000 (05:50 +1000)]
u_dynarray: fix coverity warning about ignoring return value from reralloc

>>>     Ignoring storage allocated by "reralloc_size(buf->mem_ctx, buf->data, buf->size)" leaks it.

Reviewed-by: Thomas Helland<thomashelland90@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agoglsl/lower_distance: only set max_array_access for 1D clip dist arrays
Dave Airlie [Sun, 11 Jun 2017 23:45:36 +0000 (00:45 +0100)]
glsl/lower_distance: only set max_array_access for 1D clip dist arrays

The max_array_access field applies to the first dimension, which means
we only want to set it for the 1D clip dist arrays.

This fixes an ir_validate assert seen with
KHR-GL44.cull_distance.functional
on nouveau and radeon with debug builds.

Fixes: a08c4ebbe (glsl: rewrite clip/cull distance lowering pass)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Tested-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
6 years agoi965: fix missing break
Lionel Landwerlin [Mon, 12 Jun 2017 09:32:36 +0000 (10:32 +0100)]
i965: fix missing break

Pretty obvious missing break statement.

CID: 1412564
Fixes: 641405f797 "i965: Use the new tracking mechanism for HiZ"
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed by: Elie Tournier <elie.tournier@collabora.com>

6 years agoradeonsi: pack si_context better
Marek Olšák [Fri, 9 Jun 2017 17:59:54 +0000 (19:59 +0200)]
radeonsi: pack si_context better

there isn't much to gain here

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: pack si_framebuffer better
Marek Olšák [Fri, 9 Jun 2017 17:51:36 +0000 (19:51 +0200)]
radeonsi: pack si_framebuffer better

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: pack si_sampler_view better
Marek Olšák [Fri, 9 Jun 2017 17:46:43 +0000 (19:46 +0200)]
radeonsi: pack si_sampler_view better

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: pack si_buffer_resources better
Marek Olšák [Fri, 9 Jun 2017 17:40:44 +0000 (19:40 +0200)]
radeonsi: pack si_buffer_resources better

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: pack struct si_descriptors better
Marek Olšák [Fri, 9 Jun 2017 17:36:13 +0000 (19:36 +0200)]
radeonsi: pack struct si_descriptors better

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: pack struct si_vertex_elements better
Marek Olšák [Fri, 9 Jun 2017 17:32:49 +0000 (19:32 +0200)]
radeonsi: pack struct si_vertex_elements better

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: replace si_vertex_elements::elements with separate fields
Marek Olšák [Fri, 9 Jun 2017 17:29:27 +0000 (19:29 +0200)]
radeonsi: replace si_vertex_elements::elements with separate fields

It makes si_vertex_elements a little smaller.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: rename si_vertex_element -> si_vertex_elements
Marek Olšák [Fri, 9 Jun 2017 17:33:24 +0000 (19:33 +0200)]
radeonsi: rename si_vertex_element -> si_vertex_elements

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: allocate si_state_rasterizer::pm4_poly_offset only when needed
Marek Olšák [Fri, 9 Jun 2017 17:21:18 +0000 (19:21 +0200)]
radeonsi: allocate si_state_rasterizer::pm4_poly_offset only when needed

Each element has over 700 bytes.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: pack si_state_rasterizer fields
Marek Olšák [Fri, 9 Jun 2017 17:17:25 +0000 (19:17 +0200)]
radeonsi: pack si_state_rasterizer fields

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: remove 8 bytes from si_shader_key with uint32_t ff_tcs_inputs_to_copy
Marek Olšák [Fri, 9 Jun 2017 15:26:27 +0000 (17:26 +0200)]
radeonsi: remove 8 bytes from si_shader_key with uint32_t ff_tcs_inputs_to_copy

The previous patch helps with this.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: use uint32_t to declare si_shader_key.opt.kill_outputs
Marek Olšák [Fri, 9 Jun 2017 15:25:29 +0000 (17:25 +0200)]
radeonsi: use uint32_t to declare si_shader_key.opt.kill_outputs

the next patch will benefit from this

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: remove 8 bytes from si_shader_key by flattening opt.hw_vs
Marek Olšák [Fri, 9 Jun 2017 15:15:07 +0000 (17:15 +0200)]
radeonsi: remove 8 bytes from si_shader_key by flattening opt.hw_vs

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: don't emit DB_STENCIL_CONTROL if it has no effect
Marek Olšák [Thu, 8 Jun 2017 00:42:53 +0000 (02:42 +0200)]
radeonsi: don't emit DB_STENCIL_CONTROL if it has no effect

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: fix missing num_L2_invalidates increment
Marek Olšák [Wed, 7 Jun 2017 23:32:51 +0000 (01:32 +0200)]
radeonsi: fix missing num_L2_invalidates increment

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agoradeonsi: get rid of more compressed_colortex_mask names
Marek Olšák [Wed, 7 Jun 2017 20:29:10 +0000 (22:29 +0200)]
radeonsi: get rid of more compressed_colortex_mask names

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
6 years agogallium/noop: fix sampler views
Marek Olšák [Thu, 8 Jun 2017 00:26:28 +0000 (02:26 +0200)]
gallium/noop: fix sampler views

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>