glthread: Fix use of alloca() without #include "c99_alloca.h"
[mesa.git] / src / mesa / main / vdpau.c
index 0efa56e4f4199ba42ec9d0512120087caf7ce733..6a96c40bdb8fc345a7d7791d188421c14f01710a 100644 (file)
@@ -34,6 +34,7 @@
 #include <stdbool.h>
 #include "util/hash_table.h"
 #include "util/set.h"
+#include "util/u_memory.h"
 #include "context.h"
 #include "glformats.h"
 #include "texobj.h"
@@ -145,11 +146,11 @@ register_surface(struct gl_context *ctx, GLboolean isOutput,
    surf->output = isOutput;
    for (i = 0; i < numTextureNames; ++i) {
       struct gl_texture_object *tex;
-      tex  = _mesa_lookup_texture(ctx, textureNames[i]);
+
+      tex = _mesa_lookup_texture_err(ctx, textureNames[i],
+                                     "VDPAURegisterSurfaceNV");
       if (tex == NULL) {
          free(surf);
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "VDPAURegisterSurfaceNV(texture ID not found)");
          return (GLintptr)NULL;
       }
 
@@ -163,9 +164,10 @@ register_surface(struct gl_context *ctx, GLboolean isOutput,
          return (GLintptr)NULL;
       }
 
-      if (tex->Target == 0)
+      if (tex->Target == 0) {
          tex->Target = target;
-      else if (tex->Target != target) {
+         tex->TargetIndex = _mesa_tex_target_to_index(ctx, target);
+      } else if (tex->Target != target) {
          _mesa_unlock_texture(ctx, tex);
          free(surf);
          _mesa_error(ctx, GL_INVALID_OPERATION,