r300g: require DRM 2.3.0 (kernel 2.6.34)
authorMarek Olšák <maraeo@gmail.com>
Wed, 2 Mar 2011 16:51:19 +0000 (17:51 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 2 Mar 2011 16:54:36 +0000 (17:54 +0100)
Running any older kernel is not recommended anyway.

src/gallium/drivers/r300/r300_chipset.h
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_flush.c
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_texture_desc.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/winsys/radeon/drm/radeon_drm_common.c

index 0be161fa07a84545113e9d5914090df6a9125bf9..68943d561ba7de9761920c534ab1b0c81620789e 100644 (file)
@@ -90,8 +90,6 @@ struct r300_capabilities {
     boolean high_second_pipe;
     /* DXTC texture swizzling. */
     boolean dxtc_swizzle;
-    /* Index bias (AKA index offset). */
-    boolean index_bias_supported;
 };
 
 /* Enumerations for legibility and telling which card we're running on. */
index f37e3ea0859de9ba221095f0ac452e44263ea7a0..166d965aa5bb2118cca46c983fa2c5b8046624ad 100644 (file)
@@ -169,7 +169,6 @@ 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_3_0 = r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0);
     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 has_hiz_ram = r300->screen->caps.hiz_ram > 0;
@@ -215,7 +214,7 @@ static boolean r300_setup_atoms(struct r300_context* r300)
     R300_INIT_ATOM(rs_block_state, 0);
     R300_INIT_ATOM(rs_state, 0);
     /* SC, US. */
-    R300_INIT_ATOM(fb_state_pipelined, 5 + (drm_2_3_0 ? 3 : 0));
+    R300_INIT_ATOM(fb_state_pipelined, 8);
     /* US. */
     R300_INIT_ATOM(fs, 0);
     R300_INIT_ATOM(fs_rc_constant_state, 0);
index 9b4a3063f6dfdd077e0497049894b5715b352dbf..24c82a3efd262a8ff0799ca584e4d4fd52319e76 100644 (file)
@@ -469,6 +469,7 @@ void r300_emit_fb_state_pipelined(struct r300_context *r300,
     struct pipe_framebuffer_state* fb =
             (struct pipe_framebuffer_state*)r300->fb_state.state;
     unsigned i, num_cbufs = fb->nr_cbufs;
+    unsigned mspos0, mspos1;
     CS_LOCALS(r300);
 
     /* If we use the multiwrite feature, the colorbuffers 2,3,4 must be
@@ -492,38 +493,36 @@ void r300_emit_fb_state_pipelined(struct r300_context *r300,
     /* Multisampling. Depends on framebuffer sample count.
      * These are pipelined regs and as such cannot be moved
      * to the AA state. */
-    if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) {
-        unsigned mspos0 = 0x66666666;
-        unsigned mspos1 = 0x6666666;
-
-        if (fb->nr_cbufs && fb->cbufs[0]->texture->nr_samples > 1) {
-            /* Subsample placement. These may not be optimal. */
-            switch (fb->cbufs[0]->texture->nr_samples) {
-                case 2:
-                    mspos0 = 0x33996633;
-                    mspos1 = 0x6666663;
-                    break;
-                case 3:
-                    mspos0 = 0x33936933;
-                    mspos1 = 0x6666663;
-                    break;
-                case 4:
-                    mspos0 = 0x33939933;
-                    mspos1 = 0x3966663;
-                    break;
-                case 6:
-                    mspos0 = 0x22a2aa22;
-                    mspos1 = 0x2a65672;
-                    break;
-                default:
-                    debug_printf("r300: Bad number of multisamples!\n");
-            }
-        }
+    mspos0 = 0x66666666;
+    mspos1 = 0x6666666;
 
-        OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
-        OUT_CS(mspos0);
-        OUT_CS(mspos1);
+    if (fb->nr_cbufs && fb->cbufs[0]->texture->nr_samples > 1) {
+        /* Subsample placement. These may not be optimal. */
+        switch (fb->cbufs[0]->texture->nr_samples) {
+        case 2:
+            mspos0 = 0x33996633;
+            mspos1 = 0x6666663;
+            break;
+        case 3:
+            mspos0 = 0x33936933;
+            mspos1 = 0x6666663;
+            break;
+        case 4:
+            mspos0 = 0x33939933;
+            mspos1 = 0x3966663;
+            break;
+        case 6:
+            mspos0 = 0x22a2aa22;
+            mspos1 = 0x2a65672;
+            break;
+        default:
+            debug_printf("r300: Bad number of multisamples!\n");
+        }
     }
+
+    OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
+    OUT_CS(mspos0);
+    OUT_CS(mspos1);
     END_CS;
 }
 
