OpenShadingLanguage icon indicating copy to clipboard operation
OpenShadingLanguage copied to clipboard

Add rs_allocate_closure free function.

Open curtisblack opened this issue 11 months ago • 2 comments

Description

Adds a new free function rs_allocate_closure which allows the renderer services to provide memory for closure storage, for both inbuilt (add/mul) and user defined closures.

The existing osl_* closure handling functions now use this new free function.

The CPU side fallback is to call through to the existing closure pool implementation. The GPU side fallback returns null.

testshade/testrender provide an example implementation showing how to implement a stack based closure pool for the GPU.

Tests

Checklist:

  • [x] I have read the contribution guidelines.
  • [ ] I have updated the documentation, if applicable.
  • [ ] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • [x] My code follows the prevailing code style of this project. If I haven't already run clang-format v17 before submitting, I definitely will look at the CI test that runs clang-format and fix anything that it highlights as being nonconforming.

curtisblack avatar Feb 18 '25 02:02 curtisblack

The changes to the CUDA code look like a nice simplification. Perhaps it would make sense for the pool size to be a template parameter, but given that we've been hobbling along with the fixed-size allocations that's obviously not a requirement. LGTM.

tgrant-nv avatar Mar 27 '25 21:03 tgrant-nv

What's the status here, @curtisblack ? This seems to still be broadly failing CI.

lgritz avatar Apr 01 '25 16:04 lgritz

I was holding this approved PR because of the CI failures, but I just rebased it myself and sent it through CI, and it was fine, so I will merge it now.

lgritz avatar Oct 25 '25 20:10 lgritz