aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/blend.c20
-rw-r--r--mesalib/src/mesa/main/context.c24
-rw-r--r--mesalib/src/mesa/main/extensions.c2
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp41
-rw-r--r--mesalib/src/mesa/main/mtypes.h5
-rw-r--r--mesalib/src/mesa/main/uniforms.c1
6 files changed, 43 insertions, 50 deletions
diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c
index bc446edca..5bc40a028 100644
--- a/mesalib/src/mesa/main/blend.c
+++ b/mesalib/src/mesa/main/blend.c
@@ -166,6 +166,24 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
_mesa_BlendFuncSeparateEXT(sfactor, dfactor, sfactor, dfactor);
}
+static GLboolean
+blend_factor_is_dual_src(GLenum factor)
+{
+ return (factor == GL_SRC1_COLOR ||
+ factor == GL_SRC1_ALPHA ||
+ factor == GL_ONE_MINUS_SRC1_COLOR ||
+ factor == GL_ONE_MINUS_SRC1_ALPHA);
+}
+
+static void
+update_uses_dual_src(struct gl_context *ctx, int buf)
+{
+ ctx->Color.Blend[buf]._UsesDualSrc =
+ (blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcRGB) ||
+ blend_factor_is_dual_src(ctx->Color.Blend[buf].DstRGB) ||
+ blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcA) ||
+ blend_factor_is_dual_src(ctx->Color.Blend[buf].DstA));
+}
/**
* Set the separate blend source/dest factors for all draw buffers.
@@ -220,6 +238,7 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
+ update_uses_dual_src(ctx, buf);
}
ctx->Color._BlendFuncPerBuffer = GL_FALSE;
@@ -282,6 +301,7 @@ _mesa_BlendFuncSeparatei(GLuint buf, GLenum sfactorRGB, GLenum dfactorRGB,
ctx->Color.Blend[buf].DstRGB = dfactorRGB;
ctx->Color.Blend[buf].SrcA = sfactorA;
ctx->Color.Blend[buf].DstA = dfactorA;
+ update_uses_dual_src(ctx, buf);
ctx->Color._BlendFuncPerBuffer = GL_TRUE;
if (ctx->Driver.BlendFuncSeparatei) {
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index df0452cd1..3bcedecd9 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -1703,13 +1703,6 @@ _mesa_set_mvp_with_dp4( struct gl_context *ctx,
ctx->mvp_with_dp4 = flag;
}
-static GLboolean
-blend_factor_is_dual_src(GLenum factor)
-{
- return factor == GL_SRC1_COLOR || factor == GL_SRC1_ALPHA ||
- factor == GL_ONE_MINUS_SRC1_COLOR || factor == GL_ONE_MINUS_SRC1_ALPHA;
-}
-
/*
* ARB_blend_func_extended - ERRORS section
* "The error INVALID_OPERATION is generated by Begin or any procedure that
@@ -1722,16 +1715,13 @@ static GLboolean
_mesa_check_blend_func_error(struct gl_context *ctx)
{
GLuint i;
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- if (blend_factor_is_dual_src(ctx->Color.Blend[i].SrcRGB) ||
- blend_factor_is_dual_src(ctx->Color.Blend[i].DstRGB) ||
- blend_factor_is_dual_src(ctx->Color.Blend[i].SrcA) ||
- blend_factor_is_dual_src(ctx->Color.Blend[i].DstA)) {
- if (i >= ctx->Const.MaxDualSourceDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "dual source blend on illegal attachment");
- return GL_FALSE;
- }
+ for (i = ctx->Const.MaxDualSourceDrawBuffers;
+ i < ctx->DrawBuffer->_NumColorDrawBuffers;
+ i++) {
+ if (ctx->Color.Blend[i]._UsesDualSrc) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "dual source blend on illegal attachment");
+ return GL_FALSE;
}
}
return GL_TRUE;
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index a843a4092..cd76eeb3d 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -228,7 +228,7 @@ static const struct extension extension_table[] = {
{ "GL_OES_depth32", o(dummy_false), DISABLE, 2005 },
{ "GL_OES_depth_texture", o(ARB_depth_texture), ES2, 2006 },
#if FEATURE_OES_draw_texture
- { "GL_OES_draw_texture", o(OES_draw_texture), ES1 | ES2, 2004 },
+ { "GL_OES_draw_texture", o(OES_draw_texture), ES1, 2004 },
#endif
#if FEATURE_OES_EGL_image
/* FIXME: Mesa expects GL_OES_EGL_image to be available in OpenGL contexts. */
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 8a42281db..0233f3802 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -1007,6 +1007,15 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit )
sampler_name,
ir_var_uniform);
p->top_instructions->push_head(sampler);
+
+ /* Set the texture unit for this sampler. The linker will pick this value
+ * up and do-the-right-thing.
+ *
+ * NOTE: The cast to int is important. Without it, the constant will have
+ * type uint, and things later on may get confused.
+ */
+ sampler->constant_value = new(p->mem_ctx) ir_constant(int(unit));
+
deref = new(p->mem_ctx) ir_dereference_variable(sampler);
tex->set_sampler(deref, glsl_type::vec4_type);
@@ -1350,38 +1359,6 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
_mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters);
- for (unsigned int i = 0; i < MAX_TEXTURE_UNITS; i++) {
- /* Enough space for 'sampler_999\0'.
- */
- char name[12];
-
- snprintf(name, sizeof(name), "sampler_%d", i);
-
- int loc = _mesa_get_uniform_location(ctx, p.shader_program, name);
- if (loc != -1) {
- unsigned base;
- unsigned idx;
-
- /* Avoid using _mesa_uniform() because it flags state
- * updates, so if we're generating this shader_program in a
- * state update, we end up recursing. Instead, just set the
- * value, which is picked up at re-link.
- */
- _mesa_uniform_split_location_offset(loc, &base, &idx);
- assert(idx == 0);
-
- struct gl_uniform_storage *const storage =
- &p.shader_program->UniformStorage[base];
-
- /* Update the storage, the SamplerUnits in the shader program, and
- * the SamplerUnits in the assembly shader.
- */
- storage->storage[idx].i = i;
- fp->SamplerUnits[storage->sampler] = i;
- p.shader_program->SamplerUnits[storage->sampler] = i;
- _mesa_propagate_uniforms_to_driver_storage(storage, 0, 1);
- }
- }
_mesa_update_shader_textures_used(p.shader_program, fp);
(void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp);
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index eefe5e7e9..3a8cac9c5 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -755,6 +755,11 @@ struct gl_colorbuffer_attrib
GLenum DstA; /**< Alpha blend dest term */
GLenum EquationRGB; /**< GL_ADD, GL_SUBTRACT, etc. */
GLenum EquationA; /**< GL_ADD, GL_SUBTRACT, etc. */
+ /**
+ * Set if any blend factor uses SRC1. Computed at the time blend factors
+ * get set.
+ */
+ GLboolean _UsesDualSrc;
} Blend[MAX_DRAW_BUFFERS];
/** Are the blend func terms currently different for each buffer/target? */
GLboolean _BlendFuncPerBuffer;
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index be1e1728d..e6604b1a4 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -65,6 +65,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
{
GLuint s;
+ memcpy(prog->SamplerUnits, shProg->SamplerUnits, sizeof(prog->SamplerUnits));
memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
for (s = 0; s < MAX_SAMPLERS; s++) {