summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-01-14 19:12:46 -0700
committerBrian <[email protected]>2008-01-14 19:13:34 -0700
commitac95fee4fffee77bb7bd798d094ed2e3a7c4019b (patch)
treedb6569f204ba1414d11c7bf4be8b47dafb7c2b0c
parentb4e4fafb4157d416077e985c03204ed5bbe0f2e1 (diff)
Fix problems with vertex shaders and the private draw module.
The CSO returned by pipe->create_vs_state() can't be passed to the private draw module. That was causing glRasterPos to blow up. Add a 'draw_shader' field to st_vertex_program for use with the private draw module. Change st_context->state.vs type from cso_vertex_shader to st_vertex_program.
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c23
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c6
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c4
-rw-r--r--src/mesa/state_tracker/st_cb_program.c11
-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
9 files changed, 43 insertions, 32 deletions
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 2a182c7d9c4..1ed9333556e 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_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 40319f4b4b8..758d4a40868 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 be5434f91b6..f4d6b9362c7 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -662,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: */
{
@@ -719,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);
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index aed6b1ee97d..63a954264e3 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -39,6 +39,8 @@
#include "shader/programopt.h"
#include "shader/shader_api.h"
+#include "pipe/cso_cache/cso_cache.h"
+
#include "st_context.h"
#include "st_program.h"
#include "st_atom_shader.h"
@@ -181,10 +183,11 @@ 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;
}
stvp->param_state = stvp->Base.Base.Parameters->StateFlags;
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 0f40f3ceee9..5ae21c93f93 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 cffd66751de..57450e52bf4 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 96db9e3c03b..94b3a9531a8 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 1852228b29b..1f1e6500e09 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 049f9f659fa..de02c3185fd 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[],