p_device.i 4.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
 /**************************************************************************
 * 
 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
 * All Rights Reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 **************************************************************************/

/**
 * @file
 * SWIG interface definion for Gallium types.
 *
 * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
 */


%nodefaultctor st_device;
%nodefaultdtor st_device;


struct st_device {
};

%newobject st_device::texture_create;
%newobject st_device::context_create;
%newobject st_device::buffer_create;

%extend st_device {
   
   st_device(int hardware = 1) {
      return st_device_create(hardware ? TRUE : FALSE);
   }

   ~st_device() {
      st_device_destroy($self);
   }
   
   const char * get_name( void ) {
      return $self->screen->get_name($self->screen);
   }

   const char * get_vendor( void ) {
      return $self->screen->get_vendor($self->screen);
   }

   /**
    * Query an integer-valued capability/parameter/limit
    * \param param  one of PIPE_CAP_x
    */
   int get_param( int param ) {
      return $self->screen->get_param($self->screen, param);
   }

   /**
    * Query a float-valued capability/parameter/limit
    * \param param  one of PIPE_CAP_x
    */
   float get_paramf( int param ) {
      return $self->screen->get_paramf($self->screen, param);
   }

   /**
    * Check if the given pipe_format is supported as a texture or
    * drawing surface.
84
    * \param tex_usage bitmask of PIPE_BIND flags
85 86 87 88 89
    */
   int is_format_supported( enum pipe_format format, 
                            enum pipe_texture_target target,
                            unsigned tex_usage, 
                            unsigned geom_flags ) {
90 91
      /* We can't really display surfaces with the python statetracker so mask
       * out that usage */
92
      tex_usage &= ~PIPE_BIND_DISPLAY_TARGET;
93

94 95 96 97 98 99 100 101 102 103 104 105
      return $self->screen->is_format_supported( $self->screen, 
                                                 format, 
                                                 target, 
                                                 tex_usage, 
                                                 geom_flags );
   }

   struct st_context *
   context_create(void) {
      return st_context_create($self);
   }

106
   struct pipe_resource * 
107 108 109 110 111 112 113 114 115
   texture_create(
         enum pipe_format format,
         unsigned width,
         unsigned height,
         unsigned depth = 1,
         unsigned last_level = 0,
         enum pipe_texture_target target = PIPE_TEXTURE_2D,
         unsigned tex_usage = 0
      ) {
116
      struct pipe_resource templat;
117 118 119

      /* We can't really display surfaces with the python statetracker so mask
       * out that usage */
120
      tex_usage &= ~PIPE_BIND_DISPLAY_TARGET;
121

122 123
      memset(&templat, 0, sizeof(templat));
      templat.format = format;
124 125 126
      templat.width0 = width;
      templat.height0 = height;
      templat.depth0 = depth;
127 128
      templat.last_level = last_level;
      templat.target = target;
129
      templat.bind = tex_usage;
130

131
      return $self->screen->resource_create($self->screen, &templat);
132
   }
133 134 135 136

   struct pipe_resource *
   buffer_create(unsigned size, unsigned bind = 0) {
      return pipe_buffer_create($self->screen, bind, size);
137 138 139
   }

};