@@ -1191,7 +1190,7 @@ unsigned r300_get_num_cs_end_dwords(struct r300_context *r300)
     /* Emitted in flush. */
     dwords += 26; /* emit_query_end */
     dwords += r300->hyperz_state.size + 2; /* emit_hyperz_end + zcache flush */
-    if (r300->screen->caps.index_bias_supported)
+    if (r300->screen->caps.is_r500)
         dwords += 2;
 
     return dwords;
index c77cc08539d7fd01b2064006e897aa01941a2138..9c41a1383ced7d5ba9e9d809c8edb1b456a7009c 100644 (file)
@@ -57,7 +57,7 @@ static void r300_flush(struct pipe_context* pipe,
     if (r300->dirty_hw) {
         r300_emit_hyperz_end(r300);
         r300_emit_query_end(r300);
-        if (r300->screen->caps.index_bias_supported)
+        if (r300->screen->caps.is_r500)
             r500_emit_index_bias(r300, 0);
 
         r300->flush_counter++;
index 73ed44cc5a2fd1a1e4db2add95d140999edd9431..0ec4a225865163033121f4eedcb01b6289541225 100644 (file)
@@ -205,7 +205,7 @@ static boolean r300_reserve_cs_dwords(struct r300_context *r300,
     if (first_draw) {
         cs_dwords += r300_get_num_dirty_dwords(r300);
 
-        if (r300->screen->caps.index_bias_supported)
+        if (r300->screen->caps.is_r500)
             cs_dwords += 2; /* emit_index_offset */
 
         if (emit_vertex_arrays)
@@ -257,7 +257,7 @@ static boolean r300_emit_states(struct r300_context *r300,
         }
 
         r300_emit_dirty_state(r300);
-        if (r300->screen->caps.index_bias_supported) {
+        if (r300->screen->caps.is_r500) {
             if (r300->screen->caps.has_tcl)
                 r500_emit_index_bias(r300, index_bias);
             else
@@ -557,7 +557,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
         OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
                r300_translate_primitive(mode));
 
-        if (indexBias && !r300->screen->caps.index_bias_supported) {
+        if (indexBias && !r300->screen->caps.is_r500) {
             for (i = 0; i < count-1; i += 2)
                 OUT_CS(((ptr1[i+1] + indexBias) << 16) |
                         (ptr1[i]   + indexBias));
@@ -581,7 +581,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
         OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
                r300_translate_primitive(mode));
 
-        if (indexBias && !r300->screen->caps.index_bias_supported) {
+        if (indexBias && !r300->screen->caps.is_r500) {
             for (i = 0; i < count-1; i += 2)
                 OUT_CS(((ptr2[i+1] + indexBias) << 16) |
                         (ptr2[i]   + indexBias));
@@ -601,7 +601,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300,
                R300_VAP_VF_CNTL__INDEX_SIZE_32bit |
                r300_translate_primitive(mode));
 
-        if (indexBias && !r300->screen->caps.index_bias_supported) {
+        if (indexBias && !r300->screen->caps.is_r500) {
             for (i = 0; i < count; i++)
                 OUT_CS(ptr4[i] + indexBias);
         } else {
@@ -620,13 +620,12 @@ static void r300_draw_elements(struct r300_context *r300, int indexBias,
     unsigned indexSize = r300->index_buffer.index_size;
     struct pipe_resource* orgIndexBuffer = indexBuffer;
     boolean alt_num_verts = r300->screen->caps.is_r500 &&
-                            count > 65536 &&
-                            r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0);
+                            count > 65536;
     unsigned short_count;
     int buffer_offset = 0, index_offset = 0; /* for index bias emulation */
     uint16_t indices3[3];
 
-    if (indexBias && !r300->screen->caps.index_bias_supported) {
+    if (indexBias && !r300->screen->caps.is_r500) {
         r300_split_index_bias(r300, indexBias, &buffer_offset, &index_offset);
     }
 
@@ -702,8 +701,7 @@ static void r300_draw_arrays(struct r300_context *r300, unsigned mode,
                              unsigned start, unsigned count)
 {
     boolean alt_num_verts = r300->screen->caps.is_r500 &&
-                            count > 65536 &&
-                            r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0);
+                            count > 65536;
     unsigned short_count;
 
     /* 9 spare dwords for emit_draw_arrays. Give up if the function fails. */
index 77a9c6ad86f88db92a8cbecf77b1db5329b469a4..52d0247fbfdf66683a8f3ba3f48d5e128653b3ce 100644 (file)
@@ -456,10 +456,6 @@ struct pipe_screen* r300_screen_create(struct r300_winsys_screen *rws)
     if (SCREEN_DBG_ON(r300screen, DBG_NO_HIZ))
         r300screen->caps.hiz_ram = 0;
 
-    r300screen->caps.index_bias_supported =
-            r300screen->caps.is_r500 &&
-            rws->get_value(rws, R300_VID_DRM_2_3_0);
-
     pipe_mutex_init(r300screen->num_contexts_mutex);
 
     util_slab_create(&r300screen->pool_buffers,
index be222155e67be48a48aac5aff6efc9ef8fcc117d..b810f4081c8a9d61a4c53c52df65df4fad8fb17f 100644 (file)
@@ -804,27 +804,25 @@ r300_set_framebuffer_state(struct pipe_context* pipe,
     }
 
     /* Set up AA config. */
-    if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) {
-        if (state->nr_cbufs && state->cbufs[0]->texture->nr_samples > 1) {
-            aa->aa_config = R300_GB_AA_CONFIG_AA_ENABLE;
-
-            switch (state->cbufs[0]->texture->nr_samples) {
-                case 2:
-                    aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2;
-                    break;
-                case 3:
-                    aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3;
-                    break;
-                case 4:
-                    aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4;
-                    break;
-                case 6:
-                    aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6;
-                    break;
-            }
-        } else {
-            aa->aa_config = 0;
+    if (state->nr_cbufs && state->cbufs[0]->texture->nr_samples > 1) {
+        aa->aa_config = R300_GB_AA_CONFIG_AA_ENABLE;
+
+        switch (state->cbufs[0]->texture->nr_samples) {
+        case 2:
+            aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2;
+            break;
+        case 3:
+            aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3;
+            break;
+        case 4:
+            aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4;
+            break;
+        case 6:
+            aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6;
+            break;
         }
+    } else {
+        aa->aa_config = 0;
     }
 
     if (DBG_ON(r300, DBG_FB)) {
index da06847bbe068db1b4f949e41ebce8faf2aaadf1..86ad0b8b8e04654589e6e6b9ebec3ea59124762f 100644 (file)
@@ -867,8 +867,7 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
                 break;
 
             case 2:
-                if (rws->get_value(rws, R300_VID_DRM_2_1_0))
-                    microtile = R300_BUFFER_SQUARETILED;
+                microtile = R300_BUFFER_SQUARETILED;
                 break;
         }
     }
index 9dcdf153e357c0b71a7833e2b2eb3485e6bf07f2..3846fb8b6b380d6492e6984cd99681f968f1db3e 100644 (file)
@@ -207,29 +207,6 @@ static unsigned r300_texture_get_nblocksy(struct r300_resource *tex,
     return util_format_get_nblocksy(tex->b.b.b.format, height);
 }
 
-static void r300_texture_3d_fix_mipmapping(struct r300_screen *screen,
-                                           struct r300_resource *tex)
-{
-    /* The kernels <= 2.6.34-rc4 compute the size of mipmapped 3D textures
-     * incorrectly. This is a workaround to prevent CS from being rejected. */
-
-    unsigned i, size;
-
-    if (!screen->rws->get_value(screen->rws, R300_VID_DRM_2_3_0) &&
-        tex->b.b.b.target == PIPE_TEXTURE_3D &&
-        tex->b.b.b.last_level > 0) {
-        size = 0;
-
-        for (i = 0; i <= tex->b.b.b.last_level; i++) {
-            size += tex->tex.stride_in_bytes[i] *
-                    r300_texture_get_nblocksy(tex, i, FALSE);
-        }
-
-        size *= tex->tex.depth0;
-        tex->tex.size_in_bytes = size;
-    }
-}
-
 /* Get a width in pixels from a stride in bytes. */
 static unsigned stride_to_width(enum pipe_format format,
                                 unsigned stride_in_bytes)
@@ -442,7 +419,6 @@ static void r300_setup_hyperz_properties(struct r300_screen *screen,
 static void r300_setup_tiling(struct r300_screen *screen,
                               struct r300_resource *tex)
 {
-    struct r300_winsys_screen *rws = screen->rws;
     enum pipe_format format = tex->b.b.b.format;
     boolean rv350_mode = screen->caps.family >= CHIP_FAMILY_R350;
     boolean is_zb = util_format_is_depth_or_stencil(format);
@@ -469,9 +445,7 @@ static void r300_setup_tiling(struct r300_screen *screen,
             break;
 
         case 2:
-            if (rws->get_value(rws, R300_VID_DRM_2_1_0)) {
-                tex->tex.microtile = R300_BUFFER_SQUARETILED;
-            }
+            tex->tex.microtile = R300_BUFFER_SQUARETILED;
             break;
     }
 
@@ -541,7 +515,6 @@ boolean r300_texture_desc_init(struct r300_screen *rscreen,
         r300_setup_miptree(rscreen, tex, FALSE);
     }
 
-    r300_texture_3d_fix_mipmapping(rscreen, tex);
     r300_setup_hyperz_properties(rscreen, tex);
 
     if (tex->buf_size) {
index ced7bb5edd0771b3d2f04f484e2323c3dd36c148..c0b66899f8b5754aa0c00b60f54e06f880c98951 100644 (file)
@@ -60,8 +60,6 @@ enum r300_value_id {
     R300_VID_DRM_PATCHLEVEL,
 
     /* These should probably go away: */
-    R300_VID_DRM_2_1_0,  /* Square tiling. */
-    R300_VID_DRM_2_3_0,  /* R500 VAP regs, MSPOS regs, fixed tex3D size checking */
     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 */
 
index c0044d399c4bd1e32072e440e986dcc21c94adff..72c2ff11125c9738a5a2e1e0ecc629e195fa2909 100644 (file)
@@ -96,10 +96,13 @@ static void do_ioctls(struct radeon_drm_winsys *winsys)
      * we don't actually use the info for anything yet. */
 
     version = drmGetVersion(winsys->fd);
-    if (version->version_major != 2) {
+    if (version->version_major != 2 ||
+        version->version_minor < 3) {
         fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
-                "only compatible with 2.x.x\n", __FUNCTION__,
-                version->version_major, version->version_minor,
+                "only compatible with 2.3.x (kernel 2.6.34) and later.\n",
+                __FUNCTION__,
+                version->version_major,
+                version->version_minor,
                 version->version_patchlevel);
         drmFreeVersion(version);
         exit(1);
@@ -192,10 +195,6 @@ static uint32_t radeon_get_value(struct r300_winsys_screen *rws,
         return ws->drm_minor;
     case R300_VID_DRM_PATCHLEVEL:
         return ws->drm_patchlevel;
-    case R300_VID_DRM_2_1_0:
-        return ws->drm_major*100 + ws->drm_minor >= 201;
-    case R300_VID_DRM_2_3_0:
-        return ws->drm_major*100 + ws->drm_minor >= 203;
     case R300_VID_DRM_2_6_0:
         return ws->drm_major*100 + ws->drm_minor >= 206;
     case R300_VID_DRM_2_8_0: