diff options
author | Mark Janes <mark.a.janes@intel.com> | 2015-11-24 10:39:38 -0800 |
---|---|---|
committer | Mark Janes <mark.a.janes@intel.com> | 2017-06-19 14:04:46 -0700 |
commit | 191a32c98ccc6008032d197d0e1b62920ee6dc67 (patch) | |
tree | 254b09bfbaa06d7e13daba7f394023c429aedee8 /retrace/daemon/test | |
parent | 44046314b8727111e34894768a3b254d8a6bf7c5 (diff) |
enable shader override
This commit routes UI changes to the shader text through the
ReplaceShaders method in FrameRetrace.
It includes some basic unit tests for this function, and a bug fix to
the StateTracker that was discovered via the tests.
Diffstat (limited to 'retrace/daemon/test')
-rw-r--r-- | retrace/daemon/test/retrace_daemon_test.cpp | 43 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_metrics_test.cpp | 8 | ||||
-rw-r--r-- | retrace/daemon/test/retrace_test.hpp | 48 |
3 files changed, 86 insertions, 13 deletions
diff --git a/retrace/daemon/test/retrace_daemon_test.cpp b/retrace/daemon/test/retrace_daemon_test.cpp index 08a72e64..88fcca1c 100644 --- a/retrace/daemon/test/retrace_daemon_test.cpp +++ b/retrace/daemon/test/retrace_daemon_test.cpp @@ -31,8 +31,10 @@ #include "glws.hpp" +#include "retrace_test.hpp" #include "glframe_retrace.hpp" #include "glframe_glhelper.hpp" +#include "glframe_logger.hpp" using glretrace::ExperimentId; using glretrace::GlFunctions; @@ -41,6 +43,7 @@ using glretrace::MetricId; using glretrace::MetricSeries; using glretrace::OnFrameRetrace; using glretrace::RenderId; +using glretrace::Logger; using glretrace::RenderTargetType; TEST(Build, Cmake) { @@ -56,25 +59,29 @@ class NullCallback : public OnFrameRetrace { const std::string &vertex_shader, const std::string &vertex_ir, const std::string &vertex_vec4, - const std::string &fragemnt_shader, - const std::string &fragemnt_ir, - const std::string &fragemnt_simd8, - const std::string &fragemnt_simd16, + const std::string &fragment_shader, + const std::string &fragment_ir, + const std::string &fragment_simd8, + const std::string &fragment_simd16, const std::string &fragment_nir_ssa, - const std::string &fragment_nir_final) {} + const std::string &fragment_nir_final) { + fs = fragment_shader; + } void onRenderTarget(RenderId renderId, RenderTargetType type, const uvec & pngImageData) {} void onShaderCompile(RenderId renderId, ExperimentId count, bool status, - const std::string &errorString) {} + const std::string &errorString) { + compile_error = errorString; + } void onMetricList(const std::vector<MetricId> &ids, const std::vector<std::string> &names) {} void onMetrics(const MetricSeries &metricData, ExperimentId experimentCount) {} + std::string compile_error, fs; }; - -TEST(Daemon, LoadFile) { +TEST_F(RetraceTest, LoadFile) { retrace::setUp(); GlFunctions::Init(); @@ -88,5 +95,23 @@ TEST(Daemon, LoadFile) { rt.retraceRenderTarget(RenderId(i), 0, glretrace::NORMAL_RENDER, glretrace::STOP_AT_RENDER, &cb); } - retrace::cleanUp(); +} + +TEST_F(RetraceTest, ReplaceShaders) { + NullCallback cb; + FrameRetrace rt; + rt.openFile(test_file, 7, &cb); + rt.replaceShaders(RenderId(1), ExperimentId(0), "bug", "blarb", &cb); + EXPECT_GT(cb.compile_error.size(), 0); + + rt.retraceShaderAssembly(RenderId(1), &cb); + EXPECT_GT(cb.fs.size(), 0); + std::string vs("attribute vec2 coord2d;\n" + "varying vec2 v_TexCoordinate;\n" + "void main(void) {\n" + " gl_Position = vec4(coord2d.x, -1.0 * coord2d.y, 0, 1);\n" + " v_TexCoordinate = vec2(coord2d.x, coord2d.y);\n" + "}\n"); + rt.replaceShaders(RenderId(1), ExperimentId(0), vs, cb.fs, &cb); + EXPECT_EQ(cb.compile_error.size(), 0); } diff --git a/retrace/daemon/test/retrace_metrics_test.cpp b/retrace/daemon/test/retrace_metrics_test.cpp index ae2708e1..ed7e895b 100644 --- a/retrace/daemon/test/retrace_metrics_test.cpp +++ b/retrace/daemon/test/retrace_metrics_test.cpp @@ -29,6 +29,7 @@ #include <string> #include <vector> +#include "retrace_test.hpp" #include "glframe_glhelper.hpp" #include "glframe_metrics.hpp" #include "glframe_retrace.hpp" @@ -70,8 +71,7 @@ class MetricsCallback : public OnFrameRetrace { ExperimentId experiment_count; }; -TEST(Metrics, ReadMetrics) { - GlFunctions::Init(); +TEST_F(RetraceTest, ReadMetrics) { TestContext c; MetricsCallback cb; @@ -87,7 +87,7 @@ TEST(Metrics, ReadMetrics) { static const char *test_file = CMAKE_CURRENT_SOURCE_DIR "/simple.test_trace"; -TEST(Metrics, SingleMetricData) { +TEST_F(RetraceTest, SingleMetricData) { retrace::setUp(); GlFunctions::Init(); TestContext c; @@ -120,7 +120,7 @@ TEST(Metrics, SingleMetricData) { retrace::cleanUp(); } -TEST(Metrics, FrameMetricData) { +TEST_F(RetraceTest, FrameMetricData) { GlFunctions::Init(); MetricsCallback cb; diff --git a/retrace/daemon/test/retrace_test.hpp b/retrace/daemon/test/retrace_test.hpp new file mode 100644 index 00000000..84f60c3d --- /dev/null +++ b/retrace/daemon/test/retrace_test.hpp @@ -0,0 +1,48 @@ +/************************************************************************** + * + * Copyright 2015 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. + * + **************************************************************************/ + +#ifndef _RETRACE_TEST_HPP__ +#define _RETRACE_TEST_HPP__ + +#include <gtest/gtest.h> +#include "retrace.hpp" +#include "glframe_glhelper.hpp" +#include "glframe_logger.hpp" + +class RetraceTest : public ::testing::Test { + protected: + virtual void SetUp() { + retrace::setUp(); + glretrace::GlFunctions::Init(); + glretrace::Logger::Create("/tmp"); + glretrace::Logger::Begin(); + } + virtual void TearDown() { + glretrace::Logger::Destroy(); + retrace::cleanUp(); + } +}; + +#endif // _RETRACE_TEST_HPP__ |