mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 13:10:10 +01:00
mesa/gallium: automatically lower two-sided lighting
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
011d692a52
commit
28543f1640
9 changed files with 22 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -907,6 +907,7 @@ enum pipe_cap
|
|||
PIPE_CAP_FLATSHADE,
|
||||
PIPE_CAP_ALPHA_TEST,
|
||||
PIPE_CAP_POINT_SIZE_FIXED,
|
||||
PIPE_CAP_TWO_SIDED_COLOR,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 &&
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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] =
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue