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 #include "util/u_memory.h"
00033 #include "pipe/p_inlines.h"
00034
00035 #include "draw/draw_context.h"
00036
00037 #include "sp_context.h"
00038 #include "sp_context.h"
00039 #include "sp_state.h"
00040 #include "sp_texture.h"
00041 #include "sp_tile_cache.h"
00042 #include "draw/draw_context.h"
00043
00044
00045
00046 void *
00047 softpipe_create_sampler_state(struct pipe_context *pipe,
00048 const struct pipe_sampler_state *sampler)
00049 {
00050 return mem_dup(sampler, sizeof(*sampler));
00051 }
00052
00053
00054 void
00055 softpipe_bind_sampler_states(struct pipe_context *pipe,
00056 unsigned num, void **sampler)
00057 {
00058 struct softpipe_context *softpipe = softpipe_context(pipe);
00059 unsigned i;
00060
00061 assert(num <= PIPE_MAX_SAMPLERS);
00062
00063
00064 if (num == softpipe->num_samplers &&
00065 !memcmp(softpipe->sampler, sampler, num * sizeof(void *)))
00066 return;
00067
00068 draw_flush(softpipe->draw);
00069
00070 for (i = 0; i < num; ++i)
00071 softpipe->sampler[i] = sampler[i];
00072 for (i = num; i < PIPE_MAX_SAMPLERS; ++i)
00073 softpipe->sampler[i] = NULL;
00074
00075 softpipe->num_samplers = num;
00076
00077 softpipe->dirty |= SP_NEW_SAMPLER;
00078 }
00079
00080
00081 void
00082 softpipe_set_sampler_textures(struct pipe_context *pipe,
00083 unsigned num, struct pipe_texture **texture)
00084 {
00085 struct softpipe_context *softpipe = softpipe_context(pipe);
00086 uint i;
00087
00088 assert(num <= PIPE_MAX_SAMPLERS);
00089
00090
00091 if (num == softpipe->num_textures &&
00092 !memcmp(softpipe->texture, texture, num * sizeof(struct pipe_texture *)))
00093 return;
00094
00095 draw_flush(softpipe->draw);
00096
00097 for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
00098 struct pipe_texture *tex = i < num ? texture[i] : NULL;
00099
00100 pipe_texture_reference(&softpipe->texture[i], tex);
00101 sp_tile_cache_set_texture(pipe, softpipe->tex_cache[i], tex);
00102 }
00103
00104 softpipe->num_textures = num;
00105
00106 softpipe->dirty |= SP_NEW_TEXTURE;
00107 }
00108
00109
00110 void
00111 softpipe_delete_sampler_state(struct pipe_context *pipe,
00112 void *sampler)
00113 {
00114 FREE( sampler );
00115 }
00116
00117
00118