コード例 #1
0
ファイル: hiz.cpp プロジェクト: binhpt/point-frag
  void HiZ::greyRGBA(uint8 **pixels) const
  {
    if (UNLIKELY(pixels == NULL)) return;
    if (UNLIKELY(*pixels == NULL)) return;

    // Iterate over all pixels, find the tile, find the pixel in the tile and
    // output a grey scaled pixel
    uint8 *rgba = *pixels;
    for (uint32 y = 0; y < this->height; ++y)
    for (uint32 x = 0; x < this->width; ++x) {
      const uint32 tileX = x / Tile::width;
      const uint32 tileY = y / Tile::height;
      const uint32 tileID = tileX + tileY * this->tileXNum;
      const Tile &tile = this->tiles[tileID];
      const float *zptr = &tile.z[0][0];
      const uint32 offsetX = x % Tile::width;
      const uint32 offsetY = y % Tile::height;
      const uint32 offset = offsetX + Tile::width * offsetY;
      const uint32 imageOffset = (x + y * this->width) * 4;
      const float z = min(zptr[offset] * 32.f, 255.f);
      PF_ASSERT(imageOffset < 4*this->pixelNum);
      rgba[imageOffset + 0] = uint8(z);
      rgba[imageOffset + 1] = uint8(z);
      rgba[imageOffset + 2] = uint8(z);
      rgba[imageOffset + 3] = 0xff;
    }
  }
コード例 #2
0
ファイル: hiz.cpp プロジェクト: binhpt/point-frag
  // We create packets and directly fill each zBuffer tile. Note that we
  // really store t values
  void TaskRayTraceHiZ::run(size_t taskID)
  {
    const uint32 taskX = taskID % this->taskXNum;
    const uint32 taskY = taskID / this->taskXNum;
    const uint32 startX = taskX * this->width;
    const uint32 startY = taskY * this->height;
    const uint32 endX = startX + this->width;
    const uint32 endY = startY + this->height;
    uint32 tileY = startY / HiZ::Tile::height;

    for (uint32 y = startY; y < endY; y += RayPacket::height, ++tileY) {
      uint32 tileX = startX / HiZ::Tile::width;
      for (uint32 x = startX; x < endX; x += RayPacket::width, ++tileX) {
        RayPacket pckt;
        PacketHit hit;
        gen.generate(pckt, x, y);
        intersector->traverse(pckt, hit);
        ssef zmin(inf), zmax(neg_inf);
        const uint32 tileID = tileX + tileY * zBuffer->tileXNum;
        PF_ASSERT(tileID < zBuffer->tileNum);
        HiZ::Tile &tile = zBuffer->tiles[tileID];
        for (uint32 chunkID = 0; chunkID < HiZ::Tile::chunkNum; ++chunkID) {
          //const ssef t = hit.t[chunkID];
          const ssef t = hit.t[chunkID] *dot(sse3f(view.x,view.y,view.z), pckt.dir[chunkID]);
          tile.z[chunkID] = t;
          zmin = min(zmin, t);
          zmax = max(zmax, t);
        }
        tile.zmin = reduce_min(zmin)[0];
        tile.zmax = reduce_max(zmax)[0];
      }
    }
  }
コード例 #3
0
void rnContextDelete(RnContext ctx) {
    if (ctx == NULL) return;
    PF_ASSERT(ctx == renderer);
    if (ctx->refDec()) {
        Lock<MutexSys> lock(rendererMutex);
        PF_DELETE(renderer);
        renderer = NULL;
    }
}
コード例 #4
0
void rnFrameSetCamera(RnFrame frame,
                      const float *org,
                      const float *up,
                      const float *view,
                      float fov,
                      float ratio) {
    PF_ASSERT(frame);
    frame->setCamera(org, up, view, fov, ratio);
}
コード例 #5
0
 void RendererDisplayList::add(RendererObj *obj, const float *m) {
   PF_ASSERT(this->isCompiled() == false);
   Elem elem;
   if (m) {
     elem.isIdentity = 0;
     elem.model = mat4x4f(m[0], m[1], m[2], m[3],
                          m[4], m[5], m[6], m[7],
                          m[8], m[9], m[10],m[11],
                          m[12],m[13],m[14],m[15]);
   } else {
     elem.isIdentity = 1;
     elem.model = mat4x4f(one);
   }
   elem.object = obj;
   this->objects.push_back(elem);
 }
