diff options
author | Marek Olšák <[email protected]> | 2011-04-18 02:39:50 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-04-18 02:52:32 +0200 |
commit | d35aeff4bb0b03450b2c3c08bd7f84db5bf43283 (patch) | |
tree | 7572cae9f9022991404b3a9d74882858062fe095 /src | |
parent | f79717d27aaf471b9cd6eed0d74cbf37ec697361 (diff) |
r300g/winsys: rename r300->radeon and do a little cleanup
Renaming a few files, types, and functions.
Also make the winsys independent of r300g.
Diffstat (limited to 'src')
36 files changed, 586 insertions, 593 deletions
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 66d900ebb5f..c9401b99f1c 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -29,8 +29,7 @@ C_SOURCES = \ 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 diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index ede0a2317d8..62d90afdcb0 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -23,7 +23,6 @@ #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" @@ -206,7 +205,7 @@ static void r300_clear(struct pipe_context* pipe, (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. @@ -260,8 +259,8 @@ static void r300_clear(struct pipe_context* pipe, 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. */ diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 720d666d98c..15d1278c3bb 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -32,7 +32,6 @@ #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) @@ -167,8 +166,8 @@ static boolean r300_setup_atoms(struct r300_context* r300) 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. @@ -379,7 +378,7 @@ static void r300_init_states(struct pipe_context *pipe) 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; @@ -391,7 +390,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, { 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; @@ -514,19 +513,19 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, "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"); } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index c1f766f6180..8a0a54cf1e9 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -34,7 +34,7 @@ #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; @@ -291,12 +291,12 @@ struct r300_query { 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; @@ -307,10 +307,10 @@ struct r300_surface { 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. */ @@ -340,8 +340,8 @@ struct r300_texture_desc { /* 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]; @@ -397,9 +397,9 @@ struct r300_resource 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. */ @@ -460,9 +460,9 @@ struct r300_context { 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; diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h index 2e52dfa43c6..c208e672f42 100644 --- a/src/gallium/drivers/r300/r300_cs.h +++ b/src/gallium/drivers/r300/r300_cs.h @@ -29,7 +29,6 @@ #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 @@ -40,14 +39,14 @@ */ #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) diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h index 2d111f9158d..30e9befad21 100644 --- a/src/gallium/drivers/r300/r300_defines.h +++ b/src/gallium/drivers/r300/r300_defines.h @@ -32,19 +32,4 @@ #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 diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a21668a6fc5..62435c5e2e2 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -375,7 +375,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) 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); @@ -1231,7 +1231,7 @@ validate: if (flushed) return FALSE; - r300_flush(&r300->context, R300_FLUSH_ASYNC, NULL); + r300_flush(&r300->context, RADEON_FLUSH_ASYNC, NULL); flushed = TRUE; goto validate; } diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index b3d0d344ec4..de7d77d608b 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -38,7 +38,7 @@ void r300_flush(struct pipe_context *pipe, { 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); @@ -48,11 +48,11 @@ void r300_flush(struct pipe_context *pipe, *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) { diff --git a/src/gallium/drivers/r300/r300_hyperz.c b/src/gallium/drivers/r300/r300_hyperz.c index ecaadf4af8e..ef330f34c9e 100644 --- a/src/gallium/drivers/r300/r300_hyperz.c +++ b/src/gallium/drivers/r300/r300_hyperz.c @@ -24,7 +24,6 @@ #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" @@ -153,7 +152,7 @@ static void r300_update_hyperz(struct r300_context* r300) } if (!zstex || - !r300->rws->get_value(r300->rws, R300_CAN_HYPERZ)) + !r300->rws->get_value(r300->rws, RADEON_VID_CAN_HYPERZ)) return; /* Zbuffer compression. */ diff --git a/src/gallium/drivers/r300/r300_public.h b/src/gallium/drivers/r300/r300_public.h index 8e7a963c55d..b6059203ff1 100644 --- a/src/gallium/drivers/r300/r300_public.h +++ b/src/gallium/drivers/r300/r300_public.h @@ -2,8 +2,8 @@ #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 diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 717485f43cb..9752a519491 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -26,7 +26,6 @@ #include "r300_context.h" #include "r300_screen.h" #include "r300_emit.h" -#include "r300_winsys.h" #include <stdio.h> @@ -46,7 +45,7 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe, 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) @@ -70,7 +69,7 @@ static void r300_destroy_query(struct pipe_context* pipe, { 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); } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 26594dabe42..429b85545f7 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -218,8 +218,8 @@ static boolean r300_reserve_cs_dwords(struct r300_context *r300, 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; } @@ -343,7 +343,7 @@ static boolean immd_is_good_idea(struct r300_context *r300, 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; } @@ -1080,7 +1080,7 @@ static void r300_render_draw_elements(struct vbuf_render* render, 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); diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 642523d4d9b..a5d737c4b3c 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -30,7 +30,6 @@ #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" @@ -311,9 +310,9 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, 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 || @@ -412,7 +411,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, 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); @@ -427,15 +426,15 @@ static void r300_fence_reference(struct pipe_screen *screen, 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); } @@ -444,8 +443,8 @@ static boolean r300_fence_finish(struct pipe_screen *screen, 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(); @@ -467,7 +466,7 @@ static boolean r300_fence_finish(struct pipe_screen *screen, 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); @@ -476,9 +475,9 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws) 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); @@ -488,7 +487,7 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws) 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); diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 576f9c1f4a9..bca86edb1d7 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -32,13 +32,13 @@ #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; @@ -61,8 +61,8 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) { 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; } diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index 986ae384fbf..4154c81512e 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -31,7 +31,6 @@ #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, @@ -62,7 +61,7 @@ static void r300_buffer_destroy(struct pipe_screen *screen, 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); } @@ -105,7 +104,7 @@ r300_buffer_transfer_map( struct pipe_context *pipe, { 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; @@ -126,7 +125,7 @@ static void r300_buffer_transfer_unmap( struct pipe_context *pipe, 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) { @@ -144,7 +143,7 @@ static void r300_buffer_transfer_inline_write(struct pipe_context *pipe, 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; @@ -188,7 +187,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen, 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; @@ -237,7 +236,7 @@ struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen, 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; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h index cdbc4425fcb..360ec509cc5 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.h +++ b/src/gallium/drivers/r300/r300_screen_buffer.h @@ -32,7 +32,6 @@ #include "util/u_transfer.h" #include "r300_screen.h" -#include "r300_winsys.h" #include "r300_context.h" /* Functions. */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index c92f871829a..24b41d5085d 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -45,7 +45,6 @@ #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. */ @@ -769,7 +768,7 @@ void r300_mark_fb_state_dirty(struct r300_context *r300, 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); diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 87e32a21fc1..38ca9a24e45 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -29,7 +29,6 @@ #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" @@ -874,7 +873,7 @@ static void r300_texture_destroy(struct pipe_screen *screen, { struct r300_resource* tex = (struct r300_resource*)texture; - r300_winsys_bo_reference(&tex->buf, NULL); + pb_reference(&tex->buf, NULL); FREE(tex); } @@ -882,7 +881,7 @@ boolean r300_resource_get_handle(struct pipe_screen* screen, 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) { @@ -909,17 +908,17 @@ static const struct u_resource_vtbl r300_texture_vtbl = 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; } @@ -933,13 +932,13 @@ r300_texture_create_object(struct r300_screen *rscreen, 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; } @@ -972,15 +971,16 @@ struct pipe_resource *r300_texture_create(struct pipe_screen *screen, 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*) @@ -992,10 +992,10 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen, 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 */ @@ -1014,14 +1014,14 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen, /* 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; } } @@ -1062,8 +1062,8 @@ struct pipe_surface* r300_create_surface(struct pipe_context * ctx, /* 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); diff --git a/src/gallium/drivers/r300/r300_texture_desc.c b/src/gallium/drivers/r300/r300_texture_desc.c index 2910666dd51..da5778be65e 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.c +++ b/src/gallium/drivers/r300/r300_texture_desc.c @@ -22,9 +22,7 @@ * 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" @@ -32,8 +30,8 @@ * 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] = @@ -62,8 +60,8 @@ unsigned r300_get_pixel_alignment(enum pipe_format format, 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); @@ -98,7 +96,7 @@ static boolean r300_texture_macro_switch(struct r300_resource *tex, 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 { @@ -233,10 +231,10 @@ static void r300_setup_miptree(struct r300_screen *screen, 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); @@ -424,8 +422,8 @@ static void r300_setup_tiling(struct r300_screen *screen, 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; @@ -441,11 +439,11 @@ static void r300_setup_tiling(struct r300_screen *screen, 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; } @@ -456,7 +454,7 @@ static void r300_setup_tiling(struct r300_screen *screen, /* 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; } } @@ -501,7 +499,7 @@ boolean r300_texture_desc_init(struct r300_screen *rscreen, } /* Setup tiling. */ - if (tex->tex.microtile == R300_BUFFER_SELECT_LAYOUT) { + if (tex->tex.microtile == RADEON_LAYOUT_UNKNOWN) { r300_setup_tiling(rscreen, tex); } diff --git a/src/gallium/drivers/r300/r300_texture_desc.h b/src/gallium/drivers/r300/r300_texture_desc.h index ce6e9643ec6..a84d6fae0ea 100644 --- a/src/gallium/drivers/r300/r300_texture_desc.h +++ b/src/gallium/drivers/r300/r300_texture_desc.h @@ -25,7 +25,7 @@ #define R300_TEXTURE_DESC_H #include "pipe/p_format.h" -#include "r300_defines.h" +#include "r300_context.h" struct pipe_resource; struct r300_screen; @@ -39,8 +39,8 @@ enum r300_dim { 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, diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index 65c5095be6a..e2ea4cbf6c5 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -226,7 +226,7 @@ void* r300_texture_transfer_map(struct pipe_context *ctx, 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; @@ -256,7 +256,7 @@ void* r300_texture_transfer_map(struct pipe_context *ctx, 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); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h deleted file mode 100644 index 3a6798a5423..00000000000 --- a/src/gallium/drivers/r300/r300_winsys.h +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson <[email protected]> - * Copyright 2010 Marek Olšák <[email protected]> - * - * 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 */ diff --git a/src/gallium/targets/dri-r300/target.c b/src/gallium/targets/dri-r300/target.c index 2ecf3457a76..b48bcad3710 100644 --- a/src/gallium/targets/dri-r300/target.c +++ b/src/gallium/targets/dri-r300/target.c @@ -7,10 +7,10 @@ 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; diff --git a/src/gallium/targets/egl-static/egl_pipe.c b/src/gallium/targets/egl-static/egl_pipe.c index a33d419e0aa..658c532b404 100644 --- a/src/gallium/targets/egl-static/egl_pipe.c +++ b/src/gallium/targets/egl-static/egl_pipe.c @@ -118,10 +118,10 @@ static struct pipe_screen * 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; diff --git a/src/gallium/targets/egl/pipe_r300.c b/src/gallium/targets/egl/pipe_r300.c index d84bb92539a..09940f0a194 100644 --- a/src/gallium/targets/egl/pipe_r300.c +++ b/src/gallium/targets/egl/pipe_r300.c @@ -7,10 +7,10 @@ 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; diff --git a/src/gallium/targets/xorg-radeon/radeon_target.c b/src/gallium/targets/xorg-radeon/radeon_target.c index 5a0a8dc5738..b8410efbd89 100644 --- a/src/gallium/targets/xorg-radeon/radeon_target.c +++ b/src/gallium/targets/xorg-radeon/radeon_target.c @@ -7,10 +7,10 @@ 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; diff --git a/src/gallium/winsys/radeon/drm/Makefile b/src/gallium/winsys/radeon/drm/Makefile index e63ae6f5006..d44b7c14250 100644 --- a/src/gallium/winsys/radeon/drm/Makefile +++ b/src/gallium/winsys/radeon/drm/Makefile @@ -7,10 +7,9 @@ LIBNAME = radeonwinsys 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 diff --git a/src/gallium/winsys/radeon/drm/SConscript b/src/gallium/winsys/radeon/drm/SConscript index b16e03556d3..39a8c711b84 100644 --- a/src/gallium/winsys/radeon/drm/SConscript +++ b/src/gallium/winsys/radeon/drm/SConscript @@ -5,17 +5,15 @@ env = env.Clone() 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, diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index 2b8ebf975e4..b6f12727e81 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -87,7 +87,7 @@ static struct radeon_bo *get_radeon_bo(struct pb_buffer *_buf) 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 = {}; @@ -103,7 +103,7 @@ static void radeon_bo_wait(struct r300_winsys_bo *_buf) 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 = {}; @@ -173,11 +173,11 @@ static void *radeon_bo_map_internal(struct pb_buffer *_buf, /* 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 { @@ -191,12 +191,12 @@ static void *radeon_bo_map_internal(struct pb_buffer *_buf, * 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 { @@ -209,7 +209,7 @@ static void *radeon_bo_map_internal(struct pb_buffer *_buf, radeon_drm_cs_sync_flush(cs); } - radeon_bo_wait((struct r300_winsys_bo*)bo); + radeon_bo_wait((struct pb_buffer*)bo); } } } @@ -345,7 +345,7 @@ static boolean radeon_bomgr_is_buffer_busy(struct pb_manager *_mgr, return TRUE; } - if (radeon_bo_is_busy((struct r300_winsys_bo*)bo)) { + if (radeon_bo_is_busy((struct pb_buffer*)bo)) { return TRUE; } @@ -391,8 +391,8 @@ struct pb_manager *radeon_bomgr_create(struct radeon_drm_winsys *rws) 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); @@ -400,9 +400,9 @@ static void *radeon_bo_map(struct r300_winsys_bo *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 = {}; @@ -414,19 +414,19 @@ static void radeon_bo_get_tiling(struct r300_winsys_bo *_buf, &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)); @@ -443,12 +443,12 @@ static void radeon_bo_set_tiling(struct r300_winsys_bo *_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; @@ -460,35 +460,35 @@ static void radeon_bo_set_tiling(struct r300_winsys_bo *_buf, 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; @@ -509,10 +509,10 @@ radeon_winsys_bo_create(struct r300_winsys_screen *rws, 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) @@ -575,14 +575,14 @@ done: 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) { diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h index b20a0996c93..b94881bc4ce 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h @@ -29,10 +29,10 @@ * Jérôme Glisse <[email protected]> * Marek Olšák <[email protected]> */ -#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" @@ -81,7 +81,7 @@ void radeon_bo_reference(struct radeon_bo **dst, struct radeon_bo *src) } static INLINE struct pb_buffer * -pb_buffer(struct r300_winsys_bo *buffer) +pb_buffer(struct pb_buffer *buffer) { return (struct pb_buffer *)buffer; } diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index f23533622df..0139de1973a 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -36,7 +36,7 @@ /* 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). @@ -129,7 +129,7 @@ static void radeon_destroy_cs_context(struct radeon_cs_context *csc) 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; @@ -163,9 +163,9 @@ static struct r300_winsys_cs *radeon_drm_cs_create(struct r300_winsys_screen *rw #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); @@ -220,9 +220,9 @@ int radeon_get_reloc(struct radeon_cs_context *csc, struct radeon_bo *bo) 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; @@ -284,27 +284,27 @@ static void radeon_add_reloc(struct radeon_cs_context *csc, *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); @@ -312,8 +312,8 @@ static boolean radeon_drm_cs_validate(struct r300_winsys_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; @@ -365,7 +365,7 @@ void radeon_drm_cs_sync_flush(struct radeon_drm_cs *cs) 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; @@ -389,7 +389,7 @@ static void radeon_drm_cs_flush(struct r300_winsys_cs *rcs, unsigned flags) } 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 { @@ -409,7 +409,7 @@ static void radeon_drm_cs_flush(struct r300_winsys_cs *rcs, unsigned flags) 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); @@ -421,7 +421,7 @@ static void radeon_drm_cs_destroy(struct r300_winsys_cs *rcs) 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) { @@ -430,8 +430,8 @@ static void radeon_drm_cs_set_flush(struct r300_winsys_cs *rcs, 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; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h index dc2050a27eb..339beedc6ab 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h @@ -31,7 +31,7 @@ #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; @@ -54,7 +54,7 @@ struct radeon_cs_context { }; 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 @@ -79,7 +79,7 @@ struct radeon_drm_cs { 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; } diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_public.h b/src/gallium/winsys/radeon/drm/radeon_drm_public.h index 3a208cdd4c4..76d9dda422d 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_public.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_public.h @@ -3,9 +3,9 @@ #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) { diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_common.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 72c2ff11125..37f6d18689d 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_common.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -31,7 +31,6 @@ * Marek Olšák <[email protected]> */ -#include "radeon_winsys.h" #include "radeon_drm_bo.h" #include "radeon_drm_cs.h" #include "radeon_drm_public.h" @@ -164,7 +163,7 @@ static void do_ioctls(struct radeon_drm_winsys *winsys) winsys->num_cpus = sysconf(_SC_NPROCESSORS_ONLN); } -static void radeon_winsys_destroy(struct r300_winsys_screen *rws) +static void radeon_winsys_destroy(struct radeon_winsys *rws) { struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws; @@ -173,41 +172,41 @@ static void radeon_winsys_destroy(struct r300_winsys_screen *rws) FREE(rws); } -static uint32_t radeon_get_value(struct r300_winsys_screen *rws, - enum r300_value_id id) +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 R300_VID_PCI_ID: + case RADEON_VID_PCI_ID: return ws->pci_id; - case R300_VID_GB_PIPES: + case RADEON_VID_R300_GB_PIPES: return ws->gb_pipes; - case R300_VID_Z_PIPES: + case RADEON_VID_R300_Z_PIPES: return ws->z_pipes; - case R300_VID_GART_SIZE: + case RADEON_VID_GART_SIZE: return ws->gart_size; - case R300_VID_VRAM_SIZE: + case RADEON_VID_VRAM_SIZE: return ws->vram_size; - case R300_VID_DRM_MAJOR: + case RADEON_VID_DRM_MAJOR: return ws->drm_major; - case R300_VID_DRM_MINOR: + case RADEON_VID_DRM_MINOR: return ws->drm_minor; - case R300_VID_DRM_PATCHLEVEL: + case RADEON_VID_DRM_PATCHLEVEL: return ws->drm_patchlevel; - case R300_VID_DRM_2_6_0: + case RADEON_VID_DRM_2_6_0: return ws->drm_major*100 + ws->drm_minor >= 206; - case R300_VID_DRM_2_8_0: + case RADEON_VID_DRM_2_8_0: return ws->drm_major*100 + ws->drm_minor >= 208; - case R300_CAN_HYPERZ: + case RADEON_VID_CAN_HYPERZ: return ws->hyperz; - case R300_CAN_AACOMPRESS: + case RADEON_VID_CAN_AACOMPRESS: return ws->aacompress; } return 0; } -struct r300_winsys_screen *r300_drm_winsys_screen_create(int fd) +struct radeon_winsys *radeon_drm_winsys_create(int fd) { struct radeon_drm_winsys *ws = CALLOC_STRUCT(radeon_drm_winsys); if (!ws) { diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h new file mode 100644 index 00000000000..e1b9493fc10 --- /dev/null +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h @@ -0,0 +1,67 @@ +/* + * 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 <[email protected]> + */ +#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 diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h index 9ecbb074572..ca0e6624138 100644 --- a/src/gallium/winsys/radeon/drm/radeon_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h @@ -1,67 +1,319 @@ /* - * Copyright © 2009 Corbin Simpson - * All Rights Reserved. + * Copyright 2008 Corbin Simpson <[email protected]> + * Copyright 2010 Marek Olšák <[email protected]> * - * 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 <[email protected]> - */ + * 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 |