File: FrameBuffer.ih

package info (click to toggle)
ospray 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,048 kB
  • sloc: cpp: 80,569; ansic: 951; sh: 805; makefile: 170; python: 69
file content (52 lines) | stat: -rw-r--r-- 1,694 bytes parent folder | download | duplicates (2)
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
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "OSPConfig.h"
#include "rkcommon/math/vec.ih"
// c++ shared
#include "FrameBufferShared.h"

#ifndef OSPRAY_TARGET_SYCL
extern "C" uint32 *uniform getThreadNumPixelsRendered();

extern "C" int *uniform getThreadLastFrameID();
#endif

// factor = rcp(accumID + 1), i.e. 1.0, 0.5, ...
// but rcp is not always accurate: rcp(1) can be < 1.0
// thus to be on the safe side we avoid the lerp for the first frame (to not
// mix-in stale data) and compare with a value in (0.5, 1.0], the magic 0.8
#define FRAMEBUFFER_ACCUMULATE_VALUE(value, new_value, factor)                 \
  value = (factor > 0.8f) ? new_value : lerp(factor, value, new_value)

OSPRAY_BEGIN_ISPC_NAMESPACE

#ifndef OSPRAY_TARGET_SYCL
inline void FrameBuffer_updateProgress(
    FrameBuffer *uniform self, const uniform uint32 numPixelsRendered)
{
  uint32 *uniform pixelsRendered = getThreadNumPixelsRendered();

  // Reset the pixels rendered counter for each new frame
  int *uniform lastFrameID = getThreadLastFrameID();
  if (self->frameID != *lastFrameID) {
    *pixelsRendered = 0;
    *lastFrameID = self->frameID;
  }

  // Update the pixels rendered count and report back to the atomic if we've
  // reached the reporting threshold
  *pixelsRendered += numPixelsRendered;

  // Report rendering results at the same frequency they would have been
  // reported (each tile) when using the old nested parallel fors over tiles
  // then pixels.
  if (*pixelsRendered >= TILE_SIZE * TILE_SIZE) {
    atomic_add_global(&self->numPixelsRendered, *pixelsRendered);
    *pixelsRendered = 0;
  }
}
#endif
OSPRAY_END_ISPC_NAMESPACE