[Mesa-dev] [PATCH v3 12/18] mesa/macros: move ALIGN_NPOT to macros.h

Nanley Chery nanleychery at gmail.com
Thu Jun 25 15:32:47 PDT 2015


On Wed, Jun 24, 2015 at 3:43 PM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> On Mon, Jun 22, 2015 at 4:02 PM, Nanley Chery <nanleychery at gmail.com> wrote:
>> From: Nanley Chery <nanley.g.chery at intel.com>
>>
>> Aligning with a non-power-of-two number is a general task that can be used in
>> various places. This commit is required for the next one.
>>
>> Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
>> ---
>>  src/mesa/drivers/dri/i965/intel_upload.c | 6 ------
>>  src/mesa/main/macros.h                   | 6 ++++++
>>  2 files changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_upload.c b/src/mesa/drivers/dri/i965/intel_upload.c
>> index 870aabc..deaae6c 100644
>> --- a/src/mesa/drivers/dri/i965/intel_upload.c
>> +++ b/src/mesa/drivers/dri/i965/intel_upload.c
>> @@ -44,12 +44,6 @@
>>
>>  #define INTEL_UPLOAD_SIZE (64*1024)
>>
>> -/**
>> - * Like ALIGN(), but works with a non-power-of-two alignment.
>> - */
>> -#define ALIGN_NPOT(value, alignment) \
>> -   (((value) + (alignment) - 1) / (alignment) * (alignment))
>> -
>>  void
>>  intel_upload_finish(struct brw_context *brw)
>>  {
>> diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
>> index 4a640ad..4a08130 100644
>> --- a/src/mesa/main/macros.h
>> +++ b/src/mesa/main/macros.h
>> @@ -708,6 +708,12 @@ ALIGN(uintptr_t value, uintptr_t alignment)
>>  }
>>
>>  /**
>> + * Like ALIGN(), but works with a non-power-of-two alignment.
>> + */
>> +#define ALIGN_NPOT(value, alignment) \
>> +   (((value) + (alignment) - 1) / (alignment) * (alignment))
>> +
>> +/**
> Add an assert for the 0 alignment?
>
Good catch Anuj. I will convert the macro to a static inline function
in order to include this assertion.

Thanks,
Nanley
>>   * Align a value down to an alignment value
>>   *
>>   * If \c value is not already aligned to the requested alignment value, it
>> --
>> 2.4.2
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
> R


More information about the mesa-dev mailing list