i965/fs: Implement texelFetch() on Ironlake and Sandybridge.
[mesa.git] / src / mesa / program / sampler.cpp
index 0e58aef9c95db836c0d60ea1432d39b3bd5842a3..e8d34c670a965e09c67b419d81932006f654bc44 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include <stdio.h>
+#include "ir.h"
+#include "glsl_types.h"
+#include "ir_visitor.h"
 
 extern "C" {
 #include "main/compiler.h"
 #include "main/mtypes.h"
 #include "program/prog_parameter.h"
-#include "ir.h"
-#include "ir_visitor.h"
-#include "glsl_types.h"
 }
 
 static void fail_link(struct gl_shader_program *prog, const char *fmt, ...) PRINTFLIKE(2, 3);
@@ -40,7 +39,7 @@ static void fail_link(struct gl_shader_program *prog, const char *fmt, ...)
 {
    va_list args;
    va_start(args, fmt);
-   prog->InfoLog = talloc_vasprintf_append(prog->InfoLog, fmt, args);
+   ralloc_vasprintf_append(&prog->InfoLog, fmt, args);
    va_end(args);
 
    prog->LinkStatus = GL_FALSE;
@@ -52,7 +51,7 @@ public:
    get_sampler_name(ir_dereference *last,
                    struct gl_shader_program *shader_program)
    {
-      this->mem_ctx = talloc_new(NULL);
+      this->mem_ctx = ralloc_context(NULL);
       this->shader_program = shader_program;
       this->name = NULL;
       this->offset = 0;
@@ -61,7 +60,7 @@ public:
 
    ~get_sampler_name()
    {
-      talloc_free(this->mem_ctx);
+      ralloc_free(this->mem_ctx);
    }
 
    virtual ir_visitor_status visit(ir_dereference_variable *ir)
@@ -72,7 +71,7 @@ public:
 
    virtual ir_visitor_status visit_leave(ir_dereference_record *ir)
    {
-      this->name = talloc_asprintf(mem_ctx, "%s.%s", name, ir->field);
+      this->name = ralloc_asprintf(mem_ctx, "%s.%s", name, ir->field);
       return visit_continue;
    }
 
@@ -91,16 +90,14 @@ public:
          * all that would work would be an unrolled loop counter that ends
          * up being constant above.
          */
-        shader_program->InfoLog =
-           talloc_asprintf_append(shader_program->InfoLog,
-                                  "warning: Variable sampler array index "
-                                  "unsupported.\nThis feature of the language "
-                                  "was removed in GLSL 1.20 and is unlikely "
-                                  "to be supported for 1.10 in Mesa.\n");
+        ralloc_strcat(&shader_program->InfoLog,
+                      "warning: Variable sampler array index unsupported.\n"
+                      "This feature of the language was removed in GLSL 1.20 "
+                      "and is unlikely to be supported for 1.10 in Mesa.\n");
         i = 0;
       }
       if (ir != last) {
-        this->name = talloc_asprintf(mem_ctx, "%s[%d]", name, i);
+        this->name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
       } else {
         offset = i;
       }
@@ -135,6 +132,6 @@ _mesa_get_sampler_uniform_value(class ir_dereference *sampler,
 
    index += getname.offset;
 
-   return prog->Parameters->ParameterValues[index][0];
+   return prog->Parameters->ParameterValues[index][0].f;
 }
 }