[Mesa-stable] [Mesa-dev] [PATCH] swr/rast: [rasterizer core] fix invalid casting for calls to Interlocked* functions

Cherniak, Bruce bruce.cherniak at intel.com
Mon Aug 14 16:40:18 UTC 2017


Reviewed-by: Bruce Cherniak <bruce.cherniak at intel.com>

> On Aug 9, 2017, at 5:22 PM, Tim Rowley <timothy.o.rowley at intel.com> wrote:
> 
> CID: 1416243, 1416244, 1416255
> CC: mesa-stable at lists.freedesktop.org
> ---
> src/gallium/drivers/swr/rasterizer/core/api.cpp     | 2 +-
> src/gallium/drivers/swr/rasterizer/core/context.h   | 8 ++++----
> src/gallium/drivers/swr/rasterizer/core/threads.cpp | 4 ++--
> 3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
> index 8dc9ac2..ccb6dfb 100644
> --- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
> +++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
> @@ -189,7 +189,7 @@ void QueueWork(SWR_CONTEXT *pContext)
> 
>     if (IsDraw)
>     {
> -        InterlockedIncrement((volatile long*)&pContext->drawsOutstandingFE);
> +        InterlockedIncrement(&pContext->drawsOutstandingFE);
>     }
> 
>     _ReadWriteBarrier();
> diff --git a/src/gallium/drivers/swr/rasterizer/core/context.h b/src/gallium/drivers/swr/rasterizer/core/context.h
> index 131b3cb..bcd5801 100644
> --- a/src/gallium/drivers/swr/rasterizer/core/context.h
> +++ b/src/gallium/drivers/swr/rasterizer/core/context.h
> @@ -409,12 +409,12 @@ struct DRAW_CONTEXT
>     bool            dependent;      // Backend work is dependent on all previous BE
>     bool            isCompute;      // Is this DC a compute context?
>     bool            cleanupState;   // True if this is the last draw using an entry in the state ring.
> -    volatile bool   doneFE;         // Is FE work done for this draw?
> 
>     FE_WORK         FeWork;
> 
> +    volatile OSALIGNLINE(bool)       doneFE;         // Is FE work done for this draw?
>     volatile OSALIGNLINE(uint32_t)   FeLock;
> -    volatile int32_t    threadsDone;
> +    volatile OSALIGNLINE(uint32_t)   threadsDone;
> 
>     SYNC_DESC       retireCallback; // Call this func when this DC is retired.
> };
> @@ -503,9 +503,9 @@ struct SWR_CONTEXT
>     // Scratch space for workers.
>     uint8_t** ppScratch;
> 
> -    volatile int32_t  drawsOutstandingFE;
> +    volatile OSALIGNLINE(uint32_t)  drawsOutstandingFE;
> 
> -    CachingAllocator cachingArenaAllocator;
> +    OSALIGNLINE(CachingAllocator) cachingArenaAllocator;
>     uint32_t frameCount;
> 
>     uint32_t lastFrameChecked;
> diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
> index 70bde02..b704d23 100644
> --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp
> +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp
> @@ -393,7 +393,7 @@ INLINE void ExecuteCallbacks(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONT
> // inlined-only version
> INLINE int32_t CompleteDrawContextInl(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEXT* pDC)
> {
> -    int32_t result = InterlockedDecrement((volatile long*)&pDC->threadsDone);
> +    int32_t result = static_cast<int32_t>(InterlockedDecrement(&pDC->threadsDone));
>     SWR_ASSERT(result >= 0);
> 
>     AR_FLUSH(pDC->drawId);
> @@ -639,7 +639,7 @@ INLINE void CompleteDrawFE(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEX
>     _mm_mfence();
>     pDC->doneFE = true;
> 
> -    InterlockedDecrement((volatile long*)&pContext->drawsOutstandingFE);
> +    InterlockedDecrement(&pContext->drawsOutstandingFE);
> }
> 
> void WorkOnFifoFE(SWR_CONTEXT *pContext, uint32_t workerId, uint32_t &curDrawFE)
> -- 
> 2.7.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-stable mailing list