* derived from the texture properties. */
unsigned size_in_bytes;
- /* Total size of the buffer backing this texture, in bytes.
- * It must be >= size. */
- unsigned buffer_size_in_bytes;
-
/**
* If non-zero, override the natural texture layout with
* a custom stride (in bytes).
struct pb_buffer *buf;
struct radeon_winsys_cs_handle *cs_buf;
enum radeon_bo_domain domain;
- unsigned buf_size;
/* Constant buffers are in user memory. */
uint8_t *constant_buffer;
rbuf->b.user_ptr = NULL;
rbuf->domain = RADEON_DOMAIN_GTT;
rbuf->buf = NULL;
- rbuf->buf_size = templ->width0;
rbuf->constant_buffer = NULL;
/* Alloc constant buffers in RAM. */
rbuf->b.user_ptr = ptr;
rbuf->domain = RADEON_DOMAIN_GTT;
rbuf->buf = NULL;
- rbuf->buf_size = size;
rbuf->constant_buffer = NULL;
return &rbuf->b.b.b;
}
enum radeon_bo_layout microtile,
enum radeon_bo_layout macrotile,
unsigned stride_in_bytes_override,
- unsigned max_buffer_size,
struct pb_buffer *buffer)
{
struct radeon_winsys *rws = rscreen->rws;
tex->domain = base->flags & R300_RESOURCE_FLAG_TRANSFER ?
RADEON_DOMAIN_GTT :
RADEON_DOMAIN_VRAM | RADEON_DOMAIN_GTT;
- tex->buf_size = max_buffer_size;
+ tex->buf = buffer;
if (!r300_resource_set_properties(&rscreen->screen, &tex->b.b.b, 0, base)) {
if (buffer)
}
/* Create the backing buffer if needed. */
- if (!buffer) {
- tex->buf_size = tex->tex.size_in_bytes;
+ if (!tex->buf) {
tex->buf = rws->buffer_create(rws, tex->tex.size_in_bytes, 2048,
base->bind, tex->domain);
FREE(tex);
return NULL;
}
- } else {
- tex->buf = buffer;
}
tex->cs_buf = rws->buffer_get_cs_handle(tex->buf);
return (struct pipe_resource*)
r300_texture_create_object(rscreen, base, microtile, macrotile,
- 0, 0, NULL);
+ 0, NULL);
}
struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
struct r300_screen *rscreen = r300_screen(screen);
struct pb_buffer *buffer;
enum radeon_bo_layout microtile, macrotile;
- unsigned stride, size;
+ unsigned stride;
/* Support only 2D textures without mipmaps */
if ((base->target != PIPE_TEXTURE_2D &&
return NULL;
}
- buffer = rws->buffer_from_handle(rws, whandle, &stride, &size);
+ buffer = rws->buffer_from_handle(rws, whandle, &stride, NULL);
if (!buffer)
return NULL;
return (struct pipe_resource*)
r300_texture_create_object(rscreen, base, microtile, macrotile,
- stride, size, buffer);
+ stride, buffer);
}
/* Not required to implement u_resource_vtbl, consider moving to another file:
/* Setup the miptree description. */
r300_setup_miptree(rscreen, tex, TRUE);
- /* If the required buffer size is larger the given max size,
+ /* If the required buffer size is larger than the given max size,
* try again without the alignment for the CBZB clear. */
- if (tex->buf_size && tex->tex.size_in_bytes > tex->buf_size) {
+ if (tex->buf && tex->tex.size_in_bytes > tex->buf->size) {
r300_setup_miptree(rscreen, tex, FALSE);
- }
-
- r300_setup_hyperz_properties(rscreen, tex);
- if (tex->buf_size) {
/* Make sure the buffer we got is large enough. */
- if (tex->tex.size_in_bytes > tex->buf_size) {
+ if (tex->tex.size_in_bytes > tex->buf->size) {
fprintf(stderr, "r300: texture_desc_init: The buffer is not "
"large enough. Got: %i, Need: %i, Info:\n",
- tex->buf_size, tex->tex.size_in_bytes);
+ tex->buf->size, tex->tex.size_in_bytes);
r300_tex_print_info(tex, "texture_desc_init");
return FALSE;
}
-
- tex->tex.buffer_size_in_bytes = tex->buf_size;
- } else {
- tex->tex.buffer_size_in_bytes = tex->tex.size_in_bytes;
}
+ r300_setup_hyperz_properties(rscreen, tex);
+
if (SCREEN_DBG_ON(rscreen, DBG_TEX))
r300_tex_print_info(tex, "texture_desc_init");