mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-12-03 13:13:02 +00:00
mesa,gallium: Make point coord origin a CAP
When lower_wpos_pntc is used, the state tracker inserts code to transform gl_PointCoord.y according to a uniform, to account for API-requested point coordinate origin and framebuffer orientation. With the transformation, driver-supplied point coordinates are expected to have an upper left origin. If the hardware point coordinate supports (only) a lower left origin, the backend has to use lower_wpos_pntc and then lower *again* to flip back. This ends up transforming twice, which is wasteful: a = load point coord Y with lower left origin a' = 1.0 - a a'' = uniform_transform(a') However, lower_wpos_pntc is quite capable of transforming for a lower left origin too, it just needs to flip the transformation. Add a CAP specifying the point coordinate origin convention, rather than assuming upper-left. This simplifies the Asahi code greatly. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16829>
This commit is contained in:
parent
10a2406232
commit
e749f67f89
@ -72,6 +72,8 @@ The integer capabilities:
|
||||
pixel-center fragment convention is supported.
|
||||
* ``PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER``: Whether the integer
|
||||
pixel-center fragment convention is supported.
|
||||
* ``PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT``: Whether point coordinates use the
|
||||
upper-left origin convention. Otherwise the lower-left convention is used.
|
||||
* ``PIPE_CAP_DEPTH_CLIP_DISABLE``: Whether the driver is capable of disabling
|
||||
depth clipping (through pipe_rasterizer_state).
|
||||
* ``PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE``: Whether the driver is capable of
|
||||
|
@ -74,6 +74,11 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
|
||||
case PIPE_CAP_FS_COORD_ORIGIN_LOWER_LEFT:
|
||||
case PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
|
||||
case PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER:
|
||||
return 0;
|
||||
|
||||
case PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT:
|
||||
return 1;
|
||||
|
||||
case PIPE_CAP_DEPTH_CLIP_DISABLE:
|
||||
case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE:
|
||||
case PIPE_CAP_DEPTH_CLAMP_ENABLE:
|
||||
|
@ -219,6 +219,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_INDEP_BLEND_ENABLE:
|
||||
case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT:
|
||||
case PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
|
||||
case PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT:
|
||||
case PIPE_CAP_PRIMITIVE_RESTART:
|
||||
case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
|
||||
case PIPE_CAP_VS_INSTANCEID:
|
||||
|
@ -244,6 +244,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_INDEP_BLEND_FUNC:
|
||||
case PIPE_CAP_FS_COORD_ORIGIN_UPPER_LEFT:
|
||||
case PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
|
||||
case PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT:
|
||||
case PIPE_CAP_PRIMITIVE_RESTART:
|
||||
case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
|
||||
case PIPE_CAP_VS_INSTANCEID:
|
||||
|
@ -766,6 +766,7 @@ enum pipe_cap
|
||||
PIPE_CAP_FS_COORD_ORIGIN_LOWER_LEFT,
|
||||
PIPE_CAP_FS_COORD_PIXEL_CENTER_HALF_INTEGER,
|
||||
PIPE_CAP_FS_COORD_PIXEL_CENTER_INTEGER,
|
||||
PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT,
|
||||
PIPE_CAP_DEPTH_CLIP_DISABLE,
|
||||
PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE,
|
||||
PIPE_CAP_DEPTH_CLAMP_ENABLE,
|
||||
|
@ -996,5 +996,8 @@ struct gl_constants
|
||||
|
||||
/** Use hardware accelerated GL_SELECT */
|
||||
bool HardwareAcceleratedSelect;
|
||||
|
||||
/** Origin of point coordinates. True if upper left, false if lower left. */
|
||||
bool PointCoordOriginUpperLeft;
|
||||
};
|
||||
#endif
|
||||
|
@ -743,7 +743,8 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
|
||||
|
||||
case STATE_FB_PNTC_Y_TRANSFORM:
|
||||
{
|
||||
bool flip_y = (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) ^
|
||||
bool flip_y = (ctx->Point.SpriteOrigin == GL_UPPER_LEFT) ^
|
||||
(ctx->Const.PointCoordOriginUpperLeft) ^
|
||||
(ctx->DrawBuffer->FlipY);
|
||||
|
||||
value[0] = flip_y ? -1.0F : 1.0F;
|
||||
|
@ -682,6 +682,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
|
||||
ctx->Point.MaxSize = MAX2(ctx->Const.MaxPointSize,
|
||||
ctx->Const.MaxPointSizeAA);
|
||||
|
||||
ctx->Const.PointCoordOriginUpperLeft =
|
||||
screen->get_param(screen, PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT);
|
||||
|
||||
ctx->Const.NoClippingOnCopyTex = screen->get_param(screen,
|
||||
PIPE_CAP_NO_CLIP_ON_COPY_TEX);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user