diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2020-06-18 14:17:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 11:17:57 -0700 |
| commit | dfbe3cfcdb308cdb0f89cb2844fb3aba96cfcaec (patch) | |
| tree | 749a65af64f615de3d1f86a93b3e9c08a15c39b7 /source/slang | |
| parent | 5a86cd4880f8f086631352cb5d67d60c58c087f4 (diff) | |
Fix and improvements around repro (#1397)
* * Fix output in slang repro command line
* Profile uses lowerCamel method names (had mix of upper and lower)
* Rename slang-serialize-state/SerializeStateUtil to slang-repro and ReproUtil.
Diffstat (limited to 'source/slang')
21 files changed, 127 insertions, 116 deletions
diff --git a/source/slang/slang-check-shader.cpp b/source/slang/slang-check-shader.cpp index ab1c7f580..17ca9fc78 100644 --- a/source/slang/slang-check-shader.cpp +++ b/source/slang/slang-check-shader.cpp @@ -544,7 +544,7 @@ namespace Slang auto entryPointProfile = entryPointReq->getProfile(); if( auto entryPointAttribute = entryPointFuncDecl->findModifier<EntryPointAttribute>() ) { - auto entryPointStage = entryPointProfile.GetStage(); + auto entryPointStage = entryPointProfile.getStage(); if( entryPointStage == Stage::Unknown ) { entryPointProfile.setStage(entryPointAttribute->stage); diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 729c0077a..b64169db4 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -320,7 +320,7 @@ namespace Slang // - Profile Profile::LookUp(char const* name) + Profile Profile::lookUp(char const* name) { #define PROFILE(TAG, NAME, STAGE, VERSION) if(strcmp(name, #NAME) == 0) return Profile::TAG; #define PROFILE_ALIAS(TAG, DEF, NAME) if(strcmp(name, #NAME) == 0) return Profile::TAG; @@ -634,7 +634,7 @@ namespace Slang } char const* stagePrefix = nullptr; - switch( profile.GetStage() ) + switch( profile.getStage() ) { // Note: All of the raytracing-related stages require // compiling for a `lib_*` profile, even when only a @@ -669,7 +669,7 @@ namespace Slang } char const* versionSuffix = nullptr; - switch(profile.GetVersion()) + switch(profile.getVersion()) { #define CASE(TAG, SUFFIX) case ProfileVersion::TAG: versionSuffix = #SUFFIX; break CASE(DX_4_0, _4_0); diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index b1edbe602..ba0c94e99 100644 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -180,7 +180,7 @@ namespace Slang Name* getName() { return m_name; } /// Get the stage that the entry point is to be compiled for - Stage getStage() { return m_profile.GetStage(); } + Stage getStage() { return m_profile.getStage(); } /// Get the profile that the entry point is to be compiled for Profile getProfile() { return m_profile; } @@ -725,7 +725,7 @@ namespace Slang Profile getProfile() { return m_profile; } /// Get the stage that the entry point is for. - Stage getStage() { return m_profile.GetStage(); } + Stage getStage() { return m_profile.getStage(); } /// Get the module that contains the entry point. Module* getModule(); diff --git a/source/slang/slang-dxc-support.cpp b/source/slang/slang-dxc-support.cpp index 4fe8e64ca..ffcc405c8 100644 --- a/source/slang/slang-dxc-support.cpp +++ b/source/slang/slang-dxc-support.cpp @@ -185,7 +185,7 @@ namespace Slang // TODO: Ideally the dxc back-end should be passed some information // on the "capabilities" that were used and/or requested in the code. // - if( profile.GetVersion() >= ProfileVersion::DX_6_2 ) + if( profile.getVersion() >= ProfileVersion::DX_6_2 ) { args[argCount++] = L"-enable-16bit-types"; } @@ -195,7 +195,7 @@ namespace Slang ComPtr<IDxcOperationResult> dxcResult; SLANG_RETURN_ON_FAIL(dxcCompiler->Compile(dxcSourceBlob, sourcePath.toWString().begin(), - profile.GetStage() == Stage::Unknown ? L"" : wideEntryPointName.begin(), + profile.getStage() == Stage::Unknown ? L"" : wideEntryPointName.begin(), wideProfileName.begin(), args, argCount, diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 53a110632..032f04ff3 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -1742,7 +1742,7 @@ void CPPSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPoint SLANG_UNUSED(entryPointDecor); auto profile = m_effectiveProfile; - auto stage = profile.GetStage(); + auto stage = profile.getStage(); switch (stage) { @@ -2694,7 +2694,7 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module) IREntryPointDecoration* entryPointDecor = func->findDecoration<IREntryPointDecoration>(); - if (entryPointDecor && entryPointDecor->getProfile().GetStage() == Stage::Compute) + if (entryPointDecor && entryPointDecor->getProfile().getStage() == Stage::Compute) { // https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-dispatchthreadid // SV_DispatchThreadID is the sum of SV_GroupID * numthreads and GroupThreadID. diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp index 06bbbea96..6272ea02e 100644 --- a/source/slang/slang-emit-cuda.cpp +++ b/source/slang/slang-emit-cuda.cpp @@ -799,7 +799,7 @@ void CUDASourceEmitter::emitModuleImpl(IRModule* module) // must be prefixed to indicate to the OptiX runtime what // stage it is to be compiled for. // - auto stage = entryPointDecor->getProfile().GetStage(); + auto stage = entryPointDecor->getProfile().getStage(); switch( stage ) { default: diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index a73ea529a..0154f9741 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -806,7 +806,7 @@ void GLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPoin SLANG_ASSERT(entryPointDecor); auto profile = entryPointDecor->getProfile(); - auto stage = profile.GetStage(); + auto stage = profile.getStage(); switch (stage) { @@ -1498,7 +1498,7 @@ void GLSLSourceEmitter::emitPreprocessorDirectivesImpl() auto effectiveProfile = m_effectiveProfile; if (effectiveProfile.getFamily() == ProfileFamily::GLSL) { - _requireGLSLVersion(effectiveProfile.GetVersion()); + _requireGLSLVersion(effectiveProfile.getVersion()); } // HACK: We aren't picking GLSL versions carefully right now, diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 83bfb8f2a..f33697045 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -290,11 +290,11 @@ void HLSLSourceEmitter::emitParameterGroupImpl(IRGlobalParam* varDecl, IRUniform void HLSLSourceEmitter::emitEntryPointAttributesImpl(IRFunc* irFunc, IREntryPointDecoration* entryPointDecor) { auto profile = m_effectiveProfile; - auto stage = entryPointDecor->getProfile().GetStage(); + auto stage = entryPointDecor->getProfile().getStage(); if (profile.getFamily() == ProfileFamily::DX) { - if (profile.GetVersion() >= ProfileVersion::DX_6_1) + if (profile.getVersion() >= ProfileVersion::DX_6_1) { char const* stageName = getStageName(stage); if (stageName) diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index c6f2f7468..0ca523ecf 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -208,7 +208,7 @@ struct SpvInst : SpvInstParent // // > Word Count: The complete number of words taken by an instruction, // > including the word holding the word count and opcode, and any optional - // > operands. An instruction’s word count is the total space taken by the instruction. + // > operands. An instruction’s word count is the total space taken by the instruction. // SpvWord wordCount = 1 + SpvWord(operandWords.getCount()); @@ -531,7 +531,7 @@ struct SPIRVEmitContext cursor += 4; } // - // > The final word contains the string’s nul-termination character (0), and + // > The final word contains the string’s nul-termination character (0), and // > all contents past the end of the string in the final word are padded with 0. // // For the last word, the low-order bytes will @@ -1052,7 +1052,7 @@ struct SPIRVEmitContext // to the new globals, which would be used in the SPIR-V emit case. auto entryPointDecor = cast<IREntryPointDecoration>(decoration); - auto spvStage = mapStageToExecutionModel(entryPointDecor->getProfile().GetStage()); + auto spvStage = mapStageToExecutionModel(entryPointDecor->getProfile().getStage()); auto name = entryPointDecor->getName()->getStringSlice(); emitInst(section, decoration, SpvOpEntryPoint, spvStage, dstID, name); } diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 4af7b5989..1afca6127 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -495,7 +495,7 @@ Result linkAndOptimizeIR( auto profile = targetRequest->targetProfile; if( profile.getFamily() == ProfileFamily::DX ) { - if(profile.GetVersion() <= ProfileVersion::DX_5_0) + if(profile.getVersion() <= ProfileVersion::DX_5_0) { // Fxc and earlier dxc versions do not support // a templates `.Load<T>` operation on byte-address diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp index afb67a081..794024d46 100644 --- a/source/slang/slang-ir-glsl-legalize.cpp +++ b/source/slang/slang-ir-glsl-legalize.cpp @@ -1602,7 +1602,7 @@ void legalizeEntryPointForGLSL( auto entryPointDecor = func->findDecoration<IREntryPointDecoration>(); SLANG_ASSERT(entryPointDecor); - auto stage = entryPointDecor->getProfile().GetStage(); + auto stage = entryPointDecor->getProfile().getStage(); auto layoutDecoration = func->findDecoration<IRLayoutDecoration>(); SLANG_ASSERT(layoutDecoration); diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 5bf0c6c9d..f3c702c26 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -12,7 +12,7 @@ #include "slang-file-system.h" -#include "slang-state-serialize.h" +#include "slang-repro.h" #include "slang-ir-serialize.h" #include "../core/slang-type-text-util.h" @@ -483,7 +483,7 @@ struct OptionsParser String reproName; SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, reproName)); - SLANG_RETURN_ON_FAIL(StateSerializeUtil::extractFilesToDirectory(reproName)); + SLANG_RETURN_ON_FAIL(ReproUtil::extractFilesToDirectory(reproName)); } else if (argStr == "-module-name") { @@ -498,16 +498,16 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, reproName)); List<uint8_t> buffer; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(reproName, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(reproName, buffer)); - auto requestState = StateSerializeUtil::getRequest(buffer); + auto requestState = ReproUtil::getRequest(buffer); MemoryOffsetBase base; base.set(buffer.getBuffer(), buffer.getCount()); // If we can find a directory, that exists, we will set up a file system to load from that directory ComPtr<ISlangFileSystem> fileSystem; String dirPath; - if (SLANG_SUCCEEDED(StateSerializeUtil::calcDirectoryPathFromFilename(reproName, dirPath))) + if (SLANG_SUCCEEDED(ReproUtil::calcDirectoryPathFromFilename(reproName, dirPath))) { SlangPathType pathType; if (SLANG_SUCCEEDED(Path::getPathType(dirPath, &pathType)) && pathType == SLANG_PATH_TYPE_DIRECTORY) @@ -516,7 +516,7 @@ struct OptionsParser } } - SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(base, requestState, fileSystem, requestImpl)); + SLANG_RETURN_ON_FAIL(ReproUtil::load(base, requestState, fileSystem, requestImpl)); hasLoadedRepro = true; } @@ -526,16 +526,16 @@ struct OptionsParser SLANG_RETURN_ON_FAIL(tryReadCommandLineArgument(sink, arg, &argCursor, argEnd, reproName)); List<uint8_t> buffer; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(reproName, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(reproName, buffer)); - auto requestState = StateSerializeUtil::getRequest(buffer); + auto requestState = ReproUtil::getRequest(buffer); MemoryOffsetBase base; base.set(buffer.getBuffer(), buffer.getCount()); // If we can find a directory, that exists, we will set up a file system to load from that directory ComPtr<ISlangFileSystem> dirFileSystem; String dirPath; - if (SLANG_SUCCEEDED(StateSerializeUtil::calcDirectoryPathFromFilename(reproName, dirPath))) + if (SLANG_SUCCEEDED(ReproUtil::calcDirectoryPathFromFilename(reproName, dirPath))) { SlangPathType pathType; if (SLANG_SUCCEEDED(Path::getPathType(dirPath, &pathType)) && pathType == SLANG_PATH_TYPE_DIRECTORY) @@ -545,7 +545,7 @@ struct OptionsParser } RefPtr<CacheFileSystem> cacheFileSystem; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadFileSystem(base, requestState, dirFileSystem, cacheFileSystem)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadFileSystem(base, requestState, dirFileSystem, cacheFileSystem)); // I might want to make the dir file system the fallback file system... cacheFileSystem->setInnerFileSystem(dirFileSystem, cacheFileSystem->getUniqueIdentityMode(), cacheFileSystem->getPathStyle()); @@ -624,11 +624,11 @@ struct OptionsParser { auto profile = Profile(profileID); - setProfileVersion(getCurrentTarget(), profile.GetVersion()); + setProfileVersion(getCurrentTarget(), profile.getVersion()); // A `-profile` option that also specifies a stage (e.g., `-profile vs_5_0`) // should be treated like a composite (e.g., `-profile sm_5_0 -stage vertex`) - auto stage = profile.GetStage(); + auto stage = profile.getStage(); if(stage != Stage::Unknown) { setStage(getCurrentEntryPoint(), stage); diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index ea45612ec..ee3ef1234 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -1425,7 +1425,7 @@ static RefPtr<TypeLayout> processSimpleEntryPointParameter( // if( isD3DTarget(context->getTargetRequest()) ) { - auto version = context->getTargetRequest()->targetProfile.GetVersion(); + auto version = context->getTargetRequest()->targetProfile.getVersion(); if( version <= ProfileVersion::DX_5_0 ) { // We will address the conflict here by claiming the corresponding diff --git a/source/slang/slang-profile.h b/source/slang/slang-profile.h index c90ca66d0..f5b15eda6 100644 --- a/source/slang/slang-profile.h +++ b/source/slang/slang-profile.h @@ -89,21 +89,21 @@ namespace Slang bool operator==(Profile const& other) const { return raw == other.raw; } bool operator!=(Profile const& other) const { return raw != other.raw; } - Stage GetStage() const { return Stage(uint32_t(raw) & 0xFFFF); } + Stage getStage() const { return Stage(uint32_t(raw) & 0xFFFF); } void setStage(Stage stage) { raw = (raw & ~0xFFFF) | uint32_t(stage); } - ProfileVersion GetVersion() const { return ProfileVersion((uint32_t(raw) >> 16) & 0xFFFF); } + ProfileVersion getVersion() const { return ProfileVersion((uint32_t(raw) >> 16) & 0xFFFF); } void setVersion(ProfileVersion version) { raw = (raw & 0x0000FFFF) | (uint32_t(version) << 16); } - ProfileFamily getFamily() const { return getProfileFamily(GetVersion()); } + ProfileFamily getFamily() const { return getProfileFamily(getVersion()); } - static Profile LookUp(char const* name); + static Profile lookUp(char const* name); char const* getName(); RawVal raw = Unknown; diff --git a/source/slang/slang-reflection.cpp b/source/slang/slang-reflection.cpp index c1e533140..4ed1c3e5d 100644 --- a/source/slang/slang-reflection.cpp +++ b/source/slang/slang-reflection.cpp @@ -1277,7 +1277,7 @@ SLANG_API SlangStage spReflectionEntryPoint_getStage(SlangReflectionEntryPoint* if(!entryPointLayout) return SLANG_STAGE_NONE; - return SlangStage(entryPointLayout->profile.GetStage()); + return SlangStage(entryPointLayout->profile.getStage()); } SLANG_API void spReflectionEntryPoint_getComputeThreadGroupSize( @@ -1323,7 +1323,7 @@ SLANG_API int spReflectionEntryPoint_usesAnySampleRateInput( if(!entryPointLayout) return 0; - if (entryPointLayout->profile.GetStage() != Stage::Fragment) + if (entryPointLayout->profile.getStage() != Stage::Fragment) return 0; return (entryPointLayout->flags & EntryPointLayout::Flag::usesAnySampleRateInput) != 0; diff --git a/source/slang/slang-state-serialize.cpp b/source/slang/slang-repro.cpp index 3d98f182d..80ef0322e 100644 --- a/source/slang/slang-state-serialize.cpp +++ b/source/slang/slang-repro.cpp @@ -1,5 +1,5 @@ -// slang-state-serialize.cpp -#include "slang-state-serialize.h" +// slang-repro.cpp +#include "slang-repro.h" #include "../core/slang-text-io.h" @@ -14,8 +14,8 @@ namespace Slang { -/* static */const RiffSemanticVersion StateSerializeUtil::g_semanticVersion = - RiffSemanticVersion::make(StateSerializeUtil::kMajorVersion, StateSerializeUtil::kMinorVersion, StateSerializeUtil::kPatchVersion); +/* static */const RiffSemanticVersion ReproUtil::g_semanticVersion = + RiffSemanticVersion::make(ReproUtil::kMajorVersion, ReproUtil::kMinorVersion, ReproUtil::kPatchVersion); // We can't just use sizeof for the sizes of these types, because the hash will be dependent on the ptr size, // which isn't an issue for serialization (we turn all pointers into Offset32Ptr -> uint32_t). So we use an x macro @@ -55,7 +55,7 @@ namespace Slang { // A function to calculate the hash related in list in part to how the types used are sized. Can catch crude breaking binary differences. static HashCode32 _calcTypeHash() { - typedef StateSerializeUtil Util; + typedef ReproUtil Util; const uint32_t sizes[] = { SLANG_STATE_TYPES(SLANG_STATE_TYPE_SIZE) @@ -74,9 +74,9 @@ namespace { // anonymous struct StoreContext { - typedef StateSerializeUtil::FileState FileState; - typedef StateSerializeUtil::SourceFileState SourceFileState; - typedef StateSerializeUtil::PathInfoState PathInfoState; + typedef ReproUtil::FileState FileState; + typedef ReproUtil::SourceFileState SourceFileState; + typedef ReproUtil::PathInfoState PathInfoState; StoreContext(OffsetContainer* container) { @@ -142,7 +142,7 @@ struct StoreContext auto& base = m_container->asBase(); - Offset32Ptr<StateSerializeUtil::SourceFileState> sourceFileState; + Offset32Ptr<ReproUtil::SourceFileState> sourceFileState; if (m_sourceFileMap.TryGetValue(sourceFile, sourceFileState)) { return sourceFileState; @@ -265,9 +265,9 @@ struct StoreContext return pathInfo; } - const Offset32Array<StateSerializeUtil::StringPair> calcDefines(const Dictionary<String, String>& srcDefines) + const Offset32Array<ReproUtil::StringPair> calcDefines(const Dictionary<String, String>& srcDefines) { - typedef StateSerializeUtil::StringPair StringPair; + typedef ReproUtil::StringPair StringPair; Offset32Array<StringPair> dstDefines = m_container->newArray<StringPair>(srcDefines.Count()); @@ -304,13 +304,13 @@ struct StoreContext Dictionary<String, Offset32Ptr<OffsetString> > m_stringMap; - Dictionary<SourceFile*, Offset32Ptr<StateSerializeUtil::SourceFileState> > m_sourceFileMap; + Dictionary<SourceFile*, Offset32Ptr<ReproUtil::SourceFileState> > m_sourceFileMap; - Dictionary<String, Offset32Ptr<StateSerializeUtil::FileState> > m_uniqueToFileMap; + Dictionary<String, Offset32Ptr<ReproUtil::FileState> > m_uniqueToFileMap; Dictionary<const CacheFileSystem::PathInfo*, Offset32Ptr<PathInfoState> > m_pathInfoMap; - List<Offset32Ptr<StateSerializeUtil::FileState> > m_files; + List<Offset32Ptr<ReproUtil::FileState> > m_files; OffsetContainer* m_container; }; @@ -332,7 +332,7 @@ static bool _isStorable(const PathInfo::Type type) } } -/* static */SlangResult StateSerializeUtil::store(EndToEndCompileRequest* request, OffsetContainer& inOutContainer, Offset32Ptr<RequestState>& outRequest) +/* static */SlangResult ReproUtil::store(EndToEndCompileRequest* request, OffsetContainer& inOutContainer, Offset32Ptr<RequestState>& outRequest) { StoreContext context(&inOutContainer); @@ -628,9 +628,9 @@ namespace { // anonymous struct LoadContext { - typedef StateSerializeUtil::SourceFileState SourceFileState; - typedef StateSerializeUtil::FileState FileState; - typedef StateSerializeUtil::PathInfoState PathInfoState; + typedef ReproUtil::SourceFileState SourceFileState; + typedef ReproUtil::FileState FileState; + typedef ReproUtil::PathInfoState PathInfoState; CacheFileSystem::PathInfo* getPathInfoFromFile(FileState* file) { @@ -778,7 +778,7 @@ struct LoadContext } - void loadDefines(const Offset32Array<StateSerializeUtil::StringPair>& in, Dictionary<String, String>& out) + void loadDefines(const Offset32Array<ReproUtil::StringPair>& in, Dictionary<String, String>& out) { out.Clear(); @@ -809,7 +809,7 @@ struct LoadContext } // anonymous -/* static */SlangResult StateSerializeUtil::loadFileSystem(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, RefPtr<CacheFileSystem>& outFileSystem) +/* static */SlangResult ReproUtil::loadFileSystem(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, RefPtr<CacheFileSystem>& outFileSystem) { LoadContext context(nullptr, fileSystem, &base); @@ -862,7 +862,7 @@ struct LoadContext return SLANG_OK; } -/* static */SlangResult StateSerializeUtil::load(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, EndToEndCompileRequest* request) +/* static */SlangResult ReproUtil::load(OffsetBase& base, RequestState* requestState, ISlangFileSystem* fileSystem, EndToEndCompileRequest* request) { auto externalRequest = asExternal(request); @@ -1001,7 +1001,7 @@ struct LoadContext const char* name = srcEntryPoint.name ? base.asRaw(srcEntryPoint.name)->getCstr() : nullptr; - Stage stage = srcEntryPoint.profile.GetStage(); + Stage stage = srcEntryPoint.profile.getStage(); List<const char*> args = context.toList(srcEntryPoint.specializationArgStrings); @@ -1044,7 +1044,7 @@ struct LoadContext } -/* static */SlangResult StateSerializeUtil::saveState(EndToEndCompileRequest* request, Stream* stream) +/* static */SlangResult ReproUtil::saveState(EndToEndCompileRequest* request, Stream* stream) { OffsetContainer container; Offset32Ptr<RequestState> requestState; @@ -1058,13 +1058,13 @@ struct LoadContext return RiffUtil::writeData(&header.m_chunk, sizeof(header),container.getData(), container.getDataCount(), stream); } -/* static */SlangResult StateSerializeUtil::saveState(EndToEndCompileRequest* request, const String& filename) +/* static */SlangResult ReproUtil::saveState(EndToEndCompileRequest* request, const String& filename) { RefPtr<Stream> stream(new FileStream(filename, FileMode::Create, FileAccess::Write, FileShare::ReadWrite)); return saveState(request, stream); } -/* static */ SlangResult StateSerializeUtil::loadState(const String& filename, List<uint8_t>& outBuffer) +/* static */ SlangResult ReproUtil::loadState(const String& filename, List<uint8_t>& outBuffer) { RefPtr<Stream> stream; try @@ -1079,7 +1079,7 @@ struct LoadContext return loadState(stream, outBuffer); } -/* static */ SlangResult StateSerializeUtil::loadState(Stream* stream, List<uint8_t>& buffer) +/* static */ SlangResult ReproUtil::loadState(Stream* stream, List<uint8_t>& buffer) { Header header; @@ -1102,18 +1102,18 @@ struct LoadContext return SLANG_OK; } -/* static */SlangResult StateSerializeUtil::loadState(const uint8_t* data, size_t size, List<uint8_t>& outBuffer) +/* static */SlangResult ReproUtil::loadState(const uint8_t* data, size_t size, List<uint8_t>& outBuffer) { MemoryStreamBase stream(FileAccess::Read, data, size); return loadState(&stream, outBuffer); } -/* static */ StateSerializeUtil::RequestState* StateSerializeUtil::getRequest(const List<uint8_t>& buffer) +/* static */ ReproUtil::RequestState* ReproUtil::getRequest(const List<uint8_t>& buffer) { - return (StateSerializeUtil::RequestState*)(buffer.getBuffer() + kStartOffset); + return (ReproUtil::RequestState*)(buffer.getBuffer() + kStartOffset); } -/* static */SlangResult StateSerializeUtil::calcDirectoryPathFromFilename(const String& filename, String& outPath) +/* static */SlangResult ReproUtil::calcDirectoryPathFromFilename(const String& filename, String& outPath) { String absPath; SLANG_RETURN_ON_FAIL(Path::getCanonical(filename, absPath)); @@ -1134,18 +1134,18 @@ struct LoadContext return SLANG_OK; } -/* static */SlangResult StateSerializeUtil::extractFilesToDirectory(const String& filename) +/* static */SlangResult ReproUtil::extractFilesToDirectory(const String& filename) { List<uint8_t> buffer; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(filename, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(filename, buffer)); MemoryOffsetBase base; base.set(buffer.getBuffer(), buffer.getCount()); - RequestState* requestState = StateSerializeUtil::getRequest(buffer); + RequestState* requestState = ReproUtil::getRequest(buffer); String dirPath; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::calcDirectoryPathFromFilename(filename, dirPath)); + SLANG_RETURN_ON_FAIL(ReproUtil::calcDirectoryPathFromFilename(filename, dirPath)); Path::createDirectory(dirPath); // Set up a file system to write into this directory @@ -1154,7 +1154,7 @@ struct LoadContext return extractFiles(base, requestState, &relFileSystem); } -static void _calcPreprocessorDefines(OffsetBase& base, const Offset32Array<StateSerializeUtil::StringPair>& srcDefines, CommandLine& cmd) +static void _calcPreprocessorDefines(OffsetBase& base, const Offset32Array<ReproUtil::StringPair>& srcDefines, CommandLine& cmd) { for (const auto& define : srcDefines) { @@ -1169,10 +1169,10 @@ static void _calcPreprocessorDefines(OffsetBase& base, const Offset32Array<State } } -static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::RequestState* requestState, CommandLine& cmd) +static SlangResult _calcCommandLine(OffsetBase& base, ReproUtil::RequestState* requestState, CommandLine& cmd) { - typedef StateSerializeUtil::TargetRequestState TargetRequestState; - typedef StateSerializeUtil::SourceFileState SourceFileState; + typedef ReproUtil::TargetRequestState TargetRequestState; + typedef ReproUtil::SourceFileState SourceFileState; { SlangCompileFlags flags = (SlangCompileFlags)requestState->compileFlags; @@ -1198,7 +1198,9 @@ static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::Reques case SLANG_LINE_DIRECTIVE_MODE_DEFAULT: break; case SLANG_LINE_DIRECTIVE_MODE_NONE: { - cmd.addArg("-line-directive-mode none"); break; + cmd.addArg("-line-directive-mode"); + cmd.addArg("none"); + break; } default: break; } @@ -1255,8 +1257,11 @@ static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::Reques cmd.addArg("-target"); cmd.addArg(TypeTextUtil::getCompileTargetName(SlangCompileTarget(src.target))); - cmd.addArg("-profile"); - cmd.addArg(Profile(src.profile).getName()); + if (src.profile != Profile::Unknown) + { + cmd.addArg("-profile"); + cmd.addArg(Profile(src.profile).getName()); + } if (src.targetFlags & SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES) { @@ -1361,7 +1366,7 @@ static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::Reques cmd.addArg(name); cmd.addArg("-stage"); - UnownedStringSlice stageText = getStageText(srcEntryPoint.profile.GetStage()); + UnownedStringSlice stageText = getStageText(srcEntryPoint.profile.getStage()); cmd.addArg(stageText); //cmd.addArg("-profile"); @@ -1377,7 +1382,7 @@ static SlangResult _calcCommandLine(OffsetBase& base, StateSerializeUtil::Reques return SLANG_OK; } -/* static */SlangResult StateSerializeUtil::extractFiles(OffsetBase& base, RequestState* requestState, ISlangFileSystemExt* fileSystem) +/* static */SlangResult ReproUtil::extractFiles(OffsetBase& base, RequestState* requestState, ISlangFileSystemExt* fileSystem) { StringBuilder builder; @@ -1519,7 +1524,7 @@ static SlangResult _findFirstSourcePath(EndToEndCompileRequest* request, String& return SLANG_FAIL; } -/* static */SlangResult StateSerializeUtil::findUniqueReproDumpStream(EndToEndCompileRequest* request, String& outFileName, RefPtr<Stream>& outStream) +/* static */SlangResult ReproUtil::findUniqueReproDumpStream(EndToEndCompileRequest* request, String& outFileName, RefPtr<Stream>& outStream) { String sourcePath; diff --git a/source/slang/slang-state-serialize.h b/source/slang/slang-repro.h index 9a404138e..bd35d3ee9 100644 --- a/source/slang/slang-state-serialize.h +++ b/source/slang/slang-repro.h @@ -1,6 +1,6 @@ -// slang-state-serialize.h -#ifndef SLANG_STATE_SERIALIZE_H_INCLUDED -#define SLANG_STATE_SERIALIZE_H_INCLUDED +// slang-repro.h +#ifndef SLANG_REPRO_H_INCLUDED +#define SLANG_REPRO_H_INCLUDED #include "../core/slang-riff.h" #include "../core/slang-string.h" @@ -14,7 +14,13 @@ namespace Slang { -struct StateSerializeUtil +/* Facilities to be able to save and load the full state of a compilation, including source files, +and all compilation options into 'slang-repro' files. Repro is short for 'reproducible' and it's +main purposes is to make compilations easily reproducible as everything that is needed from +a compilation environment is packaged up into a single file. The single file can be used to +repeat the compilation, or extracted such that everything that was specified in the compilation +can be inspected and modified. */ +struct ReproUtil { enum { diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index 3b30e6ee0..d6138f2af 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -1487,7 +1487,7 @@ static bool isSM5OrEarlier(TargetRequest* targetReq) if(profile.getFamily() == ProfileFamily::DX) { - if(profile.GetVersion() <= ProfileVersion::DX_5_0) + if(profile.getVersion() <= ProfileVersion::DX_5_0) return true; } @@ -1503,7 +1503,7 @@ static bool isSM5_1OrLater(TargetRequest* targetReq) if(profile.getFamily() == ProfileFamily::DX) { - if(profile.GetVersion() >= ProfileVersion::DX_5_1) + if(profile.getVersion() >= ProfileVersion::DX_5_1) return true; } diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 1710359bf..02c9e25e3 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -16,7 +16,7 @@ #include "slang-ast-dump.h" -#include "slang-state-serialize.h" +#include "slang-repro.h" #include "slang-file-system.h" @@ -231,7 +231,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::createSession( SLANG_NO_THROW SlangProfileID SLANG_MCALL Session::findProfile( char const* name) { - return Slang::Profile::LookUp(name).raw; + return Slang::Profile::lookUp(name).raw; } SLANG_NO_THROW void SLANG_MCALL Session::setDownstreamCompilerPath( @@ -426,8 +426,8 @@ Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target) break; } - auto entryPointProfileVersion = entryPointProfile.GetVersion(); - auto targetProfileVersion = targetProfile.GetVersion(); + auto entryPointProfileVersion = entryPointProfile.getVersion(); + auto targetProfileVersion = targetProfile.getVersion(); // Default to the entry point profile, since we know that has the right stage. Profile effectiveProfile = entryPointProfile; @@ -450,7 +450,7 @@ Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target) switch( effectiveProfile.getFamily() ) { case ProfileFamily::DX: - switch(effectiveProfile.GetStage()) + switch(effectiveProfile.getStage()) { default: break; @@ -472,7 +472,7 @@ Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target) break; case ProfileFamily::GLSL: - switch(effectiveProfile.GetStage()) + switch(effectiveProfile.getStage()) { default: break; @@ -494,7 +494,7 @@ Profile getEffectiveProfile(EntryPoint* entryPoint, TargetRequest* target) break; } - if( stageMinVersion > effectiveProfile.GetVersion() ) + if( stageMinVersion > effectiveProfile.getVersion() ) { effectiveProfile.setVersion(stageMinVersion); } @@ -3166,7 +3166,7 @@ SLANG_API SlangProfileID spFindProfile( SlangSession*, char const* name) { - return Slang::Profile::LookUp(name).raw; + return Slang::Profile::lookUp(name).raw; } SLANG_API int spAddEntryPoint( @@ -3327,7 +3327,7 @@ SLANG_API SlangResult spCompile( { if (req->dumpRepro.getLength()) { - SlangResult saveRes = StateSerializeUtil::saveState(req, req->dumpRepro); + SlangResult saveRes = ReproUtil::saveState(req, req->dumpRepro); if (SLANG_FAILED(saveRes)) { req->getSink()->diagnose(SourceLoc(), Diagnostics::unableToWriteReproFile, req->dumpRepro); @@ -3340,9 +3340,9 @@ SLANG_API SlangResult spCompile( SlangResult saveRes = SLANG_FAIL; RefPtr<Stream> stream; - if (SLANG_SUCCEEDED(StateSerializeUtil::findUniqueReproDumpStream(req, reproFileName, stream))) + if (SLANG_SUCCEEDED(ReproUtil::findUniqueReproDumpStream(req, reproFileName, stream))) { - saveRes = StateSerializeUtil::saveState(req, stream); + saveRes = ReproUtil::saveState(req, stream); } if (SLANG_FAILED(saveRes)) @@ -3566,14 +3566,14 @@ SLANG_API SlangResult spLoadRepro( auto request = asInternal(inRequest); List<uint8_t> buffer; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState((const uint8_t*)data, size, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState((const uint8_t*)data, size, buffer)); MemoryOffsetBase base; base.set(buffer.getBuffer(), buffer.getCount()); - StateSerializeUtil::RequestState* requestState = StateSerializeUtil::getRequest(buffer); + ReproUtil::RequestState* requestState = ReproUtil::getRequest(buffer); - SLANG_RETURN_ON_FAIL(StateSerializeUtil::load(base, requestState, fileSystem, request)); + SLANG_RETURN_ON_FAIL(ReproUtil::load(base, requestState, fileSystem, request)); return SLANG_OK; } @@ -3586,7 +3586,7 @@ SLANG_API SlangResult spSaveRepro( OwnedMemoryStream stream(FileAccess::Write); - SLANG_RETURN_ON_FAIL(StateSerializeUtil::saveState(request, &stream)); + SLANG_RETURN_ON_FAIL(ReproUtil::saveState(request, &stream)); RefPtr<ListBlob> listBlob(new ListBlob); @@ -3615,14 +3615,14 @@ SLANG_API SlangResult spExtractRepro(SlangSession* session, const void* reproDat List<uint8_t> buffer; { MemoryStreamBase memoryStream(FileAccess::Read, reproData, reproDataSize); - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(&memoryStream, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(&memoryStream, buffer)); } MemoryOffsetBase base; base.set(buffer.getBuffer(), buffer.getCount()); - StateSerializeUtil::RequestState* requestState = StateSerializeUtil::getRequest(buffer); - return StateSerializeUtil::extractFiles(base, requestState, fileSystem); + ReproUtil::RequestState* requestState = ReproUtil::getRequest(buffer); + return ReproUtil::extractFiles(base, requestState, fileSystem); } SLANG_API SlangResult spLoadReproAsFileSystem( @@ -3639,14 +3639,14 @@ SLANG_API SlangResult spLoadReproAsFileSystem( MemoryStreamBase stream(FileAccess::Read, reproData, reproDataSize); List<uint8_t> buffer; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadState(&stream, buffer)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadState(&stream, buffer)); - auto requestState = StateSerializeUtil::getRequest(buffer); + auto requestState = ReproUtil::getRequest(buffer); MemoryOffsetBase base; base.set(buffer.getBuffer(), buffer.getCount()); RefPtr<CacheFileSystem> cacheFileSystem; - SLANG_RETURN_ON_FAIL(StateSerializeUtil::loadFileSystem(base, requestState, replaceFileSystem, cacheFileSystem)); + SLANG_RETURN_ON_FAIL(ReproUtil::loadFileSystem(base, requestState, replaceFileSystem, cacheFileSystem)); *outFileSystem = cacheFileSystem.detach(); return SLANG_OK; diff --git a/source/slang/slang.vcxproj b/source/slang/slang.vcxproj index f6b321b7d..3be09765d 100644 --- a/source/slang/slang.vcxproj +++ b/source/slang/slang.vcxproj @@ -265,8 +265,8 @@ <ClInclude Include="slang-profile-defs.h" /> <ClInclude Include="slang-profile.h" /> <ClInclude Include="slang-reflection.h" /> + <ClInclude Include="slang-repro.h" /> <ClInclude Include="slang-source-loc.h" /> - <ClInclude Include="slang-state-serialize.h" /> <ClInclude Include="slang-syntax.h" /> <ClInclude Include="slang-token-defs.h" /> <ClInclude Include="slang-token.h" /> @@ -352,8 +352,8 @@ <ClCompile Include="slang-preprocessor.cpp" /> <ClCompile Include="slang-profile.cpp" /> <ClCompile Include="slang-reflection.cpp" /> + <ClCompile Include="slang-repro.cpp" /> <ClCompile Include="slang-source-loc.cpp" /> - <ClCompile Include="slang-state-serialize.cpp" /> <ClCompile Include="slang-stdlib.cpp" /> <ClCompile Include="slang-syntax.cpp" /> <ClCompile Include="slang-token.cpp" /> diff --git a/source/slang/slang.vcxproj.filters b/source/slang/slang.vcxproj.filters index a636e338a..64f912110 100644 --- a/source/slang/slang.vcxproj.filters +++ b/source/slang/slang.vcxproj.filters @@ -246,10 +246,10 @@ <ClInclude Include="slang-reflection.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="slang-source-loc.h"> + <ClInclude Include="slang-repro.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="slang-state-serialize.h"> + <ClInclude Include="slang-source-loc.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="slang-syntax.h"> @@ -503,10 +503,10 @@ <ClCompile Include="slang-reflection.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="slang-source-loc.cpp"> + <ClCompile Include="slang-repro.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="slang-state-serialize.cpp"> + <ClCompile Include="slang-source-loc.cpp"> <Filter>Source Files</Filter> </ClCompile> <ClCompile Include="slang-stdlib.cpp"> |
