Skip to content

Commit 0f919d9

Browse files
committed
Updated glslang, SPIRV-Cross, and SPIRV-Tools.
Replaced usage of the removed SPIRV remapper from glslang with equivalents in SPIRV-Tool's optimizer. Also replaced spirv.hpp to that brought in from SPIRV-Headers. Use UTF-8 codepage for Windows, allowing for using Unicode paths similar to what is currently done on Mac and Linux. Avoid printing full output on invalid arguments. This makes it easier to see what the error is for a simple mistake. Running tools by themselves will still show the full help output, but now without other errors, though will still have a non-zero exit code to indicate that it wasn't a successful run.
1 parent e8ef033 commit 0f919d9

15 files changed

Lines changed: 134 additions & 44 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ endif()
9090

9191
set(MSL_MAJOR_VERSION 1)
9292
set(MSL_MINOR_VERSION 8)
93-
set(MSL_PATCH_VERSION 1)
93+
set(MSL_PATCH_VERSION 2)
9494
set(MSL_VERSION ${MSL_MAJOR_VERSION}.${MSL_MINOR_VERSION}.${MSL_PATCH_VERSION})
9595

9696
set(MSL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

Compile/SPIRV-Cross

Submodule SPIRV-Cross updated 1480 files

Compile/SPIRV-Tools

Submodule SPIRV-Tools updated 302 files

Compile/glslang

Submodule glslang updated 457 files

Compile/src/Compiler.cpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#endif
3535

3636
#include "SPIRV/GlslangToSpv.h"
37-
#include "SPIRV/SPVRemapper.h"
3837
#include "glslang/Public/ResourceLimits.h"
3938

4039
#if MSL_GCC || MSL_CLANG
@@ -344,30 +343,26 @@ void Compiler::process(SpirV& spirv, int processOptions)
344343
if (processOptions == 0)
345344
return;
346345

347-
std::uint32_t options = 0;
346+
// NOTE: We have some known invalid code, such as missing bindings. Therefore we need to skip
347+
// validation.
348+
spv_optimizer_options options = spvOptimizerOptionsCreate();
349+
spvOptimizerOptionsSetRunValidator(options, false);
350+
spvtools::Optimizer optimizer(SPV_ENV_VULKAN_1_0);
348351
if (processOptions & RemapVariables)
349-
options |= spv::spirvbin_t::MAP_ALL;
352+
optimizer.RegisterPass(spvtools::CreateCanonicalizeIdsPass());
350353
if (processOptions & DeadCodeElimination)
351-
options |= spv::spirvbin_t::DCE_ALL;
354+
{
355+
optimizer.RegisterPass(spvtools::CreateEliminateDeadFunctionsPass());
356+
optimizer.RegisterPass(spvtools::CreateEliminateDeadConstantPass());
357+
}
352358
if (processOptions & StripDebug)
353-
options |= spv::spirvbin_t::STRIP;
354-
355-
spv::spirvbin_t remapper;
356-
remapper.remap(spirv, options);
357-
359+
optimizer.RegisterPass(spvtools::CreateStripDebugInfoPass());
358360
if (processOptions & Optimize)
359-
{
360-
// NOTE: We have some known invalid code, such as missing bindings. Therefore we need to
361-
// skip validation.
362-
spv_optimizer_options options = spvOptimizerOptionsCreate();
363-
spvOptimizerOptionsSetRunValidator(options, false);
364-
spvtools::Optimizer optimizer(SPV_ENV_VULKAN_1_0);
365361
optimizer.RegisterPerformancePasses();
366-
SpirV optimizedSpirV;
367-
if (optimizer.Run(spirv.data(), spirv.size(), &optimizedSpirV, options))
368-
spirv = std::move(optimizedSpirV);
369-
spvOptimizerOptionsDestroy(options);
370-
}
362+
SpirV optimizedSpirV;
363+
if (optimizer.Run(spirv.data(), spirv.size(), &optimizedSpirV, options))
364+
spirv = std::move(optimizedSpirV);
365+
spvOptimizerOptionsDestroy(options);
371366
}
372367

373368
} // namespace msl

Compile/src/GlslOutput.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@
1515
*/
1616

1717
#include "GlslOutput.h"
18-
#include "spirv_glsl.hpp"
1918
#include <MSL/Compile/Output.h>
2019

20+
#if MSL_GCC || MSL_CLANG
21+
#pragma GCC diagnostic push
22+
#pragma GCC diagnostic ignored "-Wconversion"
23+
#endif
24+
25+
#include "spirv_glsl.hpp"
26+
27+
#if MSL_GCC || MSL_CLANG
28+
#pragma GCC diagnostic pop
29+
#endif
30+
2131
namespace msl
2232
{
2333

Compile/src/MetalOutput.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,19 @@
1515
*/
1616

1717
#include "MetalOutput.h"
18-
#include "spirv_msl.hpp"
1918
#include <MSL/Compile/Output.h>
2019

20+
#if MSL_GCC || MSL_CLANG
21+
#pragma GCC diagnostic push
22+
#pragma GCC diagnostic ignored "-Wconversion"
23+
#endif
24+
25+
#include "spirv_msl.hpp"
26+
27+
#if MSL_GCC || MSL_CLANG
28+
#pragma GCC diagnostic pop
29+
#endif
30+
2131
namespace msl
2232
{
2333

Compile/src/SpirVProcessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "SpirVProcessor.h"
1818
#include <MSL/Compile/CompiledResult.h>
1919
#include <MSL/Compile/Output.h>
20-
#include <SPIRV/spirv.hpp>
20+
#include <spirv/unified1/spirv.hpp>
2121
#include <algorithm>
2222
#include <cassert>
2323
#include <cstring>

Compile/src/Target.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <boost/algorithm/string/classification.hpp>
3030
#include <boost/algorithm/string/split.hpp>
3131
#include <boost/algorithm/string/trim.hpp>
32-
#include <SPIRV/spirv.hpp>
32+
#include <spirv/unified1/spirv.hpp>
3333

3434
#include <algorithm>
3535
#include <cassert>

tools/mslb-extract/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ find_package(Boost CONFIG COMPONENTS program_options filesystem)
33
file(GLOB_RECURSE sources *.cpp *.h)
44
add_executable(mslb-extract ${sources})
55

6+
if (WIN32)
7+
configure_file(mslb-extract.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/mslb-extract.manifest @ONLY)
8+
target_sources(mslb-extract PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/mslb-extract.manifest)
9+
endif()
10+
611
target_link_libraries(mslb-extract PRIVATE MSL::Client Boost::program_options Boost::filesystem)
712
target_compile_definitions(mslb-extract PRIVATE BOOST_ALL_NO_LIB
813
MSL_MAJOR_VERSION=${MSL_MAJOR_VERSION} MSL_MINOR_VERSION=${MSL_MINOR_VERSION}

0 commit comments

Comments
 (0)