Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / drivers / dri / r600 / r600_tex.c
index d105b90cd18562bdb2b46ea77556dec3b80c8eb6..d6a58f410cccc3d44816cff0775a8bdf8d275e82 100644 (file)
@@ -40,20 +40,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/image.h"
 #include "main/mipmap.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
-#include "main/teximage.h"
 #include "main/texobj.h"
 
 #include "texmem.h"
 
 #include "r600_context.h"
-#include "r700_state.h"
 #include "radeon_mipmap_tree.h"
 #include "r600_tex.h"
 
-#include "xmlpool.h"
-
 
 static unsigned int translate_wrap_mode(GLenum wrapmode)
 {
@@ -281,11 +276,12 @@ static void r600SetTexBorderColor(radeonTexObjPtr t, const GLfloat color[4])
  * next UpdateTextureState
  */
 
-static void r600TexParameter(GLcontext * ctx, GLenum target,
+static void r600TexParameter(struct gl_context * ctx, GLenum target,
                             struct gl_texture_object *texObj,
                             GLenum pname, const GLfloat * params)
 {
        radeonTexObj* t = radeon_tex_obj(texObj);
+       GLenum baseFormat;
 
        radeon_print(RADEON_STATE | RADEON_TEXTURE, RADEON_VERBOSE,
                        "%s( %s )\n", __FUNCTION__,
@@ -305,30 +301,22 @@ static void r600TexParameter(GLcontext * ctx, GLenum target,
                break;
 
        case GL_TEXTURE_BORDER_COLOR:
-               r600SetTexBorderColor(t, texObj->BorderColor);
+               r600SetTexBorderColor(t, texObj->BorderColor.f);
                break;
 
        case GL_TEXTURE_BASE_LEVEL:
        case GL_TEXTURE_MAX_LEVEL:
        case GL_TEXTURE_MIN_LOD:
        case GL_TEXTURE_MAX_LOD:
-               /* This isn't the most efficient solution but there doesn't appear to
-                * be a nice alternative.  Since there's no LOD clamping,
-                * we just have to rely on loading the right subset of mipmap levels
-                * to simulate a clamped LOD.
-                */
-               if (t->mt) {
-                       radeon_miptree_unreference(t->mt);
-                       t->mt = 0;
-                       t->validated = GL_FALSE;
-               }
+               t->validated = GL_FALSE;
                break;
 
        case GL_DEPTH_TEXTURE_MODE:
                if (!texObj->Image[0][texObj->BaseLevel])
                        return;
-               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
-                   == GL_DEPTH_COMPONENT) {
+               baseFormat = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+               if (baseFormat == GL_DEPTH_COMPONENT ||
+                   baseFormat == GL_DEPTH_STENCIL) {
                        r600SetDepthTexMode(texObj);
                        break;
                } else {
@@ -344,7 +332,7 @@ static void r600TexParameter(GLcontext * ctx, GLenum target,
        }
 }
 
-static void r600DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
+static void r600DeleteTexture(struct gl_context * ctx, struct gl_texture_object *texObj)
 {
        context_t* rmesa = R700_CONTEXT(ctx);
        radeonTexObj* t = radeon_tex_obj(texObj);
@@ -368,10 +356,8 @@ static void r600DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
                t->bo = NULL;
        }
 
-       if (t->mt) {
-               radeon_miptree_unreference(t->mt);
-               t->mt = 0;
-       }
+       radeon_miptree_unreference(&t->mt);
+
        _mesa_delete_texture_object(ctx, texObj);
 }
 
@@ -382,7 +368,7 @@ static void r600DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
  * allocate the default texture objects.
  * Fixup MaxAnisotropy according to user preference.
  */
-static struct gl_texture_object *r600NewTextureObject(GLcontext * ctx,
+static struct gl_texture_object *r600NewTextureObject(struct gl_context * ctx,
                                                      GLuint name,
                                                      GLenum target)
 {
@@ -401,12 +387,60 @@ static struct gl_texture_object *r600NewTextureObject(GLcontext * ctx,
        r600SetTexDefaultState(t);
        r600UpdateTexWrap(t);
        r600SetTexFilter(t, t->base.MinFilter, t->base.MagFilter, t->base.MaxAnisotropy);
-       r600SetTexBorderColor(t, t->base.BorderColor);
+       r600SetTexBorderColor(t, t->base.BorderColor.f);
 
        return &t->base;
 }
 
-void r600InitTextureFuncs(struct dd_function_table *functions)
+unsigned r600IsFormatRenderable(gl_format mesa_format)
+{
+       switch (mesa_format) {
+       case MESA_FORMAT_RGBA8888:
+       case MESA_FORMAT_SIGNED_RGBA8888:
+       case MESA_FORMAT_RGBA8888_REV:
+       case MESA_FORMAT_SIGNED_RGBA8888_REV:
+       case MESA_FORMAT_ARGB8888:
+       case MESA_FORMAT_XRGB8888:
+       case MESA_FORMAT_ARGB8888_REV:
+       case MESA_FORMAT_XRGB8888_REV:
+       case MESA_FORMAT_RGB565:
+       case MESA_FORMAT_RGB565_REV:
+       case MESA_FORMAT_ARGB4444:
+       case MESA_FORMAT_ARGB4444_REV:
+       case MESA_FORMAT_ARGB1555:
+       case MESA_FORMAT_ARGB1555_REV:
+       case MESA_FORMAT_AL88:
+       case MESA_FORMAT_AL88_REV:
+       case MESA_FORMAT_RGB332:
+       case MESA_FORMAT_A8:
+       case MESA_FORMAT_I8:
+       case MESA_FORMAT_CI8:
+       case MESA_FORMAT_L8:
+       case MESA_FORMAT_RGBA_FLOAT32:
+       case MESA_FORMAT_RGBA_FLOAT16:
+       case MESA_FORMAT_ALPHA_FLOAT32:
+       case MESA_FORMAT_ALPHA_FLOAT16:
+       case MESA_FORMAT_LUMINANCE_FLOAT32:
+       case MESA_FORMAT_LUMINANCE_FLOAT16:
+       case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+       case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+       case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */
+       case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */
+       case MESA_FORMAT_X8_Z24:
+       case MESA_FORMAT_S8_Z24:
+       case MESA_FORMAT_Z24_S8:
+       case MESA_FORMAT_Z16:
+       case MESA_FORMAT_Z32:
+       case MESA_FORMAT_SARGB8:
+       case MESA_FORMAT_SLA8:
+       case MESA_FORMAT_SL8:
+               return 1;
+       default:
+               return 0;
+       }
+}
+
+void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions)
 {
        /* Note: we only plug in the functions we implement in the driver
         * since _mesa_init_driver_functions() was already called.
@@ -434,6 +468,11 @@ void r600InitTextureFuncs(struct dd_function_table *functions)
        functions->CompressedTexImage2D = radeonCompressedTexImage2D;
        functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
 
+       if (radeon->radeonScreen->kernel_mm) {
+               functions->CopyTexImage2D = radeonCopyTexImage2D;
+               functions->CopyTexSubImage2D = radeonCopyTexSubImage2D;
+       }
+
        functions->GenerateMipmap = radeonGenerateMipmap;
 
        driInitTextureFormats();