diff options
| author | Norbert Nopper <Norbert.Nopper@freescale.com> | 2015-02-06 20:53:06 +0100 |
|---|---|---|
| committer | Norbert Nopper <Norbert.Nopper@freescale.com> | 2015-02-06 20:53:06 +0100 |
| commit | a51adace2a7b9beae892d47483c98e581bfe8b73 (patch) | |
| tree | a3dd4f224bc361f782671213eaf12f0e00501a22 | |
| parent | 55224df6187bcbbd70a0424b95e3d446111bd8b4 (diff) | |
| parent | 3e32b4dfe595e4d00aa9b2cabc1e9b9a78f1649c (diff) | |
| download | usermoji-a51adace2a7b9beae892d47483c98e581bfe8b73.tar.xz | |
Merge pull request #1 from KhronosGroup/master
Update from head fork.
| -rw-r--r-- | BUILD.md | 72 | ||||
| -rw-r--r-- | README.md | 6 | ||||
| -rwxr-xr-x | glave-generate.py | 53 | ||||
| -rw-r--r-- | layers/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | layers/README.md | 20 | ||||
| -rw-r--r-- | layers/basic.cpp | 1 | ||||
| -rw-r--r-- | loader/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | loader/loader.c | 87 | ||||
| -rw-r--r-- | loader/loader_platform.h | 54 | ||||
| -rwxr-xr-x | update_external_sources.sh | 4 | ||||
| -rwxr-xr-x | xgl-layer-generate.py | 8 | ||||
| -rwxr-xr-x | xgl-win-def-file-generate.py | 2 |
12 files changed, 225 insertions, 105 deletions
@@ -1,17 +1,23 @@ # Build Instructions -This project supports Linux today. -Support for Windows will start in Q1'15. +This project fully supports Linux today. +Support for Windows is for the loader and layers (additional info below). Additional Windows support will be coming in Q1'15. Support for Android is TBD. -##System Requirements -Ubuntu 14.04 LTS, (Ubuntu 14.10 needed for DRI 3 demos) +##Linux System Requirements +Ubuntu 14.10 needed for DRI 3 ``` sudo apt-get install git subversion cmake libgl1-mesa-dev freeglut3-dev libglm-dev libpng12-dev libmagickwand-dev qt5-default sudo apt-get build-dep mesa ``` +Warning: Recent versions of 14.10 have **REMOVED** DRI 3. +Version: 2:2.99.914-1~exp1ubuntu4.1 is known to work. +To see status of this package: +``` +dpkg -s xserver-xorg-video-intel +``` -##Build +##Linux Build The sample driver uses cmake and should work with the usual cmake options and utilities. The standard build process builds the icd, the icd loader and all the tests. @@ -41,7 +47,7 @@ export LIBXGL_LAYERS_PATH=$PWD/layers export LIBXGL_LAYER_NAMES=APIDump:DrawState ``` -##Test +##Linux Test The test executibles can be found in the dbuild/tests directory. The tests use the Google gtest infrastructure. Tests available so far: @@ -52,14 +58,14 @@ gtest infrastructure. Tests available so far: - xgl_render_tests: Render a single triangle with XGL. Triangle will be in a .ppm in the current directory at the end of the test. -##Demos +##Linux Demos The demos executables can be found in the dbuild/demos directory. The demos use DRI 3 to render directly onto window surfaces. - tri: a textured triangle - cube: a textured spinning cube -##Render Nodes +##Linux Render Nodes The render tests depend on access to DRM render nodes. To make that available, a couple of config files need to be created to set a module option @@ -81,4 +87,52 @@ sudo tee /etc/udev/rules.d/drm.rules << EOF SUBSYSTEM=="drm", ACTION=="add", DEVPATH=="/devices/*/renderD*", MODE="020666" EOF ``` - + +##Windows System Requirements + +Windows 7+ with additional, software: + +- Microsoft Visual Studio 2013 Professional. Note: it is possible that lesser/older versions may work, but that has not been tested. +- CMake (from https://www.python.org/downloads). Note: Configure to add itself to the system PATH environment variable. +- Python 3 (from https://www.python.org/downloads). Note: Configure to add itself to the system PATH environment variable. +- Cygwin (especially a BASH shell and git packages--from https://www.cygwin.com/). + +##Windows Build + +Cygwin is used in order to obtain a local copy of the Git repository, and to run the CMake command that creates Visual Studio files. Visual Studio is used to build the software, and will re-run CMake as appropriate. + +Example debug build: +``` +cd GL-Next # cd to the root of the xgl git repository +mkdir _out64 +cd _out64 +cmake -G "Visual Studio 12 Win64" .. +``` + +At this point, you can use Windows Explorer to launch Visual Studio by double-clicking on the "XGL.sln" file in the _out64 folder. Once Visual Studio comes up, you can select "Debug" or "Release" from a drop-down list. You can start a build with either the menu (Build->Build Solution), or a keyboard shortcut (Ctrl+Shift+B). As part of the build process, Python scripts will create additional Visual Studio files and projects, along with additional source files. All of these auto-generated files are under the "_out64" folder. + +To run XGL programs you must have an appropriate icd (installable client driver) that is either installed in the C:\Windows\System32 folder, or pointed to by the +environment variable LIBXGL_DRIVERS_PATH. This environment variable cannot be set with Cygwin, but must be set via Windows, and may require a system restart in order for it to take effect. Here is how to set this environment variable on a Windows 7 system: + +- Launch Control Panel (e.g. Start->Control Panel) +- Within the search box, type "environment variable" and click on "Edit the system environment variables" (or navigate there via "System and Security->System->Advanced system settings"). +- This will launch a window with several tabs, one of which is "Advanced". Click on the "Environment Variables..." button. +- For either "User variables" or "System variables" click "New...". +- Enter "LIBXGL_DRIVERS_PATH" as the variable name, and an appropriate Windows path to where your driver DLL is (e.g. C:\Users\username\GL-Next\_out64\icd\drivername\Debug). + +It is possible to specify multiple icd folders. Simply use a semi-colon (i.e. ";") to separate folders in the environment variable. + +The icd loader searches in all of the folders for files that are named "XGL_*.dll" (e.g. "XGL_foo.dll"). It attempts to dynamically load these files, and look for appropriate functions. + +To enable debug and validation layers with your XGL programs you must tell the icd loader +where to find the layer libraries, and which ones you desire to use. The default folder for layers is C:\Windows\System32. However, you can use the following environment variables to specify alternate locations, and to specify which layers to use: + +- LIBXGL_LAYERS_PATH (semi-colon-delimited set of folders to look for layers) +- LIBXGL_LAYER_NAMES (color-delimited list of layer names) + +For example, to enable the APIDump and DrawState layers, set: + +- "LIBXGL_LAYERS_PATH" to "C:\Users\username\GL-Next\_out64\layers\Debug" +- "LIBXGL_LAYER_NAMES to "APIDump:DrawState" + +The icd loader searches in all of the folders for files that are named "XGLLayer*.dll" (e.g. "XGLLayerParamChecker.dll"). It attempts to dynamically load these files, and look for appropriate functions. @@ -39,6 +39,8 @@ The following components are available: APIDump layer is working with these new API elements.
Glave can trace and replay the cube and tri demos.
Other layers in progress.
+- Warning: Recent versions of 14.10 have **REMOVED** DRI 3.
+ Version: 2:2.99.914-1~exp1ubuntu4.1 is known to work.
## Prior updates
@@ -69,9 +71,7 @@ Information on how to enable the various Debug and Validation layers is in ## References
This version of the components are written based on the following preliminary specs and proposals:
- [**XGL Programers Reference**, 1 Jul 2014](https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/proposals/AMD/Explicit%20GL%20Programming%20Guide%20and%20API%20Reference.pdf)
-- [**BIL**, version 1.0, revision 18](https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/proposals/BIL/Specification/BIL.html)
-- [**IMG's Fixed Function Proposal**, 13 Nov 2014](https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/XGL/accepted/xgl_fixed_function_vertex_fetch_proposal.txt)
-- [**Valve's Loader Proposal**, 7 Oct 2014](https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/proposals/Valve/xglLayers.pptx)
+- [**BIL**, revision 29](https://cvs.khronos.org/svn/repos/oglc/trunk/nextgen/proposals/BIL/Specification/BIL.html)
## License
This work is intended to be released as open source under a BSD-style
diff --git a/glave-generate.py b/glave-generate.py index 263fd3d2..813c9a92 100755 --- a/glave-generate.py +++ b/glave-generate.py @@ -1510,7 +1510,7 @@ class Subcommand(object): 'XGL_MEMORY_ALLOC_INFO* pNext = (XGL_MEMORY_ALLOC_INFO*) pPacket->pAllocInfo->pNext;\n', 'XGL_MEMORY_ALLOC_INFO** ppNext = (XGL_MEMORY_ALLOC_INFO**) &(pPacket->pAllocInfo->pNext);\n', 'while (NULL != pNext)\n', '{\n', - ' *ppNext = (XGL_MEMORY_ALLOC_INFO*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pAllocInfo->pNext);\n', + ' *ppNext = (XGL_MEMORY_ALLOC_INFO*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext);\n', ' pNext = *ppNext;\n', ' switch(pNext->sType)\n', ' {\n', ' case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_BUFFER_INFO:\n', @@ -1741,6 +1741,11 @@ class Subcommand(object): cd_body.append('#endif') cd_body.append(' unsigned int m_windowWidth;') cd_body.append(' unsigned int m_windowHeight;') + cd_body.append(' unsigned int m_frameNumber;') + cd_body.append(' std::vector<uint32_t> imageWidth;') + cd_body.append(' std::vector<uint32_t> imageHeight;') + cd_body.append(' std::vector<XGL_IMAGE> imageHandles;') + cd_body.append(' std::vector<XGL_GPU_MEMORY> imageMemory;') cd_body.append('#if 0') cd_body.append(' XGL_DEVICE m_dev[XGL_MAX_PHYSICAL_GPUS];') cd_body.append(' uint32_t m_gpuCount;') @@ -1854,6 +1859,7 @@ class Subcommand(object): rc_body.append(' char msg[256];') rc_body.append(' };') rc_body.append(' std::vector<struct validationMsg> m_validationMsgs;') + rc_body.append(' std::vector<int> m_screenshotFrames;') rc_body.append(self._map_decl('XGL_GPU_MEMORY', 'XGLAllocInfo', 'm_mapData')) # Custom code for 1-off memory mapping functions rc_body.append(' void add_entry_to_mapData(XGL_GPU_MEMORY handle, XGL_GPU_SIZE size)') @@ -1952,6 +1958,22 @@ class Subcommand(object): rc_body.append(' if ((obj = remap(static_cast <%s> (object))) != XGL_NULL_HANDLE)' % t) rc_body.append(' return obj;') rc_body.append(' return XGL_NULL_HANDLE;\n }') + rc_body.append('void process_screenshot_list(const char *list)') + rc_body.append('{') + rc_body.append(' std::string spec(list), word;') + rc_body.append(' size_t start = 0, comma = 0;\n') + rc_body.append(' while (start < spec.size()) {') + rc_body.append(' comma = spec.find(\',\', start);\n') + rc_body.append(' if (comma == std::string::npos)') + rc_body.append(' word = std::string(spec, start);') + rc_body.append(' else') + rc_body.append(' word = std::string(spec, start, comma - start);\n') + rc_body.append(' m_screenshotFrames.push_back(atoi(word.c_str()));') + rc_body.append(' if (comma == std::string::npos)') + rc_body.append(' break;\n') + rc_body.append(' start = comma + 1;\n') + rc_body.append(' }') + rc_body.append('}') rc_body.append('};') return "\n".join(rc_body) @@ -2203,6 +2225,9 @@ class Subcommand(object): rs_body.append('xglReplay::xglReplay()') rs_body.append('{') rs_body.append(' m_display = new xglDisplay();') + rs_body.append(' if (g_pReplaySettings && g_pReplaySettings->screenshotList) {') + rs_body.append(' process_screenshot_list(g_pReplaySettings->screenshotList);') + rs_body.append(' }') rs_body.append('}\n') rs_body.append('xglReplay::~xglReplay()') rs_body.append('{') @@ -2925,6 +2950,8 @@ class Subcommand(object): cpi_body = [] cpi_body.append(' XGL_IMAGE img;') cpi_body.append(' XGL_GPU_MEMORY mem;') + cpi_body.append(' m_display->imageHeight.push_back(pPacket->pCreateInfo->extent.height);') + cpi_body.append(' m_display->imageWidth.push_back(pPacket->pCreateInfo->extent.width);') cpi_body.append(' replayResult = m_xglFuncs.real_xglWsiX11CreatePresentableImage(remap(pPacket->device), pPacket->pCreateInfo, &img, &mem);') cpi_body.append(' if (replayResult == XGL_SUCCESS)') cpi_body.append(' {') @@ -2932,17 +2959,36 @@ class Subcommand(object): cpi_body.append(' add_to_map(pPacket->pImage, &img);') cpi_body.append(' if(pPacket->pMem != NULL)') cpi_body.append(' add_to_map(pPacket->pMem, &mem);') + cpi_body.append(' m_display->imageHandles.push_back(img);') + cpi_body.append(' m_display->imageMemory.push_back(mem);') cpi_body.append(' }') return "\n".join(cpi_body) def _gen_replay_wsi_queue_present(self): wqp_body = [] wqp_body.append(' XGL_WSI_X11_PRESENT_INFO pInfo;') + wqp_body.append(' std::vector<int>::iterator it;') wqp_body.append(' memcpy(&pInfo, pPacket->pPresentInfo, sizeof(XGL_WSI_X11_PRESENT_INFO));') wqp_body.append(' pInfo.srcImage = remap(pPacket->pPresentInfo->srcImage);') wqp_body.append(' // use replayers Xcb window') wqp_body.append(' pInfo.destWindow = m_display->m_XcbWindow;') wqp_body.append(' replayResult = m_xglFuncs.real_xglWsiX11QueuePresent(remap(pPacket->queue), &pInfo, remap(pPacket->fence));') + wqp_body.append(' it = std::find(m_screenshotFrames.begin(), m_screenshotFrames.end(), m_display->m_frameNumber);') + wqp_body.append(' if (it != m_screenshotFrames.end())') + wqp_body.append(' {') + wqp_body.append(' for(unsigned int i=0; i<m_display->imageHandles.size(); i++)') + wqp_body.append(' {') + wqp_body.append(' if (m_display->imageHandles[i] == pInfo.srcImage)') + wqp_body.append(' {') + wqp_body.append(' char frameName[32];') + wqp_body.append(' sprintf(frameName, "%d",m_display->m_frameNumber);') + wqp_body.append(' glvWritePPM(frameName, m_display->imageWidth[i], m_display->imageHeight[i],') + wqp_body.append(' m_display->imageHandles[i], m_display->imageMemory[i], &m_xglFuncs);') + wqp_body.append(' break;') + wqp_body.append(' }') + wqp_body.append(' }') + wqp_body.append(' }') + wqp_body.append(' m_display->m_frameNumber++;') return "\n".join(wqp_body) # I don't like making these 3 mem functions 'fully' custom, but just doing it for now to avoid being too cute @@ -3372,6 +3418,7 @@ class GlaveReplayHeader(Subcommand): header_txt.append('#include <set>') header_txt.append('#include <map>') header_txt.append('#include <vector>') + header_txt.append('#include <string>') header_txt.append('#include <xcb/xcb.h>\n') header_txt.append('#include "glvreplay_window.h"') header_txt.append('#include "glvreplay_factory.h"') @@ -3393,6 +3440,10 @@ class GlaveReplayC(Subcommand): header_txt = [] header_txt.append('#include "glvreplay_xgl_replay.h"\n') header_txt.append('#include "glvreplay_xgl.h"\n') + header_txt.append('#include "glvreplay_xgl_write_ppm.h"\n') + header_txt.append('#include "glvreplay_main.h"\n') + header_txt.append('#include <algorithm>') + header_txt.append('extern glvreplay_settings *g_pReplaySettings;') header_txt.append('extern "C" {') header_txt.append('#include "glvtrace_xgl_xgl_structs.h"') header_txt.append('#include "glvtrace_xgl_xgldbg_structs.h"') diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index 4693d4e4..38a10e3a 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -38,9 +38,15 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -set (CMAKE_CXX_FLAGS "-std=c++11") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXGL_PROTOTYPES") -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES") +if (WIN32) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXGL_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS") +endif() +if (NOT WIN32) + set (CMAKE_CXX_FLAGS "-std=c++11") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXGL_PROTOTYPES") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES") +endif() add_custom_command(OUTPUT xgl_dispatch_table_helper.h COMMAND ${PROJECT_SOURCE_DIR}/xgl-generate.py dispatch-table-ops layer > xgl_dispatch_table_helper.h diff --git a/layers/README.md b/layers/README.md index 2515fe64..8123ab70 100644 --- a/layers/README.md +++ b/layers/README.md @@ -31,20 +31,24 @@ layer/Multi.cpp (name=multi1:multi2) simple example showing multiple layers per (build dir)/layer/generic_layer.c (name=Generic) - auto generated example wrapping all XGL entrypoints. Single global dispatch table. Can be LD\_PRELOADed. ### Print API Calls and Parameter Values -(build dir)/layer/api_dump.c - print out API calls along with parameter values +(build dir)/layer/api_dump.c (name=APIDump) - print out API calls along with parameter values -(build dir)/layer/api\_dump\_file.c - Write API calls along with parameter values to xgl\_apidump.txt file. +(build dir)/layer/api_dump.cpp (name=APIDumpCpp) - same as above but uses c++ strings and i/o streams -(build dir)/layer/api\_dump\_no\_addr.c - print out API calls along with parameter values but replace any variable addresses with the static string "addr". +(build dir)/layer/api\_dump\_file.c (name=APIDumpFile) - Write API calls along with parameter values to xgl\_apidump.txt file. + +(build dir)/layer/api\_dump\_no\_addr.c (name=APIDumpNoAddr) - print out API calls along with parameter values but replace any variable addresses with the static string "addr". + +(build dir)/layer/api\_dump\_no\_addr.cpp (name=APIDumpNoAddrCpp) - same as above but uses c++ strings and i/o streams ### Print Object Stats -(build dir>/layer/object_track.c - Print object CREATE/USE/DESTROY stats. Individually track objects by category. XGL\_OBJECT\_TYPE enum defined in object_track.h. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. Provides custom interface to query number of live objects of given type "XGL\_UINT64 objTrackGetObjectCount(XGL\_OBJECT\_TYPE type)" and a secondary call to return an array of those objects "XGL\_RESULT objTrackGetObjects(XGL\_OBJECT\_TYPE type, XGL\_UINT64 objCount, OBJTRACK\_NODE* pObjNodeArray)". +(build dir>/layer/object_track.c (name=ObjectTracker) - Print object CREATE/USE/DESTROY stats. Individually track objects by category. XGL\_OBJECT\_TYPE enum defined in object_track.h. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. Provides custom interface to query number of live objects of given type "XGL\_UINT64 objTrackGetObjectCount(XGL\_OBJECT\_TYPE type)" and a secondary call to return an array of those objects "XGL\_RESULT objTrackGetObjects(XGL\_OBJECT\_TYPE type, XGL\_UINT64 objCount, OBJTRACK\_NODE* pObjNodeArray)". ### Report Draw State -layer/draw\_state.c - Report the Descriptor Set, Pipeline State, and dynamic state at each Draw call. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. +layer/draw\_state.c (name=DrawState) - NOTE: This layer is currently non-functional due to a number of changes in xgl.h. When updated, it will report the Descriptor Set, Pipeline State, and dynamic state at each Draw call. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. ### Track GPU Memory -layer/mem\_tracker.c - Track GPU Memory and any binding it has to objects and/or Cmd Buffers. Report issues with freeing memory, memory dependencies on Cmd Buffers, and any memory leaks at DestroyDevice time. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. +layer/mem\_tracker.c (name=MemTracker) - NOTE: This layer is currently non-functional due to a number of changes in xgl.h. When updated, it will track GPU Memory and any binding it has to objects and/or Cmd Buffers. Report issues with freeing memory, memory dependencies on Cmd Buffers, and any memory leaks at DestroyDevice time. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. ### Check parameters <build dir>/layer/param_checker.c (name=ParamChecker) - Check the input parameters to API calls for validity. Currently this only checks ENUM params directly passed to API calls and ENUMs embedded in struct params. If a Dbg callback function is registered, this layer will use callback function(s) for reporting, otherwise uses stdout. @@ -61,7 +65,7 @@ layer/mem\_tracker.c - Track GPU Memory and any binding it has to objects and/or 3. Specify which Layers to activate by using xglCreateDevice XGL\_LAYER\_CREATE\_INFO struct or environment variable LIBXGL\_LAYER\_NAMES - export LIBXGL\_LAYER\_NAMES=Basic:Generic; + export LIBXGL\_LAYER\_NAMES=Basic:Generic cd build/tests; ./xglinfo ## Tips for writing new layers @@ -103,6 +107,8 @@ xglCreateDevice XGL\_LAYER\_CREATE\_INFO struct or environment variable LIBXGL\_ ### Current known issues +- DrawState and MemTracker layers are both non-functional due to updates to xgl.h. Work is ongoing to bring these layers up to latest header. +- Layers with multiple threads are not well tested and some layers likely to have issues. APIDump family of layers should be thread-safe. - layer libraries (except Basic) don't support multiple dispatch tables for multi-gpus; - layer libraries not yet include loader init functionality for full LD\_PRELOAD of entire API including xglInitAndEnumerateGpus; - Since Layers aren't activated until xglCreateDevice, any calls to xglGetExtension() will not report layer extensions unless implemented in the layer; diff --git a/layers/basic.cpp b/layers/basic.cpp index ac8cf803..41abf209 100644 --- a/layers/basic.cpp +++ b/layers/basic.cpp @@ -33,7 +33,6 @@ static std::unordered_map<void *, XGL_LAYER_DISPATCH_TABLE *> tableMap; static XGL_LAYER_DISPATCH_TABLE * initLayerTable(const XGL_BASE_LAYER_OBJECT *gpuw) { - xglGetProcAddrType fpGPA; XGL_LAYER_DISPATCH_TABLE *pTable; assert(gpuw); diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 13a4b5b7..2d2febfe 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -11,13 +11,18 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES") if (WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS") + add_library(XGL SHARED loader.c dirent_on_windows.c dispatch.c table_ops.h) + set_target_properties(XGL PROPERTIES SOVERSION 0) + target_link_libraries(XGL) endif() if (NOT WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXGL_PROTOTYPES") + add_library(XGL SHARED loader.c dispatch.c table_ops.h) + set_target_properties(XGL PROPERTIES SOVERSION 0) + target_link_libraries(XGL -ldl -lpthread) endif() -set_target_properties(XGL PROPERTIES SOVERSION 0) -target_link_libraries(XGL -ldl -lpthread) diff --git a/loader/loader.c b/loader/loader.c index c4cdce02..2ea37e71 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -338,49 +338,6 @@ static void loader_scanned_icd_add(const char *filename) loader.scanned_icd_list = new_node; } -#if defined(WIN32) - -#define PATH_SEPERATOR ';' -#define DIRECTORY_SYMBOL "\\" -#ifndef DEFAULT_XGL_DRIVERS_PATH -// TODO: Is this a good default location? -// Need to search for both 32bit and 64bit ICDs -#define DEFAULT_XGL_DRIVERS_PATH "C:\\Windows\\System32" -// TODO/TBD: Is this an appropriate prefix for Windows? -#define XGL_DRIVER_LIBRARY_PREFIX "XGL_" -#define XGL_DRIVER_LIBRARY_PREFIX_LEN 4 -// TODO/TBD: Is this an appropriate suffix for Windows? -#define XGL_LAYER_LIBRARY_PREFIX "XGLLayer" -#define XGL_LAYER_LIBRARY_PREFIX_LEN 8 -#define XGL_LIBRARY_SUFFIX ".dll" -#define XGL_LIBRARY_SUFFIX_LEN 4 -#endif // DEFAULT_XGL_DRIVERS_PATH -#ifndef DEFAULT_XGL_LAYERS_PATH -// TODO: Is this a good default location? -#define DEFAULT_XGL_LAYERS_PATH "C:\\Windows\\System32" -#endif // DEFAULT_XGL_LAYERS_PATH - -#else // WIN32 - -#define PATH_SEPERATOR ':' -#define DIRECTORY_SYMBOL "/" -#ifndef DEFAULT_XGL_DRIVERS_PATH -// TODO: Is this a good default location? -// Need to search for both 32bit and 64bit ICDs -#define DEFAULT_XGL_DRIVERS_PATH "/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl" -#define XGL_DRIVER_LIBRARY_PREFIX "libXGL_" -#define XGL_DRIVER_LIBRARY_PREFIX_LEN 7 -#define XGL_LAYER_LIBRARY_PREFIX "libXGLLayer" -#define XGL_LAYER_LIBRARY_PREFIX_LEN 11 -#define XGL_LIBRARY_SUFFIX ".so" -#define XGL_LIBRARY_SUFFIX_LEN 3 -#endif // DEFAULT_XGL_DRIVERS_PATH -#ifndef DEFAULT_XGL_LAYERS_PATH -// TODO: Are these good default locations? -#define DEFAULT_XGL_LAYERS_PATH ".:/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl" -#endif - -#endif // WIN32 /** * Try to \c loader_icd_scan XGL driver(s). @@ -399,7 +356,7 @@ static void loader_icd_scan(void) struct dirent *dent; char icd_library[1024]; char path[1024]; - int len; + uint32_t len; libPaths = NULL; #if !defined(WIN32) @@ -416,11 +373,11 @@ static void loader_icd_scan(void) for (p = libPaths; *p; p = next) { next = strchr(p, PATH_SEPERATOR); if (next == NULL) { - len = strlen(p); + len = (uint32_t) strlen(p); next = p + len; } else { - len = next - p; + len = (uint32_t) (next - p); sprintf(path, "%.*s", (len > sizeof(path) - 1) ? (int) sizeof(path) - 1 : len, p); p = path; next++; @@ -438,7 +395,7 @@ static void loader_icd_scan(void) if (!strncmp(dent->d_name, XGL_DRIVER_LIBRARY_PREFIX, XGL_DRIVER_LIBRARY_PREFIX_LEN)) { - int nlen = strlen(dent->d_name); + uint32_t nlen = (uint32_t) strlen(dent->d_name); const char *suf = dent->d_name + nlen - XGL_LIBRARY_SUFFIX_LEN; if ((nlen > XGL_LIBRARY_SUFFIX_LEN) && !strncmp(suf, @@ -465,13 +422,13 @@ static void layer_lib_scan_path(const char * libInPaths) char *libPaths; DIR *curdir; struct dirent *dent; - int len, i; + uint32_t len, i; char temp_str[1024]; len = 0; loader.layer_dirs = NULL; if (libInPaths){ - len = strlen(libInPaths); + len = (uint32_t) strlen(libInPaths); p = libInPaths; } else { @@ -480,14 +437,14 @@ static void layer_lib_scan_path(const char * libInPaths) #endif // WIN32 p = getenv("LIBXGL_LAYERS_PATH"); if (p != NULL) - len = strlen(p); + len = (uint32_t) strlen(p); #if !defined(WIN32) } #endif // WIN32 } if (len == 0) { - len = strlen(DEFAULT_XGL_LAYERS_PATH); + len = (uint32_t) strlen(DEFAULT_XGL_LAYERS_PATH); p = DEFAULT_XGL_LAYERS_PATH; } @@ -514,11 +471,11 @@ static void layer_lib_scan_path(const char * libInPaths) for (p = libPaths; *p; p = next) { next = strchr(p, PATH_SEPERATOR); if (next == NULL) { - len = strlen(p); + len = (uint32_t) strlen(p); next = p + len; } else { - len = next - p; + len = (uint32_t) (next - p); *(char *) next = '\0'; next++; } @@ -533,7 +490,7 @@ static void layer_lib_scan_path(const char * libInPaths) if (!strncmp(dent->d_name, XGL_LAYER_LIBRARY_PREFIX, XGL_LAYER_LIBRARY_PREFIX_LEN)) { - int nlen = strlen(dent->d_name); + uint32_t nlen = (uint32_t) strlen(dent->d_name); const char *suf = dent->d_name + nlen - XGL_LIBRARY_SUFFIX_LEN; if ((nlen > XGL_LIBRARY_SUFFIX_LEN) && !strncmp(suf, @@ -569,7 +526,7 @@ static void layer_lib_scan_path(const char * libInPaths) loader.layer_scanned = true; } -static void layer_lib_scan() +static void layer_lib_scan(void) { layer_lib_scan_path(NULL); } @@ -704,11 +661,11 @@ static uint32_t loader_get_layer_env(struct loader_icd *icd, uint32_t gpu_index, const char *lib_name = NULL; next = strchr(p, PATH_SEPERATOR); if (next == NULL) { - len = strlen(p); + len = (uint32_t) strlen(p); next = p + len; } else { - len = next - p; + len = (uint32_t) (next - p); *(char *) next = '\0'; next++; } @@ -718,7 +675,7 @@ static uint32_t loader_get_layer_env(struct loader_icd *icd, uint32_t gpu_index, continue; } - len = strlen(name); + len = (uint32_t) strlen(name); pLayerNames[count].layer_name = malloc(len + 1); if (!pLayerNames[count].layer_name) { free(pOrig); @@ -757,7 +714,7 @@ static uint32_t loader_get_layer_libs(struct loader_icd *icd, uint32_t gpu_index name = *(pCi->ppActiveLayerNames + i); if (!find_layer_name(icd, gpu_index, name, &lib_name)) return loader_get_layer_env(icd, gpu_index, layerNames); - len = strlen(name); + len = (uint32_t) strlen(name); layerNames[i].layer_name = malloc(len + 1); if (!layerNames[i].layer_name) return i; @@ -1002,7 +959,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus( icd->gpu_count = n; icd->loader_dispatch = (XGL_LAYER_DISPATCH_TABLE *) malloc(n * sizeof(XGL_LAYER_DISPATCH_TABLE)); - for (int i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { (wrapped_gpus + i)->baseObject = gpus[i]; (wrapped_gpus + i)->pGPA = get_proc_addr; (wrapped_gpus + i)->nextObject = gpus[i]; @@ -1063,7 +1020,7 @@ LOADER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char * pN LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) { uint32_t gpu_index; - uint32_t count = 0; + size_t count = 0; char *lib_name; struct loader_icd *icd = loader_get_icd((const XGL_BASE_LAYER_OBJECT *) gpu, &gpu_index); loader_platform_dl_handle handle; @@ -1092,7 +1049,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t loader_platform_close_library(handle); lib_name = basename(lib_name); pEnd = strrchr(lib_name, '.'); - siz = pEnd - lib_name - strlen(XGL_LAYER_LIBRARY_PREFIX) + 1; + siz = (int) (pEnd - lib_name - strlen(XGL_LAYER_LIBRARY_PREFIX) + 1); if (pEnd == NULL || siz <= 0) continue; cpyStr = malloc(siz); @@ -1103,7 +1060,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t strncpy(cpyStr, lib_name + strlen(XGL_LAYER_LIBRARY_PREFIX), siz); cpyStr[siz - 1] = '\0'; if (siz > maxStringSize) - siz = maxStringSize; + siz = (int) maxStringSize; strncpy((char *) (pOutLayers[count]), cpyStr, siz); pOutLayers[count][siz - 1] = '\0'; count++; @@ -1113,14 +1070,14 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t size_t cnt; uint32_t n; XGL_RESULT res; - n = (maxStringSize < 256) ? maxStringSize : 256; + n = (uint32_t) ((maxStringSize < 256) ? maxStringSize : 256); res = fpEnumerateLayers(NULL, 16, n, &cnt, layers, (char *) icd->gpus + gpu_index); loader_platform_close_library(handle); if (res != XGL_SUCCESS) continue; if (cnt + count > maxLayerCount) cnt = maxLayerCount - count; - for (unsigned int i = count; i < cnt + count; i++) { + for (uint32_t i = (uint32_t) count; i < cnt + count; i++) { strncpy((char *) (pOutLayers[i]), (char *) layers[i - count], n); if (n > 0) pOutLayers[i - count][n - 1] = '\0'; diff --git a/loader/loader_platform.h b/loader/loader_platform.h index a9cd4df1..e567700b 100644 --- a/loader/loader_platform.h +++ b/loader/loader_platform.h @@ -42,6 +42,25 @@ #include <pthread.h> #include <assert.h> +// XGL Library Filenames, Paths, etc.: +#define PATH_SEPERATOR ':' +#define DIRECTORY_SYMBOL "/" +#ifndef DEFAULT_XGL_DRIVERS_PATH +// TODO: Is this a good default location? +// Need to search for both 32bit and 64bit ICDs +#define DEFAULT_XGL_DRIVERS_PATH "/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl" +#define XGL_DRIVER_LIBRARY_PREFIX "libXGL_" +#define XGL_DRIVER_LIBRARY_PREFIX_LEN 7 +#define XGL_LAYER_LIBRARY_PREFIX "libXGLLayer" +#define XGL_LAYER_LIBRARY_PREFIX_LEN 11 +#define XGL_LIBRARY_SUFFIX ".so" +#define XGL_LIBRARY_SUFFIX_LEN 3 +#endif // DEFAULT_XGL_DRIVERS_PATH +#ifndef DEFAULT_XGL_LAYERS_PATH +// TODO: Are these good default locations? +#define DEFAULT_XGL_LAYERS_PATH ".:/usr/lib/i386-linux-gnu/xgl:/usr/lib/x86_64-linux-gnu/xgl" +#endif + // C99: #define STATIC_INLINE static inline @@ -124,10 +143,32 @@ static inline void loader_platform_thread_delete_mutex(loader_platform_thread_mu using namespace std; #endif // __cplusplus +// XGL Library Filenames, Paths, etc.: +#define PATH_SEPERATOR ';' +#define DIRECTORY_SYMBOL "\\" +#ifndef DEFAULT_XGL_DRIVERS_PATH +// TODO: Is this a good default location? +// Need to search for both 32bit and 64bit ICDs +#define DEFAULT_XGL_DRIVERS_PATH "C:\\Windows\\System32" +// TODO/TBD: Is this an appropriate prefix for Windows? +#define XGL_DRIVER_LIBRARY_PREFIX "XGL_" +#define XGL_DRIVER_LIBRARY_PREFIX_LEN 4 +// TODO/TBD: Is this an appropriate suffix for Windows? +#define XGL_LAYER_LIBRARY_PREFIX "XGLLayer" +#define XGL_LAYER_LIBRARY_PREFIX_LEN 8 +#define XGL_LIBRARY_SUFFIX ".dll" +#define XGL_LIBRARY_SUFFIX_LEN 4 +#endif // DEFAULT_XGL_DRIVERS_PATH +#ifndef DEFAULT_XGL_LAYERS_PATH +// TODO: Is this a good default location? +#define DEFAULT_XGL_LAYERS_PATH "C:\\Windows\\System32" +#endif // DEFAULT_XGL_LAYERS_PATH + // C99: // Microsoft didn't implement C99 in Visual Studio; but started adding it with // VS2013. However, VS2013 still didn't have snprintf(). The following is a -// work-around. +// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the +// "CMakeLists.txt" file). #define snprintf _snprintf #define STATIC_INLINE static // Microsoft also doesn't have basename(). Paths are different on Windows, and @@ -139,20 +180,21 @@ static char *basename(char *pathname) { char *current, *next; -#define DIRECTORY_SYMBOL '\\' - // TODO/TBD: Do we need to deal with the Windows's ":" character? +#define DIRECTORY_SYMBOL_CHAR '\\' for (current = pathname; *current != '\0'; current = next) { - next = strchr(current, DIRECTORY_SYMBOL); + next = strchr(current, DIRECTORY_SYMBOL_CHAR); if (next == NULL) { - // No more DIRECTORY_SYMBOL's so return p: + // No more DIRECTORY_SYMBOL_CHAR's so return p: return current; } else { - // Point one character past the DIRECTORY_SYMBOL: + // Point one character past the DIRECTORY_SYMBOL_CHAR: next++; } } + // We shouldn't get to here, but this makes the compiler happy: + return current; } // Dynamic Loading: diff --git a/update_external_sources.sh b/update_external_sources.sh index f76d5c60..f5720320 100755 --- a/update_external_sources.sh +++ b/update_external_sources.sh @@ -2,9 +2,9 @@ # Update source for glslang and LLVM # Copy necessary BIL pieces into glslang and LLVM -BIL_REVISION=29595 +BIL_REVISION=29773 LUNARGLASS_REVISION=1060 -GLSLANG_REVISION=29595 +GLSLANG_REVISION=29773 BUILDDIR=$PWD BASEDIR=$BUILDDIR/.. diff --git a/xgl-layer-generate.py b/xgl-layer-generate.py index 299c6757..c81990c5 100755 --- a/xgl-layer-generate.py +++ b/xgl-layer-generate.py @@ -658,7 +658,7 @@ class Subcommand(object): elif 'UnmapMemory' in proto.name: using_line += ' reset_status((void*)mem, XGL_OBJECT_TYPE_GPU_MEMORY, OBJSTATUS_GPU_MEM_MAPPED);\n' if 'AllocDescriptor' in proto.name: # Allocates array of DSs - create_line = ' for (uint32_t i; i < *pCount; i++) {\n' + create_line = ' for (uint32_t i = 0; i < *pCount; i++) {\n' create_line += ' ll_insert_obj((void*)pDescriptorSets[i], XGL_OBJECT_TYPE_DESCRIPTOR_SET);\n' create_line += ' }\n' elif 'Create' in proto.name or 'Alloc' in proto.name: @@ -899,7 +899,7 @@ class Subcommand(object): def _generate_layer_dispatch_table(self, prefix='xgl'): func_body = ["#include \"xgl_dispatch_table_helper.h\""] - func_body.append('static void initLayerTable()\n' + func_body.append('static void initLayerTable(void)\n' '{\n' ' xglGetProcAddrType fpNextGPA;\n' ' fpNextGPA = pCurObj->pGPA;\n' @@ -911,7 +911,7 @@ class Subcommand(object): def _generate_layer_dispatch_table_with_lock(self, prefix='xgl'): func_body = ["#include \"xgl_dispatch_table_helper.h\""] - func_body.append('static void initLayerTable()\n' + func_body.append('static void initLayerTable(void)\n' '{\n' ' xglGetProcAddrType fpNextGPA;\n' ' fpNextGPA = pCurObj->pGPA;\n' @@ -1418,7 +1418,7 @@ class ObjectTrackerSubcommand(Subcommand): header_txt.append('}') header_txt.append('') header_txt.append('static void validate_memory_mapping_status(const XGL_MEMORY_REF* pMemRefs, uint32_t numRefs) {') - header_txt.append(' int32_t i;') + header_txt.append(' uint32_t i;') header_txt.append(' for (i = 0; i < numRefs; i++) {') header_txt.append(' validate_status((void *)pMemRefs[i].mem, XGL_OBJECT_TYPE_GPU_MEMORY, OBJSTATUS_GPU_MEM_MAPPED, OBJSTATUS_NONE, XGL_DBG_MSG_ERROR, OBJTRACK_GPU_MEM_MAPPED, "A Mapped Memory Object was referenced in a command buffer");') header_txt.append(' }') diff --git a/xgl-win-def-file-generate.py b/xgl-win-def-file-generate.py index 56016ee7..9d66caec 100755 --- a/xgl-win-def-file-generate.py +++ b/xgl-win-def-file-generate.py @@ -94,7 +94,7 @@ class Subcommand(object): pass def generate_body(self): - return "LIBRARY " + sys.argv[1] + return "LIBRARY XGLLayer" + sys.argv[1] def generate_footer(self): return "EXPORTS\n xglGetProcAddr\n xglEnumerateLayers" |
