vk/compiler: mark inputs/outputs as read/written
authorConnor Abbott <connor.w.abbott@intel.com>
Thu, 9 Jul 2015 01:47:43 +0000 (21:47 -0400)
committerConnor Abbott <connor.w.abbott@intel.com>
Thu, 9 Jul 2015 02:03:30 +0000 (22:03 -0400)
This doesn't handle inputs and outputs larger than a vec4, but we plan
to add a varyiing splitting/packing pass to handle those anyways.

src/vulkan/compiler.cpp

index fb9615306e670e7b1f018dae6d1514c073ea0dcd..0a8ec87415fa07f98dc98bc0efd980d4a02a9415 100644 (file)
@@ -950,6 +950,23 @@ anv_compile_shader_glsl(struct anv_compiler *compiler,
    program->NumShaders++;
 }
 
+static void
+setup_nir_io(struct gl_program *prog,
+             nir_shader *shader)
+{
+   foreach_list_typed(nir_variable, var, node, &shader->inputs) {
+      prog->InputsRead |= BITFIELD64_BIT(var->data.location);
+   }
+
+   foreach_list_typed(nir_variable, var, node, &shader->outputs) {
+      /* XXX glslang gives us this but we never use it */
+      if (!strcmp(var->name, "gl_PerVertex"))
+         continue;
+
+      prog->OutputsWritten |= BITFIELD64_BIT(var->data.location);
+   }
+}
+
 static void
 anv_compile_shader_spirv(struct anv_compiler *compiler,
                          struct gl_shader_program *program,
@@ -982,6 +999,8 @@ anv_compile_shader_spirv(struct anv_compiler *compiler,
                    compiler->screen->devinfo,
                    NULL, mesa_shader->Stage);
 
+   setup_nir_io(mesa_shader->Program, mesa_shader->Program->nir);
+
    fail_if(mesa_shader->Program->nir == NULL,
            "failed to translate SPIR-V to NIR\n");