summaryrefslogtreecommitdiff
path: root/retrace/daemon/glframe_retrace_stub.hpp
blob: 1c7b9c26ea22296cee235a388eb57df7a4bd94d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/**************************************************************************
 *
 * 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.
 *
 * Authors:
 *   Mark Janes <mark.a.janes@intel.com>
 **************************************************************************/

#ifndef _GLFRAME_RETRACE_STUB_HPP_
#define _GLFRAME_RETRACE_STUB_HPP_

#include <mutex>
#include <string>
#include <vector>

#include "glframe_retrace.hpp"

namespace glretrace {

class ThreadedRetrace;

// offloads the request to a thread which serializes request to the
// retrace process, and blocks on the result.
class FrameRetraceStub : public IFrameRetrace {
 public:
  // call once, to set up the retrace socket, and shut it down at
  // exit
  void Init(const char *host, int port);
  void Shutdown();
  void Stop();
  void Flush();

  virtual void openFile(const std::string &filename,
                        const std::vector<unsigned char> &md5,
                        uint64_t fileSize,
                        uint32_t frameNumber,
                        OnFrameRetrace *callback);
  virtual void retraceRenderTarget(ExperimentId experimentCount,
                                   const RenderSelection &selection,
                                   RenderTargetType type,
                                   RenderOptions options,
                                   OnFrameRetrace *callback) const;
  virtual void retraceShaderAssembly(const RenderSelection &selection,
                                     ExperimentId experimentCount,
                                     OnFrameRetrace *callback);
  virtual void retraceMetrics(const std::vector<MetricId> &ids,
                              ExperimentId experimentCount,
                              OnFrameRetrace *callback) const;
  virtual void retraceAllMetrics(const RenderSelection &selection,
                                 ExperimentId experimentCount,
                                 OnFrameRetrace *callback) const;
  virtual void replaceShaders(RenderId renderId,
                              ExperimentId experimentCount,
                              const std::string &vs,
                              const std::string &fs,
                              const std::string &tessControl,
                              const std::string &tessEval,
                              const std::string &geom,
                              const std::string &comp,
                              OnFrameRetrace *callback);
  virtual void disableDraw(const RenderSelection &selection,
                           bool disable);
  virtual void simpleShader(const RenderSelection &selection,
                            bool simple);
  virtual void retraceApi(const RenderSelection &selection,
                          OnFrameRetrace *callback);
  virtual void retraceBatch(const RenderSelection &selection,
                            ExperimentId experimentCount,
                            OnFrameRetrace *callback);
  virtual void retraceUniform(const RenderSelection &selection,
                              ExperimentId experimentCount,
                              OnFrameRetrace *callback);
  virtual void setUniform(const RenderSelection &selection,
                          const std::string &name,
                          int index,
                          const std::string &data);
  virtual void retraceState(const RenderSelection &selection,
                            ExperimentId experimentCount,
                            OnFrameRetrace *callback);
  virtual void setState(const RenderSelection &selection,
                        const StateKey &item,
                        const std::string &value);

 private:
  mutable std::mutex m_mutex;
  mutable SelectionId m_current_rt_selection, m_current_met_selection,
    m_current_render_selection;
  mutable ExperimentId m_current_experiment;
  ThreadedRetrace *m_thread = NULL;
};
}  // namespace glretrace

#endif  // _GLFRAME_RETRACE_STUB_HPP_