Reviewed-by: Ilia Mirkin <imir...@alum.mit.edu>
On Sun, Jan 31, 2016 at 1:25 AM, Edward O'Callaghan <eocallag...@alterapraxis.com> wrote: > Change references to gl_framebuffer::Width, Height, MaxNumLayers > and Visual::samples to use the _mesa_geometric_ convenience functions > for those places where the geometry of the gl_framebuffer is needed. > This is in contrast to the geometry of the intersection of the > attachments of the gl_framebuffer. > > This patch paves the way to enable GL_ARB_framebuffer_no_attachements > for all gallium drivers. > > Signed-off-by: Edward O'Callaghan <eocallag...@alterapraxis.com> > --- > src/mesa/state_tracker/st_atom_rasterizer.c | 3 ++- > src/mesa/state_tracker/st_atom_scissor.c | 8 ++++++-- > src/mesa/state_tracker/st_cb_drawpixels.c | 9 +++++---- > src/mesa/state_tracker/st_cb_drawtex.c | 9 +++++---- > src/mesa/state_tracker/st_cb_msaa.c | 4 +++- > 5 files changed, 21 insertions(+), 12 deletions(-) > > diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c > b/src/mesa/state_tracker/st_atom_rasterizer.c > index c20cadf..c1c143b 100644 > --- a/src/mesa/state_tracker/st_atom_rasterizer.c > +++ b/src/mesa/state_tracker/st_atom_rasterizer.c > @@ -31,6 +31,7 @@ > */ > > #include "main/macros.h" > +#include "main/framebuffer.h" > #include "st_context.h" > #include "st_atom.h" > #include "st_debug.h" > @@ -243,7 +244,7 @@ static void update_raster_state( struct st_context *st ) > ctx->Multisample._Enabled && > ctx->Multisample.SampleShading && > ctx->Multisample.MinSampleShadingValue * > - ctx->DrawBuffer->Visual.samples > 1; > + _mesa_geometric_samples(ctx->DrawBuffer) > 1; > > /* _NEW_SCISSOR */ > raster->scissor = ctx->Scissor.EnableFlags; > diff --git a/src/mesa/state_tracker/st_atom_scissor.c > b/src/mesa/state_tracker/st_atom_scissor.c > index 4ebe799..605d5cb 100644 > --- a/src/mesa/state_tracker/st_atom_scissor.c > +++ b/src/mesa/state_tracker/st_atom_scissor.c > @@ -32,6 +32,7 @@ > > > #include "main/macros.h" > +#include "main/framebuffer.h" > #include "st_context.h" > #include "pipe/p_context.h" > #include "st_atom.h" > @@ -46,14 +47,17 @@ update_scissor( struct st_context *st ) > struct pipe_scissor_state scissor[PIPE_MAX_VIEWPORTS]; > const struct gl_context *ctx = st->ctx; > const struct gl_framebuffer *fb = ctx->DrawBuffer; > + const unsigned int fb_width = _mesa_geometric_width(fb); > + const unsigned int fb_height = _mesa_geometric_height(fb); > GLint miny, maxy; > unsigned i; > bool changed = false; > + > for (i = 0 ; i < ctx->Const.MaxViewports; i++) { > scissor[i].minx = 0; > scissor[i].miny = 0; > - scissor[i].maxx = fb->Width; > - scissor[i].maxy = fb->Height; > + scissor[i].maxx = fb_width; > + scissor[i].maxy = fb_height; > > if (ctx->Scissor.EnableFlags & (1 << i)) { > /* need to be careful here with xmax or ymax < 0 */ > diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c > b/src/mesa/state_tracker/st_cb_drawpixels.c > index 04a9de0..0c46277 100644 > --- a/src/mesa/state_tracker/st_cb_drawpixels.c > +++ b/src/mesa/state_tracker/st_cb_drawpixels.c > @@ -35,6 +35,7 @@ > #include "main/bufferobj.h" > #include "main/blit.h" > #include "main/format_pack.h" > +#include "main/framebuffer.h" > #include "main/macros.h" > #include "main/mtypes.h" > #include "main/pack.h" > @@ -467,8 +468,8 @@ draw_quad(struct gl_context *ctx, GLfloat x0, GLfloat y0, > GLfloat z, > /* setup vertex data */ > { > const struct gl_framebuffer *fb = st->ctx->DrawBuffer; > - const GLfloat fb_width = (GLfloat) fb->Width; > - const GLfloat fb_height = (GLfloat) fb->Height; > + const GLfloat fb_width = (GLfloat) _mesa_geometric_width(fb); > + const GLfloat fb_height = (GLfloat) _mesa_geometric_height(fb); > const GLfloat clip_x0 = x0 / fb_width * 2.0f - 1.0f; > const GLfloat clip_y0 = y0 / fb_height * 2.0f - 1.0f; > const GLfloat clip_x1 = x1 / fb_width * 2.0f - 1.0f; > @@ -670,8 +671,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint > y, GLfloat z, > > /* viewport state: viewport matching window dims */ > { > - const float w = (float) ctx->DrawBuffer->Width; > - const float h = (float) ctx->DrawBuffer->Height; > + const float w = (float) _mesa_geometric_width(ctx->DrawBuffer); > + const float h = (float) _mesa_geometric_height(ctx->DrawBuffer); > struct pipe_viewport_state vp; > vp.scale[0] = 0.5f * w; > vp.scale[1] = -0.5f * h; > diff --git a/src/mesa/state_tracker/st_cb_drawtex.c > b/src/mesa/state_tracker/st_cb_drawtex.c > index e6ab77f..811c50b 100644 > --- a/src/mesa/state_tracker/st_cb_drawtex.c > +++ b/src/mesa/state_tracker/st_cb_drawtex.c > @@ -16,6 +16,7 @@ > #include "main/image.h" > #include "main/macros.h" > #include "main/teximage.h" > +#include "main/framebuffer.h" > #include "program/program.h" > #include "program/prog_print.h" > > @@ -164,8 +165,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, > GLfloat z, > /* positions (in clip coords) */ > { > const struct gl_framebuffer *fb = st->ctx->DrawBuffer; > - const GLfloat fb_width = (GLfloat)fb->Width; > - const GLfloat fb_height = (GLfloat)fb->Height; > + const GLfloat fb_width = (GLfloat)_mesa_geometric_width(fb); > + const GLfloat fb_height = (GLfloat)_mesa_geometric_height(fb); > > const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0); > const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0); > @@ -261,8 +262,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, > GLfloat z, > { > const struct gl_framebuffer *fb = st->ctx->DrawBuffer; > const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); > - const GLfloat width = (GLfloat)fb->Width; > - const GLfloat height = (GLfloat)fb->Height; > + const GLfloat width = (GLfloat)_mesa_geometric_width(fb); > + const GLfloat height = (GLfloat)_mesa_geometric_height(fb); > struct pipe_viewport_state vp; > vp.scale[0] = 0.5f * width; > vp.scale[1] = height * (invert ? -0.5f : 0.5f); > diff --git a/src/mesa/state_tracker/st_cb_msaa.c > b/src/mesa/state_tracker/st_cb_msaa.c > index e9955b6..968df36 100644 > --- a/src/mesa/state_tracker/st_cb_msaa.c > +++ b/src/mesa/state_tracker/st_cb_msaa.c > @@ -27,6 +27,7 @@ > > #include "main/bufferobj.h" > #include "main/imports.h" > +#include "main/framebuffer.h" > > #include "state_tracker/st_cb_msaa.h" > #include "state_tracker/st_context.h" > @@ -43,11 +44,12 @@ st_GetSamplePosition(struct gl_context *ctx, > GLfloat *outPos) > { > struct st_context *st = st_context(ctx); > + unsigned int fb_samples = _mesa_geometric_samples(fb); > > st_validate_state(st); > > if (st->pipe->get_sample_position) > - st->pipe->get_sample_position(st->pipe, (unsigned) fb->Visual.samples, > + st->pipe->get_sample_position(st->pipe, fb_samples, > index, outPos); > else > outPos[0] = outPos[1] = 0.5f; > -- > 2.5.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev