Example #1
0
boolean
util_format_is_supported(enum pipe_format format, unsigned bind)
{
   if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) {
      return FALSE;
   }

#ifndef TEXTURE_FLOAT_ENABLED
   if ((bind & PIPE_BIND_RENDER_TARGET) &&
       format != PIPE_FORMAT_R9G9B9E5_FLOAT &&
       format != PIPE_FORMAT_R11G11B10_FLOAT &&
       util_format_is_float(format)) {
      return FALSE;
   }
#endif

   return TRUE;
}
Example #2
0
/**
 * Query format support for creating a texture, drawing surface, etc.
 * \param format  the format to test
 * \param type  one of PIPE_TEXTURE, PIPE_SURFACE
 */
static boolean
llvmpipe_is_format_supported( struct pipe_screen *_screen,
                              enum pipe_format format,
                              enum pipe_texture_target target,
                              unsigned sample_count,
                              unsigned bind)
{
   struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
   struct sw_winsys *winsys = screen->winsys;
   const struct util_format_description *format_desc;

   format_desc = util_format_description(format);
   if (!format_desc)
      return FALSE;

   assert(target == PIPE_BUFFER ||
          target == PIPE_TEXTURE_1D ||
          target == PIPE_TEXTURE_1D_ARRAY ||
          target == PIPE_TEXTURE_2D ||
          target == PIPE_TEXTURE_2D_ARRAY ||
          target == PIPE_TEXTURE_RECT ||
          target == PIPE_TEXTURE_3D ||
          target == PIPE_TEXTURE_CUBE);

   if (sample_count > 1)
      return FALSE;

   if (bind & PIPE_BIND_RENDER_TARGET) {
      if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
         if (format_desc->nr_channels < 3)
            return FALSE;
      }
      else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB)
         return FALSE;

      if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
          format != PIPE_FORMAT_R11G11B10_FLOAT)
         return FALSE;

      assert(format_desc->block.width == 1);
      assert(format_desc->block.height == 1);

      if (format_desc->is_mixed)
         return FALSE;

      if (!format_desc->is_array && !format_desc->is_bitmask &&
          format != PIPE_FORMAT_R11G11B10_FLOAT)
         return FALSE;

      /*
       * XXX refuse formats known to crash in generate_unswizzled_blend().
       * These include all 3-channel 24bit RGB8 variants, plus 48bit
       * (except those using floats) 3-channel RGB16 variants (the latter
       * seems to be more of a llvm bug though).
       * The mesa state tracker only seems to use these for SINT/UINT formats.
       */
      if (format_desc->is_array && format_desc->nr_channels == 3) {
         if (format_desc->block.bits == 24 || (format_desc->block.bits == 48 &&
               !util_format_is_float(format))) {
            return FALSE;
         }
      }
   }

   if (bind & PIPE_BIND_DISPLAY_TARGET) {
      if(!winsys->is_displaytarget_format_supported(winsys, bind, format))
         return FALSE;
   }

   if (bind & PIPE_BIND_DEPTH_STENCIL) {
      if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
         return FALSE;

      if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
         return FALSE;

      /* TODO: Support stencil-only formats */
      if (format_desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_NONE) {
         return FALSE;
      }
   }

   if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
      return util_format_s3tc_enabled;
   }

   /*
    * Everything can be supported by u_format
    * (those without fetch_rgba_float might be not but shouldn't hit that)
    */

   return TRUE;
}
Example #3
0
struct pipe_resource *
nv30_miptree_create(struct pipe_screen *pscreen,
                    const struct pipe_resource *tmpl)
{
   struct nouveau_device *dev = nouveau_screen(pscreen)->device;
   struct nv30_miptree *mt = CALLOC_STRUCT(nv30_miptree);
   struct pipe_resource *pt = &mt->base.base;
   unsigned blocksz, size;
   unsigned w, h, d, l;
   int ret;

   switch (tmpl->nr_samples) {
   case 4:
      mt->ms_mode = 0x00004000;
      mt->ms_x = 1;
      mt->ms_y = 1;
      break;
   case 2:
      mt->ms_mode = 0x00003000;
      mt->ms_x = 1;
      mt->ms_y = 0;
      break;
   default:
      mt->ms_mode = 0x00000000;
      mt->ms_x = 0;
      mt->ms_y = 0;
      break;
   }

   mt->base.vtbl = &nv30_miptree_vtbl;
   *pt = *tmpl;
   pipe_reference_init(&pt->reference, 1);
   pt->screen = pscreen;

   w = pt->width0 << mt->ms_x;
   h = pt->height0 << mt->ms_y;
   d = (pt->target == PIPE_TEXTURE_3D) ? pt->depth0 : 1;
   blocksz = util_format_get_blocksize(pt->format);

   if ((pt->target == PIPE_TEXTURE_RECT) ||
       !util_is_power_of_two(pt->width0) ||
       !util_is_power_of_two(pt->height0) ||
       !util_is_power_of_two(pt->depth0) ||
       util_format_is_compressed(pt->format) ||
       util_format_is_float(pt->format) || mt->ms_mode) {
      mt->uniform_pitch = util_format_get_nblocksx(pt->format, w) * blocksz;
      mt->uniform_pitch = align(mt->uniform_pitch, 64);
   }

   if (!mt->uniform_pitch)
      mt->swizzled = TRUE;

   size = 0;
   for (l = 0; l <= pt->last_level; l++) {
      struct nv30_miptree_level *lvl = &mt->level[l];
      unsigned nbx = util_format_get_nblocksx(pt->format, w);
      unsigned nby = util_format_get_nblocksx(pt->format, h);

      lvl->offset = size;
      lvl->pitch  = mt->uniform_pitch;
      if (!lvl->pitch)
         lvl->pitch = nbx * blocksz;

      lvl->zslice_size = lvl->pitch * nby;
      size += lvl->zslice_size * d;

      w = u_minify(w, 1);
      h = u_minify(h, 1);
      d = u_minify(d, 1);
   }

   mt->layer_size = size;
   if (pt->target == PIPE_TEXTURE_CUBE) {
      if (!mt->uniform_pitch)
         mt->layer_size = align(mt->layer_size, 128);
      size = mt->layer_size * 6;
   }

   ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 256, size, NULL, &mt->base.bo);
   if (ret) {
      FREE(mt);
      return NULL;
   }

   mt->base.domain = NOUVEAU_BO_VRAM;
   return &mt->base.base;
}
Example #4
0
static boolean
stw_query_attrib(
   int iPixelFormat,
   int iLayerPlane,
   int attrib,
   int *pvalue )
{
   uint count;
   const struct stw_pixelformat_info *pfi;

   count = stw_pixelformat_get_extended_count();

   if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) {
      *pvalue = (int) count;
      return TRUE;
   }

   pfi = stw_pixelformat_get_info( iPixelFormat );
   if (!pfi) {
      return FALSE;
   }

   switch (attrib) {
   case WGL_DRAW_TO_WINDOW_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_WINDOW ? TRUE : FALSE;
      return TRUE;

   case WGL_DRAW_TO_BITMAP_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_DRAW_TO_BITMAP ? TRUE : FALSE;
      return TRUE;

   case WGL_NEED_PALETTE_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_NEED_PALETTE ? TRUE : FALSE;
      return TRUE;

   case WGL_NEED_SYSTEM_PALETTE_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE;
      return TRUE;

   case WGL_SWAP_METHOD_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_SWAP_COPY ? WGL_SWAP_COPY_ARB : WGL_SWAP_UNDEFINED_ARB;
      return TRUE;

   case WGL_SWAP_LAYER_BUFFERS_ARB:
      *pvalue = FALSE;
      return TRUE;

   case WGL_NUMBER_OVERLAYS_ARB:
      *pvalue = 0;
      return TRUE;

   case WGL_NUMBER_UNDERLAYS_ARB:
      *pvalue = 0;
      return TRUE;
   }

   if (iLayerPlane != 0)
      return FALSE;

   switch (attrib) {
   case WGL_ACCELERATION_ARB:
      *pvalue = WGL_FULL_ACCELERATION_ARB;
      break;

   case WGL_TRANSPARENT_ARB:
      *pvalue = FALSE;
      break;

   case WGL_TRANSPARENT_RED_VALUE_ARB:
   case WGL_TRANSPARENT_GREEN_VALUE_ARB:
   case WGL_TRANSPARENT_BLUE_VALUE_ARB:
   case WGL_TRANSPARENT_ALPHA_VALUE_ARB:
   case WGL_TRANSPARENT_INDEX_VALUE_ARB:
      break;

   case WGL_SHARE_DEPTH_ARB:
   case WGL_SHARE_STENCIL_ARB:
   case WGL_SHARE_ACCUM_ARB:
      *pvalue = TRUE;
      break;

   case WGL_SUPPORT_GDI_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_GDI ? TRUE : FALSE;
      break;

   case WGL_SUPPORT_OPENGL_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_SUPPORT_OPENGL ? TRUE : FALSE;
      break;

   case WGL_DOUBLE_BUFFER_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_DOUBLEBUFFER ? TRUE : FALSE;
      break;

   case WGL_STEREO_ARB:
      *pvalue = pfi->pfd.dwFlags & PFD_STEREO ? TRUE : FALSE;
      break;

   case WGL_PIXEL_TYPE_ARB:
      switch (pfi->pfd.iPixelType) {
      case PFD_TYPE_RGBA:
         if (util_format_is_float(pfi->stvis.color_format)) {
            *pvalue = WGL_TYPE_RGBA_FLOAT_ARB;
         }
         else {
            *pvalue = WGL_TYPE_RGBA_ARB;
         }
         break;
      case PFD_TYPE_COLORINDEX:
         *pvalue = WGL_TYPE_COLORINDEX_ARB;
         break;
      default:
         return FALSE;
      }
      break;

   case WGL_COLOR_BITS_ARB:
      *pvalue = pfi->pfd.cColorBits;
      break;

   case WGL_RED_BITS_ARB:
      *pvalue = pfi->pfd.cRedBits;
      break;

   case WGL_RED_SHIFT_ARB:
      *pvalue = pfi->pfd.cRedShift;
      break;

   case WGL_GREEN_BITS_ARB:
      *pvalue = pfi->pfd.cGreenBits;
      break;

   case WGL_GREEN_SHIFT_ARB:
      *pvalue = pfi->pfd.cGreenShift;
      break;

   case WGL_BLUE_BITS_ARB:
      *pvalue = pfi->pfd.cBlueBits;
      break;

   case WGL_BLUE_SHIFT_ARB:
      *pvalue = pfi->pfd.cBlueShift;
      break;

   case WGL_ALPHA_BITS_ARB:
      *pvalue = pfi->pfd.cAlphaBits;
      break;

   case WGL_ALPHA_SHIFT_ARB:
      *pvalue = pfi->pfd.cAlphaShift;
      break;

   case WGL_ACCUM_BITS_ARB:
      *pvalue = pfi->pfd.cAccumBits;
      break;

   case WGL_ACCUM_RED_BITS_ARB:
      *pvalue = pfi->pfd.cAccumRedBits;
      break;

   case WGL_ACCUM_GREEN_BITS_ARB:
      *pvalue = pfi->pfd.cAccumGreenBits;
      break;

   case WGL_ACCUM_BLUE_BITS_ARB:
      *pvalue = pfi->pfd.cAccumBlueBits;
      break;

   case WGL_ACCUM_ALPHA_BITS_ARB:
      *pvalue = pfi->pfd.cAccumAlphaBits;
      break;

   case WGL_DEPTH_BITS_ARB:
      *pvalue = pfi->pfd.cDepthBits;
      break;

   case WGL_STENCIL_BITS_ARB:
      *pvalue = pfi->pfd.cStencilBits;
      break;

   case WGL_AUX_BUFFERS_ARB:
      *pvalue = pfi->pfd.cAuxBuffers;
      break;

   case WGL_SAMPLE_BUFFERS_ARB:
      *pvalue = 1;
      break;

   case WGL_SAMPLES_ARB:
      *pvalue = pfi->stvis.samples;
      break;


   /* WGL_ARB_pbuffer */

   case WGL_MAX_PBUFFER_WIDTH_ARB:
   case WGL_MAX_PBUFFER_HEIGHT_ARB:
      *pvalue = stw_dev->max_2d_length;
      break;

   case WGL_MAX_PBUFFER_PIXELS_ARB:
      *pvalue = stw_dev->max_2d_length * stw_dev->max_2d_length;
      break;

   case WGL_DRAW_TO_PBUFFER_ARB:
      *pvalue = 1;
      break;


   default:
      return FALSE;
   }

   return TRUE;
}