diff options
-rw-r--r-- | retrace/daemon/CMakeLists.txt | 2 | ||||
-rw-r--r-- | retrace/daemon/glframe_perf_enabled.hpp | 43 | ||||
-rw-r--r-- | retrace/daemon/glframe_perf_enabled_linux.cpp | 51 | ||||
-rw-r--r-- | retrace/daemon/glframe_retrace.cpp | 11 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_daemon_test.cpp | 13 |
5 files changed, 119 insertions, 1 deletions
diff --git a/retrace/daemon/CMakeLists.txt b/retrace/daemon/CMakeLists.txt index b2affde4..da428f04 100644 --- a/retrace/daemon/CMakeLists.txt +++ b/retrace/daemon/CMakeLists.txt @@ -26,6 +26,7 @@ include_directories ( ) set (RETRACE_LINUX_SOURCE + glframe_perf_enabled_linux.cpp glframe_os_linux.cpp glframe_stderr.cpp glframe_thread_linux.cpp @@ -52,6 +53,7 @@ set (RETRACE_SOURCES glframe_os.hpp glframe_logger.cpp glframe_logger.hpp + glframe_perf_enabled.hpp glframe_retrace.cpp glframe_retrace.hpp glframe_retrace_interface.hpp diff --git a/retrace/daemon/glframe_perf_enabled.hpp b/retrace/daemon/glframe_perf_enabled.hpp new file mode 100644 index 00000000..5b225678 --- /dev/null +++ b/retrace/daemon/glframe_perf_enabled.hpp @@ -0,0 +1,43 @@ +/************************************************************************** + * + * Copyright 2017 Intel Corporation + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Authors: + * Mark Janes <mark.a.janes@intel.com> + **************************************************************************/ + +#ifndef _GLFRAME_PERF_ENABLED_HPP__ +#define _GLFRAME_PERF_ENABLED_HPP__ + +namespace glretrace { + +bool perf_enabled(); + +#ifdef WIN32 +inline bool perf_enabled() { + return true; +} +#endif + +} // namespace glretrace + +#endif // _GLFRAME_PERF_ENABLED_HPP__ diff --git a/retrace/daemon/glframe_perf_enabled_linux.cpp b/retrace/daemon/glframe_perf_enabled_linux.cpp new file mode 100644 index 00000000..83ff74a8 --- /dev/null +++ b/retrace/daemon/glframe_perf_enabled_linux.cpp @@ -0,0 +1,51 @@ +/************************************************************************** + * + * Copyright 2017 Intel Corporation + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Authors: + * Mark Janes <mark.a.janes@intel.com> + **************************************************************************/ + +#include "glframe_perf_enabled.hpp" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> + +const char *perf_fn = "/proc/sys/dev/i915/perf_stream_paranoid"; + +bool glretrace::perf_enabled() { + int fh = open(perf_fn, O_RDONLY); + if (fh == -1) + return true; + char buf[256]; + ssize_t bytes = read(fh, buf, 255); + if (bytes < 1) + return true; + buf[255] = '\0'; + if (buf[0] != '0') + return false; + return true; +} + + diff --git a/retrace/daemon/glframe_retrace.cpp b/retrace/daemon/glframe_retrace.cpp index 6b0a156d..b9fa7f4c 100644 --- a/retrace/daemon/glframe_retrace.cpp +++ b/retrace/daemon/glframe_retrace.cpp @@ -38,6 +38,7 @@ #include "glframe_glhelper.hpp" #include "glframe_logger.hpp" #include "glframe_metrics.hpp" +#include "glframe_perf_enabled.hpp" #include "glframe_retrace_render.hpp" #include "glframe_stderr.hpp" #include "glretrace.hpp" @@ -109,6 +110,16 @@ FrameRetrace::openFile(const std::string &filename, uint32_t framenumber, OnFrameRetrace *callback) { check_gpu_speed(callback); + + if (perf_enabled() == false) { + std::stringstream msg; + msg << "Performance counters not enabled.\n" + "To enable counters, execute as root: " + "`/sbin/sysctl dev.i915.perf_stream_paranoid=0`"; + callback->onError(RETRACE_FATAL, msg.str()); + return; + } + assemblyOutput.init(); retrace::debug = 0; retracer.addCallbacks(glretrace::gl_callbacks); diff --git a/retrace/daemon/test/retrace_daemon_test.cpp b/retrace/daemon/test/retrace_daemon_test.cpp index 62d8e147..c0562a0a 100644 --- a/retrace/daemon/test/retrace_daemon_test.cpp +++ b/retrace/daemon/test/retrace_daemon_test.cpp @@ -95,12 +95,15 @@ class NullCallback : public OnFrameRetrace { last_selection = selectionCount; calls[renderId] = api_calls; } - void onError(ErrorSeverity s, const std::string &message) {} + void onError(ErrorSeverity s, const std::string &message) { + file_error = true; + } int renderTargetCount; SelectionId last_selection; std::string compile_error; std::vector<std::string> fs; std::map<RenderId, std::vector<std::string>> calls; + bool file_error; }; void @@ -134,6 +137,8 @@ TEST_F(RetraceTest, LoadFile) { FrameRetrace rt; get_md5(test_file, &md5, &fileSize); rt.openFile(test_file, md5, fileSize, 7, &cb); + if (cb.file_error) + return; int renderCount = rt.getRenderCount(); EXPECT_EQ(renderCount, 2); // 1 for clear, 1 for draw cb.renderTargetCount = 0; @@ -164,6 +169,8 @@ TEST_F(RetraceTest, ReplaceShaders) { FrameRetrace rt; get_md5(test_file, &md5, &fileSize); rt.openFile(test_file, md5, fileSize, 7, &cb); + if (cb.file_error) + return; rt.replaceShaders(RenderId(1), ExperimentId(0), "bug", "blarb", "", "", "", "", &cb); EXPECT_GT(cb.compile_error.size(), 0); @@ -188,6 +195,8 @@ TEST_F(RetraceTest, ApiCalls) { FrameRetrace rt; get_md5(test_file, &md5, &fileSize); rt.openFile(test_file, md5, fileSize, 7, &cb); + if (cb.file_error) + return; RenderSelection sel; sel.id = SelectionId(5); @@ -228,6 +237,8 @@ TEST_F(RetraceTest, ShaderAssembly) { FrameRetrace rt; get_md5(test_file, &md5, &fileSize); rt.openFile(test_file, md5, fileSize, 7, &cb); + if (cb.file_error) + return; RenderSelection selection; std::string expected("uniform sampler2D texUnit;\n" "varying vec2 v_TexCoordinate;\nvoid main(void) {\n" |