|
@@ -288,6 +288,8 @@ void SPIRVModule::take(InstBuilder *builder) {
|
|
|
|
|
|
// Order matters here.
|
|
|
|
|
|
+ if (spirvOptions.targetEnv == "vulkan1.1")
|
|
|
+ header.version = 0x00010300u;
|
|
|
header.collect(consumer);
|
|
|
|
|
|
for (auto &cap : capabilities) {
|
|
@@ -319,25 +321,34 @@ void SPIRVModule::take(InstBuilder *builder) {
|
|
|
|
|
|
if (shaderModelVersion != 0) {
|
|
|
llvm::Optional<uint32_t> fileName = llvm::None;
|
|
|
- if (!sourceFileName.empty() && sourceFileNameId) {
|
|
|
+
|
|
|
+ if (spirvOptions.debugInfoFile && !sourceFileName.empty() &&
|
|
|
+ sourceFileNameId) {
|
|
|
builder->opString(sourceFileNameId, sourceFileName).x();
|
|
|
fileName = sourceFileNameId;
|
|
|
}
|
|
|
|
|
|
- llvm::SmallVector<llvm::StringRef, 2> choppedSrcCode;
|
|
|
llvm::Optional<llvm::StringRef> firstSnippet;
|
|
|
- chopString(sourceFileContent, &choppedSrcCode);
|
|
|
- if (!choppedSrcCode.empty()) {
|
|
|
- firstSnippet = llvm::Optional<llvm::StringRef>(choppedSrcCode.front());
|
|
|
- }
|
|
|
+ if (spirvOptions.debugInfoSource) {
|
|
|
+ llvm::SmallVector<llvm::StringRef, 2> choppedSrcCode;
|
|
|
+ chopString(sourceFileContent, &choppedSrcCode);
|
|
|
+ if (!choppedSrcCode.empty()) {
|
|
|
+ firstSnippet = llvm::Optional<llvm::StringRef>(choppedSrcCode.front());
|
|
|
+ }
|
|
|
|
|
|
- builder
|
|
|
- ->opSource(spv::SourceLanguage::HLSL, shaderModelVersion, fileName,
|
|
|
- firstSnippet)
|
|
|
- .x();
|
|
|
+ builder
|
|
|
+ ->opSource(spv::SourceLanguage::HLSL, shaderModelVersion, fileName,
|
|
|
+ firstSnippet)
|
|
|
+ .x();
|
|
|
|
|
|
- for (uint32_t i = 1; i < choppedSrcCode.size(); ++i) {
|
|
|
- builder->opSourceContinued(choppedSrcCode[i]).x();
|
|
|
+ for (uint32_t i = 1; i < choppedSrcCode.size(); ++i) {
|
|
|
+ builder->opSourceContinued(choppedSrcCode[i]).x();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ builder
|
|
|
+ ->opSource(spv::SourceLanguage::HLSL, shaderModelVersion, fileName,
|
|
|
+ firstSnippet)
|
|
|
+ .x();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -362,7 +373,7 @@ void SPIRVModule::take(InstBuilder *builder) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isVulkan1p1) {
|
|
|
+ if (spirvOptions.debugInfoTool && spirvOptions.targetEnv == "vulkan1.1") {
|
|
|
// Emit OpModuleProcessed to indicate the commit information.
|
|
|
std::string commitHash =
|
|
|
std::string("dxc-commit-hash: ") + clang::getGitCommitHash();
|
|
@@ -374,9 +385,9 @@ void SPIRVModule::take(InstBuilder *builder) {
|
|
|
|
|
|
// Emit OpModuleProcessed to indicate the command line options that were
|
|
|
// used to generate this module.
|
|
|
- if (!clOptions.empty()) {
|
|
|
+ if (!spirvOptions.clOptions.empty()) {
|
|
|
// Using this format: "dxc-cl-option: XXXXXX"
|
|
|
- std::string clOptionStr = "dxc-cl-option:" + clOptions;
|
|
|
+ std::string clOptionStr = "dxc-cl-option:" + spirvOptions.clOptions;
|
|
|
builder->opModuleProcessed(clOptionStr).x();
|
|
|
}
|
|
|
}
|