[Mesa-dev] [PATCH 1/5] st/mesa: use precomputed st_fb_orientation

Marek Olšák maraeo at gmail.com
Wed Jun 14 21:41:13 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/state_tracker/st_atom_list.h       | 6 +++---
 src/mesa/state_tracker/st_atom_rasterizer.c | 6 +++---
 src/mesa/state_tracker/st_atom_scissor.c    | 2 +-
 src/mesa/state_tracker/st_atom_viewport.c   | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_list.h b/src/mesa/state_tracker/st_atom_list.h
index 81a9308..b76854e 100644
--- a/src/mesa/state_tracker/st_atom_list.h
+++ b/src/mesa/state_tracker/st_atom_list.h
@@ -1,24 +1,21 @@
 /* Render (non-compute) states must be first. */
 ST_STATE(ST_NEW_DSA, st_update_depth_stencil_alpha)
 ST_STATE(ST_NEW_CLIP_STATE, st_update_clip)
 
 ST_STATE(ST_NEW_FS_STATE, st_update_fp)
 ST_STATE(ST_NEW_GS_STATE, st_update_gp)
 ST_STATE(ST_NEW_TES_STATE, st_update_tep)
 ST_STATE(ST_NEW_TCS_STATE, st_update_tcp)
 ST_STATE(ST_NEW_VS_STATE, st_update_vp)
 
-ST_STATE(ST_NEW_RASTERIZER, st_update_rasterizer)
 ST_STATE(ST_NEW_POLY_STIPPLE, st_update_polygon_stipple)
-ST_STATE(ST_NEW_VIEWPORT, st_update_viewport)
-ST_STATE(ST_NEW_SCISSOR, st_update_scissor)
 ST_STATE(ST_NEW_WINDOW_RECTANGLES, st_update_window_rectangles)
 ST_STATE(ST_NEW_BLEND, st_update_blend)
 ST_STATE(ST_NEW_BLEND_COLOR, st_update_blend_color)
 
 ST_STATE(ST_NEW_VS_SAMPLER_VIEWS, st_update_vertex_textures)
 ST_STATE(ST_NEW_FS_SAMPLER_VIEWS, st_update_fragment_textures)
 ST_STATE(ST_NEW_GS_SAMPLER_VIEWS, st_update_geometry_textures)
 ST_STATE(ST_NEW_TCS_SAMPLER_VIEWS, st_update_tessctrl_textures)
 ST_STATE(ST_NEW_TES_SAMPLER_VIEWS, st_update_tesseval_textures)
 
@@ -29,22 +26,25 @@ ST_STATE(ST_NEW_TES_SAMPLERS, st_update_tesseval_samplers) /* depends on update_
 ST_STATE(ST_NEW_GS_SAMPLERS, st_update_geometry_samplers) /* depends on update_*_texture for swizzle */
 ST_STATE(ST_NEW_FS_SAMPLERS, st_update_fragment_samplers) /* depends on update_*_texture for swizzle */
 
 ST_STATE(ST_NEW_VS_IMAGES, st_bind_vs_images)
 ST_STATE(ST_NEW_TCS_IMAGES, st_bind_tcs_images)
 ST_STATE(ST_NEW_TES_IMAGES, st_bind_tes_images)
 ST_STATE(ST_NEW_GS_IMAGES, st_bind_gs_images)
 ST_STATE(ST_NEW_FS_IMAGES, st_bind_fs_images)
 
 ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer_state) /* depends on update_*_texture and bind_*_images */
+ST_STATE(ST_NEW_RASTERIZER, st_update_rasterizer) /* depends on update_framebuffer_state */
 ST_STATE(ST_NEW_SAMPLE_MASK, st_update_sample_mask) /* depends on update_framebuffer_state */
 ST_STATE(ST_NEW_SAMPLE_SHADING, st_update_sample_shading)
+ST_STATE(ST_NEW_SCISSOR, st_update_scissor) /* depends on update_framebuffer_state */
+ST_STATE(ST_NEW_VIEWPORT, st_update_viewport) /* depends on update_framebuffer_state */
 
 ST_STATE(ST_NEW_VS_CONSTANTS, st_update_vs_constants)
 ST_STATE(ST_NEW_TCS_CONSTANTS, st_update_tcs_constants)
 ST_STATE(ST_NEW_TES_CONSTANTS, st_update_tes_constants)
 ST_STATE(ST_NEW_GS_CONSTANTS, st_update_gs_constants)
 ST_STATE(ST_NEW_FS_CONSTANTS, st_update_fs_constants)
 
 ST_STATE(ST_NEW_VS_UBOS, st_bind_vs_ubos)
 ST_STATE(ST_NEW_TCS_UBOS, st_bind_tcs_ubos)
 ST_STATE(ST_NEW_TES_UBOS, st_bind_tes_ubos)
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 6e17562..e388960 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -79,21 +79,21 @@ void st_update_rasterizer( struct st_context *st )
       if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT) {
          raster->front_ccw ^= 1;
       }
 
       /*
        * Gallium's surfaces are Y=0=TOP orientation.  OpenGL is the
        * opposite.  Window system surfaces are Y=0=TOP.  Mesa's FBOs
        * must match OpenGL conventions so FBOs use Y=0=BOTTOM.  In that
        * case, we must invert Y and flip the notion of front vs. back.
        */
