Skip to content

Commit

Permalink
Merge pull request #950 from daleglass-overte/fix-warnings
Browse files Browse the repository at this point in the history
Fix C++20 warnings
  • Loading branch information
daleglass authored May 4, 2024
2 parents 19144e4 + 84b16f4 commit f9ffccf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
24 changes: 12 additions & 12 deletions interface/src/LODManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ LODManager::LODManager() {
const float LOD_ADJUST_RUNNING_AVG_TIMESCALE = 0.08f; // sec

// batchTIme is always contained in presentTime.
// We favor using batchTime instead of presentTime as a representative value for rendering duration (on present thread)
// We favor using batchTime instead of presentTime as a representative value for rendering duration (on present thread)
// if batchTime + cushionTime < presentTime.
// since we are shooting for fps around 60, 90Hz, the ideal frames are around 10ms
// so we are picking a cushion time of 3ms
// so we are picking a cushion time of 3ms
const float LOD_BATCH_TO_PRESENT_CUSHION_TIME = 3.0f; // msec

void LODManager::setRenderTimes(float presentTime, float engineRunTime, float batchTime, float gpuTime) {
Expand All @@ -64,8 +64,8 @@ void LODManager::setRenderTimes(float presentTime, float engineRunTime, float ba
}

void LODManager::autoAdjustLOD(float realTimeDelta) {
std::lock_guard<std::mutex> { _automaticLODLock };
std::lock_guard<std::mutex> lock{ _automaticLODLock };

// The "render time" is the worse of:
// - engineRunTime: Time spent in the render thread in the engine producing the gpu::Frame N
// - batchTime: Time spent in the present thread processing the batches of gpu::Frame N+1
Expand All @@ -92,7 +92,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
float smoothBlend = (realTimeDelta < LOD_ADJUST_RUNNING_AVG_TIMESCALE * _smoothScale) ? realTimeDelta / (LOD_ADJUST_RUNNING_AVG_TIMESCALE * _smoothScale) : 1.0f;

//Evaluate the running averages for the render time
// We must sanity check for the output average evaluated to be in a valid range to avoid issues
// We must sanity check for the output average evaluated to be in a valid range to avoid issues
_nowRenderTime = (1.0f - nowBlend) * _nowRenderTime + nowBlend * maxRenderTime; // msec
_nowRenderTime = std::max(0.0f, std::min(_nowRenderTime, (float)MSECS_PER_SECOND));
_smoothRenderTime = (1.0f - smoothBlend) * _smoothRenderTime + smoothBlend * maxRenderTime; // msec
Expand All @@ -112,7 +112,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
// Current fps based on latest measurments
float currentNowFPS = (float)MSECS_PER_SECOND / _nowRenderTime;
float currentSmoothFPS = (float)MSECS_PER_SECOND / _smoothRenderTime;

// Compute the Variance of the FPS signal (FPS - smouthFPS)^2
// Also scale it by a percentage for fine tuning (default is 100%)
float currentVarianceFPS = (currentSmoothFPS - currentNowFPS);
Expand Down Expand Up @@ -165,7 +165,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {

// Compute the output of the PID and record intermediate results for tuning
_pidOutputs.x = _pidCoefs.x * error; // Kp * error
_pidOutputs.y = _pidCoefs.y * integral; // Ki * integral
_pidOutputs.y = _pidCoefs.y * integral; // Ki * integral
_pidOutputs.z = _pidCoefs.z * derivative; // Kd * derivative

auto output = _pidOutputs.x + _pidOutputs.y + _pidOutputs.z;
Expand Down Expand Up @@ -300,7 +300,7 @@ void LODManager::resetLODAdjust() {
}

void LODManager::setAutomaticLODAdjust(bool value) {
std::lock_guard<std::mutex> { _automaticLODLock };
std::lock_guard<std::mutex> lock{ _automaticLODLock };
_automaticLODAdjust = value;
saveSettings();
emit autoLODChanged();
Expand Down Expand Up @@ -399,7 +399,7 @@ void LODManager::loadSettings() {
if (qApp->property(hifi::properties::OCULUS_STORE).toBool() && firstRun.get()) {
hmdQuality = WORLD_DETAIL_HIGH;
}

_automaticLODAdjust = automaticLODAdjust.get();
_lodHalfAngle = lodHalfAngle.get();

Expand Down Expand Up @@ -457,7 +457,7 @@ float LODManager::getLODTargetFPS() const {
if (qApp->isHMDMode()) {
lodTargetFPS = getHMDLODTargetFPS();
}

// if RefreshRate is slower than LOD target then it becomes the true LOD target
if (lodTargetFPS > refreshRateFPS) {
return refreshRateFPS;
Expand All @@ -476,7 +476,7 @@ void LODManager::setWorldDetailQuality(WorldDetailQuality quality, bool isHMDMod
setDesktopLODTargetFPS(desiredFPS);
}
}

void LODManager::setWorldDetailQuality(WorldDetailQuality quality) {
setWorldDetailQuality(quality, qApp->isHMDMode());
saveSettings();
Expand All @@ -492,7 +492,7 @@ ScriptValue worldDetailQualityToScriptValue(ScriptEngine* engine, const WorldDet
}

bool worldDetailQualityFromScriptValue(const ScriptValue& object, WorldDetailQuality& worldDetailQuality) {
worldDetailQuality =
worldDetailQuality =
static_cast<WorldDetailQuality>(std::min(std::max(object.toInt32(), (int)WORLD_DETAIL_LOW), (int)WORLD_DETAIL_HIGH));
return true;
}
Expand Down
32 changes: 16 additions & 16 deletions libraries/gpu/src/gpu/Batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class QDebug;
#define BATCH_PREALLOCATE_MIN 128
namespace gpu {

// The named batch data provides a mechanism for accumulating data into buffers over the course
// of many independent calls. For instance, two objects in the scene might both want to render
// The named batch data provides a mechanism for accumulating data into buffers over the course
// of many independent calls. For instance, two objects in the scene might both want to render
// a simple box, but are otherwise unaware of each other. The common code that they call to render
// the box can create buffers to store the rendering parameters for each box and register a function
// that will be called with the accumulated buffer data when the batch commands are finally
// the box can create buffers to store the rendering parameters for each box and register a function
// that will be called with the accumulated buffer data when the batch commands are finally
// executed against the backend


Expand Down Expand Up @@ -100,15 +100,15 @@ class Batch {
void clear();

// Batches may need to override the context level stereo settings
// if they're performing framebuffer copy operations, like the
// if they're performing framebuffer copy operations, like the
// deferred lighting resolution mechanism
void enableStereo(bool enable = true);
bool isStereoEnabled() const;

// Stereo batches will pre-translate the view matrix, but this isn't
// appropriate for skyboxes or other things intended to be drawn at
// infinite distance, so provide a mechanism to render in stereo
// without the pre-translation of the view.
// Stereo batches will pre-translate the view matrix, but this isn't
// appropriate for skyboxes or other things intended to be drawn at
// infinite distance, so provide a mechanism to render in stereo
// without the pre-translation of the view.
void enableSkybox(bool enable = true);
bool isSkyboxEnabled() const;

Expand Down Expand Up @@ -147,7 +147,7 @@ class Batch {
// Indirect buffer is used by the multiDrawXXXIndirect calls
// The indirect buffer contains the command descriptions to execute multiple drawcalls in a single call
void setIndirectBuffer(const BufferPointer& buffer, Offset offset = 0, Offset stride = 0);

// multi command desctription for multiDrawIndexedIndirect
class DrawIndirectCommand {
public:
Expand Down Expand Up @@ -248,7 +248,7 @@ class Batch {
void popProfileRange();

// TODO: As long as we have gl calls explicitely issued from interface
// code, we need to be able to record and batch these calls. THe long
// code, we need to be able to record and batch these calls. THe long
// term strategy is to get rid of any GL calls in favor of the HIFI GPU API
// For now, instead of calling the raw gl Call, use the equivalent call on the batch so the call is beeing recorded
// THe implementation of these functions is in GLBackend.cpp
Expand Down Expand Up @@ -348,7 +348,7 @@ class Batch {
COMMAND_stopNamedCall,

// TODO: As long as we have gl calls explicitely issued from interface
// code, we need to be able to record and batch these calls. THe long
// code, we need to be able to record and batch these calls. THe long
// term strategy is to get rid of any GL calls in favor of the HIFI GPU API
COMMAND_glUniform1i,
COMMAND_glUniform1f,
Expand Down Expand Up @@ -377,15 +377,15 @@ class Batch {
union {
#if (QT_POINTER_SIZE == 8)
size_t _size;
#endif
#endif
int32 _int;
uint32 _uint;
float _float;
char _chars[sizeof(size_t)];
};
#if (QT_POINTER_SIZE == 8)
Param(size_t val) : _size(val) {}
#endif
#endif
Param(int32 val) : _int(val) {}
Param(uint32 val) : _uint(val) {}
Param(float val) : _float(val) {}
Expand All @@ -402,7 +402,7 @@ class Batch {
public:
typedef T Data;
Data _data;
Cache<T>(const Data& data) : _data(data) {}
Cache(const Data& data) : _data(data) {}
static size_t _max;

class Vector {
Expand Down Expand Up @@ -569,7 +569,7 @@ class ProfileRangeBatch {

#else

#define PROFILE_RANGE_BATCH(batch, name)
#define PROFILE_RANGE_BATCH(batch, name)

#endif

Expand Down
18 changes: 9 additions & 9 deletions libraries/gpu/src/gpu/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Buffer : public Resource {
Size getNumTypedElements() const { return getSize() / sizeof(T); };

const Byte* getData() const { return getSysmem().readData(); }

// Resize the buffer
// Keep previous data [0 to min(pSize, mSize)]
Size resize(Size pSize);
Expand Down Expand Up @@ -95,7 +95,7 @@ class Buffer : public Resource {
// \return the number of bytes copied
Size append(Size size, const Byte* data);

template <typename T>
template <typename T>
Size append(const T& t) {
return append(sizeof(t), reinterpret_cast<const Byte*>(&t));
}
Expand All @@ -110,10 +110,10 @@ class Buffer : public Resource {


const GPUObjectPointer gpuObject {};

// Access the sysmem object, limited to ourselves and GPUObject derived classes
const Sysmem& getSysmem() const { return _sysmem; }

bool isDirty() const {
return _pages(PageManager::DIRTY);
}
Expand All @@ -127,7 +127,7 @@ class Buffer : public Resource {
// For use by the render thread to avoid the intermediate step of getUpdate/applyUpdate
void flush() const;

// FIXME don't maintain a second buffer continuously. We should be able to apply updates
// FIXME don't maintain a second buffer continuously. We should be able to apply updates
// directly to the GL object and discard _renderSysmem and _renderPages
mutable PageManager _renderPages;
mutable Sysmem _renderSysmem;
Expand Down Expand Up @@ -292,7 +292,7 @@ class BufferView {
// Direct memory access to the buffer contents is incompatible with the paging memory scheme
template <typename T> Iterator<T> begin() { return Iterator<T>(&edit<T>(0), _stride); }
template <typename T> Iterator<T> end() { return Iterator<T>(&edit<T>(getNum<T>()), _stride); }
#else
#else
template <typename T> Iterator<const T> begin() const { return Iterator<const T>(&get<T>(), _stride); }
template <typename T> Iterator<const T> end() const {
// reimplement get<T> without bounds checking
Expand Down Expand Up @@ -378,7 +378,7 @@ class BufferView {
return *(reinterpret_cast<T*> (_buffer->editData() + elementOffset));
}
};


template <class T> class StructBuffer : public gpu::BufferView {
public:
Expand All @@ -387,8 +387,8 @@ class BufferView {
U t;
return std::make_shared<gpu::Buffer>(sizeof(U), (const gpu::Byte*) &t, sizeof(U));
}
~StructBuffer<T>() {};
StructBuffer<T>() : gpu::BufferView(makeBuffer<T>()) {}
~StructBuffer() {};
StructBuffer() : gpu::BufferView(makeBuffer<T>()) {}


T& edit() {
Expand Down
4 changes: 2 additions & 2 deletions libraries/shared/src/SimpleMovingAverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class SimpleMovingAverage {

template <class T, int MAX_NUM_SAMPLES> class MovingAverage {
public:
MovingAverage<T, MAX_NUM_SAMPLES>() {}
MovingAverage<T, MAX_NUM_SAMPLES>(const MovingAverage<T, MAX_NUM_SAMPLES>& other) {
MovingAverage() {}
MovingAverage(const MovingAverage<T, MAX_NUM_SAMPLES>& other) {
*this = other;
}
MovingAverage<T, MAX_NUM_SAMPLES>& operator=(const MovingAverage<T, MAX_NUM_SAMPLES>& other) {
Expand Down

0 comments on commit f9ffccf

Please sign in to comment.