void SSAO::Update(const FrameBuffer *FBO, const Camera *camera) const
{
	ssaoFBO.Bind();
	glDepthMask(GL_FALSE);
	glDisable(GL_DEPTH_TEST);

	Shader *ssao = Manager::Shader->GetShader("ssao");
	ssao->Use();
	ssao->BindTexturesUnits();

	ssaoFBO.SendResolution(ssao);
	camera->BindViewMatrix(ssao->loc_view_matrix);
	camera->BindProjectionMatrix(ssao->loc_projection_matrix);
	camera->BindProjectionDistances(ssao);

	glUniform1f(ssao->loc_u_rad, radius);
	glUniform1i(ssao->loc_kernel_size, kernelSize);
	glUniform3fv(ssao->loc_kernel, kernelSize * 3, glm::value_ptr(kernel[0]));

	FBO->BindTexture(3, GL_TEXTURE0);
	FBO->BindTexture(4, GL_TEXTURE1);
	FBO->BindDepthTexture(GL_TEXTURE2);
	RandomNoise1->BindToTextureUnit(GL_TEXTURE3);
	RandomNoise2->BindToTextureUnit(GL_TEXTURE4);

	ScreenQuad->Render(ssao);

	// Finish TASK
	glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);

	FrameBuffer::Unbind();

	// -- COMPUTE SHADER
	int WORK_GROUP_SIZE = 16;
	auto res = ssaoFBO.GetResolution();

	Shader *S = Manager::Shader->GetShader("ssaoBlur");
	S->Use();

	// First Pass
	ssaoFBO.BindTexture(0, GL_TEXTURE0);
	
	glBindImageTexture(1, computeTexture->GetTextureID(), 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA16F);
	glDispatchCompute(GLuint(UPPER_BOUND(res.x, WORK_GROUP_SIZE)), GLuint(UPPER_BOUND(res.y, WORK_GROUP_SIZE)), 1);
	glMemoryBarrier(GL_ALL_BARRIER_BITS);

}
Exemple #2
0
/**
 * Returns a portion of a larger string.
 */
