swr: [rasterizer] Misc fixes identified by static code analysis
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 24 Mar 2016 21:52:11 +0000 (15:52 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Tue, 12 Apr 2016 16:52:04 +0000 (11:52 -0500)
No perf loss detected

Acked-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/swr/rasterizer/core/frontend.cpp
src/gallium/drivers/swr/rasterizer/core/pa.h
src/gallium/drivers/swr/rasterizer/core/threads.cpp
src/gallium/drivers/swr/rasterizer/core/tilemgr.h

index 36721e00bebf0a2c92a0b1469aab2f7912733241..93869610ff9e5be4b29f03e5e883846c05eac4c6 100644 (file)
@@ -793,8 +793,14 @@ static void GeometryShaderStage(
             uint8_t* pCutBase = pCutBufferBase + instance * cutInstanceStride;
             
             DWORD numAttribs;
-            _BitScanReverse(&numAttribs, state.feAttribMask);
-            numAttribs++;
+            if (_BitScanReverse(&numAttribs, state.feAttribMask))
+            {
+                numAttribs++;
+            }
+            else
+            {
+                numAttribs = 0;
+            }
 
             for (uint32_t stream = 0; stream < MAX_SO_STREAMS; ++stream)
             {
index f8f1a33b7e3612730d1969537760f1d637143641..4fd6dd08f82b809641fdd853fa6d0b27237c914b 100644 (file)
@@ -1167,8 +1167,14 @@ struct PA_FACTORY
         {
             memset(&indexStore, 0, sizeof(indexStore));
             DWORD numAttribs;
-            _BitScanReverse(&numAttribs, state.feAttribMask);
-            numAttribs++;
+            if (_BitScanReverse(&numAttribs, state.feAttribMask))
+            {
+                numAttribs++;
+            }
+            else
+            {
+                numAttribs = 0;
+            }
             new (&this->paCut) PA_STATE_CUT(pDC, (uint8_t*)&this->vertexStore[0], MAX_NUM_VERTS_PER_PRIM * KNOB_SIMD_WIDTH, 
                 &this->indexStore[0], numVerts, numAttribs, state.topology, false);
             cutPA = true;
index 07bc94a1a544656aacd078b201d15b11a450aa29..1a11175cfd4e785364420d478ac8314d88b079e1 100644 (file)
@@ -68,7 +68,10 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread
 
 #if defined(_WIN32)
 
-    SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer[KNOB_MAX_NUM_THREADS];
+    static std::mutex m;
+    std::lock_guard<std::mutex> l(m);
+
+    static SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer[KNOB_MAX_NUM_THREADS];
     DWORD bufSize = sizeof(buffer);
 
     BOOL ret = GetLogicalProcessorInformationEx(RelationProcessorCore, buffer, &bufSize);
index aa561badc1c770da1cb3d05e9076eb78076d577c..34992aaea75b8213cf2de37d3a4f0b31c208dc66 100644 (file)
@@ -272,7 +272,7 @@ class HotTileMgr
 public:
     HotTileMgr()
     {
-        memset(&mHotTiles[0][0], 0, sizeof(mHotTiles));
+        memset(mHotTiles, 0, sizeof(mHotTiles));
 
         // cache hottile size
         for (uint32_t i = SWR_ATTACHMENT_COLOR0; i <= SWR_ATTACHMENT_COLOR7; ++i)