radeonsi: implement TC L2 write-back (flush) without cache invalidation
[mesa.git] / src / gallium / drivers / swr / swr_state.h
index a2b4d808aa3534d24a3597d14aadb80e506c0d39..0e3b49d2b0d330476e85349d246e30d598aa33dd 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 */
@@ -73,10 +87,10 @@ struct swr_blend_state {
 struct swr_derived_state {
    SWR_RASTSTATE rastState;
    SWR_VIEWPORT vp;
-   SWR_VIEWPORT_MATRIX vpm;
+   SWR_VIEWPORT_MATRICES vpm;
 };
 
-void swr_update_derived(struct swr_context *,
+void swr_update_derived(struct pipe_context *,
                         const struct pipe_draw_info * = nullptr);
 
 /*