i965: Use immediate float operands for some VS instructions.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_wm_sampler_state.c
index aa2e519588179ea4a4897f0d345e1d68dbe18dfb..1582ff1ab6593532e107bf51ce5ebdd7aa365733 100644 (file)
@@ -89,7 +89,6 @@ struct wm_sampler_key {
       float max_aniso;
       GLenum minfilter, magfilter;
       GLenum comparemode, comparefunc;
-      dri_bo *sdc_bo;
 
       /** If target is cubemap, take context setting.
        */
@@ -105,7 +104,7 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key,
                                     dri_bo *sdc_bo,
                                     struct brw_sampler_state *sampler)
 {
-   _mesa_memset(sampler, 0, sizeof(*sampler));
+   memset(sampler, 0, sizeof(*sampler));
 
    switch (key->minfilter) {
    case GL_NEAREST:
@@ -229,8 +228,10 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 {
    GLcontext *ctx = &brw->intel.ctx;
    int unit;
+   char *last_entry_end = ((char*)&key->sampler_count) + 
+      sizeof(key->sampler_count);
 
-   memset(key, 0, sizeof(*key));
+   key->sampler_count = 0;
 
    for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) {
       if (ctx->Texture.Unit[unit]._ReallyEnabled) {
@@ -241,6 +242,10 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
         struct gl_texture_image *firstImage =
            texObj->Image[0][intelObj->firstLevel];
 
+        memset(last_entry_end, 0, 
+               (char*)entry - last_entry_end + sizeof(*entry));
+        last_entry_end = ((char*)entry) + sizeof(*entry);
+
          entry->tex_target = texObj->Target;
 
         entry->seamless_cube_map = (texObj->Target == GL_TEXTURE_CUBE_MAP)
@@ -262,10 +267,10 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
         dri_bo_unreference(brw->wm.sdc_bo[unit]);
         if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
            float bordercolor[4] = {
-              texObj->BorderColor[0],
-              texObj->BorderColor[0],
-              texObj->BorderColor[0],
-              texObj->BorderColor[0]
+              texObj->BorderColor.f[0],
+              texObj->BorderColor.f[0],
+              texObj->BorderColor.f[0],
+              texObj->BorderColor.f[0]
            };
            /* GL specs that border color for depth textures is taken from the
             * R channel, while the hardware uses A.  Spam R into all the
@@ -274,11 +279,13 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
            brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor);
         } else {
            brw->wm.sdc_bo[unit] = upload_default_color(brw,
-                                                       texObj->BorderColor);
+                                                       texObj->BorderColor.f);
         }
         key->sampler_count = unit + 1;
       }
    }
+   struct wm_sampler_entry *entry = &key->sampler[key->sampler_count];
+   memset(last_entry_end, 0, (char*)entry - last_entry_end);
 }
 
 /* All samplers must be uploaded in a single contiguous array, which
@@ -289,7 +296,7 @@ static void upload_wm_samplers( struct brw_context *brw )
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct wm_sampler_key key;
-   int i;
+   int i, sampler_key_size;
 
    brw_wm_sampler_populate_key(brw, &key);
 
@@ -303,8 +310,11 @@ static void upload_wm_samplers( struct brw_context *brw )
    if (brw->wm.sampler_count == 0)
       return;
 
+   /* Only include the populated portion of the key in the search. */
+   sampler_key_size = offsetof(struct wm_sampler_key,
+                              sampler[key.sampler_count]);
    brw->wm.sampler_bo = brw_search_cache(&brw->cache, BRW_SAMPLER,
-                                        &key, sizeof(key),
+                                        &key, sampler_key_size,
                                         brw->wm.sdc_bo, key.sampler_count,
                                         NULL);
 
@@ -324,10 +334,9 @@ static void upload_wm_samplers( struct brw_context *brw )
       }
 
       brw->wm.sampler_bo = brw_upload_cache(&brw->cache, BRW_SAMPLER,
-                                           &key, sizeof(key),
+                                           &key, sampler_key_size,
                                            brw->wm.sdc_bo, key.sampler_count,
-                                           &sampler, sizeof(sampler),
-                                           NULL, NULL);
+                                           &sampler, sizeof(sampler));
 
       /* Emit SDC relocations */
       for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {