r600g: Implement GL_ARB_texture_gather
[mesa.git] / src / mesa / state_tracker / st_cb_drawtex.c
index 269068da2b0a407b92ccccd4ccde093bdc6a1068..f997e6b000786eac325ecb36a5534f57d92ab954 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  * 
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  *
  **************************************************************************/
@@ -15,7 +15,6 @@
 #include "main/imports.h"
 #include "main/image.h"
 #include "main/macros.h"
-#include "main/mfeatures.h"
 #include "program/program.h"
 #include "program/prog_print.h"
 
@@ -116,7 +115,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
    st_validate_state(st);
 
    /* determine if we need vertex color */
-   if (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL0)
+   if (ctx->FragmentProgram._Current->Base.InputsRead & VARYING_BIT_COL0)
       emitColor = GL_TRUE;
    else
       emitColor = GL_FALSE;
@@ -124,7 +123,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
    /* determine how many enabled sets of texcoords */
    numTexCoords = 0;
    for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-      if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) {
+      if (ctx->Texture.Unit[i]._Current &&
+          ctx->Texture.Unit[i]._Current->Target == GL_TEXTURE_2D) {
          numTexCoords++;
       }
    }
@@ -148,10 +148,9 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
       GLfloat *vbuf = NULL;
       GLuint attr;
 
-      u_upload_alloc(st->uploader, 0,
-                    numAttribs * 4 * 4 * sizeof(GLfloat),
-                    &offset, &vbuffer, (void**)&vbuf);
-      if (!vbuffer) {
+      if (u_upload_alloc(st->uploader, 0,
+                         numAttribs * 4 * 4 * sizeof(GLfloat),
+                         &offset, &vbuffer, (void **) &vbuf) != PIPE_OK) {
          return;
       }
       
@@ -194,7 +193,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
 
       /* texcoords */
       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-         if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) {
+         if (ctx->Texture.Unit[i]._Current &&
+             ctx->Texture.Unit[i]._Current->Target == GL_TEXTURE_2D) {
             struct gl_texture_object *obj = ctx->Texture.Unit[i]._Current;
             struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
             const GLfloat wt = (GLfloat) img->Width;
@@ -210,7 +210,9 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
             SET_ATTRIB(2, attr, s1, t1, 0.0f, 1.0f);  /* upper right */
             SET_ATTRIB(3, attr, s0, t1, 0.0f, 1.0f);  /* upper left */
 
-            semantic_names[attr] = TGSI_SEMANTIC_GENERIC;
+            semantic_names[attr] = st->needs_texcoord_semantic ?
+               TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC;
+            /* XXX: should this use semantic index i instead of 0 ? */
             semantic_indexes[attr] = 0;
 
             attr++;
@@ -244,7 +246,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
       velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
    }
    cso_set_vertex_elements(cso, numAttribs, velements);
-   cso_set_stream_outputs(st->cso_context, 0, NULL, 0);
+   cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
 
    /* viewport state: viewport matching window dims */
    {