1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * SWIG interface definion for Gallium types.
32 * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
38 %ignore pipe_vertex_buffer::buffer;
40 %include "pipe/p_compiler.h";
41 %include "pipe/p_state.h";
44 %array_class(struct pipe_stencil_state, StencilArray);
47 %extend pipe_rt_blend_state
49 struct pipe_rt_blend_state *
50 __getitem__(int index)
52 if(index < 0 || index >= PIPE_MAX_COLOR_BUFS)
53 SWIG_exception(SWIG_ValueError, "index out of bounds");
61 %extend pipe_framebuffer_state {
63 pipe_framebuffer_state(void) {
64 return CALLOC_STRUCT(pipe_framebuffer_state);
67 ~pipe_framebuffer_state() {
69 for(index = 0; index < PIPE_MAX_COLOR_BUFS; ++index)
70 pipe_surface_reference(&$self->cbufs[index], NULL);
71 pipe_surface_reference(&$self->zsbuf, NULL);
76 set_cbuf(unsigned index, struct st_surface *surface)
78 struct pipe_surface *_surface = NULL;
80 if(index >= PIPE_MAX_COLOR_BUFS)
81 SWIG_exception(SWIG_ValueError, "index out of bounds");
84 _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE);
86 SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing");
89 pipe_surface_reference(&$self->cbufs[index], _surface);
96 set_zsbuf(struct st_surface *surface)
98 struct pipe_surface *_surface = NULL;
101 _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE);
103 SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing");
106 pipe_surface_reference(&$self->zsbuf, _surface);
115 %extend pipe_shader_state {
117 pipe_shader_state(const char *text, unsigned num_tokens = 1024) {
118 struct tgsi_token *tokens;
119 struct pipe_shader_state *shader;
121 tokens = MALLOC(num_tokens * sizeof(struct tgsi_token));
125 if(tgsi_text_translate(text, tokens, num_tokens ) != TRUE)
128 shader = CALLOC_STRUCT(pipe_shader_state);
132 shader->tokens = tokens;
143 ~pipe_shader_state() {
144 FREE((void*)$self->tokens);
148 void dump(unsigned flags = 0) {
149 tgsi_dump($self->tokens, flags);