diff --git a/ExternalDependencies.xcodeproj/project.pbxproj b/ExternalDependencies.xcodeproj/project.pbxproj index c8e58b0f..e8db3928 100644 --- a/ExternalDependencies.xcodeproj/project.pbxproj +++ b/ExternalDependencies.xcodeproj/project.pbxproj @@ -1659,7 +1659,6 @@ 450A4F64221C5A95007203D7 /* spirv_reflect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spirv_reflect.cpp; sourceTree = ""; }; A90FD89F21CC4EAB00B92BB2 /* libSPIRVCross.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSPIRVCross.a; sourceTree = BUILT_PRODUCTS_DIR; }; A90FD9E421CC4EB900B92BB2 /* libSPIRVCross.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSPIRVCross.a; sourceTree = BUILT_PRODUCTS_DIR; }; - A91BF011235F9C510039B7DE /* gen_spirv_cross_rev_hdr.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = gen_spirv_cross_rev_hdr.sh; sourceTree = ""; }; A932E9C5249A743B00D64150 /* create_fat_lib_func.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_fat_lib_func.sh; sourceTree = ""; }; A932E9DF249BC44D00D64150 /* create_fat_ext_libs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_fat_ext_libs.sh; sourceTree = ""; }; A9415EF624366B0E00566F16 /* packagePregenSpirvToolsHeaders */ = {isa = PBXFileReference; lastKnownFileType = text; path = packagePregenSpirvToolsHeaders; sourceTree = ""; }; @@ -2392,7 +2391,6 @@ children = ( A932E9DF249BC44D00D64150 /* create_fat_ext_libs.sh */, A932E9C5249A743B00D64150 /* create_fat_lib_func.sh */, - A91BF011235F9C510039B7DE /* gen_spirv_cross_rev_hdr.sh */, A9FC5F7F249DA96D003CB086 /* package_ext_libs_finish.sh */, A9679AAE21D269D900856BF7 /* package_ext_libs.sh */, A9415EF624366B0E00566F16 /* packagePregenSpirvToolsHeaders */, @@ -3764,7 +3762,6 @@ buildPhases = ( 2FEA0CDA2490322B00EEF3AD /* Headers */, 2FEA0CE32490322B00EEF3AD /* Sources */, - 2FEA0CEB2490322B00EEF3AD /* Generate Revision Header */, ); buildRules = ( ); @@ -3781,7 +3778,6 @@ buildPhases = ( A976290021CC608E00B52A68 /* Headers */, A976290121CC609100B52A68 /* Sources */, - A91BF013235F9EED0039B7DE /* Generate Revision Header */, ); buildRules = ( ); @@ -3798,7 +3794,6 @@ buildPhases = ( A97628FF21CC608900B52A68 /* Headers */, A97628FE21CC608400B52A68 /* Sources */, - A91BF012235F9E220039B7DE /* Generate Revision Header */, ); buildRules = ( ); @@ -3946,60 +3941,6 @@ shellPath = /bin/sh; shellScript = "export MVK_OS=\"tvOS\"\nexport MVK_BUILT_PROD_DIR=\"${BUILT_PRODUCTS_DIR}-${MVK_OS}\"\n\n. \"${SRCROOT}/Scripts/package_ext_libs.sh\"\n"; }; - 2FEA0CEB2490322B00EEF3AD /* Generate Revision Header */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Generate Revision Header"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Scripts/gen_spirv_cross_rev_hdr.sh\"\n"; - }; - A91BF012235F9E220039B7DE /* Generate Revision Header */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Generate Revision Header"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Scripts/gen_spirv_cross_rev_hdr.sh\"\n"; - }; - A91BF013235F9EED0039B7DE /* Generate Revision Header */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Generate Revision Header"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Scripts/gen_spirv_cross_rev_hdr.sh\"\n"; - }; A932E9C6249A7B9B00D64150 /* Create Fat Libraries */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/MoltenVK/MoltenVK.xcodeproj/project.pbxproj b/MoltenVK/MoltenVK.xcodeproj/project.pbxproj index 8d239d1e..f2a4d500 100644 --- a/MoltenVK/MoltenVK.xcodeproj/project.pbxproj +++ b/MoltenVK/MoltenVK.xcodeproj/project.pbxproj @@ -1037,6 +1037,7 @@ isa = PBXNativeTarget; buildConfigurationList = 2FEA0AB724902F9F00EEF3AD /* Build configuration list for PBXNativeTarget "MoltenVK-tvOS" */; buildPhases = ( + A980A25D24C6288D007A8F6F /* Generate Version Header */, 2FEA0A4024902F9F00EEF3AD /* Headers */, 2FEA0A8224902F9F00EEF3AD /* Sources */, 2FEA0AB524902F9F00EEF3AD /* Create Dynamic Library */, @@ -1058,6 +1059,7 @@ isa = PBXNativeTarget; buildConfigurationList = A9B8EE1D1A98D796009C5A02 /* Build configuration list for PBXNativeTarget "MoltenVK-iOS" */; buildPhases = ( + A980A25B24C6283D007A8F6F /* Generate Version Header */, A9B8EE071A98D796009C5A02 /* Headers */, A9B8EE051A98D796009C5A02 /* Sources */, A9731FAD1EDDAE39006B7298 /* Create Dynamic Library */, @@ -1079,6 +1081,7 @@ isa = PBXNativeTarget; buildConfigurationList = A9CBEDFE1B6299D800E45FDC /* Build configuration list for PBXNativeTarget "MoltenVK-macOS" */; buildPhases = ( + A980A25E24C62895007A8F6F /* Generate Version Header */, A9CBED871B6299D800E45FDC /* Headers */, A9CBEDCE1B6299D800E45FDC /* Sources */, A93F47C91D7E389E002AF700 /* Create Dynamic Library */, @@ -1288,6 +1291,60 @@ shellPath = /bin/sh; shellScript = ". \"${SRCROOT}/../Scripts/create_dylib_ios.sh\"\n"; }; + A980A25B24C6283D007A8F6F /* Generate Version Header */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Generate Version Header"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/../Scripts/gen_moltenvk_rev_hdr.sh\"\n"; + }; + A980A25D24C6288D007A8F6F /* Generate Version Header */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Generate Version Header"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/../Scripts/gen_moltenvk_rev_hdr.sh\"\n"; + }; + A980A25E24C62895007A8F6F /* Generate Version Header */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Generate Version Header"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/../Scripts/gen_moltenvk_rev_hdr.sh\"\n"; + }; A9EE084F249BD4AE00E523A2 /* Create Fat Libraries */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1633,6 +1690,7 @@ "\"$(SRCROOT)/include\"", "\"$(SRCROOT)/../MoltenVKShaderConverter\"", "\"$(SRCROOT)/../External/cereal/include\"", + "\"${BUILT_PRODUCTS_DIR}\"", ); MACH_O_TYPE = staticlib; MTL_ENABLE_DEBUG_INFO = YES; @@ -1692,6 +1750,7 @@ "\"$(SRCROOT)/include\"", "\"$(SRCROOT)/../MoltenVKShaderConverter\"", "\"$(SRCROOT)/../External/cereal/include\"", + "\"${BUILT_PRODUCTS_DIR}\"", ); MACH_O_TYPE = staticlib; MTL_ENABLE_DEBUG_INFO = NO; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h index 760bc93d..08718f32 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h @@ -350,7 +350,7 @@ protected: MVKArrayRef getQueueFamilies(); void initPipelineCacheUUID(); uint32_t getHighestMTLFeatureSet(); - uint64_t getSpirvCrossRevision(); + uint64_t getMoltenVKGitRevision(); bool getImageViewIsSupported(const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo); void populate(VkPhysicalDeviceIDProperties* pDevIdProps); void logGPUInfo(); diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 239dd29a..9c2dc86f 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -1939,10 +1939,10 @@ void MVKPhysicalDevice::initPipelineCacheUUID() { *(uint32_t*)&_properties.pipelineCacheUUID[uuidComponentOffset] = NSSwapHostIntToBig(mtlFeatSet); uuidComponentOffset += sizeof(mtlFeatSet); - // Last 8 bytes contain the first part of the SPIRV-Cross Git revision - uint64_t spvxRev = getSpirvCrossRevision(); - *(uint64_t*)&_properties.pipelineCacheUUID[uuidComponentOffset] = NSSwapHostLongLongToBig(spvxRev); - uuidComponentOffset += sizeof(spvxRev); + // Last 8 bytes contain the first part of the MoltenVK Git revision + uint64_t mvkRev = getMoltenVKGitRevision(); + *(uint64_t*)&_properties.pipelineCacheUUID[uuidComponentOffset] = NSSwapHostLongLongToBig(mvkRev); + uuidComponentOffset += sizeof(mvkRev); } uint32_t MVKPhysicalDevice::getHighestMTLFeatureSet() { @@ -1993,12 +1993,15 @@ uint32_t MVKPhysicalDevice::getHighestMTLFeatureSet() { return minFS; } -// Retrieve the SPIRV-Cross Git revision hash from a derived header file that was created in the fetchDependencies script. -uint64_t MVKPhysicalDevice::getSpirvCrossRevision() { +// Retrieve the SPIRV-Cross Git revision hash from a derived header file, +// which is generated in advance, either statically, or more typically in +// an early build phase script, and contains a line similar to the following: +// static const char* mvkRevString = "fc0750d67cfe825b887dd2cf25a42e9d9a013eb2"; +uint64_t MVKPhysicalDevice::getMoltenVKGitRevision() { -#include +#include "mvkGitRevDerived.h" - static const string revStr(spirvCrossRevisionString, 0, 16); // We just need the first 16 chars + static const string revStr(mvkRevString, 0, 16); // We just need the first 16 chars static const string lut("0123456789ABCDEF"); uint64_t revVal = 0; diff --git a/MoltenVKPackaging.xcodeproj/project.pbxproj b/MoltenVKPackaging.xcodeproj/project.pbxproj index ce4c20ce..5c40bb2c 100644 --- a/MoltenVKPackaging.xcodeproj/project.pbxproj +++ b/MoltenVKPackaging.xcodeproj/project.pbxproj @@ -232,6 +232,7 @@ A941E2B1221AEBD000890C56 /* create_framework_ios.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_framework_ios.sh; sourceTree = ""; }; A941E2B2221AEBD000890C56 /* create_framework_macos.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_framework_macos.sh; sourceTree = ""; }; A975D55C213F25D700D4834F /* create_dylib.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_dylib.sh; sourceTree = ""; }; + A980A25F24C628F3007A8F6F /* gen_moltenvk_rev_hdr.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = gen_moltenvk_rev_hdr.sh; sourceTree = ""; }; A98149E51FB78829005F00B4 /* MoltenVK_Runtime_UserGuide.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = MoltenVK_Runtime_UserGuide.md; path = Docs/MoltenVK_Runtime_UserGuide.md; sourceTree = ""; }; A99A760321852584000A8E2A /* create_framework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_framework.sh; sourceTree = ""; }; A9C70F41221B04C800FBA31A /* create_dylib_macos.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_dylib_macos.sh; sourceTree = ""; }; @@ -295,6 +296,7 @@ A941E2B2221AEBD000890C56 /* create_framework_macos.sh */, A9FC5F69249D3843003CB086 /* create_framework_tvos.sh */, A99A760321852584000A8E2A /* create_framework.sh */, + A980A25F24C628F3007A8F6F /* gen_moltenvk_rev_hdr.sh */, A9FC5F60249D2ED3003CB086 /* package_all.sh */, A92EF7C921856EA200C8B91B /* package_docs.sh */, A92EF7C621856EA200C8B91B /* package_moltenvk.sh */, diff --git a/Scripts/gen_moltenvk_rev_hdr.sh b/Scripts/gen_moltenvk_rev_hdr.sh new file mode 100755 index 00000000..c49ea4e6 --- /dev/null +++ b/Scripts/gen_moltenvk_rev_hdr.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Record the MoltenVK GIT revision as a derived header file suitable for including in a build +MVK_GIT_REV=$(git rev-parse HEAD) +MVK_HDR_FILE="${BUILT_PRODUCTS_DIR}/mvkGitRevDerived.h" +echo "// Auto-generated by MoltenVK" > "${MVK_HDR_FILE}" +echo "static const char* mvkRevString = \"${MVK_GIT_REV}\";" >> "${MVK_HDR_FILE}" + diff --git a/Scripts/gen_spirv_cross_rev_hdr.sh b/Scripts/gen_spirv_cross_rev_hdr.sh deleted file mode 100755 index 90968409..00000000 --- a/Scripts/gen_spirv_cross_rev_hdr.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Record the SPIRV-Cross revision as a derived header file suitable for including in a build -EXT_DIR="${SRCROOT}/External" -EXT_REV_DIR="${SRCROOT}/ExternalRevisions" -REPO_NAME=SPIRV-Cross -REPO_REV=$(cat "${EXT_REV_DIR}/${REPO_NAME}_repo_revision") -HDR_FILE=${EXT_DIR}/${REPO_NAME}/mvkSpirvCrossRevisionDerived.h -echo "// Auto-generated by MoltenVK" > "${HDR_FILE}" -echo "static const char* spirvCrossRevisionString = \"${REPO_REV}\";" >> "${HDR_FILE}" -