#include "main/texenvprogram.h"
#include "main/texobj.h"
#include "main/uniforms.h"
-#include "glsl/ir_builder.h"
-#include "glsl/ir_optimization.h"
-#include "glsl/glsl_parser_extras.h"
-#include "glsl/glsl_symbol_table.h"
-#include "glsl/glsl_types.h"
+#include "compiler/glsl/ir_builder.h"
+#include "compiler/glsl/ir_optimization.h"
+#include "compiler/glsl/glsl_parser_extras.h"
+#include "compiler/glsl/glsl_symbol_table.h"
+#include "compiler/glsl_types.h"
#include "program/ir_to_mesa.h"
#include "program/program.h"
#include "program/programopt.h"
#include "program/prog_parameter.h"
#include "program/prog_print.h"
#include "program/prog_statevars.h"
+#include "util/bitscan.h"
using namespace ir_builder;
GLuint nr_enabled_units:8;
GLuint enabled_units:8;
GLuint separate_specular:1;
- GLuint fog_enabled:1;
GLuint fog_mode:2; /**< FOG_x */
GLuint inputs_available:12;
GLuint num_draw_buffers:4;
} unit[MAX_TEXTURE_UNITS];
};
-#define FOG_LINEAR 0
-#define FOG_EXP 1
-#define FOG_EXP2 2
-#define FOG_UNKNOWN 3
+#define FOG_NONE 0
+#define FOG_LINEAR 1
+#define FOG_EXP 2
+#define FOG_EXP2 3
static GLuint translate_fog_mode( GLenum mode )
{
case GL_LINEAR: return FOG_LINEAR;
case GL_EXP: return FOG_EXP;
case GL_EXP2: return FOG_EXP2;
- default: return FOG_UNKNOWN;
+ default: return FOG_NONE;
}
}
*/
static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
{
- GLuint i, j;
+ GLuint j;
GLbitfield inputs_referenced = VARYING_BIT_COL0;
const GLbitfield inputs_available = get_fp_input_mask( ctx );
+ GLbitfield mask;
GLuint keySize;
memset(key, 0, sizeof(*key));
/* _NEW_TEXTURE */
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ mask = ctx->Texture._EnabledCoordUnits;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
const struct gl_texture_object *texObj = texUnit->_Current;
const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine;
const struct gl_sampler_object *samp;
GLenum format;
- if (!texUnit->_Current || !texUnit->Enabled)
+ if (!texObj)
continue;
samp = _mesa_get_samplerobj(ctx, i);
/* _NEW_FOG */
if (ctx->Fog.Enabled) {
- key->fog_enabled = 1;
key->fog_mode = translate_fog_mode(ctx->Fog.Mode);
inputs_referenced |= VARYING_BIT_FOGC; /* maybe */
}
current = p->shader->symbols->get_variable("gl_CurrentAttribFragMESA");
assert(current);
- current->data.max_array_access = MAX2(current->data.max_array_access, attrib);
+ current->data.max_array_access = MAX2(current->data.max_array_access, (int)attrib);
val = new(p->mem_ctx) ir_dereference_variable(current);
ir_rvalue *index = new(p->mem_ctx) ir_constant(attrib);
return new(p->mem_ctx) ir_dereference_array(val, index);
var = p->shader->symbols->get_variable("gl_TextureEnvColor");
assert(var);
deref = new(p->mem_ctx) ir_dereference_variable(var);
- var->data.max_array_access = MAX2(var->data.max_array_access, unit);
+ var->data.max_array_access = MAX2(var->data.max_array_access, (int)unit);
return new(p->mem_ctx) ir_dereference_array(deref,
new(p->mem_ctx) ir_constant(unit));
texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
ir_rvalue *index = new(p->mem_ctx) ir_constant(unit);
texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
- tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, unit);
+ tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, (int)unit);
}
if (!p->state->unit[unit].enabled) {
cf = new(p->mem_ctx) ir_dereference_variable(spec_result);
}
- if (key->fog_enabled) {
+ if (key->fog_mode) {
cf = emit_fog_instructions(p, cf);
}
_mesa_glsl_parse_state *state;
p.mem_ctx = ralloc_context(NULL);
- p.shader = ctx->Driver.NewShader(ctx, 0, GL_FRAGMENT_SHADER);
+ p.shader = _mesa_new_shader(0, MESA_SHADER_FRAGMENT);
p.shader->ir = new(p.shader) exec_list;
state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
p.shader);
p.shader->CompileStatus = true;
p.shader->Version = state->language_version;
- p.shader->uses_builtin_functions = state->uses_builtin_functions;
+ p.shader->info.uses_builtin_functions = state->uses_builtin_functions;
p.shader_program->Shaders =
(gl_shader **)malloc(sizeof(*p.shader_program->Shaders));
p.shader_program->Shaders[0] = p.shader;