unsigned face, unsigned level)
{
struct r300_context* r300 = r300_context(context);
- struct r300_texture* tex = (struct r300_texture*)texture;
+ struct r300_texture* tex = r300_texture(texture);
return r300->rws->is_buffer_referenced(r300->rws, tex->buffer);
}
};
/* Convenience cast wrapper. */
+static INLINE struct r300_texture* r300_texture(struct pipe_texture* tex)
+{
+ return (struct r300_texture*)tex;
+}
+
static INLINE struct r300_context* r300_context(struct pipe_context* context)
{
return (struct r300_context*)context;
/* Set up colorbuffers. */
for (i = 0; i < fb->nr_cbufs; i++) {
surf = fb->cbufs[i];
- tex = (struct r300_texture*)surf->texture;
+ tex = r300_texture(surf->texture);
assert(tex && tex->buffer && "cbuf is marked, but NULL!");
OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
/* Set up a zbuffer. */
if (fb->zsbuf) {
surf = fb->zsbuf;
- tex = (struct r300_texture*)surf->texture;
+ tex = r300_texture(surf->texture);
assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
OUT_CS_REG(R300_TX_FORMAT2_0 + (i * 4), texstate->format[2]);
OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (i * 4), 1);
- OUT_CS_TEX_RELOC((struct r300_texture *)allstate->fragment_sampler_views[i]->texture,
+ OUT_CS_TEX_RELOC(r300_texture(allstate->fragment_sampler_views[i]->texture),
texstate->tile_config,
RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
}
validate:
/* Color buffers... */
for (i = 0; i < fb->nr_cbufs; i++) {
- tex = (struct r300_texture*)fb->cbufs[i]->texture;
+ tex = r300_texture(fb->cbufs[i]->texture);
assert(tex && tex->buffer && "cbuf is marked, but NULL!");
if (!r300_add_texture(r300->rws, tex,
0, RADEON_GEM_DOMAIN_VRAM)) {
}
/* ...depth buffer... */
if (fb->zsbuf) {
- tex = (struct r300_texture*)fb->zsbuf->texture;
+ tex = r300_texture(fb->zsbuf->texture);
assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
if (!r300_add_texture(r300->rws, tex,
0, RADEON_GEM_DOMAIN_VRAM)) {
continue;
}
- tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture;
+ tex = r300_texture(texstate->fragment_sampler_views[i]->texture);
if (!r300_add_texture(r300->rws, tex,
RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
r300->context.flush(&r300->context, 0, NULL);
continue;
}
- tex = (struct r300_texture*)old_state->cbufs[i]->texture;
+ tex = r300_texture(old_state->cbufs[i]->texture);
if (tex) {
r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
if (old_state->zsbuf &&
(!new_state->zsbuf ||
old_state->zsbuf->texture != new_state->zsbuf->texture)) {
- tex = (struct r300_texture*)old_state->zsbuf->texture;
+ tex = r300_texture(old_state->zsbuf->texture);
if (tex) {
r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
/* Set tiling flags for new surfaces. */
for (i = 0; i < new_state->nr_cbufs; i++) {
- tex = (struct r300_texture*)new_state->cbufs[i]->texture;
+ tex = r300_texture(new_state->cbufs[i]->texture);
level = new_state->cbufs[i]->level;
r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
tex->mip_macrotile[level]);
}
if (new_state->zsbuf) {
- tex = (struct r300_texture*)new_state->zsbuf->texture;
+ tex = r300_texture(new_state->zsbuf->texture);
level = new_state->zsbuf->level;
r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
dirty_tex = TRUE;
/* R300-specific - set the texrect factor in the fragment shader */
- texture = (struct r300_texture *)views[i]->texture;
+ texture = r300_texture(views[i]->texture);
if (!is_r500 && texture->uses_pitch) {
/* XXX It would be nice to re-emit just 1 constant,
* XXX not all of them */
state->tx_enable |= 1 << i;
view = state->fragment_sampler_views[i];
- tex = (struct r300_texture *)view->texture;
+ tex = r300_texture(view->texture);
sampler = state->sampler_states[i];
assert(view->format == tex->tex.format);
tex->format = new_format;
- r300_setup_texture_state(r300_screen(screen), (struct r300_texture*)tex);
+ r300_setup_texture_state(r300_screen(screen), r300_texture(tex));
}
unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
static void r300_texture_destroy(struct pipe_texture* texture)
{
- struct r300_texture* tex = (struct r300_texture*)texture;
+ struct r300_texture* tex = r300_texture(texture);
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)texture->screen->winsys;
rws->buffer_reference(rws, &tex->buffer, NULL);
unsigned zslice,
unsigned flags)
{
- struct r300_texture* tex = (struct r300_texture*)texture;
+ struct r300_texture* tex = r300_texture(texture);
struct pipe_surface* surface = CALLOC_STRUCT(pipe_surface);
unsigned offset;
struct winsys_handle *whandle)
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
- struct r300_texture* tex = (struct r300_texture*)texture;
+ struct r300_texture* tex = r300_texture(texture);
unsigned stride;
if (!tex) {
struct r300_winsys_buffer** buffer,
unsigned* stride)
{
- struct r300_texture* tex = (struct r300_texture*)texture;
+ struct r300_texture* tex = r300_texture(texture);
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
struct r300_winsys_buffer *buf;
enum pipe_transfer_usage usage, unsigned x, unsigned y,
unsigned w, unsigned h)
{
- struct r300_texture *tex = (struct r300_texture *)texture;
+ struct r300_texture *tex = r300_texture(texture);
struct r300_screen *r300screen = r300_screen(ctx->screen);
struct r300_transfer *trans;
struct pipe_texture base;
}
/* Create the temporary texture. */
- trans->detiled_texture = (struct r300_texture*)
+ trans->detiled_texture = r300_texture(
ctx->screen->texture_create(ctx->screen,
- &base);
+ &base));
assert(!trans->detiled_texture->microtile &&
!trans->detiled_texture->macrotile);
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
struct r300_transfer *r300transfer = r300_transfer(transfer);
- struct r300_texture *tex = (struct r300_texture*)transfer->texture;
+ struct r300_texture *tex = r300_texture(transfer->texture);
char *map;
enum pipe_format format = tex->tex.format;
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
struct r300_transfer *r300transfer = r300_transfer(transfer);
- struct r300_texture *tex = (struct r300_texture*)transfer->texture;
+ struct r300_texture *tex = r300_texture(transfer->texture);
if (r300transfer->detiled_texture) {
rws->buffer_unmap(rws, r300transfer->detiled_texture->buffer);