コード例 #6
0
ファイル: morton.cpp プロジェクト: binhpt/point-frag
int main(int argc, char *argv[])
{
  int32_t mortonX[n];
  int32_t mortonY[n];

  for (uint32_t i = 0; i < n; ++i) mortonX[i] = mortonY[i] = -1;
  for (uint16_t y = 0; y < dim; ++y)
  for (uint16_t x = 0; x < dim; ++x) {
    uint32_t z = 0;
    for (int i = 0; i < sizeof(x) * 8; i++)
      z |= (x & 1U << i) << i | (y & 1U << i) << (i + 1);
    mortonX[z] = x;
    mortonY[z] = y;
  }

#ifndef NDEBUG
  for (uint32_t i = 0; i < n; ++i) PF_ASSERT(mortonX[i] != -1 && mortonY[i] != -1);
#endif /* NDEBUG */

  std::cout << "const int32 ALIGNED(16) RTCameraPacketGen::mortonX[] = {" << std::endl;
  for (uint32_t i = 0; i < n; i += 16) {
    for (uint32_t j = i; j < i + 16; ++j)
      std::cout << std::setw(2) << mortonX[j] << ", ";
    std::cout << std::endl;
  }
  std::cout << "};" << std::endl;
  std::cout << std::endl;

  std::cout << "const int32 ALIGNED(16) RTCameraPacketGen::mortonY[] = {" << std::endl;
  for (uint32_t i = 0; i < n; i += 16) {
    for (uint32_t j = i; j < i + 16; ++j)
      std::cout << std::setw(2) << mortonY[j] << ", ";
    std::cout << std::endl;
  }
  std::cout << "};" << std::endl;
  std::cout << std::endl;
}
コード例 #7
0
ファイル: vec.hpp プロジェクト: binhpt/point-frag
 INLINE       T& operator [](size_t axis)       {PF_ASSERT(axis < 2); return (&x)[axis];}
コード例 #8
0
ファイル: vec.hpp プロジェクト: binhpt/point-frag
 INLINE const T& operator [](size_t axis) const {PF_ASSERT(axis < 2); return (&x)[axis];}
コード例 #9
0
static void RendererObjectCompile(T *object) {
    PF_ASSERT(object);
    object->compile();
}
コード例 #10
0
RnDisplayList rnDisplayListNew(RnContext ctx) {
    PF_ASSERT(ctx);
    RnDisplayList list = PF_NEW(RendererDisplayList, *ctx);
    RendererObjectNew(list);
    return list;
}
コード例 #11
0
/*! Common for all user renderer object deletion */
static void RendererObjectDelete(RendererObject *object) {
    PF_ASSERT(object);
    object->externalRefDec();
    if (object->refDec()) PF_DELETE(object);
}
コード例 #12
0
void rnFrameSetDisplayList(RnFrame frame, RnDisplayList list) {
    PF_ASSERT(frame);
    frame->setDisplayList(list);
}
コード例 #13
0
RnTask rnFrameDisplay(RnFrame frame) {
    PF_ASSERT(frame);
    return frame->display();
}
コード例 #14
0
void rnFrameSetScreenDimension(RnFrame frame, uint32 w, uint32 h) {
    PF_ASSERT(frame);
    frame->setScreenDimension(w, h);
}
コード例 #15
0
RnFrame rnFrameNew(RnContext ctx) {
    PF_ASSERT(ctx);
    RnFrame frame = PF_NEW(RendererFrame, *ctx);
    RendererObjectNew(frame);
    return frame;
}
コード例 #16
0
ファイル: avxi.hpp プロジェクト: binhpt/point-frag
 INLINE       int32& operator []( const size_t index )       { PF_ASSERT(index < 8); return v[index]; }
コード例 #17
0
/*! Common for all user renderer object retains */
static void RendererObjectRetain(RendererObject *object) {
    PF_ASSERT(object);
    object->refInc();
    object->externalRefInc();
}
コード例 #18
0
void rnObjSetIntersector(RnObj obj, RnIntersector intersector) {
    PF_ASSERT(obj && obj->isCompiled() == false);
    obj->intersector = intersector;
}