Skip to content

Commit

Permalink
Fixing CI build issues
Browse files Browse the repository at this point in the history
Signed-off-by: Steena Monteiro <[email protected]>
  • Loading branch information
steenax86 committed Jun 23, 2023
1 parent 6b25b4a commit bacb12a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
20 changes: 20 additions & 0 deletions src/include/OSL/encodedtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ template<> struct TypeEncoder<int64_t> {
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<ptrdiff_t> {
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<std::ptrdiff_t> {
// 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<double> {
using DataType = double;
static constexpr EncodedType value = EncodedType::kDouble;
Expand Down
16 changes: 12 additions & 4 deletions src/liboslexec/wide/wide_opdictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ OSL_BATCHOP int
__OSL_OP(dict_find_iis)(void* bsg_, int nodeID, void* query)
{
auto* bsg = reinterpret_cast<BatchedShaderGlobals*>(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));
}


Expand All @@ -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);
});
}

Expand All @@ -81,7 +85,9 @@ OSL_BATCHOP int
__OSL_OP(dict_find_iss)(void* bsg_, void* dictionary, void* query)
{
auto* bsg = reinterpret_cast<BatchedShaderGlobals*>(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));
}


Expand All @@ -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);
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/testshade/simplerend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 14 additions & 13 deletions src/testshade/testshade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -380,7 +380,7 @@ add_shader(cspan<const char*> 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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1097,7 +1097,7 @@ setup_output_images(SimpleRenderer* rend, ShadingSystem* shadingsys,
OIIO::ImageBuf* ib = rend->outputbuf(i);
char* outptr = static_cast<char*>(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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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<const Matrix44, WidthT> batchResults(
Expand Down Expand Up @@ -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<uint8_t> 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) {
Expand All @@ -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,
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit bacb12a

Please sign in to comment.