[Mesa-dev] [PATCH v3] clover: fix getting scalar args api size

Francisco Jerez currojerez at riseup.net
Tue Aug 30 23:33:05 UTC 2016


Serge Martin <edb+mesa at sigluy.net> writes:

> This fix getting the size of a struct arg. vec3 types still work ok.
> Only buit-in args need to have power of two alignment, getTypeAllocSize
> reports the correct size in all cases.
> ---
>
> This v3 is v1.1 modified for the curent ToT

I'm still somewhat skeptical that the result of getTypeAllocSize matches
the expected API size in all cases, but I don't have any better
suggestions for the moment, so patch is:

Acked-by: Francisco Jerez <currojerez at riseup.net>

>
>  src/gallium/state_trackers/clover/llvm/codegen/common.cpp | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
> index 2d52fdc..834b06a 100644
> --- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
> @@ -81,11 +81,10 @@ namespace {
>  
>           // OpenCL 1.2 specification, Ch. 6.1.5: "A built-in data
>           // type that is not a power of two bytes in size must be
> -         // aligned to the next larger power of two".  We need this
> -         // alignment for three element vectors, which have
> -         // non-power-of-2 store size.
> +         // aligned to the next larger power of two.
> +         // This rule applies to built-in types only, not structs or unions."
>           const unsigned arg_store_size = dl.getTypeStoreSize(arg_type);
> -         const unsigned arg_api_size = util_next_power_of_two(arg_store_size);
> +         const unsigned arg_api_size = dl.getTypeAllocSize(arg_type);
>  
>           const auto target_type = !arg_type->isIntegerTy() ? arg_type :
>              dl.getSmallestLegalIntType(mod.getContext(), arg_store_size * 8);
> -- 
> 2.5.5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160830/2958a1ab/attachment.sig>


More information about the mesa-dev mailing list