AcademySoftwareFoundation / OpenShadingLanguage

Advanced shading language for production GI renderers
BSD 3-Clause "New" or "Revised" License
2.1k stars 360 forks source link

Changed snprintf formatting to satisfy some compilers. #1640

Closed pellerington closed 1 year ago

pellerington commented 1 year ago

Signed-off-by: Peter Ellerington elleringtonp@gmail.com

Description

When building OSL my compiler (GCC 11.3 on Ubuntu) was complaining about these snprintfs format strings not being a string literal. Writing them to a "%s" seems to satisfy it and should produce the same result.

Tests

no changes in tests

Checklist:

linux-foundation-easycla[bot] commented 1 year ago

CLA Signed

The committers listed above are authorized under a signed CLA.

pellerington commented 1 year ago

Okay, I think I've done everything now.

I've made some other modifications to make integrating my renderer easier. Let me know if your interested!

lgritz commented 1 year ago

Sure, what other modifications did you have in mind?

pellerington commented 1 year ago

The main change I added was a optional register closure which lets that closure allocate with a unique function. Eg. for microfacet instead of "osl_allocate_closure_component(...)" being run a function of the form "osl_microfacet(sg, weight, distribution, normal, roughnes ... )" gets run.

It's slightly more work because the renderer needs to implement a function for each closure and copy the arguments more manually, but there's much more freedom.

It let me do processing/interfacing with my renderer memory directly in that function (rather than storing args then looping back over everything after OSL had run). It also meant I didn't have to deal with ClosureComponent data and offset calculations/alignment issues on the gpu. I could just define a class (eg. ClosureMicrofacet) and copy the data there. Also a simpler register closure function because you just have to list the args (not their alignment/size in the struct).