 }@@
 
 @@{
-rtcMapBuffer(EXPR geom,EXPR type)
-=>
-rtcGetGeometryBufferData(geom,type) /* FIXME: check if this should be rtcNewBuffer */
-}@@
-
-
-@@{
-rtcSetIndexBuffer(EXPR geom, RTC_USER_VERTEX_BUFFER_(EXPR vertexSlot) , RTC_INDEX_BUFFER_(EXPR indexSlot));
+rtcMapBuffer(EXPR geom,EXPR type,EXPR slot)
+=>
+rtcGetGeometryBufferData(geom,type,slot) /* FIXME: check if this should be rtcNewBuffer */
+}@@
+
+
+@@{
+rtcSetIndexBuffer(EXPR geom, RTC_BUFFER(RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,EXPR vertexSlot) , RTC_BUFFER(RTC_BUFFER_TYPE_INDEX,EXPR indexSlot));
 =>
 rtcSetGeometryVertexAttributeTopology(geom, vertexSlot, indexSlot);
 }@@

=>
uniform RTCGeometry geom = rtcNewSubdivisionMesh(device,flags,numPrimitives,numEdges,numVertices,numEdgeCreases,numVertexCreases,numHoles,numTimeSteps);
@@{
rtcMapBuffer(EXPR geom,RTC_FACE_BUFFER)
=>
rtcNewBuffer(geom,RTC_FACE_BUFFER,sizeof(uniform int),numPrimitives)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_FACE_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_FACE_BUFFER,ptr,offset,stride,numPrimitives)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_INDEX_BUFFER)
=>
rtcNewBuffer(geom,RTC_INDEX_BUFFER,sizeof(uniform int),numEdges)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_INDEX_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_INDEX_BUFFER,ptr,offset,stride,numEdges)
}@@
@@{
rtcMapBuffer(EXPR geom,REGEXPR(vertex_buffer,RTC_VERTEX_BUFFER.*))
=>
rtcNewBuffer(geom,vertex_buffer,4*sizeof(uniform float),numVertices)
}@@
@@{
rtcSetBuffer(EXPR geom,REGEXPR(vertex_buffer,RTC_VERTEX_BUFFER.*),EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,vertex_buffer,ptr,offset,stride,numVertices)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_LEVEL_BUFFER)
=>
rtcNewBuffer(geom,RTC_LEVEL_BUFFER,sizeof(uniform int),numEdges)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_LEVEL_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_LEVEL_BUFFER,ptr,offset,stride,numEdges)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_EDGE_CREASE_INDEX_BUFFER)
=>
rtcNewBuffer(geom,RTC_EDGE_CREASE_INDEX_BUFFER,2*sizeof(uniform int),numEdgeCreases)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_EDGE_CREASE_INDEX_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_EDGE_CREASE_INDEX_BUFFER,ptr,offset,stride,numEdgeCreases)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_EDGE_CREASE_WEIGHT_BUFFER)
=>
rtcNewBuffer(geom,RTC_EDGE_CREASE_WEIGHT_BUFFER,sizeof(uniform float),numEdgeCreases)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_EDGE_CREASE_WEIGHT_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_EDGE_CREASE_WEIGHT_BUFFER,ptr,offset,stride,numEdgeCreases)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_VERTEX_CREASE_INDEX_BUFFER)
=>
rtcNewBuffer(geom,RTC_VERTEX_CREASE_INDEX_BUFFER,sizeof(uniform int),numVertexCreases)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_VERTEX_CREASE_INDEX_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_VERTEX_CREASE_INDEX_BUFFER,ptr,offset,stride,numVertexCreases)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_VERTEX_CREASE_WEIGHT_BUFFER)
=>
rtcNewBuffer(geom,RTC_VERTEX_CREASE_WEIGHT_BUFFER,sizeof(uniform float),numVertexCreases)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_VERTEX_CREASE_WEIGHT_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_VERTEX_CREASE_WEIGHT_BUFFER,ptr,offset,stride,numVertexCreases)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_HOLE_BUFFER)
=>
rtcNewBuffer(geom,RTC_HOLE_BUFFER,sizeof(uniform int),numPrimitives)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_HOLE_BUFFER,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_HOLE_BUFFER,ptr,offset,stride,numPrimitives)
}@@
@@{
rtcSetBuffer(EXPR geom,REGEXPR(user_vertex_buffer,RTC_USER_VERTEX_BUFFER.*),EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,user_vertex_buffer,ptr,offset,stride,numVertices) /* FIXME: verify size of this buffer! */
}@@
}@@


// buffers

@@{
RTCGeometry ID geom = rtcNewTriangleMesh(EXPR device,EXPR flags,EXPR numPrimitives,EXPR numVertices,EXPR numTimeSteps);
=>
uniform RTCGeometry geom = rtcNewTriangleMesh(device,flags,numPrimitives,numVertices,numTimeSteps);
@@{
rtcMapBuffer(EXPR geom,RTC_BUFFER_TYPE_INDEX,EXPR slot)
=>
rtcNewBuffer(geom,RTC_BUFFER_TYPE_INDEX,slot,3*sizeof(uniform int),numPrimitives)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_BUFFER_TYPE_INDEX,EXPR slot,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_BUFFER_TYPE_INDEX,slot,ptr,offset,stride,numPrimitives)
}@@
@@{
rtcMapBuffer(EXPR geom,RTC_BUFFER_TYPE_VERTEX,EXPR slot)
=>
rtcNewBuffer(geom,RTC_BUFFER_TYPE_VERTEX,slot,4*sizeof(uniform float),numVertices)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_BUFFER_TYPE_VERTEX,EXPR slot,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_BUFFER_TYPE_VERTEX,slot,ptr,offset,stride,numVertices)
}@@
@@{
rtcSetBuffer(EXPR geom,RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,EXPR slot,EXPR ptr,EXPR offset,EXPR stride)
=>
rtcSetBuffer(geom,RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE,slot,ptr,offset,stride,numVertices)
}@@
}@@

