00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "st_context.h"
00036 #include "st_atom.h"
00037 #include "st_texture.h"
00038 #include "st_cb_texture.h"
00039 #include "pipe/p_context.h"
00040 #include "pipe/p_inlines.h"
00041 #include "cso_cache/cso_context.h"
00042
00043
00044 static void
00045 update_textures(struct st_context *st)
00046 {
00047 struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
00048 GLuint su;
00049
00050 st->state.num_textures = 0;
00051
00052
00053
00054 for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; su++) {
00055 struct pipe_texture *pt = NULL;
00056
00057 if (fprog->Base.SamplersUsed & (1 << su)) {
00058 const GLuint texUnit = fprog->Base.SamplerUnits[su];
00059 struct gl_texture_object *texObj
00060 = st->ctx->Texture.Unit[texUnit]._Current;
00061 struct st_texture_object *stObj;
00062 GLboolean flush, retval;
00063
00064 if (!texObj) {
00065 texObj = st_get_default_texture(st);
00066 }
00067 stObj = st_texture_object(texObj);
00068
00069 retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
00070 if (!retval) {
00071
00072 continue;
00073 }
00074
00075 st->state.num_textures = su + 1;
00076
00077 pt = st_get_stobj_texture(stObj);
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 pipe_texture_reference(&st->state.sampler_texture[su], pt);
00090 }
00091
00092 cso_set_sampler_textures(st->cso_context,
00093 st->state.num_textures,
00094 st->state.sampler_texture);
00095 }
00096
00097
00098 const struct st_tracked_state st_update_texture = {
00099 "st_update_texture",
00100 {
00101 _NEW_TEXTURE,
00102 ST_NEW_FRAGMENT_PROGRAM,
00103 },
00104 update_textures
00105 };
00106
00107
00108
00109
00110 static void
00111 finalize_textures(struct st_context *st)
00112 {
00113 struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
00114 const GLboolean prev_missing_textures = st->missing_textures;
00115 GLuint su;
00116
00117 st->missing_textures = GL_FALSE;
00118
00119 for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; su++) {
00120 if (fprog->Base.SamplersUsed & (1 << su)) {
00121 const GLuint texUnit = fprog->Base.SamplerUnits[su];
00122 struct gl_texture_object *texObj
00123 = st->ctx->Texture.Unit[texUnit]._Current;
00124 struct st_texture_object *stObj = st_texture_object(texObj);
00125
00126 if (texObj) {
00127 GLboolean flush, retval;
00128
00129 retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
00130 if (!retval) {
00131
00132 st->missing_textures = GL_TRUE;
00133 continue;
00134 }
00135
00136 stObj->teximage_realloc = TRUE;
00137 }
00138 }
00139 }
00140
00141 if (prev_missing_textures != st->missing_textures)
00142 st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
00143 }
00144
00145
00146
00147 const struct st_tracked_state st_finalize_textures = {
00148 "st_finalize_textures",
00149 {
00150 _NEW_TEXTURE,
00151 0,
00152 },
00153 finalize_textures
00154 };