i965/fs: Use VARYING_SLOT checks rather than strcmp().
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 31 Jan 2015 12:31:16 +0000 (04:31 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 19 Feb 2015 23:15:45 +0000 (15:15 -0800)
Comparing the location field is equivalent and more efficient.

We'll also need this when we start using NIR for ARB programs, as our
NIR converter will set the location field correctly, but probably won't
use the GLSL names for these concepts.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index 850f132d757724aa597e7400a2f0b71d10765250..21238296d50c9292466892c79b47278c5a9a4228 100644 (file)
@@ -195,7 +195,7 @@ fs_visitor::nir_setup_inputs(nir_shader *shader)
       fs_reg varying = offset(nir_inputs, var->data.driver_location);
 
       fs_reg reg;
-      if (!strcmp(var->name, "gl_FragCoord")) {
+      if (var->data.location == VARYING_SLOT_POS) {
          reg = *emit_fragcoord_interpolation(var->data.pixel_center_integer,
                                              var->data.origin_upper_left);
          emit_percomp(MOV(varying, reg), 0xF);
index a2343c6b86fd5052b64dc7c0840bc525c4f77ba0..04e0f9a4782f8a9f44a2723319d9be2f3456cc8b 100644 (file)
@@ -92,10 +92,10 @@ fs_visitor::visit(ir_variable *ir)
          reg = new(this->mem_ctx)
             fs_reg(ATTR, ir->data.location,
                    brw_type_for_base_type(ir->type->get_scalar_type()));
-      } else if (!strcmp(ir->name, "gl_FragCoord")) {
+      } else if (ir->data.location == VARYING_SLOT_POS) {
          reg = emit_fragcoord_interpolation(ir->data.pixel_center_integer,
                                             ir->data.origin_upper_left);
-      } else if (!strcmp(ir->name, "gl_FrontFacing")) {
+      } else if (ir->data.location == VARYING_SLOT_FACE) {
         reg = emit_frontfacing_interpolation();
       } else {
          reg = new(this->mem_ctx) fs_reg(vgrf(ir->type));