r600g: move chip class to radeon common structure
authorJerome Glisse <jglisse@redhat.com>
Mon, 20 Sep 2010 15:58:00 +0000 (11:58 -0400)
committerJerome Glisse <jglisse@redhat.com>
Mon, 20 Sep 2010 15:59:20 +0000 (11:59 -0400)
So texture code can be shared btw new state design
& old one.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
14 files changed:
src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_blit.c
src/gallium/drivers/r600/r600_context.c
src/gallium/drivers/r600/r600_hw_states.c
src/gallium/drivers/r600/r600_screen.c
src/gallium/drivers/r600/r600_screen.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state2.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/r600/radeon.h
src/gallium/winsys/r600/drm/r600.c
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/r600/drm/radeon.c
src/gallium/winsys/r600/drm/radeon_priv.h

index 7cbacea89a1321a7b6705e8ffbad18acc2055509..a123eb62e0f0f7bc9aa85469b5a1573a0966787e 100644 (file)
@@ -90,7 +90,14 @@ enum radeon_family {
        CHIP_LAST,
 };
 
+enum chip_class {
+       R600,
+       R700,
+       EVERGREEN,
+};
+
 enum radeon_family r600_get_family(struct radeon *rw);
+enum chip_class r600_get_family_class(struct radeon *radeon);
 
 /* lowlevel WS bo */
 struct radeon_ws_bo;
index 54fbc50bbc4fe0e680f870d410f82c5d98a50e4a..0506e8280af55341619a0645ad86fbfbc13d9a99 100644 (file)
@@ -283,7 +283,7 @@ static void r600_blit_state_vs_shader(struct r600_screen *rscreen, struct radeon
                radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
                return;
        }
