r600g: first step into winsys/radeon
authorMarek Olšák <maraeo@gmail.com>
Fri, 22 Jul 2011 17:25:07 +0000 (19:25 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 16 Aug 2011 07:15:10 +0000 (09:15 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
22 files changed:
configure.ac
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_public.h
src/gallium/targets/dri-r600/Makefile
src/gallium/targets/dri-r600/target.c
src/gallium/targets/egl-static/Makefile
src/gallium/targets/egl-static/egl_pipe.c
src/gallium/targets/gbm/Makefile
src/gallium/targets/gbm/pipe_r600.c
src/gallium/targets/va-r600/Makefile
src/gallium/targets/va-r600/target.c
src/gallium/targets/vdpau-r600/Makefile
src/gallium/targets/vdpau-r600/target.c
src/gallium/targets/xvmc-r600/Makefile
src/gallium/targets/xvmc-r600/target.c
src/gallium/winsys/r600/drm/r600_drm.c
src/gallium/winsys/r600/drm/r600_drm_public.h
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
src/gallium/winsys/radeon/drm/radeon_winsys.h

index 6fa5e5177a4a5166e4af95f5011429dbc74fec95..ea58dae6593bdaa73626a5bb8ee35784fccaa1ff 100644 (file)
@@ -1855,7 +1855,7 @@ if test "x$with_gallium_drivers" != x; then
             ;;
         xr600)
             GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r600"
-            gallium_check_st "r600/drm" "dri-r600" "" "" "xvmc-r600" "vdpau-r600" "va-r600"
+            gallium_check_st "r600/drm radeon/drm" "dri-r600" "" "" "xvmc-r600" "vdpau-r600" "va-r600"
             ;;
         xnouveau)
             PKG_CHECK_MODULES([NOUVEAU], [libdrm_nouveau >= $LIBDRM_NOUVEAU_REQUIRED])
index 461f59439e88dd488f95d0d5bf01f526f429b067..6181e8b32021c7b9600effce22df279240b3ec89 100644 (file)
@@ -47,6 +47,7 @@
 #include "r600_resource.h"
 #include "r600_shader.h"
 #include "r600_pipe.h"
