MCPcopy Create free account
hub / github.com/RenderKit/embree / setBuffer

Method setBuffer

kernels/common/scene_instance_array.cpp:88–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86 }
87
88 void InstanceArray::setBuffer(RTCBufferType type, unsigned int slot, RTCFormat format, const Ref<Buffer>& buffer, size_t offset, size_t stride, unsigned int num)
89 {
90 /* verify that all accesses are 4 bytes aligned */
91 if (((size_t(buffer->getHostPtr()) + offset) & 0x3) || (stride & 0x3))
92 throw_RTCError(RTC_ERROR_INVALID_OPERATION, "data must be 4 bytes aligned");
93
94 if (type == RTC_BUFFER_TYPE_TRANSFORM)
95 {
96 if ((format != RTC_FORMAT_FLOAT3X4_COLUMN_MAJOR)
97 && (format != RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR)
98 && (format != RTC_FORMAT_FLOAT3X4_ROW_MAJOR)
99 && (format != RTC_FORMAT_QUATERNION_DECOMPOSITION))
100 throw_RTCError(RTC_ERROR_INVALID_OPERATION, "invalid transform buffer format");
101
102 if (slot >= l2w_buf.size())
103 throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "invalid transform buffer slot");
104
105 if (format == RTC_FORMAT_QUATERNION_DECOMPOSITION)
106 gsubtype = GTY_SUBTYPE_INSTANCE_QUATERNION;
107 numPrimitives = num;
108 l2w_buf[slot].set(buffer, offset, stride, num, format);
109 l2w_buf[slot].checkPadding16();
110 }
111 else if (type == RTC_BUFFER_TYPE_INDEX)
112 {
113 if (format != RTC_FORMAT_UINT)
114 throw_RTCError(RTC_ERROR_INVALID_OPERATION, "invalid index buffer format. must be RTC_FORMAT_UINT.");
115
116 if (slot != 0)
117 throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "invalid index buffer slot. must be 0.");
118
119 object_ids.set(buffer, offset, stride, num, format);
120 }
121 else
122 throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "unknown buffer type");
123 }
124
125 void* InstanceArray::getBufferData(RTCBufferType type, unsigned int slot, BufferDataPointerType pointerType)
126 {

Callers

nothing calls this directly

Calls 4

getHostPtrMethod · 0.80
checkPadding16Method · 0.80
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected