├── .clang-format
├── .travis.yml
├── CMakeLists.txt
├── LICENSE
├── README.md
├── appveyor.yml
└── spirv-stats.cpp
/.clang-format:
--------------------------------------------------------------------------------
1 | Standard: Cpp03
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: cpp
2 |
3 | os:
4 | - linux
5 | - osx
6 |
7 | compiler:
8 | - gcc
9 | - clang
10 |
11 | env:
12 | - CONFIGURATION=Debug
13 | - CONFIGURATION=Release
14 |
15 | script:
16 | - mkdir build
17 | - cd build
18 | - cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION ..
19 | - make
20 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This is free and unencumbered software released into the public domain.
2 | #
3 | # Anyone is free to copy, modify, publish, use, compile, sell, or
4 | # distribute this software, either in source code form or as a compiled
5 | # binary, for any purpose, commercial or non-commercial, and by any
6 | # means.
7 | #
8 | # In jurisdictions that recognize copyright laws, the author or authors
9 | # of this software dedicate any and all copyright interest in the
10 | # software to the public domain. We make this dedication for the benefit
11 | # of the public at large and to the detriment of our heirs and
12 | # successors. We intend this dedication to be an overt act of
13 | # relinquishment in perpetuity of all present and future rights to this
14 | # software under copyright law.
15 | #
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | # OTHER DEALINGS IN THE SOFTWARE.
23 | #
24 | # For more information, please refer to
25 |
26 | project(spirv-stats)
27 | cmake_minimum_required(VERSION 2.8.7)
28 |
29 | add_executable(spirv-stats
30 | spirv-stats.cpp
31 | )
32 |
33 | if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
34 | set_source_files_properties(spirv-stats.cpp PROPERTIES
35 | COMPILE_FLAGS "-Wall -Wextra -Werror"
36 | )
37 | elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
38 | set_source_files_properties(spirv-stats.cpp PROPERTIES
39 | COMPILE_FLAGS "-Wall -Wextra -Weverything -Werror -Wno-c++11-long-long"
40 | )
41 | elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
42 | set_source_files_properties(spirv-stats.cpp PROPERTIES
43 | COMPILE_FLAGS "/Wall /WX /wd4350 /wd4514"
44 | )
45 | else()
46 | message(WARNING "Unknown compiler '${CMAKE_C_COMPILER_ID}'!")
47 | endif()
48 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spirv-stats #
2 |
3 | [](https://ci.appveyor.com/project/sheredom/spirv-stats)
4 |
5 | [](https://travis-ci.org/sheredom/spirv-stats)
6 |
7 | spirv-stats is a command line tool to take one or more SPIR-V modules, and output statistics on the composition of the module.
8 |
9 | ## Build ##
10 |
11 | spirv-stats exists in one C++ file - spirv-stats.cpp. Build that with the compiler of your choice. Alternatively, there is a CMakeLists.txt provided within the repository that will build the command line tool for you.
12 |
13 | ## Run ##
14 |
15 | An expected run of spirv-stats is something like the below:
16 |
17 | ```
18 | Totals: 35 hits 564 bytes
19 | OpDecorate = 5 hits (14.29%) 80 bytes (14.18%)
20 | OpTypePointer = 4 hits (11.43%) 64 bytes (11.35%)
21 | OpVariable = 4 hits (11.43%) 64 bytes (11.35%)
22 | OpLoad = 3 hits ( 8.57%) 48 bytes ( 8.51%)
23 | OpTypeVector = 2 hits ( 5.71%) 32 bytes ( 5.67%)
24 | OpExtInstImport = 1 hits ( 2.86%) 24 bytes ( 4.26%)
25 | OpMemoryModel = 1 hits ( 2.86%) 12 bytes ( 2.13%)
26 | OpEntryPoint = 1 hits ( 2.86%) 32 bytes ( 5.67%)
27 | OpExecutionMode = 1 hits ( 2.86%) 12 bytes ( 2.13%)
28 | OpCapability = 1 hits ( 2.86%) 8 bytes ( 1.42%)
29 | OpTypeVoid = 1 hits ( 2.86%) 8 bytes ( 1.42%)
30 | OpTypeFloat = 1 hits ( 2.86%) 12 bytes ( 2.13%)
31 | OpTypeImage = 1 hits ( 2.86%) 36 bytes ( 6.38%)
32 | OpTypeSampledImage = 1 hits ( 2.86%) 12 bytes ( 2.13%)
33 | OpTypeFunction = 1 hits ( 2.86%) 12 bytes ( 2.13%)
34 | OpFunction = 1 hits ( 2.86%) 20 bytes ( 3.55%)
35 | OpFunctionEnd = 1 hits ( 2.86%) 4 bytes ( 0.71%)
36 | OpStore = 1 hits ( 2.86%) 12 bytes ( 2.13%)
37 | OpImageSampleImplicitLod = 1 hits ( 2.86%) 20 bytes ( 3.55%)
38 | OpFMul = 1 hits ( 2.86%) 20 bytes ( 3.55%)
39 | OpLabel = 1 hits ( 2.86%) 8 bytes ( 1.42%)
40 | OpReturn = 1 hits ( 2.86%) 4 bytes ( 0.71%)
41 | ```
42 |
43 | It first outputs the total number of opcodes found (hits) and the bytes that this SPIR-V module inhabits. Then, on a per opcode basis, it lists the opcodes found in the module, the number of times that opcode occurred (hits), and the number of bytes that that opcode takes up in the SPIR-V binary.
44 |
45 | ## License ##
46 |
47 | This is free and unencumbered software released into the public domain.
48 |
49 | Anyone is free to copy, modify, publish, use, compile, sell, or
50 | distribute this software, either in source code form or as a compiled
51 | binary, for any purpose, commercial or non-commercial, and by any
52 | means.
53 |
54 | In jurisdictions that recognize copyright laws, the author or authors
55 | of this software dedicate any and all copyright interest in the
56 | software to the public domain. We make this dedication for the benefit
57 | of the public at large and to the detriment of our heirs and
58 | successors. We intend this dedication to be an overt act of
59 | relinquishment in perpetuity of all present and future rights to this
60 | software under copyright law.
61 |
62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
63 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
65 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
66 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
67 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
68 | OTHER DEALINGS IN THE SOFTWARE.
69 |
70 | For more information, please refer to
71 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 |
3 | skip_tags: true
4 |
5 | install: []
6 |
7 | environment:
8 | matrix:
9 | - VSVERSION: Visual Studio 11
10 | - VSVERSION: Visual Studio 12
11 | - VSVERSION: Visual Studio 14
12 |
13 | platform:
14 | - Win32
15 | - x64
16 |
17 | configuration:
18 | - Debug
19 | - Release
20 |
21 | build_script:
22 | - md build
23 | - cd build
24 | - if "%PLATFORM%"=="x64" cmake -G "%VSVERSION% Win64" ..
25 | - if "%PLATFORM%"=="Win32" cmake -G "%VSVERSION%" ..
26 | - msbuild /m /p:Configuration="%CONFIGURATION%" /p:Platform="%PLATFORM%" spirv-stats.sln
27 |
--------------------------------------------------------------------------------
/spirv-stats.cpp:
--------------------------------------------------------------------------------
1 | // This is free and unencumbered software released into the public domain.
2 | //
3 | // Anyone is free to copy, modify, publish, use, compile, sell, or
4 | // distribute this software, either in source code form or as a compiled
5 | // binary, for any purpose, commercial or non-commercial, and by any
6 | // means.
7 | //
8 | // In jurisdictions that recognize copyright laws, the author or authors
9 | // of this software dedicate any and all copyright interest in the
10 | // software to the public domain. We make this dedication for the benefit
11 | // of the public at large and to the detriment of our heirs and
12 | // successors. We intend this dedication to be an overt act of
13 | // relinquishment in perpetuity of all present and future rights to this
14 | // software under copyright law.
15 | //
16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | // OTHER DEALINGS IN THE SOFTWARE.
23 | //
24 | // For more information, please refer to
25 |
26 | #ifdef _MSC_VER
27 | // Disable warning about not inlining inline functions
28 | #pragma warning(disable : 4710)
29 | // Disable warning about inlining non-inline functions
30 | #pragma warning(disable : 4711)
31 | #pragma warning(push, 1)
32 |
33 | // Disable warning in the CRT
34 | #define _CRT_SECURE_NO_WARNINGS
35 | #endif
36 |
37 | #include
38 | #include
39 |
40 | #include
41 | #include