summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_vertex_sse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl/t_vertex_sse.c')
-rw-r--r--src/mesa/tnl/t_vertex_sse.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mesa/tnl/t_vertex_sse.c b/src/mesa/tnl/t_vertex_sse.c
index 96def25206..53a6e55f4b 100644
--- a/src/mesa/tnl/t_vertex_sse.c
+++ b/src/mesa/tnl/t_vertex_sse.c
@@ -39,6 +39,12 @@
#include "x86/common_x86_asm.h"
+/**
+ * Number of bytes to allocate for generated SSE functions
+ */
+#define MAX_SSE_CODE_SIZE 1024
+
+
#define X 0
#define Y 1
#define Z 2
@@ -619,7 +625,10 @@ static GLboolean build_vertex_emit( struct x86_program *p )
x86_pop(&p->func, countEBP);
x86_ret(&p->func);
+ assert(!vtx->emit);
vtx->emit = (tnl_emit_func)x86_get_func(&p->func);
+
+ assert( (char *) p->func.csr - (char *) p->func.store <= MAX_SSE_CODE_SIZE );
return GL_TRUE;
}
@@ -644,7 +653,10 @@ void _tnl_generate_sse_emit( GLcontext *ctx )
p.identity = x86_make_reg(file_XMM, 6);
p.chan0 = x86_make_reg(file_XMM, 7);
- x86_init_func(&p.func);
+ if (!x86_init_func_size(&p.func, MAX_SSE_CODE_SIZE)) {
+ vtx->emit = NULL;
+ return;
+ }
if (build_vertex_emit(&p)) {
_tnl_register_fastpath( vtx, GL_TRUE );