swr/rast: Moved memory init out of core swr init
authorAlok Hota <alok.hota@intel.com>
Fri, 25 May 2018 15:19:48 +0000 (10:19 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Fri, 25 May 2018 15:56:55 +0000 (10:56 -0500)
Added two new files for a wrapper function for initialization

v2: added missing include for single architecture builds

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/Makefile.sources
src/gallium/drivers/swr/meson.build
src/gallium/drivers/swr/rasterizer/core/api.cpp
src/gallium/drivers/swr/rasterizer/core/state.h
src/gallium/drivers/swr/rasterizer/memory/InitMemory.cpp [new file with mode: 0644]
src/gallium/drivers/swr/rasterizer/memory/InitMemory.h [new file with mode: 0644]
src/gallium/drivers/swr/swr_loader.cpp

index 6753d50..b298356 100644 (file)
@@ -177,4 +177,6 @@ MEMORY_CXX_SOURCES := \
        rasterizer/memory/StoreTile_TileY2.cpp \
        rasterizer/memory/StoreTile_TileY.cpp \
        rasterizer/memory/TilingFunctions.h \
-       rasterizer/memory/tilingtraits.h
+       rasterizer/memory/tilingtraits.h \
+       rasterizer/memory/InitMemory.cpp \
+       rasterizer/memory/InitMemory.h
index 9b272aa..b95c8bc 100644 (file)
@@ -151,6 +151,8 @@ files_swr_arch = files(
   'rasterizer/memory/StoreTile_TileY.cpp',
   'rasterizer/memory/TilingFunctions.h',
   'rasterizer/memory/tilingtraits.h',
+  'rasterizer/memory/InitMemory.h',
+  'rasterizer/memory/InitMemory.cpp',
 )
 
 swr_context_files = files('swr_context.h')
index 47f3633..c932ec0 100644 (file)
@@ -1728,10 +1728,6 @@ void InitBackendFuncTables();
 /// @brief Initialize swr backend and memory internal tables
 void SwrInit()
 {
-    InitSimLoadTilesTable();
-    InitSimStoreTilesTable();
-    InitSimClearTilesTable();
-
     InitClearTilesTable();
     InitBackendFuncTables();
     InitRasterizerFunctions();
index c26dabe..9db17ee 100644 (file)
 
 #include "common/formats.h"
 #include "common/intrin.h"
-using gfxptr_t = unsigned long long;
 #include <functional>
 #include <algorithm>
 
+using gfxptr_t = unsigned long long;
+
 //////////////////////////////////////////////////////////////////////////
 /// PRIMITIVE_TOPOLOGY.
 //////////////////////////////////////////////////////////////////////////
diff --git a/src/gallium/drivers/swr/rasterizer/memory/InitMemory.cpp b/src/gallium/drivers/swr/rasterizer/memory/InitMemory.cpp
new file mode 100644 (file)
index 0000000..bff96e1
--- /dev/null
@@ -0,0 +1,39 @@
+/****************************************************************************
+* Copyright (C) 2018 Intel Corporation.   All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+* IN THE SOFTWARE.
+*
+* @file InitMemory.cpp
+*
+* @brief Provide access to tiles table initialization functions
+*
+******************************************************************************/
+#include "memory/InitMemory.h"
+
+void InitSimLoadTilesTable();
+void InitSimStoreTilesTable();
+void InitSimClearTilesTable();
+
+void InitTilesTable()
+{
+    InitSimLoadTilesTable();
+    InitSimStoreTilesTable();
+    InitSimClearTilesTable();
+}
diff --git a/src/gallium/drivers/swr/rasterizer/memory/InitMemory.h b/src/gallium/drivers/swr/rasterizer/memory/InitMemory.h
new file mode 100644 (file)
index 0000000..14cca6a
--- /dev/null
@@ -0,0 +1,33 @@
+/****************************************************************************
+* Copyright (C) 2018 Intel Corporation.   All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+* IN THE SOFTWARE.
+*
+* @file InitMemory.h
+*
+* @brief Provide access to tiles table initialization functions
+*
+******************************************************************************/
+#include "common/os.h"
+
+extern "C"
+{
+    SWR_VISIBLE void SWR_API InitTilesTable();
+}
index 01b9804..c5b2e29 100644 (file)
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  ***************************************************************************/
 
+#include "memory/InitMemory.h"
 #include "util/u_cpu_detect.h"
 #include "util/u_dl.h"
 #include "swr_public.h"
@@ -35,6 +36,7 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
 #ifdef HAVE_SWR_BUILTIN
    screen->pLibrary = NULL;
    screen->pfnSwrGetInterface = SwrGetInterface;
+   InitTilesTable();
    fprintf(stderr, "(using: builtin).\n");
 #else
    char filename[256] = { 0 };
@@ -48,7 +50,9 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
 
    util_dl_proc pApiProc = util_dl_get_proc_address(screen->pLibrary,
       "SwrGetInterface");
-   if (!pApiProc) {
+   util_dl_proc pInitFunc = util_dl_get_proc_address(screen->pLibrary,
+      "InitTilesTable");
+   if (!pApiProc || !pInitFunc) {
       fprintf(stderr, "(skipping: %s).\n", util_dl_error());
       util_dl_close(screen->pLibrary);
       screen->pLibrary = NULL;
@@ -56,6 +60,8 @@ swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
    }
 
    screen->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc;
+   pInitFunc();
+
    fprintf(stderr, "(using: %s).\n", filename);
 #endif
    return true;