st/nine: Propagate const_range to context
authorAxel Davy <davyaxel0@gmail.com>
Mon, 21 Jan 2019 21:40:25 +0000 (22:40 +0100)
committerAxel Davy <davyaxel0@gmail.com>
Tue, 30 Apr 2019 17:18:52 +0000 (19:18 +0200)
As with the constant compaction we map the constant
slots to new slots, we need to pass that information
to the context which is in charge of uploading
the constants.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
src/gallium/state_trackers/nine/nine_shader.h
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h
src/gallium/state_trackers/nine/pixelshader9.c
src/gallium/state_trackers/nine/pixelshader9.h
src/gallium/state_trackers/nine/vertexshader9.c
src/gallium/state_trackers/nine/vertexshader9.h

index 6eb9712..aa0c0ab 100644 (file)
@@ -118,22 +118,25 @@ struct nine_shader_variant
 {
     struct nine_shader_variant *next;
     void *cso;
+    unsigned *const_ranges;
     uint64_t key;
 };
 
 static inline void *
-nine_shader_variant_get(struct nine_shader_variant *list, uint64_t key)
+nine_shader_variant_get(struct nine_shader_variant *list, unsigned **const_ranges, uint64_t key)
 {
     while (list->key != key && list->next)
         list = list->next;
-    if (list->key == key)
+    if (list->key == key) {
+        *const_ranges = list->const_ranges;
         return list->cso;
+    }
     return NULL;
 }
 
 static inline boolean
 nine_shader_variant_add(struct nine_shader_variant *list,
-                          uint64_t key, void *cso)
+                          uint64_t key, void *cso, unsigned *const_ranges)
 {
     while (list->next) {
         assert(list->key != key);
@@ -145,6 +148,7 @@ nine_shader_variant_add(struct nine_shader_variant *list,
     list->next->next = NULL;
     list->next->key = key;
     list->next->cso = cso;
+    list->next->const_ranges = const_ranges;
     return TRUE;
 }
 
index 76c25c8..6440cf4 100644 (file)
@@ -603,7 +603,7 @@ prepare_vs(struct NineDevice9 *device, uint8_t shader_changed)
 
     /* likely because we dislike FF */
     if (likely(context->programmable_vs)) {
-        context->cso_shader.vs = NineVertexShader9_GetVariant(vs);
+        context->cso_shader.vs = NineVertexShader9_GetVariant(vs, &context->cso_shader.vs_const_ranges);
     } else {
         vs = device->ff.vs;
         context->cso_shader.vs = vs->ff_cso;
@@ -637,7 +637,7 @@ prepare_ps(struct NineDevice9 *device, uint8_t shader_changed)
         return 0;
 
     if (likely(ps)) {
-        context->cso_shader.ps = NinePixelShader9_GetVariant(ps);
+        context->cso_shader.ps = NinePixelShader9_GetVariant(ps, &context->cso_shader.ps_const_ranges);
     } else {
         ps = device->ff.ps;
         context->cso_shader.ps = ps->ff_cso;
index 376dc56..37238b8 100644 (file)
@@ -239,7 +239,9 @@ struct nine_context {
 
     struct {
         void *vs;
+        unsigned *vs_const_ranges;
         void *ps;
+        unsigned *ps_const_ranges;
     } cso_shader;
 
     struct pipe_context *pipe;
index f4b28e8..42ad2c7 100644 (file)
@@ -79,7 +79,9 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
     This->byte_code.size = info.byte_size;
 
     This->variant.cso = info.cso;
+    This->variant.const_ranges = info.const_ranges;
     This->last_cso = info.cso;
+    This->last_const_ranges = info.const_ranges;
     This->last_key = 0;
 
     This->sampler_mask = info.sampler_mask;
@@ -116,6 +118,7 @@ NinePixelShader9_dtor( struct NinePixelShader9 *This )
                 if (This->base.device->context.cso_shader.ps == var->cso)
                     pipe->bind_fs_state(pipe, NULL);
                 pipe->delete_fs_state(pipe, var->cso);
+                FREE(var->const_ranges);
             }
             var = var->next;
         } while (var);
@@ -156,7 +159,7 @@ NinePixelShader9_GetFunction( struct NinePixelShader9 *This,
 }
 
 void *
-NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
+NinePixelShader9_GetVariant( struct NinePixelShader9 *This, unsigned **const_ranges )
 {
     /* GetVariant is called from nine_context, thus we can
      * get pipe directly */
@@ -165,10 +168,12 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
     uint64_t key;
 
     key = This->next_key;
-    if (key == This->last_key)
+    if (key == This->last_key) {
+        *const_ranges = This->last_const_ranges;
         return This->last_cso;
+    }
 
-    cso = nine_shader_variant_get(&This->variant, key);
+    cso = nine_shader_variant_get(&This->variant, const_ranges, key);
     if (!cso) {
         struct NineDevice9 *device = This->base.device;
         struct nine_shader_info info;
@@ -205,12 +210,14 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
         hr = nine_translate_shader(This->base.device, &info, pipe);
         if (FAILED(hr))
             return NULL;
-        nine_shader_variant_add(&This->variant, key, info.cso);
+        nine_shader_variant_add(&This->variant, key, info.cso, info.const_ranges);
         cso = info.cso;
+        *const_ranges = info.const_ranges;
     }
 
     This->last_key = key;
     This->last_cso = cso;
+    This->last_const_ranges = *const_ranges;
 
     return cso;
 }
index d864eca..62b5abb 100644 (file)
@@ -62,6 +62,7 @@ struct NinePixelShader9
 
     uint64_t last_key;
     void *last_cso;
+    unsigned *last_const_ranges;
 
     uint64_t next_key;
 };
@@ -131,7 +132,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
 }
 
 void *
-NinePixelShader9_GetVariant( struct NinePixelShader9 *ps );
+NinePixelShader9_GetVariant( struct NinePixelShader9 *ps, unsigned **const_ranges );
 
 /*** public ***/
 
index cffe850..d14b970 100644 (file)
@@ -94,7 +94,9 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
     This->byte_code.size = info.byte_size;
 
     This->variant.cso = info.cso;
+    This->variant.const_ranges = info.const_ranges;
     This->last_cso = info.cso;
+    This->last_const_ranges = info.const_ranges;
     This->last_key = (uint32_t) (info.swvp_on << 9);
 
     This->const_used_size = info.const_used_size;
@@ -133,6 +135,7 @@ NineVertexShader9_dtor( struct NineVertexShader9 *This )
                 if (This->base.device->context.cso_shader.vs == var->cso)
                     pipe->bind_vs_state(pipe, NULL);
                 pipe->delete_vs_state(pipe, var->cso);
+                FREE(var->const_ranges);
             }
             var = var->next;
         } while (var);
