summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2019-01-20 20:44:17 +0100
committerAxel Davy <[email protected]>2019-04-30 19:18:51 +0200
commit6d86292f8acd96c3ac4f6e7c52c9f66475953790 (patch)
tree4a083834e92b51634ba0ba11c96fac7266b086b0 /src
parent1ddeb43537f2f1d702372b65aa8bf83b83f10ba8 (diff)
st/nine: Manually upload vs and ps constants
In future commits we will introduce more fine-grained uploads Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/nine/nine_state.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 475925ffda9..76c25c8831a 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -433,6 +433,7 @@ static void
prepare_vs_constants_userbuf(struct NineDevice9 *device)
{
struct nine_context *context = &device->context;
+ uint8_t *upload_ptr = NULL;
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
@@ -478,6 +479,30 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device)
cb.user_buffer = dst;
}
+ /* Note: We probably don't want to do separate memcpy to
+ * upload_ptr directly, if we have to copy some constants
+ * at random locations (context->vs->lconstf.ranges),
+ * to have efficient WC. Thus for this case we really want
+ * that intermediate buffer. */
+
+ u_upload_alloc(context->pipe->const_uploader,
+ 0,
+ cb.buffer_size,
+ 256, /* Be conservative about alignment */
+ &(cb.buffer_offset),
+ &(cb.buffer),
+ (void**)&upload_ptr);
+
+ assert(cb.buffer && upload_ptr);
+
+ memcpy(upload_ptr, cb.user_buffer, cb.buffer_size);
+
+ u_upload_unmap(context->pipe->const_uploader);
+ cb.user_buffer = NULL;
+
+ /* Free previous resource */
+ pipe_resource_reference(&context->pipe_data.cb_vs.buffer, NULL);
+
context->pipe_data.cb_vs = cb;
context->changed.vs_const_f = 0;
@@ -489,6 +514,7 @@ static void
prepare_ps_constants_userbuf(struct NineDevice9 *device)
{
struct nine_context *context = &device->context;
+ uint8_t *upload_ptr = NULL;
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
@@ -536,6 +562,24 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device)
if (!cb.buffer_size)
return;
+ u_upload_alloc(context->pipe->const_uploader,
+ 0,
+ cb.buffer_size,
+ 256, /* Be conservative about alignment */
+ &(cb.buffer_offset),
+ &(cb.buffer),
+ (void**)&upload_ptr);
+
+ assert(cb.buffer && upload_ptr);
+
+ memcpy(upload_ptr, cb.user_buffer, cb.buffer_size);
+
+ u_upload_unmap(context->pipe->const_uploader);
+ cb.user_buffer = NULL;
+
+ /* Free previous resource */
+ pipe_resource_reference(&context->pipe_data.cb_ps.buffer, NULL);
+
context->pipe_data.cb_ps = cb;
context->changed.ps_const_f = 0;
@@ -2849,6 +2893,8 @@ nine_context_clear(struct NineDevice9 *device)
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
pipe_vertex_buffer_unreference(&context->vtxbuf[i]);
pipe_resource_reference(&context->idxbuf, NULL);
+ pipe_resource_reference(&context->pipe_data.cb_vs.buffer, NULL);
+ pipe_resource_reference(&context->pipe_data.cb_ps.buffer, NULL);
for (i = 0; i < NINE_MAX_SAMPLERS; ++i) {
context->texture[i].enabled = FALSE;