src/library/textures.cc
// Meant to look like gallium's util_format_translate, but tries to use DMA:
Meant to look like gallium's util_format_translate, but tries to use DMA.
Meant to look like gallium ' s util_format_translate but tries to use DMA .
static inline void
rsxgl_util_format_translate_dma(rsxgl_context_t * ctx,
				enum pipe_format dst_format,
				void * dstaddress, const memory_t & dstmem, unsigned dst_stride,
				unsigned dst_x, unsigned dst_y,
				enum pipe_format src_format,
				const void * srcaddress, const memory_t & srcmem, unsigned src_stride,
				unsigned src_x, unsigned src_y,
				unsigned width, unsigned height)
{
  const struct util_format_description *dst_format_desc = util_format_description(dst_format);
  const struct util_format_description *src_format_desc = util_format_description(src_format);
  util_format_translate(dst_format,dstaddress,dst_stride,dst_x,dst_y,
			src_format,srcaddress,src_stride,src_x,src_y,
			width,height);
#if 0
  const uint8_t * pdstaddress = (const uint8_t *)dstaddress;
  for(unsigned int j = 0;j < 120;++j) {
    const uint8_t * ppdstaddress = pdstaddress;
    for(unsigned int i = 0;i < 160;++i) {
      rsxgl_debug_printf("(%i,%i,%i,%i)",
			 (unsigned int)ppdstaddress[0],
			 (unsigned int)ppdstaddress[1],
			 (unsigned int)ppdstaddress[2],
			 (unsigned int)ppdstaddress[3]);
      ppdstaddress += 4;
    }
    rsxgl_debug_printf("\n");
    pdstaddress += dst_stride;
  }
#endif
#if 0
  if(util_is_format_compatible(src_format_desc, dst_format_desc)) {
    const int blocksize = dst_format_desc->block.bits / 8;
    const int blockwidth = dst_format_desc->block.width;
    const int blockheight = dst_format_desc->block.height;
    dst_x /= blockwidth;
    dst_y /= blockheight;
    width = (width + blockwidth - 1)/blockwidth;
    height = (height + blockheight - 1)/blockheight;
    src_x /= blockwidth;
    src_y /= blockheight;
    const uint32_t linelength = width * blocksize;
    rsxgl_memory_transfer(ctx -> gcm_context(),
			  dstmem + (dst_x * blocksize) + (dst_y * dst_stride),dst_stride,1,
			  srcmem + (src_x * blocksize) + (src_y * src_stride),src_stride,1,
			  linelength,height);
  }
  else {
    rsxgl_debug_printf("%s: non-trivial transfer didn't happen src:%x dst:%x\n",__PRETTY_FUNCTION__,
		       (unsigned int)src_format,(unsigned int)dst_format);
    rsxgl_assert(dstaddress != 0);
    rsxgl_assert(srcaddress != 0);
    util_format_translate(dst_format,dstaddress,dst_stride,dst_x,dst_y,
			  src_format,srcaddress,src_stride,src_x,src_y,
			  width,height);
  }
#endif
}
static inline void rsxgl_util_format_translate_dma ( rsxgl_context_t * ctx , enum pipe_format dst_format , void * dstaddress , const memory_t & dstmem , unsigned dst_stride , unsigned dst_x , unsigned dst_y , enum pipe_format src_format , const void * srcaddress , const memory_t & srcmem , unsigned src_stride , unsigned src_x , unsigned src_y , unsigned width , unsigned height ) { const struct util_format_description * dst_format_desc = util_format_description ( dst_format ) ; const struct util_format_description * src_format_desc = util_format_description ( src_format ) ; util_format_translate ( dst_format , dstaddress , dst_stride , dst_x , dst_y , src_format , srcaddress , src_stride , src_x , src_y , width , height ) ; #if 0 const uint8_t * pdstaddress = ( const uint8_t * ) dstaddress ; for ( unsigned int j = 0 ; j < 120 ; ++ j ) { const uint8_t * ppdstaddress = pdstaddress ; for ( unsigned int i = 0 ; i < 160 ; ++ i ) { rsxgl_debug_printf ( " " , ( unsigned int ) ppdstaddress [ 0 ] , ( unsigned int ) ppdstaddress [ 1 ] , ( unsigned int ) ppdstaddress [ 2 ] , ( unsigned int ) ppdstaddress [ 3 ] ) ; ppdstaddress += 4 ; } rsxgl_debug_printf ( " \n " ) ; pdstaddress += dst_stride ; } #endif #if 0 if ( util_is_format_compatible ( src_format_desc , dst_format_desc ) ) { const int blocksize = dst_format_desc -> block . bits / 8 ; const int blockwidth = dst_format_desc -> block . width ; const int blockheight = dst_format_desc -> block . height ; dst_x /= blockwidth ; dst_y /= blockheight ; width = ( width + blockwidth - 1 ) / blockwidth ; height = ( height + blockheight - 1 ) / blockheight ; src_x /= blockwidth ; src_y /= blockheight ; const uint32_t linelength = width * blocksize ; rsxgl_memory_transfer ( ctx -> gcm_context ( ) , dstmem + ( dst_x * blocksize ) + ( dst_y * dst_stride ) , dst_stride , 1 , srcmem + ( src_x * blocksize ) + ( src_y * src_stride ) , src_stride , 1 , linelength , height ) ; } else { rsxgl_debug_printf ( " \n " , __PRETTY_FUNCTION__ , ( unsigned int ) src_format , ( unsigned int ) dst_format ) ; rsxgl_assert ( dstaddress != 0 ) ; rsxgl_assert ( srcaddress != 0 ) ; util_format_translate ( dst_format , dstaddress , dst_stride , dst_x , dst_y , src_format , srcaddress , src_stride , src_x , src_y , width , height ) ; } #endif }
Meant to look like gallium's util_format_translate, but tries to use DMA:
Meant to look like gallium ' s util_format_translate but tries to use DMA :