gallivm.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  *
00026  **************************************************************************/
00027 
00028  /*
00029   * Authors:
00030   *   Zack Rusin zack@tungstengraphics.com
00031   */
00032 
00033 #ifndef GALLIVM_H
00034 #define GALLIVM_H
00035 
00036 /*
00037   LLVM representation consists of two stages - layout independent
00038   intermediate representation gallivm_ir and driver specific
00039   gallivm_prog. TGSI is first being translated into gallivm_ir
00040   after that driver can set number of options on gallivm_ir and
00041   have it compiled into gallivm_prog. gallivm_prog can be either
00042   executed (assuming there's LLVM JIT backend for the current
00043   target) or machine code generation can be done (assuming there's
00044   a LLVM code generator for thecurrent target)
00045  */
00046 #if defined __cplusplus
00047 extern "C" {
00048 #endif
00049 
00050 #include "pipe/p_state.h"
00051 
00052 #ifdef MESA_LLVM
00053 
00054 struct tgsi_token;
00055 
00056 struct gallivm_ir;
00057 struct gallivm_prog;
00058 struct gallivm_cpu_engine;
00059 struct tgsi_interp_coef;
00060 struct tgsi_sampler;
00061 struct tgsi_exec_vector;
00062 
00063 enum gallivm_shader_type {
00064    GALLIVM_VS,
00065    GALLIVM_FS
00066 };
00067 
00068 enum gallivm_vector_layout {
00069    GALLIVM_AOS,
00070    GALLIVM_SOA
00071 };
00072 
00073 struct gallivm_ir *gallivm_ir_new(enum gallivm_shader_type type);
00074 void               gallivm_ir_set_layout(struct gallivm_ir *ir,
00075                                          enum gallivm_vector_layout layout);
00076 void               gallivm_ir_set_components(struct gallivm_ir *ir, int num);
00077 void               gallivm_ir_fill_from_tgsi(struct gallivm_ir *ir,
00078                                              const struct tgsi_token *tokens);
00079 void               gallivm_ir_delete(struct gallivm_ir *ir);
00080 
00081 
00082 struct gallivm_prog *gallivm_ir_compile(struct gallivm_ir *ir);
00083 
00084 void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
00085                                      float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
00086                                      const struct tgsi_interp_coef *coefs);
00087 void gallivm_prog_dump(struct gallivm_prog *prog, const char *file_prefix);
00088 
00089 
00090 struct gallivm_cpu_engine *gallivm_cpu_engine_create(struct gallivm_prog *prog);
00091 struct gallivm_cpu_engine *gallivm_global_cpu_engine();
00092 int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
00093                         struct tgsi_exec_machine *machine,
00094                         const float (*input)[4],
00095                         unsigned num_inputs,
00096                         float (*output)[4],
00097                         unsigned num_outputs,
00098                         const float (*constants)[4],
00099                         unsigned count,
00100                         unsigned input_stride,
00101                         unsigned output_stride);
00102 int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
00103                         float x, float y,
00104                         float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
00105                         float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
00106                         float (*consts)[4],
00107                         struct tgsi_sampler *samplers);
00108 void gallivm_cpu_jit_compile(struct gallivm_cpu_engine *ee, struct gallivm_prog *prog);
00109 void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *ee);
00110 
00111 
00112 #endif /* MESA_LLVM */
00113 
00114 #if defined __cplusplus
00115 }
00116 #endif
00117 
00118 #endif

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