[Mesa-stable] [PATCH] radeonsi: Fix use of 1- or 2- component GL_DOUBLE vbo's.

Marek Olšák maraeo at gmail.com
Mon Jan 7 19:49:09 UTC 2019


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Mon, Jan 7, 2019 at 1:42 PM Mario Kleiner <mario.kleiner.de at gmail.com>
wrote:

> With Mesa 18.1, commit be973ed21f6e, si_llvm_load_input_vs()
> changed the number of source 32-bit wide dword components
> used for fetching vertex attributes into the vertex shader
> from a constant 4 to a variable num_channels number, depending
> on input data format, with some special case handling for
> input data formats like 64-Bit doubles.
>
> In the case of a GL_DOUBLE input data format with one
> or two components though, e.g, submitted via ...
>
> a) glTexCoordPointer(1, GL_DOUBLE, 0, buffer);
> b) glTexCoordPointer(2, GL_DOUBLE, 0, buffer);
>
> ... the input format would be SI_FIX_FETCH_RG_64_FLOAT,
> but no special case handling was implemented for that
> case, so in the default path the number of 32-bit
> dwords would be set to the number of float input components
> derived from info->input_usage_mask. This ends with corrupted
> input to the vertex shader, because fetching a 64-bit double
> from the vbo requires fetching two 32-bit dwords instead of 1,
> and fetching a two double input requires 4 dword fetches
> instead of 2, so in these cases the vertex shader receives
> incomplete/truncated input data:
>
> a) float v = gl_MultiTexCoord0.x;  -> v.x is corrupted.
> b) vec2  v = gl_MultiTexCoord0.xy; -> v.x is assigned
>    correctly, but v.y is corrupted.
>
> This happens with the standard TGSI IR compiled shaders.
> Under NIR with R600_DEBUG=nir, we got correct behavior
> because the current radeonsi nir code always assigns
> info->input_usage_mask = TGSI_WRITEMASK_XYZW, thereby
> always fetches 4 dwords regardless of what the shader
> actually needs.
>
> Fix this by properly assigning 2 or 4 dword fetches for
> one or two component GL_DOUBLE input.
>
> Fixes: be973ed21f6e ("radeonsi: load the right number of
>        components for VS inputs and TBOs")
>
> Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
> Cc: mesa-stable at lists.freedesktop.org
> Cc: Marek Olšák <marek.olsak at amd.com>
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 190edce..14bb875 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -561,6 +561,14 @@ void si_llvm_load_input_vs(
>
>         /* Do multiple loads for special formats. */
>         switch (fix_fetch) {
> +       case SI_FIX_FETCH_RG_64_FLOAT:
> +               num_fetches = 1; /* 1 2-dword or 4-dword load */
> +               fetch_stride = 0;
> +               if (util_last_bit(info->input_usage_mask[input_index]) >=
> 2)
> +                       num_channels = 4; /* 2 doubles in 4 dwords */
> +               else
> +                       num_channels = 2; /* 1 double in 2 dwords */
> +               break;
>         case SI_FIX_FETCH_RGB_64_FLOAT:
>                 num_fetches = 3; /* 3 2-dword loads */
>                 fetch_stride = 8;
> --
> 2.7.4
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-stable
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-stable/attachments/20190107/e70634d9/attachment.html>


More information about the mesa-stable mailing list