radeonsi: implement TC L2 write-back (flush) without cache invalidation
[mesa.git] / src / gallium / drivers / swr / swr_state.h
index 32a5441295bfabd7aa25a3ffacf859ef4ae574fd..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;
-   std::unordered_map<swr_jit_vs_key, PFN_VERTEX_FUNC> map;
+   std::unordered_map<swr_jit_vs_key, std::unique_ptr<VariantVS>> map;
    SWR_STREAMOUT_STATE soState;
    PFN_SO_FUNC soFunc[PIPE_PRIM_MAX] {0};
 };
@@ -49,8 +62,9 @@ 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_fs_key, PFN_PIXEL_KERNEL> map;
+   std::unordered_map<swr_jit_fs_key, std::unique_ptr<VariantFS>> map;
 };
 
 /* Vertex element state */
@@ -73,7 +87,7 @@ 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 pipe_context *,