mesa: fix num_draw_buffers==0 in fixed-function fragment program generation
[mesa.git] / src / mesa / main / teximage.c
index 74dc273121ae1a3a84693801c9aa19e6c230cc64..47d509396a788857a4e2a4d3416b4053cb4229fb 100644 (file)
@@ -40,6 +40,7 @@
 #include "image.h"
 #include "imports.h"
 #include "macros.h"
+#include "mfeatures.h"
 #include "state.h"
 #include "texcompress.h"
 #include "texfetch.h"
@@ -340,11 +341,11 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
          return GL_RGBA;
       case GL_SLUMINANCE_ALPHA_EXT:
       case GL_SLUMINANCE8_ALPHA8_EXT:
-      case GL_COMPRESSED_SLUMINANCE_EXT:
       case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
          return GL_LUMINANCE_ALPHA;
       case GL_SLUMINANCE_EXT:
       case GL_SLUMINANCE8_EXT:
+      case GL_COMPRESSED_SLUMINANCE_EXT:
          return GL_LUMINANCE;
       default:
          ; /* fallthrough */
@@ -931,8 +932,8 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target)
 /**
  * Return number of dimensions per mipmap level for the given texture target.
  */
-static GLint
-get_texture_dimensions(GLenum target)
+GLint
+_mesa_get_texture_dimensions(GLenum target)
 {
    switch (target) {
    case GL_TEXTURE_1D:
@@ -1157,7 +1158,7 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
 
    img->TexFormat = format;
 
-   dims = get_texture_dimensions(target);
+   dims = _mesa_get_texture_dimensions(target);
 
    _mesa_set_fetch_functions(img, dims);
 }
@@ -1437,10 +1438,12 @@ legal_teximage_target(struct gl_context *ctx, GLuint dims, GLenum target)
 
 /**
  * Check if the given texture target value is legal for a
- * glCopyTexImage1/2D call.
+ * glTexSubImage, glCopyTexSubImage or glCopyTexImage call.
+ * The difference compared to legal_teximage_target() above is that
+ * proxy targets are not supported.
  */
 static GLboolean
-legal_copyteximage_target(struct gl_context *ctx, GLuint dims, GLenum target)
+legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)
 {
    switch (dims) {
    case 1:
@@ -1463,8 +1466,18 @@ legal_copyteximage_target(struct gl_context *ctx, GLuint dims, GLenum target)
       default:
          return GL_FALSE;
       }
+   case 3:
+      switch (target) {
+      case GL_TEXTURE_3D:
+         return GL_TRUE;
+      case GL_TEXTURE_2D_ARRAY_EXT:
+         return ctx->Extensions.MESA_texture_array;
+      default:
+         return GL_FALSE;
+      }
    default:
-      _mesa_problem(ctx, "invalid dims=%u in legal_copyteximage_target()", dims);
+      _mesa_problem(ctx, "invalid dims=%u in legal_texsubimage_target()",
+                    dims);
       return GL_FALSE;
    }
 }
@@ -1856,7 +1869,7 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
    GLint format;
 
    /* check target */
-   if (!legal_copyteximage_target(ctx, dimensions, target)) {
+   if (!legal_texsubimage_target(ctx, dimensions, target)) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexImage%uD(target=%s)",
                   dimensions, _mesa_lookup_enum_by_nr(target));
       return GL_TRUE;
@@ -1982,8 +1995,7 @@ copytexsubimage_error_check1( struct gl_context *ctx, GLuint dimensions,
    }
 
    /* check target (proxies not allowed) */
-   if (!legal_teximage_target(ctx, dimensions, target) ||
-       _mesa_is_proxy_texture(target)) {
+   if (!legal_texsubimage_target(ctx, dimensions, target)) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTexSubImage%uD(target=%s)",
                   dimensions, _mesa_lookup_enum_by_nr(target));
       return GL_TRUE;
@@ -2579,8 +2591,7 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
                   _mesa_lookup_enum_by_nr(type), pixels);
 
    /* check target (proxies not allowed) */
-   if (!legal_teximage_target(ctx, dims, target) ||
-       _mesa_is_proxy_texture(target)) {
+   if (!legal_texsubimage_target(ctx, dims, target)) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage%uD(target=%s)",
                   dims, _mesa_lookup_enum_by_nr(target));
       return;