void
nv04_emit_blend(struct gl_context *ctx, int emit)
{
	struct nv04_context *nv04 = to_nv04_context(ctx);

	nv04->blend &= NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__MASK;
	nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_MASK_BIT_MSB |
		       NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE;

	/* Alpha blending. */
	nv04->blend |= get_blend_func(ctx->Color.Blend[0].DstRGB) << 28 |
		       get_blend_func(ctx->Color.Blend[0].SrcRGB) << 24;

	if (ctx->Color.BlendEnabled)
		nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_BLEND_ENABLE;

	/* Shade model. */
	if (ctx->Light.ShadeModel == GL_SMOOTH)
		nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_GOURAUD;
	else
		nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_SHADE_MODE_FLAT;

	/* Secondary color */
	if (_mesa_need_secondary_color(ctx))
		nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_SPECULAR_ENABLE;

	/* Fog. */
	if (ctx->Fog.Enabled) {
		nv04->blend |= NV04_TEXTURED_TRIANGLE_BLEND_FOG_ENABLE;
		nv04->fog = pack_rgba_f(MESA_FORMAT_B8G8R8A8_UNORM, ctx->Fog.Color);
	}
}
Example #2
0
void
nv04_emit_tex_env(struct gl_context *ctx, int emit)
{
    const int i = emit - NOUVEAU_STATE_TEX_ENV0;
    struct nouveau_channel *chan = context_chan(ctx);
    struct nouveau_grobj *fahrenheit = nv04_context_engine(ctx);
    struct combiner_state rc_a = {}, rc_c = {};

    if (!nv04_mtex_engine(fahrenheit)) {
        context_dirty(ctx, BLEND);
        return;
    }

    /* Compute the new combiner state. */
    if (ctx->Texture.Unit[i]._ReallyEnabled) {
        INIT_COMBINER(A, ctx, &rc_a, i);
        setup_combiner(&rc_a);

        INIT_COMBINER(RGB, ctx, &rc_c, i);
        setup_combiner(&rc_c);

    } else {
        if (i == 0) {
            INPUT_SRC(&rc_a, 0, PRIMARY_COLOR, 0);
            INPUT_SRC(&rc_c, 0, PRIMARY_COLOR, 0);
        } else {
            INPUT_SRC(&rc_a, 0, PREVIOUS, 0);
            INPUT_SRC(&rc_c, 0, PREVIOUS, 0);
        }

        INPUT_SRC(&rc_a, 1, ZERO, INVERT);
        INPUT_SRC(&rc_c, 1, ZERO, INVERT);
        INPUT_SRC(&rc_a, 2, ZERO, 0);
        INPUT_SRC(&rc_c, 2, ZERO, 0);
        INPUT_SRC(&rc_a, 3, ZERO, 0);
        INPUT_SRC(&rc_c, 3, ZERO, 0);

        UNSIGNED_OP(&rc_a);
        UNSIGNED_OP(&rc_c);
    }

    /* Write the register combiner state out to the hardware. */
    BEGIN_RING(chan, fahrenheit,
               NV04_MULTITEX_TRIANGLE_COMBINE_ALPHA(i), 2);
    OUT_RING(chan, rc_a.hw);
    OUT_RING(chan, rc_c.hw);

    BEGIN_RING(chan, fahrenheit,
               NV04_MULTITEX_TRIANGLE_COMBINE_FACTOR, 1);
    OUT_RING(chan, pack_rgba_f(MESA_FORMAT_ARGB8888,
                               ctx->Texture.Unit[0].EnvColor));
}
Example #3
0
void
nouveau_clear(GLcontext *ctx, GLbitfield buffers)
{
	struct gl_framebuffer *fb = ctx->DrawBuffer;
	int x, y, w, h;
	int i, buf;

	nouveau_validate_framebuffer(ctx);
	get_scissors(fb, &x, &y, &w, &h);

	for (i = 0; i < BUFFER_COUNT; i++) {
		struct nouveau_surface *s;
		unsigned mask, value;

		buf = buffers & (1 << i);
		if (!buf)
			continue;

		s = &to_nouveau_renderbuffer(
			fb->Attachment[i].Renderbuffer->Wrapped)->surface;

		if (buf & BUFFER_BITS_COLOR) {
			mask = pack_rgba_i(s->format, ctx->Color.ColorMask[0]);
			value = pack_rgba_f(s->format, ctx->Color.ClearColor);

			if (mask)
				context_drv(ctx)->surface_fill(
					ctx, s, mask, value, x, y, w, h);

			buffers &= ~buf;

		} else if (buf & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
			mask = pack_zs_i(s->format,
					 (buffers & BUFFER_BIT_DEPTH &&
					  ctx->Depth.Mask) ? ~0 : 0,
					 (buffers & BUFFER_BIT_STENCIL ?
					  ctx->Stencil.WriteMask[0] : 0));
			value = pack_zs_f(s->format,
					  ctx->Depth.Clear,
					  ctx->Stencil.Clear);

			if (mask)
				context_drv(ctx)->surface_fill(
					ctx, s, mask, value, x, y, w, h);

			buffers &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
		}
	}

	if (buffers)
		_mesa_meta_Clear(ctx, buffers);
}