Example #1
0
static void r300_texture_setup_fb_state(struct r300_screen* screen,
                                        struct r300_texture* tex)
{
    unsigned i;

    /* Set framebuffer state. */
    if (util_format_is_depth_or_stencil(tex->desc.b.b.format)) {
        for (i = 0; i <= tex->desc.b.b.last_level; i++) {
            tex->fb_state.pitch[i] =
                tex->desc.stride_in_pixels[i] |
                R300_DEPTHMACROTILE(tex->desc.macrotile[i]) |
                R300_DEPTHMICROTILE(tex->desc.microtile);
        }
        tex->fb_state.format = r300_translate_zsformat(tex->desc.b.b.format);
    } else {
        for (i = 0; i <= tex->desc.b.b.last_level; i++) {
            tex->fb_state.pitch[i] =
                tex->desc.stride_in_pixels[i] |
                r300_translate_colorformat(tex->desc.b.b.format) |
                R300_COLOR_TILE(tex->desc.macrotile[i]) |
                R300_COLOR_MICROTILE(tex->desc.microtile);
        }
        tex->fb_state.format = r300_translate_out_fmt(tex->desc.b.b.format);
    }
}
static void r300_simple_msaa_resolve(struct pipe_context *pipe,
                                     struct pipe_resource *dst,
                                     unsigned dst_level,
                                     unsigned dst_layer,
                                     struct pipe_resource *src,
                                     enum pipe_format format)
{
    struct r300_context *r300 = r300_context(pipe);
    struct r300_surface *srcsurf, *dstsurf;
    struct pipe_surface surf_tmpl;
    struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;

    memset(&surf_tmpl, 0, sizeof(surf_tmpl));
    surf_tmpl.format = format;
    srcsurf = r300_surface(pipe->create_surface(pipe, src, &surf_tmpl));

    surf_tmpl.format = format;
    surf_tmpl.u.tex.level = dst_level;
    surf_tmpl.u.tex.first_layer =
    surf_tmpl.u.tex.last_layer = dst_layer;
    dstsurf = r300_surface(pipe->create_surface(pipe, dst, &surf_tmpl));

    /* COLORPITCH should contain the tiling info of the resolve buffer.
     * The tiling of the AA buffer isn't programmable anyway. */
    srcsurf->pitch &= ~(R300_COLOR_TILE(1) | R300_COLOR_MICROTILE(3));
    srcsurf->pitch |= dstsurf->pitch & (R300_COLOR_TILE(1) | R300_COLOR_MICROTILE(3));

    /* Enable AA resolve. */
    aa->dest = dstsurf;
    r300->aa_state.size = 8;
    r300_mark_atom_dirty(r300, &r300->aa_state);

    /* Resolve the surface. */
    r300_blitter_begin(r300, R300_CLEAR_SURFACE);
    util_blitter_custom_color(r300->blitter, &srcsurf->base, NULL);
    r300_blitter_end(r300);

    /* Disable AA resolve. */
    aa->dest = NULL;
    r300->aa_state.size = 4;
    r300_mark_atom_dirty(r300, &r300->aa_state);

    pipe_surface_reference((struct pipe_surface**)&srcsurf, NULL);
    pipe_surface_reference((struct pipe_surface**)&dstsurf, NULL);
}
Example #3
0
static void r300_setup_texture_state(struct r300_screen* screen, struct r300_texture* tex)
{
    struct r300_texture_format_state* state = &tex->state;
    struct pipe_texture *pt = &tex->tex;
    unsigned i;
    boolean is_r500 = screen->caps->is_r500;

    /* Set sampler state. */
    state->format0 = R300_TX_WIDTH((pt->width0 - 1) & 0x7ff) |
                     R300_TX_HEIGHT((pt->height0 - 1) & 0x7ff);

    if (tex->is_npot) {
        /* rectangles love this */
        state->format0 |= R300_TX_PITCH_EN;
        state->format2 = (tex->pitch[0] - 1) & 0x1fff;
    } else {
        /* power of two textures (3D, mipmaps, and no pitch) */
        state->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth0) & 0xf);
    }

    state->format1 = r300_translate_texformat(pt->format);
    if (pt->target == PIPE_TEXTURE_CUBE) {
        state->format1 |= R300_TX_FORMAT_CUBIC_MAP;
    }
    if (pt->target == PIPE_TEXTURE_3D) {
        state->format1 |= R300_TX_FORMAT_3D;
    }

    /* large textures on r500 */
    if (is_r500)
    {
        if (pt->width0 > 2048) {
            state->format2 |= R500_TXWIDTH_BIT11;
        }
        if (pt->height0 > 2048) {
            state->format2 |= R500_TXHEIGHT_BIT11;
        }
    }

    SCREEN_DBG(screen, DBG_TEX, "r300: Set texture state (%dx%d, %d levels)\n",
               pt->width0, pt->height0, pt->last_level);

    /* Set framebuffer state. */
    if (util_format_is_depth_or_stencil(tex->tex.format)) {
        for (i = 0; i <= tex->tex.last_level; i++) {
            tex->fb_state.depthpitch[i] =
                tex->pitch[i] |
                R300_DEPTHMACROTILE(tex->mip_macrotile[i]) |
                R300_DEPTHMICROTILE(tex->microtile);
        }
        tex->fb_state.zb_format = r300_translate_zsformat(tex->tex.format);
    } else {
        for (i = 0; i <= tex->tex.last_level; i++) {
            tex->fb_state.colorpitch[i] =
                tex->pitch[i] |
                r300_translate_colorformat(tex->tex.format) |
                R300_COLOR_TILE(tex->mip_macrotile[i]) |
                R300_COLOR_MICROTILE(tex->microtile);
        }
        tex->fb_state.us_out_fmt = r300_translate_out_fmt(tex->tex.format);
    }
}