/* r600_bo.c */
struct r600_bo;
+
struct r600_bo *r600_bo(struct radeon *radeon,
unsigned size, unsigned alignment,
unsigned binding, unsigned usage);
-struct r600_bo *r600_bo_handle(struct radeon *radeon,
- unsigned handle, unsigned *array_mode);
+struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whandle,
+ unsigned *stride, unsigned *array_mode);
void *r600_bo_map(struct radeon *radeon, struct r600_bo *bo, unsigned usage, void *ctx);
void r600_bo_unmap(struct radeon *radeon, struct r600_bo *bo);
boolean r600_bo_get_winsys_handle(struct radeon *radeon, struct r600_bo *pb_bo,
void evergreen_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id);
void evergreen_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id);
-struct radeon *radeon_decref(struct radeon *radeon);
+struct radeon *radeon_destroy(struct radeon *radeon);
void _r600_pipe_state_add_reg(struct r600_context *ctx,
struct r600_pipe_state *state,
#include <util/u_memory.h>
#include "util/u_upload_mgr.h"
-#include "state_tracker/drm_driver.h"
-
#include <xf86drm.h>
#include "radeon_drm.h"
struct r600_resource_buffer *rbuffer = r600_buffer(buf);
if (rbuffer->r.bo) {
- r600_bo_reference((struct radeon*)screen->winsys, &rbuffer->r.bo, NULL);
+ r600_bo_reference(rscreen->radeon, &rbuffer->r.bo, NULL);
}
rbuffer->r.bo = NULL;
util_slab_free(&rscreen->pool_buffers, rbuffer);
struct pipe_transfer *transfer)
{
struct r600_resource_buffer *rbuffer = r600_buffer(transfer->resource);
+ struct r600_pipe_context *rctx = (struct r600_pipe_context*)pipe;
uint8_t *data;
if (rbuffer->r.b.user_ptr)
return (uint8_t*)rbuffer->r.b.user_ptr + transfer->box.x;
- data = r600_bo_map((struct radeon*)pipe->winsys, rbuffer->r.bo, transfer->usage, pipe);
+ data = r600_bo_map(rctx->screen->radeon, rbuffer->r.bo, transfer->usage, pipe);
if (!data)
return NULL;
struct pipe_transfer *transfer)
{
struct r600_resource_buffer *rbuffer = r600_buffer(transfer->resource);
+ struct r600_pipe_context *rctx = (struct r600_pipe_context*)pipe;
if (rbuffer->r.b.user_ptr)
return;
if (rbuffer->r.bo)
- r600_bo_unmap((struct radeon*)pipe->winsys, rbuffer->r.bo);
+ r600_bo_unmap(rctx->screen->radeon, rbuffer->r.bo);
}
static void r600_buffer_transfer_flush_region(struct pipe_context *pipe,
unsigned stride,
unsigned layer_stride)
{
- struct radeon *ws = (struct radeon*)pipe->winsys;
+ struct r600_pipe_context *rctx = (struct r600_pipe_context*)pipe;
+ struct radeon *radeon = rctx->screen->radeon;
struct r600_resource_buffer *rbuffer = r600_buffer(resource);
uint8_t *map = NULL;
assert(rbuffer->r.b.user_ptr == NULL);
- map = r600_bo_map(ws, rbuffer->r.bo,
+ map = r600_bo_map(radeon, rbuffer->r.bo,
PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD | usage,
pipe);
memcpy(map + box->x, data, box->width);
if (rbuffer->r.bo)
- r600_bo_unmap(ws, rbuffer->r.bo);
+ r600_bo_unmap(radeon, rbuffer->r.bo);
}
static const struct u_resource_vtbl r600_buffer_vtbl =
rbuffer->r.size = rbuffer->r.b.b.b.width0;
rbuffer->r.bo_size = rbuffer->r.size;
- bo = r600_bo((struct radeon*)screen->winsys,
+ bo = r600_bo(rscreen->radeon,
rbuffer->r.b.b.b.width0,
alignment, rbuffer->r.b.b.b.bind,
rbuffer->r.b.b.b.usage);
struct pipe_resource *r600_buffer_from_handle(struct pipe_screen *screen,
struct winsys_handle *whandle)
{
- struct radeon *rw = (struct radeon*)screen->winsys;
+ struct radeon *rw = ((struct r600_screen*)screen)->radeon;
struct r600_resource *rbuffer;
struct r600_bo *bo = NULL;
- bo = r600_bo_handle(rw, whandle->handle, NULL);
+ bo = r600_bo_handle(rw, whandle, NULL, NULL);
if (bo == NULL) {
return NULL;
}
if (rscreen == NULL)
return;
- radeon_decref(rscreen->radeon);
+ radeon_destroy(rscreen->radeon);
+ rscreen->ws->destroy(rscreen->ws);
util_slab_destroy(&rscreen->pool_buffers);
pipe_mutex_destroy(rscreen->mutex_num_contexts);
return TRUE;
}
-struct pipe_screen *r600_screen_create(struct radeon_winsys *rw)
+struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
{
struct r600_screen *rscreen;
- struct radeon *radeon = r600_drm_winsys_create(rw);
+ struct radeon *radeon = radeon_create(ws);
rscreen = CALLOC_STRUCT(r600_screen);
if (rscreen == NULL) {
return NULL;
}
+ rscreen->ws = ws;
rscreen->radeon = radeon;
- rscreen->screen.winsys = (struct pipe_winsys*)radeon;
+ rscreen->screen.winsys = (struct pipe_winsys*)ws;
rscreen->screen.destroy = r600_destroy_screen;
rscreen->screen.get_name = r600_get_name;
rscreen->screen.get_vendor = r600_get_vendor;
struct r600_screen {
struct pipe_screen screen;
+ struct radeon_winsys *ws;
struct radeon *radeon;
struct r600_tiling_info *tiling_info;
struct util_slab_mempool pool_buffers;
struct radeon_winsys;
-struct pipe_screen *r600_screen_create(struct radeon_winsys *rw);
+struct pipe_screen *r600_screen_create(struct radeon_winsys *ws);
#endif
#include <util/u_math.h>
#include <util/u_inlines.h>
#include <util/u_memory.h>
-#include "state_tracker/drm_driver.h"
#include "pipebuffer/pb_buffer.h"
#include "r600_pipe.h"
#include "r600_resource.h"
unsigned array_mode)
{
struct pipe_resource *ptex = &rtex->resource.b.b.b;
- struct radeon *radeon = (struct radeon *)screen->winsys;
+ struct radeon *radeon = ((struct r600_screen*)screen)->radeon;
enum chip_class chipc = r600_get_family_class(radeon);
unsigned size, layer_size, i, offset;
unsigned nblocksx, nblocksy, extra_size = 0;
{
struct r600_resource_texture *rtex = (struct r600_resource_texture*)ptex;
struct r600_resource *resource = &rtex->resource;
- struct radeon *radeon = (struct radeon *)screen->winsys;
+ struct radeon *radeon = ((struct r600_screen*)screen)->radeon;
return r600_bo_get_winsys_handle(radeon, resource->bo,
rtex->pitch_in_bytes[0], whandle);
{
struct r600_resource_texture *rtex = (struct r600_resource_texture*)ptex;
struct r600_resource *resource = &rtex->resource;
- struct radeon *radeon = (struct radeon *)screen->winsys;
+ struct radeon *radeon = ((struct r600_screen*)screen)->radeon;
if (rtex->flushed_depth_texture)
pipe_resource_reference((struct pipe_resource **)&rtex->flushed_depth_texture, NULL);
{
struct r600_resource_texture *rtex;
struct r600_resource *resource;
- struct radeon *radeon = (struct radeon *)screen->winsys;
+ struct radeon *radeon = ((struct r600_screen*)screen)->radeon;
rtex = CALLOC_STRUCT(r600_resource_texture);
if (rtex == NULL)
const struct pipe_resource *templ,
struct winsys_handle *whandle)
{
- struct radeon *rw = (struct radeon*)screen->winsys;
+ struct radeon *rw = ((struct r600_screen*)screen)->radeon;
struct r600_bo *bo = NULL;
+ unsigned stride = 0;
unsigned array_mode = 0;
/* Support only 2D textures without mipmaps */
templ->depth0 != 1 || templ->last_level != 0)
return NULL;
- bo = r600_bo_handle(rw, whandle->handle, &array_mode);
+ bo = r600_bo_handle(rw, whandle, &stride, &array_mode);
if (bo == NULL) {
return NULL;
}
return (struct pipe_resource *)r600_texture_create_object(screen, templ, array_mode,
- whandle->stride,
- 0,
- bo);
+ stride, 0, bo);
}
int r600_texture_depth_flush(struct pipe_context *ctx,
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
struct r600_bo *bo;
enum pipe_format format = transfer->resource->format;
- struct radeon *radeon = (struct radeon *)ctx->screen->winsys;
+ struct radeon *radeon = ((struct r600_screen*)ctx->screen)->radeon;
unsigned offset = 0;
char *map;
struct pipe_transfer* transfer)
{
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
- struct radeon *radeon = (struct radeon *)ctx->screen->winsys;
+ struct radeon *radeon = ((struct r600_screen*)ctx->screen)->radeon;
struct r600_bo *bo;
if (rtransfer->staging_texture) {
memset(ctx, 0, sizeof(struct r600_context));
ctx->radeon = radeon;
+
LIST_INITHEAD(&ctx->query_list);
/* init dirty list */
return bo;
}
-struct r600_bo *r600_bo_handle(struct radeon *radeon,
- unsigned handle, unsigned *array_mode)
+struct r600_bo *r600_bo_handle(struct radeon *radeon, struct winsys_handle *whandle,
+ unsigned *stride, unsigned *array_mode)
{
struct r600_bo *bo = calloc(1, sizeof(struct r600_bo));
struct radeon_bo *rbo;
- rbo = bo->bo = radeon_bo(radeon, handle, 0, 0, 0);
+ rbo = bo->bo = radeon_bo(radeon, whandle->handle, 0, 0, 0);
if (rbo == NULL) {
free(bo);
return NULL;
}
+
+ pipe_reference_init(&bo->reference, 1);
bo->size = rbo->size;
bo->domains = (RADEON_GEM_DOMAIN_CPU |
RADEON_GEM_DOMAIN_GTT |
RADEON_GEM_DOMAIN_VRAM);
- pipe_reference_init(&bo->reference, 1);
+ if (stride)
+ *stride = whandle->stride;
radeon_bo_get_tiling_flags(radeon, rbo, &bo->tiling_flags, &bo->kernel_pitch);
if (array_mode) {
#include "r600_priv.h"
#include "r600_drm_public.h"
+#include "util/u_memory.h"
#include <radeon_drm.h>
#include <xf86drm.h>
#include <errno.h>
return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
}
-struct radeon *r600_drm_winsys_create(struct radeon_winsys *rw)
+struct radeon *radeon_create(struct radeon_winsys *ws)
{
- struct radeon *radeon;
int r;
-
- radeon = calloc(1, sizeof(*radeon));
+ struct radeon *radeon = CALLOC_STRUCT(radeon);
if (radeon == NULL) {
return NULL;
}
- rw->query_info(rw, &radeon->info);
+ radeon->ws = ws;
+ ws->query_info(ws, &radeon->info);
radeon->family = radeon_family_from_device(radeon->info.pci_id);
if (radeon->family == CHIP_UNKNOWN) {
fprintf(stderr, "Unknown chipset 0x%04X\n", radeon->info.pci_id);
- return radeon_decref(radeon);
+ return radeon_destroy(radeon);
}
/* setup class */
switch (radeon->family) {
}
r = radeon_init_fence(radeon);
if (r) {
- radeon_decref(radeon);
+ radeon_destroy(radeon);
return NULL;
}
return radeon;
}
-struct radeon *radeon_decref(struct radeon *radeon)
+struct radeon *radeon_destroy(struct radeon *radeon)
{
if (radeon == NULL)
return NULL;
if (radeon->bomgr)
r600_bomgr_destroy(radeon->bomgr);
- free(radeon);
+ FREE(radeon);
return NULL;
}
struct radeon_winsys;
-struct radeon *r600_drm_winsys_create(struct radeon_winsys *rw);
+struct radeon *radeon_create(struct radeon_winsys *ws);
#endif
memset(ctx, 0, sizeof(struct r600_context));
ctx->radeon = radeon;
+
LIST_INITHEAD(&ctx->query_list);
/* init dirty list */
struct r600_bo;
struct radeon {
+ struct radeon_winsys *ws;
struct radeon_info info;
unsigned family;
enum chip_class chip_class;