double : DEF = -DREAL=1
double : $(BIN)
+demo : $(BIN) ../tools/stream_plot.py
+ mkdir -p ../data/
+ $(RM) ../data/performance.dat
+ ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null
+
+movie : $(BIN) ../tools/stream_plot.py
+ mkdir -p ../data/
+ $(RM) ../data/performance.dat
+ $(RM) ../data/movie.ogv
+ ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null & recordmydesktop --fps 10 --on-the-fly-encoding -o ../data/movie.ogv
+
# The tests will compile with the default REAL definition
# To change that you can run as `make DEFS="REAL=X" tests/<target>` where X is your chosen type
# But remember to make clean first.
$(RM) tests/*.test
$(RM) tests/*.out
$(RM) tests/*.err
-
clean_full: clean
$(RM) *.*~
}
);
+ double total_cpu_time = 0;
+ double total_gpu_time = 0;
+ double total_real_time = 0;
+ struct timespec real_clock_start;
+ struct timespec real_clock_now;
+ struct timespec real_clock_prev;
+ clock_gettime(CLOCK_MONOTONIC_RAW, &real_clock_start);
+ real_clock_now = real_clock_start;
+ double frames = 0;
+ double data_rate = 1; // period between data output to stdout (if <= 0 there will be no output)
+ uint64_t data_points = 0;
+ setbuf(stdout, NULL);
while (scr.PumpEvents())
{
+ real_clock_prev = real_clock_now;
+ ++frames;
scr.Clear();
+ //view.ForceBoundsDirty();
+ //view.ForceBufferDirty();
+ //view.ForceRenderDirty();
+
view.Render(scr.ViewportWidth(), scr.ViewportHeight());
- scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS)\n", (scr.GetLastFrameTimeCPU())* 1000.0, 1.0/scr.GetLastFrameTimeCPU());
- scr.DebugFontPrintF("[GPU] Render took %lf ms (%lf FPS)\n", (scr.GetLastFrameTimeGPU())* 1000.0, 1.0/scr.GetLastFrameTimeGPU());
+
+ double cpu_frame = scr.GetLastFrameTimeCPU();
+ double gpu_frame = scr.GetLastFrameTimeGPU();
+ clock_gettime(CLOCK_MONOTONIC_RAW, &real_clock_now);
+ double real_frame = (real_clock_now.tv_sec - real_clock_prev.tv_sec) + 1e-9*(real_clock_now.tv_nsec - real_clock_prev.tv_nsec);
+
+
+ total_real_time += real_frame; total_cpu_time += cpu_frame; total_gpu_time += gpu_frame;
+ if (data_rate > 0 && total_real_time > data_rate*(data_points+1))
+ {
+ printf("%lu\t%f\t%f\t%f\t%f\t%f\t%f\n", (uint64_t)frames, total_real_time, total_cpu_time, total_gpu_time, real_frame, cpu_frame, gpu_frame);
+ data_points++;
+ }
+ scr.DebugFontPrintF("Rendered frame %lu\n", (uint64_t)frames);
+ scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS) (total %lf s, avg FPS %lf)\n", cpu_frame*1e3, 1.0/cpu_frame, total_cpu_time,frames/total_cpu_time);
+ scr.DebugFontPrintF("[GPU] Render took %lf ms (%lf FPS) (total %lf s, avg FPS %lf)\n", gpu_frame*1e3, 1.0/gpu_frame, total_gpu_time, frames/total_gpu_time);
+ scr.DebugFontPrintF("[REALTIME] Render+Present+Cruft took %lf ms (%lf FPS) (total %lf s, avg FPS %lf)\n", real_frame*1e3, 1.0/real_frame, total_real_time,frames/total_real_time);
scr.DebugFontPrintF("View bounds: %s\n", view.GetBounds().Str().c_str());
+
if (view.UsingGPUTransform())
{
scr.DebugFontPrint("Doing coordinate transform on the GPU.\n");
y = view_bounds.y * Real(target.h);
w = view_bounds.w * Real(target.w);
h = view_bounds.h * Real(target.h);
- Debug("CPURenderBounds %s -> %s -> {%li,%li,%li,%li}", bounds.Str().c_str(), view_bounds.Str().c_str(), x, y, w, h);
+ //Debug("CPURenderBounds %s -> %s -> {%li,%li,%li,%li}", bounds.Str().c_str(), view_bounds.Str().c_str(), x, y, w, h);
}
/**
m_indexes.reserve(max_objects); //TODO: Can probably make this smaller? Or leave it out? Do we care?
// Initialise and resize the ibo (for GPU rendering)
+ m_ibo.Invalidate();
m_ibo.SetUsage(GraphicsBuffer::BufferUsageStaticDraw);
m_ibo.SetType(GraphicsBuffer::BufferTypeIndex);
m_ibo.Resize(max_objects * 2 * sizeof(uint32_t));
int64_t centre_x = bounds.x + bounds.w / 2;
int64_t centre_y = bounds.y + bounds.h / 2;
- Debug("Centre is %d, %d", centre_x, centre_y);
- Debug("Bounds are %d,%d,%d,%d", bounds.x, bounds.y, bounds.w, bounds.h);
- Debug("Windos is %d,%d", target.w, target.h);
+ //Debug("Centre is %d, %d", centre_x, centre_y);
+ //Debug("Bounds are %d,%d,%d,%d", bounds.x, bounds.y, bounds.w, bounds.h);
+ //Debug("Windos is %d,%d", target.w, target.h);
for (int64_t x = max(0L, bounds.x); x <= min(bounds.x+bounds.w, target.w-1); ++x)
{
for (int64_t y = max(0L, bounds.y); y <= min(bounds.y + bounds.h, target.h-1); ++y)
void RenderPixels(int x, int y, int w, int h, uint8_t * pixels) const;
+
// Returns the CPU time (in seconds) it took to render the last completed frame.
double GetLastFrameTimeCPU() const { return m_last_frame_time / SDL_GetPerformanceFrequency(); }
// Returns the GPU time (in seconds) it took to render the last completed frame.
void View::UpdateObjBoundsVBO()
{
- Debug("Called");
m_objbounds_vbo.Invalidate();
m_objbounds_vbo.SetType(GraphicsBuffer::BufferTypeVertex);
if (m_use_gpu_transform)
void View::PrepareRender()
{
// Prepare bounds vbo
+ m_bounds_ubo.Invalidate();
m_bounds_ubo.SetType(GraphicsBuffer::BufferTypeUniform);
m_bounds_ubo.SetUsage(GraphicsBuffer::BufferUsageStreamDraw);
void ToggleGPUTransform() { m_use_gpu_transform = (!m_use_gpu_transform); m_bounds_dirty = true; m_buffer_dirty = true; }
void ToggleGPURendering() { m_use_gpu_rendering = (!m_use_gpu_rendering); m_bounds_dirty = true; m_buffer_dirty = true; }
-
+
+ void ForceBoundsDirty() {m_bounds_dirty = true;}
+ void ForceBufferDirty() {m_buffer_dirty = true;}
+ void ForceRenderDirty() {m_render_dirty = true;}
+
+
private:
struct GPUObjBounds
{