Emit only one warning about ARB_depth_buffer_float or ARB_clip_control.
This code was warning on every frame, which was unhelpful. PiperOrigin-RevId: 604267726 Change-Id: Ied1d46e3d84d58f3b21201e3752e3c2d43ea3ba9
This commit is contained in:
committed by
Copybara-Service
parent
2bbf5424e4
commit
e3dc54f609
+28
-4
@@ -93,6 +93,32 @@ void mjr_restoreBuffer(const mjrContext* con) {
|
||||
|
||||
|
||||
|
||||
// emit one warning about mjGLAD_GL_ARB_clip_control
|
||||
static void warnAboutARBClipControl(void) {
|
||||
// not thread safe, but the consequence is just too many log lines
|
||||
static int warned = 0;
|
||||
if (!warned) {
|
||||
warned = 1;
|
||||
mju_warning("ARB_clip_control unavailable while mjDEPTH_ZEROFAR requested, "
|
||||
"depth accuracy will be limited");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// emit one warning about mjGLAD_GL_ARB_depth_buffer_float
|
||||
static void warnAboutARBDepthBuffer(void) {
|
||||
// not thread safe, but the consequence is just too many log lines
|
||||
static int warned = 0;
|
||||
if (!warned) {
|
||||
warned = 1;
|
||||
mju_warning("ARB_depth_buffer_float unavailable while mjDEPTH_ZEROFAR requested, "
|
||||
"depth accuracy will be limited");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline void flipDepthIfRequired(float* depth, mjrRect viewport, const mjrContext* con) {
|
||||
if (con->readDepthMap == mjDEPTH_ZERONEAR) {
|
||||
int npixel = viewport.width * viewport.height;
|
||||
@@ -100,11 +126,9 @@ static inline void flipDepthIfRequired(float* depth, mjrRect viewport, const mjr
|
||||
depth[i] = 1.0 - depth[i]; // Reverse the reversed Z buffer
|
||||
}
|
||||
} else if (!mjGLAD_GL_ARB_clip_control) {
|
||||
mju_warning("ARB_clip_control unavailable while mjDEPTH_ZEROFAR requested, "
|
||||
"depth accuracy will be limited");
|
||||
warnAboutARBClipControl();
|
||||
} else if (!mjGLAD_GL_ARB_depth_buffer_float) {
|
||||
mju_warning("ARB_depth_buffer_float unavailable while mjDEPTH_ZEROFAR requested, "
|
||||
"depth accuracy will be limited");
|
||||
warnAboutARBDepthBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user