nir: improvements to native_integers removal
[mesa.git] / src / mesa / program / program.c
index faf5b7fa28accfba0354232369ccebb30680d147..6ab1bf50177b9919035740d622ac347cdc9fb381 100644 (file)
@@ -39,6 +39,7 @@
 #include "prog_cache.h"
 #include "prog_parameter.h"
 #include "prog_instruction.h"
+#include "util/bitscan.h"
 #include "util/ralloc.h"
 #include "util/u_atomic.h"
 
@@ -99,6 +100,7 @@ _mesa_init_program(struct gl_context *ctx)
                            ctx->Shared->DefaultFragmentProgram);
    assert(ctx->FragmentProgram.Current);
    ctx->FragmentProgram.Cache = _mesa_new_program_cache();
+   ctx->VertexProgram._VPMode = VP_MODE_FF;
 
    /* XXX probably move this stuff */
    ctx->ATIFragmentShader.Enabled = GL_FALSE;
@@ -514,8 +516,7 @@ _mesa_find_free_register(const GLboolean used[],
  */
 GLint
 _mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
-                                       const struct gl_program *prog,
-                                       bool ignore_sample_qualifier)
+                                       const struct gl_program *prog)
 {
    /* From ARB_sample_shading specification:
     * "Using gl_SampleID in a fragment shader causes the entire shader
@@ -533,11 +534,9 @@ _mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
        * "Use of the "sample" qualifier on a fragment shader input
        *  forces per-sample shading"
        */
-      if (prog->info.fs.uses_sample_qualifier && !ignore_sample_qualifier)
-         return MAX2(_mesa_geometric_samples(ctx->DrawBuffer), 1);
-
-      if (prog->info.system_values_read & (SYSTEM_BIT_SAMPLE_ID |
-                                           SYSTEM_BIT_SAMPLE_POS))
+      if (prog->info.fs.uses_sample_qualifier ||
+          (prog->info.system_values_read & (SYSTEM_BIT_SAMPLE_ID |
+                                            SYSTEM_BIT_SAMPLE_POS)))
          return MAX2(_mesa_geometric_samples(ctx->DrawBuffer), 1);
       else if (ctx->Multisample.SampleShading)
          return MAX2(ceil(ctx->Multisample.MinSampleShadingValue *
@@ -547,3 +546,19 @@ _mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
    }
    return 1;
 }
+
+
+GLbitfield
+gl_external_samplers(const struct gl_program *prog)
+{
+   GLbitfield external_samplers = 0;
+   GLbitfield mask = prog->SamplersUsed;
+
+   while (mask) {
+      int idx = u_bit_scan(&mask);
+      if (prog->sh.SamplerTargets[idx] == TEXTURE_EXTERNAL_INDEX)
+         external_samplers |= (1 << idx);
+   }
+
+   return external_samplers;
+}