sp_state_sampler.c

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 /* Authors:
00029  *  Brian Paul
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    /* Check for no-op */
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    /* Check for no-op */
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 

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