winsys/radeon: add R300 infix to winsys feature names
[mesa.git] / src / gallium / drivers / r300 / r300_state.c
index 5f0e73b617d7f6bd5e86bd8b7fc32cbc19a3060c..057cd9faf0362a93278c4667c72b9b2214362c85 100644 (file)
@@ -549,6 +549,10 @@ static void*
         dsa->z_stencil_control |=
             (r300_translate_depth_stencil_function(state->depth.func) <<
                 R300_Z_FUNC_SHIFT);
+    } else {
+        /* We must enable depth test, otherwise occlusion queries won't work. */
+        dsa->z_buffer_control |= R300_Z_ENABLE;
+        dsa->z_stencil_control |= R300_ZS_ALWAYS;
     }
 
     /* Stencil buffer setup. */
@@ -632,11 +636,13 @@ static void*
     OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
     END_CB;
 
+    /* We must enable depth test, otherwise occlusion queries won't work.
+     * We setup a dummy zbuffer to silent the CS checker, see emit_fb_state. */
     BEGIN_CB(dsa->cb_zb_no_readwrite, 10);
     OUT_CB_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function);
     OUT_CB_REG_SEQ(R300_ZB_CNTL, 3);
-    OUT_CB(0);
-    OUT_CB(0);
+    OUT_CB(R300_Z_ENABLE);
+    OUT_CB(R300_ZS_ALWAYS);
     OUT_CB(0);
     OUT_CB_REG(R500_ZB_STENCILREFMASK_BF, 0);
     OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
@@ -645,8 +651,8 @@ static void*
     BEGIN_CB(dsa->cb_fp16_zb_no_readwrite, 10);
     OUT_CB_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function_fp16);
     OUT_CB_REG_SEQ(R300_ZB_CNTL, 3);
-    OUT_CB(0);
-    OUT_CB(0);
+    OUT_CB(R300_Z_ENABLE);
+    OUT_CB(R300_ZS_ALWAYS);
     OUT_CB(0);
     OUT_CB_REG(R500_ZB_STENCILREFMASK_BF, 0);
     OUT_CB_REG(R500_FG_ALPHA_VALUE, dsa->alpha_value);
@@ -792,12 +798,14 @@ void r300_mark_fb_state_dirty(struct r300_context *r300,
     /* Now compute the fb_state atom size. */
     r300->fb_state.size = 2 + (8 * state->nr_cbufs);
 
-    if (r300->cbzb_clear)
+    if (r300->cbzb_clear) {
         r300->fb_state.size += 10;
-    else if (state->zsbuf) {
+    else if (state->zsbuf) {
         r300->fb_state.size += 10;
         if (r300->hyperz_enabled)
             r300->fb_state.size += 8;
+    } else if (state->nr_cbufs) {
+        r300->fb_state.size += 10;
     }
 
     /* The size of the rest of atoms stays the same. */
@@ -1299,7 +1307,7 @@ static void*
     sampler->filter0 |= r300_translate_tex_filters(state->min_img_filter,
                                                    state->mag_img_filter,
                                                    state->min_mip_filter,
-                                                   state->max_anisotropy > 0);
+                                                   state->max_anisotropy > 1);
 
     sampler->filter0 |= r300_anisotropy(state->max_anisotropy);
 
@@ -1457,6 +1465,8 @@ r300_create_sampler_view(struct pipe_context *pipe,
     boolean dxtc_swizzle = r300_screen(pipe->screen)->caps.dxtc_swizzle;
 
     if (view) {
+        unsigned hwformat;
+
         view->base = *templ;
         view->base.reference.count = 1;
         view->base.context = pipe;
@@ -1468,11 +1478,19 @@ r300_create_sampler_view(struct pipe_context *pipe,
         view->swizzle[2] = templ->swizzle_b;
         view->swizzle[3] = templ->swizzle_a;
 
+        hwformat = r300_translate_texformat(templ->format,
+                                            view->swizzle,
+                                            is_r500,
+                                            dxtc_swizzle);
+
+        if (hwformat == ~0) {
+            fprintf(stderr, "r300: Ooops. Got unsupported format %s in %s.\n",
+                    util_format_short_name(templ->format), __func__);
+        }
+        assert(hwformat != ~0);
+
         view->format = tex->tx_format;
-        view->format.format1 |= r300_translate_texformat(templ->format,
-                                                         view->swizzle,
-                                                         is_r500,
-                                                         dxtc_swizzle);
+        view->format.format1 |= hwformat;
         if (is_r500) {
             view->format.format2 |= r500_tx_format_msb_bit(templ->format);
         }
@@ -1604,10 +1622,9 @@ static void r300_set_index_buffer(struct pipe_context* pipe,
 }
 
 /* Initialize the PSC tables. */
-static void r300_vertex_psc(struct r300_vertex_element_state *velems,
-                            struct r300_vertex_stream_state *vstream,
-                            boolean insert_instance_id_attrib)
+static void r300_vertex_psc(struct r300_vertex_element_state *velems)
 {
+    struct r300_vertex_stream_state *vstream = &velems->vertex_stream;
     uint16_t type, swizzle;
     enum pipe_format format;
     unsigned i;
@@ -1638,27 +1655,6 @@ static void r300_vertex_psc(struct r300_vertex_element_state *velems,
         }
     }
 
-    /* Insert attrib emulating InstanceID. */
-    if (i < 15 && insert_instance_id_attrib) {
-        format = PIPE_FORMAT_R32_FLOAT;
-
-        type = r300_translate_vertex_data_type(format);
-        assert(type != R300_INVALID_FORMAT);
-
-        type |= i << R300_DST_VEC_LOC_SHIFT;
-        swizzle = r300_translate_vertex_data_swizzle(format);
-
-        if (i & 1) {
-            vstream->vap_prog_stream_cntl[i >> 1] |= type << 16;
-            vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16;
-        } else {
-            vstream->vap_prog_stream_cntl[i >> 1] |= type;
-            vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle;
-        }
-
-        i++;
-    }
-
     /* Set the last vector in the PSC. */
     if (i) {
         i -= 1;
@@ -1701,8 +1697,7 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
     if (r300_screen(pipe->screen)->caps.has_tcl) {
         /* Setup PSC.
          * The unused components will be replaced by (..., 0, 1). */
-        r300_vertex_psc(velems, &velems->vertex_stream, FALSE);
-        r300_vertex_psc(velems, &velems->vertex_stream_instanced, TRUE);
+        r300_vertex_psc(velems);
 
         for (i = 0; i < count; i++) {
             velems->format_size[i] =
@@ -1733,8 +1728,8 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe,
         return;
     }
 
-    UPDATE_STATE(velems, r300->vertex_stream_state);
-    r300->vertex_stream_state.size = (1 + velems->vertex_stream_instanced.count) * 2;
+    UPDATE_STATE(&velems->vertex_stream, r300->vertex_stream_state);
+    r300->vertex_stream_state.size = (1 + velems->vertex_stream.count) * 2;
     r300->vertex_arrays_dirty = TRUE;
 }