Merge remote-tracking branch 'mesa-public/master' into vulkan
[mesa.git] / src / gallium / state_trackers / nine / nine_shader.h
index 218240864902806453721b2d025fc7739af85c0e..1fe0c4bd182aef8761c29db52ed7e99a17c56c79 100644 (file)
@@ -48,7 +48,7 @@ struct nine_shader_info
 
     void *cso; /* out, pipe cso for bind_vs,fs_state */
 
-    uint8_t input_map[PIPE_MAX_ATTRIBS]; /* VS input -> NINE_DECLUSAGE_x */
+    uint16_t input_map[PIPE_MAX_ATTRIBS]; /* VS input -> NINE_DECLUSAGE_x */
     uint8_t num_inputs; /* there may be unused inputs (NINE_DECLUSAGE_NONE) */
 
     boolean position_t; /* out, true if VP writes pre-transformed position */
@@ -59,36 +59,40 @@ struct nine_shader_info
     uint16_t sampler_mask_shadow; /* in, which samplers use depth compare */
     uint8_t rt_mask; /* out, which render targets are being written */
 
+    uint8_t fog_enable;
+    uint8_t fog_mode;
+    uint8_t force_color_in_centroid;
+    uint16_t projected; /* ps 1.1 to 1.3 */
+
     unsigned const_i_base; /* in vec4 (16 byte) units */
     unsigned const_b_base; /* in vec4 (16 byte) units */
     unsigned const_used_size;
 
+    unsigned const_float_slots;
+    unsigned const_int_slots;
+    unsigned const_bool_slots;
+
     struct nine_lconstf lconstf; /* out, NOTE: members to be free'd by user */
+    uint8_t bumpenvmat_needed;
 };
 
-static INLINE void
+static inline void
 nine_info_mark_const_f_used(struct nine_shader_info *info, int idx)
 {
-    unsigned size = (idx + 1) * 16;
-
-    if (info->const_used_size < size)
-        info->const_used_size = size;
+    if (info->const_float_slots < (idx + 1))
+        info->const_float_slots = idx + 1;
 }
-static INLINE void
+static inline void
 nine_info_mark_const_i_used(struct nine_shader_info *info, int idx)
 {
-    unsigned size = (info->const_i_base + (idx + 1)) * 16;
-
-    if (info->const_used_size < size)
-        info->const_used_size = size;
+    if (info->const_int_slots < (idx + 1))
+        info->const_int_slots = idx + 1;
 }
-static INLINE void
+static inline void
 nine_info_mark_const_b_used(struct nine_shader_info *info, int idx)
 {
-    unsigned size = (info->const_b_base + ((idx + 4) / 4)) * 16;
-
-    if (info->const_used_size < size)
-        info->const_used_size = size;
+    if (info->const_bool_slots < (idx + 1))
+        info->const_bool_slots = idx + 1;
 }
 
 HRESULT
@@ -102,7 +106,7 @@ struct nine_shader_variant
     uint32_t key;
 };
 
-static INLINE void *
+static inline void *
 nine_shader_variant_get(struct nine_shader_variant *list, uint32_t key)
 {
     while (list->key != key && list->next)
@@ -112,7 +116,7 @@ nine_shader_variant_get(struct nine_shader_variant *list, uint32_t key)
     return NULL;
 }
 
-static INLINE boolean
+static inline boolean
 nine_shader_variant_add(struct nine_shader_variant *list,
                         uint32_t key, void *cso)
 {
@@ -129,7 +133,7 @@ nine_shader_variant_add(struct nine_shader_variant *list,
     return TRUE;
 }
 
-static INLINE void
+static inline void
 nine_shader_variants_free(struct nine_shader_variant *list)
 {
     while (list->next) {
@@ -139,4 +143,48 @@ nine_shader_variants_free(struct nine_shader_variant *list)
     }
 }
 
+struct nine_shader_variant64
+{
+    struct nine_shader_variant64 *next;
+    void *cso;
+    uint64_t key;
+};
+
+static inline void *
+nine_shader_variant_get64(struct nine_shader_variant64 *list, uint64_t key)
+{
+    while (list->key != key && list->next)
+        list = list->next;
+    if (list->key == key)
+        return list->cso;
+    return NULL;
+}
+
+static inline boolean
+nine_shader_variant_add64(struct nine_shader_variant64 *list,
+                          uint64_t key, void *cso)
+{
+    while (list->next) {
+        assert(list->key != key);
+        list = list->next;
+    }
+    list->next = MALLOC_STRUCT(nine_shader_variant64);
+    if (!list->next)
+        return FALSE;
+    list->next->next = NULL;
+    list->next->key = key;
+    list->next->cso = cso;
+    return TRUE;
+}
+
+static inline void
+nine_shader_variants_free64(struct nine_shader_variant64 *list)
+{
+    while (list->next) {
+        struct nine_shader_variant64 *ptr = list->next;
+        list->next = ptr->next;
+        FREE(ptr);
+    }
+}
+
 #endif /* _NINE_SHADER_H_ */