From b36bc54d3ceff5f514f87cdce67164147c1dd04f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 25 Aug 2008 10:59:45 +0100 Subject: vbo: seed initial max_element value with a more likely candidate (cherry picked from commit 026e7731e549e0777c010348460fd48b3d75a843) --- src/mesa/vbo/vbo_exec_array.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 68c555ae8f..82f4db17d1 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -45,9 +45,9 @@ static void get_minmax_index( GLuint count, GLuint type, switch(type) { case GL_UNSIGNED_INT: { const GLuint *ui_indices = (const GLuint *)indices; - GLuint max_ui = ui_indices[0]; + GLuint max_ui = ui_indices[count-1]; GLuint min_ui = ui_indices[0]; - for (i = 1; i < count; i++) { + for (i = 0; i < count; i++) { if (ui_indices[i] > max_ui) max_ui = ui_indices[i]; if (ui_indices[i] < min_ui) min_ui = ui_indices[i]; } @@ -57,9 +57,9 @@ static void get_minmax_index( GLuint count, GLuint type, } case GL_UNSIGNED_SHORT: { const GLushort *us_indices = (const GLushort *)indices; - GLuint max_us = us_indices[0]; + GLuint max_us = us_indices[count-1]; GLuint min_us = us_indices[0]; - for (i = 1; i < count; i++) { + for (i = 0; i < count; i++) { if (us_indices[i] > max_us) max_us = us_indices[i]; if (us_indices[i] < min_us) min_us = us_indices[i]; } @@ -69,9 +69,9 @@ static void get_minmax_index( GLuint count, GLuint type, } case GL_UNSIGNED_BYTE: { const GLubyte *ub_indices = (const GLubyte *)indices; - GLuint max_ub = ub_indices[0]; + GLuint max_ub = ub_indices[count-1]; GLuint min_ub = ub_indices[0]; - for (i = 1; i < count; i++) { + for (i = 0; i < count; i++) { if (ub_indices[i] > max_ub) max_ub = ub_indices[i]; if (ub_indices[i] < min_ub) min_ub = ub_indices[i]; } -- cgit v1.2.3 From 6f765fbde42a4f729780aa39d2b0ed9d736dd5a8 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 17 Aug 2007 15:26:33 +0100 Subject: added vbo_use_buffer_objects() to specify that immediate mode data should be put into bufferobjects --- src/mesa/vbo/vbo.h | 3 +++ src/mesa/vbo/vbo_exec_api.c | 35 +++++++++++++++++++++++++++++++++++ src/mesa/vbo/vbo_exec_draw.c | 15 +++++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 04c59c05b2..4c51b44cda 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -114,4 +114,7 @@ void vbo_rebase_prims( GLcontext *ctx, vbo_draw_func draw ); +void vbo_use_buffer_objects(GLcontext *ctx); + + #endif diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index f249289599..5513ef9449 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -651,6 +651,41 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) } +/** + * Tell the VBO module to use a real OpenGL vertex buffer object to + * store accumulated immediate-mode vertex data. + * This replaces the malloced buffer which was created in + * vb_exec_vtx_init() below. + */ +void vbo_use_buffer_objects(GLcontext *ctx) +{ + struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + /* Any buffer name but 0 can be used here since this bufferobj won't + * go into the bufferobj hashtable. + */ + GLuint bufName = 0xaabbccdd; + GLenum target = GL_ARRAY_BUFFER_ARB; + GLenum access = GL_READ_WRITE_ARB; + GLenum usage = GL_STREAM_DRAW_ARB; + GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat); + + /* Make sure this func is only used once */ + assert(exec->vtx.bufferobj == ctx->Array.NullBufferObj); + if (exec->vtx.buffer_map) { + _mesa_align_free(exec->vtx.buffer_map); + } + + /* Allocate a real buffer object now */ + exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); + ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); + + /* and map it */ + exec->vtx.buffer_map + = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); +} + + + void vbo_exec_vtx_init( struct vbo_exec_context *exec ) { GLcontext *ctx = exec->ctx; diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 86155d220d..557a43bb87 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -182,13 +182,24 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) * arrays of floats. */ for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) { - GLuint src = map[attr]; + const GLuint src = map[attr]; if (exec->vtx.attrsz[src]) { /* override the default array set above */ exec->vtx.inputs[attr] = &arrays[attr]; - arrays[attr].Ptr = (void *)data; + if (exec->vtx.bufferobj->Name) { + /* a real buffer obj: Ptr is an offset, not a pointer*/ + int offset; + assert(exec->vtx.bufferobj->Pointer); /* buf should be mapped */ + offset = (GLbyte *) data - (GLbyte *) exec->vtx.bufferobj->Pointer; + assert(offset >= 0); + arrays[attr].Ptr = (void *) offset; + } + else { + /* Ptr into ordinary app memory */ + arrays[attr].Ptr = (void *) data; + } arrays[attr].Size = exec->vtx.attrsz[src]; arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat); arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat); -- cgit v1.2.3 From 33fef8be825ee8ec6abc0c2ffd9a3a967d84df88 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 18 Dec 2007 16:56:22 +0000 Subject: vbo: unmap and remap immediate vbo before/after each draw. Also use BufferData(NULL) to get fresh storage and avoid synchronous operation where we would have to flush and wait for the fence after each draw because of the map. This will chew through a whole load of buffer space on small draws, so it isn't a proper solution. Need to support a no-fence or append mapping mode to do this right, or use user buffers. --- src/mesa/vbo/vbo_exec_draw.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 557a43bb87..f497e9a5a5 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -233,8 +233,18 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) if (exec->vtx.copied.nr != exec->vtx.vert_count) { GLcontext *ctx = exec->ctx; + GLenum target = GL_ARRAY_BUFFER_ARB; + GLenum access = GL_READ_WRITE_ARB; + GLenum usage = GL_STREAM_DRAW_ARB; + GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat); + + /* Before the unmap (why?) + */ vbo_exec_bind_arrays( ctx ); + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); + exec->vtx.buffer_map = NULL; + vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, exec->vtx.prim, @@ -242,6 +252,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) NULL, 0, exec->vtx.vert_count - 1); + + /* Get new data: + */ + ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); + exec->vtx.buffer_map + = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); } } -- cgit v1.2.3 From 8e7d941d7a29aaf66f94892b3f97670c0e972c8c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 23 Sep 2008 21:08:50 -0700 Subject: mesa: fix main/ prefix in include --- src/mesa/glapi/glapi_getproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index 3634444c85..6d40b495c7 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -32,7 +32,7 @@ #include #include -#include "glheader.h" +#include "main/glheader.h" #include "glapi.h" #include "glapioffsets.h" #include "glapitable.h" -- cgit v1.2.3 From 19d77d6cfa384142cc6ab4d9b3db4b28cefb6f19 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 18 Sep 2007 19:29:26 -0600 Subject: temporarily set the FRAG_BIT_FOGC bit in InputsRead when fog is enabled (cherry picked from commit 63be96bdc7e9f388a5c49295bd7e150462fd003a) --- src/mesa/main/texenvprogram.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 5f7634b460..d471030f14 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -1100,6 +1100,7 @@ create_new_program(GLcontext *ctx, struct state_key *key, * a reduced value and not what is expected in FogOption */ p.program->FogOption = ctx->Fog.Mode; + p.program->Base.InputsRead |= FRAG_BIT_FOGC; /* XXX new */ } else p.program->FogOption = GL_NONE; -- cgit v1.2.3 From c81cce78313a62e0d36a5c80bd9d35b770d0814a Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 25 Sep 2007 15:18:51 -0600 Subject: Disable vertex shader fog, compute fog in fragment shader. --- src/mesa/main/texenvprogram.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index d471030f14..7387f4fb2f 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -1116,15 +1116,21 @@ create_new_program(GLcontext *ctx, struct state_key *key, ASSERT(p.program->Base.NumInstructions <= MAX_INSTRUCTIONS); /* Allocate final instruction array */ - program->Base.Instructions - = _mesa_alloc_instructions(program->Base.NumInstructions); - if (!program->Base.Instructions) { + p.program->Base.Instructions + = _mesa_alloc_instructions(p.program->Base.NumInstructions); + if (!p.program->Base.Instructions) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating tex env program"); return; } - _mesa_copy_instructions(program->Base.Instructions, instBuffer, - program->Base.NumInstructions); + _mesa_copy_instructions(p.program->Base.Instructions, instBuffer, + p.program->Base.NumInstructions); + + if (p.program->FogOption) { + _mesa_append_fog_code(ctx, p.program); + p.program->FogOption = GL_NONE; + } + /* Notify driver the fragment program has (actually) changed. */ -- cgit v1.2.3 From fb3c41f5044bc0e228470ebf9f2cfdf2c53f191f Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 25 Sep 2007 15:20:04 -0600 Subject: include programopt.h (cherry picked from commit 83fad68ec1989c719646a76f4cc5e0b3d23537ed) --- src/mesa/main/texenvprogram.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 7387f4fb2f..817071d4e8 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -34,6 +34,7 @@ #include "shader/prog_instruction.h" #include "shader/prog_print.h" #include "shader/prog_statevars.h" +#include "shader/programopt.h" #include "texenvprogram.h" -- cgit v1.2.3 From 93fef22d05d0fb6f011d48d2fde533555c1695a2 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 29 Oct 2007 12:25:46 -0600 Subject: Remove ctx field from texenvprog_cache --- src/mesa/main/texenvprogram.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index 817071d4e8..d360fa35c0 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -413,9 +413,9 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p ) } -static void release_temps( struct texenv_fragment_program *p ) +static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p ) { - GLuint max_temp = p->ctx->Const.FragmentProgram.MaxTemps; + GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps; /* KW: To support tex_env_crossbar, don't release the registers in * temps_output. @@ -1053,7 +1053,7 @@ create_new_program(GLcontext *ctx, struct state_key *key, p.one = undef; p.last_tex_stage = 0; - release_temps(&p); + release_temps(ctx, &p); if (key->enabled_units) { /* First pass - to support texture_env_crossbar, first identify @@ -1071,7 +1071,7 @@ create_new_program(GLcontext *ctx, struct state_key *key, for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) if (key->enabled_units & (1< Date: Fri, 14 Dec 2007 11:16:49 -0700 Subject: set program->SamplersUsed bit when using a texture instruction --- src/mesa/main/texenvprogram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index d360fa35c0..be0b69b199 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -955,7 +955,10 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit ) unit, dim, texcoord ); if (p->state->unit[unit].shadow) p->program->Base.ShadowSamplers |= 1 << unit; - } else + + p->program->Base.SamplersUsed |= (1 << unit); + } + else p->src_texture[unit] = get_zero(p); } } -- cgit v1.2.3 From dff0b0e772185c359a1ad50afc7d5680745b1b1b Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 18 Jan 2008 12:45:27 -0700 Subject: use PROGRAM_CONSTANT instead of PROGRAM_STATE_VAR when generating immediates/literals (cherry picked from commit fdc8636bdc65deb0d95a62a51c8d9bca05bc6bb8) --- src/mesa/main/texenvprogram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index be0b69b199..bcf9102224 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -595,7 +595,7 @@ static struct ureg register_const4f( struct texenv_fragment_program *p, idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4, &swizzle ); ASSERT(swizzle == SWIZZLE_NOOP); - return make_ureg(PROGRAM_STATE_VAR, idx); + return make_ureg(PROGRAM_CONSTANT, idx); } #define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) -- cgit v1.2.3 From 1fe385fdc96688a5249d52184f457910a0c25488 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 14 Dec 2007 11:42:28 -0700 Subject: set SamplerUnit[] entry in load_texture() just to be safe (cherry picked from commit fce4612f8a29ee1798c9326a431a139d856c7a04) --- src/mesa/main/texenvprogram.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index bcf9102224..dcd7f90567 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -957,6 +957,10 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit ) p->program->Base.ShadowSamplers |= 1 << unit; p->program->Base.SamplersUsed |= (1 << unit); + /* This identity mapping should already be in place + * (see _mesa_init_program_struct()) but let's be safe. + */ + p->program->Base.SamplerUnits[unit] = unit; } else p->src_texture[unit] = get_zero(p); -- cgit v1.2.3 From c5945c2d173b77ace00e6fc225097a6afddecfa3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 24 Sep 2008 15:10:45 -0700 Subject: intel: Fix clears to depth_stencil texture attachments. Broken by 0adfd1021035e90995a25ec5f20b736e55075d92, showed up as an assertion failure in a software fallback in the shadowtex demo when we failed to recognize the texture format. --- src/mesa/drivers/dri/intel/intel_fbo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 3677dd41d9..fce5e36b9d 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -540,7 +540,7 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb, irb->Base._ActualFormat = GL_DEPTH_COMPONENT16; irb->Base._BaseFormat = GL_DEPTH_COMPONENT; DBG("Render to DEPTH16 texture OK\n"); - } else if (texImage->TexFormat == &_mesa_texformat_z24_s8) { + } else if (texImage->TexFormat == &_mesa_texformat_s8_z24) { irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT; irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT; DBG("Render to DEPTH_STENCIL texture OK\n"); -- cgit v1.2.3 From 831bfb9053a6e1f065fc07f9f25ae0ea27053733 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 23 Sep 2008 17:56:19 +0200 Subject: i965: more meaningful message for unsupported opcodes. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 5 ++++- src/mesa/drivers/dri/i965/brw_wm_emit.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 8759826e83..b0b0449f99 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1155,7 +1155,10 @@ void brw_vs_emit(struct brw_vs_compile *c ) case OPCODE_ENDSUB: break; default: - _mesa_printf("Unsupport opcode %d in vertex shader\n", inst->Opcode); + _mesa_printf("Unsupported opcode %i (%s) in vertex shader\n", + inst->Opcode, inst->Opcode < MAX_OPCODE ? + _mesa_opcode_string(inst->Opcode) : + "unknown"); break; } diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index f1c14c98f9..58c78c4b2c 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -1302,8 +1302,10 @@ void brw_wm_emit( struct brw_wm_compile *c ) break; default: - _mesa_printf("unsupport opcode %d in fragment program\n", - inst->opcode); + _mesa_printf("Unsupported opcode %i (%s) in fragment shader\n", + inst->opcode, inst->opcode < MAX_OPCODE ? + _mesa_opcode_string(inst->opcode) : + "unknown"); } for (i = 0; i < 4; i++) -- cgit v1.2.3 From 561787e69759ed757edb897c027d2d94beac8d11 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 25 Sep 2008 10:49:05 +0200 Subject: i965: support for sin() and cos() in vertex shaders. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index b0b0449f99..9de05408ba 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1024,6 +1024,9 @@ void brw_vs_emit(struct brw_vs_compile *c ) case OPCODE_ADD: brw_ADD(p, dst, args[0], args[1]); break; + case OPCODE_COS: + emit_math1(c, BRW_MATH_FUNCTION_COS, dst, args[0], BRW_MATH_PRECISION_FULL); + break; case OPCODE_DP3: brw_DP3(p, dst, args[0], args[1]); break; @@ -1089,6 +1092,9 @@ void brw_vs_emit(struct brw_vs_compile *c ) case OPCODE_SEQ: emit_seq(p, dst, args[0], args[1]); break; + case OPCODE_SIN: + emit_math1(c, BRW_MATH_FUNCTION_SIN, dst, args[0], BRW_MATH_PRECISION_FULL); + break; case OPCODE_SNE: emit_sne(p, dst, args[0], args[1]); break; -- cgit v1.2.3 From 7be5411ce69f0f6be1f31079b9fbdea4967358a0 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 25 Sep 2008 14:56:41 +0200 Subject: mesa: prevent the slang code generator from aborting when faced with a sampler variable redeclaration. --- src/mesa/shader/slang/slang_codegen.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 7006e86958..72a3c0ef9e 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2439,7 +2439,11 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var) /*assert(!var->declared);*/ var->declared = GL_TRUE; - assert(!is_sampler_type(&var->type)); + if(is_sampler_type(&var->type)) { + slang_info_log_error(A->log, "redeclaration of sampler '%s'", + (char*) var->a_name); + return NULL; + } n = new_node0(IR_VAR_DECL); if (n) { -- cgit v1.2.3 From 507ef82077891a7b833c1c3e82c61299cf281ee8 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 25 Sep 2008 09:58:27 -0600 Subject: mesa: fix function params to match prototypes --- src/mesa/shader/grammar/grammar_crt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/shader/grammar/grammar_crt.c b/src/mesa/shader/grammar/grammar_crt.c index bdf2da9b2e..d2c95d1c8e 100644 --- a/src/mesa/shader/grammar/grammar_crt.c +++ b/src/mesa/shader/grammar/grammar_crt.c @@ -10,17 +10,17 @@ void grammar_alloc_free (void *ptr) free (ptr); } -void *grammar_alloc_malloc (unsigned int size) +void *grammar_alloc_malloc (size_t size) { return malloc (size); } -void *grammar_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size) +void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size) { return realloc (ptr, size); } -void *grammar_memory_copy (void *dst, const void * src, unsigned int size) +void *grammar_memory_copy (void *dst, const void * src, size_t size) { return memcpy (dst, src, size); } @@ -30,7 +30,7 @@ int grammar_string_compare (const byte *str1, const byte *str2) return strcmp ((const char *) str1, (const char *) str2); } -int grammar_string_compare_n (const byte *str1, const byte *str2, unsigned int n) +int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n) { return strncmp ((const char *) str1, (const char *) str2, n); } @@ -40,7 +40,7 @@ byte *grammar_string_copy (byte *dst, const byte *src) return (byte *) strcpy ((char *) dst, (const char *) src); } -byte *grammar_string_copy_n (byte *dst, const byte *src, unsigned int n) +byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n) { return (byte *) strncpy ((char *) dst, (const char *) src, n); } -- cgit v1.2.3 From 6222eb3fcd12147ea2e7ccc20a71a921cebbb0d2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 11:03:46 -0600 Subject: mesa: fix some VBO buffer object issues The VBO module may use a real VBO or a malloc'd buffer for vertex storage. Be careful not to accidentally replace the later with the former when drawing. Check if using a real VBO at destroy time to prevent a double-free. --- src/mesa/vbo/vbo_exec_api.c | 16 ++++++++++++---- src/mesa/vbo/vbo_exec_draw.c | 18 +++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 5513ef9449..d48f5230cb 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -699,8 +699,8 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) &exec->vtx.bufferobj, ctx->Array.NullBufferObj); + ASSERT(!exec->vtx.buffer_map); exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64); - vbo_exec_vtxfmt_init( exec ); /* Hook our functions into the dispatch table. @@ -725,9 +725,17 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) { - if (exec->vtx.buffer_map) { - ALIGN_FREE(exec->vtx.buffer_map); - exec->vtx.buffer_map = NULL; + if (exec->vtx.bufferobj->Name) { + /* using a real VBO for vertex data */ + GLcontext *ctx = exec->ctx; + _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); + } + else { + /* just using malloc'd space for vertex data */ + if (exec->vtx.buffer_map) { + ALIGN_FREE(exec->vtx.buffer_map); + exec->vtx.buffer_map = NULL; + } } } diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index f497e9a5a5..92356ba977 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -242,8 +242,11 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) */ vbo_exec_bind_arrays( ctx ); - ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); - exec->vtx.buffer_map = NULL; + /* if using a real VBO, unmap it before drawing */ + if (exec->vtx.bufferobj->Name) { + ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj); + exec->vtx.buffer_map = NULL; + } vbo_context(ctx)->draw_prims( ctx, exec->vtx.inputs, @@ -253,11 +256,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec ) 0, exec->vtx.vert_count - 1); - /* Get new data: - */ - ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); - exec->vtx.buffer_map - = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + /* If using a real VBO, get new storage */ + if (exec->vtx.bufferobj->Name) { + ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); + exec->vtx.buffer_map = + ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj); + } } } -- cgit v1.2.3 From 8124faf89d638285d8e9aa93adc3ca7f4ee729f3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 11:54:00 -0600 Subject: mesa: fix float->int mapping for glGetIntegerv(GL_DEPTH_CLEAR_VALUE) --- src/mesa/main/get.c | 4 ++-- src/mesa/main/get_gen.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 5202c3ddac..e87eea91dd 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -2137,7 +2137,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = (GLfloat)(ctx->DrawBuffer->Visual.depthBits); break; case GL_DEPTH_CLEAR_VALUE: - params[0] = (GLfloat)ctx->Depth.Clear; + params[0] = ctx->Depth.Clear; break; case GL_DEPTH_FUNC: params[0] = ENUM_TO_FLOAT(ctx->Depth.Func); @@ -3985,7 +3985,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ctx->DrawBuffer->Visual.depthBits; break; case GL_DEPTH_CLEAR_VALUE: - params[0] = IROUND(ctx->Depth.Clear); + params[0] = FLOAT_TO_INT(ctx->Depth.Clear); break; case GL_DEPTH_FUNC: params[0] = ENUM_TO_INT(ctx->Depth.Func); diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index decc9dd52a..dc543eb003 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -179,7 +179,7 @@ StateVars = [ ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", None ), ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"], "", None ), - ( "GL_DEPTH_CLEAR_VALUE", GLfloat, ["ctx->Depth.Clear"], "", None ), + ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["ctx->Depth.Clear"], "", None ), ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ), ( "GL_DEPTH_RANGE", GLfloatN, [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ), -- cgit v1.2.3 From b3c3bc63f0f008100c002e0183b927b8381d5498 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Sep 2008 18:55:52 -0600 Subject: mesa: fix typo (s/feadback/feedback/). Fixes broken selection/feedback. --- src/mesa/main/api_exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c index 8ebe4a3e4a..0c3c9c4de4 100644 --- a/src/mesa/main/api_exec.c +++ b/src/mesa/main/api_exec.c @@ -74,7 +74,7 @@ #include "eval.h" #endif #include "get.h" -#if FEATURE_feadback +#if FEATURE_feedback #include "feedback.h" #endif #include "fog.h" @@ -222,7 +222,7 @@ _mesa_init_exec_table(struct _glapi_table *exec) SET_CopyPixels(exec, _mesa_CopyPixels); SET_DrawPixels(exec, _mesa_DrawPixels); #endif -#if FEATURE_feadback +#if FEATURE_feedback SET_InitNames(exec, _mesa_InitNames); SET_FeedbackBuffer(exec, _mesa_FeedbackBuffer); SET_LoadName(exec, _mesa_LoadName); -- cgit v1.2.3 From 1e3a44fab068f00378613456036716d0c3772969 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 25 Sep 2008 19:57:34 -0600 Subject: mesa: fix cast/conversion for optional code --- src/mesa/main/get.c | 4 ++-- src/mesa/main/get_gen.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index e87eea91dd..f72aa6a288 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1092,7 +1092,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); ASSERT(n <= 100); for (i = 0; i < n; i++) - params[i] = ENUM_TO_INT(formats[i]); + params[i] = ENUM_TO_BOOLEAN(formats[i]); } break; case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: @@ -2940,7 +2940,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); ASSERT(n <= 100); for (i = 0; i < n; i++) - params[i] = (GLfloat)(ENUM_TO_INT(formats[i])); + params[i] = ENUM_TO_FLOAT(formats[i]); } break; case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT: diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py index dc543eb003..152e378b4f 100644 --- a/src/mesa/main/get_gen.py +++ b/src/mesa/main/get_gen.py @@ -50,7 +50,8 @@ TypeStrings = { # - the GL state name, such as GL_CURRENT_COLOR # - the state datatype, one of GLint, GLfloat, GLboolean or GLenum # - list of code fragments to get the state, such as ["ctx->Foo.Bar"] -# - optional extra code or empty string +# - optional extra code or empty string. If present, "CONVERSION" will be +# replaced by ENUM_TO_FLOAT, INT_TO_FLOAT, etc. # - optional extensions to check, or None # StateVars = [ @@ -532,7 +533,7 @@ StateVars = [ GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); ASSERT(n <= 100); for (i = 0; i < n; i++) - params[i] = ENUM_TO_INT(formats[i]);""", + params[i] = CONVERSION(formats[i]);""", ["ARB_texture_compression"] ), # GL_EXT_compiled_vertex_array @@ -1083,10 +1084,11 @@ def EmitGetFunction(stateVars, returnType): assert len(extensions) == 4 print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' % (extensions[0], extensions[1], extensions[2], extensions[3], function)) + conversion = ConversionFunc(varType, returnType) if optionalCode: + optionalCode = string.replace(optionalCode, "CONVERSION", conversion); print " {" print " " + optionalCode - conversion = ConversionFunc(varType, returnType) n = len(state) for i in range(n): if conversion: -- cgit v1.2.3