Not sure the generated program looks correct though...
GLuint nr;
};
+
struct pipe_fs_state {
- struct gl_fragment_program *fp;
+ GLuint inputs_read; /* FRAG_ATTRIB_* */
+ const struct tgsi_token *tokens;
+
};
struct pipe_constant_buffer {
#include "main/glheader.h"
#include "main/macros.h"
#include "main/enums.h"
-#include "shader/program.h"
#include "vf/vf.h"
#include "pipe/draw/draw_context.h"
*/
static void calculate_vertex_layout( struct softpipe_context *softpipe )
{
- struct gl_fragment_program *fp = softpipe->fs.fp;
- const GLuint inputsRead = fp->Base.InputsRead;
+ const GLuint inputsRead = softpipe->fs.inputs_read;
GLuint slot_to_vf_attr[VF_ATTRIB_MAX];
GLbitfield attr_mask = 0x0;
GLuint i;
GLuint deflt = !(flags & TGSI_DUMP_NO_DEFAULT);
{
+#if 0
static GLuint counter = 0;
char buffer[64];
sprintf( buffer, "sbir-dump-%.4u.txt", counter++ );
dump.file = fopen( buffer, "wt" );
+#else
+ dump.file = stderr;
dump.tabs = 0;
+#endif
}
tgsi_parse_init( &parse, tokens );
extern "C" {\r
#endif // defined __cplusplus\r
\r
+struct tgsi_token;\r
+\r
GLboolean\r
tgsi_mesa_compile_fp_program(\r
const struct gl_fragment_program *program,\r
state_tracker/st_atom_clip.c \
state_tracker/st_atom_depth.c \
state_tracker/st_atom_fs.c \
+ state_tracker/st_atom_vs.c \
state_tracker/st_atom_framebuffer.c \
state_tracker/st_atom_sampler.c \
state_tracker/st_atom_scissor.c \
&st_update_clear_color,
&st_update_depth,
&st_update_clip,
+ &st_update_vs,
&st_update_fs,
&st_update_setup,
&st_update_polygon_stipple,
const struct st_tracked_state st_update_clear_color;
const struct st_tracked_state st_update_depth;
const struct st_tracked_state st_update_fs;
+const struct st_tracked_state st_update_vs;
const struct st_tracked_state st_update_setup;
const struct st_tracked_state st_update_polygon_stipple;
const struct st_tracked_state st_update_viewport;
#include "st_context.h"
#include "pipe/p_context.h"
#include "st_atom.h"
+#include "st_program.h"
+#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
+#include "pipe/tgsi/core/tgsi_dump.h"
+
+static void compile_fs( struct st_context *st,
+ struct st_fragment_program *fs )
+{
+ /* XXX: fix static allocation of tokens:
+ */
+ tgsi_mesa_compile_fp_program( &fs->Base, fs->tokens, ST_FP_MAX_TOKENS );
+
+ tgsi_dump( fs->tokens, TGSI_DUMP_VERBOSE );
+}
static void update_fs( struct st_context *st )
{
struct pipe_fs_state fs;
+ struct st_fragment_program *fp = st_fragment_program(st->ctx->FragmentProgram._Current);
+
+ memset( &fs, 0, sizeof(fs) );
- fs.fp = st->ctx->FragmentProgram._Current;
+ if (fp->dirty)
+ compile_fs( st, fp );
+
+ fs.inputs_read = fp->Base.Base.InputsRead;
+ fs.tokens = &fp->tokens[0];
- if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0) {
+ if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 ||
+ fp->dirty)
+ {
+ fp->dirty = 0;
st->state.fs = fs;
st->pipe->set_fs_state(st->pipe, &fs);
}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2003 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "st_context.h"
+#include "pipe/p_context.h"
+#include "st_atom.h"
+
+
+
+static void update_vs( struct st_context *st )
+{
+}
+
+
+const struct st_tracked_state st_update_vs = {
+ .dirty = {
+ .mesa = 0,
+ .st = ST_NEW_VERTEX_PROGRAM,
+ },
+ .update = update_vs
+};
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
+ st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
break;
case GL_FRAGMENT_PROGRAM_ARB:
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
struct st_context *st = st_context(ctx);
switch (target) {
- case GL_VERTEX_PROGRAM_ARB:
- return _mesa_init_vertex_program(ctx,
- CALLOC_STRUCT(gl_vertex_program),
- target,
- id);
+ case GL_VERTEX_PROGRAM_ARB: {
+ struct st_vertex_program *prog = CALLOC_STRUCT(st_vertex_program);
+
+ prog->id = st->program_id++;
+ prog->dirty = 1;
+
+ return _mesa_init_vertex_program( ctx,
+ &prog->Base,
+ target,
+ id );
+ }
case GL_FRAGMENT_PROGRAM_ARB: {
struct st_fragment_program *prog = CALLOC_STRUCT(st_fragment_program);
prog->id = st->program_id++;
+ prog->dirty = 1;
return _mesa_init_fragment_program( ctx,
&prog->Base,
GLenum target,
struct gl_program *prog )
{
- if (target == GL_FRAGMENT_PROGRAM_ARB) {
- struct st_context *st = st_context(ctx);
+ struct st_context *st = st_context(ctx);
- if (prog == &st->ctx->FragmentProgram._Current->Base)
- {
- struct st_fragment_program *p =
- (struct st_fragment_program *) prog;
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct st_fragment_program *p = (struct st_fragment_program *)prog;
+ if (prog == &ctx->FragmentProgram._Current->Base)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
- p->id = st->program_id++;
-#if 0
- p->param_state = p->Base.Base.Parameters->StateFlags;
- p->translated = 0;
-#endif
-
- /* Gack! do this in the compiler:
- */
- if (p->Base.FogOption) {
- /* add extra instructions to do fog, then turn off FogOption field */
- _mesa_append_fog_code(ctx, &p->Base);
- p->Base.FogOption = GL_NONE;
- }
-
- /* XXX: Not hooked-up yet. */
- {
- struct tgsi_token tokens[1024];
-
- tgsi_mesa_compile_fp_program( prog, tokens, 1024 );
- tgsi_dump( tokens, TGSI_DUMP_VERBOSE );
- }
- }
+ p->id = st->program_id++;
+ p->param_state = p->Base.Base.Parameters->StateFlags;
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
+ struct st_vertex_program *p = (struct st_vertex_program *)prog;
+
+ if (prog == &ctx->VertexProgram._Current->Base)
+ st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
+
+ p->id = st->program_id++;
+ p->param_state = p->Base.Base.Parameters->StateFlags;
/* Also tell tnl about it:
*/
#define ST_NEW_MESA 0x1 /* Mesa state has changed */
#define ST_NEW_FRAGMENT_PROGRAM 0x2
+#define ST_NEW_VERTEX_PROGRAM 0x4
struct st_state_flags {
GLuint mesa;
#ifndef ST_PROGRAM_H
#define ST_PROGRAM_H
+#include "mtypes.h"
+#include "pipe/tgsi/core/tgsi_token.h"
+
+#define ST_FP_MAX_TOKENS 1024
+
+
struct st_fragment_program
{
struct gl_fragment_program Base;
* ProgramStringNotify changes.
*/
+
+ struct tgsi_token tokens[ST_FP_MAX_TOKENS];
+ GLboolean dirty;
+
+
#if 0
GLfloat (*cbuffer)[4];
GLuint nr_constants;
const GLfloat *values; /* Pointer to tracked values */
} *param;
GLuint nr_params;
+#endif
GLuint param_state;
-#endif
};
+struct st_vertex_program
+{
+ struct gl_vertex_program Base;
+ GLboolean error; /* If program is malformed for any reason. */
+
+ GLuint id; /* String id, for tracking
+ * ProgramStringNotify changes.
+ */
+
+ GLboolean dirty;
+ GLuint param_state;
+};
+
void st_init_cb_program( struct st_context *st );
void st_destroy_cb_program( struct st_context *st );
+static inline struct st_fragment_program *
+st_fragment_program( struct gl_fragment_program *fp )
+{
+ return (struct st_fragment_program *)fp;
+}
+
+static inline struct st_vertex_program *
+st_vertex_program( struct gl_vertex_program *vp )
+{
+ return (struct st_vertex_program *)vp;
+}
+
#endif