boolean r300_is_sampler_format_supported(enum pipe_format format) { return r300_translate_texformat(format, 0, TRUE, FALSE) != ~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); } }