aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/program
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2015-02-22 21:39:56 +0100
committermarha <marha@users.sourceforge.net>2015-02-22 21:39:56 +0100
commit462f18c7b25fe3e467f837647d07ab0a78aa8d2b (patch)
treefc8013c0a1bac05a1945846c1697e973f4c35013 /mesalib/src/mesa/program
parent36f711ee12b6dd5184198abed3aa551efb585587 (diff)
downloadvcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.gz
vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.tar.bz2
vcxsrv-462f18c7b25fe3e467f837647d07ab0a78aa8d2b.zip
Merged origin/release (checked in because wanted to merge new stuff)
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.cpp54
-rw-r--r--mesalib/src/mesa/program/prog_cache.h11
-rw-r--r--mesalib/src/mesa/program/prog_execute.c77
-rw-r--r--mesalib/src/mesa/program/prog_hash_table.c2
-rw-r--r--mesalib/src/mesa/program/prog_instruction.c23
-rw-r--r--mesalib/src/mesa/program/prog_instruction.h4
-rw-r--r--mesalib/src/mesa/program/prog_optimize.c4
-rw-r--r--mesalib/src/mesa/program/prog_optimize.h11
-rw-r--r--mesalib/src/mesa/program/prog_parameter.c2
-rw-r--r--mesalib/src/mesa/program/prog_print.c4
-rw-r--r--mesalib/src/mesa/program/prog_print.h11
-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.h14
-rw-r--r--mesalib/src/mesa/program/sampler.cpp9
-rw-r--r--mesalib/src/mesa/program/sampler.h7
19 files changed, 136 insertions, 229 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 b814497a6..6122b1f8a 100644
--- a/mesalib/src/mesa/program/hash_table.h
+++ b/mesalib/src/mesa/program/hash_table.h
@@ -199,6 +199,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
*
@@ -230,6 +235,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
@@ -282,6 +305,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 5cd905822..b2776da45 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -43,19 +43,18 @@
#include "linker.h"
#include "main/mtypes.h"
+#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "main/uniforms.h"
-#include "program/hash_table.h"
-extern "C" {
-#include "main/shaderapi.h"
+#include "program/hash_table.h"
#include "program/prog_instruction.h"
#include "program/prog_optimize.h"
#include "program/prog_print.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/sampler.h"
-}
+
static int swizzle_for_size(int size);
@@ -607,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;
@@ -1153,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;
@@ -1349,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:
@@ -1356,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:
@@ -1450,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) {
@@ -2385,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;
}
@@ -2489,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);
@@ -2500,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;
@@ -2524,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]);
@@ -2943,12 +2976,9 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
/* Lowering */
do_mat_op_to_vec(ir);
- GLenum target = _mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage);
- 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)
- | ((target == GL_VERTEX_PROGRAM_ARB) ? SAT_TO_CLAMP
- : 0)));
+ | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
diff --git a/mesalib/src/mesa/program/prog_cache.h b/mesalib/src/mesa/program/prog_cache.h
index fdd7e264b..e37f1d7be 100644
--- a/mesalib/src/mesa/program/prog_cache.h
+++ b/mesalib/src/mesa/program/prog_cache.h
@@ -32,6 +32,12 @@
#include "main/glheader.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct gl_context;
/** Opaque type */
@@ -65,4 +71,9 @@ _mesa_shader_cache_insert(struct gl_context *ctx,
struct gl_shader_program *program);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif /* PROG_CACHE_H */
diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c
index 650c40f2a..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:
@@ -298,15 +298,6 @@ 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);
- return src[GET_SWZ(source->Swizzle, 0)];
-}
-
-
/**
* Fetch texel from texture. Use partial derivatives when possible.
*/
@@ -488,71 +479,6 @@ store_vector4(const struct prog_instruction *inst,
/**
- * Store 4 uints into a register. Observe the set-condition-code flags.
- */
-static void
-store_vector4ui(const struct prog_instruction *inst,
- struct gl_program_machine *machine, const GLuint value[4])
-{
- const struct prog_dst_register *dstReg = &(inst->DstReg);
- GLuint writeMask = dstReg->WriteMask;
- GLuint *dst = (GLuint *) get_dst_register_pointer(dstReg, machine);
-
- if (dstReg->CondMask != COND_TR) {
- /* condition codes may turn off some writes */
- if (writeMask & WRITEMASK_X) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 0)],
- dstReg->CondMask))
- writeMask &= ~WRITEMASK_X;
- }
- if (writeMask & WRITEMASK_Y) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 1)],
- dstReg->CondMask))
- writeMask &= ~WRITEMASK_Y;
- }
- if (writeMask & WRITEMASK_Z) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 2)],
- dstReg->CondMask))
- writeMask &= ~WRITEMASK_Z;
- }
- if (writeMask & WRITEMASK_W) {
- if (!test_cc(machine->CondCodes[GET_SWZ(dstReg->CondSwizzle, 3)],
- dstReg->CondMask))
- writeMask &= ~WRITEMASK_W;
- }
- }
-
- if (writeMask & WRITEMASK_X)
- dst[0] = value[0];
- if (writeMask & WRITEMASK_Y)
- dst[1] = value[1];
- if (writeMask & WRITEMASK_Z)
- dst[2] = value[2];
- if (writeMask & WRITEMASK_W)
- dst[3] = value[3];
-
- if (inst->CondUpdate) {
- if (writeMask & WRITEMASK_X)
- machine->CondCodes[0] = generate_cc((float)value[0]);
- if (writeMask & WRITEMASK_Y)
- machine->CondCodes[1] = generate_cc((float)value[1]);
- if (writeMask & WRITEMASK_Z)
- machine->CondCodes[2] = generate_cc((float)value[2]);
- if (writeMask & WRITEMASK_W)
- machine->CondCodes[3] = generate_cc((float)value[3]);
-#if DEBUG_PROG
- printf("CondCodes=(%s,%s,%s,%s) for:\n",
- _mesa_condcode_string(machine->CondCodes[0]),
- _mesa_condcode_string(machine->CondCodes[1]),
- _mesa_condcode_string(machine->CondCodes[2]),
- _mesa_condcode_string(machine->CondCodes[3]));
-#endif
- }
-}
-
-
-
-/**
* Execute the given vertex/fragment program.
*
* \param ctx rendering context
@@ -1334,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_instruction.c b/mesalib/src/mesa/program/prog_instruction.c
index 976024e3c..254c0128f 100644
--- a/mesalib/src/mesa/program/prog_instruction.c
+++ b/mesalib/src/mesa/program/prog_instruction.c
@@ -75,29 +75,6 @@ _mesa_alloc_instructions(GLuint numInst)
/**
- * Reallocate memory storing an array of program instructions.
- * This is used when we need to append additional instructions onto an
- * program.
- * \param oldInst pointer to first of old/src instructions
- * \param numOldInst number of instructions at <oldInst>
- * \param numNewInst desired size of new instruction array.
- * \return pointer to start of new instruction array.
- */
-struct prog_instruction *
-_mesa_realloc_instructions(struct prog_instruction *oldInst,
- GLuint numOldInst, GLuint numNewInst)
-{
- struct prog_instruction *newInst;
-
- newInst = (struct prog_instruction *)
- realloc(oldInst,
- numNewInst * sizeof(struct prog_instruction));
-
- return newInst;
-}
-
-
-/**
* Copy an array of program instructions.
* \param dest pointer to destination.
* \param src pointer to source.
diff --git a/mesalib/src/mesa/program/prog_instruction.h b/mesalib/src/mesa/program/prog_instruction.h
index de7880499..0957bd9d7 100644
--- a/mesalib/src/mesa/program/prog_instruction.h
+++ b/mesalib/src/mesa/program/prog_instruction.h
@@ -385,10 +385,6 @@ extern struct prog_instruction *
_mesa_alloc_instructions(GLuint numInst);
extern struct prog_instruction *
-_mesa_realloc_instructions(struct prog_instruction *oldInst,
- GLuint numOldInst, GLuint numNewInst);
-
-extern struct prog_instruction *
_mesa_copy_instructions(struct prog_instruction *dest,
const struct prog_instruction *src, GLuint n);
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_optimize.h b/mesalib/src/mesa/program/prog_optimize.h
index 7607bffdd..1f20ac0f8 100644
--- a/mesalib/src/mesa/program/prog_optimize.h
+++ b/mesalib/src/mesa/program/prog_optimize.h
@@ -29,6 +29,11 @@
#include "main/glheader.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct gl_context;
struct gl_program;
struct prog_instruction;
@@ -46,4 +51,10 @@ _mesa_optimize_program(struct gl_context *ctx, struct gl_program *program);
extern GLboolean
_mesa_constant_fold(struct gl_program *prog);
+
+#ifdef __cplusplus
+}
+#endif
+
+
#endif
diff --git a/mesalib/src/mesa/program/prog_parameter.c b/mesalib/src/mesa/program/prog_parameter.c
index 896c6052b..0ef46415d 100644
--- a/mesalib/src/mesa/program/prog_parameter.c
+++ b/mesalib/src/mesa/program/prog_parameter.c
@@ -120,7 +120,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
paramList->Size = paramList->Size + 4 * sz4;
/* realloc arrays */
- paramList->Parameters = (struct gl_program_parameter *)
+ paramList->Parameters =
realloc(paramList->Parameters,
paramList->Size * sizeof(struct gl_program_parameter));
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_print.h b/mesalib/src/mesa/program/prog_print.h
index cd61568e9..9058dfa76 100644
--- a/mesalib/src/mesa/program/prog_print.h
+++ b/mesalib/src/mesa/program/prog_print.h
@@ -31,6 +31,12 @@
#include "main/glheader.h"
#include "main/mtypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct gl_program;
struct gl_program_parameter_list;
struct gl_shader;
@@ -115,4 +121,9 @@ extern void
_mesa_append_uniforms_to_file(const struct gl_shader *shader);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif /* PROG_PRINT_H */
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 f22109fb4..757421edf 100644
--- a/mesalib/src/mesa/program/programopt.h
+++ b/mesalib/src/mesa/program/programopt.h
@@ -28,6 +28,12 @@
#include "main/mtypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
extern void
_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog);
@@ -45,11 +51,9 @@ _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
+}
+#endif
#endif /* PROGRAMOPT_H */
diff --git a/mesalib/src/mesa/program/sampler.cpp b/mesalib/src/mesa/program/sampler.cpp
index 29a540871..f8584c968 100644
--- a/mesalib/src/mesa/program/sampler.cpp
+++ b/mesalib/src/mesa/program/sampler.cpp
@@ -27,15 +27,14 @@
#include "glsl_types.h"
#include "ir_visitor.h"
#include "../glsl/program.h"
-#include "program/hash_table.h"
#include "ir_uniform.h"
-extern "C" {
#include "main/compiler.h"
#include "main/mtypes.h"
+#include "program/hash_table.h"
#include "program/prog_parameter.h"
#include "program/program.h"
-}
+
class get_sampler_name : public ir_hierarchical_visitor
{
@@ -104,7 +103,7 @@ public:
};
-extern "C" int
+int
_mesa_get_sampler_uniform_value(class ir_dereference *sampler,
struct gl_shader_program *shader_program,
const struct gl_program *prog)
@@ -136,7 +135,7 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
}
-extern "C" class ir_rvalue *
+class ir_rvalue *
_mesa_get_sampler_array_nonconst_index(class ir_dereference *sampler)
{
ir_dereference_array *deref_arr = sampler->as_dereference_array();
diff --git a/mesalib/src/mesa/program/sampler.h b/mesalib/src/mesa/program/sampler.h
index 8b7c3b63e..61c7f5851 100644
--- a/mesalib/src/mesa/program/sampler.h
+++ b/mesalib/src/mesa/program/sampler.h
@@ -23,6 +23,10 @@
* DEALINGS IN THE SOFTWARE.
*/
+#ifndef SAMPLER_H
+#define SAMPLER_H
+
+
int
_mesa_get_sampler_uniform_value(class ir_dereference *sampler,
struct gl_shader_program *shader_program,
@@ -30,3 +34,6 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
class ir_rvalue *
_mesa_get_sampler_array_nonconst_index(class ir_dereference *sampler);
+
+
+#endif /* SAMPLER_H */