Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygent_pipeline.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 6.5.3 00004 * 00005 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Authors: 00025 * Keith Whitwell <keith@tungstengraphics.com> 00026 */ 00027 00028 #include "main/glheader.h" 00029 #include "main/context.h" 00030 #include "main/imports.h" 00031 #include "main/state.h" 00032 #include "main/mtypes.h" 00033 00034 #include "t_context.h" 00035 #include "t_pipeline.h" 00036 #include "t_vp_build.h" 00037 #include "t_vertex.h" 00038 00039 void _tnl_install_pipeline( GLcontext *ctx, 00040 const struct tnl_pipeline_stage **stages ) 00041 { 00042 TNLcontext *tnl = TNL_CONTEXT(ctx); 00043 GLuint i; 00044 00045 tnl->pipeline.new_state = ~0; 00046 00047 /* Create a writeable copy of each stage. 00048 */ 00049 for (i = 0 ; i < MAX_PIPELINE_STAGES && stages[i] ; i++) { 00050 struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; 00051 MEMCPY(s, stages[i], sizeof(*s)); 00052 if (s->create) 00053 s->create(ctx, s); 00054 } 00055 00056 tnl->pipeline.nr_stages = i; 00057 } 00058 00059 void _tnl_destroy_pipeline( GLcontext *ctx ) 00060 { 00061 TNLcontext *tnl = TNL_CONTEXT(ctx); 00062 GLuint i; 00063 00064 for (i = 0 ; i < tnl->pipeline.nr_stages ; i++) { 00065 struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; 00066 if (s->destroy) 00067 s->destroy(s); 00068 } 00069 00070 tnl->pipeline.nr_stages = 0; 00071 } 00072 00073 00074 00075 static GLuint check_input_changes( GLcontext *ctx ) 00076 { 00077 TNLcontext *tnl = TNL_CONTEXT(ctx); 00078 GLuint i; 00079 00080 for (i = 0; i <= _TNL_LAST_MAT; i++) { 00081 if (tnl->vb.AttribPtr[i]->size != tnl->pipeline.last_attrib_size[i] || 00082 tnl->vb.AttribPtr[i]->stride != tnl->pipeline.last_attrib_stride[i]) { 00083 tnl->pipeline.last_attrib_size[i] = tnl->vb.AttribPtr[i]->size; 00084 tnl->pipeline.last_attrib_stride[i] = tnl->vb.AttribPtr[i]->stride; 00085 tnl->pipeline.input_changes |= 1<<i; 00086 } 00087 } 00088 00089 if (tnl->pipeline.input_changes && 00090 tnl->Driver.NotifyInputChanges) 00091 tnl->Driver.NotifyInputChanges( ctx, tnl->pipeline.input_changes ); 00092 00093 return tnl->pipeline.input_changes; 00094 } 00095 00096 00097 static GLuint check_output_changes( GLcontext *ctx ) 00098 { 00099 #if 0 00100 TNLcontext *tnl = TNL_CONTEXT(ctx); 00101 00102 for (i = 0; i < VERT_RESULT_MAX; i++) { 00103 if (tnl->vb.ResultPtr[i]->size != tnl->last_result_size[i] || 00104 tnl->vb.ResultPtr[i]->stride != tnl->last_result_stride[i]) { 00105 tnl->last_result_size[i] = tnl->vb.ResultPtr[i]->size; 00106 tnl->last_result_stride[i] = tnl->vb.ResultPtr[i]->stride; 00107 tnl->pipeline.output_changes |= 1<<i; 00108 } 00109 } 00110 00111 if (tnl->pipeline.output_changes) 00112 tnl->Driver.NotifyOutputChanges( ctx, tnl->pipeline.output_changes ); 00113 00114 return tnl->pipeline.output_changes; 00115 #else 00116 return ~0; 00117 #endif 00118 } 00119 00120 00121 void _tnl_run_pipeline( GLcontext *ctx ) 00122 { 00123 TNLcontext *tnl = TNL_CONTEXT(ctx); 00124 unsigned short __tmp; 00125 GLuint i; 00126 00127 if (!tnl->vb.Count) 00128 return; 00129 00130 /* Check for changed input sizes or change in stride to/from zero 00131 * (ie const or non-const). 00132 */ 00133 if (check_input_changes( ctx ) || tnl->pipeline.new_state) { 00134 if (ctx->VertexProgram._MaintainTnlProgram) 00135 _tnl_UpdateFixedFunctionProgram( ctx ); 00136 00137 for (i = 0; i < tnl->pipeline.nr_stages ; i++) { 00138 struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; 00139 if (s->validate) 00140 s->validate( ctx, s ); 00141 } 00142 00143 tnl->pipeline.new_state = 0; 00144 tnl->pipeline.input_changes = 0; 00145 00146 /* Pipeline can only change its output in response to either a 00147 * statechange or an input size/stride change. No other changes 00148 * are allowed. 00149 */ 00150 if (check_output_changes( ctx )) 00151 _tnl_notify_pipeline_output_change( ctx ); 00152 } 00153 00154 START_FAST_MATH(__tmp); 00155 00156 for (i = 0; i < tnl->pipeline.nr_stages ; i++) { 00157 struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i]; 00158 if (!s->run( ctx, s )) 00159 break; 00160 } 00161 00162 END_FAST_MATH(__tmp); 00163 } 00164 00165 00166 00167 /* The default pipeline. This is useful for software rasterizers, and 00168 * simple hardware rasterizers. For customization, I don't recommend 00169 * tampering with the internals of these stages in the way that 00170 * drivers did in Mesa 3.4. These stages are basically black boxes, 00171 * and should be left intact. 00172 * 00173 * To customize the pipeline, consider: 00174 * 00175 * - removing redundant stages (making sure that the software rasterizer 00176 * can cope with this on fallback paths). An example is fog 00177 * coordinate generation, which is not required in the FX driver. 00178 * 00179 * - replacing general-purpose machine-independent stages with 00180 * general-purpose machine-specific stages. There is no example of 00181 * this to date, though it must be borne in mind that all subsequent 00182 * stages that reference the output of the new stage must cope with 00183 * any machine-specific data introduced. This may not be easy 00184 * unless there are no such stages (ie the new stage is the last in 00185 * the pipe). 00186 * 00187 * - inserting optimized (but specialized) stages ahead of the 00188 * general-purpose fallback implementation. For example, the old 00189 * fastpath mechanism, which only works when the VB->Elts input is 00190 * available, can be duplicated by placing the fastpath stage at the 00191 * head of this pipeline. Such specialized stages are currently 00192 * constrained to have no outputs (ie. they must either finish the * 00193 * pipeline by returning GL_FALSE from run(), or do nothing). 00194 * 00195 * Some work can be done to lift some of the restrictions in the final 00196 * case, if it becomes necessary to do so. 00197 */ 00198 const struct tnl_pipeline_stage *_tnl_default_pipeline[] = { 00199 &_tnl_vertex_transform_stage, 00200 &_tnl_normal_transform_stage, 00201 &_tnl_lighting_stage, 00202 &_tnl_texgen_stage, 00203 &_tnl_texture_transform_stage, 00204 &_tnl_point_attenuation_stage, 00205 &_tnl_vertex_program_stage, 00206 &_tnl_fog_coordinate_stage, 00207 &_tnl_render_stage, 00208 NULL 00209 }; 00210 00211 const struct tnl_pipeline_stage *_tnl_vp_pipeline[] = { 00212 &_tnl_vertex_program_stage, 00213 &_tnl_render_stage, 00214 NULL 00215 }; Generated on Sun May 27 2012 04:20:45 for ReactOS by
1.7.6.1
|