mesa/st: move st_fb_orientation into a mesa function
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14675>
This commit is contained in:
parent
840aabe752
commit
f6926efaad
|
@ -47,6 +47,7 @@
|
|||
#include "state_tracker/st_cb_bitmap.h"
|
||||
#include "state_tracker/st_cb_texture.h"
|
||||
#include "state_tracker/st_manager.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_scissor.h"
|
||||
#include "state_tracker/st_texture.h"
|
||||
#include "state_tracker/st_util.h"
|
||||
|
@ -403,7 +404,7 @@ do_blit_framebuffer(struct gl_context *ctx,
|
|||
(dstX1 != clip.dstX1) ||
|
||||
(dstY1 != clip.dstY1);
|
||||
|
||||
if (st_fb_orientation(drawFB) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(drawFB) == Y_0_TOP) {
|
||||
/* invert Y for dest */
|
||||
dstY0 = drawFB->Height - dstY0;
|
||||
dstY1 = drawFB->Height - dstY1;
|
||||
|
@ -423,7 +424,7 @@ do_blit_framebuffer(struct gl_context *ctx,
|
|||
#endif
|
||||
}
|
||||
|
||||
if (st_fb_orientation(readFB) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(readFB) == Y_0_TOP) {
|
||||
/* invert Y for src */
|
||||
srcY0 = readFB->Height - srcY0;
|
||||
srcY1 = readFB->Height - srcY1;
|
||||
|
|
|
@ -101,6 +101,33 @@ _mesa_geometric_layers(const struct gl_framebuffer *buffer)
|
|||
buffer->MaxNumLayers : buffer->DefaultGeometry.Layers;
|
||||
}
|
||||
|
||||
#define Y_0_TOP 1
|
||||
#define Y_0_BOTTOM 2
|
||||
|
||||
static inline GLuint
|
||||
_mesa_fb_orientation(const struct gl_framebuffer *fb)
|
||||
{
|
||||
if (fb && fb->FlipY) {
|
||||
/* Drawing into a window (on-screen buffer).
|
||||
*
|
||||
* Negate Y scale to flip image vertically.
|
||||
* The NDC Y coords prior to viewport transformation are in the range
|
||||
* [y=-1=bottom, y=1=top]
|
||||
* Hardware window coords are in the range [y=0=top, y=H-1=bottom] where
|
||||
* H is the window height.
|
||||
* Use the viewport transformation to invert Y.
|
||||
*/
|
||||
return Y_0_TOP;
|
||||
}
|
||||
else {
|
||||
/* Drawing into user-created FBO (very likely a texture).
|
||||
*
|
||||
* For textures, T=0=Bottom, so by extension Y=0=Bottom for rendering.
|
||||
*/
|
||||
return Y_0_BOTTOM;
|
||||
}
|
||||
}
|
||||
|
||||
extern void
|
||||
_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
|
||||
struct gl_framebuffer *drawFb);
|
||||
|
|
|
@ -118,7 +118,7 @@ st_update_framebuffer_state( struct st_context *st )
|
|||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
st->state.fb_orientation = st_fb_orientation(fb);
|
||||
st->state.fb_orientation = _mesa_fb_orientation(fb);
|
||||
|
||||
/**
|
||||
* Quantize the derived default number of samples:
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
#include "main/context.h"
|
||||
#include "main/viewport.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "st_context.h"
|
||||
#include "st_atom.h"
|
||||
#include "st_util.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "main/image.h"
|
||||
#include "main/bufferobj.h"
|
||||
#include "main/dlist.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/macros.h"
|
||||
#include "main/pbo.h"
|
||||
#include "program/program.h"
|
||||
|
|
|
@ -331,7 +331,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
|
|||
|
||||
/* viewport state: viewport matching window dims */
|
||||
cso_set_viewport_dims(st->cso_context, fb_width, fb_height,
|
||||
st_fb_orientation(fb) == Y_0_TOP);
|
||||
_mesa_fb_orientation(fb) == Y_0_TOP);
|
||||
|
||||
set_fragment_shader(st);
|
||||
cso_set_tessctrl_shader_handle(cso, NULL);
|
||||
|
|
|
@ -905,7 +905,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
|
|||
* Recall that these coords are transformed by the current
|
||||
* vertex shader and viewport transformation.
|
||||
*/
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM) {
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM) {
|
||||
y = fb_height - (int) (y + height * ctx->Pixel.ZoomY);
|
||||
invertTex = !invertTex;
|
||||
}
|
||||
|
@ -973,7 +973,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
|
||||
rb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
|
||||
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
y = ctx->DrawBuffer->Height - y - height;
|
||||
}
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
{
|
||||
GLint spanY;
|
||||
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
spanY = height - row - 1;
|
||||
}
|
||||
else {
|
||||
|
@ -1454,7 +1454,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
else
|
||||
usage = PIPE_MAP_WRITE;
|
||||
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
dsty = rbDraw->Height - dsty - height;
|
||||
}
|
||||
|
||||
|
@ -1478,7 +1478,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
|
||||
y = i;
|
||||
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
y = height - y - 1;
|
||||
}
|
||||
|
||||
|
@ -1591,12 +1591,12 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
}
|
||||
|
||||
/* Flip src/dst position depending on the orientation of buffers. */
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
readY = rbRead->Height - readY;
|
||||
readH = -readH;
|
||||
}
|
||||
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
|
||||
/* We can't flip the destination for pipe->blit, so we only adjust
|
||||
* its position and flip the source.
|
||||
*/
|
||||
|
@ -1817,7 +1817,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
|
|||
}
|
||||
|
||||
/* Invert src region if needed */
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
srcy = ctx->ReadBuffer->Height - srcy - height;
|
||||
invertTex = !invertTex;
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
|
|||
/* viewport state: viewport matching window dims */
|
||||
{
|
||||
const struct gl_framebuffer *fb = ctx->DrawBuffer;
|
||||
const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
|
||||
const GLboolean invert = (_mesa_fb_orientation(fb) == Y_0_TOP);
|
||||
const GLfloat width = (GLfloat)_mesa_geometric_width(fb);
|
||||
const GLfloat height = (GLfloat)_mesa_geometric_height(fb);
|
||||
struct pipe_viewport_state vp;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "main/context.h"
|
||||
#include "main/feedback.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/varray.h"
|
||||
|
||||
#include "util/u_memory.h"
|
||||
|
@ -92,7 +93,7 @@ feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
|
|||
ubyte slot;
|
||||
|
||||
win[0] = v->data[0][0];
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
|
||||
win[1] = ctx->DrawBuffer->Height - v->data[0][1];
|
||||
else
|
||||
win[1] = v->data[0][1];
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "main/macros.h"
|
||||
#include "main/arrayobj.h"
|
||||
#include "main/feedback.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/rastpos.h"
|
||||
#include "main/state.h"
|
||||
#include "main/varray.h"
|
||||
|
@ -51,7 +52,6 @@
|
|||
#include "st_draw.h"
|
||||
#include "st_program.h"
|
||||
#include "st_cb_rasterpos.h"
|
||||
#include "st_util.h"
|
||||
#include "draw/draw_context.h"
|
||||
#include "draw/draw_pipe.h"
|
||||
#include "vbo/vbo.h"
|
||||
|
@ -155,7 +155,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
|
|||
/* update raster pos */
|
||||
pos = prim->v[0]->data[0];
|
||||
ctx->Current.RasterPos[0] = pos[0];
|
||||
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
|
||||
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP)
|
||||
ctx->Current.RasterPos[1] = height - pos[1]; /* invert Y */
|
||||
else
|
||||
ctx->Current.RasterPos[1] = pos[1];
|
||||
|
|
|
@ -484,7 +484,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
|
||||
if (st->pbo.download_enabled && pack->BufferObj) {
|
||||
if (try_pbo_readpixels(st, rb,
|
||||
st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
|
||||
_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
|
||||
x, y, width, height,
|
||||
format, src_format, dst_format,
|
||||
pack, pixels))
|
||||
|
@ -499,7 +499,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
* synchronization overhead.
|
||||
*/
|
||||
dst = try_cached_readpixels(st, rb,
|
||||
st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
|
||||
_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
|
||||
width, height, format, src_format, dst_format);
|
||||
if (dst) {
|
||||
dst_x = x;
|
||||
|
@ -514,7 +514,7 @@ st_ReadPixels(struct gl_context *ctx, GLint x, GLint y,
|
|||
}
|
||||
|
||||
dst = blit_to_staging(st, rb,
|
||||
st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
|
||||
_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP,
|
||||
x, y, width, height, format,
|
||||
src_format, dst_format);
|
||||
if (!dst)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "main/fbobject.h"
|
||||
#include "main/formats.h"
|
||||
#include "main/format_utils.h"
|
||||
#include "main/framebuffer.h"
|
||||
#include "main/glformats.h"
|
||||
#include "main/image.h"
|
||||
#include "main/formatquery.h"
|
||||
|
@ -2565,7 +2566,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
|
|||
if (ST_DEBUG & DEBUG_FALLBACK)
|
||||
debug_printf("%s: fallback processing\n", __func__);
|
||||
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
srcY = rb->Height - srcY - height;
|
||||
}
|
||||
|
||||
|
@ -2605,7 +2606,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
|
|||
uint *data;
|
||||
|
||||
/* determine bottom-to-top vs. top-to-bottom order for src buffer */
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
srcY = height - 1;
|
||||
yStep = -1;
|
||||
}
|
||||
|
@ -2649,7 +2650,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
|
|||
struct gl_texture_image *texImage = stImage;
|
||||
struct gl_pixelstore_attrib unpack = ctx->DefaultPacking;
|
||||
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
if (_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
unpack.Invert = GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -2744,7 +2745,7 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
|
|||
struct pipe_screen *screen = st->screen;
|
||||
struct pipe_blit_info blit;
|
||||
enum pipe_format dst_format;
|
||||
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
|
||||
GLboolean do_flip = (_mesa_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
|
||||
unsigned bind;
|
||||
GLint srcY0, srcY1;
|
||||
|
||||
|
|
|
@ -64,35 +64,6 @@ st_invalidate_readpix_cache(struct st_context *st)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define Y_0_TOP 1
|
||||
#define Y_0_BOTTOM 2
|
||||
|
||||
static inline GLuint
|
||||
st_fb_orientation(const struct gl_framebuffer *fb)
|
||||
{
|
||||
if (fb && fb->FlipY) {
|
||||
/* Drawing into a window (on-screen buffer).
|
||||
*
|
||||
* Negate Y scale to flip image vertically.
|
||||
* The NDC Y coords prior to viewport transformation are in the range
|
||||
* [y=-1=bottom, y=1=top]
|
||||
* Hardware window coords are in the range [y=0=top, y=H-1=bottom] where
|
||||
* H is the window height.
|
||||
* Use the viewport transformation to invert Y.
|
||||
*/
|
||||
return Y_0_TOP;
|
||||
}
|
||||
else {
|
||||
/* Drawing into user-created FBO (very likely a texture).
|
||||
*
|
||||
* For textures, T=0=Bottom, so by extension Y=0=Bottom for rendering.
|
||||
*/
|
||||
return Y_0_BOTTOM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline bool
|
||||
st_user_clip_planes_enabled(struct gl_context *ctx)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue