uint32_t format1; /* R300_TX_FORMAT1: 0x44c0 */
uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */
uint32_t tile_config; /* R300_TX_OFFSET (subset thereof) */
+ uint32_t us_format0; /* R500_US_FORMAT0_0: 0x4640 (through 15) */
};
struct r300_sampler_view {
struct r300_texture_format_state format;
uint32_t filter0; /* R300_TX_FILTER0: 0x4400 */
uint32_t filter1; /* R300_TX_FILTER1: 0x4440 */
- uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */
+ uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */
};
struct r300_textures_state {
unsigned min_level, max_level, i, j, size;
unsigned count = MIN2(state->sampler_view_count,
state->sampler_state_count);
+ boolean has_us_format = r300->screen->caps.has_us_format;
/* The KIL opcode fix, see below. */
if (!count && !r300->screen->caps.is_r500)
texstate->filter0 |= i << 28;
- size += 16;
+ size += 16 + (has_us_format ? 2 : 0);
state->count = i+1;
} else {
/* For the KIL opcode to work on r3xx-r4xx, the texture unit
texstate->border_color = 0;
texstate->filter0 |= i << 28;
- size += 16;
+ size += 16 + (has_us_format ? 2 : 0);
state->count = i+1;
}
}
struct pipe_resource *pt = &tex->b.b.b;
struct r300_texture_desc *desc = &tex->tex;
boolean is_r500 = screen->caps.is_r500;
+ unsigned width, height, depth;
+ unsigned txwidth, txheight, txdepth;
+
+ width = u_minify(desc->width0, level);
+ height = u_minify(desc->height0, level);
+ depth = u_minify(desc->depth0, level);
+
+ txwidth = (width - 1) & 0x7ff;
+ txheight = (height - 1) & 0x7ff;
+ txdepth = util_logbase2(depth) & 0xf;
/* Mask out all the fields we change. */
out->format0 = 0;
/* Set sampler state. */
out->format0 =
- R300_TX_WIDTH((u_minify(desc->width0, level) - 1) & 0x7ff) |
- R300_TX_HEIGHT((u_minify(desc->height0, level) - 1) & 0x7ff) |
- R300_TX_DEPTH(util_logbase2(u_minify(desc->depth0, level)) & 0xf);
+ R300_TX_WIDTH(txwidth) |
+ R300_TX_HEIGHT(txheight) |
+ R300_TX_DEPTH(txdepth);
if (desc->uses_stride_addressing) {
/* rectangles love this */
/* large textures on r500 */
if (is_r500)
{
- if (desc->width0 > 2048) {
+ unsigned us_width = txwidth;
+ unsigned us_height = txheight;
+ unsigned us_depth = txdepth;
+
+ if (width > 2048) {
out->format2 |= R500_TXWIDTH_BIT11;
}
- if (desc->height0 > 2048) {
+ if (height > 2048) {
out->format2 |= R500_TXHEIGHT_BIT11;
}
+
+ /* The US_FORMAT register fixes an R500 TX addressing bug.
+ * Don't ask why it must be set like this. I don't know it either. */
+ if (width > 2048) {
+ us_width = (0x000007FF + us_width) >> 1;
+ us_depth |= 0x0000000D;
+ }
+ if (height > 2048) {
+ us_height = (0x000007FF + us_height) >> 1;
+ us_depth |= 0x0000000E;
+ }
+
+ out->us_format0 =
+ R300_TX_WIDTH(us_width) |
+ R300_TX_HEIGHT(us_height) |
+ R300_TX_DEPTH(us_depth);
}
out->tile_config = R300_TXO_MACRO_TILE(desc->macrotile[level]) |