spif_charptr_t
spiftool_substr(spif_charptr_t str, spif_int32_t idx, spif_int32_t cnt)
{
    spif_charptr_t newstr;
    spif_uint32_t start_pos, char_count;
    spif_uint32_t len;

    REQUIRE_RVAL(str != (spif_charptr_t) NULL, (spif_charptr_t) NULL);

    len = (spif_uint32_t) strlen((char *) str);

    if (idx < 0) {
        start_pos = len + idx;
    } else {
        start_pos = idx;
    }
    REQUIRE_RVAL(start_pos < len, (spif_charptr_t) NULL);

    if (cnt <= 0) {
        char_count = len - start_pos + cnt;
    } else {
        char_count = cnt;
    }
    UPPER_BOUND(char_count, len - start_pos);

    newstr = (spif_charptr_t) MALLOC(char_count + 1);
    memcpy(newstr, str + start_pos, char_count);
    newstr[char_count] = 0;
    return newstr;
}
Exemple #3
0
Fichier : str.c Projet : mej/libast
spif_str_t
spif_str_substr(spif_str_t self, spif_stridx_t idx, spif_stridx_t cnt)
{
    ASSERT_RVAL(!SPIF_STR_ISNULL(self), (spif_str_t) NULL);
    if (idx < 0) {
        idx = self->len + idx;
    }
    REQUIRE_RVAL(idx >= 0, (spif_str_t) NULL);
    REQUIRE_RVAL(idx < self->len, (spif_str_t) NULL);
    if (cnt <= 0) {
        cnt = self->len - idx + cnt;
    }
    REQUIRE_RVAL(cnt >= 0, (spif_str_t) NULL);
    UPPER_BOUND(cnt, self->len - idx);
    return spif_str_new_from_buff(SPIF_STR_STR(self) + idx, cnt);
}
Exemple #4
0
Fichier : str.c Projet : mej/libast
spif_charptr_t
spif_str_substr_to_ptr(spif_str_t self, spif_stridx_t idx, spif_stridx_t cnt)
{
    spif_charptr_t newstr;

    ASSERT_RVAL(!SPIF_STR_ISNULL(self), (spif_charptr_t) NULL);
    if (idx < 0) {
        idx = self->len + idx;
    }
    REQUIRE_RVAL(idx >= 0, (spif_charptr_t) NULL);
    REQUIRE_RVAL(idx < self->len, (spif_charptr_t) NULL);
    if (cnt <= 0) {
        cnt = self->len - idx + cnt;
    }
    REQUIRE_RVAL(cnt >= 0, (spif_charptr_t) NULL);
    UPPER_BOUND(cnt, self->len - idx);

    newstr = (spif_charptr_t) MALLOC(cnt + 1);
    memcpy(newstr, SPIF_STR_STR(self) + idx, cnt);
    newstr[cnt] = 0;
    return newstr;
}
Exemple #5
0
void
scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes)
{

    D_SCROLLBAR(("scrollbar_draw_anchor(%u, 0x%02x)\n", (unsigned int) image_state, (unsigned int) force_modes));
    if (image_state != IMAGE_STATE_CURRENT) {
        if ((image_state == IMAGE_STATE_NORMAL) && (images[image_sa].current != images[image_sa].norm)) {
            images[image_sa].current = images[image_sa].norm;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_sa].current != images[image_sa].selected)) {
            images[image_sa].current = images[image_sa].selected;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_sa].current != images[image_sa].clicked)) {
            images[image_sa].current = images[image_sa].clicked;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_DISABLED) && (images[image_sa].current != images[image_sa].disabled)) {
            images[image_sa].current = images[image_sa].disabled;
            force_modes = MODE_MASK;
        }
        if ((image_state == IMAGE_STATE_NORMAL) && (images[image_st].current != images[image_st].norm)) {
            images[image_st].current = images[image_st].norm;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_SELECTED) && (images[image_st].current != images[image_st].selected)) {
            images[image_st].current = images[image_st].selected;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_CLICKED) && (images[image_st].current != images[image_st].clicked)) {
            images[image_st].current = images[image_st].clicked;
            force_modes = MODE_MASK;
        } else if ((image_state == IMAGE_STATE_DISABLED) && (images[image_st].current != images[image_st].disabled)) {
            images[image_st].current = images[image_st].disabled;
            force_modes = MODE_MASK;
        }
    }
    if (!image_mode_is(image_sa, MODE_MASK)) {
        /* Solid mode.  Redraw every time since it's cheap. */
#ifdef XTERM_SCROLLBAR
        if (scrollbar.type == SCROLLBAR_XTERM) {
            int x = ((BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_RIGHT)) ? 1 : 0);

            XSetForeground(Xdisplay, gc_stipple, images[image_sa].current->bg);
            XFillRectangle(Xdisplay, scrollbar.sa_win, gc_stipple, x + 1, 0, scrollbar_anchor_width() - x - 1,
                           scrollbar_anchor_height());
            XClearWindow(Xdisplay, scrollbar.sa_win);
        }
#endif /* XTERM_SCROLLBAR */
#if defined(MOTIF_SCROLLBAR) || defined(NEXT_SCROLLBAR)
        if (scrollbar.type == SCROLLBAR_MOTIF || scrollbar.type == SCROLLBAR_NEXT) {
            if (BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_SCROLLBAR_FLOATING)) {
                XSetWindowBackground(Xdisplay, scrollbar.sa_win, PixColors[bgColor]);
                XClearWindow(Xdisplay, scrollbar.sa_win);
            } else {
                XSetForeground(Xdisplay, gc_scrollbar, images[image_sa].current->bg);
                XFillRectangle(Xdisplay, scrollbar.sa_win, gc_scrollbar, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height());
            }
            XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, ""));
            XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, ""));
            if (scrollbar_anchor_is_pressed()) {
                draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(),
                            scrollbar_get_shadow());
            } else {
                draw_shadow(scrollbar.sa_win, gc_top, gc_bottom, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(),
                            scrollbar_get_shadow());
            }
        }
