/*00A38*/ EMIT_STATE(PA_WIDE_LINE_WIDTH0, rasterizer->PA_LINE_WIDTH);
/*00A3C*/ EMIT_STATE(PA_WIDE_LINE_WIDTH1, rasterizer->PA_LINE_WIDTH);
}
- if (unlikely(dirty & (ETNA_DIRTY_SCISSOR | ETNA_DIRTY_FRAMEBUFFER |
- ETNA_DIRTY_RASTERIZER | ETNA_DIRTY_VIEWPORT))) {
- /* this is a bit of a mess: rasterizer.scissor determines whether to use
- * only the framebuffer scissor, or specific scissor state, and the
- * viewport clips too so the logic spans four CSOs */
- struct etna_rasterizer_state *rasterizer = etna_rasterizer_state(ctx->rasterizer);
-
- uint32_t scissor_left =
- MAX2(ctx->framebuffer.SE_SCISSOR_LEFT, ctx->viewport.SE_SCISSOR_LEFT);
- uint32_t scissor_top =
- MAX2(ctx->framebuffer.SE_SCISSOR_TOP, ctx->viewport.SE_SCISSOR_TOP);
- uint32_t scissor_right =
- MIN2(ctx->framebuffer.SE_SCISSOR_RIGHT, ctx->viewport.SE_SCISSOR_RIGHT);
- uint32_t scissor_bottom =
- MIN2(ctx->framebuffer.SE_SCISSOR_BOTTOM, ctx->viewport.SE_SCISSOR_BOTTOM);
-
- if (rasterizer->scissor) {
- scissor_left = MAX2(ctx->scissor.SE_SCISSOR_LEFT, scissor_left);
- scissor_top = MAX2(ctx->scissor.SE_SCISSOR_TOP, scissor_top);
- scissor_right = MIN2(ctx->scissor.SE_SCISSOR_RIGHT, scissor_right);
- scissor_bottom = MIN2(ctx->scissor.SE_SCISSOR_BOTTOM, scissor_bottom);
- }
-
- /*00C00*/ EMIT_STATE_FIXP(SE_SCISSOR_LEFT, scissor_left);
- /*00C04*/ EMIT_STATE_FIXP(SE_SCISSOR_TOP, scissor_top);
- /*00C08*/ EMIT_STATE_FIXP(SE_SCISSOR_RIGHT, scissor_right + ETNA_SE_SCISSOR_MARGIN_RIGHT);
- /*00C0C*/ EMIT_STATE_FIXP(SE_SCISSOR_BOTTOM, scissor_bottom + ETNA_SE_SCISSOR_MARGIN_BOTTOM);
+ if (unlikely(dirty & (ETNA_DIRTY_SCISSOR_CLIP))) {
+ /*00C00*/ EMIT_STATE_FIXP(SE_SCISSOR_LEFT, ctx->clipping.SE_SCISSOR_LEFT);
+ /*00C04*/ EMIT_STATE_FIXP(SE_SCISSOR_TOP, ctx->clipping.SE_SCISSOR_TOP);
+ /*00C08*/ EMIT_STATE_FIXP(SE_SCISSOR_RIGHT, ctx->clipping.SE_SCISSOR_RIGHT + ETNA_SE_SCISSOR_MARGIN_RIGHT);
+ /*00C0C*/ EMIT_STATE_FIXP(SE_SCISSOR_BOTTOM, ctx->clipping.SE_SCISSOR_BOTTOM + ETNA_SE_SCISSOR_MARGIN_BOTTOM);
}
if (unlikely(dirty & (ETNA_DIRTY_RASTERIZER))) {
struct etna_rasterizer_state *rasterizer = etna_rasterizer_state(ctx->rasterizer);
/*00C14*/ EMIT_STATE(SE_DEPTH_BIAS, rasterizer->SE_DEPTH_BIAS);
/*00C18*/ EMIT_STATE(SE_CONFIG, rasterizer->SE_CONFIG);
}
- if (unlikely(dirty & (ETNA_DIRTY_SCISSOR | ETNA_DIRTY_FRAMEBUFFER |
- ETNA_DIRTY_RASTERIZER | ETNA_DIRTY_VIEWPORT))) {
- struct etna_rasterizer_state *rasterizer = etna_rasterizer_state(ctx->rasterizer);
-
- uint32_t clip_right =
- MIN2(ctx->framebuffer.SE_SCISSOR_RIGHT, ctx->viewport.SE_SCISSOR_RIGHT);
- uint32_t clip_bottom =
- MIN2(ctx->framebuffer.SE_SCISSOR_BOTTOM, ctx->viewport.SE_SCISSOR_BOTTOM);
-
- if (rasterizer->scissor) {
- clip_right = MIN2(ctx->scissor.SE_SCISSOR_RIGHT, clip_right);
- clip_bottom = MIN2(ctx->scissor.SE_SCISSOR_BOTTOM, clip_bottom);
- }
-
- /*00C20*/ EMIT_STATE_FIXP(SE_CLIP_RIGHT, clip_right + ETNA_SE_CLIP_MARGIN_RIGHT);
- /*00C24*/ EMIT_STATE_FIXP(SE_CLIP_BOTTOM, clip_bottom + ETNA_SE_CLIP_MARGIN_BOTTOM);
+ if (unlikely(dirty & (ETNA_DIRTY_SCISSOR_CLIP))) {
+ /*00C20*/ EMIT_STATE_FIXP(SE_CLIP_RIGHT, ctx->clipping.SE_SCISSOR_RIGHT + ETNA_SE_CLIP_MARGIN_RIGHT);
+ /*00C24*/ EMIT_STATE_FIXP(SE_CLIP_BOTTOM, ctx->clipping.SE_SCISSOR_BOTTOM + ETNA_SE_CLIP_MARGIN_BOTTOM);
}
if (unlikely(dirty & (ETNA_DIRTY_SHADER))) {
/*00E00*/ EMIT_STATE(RA_CONTROL, ctx->shader_state.RA_CONTROL);
#include "etnaviv_clear_blit.h"
#include "etnaviv_context.h"
#include "etnaviv_format.h"
+#include "etnaviv_rasterizer.h"
#include "etnaviv_screen.h"
#include "etnaviv_shader.h"
#include "etnaviv_surface.h"
return true;
}
+static bool
+etna_update_clipping(struct etna_context *ctx)
+{
+ const struct etna_rasterizer_state *rasterizer = etna_rasterizer_state(ctx->rasterizer);
+
+ /* clip framebuffer against viewport */
+ uint32_t scissor_left =
+ MAX2(ctx->framebuffer.SE_SCISSOR_LEFT, ctx->viewport.SE_SCISSOR_LEFT);
+ uint32_t scissor_top =
+ MAX2(ctx->framebuffer.SE_SCISSOR_TOP, ctx->viewport.SE_SCISSOR_TOP);
+ uint32_t scissor_right =
+ MIN2(ctx->framebuffer.SE_SCISSOR_RIGHT, ctx->viewport.SE_SCISSOR_RIGHT);
+ uint32_t scissor_bottom =
+ MIN2(ctx->framebuffer.SE_SCISSOR_BOTTOM, ctx->viewport.SE_SCISSOR_BOTTOM);
+
+ /* clip against scissor */
+ if (rasterizer->scissor) {
+ scissor_left = MAX2(ctx->scissor.SE_SCISSOR_LEFT, scissor_left);
+ scissor_top = MAX2(ctx->scissor.SE_SCISSOR_TOP, scissor_top);
+ scissor_right = MIN2(ctx->scissor.SE_SCISSOR_RIGHT, scissor_right);
+ scissor_bottom = MIN2(ctx->scissor.SE_SCISSOR_BOTTOM, scissor_bottom);
+ }
+
+ ctx->clipping.SE_SCISSOR_LEFT = scissor_left;
+ ctx->clipping.SE_SCISSOR_TOP = scissor_top;
+ ctx->clipping.SE_SCISSOR_RIGHT = scissor_right;
+ ctx->clipping.SE_SCISSOR_BOTTOM = scissor_bottom;
+
+ ctx->dirty |= ETNA_DIRTY_SCISSOR_CLIP;
+
+ return true;
+}
+
struct etna_state_updater {
bool (*update)(struct etna_context *ctx);
uint32_t dirty;
},
{
etna_update_ts_config, ETNA_DIRTY_DERIVE_TS,
+ },
+ {
+ etna_update_clipping, ETNA_DIRTY_SCISSOR | ETNA_DIRTY_FRAMEBUFFER |
+ ETNA_DIRTY_RASTERIZER | ETNA_DIRTY_VIEWPORT,
}
};