@@ -182,7 +185,7 @@ NineVertexShader9_GetFunction( struct NineVertexShader9 *This,
 }
 
 void *
-NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
+NineVertexShader9_GetVariant( struct NineVertexShader9 *This, unsigned **const_ranges )
 {
     /* GetVariant is called from nine_context, thus we can
      * get pipe directly */
@@ -191,10 +194,12 @@ NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
     uint64_t key;
 
     key = This->next_key;
-    if (key == This->last_key)
+    if (key == This->last_key) {
+        *const_ranges = This->last_const_ranges;
         return This->last_cso;
+    }
 
-    cso = nine_shader_variant_get(&This->variant, key);
+    cso = nine_shader_variant_get(&This->variant, const_ranges, key);
     if (!cso) {
         struct NineDevice9 *device = This->base.device;
         struct nine_shader_info info;
@@ -218,12 +223,14 @@ NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
         hr = nine_translate_shader(This->base.device, &info, pipe);
         if (FAILED(hr))
             return NULL;
-        nine_shader_variant_add(&This->variant, key, info.cso);
+        nine_shader_variant_add(&This->variant, key, info.cso, info.const_ranges);
         cso = info.cso;
+        *const_ranges = info.const_ranges;
     }
 
     This->last_key = key;
     This->last_cso = cso;
+    This->last_const_ranges = *const_ranges;
 
     return cso;
 }
index 766b2fd..0b139c5 100644 (file)
@@ -72,6 +72,7 @@ struct NineVertexShader9
 
     uint64_t last_key;
     void *last_cso;
+    unsigned *last_const_ranges;
 
     uint64_t next_key;
 
@@ -123,7 +124,7 @@ NineVertexShader9_UpdateKey( struct NineVertexShader9 *vs,
 }
 
 void *
-NineVertexShader9_GetVariant( struct NineVertexShader9 *vs );
+NineVertexShader9_GetVariant( struct NineVertexShader9 *vs, unsigned **const_ranges );
 
 void *
 NineVertexShader9_GetVariantProcessVertices( struct NineVertexShader9 *vs,