intel: Remove dead code in intelAllocateBuffer
[mesa.git] / src / mesa / drivers / dri / intel / intel_tex_image.c
index dd0c6d34c63ab1d600752b2093568bf1904f4943..a023fef563474313daf4af1b06e1294d98a5f71d 100644 (file)
@@ -84,6 +84,8 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
          intelImage->base.Base.Level == firstLevel &&
          (intel->gen < 4 || firstLevel == 0)) {
         lastLevel = firstLevel;
+      } else if (intelObj->base.Target == GL_TEXTURE_EXTERNAL_OES) {
+        lastLevel = firstLevel;
       } else {
         lastLevel = firstLevel + _mesa_logbase2(MAX2(MAX2(width, height), depth));
       }
@@ -97,7 +99,9 @@ intel_miptree_create_for_teximage(struct intel_context *intel,
                               width,
                               height,
                               depth,
-                              expect_accelerated_upload);
+                              expect_accelerated_upload,
+                               0 /* num_samples */,
+                               INTEL_MSAA_LAYOUT_NONE);
 }
 
 /* There are actually quite a few combinations this will work for,
@@ -199,17 +203,16 @@ try_pbo_upload(struct gl_context *ctx,
 
 static void
 intelTexImage(struct gl_context * ctx,
-              GLint dims,
-              GLenum target, GLint level,
+              GLuint dims,
+              struct gl_texture_image *texImage,
               GLint internalFormat,
-              GLint width, GLint height, GLint depth,
+              GLint width, GLint height, GLint depth, GLint border,
               GLenum format, GLenum type, const void *pixels,
-              const struct gl_pixelstore_attrib *unpack,
-              struct gl_texture_object *texObj,
-              struct gl_texture_image *texImage, GLsizei imageSize)
+              const struct gl_pixelstore_attrib *unpack)
 {
    DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__,
-       _mesa_lookup_enum_by_nr(target), level, width, height, depth);
+       _mesa_lookup_enum_by_nr(texImage->TexObject->Target),
+       texImage->Level, width, height, depth);
 
    /* Attempt to use the blitter for PBO image uploads.
     */
@@ -222,59 +225,9 @@ intelTexImage(struct gl_context * ctx,
    DBG("%s: upload image %dx%dx%d pixels %p\n",
        __FUNCTION__, width, height, depth, pixels);
 
-   _mesa_store_teximage3d(ctx, target, level, internalFormat,
-                         width, height, depth, 0,
-                         format, type, pixels,
-                         unpack, texObj, texImage);
-}
-
-
-static void
-intelTexImage3D(struct gl_context * ctx,
-                GLenum target, GLint level,
-                GLint internalFormat,
-                GLint width, GLint height, GLint depth,
-                GLint border,
-                GLenum format, GLenum type, const void *pixels,
-                const struct gl_pixelstore_attrib *unpack,
-                struct gl_texture_object *texObj,
-                struct gl_texture_image *texImage)
-{
-   intelTexImage(ctx, 3, target, level,
-                 internalFormat, width, height, depth,
-                 format, type, pixels, unpack, texObj, texImage, 0);
-}
-
-
-static void
-intelTexImage2D(struct gl_context * ctx,
-                GLenum target, GLint level,
-                GLint internalFormat,
-                GLint width, GLint height, GLint border,
-                GLenum format, GLenum type, const void *pixels,
-                const struct gl_pixelstore_attrib *unpack,
-                struct gl_texture_object *texObj,
-                struct gl_texture_image *texImage)
-{
-   intelTexImage(ctx, 2, target, level,
-                 internalFormat, width, height, 1,
-                 format, type, pixels, unpack, texObj, texImage, 0);
-}
-
-
-static void
-intelTexImage1D(struct gl_context * ctx,
-                GLenum target, GLint level,
-                GLint internalFormat,
-                GLint width, GLint border,
-                GLenum format, GLenum type, const void *pixels,
-                const struct gl_pixelstore_attrib *unpack,
-                struct gl_texture_object *texObj,
-                struct gl_texture_image *texImage)
-{
-   intelTexImage(ctx, 1, target, level,
-                 internalFormat, width, 1, 1,
-                 format, type, pixels, unpack, texObj, texImage, 0);
+   _mesa_store_teximage(ctx, dims, texImage, internalFormat,
+                        width, height, depth, 0,
+                        format, type, pixels, unpack);
 }
 
 
@@ -289,14 +242,15 @@ intel_set_texture_image_region(struct gl_context *ctx,
                               struct intel_region *region,
                               GLenum target,
                               GLenum internalFormat,
-                              gl_format format)
+                              gl_format format,
+                               uint32_t offset)
 {
    struct intel_context *intel = intel_context(ctx);
    struct intel_texture_image *intel_image = intel_texture_image(image);
    struct gl_texture_object *texobj = image->TexObject;
    struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
 
-   _mesa_init_teximage_fields(&intel->ctx, target, image,
+   _mesa_init_teximage_fields(&intel->ctx, image,
                              region->width, region->height, 1,
                              0, internalFormat, format);
 
@@ -308,6 +262,7 @@ intel_set_texture_image_region(struct gl_context *ctx,
    if (intel_image->mt == NULL)
        return;
 
+   intel_image->mt->offset = offset;
    intel_image->base.RowStride = region->pitch;
 
    /* Immediately validate the image to the object. */
@@ -326,8 +281,8 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    struct intel_renderbuffer *rb;
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
-   int level = 0, internalFormat;
-   gl_format texFormat;
+   int level = 0, internalFormat = 0;
+   gl_format texFormat = MESA_FORMAT_NONE;
 
    texObj = _mesa_get_current_tex_object(ctx, target);
    intelObj = intel_texture_object(texObj);
@@ -346,19 +301,24 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    if (!rb || !rb->mt)
       return;
 
-   if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
+   if (rb->mt->cpp == 4) {
+      if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
+         internalFormat = GL_RGB;
+         texFormat = MESA_FORMAT_XRGB8888;
+      }
+      else {
+         internalFormat = GL_RGBA;
+         texFormat = MESA_FORMAT_ARGB8888;
+      }
+   } else if (rb->mt->cpp == 2) {
       internalFormat = GL_RGB;
-      texFormat = MESA_FORMAT_XRGB8888;
-   }
-   else {
-      internalFormat = GL_RGBA;
-      texFormat = MESA_FORMAT_ARGB8888;
+      texFormat = MESA_FORMAT_RGB565;
    }
 
    _mesa_lock_texture(&intel->ctx, texObj);
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
    intel_set_texture_image_region(ctx, texImage, rb->mt->region, target,
-                                 internalFormat, texFormat);
+                                 internalFormat, texFormat, 0);
    _mesa_unlock_texture(&intel->ctx, texObj);
 }
 
@@ -389,16 +349,15 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
 
    intel_set_texture_image_region(ctx, texImage, image->region,
-                                 target, image->internal_format, image->format);
+                                 target, image->internal_format,
+                                  image->format, image->offset);
 }
 #endif
 
 void
 intelInitTextureImageFuncs(struct dd_function_table *functions)
 {
-   functions->TexImage1D = intelTexImage1D;
-   functions->TexImage2D = intelTexImage2D;
-   functions->TexImage3D = intelTexImage3D;
+   functions->TexImage = intelTexImage;
 
 #if FEATURE_OES_EGL_image
    functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;