From: Marek Olšák <marek.ol...@amd.com> --- src/mesa/drivers/dri/i915/intel_tris.c | 1 + src/mesa/drivers/dri/i965/brw_clip.c | 2 +- src/mesa/drivers/dri/i965/brw_context.c | 4 ++++ src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/brw_sf.c | 2 +- src/mesa/drivers/dri/i965/brw_sf_state.c | 2 +- src/mesa/drivers/dri/i965/genX_state_upload.c | 6 +++--- src/mesa/drivers/dri/r200/r200_swtcl.c | 1 + src/mesa/drivers/dri/radeon/radeon_swtcl.c | 1 + src/mesa/main/mtypes.h | 1 - src/mesa/main/polygon.c | 1 - src/mesa/main/state.c | 18 ------------------ src/mesa/main/state.h | 10 ++++++++++ src/mesa/swrast_setup/ss_triangle.c | 1 + src/mesa/swrast_setup/ss_tritmp.h | 2 +- src/mesa/tnl_dd/t_dd_tritmp.h | 4 ++-- 16 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 36cba22..70e4fa3 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -32,20 +32,21 @@ */ #include "main/glheader.h" #include "main/context.h" #include "main/macros.h" #include "main/enums.h" #include "main/texobj.h" #include "main/state.h" #include "main/dd.h" #include "main/fbobject.h" +#include "main/state.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" #include "tnl/t_vertex.h" #include "intel_screen.h" #include "intel_context.h" #include "intel_tris.h" diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c index d8805ff..e3023e5 100644 --- a/src/mesa/drivers/dri/i965/brw_clip.c +++ b/src/mesa/drivers/dri/i965/brw_clip.c @@ -174,21 +174,21 @@ brw_upload_clip_prog(struct brw_context *brw) */ key.clip_mode = BRW_CLIP_MODE_CLIP_NON_REJECTED; if (offset_back || offset_front) { /* _NEW_POLYGON, _NEW_BUFFERS */ key.offset_units = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD * 2; key.offset_factor = ctx->Polygon.OffsetFactor * ctx->DrawBuffer->_MRD; key.offset_clamp = ctx->Polygon.OffsetClamp * ctx->DrawBuffer->_MRD; } - if (!ctx->Polygon._FrontBit) { + if (!brw->polygon_front_bit) { key.fill_ccw = fill_front; key.fill_cw = fill_back; key.offset_ccw = offset_front; key.offset_cw = offset_back; if (ctx->Light.Model.TwoSide && key.fill_cw != BRW_CLIP_FILL_MODE_CULL) key.copy_bfc_cw = 1; } else { key.fill_cw = fill_front; key.fill_ccw = fill_back; diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index b5fd795..30ab2de 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -37,20 +37,21 @@ #include "main/fbobject.h" #include "main/extensions.h" #include "main/imports.h" #include "main/macros.h" #include "main/points.h" #include "main/version.h" #include "main/vtxfmt.h" #include "main/texobj.h" #include "main/framebuffer.h" #include "main/stencil.h" +#include "main/state.h" #include "vbo/vbo_context.h" #include "drivers/common/driverfuncs.h" #include "drivers/common/meta.h" #include "utils.h" #include "brw_context.h" #include "brw_defines.h" #include "brw_blorp.h" @@ -202,20 +203,23 @@ intel_update_state(struct gl_context * ctx) _mesa_unlock_context_textures(ctx); if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) { brw->stencil_enabled = _mesa_stencil_is_enabled(ctx); brw->stencil_two_sided = _mesa_stencil_is_two_sided(ctx); brw->stencil_write_enabled = _mesa_stencil_is_write_enabled(ctx, brw->stencil_two_sided); } + if (new_state & _NEW_POLYGON) + brw->polygon_front_bit = _mesa_polygon_get_front_bit(ctx); + intel_prepare_render(brw); /* Resolve the depth buffer's HiZ buffer. */ depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH); if (depth_irb && depth_irb->mt) { intel_miptree_prepare_depth(brw, depth_irb->mt, depth_irb->mt_level, depth_irb->mt_layer, depth_irb->layer_count); } diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 38eeabd..1219833 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -757,20 +757,22 @@ struct brw_context * edges. Enabling this flag causes the fragment shader to use * non-centroid interpolation for unlit pixels, at the expense of two extra * fragment shader instructions. */ bool needs_unlit_centroid_workaround; /** Derived stencil states. */ bool stencil_enabled; bool stencil_two_sided; bool stencil_write_enabled; + /** Derived polygon state. */ + bool polygon_front_bit; /**< 0=GL_CCW, 1=GL_CW */ struct isl_device isl_dev; struct blorp_context blorp; GLuint NewGLState; struct { struct brw_state_flags pipelines[BRW_NUM_PIPELINES]; } state; diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index d92b519..1d50232 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -154,19 +154,19 @@ brw_upload_sf_prog(struct brw_context *brw) /* _NEW_LIGHT | _NEW_PROGRAM */ key.do_twoside_color = _mesa_vertex_program_two_side_enabled(ctx); /* _NEW_POLYGON */ if (key.do_twoside_color) { /* If we're rendering to a FBO, we have to invert the polygon * face orientation, just as we invert the viewport in * sf_unit_create_from_key(). */ - key.frontface_ccw = ctx->Polygon._FrontBit == render_to_fbo; + key.frontface_ccw = brw->polygon_front_bit == render_to_fbo; } if (!brw_search_cache(&brw->cache, BRW_CACHE_SF_PROG, &key, sizeof(key), &brw->sf.prog_offset, &brw->sf.prog_data)) { compile_sf_prog( brw, &key ); } } diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 8cc81c9..d44a0d9 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -86,21 +86,21 @@ static void upload_sf_unit( struct brw_context *brw ) /* BRW_NEW_SF_VP */ sf->sf5.sf_viewport_state_offset = (brw->batch.bo->offset64 + brw->sf.vp_offset) >> 5; /* reloc */ sf->sf5.viewport_transform = 1; sf->sf6.scissor = 1; /* _NEW_POLYGON */ - if (ctx->Polygon._FrontBit) + if (brw->polygon_front_bit) sf->sf5.front_winding = BRW_FRONTWINDING_CW; else sf->sf5.front_winding = BRW_FRONTWINDING_CCW; /* _NEW_BUFFERS * The viewport is inverted for rendering to a FBO, and that inverts * polygon front/back orientation. */ sf->sf5.front_winding ^= render_to_fbo; diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c index a6e02e3..59db676 100644 --- a/src/mesa/drivers/dri/i965/genX_state_upload.c +++ b/src/mesa/drivers/dri/i965/genX_state_upload.c @@ -1244,21 +1244,21 @@ genX(upload_clip_state)(struct brw_context *brw) if (wm_prog_data->barycentric_interp_modes & BRW_BARYCENTRIC_NONPERSPECTIVE_BITS) clip.NonPerspectiveBarycentricEnable = true; #if GEN_GEN >= 7 clip.EarlyCullEnable = true; #endif #if GEN_GEN == 7 - clip.FrontWinding = ctx->Polygon._FrontBit == _mesa_is_user_fbo(fb); + clip.FrontWinding = brw->polygon_front_bit == _mesa_is_user_fbo(fb); if (ctx->Polygon.CullFlag) { switch (ctx->Polygon.CullFaceMode) { case GL_FRONT: clip.CullMode = CULLMODE_FRONT; break; case GL_BACK: clip.CullMode = CULLMODE_BACK; break; case GL_FRONT_AND_BACK: @@ -1375,21 +1375,21 @@ genX(upload_sf)(struct brw_context *brw) sf.StatisticsEnable = true; sf.ViewportTransformEnable = true; #if GEN_GEN == 7 /* _NEW_BUFFERS */ sf.DepthBufferSurfaceFormat = brw_depthbuffer_format(brw); #endif #if GEN_GEN <= 7 /* _NEW_POLYGON */ - sf.FrontWinding = ctx->Polygon._FrontBit == render_to_fbo; + sf.FrontWinding = brw->polygon_front_bit == render_to_fbo; sf.GlobalDepthOffsetEnableSolid = ctx->Polygon.OffsetFill; sf.GlobalDepthOffsetEnableWireframe = ctx->Polygon.OffsetLine; sf.GlobalDepthOffsetEnablePoint = ctx->Polygon.OffsetPoint; switch (ctx->Polygon.FrontMode) { case GL_FILL: sf.FrontFaceFillMode = FILL_MODE_SOLID; break; case GL_LINE: sf.FrontFaceFillMode = FILL_MODE_WIREFRAME; @@ -3816,21 +3816,21 @@ genX(upload_raster)(struct brw_context *brw) /* _NEW_BUFFERS */ bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer); /* _NEW_POLYGON */ struct gl_polygon_attrib *polygon = &ctx->Polygon; /* _NEW_POINT */ struct gl_point_attrib *point = &ctx->Point; brw_batch_emit(brw, GENX(3DSTATE_RASTER), raster) { - if (polygon->_FrontBit == render_to_fbo) + if (brw->polygon_front_bit == render_to_fbo) raster.FrontWinding = CounterClockwise; if (polygon->CullFlag) { switch (polygon->CullFaceMode) { case GL_FRONT: raster.CullMode = CULLMODE_FRONT; break; case GL_BACK: raster.CullMode = CULLMODE_BACK; break; diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c index 6ca85f5..0fda586 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -31,20 +31,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Keith Whitwell <kei...@vmware.com> */ #include "main/glheader.h" #include "main/mtypes.h" #include "main/enums.h" #include "main/image.h" #include "main/imports.h" #include "main/macros.h" +#include "main/state.h" #include "swrast/s_context.h" #include "swrast/s_fog.h" #include "swrast_setup/swrast_setup.h" #include "tnl/tnl.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" #include "r200_context.h" #include "r200_ioctl.h" diff --git a/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/src/mesa/drivers/dri/radeon/radeon_swtcl.c index f2bc462..d5365cd 100644 --- a/src/mesa/drivers/dri/radeon/radeon_swtcl.c +++ b/src/mesa/drivers/dri/radeon/radeon_swtcl.c @@ -30,20 +30,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Keith Whitwell <kei...@vmware.com> */ #include "main/glheader.h" #include "main/mtypes.h" #include "main/enums.h" #include "main/imports.h" #include "main/macros.h" +#include "main/state.h" #include "math/m_xform.h" #include "swrast_setup/swrast_setup.h" #include "tnl/tnl.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" #include "radeon_context.h" diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 1a8ae28..8c83944 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -792,21 +792,20 @@ struct gl_point_attrib /** * Polygon attribute group (GL_POLYGON_BIT). */ struct gl_polygon_attrib { GLenum FrontFace; /**< Either GL_CW or GL_CCW */ GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */ - GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */ GLboolean CullFlag; /**< Culling on/off flag */ GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */ GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */ GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */ GLfloat OffsetFactor; /**< Polygon offset factor, from user */ GLfloat OffsetUnits; /**< Polygon offset units, from user */ GLfloat OffsetClamp; /**< Polygon offset clamp, from user */ GLboolean OffsetPoint; /**< Offset in GL_POINT mode */ GLboolean OffsetLine; /**< Offset in GL_LINE mode */ GLboolean OffsetFill; /**< Offset in GL_FILL mode */ diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index 1bb7190..e509fe4 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -311,21 +311,20 @@ _mesa_PolygonOffsetClampEXT( GLfloat factor, GLfloat units, GLfloat clamp ) * * Initializes __struct gl_contextRec::Polygon and __struct gl_contextRec::PolygonStipple * attribute groups. */ void _mesa_init_polygon( struct gl_context * ctx ) { /* Polygon group */ ctx->Polygon.CullFlag = GL_FALSE; ctx->Polygon.CullFaceMode = GL_BACK; ctx->Polygon.FrontFace = GL_CCW; - ctx->Polygon._FrontBit = 0; ctx->Polygon.FrontMode = GL_FILL; ctx->Polygon.BackMode = GL_FILL; ctx->Polygon.SmoothFlag = GL_FALSE; ctx->Polygon.StippleFlag = GL_FALSE; ctx->Polygon.OffsetFactor = 0.0F; ctx->Polygon.OffsetUnits = 0.0F; ctx->Polygon.OffsetClamp = 0.0F; ctx->Polygon.OffsetPoint = GL_FALSE; ctx->Polygon.OffsetLine = GL_FALSE; ctx->Polygon.OffsetFill = GL_FALSE; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 0772e6b..7972798 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -267,35 +267,20 @@ update_program_constants(struct gl_context *ctx) ctx->VertexProgram._Current->Parameters; if (params && params->StateFlags & ctx->NewState) { new_state |= _NEW_PROGRAM_CONSTANTS; } } return new_state; } - - -/** - * Update the ctx->Polygon._FrontBit flag. - */ -static void -update_frontbit(struct gl_context *ctx) -{ - if (ctx->Transform.ClipOrigin == GL_LOWER_LEFT) - ctx->Polygon._FrontBit = (ctx->Polygon.FrontFace == GL_CW); - else - ctx->Polygon._FrontBit = (ctx->Polygon.FrontFace == GL_CCW); -} - - /** * Compute derived GL state. * If __struct gl_contextRec::NewState is non-zero then this function \b must * be called before rendering anything. * * Calls dd_function_table::UpdateState to perform any internal state * management necessary. * * \sa _mesa_update_modelview_project(), _mesa_update_texture(), * _mesa_update_buffer_bounds(), @@ -341,23 +326,20 @@ _mesa_update_state_locked( struct gl_context *ctx ) if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION)) _mesa_update_modelview_project( ctx, new_state ); if (new_state & _NEW_TEXTURE_MATRIX) _mesa_update_texture_matrices(ctx); if (new_state & (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE | _NEW_PROGRAM)) _mesa_update_texture_state(ctx); - if (new_state & _NEW_POLYGON) - update_frontbit( ctx ); - if (new_state & _NEW_BUFFERS) _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer); if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer); if (new_state & _NEW_LIGHT) _mesa_update_lighting( ctx ); if (new_state & _NEW_PIXEL) diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index 8817a47..6d81c3f 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -76,11 +76,21 @@ _mesa_need_secondary_color(const struct gl_context *ctx) static inline bool _mesa_vertex_program_two_side_enabled(const struct gl_context *ctx) { if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] || ctx->VertexProgram._Enabled) return ctx->VertexProgram.TwoSideEnabled; return ctx->Light.Enabled && ctx->Light.Model.TwoSide; } +/** Return 0=GL_CCW or 1=GL_CW */ +static inline bool +_mesa_polygon_get_front_bit(const struct gl_context *ctx) +{ + if (ctx->Transform.ClipOrigin == GL_LOWER_LEFT) + return ctx->Polygon.FrontFace == GL_CW; + + return ctx->Polygon.FrontFace == GL_CCW; +} + #endif diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c index 8f034d8..d3a0e23 100644 --- a/src/mesa/swrast_setup/ss_triangle.c +++ b/src/mesa/swrast_setup/ss_triangle.c @@ -23,20 +23,21 @@ * * Authors: * Keith Whitwell <kei...@vmware.com> */ #include "c99_math.h" #include "main/glheader.h" #include "main/macros.h" #include "main/mtypes.h" #include "main/stencil.h" +#include "main/state.h" #include "tnl/t_context.h" #include "ss_triangle.h" #include "ss_context.h" #define SS_OFFSET_BIT 0x1 #define SS_TWOSIDE_BIT 0x2 #define SS_UNFILLED_BIT 0x4 #define SS_MAX_TRIFUNC 0x8 diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h index adb77bd..c887472 100644 --- a/src/mesa/swrast_setup/ss_tritmp.h +++ b/src/mesa/swrast_setup/ss_tritmp.h @@ -51,21 +51,21 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) { GLfloat ex = v[0]->attrib[VARYING_SLOT_POS][0] - v[2]->attrib[VARYING_SLOT_POS][0]; GLfloat ey = v[0]->attrib[VARYING_SLOT_POS][1] - v[2]->attrib[VARYING_SLOT_POS][1]; GLfloat fx = v[1]->attrib[VARYING_SLOT_POS][0] - v[2]->attrib[VARYING_SLOT_POS][0]; GLfloat fy = v[1]->attrib[VARYING_SLOT_POS][1] - v[2]->attrib[VARYING_SLOT_POS][1]; GLfloat cc = ex*fy - ey*fx; if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT)) { - facing = (cc < 0.0F) ^ ctx->Polygon._FrontBit; + facing = (cc < 0.0F) ^ _mesa_polygon_get_front_bit(ctx); if (IND & SS_UNFILLED_BIT) mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode; if (facing == 1) { if (IND & SS_TWOSIDE_BIT) { if (VB->BackfaceColorPtr) { GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data; if (swsetup->intColors) { diff --git a/src/mesa/tnl_dd/t_dd_tritmp.h b/src/mesa/tnl_dd/t_dd_tritmp.h index 2176f1f..2294a76 100644 --- a/src/mesa/tnl_dd/t_dd_tritmp.h +++ b/src/mesa/tnl_dd/t_dd_tritmp.h @@ -130,21 +130,21 @@ static void TAG(triangle)( struct gl_context *ctx, GLuint e0, GLuint e1, GLuint if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL) { GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]); GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]); GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]); GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]); GLfloat cc = ex*fy - ey*fx; if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL) { - facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit; + facing = AREA_IS_CCW( cc ) ^ _mesa_polygon_get_front_bit(ctx); if (DO_UNFILLED) { if (facing) { mode = ctx->Polygon.BackMode; if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode != GL_FRONT) { return; } } else { mode = ctx->Polygon.FrontMode; @@ -355,21 +355,21 @@ static void TAG(quadr)( struct gl_context *ctx, if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL) { GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]); GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]); GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]); GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]); GLfloat cc = ex*fy - ey*fx; if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL) { - facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit; + facing = AREA_IS_CCW( cc ) ^ _mesa_polygon_get_front_bit(ctx); if (DO_UNFILLED) { if (facing) { mode = ctx->Polygon.BackMode; if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode != GL_FRONT) { return; } } else { mode = ctx->Polygon.FrontMode; -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev