#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"
/** 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 */
};
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;
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;
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;
}
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 */
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:
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: */
{
/* 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);
#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"
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;
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;
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);
/* 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
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;
/* 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.
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
* \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[],
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;
}
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;
};
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[],