From 10bd931949d8dd3c63fe8bcc00899875d7dde105 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 01:50:08 -0800 Subject: glsl: Remove unnecessary header from slang_log.c. --- src/mesa/shader/slang/slang_log.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_log.c b/src/mesa/shader/slang/slang_log.c index d7d2b4fbfd0..4f6b8541c5a 100644 --- a/src/mesa/shader/slang/slang_log.c +++ b/src/mesa/shader/slang/slang_log.c @@ -24,7 +24,6 @@ */ #include "main/imports.h" -#include "main/context.h" #include "slang_log.h" #include "slang_utility.h" -- cgit v1.2.3 From 1d3bdc20908f860316e0bfeaa54dc8fa6d344d0c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 02:02:49 -0800 Subject: glsl: Remove unnecessary header from slang_link.c. --- src/mesa/shader/slang/slang_link.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 0a2bc497803..e9f1ee44ced 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -31,7 +31,6 @@ #include "main/imports.h" #include "main/context.h" -#include "main/hash.h" #include "main/macros.h" #include "shader/program.h" #include "shader/prog_instruction.h" -- cgit v1.2.3 From 535084996b050a75f230dc10c15bd6239e2aa08a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 02:16:24 -0800 Subject: glsl: Remove unnecessary headers from slang_compile.c. --- src/mesa/shader/slang/slang_compile.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 57e3555c221..6a91d0f3f07 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -40,14 +40,11 @@ #include "slang_compile.h" #include "slang_preprocess.h" #include "slang_storage.h" -#include "slang_emit.h" #include "slang_log.h" #include "slang_mem.h" #include "slang_vartable.h" #include "slang_simplify.h" -#include "slang_print.h" - /* * This is a straightforward implementation of the slang front-end * compiler. Lots of error-checking functionality is missing but -- cgit v1.2.3 From 59db91e2eec1e755de71deba87227a647845b1c9 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 02:20:51 -0800 Subject: glsl: Remove unnecessary header from slang_builtin.c. --- src/mesa/shader/slang/slang_builtin.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c index e5809509c93..0a9f0b97fb9 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -36,7 +36,6 @@ #include "shader/prog_parameter.h" #include "shader/prog_statevars.h" #include "shader/slang/slang_ir.h" -#include "shader/slang/slang_emit.h" #include "shader/slang/slang_builtin.h" -- cgit v1.2.3 From 1f7762f62bb082fceb579434a4ca78f13d78da49 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 15:00:29 -0800 Subject: glsl: Remove unnecessary header from slang_emit.c. --- src/mesa/shader/slang/slang_emit.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index c0e4b27aa5f..f812a3fbc56 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -38,7 +38,6 @@ #include "main/imports.h" #include "main/context.h" -#include "main/macros.h" #include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" -- cgit v1.2.3 From 0d622420826ccbf35eed80b663994ffb918dc9a1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 15:35:56 -0800 Subject: glsl: Remove unnecessary headers from shader_api.c. --- src/mesa/shader/shader_api.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 453cd3964af..e522d7017a9 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -39,10 +39,8 @@ #include "main/glheader.h" #include "main/context.h" #include "main/hash.h" -#include "main/macros.h" #include "shader/program.h" #include "shader/prog_parameter.h" -#include "shader/prog_print.h" #include "shader/prog_statevars.h" #include "shader/prog_uniform.h" #include "shader/shader_api.h" -- cgit v1.2.3 From 148498d8cc897d70c54e9ddc09e957a855a597d4 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 15:51:52 -0800 Subject: glsl: Remove unnecessary header from prog_statevars.c. --- src/mesa/shader/prog_statevars.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 058d4bbafb7..3a446fd9bb2 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -31,7 +31,6 @@ #include "main/glheader.h" #include "main/context.h" -#include "main/hash.h" #include "main/imports.h" #include "main/macros.h" #include "main/mtypes.h" -- cgit v1.2.3 From 5a4d5b694c0fa92b613bd73138d32f68b966a56c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 16:06:58 -0800 Subject: glsl: Remove unnecessary header from prog_execute.c. --- src/mesa/shader/prog_execute.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 192d39aed1e..1ef801a17dd 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -38,7 +38,6 @@ #include "main/glheader.h" #include "main/colormac.h" #include "main/context.h" -#include "program.h" #include "prog_execute.h" #include "prog_instruction.h" #include "prog_parameter.h" -- cgit v1.2.3 From 97fc7ae69f4e620a5b14a3dbe574c4810741293c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 16:15:37 -0800 Subject: mesa: Remove unnecessary header from nvvertparse.c. --- src/mesa/shader/nvvertparse.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index 8574016050c..baff7658d18 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -40,7 +40,6 @@ #include "main/glheader.h" #include "main/context.h" #include "main/imports.h" -#include "main/macros.h" #include "nvprogram.h" #include "nvvertparse.h" #include "prog_instruction.h" -- cgit v1.2.3 From 97e44cde17ce508fd3708d391f7701e1919352fb Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 23:41:05 -0800 Subject: mesa: Remove unnecessary headers from arbprogparse.c. --- src/mesa/shader/arbprogparse.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index dd732b6666b..a33f5100db9 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -54,11 +54,8 @@ having three separate program parameter arrays. #include "main/glheader.h" #include "main/imports.h" #include "main/context.h" -#include "main/macros.h" #include "main/mtypes.h" -#include "shader/grammar/grammar_mesa.h" #include "arbprogparse.h" -#include "program.h" #include "programopt.h" #include "prog_parameter.h" #include "prog_statevars.h" -- cgit v1.2.3 From e59353f592ef587d34279f0735f06053e289a7b4 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Wed, 20 Jan 2010 22:38:39 -0800 Subject: mesa: support for GL_ARB_fragment_coord_conventions Signed-off-by: Brian Paul --- src/mesa/main/extensions.c | 1 + src/mesa/main/mtypes.h | 3 +++ src/mesa/shader/arbprogparse.c | 2 ++ src/mesa/shader/program_parse_extra.c | 12 ++++++++++++ src/mesa/shader/program_parser.h | 2 ++ 5 files changed, 20 insertions(+) (limited to 'src/mesa/shader') diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 00427aa5806..ac7ff26b50f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -50,6 +50,7 @@ static const struct { { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, + { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7eff5cadd0d..919ddd7a298 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1762,6 +1762,8 @@ struct gl_fragment_program struct gl_program Base; /**< base class */ GLenum FogOption; GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean OriginUpperLeft; + GLboolean PixelCenterInteger; }; @@ -2395,6 +2397,7 @@ struct gl_extensions GLboolean ARB_depth_clamp; GLboolean ARB_draw_buffers; GLboolean ARB_draw_elements_base_vertex; + GLboolean ARB_fragment_coord_conventions; GLboolean ARB_fragment_program; GLboolean ARB_fragment_program_shadow; GLboolean ARB_fragment_shader; diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index a09be71020e..3e22a8a3057 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -123,6 +123,8 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, case OPTION_FOG_LINEAR: program->FogOption = GL_LINEAR; break; default: program->FogOption = GL_NONE; break; } + program->OriginUpperLeft = state.option.OriginUpperLeft; + program->PixelCenterInteger = state.option.PixelCenterInteger; program->UsesKill = state.fragment.UsesKill; diff --git a/src/mesa/shader/program_parse_extra.c b/src/mesa/shader/program_parse_extra.c index 0656c5eaa8e..ae98b782b70 100644 --- a/src/mesa/shader/program_parse_extra.c +++ b/src/mesa/shader/program_parse_extra.c @@ -216,6 +216,18 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option) state->option.Shadow = 1; return 1; } + } else if (strncmp(option, "fragment_coord_", 15) == 0) { + option += 15; + if (state->ctx->Extensions.ARB_fragment_coord_conventions) { + if (strcmp(option, "origin_upper_left") == 0) { + state->option.OriginUpperLeft = 1; + return 1; + } + else if (strcmp(option, "pixel_center_integer") == 0) { + state->option.PixelCenterInteger = 1; + return 1; + } + } } } else if (strncmp(option, "NV_fragment_program", 19) == 0) { option += 19; diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h index 69396ca2c0f..730466c30f5 100644 --- a/src/mesa/shader/program_parser.h +++ b/src/mesa/shader/program_parser.h @@ -209,6 +209,8 @@ struct asm_parser_state { unsigned TexRect:1; unsigned TexArray:1; unsigned NV_fragment:1; + unsigned OriginUpperLeft:1; + unsigned PixelCenterInteger:1; } option; struct { -- cgit v1.2.3 From 2b20b604277e3cdf7afb2431b50dbb05da12ff1c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 22 Jan 2010 10:38:06 -0700 Subject: mesa: Add "shader/" path to #include statements in shader parser/lexer sources Signed-off-by: Alan Coopersmith Note sure why the compiler's -I paths aren't doing the job, but this is OK. Signed-off-by: Brian Paul --- src/mesa/shader/lex.yy.c | 10 +++++----- src/mesa/shader/program_lexer.l | 10 +++++----- src/mesa/shader/program_parse.tab.c | 16 ++++++++-------- src/mesa/shader/program_parse.y | 16 ++++++++-------- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index 68543ae2e12..d1af35fedb6 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -1043,12 +1043,12 @@ static yyconst flex_int16_t yy_chk[1368] = */ #include "main/glheader.h" #include "main/imports.h" -#include "prog_instruction.h" -#include "prog_statevars.h" +#include "shader/prog_instruction.h" +#include "shader/prog_statevars.h" -#include "symbol_table.h" -#include "program_parser.h" -#include "program_parse.tab.h" +#include "shader/symbol_table.h" +#include "shader/program_parser.h" +#include "shader/program_parse.tab.h" #define require_ARB_vp (yyextra->mode == ARB_vertex) #define require_ARB_fp (yyextra->mode == ARB_fragment) diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index e2acb3c0c96..83bc5089d9e 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -23,12 +23,12 @@ */ #include "main/glheader.h" #include "main/imports.h" -#include "prog_instruction.h" -#include "prog_statevars.h" +#include "shader/prog_instruction.h" +#include "shader/prog_statevars.h" -#include "symbol_table.h" -#include "program_parser.h" -#include "program_parse.tab.h" +#include "shader/symbol_table.h" +#include "shader/program_parser.h" +#include "shader/program_parse.tab.h" #define require_ARB_vp (yyextra->mode == ARB_vertex) #define require_ARB_fp (yyextra->mode == ARB_fragment) diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index b12dcee9dfa..2adfb409739 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -98,14 +98,14 @@ #include "main/mtypes.h" #include "main/imports.h" -#include "program.h" -#include "prog_parameter.h" -#include "prog_parameter_layout.h" -#include "prog_statevars.h" -#include "prog_instruction.h" - -#include "symbol_table.h" -#include "program_parser.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_parameter_layout.h" +#include "shader/prog_statevars.h" +#include "shader/prog_instruction.h" + +#include "shader/symbol_table.h" +#include "shader/program_parser.h" extern void *yy_scan_string(char *); extern void yy_delete_buffer(void *); diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 5c5d8d75908..3880d549172 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -27,14 +27,14 @@ #include "main/mtypes.h" #include "main/imports.h" -#include "program.h" -#include "prog_parameter.h" -#include "prog_parameter_layout.h" -#include "prog_statevars.h" -#include "prog_instruction.h" - -#include "symbol_table.h" -#include "program_parser.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_parameter_layout.h" +#include "shader/prog_statevars.h" +#include "shader/prog_instruction.h" + +#include "shader/symbol_table.h" +#include "shader/program_parser.h" extern void *yy_scan_string(char *); extern void yy_delete_buffer(void *); -- cgit v1.2.3 From 8d1a01d37039a76ecbb8fdb4c10ff8d11aa02dfb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 15:36:28 -0700 Subject: mesa: use new fetch_vector1ui() function for 'unpack' GPU instructions The UP2H, UP2US, UP4B and UP4UB instructions interpret the float registers as integers. With gcc -O3 some bits were getting mixed up somewhere. This is part of the fix for the piglit fp-unpack-01 test failure (bug 25973). --- src/mesa/shader/prog_execute.c | 66 +++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 1ef801a17dd..fb29768935f 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -341,6 +341,28 @@ fetch_vector1(const struct prog_src_register *source, } +static GLuint +fetch_vector1ui(const struct prog_src_register *source, + const struct gl_program_machine *machine) +{ + const GLuint *src = (GLuint *) get_src_register_pointer(source, machine); + GLuint result; + + ASSERT(src); + + result = src[GET_SWZ(source->Swizzle, 0)]; + + if (source->Abs) { + result = FABSF(result); + } + if (source->Negate) { + result = -result; + } + + return result; +} + + /** * Fetch texel from texture. Use partial derivatives when possible. */ @@ -1633,12 +1655,11 @@ _mesa_execute_program(GLcontext * ctx, break; case OPCODE_UP2H: /* unpack two 16-bit floats */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; GLhalfNV hx, hy; - fetch_vector1(&inst->SrcReg[0], machine, a); - hx = rawBits[0] & 0xffff; - hy = rawBits[0] >> 16; + hx = raw & 0xffff; + hy = raw >> 16; result[0] = result[2] = _mesa_half_to_float(hx); result[1] = result[3] = _mesa_half_to_float(hy); store_vector4(inst, machine, result); @@ -1646,12 +1667,11 @@ _mesa_execute_program(GLcontext * ctx, break; case OPCODE_UP2US: /* unpack two GLushorts */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; GLushort usx, usy; - fetch_vector1(&inst->SrcReg[0], machine, a); - usx = rawBits[0] & 0xffff; - usy = rawBits[0] >> 16; + usx = raw & 0xffff; + usy = raw >> 16; result[0] = result[2] = usx * (1.0f / 65535.0f); result[1] = result[3] = usy * (1.0f / 65535.0f); store_vector4(inst, machine, result); @@ -1659,25 +1679,23 @@ _mesa_execute_program(GLcontext * ctx, break; case OPCODE_UP4B: /* unpack four GLbytes */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F; - result[1] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F; - result[2] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F; - result[3] = (((rawBits[0] >> 24) & 0xff) - 128) / 127.0F; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; + result[0] = (((raw >> 0) & 0xff) - 128) / 127.0F; + result[1] = (((raw >> 8) & 0xff) - 128) / 127.0F; + result[2] = (((raw >> 16) & 0xff) - 128) / 127.0F; + result[3] = (((raw >> 24) & 0xff) - 128) / 127.0F; store_vector4(inst, machine, result); } break; case OPCODE_UP4UB: /* unpack four GLubytes */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F; - result[1] = ((rawBits[0] >> 8) & 0xff) / 255.0F; - result[2] = ((rawBits[0] >> 16) & 0xff) / 255.0F; - result[3] = ((rawBits[0] >> 24) & 0xff) / 255.0F; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; + result[0] = ((raw >> 0) & 0xff) / 255.0F; + result[1] = ((raw >> 8) & 0xff) / 255.0F; + result[2] = ((raw >> 16) & 0xff) / 255.0F; + result[3] = ((raw >> 24) & 0xff) / 255.0F; store_vector4(inst, machine, result); } break; -- cgit v1.2.3 From 099e8ec54d4f7b9cd9ae3a481d6a6ae60f4590be Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 15:41:08 -0700 Subject: mesa: re-implement _mesa_ProgramEnvParameter4fvARB() with memcpy() This is faster and ensures that NaN floats get stored properly. Before, NaN values (which might be used with UP2H, UP2US, UP4B and UP4UB) weren't getting stored properly with gcc -O3. This is the second part of the fix for the piglit fp-unpack-01 failure (bug 25973). --- src/mesa/shader/arbprogram.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index eb537cd1b99..3cb26109508 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -561,6 +561,8 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, } } + + /** * Set a program env parameter register. * \note Called from the GL API dispatcher. @@ -569,10 +571,35 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, */ void GLAPIENTRY _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) + const GLfloat *params) { - _mesa_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + if (target == GL_FRAGMENT_PROGRAM_ARB + && ctx->Extensions.ARB_fragment_program) { + if (index >= ctx->Const.FragmentProgram.MaxEnvParams) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)"); + return; + } + memcpy(ctx->FragmentProgram.Parameters[index], params, + 4 * sizeof(GLfloat)); + } + else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */ + && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) { + if (index >= ctx->Const.VertexProgram.MaxEnvParams) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)"); + return; + } + memcpy(ctx->VertexProgram.Parameters[index], params, + 4 * sizeof(GLfloat)); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter4fv(target)"); + return; + } } -- cgit v1.2.3 From ffe4e2a6677beecf1e724f4a64100b24e0b05970 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 16:18:56 -0700 Subject: mesa: use switch in _mesa_DeletePrograms() --- src/mesa/shader/arbprogram.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 3cb26109508..b1915f096ef 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -180,23 +180,24 @@ _mesa_DeletePrograms(GLsizei n, const GLuint *ids) } else if (prog) { /* Unbind program if necessary */ - if (prog->Target == GL_VERTEX_PROGRAM_ARB || /* == GL_VERTEX_PROGRAM_NV */ - prog->Target == GL_VERTEX_STATE_PROGRAM_NV) { + switch (prog->Target) { + case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ + case GL_VERTEX_STATE_PROGRAM_NV: if (ctx->VertexProgram.Current && ctx->VertexProgram.Current->Base.Id == ids[i]) { /* unbind this currently bound program */ _mesa_BindProgram(prog->Target, 0); } - } - else if (prog->Target == GL_FRAGMENT_PROGRAM_NV || - prog->Target == GL_FRAGMENT_PROGRAM_ARB) { + break; + case GL_FRAGMENT_PROGRAM_NV: + case GL_FRAGMENT_PROGRAM_ARB: if (ctx->FragmentProgram.Current && ctx->FragmentProgram.Current->Base.Id == ids[i]) { /* unbind this currently bound program */ _mesa_BindProgram(prog->Target, 0); } - } - else { + break; + default: _mesa_problem(ctx, "bad target in glDeleteProgramsNV"); return; } -- cgit v1.2.3 From b23b13b69061d419b6f4e006dc5ca836a6b1e2be Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 16:23:50 -0700 Subject: mesa: use memcpy() in _mesa_ProgramEnv/LocalParameters4fvEXT() --- src/mesa/shader/arbprogram.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index b1915f096ef..746138071ed 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -609,7 +609,6 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - GLint i; GLfloat * dest; ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -640,11 +639,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, return; } - for ( i = 0 ; i < count ; i++ ) { - COPY_4V(dest, params); - params += 4; - dest += 4; - } + memcpy(dest, params, count * 4 * sizeof(GLfloat)); } @@ -757,8 +752,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - struct gl_program *prog; - GLint i; + GLfloat *dest; ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); @@ -773,7 +767,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)"); return; } - prog = &(ctx->FragmentProgram.Current->Base); + dest = ctx->FragmentProgram.Current->Base.LocalParams[index]; } else if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) { @@ -781,18 +775,14 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)"); return; } - prog = &(ctx->VertexProgram.Current->Base); + dest = ctx->VertexProgram.Current->Base.LocalParams[index]; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameters4fvEXT(target)"); return; } - for (i = 0; i < count; i++) { - ASSERT((index + i) < MAX_PROGRAM_LOCAL_PARAMS); - COPY_4V(prog->LocalParams[index + i], params); - params += 4; - } + memcpy(dest, params, count * 4 * sizeof(GLfloat)); } -- cgit v1.2.3 From 20fbb24b67dda0679774756e4b6d98c2c66c2c42 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:03:04 -0700 Subject: mesa: fix double->float assignment warnings, int/uint comparison warnings Reported by Karl Schultz. --- src/mesa/shader/nvprogram.c | 4 ++-- src/mesa/shader/prog_execute.c | 4 ++-- src/mesa/shader/prog_optimize.c | 8 ++++---- src/mesa/shader/program.c | 2 +- src/mesa/shader/shader_api.c | 8 ++++---- src/mesa/shader/slang/slang_codegen.c | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c index fd6cbb0f409..87f295e39ae 100644 --- a/src/mesa/shader/nvprogram.c +++ b/src/mesa/shader/nvprogram.c @@ -515,7 +515,7 @@ _mesa_emit_nv_temp_initialization(GLcontext *ctx, struct gl_program *program) { struct prog_instruction *inst; - int i; + GLuint i; if (!ctx->Shader.EmitNVTempInitialization) return; @@ -559,7 +559,7 @@ _mesa_emit_nv_temp_initialization(GLcontext *ctx, void _mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program) { - int i; + GLuint i; program->NumTemporaries = 0; for (i = 0; i < program->NumInstructions; i++) { diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index c212790dcd9..5641014d2c6 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -1017,12 +1017,12 @@ _mesa_execute_program(GLcontext * ctx, /* XXX we could probably just use pow() here */ if (a[0] > 0.0F) { if (a[1] == 0.0 && a[3] == 0.0) - result[2] = 1.0; + result[2] = 1.0F; else result[2] = (GLfloat) _mesa_pow(a[1], a[3]); } else { - result[2] = 0.0; + result[2] = 0.0F; } result[3] = 1.0F; store_vector4(inst, machine, result); diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c index ce411731b22..e1ec52254c0 100644 --- a/src/mesa/shader/prog_optimize.c +++ b/src/mesa/shader/prog_optimize.c @@ -459,7 +459,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog) */ for (j = i + 1; j < prog->NumInstructions; j++) { struct prog_instruction *inst2 = prog->Instructions + j; - int arg; + GLuint arg; if (_mesa_is_flow_control_opcode(inst2->Opcode)) break; @@ -867,7 +867,7 @@ find_live_intervals(struct gl_program *prog, _mesa_printf("Reg[%d] live [%d, %d]:", inv->Reg, inv->Start, inv->End); if (1) { - int j; + GLuint j; for (j = 0; j < inv->Start; j++) _mesa_printf(" "); for (j = inv->Start; j <= inv->End; j++) @@ -945,7 +945,7 @@ _mesa_reallocate_registers(struct gl_program *prog) */ { GLint j; - for (j = 0; j < activeIntervals.Num; j++) { + for (j = 0; j < (GLint) activeIntervals.Num; j++) { const struct interval *inv = activeIntervals.Intervals + j; if (inv->End >= live->Start) { /* Stop now. Since the activeInterval list is sorted @@ -994,7 +994,7 @@ _mesa_reallocate_registers(struct gl_program *prog) } } - if (maxTemp + 1 < liveIntervals.Num) { + if (maxTemp + 1 < (GLint) liveIntervals.Num) { /* OK, we've reduced the number of registers needed. * Scan the program and replace all the old temporary register * indexes with the new indexes. diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 6b8d94e6614..3e86d0adad4 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -580,7 +580,7 @@ _mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count) for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = prog->Instructions + i; if (inst->BranchTarget > 0) { - if (inst->BranchTarget > start) { + if (inst->BranchTarget > (GLint) start) { inst->BranchTarget -= count; } } diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index e522d7017a9..d53580f5f69 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -955,7 +955,7 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index, if (size) { GLint typeSize = sizeof_glsl_type(param->DataType); - if (param->Size > typeSize) { + if ((GLint) param->Size > typeSize) { /* This is an array. * Array elements are placed on vector[4] boundaries so they're * a multiple of four floats. We round typeSize up to next multiple @@ -1726,7 +1726,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, const GLint typeSize = sizeof_glsl_type(param->DataType); GLsizei k, i; - if (param->Size > typeSize) { + if ((GLint) param->Size > typeSize) { /* an array */ /* we'll ignore extra data below */ } @@ -1911,7 +1911,7 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, GLuint mat, row, col; GLuint src = 0; const struct gl_program_parameter * param = &program->Parameters->Parameters[index]; - const GLint slots = (param->Size + 3) / 4; + const GLuint slots = (param->Size + 3) / 4; const GLint typeSize = sizeof_glsl_type(param->DataType); GLint nr, nc; @@ -1923,7 +1923,7 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, return; } - if (param->Size <= typeSize) { + if ((GLint) param->Size <= typeSize) { /* non-array: count must be at most one; count == 0 is handled by the loop below */ if (count > 1) { _mesa_error(ctx, GL_INVALID_OPERATION, diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 372a9acdd03..83098b7350e 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3196,7 +3196,7 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper) newOper = slang_operation_new(1); newOper->type = SLANG_OPER_LITERAL_INT; newOper->literal_size = 1; - newOper->literal[0] = iter; + newOper->literal[0] = (GLfloat) iter; /* replace instances of the loop variable with newOper */ slang_substitute(A, body, 1, &oldVar, &newOper, GL_FALSE); -- cgit v1.2.3