[Mesa-dev] [RFC PATCH 16/56] mesa/program: Add misc tessellation shader support.
Chris Forbes
chrisf at ijw.co.nz
Sat Sep 20 18:40:56 PDT 2014
From: Fabian Bieler <fabianbieler at fastmail.fm>
---
src/mesa/program/program.c | 44 ++++++++++++++++++++++++++++++++++
src/mesa/program/program.h | 60 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 103 insertions(+), 1 deletion(-)
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index dc030b0..d7c457a 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -101,6 +101,14 @@ _mesa_init_program(struct gl_context *ctx)
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current,
NULL);
+ ctx->TessCtrlProgram.Enabled = GL_FALSE;
+ _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram.Current,
+ NULL);
+
+ ctx->TessEvalProgram.Enabled = GL_FALSE;
+ _mesa_reference_tesseprog(ctx, &ctx->TessEvalProgram.Current,
+ NULL);
+
/* XXX probably move this stuff */
ctx->ATIFragmentShader.Enabled = GL_FALSE;
ctx->ATIFragmentShader.Current = ctx->Shared->DefaultFragmentShader;
@@ -120,6 +128,8 @@ _mesa_free_program_data(struct gl_context *ctx)
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
_mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache);
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL);
+ _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram.Current, NULL);
+ _mesa_reference_tesseprog(ctx, &ctx->TessEvalProgram.Current, NULL);
/* XXX probably move this stuff */
if (ctx->ATIFragmentShader.Current) {
@@ -152,6 +162,12 @@ _mesa_update_default_objects_program(struct gl_context *ctx)
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current,
ctx->Shared->DefaultGeometryProgram);
+ _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram.Current,
+ ctx->Shared->DefaultTessCtrlProgram);
+
+ _mesa_reference_tesseprog(ctx, &ctx->TessEvalProgram.Current,
+ ctx->Shared->DefaultTessEvalProgram);
+
/* XXX probably move this stuff */
if (ctx->ATIFragmentShader.Current) {
ctx->ATIFragmentShader.Current->RefCount--;
@@ -373,6 +389,16 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
CALLOC_STRUCT(gl_geometry_program),
target, id);
break;
+ case GL_TESS_CONTROL_PROGRAM_NV:
+ prog = _mesa_init_tess_ctrl_program(ctx,
+ CALLOC_STRUCT(gl_tess_ctrl_program),
+ target, id);
+ break;
+ case GL_TESS_EVALUATION_PROGRAM_NV:
+ prog = _mesa_init_tess_eval_program(ctx,
+ CALLOC_STRUCT(gl_tess_eval_program),
+ target, id);
+ break;
case GL_COMPUTE_PROGRAM_NV:
prog = _mesa_init_compute_program(ctx,
CALLOC_STRUCT(gl_compute_program),
@@ -590,6 +616,24 @@ _mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog)
gpc->UsesStreams = gp->UsesStreams;
}
break;
+ case GL_TESS_CONTROL_PROGRAM_NV:
+ {
+ const struct gl_tess_ctrl_program *tcp = gl_tess_ctrl_program_const(prog);
+ struct gl_tess_ctrl_program *tcpc = gl_tess_ctrl_program(clone);
+ tcpc->VerticesOut = tcp->VerticesOut;
+ // XXX: tcpc->UsesBarrier = tcp->UseBarrier;
+ }
+ break;
+ case GL_TESS_EVALUATION_PROGRAM_NV:
+ {
+ const struct gl_tess_eval_program *tep = gl_tess_eval_program_const(prog);
+ struct gl_tess_eval_program *tepc = gl_tess_eval_program(clone);
+ tepc->PrimitiveMode = tep->PrimitiveMode;
+ tepc->Spacing = tep->Spacing;
+ tepc->VertexOrder = tep->VertexOrder;
+ tepc->PointMode = tep->PointMode;
+ }
+ break;
default:
_mesa_problem(NULL, "Unexpected target in _mesa_clone_program");
}
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index dd5198a..0216e62 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -148,6 +148,24 @@ _mesa_reference_geomprog(struct gl_context *ctx,
(struct gl_program *) prog);
}
+static inline void
+_mesa_reference_tesscprog(struct gl_context *ctx,
+ struct gl_tess_ctrl_program **ptr,
+ struct gl_tess_ctrl_program *prog)
+{
+ _mesa_reference_program(ctx, (struct gl_program **) ptr,
+ (struct gl_program *) prog);
+}
+
+static inline void
+_mesa_reference_tesseprog(struct gl_context *ctx,
+ struct gl_tess_eval_program **ptr,
+ struct gl_tess_eval_program *prog)
+{
+ _mesa_reference_program(ctx, (struct gl_program **) ptr,
+ (struct gl_program *) prog);
+}
+
extern struct gl_program *
_mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog);
@@ -158,6 +176,20 @@ _mesa_clone_vertex_program(struct gl_context *ctx,
return (struct gl_vertex_program *) _mesa_clone_program(ctx, &prog->Base);
}
+static inline struct gl_tess_ctrl_program *
+_mesa_clone_tess_ctrl_program(struct gl_context *ctx,
+ const struct gl_tess_ctrl_program *prog)
+{
+ return (struct gl_tess_ctrl_program *) _mesa_clone_program(ctx, &prog->Base);
+}
+
+static inline struct gl_tess_eval_program *
+_mesa_clone_tess_eval_program(struct gl_context *ctx,
+ const struct gl_tess_eval_program *prog)
+{
+ return (struct gl_tess_eval_program *) _mesa_clone_program(ctx, &prog->Base);
+}
+
static inline struct gl_geometry_program *
_mesa_clone_geometry_program(struct gl_context *ctx,
const struct gl_geometry_program *prog)
@@ -253,7 +285,7 @@ _mesa_shader_stage_to_program(unsigned stage)
}
-/* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */
+/* Cast wrappers from gl_program to gl_vertex/tess_control/tess_evaluation/geometry/fragment_program */
static inline struct gl_fragment_program *
gl_fragment_program(struct gl_program *prog)
@@ -294,6 +326,32 @@ gl_geometry_program_const(const struct gl_program *prog)
}
+static inline struct gl_tess_ctrl_program *
+gl_tess_ctrl_program(struct gl_program *prog)
+{
+ return (struct gl_tess_ctrl_program *) prog;
+}
+
+static inline const struct gl_tess_ctrl_program *
+gl_tess_ctrl_program_const(const struct gl_program *prog)
+{
+ return (const struct gl_tess_ctrl_program *) prog;
+}
+
+
+static inline struct gl_tess_eval_program *
+gl_tess_eval_program(struct gl_program *prog)
+{
+ return (struct gl_tess_eval_program *) prog;
+}
+
+static inline const struct gl_tess_eval_program *
+gl_tess_eval_program_const(const struct gl_program *prog)
+{
+ return (const struct gl_tess_eval_program *) prog;
+}
+
+
#ifdef __cplusplus
} /* extern "C" */
#endif
--
2.1.0
More information about the mesa-dev
mailing list