/** * Compile the vertex shader. */ struct ilo_shader * ilo_shader_compile_vs(const struct ilo_shader_state *state, const struct ilo_shader_variant *variant) { struct vs_compile_context vcc; bool need_gs; if (!vs_setup(&vcc, state, variant)) return NULL; if (ilo_dev_gen(vcc.tc.dev) >= ILO_GEN(7)) { need_gs = false; } else { need_gs = variant->u.vs.rasterizer_discard || state->info.stream_output.num_outputs; } vs_write_vue(&vcc); if (!vs_compile(&vcc)) { FREE(vcc.shader); vcc.shader = NULL; } toy_tgsi_cleanup(&vcc.tgsi); toy_compiler_cleanup(&vcc.tc); if (need_gs) { int so_mapping[PIPE_MAX_SHADER_OUTPUTS]; int i, j; for (i = 0; i < vcc.tgsi.num_outputs; i++) { int attr = 0; for (j = 0; j < vcc.shader->out.count; j++) { if (vcc.tgsi.outputs[i].semantic_name == vcc.shader->out.semantic_names[j] && vcc.tgsi.outputs[i].semantic_index == vcc.shader->out.semantic_indices[j]) { attr = j; break; } } so_mapping[i] = attr; } if (!ilo_shader_compile_gs_passthrough(state, variant, so_mapping, vcc.shader)) { ilo_shader_destroy_kernel(vcc.shader); vcc.shader = NULL; } } return vcc.shader; }
/** * Compile the geometry shader. */ struct ilo_shader * ilo_shader_compile_gs(const struct ilo_shader_state *state, const struct ilo_shader_variant *variant) { struct gs_compile_context gcc; if (!gs_setup(&gcc, state, variant, 0)) return NULL; if (!gs_compile(&gcc)) { FREE(gcc.shader); gcc.shader = NULL; } toy_tgsi_cleanup(&gcc.tgsi); toy_compiler_cleanup(&gcc.tc); return gcc.shader;; }
/** * Compile the fragment shader. */ struct ilo_shader * ilo_shader_compile_fs(const struct ilo_shader_state *state, const struct ilo_shader_variant *variant) { struct fs_compile_context fcc; if (!fs_setup(&fcc, state, variant)) return NULL; fs_write_fb(&fcc); if (!fs_compile(&fcc)) { FREE(fcc.shader); fcc.shader = NULL; } toy_tgsi_cleanup(&fcc.tgsi); toy_compiler_cleanup(&fcc.tc); return fcc.shader; }