Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 14 additions & 1 deletion kernels/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,21 @@ namespace embree
/*! sets the buffer view */
void set(const Ref<Buffer>& buffer_in, size_t offset_in, size_t stride_in, size_t num_in, RTCFormat format_in)
{
if ((offset_in + stride_in * num_in) > (stride_in * buffer_in->numBytes))
if (stride_in > 0xFFFFFFFFu) {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"stride too large");
}

if (num_in > 0xFFFFFFFFu) {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"item count too large");
}

if (offset_in > 0 && offset_in >= buffer_in->numBytes) {
Comment thread
stefanatwork marked this conversation as resolved.
Outdated
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "offset too large");
}

if (stride_in * num_in > buffer_in->numBytes - offset_in) {
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "buffer range out of bounds");
}

ptr_ofs = buffer_in->getHostPtr() + offset_in;
dptr_ofs = buffer_in->getDevicePtr() + offset_in;
Expand Down
15 changes: 15 additions & 0 deletions kernels/common/rtcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,9 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
if (itemCount > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"buffer too large");

if (byteStride > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"stride too large");

geometry->setBuffer(type, slot, format, buffer, byteOffset, byteStride, (unsigned int)itemCount);
RTC_CATCH_END2(geometry);
}
Expand All @@ -1871,6 +1874,9 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
if (itemCount > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"buffer too large");

if (byteStride > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"stride too large");

Ref<Buffer> buffer = new Buffer(geometry->device, itemCount*byteStride, (char*)ptr + byteOffset);
geometry->setBuffer(type, slot, format, buffer, 0, byteStride, (unsigned int)itemCount);
RTC_CATCH_END2(geometry);
Expand All @@ -1889,6 +1895,9 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
if (itemCount > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"buffer too large");

if (byteStride > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"stride too large");

if ((ptr == nullptr) || (dptr == nullptr))
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"host and device pointer may not be NULL pointers when using SYCL devices");

Expand Down Expand Up @@ -1916,6 +1925,9 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
if (itemCount > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"buffer too large");

if (byteStride > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"stride too large");

/* vertex buffers need to get overallocated slightly as elements are accessed using SSE loads */
size_t bytes = itemCount*byteStride;
if (type == RTC_BUFFER_TYPE_VERTEX || type == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE)
Expand All @@ -1941,6 +1953,9 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
if (itemCount > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"buffer too large");

if (byteStride > 0xFFFFFFFFu)
throw_RTCError(RTC_ERROR_INVALID_ARGUMENT,"stride too large");

/* vertex buffers need to get overallocated slightly as elements are accessed using SSE loads */
size_t bytes = itemCount*byteStride;
if (bufferType == RTC_BUFFER_TYPE_VERTEX || bufferType == RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE)
Expand Down