Commit 946cf4eb authored by Rob Clark's avatar Rob Clark

freedreno/a5xx: initial support

Signed-off-by: Rob Clark's avatarRob Clark <robdclark@gmail.com>
parent fcba3046
......@@ -74,7 +74,7 @@ LIBDRM_AMDGPU_REQUIRED=2.4.63
LIBDRM_INTEL_REQUIRED=2.4.61
LIBDRM_NVVIEUX_REQUIRED=2.4.66
LIBDRM_NOUVEAU_REQUIRED=2.4.66
LIBDRM_FREEDRENO_REQUIRED=2.4.68
LIBDRM_FREEDRENO_REQUIRED=2.4.74
LIBDRM_VC4_REQUIRED=2.4.69
DRI2PROTO_REQUIRED=2.6
DRI3PROTO_REQUIRED=1.0
......
......@@ -20,6 +20,7 @@ libfreedreno_la_SOURCES = \
$(a2xx_SOURCES) \
$(a3xx_SOURCES) \
$(a4xx_SOURCES) \
$(a5xx_SOURCES) \
$(ir3_SOURCES) \
$(ir3_GENERATED_FILES)
......
......@@ -120,6 +120,33 @@ a4xx_SOURCES := \
a4xx/fd4_zsa.c \
a4xx/fd4_zsa.h
a5xx_SOURCES := \
a5xx/a5xx.xml.h \
a5xx/fd5_blend.c \
a5xx/fd5_blend.h \
a5xx/fd5_context.c \
a5xx/fd5_context.h \
a5xx/fd5_draw.c \
a5xx/fd5_draw.h \
a5xx/fd5_emit.c \
a5xx/fd5_emit.h \
a5xx/fd5_format.c \
a5xx/fd5_format.h \
a5xx/fd5_gmem.c \
a5xx/fd5_gmem.h \
a5xx/fd5_program.c \
a5xx/fd5_program.h \
a5xx/fd5_query.c \
a5xx/fd5_query.h \
a5xx/fd5_rasterizer.c \
a5xx/fd5_rasterizer.h \
a5xx/fd5_screen.c \
a5xx/fd5_screen.h \
a5xx/fd5_texture.c \
a5xx/fd5_texture.h \
a5xx/fd5_zsa.c \
a5xx/fd5_zsa.h
ir3_SOURCES := \
ir3/disasm-a3xx.c \
ir3/instr-a3xx.h \
......
/*
* Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
*/
#include "pipe/p_state.h"
#include "util/u_blend.h"
#include "util/u_string.h"
#include "util/u_memory.h"
#include "fd5_blend.h"
#include "fd5_context.h"
#include "fd5_format.h"
// XXX move somewhere common.. same across a3xx/a4xx/a5xx..
static enum a3xx_rb_blend_opcode
blend_func(unsigned func)
{
switch (func) {
case PIPE_BLEND_ADD:
return BLEND_DST_PLUS_SRC;
case PIPE_BLEND_MIN:
return BLEND_MIN_DST_SRC;
case PIPE_BLEND_MAX:
return BLEND_MAX_DST_SRC;
case PIPE_BLEND_SUBTRACT:
return BLEND_SRC_MINUS_DST;
case PIPE_BLEND_REVERSE_SUBTRACT:
return BLEND_DST_MINUS_SRC;
default:
DBG("invalid blend func: %x", func);
return 0;
}
}
void *
fd5_blend_state_create(struct pipe_context *pctx,
const struct pipe_blend_state *cso)
{
struct fd5_blend_stateobj *so;
// enum a3xx_rop_code rop = ROP_COPY;
bool reads_dest = false;
unsigned i, mrt_blend = 0;
if (cso->logicop_enable) {
// rop = cso->logicop_func; /* maps 1:1 */
switch (cso->logicop_func) {
case PIPE_LOGICOP_NOR:
case PIPE_LOGICOP_AND_INVERTED:
case PIPE_LOGICOP_AND_REVERSE:
case PIPE_LOGICOP_INVERT:
case PIPE_LOGICOP_XOR:
case PIPE_LOGICOP_NAND:
case PIPE_LOGICOP_AND:
case PIPE_LOGICOP_EQUIV:
case PIPE_LOGICOP_NOOP:
case PIPE_LOGICOP_OR_INVERTED:
case PIPE_LOGICOP_OR_REVERSE:
case PIPE_LOGICOP_OR:
reads_dest = true;
break;
}
}
so = CALLOC_STRUCT(fd5_blend_stateobj);
if (!so)
return NULL;
so->base = *cso;
for (i = 0; i < ARRAY_SIZE(so->rb_mrt); i++) {
const struct pipe_rt_blend_state *rt;
if (cso->independent_blend_enable)
rt = &cso->rt[i];
else
rt = &cso->rt[0];
so->rb_mrt[i].blend_control_rgb =
A5XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(fd_blend_factor(rt->rgb_src_factor)) |
A5XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(blend_func(rt->rgb_func)) |
A5XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(rt->rgb_dst_factor));
so->rb_mrt[i].blend_control_alpha =
A5XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR(fd_blend_factor(rt->alpha_src_factor)) |
A5XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE(blend_func(rt->alpha_func)) |
A5XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(fd_blend_factor(rt->alpha_dst_factor));
so->rb_mrt[i].blend_control_no_alpha_rgb =
A5XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_src_factor))) |
A5XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(blend_func(rt->rgb_func)) |
A5XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_dst_factor)));
so->rb_mrt[i].control =
// A5XX_RB_MRT_CONTROL_ROP_CODE(rop) |
// COND(cso->logicop_enable, A5XX_RB_MRT_CONTROL_ROP_ENABLE) |
0x60 | /* XXX set other than RECTLIST clear blits?? */
A5XX_RB_MRT_CONTROL_COMPONENT_ENABLE(rt->colormask);
if (rt->blend_enable) {
so->rb_mrt[i].control |=
// A5XX_RB_MRT_CONTROL_READ_DEST_ENABLE |
A5XX_RB_MRT_CONTROL_BLEND |
A5XX_RB_MRT_CONTROL_BLEND2;
mrt_blend |= (1 << i);
}
if (reads_dest) {
// so->rb_mrt[i].control |= A5XX_RB_MRT_CONTROL_READ_DEST_ENABLE;
mrt_blend |= (1 << i);
}
// if (cso->dither)
// so->rb_mrt[i].buf_info |= A5XX_RB_MRT_BUF_INFO_DITHER_MODE(DITHER_ALWAYS);
}
so->rb_blend_cntl = A5XX_RB_BLEND_CNTL_ENABLE_BLEND(mrt_blend) |
COND(cso->independent_blend_enable, A5XX_RB_BLEND_CNTL_INDEPENDENT_BLEND);
return so;
}
/*
* Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
*/
#ifndef FD5_BLEND_H_
#define FD5_BLEND_H_
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "freedreno_util.h"
struct fd5_blend_stateobj {
struct pipe_blend_state base;
struct {
uint32_t control;
uint32_t buf_info;
/* Blend control bits for color if there is an alpha channel */
uint32_t blend_control_rgb;
/* Blend control bits for color if there is no alpha channel */
uint32_t blend_control_no_alpha_rgb;
/* Blend control bits for alpha channel */
uint32_t blend_control_alpha;
} rb_mrt[A5XX_MAX_RENDER_TARGETS];
uint32_t rb_blend_cntl;
};
static inline struct fd5_blend_stateobj *
fd5_blend_stateobj(struct pipe_blend_state *blend)
{
return (struct fd5_blend_stateobj *)blend;
}
void * fd5_blend_state_create(struct pipe_context *pctx,
const struct pipe_blend_state *cso);
#endif /* FD5_BLEND_H_ */
/*
* Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
*/
#include "fd5_context.h"
#include "fd5_blend.h"
#include "fd5_draw.h"
#include "fd5_emit.h"
#include "fd5_gmem.h"
#include "fd5_program.h"
#include "fd5_query.h"
#include "fd5_rasterizer.h"
#include "fd5_texture.h"
#include "fd5_zsa.h"
static void
fd5_context_destroy(struct pipe_context *pctx)
{
struct fd5_context *fd5_ctx = fd5_context(fd_context(pctx));
fd_bo_del(fd5_ctx->vs_pvt_mem);
fd_bo_del(fd5_ctx->fs_pvt_mem);
fd_bo_del(fd5_ctx->vsc_size_mem);
fd_bo_del(fd5_ctx->blit_mem);
fd_context_cleanup_common_vbos(&fd5_ctx->base);
u_upload_destroy(fd5_ctx->border_color_uploader);
fd_context_destroy(pctx);
}
static const uint8_t primtypes[] = {
[PIPE_PRIM_POINTS] = DI_PT_POINTLIST,
[PIPE_PRIM_LINES] = DI_PT_LINELIST,
[PIPE_PRIM_LINE_STRIP] = DI_PT_LINESTRIP,
[PIPE_PRIM_LINE_LOOP] = DI_PT_LINELOOP,
[PIPE_PRIM_TRIANGLES] = DI_PT_TRILIST,
[PIPE_PRIM_TRIANGLE_STRIP] = DI_PT_TRISTRIP,
[PIPE_PRIM_TRIANGLE_FAN] = DI_PT_TRIFAN,
[PIPE_PRIM_MAX] = DI_PT_RECTLIST, /* internal clear blits */
};
struct pipe_context *
fd5_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
{
struct fd_screen *screen = fd_screen(pscreen);
struct fd5_context *fd5_ctx = CALLOC_STRUCT(fd5_context);
struct pipe_context *pctx;
if (!fd5_ctx)
return NULL;
pctx = &fd5_ctx->base.base;
fd5_ctx->base.dev = fd_device_ref(screen->dev);
fd5_ctx->base.screen = fd_screen(pscreen);
pctx->destroy = fd5_context_destroy;
pctx->create_blend_state = fd5_blend_state_create;
pctx->create_rasterizer_state = fd5_rasterizer_state_create;
pctx->create_depth_stencil_alpha_state = fd5_zsa_state_create;
fd5_draw_init(pctx);
fd5_gmem_init(pctx);
fd5_texture_init(pctx);
fd5_prog_init(pctx);
fd5_emit_init(pctx);
pctx = fd_context_init(&fd5_ctx->base, pscreen, primtypes, priv);
if (!pctx)
return NULL;
fd5_ctx->vs_pvt_mem = fd_bo_new(screen->dev, 0x2000,
DRM_FREEDRENO_GEM_TYPE_KMEM);
fd5_ctx->fs_pvt_mem = fd_bo_new(screen->dev, 0x2000,
DRM_FREEDRENO_GEM_TYPE_KMEM);
fd5_ctx->vsc_size_mem = fd_bo_new(screen->dev, 0x1000,
DRM_FREEDRENO_GEM_TYPE_KMEM);
fd5_ctx->blit_mem = fd_bo_new(screen->dev, 0x1000,
DRM_FREEDRENO_GEM_TYPE_KMEM);
fd_context_setup_common_vbos(&fd5_ctx->base);
fd5_query_context_init(pctx);
fd5_ctx->border_color_uploader = u_upload_create(pctx, 4096, 0,
PIPE_USAGE_STREAM);
return pctx;
}
/*
* Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
*/
#ifndef FD5_CONTEXT_H_
#define FD5_CONTEXT_H_
#include "util/u_upload_mgr.h"
#include "freedreno_drmif.h"
#include "freedreno_context.h"
#include "ir3_shader.h"
struct fd5_context {
struct fd_context base;
struct fd_bo *vs_pvt_mem, *fs_pvt_mem;
/* This only needs to be 4 * num_of_pipes bytes (ie. 32 bytes). We
* could combine it with another allocation.
*
* (upper area used as scratch bo.. see fd5_query)
*
* XXX remove if unneeded after binning r/e..
*/
struct fd_bo *vsc_size_mem;
/* TODO not sure what this is for.. */
struct fd_bo *blit_mem;
struct u_upload_mgr *border_color_uploader;
struct pipe_resource *border_color_buf;
/* if *any* of bits are set in {v,f}saturate_{s,t,r} */
bool vsaturate, fsaturate;
/* bitmask of sampler which needs coords clamped for vertex
* shader:
*/
uint16_t vsaturate_s, vsaturate_t, vsaturate_r;
/* bitmask of sampler which needs coords clamped for frag
* shader:
*/
uint16_t fsaturate_s, fsaturate_t, fsaturate_r;
/* bitmask of samplers which need astc srgb workaround: */
uint16_t vastc_srgb, fastc_srgb;
/* some state changes require a different shader variant. Keep
* track of this so we know when we need to re-emit shader state
* due to variant change. See fixup_shader_state()
*/
struct ir3_shader_key last_key;
};
static inline struct fd5_context *
fd5_context(struct fd_context *ctx)
{
return (struct fd5_context *)ctx;
}
struct pipe_context *
fd5_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);
#endif /* FD5_CONTEXT_H_ */
/*
* Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
*/
#include "pipe/p_state.h"
#include "util/u_string.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
#include "freedreno_state.h"
#include "freedreno_resource.h"
#include "fd5_draw.h"
#include "fd5_context.h"
#include "fd5_emit.h"
#include "fd5_program.h"
#include "fd5_format.h"
#include "fd5_zsa.h"
static void
draw_impl(struct fd_context *ctx, struct fd_ringbuffer *ring,
struct fd5_emit *emit)
{
const struct pipe_draw_info *info = emit->info;
enum pc_di_primtype primtype = ctx->primtypes[info->mode];
fd5_emit_state(ctx, ring, emit);
if (emit->dirty & (FD_DIRTY_VTXBUF | FD_DIRTY_VTXSTATE))
fd5_emit_vertex_bufs(ring, emit);
OUT_PKT4(ring, REG_A5XX_VFD_INDEX_OFFSET, 2);
OUT_RING(ring, info->indexed ? info->index_bias : info->start); /* VFD_INDEX_OFFSET */
OUT_RING(ring, info->start_instance); /* ??? UNKNOWN_2209 */
OUT_PKT4(ring, REG_A5XX_PC_RESTART_INDEX, 1);
OUT_RING(ring, info->primitive_restart ? /* PC_RESTART_INDEX */
info->restart_index : 0xffffffff);
/* points + psize -> spritelist: */
if (ctx->rasterizer->point_size_per_vertex &&
fd5_emit_get_vp(emit)->writes_psize &&
(info->mode == PIPE_PRIM_POINTS))
primtype = DI_PT_POINTLIST_PSIZE;
fd5_emit_render_cntl(ctx, false);
fd5_draw_emit(ctx->batch, ring, primtype,
emit->key.binning_pass ? IGNORE_VISIBILITY : USE_VISIBILITY,
info);
}
/* fixup dirty shader state in case some "unrelated" (from the state-
* tracker's perspective) state change causes us to switch to a
* different variant.
*/
static void
fixup_shader_state(struct fd_context *ctx, struct ir3_shader_key *key)
{
struct fd5_context *fd5_ctx = fd5_context(ctx);
struct ir3_shader_key *last_key = &fd5_ctx->last_key;
if (!ir3_shader_key_equal(last_key, key)) {
if (last_key->has_per_samp || key->has_per_samp) {
if ((last_key->vsaturate_s != key->vsaturate_s) ||
(last_key->vsaturate_t != key->vsaturate_t) ||
(last_key->vsaturate_r != key->vsaturate_r) ||
(last_key->vastc_srgb != key->vastc_srgb))
ctx->dirty |= FD_SHADER_DIRTY_VP;
if ((last_key->fsaturate_s != key->fsaturate_s) ||
(last_key->fsaturate_t != key->fsaturate_t) ||
(last_key->fsaturate_r != key->fsaturate_r) ||
(last_key->fastc_srgb != key->fastc_srgb))
ctx->dirty |= FD_SHADER_DIRTY_FP;
}
if (last_key->vclamp_color != key->vclamp_color)
ctx->dirty |= FD_SHADER_DIRTY_VP;
if (last_key->fclamp_color != key->fclamp_color)
ctx->dirty |= FD_SHADER_DIRTY_FP;
if (last_key->color_two_side != key->color_two_side)
ctx->dirty |= FD_SHADER_DIRTY_FP;
if (last_key->half_precision != key->half_precision)
ctx->dirty |= FD_SHADER_DIRTY_FP;
if (last_key->rasterflat != key->rasterflat)
ctx->dirty |= FD_SHADER_DIRTY_FP;
if (last_key->ucp_enables != key->ucp_enables)
ctx->dirty |= FD_SHADER_DIRTY_FP | FD_SHADER_DIRTY_VP;
fd5_ctx->last_key = *key;
}
}
static bool
fd5_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info)
{
struct fd5_context *fd5_ctx = fd5_context(ctx);
struct fd5_emit emit = {
.debug = &ctx->debug,
.vtx = &ctx->vtx,
.prog = &ctx->prog,
.info = info,
.key = {
.color_two_side = ctx->rasterizer->light_twoside,
.vclamp_color = ctx->rasterizer->clamp_vertex_color,
.fclamp_color = ctx->rasterizer->clamp_fragment_color,
.rasterflat = ctx->rasterizer->flatshade,
.half_precision = ctx->in_blit &&
fd_half_precision(&ctx->batch->framebuffer),
.ucp_enables = ctx->rasterizer->clip_plane_enable,
.has_per_samp = (fd5_ctx->fsaturate || fd5_ctx->vsaturate ||
fd5_ctx->fastc_srgb || fd5_ctx->vastc_srgb),
.vsaturate_s = fd5_ctx->vsaturate_s,
.vsaturate_t = fd5_ctx->vsaturate_t,
.vsaturate_r = fd5_ctx->vsaturate_r,
.fsaturate_s = fd5_ctx->fsaturate_s,
.fsaturate_t = fd5_ctx->fsaturate_t,
.fsaturate_r = fd5_ctx->fsaturate_r,
.vastc_srgb = fd5_ctx->vastc_srgb,
.fastc_srgb = fd5_ctx->fastc_srgb,
},
.rasterflat = ctx->rasterizer->flatshade,
.sprite_coord_enable = ctx->rasterizer->sprite_coord_enable,
.sprite_coord_mode = ctx->rasterizer->sprite_coord_mode,
};
fixup_shader_state(ctx, &emit.key);
unsigned dirty = ctx->dirty;
/* do regular pass first, since that is more likely to fail compiling: */
if (!(fd5_emit_get_vp(&emit) && fd5_emit_get_fp(&emit)))
return false;
emit.key.binning_pass = false;
emit.dirty = dirty;
draw_impl(ctx, ctx->batch->draw, &emit);
// /* and now binning pass: */
// emit.key.binning_pass = true;
// emit.dirty = dirty & ~(FD_DIRTY_BLEND);
// emit.vp = NULL; /* we changed key so need to refetch vp */
// emit.fp = NULL;
// draw_impl(ctx, ctx->batch->binning, &emit);
return true;
}
static void
fd5_clear(struct fd_context *ctx, unsigned buffers,
const union pipe_color_union *color, double depth, unsigned stencil)
{
struct fd_ringbuffer *ring = ctx->batch->draw;
struct pipe_framebuffer_state *pfb = &ctx->batch->framebuffer;
struct pipe_scissor_state *scissor = fd_context_get_scissor(ctx);
/* TODO handle scissor.. or fallback to slow-clear? */
ctx->batch->max_scissor.minx = MIN2(ctx->batch->max_scissor.minx, scissor->minx);
ctx->batch->max_scissor.miny = MIN2(ctx->batch->max_scissor.miny, scissor->miny);
ctx->batch->max_scissor.maxx = MAX2(ctx->batch->max_scissor.maxx, scissor->maxx);
ctx->batch->max_scissor.maxy = MAX2(ctx->batch->max_scissor.maxy, scissor->maxy);
fd5_emit_render_cntl(ctx, true);
if (buffers & PIPE_CLEAR_COLOR) {
for (int i = 0; i < pfb->nr_cbufs; i++) {
union util_color uc = {0};
if (!pfb->cbufs[i])
continue;
if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
continue;
// XXX I think RB_CLEAR_COLOR_DWn wants to take into account SWAP??
float f[4];
switch (fd5_pipe2swap(pfb->cbufs[i]->format)) {
case WZYX:
f[0] = color->f[0];
f[1] = color->f[1];
f[2] = color->f[2];
f[3] = color->f[3];
break;
case WXYZ:
f[2] = color->f[0];
f[1] = color->f[1];
f[0] = color->f[2];
f[3] = color->f[3];
break;
case ZYXW:
f[3] = color->f[0];
f[0] = color->f[1];
f[1] = color->f[2];
f[2] = color->f[3];
break;
case XYZW:
f[3] = color->f[0];
f[2] = color->f[1];
f[1] = color->f[2];
f[0] = color->f[3];
break;
}
util_pack_color(f, pfb->cbufs[i]->format, &uc);
OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1);
OUT_RING(ring, A5XX_RB_BLIT_CNTL_BUF(BLIT_MRT0 + i));
OUT_PKT4(ring, REG_A5XX_RB_CLEAR_CNTL, 1);
OUT_RING(ring, A5XX_RB_CLEAR_CNTL_FAST_CLEAR |
A5XX_RB_CLEAR_CNTL_MASK(0xf));