[Mesa-dev] [PATCH v2 09/11] swr: [rasterizer] Small cleanups

Tim Rowley timothy.o.rowley at intel.com
Fri Apr 22 00:37:47 UTC 2016


---
 .../drivers/swr/rasterizer/core/frontend.cpp       |  3 ++-
 src/gallium/drivers/swr/rasterizer/core/frontend.h |  2 +-
 src/gallium/drivers/swr/rasterizer/core/utils.cpp  | 31 +++++++++++++++-------
 src/gallium/drivers/swr/rasterizer/core/utils.h    |  3 ++-
 .../drivers/swr/rasterizer/jitter/JitManager.cpp   |  6 -----
 .../drivers/swr/rasterizer/jitter/jit_api.h        |  3 +++
 .../drivers/swr/rasterizer/memory/StoreTile.cpp    |  1 -
 7 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
index 5dcd05b..e6c77d8 100644
--- a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
@@ -39,6 +39,7 @@
 #include "clip.h"
 #include "tilemgr.h"
 #include "tessellator.h"
+#include <limits>
 
 //////////////////////////////////////////////////////////////////////////
 /// @brief Helper macro to generate a bitmask
@@ -1847,7 +1848,7 @@ void BinTriangles(
                 }
             }
         }
-
+nextPrimitive:
         triMask &= ~(1 << triIndex);
     }
 
diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.h b/src/gallium/drivers/swr/rasterizer/core/frontend.h
index b637785..e1b0400 100644
--- a/src/gallium/drivers/swr/rasterizer/core/frontend.h
+++ b/src/gallium/drivers/swr/rasterizer/core/frontend.h
@@ -308,7 +308,7 @@ bool CanUseSimplePoints(DRAW_CONTEXT *pDC)
 }
 
 INLINE
-bool vIsNaN(const __m128& vec)
+bool vHasNaN(const __m128& vec)
 {
     const __m128 result = _mm_cmpunord_ps(vec, vec);
     const int32_t mask = _mm_movemask_ps(result);
diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.cpp b/src/gallium/drivers/swr/rasterizer/core/utils.cpp
index a1d665e..97b631b 100644
--- a/src/gallium/drivers/swr/rasterizer/core/utils.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/utils.cpp
@@ -74,7 +74,8 @@ void SaveImageToPNGFile(
     const WCHAR *pFilename,
     void *pBuffer,
     uint32_t width,
-    uint32_t height)
+    uint32_t height,
+    bool broadcastRed = false)
 {
     // dump pixels to a png
     // Initialize GDI+.
@@ -84,23 +85,33 @@ void SaveImageToPNGFile(
 
     Bitmap *bitmap = new Bitmap(width, height);
     BYTE *pBytes = (BYTE*)pBuffer;
-    static const uint32_t bytesPerPixel = 4;
+    const uint32_t bytesPerPixel = (broadcastRed ? 1 : 4);
     for (uint32_t y = 0; y < height; ++y)
         for (uint32_t x = 0; x < width; ++x)
         {
-            uint32_t pixel = *(uint32_t*)pBytes;
-            if (pixel == 0xcdcdcdcd)
+            uint32_t pixel = 0;
+            if (broadcastRed)
             {
-                pixel = 0xFFFF00FF;
-            }
-            else if (pixel == 0xdddddddd)
-            {
-                pixel = 0x80FF0000;
+                pixel = *(uint8_t*)pBytes;
+                pixel = pixel | (pixel << 8) | (pixel << 16) | 0xFF000000;
             }
             else
             {
-                pixel |= 0xFF000000;
+                pixel = *(uint32_t*)pBytes;
+                if (pixel == 0xcdcdcdcd)
+                {
+                    pixel = 0xFFFF00FF;
+                }
+                else if (pixel == 0xdddddddd)
+                {
+                    pixel = 0x80FF0000;
+                }
+                else
+                {
+                    pixel |= 0xFF000000;
+                }
             }
+
             Color color(pixel);
             bitmap->SetPixel(x, y, color);
             pBytes += bytesPerPixel;
diff --git a/src/gallium/drivers/swr/rasterizer/core/utils.h b/src/gallium/drivers/swr/rasterizer/core/utils.h
index 63ecd5c..e3c534d 100644
--- a/src/gallium/drivers/swr/rasterizer/core/utils.h
+++ b/src/gallium/drivers/swr/rasterizer/core/utils.h
@@ -38,7 +38,8 @@ void SaveImageToPNGFile(
     const WCHAR *pFilename,
     void *pBuffer,
     uint32_t width,
-    uint32_t height);
+    uint32_t height,
+    bool broadcastRed);
 
 void OpenBitmapFromFile(
     const WCHAR *pFilename,
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
index de856c4..271c196 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
@@ -197,12 +197,6 @@ JitManager::JitManager(uint32_t simdWidth, const char *arch)
         CreateDirectory(SWR_OUTPUT_DIR, NULL);
         CreateDirectory(JITTER_OUTPUT_DIR, NULL);
     }
-
-    ///@todo Figure out a better solution for this.
-    // Redirect stdin, stdout, and stderr to attached console.
-    freopen("CONIN$", "r", stdin);
-    freopen("CONOUT$", "w", stdout);
-    freopen("CONOUT$", "w", stderr);
 #endif
 }
 
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/jit_api.h b/src/gallium/drivers/swr/rasterizer/jitter/jit_api.h
index 39d6383..b668eb4 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/jit_api.h
+++ b/src/gallium/drivers/swr/rasterizer/jitter/jit_api.h
@@ -34,6 +34,8 @@
 #include "streamout_jit.h"
 #include "blend_jit.h"
 
+#include <stdlib.h>
+
 #if defined(_WIN32)
 #define EXCEPTION_PRINT_STACK(ret) ret
 #endif // _WIN32
@@ -61,6 +63,7 @@ struct JIT_COMPILE_INPUT
     bool enableJitSampler;
 };
 
+
 //////////////////////////////////////////////////////////////////////////
 /// @brief Create JIT context.
 HANDLE JITCALL JitCreateContext(uint32_t targetSimdWidth, const char* arch);
diff --git a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.cpp b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.cpp
index 9ed1d0b..419f28b 100644
--- a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.cpp
+++ b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.cpp
@@ -1694,7 +1694,6 @@ template <SWR_TILE_MODE TileModeT, size_t NumTileModes, size_t ArraySizeT>
 void InitStoreTilesTableStencil(
     PFN_STORE_TILES(&table)[NumTileModes][ArraySizeT])
 {
-    table[TileModeT][R32_UINT]                  = StoreMacroTile<TilingTraits<TileModeT, 32>, R8_UINT, R32_UINT>::Store;
     table[TileModeT][R8_UINT]                   = StoreMacroTile<TilingTraits<TileModeT, 8>, R8_UINT, R8_UINT>::Store;
 }
 
-- 
1.9.1



More information about the mesa-dev mailing list