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.tags/mesa_20090313
@@ -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; |
@@ -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: |
@@ -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); |
@@ -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; |
@@ -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; |
@@ -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); | |||
@@ -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 |
@@ -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; | |||
} | |||
@@ -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[], |