Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7188,6 +7188,14 @@ interpolation buffer, one can specify vertex buffers
(`RTC_BUFFER_TYPE_VERTEX`) and vertex attribute buffers
(`RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE`) as well.

The `bufferType` has to be either `RTC_BUFFER_TYPE_VERTEX` or
`RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE`, and the `bufferSlot` has to be a
valid slot of the specified buffer type, thus smaller than the number of
time steps for vertex buffers and smaller than the vertex attribute
count set using `rtcSetGeometryVertexAttributeCount` for vertex
attribute buffers. Otherwise an `RTC_ERROR_INVALID_ARGUMENT` error is
raised and no data is interpolated.

The `rtcInterpolate` call stores `valueCount` number of interpolated
floating point values to the memory location pointed to by `P`. One can
avoid storing the interpolated value by setting `P` to `NULL`.
Expand Down
8 changes: 8 additions & 0 deletions doc/src/api/rtcInterpolate.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ interpolation buffer, one can specify vertex buffers
(`RTC_BUFFER_TYPE_VERTEX`) and vertex attribute buffers
(`RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE`) as well.

The `bufferType` has to be either `RTC_BUFFER_TYPE_VERTEX` or
`RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE`, and the `bufferSlot` has to be a
valid slot of the specified buffer type, thus smaller than the number
of time steps for vertex buffers and smaller than the vertex attribute
count set using `rtcSetGeometryVertexAttributeCount` for vertex
attribute buffers. Otherwise an `RTC_ERROR_INVALID_ARGUMENT` error is
raised and no data is interpolated.

The `rtcInterpolate` call stores `valueCount` number of interpolated
floating point values to the memory location pointed to by `P`. One
can avoid storing the interpolated value by setting `P` to `NULL`.
Expand Down
20 changes: 14 additions & 6 deletions kernels/common/scene_curves.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,16 +545,20 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < numTimeSteps) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot <= vertexAttribs.size()));
const char* src = nullptr;
size_t stride = 0;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
} else {
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

for (unsigned int i=0; i<valueCount; i+=N)
Expand Down Expand Up @@ -711,7 +715,8 @@ namespace embree
/* we interpolate vertex attributes linearly for hermite basis */
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE)
{
assert(bufferSlot <= vertexAttribs.size());
Comment thread
stefanatwork marked this conversation as resolved.
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
const char* vsrc = vertexAttribs[bufferSlot].getPtr();
const size_t vstride = vertexAttribs[bufferSlot].getStride();

Expand All @@ -730,9 +735,10 @@ namespace embree
}

/* interpolation for vertex buffers */
else
else if (bufferType == RTC_BUFFER_TYPE_VERTEX)
{
assert(bufferSlot < numTimeSteps);
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
const char* vsrc = vertices[bufferSlot].getPtr();
const char* tsrc = tangents[bufferSlot].getPtr();
const size_t vstride = vertices[bufferSlot].getStride();
Expand All @@ -754,6 +760,8 @@ namespace embree
if (ddPdudu) mem<vfloat<N>>::storeu(valid,ddPdudu+i,curve.eval_dudu(u));
}
}
else
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

void interpolate(const RTCInterpolateArguments* const args) {
Expand Down
10 changes: 7 additions & 3 deletions kernels/common/scene_grid_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,20 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < numTimeSteps) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot <= vertexAttribs.size()));
const char* src = nullptr;
size_t stride = 0;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
} else {
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

const Grid& grid = grids[primID];
Expand Down
10 changes: 7 additions & 3 deletions kernels/common/scene_line_segments.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,20 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < numTimeSteps) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot <= vertexAttribs.size()));
const char* src = nullptr;
size_t stride = 0;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
} else {
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

for (unsigned int i=0; i<valueCount; i+=N)
Expand Down
10 changes: 7 additions & 3 deletions kernels/common/scene_quad_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,20 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < numTimeSteps) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot <= vertexAttribs.size()));
const char* src = nullptr;
size_t stride = 0;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
} else {
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

for (unsigned int i=0; i<valueCount; i+=N)
Expand Down
24 changes: 14 additions & 10 deletions kernels/common/scene_subdiv_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,25 +859,27 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < RTC_MAX_TIME_STEP_COUNT) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot < RTC_MAX_USER_VERTEX_BUFFERS));
const char* src = nullptr;
size_t stride = 0;
std::vector<SharedLazyTessellationCache::CacheEntry>* baseEntry = nullptr;
Topology* topo = nullptr;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
assert(bufferSlot < vertexAttribs.size());
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
baseEntry = &vertex_attrib_buffer_tags[bufferSlot];
int topologyID = vertexAttribs[bufferSlot].userData;
topo = &topology[topologyID];
} else {
assert(bufferSlot < numTimeSteps);
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
baseEntry = &vertex_buffer_tags[bufferSlot];
topo = &topology[0];
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

bool has_P = P;
Expand Down Expand Up @@ -936,25 +938,27 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < RTC_MAX_TIME_STEP_COUNT) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot < RTC_MAX_USER_VERTEX_BUFFERS));
const char* src = nullptr;
size_t stride = 0;
std::vector<SharedLazyTessellationCache::CacheEntry>* baseEntry = nullptr;
Topology* topo = nullptr;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
assert(bufferSlot < vertexAttribs.size());
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
baseEntry = &vertex_attrib_buffer_tags[bufferSlot];
int topologyID = vertexAttribs[bufferSlot].userData;
topo = &topology[topologyID];
} else {
assert(bufferSlot < numTimeSteps);
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
baseEntry = &vertex_buffer_tags[bufferSlot];
topo = &topology[0];
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

const int* valid = (const int*) valid_i;
Expand Down
10 changes: 7 additions & 3 deletions kernels/common/scene_triangle_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,20 @@ namespace embree
unsigned int valueCount = args->valueCount;

/* calculate base pointer and stride */
assert((bufferType == RTC_BUFFER_TYPE_VERTEX && bufferSlot < numTimeSteps) ||
(bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE && bufferSlot <= vertexAttribs.size()));
const char* src = nullptr;
size_t stride = 0;
if (bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE) {
if (unlikely(bufferSlot >= vertexAttribs.size()))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex attribute buffer slot specified for interpolation");
src = vertexAttribs[bufferSlot].getPtr();
stride = vertexAttribs[bufferSlot].getStride();
} else {
} else if (bufferType == RTC_BUFFER_TYPE_VERTEX) {
if (unlikely(bufferSlot >= numTimeSteps))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid vertex buffer slot specified for interpolation");
src = vertices[bufferSlot].getPtr();
stride = vertices[bufferSlot].getStride();
} else {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"invalid buffer type specified for interpolation");
}

for (unsigned int i=0; i<valueCount; i+=N)
Expand Down
Loading