summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorGurchetan Singh <[email protected]>2019-03-13 22:58:22 +0000
committerGurchetan Singh <[email protected]>2019-03-13 22:58:22 +0000
commitd6dc68e7b5b6f76a55037f6995dad101cc089d02 (patch)
tree9da41c73d685f8717d26ede50df3b816da256590 /src/gallium/winsys
parent56717e13a65007a641ede756ea0b26a333dbc72b (diff)
virgl: use uint16_t mask instead of separate booleans
This should save some space. Suggested-by: Erik Faye-Lund <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/virgl/drm/virgl_drm_winsys.c101
-rw-r--r--src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c62
2 files changed, 83 insertions, 80 deletions
diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index 7759c87f9cf..120e8eda2cd 100644
--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -230,7 +230,7 @@ virgl_drm_winsys_resource_create(struct virgl_winsys *qws,
res->size = size;
res->stride = stride;
pipe_reference_init(&res->reference, 1);
- res->num_cs_references = 0;
+ p_atomic_set(&res->num_cs_references, 0);
res->fence_fd = -1;
return res;
}
@@ -564,54 +564,6 @@ static void virgl_drm_resource_wait(struct virgl_winsys *qws,
goto again;
}
-static struct virgl_cmd_buf *virgl_drm_cmd_buf_create(struct virgl_winsys *qws,
- uint32_t size)
-{
- struct virgl_drm_cmd_buf *cbuf;
-
- cbuf = CALLOC_STRUCT(virgl_drm_cmd_buf);
- if (!cbuf)
- return NULL;
-
- cbuf->ws = qws;
-
- cbuf->nres = 512;
- cbuf->res_bo = CALLOC(cbuf->nres, sizeof(struct virgl_hw_buf*));
- if (!cbuf->res_bo) {
- FREE(cbuf);
- return NULL;
- }
- cbuf->res_hlist = MALLOC(cbuf->nres * sizeof(uint32_t));
- if (!cbuf->res_hlist) {
- FREE(cbuf->res_bo);
- FREE(cbuf);
- return NULL;
- }
-
- cbuf->buf = CALLOC(size, sizeof(uint32_t));
- if (!cbuf->buf) {
- FREE(cbuf->res_hlist);
- FREE(cbuf->res_bo);
- FREE(cbuf);
- return NULL;
- }
-
- cbuf->base.buf = cbuf->buf;
- cbuf->base.in_fence_fd = -1;
- return &cbuf->base;
-}
-
-static void virgl_drm_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf)
-{
- struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf);
-
- FREE(cbuf->res_hlist);
- FREE(cbuf->res_bo);
- FREE(cbuf->buf);
- FREE(cbuf);
-
-}
-
static boolean virgl_drm_lookup_res(struct virgl_drm_cmd_buf *cbuf,
struct virgl_hw_res *res)
{
@@ -702,12 +654,61 @@ static boolean virgl_drm_res_is_ref(struct virgl_winsys *qws,
struct virgl_cmd_buf *_cbuf,
struct virgl_hw_res *res)
{
- if (!res->num_cs_references)
+ if (!p_atomic_read(&res->num_cs_references))
return FALSE;
return TRUE;
}
+static struct virgl_cmd_buf *virgl_drm_cmd_buf_create(struct virgl_winsys *qws,
+ uint32_t size)
+{
+ struct virgl_drm_cmd_buf *cbuf;
+
+ cbuf = CALLOC_STRUCT(virgl_drm_cmd_buf);
+ if (!cbuf)
+ return NULL;
+
+ cbuf->ws = qws;
+
+ cbuf->nres = 512;
+ cbuf->res_bo = CALLOC(cbuf->nres, sizeof(struct virgl_hw_buf*));
+ if (!cbuf->res_bo) {
+ FREE(cbuf);
+ return NULL;
+ }
+ cbuf->res_hlist = MALLOC(cbuf->nres * sizeof(uint32_t));
+ if (!cbuf->res_hlist) {
+ FREE(cbuf->res_bo);
+ FREE(cbuf);
+ return NULL;
+ }
+
+ cbuf->buf = CALLOC(size, sizeof(uint32_t));
+ if (!cbuf->buf) {
+ FREE(cbuf->res_hlist);
+ FREE(cbuf->res_bo);
+ FREE(cbuf);
+ return NULL;
+ }
+
+ cbuf->base.buf = cbuf->buf;
+ cbuf->base.in_fence_fd = -1;
+ return &cbuf->base;
+}
+
+static void virgl_drm_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf)
+{
+ struct virgl_drm_cmd_buf *cbuf = virgl_drm_cmd_buf(_cbuf);
+
+ virgl_drm_release_all_res(virgl_drm_winsys(cbuf->ws), cbuf);
+ FREE(cbuf->res_hlist);
+ FREE(cbuf->res_bo);
+ FREE(cbuf->buf);
+ FREE(cbuf);
+
+}
+
static int virgl_drm_winsys_submit_cmd(struct virgl_winsys *qws,
struct virgl_cmd_buf *_cbuf,
int in_fence_fd, int *out_fence_fd)
diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
index bc65ef3d22a..3ca15e6aed7 100644
--- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
+++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
@@ -247,6 +247,7 @@ virgl_vtest_winsys_resource_create(struct virgl_winsys *vws,
res->res_handle = handle++;
pipe_reference_init(&res->reference, 1);
+ p_atomic_set(&res->num_cs_references, 0);
return res;
}
@@ -394,35 +395,6 @@ alloc:
return res;
}
-static struct virgl_cmd_buf *virgl_vtest_cmd_buf_create(struct virgl_winsys *vws,
- uint32_t size)
-{
- struct virgl_vtest_cmd_buf *cbuf;
-
- cbuf = CALLOC_STRUCT(virgl_vtest_cmd_buf);
- if (!cbuf)
- return NULL;
-
- cbuf->nres = 512;
- cbuf->res_bo = CALLOC(cbuf->nres, sizeof(struct virgl_hw_buf*));
- if (!cbuf->res_bo) {
- FREE(cbuf);
- return NULL;
- }
- cbuf->ws = vws;
- cbuf->base.buf = cbuf->buf;
- cbuf->base.in_fence_fd = -1;
- return &cbuf->base;
-}
-
-static void virgl_vtest_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf)
-{
- struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf);
-
- FREE(cbuf->res_bo);
- FREE(cbuf);
-}
-
static boolean virgl_vtest_lookup_res(struct virgl_vtest_cmd_buf *cbuf,
struct virgl_hw_res *res)
{
@@ -485,6 +457,36 @@ static void virgl_vtest_add_res(struct virgl_vtest_winsys *vtws,
cbuf->cres++;
}
+static struct virgl_cmd_buf *virgl_vtest_cmd_buf_create(struct virgl_winsys *vws,
+ uint32_t size)
+{
+ struct virgl_vtest_cmd_buf *cbuf;
+
+ cbuf = CALLOC_STRUCT(virgl_vtest_cmd_buf);
+ if (!cbuf)
+ return NULL;
+
+ cbuf->nres = 512;
+ cbuf->res_bo = CALLOC(cbuf->nres, sizeof(struct virgl_hw_buf*));
+ if (!cbuf->res_bo) {
+ FREE(cbuf);
+ return NULL;
+ }
+ cbuf->ws = vws;
+ cbuf->base.buf = cbuf->buf;
+ cbuf->base.in_fence_fd = -1;
+ return &cbuf->base;
+}
+
+static void virgl_vtest_cmd_buf_destroy(struct virgl_cmd_buf *_cbuf)
+{
+ struct virgl_vtest_cmd_buf *cbuf = virgl_vtest_cmd_buf(_cbuf);
+
+ virgl_vtest_release_all_res(virgl_vtest_winsys(cbuf->ws), cbuf);
+ FREE(cbuf->res_bo);
+ FREE(cbuf);
+}
+
static int virgl_vtest_winsys_submit_cmd(struct virgl_winsys *vws,
struct virgl_cmd_buf *_cbuf,
int in_fence_fd, int *out_fence_fd)
@@ -525,7 +527,7 @@ static boolean virgl_vtest_res_is_ref(struct virgl_winsys *vws,
struct virgl_cmd_buf *_cbuf,
struct virgl_hw_res *res)
{
- if (!res->num_cs_references)
+ if (!p_atomic_read(&res->num_cs_references))
return FALSE;
return TRUE;