+#include "../../winsys/r600/drm/r600_drm_public.h"
 
 /*
  * pipe_context
@@ -563,9 +564,10 @@ static boolean r600_fence_finish(struct pipe_screen *pscreen,
        return TRUE;
 }
 
-struct pipe_screen *r600_screen_create(struct radeon *radeon)
+struct pipe_screen *r600_screen_create(struct radeon_winsys *rw)
 {
        struct r600_screen *rscreen;
+       struct radeon *radeon = r600_drm_winsys_create(rw);
 
        rscreen = CALLOC_STRUCT(r600_screen);
        if (rscreen == NULL) {
index 6f399ed43b0b29baf004033078793d3ee899401d..c53a191594bd8b6a331a364bedb5d228fe7e5415 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef R600_PIPE_H
 #define R600_PIPE_H
 
+#include "../../winsys/radeon/drm/radeon_winsys.h"
+
 #include <pipe/p_state.h>
 #include <pipe/p_screen.h>
 #include <pipe/p_context.h>
@@ -183,7 +185,7 @@ struct r600_pipe_context {
        struct r600_pipe_state          *states[R600_PIPE_NSTATES];
        struct r600_context             ctx;
        struct r600_vertex_element      *vertex_elements;
-       struct r600_pipe_resource_state         fs_resource[PIPE_MAX_ATTRIBS];
+       struct r600_pipe_resource_state fs_resource[PIPE_MAX_ATTRIBS];
        struct pipe_framebuffer_state   framebuffer;
        struct pipe_index_buffer        index_buffer;
        unsigned                        cb_target_mask;
index f1970201e894b9d4f473099b989c668bebd24df8..1c82a7af68fac99c6f51f12baa86cd077b870286 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef R600_PUBLIC_H
 #define R600_PUBLIC_H
 
-struct pipe_screen *r600_screen_create(struct radeon *radeon);
+struct radeon_winsys;
+
+struct pipe_screen *r600_screen_create(struct radeon_winsys *rw);
 
 #endif
index 0c4de203d357da44b526c0d1e8600ac72b852869..2d7463008fee351312f7971727e33896433d0823 100644 (file)
@@ -7,6 +7,7 @@ PIPE_DRIVERS = \
        $(TOP)/src/gallium/drivers/r600/libr600.a \
        $(TOP)/src/gallium/state_trackers/dri/drm/libdridrm.a \
        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/drivers/rbug/librbug.a \
        $(TOP)/src/gallium/drivers/noop/libnoop.a
index 8753e2bab1759bbc7990d45c60f571da16a00ea5..1b8b6816ec150fd43eeff64c4cc71db9c57a218a 100644 (file)
@@ -1,14 +1,14 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
-#include "r600/drm/r600_drm_public.h"
+#include "radeon/drm/radeon_drm_public.h"
 #include "r600/r600_public.h"
 
 static struct pipe_screen *create_screen(int fd)
 {
-   struct radeon *radeon;
+   struct radeon_winsys *radeon;
    struct pipe_screen *screen;
 
-   radeon = r600_drm_winsys_create(fd);
+   radeon = radeon_drm_winsys_create(fd);
    if (!radeon)
       return NULL;
 
index 42d34b8eda15e77c25b8b776697f164b8541835e..1583ab181ea9de25d3a7b4ca5663054c73fbbc03 100644 (file)
@@ -117,17 +117,20 @@ endif
 
 # r300
 ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
+ifneq ($(findstring r300,$(GALLIUM_DRIVERS_DIRS)),)
 egl_CPPFLAGS += -D_EGL_PIPE_R300=1
 egl_LIBS += \
        $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/r300/libr300.a
 endif
+endif
 
 # r600
 ifneq ($(findstring r600/drm,$(GALLIUM_WINSYS_DIRS)),)
 egl_CPPFLAGS += -D_EGL_PIPE_R600=1
 egl_LIBS += \
        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/r600/libr600.a
 endif
 
index 658c532b404c152f1da56cbff1d72ee5c73d87d8..f2b50bd0eab0d4d63bc6d79b7a43d801339847d0 100644 (file)
@@ -42,7 +42,6 @@
 #include "radeon/drm/radeon_drm_public.h"
 #include "r300/r300_public.h"
 /* for r600 */
-#include "r600/drm/r600_drm_public.h"
 #include "r600/r600_public.h"
 /* for vmwgfx */
 #include "svga/drm/svga_drm_public.h"
