#include "r300_transfer.h"
#include "r300_screen.h"
-#include "util/u_format.h"
-#include "util/u_format_s3tc.h"
+#include "util/format/u_format.h"
+#include "util/format/u_format_s3tc.h"
#include "util/u_math.h"
#include "util/u_memory.h"
-#include "util/u_mm.h"
#include "pipe/p_screen.h"
+#include "frontend/winsys_handle.h"
/* These formats are supported by swapping their bytes.
* The swizzles must be set exactly like their non-swapped counterparts,
/* S3TC formats. */
if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
- if (!util_format_s3tc_enabled) {
- return ~0; /* Unsupported. */
- }
-
switch (format) {
case PIPE_FORMAT_DXT1_RGB:
case PIPE_FORMAT_DXT1_RGBA:
case PIPE_FORMAT_RGTC1_SNORM:
case PIPE_FORMAT_LATC1_SNORM:
result |= sign_bit[0];
+ /* fallthrough */
case PIPE_FORMAT_LATC1_UNORM:
case PIPE_FORMAT_RGTC1_UNORM:
return R500_TX_FORMAT_ATI1N | result;
case PIPE_FORMAT_RGTC2_SNORM:
case PIPE_FORMAT_LATC2_SNORM:
result |= sign_bit[1] | sign_bit[0];
+ /* fallthrough */
case PIPE_FORMAT_RGTC2_UNORM:
case PIPE_FORMAT_LATC2_UNORM:
return R400_TX_FORMAT_ATI2N | result;
FREE(tex);
}
-boolean r300_resource_get_handle(struct pipe_screen* screen,
- struct pipe_context *ctx,
- struct pipe_resource *texture,
- struct winsys_handle *whandle,
- unsigned usage)
+bool r300_resource_get_handle(struct pipe_screen* screen,
+ struct pipe_context *ctx,
+ struct pipe_resource *texture,
+ struct winsys_handle *whandle,
+ unsigned usage)
{
struct radeon_winsys *rws = r300_screen(screen)->rws;
struct r300_resource* tex = (struct r300_resource*)texture;
if (!tex) {
- return FALSE;
+ return false;
}
- return rws->buffer_get_handle(tex->buf, tex->tex.stride_in_bytes[0],
- 0, 0, whandle);
+ whandle->stride = tex->tex.stride_in_bytes[0];
+ whandle->offset = 0;
+
+ return rws->buffer_get_handle(rws, tex->buf, whandle);
}
static const struct u_resource_vtbl r300_texture_vtbl =
/* Create the backing buffer if needed. */
if (!tex->buf) {
+ /* Only use the first domain for allocation. Multiple domains are not allowed. */
+ unsigned alloc_domain =
+ tex->domain & RADEON_DOMAIN_VRAM ? RADEON_DOMAIN_VRAM :
+ RADEON_DOMAIN_GTT;
+
tex->buf = rws->buffer_create(rws, tex->tex.size_in_bytes, 2048,
- tex->domain, RADEON_FLAG_NO_SUBALLOC);
+ alloc_domain,
+ RADEON_FLAG_NO_SUBALLOC |
+ /* Use the reusable pool: */
+ RADEON_FLAG_NO_INTERPROCESS_SHARING);
if (!tex->buf) {
goto fail;
tiling.u.legacy.microtile = tex->tex.microtile;
tiling.u.legacy.macrotile = tex->tex.macrotile[0];
tiling.u.legacy.stride = tex->tex.stride_in_bytes[0];
- rws->buffer_set_metadata(tex->buf, &tiling);
+ rws->buffer_set_metadata(tex->buf, &tiling, NULL);
return tex;
struct r300_screen *rscreen = r300_screen(screen);
struct radeon_winsys *rws = rscreen->rws;
struct pb_buffer *buffer;
- unsigned stride;
struct radeon_bo_metadata tiling = {};
/* Support only 2D textures without mipmaps */
return NULL;
}
- buffer = rws->buffer_from_handle(rws, whandle, &stride, NULL);
+ buffer = rws->buffer_from_handle(rws, whandle, 0);
if (!buffer)
return NULL;
- rws->buffer_get_metadata(buffer, &tiling);
+ rws->buffer_get_metadata(buffer, &tiling, NULL);
/* Enforce a microtiled zbuffer. */
if (util_format_is_depth_or_stencil(base->format) &&
return (struct pipe_resource*)
r300_texture_create_object(rscreen, base, tiling.u.legacy.microtile, tiling.u.legacy.macrotile,
- stride, buffer);
+ whandle->stride, buffer);
}
/* Not required to implement u_resource_vtbl, consider moving to another file:
surface->base.u.tex.first_layer = surf_tmpl->u.tex.first_layer;
surface->base.u.tex.last_layer = surf_tmpl->u.tex.last_layer;
- surface->buf = tex->buf;
surface->buf = tex->buf;
/* Prefer VRAM if there are multiple domains to choose from. */