summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/python/p_device.i
blob: a83bcc71a1ac569a14b82d5e74a4fb80750ad0e7 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 /**************************************************************************
 * 
 * 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.
    * \param type  one of PIPE_TEXTURE, PIPE_SURFACE
    */
   int is_format_supported( enum pipe_format format, 
                            enum pipe_texture_target target,
                            unsigned tex_usage, 
                            unsigned geom_flags ) {
      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);
   }

   struct pipe_texture * 
   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
      ) {
      struct pipe_texture templat;
      memset(&templat, 0, sizeof(templat));
      templat.format = format;
      pf_get_block(templat.format, &templat.block);
      templat.width0 = width;
      templat.height0 = height;
      templat.depth0 = depth;
      templat.last_level = last_level;
      templat.target = target;
      templat.tex_usage = tex_usage;
      return $self->screen->texture_create($self->screen, &templat);
   }
   
   struct pipe_buffer *
   buffer_create(unsigned size, unsigned alignment = 0, unsigned usage = 0) {
      return pipe_buffer_create($self->screen, alignment, usage, size);
   }

};