st/nine: Allocate vs constbuf buffer for indirect addressing once.
authorAxel Davy <axel.davy@ens.fr>
Sat, 3 Jan 2015 10:29:40 +0000 (11:29 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 22 Jan 2015 22:16:24 +0000 (22:16 +0000)
When the shader does indirect addressing on the constants,
we allocate a temporary constant buffer to which we copy
the constants from the app given user constants and
the constants filled in the shader.

This patch makes this buffer be allocated once.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Tiziano Bacocco <tizbac2@gmail.com>
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
src/gallium/state_trackers/nine/device9.c
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h

index dae7bd45767ea5a41a5e22be061fcccae5c9bb35..ef3d2b0be581f5412fc875237262b8eaabbdaea3 100644 (file)
@@ -267,7 +267,9 @@ NineDevice9_ctor( struct NineDevice9 *This,
         /* Include space for I,B constants for user constbuf. */
         This->state.vs_const_f = CALLOC(This->vs_const_size, 1);
         This->state.ps_const_f = CALLOC(This->ps_const_size, 1);
-        if (!This->state.vs_const_f || !This->state.ps_const_f)
+        This->state.vs_lconstf_temp = CALLOC(This->vs_const_size,1);
+        if (!This->state.vs_const_f || !This->state.ps_const_f ||
+            !This->state.vs_lconstf_temp)
             return E_OUTOFMEMORY;
 
         if (strstr(pScreen->get_name(pScreen), "AMD") ||
@@ -347,6 +349,7 @@ NineDevice9_dtor( struct NineDevice9 *This )
     pipe_resource_reference(&This->constbuf_ps, NULL);
     FREE(This->state.vs_const_f);
     FREE(This->state.ps_const_f);
+    FREE(This->state.vs_lconstf_temp);
 
     if (This->swapchains) {
         for (i = 0; i < This->nswapchains; ++i)
index e019dfb0f411323f8fd25b625c4bbf4c81172df7..1187a20bdb37e45830f2495289a9c6d7a0c50ff5 100644 (file)
@@ -500,7 +500,7 @@ update_vs_constants_userbuf(struct NineDevice9 *device)
         const struct nine_lconstf *lconstf =  &device->state.vs->lconstf;
         const struct nine_range *r = lconstf->ranges;
         unsigned n = 0;
-        float *dst = (float *)MALLOC(cb.buffer_size);
+        float *dst = device->state.vs_lconstf_temp;
         float *src = (float *)cb.user_buffer;
         memcpy(dst, src, cb.buffer_size);
         while (r) {
@@ -515,9 +515,6 @@ update_vs_constants_userbuf(struct NineDevice9 *device)
 
     pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &cb);
 
-    if (device->state.vs->lconstf.ranges)
-        FREE((void *)cb.user_buffer);
-
     if (device->state.changed.vs_const_f) {
         struct nine_range *r = device->state.changed.vs_const_f;
         struct nine_range *p = r;
index 742c6f67425b4ba925a50ea133ad6973e54fa764..58ca8c9f63565b13b34716102ccd54bf3b96067b 100644 (file)
@@ -144,6 +144,7 @@ struct nine_state
     float *vs_const_f;
     int    vs_const_i[NINE_MAX_CONST_I][4];
     BOOL   vs_const_b[NINE_MAX_CONST_B];
+    float *vs_lconstf_temp;
     uint32_t vs_key;
 
     struct NinePixelShader9 *ps;