예제 #1
0
static void *
svga_create_sampler_state(struct pipe_context *pipe,
                          const struct pipe_sampler_state *sampler)
{
   struct svga_context *svga = svga_context(pipe);
   struct svga_sampler_state *cso = CALLOC_STRUCT( svga_sampler_state );
   
   cso->mipfilter = translate_mip_filter(sampler->min_mip_filter);
   cso->magfilter = translate_img_filter( sampler->mag_img_filter );
   cso->minfilter = translate_img_filter( sampler->min_img_filter );
   cso->aniso_level = MAX2( (unsigned) sampler->max_anisotropy, 1 );
   cso->lod_bias = sampler->lod_bias;
   cso->addressu = translate_wrap_mode(sampler->wrap_s);
   cso->addressv = translate_wrap_mode(sampler->wrap_t);
   cso->addressw = translate_wrap_mode(sampler->wrap_r);
   cso->normalized_coords = sampler->normalized_coords;
   cso->compare_mode = sampler->compare_mode;
   cso->compare_func = sampler->compare_func;

   {
      ubyte r = float_to_ubyte(sampler->border_color[0]);
      ubyte g = float_to_ubyte(sampler->border_color[1]);
      ubyte b = float_to_ubyte(sampler->border_color[2]);
      ubyte a = float_to_ubyte(sampler->border_color[3]);

      util_pack_color_ub( r, g, b, a,
                          PIPE_FORMAT_B8G8R8A8_UNORM,
                          &cso->bordercolor );
   }

   /* No SVGA3D support for:
    *    - min/max LOD clamping
    */
   cso->min_lod = 0;
   cso->view_min_lod = MAX2(sampler->min_lod, 0);
   cso->view_max_lod = MAX2(sampler->max_lod, 0);

   /* Use min_mipmap */
   if (svga->debug.use_min_mipmap) {
      if (cso->view_min_lod == cso->view_max_lod) {
         cso->min_lod = cso->view_min_lod;
         cso->view_min_lod = 0;
         cso->view_max_lod = 1000; /* Just a high number */
         cso->mipfilter = SVGA3D_TEX_FILTER_NONE;
      }
   }

   SVGA_DBG(DEBUG_VIEWS, "min %u, view(min %u, max %u) lod, mipfilter %s\n",
            cso->min_lod, cso->view_min_lod, cso->view_max_lod,
            cso->mipfilter == SVGA3D_TEX_FILTER_NONE ? "SVGA3D_TEX_FILTER_NONE" : "SOMETHING");

   return cso;
}
예제 #2
0
/**
 * Update the pixelmap texture with the contents of the R/G/B/A pixel maps.
 */
static void
load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
{
   struct pipe_context *pipe = ctx->st->pipe;
   struct pipe_screen *screen = pipe->screen;
   struct pipe_surface *surface;
   const GLuint rSize = ctx->PixelMaps.RtoR.Size;
   const GLuint gSize = ctx->PixelMaps.GtoG.Size;
   const GLuint bSize = ctx->PixelMaps.BtoB.Size;
   const GLuint aSize = ctx->PixelMaps.AtoA.Size;
   const uint texSize = pt->width[0];
   uint *dest;
   uint i, j;

   surface = screen->get_tex_surface(screen, pt, 0, 0, 0, 
                                     PIPE_BUFFER_USAGE_CPU_WRITE);
   dest = (uint *) screen->surface_map(screen, surface,
                                       PIPE_BUFFER_USAGE_CPU_WRITE);

   /* Pack four 1D maps into a 2D texture:
    * R map is placed horizontally, indexed by S, in channel 0
    * G map is placed vertically, indexed by T, in channel 1
    * B map is placed horizontally, indexed by S, in channel 2
    * A map is placed vertically, indexed by T, in channel 3
    */
   for (i = 0; i < texSize; i++) {
      for (j = 0; j < texSize; j++) {
         int k = (i * texSize + j);
         ubyte r = ctx->PixelMaps.RtoR.Map8[j * rSize / texSize];
         ubyte g = ctx->PixelMaps.GtoG.Map8[i * gSize / texSize];
         ubyte b = ctx->PixelMaps.BtoB.Map8[j * bSize / texSize];
         ubyte a = ctx->PixelMaps.AtoA.Map8[i * aSize / texSize];
         util_pack_color_ub(r, g, b, a, pt->format, dest + k);
      }
   }

   screen->surface_unmap(screen, surface);
   pipe_surface_reference(&surface, NULL);
}
예제 #3
0
/**
 * Update the pixelmap texture with the contents of the R/G/B/A pixel maps.
 */
static void
load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
{
   struct pipe_context *pipe = ctx->st->pipe;
   struct pipe_screen *screen = pipe->screen;
   struct pipe_transfer *transfer;
   const GLuint rSize = ctx->PixelMaps.RtoR.Size;
   const GLuint gSize = ctx->PixelMaps.GtoG.Size;
   const GLuint bSize = ctx->PixelMaps.BtoB.Size;
   const GLuint aSize = ctx->PixelMaps.AtoA.Size;
   const uint texSize = pt->width[0];
   uint *dest;
   uint i, j;

   transfer = st_cond_flush_get_tex_transfer(st_context(ctx),
					     pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
					     0, 0, texSize, texSize);
   dest = (uint *) screen->transfer_map(screen, transfer);

   /* Pack four 1D maps into a 2D texture:
    * R map is placed horizontally, indexed by S, in channel 0
    * G map is placed vertically, indexed by T, in channel 1
    * B map is placed horizontally, indexed by S, in channel 2
    * A map is placed vertically, indexed by T, in channel 3
    */
   for (i = 0; i < texSize; i++) {
      for (j = 0; j < texSize; j++) {
         int k = (i * texSize + j);
         ubyte r = ctx->PixelMaps.RtoR.Map8[j * rSize / texSize];
         ubyte g = ctx->PixelMaps.GtoG.Map8[i * gSize / texSize];
         ubyte b = ctx->PixelMaps.BtoB.Map8[j * bSize / texSize];
         ubyte a = ctx->PixelMaps.AtoA.Map8[i * aSize / texSize];
         util_pack_color_ub(r, g, b, a, pt->format, dest + k);
      }
   }

   screen->transfer_unmap(screen, transfer);
   screen->tex_transfer_destroy(transfer);
}