translate.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2008 Tungsten Graphics, inc.
00003  * All Rights Reserved.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * on the rights to use, copy, modify, merge, publish, distribute, sub
00009  * license, and/or sell copies of the Software, and to permit persons to whom
00010  * the Software is furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice (including the next
00013  * paragraph) shall be included in all copies or substantial portions of the
00014  * Software.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
00019  * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
00020  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
00021  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
00022  * USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 
00039 #ifndef _TRANSLATE_H
00040 #define _TRANSLATE_H
00041 
00042 
00043 #include "pipe/p_compiler.h"
00044 #include "pipe/p_format.h"
00045 #include "pipe/p_state.h"
00046 
00047 struct translate_element 
00048 {
00049    enum pipe_format input_format;
00050    enum pipe_format output_format;
00051    unsigned input_buffer:8;
00052    unsigned input_offset:24;
00053    unsigned output_offset;
00054 };
00055 
00056 
00057 struct translate_key {
00058    unsigned output_stride;
00059    unsigned nr_elements;
00060    struct translate_element element[PIPE_MAX_ATTRIBS + 1];
00061 };
00062 
00063 
00064 struct translate {
00065    struct translate_key key;
00066 
00067    void (*release)( struct translate * );
00068 
00069    void (*set_buffer)( struct translate *,
00070                        unsigned i,
00071                        const void *ptr,
00072                        unsigned stride );
00073 
00074    void (PIPE_CDECL *run_elts)( struct translate *,
00075                                 const unsigned *elts,
00076                                 unsigned count,
00077                                 void *output_buffer);
00078 
00079    void (PIPE_CDECL *run)( struct translate *,
00080                            unsigned start,
00081                            unsigned count,
00082                            void *output_buffer);
00083 };
00084 
00085 
00086 
00087 #if 0
00088 struct translate_context *translate_context_create( void );
00089 void translate_context_destroy( struct translate_context * );
00090 
00091 struct translate *translate_lookup_or_create( struct translate_context *tctx,
00092                                               const struct translate_key *key );
00093 #endif
00094 
00095 
00096 struct translate *translate_create( const struct translate_key *key );
00097 
00098 static INLINE int translate_keysize( const struct translate_key *key )
00099 {
00100    return 2 * sizeof(int) + key->nr_elements * sizeof(struct translate_element);
00101 }
00102 
00103 static INLINE int translate_key_compare( const struct translate_key *a,
00104                                          const struct translate_key *b )
00105 {
00106    int keysize = translate_keysize(a);
00107    return memcmp(a, b, keysize);
00108 }
00109 
00110 
00111 static INLINE void translate_key_sanitize( struct translate_key *a )
00112 {
00113    int keysize = translate_keysize(a);
00114    char *ptr = (char *)a;
00115    memset(ptr + keysize, 0, sizeof(*a) - keysize);
00116 }
00117 
00118 
00119 /*******************************************************************************
00120  *  Private:
00121  */
00122 struct translate *translate_sse2_create( const struct translate_key *key );
00123 
00124 struct translate *translate_generic_create( const struct translate_key *key );
00125 
00126 
00127 #endif

Generated on Tue Sep 29 06:25:15 2009 for Gallium3D by  doxygen 1.5.4