@@ -141,10 +140,10 @@ static struct pipe_screen *
 pipe_r600_create_screen(int fd)
 {
 #if _EGL_PIPE_R600
-   struct radeon *rw;
+   struct radeon_winsys *rw;
    struct pipe_screen *screen;
 
-   rw = r600_drm_winsys_create(fd);
+   rw = radeon_drm_winsys_create(fd);
    if (!rw)
       return NULL;
 
index faacc89f1a0076a4a7bc996314c9d2632ecf274d..033a1acaaf9b0593439c507e8467b7a3843e8770 100644 (file)
@@ -83,6 +83,7 @@ r300_LIBS = \
 # r600 pipe driver
 r600_LIBS = \
        $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/r600/libr600.a
 
 # vmwgfx pipe driver
@@ -90,13 +91,18 @@ vmwgfx_LIBS = \
        $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
        $(TOP)/src/gallium/drivers/svga/libsvga.a
 
+
+
 # LLVM
 ifeq ($(MESA_LLVM),1)
-pipe_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 pipe_SYS += $(LLVM_LIBS)
 pipe_LDFLAGS += $(LLVM_LDFLAGS)
 endif
 
+ifneq ($(findstring llvmpipe,$(GALLIUM_DRIVERS_DIRS)),)
+pipe_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
+endif
+
 # determine the targets/sources
 pipe_TARGETS =
 pipe_SOURCES =
@@ -117,9 +123,11 @@ pipe_SOURCES += pipe_nouveau.c
 endif
 
 ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
+ifneq ($(findstring r300,$(GALLIUM_DRIVERS_DIRS)),)
 pipe_TARGETS += $(PIPE_PREFIX)r300.so
 pipe_SOURCES += pipe_r300.c
 endif
+endif
 
 ifneq ($(findstring r600/drm,$(GALLIUM_WINSYS_DIRS)),)
 pipe_TARGETS += $(PIPE_PREFIX)r600.so
index 486a659258571d509a111684b22bfad8ded158fd..9f61a51404a8962534b54436cb1034884e7b1d68 100644 (file)
@@ -1,16 +1,15 @@
-
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
-#include "r600/drm/r600_drm_public.h"
+#include "radeon/drm/radeon_drm_public.h"
 #include "r600/r600_public.h"
 
 static struct pipe_screen *
 create_screen(int fd)
 {
-   struct radeon *rw;
+   struct radeon_winsys *rw;
    struct pipe_screen *screen;
 
-   rw = r600_drm_winsys_create(fd);
+   rw = radeon_drm_winsys_create(fd);
    if (!rw)
       return NULL;
 
index 28797ad528d59653799fb2b2c34d1a1a891bc1ee..d09a3aa8ad2f80bc4f7fbd9181e842e86a70b21e 100644 (file)
@@ -10,6 +10,7 @@ PIPE_DRIVERS = \
        $(TOP)/src/gallium/drivers/r600/libr600.a \
        $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
         $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
        $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
         $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/auxiliary/libgallium.a
index 8753e2bab1759bbc7990d45c60f571da16a00ea5..1b8b6816ec150fd43eeff64c4cc71db9c57a218a 100644 (file)
@@ -1,14 +1,14 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
-#include "r600/drm/r600_drm_public.h"
+#include "radeon/drm/radeon_drm_public.h"
 #include "r600/r600_public.h"
 
 static struct pipe_screen *create_screen(int fd)
 {
-   struct radeon *radeon;
+   struct radeon_winsys *radeon;
    struct pipe_screen *screen;
 
-   radeon = r600_drm_winsys_create(fd);
+   radeon = radeon_drm_winsys_create(fd);
    if (!radeon)
       return NULL;
 
index 0fd817b8e823ce134c6e7bda0be94783c1786ecd..c2d95af295af269407fbc0d508fca4fb074ce65e 100644 (file)
@@ -7,6 +7,7 @@ PIPE_DRIVERS = \
         $(TOP)/src/gallium/drivers/r600/libr600.a \
        $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
         $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
         $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/auxiliary/libgallium.a
 
index 8753e2bab1759bbc7990d45c60f571da16a00ea5..1b8b6816ec150fd43eeff64c4cc71db9c57a218a 100644 (file)
@@ -1,14 +1,14 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
-#include "r600/drm/r600_drm_public.h"
+#include "radeon/drm/radeon_drm_public.h"
 #include "r600/r600_public.h"
 
 static struct pipe_screen *create_screen(int fd)
 {
-   struct radeon *radeon;
+   struct radeon_winsys *radeon;
    struct pipe_screen *screen;
 
-   radeon = r600_drm_winsys_create(fd);
+   radeon = radeon_drm_winsys_create(fd);
    if (!radeon)
       return NULL;
 
index 0bb72f1eff920225f3e83941c4a17a7d52cc3d07..a10a42d18ed305765990edb392c2023bb026813a 100644 (file)
@@ -7,6 +7,7 @@ PIPE_DRIVERS = \
         $(TOP)/src/gallium/drivers/r600/libr600.a \
        $(TOP)/src/gallium/winsys/g3dvl/dri/libvldri.a \
         $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
+       $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
         $(TOP)/src/gallium/drivers/trace/libtrace.a \
        $(TOP)/src/gallium/auxiliary/libgallium.a
 
index 8753e2bab1759bbc7990d45c60f571da16a00ea5..1b8b6816ec150fd43eeff64c4cc71db9c57a218a 100644 (file)
@@ -1,14 +1,14 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
-#include "r600/drm/r600_drm_public.h"
+#include "radeon/drm/radeon_drm_public.h"
 #include "r600/r600_public.h"
 
 static struct pipe_screen *create_screen(int fd)
 {
-   struct radeon *radeon;
+   struct radeon_winsys *radeon;
    struct pipe_screen *screen;
 
-   radeon = r600_drm_winsys_create(fd);
+   radeon = radeon_drm_winsys_create(fd);
    if (!radeon)
       return NULL;
 
index 8aa8c3df52a93d191bb0f24acd6edb50144326e9..325547ab4ec35c1b67ad1928f8dd95fadc0b093f 100644 (file)
@@ -37,6 +37,7 @@
 #include "r600_drm_public.h"
 #include "xf86drm.h"
 #include "radeon_drm.h"
+#include "../../radeon/drm/radeon_winsys.h"
 
 #ifndef RADEON_INFO_TILING_CONFIG
 #define RADEON_INFO_TILING_CONFIG 0x6
@@ -98,20 +99,6 @@ unsigned r600_get_minor_version(struct radeon *radeon)
        return radeon->minor_version;
 }
 
-
-static int radeon_get_device(struct radeon *radeon)
-{
-       struct drm_radeon_info info = {};
-       int r;
-
-       radeon->device = 0;
-       info.request = RADEON_INFO_DEVICE_ID;
-       info.value = (uintptr_t)&radeon->device;
-       r = drmCommandWriteRead(radeon->fd, DRM_RADEON_INFO, &info,
-                       sizeof(struct drm_radeon_info));
-       return r;
-}
-
 static int r600_interpret_tiling(struct radeon *radeon, uint32_t tiling_config)
 {
        switch ((tiling_config & 0xe) >> 1) {
@@ -320,39 +307,22 @@ static int handle_compare(void *key1, void *key2)
     return PTR_TO_UINT(key1) != PTR_TO_UINT(key2);
 }
 
-static struct radeon *radeon_new(int fd, unsigned device)
+static struct radeon *radeon_new(struct radeon_winsys *rw)
 {
        struct radeon *radeon;
        int r;
-       drmVersionPtr version;
 
        radeon = calloc(1, sizeof(*radeon));
        if (radeon == NULL) {
                return NULL;
        }
-       radeon->fd = fd;
-       radeon->device = device;
-       radeon->refcount = 1;
-
-       version = drmGetVersion(radeon->fd);
-       if (version->version_major != 2) {
-               fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
-                       "only compatible with 2.x.x\n", __FUNCTION__,
-                       version->version_major, version->version_minor,
-                       version->version_patchlevel);
-               drmFreeVersion(version);
-               exit(1);
-       }
-
-       radeon->minor_version = version->version_minor;
-
-       drmFreeVersion(version);
 
-       r = radeon_get_device(radeon);
-       if (r) {
-               fprintf(stderr, "Failed to get device id\n");
-               return radeon_decref(radeon);
-       }
+       rw->query_info(rw, &radeon->info);
+       radeon->fd = radeon->info.fd;
+       radeon->device = radeon->info.pci_id;
+       radeon->num_backends = radeon->info.r600_num_backends;
+       radeon->refcount = 1;
+       radeon->minor_version = radeon->info.drm_minor;
 
        radeon->family = radeon_family_from_device(radeon->device);
        if (radeon->family == CHIP_UNKNOWN) {
@@ -436,9 +406,9 @@ static struct radeon *radeon_new(int fd, unsigned device)
        return radeon;
 }
 
-struct radeon *r600_drm_winsys_create(int drmfd)
+struct radeon *r600_drm_winsys_create(struct radeon_winsys *rw)
 {
-       return radeon_new(drmfd, 0);
+       return radeon_new(rw);
 }
 
 struct radeon *radeon_decref(struct radeon *radeon)
index cfce8df9c2cc4f3076a01c1abcc01b4386ecda21..1d990f91013fd0f9b1f2622cb13e2beed7cb9b54 100644 (file)
@@ -26,8 +26,8 @@
 #ifndef R600_DRM_PUBLIC_H
 #define R600_DRM_PUBLIC_H
 
-struct radeon;
+struct radeon_winsys;
 
-struct radeon *r600_drm_winsys_create(int drmFD);
+struct radeon *r600_drm_winsys_create(struct radeon_winsys *rw);
 
 #endif
index 75115fdaed7433613b50305ea4c5abd6aae24eaa..7630b30b5f083486a01b8e1e560a6e2820e6c86f 100644 (file)
@@ -35,6 +35,7 @@
 #include "util/u_hash_table.h"
 #include <os/os_thread.h>
 #include "r600.h"
+#include "../../radeon/drm/radeon_winsys.h"
 
 #define PKT_COUNT_C                     0xC000FFFF
 #define PKT_COUNT_S(x)                  (((x) & 0x3FFF) << 16)
@@ -43,6 +44,7 @@ struct r600_bomgr;
 struct r600_bo;
 
 struct radeon {
+       struct radeon_info              info;
        int                             fd;
        int                             refcount;
        unsigned                        device;
index 5983e86c5700735e76b5c71c30af078276b16985..faeb66c89081e32a8ba26fa6a129446323aeb510 100644 (file)
@@ -47,6 +47,9 @@
 #ifndef RADEON_INFO_WANT_CMASK
 #define RADEON_INFO_WANT_CMASK 8
 #endif
+#ifndef RADEON_INFO_NUM_BACKENDS
+#define RADEON_INFO_NUM_BACKENDS 10
+#endif
 
 /* Enable/disable feature access for one command stream.
  * If enable == TRUE, return TRUE on success.
@@ -175,6 +178,13 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
 #define CHIPSET(pci_id, name, family) case pci_id:
 #include "pci_ids/r300_pci_ids.h"
 #undef CHIPSET
+        ws->gen = R300;
+        break;
+
+#define CHIPSET(pci_id, name, family) case pci_id:
+#include "pci_ids/r600_pci_ids.h"
+#undef CHIPSET
+        ws->gen = R600;
         break;
 
     default:
@@ -196,15 +206,23 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
     ws->num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
     /* Generation-specific queries. */
-    if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_GB_PIPES,
-                              "GB pipe count",
-                              &ws->info.r300_num_gb_pipes))
-        return FALSE;
+    if (ws->gen == R300) {
+        if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_GB_PIPES,
+                                  "GB pipe count",
+                                  &ws->info.r300_num_gb_pipes))
+            return FALSE;
 
-    if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_Z_PIPES,
-                              "Z pipe count",
-                              &ws->info.r300_num_z_pipes))
-        return FALSE;
+        if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_Z_PIPES,
+                                  "Z pipe count",
+                                  &ws->info.r300_num_z_pipes))
+            return FALSE;
+    }
+    else if (ws->gen == R600) {
+        if (!radeon_get_drm_value(ws->fd, RADEON_INFO_NUM_BACKENDS,
+                                  "num backends",
+                                  &ws->info.r600_num_backends))
+            return FALSE;
+    }
 
     return TRUE;
 }
