mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.
[mesa.git] / src / glsl / ir_reader.cpp
index 4dec4e87e581cfb1d1f0ca4ed27b39a1815d097c..16fdc41b456ba223ce51fc29ce9608808c81d94d 100644 (file)
@@ -911,22 +911,31 @@ ir_reader::read_texture(s_expression *expr)
    s_expression *s_proj = NULL;
    s_list *s_shadow = NULL;
    s_expression *s_lod = NULL;
+   s_expression *s_sample_index = NULL;
 
    ir_texture_opcode op = ir_tex; /* silence warning */
 
    s_pattern tex_pattern[] =
       { "tex", s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow };
+   s_pattern lod_pattern[] =
+      { "lod", s_type, s_sampler, s_coord };
    s_pattern txf_pattern[] =
       { "txf", s_type, s_sampler, s_coord, s_offset, s_lod };
+   s_pattern txf_ms_pattern[] =
+      { "txf_ms", s_type, s_sampler, s_coord, s_sample_index };
    s_pattern txs_pattern[] =
       { "txs", s_type, s_sampler, s_lod };
    s_pattern other_pattern[] =
       { tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod };
 
-   if (MATCH(expr, tex_pattern)) {
+   if (MATCH(expr, lod_pattern)) {
+      op = ir_lod;
+   } else if (MATCH(expr, tex_pattern)) {
       op = ir_tex;
    } else if (MATCH(expr, txf_pattern)) {
       op = ir_txf;
+   } else if (MATCH(expr, txf_ms_pattern)) {
+      op = ir_txf_ms;
    } else if (MATCH(expr, txs_pattern)) {
       op = ir_txs;
    } else if (MATCH(expr, other_pattern)) {
@@ -934,7 +943,7 @@ ir_reader::read_texture(s_expression *expr)
       if (op == -1)
         return NULL;
    } else {
-      ir_read_error(NULL, "unexpected texture pattern");
+      ir_read_error(NULL, "unexpected texture pattern %s", tag->value());
       return NULL;
    }
 
@@ -966,18 +975,20 @@ ir_reader::read_texture(s_expression *expr)
         return NULL;
       }
 
-      // Read texel offset - either 0 or an rvalue.
-      s_int *si_offset = SX_AS_INT(s_offset);
-      if (si_offset == NULL || si_offset->value() != 0) {
-        tex->offset = read_rvalue(s_offset);
-        if (tex->offset == NULL) {
-           ir_read_error(s_offset, "expected 0 or an expression");
-           return NULL;
-        }
+      if (op != ir_txf_ms && op != ir_lod) {
+         // Read texel offset - either 0 or an rvalue.
+         s_int *si_offset = SX_AS_INT(s_offset);
+         if (si_offset == NULL || si_offset->value() != 0) {
+            tex->offset = read_rvalue(s_offset);
+            if (tex->offset == NULL) {
+               ir_read_error(s_offset, "expected 0 or an expression");
+               return NULL;
+            }
+         }
       }
    }
 
-   if (op != ir_txf && op != ir_txs) {
+   if (op != ir_txf && op != ir_txf_ms && op != ir_txs && op != ir_lod) {
       s_int *proj_as_int = SX_AS_INT(s_proj);
       if (proj_as_int && proj_as_int->value() == 1) {
         tex->projector = NULL;
@@ -1020,6 +1031,13 @@ ir_reader::read_texture(s_expression *expr)
         return NULL;
       }
       break;
+   case ir_txf_ms:
+      tex->lod_info.sample_index = read_rvalue(s_sample_index);
+      if (tex->lod_info.sample_index == NULL) {
+         ir_read_error(NULL, "when reading sample_index in (txf_ms ...)");
+         return NULL;
+      }
+      break;
    case ir_txd: {
       s_expression *s_dx, *s_dy;
       s_pattern dxdy_pat[] = { s_dx, s_dy };
@@ -1040,7 +1058,7 @@ ir_reader::read_texture(s_expression *expr)
       break;
    }
    default:
-      // tex doesn't have any extra parameters.
+      // tex and lod don't have any extra parameters.
       break;
    };
    return tex;