Skip to content

Commit b76ec90

Browse files
author
Nick Klingensmith
committed
Hide logs from intentional error based capability/property detection code
Signed-off-by: Nick Klingensmith <quic_nklingen@quicinc.com>
1 parent 849786b commit b76ec90

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

sk_gpu.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ typedef struct {
789789

790790
SKG_API void skg_log (skg_log_ level, const char *text);
791791
SKG_API void skg_logf (skg_log_ level, const char *text, ...);
792+
SKG_API void skg_log_enable (bool enabled);
792793
SKG_API bool skg_read_file (const char *filename, void **out_data, size_t *out_size);
793794
SKG_API uint64_t skg_hash (const char *string);
794795
SKG_API uint32_t skg_mip_count (int32_t width, int32_t height);
@@ -3917,6 +3918,7 @@ void gl_check_exts() {
39173918
while (glGetError() != 0) {}
39183919

39193920
// Create a texture of each format to check compatibility
3921+
skg_log_enable(false); // Intentional errors, don't scare the users
39203922
glActiveTexture(skg_settings_tex_slot);
39213923
for (int32_t i=0; i<skg_tex_fmt_max; i+=1) {
39223924
int64_t internal_format = (int64_t)skg_tex_fmt_to_native((skg_tex_fmt_)i);
@@ -3934,6 +3936,7 @@ void gl_check_exts() {
39343936

39353937
glDeleteTextures(1, &texture);
39363938
}
3939+
skg_log_enable(true);
39373940
};
39383941

39393942
///////////////////////////////////////////
@@ -5074,7 +5077,9 @@ skg_tex_t skg_tex_create_from_existing(void *native_tex, skg_tex_type_ type, skg
50745077

50755078
// Check if this is an external texture
50765079
gl_pipeline.tex_bind[0] = result._texture; // Similar to a PIPELINE_CHECK
5080+
skg_log_enable(false); // Intentional error, don't scare the users.
50775081
glBindTexture(GL_TEXTURE_EXTERNAL_OES, result._texture);
5082+
skg_log_enable(true);
50785083
if (!glGetError()) {
50795084
result._target = GL_TEXTURE_EXTERNAL_OES;
50805085
}
@@ -5829,14 +5834,18 @@ skg_shader_t skg_shader_create_manual(skg_shader_meta_t *meta, skg_shader_stage_
58295834
#include <android/asset_manager.h>
58305835
#endif
58315836

5837+
bool _skg_log_disabled = false;
5838+
58325839
void (*_skg_log)(skg_log_ level, const char *text);
58335840
void skg_callback_log(void (*callback)(skg_log_ level, const char *text)) {
58345841
_skg_log = callback;
58355842
}
58365843
void skg_log(skg_log_ level, const char *text) {
5844+
if (_skg_log_disabled) return;
58375845
if (_skg_log) _skg_log(level, text);
58385846
}
58395847
void skg_logf (skg_log_ level, const char *text, ...) {
5848+
if (_skg_log_disabled) return;
58405849
if (!_skg_log) return;
58415850

58425851
va_list args, copy;
@@ -5852,6 +5861,9 @@ void skg_logf (skg_log_ level, const char *text, ...) {
58525861
va_end(args);
58535862
va_end(copy);
58545863
}
5864+
void skg_log_enable(bool enabled) {
5865+
_skg_log_disabled = !enabled;
5866+
}
58555867

58565868
///////////////////////////////////////////
58575869

src/sk_gpu_common.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@
1313
#include <android/asset_manager.h>
1414
#endif
1515

16+
bool _skg_log_disabled = false;
17+
1618
void (*_skg_log)(skg_log_ level, const char *text);
1719
void skg_callback_log(void (*callback)(skg_log_ level, const char *text)) {
1820
_skg_log = callback;
1921
}
2022
void skg_log(skg_log_ level, const char *text) {
23+
if (_skg_log_disabled) return;
2124
if (_skg_log) _skg_log(level, text);
2225
}
2326
void skg_logf (skg_log_ level, const char *text, ...) {
27+
if (_skg_log_disabled) return;
2428
if (!_skg_log) return;
2529

2630
va_list args, copy;
@@ -36,6 +40,9 @@ void skg_logf (skg_log_ level, const char *text, ...) {
3640
va_end(args);
3741
va_end(copy);
3842
}
43+
void skg_log_enable(bool enabled) {
44+
_skg_log_disabled = !enabled;
45+
}
3946

4047
///////////////////////////////////////////
4148

src/sk_gpu_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ typedef struct {
2828

2929
SKG_API void skg_log (skg_log_ level, const char *text);
3030
SKG_API void skg_logf (skg_log_ level, const char *text, ...);
31+
SKG_API void skg_log_enable (bool enabled);
3132
SKG_API bool skg_read_file (const char *filename, void **out_data, size_t *out_size);
3233
SKG_API uint64_t skg_hash (const char *string);
3334
SKG_API uint32_t skg_mip_count (int32_t width, int32_t height);

src/sk_gpu_gl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ void gl_check_exts() {
840840
while (glGetError() != 0) {}
841841

842842
// Create a texture of each format to check compatibility
843+
skg_log_enable(false); // Intentional errors, don't scare the users
843844
glActiveTexture(skg_settings_tex_slot);
844845
for (int32_t i=0; i<skg_tex_fmt_max; i+=1) {
845846
int64_t internal_format = (int64_t)skg_tex_fmt_to_native((skg_tex_fmt_)i);
@@ -857,6 +858,7 @@ void gl_check_exts() {
857858

858859
glDeleteTextures(1, &texture);
859860
}
861+
skg_log_enable(true);
860862
};
861863

862864
///////////////////////////////////////////
@@ -1997,7 +1999,9 @@ skg_tex_t skg_tex_create_from_existing(void *native_tex, skg_tex_type_ type, skg
19971999

19982000
// Check if this is an external texture
19992001
gl_pipeline.tex_bind[0] = result._texture; // Similar to a PIPELINE_CHECK
2002+
skg_log_enable(false); // Intentional error, don't scare the users.
20002003
glBindTexture(GL_TEXTURE_EXTERNAL_OES, result._texture);
2004+
skg_log_enable(true);
20012005
if (!glGetError()) {
20022006
result._target = GL_TEXTURE_EXTERNAL_OES;
20032007
}

0 commit comments

Comments
 (0)