#endif
        return;
    }
    if (!((images[image_sa].mode & MODE_MASK) & (force_modes))) {
        return;
    }
    if (scrollbar_anchor_height() > 1) {
        unsigned char thumb;
        Pixmap pmap;

        thumb = (images[image_st].current->iml) ? 1 : 0;
        render_simage(images[image_sa].current, scrollbar.sa_win, scrollbar_anchor_width(), scrollbar_anchor_height(), image_sa,
                      thumb);
        pmap = images[image_sa].current->pmap->pixmap;
        /* Draw the thumb if there is one. */
        if (thumb) {
            unsigned short tw = 0, th = 0;
            imlib_t *iml = images[image_st].current->iml, *siml = images[image_sa].current->iml;

            if (image_mode_is(image_st, MODE_IMAGE) && iml->im) {
#ifdef PIXMAP_SUPPORT
                imlib_context_set_image(iml->im);
                tw = imlib_image_get_width();
                th = imlib_image_get_height();
#endif
            } else if (siml->bevel) {
                tw = scrollbar_anchor_width() - (siml->bevel->edges->left + siml->bevel->edges->right);
                th = scrollbar_anchor_width() - (siml->bevel->edges->top + siml->bevel->edges->bottom);
            } else if (siml->border) {
                tw = scrollbar_anchor_width() - (siml->border->left + siml->border->right);
                th = scrollbar_anchor_width() - (siml->border->top + siml->border->bottom);
            } else if (iml->bevel) {
                tw = iml->bevel->edges->left + iml->bevel->edges->right + 4;
                th = iml->bevel->edges->top + iml->bevel->edges->bottom + 4;
            }
            UPPER_BOUND(tw, scrollbar_anchor_width());
            UPPER_BOUND(th, scrollbar_anchor_height() >> 1);
            D_SCROLLBAR(("Thumb width/height has been calculated at %hux%hu.\n", tw, th));
            if ((tw > 0) && (th > 0)) {
                paste_simage(images[image_st].current, image_st, scrollbar.sa_win, pmap, (scrollbar_anchor_width() - tw) >> 1,
                             (scrollbar_anchor_height() - th) >> 1, tw, th);
                XSetWindowBackgroundPixmap(Xdisplay, scrollbar.sa_win, pmap);
                XClearWindow(Xdisplay, scrollbar.sa_win);
                IMLIB_FREE_PIXMAP(pmap);
                images[image_sa].current->pmap->pixmap = None;
            }
        }
Exemple #6
0
static void pcmReadFromDSP( void )
{
#if defined(MT6260)

#ifndef UPPER_BOUND
#define UPPER_BOUND(in,up)  ((in) > (up) ? (up) : (in))
#endif

    kal_uint16 *rb_addr, *rb_end;
    kal_int32 write_count = 0;
    kal_int32 count = mediaGetFreeSpace();
    kal_int32 I = (kal_int32)Pseudo_SAL_PcmEx_GetBufLen(PSEUDO_SAL_PCMEX_BUF_IDLE_SE);;

    count = UPPER_BOUND(count, I);

    if (count == 0)
    {
        return;
    }

    rb_end  = &pcm.ctrl->rb_base[pcm.ctrl->rb_size];
    rb_addr = &pcm.ctrl->rb_base[pcm.ctrl->write];

    if (Media_IsRecordSilence())
    {
        for (I = 0; I < count; I++)
        {
            if (pcm.PutSample(&rb_addr, 0))
            {
                write_count++;
                if (rb_addr == rb_end)
                {
                    rb_addr = &pcm.ctrl->rb_base[0];
                }
            }
        }
    }
    else
#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
    {
        volatile kal_uint16 *dspAddr = Pseudo_SAL_PcmEx_GetBuf(PSEUDO_SAL_PCMEX_BUF_SE);
        
        for (I = 0; I < count; I++)
        {
           if( pcm.PutSample( &rb_addr, *dspAddr++ ) ) 
           {
              write_count++;
              if( rb_addr == rb_end )
              {
                 rb_addr = &pcm.ctrl->rb_base[0];
              }
           }
        }
    }
#else
    {
        volatile kal_uint16 *dspAddr = Pseudo_SAL_PcmEx_GetBuf(PSEUDO_SAL_PCMEX_BUF_SE);
        kal_uint16 dummy = *dspAddr;
   
        for (I = 0; I < count; I++)
        {
            if (pcm.PutSample(&rb_addr, *IDMA_SHORT_ADDR)) 
            {
                write_count++;
                if (rb_addr == rb_end)
                {
                    rb_addr = &pcm.ctrl->rb_base[0];
                }
            }
        }
   }
#endif
#else   // chip compile option

#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
   volatile kal_uint16* idmaPtr;
#endif

	 kal_int32 I, count, write_count = 0;
   kal_uint16 *rb_addr, *rb_end, ptr_addr;

   count = mediaGetFreeSpace();

   if ( pcm.ctrl->format == MEDIA_FORMAT_PCM_16K )
      I = DSP_PCM_16K_REC_LEN;
   else
      I = (kal_int32)(*DSP_PCM_REC_LEN);
   if( I < count )
      count = I;
   if( count == 0 )
      return;

   rb_end   = &pcm.ctrl->rb_base[pcm.ctrl->rb_size];
   rb_addr  = &pcm.ctrl->rb_base[pcm.ctrl->write];

   if(Media_IsRecordSilence())
   {
      for( I = 0; I < count; I++ )
      {
         if( pcm.PutSample( &rb_addr, 0 ) ) 
         {
            write_count++;
            if( rb_addr == rb_end )
            {
               rb_addr = &pcm.ctrl->rb_base[0];
            }
         }
      }
   }
   else
#ifdef L1AUDIO_IDMA_ALL_ADDRESS_MODE
   {
      if ( pcm.ctrl->format == MEDIA_FORMAT_PCM_16K )
      { 
         ptr_addr = *DSP2_DM_ADDR(PAGE_NUM, DSP_PCM_16K_REC_PTR);
         idmaPtr=DSP2_DM_ADDR(PAGE_NUM, ptr_addr);
      
      }
      else
      {
         idmaPtr=DSP_DM_ADDR(PAGE_NUM, *DSP_PCM_REC_ADDR);
      }
      for( I = 0; I < count; I++ )
      {
         if( pcm.PutSample( &rb_addr, *idmaPtr++ ) ) 
         {
            write_count++;
            if( rb_addr == rb_end )
            {
               rb_addr = &pcm.ctrl->rb_base[0];
            }
         }
      }
   }
#else// L1AUDIO_IDMA_ALL_ADDRESS_MODE
   {
      kal_uint16 dummy;
      if ( pcm.ctrl->format == MEDIA_FORMAT_PCM_16K )
      { 
         ptr_addr = *DSP2_DM_ADDR(PAGE_NUM, DSP_PCM_16K_REC_PTR);
         dummy    = *DSP2_DM_ADDR(PAGE_NUM, ptr_addr);
      }
      else
      {
         dummy = *DSP_DM_ADDR(PAGE_NUM, *DSP_PCM_REC_ADDR);
      }
   
      for( I = 0; I < count; I++ )
      {
         if( pcm.PutSample( &rb_addr, *IDMA_SHORT_ADDR ) ) 
         {
            write_count++;
            if( rb_addr == rb_end )
            {
               rb_addr = &pcm.ctrl->rb_base[0];
            }
         }
      }
   }
#endif
#endif  // chip compile option
   pcm.MIC1_framesize = write_count;
   pcm.ctrl->write += write_count;
   if( pcm.ctrl->write >= pcm.ctrl->rb_size )
   {
      pcm.ctrl->write -= pcm.ctrl->rb_size;
   }
}