[Mesa-dev] [RFC PATCH 05/56] mesa/main: Add tessellation shader state and limits
Chris Forbes
chrisf at ijw.co.nz
Sat Sep 20 18:40:45 PDT 2014
---
src/mesa/main/config.h | 8 ++++++++
src/mesa/main/context.c | 10 ++++++++++
src/mesa/main/mtypes.h | 9 +++++++++
src/mesa/main/shaderapi.c | 7 +++++++
4 files changed, 34 insertions(+)
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 4ec4b75..c0b5914 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -300,6 +300,14 @@
#define MAX_COMPUTE_IMAGE_UNIFORMS 8
/*@}*/
+/** For GL_ARB_tessellation_shader */
+/*@{*/
+#define MAX_TESS_GEN_LEVEL 64
+#define MAX_PATCH_VERTICES 32
+#define MAX_TESS_PATCH_COMPONENTS 120
+#define MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 4096
+/*@}*/
+
/*
* Color channel component order
*
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 682b9c7..d9be2f5 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -493,6 +493,8 @@ init_program_limits(struct gl_constants *consts, gl_shader_stage stage,
prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */
prog->MaxOutputComponents = 0; /* value not used */
break;
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
prog->MaxAttribs = MAX_VERTEX_GENERIC_ATTRIBS;
@@ -723,6 +725,14 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
/** GL_ARB_gpu_shader5 */
consts->MinFragmentInterpolationOffset = MIN_FRAGMENT_INTERPOLATION_OFFSET;
consts->MaxFragmentInterpolationOffset = MAX_FRAGMENT_INTERPOLATION_OFFSET;
+
+ /** GL_ARB_tessellation_shader */
+ consts->MaxTessGenLevel = MAX_TESS_GEN_LEVEL;
+ consts->MaxPatchVertices = MAX_PATCH_VERTICES;
+ consts->Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->Program[MESA_SHADER_TESS_EVAL].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ consts->MaxTessPatchComponents = MAX_TESS_PATCH_COMPONENTS;
+ consts->MaxTessControlTotalOutputComponents = MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 23cb98d..9e989d7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3486,6 +3486,9 @@ struct gl_program_constants
/* GL_ARB_shader_image_load_store */
GLuint MaxImageUniforms;
+
+ /* GL_ARB_tessellation_shader */
+ GLuint MaxPatchVertices;
};
@@ -3747,6 +3750,12 @@ struct gl_constants
GLboolean FakeSWMSAA;
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
+
+ /** GL_ARB_tessellation_shader */
+ GLuint MaxPatchVertices;
+ GLuint MaxTessGenLevel;
+ GLuint MaxTessPatchComponents;
+ GLuint MaxTessControlTotalOutputComponents;
};
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 79d2e94..c11ad4f 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -105,6 +105,7 @@ _mesa_get_shader_flags(void)
void
_mesa_init_shader_state(struct gl_context *ctx)
{
+ int i;
/* Device drivers may override these to control what kind of instructions
* are generated by the GLSL compiler.
*/
@@ -126,6 +127,12 @@ _mesa_init_shader_state(struct gl_context *ctx)
/* Extended for ARB_separate_shader_objects */
ctx->Shader.RefCount = 1;
mtx_init(&ctx->Shader.Mutex, mtx_plain);
+
+ ctx->TessCtrlProgram.patch_vertices = 3;
+ for (i = 0; i < 4; ++i)
+ ctx->TessCtrlProgram.patch_default_outer_level[i] = 1.0;
+ for (i = 0; i < 2; ++i)
+ ctx->TessCtrlProgram.patch_default_inner_level[i] = 1.0;
}
--
2.1.0
More information about the mesa-dev
mailing list