Esempio n. 1
0
  void NativeCurves::setBuffer(RTCBufferType type, void* ptr, size_t offset, size_t stride, size_t size) 
  { 
    if (scene->isStatic() && scene->isBuild())
      throw_RTCError(RTC_INVALID_OPERATION,"static geometries cannot get modified");

    /* verify that all accesses are 4 bytes aligned */
    if (((size_t(ptr) + offset) & 0x3) || (stride & 0x3)) 
      throw_RTCError(RTC_INVALID_OPERATION,"data must be 4 bytes aligned");

    unsigned bid = type & 0xFFFF;
    if (type >= RTC_VERTEX_BUFFER0 && type < RTCBufferType(RTC_VERTEX_BUFFER0 + numTimeSteps)) 
    {
      size_t t = type - RTC_VERTEX_BUFFER0;
      vertices[t].set(ptr,offset,stride,size); 
      vertices[t].checkPadding16();
    } 
    else if (type >= RTC_USER_VERTEX_BUFFER0 && type < RTC_USER_VERTEX_BUFFER0+RTC_MAX_USER_VERTEX_BUFFERS)
    {
      if (bid >= userbuffers.size()) userbuffers.resize(bid+1);
      userbuffers[bid] = APIBuffer<char>(scene->device,numVertices(),stride);
      userbuffers[bid].set(ptr,offset,stride,size);  
      userbuffers[bid].checkPadding16();
    }
    else if (type == RTC_INDEX_BUFFER) 
    {
      if (isEnabled() && size != (size_t)-1) disabling();
      curves.set(ptr,offset,stride,size); 
      setNumPrimitives(size);
      if (isEnabled() && size != (size_t)-1) enabling();
    }
    else 
        throw_RTCError(RTC_INVALID_ARGUMENT,"unknown buffer type"); 
  }
Esempio n. 2
0
void BvhTriangleSystem::initOnDevice()
{
    std::cout<<"\n triangle system init on device";
    setNumPrimitives(numTriangles());
    CudaMassSystem::initOnDevice();
    CudaLinearBvh::initOnDevice();
}
  void QuadMesh::setBuffer(RTCBufferType type, unsigned int slot, RTCFormat format, const Ref<Buffer>& buffer, size_t offset, size_t stride, unsigned int num)
  { 
    /* verify that all accesses are 4 bytes aligned */
    if (((size_t(buffer->getPtr()) + offset) & 0x3) || (stride & 0x3)) 
      throw_RTCError(RTC_ERROR_INVALID_OPERATION, "data must be 4 bytes aligned");

    if (type == RTC_BUFFER_TYPE_VERTEX) 
    {
      if (format != RTC_FORMAT_FLOAT3)
        throw_RTCError(RTC_ERROR_INVALID_OPERATION, "invalid vertex buffer format");

      /* if buffer is larger than 16GB the premultiplied index optimization does not work */
      if (stride*num > 16ll*1024ll*1024ll*1024ll)
       throw_RTCError(RTC_ERROR_INVALID_OPERATION, "vertex buffer can be at most 16GB large");

      if (slot >= vertices.size())
        throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "invalid vertex buffer slot");

      vertices[slot].set(buffer, offset, stride, num, format);
      vertices[slot].checkPadding16();
      vertices0 = vertices[0];
    } 
    else if (type >= RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE)
    {
      if (format < RTC_FORMAT_FLOAT || format > RTC_FORMAT_FLOAT16)
        throw_RTCError(RTC_ERROR_INVALID_OPERATION, "invalid vertex attribute buffer format");

      if (slot >= vertexAttribs.size())
        throw_RTCError(RTC_ERROR_INVALID_OPERATION, "invalid vertex attribute buffer slot");
      
      vertexAttribs[slot].set(buffer, offset, stride, num, format);
      vertexAttribs[slot].checkPadding16();
    }
    else if (type == RTC_BUFFER_TYPE_INDEX)
    {
      if (slot != 0)
        throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "invalid buffer slot");
      if (format != RTC_FORMAT_UINT4)
        throw_RTCError(RTC_ERROR_INVALID_OPERATION, "invalid index buffer format");

      quads.set(buffer, offset, stride, num, format);
      setNumPrimitives(num);
    }
    else
      throw_RTCError(RTC_ERROR_INVALID_ARGUMENT, "unknown buffer type");
  }
Esempio n. 4
0
void BvhTetrahedronSystem::initOnDevice() 
{
    std::cout<<"\n tetrahedron system init on device";
	m_deviceTetrahedronVicinityInd->create(numTetrahedronVicinityInd() * 4);
	m_deviceTetrahedronVicinityStart->create((numTetrahedrons() + 1) * 4);
	m_deviceTetrahedronVicinityInd->hostToDevice(hostTetrahedronVicinityInd());
	m_deviceTetrahedronVicinityStart->hostToDevice(hostTetrahedronVicinityStart());
	m_vicinity->create(numTetrahedrons()*TETRAHEDRONSYSTEM_VICINITY_LENGTH*4);
	
	tetrasys::writeVicinity((int *)vicinity(), 
	         (int *)m_deviceTetrahedronVicinityInd->bufferOnDevice(), 
	         (int *)m_deviceTetrahedronVicinityStart->bufferOnDevice(), 
	         numTetrahedrons());
	
	CudaMassSystem::initOnDevice();
	
	setNumPrimitives(numTetrahedrons());
	CudaLinearBvh::initOnDevice();
}
Esempio n. 5
0
  void QuadMesh::setBuffer(RTCBufferType type, void* ptr, size_t offset, size_t stride, size_t size) 
  { 
    if (scene->isStatic() && scene->isBuild()) 
      throw_RTCError(RTC_INVALID_OPERATION,"static scenes cannot get modified");

    /* verify that all accesses are 4 bytes aligned */
    if (((size_t(ptr) + offset) & 0x3) || (stride & 0x3)) 
      throw_RTCError(RTC_INVALID_OPERATION,"data must be 4 bytes aligned");

    unsigned bid = type & 0xFFFF;
    if (type >= RTC_VERTEX_BUFFER0 && type < RTCBufferType(RTC_VERTEX_BUFFER0 + numTimeSteps)) 
    {
      size_t t = type - RTC_VERTEX_BUFFER0;
      if (size == -1) size = vertices[t].size();

      /* if buffer is larger than 16GB the premultiplied index optimization does not work */
      if (stride*size > 16ll*1024ll*1024ll*1024ll) 
       throw_RTCError(RTC_INVALID_OPERATION,"vertex buffer can be at most 16GB large");

      vertices[t].set(ptr,offset,stride,size); 
      vertices[t].checkPadding16();
      vertices0 = vertices[0];
    } 
    else if (type >= RTC_USER_VERTEX_BUFFER0 && type < RTC_USER_VERTEX_BUFFER0+RTC_MAX_USER_VERTEX_BUFFERS)
    {
      if (bid >= userbuffers.size()) userbuffers.resize(bid+1);
      userbuffers[bid] = APIBuffer<char>(scene->device,numVertices(),stride);
      userbuffers[bid].set(ptr,offset,stride,size);  
      userbuffers[bid].checkPadding16();
    }
    else if (type == RTC_INDEX_BUFFER) 
    {
      if (size != (size_t)-1) disabling();
      quads.set(ptr,offset,stride,size);
      setNumPrimitives(size);
      if (size != (size_t)-1) enabling();
    }
    else
      throw_RTCError(RTC_INVALID_ARGUMENT,"unknown buffer type");
  }