@@ -263,6 +281,7 @@ struct radeon_winsys *radeon_drm_winsys_create(int fd)
     }
 
     ws->fd = fd;
+    ws->info.fd = fd;
 
     if (!do_winsys_init(ws))
         goto fail;
index 347e1f1d11a0616fc58a71f3d8ee9a65fca1e74d..69216448496ee4ee6533279a946ffb9d40f9aac3 100644 (file)
 #include "radeon_winsys.h"
 #include "os/os_thread.h"
 
+enum radeon_generation {
+    R300,
+    R600
+};
+
 struct radeon_drm_winsys {
     struct radeon_winsys base;
 
     int fd; /* DRM file descriptor */
     int num_cs; /* The number of command streams created. */
 
+    enum radeon_generation gen;
     struct radeon_info info;
 
     struct pb_manager *kman;
index 6d52dc25022e2f03e39bb1b9cd6fece29358b7c9..2a49e615981294c85b43666ae091dcf804b22093 100644 (file)
@@ -73,6 +73,7 @@ struct radeon_info {
     uint32_t pci_id;
     uint32_t gart_size;
     uint32_t vram_size;
+    uint32_t fd; /* XXX transitional */
 
     uint32_t drm_major; /* version */
     uint32_t drm_minor;
@@ -80,6 +81,8 @@ struct radeon_info {
 
     uint32_t r300_num_gb_pipes;
     uint32_t r300_num_z_pipes;
+
+    uint32_t r600_num_backends;
 };
 
 enum radeon_feature_id {