util: Move u_debug to utils
[mesa.git] / src / gallium / auxiliary / util / u_texture.c
index cd477ab640fc3f8ea41a0671a1a99709bb58d8c5..cf09368a86a50dcf0681d326cc3b171321ed4738 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  * Copyright 2008 VMware, Inc.  All rights reserved.
  * Copyright 2009 Marek Olšák <maraeo@gmail.com>
@@ -20,7 +20,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "pipe/p_defines.h"
 
+#include "util/u_debug.h"
 #include "util/u_texture.h"
 
 void util_map_texcoords2d_onto_cubemap(unsigned face,
                                        const float *in_st, unsigned in_stride,
-                                       float *out_str, unsigned out_stride)
+                                       float *out_str, unsigned out_stride,
+                                       boolean allow_scale)
 {
    int i;
    float rx, ry, rz;
@@ -51,8 +53,14 @@ void util_map_texcoords2d_onto_cubemap(unsigned face,
       /* Compute sc = +/-scale and tc = +/-scale.
        * Not +/-1 to avoid cube face selection ambiguity near the edges,
        * though that can still sometimes happen with this scale factor...
+       *
+       * XXX: Yep, there is no safe scale factor that will prevent sampling
+       * the neighbouring face when stretching out.  A more reliable solution
+       * would be to clamp (sc, tc) against +/- 1.0-1.0/mipsize, in the shader.
+       *
+       * Also, this is not necessary when minifying, or 1:1 blits.
        */
-      const float scale = 0.9999f;
+      const float scale = allow_scale ? 0.9999f : 1.0f;
       const float sc = (2 * in_st[0] - 1) * scale;
       const float tc = (2 * in_st[1] - 1) * scale;