Пример #1
0
FX_ENTRY void FX_CALL
grDrawTriangle(const void *a, const void *b, const void *c)
{
    WriteTrace(TraceGlitch, TraceDebug, "start");

    if (nvidia_viewport_hack && !render_to_texture)
    {
        glViewport(0, viewport_offset, viewport_width, viewport_height);
        nvidia_viewport_hack = 0;
    }

    reloadTexture();

    if (need_to_compile) compile_shader();

    if (vertex_buffer_count + 3 > VERTEX_BUFFER_SIZE)
    {
        vbo_draw();
    }
    vertex_draw_mode = GL_TRIANGLES;
    memcpy(&vertex_buffer[vertex_buffer_count], a, VERTEX_SIZE);
    memcpy(&vertex_buffer[vertex_buffer_count + 1], b, VERTEX_SIZE);
    memcpy(&vertex_buffer[vertex_buffer_count + 2], c, VERTEX_SIZE);
    vertex_buffer_count += 3;

    WriteTrace(TraceGlitch, TraceDebug, "Done");
}
Пример #2
0
FX_ENTRY void FX_CALL
grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 stride)
{
    WriteTrace(TraceGlitch, TraceDebug, "grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);

    if (nvidia_viewport_hack && !render_to_texture)
    {
        glViewport(0, viewport_offset, viewport_width, viewport_height);
        nvidia_viewport_hack = 0;
    }

    if (stride != 156)
    {
        //LOGINFO("Incompatible stride\n");
    }

    reloadTexture();

    if (need_to_compile) compile_shader();

    vbo_enable();

    switch (mode)
    {
    case GR_TRIANGLE_STRIP:
        vbo_buffer(GL_TRIANGLE_STRIP, 0, Count, pointers);
        break;
    case GR_TRIANGLE_FAN:
        vbo_buffer(GL_TRIANGLE_FAN, 0, Count, pointers);
        break;
    default:
        WriteTrace(TraceGlitch, TraceWarning, "grDrawVertexArrayContiguous : unknown mode : %x", mode);
    }
}
Пример #3
0
FX_ENTRY void FX_CALL
grDrawPoint( const void *pt )
{
  float *x = (float*)pt + xy_off/sizeof(float);
  float *y = (float*)pt + xy_off/sizeof(float) + 1;
  float *z = (float*)pt + z_off/sizeof(float);
  float *q = (float*)pt + q_off/sizeof(float);
  unsigned char *pargb = (unsigned char*)pt + pargb_off;
  float *s0 = (float*)pt + st0_off/sizeof(float);
  float *t0 = (float*)pt + st0_off/sizeof(float) + 1;
  float *s1 = (float*)pt + st1_off/sizeof(float);
  float *t1 = (float*)pt + st1_off/sizeof(float) + 1;
  float *fog = (float*)pt + fog_ext_off/sizeof(float);
  LOG("grDrawPoint()\r\n");

  if(nvidia_viewport_hack && !render_to_texture)
  {
    glViewport(0, viewport_offset, viewport_width, viewport_height);
    nvidia_viewport_hack = 0;
  }

  reloadTexture();

  if(need_to_compile) compile_shader();

  glBegin(GL_POINTS);

  if (nbTextureUnits > 2)
  {
    if (st0_en)
      glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
      ytex(0, *t0 / *q / (float)tex1_height));
    if (st1_en)
      glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
      ytex(1, *t1 / *q / (float)tex0_height));
  }
  else
  {
    if (st0_en)
      glTexCoord2f(*s0 / *q / (float)tex0_width,
      ytex(0, *t0 / *q / (float)tex0_height));
  }
  if (pargb_en)
    glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
  if (fog_enabled && fog_coord_support)
  {
    if(!fog_ext_en || fog_enabled != 2)
      glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
    else
      glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
  }
  glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
    -(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z ,*q), 1.0f / *q);

  glEnd();
}
FX_ENTRY void FX_CALL
grDrawTriangle( const void *a, const void *b, const void *c )
{
  LOG("grDrawTriangle()\r\n\t");

  if(nvidia_viewport_hack && !render_to_texture)
  {
    glViewport(0, viewport_offset, viewport_width, viewport_height);
    nvidia_viewport_hack = 0;
  }

  reloadTexture();

  if(need_to_compile) compile_shader();

  VERTEX v[3] = {*(VERTEX *)a, *(VERTEX *)b, *(VERTEX *)c};

  vbo_enable();
  vbo_buffer(GL_TRIANGLES, 0, 3, &v[0]);
}
Пример #5
0
FX_ENTRY void FX_CALL
grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
{
    void **pointers = (void**)pointers2;
    WriteTrace(TraceGlitch, TraceDebug, "grDrawVertexArray(%d,%d)\r\n", mode, Count);

    if (nvidia_viewport_hack && !render_to_texture)
    {
        glViewport(0, viewport_offset, viewport_width, viewport_height);
        nvidia_viewport_hack = 0;
    }

    reloadTexture();

    if (need_to_compile) compile_shader();

    if (mode != GR_TRIANGLE_FAN)
    {
        WriteTrace(TraceGlitch, TraceWarning, "grDrawVertexArray : unknown mode : %x", mode);
    }

    vbo_enable();
    vbo_buffer(GL_TRIANGLE_FAN, 0, Count, pointers[0]);
}
Пример #6
0
void Layer::lockPageFlip(bool& recomputeVisibleRegions)
{
    ClientRef::Access sharedClient(mUserClientRef);
    SharedBufferServer* lcblk(sharedClient.get());
    if (!lcblk) {
        // client died
        recomputeVisibleRegions = true;
        return;
    }

    ssize_t buf = lcblk->retireAndLock();
    if (buf == NOT_ENOUGH_DATA) {
        // NOTE: This is not an error, it simply means there is nothing to
        // retire. The buffer is locked because we will use it
        // for composition later in the loop
        return;
    }

    if (buf < NO_ERROR) {
        LOGE("retireAndLock() buffer index (%d) out of range", int(buf));
        mPostedDirtyRegion.clear();
        return;
    }

    // we retired a buffer, which becomes the new front buffer
    if (mBufferManager.setActiveBufferIndex(buf) < NO_ERROR) {
        LOGE("retireAndLock() buffer index (%d) out of range", int(buf));
        mPostedDirtyRegion.clear();
        return;
    }

    sp<GraphicBuffer> newFrontBuffer(getBuffer(buf));
    if (newFrontBuffer != NULL) {
        // get the dirty region
        // compute the posted region
        const Region dirty(lcblk->getDirtyRegion(buf));
        mPostedDirtyRegion = dirty.intersect( newFrontBuffer->getBounds() );

        // update the layer size and release freeze-lock
        const Layer::State& front(drawingState());
        if (newFrontBuffer->getWidth()  == front.requested_w &&
            newFrontBuffer->getHeight() == front.requested_h)
        {
            if ((front.w != front.requested_w) ||
                (front.h != front.requested_h))
            {
                // Here we pretend the transaction happened by updating the
                // current and drawing states. Drawing state is only accessed
                // in this thread, no need to have it locked
                Layer::State& editDraw(mDrawingState);
                editDraw.w = editDraw.requested_w;
                editDraw.h = editDraw.requested_h;

                // We also need to update the current state so that we don't
                // end-up doing too much work during the next transaction.
                // NOTE: We actually don't need hold the transaction lock here
                // because State::w and State::h are only accessed from
                // this thread
                Layer::State& editTemp(currentState());
                editTemp.w = editDraw.w;
                editTemp.h = editDraw.h;

                // recompute visible region
                recomputeVisibleRegions = true;
            }

            // we now have the correct size, unfreeze the screen
            mFreezeLock.clear();
        }

        // get the crop region
        setBufferCrop( lcblk->getCrop(buf) );

        // get the transformation
        setBufferTransform( lcblk->getTransform(buf) );

    } else {
        // this should not happen unless we ran out of memory while
        // allocating the buffer. we're hoping that things will get back
        // to normal the next time the app tries to draw into this buffer.
        // meanwhile, pretend the screen didn't update.
        mPostedDirtyRegion.clear();
    }

    if (lcblk->getQueuedCount()) {
        // signal an event if we have more buffers waiting
        mFlinger->signalEvent();
    }

    /* a buffer was posted, so we need to call reloadTexture(), which
     * will update our internal data structures (eg: EGLImageKHR or
     * texture names). we need to do this even if mPostedDirtyRegion is
     * empty -- it's orthogonal to the fact that a new buffer was posted,
     * for instance, a degenerate case could be that the user did an empty
     * update but repainted the buffer with appropriate content (after a
     * resize for instance).
     */
    reloadTexture( mPostedDirtyRegion );
}
Пример #7
0
FX_ENTRY void FX_CALL
grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 stride)
{
  unsigned int i;
  float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog;
  unsigned char *pargb;
  LOG("grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);

  if(nvidia_viewport_hack && !render_to_texture)
  {
    glViewport(0, viewport_offset, viewport_width, viewport_height);
    nvidia_viewport_hack = 0;
  }

  reloadTexture();

  if(need_to_compile) compile_shader();

  switch(mode)
  {
  case GR_TRIANGLE_STRIP:
    glBegin(GL_TRIANGLE_STRIP);
    break;
  case GR_TRIANGLE_FAN:
    glBegin(GL_TRIANGLE_FAN);
    break;
  default:
    display_warning("grDrawVertexArrayContiguous : unknown mode : %x", mode);
  }

  for (i=0; i<Count; i++)
  {
    x = (float*)((unsigned char*)pointers+stride*i) + xy_off/sizeof(float);
    y = (float*)((unsigned char*)pointers+stride*i) + xy_off/sizeof(float) + 1;
    z = (float*)((unsigned char*)pointers+stride*i) + z_off/sizeof(float);
    q = (float*)((unsigned char*)pointers+stride*i) + q_off/sizeof(float);
    pargb = (unsigned char*)pointers+stride*i + pargb_off;
    s0 = (float*)((unsigned char*)pointers+stride*i) + st0_off/sizeof(float);
    t0 = (float*)((unsigned char*)pointers+stride*i) + st0_off/sizeof(float) + 1;
    s1 = (float*)((unsigned char*)pointers+stride*i) + st1_off/sizeof(float);
    t1 = (float*)((unsigned char*)pointers+stride*i) + st1_off/sizeof(float) + 1;
    fog = (float*)((unsigned char*)pointers+stride*i) + fog_ext_off/sizeof(float);

    //if(*fog == 0.0f) *fog = 1.0f;

    if (nbTextureUnits > 2)
    {
      if (st0_en)
        glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
        ytex(0, *t0 / *q / (float)tex1_height));
      if (st1_en)
        glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
        ytex(1, *t1 / *q / (float)tex0_height));
    }
    else
    {
      if (st0_en)
        glTexCoord2f(*s0 / *q / (float)tex0_width,
        ytex(0, *t0 / *q / (float)tex0_height));
    }
    if (pargb_en)
      glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
    if (fog_enabled && fog_coord_support)
    {
      if(!fog_ext_en || fog_enabled != 2)
        glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
      else
        glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
    }

    glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
      -(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z, *q), 1.0f / *q);
  }
  glEnd();
}
Пример #8
0
FX_ENTRY void FX_CALL
grDrawLine( const void *a, const void *b )
{
  float *a_x = (float*)a + xy_off/sizeof(float);
  float *a_y = (float*)a + xy_off/sizeof(float) + 1;
  float *a_z = (float*)a + z_off/sizeof(float);
  float *a_q = (float*)a + q_off/sizeof(float);
  unsigned char *a_pargb = (unsigned char*)a + pargb_off;
  float *a_s0 = (float*)a + st0_off/sizeof(float);
  float *a_t0 = (float*)a + st0_off/sizeof(float) + 1;
  float *a_s1 = (float*)a + st1_off/sizeof(float);
  float *a_t1 = (float*)a + st1_off/sizeof(float) + 1;
  float *a_fog = (float*)a + fog_ext_off/sizeof(float);

  float *b_x = (float*)b + xy_off/sizeof(float);
  float *b_y = (float*)b + xy_off/sizeof(float) + 1;
  float *b_z = (float*)b + z_off/sizeof(float);
  float *b_q = (float*)b + q_off/sizeof(float);
  unsigned char *b_pargb = (unsigned char*)b + pargb_off;
  float *b_s0 = (float*)b + st0_off/sizeof(float);
  float *b_t0 = (float*)b + st0_off/sizeof(float) + 1;
  float *b_s1 = (float*)b + st1_off/sizeof(float);
  float *b_t1 = (float*)b + st1_off/sizeof(float) + 1;
  float *b_fog = (float*)b + fog_ext_off/sizeof(float);
  LOG("grDrawLine()\r\n");

  if(nvidia_viewport_hack && !render_to_texture)
  {
    glViewport(0, viewport_offset, viewport_width, viewport_height);
    nvidia_viewport_hack = 0;
  }

  reloadTexture();

  if(need_to_compile) compile_shader();

  glBegin(GL_LINES);

  if (nbTextureUnits > 2)
  {
    if (st0_en)
      glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *a_s0 / *a_q / (float)tex1_width, ytex(0, *a_t0 / *a_q / (float)tex1_height));
    if (st1_en)
      glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *a_s1 / *a_q / (float)tex0_width, ytex(1, *a_t1 / *a_q / (float)tex0_height));
  }
  else
  {
    if (st0_en)
      glTexCoord2f(*a_s0 / *a_q / (float)tex0_width, ytex(0, *a_t0 / *a_q / (float)tex0_height));
  }
  if (pargb_en)
    glColor4f(a_pargb[2]/255.0f, a_pargb[1]/255.0f, a_pargb[0]/255.0f, a_pargb[3]/255.0f);
  if (fog_enabled && fog_coord_support)
  {
    if(!fog_ext_en || fog_enabled != 2)
      glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f);
    else
      glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f);
  }
  glVertex4f((*a_x - (float)widtho) / (float)(width/2) / *a_q,
    -(*a_y - (float)heighto) / (float)(height/2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q);

  if (nbTextureUnits > 2)
  {
    if (st0_en)
      glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *b_s0 / *b_q / (float)tex1_width,
      ytex(0, *b_t0 / *b_q / (float)tex1_height));
    if (st1_en)
      glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *b_s1 / *b_q / (float)tex0_width,
      ytex(1, *b_t1 / *b_q / (float)tex0_height));
  }
  else
  {
    if (st0_en)
      glTexCoord2f(*b_s0 / *b_q / (float)tex0_width,
      ytex(0, *b_t0 / *b_q / (float)tex0_height));
  }
  if (pargb_en)
    glColor4f(b_pargb[2]/255.0f, b_pargb[1]/255.0f, b_pargb[0]/255.0f, b_pargb[3]/255.0f);
  if (fog_enabled && fog_coord_support)
  {
    if(!fog_ext_en || fog_enabled != 2)
      glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f);
    else
      glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f);
  }
  glVertex4f((*b_x - (float)widtho) / (float)(width/2) / *b_q,
    -(*b_y - (float)heighto) / (float)(height/2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q);

  glEnd();
}