summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-04-23 12:39:38 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-04-23 12:39:38 +1000
commit104ff59585ad1888c8cef5ad9de0e2fdb3f48c21 (patch)
tree9128984eef4a90cc6177d336759ce795b835d71f /src/mesa/state_tracker
parentb20acef90695d6e5975f538b6e9cb812b05f0cf6 (diff)
parent6fc530ccda2971a5d99a955ad90ae9762238040f (diff)
Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c209
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c4
-rw-r--r--src/mesa/state_tracker/st_cache.c181
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c96
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c5
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c14
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c37
-rw-r--r--src/mesa/state_tracker/st_cb_feedback.c9
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c2
-rw-r--r--src/mesa/state_tracker/st_cb_program.c4
-rw-r--r--src/mesa/state_tracker/st_cb_rasterpos.c2
-rw-r--r--src/mesa/state_tracker/st_context.c10
-rw-r--r--src/mesa/state_tracker/st_context.h5
-rw-r--r--src/mesa/state_tracker/st_draw.c6
-rw-r--r--src/mesa/state_tracker/st_extensions.c1
-rw-r--r--src/mesa/state_tracker/st_format.c9
-rw-r--r--src/mesa/state_tracker/st_format.h4
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c6
-rw-r--r--src/mesa/state_tracker/st_program.c5
-rw-r--r--src/mesa/state_tracker/st_program.h10
21 files changed, 322 insertions, 299 deletions
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 6410e7cb24..76356bbad7 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -42,14 +42,22 @@
#include "shader/prog_print.h"
#include "st_context.h"
+#include "st_format.h"
#include "st_program.h"
+#include "st_texture.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
+#include "util/u_pack_color.h"
struct state_key
{
GLuint scaleAndBias:1;
GLuint colorMatrix:1;
+ GLuint colorMatrixPostScaleBias:1;
+ GLuint pixelMaps:1;
#if 0
GLfloat Maps[3][256][4];
@@ -80,6 +88,9 @@ is_identity(const GLfloat m[16])
static void
make_state_key(GLcontext *ctx, struct state_key *key)
{
+ static const GLfloat zero[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ static const GLfloat one[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
+
memset(key, 0, sizeof(*key));
if (ctx->Pixel.RedBias != 0.0 || ctx->Pixel.RedScale != 1.0 ||
@@ -92,9 +103,76 @@ make_state_key(GLcontext *ctx, struct state_key *key)
if (!is_identity(ctx->ColorMatrixStack.Top->m)) {
key->colorMatrix = 1;
}
+
+ if (!TEST_EQ_4V(ctx->Pixel.PostColorMatrixScale, one) ||
+ !TEST_EQ_4V(ctx->Pixel.PostColorMatrixBias, zero)) {
+ key->colorMatrixPostScaleBias = 1;
+ }
+
+ key->pixelMaps = ctx->Pixel.MapColorFlag;
+}
+
+
+static struct pipe_texture *
+create_color_map_texture(GLcontext *ctx)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_texture *pt;
+ enum pipe_format format;
+ const uint texSize = 256; /* simple, and usually perfect */
+
+ /* find an RGBA texture format */
+ format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+
+ /* create texture for color map/table */
+ pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
+ texSize, texSize, 1, 0);
+ return pt;
}
+/**
+ * Update the pixelmap texture with the contents of the R/G/B/A pixel maps.
+ */
+static void
+load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
+{
+ struct pipe_context *pipe = ctx->st->pipe;
+ struct pipe_screen *screen = pipe->screen;
+ struct pipe_surface *surface;
+ const GLuint rSize = ctx->PixelMaps.RtoR.Size;
+ const GLuint gSize = ctx->PixelMaps.GtoG.Size;
+ const GLuint bSize = ctx->PixelMaps.BtoB.Size;
+ const GLuint aSize = ctx->PixelMaps.AtoA.Size;
+ const uint texSize = pt->width[0];
+ uint *dest;
+ uint i, j;
+
+ surface = screen->get_tex_surface(screen, pt, 0, 0, 0);
+ dest = (uint *) pipe_surface_map(surface);
+
+ /* Pack four 1D maps into a 2D texture:
+ * R map is placed horizontally, indexed by S, in channel 0
+ * G map is placed vertically, indexed by T, in channel 1
+ * B map is placed horizontally, indexed by S, in channel 2
+ * A map is placed vertically, indexed by T, in channel 3
+ */
+ for (i = 0; i < texSize; i++) {
+ for (j = 0; j < texSize; j++) {
+ int k = (i * texSize + j);
+ ubyte r = ctx->PixelMaps.RtoR.Map8[j * rSize / texSize];
+ ubyte g = ctx->PixelMaps.GtoG.Map8[i * gSize / texSize];
+ ubyte b = ctx->PixelMaps.BtoB.Map8[j * bSize / texSize];
+ ubyte a = ctx->PixelMaps.AtoA.Map8[i * aSize / texSize];
+ util_pack_color_ub(r, g, b, a, pt->format, dest + k);
+ }
+ }
+
+ pipe_surface_unmap(surface);
+ pipe_surface_reference(&surface, NULL);
+ pipe->texture_update(pipe, pt, 0, 0x1);
+}
+
#define MAX_INST 100
@@ -105,6 +183,7 @@ make_state_key(GLcontext *ctx, struct state_key *key)
static struct gl_fragment_program *
get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
{
+ struct st_context *st = ctx->st;
struct prog_instruction inst[MAX_INST];
struct gl_program_parameter_list *params;
struct gl_fragment_program *fp;
@@ -118,7 +197,10 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
params = _mesa_new_parameter_list();
- /* TEX colorTemp, fragment.texcoord[0], texture[0], 2D; */
+ /*
+ * Get initial pixel color from the texture.
+ * TEX colorTemp, fragment.texcoord[0], texture[0], 2D;
+ */
_mesa_init_instructions(inst + ic, 1);
inst[ic].Opcode = OPCODE_TEX;
inst[ic].DstReg.File = PROGRAM_TEMPORARY;
@@ -132,7 +214,6 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
fp->Base.OutputsWritten = (1 << FRAG_RESULT_COLR);
fp->Base.SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
- /* MAD colorTemp, colorTemp, scale, bias; */
if (key->scaleAndBias) {
static const gl_state_index scale_state[STATE_LENGTH] =
{ STATE_INTERNAL, STATE_PT_SCALE, 0, 0, 0 };
@@ -153,6 +234,7 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
scale_p = _mesa_add_state_reference(params, scale_state);
bias_p = _mesa_add_state_reference(params, bias_state);
+ /* MAD colorTemp, colorTemp, scale, bias; */
_mesa_init_instructions(inst + ic, 1);
inst[ic].Opcode = OPCODE_MAD;
inst[ic].DstReg.File = PROGRAM_TEMPORARY;
@@ -166,6 +248,56 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
ic++;
}
+ if (key->pixelMaps) {
+ const GLuint temp = 1;
+
+ /* create the colormap/texture now if not already done */
+ if (!st->pixel_xfer.pixelmap_texture) {
+ st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx);
+ }
+
+ /* with a little effort, we can do four pixel map look-ups with
+ * two TEX instructions:
+ */
+
+ /* TEX temp.rg, colorTemp.rgba, texture[1], 2D; */
+ _mesa_init_instructions(inst + ic, 1);
+ inst[ic].Opcode = OPCODE_TEX;
+ inst[ic].DstReg.File = PROGRAM_TEMPORARY;
+ inst[ic].DstReg.Index = temp;
+ inst[ic].DstReg.WriteMask = WRITEMASK_XY; /* write R,G */
+ inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst[ic].SrcReg[0].Index = colorTemp;
+ inst[ic].TexSrcUnit = 1;
+ inst[ic].TexSrcTarget = TEXTURE_2D_INDEX;
+ ic++;
+
+ /* TEX temp.ba, colorTemp.baba, texture[1], 2D; */
+ _mesa_init_instructions(inst + ic, 1);
+ inst[ic].Opcode = OPCODE_TEX;
+ inst[ic].DstReg.File = PROGRAM_TEMPORARY;
+ inst[ic].DstReg.Index = temp;
+ inst[ic].DstReg.WriteMask = WRITEMASK_ZW; /* write B,A */
+ inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst[ic].SrcReg[0].Index = colorTemp;
+ inst[ic].SrcReg[0].Swizzle = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W,
+ SWIZZLE_Z, SWIZZLE_W);
+ inst[ic].TexSrcUnit = 1;
+ inst[ic].TexSrcTarget = TEXTURE_2D_INDEX;
+ ic++;
+
+ /* MOV colorTemp, temp; */
+ _mesa_init_instructions(inst + ic, 1);
+ inst[ic].Opcode = OPCODE_MOV;
+ inst[ic].DstReg.File = PROGRAM_TEMPORARY;
+ inst[ic].DstReg.Index = colorTemp;
+ inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst[ic].SrcReg[0].Index = temp;
+ ic++;
+
+ fp->Base.SamplersUsed |= (1 << 1); /* sampler 1 is used */
+ }
+
if (key->colorMatrix) {
static const gl_state_index row0_state[STATE_LENGTH] =
{ STATE_COLOR_MATRIX, 0, 0, 0, 0 };
@@ -182,64 +314,85 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
GLint row3_p = _mesa_add_state_reference(params, row3_state);
const GLuint temp = 1;
- /* MOV temp, colorTemp; */
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_MOV;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = temp;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = colorTemp;
- ic++;
-
- /* XXX reimplement in terms of MUL/MAD (see t_vp_build.c) */
-
- /* DP4 colorTemp.x, temp, matrow0; */
+ /* DP4 temp.x, colorTemp, matrow0; */
_mesa_init_instructions(inst + ic, 1);
inst[ic].Opcode = OPCODE_DP4;
inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = colorTemp;
+ inst[ic].DstReg.Index = temp;
inst[ic].DstReg.WriteMask = WRITEMASK_X;
inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = temp;
+ inst[ic].SrcReg[0].Index = colorTemp;
inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
inst[ic].SrcReg[1].Index = row0_p;
ic++;
- /* DP4 colorTemp.y, temp, matrow1; */
+ /* DP4 temp.y, colorTemp, matrow1; */
_mesa_init_instructions(inst + ic, 1);
inst[ic].Opcode = OPCODE_DP4;
inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = colorTemp;
+ inst[ic].DstReg.Index = temp;
inst[ic].DstReg.WriteMask = WRITEMASK_Y;
inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = temp;
+ inst[ic].SrcReg[0].Index = colorTemp;
inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
inst[ic].SrcReg[1].Index = row1_p;
ic++;
- /* DP4 colorTemp.z, temp, matrow2; */
+ /* DP4 temp.z, colorTemp, matrow2; */
_mesa_init_instructions(inst + ic, 1);
inst[ic].Opcode = OPCODE_DP4;
inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = colorTemp;
+ inst[ic].DstReg.Index = temp;
inst[ic].DstReg.WriteMask = WRITEMASK_Z;
inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = temp;
+ inst[ic].SrcReg[0].Index = colorTemp;
inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
inst[ic].SrcReg[1].Index = row2_p;
ic++;
- /* DP4 colorTemp.w, temp, matrow3; */
+ /* DP4 temp.w, colorTemp, matrow3; */
_mesa_init_instructions(inst + ic, 1);
inst[ic].Opcode = OPCODE_DP4;
inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index =colorTemp;
+ inst[ic].DstReg.Index = temp;
inst[ic].DstReg.WriteMask = WRITEMASK_W;
inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = temp;
+ inst[ic].SrcReg[0].Index = colorTemp;
inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
inst[ic].SrcReg[1].Index = row3_p;
ic++;
+
+ /* MOV colorTemp, temp; */
+ _mesa_init_instructions(inst + ic, 1);
+ inst[ic].Opcode = OPCODE_MOV;
+ inst[ic].DstReg.File = PROGRAM_TEMPORARY;
+ inst[ic].DstReg.Index = colorTemp;
+ inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst[ic].SrcReg[0].Index = temp;
+ ic++;
+ }
+
+ if (key->colorMatrixPostScaleBias) {
+ static const gl_state_index scale_state[STATE_LENGTH] =
+ { STATE_INTERNAL, STATE_PT_SCALE, 0, 0, 0 };
+ static const gl_state_index bias_state[STATE_LENGTH] =
+ { STATE_INTERNAL, STATE_PT_BIAS, 0, 0, 0 };
+ GLint scale_param, bias_param;
+
+ scale_param = _mesa_add_state_reference(params, scale_state);
+ bias_param = _mesa_add_state_reference(params, bias_state);
+
+ _mesa_init_instructions(inst + ic, 1);
+ inst[ic].Opcode = OPCODE_MAD;
+ inst[ic].DstReg.File = PROGRAM_TEMPORARY;
+ inst[ic].DstReg.Index = colorTemp;
+ inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
+ inst[ic].SrcReg[0].Index = colorTemp;
+ inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
+ inst[ic].SrcReg[1].Index = scale_param;
+ inst[ic].SrcReg[2].File = PROGRAM_STATE_VAR;
+ inst[ic].SrcReg[2].Index = bias_param;
+ ic++;
}
/* Modify last instruction's dst reg to write to result.color */
@@ -285,6 +438,7 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
static void
update_pixel_transfer(struct st_context *st)
{
+ GLcontext *ctx = st->ctx;
struct state_key key;
struct gl_fragment_program *fp;
@@ -298,6 +452,11 @@ update_pixel_transfer(struct st_context *st)
&key, sizeof(key), &fp->Base);
}
+ if (ctx->Pixel.MapColorFlag) {
+ load_color_map_texture(ctx, st->pixel_xfer.pixelmap_texture);
+ }
+ st->pixel_xfer.pixelmap_enabled = ctx->Pixel.MapColorFlag;
+
st->pixel_xfer.program = (struct st_fragment_program *) fp;
}
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index ec39026eb3..3f5ec71112 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -273,8 +273,8 @@ update_linkage( struct st_context *st )
st->vp = stvp;
st->fp = stfp;
- st->pipe->bind_vs_state(st->pipe, stvp->driver_shader);
- st->pipe->bind_fs_state(st->pipe, stfp->driver_shader);
+ cso_set_vertex_shader_handle(st->cso_context, stvp->driver_shader);
+ cso_set_fragment_shader_handle(st->cso_context, stfp->driver_shader);
st->vertex_result_to_slot = xvp->output_to_slot;
}
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
deleted file mode 100644
index 7ee4fadc37..0000000000
--- a/src/mesa/state_tracker/st_cache.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin <zack@tungstengraphics.com>
- */
-
-#include "st_cache.h"
-
-#include "st_context.h"
-
-#include "pipe/p_state.h"
-
-#include "cso_cache/cso_cache.h"
-#include "cso_cache/cso_hash.h"
-
-
-/* Those function will either find the state of the given template
- * in the cache or they will create a new state from the given
- * template, insert it in the cache and return it.
- */
-
-/*
- * If the driver returns 0 from the create method then they will assign
- * the data member of the cso to be the template itself.
- */
-
-const struct cso_blend * st_cached_blend_state(struct st_context *st,
- const struct pipe_blend_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_blend_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_BLEND,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_blend *cso = malloc(sizeof(struct cso_blend));
- memcpy(&cso->state, templ, sizeof(struct pipe_blend_state));
- cso->data = st->pipe->create_blend_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- cso->delete_state = (cso_state_callback)st->pipe->delete_blend_state;
- cso->context = st->pipe;
- iter = cso_insert_state(st->cache, hash_key, CSO_BLEND, cso);
- }
- return ((struct cso_blend *)cso_hash_iter_data(iter));
-}
-
-const struct cso_sampler *
-st_cached_sampler_state(struct st_context *st,
- const struct pipe_sampler_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_SAMPLER,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_sampler *cso = malloc(sizeof(struct cso_sampler));
- memcpy(&cso->state, templ, sizeof(struct pipe_sampler_state));
- cso->data = st->pipe->create_sampler_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- cso->delete_state = (cso_state_callback)st->pipe->delete_sampler_state;
- cso->context = st->pipe;
- iter = cso_insert_state(st->cache, hash_key, CSO_SAMPLER, cso);
- }
- return (struct cso_sampler*)(cso_hash_iter_data(iter));
-}
-
-const struct cso_depth_stencil_alpha *
-st_cached_depth_stencil_alpha_state(struct st_context *st,
- const struct pipe_depth_stencil_alpha_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ,
- sizeof(struct pipe_depth_stencil_alpha_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key,
- CSO_DEPTH_STENCIL_ALPHA,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_depth_stencil_alpha *cso = malloc(sizeof(struct cso_depth_stencil_alpha));
- memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_alpha_state));
- cso->data = st->pipe->create_depth_stencil_alpha_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- cso->delete_state = (cso_state_callback)st->pipe->delete_depth_stencil_alpha_state;
- cso->context = st->pipe;
- iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL_ALPHA, cso);
- }
- return (struct cso_depth_stencil_alpha*)(cso_hash_iter_data(iter));
-}
-
-const struct cso_rasterizer* st_cached_rasterizer_state(
- struct st_context *st,
- const struct pipe_rasterizer_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ,
- sizeof(struct pipe_rasterizer_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_RASTERIZER,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_rasterizer *cso = malloc(sizeof(struct cso_rasterizer));
- memcpy(&cso->state, templ, sizeof(struct pipe_rasterizer_state));
- cso->data = st->pipe->create_rasterizer_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- cso->delete_state = (cso_state_callback)st->pipe->delete_rasterizer_state;
- cso->context = st->pipe;
- iter = cso_insert_state(st->cache, hash_key, CSO_RASTERIZER, cso);
- }
- return (struct cso_rasterizer*)(cso_hash_iter_data(iter));
-}
-
-const struct cso_fragment_shader *
-st_cached_fs_state(struct st_context *st,
- const struct pipe_shader_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ,
- sizeof(struct pipe_shader_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_FRAGMENT_SHADER,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_fragment_shader *cso = malloc(sizeof(struct cso_fragment_shader));
- memcpy(&cso->state, templ, sizeof(struct pipe_shader_state));
- cso->data = st->pipe->create_fs_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- cso->delete_state = (cso_state_callback)st->pipe->delete_fs_state;
- cso->context = st->pipe;
- iter = cso_insert_state(st->cache, hash_key, CSO_FRAGMENT_SHADER, cso);
- }
- return (struct cso_fragment_shader*)(cso_hash_iter_data(iter));
-}
-
-const struct cso_vertex_shader *
-st_cached_vs_state(struct st_context *st,
- const struct pipe_shader_state *templ)
-{
- unsigned hash_key = cso_construct_key((void*)templ,
- sizeof(struct pipe_shader_state));
- struct cso_hash_iter iter = cso_find_state_template(st->cache,
- hash_key, CSO_VERTEX_SHADER,
- (void*)templ);
- if (cso_hash_iter_is_null(iter)) {
- struct cso_vertex_shader *cso = malloc(sizeof(struct cso_vertex_shader));
- memcpy(&cso->state, templ, sizeof(struct pipe_shader_state));
- cso->data = st->pipe->create_vs_state(st->pipe, &cso->state);
- if (!cso->data)
- cso->data = &cso->state;
- cso->delete_state = (cso_state_callback)st->pipe->delete_vs_state;
- cso->context = st->pipe;
- iter = cso_insert_state(st->cache, hash_key, CSO_VERTEX_SHADER, cso);
- }
- return (struct cso_vertex_shader*)(cso_hash_iter_data(iter));
-}
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 4f9a22161c..1636bed91a 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -173,6 +173,8 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
default:
_mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
+
+ pipe_surface_unmap(acc_ps);
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 505a13cc2b..7752b40e8b 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -105,7 +105,7 @@ struct bitmap_cache
* This program will be combined with the user's fragment program.
*/
static struct st_fragment_program *
-make_bitmap_fragment_program(GLcontext *ctx)
+make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex)
{
struct st_fragment_program *stfp;
struct gl_program *p;
@@ -130,7 +130,7 @@ make_bitmap_fragment_program(GLcontext *ctx)
p->Instructions[ic].DstReg.Index = 0;
p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_TEX0;
- p->Instructions[ic].TexSrcUnit = 0;
+ p->Instructions[ic].TexSrcUnit = samplerIndex;
p->Instructions[ic].TexSrcTarget = TEXTURE_2D_INDEX;
ic++;
@@ -148,7 +148,7 @@ make_bitmap_fragment_program(GLcontext *ctx)
p->InputsRead = FRAG_BIT_TEX0;
p->OutputsWritten = 0x0;
- p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
+ p->SamplersUsed = (1 << samplerIndex);
stfp = (struct st_fragment_program *) p;
stfp->Base.UsesKill = GL_TRUE;
@@ -158,6 +158,19 @@ make_bitmap_fragment_program(GLcontext *ctx)
}
+static int
+find_free_bit(uint bitfield)
+{
+ int i;
+ for (i = 0; i < 32; i++) {
+ if ((bitfield & (1 << i)) == 0) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+
/**
* Combine basic bitmap fragment program with the user-defined program.
*/
@@ -165,28 +178,26 @@ static struct st_fragment_program *
combined_bitmap_fragment_program(GLcontext *ctx)
{
struct st_context *st = ctx->st;
- struct st_fragment_program *stfp;
-
- if (!st->bitmap.program) {
- /* create the basic bitmap fragment program */
- st->bitmap.program = make_bitmap_fragment_program(ctx);
- }
+ struct st_fragment_program *stfp = st->fp;
- if (st->bitmap.user_prog_sn == st->fp->serialNo) {
- /* re-use */
- stfp = st->bitmap.combined_prog;
- }
- else {
- /* Concatenate the bitmap program with the current user-defined program.
+ if (!stfp->bitmap_program) {
+ /*
+ * Generate new program which is the user-defined program prefixed
+ * with the bitmap sampler/kill instructions.
*/
- stfp = (struct st_fragment_program *)
- _mesa_combine_programs(ctx,
- &st->bitmap.program->Base.Base,
- &st->fp->Base.Base);
+ struct st_fragment_program *bitmap_prog;
+ uint sampler;
+ sampler = find_free_bit(st->fp->Base.Base.SamplersUsed);
+ bitmap_prog = make_bitmap_fragment_program(ctx, sampler);
+
+ stfp->bitmap_program = (struct st_fragment_program *)
+ _mesa_combine_programs(ctx,
+ &bitmap_prog->Base.Base, &stfp->Base.Base);
+ stfp->bitmap_program->bitmap_sampler = sampler;
#if 0
{
- struct gl_program *p = &stfp->Base.Base;
+ struct gl_program *p = &stfp->bitmap_program->Base.Base;
printf("Combined bitmap program:\n");
_mesa_print_program(p);
printf("InputsRead: 0x%x\n", p->InputsRead);
@@ -196,11 +207,7 @@ combined_bitmap_fragment_program(GLcontext *ctx)
#endif
/* translate to TGSI tokens */
- st_translate_fragment_program(st, stfp, NULL);
-
- /* save new program, update serial numbers */
- st->bitmap.user_prog_sn = st->fp->serialNo;
- st->bitmap.combined_prog = stfp;
+ st_translate_fragment_program(st, stfp->bitmap_program, NULL);
}
/* Ideally we'd have updated the pipe constants during the normal
@@ -208,7 +215,7 @@ combined_bitmap_fragment_program(GLcontext *ctx)
*/
st_upload_constants(st, stfp->Base.Base.Parameters, PIPE_SHADER_FRAGMENT);
- return stfp;
+ return stfp->bitmap_program;
}
@@ -438,21 +445,38 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_save_samplers(cso);
cso_save_sampler_textures(cso);
cso_save_viewport(cso);
+ cso_save_fragment_shader(cso);
+ cso_save_vertex_shader(cso);
/* rasterizer state: just scissor */
st->bitmap.rasterizer.scissor = ctx->Scissor.Enabled;
cso_set_rasterizer(cso, &st->bitmap.rasterizer);
/* fragment shader state: TEX lookup program */
- pipe->bind_fs_state(pipe, stfp->driver_shader);
+ cso_set_fragment_shader_handle(cso, stfp->driver_shader);
/* vertex shader state: position + texcoord pass-through */
- pipe->bind_vs_state(pipe, st->bitmap.vs);
+ cso_set_vertex_shader_handle(cso, st->bitmap.vs);
+
+ /* user samplers, plus our bitmap sampler */
+ {
+ struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
+ uint num = MAX2(stfp->bitmap_sampler + 1, st->state.num_samplers);
+ uint i;
+ for (i = 0; i < st->state.num_samplers; i++) {
+ samplers[i] = &st->state.samplers[i];
+ }
+ samplers[stfp->bitmap_sampler] = &st->bitmap.sampler;
+ cso_set_samplers(cso, num, (const struct pipe_sampler_state **) samplers); }
- /* sampler / texture state */
- cso_single_sampler(cso, 0, &st->bitmap.sampler);
- cso_single_sampler_done(cso);
- pipe->set_sampler_textures(pipe, 1, &pt);
+ /* user textures, plus the bitmap texture */
+ {
+ struct pipe_texture *textures[PIPE_MAX_SAMPLERS];
+ uint num = MAX2(stfp->bitmap_sampler + 1, st->state.num_textures);
+ memcpy(textures, st->state.sampler_texture, sizeof(textures));
+ textures[stfp->bitmap_sampler] = pt;
+ cso_set_sampler_textures(cso, num, textures);
+ }
/* viewport state: viewport matching window dims */
{
@@ -488,9 +512,8 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_restore_samplers(cso);
cso_restore_sampler_textures(cso);
cso_restore_viewport(cso);
- /* shaders don't go through cso yet */
- pipe->bind_fs_state(pipe, st->fp->driver_shader);
- pipe->bind_vs_state(pipe, st->vp->driver_shader);
+ cso_restore_fragment_shader(cso);
+ cso_restore_vertex_shader(cso);
}
@@ -770,6 +793,7 @@ st_destroy_bitmap(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
+#if 0
if (st->bitmap.combined_prog) {
st_delete_program(st->ctx, &st->bitmap.combined_prog->Base.Base);
}
@@ -777,7 +801,7 @@ st_destroy_bitmap(struct st_context *st)
if (st->bitmap.program) {
st_delete_program(st->ctx, &st->bitmap.program->Base.Base);
}
-
+#endif
if (st->bitmap.vs) {
pipe->delete_vs_state(pipe, st->bitmap.vs);
st->bitmap.vs = NULL;
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 63211d8b66..0533d9460f 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -71,7 +71,6 @@ st_BlitFramebuffer(GLcontext *ctx,
GLbitfield mask, GLenum filter)
{
struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
const uint pFilter = ((filter == GL_NEAREST)
? PIPE_TEX_MIPFILTER_NEAREST
@@ -100,10 +99,6 @@ st_BlitFramebuffer(GLcontext *ctx,
0.0, pFilter);
}
-
- /* shaders don't go through CSO yet */
- pipe->bind_fs_state(pipe, st->fp->driver_shader);
- pipe->bind_vs_state(pipe, st->vp->driver_shader);
}
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index fa9f986f11..dac346a06c 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -195,7 +195,6 @@ clear_with_quad(GLcontext *ctx,
GLboolean color, GLboolean depth, GLboolean stencil)
{
struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
const GLfloat x0 = ctx->DrawBuffer->_Xmin;
const GLfloat x1 = ctx->DrawBuffer->_Xmax;
GLfloat y0, y1;
@@ -222,6 +221,8 @@ clear_with_quad(GLcontext *ctx,
cso_save_depth_stencil_alpha(st->cso_context);
cso_save_rasterizer(st->cso_context);
cso_save_viewport(st->cso_context);
+ cso_save_fragment_shader(st->cso_context);
+ cso_save_vertex_shader(st->cso_context);
/* blend state: RGBA masking */
{
@@ -273,8 +274,8 @@ clear_with_quad(GLcontext *ctx,
cso_set_rasterizer(st->cso_context, &st->clear.raster);
cso_set_viewport(st->cso_context, &st->clear.viewport);
- pipe->bind_fs_state(pipe, st->clear.fs);
- pipe->bind_vs_state(pipe, st->clear.vs);
+ cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
+ cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
/* draw quad matching scissor rect (XXX verify coord round-off) */
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
@@ -284,9 +285,8 @@ clear_with_quad(GLcontext *ctx,
cso_restore_depth_stencil_alpha(st->cso_context);
cso_restore_rasterizer(st->cso_context);
cso_restore_viewport(st->cso_context);
- /* these don't go through cso yet */
- pipe->bind_fs_state(pipe, st->fp->driver_shader);
- pipe->bind_vs_state(pipe, st->vp->driver_shader);
+ cso_restore_fragment_shader(st->cso_context);
+ cso_restore_vertex_shader(st->cso_context);
}
@@ -406,7 +406,7 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
/* clear whole buffer w/out masking */
struct st_renderbuffer *strb = st_renderbuffer(rb);
uint clearValue;
- util_pack_color(ctx->Color.ClearColor, strb->surface->format, &clearValue);
+ util_pack_color(ctx->Color.ClearColor, PIPE_FORMAT_A8R8G8B8_UNORM, &clearValue);
ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue);
}
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 5f8c90cbba..3921500659 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -532,6 +532,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_save_viewport(cso);
cso_save_samplers(cso);
cso_save_sampler_textures(cso);
+ cso_save_fragment_shader(cso);
+ cso_save_vertex_shader(cso);
/* rasterizer state: just scissor */
{
@@ -543,10 +545,10 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
}
/* fragment shader state: TEX lookup program */
- pipe->bind_fs_state(pipe, stfp->driver_shader);
+ cso_set_fragment_shader_handle(cso, stfp->driver_shader);
/* vertex shader state: position + texcoord pass-through */
- pipe->bind_vs_state(pipe, stvp->driver_shader);
+ cso_set_vertex_shader_handle(cso, stvp->driver_shader);
/* texture sampling state: */
@@ -562,6 +564,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
sampler.normalized_coords = 1;
cso_single_sampler(cso, 0, &sampler);
+ if (st->pixel_xfer.pixelmap_enabled) {
+ cso_single_sampler(cso, 1, &sampler);
+ }
cso_single_sampler_done(cso);
}
@@ -582,7 +587,15 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
}
/* texture state: */
- pipe->set_sampler_textures(pipe, 1, &pt);
+ if (st->pixel_xfer.pixelmap_enabled) {
+ struct pipe_texture *textures[2];
+ textures[0] = pt;
+ textures[1] = st->pixel_xfer.pixelmap_texture;
+ pipe->set_sampler_textures(pipe, 2, textures);
+ }
+ else {
+ pipe->set_sampler_textures(pipe, 1, &pt);
+ }
/* Compute window coords (y=0=bottom) with pixel zoom.
* Recall that these coords are transformed by the current
@@ -604,10 +617,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_restore_viewport(cso);
cso_restore_samplers(cso);
cso_restore_sampler_textures(cso);
-
- /* shaders don't go through cso yet */
- pipe->bind_fs_state(pipe, st->fp->driver_shader);
- pipe->bind_vs_state(pipe, st->vp->driver_shader);
+ cso_restore_fragment_shader(cso);
+ cso_restore_vertex_shader(cso);
}
@@ -871,7 +882,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
struct pipe_surface *psRead = rbRead->surface;
struct pipe_surface *psDraw = rbDraw->surface;
- ubyte *readMap, *drawMap;
+ ubyte *drawMap;
ubyte *buffer;
int i;
@@ -881,14 +892,13 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
return;
}
- /* map the stencil buffers */
- readMap = pipe_surface_map(psRead);
- drawMap = pipe_surface_map(psDraw);
-
/* this will do stencil pixel transfer ops */
st_read_stencil_pixels(ctx, srcx, srcy, width, height, GL_UNSIGNED_BYTE,
&ctx->DefaultPacking, buffer);
+ /* map the stencil buffer */
+ drawMap = pipe_surface_map(psDraw);
+
/* draw */
/* XXX PixelZoom not handled yet */
for (i = 0; i < height; i++) {
@@ -926,8 +936,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
free(buffer);
- /* unmap the stencil buffers */
- pipe_surface_unmap(psRead);
+ /* unmap the stencil buffer */
pipe_surface_unmap(psDraw);
}
diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index 5315294c07..1b50792bd1 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -56,7 +56,7 @@
#include "cso_cache/cso_cache.h"
#include "draw/draw_context.h"
-#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
/**
@@ -238,6 +238,12 @@ select_reset_stipple_counter( struct draw_stage *stage )
/* no-op */
}
+static void
+select_destroy( struct draw_stage *stage )
+{
+ /* no-op */
+}
+
/**
* Create GL selection mode drawing stage.
@@ -254,6 +260,7 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw)
fs->stage.tri = select_tri;
fs->stage.flush = select_flush;
fs->stage.reset_stipple_counter = select_reset_stipple_counter;
+ fs->stage.destroy = select_destroy;
fs->ctx = ctx;
return &fs->stage;
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index 1b3402cee2..5e866b0d41 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -67,7 +67,9 @@ display_front_buffer(struct st_context *st)
st->pipe->winsys->flush_frontbuffer( st->pipe->winsys, front_surf,
st->pipe->priv );
+ /*
st->frontbuffer_status = FRONT_STATUS_UNDEFINED;
+ */
}
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 003ec0d2b7..67f8b1f8eb 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -159,6 +159,10 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
stfp->state.tokens = NULL;
}
+ if (stfp->bitmap_program) {
+ st_delete_program(ctx, &stfp->bitmap_program->Base.Base);
+ }
+
st_free_translated_vertex_programs(st, stfp->vertex_programs);
}
break;
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 2ed228778e..3cb7b68bea 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -46,7 +46,7 @@
#include "st_cb_rasterpos.h"
#include "st_draw.h"
#include "draw/draw_context.h"
-#include "draw/draw_private.h"
+#include "draw/draw_pipe.h"
#include "shader/prog_instruction.h"
#include "vbo/vbo.h"
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 154327239d..dadc524b51 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -170,10 +170,6 @@ static void st_destroy_context_priv( struct st_context *st )
_vbo_DestroyContext(st->ctx);
- cso_destroy_context(st->cso_context);
-
- _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
-
for (i = 0; i < Elements(st->state.constants); i++) {
if (st->state.constants[i].buffer) {
pipe_buffer_reference(ws, &st->state.constants[i].buffer, NULL);
@@ -188,6 +184,12 @@ static void st_destroy_context_priv( struct st_context *st )
void st_destroy_context( struct st_context *st )
{
GLcontext *ctx = st->ctx;
+
+ /* need to unbind and destroy CSO objects before anything else */
+ cso_destroy_context(st->cso_context);
+
+ _mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
+
_mesa_free_context_data(ctx);
st_destroy_context_priv(st);
free(ctx);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index d89e54c43c..2851770d4c 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -138,13 +138,12 @@ struct st_context
GLuint user_prog_sn; /**< user fragment program serial no. */
struct st_fragment_program *combined_prog;
GLuint combined_prog_sn;
+ struct pipe_texture *pixelmap_texture;
+ boolean pixelmap_enabled; /**< use the pixelmap texture? */
} pixel_xfer;
/** for glBitmap */
struct {
- struct st_fragment_program *program; /**< bitmap tex/kil program */
- GLuint user_prog_sn; /**< user fragment program serial no. */
- struct st_fragment_program *combined_prog;
struct pipe_rasterizer_state rasterizer;
struct pipe_sampler_state sampler;
struct pipe_shader_state vert_shader;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index f0f62246dd..befcb96bd8 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -611,10 +611,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
* unmap vertex/index buffers
*/
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
- if (draw->vertex_buffer[i].buffer) {
+ if (draw->pt.vertex_buffer[i].buffer) {
pipe->winsys->buffer_unmap(pipe->winsys,
- draw->vertex_buffer[i].buffer);
- pipe_buffer_reference(winsys, &draw->vertex_buffer[i].buffer, NULL);
+ draw->pt.vertex_buffer[i].buffer);
+ pipe_buffer_reference(winsys, &draw->pt.vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 2f7ac074da..f2d40e84b3 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -164,6 +164,7 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.NV_blend_square = GL_TRUE;
ctx->Extensions.NV_texgen_reflection = GL_TRUE;
+ ctx->Extensions.SGI_color_matrix = GL_TRUE;
ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; /* XXX temp */
/*
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index cd41dc4684..3d15a03cab 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -354,8 +354,9 @@ default_depth_format(struct pipe_screen *screen, uint type)
* Given an OpenGL internalFormat value for a texture or surface, return
* the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
*/
-static enum pipe_format
-choose_format(struct pipe_context *pipe, GLint internalFormat, uint surfType)
+enum pipe_format
+st_choose_format(struct pipe_context *pipe, GLint internalFormat,
+ uint surfType)
{
struct pipe_screen *screen = pipe->screen;
@@ -530,7 +531,7 @@ choose_format(struct pipe_context *pipe, GLint internalFormat, uint surfType)
enum pipe_format
st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
{
- return choose_format(pipe, internalFormat, PIPE_SURFACE);
+ return st_choose_format(pipe, internalFormat, PIPE_SURFACE);
}
@@ -594,7 +595,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
(void) format;
(void) type;
- pFormat = choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE);
+ pFormat = st_choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE);
if (pFormat == PIPE_FORMAT_NONE)
return NULL;
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index c9a11de504..ff0fd042db 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -64,6 +64,10 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat);
extern enum pipe_format
+st_choose_format(struct pipe_context *pipe, GLint internalFormat,
+ uint surfType);
+
+extern enum pipe_format
st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat);
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index a931911227..da9ec12a4d 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -95,12 +95,6 @@ st_render_mipmap(struct st_context *st,
util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel,
PIPE_TEX_FILTER_LINEAR);
- /* shaders don't go through CSO yet */
- if (st->fp)
- pipe->bind_fs_state(pipe, st->fp->driver_shader);
- if (st->vp)
- pipe->bind_vs_state(pipe, st->vp->driver_shader);
-
return TRUE;
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 4d1ef1bf3d..3648ded8a1 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -315,7 +315,7 @@ st_translate_vertex_program(struct st_context *st,
* \param tokensOut destination for TGSI tokens
* \return pointer to cached pipe_shader object.
*/
-const struct cso_fragment_shader *
+void
st_translate_fragment_program(struct st_context *st,
struct st_fragment_program *stfp,
const GLuint inputMapping[])
@@ -325,7 +325,6 @@ st_translate_fragment_program(struct st_context *st,
GLuint outputMapping[FRAG_RESULT_MAX];
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
struct pipe_shader_state fs;
- const struct cso_fragment_shader *cso;
GLuint interpMode[16]; /* XXX size? */
GLuint attr;
const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
@@ -475,7 +474,5 @@ st_translate_fragment_program(struct st_context *st,
if (TGSI_DEBUG)
tgsi_dump( fs.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
-
- return cso;
}
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 63d6590540..1a2062131d 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -61,7 +61,7 @@ struct st_fragment_program
GLuint input_map[PIPE_MAX_SHADER_INPUTS];
struct pipe_shader_state state;
- struct pipe_shader_state *driver_shader;
+ void *driver_shader;
GLuint param_state;
@@ -69,6 +69,10 @@ struct st_fragment_program
* outputs match this fragment program's inputs.
*/
struct translated_vertex_program *vertex_programs;
+
+ /** Program prefixed with glBitmap prologue */
+ struct st_fragment_program *bitmap_program;
+ uint bitmap_sampler;
};
@@ -88,7 +92,7 @@ struct st_vertex_program
GLuint num_inputs;
struct pipe_shader_state state;
- struct pipe_shader_state *driver_shader;
+ void *driver_shader;
/** For using our private draw module (glRasterPos) */
struct draw_vertex_shader *draw_shader;
@@ -111,7 +115,7 @@ st_vertex_program( struct gl_vertex_program *vp )
}
-extern const struct cso_fragment_shader *
+extern void
st_translate_fragment_program(struct st_context *st,
struct st_fragment_program *fp,
const GLuint inputMapping[]);