mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
asahi: Support one-sided polygon modes
We can implement glPolygonMode(GL_FRONT_AND_BACK, ...) natively. What we can't implement natively are two-sided polygon modes. For that Apple has a nontrivial lowering which I don't feel the need to implement unless someone actually hits a workload other than Piglit that uses it. Vulkan requires only one-sided polygon modes (so this is sufficient there), and GLES doesn't have polygon modes at all. If an app hits the unimplemented case, throw a warning like Zink does. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20017>
This commit is contained in:
parent
5e15b3c323
commit
21f9a72c77
2 changed files with 24 additions and 3 deletions
|
|
@ -259,6 +259,17 @@ agx_bind_zsa_state(struct pipe_context *pctx, void *cso)
|
|||
ctx->dirty |= AGX_DIRTY_ZS;
|
||||
}
|
||||
|
||||
static enum agx_polygon_mode
|
||||
agx_translate_polygon_mode(unsigned mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case PIPE_POLYGON_MODE_FILL: return AGX_POLYGON_MODE_FILL;
|
||||
case PIPE_POLYGON_MODE_POINT: return AGX_POLYGON_MODE_POINT;
|
||||
case PIPE_POLYGON_MODE_LINE: return AGX_POLYGON_MODE_LINE;
|
||||
default: unreachable("Unsupported polygon mode");
|
||||
}
|
||||
}
|
||||
|
||||
static void *
|
||||
agx_create_rs_state(struct pipe_context *ctx,
|
||||
const struct pipe_rasterizer_state *cso)
|
||||
|
|
@ -280,6 +291,16 @@ agx_create_rs_state(struct pipe_context *ctx,
|
|||
cfg.depth_clamp = !cso->depth_clip_near;
|
||||
};
|
||||
|
||||
/* Two-sided polygon mode doesn't seem to work on G13. Apple's OpenGL
|
||||
* implementation lowers to multiple draws with culling. Warn.
|
||||
*/
|
||||
if (unlikely(cso->fill_front != cso->fill_back)) {
|
||||
fprintf(stderr, "Warning: Two-sided fill modes are unsupported, "
|
||||
"rendering may be incorrect.\n");
|
||||
}
|
||||
|
||||
so->polygon_mode = agx_translate_polygon_mode(cso->fill_front);
|
||||
|
||||
return so;
|
||||
}
|
||||
|
||||
|
|
@ -1783,15 +1804,14 @@ agx_encode_state(struct agx_batch *batch, uint8_t *out,
|
|||
agx_pack(&front_face, FRAGMENT_FACE, cfg) {
|
||||
cfg.stencil_reference = ctx->stencil_ref.ref_value[0];
|
||||
cfg.line_width = rast->line_width;
|
||||
cfg.polygon_mode = AGX_POLYGON_MODE_FILL;
|
||||
cfg.polygon_mode = rast->polygon_mode;
|
||||
};
|
||||
|
||||
agx_pack(&back_face, FRAGMENT_FACE, cfg) {
|
||||
bool twosided = ctx->zs->base.stencil[1].enabled;
|
||||
cfg.stencil_reference = ctx->stencil_ref.ref_value[twosided ? 1 : 0];
|
||||
|
||||
cfg.line_width = rast->line_width;
|
||||
cfg.polygon_mode = AGX_POLYGON_MODE_FILL;
|
||||
cfg.polygon_mode = rast->polygon_mode;
|
||||
};
|
||||
|
||||
front_face.opaque[0] |= ctx->zs->depth.opaque[0];
|
||||
|
|
|
|||
|
|
@ -241,6 +241,7 @@ struct agx_rasterizer {
|
|||
struct pipe_rasterizer_state base;
|
||||
uint8_t cull[AGX_CULL_LENGTH];
|
||||
uint8_t line_width;
|
||||
uint8_t polygon_mode;
|
||||
};
|
||||
|
||||
struct agx_query {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue