#define MALI_OCCLUSION_QUERY (1 << 3)
#define MALI_OCCLUSION_PRECISE (1 << 4)
-#define MALI_FRONT_FACE(v) (v << 5)
-#define MALI_CCW (0)
-#define MALI_CW (1)
+/* Set for a glFrontFace(GL_CCW) in a Y=0=TOP coordinate system (like Gallium).
+ * In OpenGL, this would corresponds to glFrontFace(GL_CW). Mesa and the blob
+ * disagree about how to do viewport flipping, so the blob actually sets this
+ * for GL_CW but then has a negative viewport stride */
+#define MALI_FRONT_CCW_TOP (1 << 5)
#define MALI_CULL_FACE_FRONT (1 << 6)
#define MALI_CULL_FACE_BACK (1 << 7)
.lower_fpow = true,
.lower_find_lsb = true,
+ .lower_wpos_pntc = true,
+
/* TODO: We have native ops to help here, which we'll want to look into
* eventually */
.lower_fsign = true,
const struct pipe_viewport_state *vp = &ctx->pipe_viewport;
- /* For flipped-Y buffers (signaled by negative scale), the translate is
- * flipped as well */
-
- bool invert_y = vp->scale[1] < 0.0;
- float translate_y = vp->translate[1];
-
- if (invert_y)
- translate_y = ctx->pipe_framebuffer.height - translate_y;
-
for (int i = 0; i <= PIPE_SHADER_FRAGMENT; ++i) {
struct panfrost_constant_buffer *buf = &ctx->constant_buffer[i];
if (sysval == PAN_SYSVAL_VIEWPORT_SCALE) {
uniforms[4*i + 0] = vp->scale[0];
- uniforms[4*i + 1] = fabsf(vp->scale[1]);
+ uniforms[4*i + 1] = vp->scale[1];
uniforms[4*i + 2] = vp->scale[2];
} else if (sysval == PAN_SYSVAL_VIEWPORT_OFFSET) {
uniforms[4*i + 0] = vp->translate[0];
- uniforms[4*i + 1] = translate_y;
+ uniforms[4*i + 1] = vp->translate[1];
uniforms[4*i + 2] = vp->translate[2];
} else {
assert(0);
view.viewport0[0] = (int) (vp->translate[0] - vp->scale[0]);
view.viewport1[0] = MALI_POSITIVE((int) (vp->translate[0] + vp->scale[0]));
- view.viewport0[1] = (int) (translate_y - fabs(vp->scale[1]));
- view.viewport1[1] = MALI_POSITIVE((int) (translate_y + fabs(vp->scale[1])));
+ int miny = (int) (vp->translate[1] - vp->scale[1]);
+ int maxy = (int) (vp->translate[1] + vp->scale[1]);
if (ss && ctx->rasterizer && ctx->rasterizer->base.scissor) {
- /* Invert scissor if needed */
- unsigned miny = invert_y ?
- ctx->pipe_framebuffer.height - ss->maxy : ss->miny;
-
- unsigned maxy = invert_y ?
- ctx->pipe_framebuffer.height - ss->miny : ss->maxy;
-
- /* Set the actual scissor */
view.viewport0[0] = ss->minx;
- view.viewport0[1] = miny;
view.viewport1[0] = MALI_POSITIVE(ss->maxx);
- view.viewport1[1] = MALI_POSITIVE(maxy);
+
+ miny = ss->miny;
+ maxy = ss->maxy;
}
+ /* Hardware needs the min/max to be strictly ordered, so flip if we
+ * need to */
+ if (miny > maxy) {
+ int temp = miny;
+ miny = maxy;
+ maxy = temp;
+ }
+
+ view.viewport0[1] = miny;
+ view.viewport1[1] = MALI_POSITIVE(maxy);
+
ctx->payload_tiler.postfix.viewport =
panfrost_upload_transient(ctx,
&view,
/* Bitmask, unknown meaning of the start value */
so->tiler_gl_enables = ctx->is_t6xx ? 0x105 : 0x7;
- so->tiler_gl_enables |= MALI_FRONT_FACE(
- cso->front_ccw ? MALI_CCW : MALI_CW);
+ if (cso->front_ccw)
+ so->tiler_gl_enables |= MALI_FRONT_CCW_TOP;
if (cso->cull_face & PIPE_FACE_FRONT)
so->tiler_gl_enables |= MALI_CULL_FACE_FRONT;
assert(num_viewports == 1);
ctx->pipe_viewport = *viewports;
-
-#if 0
- /* TODO: What if not centered? */
- float w = abs(viewports->scale[0]) * 2.0;
- float h = abs(viewports->scale[1]) * 2.0;
-
- ctx->viewport.viewport1[0] = MALI_POSITIVE((int) w);
- ctx->viewport.viewport1[1] = MALI_POSITIVE((int) h);
-#endif
}
static void
bool
panfrost_is_scanout(struct panfrost_context *ctx);
-mali_ptr
-panfrost_sfbd_fragment(struct panfrost_context *ctx, bool flip_y);
-
-mali_ptr
-panfrost_mfbd_fragment(struct panfrost_context *ctx, bool flip_y);
+mali_ptr panfrost_sfbd_fragment(struct panfrost_context *ctx);
+mali_ptr panfrost_mfbd_fragment(struct panfrost_context *ctx);
struct bifrost_framebuffer
panfrost_emit_mfbd(struct panfrost_context *ctx);
mali_ptr
panfrost_fragment_job(struct panfrost_context *ctx)
{
- /* TODO: Check viewport or something */
- bool flip_y = panfrost_is_scanout(ctx);
-
mali_ptr framebuffer = ctx->require_sfbd ?
- panfrost_sfbd_fragment(ctx, flip_y) :
- panfrost_mfbd_fragment(ctx, flip_y);
+ panfrost_sfbd_fragment(ctx) :
+ panfrost_mfbd_fragment(ctx);
struct mali_job_descriptor_header header = {
.job_type = JOB_TYPE_FRAGMENT,
static void
panfrost_mfbd_set_cbuf(
struct bifrost_render_target *rt,
- struct pipe_surface *surf,
- bool flip_y)
+ struct pipe_surface *surf)
{
struct panfrost_resource *rsrc = pan_resource(surf->texture);
int stride = rsrc->bo->slices[0].stride;
/* Now, we set the layout specific pieces */
if (rsrc->bo->layout == PAN_LINEAR) {
- mali_ptr framebuffer = rsrc->bo->gpu;
-
- if (flip_y) {
- framebuffer += stride * (surf->texture->height0 - 1);
- stride = -stride;
- }
-
- rt->framebuffer = framebuffer;
+ rt->framebuffer = rsrc->bo->gpu;
rt->framebuffer_stride = stride / 16;
} else if (rsrc->bo->layout == PAN_AFBC) {
rt->afbc.metadata = rsrc->bo->afbc_slab.gpu;
/* Creates an MFBD for the FRAGMENT section of the bound framebuffer */
mali_ptr
-panfrost_mfbd_fragment(struct panfrost_context *ctx, bool flip_y)
+panfrost_mfbd_fragment(struct panfrost_context *ctx)
{
struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
for (int cb = 0; cb < ctx->pipe_framebuffer.nr_cbufs; ++cb) {
struct pipe_surface *surf = ctx->pipe_framebuffer.cbufs[cb];
- panfrost_mfbd_set_cbuf(&rts[cb], surf, flip_y);
+ panfrost_mfbd_set_cbuf(&rts[cb], surf);
}
if (ctx->pipe_framebuffer.zsbuf) {
case PIPE_CAP_INDEP_BLEND_FUNC:
return 1;
- case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
+ /* Hardware is natively upper left */
+ return 0;
+
+ case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
+ return 1;
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
return 1;
static void
panfrost_sfbd_set_cbuf(
struct mali_single_framebuffer *fb,
- struct pipe_surface *surf,
- bool flip_y)
+ struct pipe_surface *surf)
{
struct panfrost_resource *rsrc = pan_resource(surf->texture);
fb->format = panfrost_sfbd_format(surf);
if (rsrc->bo->layout == PAN_LINEAR) {
- mali_ptr framebuffer = rsrc->bo->gpu;
-
- /* The default is upside down from OpenGL's perspective. */
- if (flip_y) {
- framebuffer += stride * (surf->texture->height0 - 1);
- stride = -stride;
- }
-
- fb->framebuffer = framebuffer;
+ fb->framebuffer = rsrc->bo->gpu;
fb->stride = stride;
} else {
fprintf(stderr, "Invalid render layout\n");
/* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
mali_ptr
-panfrost_sfbd_fragment(struct panfrost_context *ctx, bool flip_y)
+panfrost_sfbd_fragment(struct panfrost_context *ctx)
{
struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx);
/* SFBD does not support MRT natively; sanity check */
assert(ctx->pipe_framebuffer.nr_cbufs == 1);
- panfrost_sfbd_set_cbuf(&fb, ctx->pipe_framebuffer.cbufs[0], flip_y);
+ panfrost_sfbd_set_cbuf(&fb, ctx->pipe_framebuffer.cbufs[0]);
if (ctx->pipe_framebuffer.zsbuf) {
/* TODO */
#define FLAG_INFO(flag) { MALI_##flag, "MALI_" #flag }
static const struct pandecode_flag_info gl_enable_flag_info[] = {
- FLAG_INFO(CULL_FACE_FRONT),
- FLAG_INFO(CULL_FACE_BACK),
FLAG_INFO(OCCLUSION_QUERY),
FLAG_INFO(OCCLUSION_PRECISE),
+ FLAG_INFO(FRONT_CCW_TOP),
+ FLAG_INFO(CULL_FACE_FRONT),
+ FLAG_INFO(CULL_FACE_BACK),
{}
};
#undef FLAG_INFO
{
pandecode_log(".gl_enables = ");
- if (job_type == JOB_TYPE_TILER) {
- pandecode_log_cont("MALI_FRONT_FACE(MALI_%s) | ",
- gl_enables & MALI_FRONT_FACE(MALI_CW) ? "CW" : "CCW");
-
- gl_enables &= ~(MALI_FRONT_FACE(1));
- }
-
pandecode_log_decoded_flags(gl_enable_flag_info, gl_enables);
pandecode_log_cont(",\n");