Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stride for mapped direct array parameters #78

Closed
jeffamstutz opened this issue May 10, 2023 · 0 comments
Closed

Add stride for mapped direct array parameters #78

jeffamstutz opened this issue May 10, 2023 · 0 comments
Labels
v1.0 Issues to be decided on for the v1.0 specification

Comments

@jeffamstutz
Copy link
Contributor

While not common, it has come up in practice that direct array parameters may want to allow writing sparse data arrays internal to the 3D rendering engine. This specifically came up in the Cycles implementation where VEC3 data is 16-byte aligned -- thus a staging buffer is required for the current formulation of direct parameter arrays.

The remedy is quite simple -- have a stride out-parameter that implementations use to calculate the offset into the memory for each element. This would look like:

ANARIGeometry geom = anariNewGeometry(device, "triangle");
size_t outStride = 0;
void *vertices = anariMapParameterArray1D(device, geom, "vertex.position", ANARI_FLOAT32_VEC3, numVertices, &outStride);
for (int i = 0; i < numVertices, i++) {
  float3 *out = vertices + i * outStride;
  *out = inVertices[i];
} 
// ...
@jeffamstutz jeffamstutz added the v1.0 Issues to be decided on for the v1.0 specification label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v1.0 Issues to be decided on for the v1.0 specification
Projects
None yet
Development

No branches or pull requests

2 participants