summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_screen.c1
-rw-r--r--src/gallium/docs/source/screen.rst1
-rw-r--r--src/gallium/include/pipe/p_defines.h1
-rw-r--r--src/mesa/state_tracker/st_atom_rasterizer.c3
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c5
-rw-r--r--src/mesa/state_tracker/st_context.c7
-rw-r--r--src/mesa/state_tracker/st_context.h1
-rw-r--r--src/mesa/state_tracker/st_program.c3
-rw-r--r--src/mesa/state_tracker/st_program.h3
9 files changed, 22 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c
index 4c52874f3a5..2a0c28aabc1 100644
--- a/src/gallium/auxiliary/util/u_screen.c
+++ b/src/gallium/auxiliary/util/u_screen.c
@@ -397,6 +397,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
case PIPE_CAP_FLATSHADE:
case PIPE_CAP_ALPHA_TEST:
case PIPE_CAP_POINT_SIZE_FIXED:
+ case PIPE_CAP_TWO_SIDED_COLOR:
return 1;
default:
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index f280ad1cfec..ffe104e8dc6 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -562,6 +562,7 @@ The integer capabilities:
* ``PIPE_CAP_ALPHA_TEST``: Driver supports alpha-testing.
* ``PIPE_CAP_POINT_SIZE_FIXED``: Driver supports point-sizes that are fixed,
as opposed to writing gl_PointSize for every point.
+* ``PIPE_CAP_TWO_SIDED_COLOR``: Driver supports two-sided coloring.
.. _pipe_capf:
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index e5a68ca7cf7..ec446ad8de3 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -907,6 +907,7 @@ enum pipe_cap
PIPE_CAP_FLATSHADE,
PIPE_CAP_ALPHA_TEST,
PIPE_CAP_POINT_SIZE_FIXED,
+ PIPE_CAP_TWO_SIDED_COLOR,
};
/**
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 1cbefce29b5..bcbb3cd6b79 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -101,7 +101,8 @@ st_update_rasterizer(struct st_context *st)
GL_FIRST_VERTEX_CONVENTION_EXT;
/* _NEW_LIGHT | _NEW_PROGRAM */
- raster->light_twoside = _mesa_vertex_program_two_side_enabled(ctx);
+ if (!st->lower_two_sided_color)
+ raster->light_twoside = _mesa_vertex_program_two_side_enabled(ctx);
/*_NEW_LIGHT | _NEW_BUFFERS */
raster->clamp_vertex_color = !st->clamp_vert_color_in_shader &&
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 0f4b3b48387..c784ea8c59d 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -38,6 +38,7 @@
#include "main/imports.h"
#include "main/mtypes.h"
#include "main/framebuffer.h"
+#include "main/state.h"
#include "main/texobj.h"
#include "main/texstate.h"
#include "program/program.h"
@@ -128,6 +129,10 @@ st_update_fp( struct st_context *st )
if (st->lower_alpha_test && _mesa_is_alpha_test_enabled(st->ctx))
key.lower_alpha_func = st->ctx->Color.AlphaFunc;
+ /* _NEW_LIGHT | _NEW_PROGRAM */
+ key.lower_two_sided_color = st->lower_two_sided_color &&
+ _mesa_vertex_program_two_side_enabled(st->ctx);
+
/* _NEW_FRAG_CLAMP */
key.clamp_color = st->clamp_frag_color_in_shader &&
st->ctx->Color._ClampFragmentColor;
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 6997e70035a..d0134bc3313 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -228,7 +228,7 @@ st_invalidate_state(struct gl_context *ctx)
st->dirty |= ST_NEW_RASTERIZER;
if ((new_state & _NEW_LIGHT) &&
- st->lower_flatshade)
+ (st->lower_flatshade || st->lower_two_sided_color))
st->dirty |= ST_NEW_FS_STATE;
if (new_state & _NEW_PROJECTION &&
@@ -679,6 +679,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
!screen->get_param(screen, PIPE_CAP_ALPHA_TEST);
st->lower_point_size =
!screen->get_param(screen, PIPE_CAP_POINT_SIZE_FIXED);
+ st->lower_two_sided_color =
+ !screen->get_param(screen, PIPE_CAP_TWO_SIDED_COLOR);
st->has_hw_atomics =
screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
@@ -751,7 +753,8 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
!st->lower_alpha_test &&
!st->clamp_frag_color_in_shader &&
!st->clamp_frag_depth_in_shader &&
- !st->force_persample_in_shader;
+ !st->force_persample_in_shader &&
+ !st->lower_two_sided_color;
st->shader_has_one_variant[MESA_SHADER_TESS_CTRL] = st->has_shareable_shaders;
st->shader_has_one_variant[MESA_SHADER_TESS_EVAL] =
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 433e27160da..159aecad5cf 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -150,6 +150,7 @@ struct st_context
boolean lower_flatshade;
boolean lower_alpha_test;
boolean lower_point_size;
+ boolean lower_two_sided_color;
/**
* If a shader can be created when we get its source.
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 857a5444fcc..205fc9561fe 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1181,6 +1181,9 @@ st_create_fp_variant(struct st_context *st,
false, alpha_ref_state);
}
+ if (key->lower_two_sided_color)
+ NIR_PASS_V(tgsi.ir.nir, nir_lower_two_sided_color);
+
if (key->persample_shading) {
nir_shader *shader = tgsi.ir.nir;
nir_foreach_variable(var, &shader->inputs)
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 85934ee1df5..53638db687a 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -126,6 +126,9 @@ struct st_fp_variant_key
/** for ARB_depth_clamp */
GLuint lower_depth_clamp:1;
+ /** for OpenGL 1.0 on modern hardware */
+ GLuint lower_two_sided_color:1;
+
/** needed for ATI_fragment_shader */
char texture_targets[MAX_NUM_FRAGMENT_REGISTERS_ATI];