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 6eb97127b9cb1db13d8d20c497a23cc7c0f4d8ef..aa0c0ab1f7a0d7531ddb6f9966e75261a27eb2fd 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 76c25c8831a42097b6ea8c09d00dc3dcacd1cf8c..6440cf46c93fc7d617731867c4058b9e126b6f5d 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 376dc5616977a5ffe5eaebca714c31ef063e551f..37238b8593632ad535634392f8f50acc67e821fc 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 f4b28e8d03949f93e8efaa86aa0d928eef4a7997..42ad2c76a7f9b315104539fd9226fe0cb7f4f9b8 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 d864eca15a473aeeac4edeed61d86797b3432ed5..62b5abb596254398e4a5e0650ca58f9545d2bcfd 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 cffe850167796f679fbf1e52e160d463fbe701fd..d14b9702a187d595519fc65e0c989b4c35579259 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 766b2fd13eadcc1b212bbae54737dc3353829360..0b139c5dad1408a78d4d39b53c9f43491cbfb68e 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,