From 3bf59982e5ca8b72f928d7a8a73d6eee534099ca Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Thu, 17 Aug 2023 21:12:54 -0700 Subject: [PATCH] Restore stubs for printf (fixes OptiX problems with 1702) (#1711) The recently merged PR 1702 fails all the OptiX tests. I tracked down the problem and it's that the patch was a bit too aggressive about removing things no longer needed. The intent was that even if you don't use the new journaling, nothing should break. But it does break for OptiX, and this patch restores some of the functions 1702 removed (like the implementation of osl_printf) and some other necessary stubs. This takes us from failing all ~150 OptiX oriented tests to failing only 4, which I believe are unrelated to 1702 and are merely revealed by them. I will fix those in a separate PR. Signed-off-by: Larry Gritz --- src/liboslexec/builtindecl.h | 6 ++++++ src/liboslexec/opstring.cpp | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/liboslexec/builtindecl.h b/src/liboslexec/builtindecl.h index f620d4020..1b58ba836 100644 --- a/src/liboslexec/builtindecl.h +++ b/src/liboslexec/builtindecl.h @@ -126,6 +126,12 @@ DECL(osl_gen_warningfmt, "xXhiXiX") DECL(osl_split, "isXsii") DECL(osl_incr_layers_executed, "xX") +// For legacy printf support +DECL(osl_printf, "xXs*") +DECL(osl_fprintf, "xXss*") +DECL(osl_error, "xXs*") +DECL(osl_warning, "xXs*") + NOISE_IMPL(cellnoise) //NOISE_DERIV_IMPL(cellnoise) NOISE_IMPL(hashnoise) diff --git a/src/liboslexec/opstring.cpp b/src/liboslexec/opstring.cpp index a68586f8a..50c7fa206 100644 --- a/src/liboslexec/opstring.cpp +++ b/src/liboslexec/opstring.cpp @@ -12,6 +12,7 @@ #include +#include #include #include @@ -161,6 +162,8 @@ osl_format(const char* format_str, ...) return ustring(s).c_str(); } + + OSL_SHADEOP int osl_split(const char* str, ustring* results, const char* sep, int maxsplit, int resultslen) @@ -175,5 +178,37 @@ osl_split(const char* str, ustring* results, const char* sep, int maxsplit, } + +//////// +// The osl_printf, osl_error, osl_warning, and osl_fprintf are deprecated but +// the stubs are needed for now to prevent breaking OptiX-based renderers who +// aren't quite ready to refactor around the journaling print family of +// functions. They eventually can be removed when we're happy that all the +// compliant renderers have adapted. + +OSL_SHADEOP void +osl_printf(ShaderGlobals* sg, const char* format_str, ...) +{ +} + +OSL_SHADEOP void +osl_error(ShaderGlobals* sg, const char* format_str, ...) +{ +} + +OSL_SHADEOP void +osl_warning(ShaderGlobals* sg, const char* format_str, ...) +{ +} + +OSL_SHADEOP void +osl_fprintf(ShaderGlobals* /*sg*/, const char* filename, const char* format_str, + ...) +{ +} + +//////// + + } // end namespace pvt OSL_NAMESPACE_EXIT