From bacb12a31497fcc71529a220254e6c1814bbc527 Mon Sep 17 00:00:00 2001 From: Steena Monteiro Date: Fri, 23 Jun 2023 14:40:30 -0700 Subject: [PATCH] Fixing CI build issues Signed-off-by: Steena Monteiro --- src/include/OSL/encodedtypes.h | 20 +++++++++++++++++ src/liboslexec/wide/wide_opdictionary.cpp | 16 ++++++++++---- src/testshade/simplerend.h | 8 +++---- src/testshade/testshade.cpp | 27 ++++++++++++----------- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/include/OSL/encodedtypes.h b/src/include/OSL/encodedtypes.h index ae79d09ce2..93fd1e6736 100644 --- a/src/include/OSL/encodedtypes.h +++ b/src/include/OSL/encodedtypes.h @@ -115,6 +115,26 @@ template<> struct TypeEncoder { static DataType Encode(const int64_t val) { return val; } }; +// On macOS 10.+ ptrdiff_t is a long, but on linux this +// specialization would conflict with int64_t +#if OSL_APPLE_CLANG_VERSION +template<> struct TypeEncoder { + using DataType = int64_t; + static constexpr EncodedType value = EncodedType::kInt64; + static_assert(size_of_encoded_type(value) == sizeof(DataType), + "unexpected"); + static DataType Encode(const ptrdiff_t val) { return val; } +}; +#endif + +// template<> struct TypeEncoder { +// using DataType = int64_t; +// static constexpr EncodedType value = EncodedType::kInt64; +// static_assert(size_of_encoded_type(value) == sizeof(DataType), +// "unexpected"); +// static DataType Encode(const std::ptrdiff_t val) { return val; } +// }; + template<> struct TypeEncoder { using DataType = double; static constexpr EncodedType value = EncodedType::kDouble; diff --git a/src/liboslexec/wide/wide_opdictionary.cpp b/src/liboslexec/wide/wide_opdictionary.cpp index 311b4bfc42..64414d28c7 100644 --- a/src/liboslexec/wide/wide_opdictionary.cpp +++ b/src/liboslexec/wide/wide_opdictionary.cpp @@ -51,7 +51,9 @@ OSL_BATCHOP int __OSL_OP(dict_find_iis)(void* bsg_, int nodeID, void* query) { auto* bsg = reinterpret_cast(bsg_); - return bsg->uniform.context->dict_find(nullptr/*causes errors be reported through ShadingContext*/, nodeID, USTR(query)); + return bsg->uniform.context->dict_find( + nullptr /*causes errors be reported through ShadingContext*/, nodeID, + USTR(query)); } @@ -71,7 +73,9 @@ __OSL_MASKED_OP3(dict_find, Wi, Wi, Ws)(void* bsg_, void* wout, void* wnodeID, mask.foreach ([=](ActiveLane lane) -> void { int nodeID = wNID[lane]; ustring query = wQ[lane]; - wOut[lane] = bsg->uniform.context->dict_find(nullptr/*causes errors be reported through ShadingContext*/, nodeID, query); + wOut[lane] = bsg->uniform.context->dict_find( + nullptr /*causes errors be reported through ShadingContext*/, + nodeID, query); }); } @@ -81,7 +85,9 @@ OSL_BATCHOP int __OSL_OP(dict_find_iss)(void* bsg_, void* dictionary, void* query) { auto* bsg = reinterpret_cast(bsg_); - return bsg->uniform.context->dict_find(nullptr/*causes errors be reported through ShadingContext*/, USTR(dictionary), USTR(query)); + return bsg->uniform.context->dict_find( + nullptr /*causes errors be reported through ShadingContext*/, + USTR(dictionary), USTR(query)); } @@ -102,7 +108,9 @@ __OSL_MASKED_OP3(dict_find, Wi, Ws, Ws)(void* bsg_, void* wout, mask.foreach ([=](ActiveLane lane) -> void { ustring dictionary = wD[lane]; ustring query = wQ[lane]; - wOut[lane] = bsg->uniform.context->dict_find(nullptr/*causes errors be reported through ShadingContext*/, dictionary, query); + wOut[lane] = bsg->uniform.context->dict_find( + nullptr /*causes errors be reported through ShadingContext*/, + dictionary, query); }); } diff --git a/src/testshade/simplerend.h b/src/testshade/simplerend.h index b703bac96c..4d7048833f 100644 --- a/src/testshade/simplerend.h +++ b/src/testshade/simplerend.h @@ -71,17 +71,17 @@ class SimpleRenderer : public RendererServices { void errorfmt(OSL::ShaderGlobals* sg, OSL::ustringhash fmt_specification, int32_t count, const EncodedType* argTypes, - uint32_t argValuesSize, uint8_t* argValues); + uint32_t argValuesSize, uint8_t* argValues) override; void warningfmt(OSL::ShaderGlobals* sg, OSL::ustringhash fmt_specification, int32_t count, const EncodedType* argTypes, - uint32_t argValuesSize, uint8_t* argValues); + uint32_t argValuesSize, uint8_t* argValues) override; void printfmt(OSL::ShaderGlobals* sg, OSL::ustringhash fmt_specification, int32_t count, const EncodedType* argTypes, - uint32_t argValuesSize, uint8_t* argValues); + uint32_t argValuesSize, uint8_t* argValues) override; void filefmt(OSL::ShaderGlobals* sg, OSL::ustringhash filename_hash, OSL::ustringhash fmt_specification, int32_t arg_count, const EncodedType* argTypes, uint32_t argValuesSize, - uint8_t* argValues); + uint8_t* argValues) override; // Set and get renderer attributes/options void attribute(string_view name, TypeDesc type, const void* value); diff --git a/src/testshade/testshade.cpp b/src/testshade/testshade.cpp index 8badf88aa4..1c0be5d4e6 100644 --- a/src/testshade/testshade.cpp +++ b/src/testshade/testshade.cpp @@ -346,7 +346,7 @@ compile_buffer(const std::string& sourcecode, const std::string& shadername) // std::cout << "Compiled to oso:\n---\n" << osobuffer << "---\n\n"; if (!shadingsys->LoadMemoryCompiledShader(shadername, osobuffer)) { - std::cerr << "Could not load compiled buffer from \"" << shadername + std::cerr << "Could not load compiled jBuffer from \"" << shadername << "\"\n"; exit(EXIT_FAILURE); } @@ -380,7 +380,7 @@ add_shader(cspan argv) set_shadingsys_options(); - if (inbuffer) // Request to exercise the buffer-based API calls + if (inbuffer) // Request to exercise the jBuffer-based API calls shader_from_buffers(shadername); inject_params(); @@ -783,7 +783,7 @@ getargs(int argc, const char* argv[]) ap.arg("--oslquery", &do_oslquery) .help("Test OSLQuery at runtime"); ap.arg("--inbuffer", &inbuffer) - .help("Compile osl source from and to buffer"); + .help("Compile osl source from and to jBuffer"); ap.arg("--no-output-placement") .help("Turn off use of output placement, rely only on get_symbol") .action(OIIO::ArgParse::store_false()); @@ -813,7 +813,7 @@ getargs(int argc, const char* argv[]) ap.arg("--use_rs_bitcode", &use_rs_bitcode) .help("Use free function bitcode Renderer services"); ap.arg("--jbufferMB %d:JBUFFER", &jbufferMB) - .help("journal buffer size in MB"); + .help("journal jBuffer size in MB"); // clang-format on if (ap.parse(argc, argv) < 0) { @@ -1097,7 +1097,7 @@ setup_output_images(SimpleRenderer* rend, ShadingSystem* shadingsys, OIIO::ImageBuf* ib = rend->outputbuf(i); char* outptr = static_cast(ib->pixeladdr(0, 0)); if (i == 0) { - // The output arena is the start of the first output buffer + // The output arena is the start of the first output jBuffer output_base_ptr = outptr; } ptrdiff_t offset = outptr - output_base_ptr; @@ -1216,7 +1216,7 @@ save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys, int nchans = outputimg->nchannels(); if (t.basetype == TypeDesc::FLOAT) { // If the variable we are outputting is float-based, set it - // directly in the output buffer. + // directly in the output jBuffer. outputimg->setpixel(x, y, (const float*)data); if (print_outputs) { print(" {} :", outputvarnames[i]); @@ -1298,7 +1298,7 @@ batched_save_outputs(SimpleRenderer* rend, ShadingSystem* shadingsys, // Used Wide access on the symbol's data t access per lane results if (t.basetype == TypeDesc::FLOAT) { // If the variable we are outputting is float-based, set it - // directly in the output buffer. + // directly in the output jBuffer. if (t.aggregate == TypeDesc::MATRIX44) { OSL_DASSERT(nchans == 16); Wide batchResults( @@ -2103,11 +2103,11 @@ test_shade(int argc, const char* argv[]) } //Initialize a Journal Buffer for all threads to use for journaling fmt specification calls. - const size_t jbuffer_bytes = jbufferMB * 1024 * 1024; - std::unique_ptr buffer((uint8_t*)malloc(jbuffer_bytes)); + const size_t jbuffer_bytes = jbufferMB * 1024 * 1024; + uint8_t* jBuffer = (uint8_t*)malloc(jbuffer_bytes); constexpr int jbuffer_pagesize = 1024; bool init_buffer_success - = OSL::journal::initialize_buffer(buffer.get(), jbuffer_bytes, + = OSL::journal::initialize_buffer(jBuffer, jbuffer_bytes, jbuffer_pagesize, num_threads); if (!init_buffer_success) { @@ -2116,7 +2116,7 @@ test_shade(int argc, const char* argv[]) //Send the populated Journal Buffer to the renderer - theRenderState.journal_buffer = buffer.get(); + theRenderState.journal_buffer = jBuffer; // Allow a settable number of iterations to "render" the whole image, @@ -2189,9 +2189,9 @@ test_shade(int argc, const char* argv[]) limit_errors, error_history_capacity, limit_warnings, warning_history_capacity); TestshadeReporter reporter(&errhandler, tracker_error_warnings); - OSL::journal::Reader jreader(buffer.get(), reporter); + OSL::journal::Reader jreader(jBuffer, reporter); jreader.process(); - // Need to call journal::initialize_buffer before re-using the buffer + // Need to call journal::initialize_buffer before re-using the jBuffer double runtime = timer.lap(); @@ -2258,6 +2258,7 @@ test_shade(int argc, const char* argv[]) // We're done with the shading system now, destroy it shadergroup.reset(); // Must release this before destroying shadingsys + delete jBuffer; delete shadingsys; int retcode = EXIT_SUCCESS;