summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c23
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c146
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c6
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c15
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c3
-rw-r--r--src/mesa/state_tracker/st_cb_program.c18
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c7
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c14
-rw-r--r--src/mesa/state_tracker/st_context.h2
-rw-r--r--src/mesa/state_tracker/st_debug.c4
-rw-r--r--src/mesa/state_tracker/st_draw.c12
-rw-r--r--src/mesa/state_tracker/st_program.c6
-rw-r--r--src/mesa/state_tracker/st_program.h7
-rw-r--r--src/mesa/state_tracker/st_texture.c4
-rw-r--r--src/mesa/state_tracker/st_texture.h4
15 files changed, 82 insertions, 189 deletions
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 2a182c7d9c..1ed9333556 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -43,6 +43,8 @@
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/cso_cache/cso_cache.h"
+
#include "st_context.h"
#include "st_cache.h"
#include "st_atom.h"
@@ -71,8 +73,8 @@ struct translated_vertex_program
/** The program in TGSI format */
struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
- /** Pointer to the translated, cached vertex shader */
- const struct cso_vertex_shader *vs;
+ /** Pointer to the translated vertex program */
+ struct st_vertex_program *vp;
struct translated_vertex_program *next; /**< next in linked list */
};
@@ -257,12 +259,13 @@ find_translated_vp(struct st_context *st,
assert(stvp->Base.Base.NumInstructions > 1);
- xvp->vs = st_translate_vertex_program(st, stvp,
- xvp->output_to_slot,
- xvp->tokens,
- ST_MAX_SHADER_TOKENS);
- assert(xvp->vs);
- stvp->vs = NULL; /* don't want to use this */
+ st_translate_vertex_program(st, stvp,
+ xvp->output_to_slot,
+ xvp->tokens,
+ ST_MAX_SHADER_TOKENS);
+
+ assert(stvp->cso);
+ xvp->vp = stvp;
/* translated VP is up to date now */
xvp->serialNo = stvp->serialNo;
@@ -291,8 +294,8 @@ update_linkage( struct st_context *st )
xvp = find_translated_vp(st, stvp, stfp);
st->vp = stvp;
- st->state.vs = xvp->vs;
- st->pipe->bind_vs_state(st->pipe, st->state.vs->data);
+ st->state.vs = xvp->vp;
+ st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data);
st->fp = stfp;
st->state.fs = stfp->fs;
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index cf2e9db51c..3a3bf9016d 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -43,6 +43,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "pipe/util/p_tile.h"
#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
@@ -59,6 +60,7 @@
void
st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
+ struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
struct pipe_surface *acc_ps = acc_strb->surface;
const GLint xpos = ctx->DrawBuffer->_Xmin;
@@ -69,102 +71,17 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
const GLfloat g = ctx->Accum.ClearColor[1];
const GLfloat b = ctx->Accum.ClearColor[2];
const GLfloat a = ctx->Accum.ClearColor[3];
+ GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
+ int i;
- (void) pipe_surface_map(acc_ps);
-
- switch (acc_ps->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const short sr = (short) (32767 * r);
- const short sg = (short) (32767 * g);
- const short sb = (short) (32767 * b);
- const short sa = (short) (32767 * a);
- short *acc = ((short *) acc_ps->map)
- + (ypos * acc_ps->pitch + xpos) * 4;
- int i, j;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- acc[j*4+0] = sr;
- acc[j*4+1] = sg;
- acc[j*4+2] = sb;
- acc[j*4+3] = sa;
- }
- acc += acc_ps->pitch * 4;
- }
- }
- break;
- default:
- assert(0);
- }
-
- pipe_surface_unmap(acc_ps);
-}
-
-
-/** Get block of values from accum buffer, converting to float */
-static void
-get_accum_tile(struct pipe_context *pipe,
- struct pipe_surface *acc_surf,
- int xpos, int ypos, int width, int height,
- float *buf)
-{
- switch (acc_surf->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const short *acc = ((const short *) acc_surf->map)
- + (ypos * acc_surf->pitch + xpos) * 4;
- int i, j;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- buf[j*4+0] = SHORT_TO_FLOAT(acc[j*4+0]);
- buf[j*4+1] = SHORT_TO_FLOAT(acc[j*4+1]);
- buf[j*4+2] = SHORT_TO_FLOAT(acc[j*4+2]);
- buf[j*4+3] = SHORT_TO_FLOAT(acc[j*4+3]);
- }
- acc += acc_surf->pitch * 4;
- buf += width * 4;
- }
- }
- break;
- default:
- assert(0);
+ for (i = 0; i < width * height; i++) {
+ accBuf[i*4+0] = r;
+ accBuf[i*4+1] = g;
+ accBuf[i*4+2] = b;
+ accBuf[i*4+3] = a;
}
-}
-
-/** Put block of values into accum buffer, converting from float */
-static void
-put_accum_tile(struct pipe_context *pipe,
- struct pipe_surface *acc_surf,
- int xpos, int ypos, int width, int height,
- const float *buf)
-{
- switch (acc_surf->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- short *acc = ((short *) acc_surf->map)
- + (ypos * acc_surf->pitch + xpos) * 4;
- int i, j;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- short r, g, b, a;
- UNCLAMPED_FLOAT_TO_SHORT(r, buf[j*4+0]);
- UNCLAMPED_FLOAT_TO_SHORT(g, buf[j*4+1]);
- UNCLAMPED_FLOAT_TO_SHORT(b, buf[j*4+2]);
- UNCLAMPED_FLOAT_TO_SHORT(a, buf[j*4+3]);
- acc[j*4+0] = r;
- acc[j*4+1] = g;
- acc[j*4+2] = b;
- acc[j*4+3] = a;
- }
- acc += acc_surf->pitch * 4;
- buf += width * 4;
- }
- }
- break;
- default:
- assert(0);
- }
+ pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
}
@@ -179,19 +96,15 @@ accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias,
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(acc_ps);
-
- get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] * scale + bias;
}
- put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(accBuf);
-
- pipe_surface_unmap(acc_ps);
}
@@ -201,30 +114,23 @@ accum_accum(struct pipe_context *pipe, GLfloat value,
struct pipe_surface *acc_ps,
struct pipe_surface *color_ps)
{
- ubyte *colorMap, *accMap;
GLfloat *colorBuf, *accBuf;
GLint i;
colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- colorMap = pipe_surface_map(color_ps);
- accMap = pipe_surface_map(acc_ps);
-
- pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
- get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
+ pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
for (i = 0; i < 4 * width * height; i++) {
accBuf[i] = accBuf[i] + colorBuf[i] * value;
}
- put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, accBuf);
+ pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
free(colorBuf);
free(accBuf);
-
- pipe_surface_unmap(color_ps);
- pipe_surface_unmap(acc_ps);
}
@@ -239,21 +145,15 @@ accum_load(struct pipe_context *pipe, GLfloat value,
buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(color_ps);
- (void) pipe_surface_map(acc_ps);
-
- pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
+ pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
for (i = 0; i < 4 * width * height; i++) {
buf[i] = buf[i] * value;
}
- put_accum_tile(pipe, acc_ps, xpos, ypos, width, height, buf);
+ pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf);
free(buf);
-
- pipe_surface_unmap(color_ps);
- pipe_surface_unmap(acc_ps);
}
@@ -270,14 +170,11 @@ accum_return(GLcontext *ctx, GLfloat value,
abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(color_ps);
- (void) pipe_surface_map(acc_ps);
-
- get_accum_tile(pipe, acc_ps, xpos, ypos, width, height, abuf);
+ pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf);
if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe->get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf);
+ pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf);
}
for (i = 0; i < width * height; i++) {
@@ -292,14 +189,11 @@ accum_return(GLcontext *ctx, GLfloat value,
}
}
- pipe->put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf);
+ pipe_put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf);
free(abuf);
if (cbuf)
free(cbuf);
-
- pipe_surface_unmap(color_ps);
- pipe_surface_unmap(acc_ps);
}
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 40319f4b4b..758d4a4086 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -208,7 +208,7 @@ make_vertex_shader(struct st_context *st)
stvp = (struct st_vertex_program *) p;
st_translate_vertex_program(st, stvp, NULL,
stvp->tokens, ST_MAX_SHADER_TOKENS);
- assert(stvp->vs);
+ assert(stvp->cso);
return stvp;
}
@@ -350,7 +350,7 @@ clear_with_quad(GLcontext *ctx,
if (!stvp) {
stvp = make_vertex_shader(st);
}
- pipe->bind_vs_state(pipe, stvp->vs->data);
+ pipe->bind_vs_state(pipe, stvp->cso->data);
}
/* viewport state: viewport matching window dims */
@@ -376,7 +376,7 @@ clear_with_quad(GLcontext *ctx,
pipe->bind_blend_state(pipe, st->state.blend->data);
pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data);
pipe->bind_fs_state(pipe, st->state.fs->data);
- pipe->bind_vs_state(pipe, st->state.vs->data);
+ pipe->bind_vs_state(pipe, st->state.vs->cso->data);
pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
pipe->set_viewport_state(pipe, &st->state.viewport);
/* OR:
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 2db12c653b..f4d6b9362c 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -56,6 +56,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
+#include "pipe/util/p_tile.h"
#include "shader/prog_instruction.h"
@@ -661,7 +662,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
pipe->bind_fs_state(pipe, stfp->fs->data);
/* vertex shader state: position + texcoord pass-through */
- pipe->bind_vs_state(pipe, stvp->vs->data);
+ pipe->bind_vs_state(pipe, stvp->cso->data);
/* texture sampling state: */
{
@@ -718,7 +719,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
/* restore GL state */
pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
- pipe->bind_vs_state(pipe, ctx->st->state.vs->data);
+ pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
@@ -1261,14 +1262,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* alternate path using get/put_tile() */
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- (void) pipe_surface_map(psRead);
- (void) pipe_surface_map(psTex);
-
- pipe->get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
- pipe->put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
-
- pipe_surface_unmap(psRead);
- pipe_surface_unmap(psTex);
+ pipe_get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
free(buf);
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index bc0f26ffb0..2d6b3fc749 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -97,9 +97,6 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
- /* loop here since mapping is refcounted */
- while (strb->surface->map)
- pipe_surface_unmap(strb->surface);
if (strb->surface->buffer)
pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer,
NULL);
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index aed6b1ee97..f1f33fb0dd 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -39,6 +39,9 @@
#include "shader/programopt.h"
#include "shader/shader_api.h"
+#include "pipe/cso_cache/cso_cache.h"
+#include "pipe/draw/draw_context.h"
+
#include "st_context.h"
#include "st_program.h"
#include "st_atom_shader.h"
@@ -181,17 +184,22 @@ static void st_program_string_notify( GLcontext *ctx,
stvp->serialNo++;
- if (stvp->vs) {
- /* free the TGSI code */
- // cso_delete(stfp->vs);
- stvp->vs = NULL;
+ if (stvp->cso) {
+ /* free the CSO data */
+ st->pipe->delete_vs_state(st->pipe, stvp->cso->data);
+ FREE((void *) stvp->cso);
+ stvp->cso = NULL;
+ }
+
+ if (stvp->draw_shader) {
+ draw_delete_vertex_shader(st->draw, stvp->draw_shader);
+ stvp->draw_shader = NULL;
}
stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
if (st->vp == stvp)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
-
}
}
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index b0c9275c6f..a1bbb3a831 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -40,6 +40,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "pipe/util/p_tile.h"
#include "st_context.h"
#include "st_cb_readpixels.h"
#include "st_cb_fbo.h"
@@ -179,8 +180,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
if (!strb)
return;
- pipe_surface_map(strb->surface);
-
if (format == GL_RGBA && type == GL_FLOAT) {
/* write tile(row) directly into user's buffer */
df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
@@ -212,7 +211,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
- pipe->get_tile_rgba(pipe, strb->surface, x, y, width, 1, df);
+ pipe_get_tile_rgba(pipe, strb->surface, x, y, width, 1, df);
y += yStep;
df += dfStride;
if (!dfStride) {
@@ -229,8 +228,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
}
-
- pipe_surface_unmap(strb->surface);
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index e813bdb47a..ba0950e295 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -45,6 +45,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "pipe/util/p_tile.h"
#define DBG if (0) printf
@@ -97,7 +98,7 @@ st_get_texobj_texture(struct gl_texture_object *texObj)
}
-static unsigned
+static enum pipe_texture_target
gl_target_to_pipe(GLenum target)
{
switch (target) {
@@ -1063,15 +1064,12 @@ fallback_copy_texsubimage(GLcontext *ctx,
dest_surf = pipe->get_tex_surface(pipe, pt,
face, level, destZ);
- (void) pipe_surface_map(dest_surf);
- (void) pipe_surface_map(src_surf);
-
/* buffer for one row */
data = (GLfloat *) malloc(width * 4 * sizeof(GLfloat));
/* do copy row by row */
for (row = 0; row < height; row++) {
- pipe->get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data);
+ pipe_get_tile_rgba(pipe, src_surf, srcX, srcY + row, width, 1, data);
/* XXX we're ignoring convolution for now */
if (ctx->_ImageTransferState) {
@@ -1080,14 +1078,10 @@ fallback_copy_texsubimage(GLcontext *ctx,
width, (GLfloat (*)[4])data);
}
- pipe->put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data);
+ pipe_put_tile_rgba(pipe, dest_surf, destX, destY, width, 1, data);
destY += yStep;
}
-
- (void) pipe_surface_unmap(dest_surf);
- (void) pipe_surface_unmap(src_surf);
-
free(data);
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 0f40f3ceee..5ae21c93f9 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -100,7 +100,7 @@ struct st_context
const struct cso_depth_stencil_alpha *depth_stencil;
const struct cso_rasterizer *rasterizer;
const struct cso_fragment_shader *fs;
- const struct cso_vertex_shader *vs;
+ struct st_vertex_program *vs;
struct pipe_blend_color blend_color;
struct pipe_clip_state clip;
diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c
index cffd66751d..57450e52bf 100644
--- a/src/mesa/state_tracker/st_debug.c
+++ b/src/mesa/state_tracker/st_debug.c
@@ -53,11 +53,11 @@ st_print_current(void)
int i;
printf("Vertex Transform Inputs:\n");
- for (i = 0; i < st->state.vs->state.num_inputs; i++) {
+ for (i = 0; i < st->state.vs->cso->state.num_inputs; i++) {
printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]);
}
- tgsi_dump( st->state.vs->state.tokens, 0 );
+ tgsi_dump( st->state.vs->cso->state.tokens, 0 );
if (st->vp->Base.Base.Parameters)
_mesa_print_parameter_list(st->vp->Base.Base.Parameters);
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 96db9e3c03..94b3a9531a 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -241,7 +241,7 @@ st_draw_vbo(GLcontext *ctx,
/* must get these after state validation! */
vp = ctx->st->vp;
- vs = &ctx->st->state.vs->state;
+ vs = &ctx->st->state.vs->cso->state;
/* loop over TGSI shader inputs to determine vertex buffer
* and attribute info
@@ -447,7 +447,7 @@ set_feedback_vertex_format(GLcontext *ctx)
else {
/* GL_FEEDBACK, or glRasterPos */
/* emit all attribs (pos, color, texcoord) as GLfloat[4] */
- vinfo.num_attribs = st->state.vs->state.num_outputs;
+ vinfo.num_attribs = st->state.vs->cso->state.num_outputs;
for (i = 0; i < vinfo.num_attribs; i++) {
vinfo.format[i] = FORMAT_4F;
vinfo.interp_mode[i] = INTERP_LINEAR;
@@ -491,7 +491,11 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* must get these after state validation! */
vp = ctx->st->vp;
- vs = &ctx->st->state.vs->state;
+ vs = &ctx->st->state.vs->cso->state;
+
+ if (!st->state.vs->draw_shader) {
+ st->state.vs->draw_shader = draw_create_vertex_shader(draw, vs);
+ }
/*
* Set up the draw module's state.
@@ -503,7 +507,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
draw_set_viewport_state(draw, &st->state.viewport);
draw_set_clip_state(draw, &st->state.clip);
draw_set_rasterizer_state(draw, &st->state.rasterizer->state);
- draw_bind_vertex_shader(draw, st->state.vs->data);
+ draw_bind_vertex_shader(draw, st->state.vs->draw_shader);
set_feedback_vertex_format(ctx);
/* loop over TGSI shader inputs to determine vertex buffer
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 1852228b29..1f1e6500e0 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -57,7 +57,7 @@
* \param tokensOut destination for TGSI tokens
* \return pointer to cached pipe_shader object.
*/
-const struct cso_vertex_shader *
+void
st_translate_vertex_program(struct st_context *st,
struct st_vertex_program *stvp,
const GLuint outputMapping[],
@@ -256,12 +256,10 @@ st_translate_vertex_program(struct st_context *st,
vs.tokens = tokensOut;
cso = st_cached_vs_state(st, &vs);
- stvp->vs = cso;
+ stvp->cso = cso;
if (TGSI_DEBUG)
tgsi_dump( tokensOut, 0 );
-
- return cso;
}
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 049f9f659f..de02c3185f 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -90,7 +90,10 @@ struct st_vertex_program
struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
/** Pointer to the corresponding cached shader */
- const struct cso_vertex_shader *vs;
+ const struct cso_vertex_shader *cso;
+
+ /** For using our private draw module (glRasterPos) */
+ struct draw_vertex_shader *draw_shader;
GLuint param_state;
};
@@ -122,7 +125,7 @@ st_translate_fragment_program(struct st_context *st,
GLuint maxTokens);
-extern const struct cso_vertex_shader *
+extern void
st_translate_vertex_program(struct st_context *st,
struct st_vertex_program *vp,
const GLuint vert_output_to_slot[],
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index c7d28eeca2..a2bdf846ca 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -61,8 +61,8 @@ target_to_target(GLenum target)
struct pipe_texture *
st_texture_create(struct st_context *st,
- unsigned target,
- unsigned format,
+ enum pipe_texture_target target,
+ enum pipe_format format,
GLuint first_level,
GLuint last_level,
GLuint width0,
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 7524c219e0..d8b1bcad9d 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -37,8 +37,8 @@ struct pipe_texture;
extern struct pipe_texture *
st_texture_create(struct st_context *st,
- unsigned target,
- unsigned format,
+ enum pipe_texture_target target,
+ enum pipe_format format,
GLuint first_level,
GLuint last_level,
GLuint width0,