static void setup_combiners(NVPtr pNv, PicturePtr src, PicturePtr mask) { struct nouveau_channel *chan = pNv->chan; uint32_t rc_in_alpha = 0, rc_in_rgb = 0; if (PICT_FORMAT_A(src->format)) rc_in_alpha |= RC_IN_TEX(A, ALPHA, 0); else rc_in_alpha |= RC_IN_ONE(A); if (mask && PICT_FORMAT_A(mask->format)) rc_in_alpha |= RC_IN_TEX(B, ALPHA, 1); else rc_in_alpha |= RC_IN_ONE(B); if (effective_component_alpha(mask)) { if (!needs_src_alpha(pNv->alu)) { /* The alpha channels won't be used for blending. Drop * them, as our pixels only have 4 components... * output_i = src_i * mask_i */ if (PICT_FORMAT_RGB(src->format)) rc_in_rgb |= RC_IN_TEX(A, RGB, 0); } else { /* The RGB channels won't be used for blending. Drop * them. * output_i = src_alpha * mask_i */ if (PICT_FORMAT_A(src->format)) rc_in_rgb |= RC_IN_TEX(A, ALPHA, 0); else rc_in_rgb |= RC_IN_ONE(A); } rc_in_rgb |= RC_IN_TEX(B, RGB, 1); } else { if (PICT_FORMAT_RGB(src->format)) rc_in_rgb |= RC_IN_TEX(A, RGB, 0); if (mask && PICT_FORMAT_A(mask->format)) rc_in_rgb |= RC_IN_TEX(B, ALPHA, 1); else rc_in_rgb |= RC_IN_ONE(B); } BEGIN_NV04(chan, NV10_3D(RC_IN_ALPHA(0)), 1); OUT_RING (chan, rc_in_alpha); BEGIN_NV04(chan, NV10_3D(RC_IN_RGB(0)), 1); OUT_RING (chan, rc_in_rgb); }
Bool NV10EXAPrepareComposite(int op, PicturePtr pict_src, PicturePtr pict_mask, PicturePtr pict_dst, PixmapPtr src, PixmapPtr mask, PixmapPtr dst) { ScrnInfoPtr pScrn = xf86ScreenToScrn(dst->drawable.pScreen); NVPtr pNv = NVPTR(pScrn); struct nouveau_pushbuf *push = pNv->pushbuf; uint32_t sc, sa, mc, ma; if (!PUSH_SPACE(push, 128)) return FALSE; PUSH_RESET(push); /* setup render target and blending */ if (!setup_render_target(pNv, pict_dst, dst)) return FALSE; setup_blend_function(pNv, pict_dst, op); /* select picture sources */ if (!setup_picture(pNv, pict_src, src, 0, &sc, &sa)) return FALSE; if (!setup_picture(pNv, pict_mask, mask, 1, &mc, &ma)) return FALSE; /* configure register combiners */ BEGIN_NV04(push, NV10_3D(RC_IN_ALPHA(0)), 1); PUSH_DATA (push, sa | ma); BEGIN_NV04(push, NV10_3D(RC_IN_RGB(0)), 1); if (effective_component_alpha(pict_mask)) { if (needs_src_alpha(op)) PUSH_DATA(push, sa | mc); else PUSH_DATA(push, sc | mc); } else { PUSH_DATA(push, sc | ma); } nouveau_pushbuf_bufctx(push, pNv->bufctx); if (nouveau_pushbuf_validate(push)) { nouveau_pushbuf_bufctx(push, NULL); return FALSE; } pNv->pspict = pict_src; pNv->pmpict = pict_mask; return TRUE; }
static void nv20_hwctx_init(struct gl_context *ctx) { struct nouveau_pushbuf *push = context_push(ctx); struct nouveau_hw_state *hw = &to_nouveau_context(ctx)->hw; struct nv04_fifo *fifo = hw->chan->data; int i; BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1); PUSH_DATA (push, hw->eng3d->handle); BEGIN_NV04(push, NV20_3D(DMA_NOTIFY), 1); PUSH_DATA (push, hw->ntfy->handle); BEGIN_NV04(push, NV20_3D(DMA_TEXTURE0), 2); PUSH_DATA (push, fifo->vram); PUSH_DATA (push, fifo->gart); BEGIN_NV04(push, NV20_3D(DMA_COLOR), 2); PUSH_DATA (push, fifo->vram); PUSH_DATA (push, fifo->vram); BEGIN_NV04(push, NV20_3D(DMA_VTXBUF0), 2); PUSH_DATA (push, fifo->vram); PUSH_DATA (push, fifo->gart); BEGIN_NV04(push, NV20_3D(DMA_QUERY), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RT_HORIZ), 2); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(0)), 1); PUSH_DATA (push, 0xfff << 16 | 0x0); BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(0)), 1); PUSH_DATA (push, 0xfff << 16 | 0x0); for (i = 1; i < NV20_3D_VIEWPORT_CLIP_HORIZ__LEN; i++) { BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_HORIZ(i)), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_VERT(i)), 1); PUSH_DATA (push, 0); } BEGIN_NV04(push, NV20_3D(VIEWPORT_CLIP_MODE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, SUBC_3D(0x17e0), 3); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 1.0); if (context_chipset(ctx) >= 0x25) { BEGIN_NV04(push, NV20_3D(TEX_RCOMP), 1); PUSH_DATA (push, NV20_3D_TEX_RCOMP_LEQUAL | 0xdb0); } else { BEGIN_NV04(push, SUBC_3D(0x1e68), 1); PUSH_DATA (push, 0x4b800000); /* 16777216.000000 */ BEGIN_NV04(push, NV20_3D(TEX_RCOMP), 1); PUSH_DATA (push, NV20_3D_TEX_RCOMP_LEQUAL); } BEGIN_NV04(push, SUBC_3D(0x290), 1); PUSH_DATA (push, 0x10 << 16 | 1); BEGIN_NV04(push, SUBC_3D(0x9fc), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, SUBC_3D(0x1d80), 1); PUSH_DATA (push, 1); BEGIN_NV04(push, SUBC_3D(0x9f8), 1); PUSH_DATA (push, 4); BEGIN_NV04(push, SUBC_3D(0x17ec), 3); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 0.0); if (context_chipset(ctx) >= 0x25) { BEGIN_NV04(push, SUBC_3D(0x1d88), 1); PUSH_DATA (push, 3); BEGIN_NV04(push, NV25_3D(DMA_HIERZ), 1); PUSH_DATA (push, fifo->vram); BEGIN_NV04(push, NV25_3D(UNK01AC), 1); PUSH_DATA (push, fifo->vram); } BEGIN_NV04(push, NV20_3D(DMA_FENCE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, SUBC_3D(0x1e98), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV04_GRAPH(3D, NOTIFY), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, SUBC_3D(0x120), 3); PUSH_DATA (push, 0); PUSH_DATA (push, 1); PUSH_DATA (push, 2); if (context_chipset(ctx) >= 0x25) { BEGIN_NV04(push, SUBC_3D(0x1da4), 1); PUSH_DATA (push, 0); } BEGIN_NV04(push, NV20_3D(RT_HORIZ), 2); PUSH_DATA (push, 0 << 16 | 0); PUSH_DATA (push, 0 << 16 | 0); BEGIN_NV04(push, NV20_3D(ALPHA_FUNC_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(ALPHA_FUNC_FUNC), 2); PUSH_DATA (push, NV20_3D_ALPHA_FUNC_FUNC_ALWAYS); PUSH_DATA (push, 0); for (i = 0; i < NV20_3D_TEX__LEN; i++) { BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1); PUSH_DATA (push, 0); } BEGIN_NV04(push, NV20_3D(TEX_SHADER_OP), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(TEX_SHADER_CULL_MODE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RC_IN_ALPHA(0)), 4); PUSH_DATA (push, 0x30d410d0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RC_OUT_RGB(0)), 4); PUSH_DATA (push, 0x00000c00); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1); PUSH_DATA (push, 0x00011101); BEGIN_NV04(push, NV20_3D(RC_FINAL0), 2); PUSH_DATA (push, 0x130e0300); PUSH_DATA (push, 0x0c091c80); BEGIN_NV04(push, NV20_3D(RC_OUT_ALPHA(0)), 4); PUSH_DATA (push, 0x00000c00); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RC_IN_RGB(0)), 4); PUSH_DATA (push, 0x20c400c0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RC_COLOR0), 2); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(RC_CONSTANT_COLOR0(0)), 4); PUSH_DATA (push, 0x035125a0); PUSH_DATA (push, 0); PUSH_DATA (push, 0x40002000); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(MULTISAMPLE_CONTROL), 1); PUSH_DATA (push, 0xffff0000); BEGIN_NV04(push, NV20_3D(BLEND_FUNC_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(DITHER_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(STENCIL_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(BLEND_FUNC_SRC), 4); PUSH_DATA (push, NV20_3D_BLEND_FUNC_SRC_ONE); PUSH_DATA (push, NV20_3D_BLEND_FUNC_DST_ZERO); PUSH_DATA (push, 0); PUSH_DATA (push, NV20_3D_BLEND_EQUATION_FUNC_ADD); BEGIN_NV04(push, NV20_3D(STENCIL_MASK), 7); PUSH_DATA (push, 0xff); PUSH_DATA (push, NV20_3D_STENCIL_FUNC_FUNC_ALWAYS); PUSH_DATA (push, 0); PUSH_DATA (push, 0xff); PUSH_DATA (push, NV20_3D_STENCIL_OP_FAIL_KEEP); PUSH_DATA (push, NV20_3D_STENCIL_OP_ZFAIL_KEEP); PUSH_DATA (push, NV20_3D_STENCIL_OP_ZPASS_KEEP); BEGIN_NV04(push, NV20_3D(COLOR_LOGIC_OP_ENABLE), 2); PUSH_DATA (push, 0); PUSH_DATA (push, NV20_3D_COLOR_LOGIC_OP_OP_COPY); BEGIN_NV04(push, SUBC_3D(0x17cc), 1); PUSH_DATA (push, 0); if (context_chipset(ctx) >= 0x25) { BEGIN_NV04(push, SUBC_3D(0x1d84), 1); PUSH_DATA (push, 1); } BEGIN_NV04(push, NV20_3D(LIGHTING_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(LIGHT_MODEL), 1); PUSH_DATA (push, NV20_3D_LIGHT_MODEL_VIEWER_NONLOCAL); BEGIN_NV04(push, NV20_3D(SEPARATE_SPECULAR_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(LIGHT_MODEL_TWO_SIDE_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(ENABLED_LIGHTS), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(NORMALIZE_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(POLYGON_STIPPLE_PATTERN(0)), NV20_3D_POLYGON_STIPPLE_PATTERN__LEN); for (i = 0; i < NV20_3D_POLYGON_STIPPLE_PATTERN__LEN; i++) { PUSH_DATA (push, 0xffffffff); } BEGIN_NV04(push, NV20_3D(POLYGON_OFFSET_POINT_ENABLE), 3); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(DEPTH_FUNC), 1); PUSH_DATA (push, NV20_3D_DEPTH_FUNC_LESS); BEGIN_NV04(push, NV20_3D(DEPTH_WRITE_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(DEPTH_TEST_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(POLYGON_OFFSET_FACTOR), 2); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); BEGIN_NV04(push, NV20_3D(DEPTH_CLAMP), 1); PUSH_DATA (push, 1); if (context_chipset(ctx) < 0x25) { BEGIN_NV04(push, SUBC_3D(0x1d84), 1); PUSH_DATA (push, 3); } BEGIN_NV04(push, NV20_3D(POINT_SIZE), 1); if (context_chipset(ctx) >= 0x25) PUSH_DATAf(push, 1.0); else PUSH_DATA (push, 8); if (context_chipset(ctx) >= 0x25) { BEGIN_NV04(push, NV20_3D(POINT_PARAMETERS_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, SUBC_3D(0x0a1c), 1); PUSH_DATA (push, 0x800); } else { BEGIN_NV04(push, NV20_3D(POINT_PARAMETERS_ENABLE), 2); PUSH_DATA (push, 0); PUSH_DATA (push, 0); } BEGIN_NV04(push, NV20_3D(LINE_WIDTH), 1); PUSH_DATA (push, 8); BEGIN_NV04(push, NV20_3D(LINE_SMOOTH_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(POLYGON_MODE_FRONT), 2); PUSH_DATA (push, NV20_3D_POLYGON_MODE_FRONT_FILL); PUSH_DATA (push, NV20_3D_POLYGON_MODE_BACK_FILL); BEGIN_NV04(push, NV20_3D(CULL_FACE), 2); PUSH_DATA (push, NV20_3D_CULL_FACE_BACK); PUSH_DATA (push, NV20_3D_FRONT_FACE_CCW); BEGIN_NV04(push, NV20_3D(POLYGON_SMOOTH_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(CULL_FACE_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(SHADE_MODEL), 1); PUSH_DATA (push, NV20_3D_SHADE_MODEL_SMOOTH); BEGIN_NV04(push, NV20_3D(POLYGON_STIPPLE_ENABLE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(TEX_GEN_MODE(0,0)), 4 * NV20_3D_TEX_GEN_MODE__ESIZE); for (i=0; i < 4 * NV20_3D_TEX_GEN_MODE__LEN; i++) PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(FOG_COEFF(0)), 3); PUSH_DATAf(push, 1.5); PUSH_DATAf(push, -0.090168); PUSH_DATAf(push, 0.0); BEGIN_NV04(push, NV20_3D(FOG_MODE), 2); PUSH_DATA (push, NV20_3D_FOG_MODE_EXP_SIGNED); PUSH_DATA (push, NV20_3D_FOG_COORD_FOG); BEGIN_NV04(push, NV20_3D(FOG_ENABLE), 2); PUSH_DATA (push, 0); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(ENGINE), 1); PUSH_DATA (push, NV20_3D_ENGINE_FIXED); for (i = 0; i < NV20_3D_TEX_MATRIX_ENABLE__LEN; i++) { BEGIN_NV04(push, NV20_3D(TEX_MATRIX_ENABLE(i)), 1); PUSH_DATA (push, 0); } BEGIN_NV04(push, NV20_3D(VERTEX_ATTR_4F_X(1)), 4 * 15); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 1.0); PUSH_DATAf(push, 1.0); for (i = 0; i < 12; i++) { PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 1.0); } BEGIN_NV04(push, NV20_3D(EDGEFLAG_ENABLE), 1); PUSH_DATA (push, 1); BEGIN_NV04(push, NV20_3D(COLOR_MASK), 1); PUSH_DATA (push, 0x00010101); BEGIN_NV04(push, NV20_3D(CLEAR_VALUE), 1); PUSH_DATA (push, 0); BEGIN_NV04(push, NV20_3D(DEPTH_RANGE_NEAR), 2); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 16777216.0); BEGIN_NV04(push, NV20_3D(VIEWPORT_TRANSLATE_X), 4); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 16777215.0); BEGIN_NV04(push, NV20_3D(VIEWPORT_SCALE_X), 4); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 0.0); PUSH_DATAf(push, 16777215.0 * 0.5); PUSH_DATAf(push, 65535.0); PUSH_KICK (push); }
Bool NV30EXAPrepareComposite(int op, PicturePtr psPict, PicturePtr pmPict, PicturePtr pdPict, PixmapPtr psPix, PixmapPtr pmPix, PixmapPtr pdPix) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pdPix->drawable.pScreen); NVPtr pNv = NVPTR(pScrn); nv_pict_op_t *blend = NV30_GetPictOpRec(op); struct nouveau_pushbuf *push = pNv->pushbuf; uint32_t sc, sa, mc, ma, solid[2]; if (!PUSH_SPACE(push, 128)) return FALSE; PUSH_RESET(push); /* setup render target and blending */ if (!NV30_SetupSurface(pScrn, pdPix, pdPict)) return FALSE; NV30_SetupBlend(pScrn, blend, pdPict->format, (pmPict && pmPict->componentAlpha && PICT_FORMAT_RGB(pmPict->format))); /* select picture sources */ if (!NV30EXAPicture(pScrn, psPix, psPict, 0, &sc, &sa, &solid[0])) return FALSE; if (!NV30EXAPicture(pScrn, pmPix, pmPict, 1, &mc, &ma, &solid[1])) return FALSE; /* configure register combiners */ BEGIN_NV04(push, NV30_3D(RC_IN_ALPHA(0)), 6); PUSH_DATA (push, sa | ma); if (pmPict && pmPict->componentAlpha && PICT_FORMAT_RGB(pmPict->format)) { if (blend->src_alpha) PUSH_DATA(push, sa | mc); else PUSH_DATA(push, sc | mc); } else { PUSH_DATA(push, sc | ma); } PUSH_DATA (push, solid[0]); PUSH_DATA (push, solid[1]); PUSH_DATA (push, 0x00000c00); PUSH_DATA (push, 0x00000c00); BEGIN_NV04(push, NV30_3D(RC_FINAL0), 3); if (pdPict->format != PICT_a8) PUSH_DATA (push, 0x0000000c); else PUSH_DATA (push, 0x0000001c); PUSH_DATA (push, 0x00001c00); PUSH_DATA (push, 0x01000101); /* select fragprog which just sources textures for combiners */ BEGIN_NV04(push, NV30_3D(FP_ACTIVE_PROGRAM), 1); PUSH_MTHD (push, NV30_3D(FP_ACTIVE_PROGRAM), pNv->scratch, PFP_PASS, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW | NOUVEAU_BO_OR, NV30_3D_FP_ACTIVE_PROGRAM_DMA0, NV30_3D_FP_ACTIVE_PROGRAM_DMA1); BEGIN_NV04(push, NV30_3D(FP_REG_CONTROL), 1); PUSH_DATA (push, 0x0001000f); BEGIN_NV04(push, NV30_3D(FP_CONTROL), 1); PUSH_DATA (push, 0x00000000); BEGIN_NV04(push, NV30_3D(TEX_UNITS_ENABLE), 1); PUSH_DATA (push, 3); nouveau_pushbuf_bufctx(push, pNv->bufctx); if (nouveau_pushbuf_validate(push)) { nouveau_pushbuf_bufctx(push, NULL); return FALSE; } return TRUE; }