Skip to content

Commit 51fe7a8

Browse files
authored
Merge branch 'master' into cheneym2/errcheck2
2 parents 6e480bf + 3058a58 commit 51fe7a8

File tree

5 files changed

+59
-20
lines changed

5 files changed

+59
-20
lines changed

CMakeLists.txt

+31-15
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,19 @@ advanced_option(
199199
)
200200
advanced_option(
201201
SLANG_OVERRIDE_GLSLANG_PATH
202-
"Build using user defined path for glslang, this also requires "
202+
"Build using user defined path for glslang"
203+
OFF
204+
)
205+
206+
advanced_option(
207+
SLANG_EXCLUDE_DAWN
208+
"Optionally exclude webgpu_dawn from the build"
209+
OFF
210+
)
211+
212+
advanced_option(
213+
SLANG_EXCLUDE_TINT
214+
"Optionally exclude slang-tint from the build"
203215
OFF
204216
)
205217

@@ -292,24 +304,28 @@ if(SLANG_SLANG_LLVM_FLAVOR MATCHES FETCH_BINARY)
292304
)
293305
endif()
294306

295-
set(webgpu_dawn_release_tag "webgpu_dawn-0")
296-
if(
297-
CMAKE_SYSTEM_NAME MATCHES "Windows"
298-
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
299-
)
300-
set(SLANG_WEBGPU_DAWN_BINARY_URL
301-
"https://github.com/shader-slang/dawn/releases/download/${webgpu_dawn_release_tag}/webgpu_dawn-windows-x64.zip"
307+
if(NOT SLANG_EXCLUDE_DAWN)
308+
set(webgpu_dawn_release_tag "webgpu_dawn-0")
309+
if(
310+
CMAKE_SYSTEM_NAME MATCHES "Windows"
311+
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
302312
)
313+
set(SLANG_WEBGPU_DAWN_BINARY_URL
314+
"https://github.com/shader-slang/dawn/releases/download/${webgpu_dawn_release_tag}/webgpu_dawn-windows-x64.zip"
315+
)
316+
endif()
303317
endif()
304318

305-
set(slang_tint_release_tag "slang-tint-0")
306-
if(
307-
CMAKE_SYSTEM_NAME MATCHES "Windows"
308-
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
309-
)
310-
set(SLANG_SLANG_TINT_BINARY_URL
311-
"https://github.com/shader-slang/dawn/releases/download/${slang_tint_release_tag}/slang-tint-windows-x64.zip"
319+
if(NOT SLANG_EXCLUDE_TINT)
320+
set(slang_tint_release_tag "slang-tint-0")
321+
if(
322+
CMAKE_SYSTEM_NAME MATCHES "Windows"
323+
AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64"
312324
)
325+
set(SLANG_SLANG_TINT_BINARY_URL
326+
"https://github.com/shader-slang/dawn/releases/download/${slang_tint_release_tag}/slang-tint-windows-x64.zip"
327+
)
328+
endif()
313329
endif()
314330

315331
#

source/slang-glslang/slang-glslang.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ extern "C"
997997
spvtools::Context context(SPV_ENV_UNIVERSAL_1_5);
998998
spvtools::LinkerOptions options = {};
999999

1000+
options.SetUseHighestVersion(true);
1001+
10001002
spvtools::MessageConsumer consumer = [](spv_message_level_t level,
10011003
const char* source,
10021004
const spv_position_t& position,

source/slang/slang-check-shader.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,17 @@ void validateEntryPoint(EntryPoint* entryPoint, DiagnosticSink* sink)
537537
}
538538
else
539539
{
540-
// Only attempt to error if a user adds to slangc either `-profile` or `-capability`
541-
if ((target->getOptionSet().hasOption(CompilerOptionName::Capability) ||
542-
target->getOptionSet().hasOption(CompilerOptionName::Profile)) &&
540+
auto& targetOptionSet = target->getOptionSet();
541+
bool specificProfileRequested =
542+
targetOptionSet.hasOption(CompilerOptionName::Profile) &&
543+
(targetOptionSet.getIntOption(CompilerOptionName::Profile) !=
544+
SLANG_PROFILE_UNKNOWN);
545+
bool specificCapabilityRequested =
546+
targetOptionSet.hasOption(CompilerOptionName::Capability) &&
547+
(targetOptionSet.getIntOption(CompilerOptionName::Capability) !=
548+
SLANG_CAPABILITY_UNKNOWN);
549+
// Only attempt to error if a specific profile or capability is requested
550+
if ((specificCapabilityRequested || specificProfileRequested) &&
543551
targetCaps.atLeastOneSetImpliedInOther(
544552
entryPointFuncDecl->inferredCapabilityRequirements) ==
545553
CapabilitySet::ImpliesReturnFlags::NotImplied)

source/slang/slang-emit-spirv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ enum class SpvLogicalSectionID
9191
};
9292

9393
// The registered id for the Slang compiler.
94-
static const uint32_t kSPIRVSlangCompilerId = 40;
94+
static const uint32_t kSPIRVSlangCompilerId = 40 << 16;
9595

9696
// While the SPIR-V module is nominally (according to the spec) just
9797
// a flat sequence of instructions, in practice some of the instructions

source/slang/slang-options.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,20 @@ SlangResult OptionsParser::_parseReferenceModule(const CommandLineArg& arg)
18311831
CommandLineArg referenceModuleName;
18321832
SLANG_RETURN_ON_FAIL(m_reader.expectArg(referenceModuleName));
18331833

1834-
return addReferencedModule(referenceModuleName.value, referenceModuleName.loc, true);
1834+
// Add the module to the request
1835+
SLANG_RETURN_ON_FAIL(
1836+
addReferencedModule(referenceModuleName.value, referenceModuleName.loc, true));
1837+
1838+
// In addition to adding the module to the request, we also add to the options set, because
1839+
// the same options parser is also used for IGlobalSession::parseCommandLineArguments, which
1840+
// parses options via a dummy request that is destroyed once the command line options are
1841+
// obtained. Therefore, also add the option here so that
1842+
// IGlobalSession::parseCommandLineArguments can return them.
1843+
m_requestImpl->getLinkage()->m_optionSet.add(
1844+
CompilerOptionName::ReferenceModule,
1845+
referenceModuleName.value);
1846+
1847+
return SLANG_OK;
18351848
}
18361849

18371850
SlangResult OptionsParser::_parseReproFileSystem(const CommandLineArg& arg)

0 commit comments

Comments
 (0)