summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorChris Forbes <[email protected]>2014-09-21 12:37:47 +1200
committerMarek Olšák <[email protected]>2015-07-23 00:59:25 +0200
commit8e758c3a74a35f8ee6c5969d5bb5f788b4ef4337 (patch)
tree0e601b16fae0cb6ca6ae8ada815f680d895890a5 /src/mesa
parentfa602c208815c3e4d757072cadc00e617e30b933 (diff)
mesa: allow drawing of patch primitives
Cosmetic changes and fixes by Marek. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/api_validate.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 21ae07b9d50..13a7362ed17 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -127,6 +127,9 @@ _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode)
if (mode <= GL_TRIANGLE_STRIP_ADJACENCY)
return _mesa_has_geometry_shaders(ctx);
+ if (mode == GL_PATCHES)
+ return _mesa_has_tessellation(ctx);
+
return false;
}
@@ -136,6 +139,7 @@ _mesa_is_valid_prim_mode(struct gl_context *ctx, GLenum mode)
* etc? Also, do additional checking related to transformation feedback.
* Note: this function cannot be called during glNewList(GL_COMPILE) because
* this code depends on current transform feedback state.
+ * Also, do additional checking related to tessellation shaders.
*/
GLboolean
_mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
@@ -215,6 +219,36 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
}
}
+ /* From the OpenGL 4.0 (Core Profile) spec (section 2.12):
+ *
+ * "Tessellation operates only on patch primitives. If tessellation is
+ * active, any command that transfers vertices to the GL will
+ * generate an INVALID_OPERATION error if the primitive mode is not
+ * PATCHES.
+ * Patch primitives are not supported by pipeline stages below the
+ * tessellation evaluation shader. If there is no active program
+ * object or the active program object does not contain a tessellation
+ * evaluation shader, the error INVALID_OPERATION is generated by any
+ * command that transfers vertices to the GL if the primitive mode is
+ * PATCHES."
+ *
+ */
+ if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL] ||
+ ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL]) {
+ if (mode != GL_PATCHES) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "only GL_PATCHES valid with tessellation");
+ return GL_FALSE;
+ }
+ }
+ else {
+ if (mode == GL_PATCHES) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "GL_PATCHES only valid with tessellation");
+ return GL_FALSE;
+ }
+ }
+
/* From the GL_EXT_transform_feedback spec:
*
* "The error INVALID_OPERATION is generated if Begin, or any command
@@ -247,6 +281,17 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
pass = GL_FALSE;
}
}
+ else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
+ struct gl_shader_program *tes =
+ ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
+
+ if (tes->TessEval.PointMode)
+ pass = ctx->TransformFeedback.Mode == GL_POINTS;
+ else if (tes->TessEval.PrimitiveMode == GL_ISOLINES)
+ pass = ctx->TransformFeedback.Mode == GL_LINES;
+ else
+ pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
+ }
else {
switch (mode) {
case GL_POINTS: