swr: [rasterizer jitter] fetch support for offsetting VertexID
[mesa.git] / src / gallium / drivers / swr / swr_state.h
index f0a7ff3b185321929189b9b5d92da162e256d7a8..dcb1145a3626aa56a0aa551e6718980076afd816 100644 (file)
 #include "tgsi/tgsi_scan.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_dump.h"
+#include "gallivm/lp_bld_init.h"
 #include "gallivm/lp_bld_tgsi.h"
 #include "util/u_hash.h"
 #include "api.h"
 #include "swr_tex_sample.h"
 #include "swr_shader.h"
 #include <unordered_map>
+#include <memory>
+
+template <typename T>
+struct ShaderVariant {
+   struct gallivm_state *gallivm;
+   T shader;
+
+   ShaderVariant(struct gallivm_state *gs, T code) : gallivm(gs), shader(code) {}
+   ~ShaderVariant() { gallivm_destroy(gallivm); }
+};
+
+typedef ShaderVariant<PFN_VERTEX_FUNC> VariantVS;
+typedef ShaderVariant<PFN_PIXEL_KERNEL> VariantFS;
 
 /* skeleton */
 struct swr_vertex_shader {
    struct pipe_shader_state pipe;
    struct lp_tgsi_info info;
-   unsigned linkageMask;
-   PFN_VERTEX_FUNC func;
+   std::unordered_map<swr_jit_vs_key, std::unique_ptr<VariantVS>> map;
    SWR_STREAMOUT_STATE soState;
-   PFN_SO_FUNC soFunc[PIPE_PRIM_MAX];
+   PFN_SO_FUNC soFunc[PIPE_PRIM_MAX] {0};
 };
 
 struct swr_fragment_shader {
    struct pipe_shader_state pipe;
    struct lp_tgsi_info info;
    uint32_t constantMask;
+   uint32_t flatConstantMask;
    uint32_t pointSpriteMask;
-   std::unordered_map<swr_jit_key, PFN_PIXEL_KERNEL> map;
+   std::unordered_map<swr_jit_fs_key, std::unique_ptr<VariantFS>> map;
 };
 
 /* Vertex element state */