Renaming a few files, types, and functions.
Also make the winsys independent of r300g.
r300_transfer.c
LIBRARY_INCLUDES = \
- -I$(TOP)/src/mesa/drivers/dri/r300/compiler \
- -I$(TOP)/src/gallium/winsys/drm/radeon/core
+ -I$(TOP)/src/mesa/drivers/dri/r300/compiler
COMPILER_ARCHIVE = $(TOP)/src/mesa/drivers/dri/r300/compiler/libr300compiler.a
#include "r300_context.h"
#include "r300_emit.h"
#include "r300_texture.h"
-#include "r300_winsys.h"
#include "util/u_format.h"
#include "util/u_pack_color.h"
(struct r300_hyperz_state*)r300->hyperz_state.state;
uint32_t width = fb->width;
uint32_t height = fb->height;
- boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ);
+ boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ);
uint32_t hyperz_dcv = hyperz->zb_depthclearvalue;
/* Enable fast Z clear.
r300_get_num_cs_end_dwords(r300);
/* Reserve CS space. */
- if (dwords > (R300_MAX_CMDBUF_DWORDS - r300->cs->cdw)) {
- r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL);
+ if (dwords > (RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw)) {
+ r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL);
}
/* Emit clear packets. */
#include "r300_emit.h"
#include "r300_screen.h"
#include "r300_screen_buffer.h"
-#include "r300_winsys.h"
static void r300_update_num_contexts(struct r300_screen *r300screen,
int diff)
boolean is_rv350 = r300->screen->caps.is_rv350;
boolean is_r500 = r300->screen->caps.is_r500;
boolean has_tcl = r300->screen->caps.has_tcl;
- boolean drm_2_6_0 = r300->rws->get_value(r300->rws, R300_VID_DRM_2_6_0);
- boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ);
+ boolean drm_2_6_0 = r300->rws->get_value(r300->rws, RADEON_VID_DRM_2_6_0);
+ boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ);
boolean has_hiz_ram = r300->screen->caps.hiz_ram > 0;
/* Create the actual atom list.
if (r300->screen->caps.is_r500 ||
(r300->screen->caps.is_rv350 &&
- r300->rws->get_value(r300->rws, R300_VID_DRM_2_6_0))) {
+ r300->rws->get_value(r300->rws, RADEON_VID_DRM_2_6_0))) {
OUT_CB_REG(R300_GB_Z_PEQ_CONFIG, 0);
}
END_CB;
{
struct r300_context* r300 = CALLOC_STRUCT(r300_context);
struct r300_screen* r300screen = r300_screen(screen);
- struct r300_winsys_screen *rws = r300screen->rws;
+ struct radeon_winsys *rws = r300screen->rws;
if (!r300)
return NULL;
"r300: DRM version: %d.%d.%d, Name: %s, ID: 0x%04x, GB: %d, Z: %d\n"
"r300: GART size: %d MB, VRAM size: %d MB\n"
"r300: AA compression: %s, Z compression: %s, HiZ: %s\n",
- rws->get_value(rws, R300_VID_DRM_MAJOR),
- rws->get_value(rws, R300_VID_DRM_MINOR),
- rws->get_value(rws, R300_VID_DRM_PATCHLEVEL),
+ rws->get_value(rws, RADEON_VID_DRM_MAJOR),
+ rws->get_value(rws, RADEON_VID_DRM_MINOR),
+ rws->get_value(rws, RADEON_VID_DRM_PATCHLEVEL),
screen->get_name(screen),
- rws->get_value(rws, R300_VID_PCI_ID),
- rws->get_value(rws, R300_VID_GB_PIPES),
- rws->get_value(rws, R300_VID_Z_PIPES),
- rws->get_value(rws, R300_VID_GART_SIZE) >> 20,
- rws->get_value(rws, R300_VID_VRAM_SIZE) >> 20,
- rws->get_value(rws, R300_CAN_AACOMPRESS) ? "YES" : "NO",
- rws->get_value(rws, R300_CAN_HYPERZ) &&
+ rws->get_value(rws, RADEON_VID_PCI_ID),
+ rws->get_value(rws, RADEON_VID_R300_GB_PIPES),
+ rws->get_value(rws, RADEON_VID_R300_Z_PIPES),
+ rws->get_value(rws, RADEON_VID_GART_SIZE) >> 20,
+ rws->get_value(rws, RADEON_VID_VRAM_SIZE) >> 20,
+ rws->get_value(rws, RADEON_VID_CAN_AACOMPRESS) ? "YES" : "NO",
+ rws->get_value(rws, RADEON_VID_CAN_HYPERZ) &&
r300->screen->caps.zmask_ram ? "YES" : "NO",
- rws->get_value(rws, R300_CAN_HYPERZ) &&
+ rws->get_value(rws, RADEON_VID_CAN_HYPERZ) &&
r300->screen->caps.hiz_ram ? "YES" : "NO");
}
#include "r300_defines.h"
#include "r300_screen.h"
-#include "r300_winsys.h"
+#include "../../winsys/radeon/drm/radeon_winsys.h"
struct u_upload_mgr;
struct r300_context;
boolean begin_emitted;
/* The buffer where query results are stored. */
- struct r300_winsys_bo *buf;
- struct r300_winsys_cs_handle *cs_buf;
+ struct pb_buffer *buf;
+ struct radeon_winsys_cs_handle *cs_buf;
/* The size of the buffer. */
unsigned buffer_size;
/* The domain of the buffer. */
- enum r300_buffer_domain domain;
+ enum radeon_bo_domain domain;
/* Linked list members. */
struct r300_query* prev;
struct pipe_surface base;
/* Winsys buffer backing the texture. */
- struct r300_winsys_bo *buf;
- struct r300_winsys_cs_handle *cs_buf;
+ struct pb_buffer *buf;
+ struct radeon_winsys_cs_handle *cs_buf;
- enum r300_buffer_domain domain;
+ enum radeon_bo_domain domain;
uint32_t offset; /* COLOROFFSET or DEPTHOFFSET. */
uint32_t pitch; /* COLORPITCH or DEPTHPITCH. */
/* Buffer tiling.
* Macrotiling is specified per-level because small mipmaps cannot
* be macrotiled. */
- enum r300_buffer_tiling microtile;
- enum r300_buffer_tiling macrotile[R300_MAX_TEXTURE_LEVELS];
+ enum radeon_bo_layout microtile;
+ enum radeon_bo_layout macrotile[R300_MAX_TEXTURE_LEVELS];
/* Offsets into the buffer. */
unsigned offset_in_bytes[R300_MAX_TEXTURE_LEVELS];
struct u_vbuf_resource b;
/* Winsys buffer backing this resource. */
- struct r300_winsys_bo *buf;
- struct r300_winsys_cs_handle *cs_buf;
- enum r300_buffer_domain domain;
+ 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. */
struct pipe_context context;
/* The interface to the windowing system, etc. */
- struct r300_winsys_screen *rws;
+ struct radeon_winsys *rws;
/* The command stream. */
- struct r300_winsys_cs *cs;
+ struct radeon_winsys_cs *cs;
/* Screen. */
struct r300_screen *screen;
#include "r300_reg.h"
#include "r300_context.h"
-#include "r300_winsys.h"
/* Yes, I know macros are ugly. However, they are much prettier than the code
* that they neatly hide away, and don't have the cost of function setup,so
*/
#define CS_LOCALS(context) \
- struct r300_winsys_cs *cs_copy = (context)->cs; \
- struct r300_winsys_screen *cs_winsys = (context)->rws; \
+ struct radeon_winsys_cs *cs_copy = (context)->cs; \
+ struct radeon_winsys *cs_winsys = (context)->rws; \
int cs_count = 0; (void) cs_count; (void) cs_winsys;
#ifdef DEBUG
#define BEGIN_CS(size) do { \
- assert(size <= (R300_MAX_CMDBUF_DWORDS - cs_copy->cdw)); \
+ assert(size <= (RADEON_MAX_CMDBUF_DWORDS - cs_copy->cdw)); \
cs_count = size; \
} while (0)
#define R300_INVALID_FORMAT 0xffff
-/* Tiling flags. */
-enum r300_buffer_tiling {
- R300_BUFFER_LINEAR = 0,
- R300_BUFFER_TILED,
- R300_BUFFER_SQUARETILED,
-
- R300_BUFFER_UNKNOWN,
- R300_BUFFER_SELECT_LAYOUT = R300_BUFFER_UNKNOWN
-};
-
-enum r300_buffer_domain { /* bitfield */
- R300_DOMAIN_GTT = 2,
- R300_DOMAIN_VRAM = 4
-};
-
#endif
struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)state;
struct r300_surface* surf;
unsigned i;
- boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ);
+ boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ);
uint32_t rb3d_cctl = 0;
CS_LOCALS(r300);
if (flushed)
return FALSE;
- r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL);
+ r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL);
flushed = TRUE;
goto validate;
}
{
struct r300_context *r300 = r300_context(pipe);
struct r300_atom *atom;
- struct r300_winsys_bo **rfence = (struct r300_winsys_bo**)fence;
+ struct pb_buffer **rfence = (struct pb_buffer**)fence;
if (r300->draw && !r300->draw_vbo_locked)
r300_draw_flush_vbuf(r300);
*rfence = r300->rws->buffer_create(r300->rws, 1, 1,
PIPE_BIND_VERTEX_BUFFER,
PIPE_USAGE_STATIC,
- R300_DOMAIN_GTT);
+ RADEON_DOMAIN_GTT);
/* Add the fence as a dummy relocation. */
r300->rws->cs_add_reloc(r300->cs,
r300->rws->buffer_get_cs_handle(*rfence),
- R300_DOMAIN_GTT, R300_DOMAIN_GTT);
+ RADEON_DOMAIN_GTT, RADEON_DOMAIN_GTT);
}
if (r300->dirty_hw) {
#include "r300_context.h"
#include "r300_reg.h"
#include "r300_fs.h"
-#include "r300_winsys.h"
#include "util/u_format.h"
#include "util/u_mm.h"
}
if (!zstex ||
- !r300->rws->get_value(r300->rws, R300_CAN_HYPERZ))
+ !r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ))
return;
/* Zbuffer compression. */
#ifndef R300_PUBLIC_H
#define R300_PUBLIC_H
-struct r300_winsys_screen;
+struct radeon_winsys;
-struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws);
+struct pipe_screen* r300_screen_create(struct radeon_winsys *rws);
#endif
#include "r300_context.h"
#include "r300_screen.h"
#include "r300_emit.h"
-#include "r300_winsys.h"
#include <stdio.h>
return NULL;
q->type = query_type;
- q->domain = R300_DOMAIN_GTT;
+ q->domain = RADEON_DOMAIN_GTT;
q->buffer_size = 4096;
if (r300screen->caps.family == CHIP_FAMILY_RV530)
{
struct r300_query* q = r300_query(query);
- r300_winsys_bo_reference(&q->buf, NULL);
+ pb_reference(&q->buf, NULL);
remove_from_list(q);
FREE(query);
}
cs_dwords += r300_get_num_cs_end_dwords(r300);
/* Reserve requested CS space. */
- if (cs_dwords > (R300_MAX_CMDBUF_DWORDS - r300->cs->cdw)) {
- r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL);
+ if (cs_dwords > (RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw)) {
+ r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL);
flushed = TRUE;
}
if (!checked[vbi]) {
buf = r300->vbuf_mgr->real_vertex_buffer[vbi];
- if ((r300_resource(buf)->domain != R300_DOMAIN_GTT)) {
+ if ((r300_resource(buf)->domain != RADEON_DOMAIN_GTT)) {
return FALSE;
}
end_cs_dwords = r300_get_num_cs_end_dwords(r300);
while (count) {
- free_dwords = R300_MAX_CMDBUF_DWORDS - r300->cs->cdw;
+ free_dwords = RADEON_MAX_CMDBUF_DWORDS - r300->cs->cdw;
short_count = MIN2(count, (free_dwords - end_cs_dwords - 6) * 2);
#include "r300_texture.h"
#include "r300_screen_buffer.h"
#include "r300_state_inlines.h"
-#include "r300_winsys.h"
#include "r300_public.h"
#include "draw/draw_context.h"
unsigned sample_count,
unsigned usage)
{
- struct r300_winsys_screen *rws = r300_screen(screen)->rws;
+ struct radeon_winsys *rws = r300_screen(screen)->rws;
uint32_t retval = 0;
- boolean drm_2_8_0 = rws->get_value(rws, R300_VID_DRM_2_8_0);
+ boolean drm_2_8_0 = rws->get_value(rws, RADEON_VID_DRM_2_8_0);
boolean is_r500 = r300_screen(screen)->caps.is_r500;
boolean is_r400 = r300_screen(screen)->caps.is_r400;
boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM ||
static void r300_destroy_screen(struct pipe_screen* pscreen)
{
struct r300_screen* r300screen = r300_screen(pscreen);
- struct r300_winsys_screen *rws = r300_winsys_screen(pscreen);
+ struct radeon_winsys *rws = radeon_winsys(pscreen);
util_slab_destroy(&r300screen->pool_buffers);
pipe_mutex_destroy(r300screen->num_contexts_mutex);
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence)
{
- r300_winsys_bo_reference((struct r300_winsys_bo**)ptr,
- (struct r300_winsys_bo*)fence);
+ pb_reference((struct pb_buffer**)ptr,
+ (struct pb_buffer*)fence);
}
static boolean r300_fence_signalled(struct pipe_screen *screen,
struct pipe_fence_handle *fence)
{
- struct r300_winsys_screen *rws = r300_screen(screen)->rws;
- struct r300_winsys_bo *rfence = (struct r300_winsys_bo*)fence;
+ struct radeon_winsys *rws = r300_screen(screen)->rws;
+ struct pb_buffer *rfence = (struct pb_buffer*)fence;
return !rws->buffer_is_busy(rfence);
}
struct pipe_fence_handle *fence,
uint64_t timeout)
{
- struct r300_winsys_screen *rws = r300_screen(screen)->rws;
- struct r300_winsys_bo *rfence = (struct r300_winsys_bo*)fence;
+ struct radeon_winsys *rws = r300_screen(screen)->rws;
+ struct pb_buffer *rfence = (struct pb_buffer*)fence;
if (timeout != PIPE_TIMEOUT_INFINITE) {
int64_t start_time = os_time_get();
return TRUE;
}
-struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws)
+struct pipe_screen* r300_screen_create(struct radeon_winsys *rws)
{
struct r300_screen *r300screen = CALLOC_STRUCT(r300_screen);
return NULL;
}
- r300screen->caps.pci_id = rws->get_value(rws, R300_VID_PCI_ID);
- r300screen->caps.num_frag_pipes = rws->get_value(rws, R300_VID_GB_PIPES);
- r300screen->caps.num_z_pipes = rws->get_value(rws, R300_VID_Z_PIPES);
+ r300screen->caps.pci_id = rws->get_value(rws, RADEON_VID_PCI_ID);
+ r300screen->caps.num_frag_pipes = rws->get_value(rws, RADEON_VID_R300_GB_PIPES);
+ r300screen->caps.num_z_pipes = rws->get_value(rws, RADEON_VID_R300_Z_PIPES);
r300_init_debug(r300screen);
r300_parse_chipset(&r300screen->caps);
if (SCREEN_DBG_ON(r300screen, DBG_NO_HIZ))
r300screen->caps.hiz_ram = 0;
- if (!rws->get_value(rws, R300_VID_DRM_2_8_0))
+ if (!rws->get_value(rws, RADEON_VID_DRM_2_8_0))
r300screen->caps.has_us_format = FALSE;
pipe_mutex_init(r300screen->num_contexts_mutex);
#include <stdio.h>
-struct r300_winsys_screen;
+struct radeon_winsys;
struct r300_screen {
/* Parent class */
struct pipe_screen screen;
- struct r300_winsys_screen *rws;
+ struct radeon_winsys *rws;
/* Chipset capabilities */
struct r300_capabilities caps;
return (struct r300_screen*)screen;
}
-static INLINE struct r300_winsys_screen *
-r300_winsys_screen(struct pipe_screen *screen) {
+static INLINE struct radeon_winsys *
+radeon_winsys(struct pipe_screen *screen) {
return r300_screen(screen)->rws;
}
#include "util/u_math.h"
#include "r300_screen_buffer.h"
-#include "r300_winsys.h"
void r300_upload_index_buffer(struct r300_context *r300,
struct pipe_resource **index_buffer,
FREE(rbuf->constant_buffer);
if (rbuf->buf)
- r300_winsys_bo_reference(&rbuf->buf, NULL);
+ pb_reference(&rbuf->buf, NULL);
util_slab_free(&r300screen->pool_buffers, rbuf);
}
{
struct r300_context *r300 = r300_context(pipe);
struct r300_screen *r300screen = r300_screen(pipe->screen);
- struct r300_winsys_screen *rws = r300screen->rws;
+ struct radeon_winsys *rws = r300screen->rws;
struct r300_resource *rbuf = r300_resource(transfer->resource);
uint8_t *map;
struct pipe_transfer *transfer )
{
struct r300_screen *r300screen = r300_screen(pipe->screen);
- struct r300_winsys_screen *rws = r300screen->rws;
+ struct radeon_winsys *rws = r300screen->rws;
struct r300_resource *rbuf = r300_resource(transfer->resource);
if (rbuf->buf) {
unsigned layer_stride)
{
struct r300_context *r300 = r300_context(pipe);
- struct r300_winsys_screen *rws = r300->screen->rws;
+ struct radeon_winsys *rws = r300->screen->rws;
struct r300_resource *rbuf = r300_resource(resource);
uint8_t *map = NULL;
pipe_reference_init(&rbuf->b.b.b.reference, 1);
rbuf->b.b.b.screen = screen;
rbuf->b.user_ptr = NULL;
- rbuf->domain = R300_DOMAIN_GTT;
+ rbuf->domain = RADEON_DOMAIN_GTT;
rbuf->buf = NULL;
rbuf->buf_size = templ->width0;
rbuf->constant_buffer = NULL;
rbuf->b.b.b.flags = 0;
rbuf->b.b.vtbl = &r300_buffer_vtbl;
rbuf->b.user_ptr = ptr;
- rbuf->domain = R300_DOMAIN_GTT;
+ rbuf->domain = RADEON_DOMAIN_GTT;
rbuf->buf = NULL;
rbuf->buf_size = size;
rbuf->constant_buffer = NULL;
#include "util/u_transfer.h"
#include "r300_screen.h"
-#include "r300_winsys.h"
#include "r300_context.h"
/* Functions. */
#include "r300_fs.h"
#include "r300_texture.h"
#include "r300_vs.h"
-#include "r300_winsys.h"
/* r300_state: Functions used to intialize state context by translating
* Gallium state objects into semi-native r300 state objects. */
enum r300_fb_state_change change)
{
struct pipe_framebuffer_state *state = r300->fb_state.state;
- boolean can_hyperz = r300->rws->get_value(r300->rws, R300_CAN_HYPERZ);
+ boolean can_hyperz = r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ);
r300_mark_atom_dirty(r300, &r300->gpu_flush);
r300_mark_atom_dirty(r300, &r300->fb_state);
#include "r300_texture_desc.h"
#include "r300_transfer.h"
#include "r300_screen.h"
-#include "r300_winsys.h"
#include "util/u_format.h"
#include "util/u_format_s3tc.h"
{
struct r300_resource* tex = (struct r300_resource*)texture;
- r300_winsys_bo_reference(&tex->buf, NULL);
+ pb_reference(&tex->buf, NULL);
FREE(tex);
}
struct pipe_resource *texture,
struct winsys_handle *whandle)
{
- struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
+ struct radeon_winsys *rws = (struct radeon_winsys *)screen->winsys;
struct r300_resource* tex = (struct r300_resource*)texture;
if (!tex) {
static struct r300_resource*
r300_texture_create_object(struct r300_screen *rscreen,
const struct pipe_resource *base,
- enum r300_buffer_tiling microtile,
- enum r300_buffer_tiling macrotile,
+ enum radeon_bo_layout microtile,
+ enum radeon_bo_layout macrotile,
unsigned stride_in_bytes_override,
unsigned max_buffer_size,
- struct r300_winsys_bo *buffer)
+ struct pb_buffer *buffer)
{
- struct r300_winsys_screen *rws = rscreen->rws;
+ struct radeon_winsys *rws = rscreen->rws;
struct r300_resource *tex = CALLOC_STRUCT(r300_resource);
if (!tex) {
if (buffer)
- r300_winsys_bo_reference(&buffer, NULL);
+ pb_reference(&buffer, NULL);
return NULL;
}
tex->tex.macrotile[0] = macrotile;
tex->tex.stride_in_bytes_override = stride_in_bytes_override;
tex->domain = base->flags & R300_RESOURCE_FLAG_TRANSFER ?
- R300_DOMAIN_GTT :
- R300_DOMAIN_VRAM | R300_DOMAIN_GTT;
+ RADEON_DOMAIN_GTT :
+ RADEON_DOMAIN_VRAM | RADEON_DOMAIN_GTT;
tex->buf_size = max_buffer_size;
if (!r300_resource_set_properties(&rscreen->screen, &tex->b.b.b, 0, base)) {
if (buffer)
- r300_winsys_bo_reference(&buffer, NULL);
+ pb_reference(&buffer, NULL);
FREE(tex);
return NULL;
}
const struct pipe_resource *base)
{
struct r300_screen *rscreen = r300_screen(screen);
- enum r300_buffer_tiling microtile, macrotile;
+ enum radeon_bo_layout microtile, macrotile;
if ((base->flags & R300_RESOURCE_FLAG_TRANSFER) ||
(base->bind & PIPE_BIND_SCANOUT)) {
- microtile = R300_BUFFER_LINEAR;
- macrotile = R300_BUFFER_LINEAR;
+ microtile = RADEON_LAYOUT_LINEAR;
+ macrotile = RADEON_LAYOUT_LINEAR;
} else {
- microtile = R300_BUFFER_SELECT_LAYOUT;
- macrotile = R300_BUFFER_SELECT_LAYOUT;
+ /* This will make the texture_create_function select the layout. */
+ microtile = RADEON_LAYOUT_UNKNOWN;
+ macrotile = RADEON_LAYOUT_UNKNOWN;
}
return (struct pipe_resource*)
const struct pipe_resource *base,
struct winsys_handle *whandle)
{
- struct r300_winsys_screen *rws = (struct r300_winsys_screen*)screen->winsys;
+ struct radeon_winsys *rws = (struct radeon_winsys*)screen->winsys;
struct r300_screen *rscreen = r300_screen(screen);
- struct r300_winsys_bo *buffer;
- enum r300_buffer_tiling microtile, macrotile;
+ struct pb_buffer *buffer;
+ enum radeon_bo_layout microtile, macrotile;
unsigned stride, size;
/* Support only 2D textures without mipmaps */
/* Enforce a microtiled zbuffer. */
if (util_format_is_depth_or_stencil(base->format) &&
- microtile == R300_BUFFER_LINEAR) {
+ microtile == RADEON_LAYOUT_LINEAR) {
switch (util_format_get_blocksize(base->format)) {
case 4:
- microtile = R300_BUFFER_TILED;
+ microtile = RADEON_LAYOUT_TILED;
break;
case 2:
- microtile = R300_BUFFER_SQUARETILED;
+ microtile = RADEON_LAYOUT_SQUARETILED;
break;
}
}
/* Prefer VRAM if there are multiple domains to choose from. */
surface->domain = tex->domain;
- if (surface->domain & R300_DOMAIN_VRAM)
- surface->domain &= ~R300_DOMAIN_GTT;
+ if (surface->domain & RADEON_DOMAIN_VRAM)
+ surface->domain &= ~RADEON_DOMAIN_GTT;
surface->offset = r300_texture_get_offset(tex, level,
surf_tmpl->u.tex.first_layer);
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "r300_texture_desc.h"
-
#include "r300_context.h"
-#include "r300_winsys.h"
#include "util/u_format.h"
* in the given dimension. */
unsigned r300_get_pixel_alignment(enum pipe_format format,
unsigned num_samples,
- enum r300_buffer_tiling microtile,
- enum r300_buffer_tiling macrotile,
+ enum radeon_bo_layout microtile,
+ enum radeon_bo_layout macrotile,
enum r300_dim dim, boolean is_rs690)
{
static const unsigned table[2][5][3][2] =
unsigned tile = 0;
unsigned pixsize = util_format_get_blocksize(format);
- assert(macrotile <= R300_BUFFER_TILED);
- assert(microtile <= R300_BUFFER_SQUARETILED);
+ assert(macrotile <= RADEON_LAYOUT_TILED);
+ assert(microtile <= RADEON_LAYOUT_SQUARETILED);
assert(pixsize <= 16);
assert(dim <= DIM_HEIGHT);
unsigned tile, texdim;
tile = r300_get_pixel_alignment(tex->b.b.b.format, tex->b.b.b.nr_samples,
- tex->tex.microtile, R300_BUFFER_TILED, dim, 0);
+ tex->tex.microtile, RADEON_LAYOUT_TILED, dim, 0);
if (dim == DIM_WIDTH) {
texdim = u_minify(tex->tex.width0, level);
} else {
for (i = 0; i <= base->last_level; i++) {
/* Let's see if this miplevel can be macrotiled. */
tex->tex.macrotile[i] =
- (tex->tex.macrotile[0] == R300_BUFFER_TILED &&
+ (tex->tex.macrotile[0] == RADEON_LAYOUT_TILED &&
r300_texture_macro_switch(tex, i, rv350_mode, DIM_WIDTH) &&
r300_texture_macro_switch(tex, i, rv350_mode, DIM_HEIGHT)) ?
- R300_BUFFER_TILED : R300_BUFFER_LINEAR;
+ RADEON_LAYOUT_TILED : RADEON_LAYOUT_LINEAR;
stride = r300_texture_get_stride(screen, tex, i);
boolean is_zb = util_format_is_depth_or_stencil(format);
boolean dbg_no_tiling = SCREEN_DBG_ON(screen, DBG_NO_TILING);
- tex->tex.microtile = R300_BUFFER_LINEAR;
- tex->tex.macrotile[0] = R300_BUFFER_LINEAR;
+ tex->tex.microtile = RADEON_LAYOUT_LINEAR;
+ tex->tex.macrotile[0] = RADEON_LAYOUT_LINEAR;
if (!util_format_is_plain(format)) {
return;
case 1:
case 4:
case 8:
- tex->tex.microtile = R300_BUFFER_TILED;
+ tex->tex.microtile = RADEON_LAYOUT_TILED;
break;
case 2:
- tex->tex.microtile = R300_BUFFER_SQUARETILED;
+ tex->tex.microtile = RADEON_LAYOUT_SQUARETILED;
break;
}
/* Set macrotiling. */
if (r300_texture_macro_switch(tex, 0, rv350_mode, DIM_WIDTH) &&
r300_texture_macro_switch(tex, 0, rv350_mode, DIM_HEIGHT)) {
- tex->tex.macrotile[0] = R300_BUFFER_TILED;
+ tex->tex.macrotile[0] = RADEON_LAYOUT_TILED;
}
}
}
/* Setup tiling. */
- if (tex->tex.microtile == R300_BUFFER_SELECT_LAYOUT) {
+ if (tex->tex.microtile == RADEON_LAYOUT_UNKNOWN) {
r300_setup_tiling(rscreen, tex);
}
#define R300_TEXTURE_DESC_H
#include "pipe/p_format.h"
-#include "r300_defines.h"
+#include "r300_context.h"
struct pipe_resource;
struct r300_screen;
unsigned r300_get_pixel_alignment(enum pipe_format format,
unsigned num_samples,
- enum r300_buffer_tiling microtile,
- enum r300_buffer_tiling macrotile,
+ enum radeon_bo_layout microtile,
+ enum radeon_bo_layout macrotile,
enum r300_dim dim, boolean is_rs690);
boolean r300_texture_desc_init(struct r300_screen *rscreen,
struct pipe_transfer *transfer)
{
struct r300_context *r300 = r300_context(ctx);
- struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
+ struct radeon_winsys *rws = (struct radeon_winsys *)ctx->winsys;
struct r300_transfer *r300transfer = r300_transfer(transfer);
struct r300_resource *tex = r300_resource(transfer->resource);
char *map;
void r300_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
- struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
+ struct radeon_winsys *rws = (struct radeon_winsys *)ctx->winsys;
struct r300_transfer *r300transfer = r300_transfer(transfer);
struct r300_resource *tex = r300_resource(transfer->resource);
+++ /dev/null
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- * Copyright 2010 Marek Olšák <maraeo@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE. */
-
-#ifndef R300_WINSYS_H
-#define R300_WINSYS_H
-
-/* The public winsys interface header for the r300 pipe driver.
- * Any winsys hosting this pipe needs to implement r300_winsys_screen and then
- * call r300_screen_create to start things. */
-
-#include "r300_defines.h"
-
-#include "pipebuffer/pb_bufmgr.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#define R300_MAX_CMDBUF_DWORDS (16 * 1024)
-#define R300_FLUSH_ASYNC (1 << 0)
-
-struct winsys_handle;
-struct r300_winsys_screen;
-
-#define r300_winsys_bo pb_buffer
-#define r300_winsys_bo_reference(pdst, src) pb_reference(pdst, src)
-
-struct r300_winsys_cs_handle; /* for write_reloc etc. */
-
-struct r300_winsys_cs {
- unsigned cdw; /* Number of used dwords. */
- uint32_t *buf; /* The command buffer. */
-};
-
-enum r300_value_id {
- R300_VID_PCI_ID,
- R300_VID_GB_PIPES,
- R300_VID_Z_PIPES,
- R300_VID_GART_SIZE,
- R300_VID_VRAM_SIZE,
- R300_VID_DRM_MAJOR,
- R300_VID_DRM_MINOR,
- R300_VID_DRM_PATCHLEVEL,
-
- /* These should probably go away: */
- R300_VID_DRM_2_6_0, /* Hyper-Z, GB_Z_PEQ_CONFIG on rv350->r4xx, R500 FG_ALPHA_VALUE */
- R300_VID_DRM_2_8_0, /* R500 US_FORMAT regs, R500 ARGB2101010 colorbuffer, CMask, R16F/RG16F */
-
- R300_CAN_HYPERZ, /* ZMask + HiZ */
- R300_CAN_AACOMPRESS, /* CMask */
-};
-
-struct r300_winsys_screen {
- /**
- * Destroy this winsys.
- *
- * \param ws The winsys this function is called from.
- */
- void (*destroy)(struct r300_winsys_screen *ws);
-
- /**
- * Query a system value from a winsys.
- *
- * \param ws The winsys this function is called from.
- * \param vid One of the R300_VID_* enums.
- */
- uint32_t (*get_value)(struct r300_winsys_screen *ws,
- enum r300_value_id vid);
-
- /**************************************************************************
- * Buffer management. Buffer attributes are mostly fixed over its lifetime.
- *
- * Remember that gallium gets to choose the interface it needs, and the
- * window systems must then implement that interface (rather than the
- * other way around...).
- *************************************************************************/
-
- /**
- * Create a buffer object.
- *
- * \param ws The winsys this function is called from.
- * \param size The size to allocate.
- * \param alignment An alignment of the buffer in memory.
- * \param bind A bitmask of the PIPE_BIND_* flags.
- * \param usage A bitmask of the PIPE_USAGE_* flags.
- * \param domain A bitmask of the R300_DOMAIN_* flags.
- * \return The created buffer object.
- */
- struct r300_winsys_bo *(*buffer_create)(struct r300_winsys_screen *ws,
- unsigned size,
- unsigned alignment,
- unsigned bind,
- unsigned usage,
- enum r300_buffer_domain domain);
-
- struct r300_winsys_cs_handle *(*buffer_get_cs_handle)(
- struct r300_winsys_bo *buf);
-
- /**
- * Map the entire data store of a buffer object into the client's address
- * space.
- *
- * \param buf A winsys buffer object to map.
- * \param cs A command stream to flush if the buffer is referenced by it.
- * \param usage A bitmask of the PIPE_TRANSFER_* flags.
- * \return The pointer at the beginning of the buffer.
- */
- void *(*buffer_map)(struct r300_winsys_bo *buf,
- struct r300_winsys_cs *cs,
- enum pipe_transfer_usage usage);
-
- /**
- * Unmap a buffer object from the client's address space.
- *
- * \param buf A winsys buffer object to unmap.
- */
- void (*buffer_unmap)(struct r300_winsys_bo *buf);
-
- /**
- * Return TRUE if a buffer object is being used by the GPU.
- *
- * \param buf A winsys buffer object.
- */
- boolean (*buffer_is_busy)(struct r300_winsys_bo *buf);
-
- /**
- * Wait for a buffer object until it is not used by a GPU. This is
- * equivalent to a fence placed after the last command using the buffer,
- * and synchronizing to the fence.
- *
- * \param buf A winsys buffer object to wait for.
- */
- void (*buffer_wait)(struct r300_winsys_bo *buf);
-
- /**
- * Return tiling flags describing a memory layout of a buffer object.
- *
- * \param buf A winsys buffer object to get the flags from.
- * \param macrotile A pointer to the return value of the microtile flag.
- * \param microtile A pointer to the return value of the macrotile flag.
- *
- * \note microtile and macrotile are not bitmasks!
- */
- void (*buffer_get_tiling)(struct r300_winsys_bo *buf,
- enum r300_buffer_tiling *microtile,
- enum r300_buffer_tiling *macrotile);
-
- /**
- * Set tiling flags describing a memory layout of a buffer object.
- *
- * \param buf A winsys buffer object to set the flags for.
- * \param cs A command stream to flush if the buffer is referenced by it.
- * \param macrotile A macrotile flag.
- * \param microtile A microtile flag.
- * \param stride A stride of the buffer in bytes, for texturing.
- *
- * \note microtile and macrotile are not bitmasks!
- */
- void (*buffer_set_tiling)(struct r300_winsys_bo *buf,
- struct r300_winsys_cs *cs,
- enum r300_buffer_tiling microtile,
- enum r300_buffer_tiling macrotile,
- unsigned stride);
-
- /**
- * Get a winsys buffer from a winsys handle. The internal structure
- * of the handle is platform-specific and only a winsys should access it.
- *
- * \param ws The winsys this function is called from.
- * \param whandle A winsys handle pointer as was received from a state
- * tracker.
- * \param stride The returned buffer stride in bytes.
- * \param size The returned buffer size.
- */
- struct r300_winsys_bo *(*buffer_from_handle)(struct r300_winsys_screen *ws,
- struct winsys_handle *whandle,
- unsigned *stride,
- unsigned *size);
-
- /**
- * Get a winsys handle from a winsys buffer. The internal structure
- * of the handle is platform-specific and only a winsys should access it.
- *
- * \param buf A winsys buffer object to get the handle from.
- * \param whandle A winsys handle pointer.
- * \param stride A stride of the buffer in bytes, for texturing.
- * \return TRUE on success.
- */
- boolean (*buffer_get_handle)(struct r300_winsys_bo *buf,
- unsigned stride,
- struct winsys_handle *whandle);
-
- /**************************************************************************
- * Command submission.
- *
- * Each pipe context should create its own command stream and submit
- * commands independently of other contexts.
- *************************************************************************/
-
- /**
- * Create a command stream.
- *
- * \param ws The winsys this function is called from.
- */
- struct r300_winsys_cs *(*cs_create)(struct r300_winsys_screen *ws);
-
- /**
- * Destroy a command stream.
- *
- * \param cs A command stream to destroy.
- */
- void (*cs_destroy)(struct r300_winsys_cs *cs);
-
- /**
- * Add a new buffer relocation. Every relocation must first be added
- * before it can be written.
- *
- * \param cs A command stream to add buffer for validation against.
- * \param buf A winsys buffer to validate.
- * \param rd A read domain containing a bitmask of the R300_DOMAIN_* flags.
- * \param wd A write domain containing a bitmask of the R300_DOMAIN_* flags.
- */
- void (*cs_add_reloc)(struct r300_winsys_cs *cs,
- struct r300_winsys_cs_handle *buf,
- enum r300_buffer_domain rd,
- enum r300_buffer_domain wd);
-
- /**
- * Return TRUE if there is enough memory in VRAM and GTT for the relocs
- * added so far.
- *
- * \param cs A command stream to validate.
- */
- boolean (*cs_validate)(struct r300_winsys_cs *cs);
-
- /**
- * Write a relocated dword to a command buffer.
- *
- * \param cs A command stream the relocation is written to.
- * \param buf A winsys buffer to write the relocation for.
- * \param rd A read domain containing a bitmask of the R300_DOMAIN_* flags.
- * \param wd A write domain containing a bitmask of the R300_DOMAIN_* flags.
- */
- void (*cs_write_reloc)(struct r300_winsys_cs *cs,
- struct r300_winsys_cs_handle *buf);
-
- /**
- * Flush a command stream.
- *
- * \param cs A command stream to flush.
- * \param flags, R300_FLUSH_ASYNC or 0.
- */
- void (*cs_flush)(struct r300_winsys_cs *cs, unsigned flags);
-
- /**
- * Set a flush callback which is called from winsys when flush is
- * required.
- *
- * \param cs A command stream to set the callback for.
- * \param flush A flush callback function associated with the command stream.
- * \param user A user pointer that will be passed to the flush callback.
- */
- void (*cs_set_flush)(struct r300_winsys_cs *cs,
- void (*flush)(void *ctx, unsigned flags),
- void *user);
-
- /**
- * Return TRUE if a buffer is referenced by a command stream.
- *
- * \param cs A command stream.
- * \param buf A winsys buffer.
- */
- boolean (*cs_is_buffer_referenced)(struct r300_winsys_cs *cs,
- struct r300_winsys_cs_handle *buf);
-};
-
-#endif /* R300_WINSYS_H */
static struct pipe_screen *
create_screen(int fd)
{
- struct r300_winsys_screen *sws;
+ struct radeon_winsys *sws;
struct pipe_screen *screen;
- sws = r300_drm_winsys_screen_create(fd);
+ sws = radeon_drm_winsys_create(fd);
if (!sws)
return NULL;
pipe_r300_create_screen(int fd)
{
#if _EGL_PIPE_R300
- struct r300_winsys_screen *sws;
+ struct radeon_winsys *sws;
struct pipe_screen *screen;
- sws = r300_drm_winsys_screen_create(fd);
+ sws = radeon_drm_winsys_create(fd);
if (!sws)
return NULL;
static struct pipe_screen *
create_screen(int fd)
{
- struct r300_winsys_screen *sws;
+ struct radeon_winsys *sws;
struct pipe_screen *screen;
- sws = r300_drm_winsys_screen_create(fd);
+ sws = radeon_drm_winsys_create(fd);
if (!sws)
return NULL;
static struct pipe_screen *
create_screen(int fd)
{
- struct r300_winsys_screen *sws;
+ struct radeon_winsys *sws;
struct pipe_screen *screen;
- sws = r300_drm_winsys_screen_create(fd);
+ sws = radeon_drm_winsys_create(fd);
if (!sws)
return NULL;
C_SOURCES = \
radeon_drm_bo.c \
radeon_drm_cs.c \
- radeon_drm_common.c
+ radeon_drm_winsys.c
-LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \
- $(shell pkg-config libdrm --cflags-only-I)
+LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
include ../../../Makefile.template
radeon_sources = [
'radeon_drm_bo.c',
'radeon_drm_cs.c',
- 'radeon_drm_common.c',
+ 'radeon_drm_winsys.c',
]
try:
- env.ParseConfig('pkg-config --cflags libdrm_radeon')
+ env.ParseConfig('pkg-config --cflags libdrm')
except:
- print 'warning: not building r300g'
+ print 'warning: not building Gallium Radeon'
Return()
-env.Append(CPPPATH = '#/src/gallium/drivers/r300')
-
radeonwinsys = env.ConvenienceLibrary(
target ='radeonwinsys',
source = radeon_sources,
return bo;
}
-static void radeon_bo_wait(struct r300_winsys_bo *_buf)
+static void radeon_bo_wait(struct pb_buffer *_buf)
{
struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
struct drm_radeon_gem_wait_idle args = {};
bo->busy_for_write = FALSE;
}
-static boolean radeon_bo_is_busy(struct r300_winsys_bo *_buf)
+static boolean radeon_bo_is_busy(struct pb_buffer *_buf)
{
struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
struct drm_radeon_gem_busy args = {};
/* DONTBLOCK doesn't make sense with UNSYNCHRONIZED. */
if (flags & PB_USAGE_DONTBLOCK) {
if (radeon_bo_is_referenced_by_cs(cs, bo)) {
- cs->flush_cs(cs->flush_data, R300_FLUSH_ASYNC);
+ cs->flush_cs(cs->flush_data, RADEON_FLUSH_ASYNC);
return NULL;
}
- if (radeon_bo_is_busy((struct r300_winsys_bo*)bo)) {
+ if (radeon_bo_is_busy((struct pb_buffer*)bo)) {
return NULL;
}
} else {
* Only check whether the buffer is being used for write. */
if (radeon_bo_is_referenced_by_cs_for_write(cs, bo)) {
cs->flush_cs(cs->flush_data, 0);
- radeon_bo_wait((struct r300_winsys_bo*)bo);
+ radeon_bo_wait((struct pb_buffer*)bo);
} else if (bo->busy_for_write) {
/* Update the busy_for_write field (done by radeon_bo_is_busy)
* and wait if needed. */
- if (radeon_bo_is_busy((struct r300_winsys_bo*)bo)) {
- radeon_bo_wait((struct r300_winsys_bo*)bo);
+ if (radeon_bo_is_busy((struct pb_buffer*)bo)) {
+ radeon_bo_wait((struct pb_buffer*)bo);
}
}
} else {
radeon_drm_cs_sync_flush(cs);
}
- radeon_bo_wait((struct r300_winsys_bo*)bo);
+ radeon_bo_wait((struct pb_buffer*)bo);
}
}
}
return TRUE;
}
- if (radeon_bo_is_busy((struct r300_winsys_bo*)bo)) {
+ if (radeon_bo_is_busy((struct pb_buffer*)bo)) {
return TRUE;
}
return &mgr->base;
}
-static void *radeon_bo_map(struct r300_winsys_bo *buf,
- struct r300_winsys_cs *cs,
+static void *radeon_bo_map(struct pb_buffer *buf,
+ struct radeon_winsys_cs *cs,
enum pipe_transfer_usage usage)
{
struct pb_buffer *_buf = pb_buffer(buf);
return pb_map(_buf, get_pb_usage_from_transfer_flags(usage), cs);
}
-static void radeon_bo_get_tiling(struct r300_winsys_bo *_buf,
- enum r300_buffer_tiling *microtiled,
- enum r300_buffer_tiling *macrotiled)
+static void radeon_bo_get_tiling(struct pb_buffer *_buf,
+ enum radeon_bo_layout *microtiled,
+ enum radeon_bo_layout *macrotiled)
{
struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
struct drm_radeon_gem_set_tiling args = {};
&args,
sizeof(args));
- *microtiled = R300_BUFFER_LINEAR;
- *macrotiled = R300_BUFFER_LINEAR;
+ *microtiled = RADEON_LAYOUT_LINEAR;
+ *macrotiled = RADEON_LAYOUT_LINEAR;
if (args.tiling_flags & RADEON_BO_FLAGS_MICRO_TILE)
- *microtiled = R300_BUFFER_TILED;
+ *microtiled = RADEON_LAYOUT_TILED;
if (args.tiling_flags & RADEON_BO_FLAGS_MACRO_TILE)
- *macrotiled = R300_BUFFER_TILED;
+ *macrotiled = RADEON_LAYOUT_TILED;
}
-static void radeon_bo_set_tiling(struct r300_winsys_bo *_buf,
- struct r300_winsys_cs *rcs,
- enum r300_buffer_tiling microtiled,
- enum r300_buffer_tiling macrotiled,
+static void radeon_bo_set_tiling(struct pb_buffer *_buf,
+ struct radeon_winsys_cs *rcs,
+ enum radeon_bo_layout microtiled,
+ enum radeon_bo_layout macrotiled,
uint32_t pitch)
{
struct radeon_bo *bo = get_radeon_bo(pb_buffer(_buf));
sched_yield();
}
- if (microtiled == R300_BUFFER_TILED)
+ if (microtiled == RADEON_LAYOUT_TILED)
args.tiling_flags |= RADEON_BO_FLAGS_MICRO_TILE;
- else if (microtiled == R300_BUFFER_SQUARETILED)
+ else if (microtiled == RADEON_LAYOUT_SQUARETILED)
args.tiling_flags |= RADEON_BO_FLAGS_MICRO_TILE_SQUARE;
- if (macrotiled == R300_BUFFER_TILED)
+ if (macrotiled == RADEON_LAYOUT_TILED)
args.tiling_flags |= RADEON_BO_FLAGS_MACRO_TILE;
args.handle = bo->handle;
sizeof(args));
}
-static struct r300_winsys_cs_handle *radeon_drm_get_cs_handle(
- struct r300_winsys_bo *_buf)
+static struct radeon_winsys_cs_handle *radeon_drm_get_cs_handle(
+ struct pb_buffer *_buf)
{
/* return radeon_bo. */
- return (struct r300_winsys_cs_handle*)
+ return (struct radeon_winsys_cs_handle*)
get_radeon_bo(pb_buffer(_buf));
}
static unsigned get_pb_usage_from_create_flags(unsigned bind, unsigned usage,
- enum r300_buffer_domain domain)
+ enum radeon_bo_domain domain)
{
unsigned res = 0;
- if (domain & R300_DOMAIN_GTT)
+ if (domain & RADEON_DOMAIN_GTT)
res |= RADEON_PB_USAGE_DOMAIN_GTT;
- if (domain & R300_DOMAIN_VRAM)
+ if (domain & RADEON_DOMAIN_VRAM)
res |= RADEON_PB_USAGE_DOMAIN_VRAM;
return res;
}
-static struct r300_winsys_bo *
-radeon_winsys_bo_create(struct r300_winsys_screen *rws,
+static struct pb_buffer *
+radeon_winsys_bo_create(struct radeon_winsys *rws,
unsigned size,
unsigned alignment,
unsigned bind,
unsigned usage,
- enum r300_buffer_domain domain)
+ enum radeon_bo_domain domain)
{
struct radeon_drm_winsys *ws = radeon_drm_winsys(rws);
struct pb_desc desc;
if (!buffer)
return NULL;
- return (struct r300_winsys_bo*)buffer;
+ return (struct pb_buffer*)buffer;
}
-static struct r300_winsys_bo *radeon_winsys_bo_from_handle(struct r300_winsys_screen *rws,
+static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws,
struct winsys_handle *whandle,
unsigned *stride,
unsigned *size)
if (size)
*size = bo->base.base.size;
- return (struct r300_winsys_bo*)bo;
+ return (struct pb_buffer*)bo;
fail:
pipe_mutex_unlock(mgr->bo_handles_mutex);
return NULL;
}
-static boolean radeon_winsys_bo_get_handle(struct r300_winsys_bo *buffer,
+static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
unsigned stride,
struct winsys_handle *whandle)
{
* Jérôme Glisse <glisse@freedesktop.org>
* Marek Olšák <maraeo@gmail.com>
*/
-#ifndef RADEON_DRM_BUFFER_H
-#define RADEON_DRM_BUFFER_H
+#ifndef RADEON_DRM_BO_H
+#define RADEON_DRM_BO_H
-#include "radeon_winsys.h"
+#include "radeon_drm_winsys.h"
#include "pipebuffer/pb_bufmgr.h"
#include "os/os_thread.h"
}
static INLINE struct pb_buffer *
-pb_buffer(struct r300_winsys_bo *buffer)
+pb_buffer(struct pb_buffer *buffer)
{
return (struct pb_buffer *)buffer;
}
+++ /dev/null
-/*
- * Copyright © 2009 Corbin Simpson
- * Copyright © 2011 Marek Olšák <maraeo@gmail.com>
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Corbin Simpson <MostAwesomeDude@gmail.com>
- * Joakim Sindholt <opensource@zhasha.com>
- * Marek Olšák <maraeo@gmail.com>
- */
-
-#include "radeon_winsys.h"
-#include "radeon_drm_bo.h"
-#include "radeon_drm_cs.h"
-#include "radeon_drm_public.h"
-
-#include "pipebuffer/pb_bufmgr.h"
-#include "util/u_memory.h"
-
-#include <xf86drm.h>
-#include <stdio.h>
-
-#ifndef RADEON_INFO_WANT_HYPERZ
-#define RADEON_INFO_WANT_HYPERZ 7
-#endif
-#ifndef RADEON_INFO_WANT_CMASK
-#define RADEON_INFO_WANT_CMASK 8
-#endif
-
-/* Enable/disable feature access. Return TRUE on success. */
-static boolean radeon_set_fd_access(int fd, unsigned request, boolean enable)
-{
- struct drm_radeon_info info = {0};
- unsigned value = enable ? 1 : 0;
-
- info.value = (unsigned long)&value;
- info.request = request;
-
- if (drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)) != 0)
- return FALSE;
-
- if (enable && !value)
- return FALSE;
-
- return TRUE;
-}
-
-/* Helper function to do the ioctls needed for setup and init. */
-static void do_ioctls(struct radeon_drm_winsys *winsys)
-{
- struct drm_radeon_gem_info gem_info = {0};
- struct drm_radeon_info info = {0};
- int target = 0;
- int retval;
- drmVersionPtr version;
-
- info.value = (unsigned long)⌖
-
- /* We do things in a specific order here.
- *
- * DRM version first. We need to be sure we're running on a KMS chipset.
- * This is also for some features.
- *
- * Then, the PCI ID. This is essential and should return usable numbers
- * for all Radeons. If this fails, we probably got handed an FD for some
- * non-Radeon card.
- *
- * The GB and Z pipe requests should always succeed, but they might not
- * return sensical values for all chipsets, but that's alright because
- * the pipe drivers already know that.
- *
- * The GEM info is actually bogus on the kernel side, as well as our side
- * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
- * we don't actually use the info for anything yet. */
-
- version = drmGetVersion(winsys->fd);
- if (version->version_major != 2 ||
- version->version_minor < 3) {
- fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
- "only compatible with 2.3.x (kernel 2.6.34) and later.\n",
- __FUNCTION__,
- version->version_major,
- version->version_minor,
- version->version_patchlevel);
- drmFreeVersion(version);
- exit(1);
- }
-
- winsys->drm_major = version->version_major;
- winsys->drm_minor = version->version_minor;
- winsys->drm_patchlevel = version->version_patchlevel;
-
- info.request = RADEON_INFO_DEVICE_ID;
- retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_INFO, &info, sizeof(info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get PCI ID, "
- "error number %d\n", __FUNCTION__, retval);
- exit(1);
- }
- winsys->pci_id = target;
-
- info.request = RADEON_INFO_NUM_GB_PIPES;
- retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_INFO, &info, sizeof(info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get GB pipe count, "
- "error number %d\n", __FUNCTION__, retval);
- exit(1);
- }
- winsys->gb_pipes = target;
-
- info.request = RADEON_INFO_NUM_Z_PIPES;
- retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_INFO, &info, sizeof(info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get Z pipe count, "
- "error number %d\n", __FUNCTION__, retval);
- exit(1);
- }
- winsys->z_pipes = target;
-
- if (debug_get_bool_option("RADEON_HYPERZ", FALSE)) {
- winsys->hyperz = radeon_set_fd_access(winsys->fd,
- RADEON_INFO_WANT_HYPERZ, TRUE);
- }
-
- if (debug_get_bool_option("RADEON_CMASK", FALSE)) {
- winsys->aacompress = radeon_set_fd_access(winsys->fd,
- RADEON_INFO_WANT_CMASK, TRUE);
- }
-
- retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_GEM_INFO,
- &gem_info, sizeof(gem_info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
- __FUNCTION__, retval);
- exit(1);
- }
- winsys->gart_size = gem_info.gart_size;
- winsys->vram_size = gem_info.vram_size;
-
- drmFreeVersion(version);
-
- winsys->num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
-}
-
-static void radeon_winsys_destroy(struct r300_winsys_screen *rws)
-{
- struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws;
-
- ws->cman->destroy(ws->cman);
- ws->kman->destroy(ws->kman);
- FREE(rws);
-}
-
-static uint32_t radeon_get_value(struct r300_winsys_screen *rws,
- enum r300_value_id id)
-{
- struct radeon_drm_winsys *ws = (struct radeon_drm_winsys *)rws;
-
- switch(id) {
- case R300_VID_PCI_ID:
- return ws->pci_id;
- case R300_VID_GB_PIPES:
- return ws->gb_pipes;
- case R300_VID_Z_PIPES:
- return ws->z_pipes;
- case R300_VID_GART_SIZE:
- return ws->gart_size;
- case R300_VID_VRAM_SIZE:
- return ws->vram_size;
- case R300_VID_DRM_MAJOR:
- return ws->drm_major;
- case R300_VID_DRM_MINOR:
- return ws->drm_minor;
- case R300_VID_DRM_PATCHLEVEL:
- return ws->drm_patchlevel;
- case R300_VID_DRM_2_6_0:
- return ws->drm_major*100 + ws->drm_minor >= 206;
- case R300_VID_DRM_2_8_0:
- return ws->drm_major*100 + ws->drm_minor >= 208;
- case R300_CAN_HYPERZ:
- return ws->hyperz;
- case R300_CAN_AACOMPRESS:
- return ws->aacompress;
- }
- return 0;
-}
-
-struct r300_winsys_screen *r300_drm_winsys_screen_create(int fd)
-{
- struct radeon_drm_winsys *ws = CALLOC_STRUCT(radeon_drm_winsys);
- if (!ws) {
- return NULL;
- }
-
- ws->fd = fd;
- do_ioctls(ws);
-
- if (!is_r3xx(ws->pci_id)) {
- goto fail;
- }
-
- /* Create managers. */
- ws->kman = radeon_bomgr_create(ws);
- if (!ws->kman)
- goto fail;
- ws->cman = pb_cache_manager_create(ws->kman, 1000000);
- if (!ws->cman)
- goto fail;
-
- /* Set functions. */
- ws->base.destroy = radeon_winsys_destroy;
- ws->base.get_value = radeon_get_value;
-
- radeon_bomgr_init_functions(ws);
- radeon_drm_cs_init_functions(ws);
-
- return &ws->base;
-
-fail:
- if (ws->cman)
- ws->cman->destroy(ws->cman);
- if (ws->kman)
- ws->kman->destroy(ws->kman);
- FREE(ws);
- return NULL;
-}
/*
This file replaces libdrm's radeon_cs_gem with our own implemention.
- It's optimized specifically for r300g, but r600g could use it as well.
+ It's optimized specifically for Radeon DRM.
Reloc writes and space checking are faster and simpler than their
counterparts in libdrm (the time complexity of all the functions
is O(1) in nearly all scenarios, thanks to hashing).
FREE(csc->relocs);
}
-static struct r300_winsys_cs *radeon_drm_cs_create(struct r300_winsys_screen *rws)
+static struct radeon_winsys_cs *radeon_drm_cs_create(struct radeon_winsys *rws)
{
struct radeon_drm_winsys *ws = radeon_drm_winsys(rws);
struct radeon_drm_cs *cs;
#define OUT_CS(cs, value) (cs)->buf[(cs)->cdw++] = (value)
static INLINE void update_domains(struct drm_radeon_cs_reloc *reloc,
- enum r300_buffer_domain rd,
- enum r300_buffer_domain wd,
- enum r300_buffer_domain *added_domains)
+ enum radeon_bo_domain rd,
+ enum radeon_bo_domain wd,
+ enum radeon_bo_domain *added_domains)
{
*added_domains = (rd | wd) & ~(reloc->read_domains | reloc->write_domain);
static void radeon_add_reloc(struct radeon_cs_context *csc,
struct radeon_bo *bo,
- enum r300_buffer_domain rd,
- enum r300_buffer_domain wd,
- enum r300_buffer_domain *added_domains)
+ enum radeon_bo_domain rd,
+ enum radeon_bo_domain wd,
+ enum radeon_bo_domain *added_domains)
{
struct drm_radeon_cs_reloc *reloc;
unsigned i;
*added_domains = rd | wd;
}
-static void radeon_drm_cs_add_reloc(struct r300_winsys_cs *rcs,
- struct r300_winsys_cs_handle *buf,
- enum r300_buffer_domain rd,
- enum r300_buffer_domain wd)
+static void radeon_drm_cs_add_reloc(struct radeon_winsys_cs *rcs,
+ struct radeon_winsys_cs_handle *buf,
+ enum radeon_bo_domain rd,
+ enum radeon_bo_domain wd)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
struct radeon_bo *bo = (struct radeon_bo*)buf;
- enum r300_buffer_domain added_domains;
+ enum radeon_bo_domain added_domains;
radeon_add_reloc(cs->csc, bo, rd, wd, &added_domains);
if (!added_domains)
return;
- if (added_domains & R300_DOMAIN_GTT)
+ if (added_domains & RADEON_DOMAIN_GTT)
cs->csc->used_gart += bo->size;
- if (added_domains & R300_DOMAIN_VRAM)
+ if (added_domains & RADEON_DOMAIN_VRAM)
cs->csc->used_vram += bo->size;
}
-static boolean radeon_drm_cs_validate(struct r300_winsys_cs *rcs)
+static boolean radeon_drm_cs_validate(struct radeon_winsys_cs *rcs)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
cs->csc->used_vram < cs->ws->vram_size * 0.8;
}
-static void radeon_drm_cs_write_reloc(struct r300_winsys_cs *rcs,
- struct r300_winsys_cs_handle *buf)
+static void radeon_drm_cs_write_reloc(struct radeon_winsys_cs *rcs,
+ struct radeon_winsys_cs_handle *buf)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
struct radeon_bo *bo = (struct radeon_bo*)buf;
DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", TRUE)
-static void radeon_drm_cs_flush(struct r300_winsys_cs *rcs, unsigned flags)
+static void radeon_drm_cs_flush(struct radeon_winsys_cs *rcs, unsigned flags)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
struct radeon_cs_context *tmp;
}
if (cs->ws->num_cpus > 1 && debug_get_option_thread() &&
- (flags & R300_FLUSH_ASYNC)) {
+ (flags & RADEON_FLUSH_ASYNC)) {
cs->thread = pipe_thread_create(radeon_drm_cs_emit_ioctl, cs->csc);
assert(cs->thread);
} else {
cs->base.cdw = 0;
}
-static void radeon_drm_cs_destroy(struct r300_winsys_cs *rcs)
+static void radeon_drm_cs_destroy(struct radeon_winsys_cs *rcs)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
radeon_drm_cs_sync_flush(cs);
FREE(cs);
}
-static void radeon_drm_cs_set_flush(struct r300_winsys_cs *rcs,
+static void radeon_drm_cs_set_flush(struct radeon_winsys_cs *rcs,
void (*flush)(void *ctx, unsigned flags),
void *user)
{
cs->flush_data = user;
}
-static boolean radeon_bo_is_referenced(struct r300_winsys_cs *rcs,
- struct r300_winsys_cs_handle *_buf)
+static boolean radeon_bo_is_referenced(struct radeon_winsys_cs *rcs,
+ struct radeon_winsys_cs_handle *_buf)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
struct radeon_bo *bo = (struct radeon_bo*)_buf;
#include <radeon_drm.h>
struct radeon_cs_context {
- uint32_t buf[R300_MAX_CMDBUF_DWORDS];
+ uint32_t buf[RADEON_MAX_CMDBUF_DWORDS];
int fd;
struct drm_radeon_cs cs;
};
struct radeon_drm_cs {
- struct r300_winsys_cs base;
+ struct radeon_winsys_cs base;
/* We flip between these two CS. While one is being consumed
* by the kernel in another thread, the other one is being filled
int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo);
static INLINE struct radeon_drm_cs *
-radeon_drm_cs(struct r300_winsys_cs *base)
+radeon_drm_cs(struct radeon_winsys_cs *base)
{
return (struct radeon_drm_cs*)base;
}
#include "pipe/p_defines.h"
-struct r300_winsys_screen;
+struct radeon_winsys;
-struct r300_winsys_screen *r300_drm_winsys_screen_create(int fd);
+struct radeon_winsys *radeon_drm_winsys_create(int fd);
static INLINE boolean is_r3xx(int pciid)
{
--- /dev/null
+/*
+ * Copyright © 2009 Corbin Simpson
+ * Copyright © 2011 Marek Olšák <maraeo@gmail.com>
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Joakim Sindholt <opensource@zhasha.com>
+ * Marek Olšák <maraeo@gmail.com>
+ */
+
+#include "radeon_drm_bo.h"
+#include "radeon_drm_cs.h"
+#include "radeon_drm_public.h"
+
+#include "pipebuffer/pb_bufmgr.h"
+#include "util/u_memory.h"
+
+#include <xf86drm.h>
+#include <stdio.h>
+
+#ifndef RADEON_INFO_WANT_HYPERZ
+#define RADEON_INFO_WANT_HYPERZ 7
+#endif
+#ifndef RADEON_INFO_WANT_CMASK
+#define RADEON_INFO_WANT_CMASK 8
+#endif
+
+/* Enable/disable feature access. Return TRUE on success. */
+static boolean radeon_set_fd_access(int fd, unsigned request, boolean enable)
+{
+ struct drm_radeon_info info = {0};
+ unsigned value = enable ? 1 : 0;
+
+ info.value = (unsigned long)&value;
+ info.request = request;
+
+ if (drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)) != 0)
+ return FALSE;
+
+ if (enable && !value)
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Helper function to do the ioctls needed for setup and init. */
+static void do_ioctls(struct radeon_drm_winsys *winsys)
+{
+ struct drm_radeon_gem_info gem_info = {0};
+ struct drm_radeon_info info = {0};
+ int target = 0;
+ int retval;
+ drmVersionPtr version;
+
+ info.value = (unsigned long)⌖
+
+ /* We do things in a specific order here.
+ *
+ * DRM version first. We need to be sure we're running on a KMS chipset.
+ * This is also for some features.
+ *
+ * Then, the PCI ID. This is essential and should return usable numbers
+ * for all Radeons. If this fails, we probably got handed an FD for some
+ * non-Radeon card.
+ *
+ * The GB and Z pipe requests should always succeed, but they might not
+ * return sensical values for all chipsets, but that's alright because
+ * the pipe drivers already know that.
+ *
+ * The GEM info is actually bogus on the kernel side, as well as our side
+ * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
+ * we don't actually use the info for anything yet. */
+
+ version = drmGetVersion(winsys->fd);
+ if (version->version_major != 2 ||
+ version->version_minor < 3) {
+ fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
+ "only compatible with 2.3.x (kernel 2.6.34) and later.\n",
+ __FUNCTION__,
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ drmFreeVersion(version);
+ exit(1);
+ }
+
+ winsys->drm_major = version->version_major;
+ winsys->drm_minor = version->version_minor;
+ winsys->drm_patchlevel = version->version_patchlevel;
+
+ info.request = RADEON_INFO_DEVICE_ID;
+ retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_INFO, &info, sizeof(info));
+ if (retval) {
+ fprintf(stderr, "%s: Failed to get PCI ID, "
+ "error number %d\n", __FUNCTION__, retval);
+ exit(1);
+ }
+ winsys->pci_id = target;
+
+ info.request = RADEON_INFO_NUM_GB_PIPES;
+ retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_INFO, &info, sizeof(info));
+ if (retval) {
+ fprintf(stderr, "%s: Failed to get GB pipe count, "
+ "error number %d\n", __FUNCTION__, retval);
+ exit(1);
+ }
+ winsys->gb_pipes = target;
+
+ info.request = RADEON_INFO_NUM_Z_PIPES;
+ retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_INFO, &info, sizeof(info));
+ if (retval) {
+ fprintf(stderr, "%s: Failed to get Z pipe count, "
+ "error number %d\n", __FUNCTION__, retval);
+ exit(1);
+ }
+ winsys->z_pipes = target;
+
+ if (debug_get_bool_option("RADEON_HYPERZ", FALSE)) {
+ winsys->hyperz = radeon_set_fd_access(winsys->fd,
+ RADEON_INFO_WANT_HYPERZ, TRUE);
+ }
+
+ if (debug_get_bool_option("RADEON_CMASK", FALSE)) {
+ winsys->aacompress = radeon_set_fd_access(winsys->fd,
+ RADEON_INFO_WANT_CMASK, TRUE);
+ }
+
+ retval = drmCommandWriteRead(winsys->fd, DRM_RADEON_GEM_INFO,
+ &gem_info, sizeof(gem_info));
+ if (retval) {
+ fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
+ __FUNCTION__, retval);
+ exit(1);
+ }
+ winsys->gart_size = gem_info.gart_size;
+ winsys->vram_size = gem_info.vram_size;
+
+ drmFreeVersion(version);
+
+ winsys->num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+}
+
+static void radeon_winsys_destroy(struct radeon_winsys *rws)
+{
+ struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws;
+
+ ws->cman->destroy(ws->cman);
+ ws->kman->destroy(ws->kman);
+ FREE(rws);
+}
+
+static uint32_t radeon_get_value(struct radeon_winsys *rws,
+ enum radeon_value_id id)
+{
+ struct radeon_drm_winsys *ws = (struct radeon_drm_winsys *)rws;
+
+ switch(id) {
+ case RADEON_VID_PCI_ID:
+ return ws->pci_id;
+ case RADEON_VID_R300_GB_PIPES:
+ return ws->gb_pipes;
+ case RADEON_VID_R300_Z_PIPES:
+ return ws->z_pipes;
+ case RADEON_VID_GART_SIZE:
+ return ws->gart_size;
+ case RADEON_VID_VRAM_SIZE:
+ return ws->vram_size;
+ case RADEON_VID_DRM_MAJOR:
+ return ws->drm_major;
+ case RADEON_VID_DRM_MINOR:
+ return ws->drm_minor;
+ case RADEON_VID_DRM_PATCHLEVEL:
+ return ws->drm_patchlevel;
+ case RADEON_VID_DRM_2_6_0:
+ return ws->drm_major*100 + ws->drm_minor >= 206;
+ case RADEON_VID_DRM_2_8_0:
+ return ws->drm_major*100 + ws->drm_minor >= 208;
+ case RADEON_VID_CAN_HYPERZ:
+ return ws->hyperz;
+ case RADEON_VID_CAN_AACOMPRESS:
+ return ws->aacompress;
+ }
+ return 0;
+}
+
+struct radeon_winsys *radeon_drm_winsys_create(int fd)
+{
+ struct radeon_drm_winsys *ws = CALLOC_STRUCT(radeon_drm_winsys);
+ if (!ws) {
+ return NULL;
+ }
+
+ ws->fd = fd;
+ do_ioctls(ws);
+
+ if (!is_r3xx(ws->pci_id)) {
+ goto fail;
+ }
+
+ /* Create managers. */
+ ws->kman = radeon_bomgr_create(ws);
+ if (!ws->kman)
+ goto fail;
+ ws->cman = pb_cache_manager_create(ws->kman, 1000000);
+ if (!ws->cman)
+ goto fail;
+
+ /* Set functions. */
+ ws->base.destroy = radeon_winsys_destroy;
+ ws->base.get_value = radeon_get_value;
+
+ radeon_bomgr_init_functions(ws);
+ radeon_drm_cs_init_functions(ws);
+
+ return &ws->base;
+
+fail:
+ if (ws->cman)
+ ws->cman->destroy(ws->cman);
+ if (ws->kman)
+ ws->kman->destroy(ws->kman);
+ FREE(ws);
+ return NULL;
+}
--- /dev/null
+/*
+ * Copyright © 2009 Corbin Simpson
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ */
+#ifndef RADEON_DRM_WINSYS_H
+#define RADEON_DRM_WINSYS_H
+
+#include "radeon_winsys.h"
+
+struct radeon_drm_winsys {
+ struct radeon_winsys base;
+
+ int fd; /* DRM file descriptor */
+ int num_cs; /* The number of command streams created. */
+
+ struct pb_manager *kman;
+ struct pb_manager *cman;
+
+ uint32_t pci_id; /* PCI ID */
+ uint32_t gb_pipes; /* GB pipe count */
+ uint32_t z_pipes; /* Z pipe count (rv530 only) */
+ uint32_t gart_size; /* GART size. */
+ uint32_t vram_size; /* VRAM size. */
+ uint32_t num_cpus; /* Number of CPUs. */
+
+ unsigned drm_major;
+ unsigned drm_minor;
+ unsigned drm_patchlevel;
+
+ /* Hyper-Z user */
+ boolean hyperz;
+ /* AA compression (CMask) */
+ boolean aacompress;
+};
+
+static INLINE struct radeon_drm_winsys *
+radeon_drm_winsys(struct radeon_winsys *base)
+{
+ return (struct radeon_drm_winsys*)base;
+}
+
+#endif
/*
- * Copyright © 2009 Corbin Simpson
- * All Rights Reserved.
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2010 Marek Olšák <maraeo@gmail.com>
*
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
*
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Corbin Simpson <MostAwesomeDude@gmail.com>
- */
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
#ifndef RADEON_WINSYS_H
#define RADEON_WINSYS_H
-#include "r300_winsys.h"
+/* The public winsys interface header for the radeon driver. */
-struct radeon_drm_winsys {
- struct r300_winsys_screen base;
+#include "pipebuffer/pb_bufmgr.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_state.h"
- int fd; /* DRM file descriptor */
- int num_cs; /* The number of command streams created. */
+#define RADEON_MAX_CMDBUF_DWORDS (16 * 1024)
+#define RADEON_FLUSH_ASYNC (1 << 0)
- struct pb_manager *kman;
- struct pb_manager *cman;
+/* Tiling flags. */
+enum radeon_bo_layout {
+ RADEON_LAYOUT_LINEAR = 0,
+ RADEON_LAYOUT_TILED,
+ RADEON_LAYOUT_SQUARETILED,
- uint32_t pci_id; /* PCI ID */
- uint32_t gb_pipes; /* GB pipe count */
- uint32_t z_pipes; /* Z pipe count (rv530 only) */
- uint32_t gart_size; /* GART size. */
- uint32_t vram_size; /* VRAM size. */
- uint32_t num_cpus; /* Number of CPUs. */
+ RADEON_LAYOUT_UNKNOWN
+};
+
+enum radeon_bo_domain { /* bitfield */
+ RADEON_DOMAIN_GTT = 2,
+ RADEON_DOMAIN_VRAM = 4
+};
- unsigned drm_major;
- unsigned drm_minor;
- unsigned drm_patchlevel;
+struct winsys_handle;
+struct radeon_winsys_cs_handle; /* for write_reloc etc. */
- /* Hyper-Z user */
- boolean hyperz;
- /* AA compression (CMask) */
- boolean aacompress;
+struct radeon_winsys_cs {
+ unsigned cdw; /* Number of used dwords. */
+ uint32_t *buf; /* The command buffer. */
};
-static INLINE struct radeon_drm_winsys *
-radeon_drm_winsys(struct r300_winsys_screen *base)
-{
- return (struct radeon_drm_winsys*)base;
-}
+enum radeon_value_id {
+ RADEON_VID_PCI_ID,
+ RADEON_VID_R300_GB_PIPES,
+ RADEON_VID_R300_Z_PIPES,
+ RADEON_VID_GART_SIZE,
+ RADEON_VID_VRAM_SIZE,
+ RADEON_VID_DRM_MAJOR,
+ RADEON_VID_DRM_MINOR,
+ RADEON_VID_DRM_PATCHLEVEL,
+
+ /* These should probably go away: */
+
+ /* R300 features:
+ * - Hyper-Z
+ * - GB_Z_PEQ_CONFIG on rv350->r4xx
+ * - R500 FG_ALPHA_VALUE
+ *
+ * R600 features:
+ * - TBD
+ */
+ RADEON_VID_DRM_2_6_0,
+
+ /* R300 features:
+ * - R500 US_FORMAT regs
+ * - R500 ARGB2101010 colorbuffer
+ * - CMask and AA regs
+ * - R16F/RG16F
+ *
+ * R600 features:
+ * - TBD
+ */
+ RADEON_VID_DRM_2_8_0,
+
+ RADEON_VID_CAN_HYPERZ, /* ZMask + HiZ */
+ RADEON_VID_CAN_AACOMPRESS, /* CMask */
+};
+
+struct radeon_winsys {
+ /**
+ * Destroy this winsys.
+ *
+ * \param ws The winsys this function is called from.
+ */
+ void (*destroy)(struct radeon_winsys *ws);
+
+ /**
+ * Query a system value from a winsys.
+ *
+ * \param ws The winsys this function is called from.
+ * \param vid One of the RADEON_VID_* enums.
+ */
+ uint32_t (*get_value)(struct radeon_winsys *ws,
+ enum radeon_value_id vid);
+
+ /**************************************************************************
+ * Buffer management. Buffer attributes are mostly fixed over its lifetime.
+ *
+ * Remember that gallium gets to choose the interface it needs, and the
+ * window systems must then implement that interface (rather than the
+ * other way around...).
+ *************************************************************************/
+
+ /**
+ * Create a buffer object.
+ *
+ * \param ws The winsys this function is called from.
+ * \param size The size to allocate.
+ * \param alignment An alignment of the buffer in memory.
+ * \param bind A bitmask of the PIPE_BIND_* flags.
+ * \param usage A bitmask of the PIPE_USAGE_* flags.
+ * \param domain A bitmask of the RADEON_DOMAIN_* flags.
+ * \return The created buffer object.
+ */
+ struct pb_buffer *(*buffer_create)(struct radeon_winsys *ws,
+ unsigned size,
+ unsigned alignment,
+ unsigned bind,
+ unsigned usage,
+ enum radeon_bo_domain domain);
+
+ struct radeon_winsys_cs_handle *(*buffer_get_cs_handle)(
+ struct pb_buffer *buf);
+
+ /**
+ * Map the entire data store of a buffer object into the client's address
+ * space.
+ *
+ * \param buf A winsys buffer object to map.
+ * \param cs A command stream to flush if the buffer is referenced by it.
+ * \param usage A bitmask of the PIPE_TRANSFER_* flags.
+ * \return The pointer at the beginning of the buffer.
+ */
+ void *(*buffer_map)(struct pb_buffer *buf,
+ struct radeon_winsys_cs *cs,
+ enum pipe_transfer_usage usage);
+
+ /**
+ * Unmap a buffer object from the client's address space.
+ *
+ * \param buf A winsys buffer object to unmap.
+ */
+ void (*buffer_unmap)(struct pb_buffer *buf);
+
+ /**
+ * Return TRUE if a buffer object is being used by the GPU.
+ *
+ * \param buf A winsys buffer object.
+ */
+ boolean (*buffer_is_busy)(struct pb_buffer *buf);
+
+ /**
+ * Wait for a buffer object until it is not used by a GPU. This is
+ * equivalent to a fence placed after the last command using the buffer,
+ * and synchronizing to the fence.
+ *
+ * \param buf A winsys buffer object to wait for.
+ */
+ void (*buffer_wait)(struct pb_buffer *buf);
+
+ /**
+ * Return tiling flags describing a memory layout of a buffer object.
+ *
+ * \param buf A winsys buffer object to get the flags from.
+ * \param macrotile A pointer to the return value of the microtile flag.
+ * \param microtile A pointer to the return value of the macrotile flag.
+ *
+ * \note microtile and macrotile are not bitmasks!
+ */
+ void (*buffer_get_tiling)(struct pb_buffer *buf,
+ enum radeon_bo_layout *microtile,
+ enum radeon_bo_layout *macrotile);
+
+ /**
+ * Set tiling flags describing a memory layout of a buffer object.
+ *
+ * \param buf A winsys buffer object to set the flags for.
+ * \param cs A command stream to flush if the buffer is referenced by it.
+ * \param macrotile A macrotile flag.
+ * \param microtile A microtile flag.
+ * \param stride A stride of the buffer in bytes, for texturing.
+ *
+ * \note microtile and macrotile are not bitmasks!
+ */
+ void (*buffer_set_tiling)(struct pb_buffer *buf,
+ struct radeon_winsys_cs *cs,
+ enum radeon_bo_layout microtile,
+ enum radeon_bo_layout macrotile,
+ unsigned stride);
+
+ /**
+ * Get a winsys buffer from a winsys handle. The internal structure
+ * of the handle is platform-specific and only a winsys should access it.
+ *
+ * \param ws The winsys this function is called from.
+ * \param whandle A winsys handle pointer as was received from a state
+ * tracker.
+ * \param stride The returned buffer stride in bytes.
+ * \param size The returned buffer size.
+ */
+ struct pb_buffer *(*buffer_from_handle)(struct radeon_winsys *ws,
+ struct winsys_handle *whandle,
+ unsigned *stride,
+ unsigned *size);
+
+ /**
+ * Get a winsys handle from a winsys buffer. The internal structure
+ * of the handle is platform-specific and only a winsys should access it.
+ *
+ * \param buf A winsys buffer object to get the handle from.
+ * \param whandle A winsys handle pointer.
+ * \param stride A stride of the buffer in bytes, for texturing.
+ * \return TRUE on success.
+ */
+ boolean (*buffer_get_handle)(struct pb_buffer *buf,
+ unsigned stride,
+ struct winsys_handle *whandle);
+
+ /**************************************************************************
+ * Command submission.
+ *
+ * Each pipe context should create its own command stream and submit
+ * commands independently of other contexts.
+ *************************************************************************/
+
+ /**
+ * Create a command stream.
+ *
+ * \param ws The winsys this function is called from.
+ */
+ struct radeon_winsys_cs *(*cs_create)(struct radeon_winsys *ws);
+
+ /**
+ * Destroy a command stream.
+ *
+ * \param cs A command stream to destroy.
+ */
+ void (*cs_destroy)(struct radeon_winsys_cs *cs);
+
+ /**
+ * Add a new buffer relocation. Every relocation must first be added
+ * before it can be written.
+ *
+ * \param cs A command stream to add buffer for validation against.
+ * \param buf A winsys buffer to validate.
+ * \param rd A read domain containing a bitmask of the RADEON_DOMAIN_* flags.
+ * \param wd A write domain containing a bitmask of the RADEON_DOMAIN_* flags.
+ */
+ void (*cs_add_reloc)(struct radeon_winsys_cs *cs,
+ struct radeon_winsys_cs_handle *buf,
+ enum radeon_bo_domain rd,
+ enum radeon_bo_domain wd);
+
+ /**
+ * Return TRUE if there is enough memory in VRAM and GTT for the relocs
+ * added so far.
+ *
+ * \param cs A command stream to validate.
+ */
+ boolean (*cs_validate)(struct radeon_winsys_cs *cs);
+
+ /**
+ * Write a relocated dword to a command buffer.
+ *
+ * \param cs A command stream the relocation is written to.
+ * \param buf A winsys buffer to write the relocation for.
+ * \param rd A read domain containing a bitmask of the RADEON_DOMAIN_* flags.
+ * \param wd A write domain containing a bitmask of the RADEON_DOMAIN_* flags.
+ */
+ void (*cs_write_reloc)(struct radeon_winsys_cs *cs,
+ struct radeon_winsys_cs_handle *buf);
+
+ /**
+ * Flush a command stream.
+ *
+ * \param cs A command stream to flush.
+ * \param flags, RADEON_FLUSH_ASYNC or 0.
+ */
+ void (*cs_flush)(struct radeon_winsys_cs *cs, unsigned flags);
+
+ /**
+ * Set a flush callback which is called from winsys when flush is
+ * required.
+ *
+ * \param cs A command stream to set the callback for.
+ * \param flush A flush callback function associated with the command stream.
+ * \param user A user pointer that will be passed to the flush callback.
+ */
+ void (*cs_set_flush)(struct radeon_winsys_cs *cs,
+ void (*flush)(void *ctx, unsigned flags),
+ void *user);
+
+ /**
+ * Return TRUE if a buffer is referenced by a command stream.
+ *
+ * \param cs A command stream.
+ * \param buf A winsys buffer.
+ */
+ boolean (*cs_is_buffer_referenced)(struct radeon_winsys_cs *cs,
+ struct radeon_winsys_cs_handle *buf);
+};
#endif