-       switch (rscreen->chip_class) {
+       switch (radeon_get_family_class(rscreen->rw)) {
        case R600:
                memcpy(data, shader_bc_r600, 128);
                break;
@@ -347,7 +347,7 @@ static void r600_blit_state_ps_shader(struct r600_screen *rscreen, struct radeon
                radeon_ws_bo_reference(rscreen->rw, &bo, NULL);
                return;
        }
-       switch (rscreen->chip_class) {
+       switch (radeon_get_family_class(rscreen->rw)) {
        case R600:
                memcpy(data, shader_bc_r600, 48);
                break;
index 97b21d5e31d3dc42bda32465708bee44707f6c5f..72aab91d04e3da00c53954f9af182efe2fdaadc8 100644 (file)
@@ -113,7 +113,7 @@ struct pipe_context *r600_create_context(struct pipe_screen *screen, void *priv)
        rctx->screen = rscreen;
        rctx->rw = rscreen->rw;
 
-       if (rscreen->chip_class == EVERGREEN)
+       if (radeon_get_family_class(rscreen->rw) == EVERGREEN)
                rctx->vtbl = &eg_hw_state_vtbl;
        else
                rctx->vtbl = &r600_hw_state_vtbl;
index a4cd1bf1a1d6cc3b55eddc6de1375a06df3b9963..271bd1ac506292f4e39877d887a65538262b3021 100644 (file)
@@ -457,7 +457,7 @@ static void r600_dsa(struct r600_context *rctx, struct radeon_state *rstate)
 
        if (query_running) {
                db_render_override |= S_028D10_NOOP_CULL_DISABLE(1);
-               if (rscreen->chip_class == R700)
+               if (radeon_get_family_class(rscreen->rw) == R700)
                        db_render_control |= S_028D0C_R700_PERFECT_ZPASS_COUNTS(1);
        }
 
@@ -656,7 +656,7 @@ static void r600_cb_cntl(struct r600_context *rctx, struct radeon_state *rstate)
        rstate->states[R600_CB_CNTL__CB_SHADER_MASK] = shader_mask;
        rstate->states[R600_CB_CNTL__CB_TARGET_MASK] = target_mask;
        rstate->states[R600_CB_CNTL__CB_COLOR_CONTROL] = color_control;
-       if (rscreen->chip_class == R700)
+       if (radeon_get_family_class(rscreen->rw) == R700)
                rstate->states[R600_CB_CNTL__CB_SHADER_CONTROL] = shader_control;
        rstate->states[R600_CB_CNTL__PA_SC_AA_CONFIG] = 0x00000000;
        rstate->states[R600_CB_CNTL__PA_SC_AA_SAMPLE_LOCS_MCTX] = 0x00000000;
index 1711fabfc7a29a215ffbde3631fa88815f6d8464..d280a45bab73ba50e713c58f3eaf460991bc9200 100644 (file)
@@ -242,39 +242,13 @@ struct pipe_screen *r600_screen_create(struct radeon *rw)
        if (rscreen == NULL) {
                return NULL;
        }
-       
+
        /* don't enable mem constant for r600 yet */
        rscreen->use_mem_constant = FALSE;
-
-       switch (family) {
-       case CHIP_R600:
-       case CHIP_RV610:
-       case CHIP_RV630:
-       case CHIP_RV670:
-       case CHIP_RV620:
-       case CHIP_RV635:
-       case CHIP_RS780:
-       case CHIP_RS880:
-               rscreen->chip_class = R600;
-               break;
-       case CHIP_RV770:
-       case CHIP_RV730:
-       case CHIP_RV710:
-       case CHIP_RV740:
-               rscreen->chip_class = R700;
-               break;
-       case CHIP_CEDAR:
-       case CHIP_REDWOOD:
-       case CHIP_JUNIPER:
-       case CHIP_CYPRESS:
-       case CHIP_HEMLOCK:
-               rscreen->chip_class = EVERGREEN;
+       if (radeon_get_family_class(rw) == EVERGREEN) {
                rscreen->use_mem_constant = TRUE;
-               break;
-       default:
-               FREE(rscreen);
-               return NULL;
        }
+
        radeon_set_mem_constant(rw, rscreen->use_mem_constant);
        rscreen->rw = rw;
        rscreen->screen.winsys = (struct pipe_winsys*)rw;
index 4be77865fbd6cf973a7190e5c5e929b77db8c190..502444f03ac9c162582a3feb25a8ed5cb5b713b8 100644 (file)
@@ -42,17 +42,10 @@ struct r600_transfer {
        struct pipe_resource            *linear_texture;
 };
 
-enum chip_class {
-       R600,
-       R700,
-       EVERGREEN,
-};
-
 struct r600_screen {
        struct pipe_screen              screen;
        struct radeon                   *rw;
-       enum chip_class                 chip_class;
-       boolean use_mem_constant;
+       boolean                         use_mem_constant;
 };
 
 static INLINE struct r600_screen *r600_screen(struct pipe_screen *screen)
index 2b97c2a94e32e3888022d6edb5d5ed50867b5b60..424f7a8913f805ef02c00285254fd15fe4b11deb 100644 (file)
@@ -527,7 +527,7 @@ void r600_init_state_functions(struct r600_context *rctx)
        rctx->context.set_blend_color = r600_set_blend_color;
        rctx->context.set_clip_state = r600_set_clip_state;
 
-       if (rctx->screen->chip_class == EVERGREEN)
+       if (radeon_get_family_class(rctx->rw) == EVERGREEN)
                rctx->context.set_constant_buffer = eg_set_constant_buffer;
        else if (rctx->screen->use_mem_constant)
                rctx->context.set_constant_buffer = r600_set_constant_buffer_mem;
index a190204ef47fec1959a67a3e772b88dd68acd807..ffb18ab7fb309aa6c01b16d89df060e1bc865914 100644 (file)
@@ -56,12 +56,6 @@ uint32_t r600_translate_texformat(enum pipe_format format,
 
 #include "r600_state_inlines.h"
 
-enum chip_class {
-       R600,
-       R700,
-       EVERGREEN,
-};
-
 enum r600_pipe_state_id {
        R600_PIPE_STATE_BLEND = 0,
        R600_PIPE_STATE_BLEND_COLOR,
@@ -85,7 +79,6 @@ enum r600_pipe_state_id {
 struct r600_screen {
        struct pipe_screen              screen;
        struct radeon                   *radeon;
-       unsigned                        chip_class;
 };
 
 struct r600_pipe_sampler_view {
@@ -2189,27 +2182,6 @@ struct pipe_screen *r600_screen_create2(struct radeon *radeon)
                return NULL;
        }
 
-       switch (family) {
-       case CHIP_R600:
-       case CHIP_RV610:
-       case CHIP_RV630:
-       case CHIP_RV670:
-       case CHIP_RV620:
-       case CHIP_RV635:
-       case CHIP_RS780:
-       case CHIP_RS880:
-               rscreen->chip_class = R600;
-               break;
-       case CHIP_RV770:
-       case CHIP_RV730:
-       case CHIP_RV710:
-       case CHIP_RV740:
-               rscreen->chip_class = R700;
-               break;
-       default:
-               FREE(rscreen);
-               return NULL;
-       }
        rscreen->radeon = radeon;
        rscreen->screen.winsys = (struct pipe_winsys*)radeon;
        rscreen->screen.destroy = r600_destroy_screen;
index 0d24f6ab0d1c8f6924b08ab5515cf2c346131969..66332580908a526a369e07f9be31929580b857a5 100644 (file)
@@ -107,7 +107,6 @@ static void r600_setup_miptree(struct r600_resource_texture *rtex, enum chip_cla
 struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
                                                const struct pipe_resource *templ)
 {
-       struct r600_screen *rscreen = r600_screen(screen);
        struct r600_resource_texture *rtex;
        struct r600_resource *resource;
        struct radeon *radeon = (struct radeon *)screen->winsys;
@@ -121,7 +120,7 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
        resource->base.vtbl = &r600_texture_vtbl;
        pipe_reference_init(&resource->base.b.reference, 1);
        resource->base.b.screen = screen;
-       r600_setup_miptree(rtex, rscreen->chip_class);
+       r600_setup_miptree(rtex, radeon_get_family_class(radeon));
 
        /* FIXME alignment 4096 enought ? too much ? */
        resource->domain = r600_domain_from_usage(resource->base.b.bind);
@@ -320,7 +319,6 @@ void r600_texture_transfer_destroy(struct pipe_context *ctx,
 void* r600_texture_transfer_map(struct pipe_context *ctx,
                                struct pipe_transfer* transfer)
 {
-       struct r600_screen *rscreen = r600_screen(ctx->screen);
        struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
        struct radeon_ws_bo *bo;
        enum pipe_format format = transfer->resource->format;
@@ -334,7 +332,7 @@ void* r600_texture_transfer_map(struct pipe_context *ctx,
                bo = ((struct r600_resource *)rtransfer->linear_texture)->bo;
        } else {
                rtex = (struct r600_resource_texture*)transfer->resource;
-               if (rtex->depth && rscreen->chip_class != EVERGREEN) {
+               if (rtex->depth && radeon_get_family_class(radeon) != EVERGREEN) {
                        r = r600_texture_from_depth(ctx, rtex, transfer->sr.level);
                        if (r) {
                                return NULL;
index 06b5cec5a6e980155ab5da8396342e79765097fe..e52dcb4a341969eae5de27d9309cc9e6f69aabf2 100644 (file)
@@ -79,6 +79,12 @@ enum radeon_family {
        CHIP_LAST,
 };
 
+enum chip_class {
+       R600,
+       R700,
+       EVERGREEN,
+};
+
 enum {
        R600_SHADER_PS = 1,
        R600_SHADER_VS,
@@ -88,6 +94,7 @@ enum {
 };
 
 enum radeon_family radeon_get_family(struct radeon *rw);
+enum chip_class radeon_get_family_class(struct radeon *radeon);
 void radeon_set_mem_constant(struct radeon *radeon, boolean state);
 
 /* lowlevel WS bo */
index af9b9187ab18d55de1828ea628d2494791950ae6..fdcadffc532320611434f0796f88269e3fadde2f 100644 (file)
@@ -32,6 +32,11 @@ enum radeon_family r600_get_family(struct radeon *r600)
        return r600->family;
 }
 
+enum chip_class r600_get_family_class(struct radeon *radeon)
+{
+       return radeon->chip_class;
+}
+
 static int r600_get_device(struct radeon *r600)
 {
        struct drm_radeon_info info;
@@ -117,6 +122,37 @@ struct radeon *r600_new(int fd, unsigned device)
                R600_ERR("unknown or unsupported chipset 0x%04X\n", r600->device);
                break;
        }
+
+       /* setup class */
+       switch (r600->family) {
+       case CHIP_R600:
+       case CHIP_RV610:
+       case CHIP_RV630:
+       case CHIP_RV670:
+       case CHIP_RV620:
+       case CHIP_RV635:
+       case CHIP_RS780:
+       case CHIP_RS880:
+               r600->chip_class = R600;
+               break;
+       case CHIP_RV770:
+       case CHIP_RV730:
+       case CHIP_RV710:
+       case CHIP_RV740:
+               r600->chip_class = R700;
+               break;
+       case CHIP_CEDAR:
+       case CHIP_REDWOOD:
+       case CHIP_JUNIPER:
+       case CHIP_CYPRESS:
+       case CHIP_HEMLOCK:
+               r600->chip_class = EVERGREEN;
+               break;
+       default:
+               R600_ERR("unknown or unsupported chipset 0x%04X\n", r600->device);
+               break;
+       }
+
        return r600;
 }
 
index 7a9025ad3c23801b8ef278af61fdd11c427b520b..d02562f17f3ce4eea531051f3bcba3b65ae0c7f0 100644 (file)
@@ -38,6 +38,7 @@ struct radeon {
        int                             refcount;
        unsigned                        device;
        unsigned                        family;
+       enum chip_class                 chip_class;
 };
 
 struct radeon *r600_new(int fd, unsigned device);
index f39d020559c2705c2cdc078fd55cfc0a69609016..c3d345fef929291bad19e84a90df8b0330c09afb 100644 (file)
@@ -30,6 +30,11 @@ enum radeon_family radeon_get_family(struct radeon *radeon)
        return radeon->family;
 }
 
+enum chip_class radeon_get_family_class(struct radeon *radeon)
+{
+       return radeon->chip_class;
+}
+
 void radeon_set_mem_constant(struct radeon *radeon, boolean state)
 {
        radeon->use_mem_constant = state;
@@ -127,6 +132,37 @@ struct radeon *radeon_new(int fd, unsigned device)
                break;
        }
 
+       /* setup class */
+       switch (radeon->family) {
+       case CHIP_R600:
+       case CHIP_RV610:
+       case CHIP_RV630:
+       case CHIP_RV670:
+       case CHIP_RV620:
+       case CHIP_RV635:
+       case CHIP_RS780:
+       case CHIP_RS880:
+               radeon->chip_class = R600;
+               break;
+       case CHIP_RV770:
+       case CHIP_RV730:
+       case CHIP_RV710:
+       case CHIP_RV740:
+               radeon->chip_class = R700;
+               break;
+       case CHIP_CEDAR:
+       case CHIP_REDWOOD:
+       case CHIP_JUNIPER:
+       case CHIP_CYPRESS:
+       case CHIP_HEMLOCK:
+               radeon->chip_class = EVERGREEN;
+               break;
+       default:
+               fprintf(stderr, "%s unknown or unsupported chipset 0x%04X\n",
+                       __func__, radeon->device);
+               break;
+       }
+
        radeon->mman = pb_malloc_bufmgr_create();
        if (!radeon->mman)
                return NULL;
index c284f6aa7d17389f3dd0b2bf9deb28e68289af36..85aea89c700d420b536d7fb5c0394a9dc9bef6fb 100644 (file)
@@ -83,6 +83,7 @@ struct radeon {
        int                             refcount;
        unsigned                        device;
        unsigned                        family;
+       enum chip_class                 chip_class;
        unsigned                        nstype;
        struct radeon_stype_info        *stype;
        unsigned max_states;