--deqp-log-filename=<path>
+By default, the shader cache will be written into the path "shadercache.bin". If the
+platform requires a different path, it can be specified with:
+
+ --deqp-shadercache-filename=<path>
+
+If the shader cache is not desired, it can be disabled with:
+
+ --deqp-shadercache=disable
+
No other command line options are allowed.
### Win32
optimizer on the hand-written SPIR-V as well, which may be useful in
finding new bugs in drivers or the optimizer itself, but will likely
invalidate the tests themselves.
+
+
+Shader Cache
+------------
+
+The Vulkan CTS framework contains a shader cache for speeding up the running
+of the CTS. Skipping shader compilation can significantly reduce runtime,
+especially for repeated runs.
+
+Default behavior is to have the shader cache enabled, but truncated at the
+start of the CTS run. This still gives the benefit of skipping shader
+compilation for identical shaders in different tests (which there are many),
+while making sure that the shader cache file does not grow indefinitely.
+
+The shader cache identifies the shaders by hashing the shader source code
+along with various bits of information that may affect the shader compilation
+(such as shader stage, CTS version, possible compilation flags, etc). If a
+cached shader with matching hash is found, a byte-by-byte comparison of the
+shader sources is made to make sure that the correct shader is being
+retrieved from the cache.
+
+The behavior of the shader cache can be modified with the following command
+line options:
+
+ --deqp-shadercache=disable
+
+Disable the shader cache. All shaders will be compiled every time.
+
+ --deqp-shadercache-filename=<filename>
+
+Set the name of the file where the cached shaders will be stored. This
+option may be required for the shader cache to work at all on Android
+targets.
+
+ --deqp-shadercache-truncate=disable
+
+Do not truncate the shader cache file at startup. No shader compilation will
+occur on repeated runs of the CTS.
de::Mutex cacheFileMutex;
map<deUint32, vector<deUint32> > cacheFileIndex;
+bool cacheFileFirstRun = true;
+
+void shaderCacheFirstRunCheck (const char* shaderCacheFile, bool truncate)
+{
+ cacheFileMutex.lock();
+ if (cacheFileFirstRun)
+ {
+ cacheFileFirstRun = false;
+ if (truncate)
+ {
+ // Open file with "w" access to truncate it
+ FILE* f = fopen(shaderCacheFile, "wb");
+ if (f)
+ fclose(f);
+ }
+ else
+ {
+ // Parse chunked shader cache file for hashes and offsets
+ FILE* file = fopen(shaderCacheFile, "rb");
+ int count = 0;
+ if (file)
+ {
+ deUint32 chunksize = 0;
+ deUint32 hash = 0;
+ deUint32 offset = 0;
+ bool ok = true;
+ while (ok)
+ {
+ offset = (deUint32)ftell(file);
+ if (ok) ok = fread(&chunksize, 1, 4, file) == 4;
+ if (ok) ok = fread(&hash, 1, 4, file) == 4;
+ if (ok) cacheFileIndex[hash].push_back(offset);
+ if (ok) ok = fseek(file, offset + chunksize, SEEK_SET) == 0;
+ count++;
+ }
+ fclose(file);
+ }
+ }
+ }
+ cacheFileMutex.unlock();
+}
std::string intToString (deUint32 integer)
{
return temp_sstream.str();
}
-// Parse chunked shader cache file for hashes and offsets
-void shaderCacheParse (const char* shaderCacheFile)
-{
- FILE* file = fopen(shaderCacheFile, "rb");
- int count = 0;
- if (file)
- {
- deUint32 chunksize = 0;
- deUint32 hash = 0;
- deUint32 offset = 0;
- bool ok = true;
- while (ok)
- {
- offset = (deUint32)ftell(file);
- if (ok) ok = fread(&chunksize, 1, 4, file) == 4;
- if (ok) ok = fread(&hash, 1, 4, file) == 4;
- if (ok) cacheFileIndex[hash].push_back(offset);
- if (ok) ok = fseek(file, offset + chunksize, SEEK_SET) == 0;
- count++;
- }
- fclose(file);
- }
-}
-
vk::ProgramBinary* shadercacheLoad (const std::string& shaderstring, const char* shaderCacheFilename)
{
deUint32 hash = deStringHash(shaderstring.c_str());
char* source = 0;
bool ok = true;
cacheFileMutex.lock();
- if (cacheFileIndex.empty())
- shaderCacheParse(shaderCacheFilename);
if (cacheFileIndex.count(hash) == 0)
{
if (commandLine.isShadercacheEnabled())
{
+ shaderCacheFirstRunCheck(commandLine.getShaderCacheFilename(), commandLine.isShaderCacheTruncateEnabled());
getCompileEnvironment(shaderstring);
getBuildOptions(shaderstring, program.buildOptions, optimizationRecipe);
if (commandLine.isShadercacheEnabled())
{
+ shaderCacheFirstRunCheck(commandLine.getShaderCacheFilename(), commandLine.isShaderCacheTruncateEnabled());
getCompileEnvironment(shaderstring);
getBuildOptions(shaderstring, program.buildOptions, optimizationRecipe);
if (commandLine.isShadercacheEnabled())
{
+ shaderCacheFirstRunCheck(commandLine.getShaderCacheFilename(), commandLine.isShaderCacheTruncateEnabled());
getCompileEnvironment(shaderstring);
shaderstring += "Target Spir-V ";
shaderstring += getSpirvVersionName(spirvVersion);
DE_DECLARE_COMMAND_LINE_OPT(VulkanVersion, deUint32);
DE_DECLARE_COMMAND_LINE_OPT(ShaderCache, bool);
DE_DECLARE_COMMAND_LINE_OPT(ShaderCacheFilename, std::string);
+DE_DECLARE_COMMAND_LINE_OPT(ShaderCacheTruncate, bool);
static const de::cmdline::NamedValue<bool> s_enableNames[] =
{
DE_STATIC_ASSERT(vk::SPIRV_VERSION_1_3 + 1 == vk::SPIRV_VERSION_LAST);
- parser << Option<opt::DstPath> ("d", "dst-path", "Destination path", "out")
- << Option<opt::Cases> ("n", "deqp-case", "Case path filter (works as in test binaries)")
- << Option<opt::Validate> ("v", "validate-spv", "Validate generated SPIR-V binaries")
- << Option<opt::VulkanVersion> ("t", "target-vulkan-version", "Target Vulkan version", s_vulkanVersion, "1.1")
- << Option<opt::ShaderCache> ("s", "shadercache", "Enable or disable shader cache", s_enableNames, "disable")
- << Option<opt::ShaderCacheFilename> ("r", "shadercache-filename", "Write shader cache to given file", "shadercache.bin");
+ parser << Option<opt::DstPath>("d", "dst-path", "Destination path", "out")
+ << Option<opt::Cases>("n", "deqp-case", "Case path filter (works as in test binaries)")
+ << Option<opt::Validate>("v", "validate-spv", "Validate generated SPIR-V binaries")
+ << Option<opt::VulkanVersion>("t", "target-vulkan-version", "Target Vulkan version", s_vulkanVersion, "1.1")
+ << Option<opt::ShaderCache>("s", "shadercache", "Enable or disable shader cache", s_enableNames, "enable")
+ << Option<opt::ShaderCacheFilename>("r", "shadercache-filename", "Write shader cache to given file", "shadercache.bin")
+ << Option<opt::ShaderCacheTruncate>("x", "shadercache-truncate", "Truncate shader cache before running", s_enableNames, "enable");
}
} // opt
deqpArgv.push_back("disable");
}
+ if (cmdLine.hasOption<opt::ShaderCacheTruncate>())
+ {
+ deqpArgv.push_back("--deqp-shadercache-truncate");
+ if (cmdLine.getOption<opt::ShaderCacheTruncate>())
+ deqpArgv.push_back("enable");
+ else
+ deqpArgv.push_back("disable");
+ }
+
if (!deqpCmdLine.parse((int)deqpArgv.size(), &deqpArgv[0]))
return -1;
}
DE_DECLARE_COMMAND_LINE_OPT(ShaderCacheFilename, std::string);
DE_DECLARE_COMMAND_LINE_OPT(Optimization, int);
DE_DECLARE_COMMAND_LINE_OPT(OptimizeSpirv, bool);
+DE_DECLARE_COMMAND_LINE_OPT(ShaderCacheTruncate, bool);
static void parseIntList (const char* src, std::vector<int>* dst)
{
<< Option<TestOOM> (DE_NULL, "deqp-test-oom", "Run tests that exhaust memory on purpose", s_enableNames, TEST_OOM_DEFAULT)
<< Option<LogFlush> (DE_NULL, "deqp-log-flush", "Enable or disable log file fflush", s_enableNames, "enable")
<< Option<Validation> (DE_NULL, "deqp-validation", "Enable or disable test case validation", s_enableNames, "disable")
- << Option<ShaderCache> (DE_NULL, "deqp-shadercache", "Enable or disable shader cache", s_enableNames, "disable")
- << Option<ShaderCacheFilename> (DE_NULL, "deqp-shadercache-filename", "Write shader cache to given file", "shadercache.bin")
<< Option<Optimization> (DE_NULL, "deqp-optimization-recipe", "Shader optimization recipe (0=disabled)", "0")
- << Option<OptimizeSpirv> (DE_NULL, "deqp-optimize-spirv", "Apply optimization to spir-v shaders as well", s_enableNames, "disable");
+ << Option<OptimizeSpirv> (DE_NULL, "deqp-optimize-spirv", "Apply optimization to spir-v shaders as well", s_enableNames, "disable")
+ << Option<ShaderCache> (DE_NULL, "deqp-shadercache", "Enable or disable shader cache", s_enableNames, "enable")
+ << Option<ShaderCacheFilename> (DE_NULL, "deqp-shadercache-filename", "Write shader cache to given file", "shadercache.bin")
+ << Option<ShaderCacheTruncate> (DE_NULL, "deqp-shadercache-truncate", "Truncate shader cache before running tests", s_enableNames, "enable");
}
void registerLegacyOptions (de::cmdline::Parser& parser)
return isOk;
}
-const char* CommandLine::getLogFileName (void) const { return m_cmdLine.getOption<opt::LogFilename>().c_str(); }
-deUint32 CommandLine::getLogFlags (void) const { return m_logFlags; }
-RunMode CommandLine::getRunMode (void) const { return m_cmdLine.getOption<opt::RunMode>(); }
-const char* CommandLine::getCaseListExportFile (void) const { return m_cmdLine.getOption<opt::ExportFilenamePattern>().c_str(); }
-WindowVisibility CommandLine::getVisibility (void) const { return m_cmdLine.getOption<opt::Visibility>(); }
-bool CommandLine::isWatchDogEnabled (void) const { return m_cmdLine.getOption<opt::WatchDog>(); }
-bool CommandLine::isCrashHandlingEnabled (void) const { return m_cmdLine.getOption<opt::CrashHandler>(); }
-int CommandLine::getBaseSeed (void) const { return m_cmdLine.getOption<opt::BaseSeed>(); }
-int CommandLine::getTestIterationCount (void) const { return m_cmdLine.getOption<opt::TestIterationCount>(); }
-int CommandLine::getSurfaceWidth (void) const { return m_cmdLine.getOption<opt::SurfaceWidth>(); }
-int CommandLine::getSurfaceHeight (void) const { return m_cmdLine.getOption<opt::SurfaceHeight>(); }
-SurfaceType CommandLine::getSurfaceType (void) const { return m_cmdLine.getOption<opt::SurfaceType>(); }
-ScreenRotation CommandLine::getScreenRotation (void) const { return m_cmdLine.getOption<opt::ScreenRotation>(); }
-int CommandLine::getGLConfigId (void) const { return m_cmdLine.getOption<opt::GLConfigID>(); }
-int CommandLine::getCLPlatformId (void) const { return m_cmdLine.getOption<opt::CLPlatformID>(); }
-const std::vector<int>& CommandLine::getCLDeviceIds (void) const { return m_cmdLine.getOption<opt::CLDeviceIDs>(); }
-int CommandLine::getVKDeviceId (void) const { return m_cmdLine.getOption<opt::VKDeviceID>(); }
-int CommandLine::getVKDeviceGroupId (void) const { return m_cmdLine.getOption<opt::VKDeviceGroupID>(); }
-bool CommandLine::isValidationEnabled (void) const { return m_cmdLine.getOption<opt::Validation>(); }
-bool CommandLine::isOutOfMemoryTestEnabled (void) const { return m_cmdLine.getOption<opt::TestOOM>(); }
-bool CommandLine::isShadercacheEnabled (void) const { return m_cmdLine.getOption<opt::ShaderCache>(); }
-const char* CommandLine::getShaderCacheFilename (void) const { return m_cmdLine.getOption<opt::ShaderCacheFilename>().c_str(); }
-int CommandLine::getOptimizationRecipe (void) const { return m_cmdLine.getOption<opt::Optimization>(); }
-bool CommandLine::isSpirvOptimizationEnabled (void) const { return m_cmdLine.getOption<opt::OptimizeSpirv>(); }
+const char* CommandLine::getLogFileName (void) const { return m_cmdLine.getOption<opt::LogFilename>().c_str(); }
+deUint32 CommandLine::getLogFlags (void) const { return m_logFlags; }
+RunMode CommandLine::getRunMode (void) const { return m_cmdLine.getOption<opt::RunMode>(); }
+const char* CommandLine::getCaseListExportFile (void) const { return m_cmdLine.getOption<opt::ExportFilenamePattern>().c_str(); }
+WindowVisibility CommandLine::getVisibility (void) const { return m_cmdLine.getOption<opt::Visibility>(); }
+bool CommandLine::isWatchDogEnabled (void) const { return m_cmdLine.getOption<opt::WatchDog>(); }
+bool CommandLine::isCrashHandlingEnabled (void) const { return m_cmdLine.getOption<opt::CrashHandler>(); }
+int CommandLine::getBaseSeed (void) const { return m_cmdLine.getOption<opt::BaseSeed>(); }
+int CommandLine::getTestIterationCount (void) const { return m_cmdLine.getOption<opt::TestIterationCount>(); }
+int CommandLine::getSurfaceWidth (void) const { return m_cmdLine.getOption<opt::SurfaceWidth>(); }
+int CommandLine::getSurfaceHeight (void) const { return m_cmdLine.getOption<opt::SurfaceHeight>(); }
+SurfaceType CommandLine::getSurfaceType (void) const { return m_cmdLine.getOption<opt::SurfaceType>(); }
+ScreenRotation CommandLine::getScreenRotation (void) const { return m_cmdLine.getOption<opt::ScreenRotation>(); }
+int CommandLine::getGLConfigId (void) const { return m_cmdLine.getOption<opt::GLConfigID>(); }
+int CommandLine::getCLPlatformId (void) const { return m_cmdLine.getOption<opt::CLPlatformID>(); }
+const std::vector<int>& CommandLine::getCLDeviceIds (void) const { return m_cmdLine.getOption<opt::CLDeviceIDs>(); }
+int CommandLine::getVKDeviceId (void) const { return m_cmdLine.getOption<opt::VKDeviceID>(); }
+int CommandLine::getVKDeviceGroupId (void) const { return m_cmdLine.getOption<opt::VKDeviceGroupID>(); }
+bool CommandLine::isValidationEnabled (void) const { return m_cmdLine.getOption<opt::Validation>(); }
+bool CommandLine::isOutOfMemoryTestEnabled (void) const { return m_cmdLine.getOption<opt::TestOOM>(); }
+bool CommandLine::isShadercacheEnabled (void) const { return m_cmdLine.getOption<opt::ShaderCache>(); }
+const char* CommandLine::getShaderCacheFilename (void) const { return m_cmdLine.getOption<opt::ShaderCacheFilename>().c_str(); }
+bool CommandLine::isShaderCacheTruncateEnabled (void) const { return m_cmdLine.getOption<opt::ShaderCacheTruncate>(); }
+int CommandLine::getOptimizationRecipe (void) const { return m_cmdLine.getOption<opt::Optimization>(); }
+bool CommandLine::isSpirvOptimizationEnabled (void) const { return m_cmdLine.getOption<opt::OptimizeSpirv>(); }
const char* CommandLine::getGLContextType (void) const
{
class CommandLine
{
public:
- CommandLine (void);
- CommandLine (int argc, const char* const* argv);
- explicit CommandLine (const std::string& cmdLine);
- ~CommandLine (void);
+ CommandLine (void);
+ CommandLine (int argc, const char* const* argv);
+ explicit CommandLine (const std::string& cmdLine);
+ ~CommandLine (void);
- bool parse (int argc, const char* const* argv);
- bool parse (const std::string& cmdLine);
+ bool parse (int argc, const char* const* argv);
+ bool parse (const std::string& cmdLine);
//! Get log file name (--deqp-log-filename)
- const char* getLogFileName (void) const;
+ const char* getLogFileName (void) const;
//! Get logging flags
- deUint32 getLogFlags (void) const;
+ deUint32 getLogFlags (void) const;
//! Get run mode (--deqp-runmode)
- RunMode getRunMode (void) const;
+ RunMode getRunMode (void) const;
//! Get caselist dump target file pattern (--deqp-caselist-export-file)
- const char* getCaseListExportFile (void) const;
+ const char* getCaseListExportFile (void) const;
//! Get default window visibility (--deqp-visibility)
- WindowVisibility getVisibility (void) const;
+ WindowVisibility getVisibility (void) const;
//! Get watchdog enable status (--deqp-watchdog)
- bool isWatchDogEnabled (void) const;
+ bool isWatchDogEnabled (void) const;
//! Get crash handling enable status (--deqp-crashhandler)
- bool isCrashHandlingEnabled (void) const;
+ bool isCrashHandlingEnabled (void) const;
//! Get base seed for randomization (--deqp-base-seed)
- int getBaseSeed (void) const;
+ int getBaseSeed (void) const;
//! Get test iteration count (--deqp-test-iteration-count)
- int getTestIterationCount (void) const;
+ int getTestIterationCount (void) const;
//! Get rendering target width (--deqp-surface-width)
- int getSurfaceWidth (void) const;
+ int getSurfaceWidth (void) const;
//! Get rendering target height (--deqp-surface-height)
- int getSurfaceHeight (void) const;
+ int getSurfaceHeight (void) const;
//! Get rendering taget type (--deqp-surface-type)
- SurfaceType getSurfaceType (void) const;
+ SurfaceType getSurfaceType (void) const;
//! Get screen rotation (--deqp-screen-rotation)
- ScreenRotation getScreenRotation (void) const;
+ ScreenRotation getScreenRotation (void) const;
//! Get GL context factory name (--deqp-gl-context-type)
- const char* getGLContextType (void) const;
+ const char* getGLContextType (void) const;
//! Get GL config ID (--deqp-gl-config-id)
- int getGLConfigId (void) const;
+ int getGLConfigId (void) const;
//! Get GL config name (--deqp-gl-config-name)
- const char* getGLConfigName (void) const;
+ const char* getGLConfigName (void) const;
//! Get GL context flags (--deqp-gl-context-flags)
- const char* getGLContextFlags (void) const;
+ const char* getGLContextFlags (void) const;
//! Get OpenCL platform ID (--deqp-cl-platform-id)
- int getCLPlatformId (void) const;
+ int getCLPlatformId (void) const;
//! Get OpenCL device IDs (--deqp-cl-device-ids)
- void getCLDeviceIds (std::vector<int>& deviceIds) const { deviceIds = getCLDeviceIds(); }
- const std::vector<int>& getCLDeviceIds (void) const;
+ void getCLDeviceIds (std::vector<int>& deviceIds) const { deviceIds = getCLDeviceIds(); }
+ const std::vector<int>& getCLDeviceIds (void) const;
//! Get extra OpenCL program build options (--deqp-cl-build-options)
- const char* getCLBuildOptions (void) const;
+ const char* getCLBuildOptions (void) const;
//! Get EGL native display factory (--deqp-egl-display-type)
- const char* getEGLDisplayType (void) const;
+ const char* getEGLDisplayType (void) const;
//! Get EGL native window factory (--deqp-egl-window-type)
- const char* getEGLWindowType (void) const;
+ const char* getEGLWindowType (void) const;
//! Get EGL native pixmap factory (--deqp-egl-pixmap-type)
- const char* getEGLPixmapType (void) const;
+ const char* getEGLPixmapType (void) const;
//! Get Vulkan device ID (--deqp-vk-device-id)
- int getVKDeviceId (void) const;
+ int getVKDeviceId (void) const;
//! Get Vulkan device group ID (--deqp-vk-device-group-id)
- int getVKDeviceGroupId (void) const;
+ int getVKDeviceGroupId (void) const;
//! Enable development-time test case validation checks
- bool isValidationEnabled (void) const;
+ bool isValidationEnabled (void) const;
//! Should we run tests that exhaust memory (--deqp-test-oom)
- bool isOutOfMemoryTestEnabled (void) const;
+ bool isOutOfMemoryTestEnabled (void) const;
//! Should the shader cache be enabled (--deqp-shadercache)
- bool isShadercacheEnabled (void) const;
+ bool isShadercacheEnabled (void) const;
//! Get the filename for shader cache (--deqp-shadercache-filename)
- const char* getShaderCacheFilename (void) const;
+ const char* getShaderCacheFilename (void) const;
+
+ //! Should the shader cache be truncated before run (--deqp-shadercache-truncate)
+ bool isShaderCacheTruncateEnabled (void) const;
//! Get shader optimization recipe (--deqp-optimization-recipe)
int getOptimizationRecipe (void) const;