aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/program
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/program')
-rw-r--r--mesalib/src/mesa/program/Android.mk2
-rw-r--r--mesalib/src/mesa/program/arbprogparse.c3
-rw-r--r--mesalib/src/mesa/program/hash_table.h34
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp42
-rw-r--r--mesalib/src/mesa/program/prog_execute.c3
-rw-r--r--mesalib/src/mesa/program/prog_hash_table.c2
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c4
-rw-r--r--mesalib/src/mesa/program/prog_print.c4
-rw-r--r--mesalib/src/mesa/program/prog_statevars.c2
-rw-r--r--mesalib/src/mesa/program/programopt.c91
-rw-r--r--mesalib/src/mesa/program/programopt.h6
11 files changed, 78 insertions, 115 deletions
diff --git a/mesalib/src/mesa/program/Android.mk b/mesalib/src/mesa/program/Android.mk
index 19c4be0fe..a237b65bc 100644
--- a/mesalib/src/mesa/program/Android.mk
+++ b/mesalib/src/mesa/program/Android.mk
@@ -39,8 +39,6 @@ endef
# Import the following variables:
# PROGRAM_FILES
include $(MESA_TOP)/src/mesa/Makefile.sources
-SRCDIR :=
-BUILDDIR :=
include $(CLEAR_VARS)
diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c
index 7dec399a5..53a6f37cb 100644
--- a/mesalib/src/mesa/program/arbprogparse.c
+++ b/mesalib/src/mesa/program/arbprogparse.c
@@ -85,9 +85,6 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
return;
}
- if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
- _mesa_optimize_program(ctx, &prog);
-
free(program->Base.String);
/* Copy the relevant contents of the arb_program struct into the
diff --git a/mesalib/src/mesa/program/hash_table.h b/mesalib/src/mesa/program/hash_table.h
index e95fc4982..eed2e55dc 100644
--- a/mesalib/src/mesa/program/hash_table.h
+++ b/mesalib/src/mesa/program/hash_table.h
@@ -198,6 +198,11 @@ string_to_uint_map_dtor(struct string_to_uint_map *);
#ifdef __cplusplus
}
+struct string_map_iterate_wrapper_closure {
+ void (*callback)(const char *key, unsigned value, void *closure);
+ void *closure;
+};
+
/**
* Map from a string (name) to an unsigned integer value
*
@@ -229,6 +234,24 @@ public:
}
/**
+ * Runs a passed callback for the hash
+ */
+ void iterate(void (*func)(const char *, unsigned, void *), void *closure)
+ {
+ struct string_map_iterate_wrapper_closure *wrapper;
+
+ wrapper = (struct string_map_iterate_wrapper_closure *)
+ malloc(sizeof(struct string_map_iterate_wrapper_closure));
+ if (wrapper == NULL)
+ return;
+
+ wrapper->callback = func;
+ wrapper->closure = closure;
+
+ hash_table_call_foreach(this->ht, subtract_one_wrapper, wrapper);
+ }
+
+ /**
* Get the value associated with a particular key
*
* \return
@@ -281,6 +304,17 @@ private:
free((char *)key);
}
+ static void subtract_one_wrapper(const void *key, void *data, void *closure)
+ {
+ struct string_map_iterate_wrapper_closure *wrapper =
+ (struct string_map_iterate_wrapper_closure *) closure;
+ unsigned value = (intptr_t) data;
+
+ value -= 1;
+
+ wrapper->callback((const char *) key, value, wrapper->closure);
+ }
+
struct hash_table *ht;
};
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index ce3af3120..b2776da45 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -606,6 +606,20 @@ type_size(const struct glsl_type *type)
*/
return 1;
}
+ break;
+ case GLSL_TYPE_DOUBLE:
+ if (type->is_matrix()) {
+ if (type->vector_elements > 2)
+ return type->matrix_columns * 2;
+ else
+ return type->matrix_columns;
+ } else {
+ if (type->vector_elements > 2)
+ return 2;
+ else
+ return 1;
+ }
+ break;
case GLSL_TYPE_ARRAY:
assert(type->length > 0);
return type_size(type->fields.array) * type->length;
@@ -1152,7 +1166,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
assert(!"not reached: should be handled by ir_div_to_mul_rcp");
break;
case ir_binop_mod:
- /* Floating point should be lowered by MOD_TO_FRACT in the compiler. */
+ /* Floating point should be lowered by MOD_TO_FLOOR in the compiler. */
assert(ir->type->is_integer());
emit(ir, OPCODE_MUL, result_dst, op[0], op[1]);
break;
@@ -1348,6 +1362,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_unop_pack_unorm_2x16:
case ir_unop_pack_unorm_4x8:
case ir_unop_pack_half_2x16:
+ case ir_unop_pack_double_2x32:
case ir_unop_unpack_snorm_2x16:
case ir_unop_unpack_snorm_4x8:
case ir_unop_unpack_unorm_2x16:
@@ -1355,11 +1370,21 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_unop_unpack_half_2x16:
case ir_unop_unpack_half_2x16_split_x:
case ir_unop_unpack_half_2x16_split_y:
+ case ir_unop_unpack_double_2x32:
case ir_binop_pack_half_2x16_split:
case ir_unop_bitfield_reverse:
case ir_unop_bit_count:
case ir_unop_find_msb:
case ir_unop_find_lsb:
+ case ir_unop_d2f:
+ case ir_unop_f2d:
+ case ir_unop_d2i:
+ case ir_unop_i2d:
+ case ir_unop_d2u:
+ case ir_unop_u2d:
+ case ir_unop_d2b:
+ case ir_unop_frexp_sig:
+ case ir_unop_frexp_exp:
assert(!"not supported");
break;
case ir_binop_min:
@@ -1449,6 +1474,7 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir)
ir->val->accept(this);
src = this->result;
assert(src.file != PROGRAM_UNDEFINED);
+ assert(ir->type->vector_elements > 0);
for (i = 0; i < 4; i++) {
if (i < ir->type->vector_elements) {
@@ -2384,6 +2410,8 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
if (type->is_vector() || type->is_scalar()) {
size = type->vector_elements;
+ if (type->is_double())
+ size *= 2;
} else {
size = type_size(type) * 4;
}
@@ -2488,6 +2516,7 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
enum gl_uniform_driver_format format = uniform_native;
unsigned columns = 0;
+ int dmul = 4 * sizeof(float);
switch (storage->type->base_type) {
case GLSL_TYPE_UINT:
assert(ctx->Const.NativeIntegers);
@@ -2499,6 +2528,11 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
(ctx->Const.NativeIntegers) ? uniform_native : uniform_int_float;
columns = 1;
break;
+
+ case GLSL_TYPE_DOUBLE:
+ if (storage->type->vector_elements > 2)
+ dmul *= 2;
+ /* fallthrough */
case GLSL_TYPE_FLOAT:
format = uniform_native;
columns = storage->type->matrix_columns;
@@ -2523,8 +2557,8 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
}
_mesa_uniform_attach_driver_storage(storage,
- 4 * sizeof(float) * columns,
- 4 * sizeof(float),
+ dmul * columns,
+ dmul,
format,
&params->ParameterValues[i]);
@@ -2942,7 +2976,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
/* Lowering */
do_mat_op_to_vec(ir);
- lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
+ lower_instructions(ir, (MOD_TO_FLOOR | DIV_TO_MUL_RCP | EXP_TO_EXP2
| LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
| ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c
index 33c1751e8..b2fbc808a 100644
--- a/mesalib/src/mesa/program/prog_execute.c
+++ b/mesalib/src/mesa/program/prog_execute.c
@@ -123,7 +123,7 @@ get_src_register_pointer(const struct prog_src_register *source,
return (GLfloat *) prog->Parameters->ParameterValues[reg];
case PROGRAM_SYSTEM_VALUE:
- assert(reg < Elements(machine->SystemValues));
+ assert(reg < (GLint) Elements(machine->SystemValues));
return machine->SystemValues[reg];
default:
@@ -1260,7 +1260,6 @@ _mesa_execute_program(struct gl_context * ctx,
else if (swz == SWIZZLE_ONE)
result[i] = 1.0;
else {
- ASSERT(swz >= 0);
ASSERT(swz <= 3);
result[i] = src[swz];
}
diff --git a/mesalib/src/mesa/program/prog_hash_table.c b/mesalib/src/mesa/program/prog_hash_table.c
index 2445d8434..5592b6fb8 100644
--- a/mesalib/src/mesa/program/prog_hash_table.c
+++ b/mesalib/src/mesa/program/prog_hash_table.c
@@ -29,7 +29,7 @@
*/
#include "main/imports.h"
-#include "main/simple_list.h"
+#include "util/simple_list.h"
#include "hash_table.h"
struct node {
diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c
index 60530ebf0..65d427cb4 100644
--- a/mesalib/src/mesa/program/prog_optimize.c
+++ b/mesalib/src/mesa/program/prog_optimize.c
@@ -408,7 +408,7 @@ find_next_use(const struct gl_program *prog,
for (j = 0; j < numSrc; j++) {
if (inst->SrcReg[j].RelAddr ||
(inst->SrcReg[j].File == PROGRAM_TEMPORARY &&
- inst->SrcReg[j].Index == index &&
+ inst->SrcReg[j].Index == (GLint)index &&
(get_src_arg_mask(inst,j,NO_MASK) & mask)))
return READ;
}
@@ -944,7 +944,7 @@ update_interval(GLint intBegin[], GLint intEnd[],
struct loop_info *loopStack, GLuint loopStackDepth,
GLuint index, GLuint ic)
{
- int i;
+ unsigned i;
GLuint begin = ic;
GLuint end = ic;
diff --git a/mesalib/src/mesa/program/prog_print.c b/mesalib/src/mesa/program/prog_print.c
index 4a5c1c1fb..3f499749a 100644
--- a/mesalib/src/mesa/program/prog_print.c
+++ b/mesalib/src/mesa/program/prog_print.c
@@ -82,7 +82,7 @@ _mesa_register_file_name(gl_register_file f)
* Return ARB_v/f_prog-style input attrib string.
*/
static const char *
-arb_input_attrib_string(GLint index, GLenum progType)
+arb_input_attrib_string(GLuint index, GLenum progType)
{
/*
* These strings should match the VERT_ATTRIB_x and VARYING_SLOT_x tokens.
@@ -242,7 +242,7 @@ _mesa_print_fp_inputs(GLbitfield inputs)
* Return ARB_v/f_prog-style output attrib string.
*/
static const char *
-arb_output_attrib_string(GLint index, GLenum progType)
+arb_output_attrib_string(GLuint index, GLenum progType)
{
/*
* These strings should match the VARYING_SLOT_x and FRAG_RESULT_x tokens.
diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c
index be5ddb106..7f5daf8c6 100644
--- a/mesalib/src/mesa/program/prog_statevars.c
+++ b/mesalib/src/mesa/program/prog_statevars.c
@@ -295,9 +295,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
const gl_state_index modifier = state[4];
const GLfloat *m;
GLuint row, i;
- ASSERT(firstRow >= 0);
ASSERT(firstRow < 4);
- ASSERT(lastRow >= 0);
ASSERT(lastRow < 4);
if (mat == STATE_MODELVIEW_MATRIX) {
matrix = ctx->ModelviewMatrixStack.Top;
diff --git a/mesalib/src/mesa/program/programopt.c b/mesalib/src/mesa/program/programopt.c
index b654b1db6..fdaa4a465 100644
--- a/mesalib/src/mesa/program/programopt.c
+++ b/mesalib/src/mesa/program/programopt.c
@@ -589,94 +589,3 @@ _mesa_remove_output_reads(struct gl_program *prog, gl_register_file type)
}
}
}
-
-
-/**
- * Make the given fragment program into a "no-op" shader.
- * Actually, just copy the incoming fragment color (or texcoord)
- * to the output color.
- * This is for debug/test purposes.
- */
-void
-_mesa_nop_fragment_program(struct gl_context *ctx, struct gl_fragment_program *prog)
-{
- struct prog_instruction *inst;
- GLuint inputAttr;
-
- inst = _mesa_alloc_instructions(2);
- if (!inst) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "_mesa_nop_fragment_program");
- return;
- }
-
- _mesa_init_instructions(inst, 2);
-
- inst[0].Opcode = OPCODE_MOV;
- inst[0].DstReg.File = PROGRAM_OUTPUT;
- inst[0].DstReg.Index = FRAG_RESULT_COLOR;
- inst[0].SrcReg[0].File = PROGRAM_INPUT;
- if (prog->Base.InputsRead & VARYING_BIT_COL0)
- inputAttr = VARYING_SLOT_COL0;
- else
- inputAttr = VARYING_SLOT_TEX0;
- inst[0].SrcReg[0].Index = inputAttr;
-
- inst[1].Opcode = OPCODE_END;
-
- _mesa_free_instructions(prog->Base.Instructions,
- prog->Base.NumInstructions);
-
- prog->Base.Instructions = inst;
- prog->Base.NumInstructions = 2;
- prog->Base.InputsRead = BITFIELD64_BIT(inputAttr);
- prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
-}
-
-
-/**
- * \sa _mesa_nop_fragment_program
- * Replace the given vertex program with a "no-op" program that just
- * transforms vertex position and emits color.
- */
-void
-_mesa_nop_vertex_program(struct gl_context *ctx, struct gl_vertex_program *prog)
-{
- struct prog_instruction *inst;
- GLuint inputAttr;
-
- /*
- * Start with a simple vertex program that emits color.
- */
- inst = _mesa_alloc_instructions(2);
- if (!inst) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "_mesa_nop_vertex_program");
- return;
- }
-
- _mesa_init_instructions(inst, 2);
-
- inst[0].Opcode = OPCODE_MOV;
- inst[0].DstReg.File = PROGRAM_OUTPUT;
- inst[0].DstReg.Index = VARYING_SLOT_COL0;
- inst[0].SrcReg[0].File = PROGRAM_INPUT;
- if (prog->Base.InputsRead & VERT_BIT_COLOR0)
- inputAttr = VERT_ATTRIB_COLOR0;
- else
- inputAttr = VERT_ATTRIB_TEX0;
- inst[0].SrcReg[0].Index = inputAttr;
-
- inst[1].Opcode = OPCODE_END;
-
- _mesa_free_instructions(prog->Base.Instructions,
- prog->Base.NumInstructions);
-
- prog->Base.Instructions = inst;
- prog->Base.NumInstructions = 2;
- prog->Base.InputsRead = BITFIELD64_BIT(inputAttr);
- prog->Base.OutputsWritten = BITFIELD64_BIT(VARYING_SLOT_COL0);
-
- /*
- * Now insert code to do standard modelview/projection transformation.
- */
- _mesa_insert_mvp_code(ctx, prog);
-}
diff --git a/mesalib/src/mesa/program/programopt.h b/mesalib/src/mesa/program/programopt.h
index 93c00f740..757421edf 100644
--- a/mesalib/src/mesa/program/programopt.h
+++ b/mesalib/src/mesa/program/programopt.h
@@ -51,12 +51,6 @@ _mesa_count_texture_instructions(struct gl_program *prog);
extern void
_mesa_remove_output_reads(struct gl_program *prog, gl_register_file type);
-extern void
-_mesa_nop_fragment_program(struct gl_context *ctx, struct gl_fragment_program *prog);
-
-extern void
-_mesa_nop_vertex_program(struct gl_context *ctx, struct gl_vertex_program *prog);
-
#ifdef __cplusplus
}