Mesa (master): virgl: wrap vertex element state in a struct

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 13 15:13:19 UTC 2018


Module: Mesa
Branch: master
Commit: 8447b64238773db0e365802315772d1819c1923f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8447b64238773db0e365802315772d1819c1923f

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Tue Dec 11 12:34:38 2018 +0000

virgl: wrap vertex element state in a struct

This just has one member for now; the handle. But this is about to
change.

Signed-off-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Reviewed-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
Tested-By: Gert Wollny <gert.wollny at collabora.com>

---

 src/gallium/drivers/virgl/virgl_context.c | 28 +++++++++++++++++++---------
 src/gallium/drivers/virgl/virgl_context.h |  2 ++
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index df6d9b83ff..121d9139f2 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -48,6 +48,10 @@
 #include "virgl_resource.h"
 #include "virgl_screen.h"
 
+struct virgl_vertex_elements_state {
+   uint32_t handle;
+};
+
 static uint32_t next_handle;
 uint32_t virgl_object_assign_handle(void)
 {
@@ -387,28 +391,34 @@ static void *virgl_create_vertex_elements_state(struct pipe_context *ctx,
                                                         const struct pipe_vertex_element *elements)
 {
    struct virgl_context *vctx = virgl_context(ctx);
-   uint32_t handle = virgl_object_assign_handle();
-   virgl_encoder_create_vertex_elements(vctx, handle,
-                                       num_elements, elements);
-   return (void*)(unsigned long)handle;
+   struct virgl_vertex_elements_state *state =
+      CALLOC_STRUCT(virgl_vertex_elements_state);
 
+   state->handle = virgl_object_assign_handle();
+   virgl_encoder_create_vertex_elements(vctx, state->handle,
+                                       num_elements, elements);
+   return state;
 }
 
 static void virgl_delete_vertex_elements_state(struct pipe_context *ctx,
                                               void *ve)
 {
    struct virgl_context *vctx = virgl_context(ctx);
-   uint32_t handle = (unsigned long)ve;
-
-   virgl_encode_delete_object(vctx, handle, VIRGL_OBJECT_VERTEX_ELEMENTS);
+   struct virgl_vertex_elements_state *state =
+      (struct virgl_vertex_elements_state *)ve;
+   virgl_encode_delete_object(vctx, state->handle, VIRGL_OBJECT_VERTEX_ELEMENTS);
+   FREE(state);
 }
 
 static void virgl_bind_vertex_elements_state(struct pipe_context *ctx,
                                                      void *ve)
 {
    struct virgl_context *vctx = virgl_context(ctx);
-   uint32_t handle = (unsigned long)ve;
-   virgl_encode_bind_object(vctx, handle, VIRGL_OBJECT_VERTEX_ELEMENTS);
+   struct virgl_vertex_elements_state *state =
+      (struct virgl_vertex_elements_state *)ve;
+   vctx->vertex_elements = state;
+   virgl_encode_bind_object(vctx, state ? state->handle : 0,
+                            VIRGL_OBJECT_VERTEX_ELEMENTS);
 }
 
 static void virgl_set_vertex_buffers(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h
index 20988baa3c..09cf0db2ae 100644
--- a/src/gallium/drivers/virgl/virgl_context.h
+++ b/src/gallium/drivers/virgl/virgl_context.h
@@ -32,6 +32,7 @@ struct pipe_screen;
 struct tgsi_token;
 struct u_upload_mgr;
 struct virgl_cmd_buf;
+struct virgl_vertex_elements_state;
 
 struct virgl_sampler_view {
    struct pipe_sampler_view base;
@@ -53,6 +54,7 @@ struct virgl_context {
    struct virgl_cmd_buf *cbuf;
 
    struct virgl_textures_info samplers[PIPE_SHADER_TYPES];
+   struct virgl_vertex_elements_state *vertex_elements;
 
    struct pipe_framebuffer_state framebuffer;
 




More information about the mesa-commit mailing list