panfrost: Resolve alignment issue on 32-bit

Submitted by Alyssa Rosenzweig on Feb. 11, 2019, 3:17 a.m.

Details

Message ID 20190211031715.3597-1-alyssa@rosenzweig.io
State New
Headers show
Series "panfrost: Resolve alignment issue on 32-bit" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Alyssa Rosenzweig Feb. 11, 2019, 3:17 a.m.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
---
 src/gallium/drivers/panfrost/pan_blending.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/panfrost/pan_blending.c b/src/gallium/drivers/panfrost/pan_blending.c
index 058fb6bda84..a19d048123b 100644
--- a/src/gallium/drivers/panfrost/pan_blending.c
+++ b/src/gallium/drivers/panfrost/pan_blending.c
@@ -333,9 +333,10 @@  panfrost_make_constant(unsigned *factors, unsigned num_factors, const struct pip
                 }
         }
 
-        /* We have the constant -- success! */
+        /* We have the constant -- success! Copy it in indirectly (to prevent
+         * alignment issues on some platforms) */
 
-        *out = constant;
+        memcpy(out, &constant, sizeof(float));
         return true;
 }
 

Comments

Alyssa Rosenzweig <alyssa@rosenzweig.io> writes:

> Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
> ---
>  src/gallium/drivers/panfrost/pan_blending.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/panfrost/pan_blending.c b/src/gallium/drivers/panfrost/pan_blending.c
> index 058fb6bda84..a19d048123b 100644
> --- a/src/gallium/drivers/panfrost/pan_blending.c
> +++ b/src/gallium/drivers/panfrost/pan_blending.c
> @@ -333,9 +333,10 @@ panfrost_make_constant(unsigned *factors, unsigned num_factors, const struct pip
>                  }
>          }
>  
> -        /* We have the constant -- success! */
> +        /* We have the constant -- success! Copy it in indirectly (to prevent
> +         * alignment issues on some platforms) */
>  
> -        *out = constant;
> +        memcpy(out, &constant, sizeof(float));
>          return true;

You've got a float *out that's unaligned?  I would recommend a void
pointer if you're breaking the alignment rules.
> You've got a float *out that's unaligned?  I would recommend a void
> pointer if you're breaking the alignment rules.

Fixed in the (much more comprehensive) "backport to T760" patchset,
thank you :)

-A