r300g: fix min/max lod computation
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index d6f3229bed78b1c5d5f346e42a44b4c780238071..ded242d3dc54219b145faabdc920a6b73d4e6c21 100644 (file)
 #include "sp_context.h"
 #include "sp_state.h"
 #include "sp_fs.h"
-#include "sp_buffer.h"
+#include "sp_texture.h"
 
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vs.h"
+#include "draw/draw_gs.h"
 #include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_exec.h"
 #include "tgsi/tgsi_scan.h"
 #include "tgsi/tgsi_parse.h"
 
@@ -95,10 +97,18 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 void
 softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
 {
+   struct softpipe_context *softpipe = softpipe_context(pipe);
    struct sp_fragment_shader *state = fs;
 
    assert(fs != softpipe_context(pipe)->fs);
-   
+
+   if (softpipe->fs_machine->Tokens == state->shader.tokens) {
+      /* unbind the shader from the tgsi executor if we're
+       * deleting it.
+       */
+      tgsi_exec_machine_bind_shader(softpipe->fs_machine, NULL, 0, NULL);
+   }
+
    state->delete( state );
 }
 
@@ -167,25 +177,26 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
 void
 softpipe_set_constant_buffer(struct pipe_context *pipe,
                              uint shader, uint index,
-                             struct pipe_buffer *constants)
+                             struct pipe_resource *constants)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
-   unsigned size = constants ? constants->size : 0;
-   const void *data = constants ? softpipe_buffer(constants)->data : NULL;
+   unsigned size = constants ? constants->width0 : 0;
+   const void *data = constants ? softpipe_resource(constants)->data : NULL;
 
    assert(shader < PIPE_SHADER_TYPES);
-   assert(index == 0);
 
    draw_flush(softpipe->draw);
 
    /* note: reference counting */
-   pipe_buffer_reference(&softpipe->constants[shader][index], constants);
+   pipe_resource_reference(&softpipe->constants[shader][index], constants);
 
    if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
       draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size);
    }
 
    softpipe->mapped_constants[shader][index] = data;
+   softpipe->const_buffer_size[shader][index] = size;
+
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }
 
@@ -215,6 +226,8 @@ softpipe_create_gs_state(struct pipe_context *pipe,
    if (state->draw_data == NULL)
       goto fail;
 
+   state->max_sampler = state->draw_data->info.file_max[TGSI_FILE_SAMPLER];
+
    return state;
 
 fail: