st/nine: Handle const_ranges in nine_state
authorAxel Davy <davyaxel0@gmail.com>
Mon, 21 Jan 2019 21:50:01 +0000 (22:50 +0100)
committerAxel Davy <davyaxel0@gmail.com>
Tue, 30 Apr 2019 17:18:52 +0000 (19:18 +0200)
Handle slot mapping if there is one.

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

index 7de5fc9a4c6e0ecc2c34e5e8ef1054b6eb89f6e9..43675716a5ec81977b16d383a1b5c26bd5ceb351 100644 (file)
@@ -495,7 +495,19 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device)
 
     assert(cb.buffer && upload_ptr);
 
-    memcpy(upload_ptr, cb.user_buffer, cb.buffer_size);
+    if (!context->cso_shader.vs_const_ranges) {
+        memcpy(upload_ptr, cb.user_buffer, cb.buffer_size);
+    } else {
+        unsigned i = 0;
+        unsigned offset = 0;
+        while (context->cso_shader.vs_const_ranges[i*2+1] != 0) {
+            memcpy(upload_ptr+offset,
+                   &((float*)cb.user_buffer)[4*context->cso_shader.vs_const_ranges[i*2]],
+                   context->cso_shader.vs_const_ranges[i*2+1] * sizeof(float[4]));
+            offset += context->cso_shader.vs_const_ranges[i*2+1] * sizeof(float[4]);
+            i++;
+        }
+    }
 
     u_upload_unmap(context->pipe->const_uploader);
     cb.user_buffer = NULL;
@@ -571,7 +583,19 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device)
 
     assert(cb.buffer && upload_ptr);
 
-    memcpy(upload_ptr, cb.user_buffer, cb.buffer_size);
+    if (!context->cso_shader.ps_const_ranges) {
+        memcpy(upload_ptr, cb.user_buffer, cb.buffer_size);
+    } else {
+        unsigned i = 0;
+        unsigned offset = 0;
+        while (context->cso_shader.ps_const_ranges[i*2+1] != 0) {
+            memcpy(upload_ptr+offset,
+                   &((float*)cb.user_buffer)[4*context->cso_shader.ps_const_ranges[i*2]],
+                   context->cso_shader.ps_const_ranges[i*2+1] * sizeof(float[4]));
+            offset += context->cso_shader.ps_const_ranges[i*2+1] * sizeof(float[4]);
+            i++;
+        }
+    }
 
     u_upload_unmap(context->pipe->const_uploader);
     cb.user_buffer = NULL;