-      if (st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM) {
+      if (st->state.fb_orientation == Y_0_BOTTOM) {
          /* Drawing to an FBO.  The viewport will be inverted. */
          raster->front_ccw ^= 1;
       }
    }
 
    /* _NEW_LIGHT
     */
    raster->flatshade = ctx->Light.ShadeModel == GL_FLAT;
       
    raster->flatshade_first = ctx->Light.ProvokingVertex ==
@@ -167,21 +167,21 @@ void st_update_rasterizer( struct st_context *st )
    /* _NEW_POINT
     */
    raster->point_size = ctx->Point.Size;
    raster->point_smooth = !ctx->Point.PointSprite && ctx->Point.SmoothFlag;
 
    /* _NEW_POINT | _NEW_PROGRAM
     */
    if (ctx->Point.PointSprite) {
       /* origin */
       if ((ctx->Point.SpriteOrigin == GL_UPPER_LEFT) ^
-          (st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM))
+          (st->state.fb_orientation == Y_0_BOTTOM))
          raster->sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
       else 
          raster->sprite_coord_mode = PIPE_SPRITE_COORD_LOWER_LEFT;
 
       /* Coord replacement flags.  If bit 'k' is set that means
        * that we need to replace GENERIC[k] attrib with an automatically
        * computed texture coord.
        */
       raster->sprite_coord_enable = ctx->Point.CoordReplace &
          ((1u << MAX_TEXTURE_COORD_UNITS) - 1);
@@ -262,21 +262,21 @@ void st_update_rasterizer( struct st_context *st )
          _mesa_geometric_samples(ctx->DrawBuffer) > 1;
 
    /* _NEW_SCISSOR */
    raster->scissor = ctx->Scissor.EnableFlags;
 
    /* _NEW_FRAG_CLAMP */
    raster->clamp_fragment_color = !st->clamp_frag_color_in_shader &&
                                   ctx->Color._ClampFragmentColor;
 
    raster->half_pixel_center = 1;
-   if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
+   if (st->state.fb_orientation == Y_0_TOP)
       raster->bottom_edge_rule = 1;
    /* _NEW_TRANSFORM */
    if (ctx->Transform.ClipOrigin == GL_UPPER_LEFT)
       raster->bottom_edge_rule ^= 1;
 
    /* ST_NEW_RASTERIZER */
    raster->rasterizer_discard = ctx->RasterDiscard;
 
    if (st->edgeflag_culls_prims) {
       /* All edge flags are FALSE. Cull the affected faces. */
diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c
index d3450be..ccd6e8e 100644
--- a/src/mesa/state_tracker/st_atom_scissor.c
+++ b/src/mesa/state_tracker/st_atom_scissor.c
@@ -75,21 +75,21 @@ st_update_scissor( struct st_context *st )
             scissor[i].maxy = ymax;
          
          /* check for null space */
          if (scissor[i].minx >= scissor[i].maxx || scissor[i].miny >= scissor[i].maxy)
             scissor[i].minx = scissor[i].miny = scissor[i].maxx = scissor[i].maxy = 0;
       }
 
       /* Now invert Y if needed.
        * Gallium drivers use the convention Y=0=top for surfaces.
        */
-      if (st_fb_orientation(fb) == Y_0_TOP) {
+      if (st->state.fb_orientation == Y_0_TOP) {
          miny = fb->Height - scissor[i].maxy;
          maxy = fb->Height - scissor[i].miny;
          scissor[i].miny = miny;
          scissor[i].maxy = maxy;
       }
 
       if (memcmp(&scissor[i], &st->state.scissor[i], sizeof(scissor[0])) != 0) {
          /* state has changed */
          st->state.scissor[i] = scissor[i];  /* struct copy */
          changed = true;
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
index 900f061..1fc8908 100644
--- a/src/mesa/state_tracker/st_atom_viewport.c
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -40,21 +40,21 @@
  *  - window pos/size or FBO size
  */
 void
 st_update_viewport( struct st_context *st )
 {
    struct gl_context *ctx = st->ctx;
    GLfloat yScale, yBias;
    unsigned i;
    /* _NEW_BUFFERS
     */
-   if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
+   if (st->state.fb_orientation == Y_0_TOP) {
       /* Drawing to a window.  The corresponding gallium surface uses
        * Y=0=TOP but OpenGL is Y=0=BOTTOM.  So we need to invert the viewport.
        */
       yScale = -1;
       yBias = (GLfloat)ctx->DrawBuffer->Height;
    }
    else {
       /* Drawing to an FBO where Y=0=BOTTOM, like OpenGL - don't invert */
       yScale = 1.0;
       yBias = 0.0;
-- 
2.7.4



More information about the mesa-dev mailing list