summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/winsys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 02:30:08 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 02:30:08 +0000
commit1d35364040c0ffa99133522fa5ab3bd6131d8bf7 (patch)
tree0ea3d9ca4ad10692c6477168b67e98cb50ea6bd3 /lib/mesa/src/gallium/winsys
parentb24b5b9049e889ee4eb39b565bcc8d48bd45ab48 (diff)
Merge Mesa 21.3.7
Diffstat (limited to 'lib/mesa/src/gallium/winsys')
-rw-r--r--lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk48
-rw-r--r--lib/mesa/src/gallium/winsys/amdgpu/drm/Makefile.sources29
-rw-r--r--lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c17
-rw-r--r--lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c238
-rw-r--r--lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h25
-rw-r--r--lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c2
-rw-r--r--lib/mesa/src/gallium/winsys/etnaviv/drm/Android.mk33
-rw-r--r--lib/mesa/src/gallium/winsys/etnaviv/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c55
-rw-r--r--lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk36
-rw-r--r--lib/mesa/src/gallium/winsys/freedreno/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c10
-rw-r--r--lib/mesa/src/gallium/winsys/i915/drm/Android.mk41
-rw-r--r--lib/mesa/src/gallium/winsys/i915/drm/Makefile.sources7
-rw-r--r--lib/mesa/src/gallium/winsys/iris/drm/Android.mk40
-rw-r--r--lib/mesa/src/gallium/winsys/iris/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/kmsro/drm/Android.mk35
-rw-r--r--lib/mesa/src/gallium/winsys/kmsro/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/lima/drm/Android.mk32
-rw-r--r--lib/mesa/src/gallium/winsys/nouveau/drm/Android.mk37
-rw-r--r--lib/mesa/src/gallium/winsys/nouveau/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/panfrost/drm/Android.mk33
-rw-r--r--lib/mesa/src/gallium/winsys/panfrost/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/radeon/drm/Android.mk37
-rw-r--r--lib/mesa/src/gallium/winsys/radeon/drm/Makefile.sources13
-rw-r--r--lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.c4
-rw-r--r--lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c10
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/Android.mk42
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/Makefile.sources20
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c65
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h15
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c2
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_svga.c418
-rw-r--r--lib/mesa/src/gallium/winsys/svga/drm/vmwgfx_drm.h46
-rw-r--r--lib/mesa/src/gallium/winsys/sw/dri/Android.mk35
-rw-r--r--lib/mesa/src/gallium/winsys/sw/dri/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/sw/kms-dri/Android.mk33
-rw-r--r--lib/mesa/src/gallium/winsys/sw/kms-dri/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/sw/null/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/sw/wrapper/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/sw/xlib/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/tegra/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/v3d/drm/Android.mk33
-rw-r--r--lib/mesa/src/gallium/winsys/v3d/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/vc4/drm/Android.mk33
-rw-r--r--lib/mesa/src/gallium/winsys/vc4/drm/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/common/Android.mk35
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/common/Makefile.sources3
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/drm/Android.mk35
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/drm/Makefile.sources5
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c96
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h7
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk35
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources6
-rw-r--r--lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c27
55 files changed, 773 insertions, 1042 deletions
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk b/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk
deleted file mode 100644
index 0b8edf972..000000000
--- a/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2011 Chia-I Wu <olvaffe@gmail.com>
-# Copyright (C) 2011 LunarG Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_CFLAGS := $(AMDGPU_CFLAGS)
-
-LOCAL_STATIC_LIBRARIES := libmesa_amdgpu_addrlib libmesa_amd_common
-
-LOCAL_SHARED_LIBRARIES := libdrm_amdgpu
-LOCAL_MODULE := libmesa_winsys_amdgpu
-
-$(call mesa-build-with-llvm)
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
-
-ifneq ($(HAVE_GALLIUM_RADEONSI),)
-$(eval GALLIUM_LIBS += $(LOCAL_MODULE) $(LOCAL_STATIC_LIBRARIES))
-$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES))
-endif
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/amdgpu/drm/Makefile.sources
deleted file mode 100644
index 23630044a..000000000
--- a/lib/mesa/src/gallium/winsys/amdgpu/drm/Makefile.sources
+++ /dev/null
@@ -1,29 +0,0 @@
-C_SOURCES := \
- addrlib/addrinterface.cpp \
- addrlib/addrinterface.h \
- addrlib/addrtypes.h \
- addrlib/core/addrcommon.h \
- addrlib/core/addrelemlib.cpp \
- addrlib/core/addrelemlib.h \
- addrlib/core/addrlib.cpp \
- addrlib/core/addrlib.h \
- addrlib/core/addrobject.cpp \
- addrlib/core/addrobject.h \
- addrlib/inc/chip/r800/si_gb_reg.h \
- addrlib/inc/lnx_common_defs.h \
- addrlib/r800/chip/si_ci_vi_merged_enum.h \
- addrlib/r800/ciaddrlib.cpp \
- addrlib/r800/ciaddrlib.h \
- addrlib/r800/egbaddrlib.cpp \
- addrlib/r800/egbaddrlib.h \
- addrlib/r800/siaddrlib.cpp \
- addrlib/r800/siaddrlib.h \
- amdgpu_bo.c \
- amdgpu_bo.h \
- amdgpu_cs.c \
- amdgpu_cs.h \
- amdgpu_id.h \
- amdgpu_public.h \
- amdgpu_surface.c \
- amdgpu_winsys.c \
- amdgpu_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index ba98aa130..d2c1f3514 100644
--- a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -67,14 +67,7 @@ static bool amdgpu_bo_wait(struct radeon_winsys *rws,
return false;
}
- bool is_shared = false;
- if (bo->bo) {
- simple_mtx_lock(&bo->lock);
- is_shared = bo->u.real.is_shared;
- simple_mtx_unlock(&bo->lock);
- }
-
- if (is_shared) {
+ if (bo->bo && bo->u.real.is_shared) {
/* We can't use user fences for shared buffers, because user fences
* are local to this process only. If we want to wait for all buffer
* uses in all processes, we have to use amdgpu_bo_wait_for_idle.
@@ -1647,11 +1640,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
if (sws->fd == ws->fd) {
whandle->handle = bo->u.real.kms_handle;
- simple_mtx_lock(&bo->lock);
- bool is_shared = bo->u.real.is_shared;
- simple_mtx_unlock(&bo->lock);
-
- if (is_shared)
+ if (bo->u.real.is_shared)
return true;
goto hash_table_set;
@@ -1697,9 +1686,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
_mesa_hash_table_insert(ws->bo_export_table, bo->bo, bo);
simple_mtx_unlock(&ws->bo_export_table_lock);
- simple_mtx_lock(&bo->lock);
bo->u.real.is_shared = true;
- simple_mtx_unlock(&bo->lock);
return true;
}
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
index e82638189..6452d2ba4 100644
--- a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
+++ b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
@@ -414,15 +414,9 @@ static bool amdgpu_cs_has_user_fence(struct amdgpu_cs_context *cs)
cs->ib[IB_MAIN].ip_type != AMDGPU_HW_IP_VCN_JPEG;
}
-static bool amdgpu_cs_has_chaining(struct amdgpu_cs *cs)
+static inline unsigned amdgpu_cs_epilog_dws(struct amdgpu_cs *cs)
{
- return cs->ws->info.chip_class >= GFX7 &&
- (cs->ring_type == RING_GFX || cs->ring_type == RING_COMPUTE);
-}
-
-static unsigned amdgpu_cs_epilog_dws(struct amdgpu_cs *cs)
-{
- if (amdgpu_cs_has_chaining(cs))
+ if (cs->has_chaining)
return 4; /* for chaining */
return 0;
@@ -431,7 +425,7 @@ static unsigned amdgpu_cs_epilog_dws(struct amdgpu_cs *cs)
static int amdgpu_lookup_buffer(struct amdgpu_cs_context *cs, struct amdgpu_winsys_bo *bo,
struct amdgpu_cs_buffer *buffers, unsigned num_buffers)
{
- unsigned hash = bo->unique_id & (ARRAY_SIZE(cs->buffer_indices_hashlist)-1);
+ unsigned hash = bo->unique_id & (BUFFER_HASHLIST_SIZE-1);
int i = cs->buffer_indices_hashlist[hash];
/* not found or found */
@@ -450,7 +444,7 @@ static int amdgpu_lookup_buffer(struct amdgpu_cs_context *cs, struct amdgpu_wins
* AAAAAAAAAAABBBBBBBBBBBBBBCCCCCCCC
* will collide here: ^ and here: ^,
* meaning that we should get very few collisions in the end. */
- cs->buffer_indices_hashlist[hash] = i;
+ cs->buffer_indices_hashlist[hash] = i & 0x7fff;
return i;
}
}
@@ -528,8 +522,8 @@ amdgpu_lookup_or_add_real_buffer(struct radeon_cmdbuf *rcs, struct amdgpu_cs *ac
idx = amdgpu_do_add_real_buffer(acs->ws, cs, bo);
- hash = bo->unique_id & (ARRAY_SIZE(cs->buffer_indices_hashlist)-1);
- cs->buffer_indices_hashlist[hash] = idx;
+ hash = bo->unique_id & (BUFFER_HASHLIST_SIZE-1);
+ cs->buffer_indices_hashlist[hash] = idx & 0x7fff;
if (bo->base.placement & RADEON_DOMAIN_VRAM)
rcs->used_vram_kb += bo->base.size / 1024;
@@ -583,8 +577,8 @@ static int amdgpu_lookup_or_add_slab_buffer(struct amdgpu_winsys *ws,
buffer->u.slab.real_idx = real_idx;
cs->num_slab_buffers++;
- hash = bo->unique_id & (ARRAY_SIZE(cs->buffer_indices_hashlist)-1);
- cs->buffer_indices_hashlist[hash] = idx;
+ hash = bo->unique_id & (BUFFER_HASHLIST_SIZE-1);
+ cs->buffer_indices_hashlist[hash] = idx & 0x7fff;
return idx;
}
@@ -627,8 +621,8 @@ static int amdgpu_lookup_or_add_sparse_buffer(struct amdgpu_winsys *ws,
amdgpu_winsys_bo_reference(ws, &buffer->bo, bo);
cs->num_sparse_buffers++;
- hash = bo->unique_id & (ARRAY_SIZE(cs->buffer_indices_hashlist)-1);
- cs->buffer_indices_hashlist[hash] = idx;
+ hash = bo->unique_id & (BUFFER_HASHLIST_SIZE-1);
+ cs->buffer_indices_hashlist[hash] = idx & 0x7fff;
/* We delay adding the backing buffers until we really have to. However,
* we cannot delay accounting for memory use.
@@ -721,10 +715,10 @@ static bool amdgpu_ib_new_buffer(struct amdgpu_winsys *ws,
* is the largest power of two that fits into the size field of the
* INDIRECT_BUFFER packet.
*/
- if (amdgpu_cs_has_chaining(cs))
- buffer_size = 4 *util_next_power_of_two(ib->max_ib_size);
+ if (cs->has_chaining)
+ buffer_size = 4 * util_next_power_of_two(ib->max_ib_size);
else
- buffer_size = 4 *util_next_power_of_two(4 * ib->max_ib_size);
+ buffer_size = 4 * util_next_power_of_two(4 * ib->max_ib_size);
const unsigned min_size = MAX2(ib->max_check_space_size, 8 * 1024 * 4);
const unsigned max_size = 512 * 1024 * 4;
@@ -767,24 +761,6 @@ static bool amdgpu_ib_new_buffer(struct amdgpu_winsys *ws,
return true;
}
-static unsigned amdgpu_ib_max_submit_dwords(enum ib_type ib_type)
-{
- /* The maximum IB size including all chained IBs. */
- switch (ib_type) {
- case IB_MAIN:
- /* Smaller submits means the GPU gets busy sooner and there is less
- * waiting for buffers and fences. Proof:
- * http://www.phoronix.com/scan.php?page=article&item=mesa-111-si&num=1
- */
- return 20 * 1024;
- case IB_PARALLEL_COMPUTE:
- /* Always chain this IB. */
- return UINT_MAX;
- default:
- unreachable("bad ib_type");
- }
-}
-
static bool amdgpu_get_new_ib(struct amdgpu_winsys *ws,
struct radeon_cmdbuf *rcs,
struct amdgpu_ib *ib,
@@ -803,10 +779,10 @@ static bool amdgpu_get_new_ib(struct amdgpu_winsys *ws,
*/
ib_size = MAX2(ib_size, ib->max_check_space_size);
- if (!amdgpu_cs_has_chaining(cs)) {
+ if (!cs->has_chaining) {
ib_size = MAX2(ib_size,
4 * MIN2(util_next_power_of_two(ib->max_ib_size),
- amdgpu_ib_max_submit_dwords(ib->ib_type)));
+ IB_MAX_SUBMIT_DWORDS));
}
ib->max_ib_size = ib->max_ib_size - ib->max_ib_size / 32;
@@ -835,6 +811,9 @@ static bool amdgpu_get_new_ib(struct amdgpu_winsys *ws,
rcs->current.buf = (uint32_t*)(ib->ib_mapped + ib->used_ib_space);
+ if (ib->ib_type == IB_MAIN)
+ cs->csc->ib_main_addr = rcs->current.buf;
+
ib_size = ib->big_ib_buffer->size - ib->used_ib_space;
rcs->current.max_dw = ib_size / 4 - amdgpu_cs_epilog_dws(cs);
rcs->gpu_address = info->va_start;
@@ -914,10 +893,6 @@ static bool amdgpu_init_cs_context(struct amdgpu_winsys *ws,
assert(0);
}
- cs->ib[IB_PARALLEL_COMPUTE].ip_type = AMDGPU_HW_IP_COMPUTE;
- cs->ib[IB_PARALLEL_COMPUTE].flags = AMDGPU_IB_FLAG_TC_WB_NOT_INVALIDATE;
-
- memset(cs->buffer_indices_hashlist, -1, sizeof(cs->buffer_indices_hashlist));
cs->last_added_bo = NULL;
return true;
}
@@ -945,15 +920,11 @@ static void amdgpu_cs_context_cleanup(struct amdgpu_winsys *ws, struct amdgpu_cs
cleanup_fence_list(&cs->fence_dependencies);
cleanup_fence_list(&cs->syncobj_dependencies);
cleanup_fence_list(&cs->syncobj_to_signal);
- cleanup_fence_list(&cs->compute_fence_dependencies);
- cleanup_fence_list(&cs->compute_start_fence_dependencies);
cs->num_real_buffers = 0;
cs->num_slab_buffers = 0;
cs->num_sparse_buffers = 0;
amdgpu_fence_reference(&cs->fence, NULL);
-
- memset(cs->buffer_indices_hashlist, -1, sizeof(cs->buffer_indices_hashlist));
cs->last_added_bo = NULL;
}
@@ -966,8 +937,6 @@ static void amdgpu_destroy_cs_context(struct amdgpu_winsys *ws, struct amdgpu_cs
FREE(cs->fence_dependencies.list);
FREE(cs->syncobj_dependencies.list);
FREE(cs->syncobj_to_signal.list);
- FREE(cs->compute_fence_dependencies.list);
- FREE(cs->compute_start_fence_dependencies.list);
}
@@ -997,6 +966,8 @@ amdgpu_cs_create(struct radeon_cmdbuf *rcs,
cs->ring_type = ring_type;
cs->stop_exec_on_failure = stop_exec_on_failure;
cs->noop = ctx->ws->noop_cs;
+ cs->has_chaining = ctx->ws->info.chip_class >= GFX7 &&
+ (ring_type == RING_GFX || ring_type == RING_COMPUTE);
struct amdgpu_cs_fence_info fence_info;
fence_info.handle = cs->ctx->user_fence_bo;
@@ -1004,7 +975,6 @@ amdgpu_cs_create(struct radeon_cmdbuf *rcs,
amdgpu_cs_chunk_fence_info_to_data(&fence_info, (void*)&cs->fence_chunk);
cs->main.ib_type = IB_MAIN;
- cs->compute_ib.ib_type = IB_PARALLEL_COMPUTE;
if (!amdgpu_init_cs_context(ctx->ws, &cs->csc1, ring_type)) {
FREE(cs);
@@ -1017,10 +987,16 @@ amdgpu_cs_create(struct radeon_cmdbuf *rcs,
return false;
}
+ memset(cs->buffer_indices_hashlist, -1, sizeof(cs->buffer_indices_hashlist));
+
/* Set the first submission context as current. */
cs->csc = &cs->csc1;
cs->cst = &cs->csc2;
+ /* Assign to both amdgpu_cs_context; only csc will use it. */
+ cs->csc1.buffer_indices_hashlist = cs->buffer_indices_hashlist;
+ cs->csc2.buffer_indices_hashlist = cs->buffer_indices_hashlist;
+
cs->main.rcs = rcs;
rcs->priv = cs;
@@ -1037,37 +1013,6 @@ amdgpu_cs_create(struct radeon_cmdbuf *rcs,
}
static bool
-amdgpu_cs_add_parallel_compute_ib(struct radeon_cmdbuf *compute_cs,
- struct radeon_cmdbuf *gfx_cs,
- bool uses_gds_ordered_append)
-{
- struct amdgpu_cs *cs = amdgpu_cs(gfx_cs);
- struct amdgpu_winsys *ws = cs->ws;
-
- if (cs->ring_type != RING_GFX)
- return false;
-
- /* only one secondary IB can be added */
- if (cs->compute_ib.ib_mapped)
- return false;
-
- /* Allocate the compute IB. */
- if (!amdgpu_get_new_ib(ws, compute_cs, &cs->compute_ib, cs))
- return false;
-
- if (uses_gds_ordered_append) {
- cs->csc1.ib[IB_PARALLEL_COMPUTE].flags |=
- AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID;
- cs->csc2.ib[IB_PARALLEL_COMPUTE].flags |=
- AMDGPU_IB_FLAG_RESET_GDS_MAX_WAVE_ID;
- }
-
- cs->compute_ib.rcs = compute_cs;
- compute_cs->priv = cs;
- return true;
-}
-
-static bool
amdgpu_cs_setup_preemption(struct radeon_cmdbuf *rcs, const uint32_t *preamble_ib,
unsigned preamble_num_dw)
{
@@ -1129,12 +1074,9 @@ static bool amdgpu_cs_check_space(struct radeon_cmdbuf *rcs, unsigned dw,
bool force_chaining)
{
struct amdgpu_cs *cs = amdgpu_cs(rcs);
- struct amdgpu_ib *ib = rcs == cs->main.rcs ? &cs->main : &cs->compute_ib;
- unsigned requested_size = rcs->prev_dw + rcs->current.cdw + dw;
+ struct amdgpu_ib *ib = &cs->main;
unsigned cs_epilog_dw = amdgpu_cs_epilog_dws(cs);
unsigned need_byte_size = (dw + cs_epilog_dw) * 4;
- uint64_t va;
- uint32_t *new_ptr_ib_size;
assert(rcs->current.cdw <= rcs->current.max_dw);
@@ -1145,7 +1087,9 @@ static bool amdgpu_cs_check_space(struct radeon_cmdbuf *rcs, unsigned dw,
/* If force_chaining is true, we can't return. We have to chain. */
if (!force_chaining) {
- if (requested_size > amdgpu_ib_max_submit_dwords(ib->ib_type))
+ unsigned requested_size = rcs->prev_dw + rcs->current.cdw + dw;
+
+ if (requested_size > IB_MAX_SUBMIT_DWORDS)
return false;
ib->max_ib_size = MAX2(ib->max_ib_size, requested_size);
@@ -1154,7 +1098,7 @@ static bool amdgpu_cs_check_space(struct radeon_cmdbuf *rcs, unsigned dw,
return true;
}
- if (!amdgpu_cs_has_chaining(cs)) {
+ if (!cs->has_chaining) {
assert(!force_chaining);
return false;
}
@@ -1178,7 +1122,7 @@ static bool amdgpu_cs_check_space(struct radeon_cmdbuf *rcs, unsigned dw,
return false;
assert(ib->used_ib_space == 0);
- va = amdgpu_winsys_bo(ib->big_ib_buffer)->va;
+ uint64_t va = amdgpu_winsys_bo(ib->big_ib_buffer)->va;
/* This space was originally reserved. */
rcs->current.max_dw += cs_epilog_dw;
@@ -1191,7 +1135,7 @@ static bool amdgpu_cs_check_space(struct radeon_cmdbuf *rcs, unsigned dw,
radeon_emit(rcs, PKT3(PKT3_INDIRECT_BUFFER_CIK, 2, 0));
radeon_emit(rcs, va);
radeon_emit(rcs, va >> 32);
- new_ptr_ib_size = &rcs->current.buf[rcs->current.cdw++];
+ uint32_t *new_ptr_ib_size = &rcs->current.buf[rcs->current.cdw++];
assert((rcs->current.cdw & ib_pad_dw_mask) == 0);
assert((rcs->current.cdw & 7) == 0);
@@ -1288,18 +1232,6 @@ static void amdgpu_cs_add_fence_dependency(struct radeon_cmdbuf *rws,
util_queue_fence_wait(&fence->submitted);
- if (dependency_flags & RADEON_DEPENDENCY_PARALLEL_COMPUTE_ONLY) {
- /* Syncobjs are not needed here. */
- assert(!amdgpu_fence_is_syncobj(fence));
-
- if (acs->ws->info.has_scheduled_fence_dependency &&
- dependency_flags & RADEON_DEPENDENCY_START_FENCE)
- add_fence_to_list(&cs->compute_start_fence_dependencies, fence);
- else
- add_fence_to_list(&cs->compute_fence_dependencies, fence);
- return;
- }
-
/* Start fences are not needed here. */
assert(!(dependency_flags & RADEON_DEPENDENCY_START_FENCE));
@@ -1455,7 +1387,7 @@ static bool amdgpu_add_sparse_backing_buffers(struct amdgpu_winsys *ws,
return true;
}
-static void amdgpu_cs_submit_ib(void *job, int thread_index)
+static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index)
{
struct amdgpu_cs *acs = (struct amdgpu_cs*)job;
struct amdgpu_winsys *ws = acs->ws;
@@ -1534,6 +1466,8 @@ static void amdgpu_cs_submit_ib(void *job, int thread_index)
if (acs->ring_type == RING_GFX)
ws->gfx_bo_list_counter += cs->num_real_buffers;
+ bool noop = false;
+
if (acs->stop_exec_on_failure && acs->ctx->num_rejected_cs) {
r = -ECANCELED;
} else {
@@ -1591,66 +1525,6 @@ static void amdgpu_cs_submit_ib(void *job, int thread_index)
num_chunks++;
}
- /* Submit the parallel compute IB first. */
- if (cs->ib[IB_PARALLEL_COMPUTE].ib_bytes > 0) {
- unsigned old_num_chunks = num_chunks;
-
- /* Add compute fence dependencies. */
- unsigned num_dependencies = cs->compute_fence_dependencies.num;
- if (num_dependencies) {
- struct drm_amdgpu_cs_chunk_dep *dep_chunk =
- alloca(num_dependencies * sizeof(*dep_chunk));
-
- for (unsigned i = 0; i < num_dependencies; i++) {
- struct amdgpu_fence *fence =
- (struct amdgpu_fence*)cs->compute_fence_dependencies.list[i];
-
- assert(util_queue_fence_is_signalled(&fence->submitted));
- amdgpu_cs_chunk_fence_to_dep(&fence->fence, &dep_chunk[i]);
- }
-
- chunks[num_chunks].chunk_id = AMDGPU_CHUNK_ID_DEPENDENCIES;
- chunks[num_chunks].length_dw = sizeof(dep_chunk[0]) / 4 * num_dependencies;
- chunks[num_chunks].chunk_data = (uintptr_t)dep_chunk;
- num_chunks++;
- }
-
- /* Add compute start fence dependencies. */
- unsigned num_start_dependencies = cs->compute_start_fence_dependencies.num;
- if (num_start_dependencies) {
- struct drm_amdgpu_cs_chunk_dep *dep_chunk =
- alloca(num_start_dependencies * sizeof(*dep_chunk));
-
- for (unsigned i = 0; i < num_start_dependencies; i++) {
- struct amdgpu_fence *fence =
- (struct amdgpu_fence*)cs->compute_start_fence_dependencies.list[i];
-
- assert(util_queue_fence_is_signalled(&fence->submitted));
- amdgpu_cs_chunk_fence_to_dep(&fence->fence, &dep_chunk[i]);
- }
-
- chunks[num_chunks].chunk_id = AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES;
- chunks[num_chunks].length_dw = sizeof(dep_chunk[0]) / 4 * num_start_dependencies;
- chunks[num_chunks].chunk_data = (uintptr_t)dep_chunk;
- num_chunks++;
- }
-
- /* Convert from dwords to bytes. */
- cs->ib[IB_PARALLEL_COMPUTE].ib_bytes *= 4;
- chunks[num_chunks].chunk_id = AMDGPU_CHUNK_ID_IB;
- chunks[num_chunks].length_dw = sizeof(struct drm_amdgpu_cs_chunk_ib) / 4;
- chunks[num_chunks].chunk_data = (uintptr_t)&cs->ib[IB_PARALLEL_COMPUTE];
- num_chunks++;
-
- r = acs->noop ? 0 : amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
- num_chunks, chunks, NULL);
- if (r)
- goto finalize;
-
- /* Back off the compute chunks. */
- num_chunks = old_num_chunks;
- }
-
/* Syncobj signals. */
unsigned num_syncobj_to_signal = cs->syncobj_to_signal.num;
if (num_syncobj_to_signal) {
@@ -1703,12 +1577,25 @@ static void amdgpu_cs_submit_ib(void *job, int thread_index)
cs->ib[IB_MAIN].flags &= ~AMDGPU_IB_FLAGS_SECURE;
}
+ /* Apply RADEON_NOOP. */
+ if (acs->noop) {
+ if (acs->ring_type == RING_GFX) {
+ /* Reduce the IB size and fill it with NOP to make it like an empty IB. */
+ unsigned noop_size = MIN2(cs->ib[IB_MAIN].ib_bytes, ws->info.ib_alignment);
+
+ cs->ib_main_addr[0] = PKT3(PKT3_NOP, noop_size / 4 - 2, 0);
+ cs->ib[IB_MAIN].ib_bytes = noop_size;
+ } else {
+ noop = true;
+ }
+ }
+
assert(num_chunks <= ARRAY_SIZE(chunks));
- r = acs->noop ? 0 : amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
- num_chunks, chunks, &seq_no);
+ r = noop ? 0 : amdgpu_cs_submit_raw2(ws->dev, acs->ctx->ctx, bo_list,
+ num_chunks, chunks, &seq_no);
}
-finalize:
+
if (r) {
if (r == -ENOMEM)
fprintf(stderr, "amdgpu: Not enough memory for command submission.\n");
@@ -1720,7 +1607,7 @@ finalize:
acs->ctx->num_rejected_cs++;
ws->num_total_rejected_cs++;
- } else if (!acs->noop) {
+ } else if (!noop) {
/* Success. */
uint64_t *user_fence = NULL;
@@ -1742,7 +1629,7 @@ finalize:
cleanup:
/* If there was an error, signal the fence, because it won't be signalled
* by the hardware. */
- if (r || acs->noop)
+ if (r || noop)
amdgpu_fence_signalled(cs->fence);
cs->error_code = r;
@@ -1800,12 +1687,6 @@ static int amdgpu_cs_flush(struct radeon_cmdbuf *rcs,
}
if (cs->ring_type == RING_GFX)
ws->gfx_ib_size_counter += (rcs->prev_dw + rcs->current.cdw) * 4;
-
- /* Also pad secondary IBs. */
- if (cs->compute_ib.ib_mapped) {
- while (cs->compute_ib.rcs->current.cdw & ib_pad_dw_mask)
- radeon_emit(cs->compute_ib.rcs, PKT3_NOP_PAD);
- }
break;
case RING_UVD:
case RING_UVD_ENC:
@@ -1841,9 +1722,6 @@ static int amdgpu_cs_flush(struct radeon_cmdbuf *rcs,
/* Set IB sizes. */
amdgpu_ib_finalize(ws, rcs, &cs->main);
- if (cs->compute_ib.ib_mapped)
- amdgpu_ib_finalize(ws, cs->compute_ib.rcs, &cs->compute_ib);
-
/* Create a fence. */
amdgpu_fence_reference(&cur->fence, NULL);
if (cs->next_fence) {
@@ -1896,9 +1774,9 @@ static int amdgpu_cs_flush(struct radeon_cmdbuf *rcs,
amdgpu_cs_context_cleanup(ws, cs->csc);
}
+ memset(cs->csc->buffer_indices_hashlist, -1, sizeof(cs->buffer_indices_hashlist));
+
amdgpu_get_new_ib(ws, rcs, &cs->main, cs);
- if (cs->compute_ib.ib_mapped)
- amdgpu_get_new_ib(ws, cs->compute_ib.rcs, &cs->compute_ib, cs);
if (cs->preamble_ib_bo) {
amdgpu_cs_add_buffer(rcs, cs->preamble_ib_bo, RADEON_USAGE_READ, 0,
@@ -1929,9 +1807,6 @@ static void amdgpu_cs_destroy(struct radeon_cmdbuf *rcs)
radeon_bo_reference(&cs->ws->dummy_ws.base, &cs->preamble_ib_bo, NULL);
radeon_bo_reference(&cs->ws->dummy_ws.base, &cs->main.big_ib_buffer, NULL);
FREE(rcs->prev);
- radeon_bo_reference(&cs->ws->dummy_ws.base, &cs->compute_ib.big_ib_buffer, NULL);
- if (cs->compute_ib.rcs)
- FREE(cs->compute_ib.rcs->prev);
amdgpu_destroy_cs_context(cs->ws, &cs->csc1);
amdgpu_destroy_cs_context(cs->ws, &cs->csc2);
amdgpu_fence_reference(&cs->next_fence, NULL);
@@ -1954,7 +1829,6 @@ void amdgpu_cs_init_functions(struct amdgpu_screen_winsys *ws)
ws->base.ctx_destroy = amdgpu_ctx_destroy;
ws->base.ctx_query_reset_status = amdgpu_ctx_query_reset_status;
ws->base.cs_create = amdgpu_cs_create;
- ws->base.cs_add_parallel_compute_ib = amdgpu_cs_add_parallel_compute_ib;
ws->base.cs_setup_preemption = amdgpu_cs_setup_preemption;
ws->base.cs_destroy = amdgpu_cs_destroy;
ws->base.cs_add_buffer = amdgpu_cs_add_buffer;
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
index cfd80a5c5..1ce8e5bae 100644
--- a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
+++ b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
@@ -32,6 +32,12 @@
#include "util/u_memory.h"
#include "drm-uapi/amdgpu_drm.h"
+/* Smaller submits means the GPU gets busy sooner and there is less
+ * waiting for buffers and fences. Proof:
+ * http://www.phoronix.com/scan.php?page=article&item=mesa-111-si&num=1
+ */
+#define IB_MAX_SUBMIT_DWORDS (20 * 1024)
+
struct amdgpu_ctx {
struct amdgpu_winsys *ws;
amdgpu_context_handle ctx;
@@ -58,7 +64,6 @@ struct amdgpu_cs_buffer {
enum ib_type {
IB_PREAMBLE,
IB_MAIN,
- IB_PARALLEL_COMPUTE,
IB_NUM,
};
@@ -90,6 +95,7 @@ struct amdgpu_fence_list {
struct amdgpu_cs_context {
struct drm_amdgpu_cs_chunk_ib ib[IB_NUM];
+ uint32_t *ib_main_addr; /* the beginning of IB before chaining */
/* Buffers. */
unsigned max_real_buffers;
@@ -104,7 +110,7 @@ struct amdgpu_cs_context {
unsigned max_sparse_buffers;
struct amdgpu_cs_buffer *sparse_buffers;
- int buffer_indices_hashlist[4096];
+ int16_t *buffer_indices_hashlist;
struct amdgpu_winsys_bo *last_added_bo;
unsigned last_added_bo_index;
@@ -115,10 +121,6 @@ struct amdgpu_cs_context {
struct amdgpu_fence_list syncobj_dependencies;
struct amdgpu_fence_list syncobj_to_signal;
- /* The compute IB uses the dependencies above + these: */
- struct amdgpu_fence_list compute_fence_dependencies;
- struct amdgpu_fence_list compute_start_fence_dependencies;
-
struct pipe_fence_handle *fence;
/* the error returned from cs_flush for non-async submissions */
@@ -128,9 +130,10 @@ struct amdgpu_cs_context {
bool secure;
};
+#define BUFFER_HASHLIST_SIZE 4096
+
struct amdgpu_cs {
struct amdgpu_ib main; /* must be first because this is inherited */
- struct amdgpu_ib compute_ib; /* optional parallel compute IB */
struct amdgpu_winsys *ws;
struct amdgpu_ctx *ctx;
enum ring_type ring_type;
@@ -145,12 +148,20 @@ struct amdgpu_cs {
struct amdgpu_cs_context *csc;
/* The CS being currently-owned by the other thread. */
struct amdgpu_cs_context *cst;
+ /* buffer_indices_hashlist[hash(bo)] returns -1 if the bo
+ * isn't part of any buffer lists or the index where the bo could be found.
+ * Since 1) hash collisions of 2 different bo can happen and 2) we use a
+ * single hashlist for the 3 buffer list, this is only a hint.
+ * amdgpu_lookup_buffer uses this hint to speed up buffers look up.
+ */
+ int16_t buffer_indices_hashlist[BUFFER_HASHLIST_SIZE];
/* Flush CS. */
void (*flush_cs)(void *ctx, unsigned flags, struct pipe_fence_handle **fence);
void *flush_data;
bool stop_exec_on_failure;
bool noop;
+ bool has_chaining;
struct util_queue_fence flush_completed;
struct pipe_fence_handle *next_fence;
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 5ee8ed416..06dcf3369 100644
--- a/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/lib/mesa/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -508,7 +508,7 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
(void) simple_mtx_init(&aws->bo_export_table_lock, mtx_plain);
if (!util_queue_init(&aws->cs_queue, "cs", 8, 1,
- UTIL_QUEUE_INIT_RESIZE_IF_FULL)) {
+ UTIL_QUEUE_INIT_RESIZE_IF_FULL, NULL)) {
amdgpu_winsys_destroy(&ws->base);
simple_mtx_unlock(&dev_tab_mutex);
return NULL;
diff --git a/lib/mesa/src/gallium/winsys/etnaviv/drm/Android.mk b/lib/mesa/src/gallium/winsys/etnaviv/drm/Android.mk
deleted file mode 100644
index 32091bea0..000000000
--- a/lib/mesa/src/gallium/winsys/etnaviv/drm/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2016 Linaro, Ltd, Rob Herring <robh@kernel.org>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_SHARED_LIBRARIES := libdrm_etnaviv
-
-LOCAL_MODULE := libmesa_winsys_etnaviv
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/etnaviv/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/etnaviv/drm/Makefile.sources
deleted file mode 100644
index f338b0848..000000000
--- a/lib/mesa/src/gallium/winsys/etnaviv/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- etnaviv_drm_public.h \
- etnaviv_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c b/lib/mesa/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
index d5670af86..03dac9374 100644
--- a/lib/mesa/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
+++ b/lib/mesa/src/gallium/winsys/etnaviv/drm/etnaviv_drm_winsys.c
@@ -28,7 +28,6 @@
#include "util/os_file.h"
#include "util/u_hash_table.h"
-#include "util/u_memory.h"
#include "util/u_pointer.h"
#include "etnaviv/etnaviv_screen.h"
@@ -96,14 +95,14 @@ hash_table_create_file_description_keys(void)
}
static struct pipe_screen *
-screen_create(struct renderonly *ro)
+screen_create(int gpu_fd, struct renderonly *ro)
{
struct etna_device *dev;
struct etna_gpu *gpu;
uint64_t val;
int i;
- dev = etna_device_new_dup(ro->gpu_fd);
+ dev = etna_device_new_dup(gpu_fd);
if (!dev) {
fprintf(stderr, "Error creating device\n");
return NULL;
@@ -127,7 +126,7 @@ screen_create(struct renderonly *ro)
return etna_screen_create(dev, gpu, ro);
}
-static struct hash_table *etna_tab = NULL;
+static struct hash_table *fd_tab = NULL;
static mtx_t etna_screen_mutex = _MTX_INITIALIZER_NP;
@@ -141,7 +140,12 @@ etna_drm_screen_destroy(struct pipe_screen *pscreen)
destroy = --screen->refcnt == 0;
if (destroy) {
int fd = etna_device_fd(screen->dev);
- _mesa_hash_table_remove_key(etna_tab, intptr_to_pointer(fd));
+ _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd));
+
+ if (!fd_tab->entries) {
+ _mesa_hash_table_destroy(fd_tab, NULL);
+ fd_tab = NULL;
+ }
}
mtx_unlock(&etna_screen_mutex);
@@ -151,32 +155,32 @@ etna_drm_screen_destroy(struct pipe_screen *pscreen)
}
}
-struct pipe_screen *
-etna_drm_screen_create_renderonly(struct renderonly *ro)
+static struct pipe_screen *
+etna_lookup_or_create_screen(int gpu_fd, struct renderonly *ro)
{
struct pipe_screen *pscreen = NULL;
mtx_lock(&etna_screen_mutex);
- if (!etna_tab) {
- etna_tab = hash_table_create_file_description_keys();
- if (!etna_tab)
+ if (!fd_tab) {
+ fd_tab = hash_table_create_file_description_keys();
+ if (!fd_tab)
goto unlock;
}
- pscreen = util_hash_table_get(etna_tab, intptr_to_pointer(ro->gpu_fd));
+ pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(gpu_fd));
if (pscreen) {
etna_screen(pscreen)->refcnt++;
} else {
- pscreen = screen_create(ro);
+ pscreen = screen_create(gpu_fd, ro);
if (pscreen) {
int fd = etna_device_fd(etna_screen(pscreen)->dev);
- _mesa_hash_table_insert(etna_tab, intptr_to_pointer(fd), pscreen);
+ _mesa_hash_table_insert(fd_tab, intptr_to_pointer(fd), pscreen);
/* Bit of a hack, to avoid circular linkage dependency,
* ie. pipe driver having to call in to winsys, we
* override the pipe drivers screen->destroy() */
etna_screen(pscreen)->winsys_priv = pscreen->destroy;
- pscreen->destroy = etna_drm_screen_destroy;
+ pscreen->destroy = etna_drm_screen_destroy;
}
}
@@ -185,29 +189,14 @@ unlock:
return pscreen;
}
-static void etnaviv_ro_destroy(struct renderonly *ro)
+struct pipe_screen *
+etna_drm_screen_create_renderonly(struct renderonly *ro)
{
- FREE(ro);
+ return etna_lookup_or_create_screen(ro->gpu_fd, ro);
}
struct pipe_screen *
etna_drm_screen_create(int fd)
{
-
- struct renderonly *ro = CALLOC_STRUCT(renderonly);
- struct pipe_screen *screen;
-
- if (!ro)
- return NULL;
-
- ro->create_for_resource = renderonly_create_gpu_import_for_resource;
- ro->destroy = etnaviv_ro_destroy;
- ro->kms_fd = -1;
- ro->gpu_fd = fd;
-
- screen = etna_drm_screen_create_renderonly(ro);
- if (!screen)
- FREE(ro);
-
- return screen;
+ return etna_lookup_or_create_screen(fd, NULL);
}
diff --git a/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk b/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk
deleted file mode 100644
index 09edab391..000000000
--- a/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_SHARED_LIBRARIES := libdrm_freedreno
-LOCAL_STATIC_LIBRARIES := libfreedreno_registers
-
-LOCAL_MODULE := libmesa_winsys_freedreno
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/freedreno/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/freedreno/drm/Makefile.sources
deleted file mode 100644
index f0581dfb3..000000000
--- a/lib/mesa/src/gallium/winsys/freedreno/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- freedreno_drm_public.h \
- freedreno_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c b/lib/mesa/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
index 6773af41b..3e4109e3e 100644
--- a/lib/mesa/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
+++ b/lib/mesa/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c
@@ -54,6 +54,11 @@ fd_drm_screen_destroy(struct pipe_screen *pscreen)
if (destroy) {
int fd = fd_device_fd(screen->dev);
_mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd));
+
+ if (!fd_tab->entries) {
+ _mesa_hash_table_destroy(fd_tab, NULL);
+ fd_tab = NULL;
+ }
}
mtx_unlock(&fd_screen_mutex);
@@ -64,7 +69,8 @@ fd_drm_screen_destroy(struct pipe_screen *pscreen)
}
struct pipe_screen *
-fd_drm_screen_create(int fd, struct renderonly *ro)
+fd_drm_screen_create(int fd, struct renderonly *ro,
+ const struct pipe_screen_config *config)
{
struct pipe_screen *pscreen = NULL;
@@ -83,7 +89,7 @@ fd_drm_screen_create(int fd, struct renderonly *ro)
if (!dev)
goto unlock;
- pscreen = fd_screen_create(dev, ro);
+ pscreen = fd_screen_create(dev, ro, config);
if (pscreen) {
int fd = fd_device_fd(dev);
diff --git a/lib/mesa/src/gallium/winsys/i915/drm/Android.mk b/lib/mesa/src/gallium/winsys/i915/drm/Android.mk
deleted file mode 100644
index bab3e85c5..000000000
--- a/lib/mesa/src/gallium/winsys/i915/drm/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
-# Copyright (C) 2010-2011 LunarG Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_SHARED_LIBRARIES := libdrm_intel
-LOCAL_MODULE := libmesa_winsys_i915
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
-
-ifneq ($(HAVE_GALLIUM_I915),)
-$(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES))
-endif
diff --git a/lib/mesa/src/gallium/winsys/i915/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/i915/drm/Makefile.sources
deleted file mode 100644
index 1e1f56247..000000000
--- a/lib/mesa/src/gallium/winsys/i915/drm/Makefile.sources
+++ /dev/null
@@ -1,7 +0,0 @@
-C_SOURCES := \
- i915_drm_batchbuffer.c \
- i915_drm_buffer.c \
- i915_drm_fence.c \
- i915_drm_public.h \
- i915_drm_winsys.c \
- i915_drm_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/iris/drm/Android.mk b/lib/mesa/src/gallium/winsys/iris/drm/Android.mk
deleted file mode 100644
index 820f32c3e..000000000
--- a/lib/mesa/src/gallium/winsys/iris/drm/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2018 Intel Corporation
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
- libmesa_isl \
- libmesa_intel_dev
-
-LOCAL_SHARED_LIBRARIES := libdrm_intel
-LOCAL_MODULE := libmesa_winsys_iris
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/iris/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/iris/drm/Makefile.sources
deleted file mode 100644
index f5da79876..000000000
--- a/lib/mesa/src/gallium/winsys/iris/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- iris_drm_public.h \
- iris_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/kmsro/drm/Android.mk b/lib/mesa/src/gallium/winsys/kmsro/drm/Android.mk
deleted file mode 100644
index 439d2cc0e..000000000
--- a/lib/mesa/src/gallium/winsys/kmsro/drm/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_kmsro
-
-$(foreach d, $(MESA_BUILD_GALLIUM), $(eval LOCAL_CFLAGS += $(patsubst HAVE_%,-D%,$(d))))
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/kmsro/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/kmsro/drm/Makefile.sources
deleted file mode 100644
index 220b6fc82..000000000
--- a/lib/mesa/src/gallium/winsys/kmsro/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- kmsro_drm_public.h \
- kmsro_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/lima/drm/Android.mk b/lib/mesa/src/gallium/winsys/lima/drm/Android.mk
deleted file mode 100644
index cd5e5ad56..000000000
--- a/lib/mesa/src/gallium/winsys/lima/drm/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.io>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- lima_drm_public.h \
- lima_drm_winsys.c
-
-LOCAL_MODULE := libmesa_winsys_lima
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/nouveau/drm/Android.mk b/lib/mesa/src/gallium/winsys/nouveau/drm/Android.mk
deleted file mode 100644
index b9b8812a3..000000000
--- a/lib/mesa/src/gallium/winsys/nouveau/drm/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2011 Chia-I Wu <olvaffe@gmail.com>
-# Copyright (C) 2011 LunarG Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_SHARED_LIBRARIES := libdrm_nouveau
-LOCAL_MODULE := libmesa_winsys_nouveau
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/nouveau/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/nouveau/drm/Makefile.sources
deleted file mode 100644
index 9f70e9f49..000000000
--- a/lib/mesa/src/gallium/winsys/nouveau/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- nouveau_drm_public.h \
- nouveau_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/panfrost/drm/Android.mk b/lib/mesa/src/gallium/winsys/panfrost/drm/Android.mk
deleted file mode 100644
index 5f286856b..000000000
--- a/lib/mesa/src/gallium/winsys/panfrost/drm/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_panfrost
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/panfrost/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/panfrost/drm/Makefile.sources
deleted file mode 100644
index 24a107309..000000000
--- a/lib/mesa/src/gallium/winsys/panfrost/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- panfrost_drm_public.h \
- panfrost_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/radeon/drm/Android.mk b/lib/mesa/src/gallium/winsys/radeon/drm/Android.mk
deleted file mode 100644
index 2e0c40c06..000000000
--- a/lib/mesa/src/gallium/winsys/radeon/drm/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2011 Chia-I Wu <olvaffe@gmail.com>
-# Copyright (C) 2011 LunarG Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_SHARED_LIBRARIES := libdrm_radeon
-LOCAL_MODULE := libmesa_winsys_radeon
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/radeon/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/radeon/drm/Makefile.sources
deleted file mode 100644
index a00c84d35..000000000
--- a/lib/mesa/src/gallium/winsys/radeon/drm/Makefile.sources
+++ /dev/null
@@ -1,13 +0,0 @@
-C_SOURCES := \
- radeon_drm_bo.c \
- radeon_drm_bo.h \
- radeon_drm_cs.c \
- radeon_drm_cs_dump.c \
- radeon_drm_cs.h \
- radeon_drm_public.h \
- radeon_drm_surface.c \
- radeon_drm_winsys.c \
- radeon_drm_winsys.h
-
-TOOLS_HDR := \
- radeon_ctx.h
diff --git a/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index a9eaf9688..c5e92ec67 100644
--- a/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -475,7 +475,7 @@ static unsigned radeon_drm_cs_get_buffer_list(struct radeon_cmdbuf *rcs,
return cs->csc->num_relocs;
}
-void radeon_drm_cs_emit_ioctl_oneshot(void *job, int thread_index)
+void radeon_drm_cs_emit_ioctl_oneshot(void *job, void *gdata, int thread_index)
{
struct radeon_cs_context *csc = ((struct radeon_drm_cs*)job)->cst;
unsigned i;
@@ -710,7 +710,7 @@ static int radeon_drm_cs_flush(struct radeon_cmdbuf *rcs,
if (!(flags & PIPE_FLUSH_ASYNC))
radeon_drm_cs_sync_flush(rcs);
} else {
- radeon_drm_cs_emit_ioctl_oneshot(cs, 0);
+ radeon_drm_cs_emit_ioctl_oneshot(cs, NULL, 0);
}
} else {
radeon_cs_context_cleanup(cs->cst);
diff --git a/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 08ee7e7e5..22d8b98ac 100644
--- a/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -314,13 +314,14 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
}
/* Check for UVD and VCE */
- ws->info.has_hw_decode = false;
+ ws->info.has_video_hw.uvd_decode = false;
+ ws->info.has_video_hw.vce_encode = false;
ws->info.vce_fw_version = 0x00000000;
if (ws->info.drm_minor >= 32) {
uint32_t value = RADEON_CS_RING_UVD;
if (radeon_get_drm_value(ws->fd, RADEON_INFO_RING_WORKING,
"UVD Ring working", &value)) {
- ws->info.has_hw_decode = value;
+ ws->info.has_video_hw.uvd_decode = value;
ws->info.num_rings[RING_UVD] = 1;
}
@@ -332,6 +333,7 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
"VCE FW version", &value)) {
ws->info.vce_fw_version = value;
ws->info.num_rings[RING_VCE] = 1;
+ ws->info.has_video_hw.vce_encode = true;
}
}
}
@@ -605,8 +607,6 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
ws->info.max_wave64_per_simd = 10;
ws->info.num_physical_sgprs_per_simd = 512;
ws->info.num_physical_wave64_vgprs_per_simd = 256;
- /* Potential hang on Kabini: */
- ws->info.use_late_alloc = ws->info.family != CHIP_KABINI;
ws->info.has_3d_cube_border_color_mipmap = true;
ws->check_vm = strstr(debug_get_option("R600_DEBUG", ""), "check_vm") != NULL ||
@@ -938,7 +938,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
ws->info.pte_fragment_size = 64 * 1024; /* GPUVM page size */
if (ws->num_cpus > 1 && debug_get_option_thread())
- util_queue_init(&ws->cs_queue, "rcs", 8, 1, 0);
+ util_queue_init(&ws->cs_queue, "rcs", 8, 1, 0, NULL);
/* Create the screen at the end. The winsys must be initialized
* completely.
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/Android.mk b/lib/mesa/src/gallium/winsys/svga/drm/Android.mk
deleted file mode 100644
index 67c9f4f46..000000000
--- a/lib/mesa/src/gallium/winsys/svga/drm/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
-# Copyright (C) 2010-2011 LunarG Inc.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_CFLAGS := -D_FILE_OFFSET_BITS=64
-
-LOCAL_C_INCLUDES := \
- $(GALLIUM_TOP)/drivers/svga \
- $(GALLIUM_TOP)/drivers/svga/include
-
-LOCAL_MODULE := libmesa_winsys_svga
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/svga/drm/Makefile.sources
deleted file mode 100644
index ab2b9321f..000000000
--- a/lib/mesa/src/gallium/winsys/svga/drm/Makefile.sources
+++ /dev/null
@@ -1,20 +0,0 @@
-C_SOURCES := \
- pb_buffer_simple_fenced.c \
- svga_drm_public.h \
- vmw_buffer.c \
- vmw_buffer.h \
- vmw_context.c \
- vmw_context.h \
- vmw_fence.c \
- vmw_fence.h \
- vmwgfx_drm.h \
- vmw_screen.c \
- vmw_screen_dri.c \
- vmw_screen.h \
- vmw_screen_ioctl.c \
- vmw_screen_pools.c \
- vmw_screen_svga.c \
- vmw_surface.c \
- vmw_surface.h \
- vmw_shader.c \
- vmw_shader.h
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c
index e97f1621e..60051bbdf 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.c
@@ -27,6 +27,8 @@
#include "vmw_screen.h"
#include "vmw_fence.h"
#include "vmw_context.h"
+#include "vmwgfx_drm.h"
+#include "xf86drm.h"
#include "util/os_file.h"
#include "util/u_memory.h"
@@ -41,6 +43,8 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
static struct hash_table *dev_hash = NULL;
@@ -55,6 +59,61 @@ static uint32_t vmw_dev_hash(const void *key)
return (major(*(dev_t *) key) << 16) | minor(*(dev_t *) key);
}
+#ifdef VMX86_STATS
+/**
+ * Initializes mksstat TLS store.
+ */
+static void
+vmw_winsys_screen_init_mksstat(struct vmw_winsys_screen *vws)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(vws->mksstat_tls); ++i) {
+ vws->mksstat_tls[i].stat_pages = NULL;
+ vws->mksstat_tls[i].stat_id = -1UL;
+ vws->mksstat_tls[i].pid = 0;
+ }
+}
+
+/**
+ * Deinits mksstat TLS store.
+ */
+static void
+vmw_winsys_screen_deinit_mksstat(struct vmw_winsys_screen *vws)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(vws->mksstat_tls); ++i) {
+ uint32_t expected = __atomic_load_n(&vws->mksstat_tls[i].pid, __ATOMIC_ACQUIRE);
+
+ if (expected == -1U) {
+ fprintf(stderr, "%s encountered locked mksstat TLS entry at index %lu.\n", __FUNCTION__, i);
+ continue;
+ }
+
+ if (expected == 0)
+ continue;
+
+ if (__atomic_compare_exchange_n(&vws->mksstat_tls[i].pid, &expected, 0, false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) {
+ struct drm_vmw_mksstat_remove_arg arg = {
+ .id = vws->mksstat_tls[i].stat_id
+ };
+
+ assert(vws->mksstat_tls[i].stat_pages);
+ assert(vws->mksstat_tls[i].stat_id != -1UL);
+
+ if (drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_MKSSTAT_REMOVE, &arg, sizeof(arg))) {
+ fprintf(stderr, "%s could not ioctl: %s\n", __FUNCTION__, strerror(errno));
+ } else if (munmap(vws->mksstat_tls[i].stat_pages, vmw_svga_winsys_stats_len())) {
+ fprintf(stderr, "%s could not munmap: %s\n", __FUNCTION__, strerror(errno));
+ }
+ } else {
+ fprintf(stderr, "%s encountered volatile mksstat TLS entry at index %lu.\n", __FUNCTION__, i);
+ }
+ }
+}
+
+#endif
/* Called from vmw_drm_create_screen(), creates and initializes the
* vmw_winsys_screen structure, which is the main entity in this
* module.
@@ -112,6 +171,9 @@ vmw_winsys_create( int fd )
if (!vmw_winsys_screen_init_svga(vws))
goto out_no_svga;
+#ifdef VMX86_STATS
+ vmw_winsys_screen_init_mksstat(vws);
+#endif
_mesa_hash_table_insert(dev_hash, &vws->device, vws);
cnd_init(&vws->cs_cond);
@@ -139,6 +201,9 @@ vmw_winsys_destroy(struct vmw_winsys_screen *vws)
vmw_pools_cleanup(vws);
vws->fence_ops->destroy(vws->fence_ops);
vmw_ioctl_cleanup(vws);
+#ifdef VMX86_STATS
+ vmw_winsys_screen_deinit_mksstat(vws);
+#endif
close(vws->ioctl.drm_fd);
mtx_destroy(&vws->cs_mutex);
cnd_destroy(&vws->cs_cond);
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h
index 73f04435a..170892130 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen.h
@@ -81,6 +81,7 @@ struct vmw_winsys_screen
boolean have_drm_2_16;
boolean have_drm_2_17;
boolean have_drm_2_18;
+ boolean have_drm_2_19;
} ioctl;
struct {
@@ -99,6 +100,17 @@ struct vmw_winsys_screen
struct pb_fence_ops *fence_ops;
+#ifdef VMX86_STATS
+ /*
+ * mksGuestStats TLS array; length must be power of two
+ */
+ struct {
+ void * stat_pages;
+ uint64_t stat_id;
+ uint32_t pid;
+ } mksstat_tls[64];
+
+#endif
/*
* Screen instances
*/
@@ -257,4 +269,7 @@ void
vmw_svga_winsys_shader_destroy(struct svga_winsys_screen *sws,
struct svga_winsys_gb_shader *shader);
+size_t
+vmw_svga_winsys_stats_len(void);
+
#endif /* VMW_SCREEN_H_ */
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
index a44c22c75..c470b7ba5 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c
@@ -1003,6 +1003,8 @@ vmw_ioctl_init(struct vmw_winsys_screen *vws)
(version->version_major == 2 && version->version_minor > 16);
vws->ioctl.have_drm_2_18 = version->version_major > 2 ||
(version->version_major == 2 && version->version_minor > 17);
+ vws->ioctl.have_drm_2_19 = version->version_major > 2 ||
+ (version->version_major == 2 && version->version_minor > 18);
vws->ioctl.drm_execbuf_version = vws->ioctl.have_drm_2_9 ? 2 : 1;
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_svga.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_svga.c
index 9cf5ad609..547d6ea6d 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_svga.c
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_screen_svga.c
@@ -33,6 +33,9 @@
*/
#include <libsync.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
#include "svga_cmd.h"
#include "svga3d_caps.h"
@@ -52,7 +55,9 @@
#include "vmw_msg.h"
#include "vmw_shader.h"
#include "vmw_query.h"
+#include "vmwgfx_drm.h"
#include "svga3d_surfacedefs.h"
+#include "xf86drm.h"
/**
* Try to get a surface backing buffer from the cache
@@ -60,6 +65,304 @@
*/
#define VMW_TRY_CACHED_SIZE (2*1024*1024)
+#ifdef VMX86_STATS
+static const char* const vmw_svga_winsys_stats_count_names[] = {
+ SVGA_STATS_COUNT_NAMES
+};
+
+static const char* const vmw_svga_winsys_stats_time_names[] = {
+ SVGA_STATS_TIME_NAMES
+};
+
+/*
+ * It's imperative that the above two arrays are const, so that the next
+ * function can be optimized to a constant.
+ */
+static inline size_t
+vmw_svga_winsys_stats_names_len(void)
+{
+ size_t i, res = 0;
+ for (i = 0; i < ARRAY_SIZE(vmw_svga_winsys_stats_count_names); ++i)
+ res += strlen(vmw_svga_winsys_stats_count_names[i]) + 1;
+ for (i = 0; i < ARRAY_SIZE(vmw_svga_winsys_stats_time_names); ++i)
+ res += strlen(vmw_svga_winsys_stats_time_names[i]) + 1;
+ return res;
+}
+
+typedef struct Atomic_uint64 {
+ uint64_t value;
+} Atomic_uint64;
+
+typedef struct MKSGuestStatCounter {
+ Atomic_uint64 count;
+} MKSGuestStatCounter;
+
+typedef struct MKSGuestStatCounterTime {
+ MKSGuestStatCounter counter;
+ Atomic_uint64 selfCycles;
+ Atomic_uint64 totalCycles;
+} MKSGuestStatCounterTime;
+
+#define MKS_GUEST_STAT_FLAG_NONE 0
+#define MKS_GUEST_STAT_FLAG_TIME (1U << 0)
+
+typedef __attribute__((aligned(32))) struct MKSGuestStatInfoEntry {
+ union {
+ const char *s;
+ uint64_t u;
+ } name;
+ union {
+ const char *s;
+ uint64_t u;
+ } description;
+ uint64_t flags;
+ union {
+ MKSGuestStatCounter *counter;
+ MKSGuestStatCounterTime *counterTime;
+ uint64_t u;
+ } stat;
+} MKSGuestStatInfoEntry;
+
+static __thread struct svga_winsys_stats_timeframe *mksstat_tls_global = NULL;
+
+#define ALIGN(x, power_of_two) (((x) + (power_of_two) - 1) & ~((power_of_two) - 1))
+
+static const size_t mksstat_area_size_info = sizeof(MKSGuestStatInfoEntry) * (SVGA_STATS_COUNT_MAX + SVGA_STATS_TIME_MAX);
+static const size_t mksstat_area_size_stat = sizeof(MKSGuestStatCounter) * SVGA_STATS_COUNT_MAX +
+ sizeof(MKSGuestStatCounterTime) * SVGA_STATS_TIME_MAX;
+
+size_t
+vmw_svga_winsys_stats_len(void)
+{
+ const size_t pg_size = getpagesize();
+ const size_t area_size_stat_pg = ALIGN(mksstat_area_size_stat, pg_size);
+ const size_t area_size_info_pg = ALIGN(mksstat_area_size_info, pg_size);
+ const size_t area_size_strs = vmw_svga_winsys_stats_names_len();
+ const size_t area_size = area_size_stat_pg + area_size_info_pg + area_size_strs;
+
+ return area_size;
+}
+
+/**
+ * vmw_mksstat_get_pstat: Computes the address of the MKSGuestStatCounter
+ * array from the address of the base page.
+ *
+ * @page_addr: Pointer to the base page.
+ * @page_size: Size of page.
+ * Return: Pointer to the MKSGuestStatCounter array.
+ */
+
+static inline MKSGuestStatCounter *
+vmw_mksstat_get_pstat(uint8_t *page_addr, size_t page_size)
+{
+ return (MKSGuestStatCounter *)page_addr;
+}
+
+/**
+ * vmw_mksstat_get_pstat_time: Computes the address of the MKSGuestStatCounterTime
+ * array from the address of the base page.
+ *
+ * @page_addr: Pointer to the base page.
+ * @page_size: Size of page.
+ * Return: Pointer to the MKSGuestStatCounterTime array.
+ */
+
+static inline MKSGuestStatCounterTime *
+vmw_mksstat_get_pstat_time(uint8_t *page_addr, size_t page_size)
+{
+ return (MKSGuestStatCounterTime *)(page_addr + sizeof(MKSGuestStatCounter) * SVGA_STATS_COUNT_MAX);
+}
+
+/**
+ * vmw_mksstat_get_pinfo: Computes the address of the MKSGuestStatInfoEntry
+ * array from the address of the base page.
+ *
+ * @page_addr: Pointer to the base page.
+ * @page_size: Size of page.
+ * Return: Pointer to the MKSGuestStatInfoEntry array.
+ */
+
+static inline MKSGuestStatInfoEntry *
+vmw_mksstat_get_pinfo(uint8_t *page_addr, size_t page_size)
+{
+ const size_t area_size_stat_pg = ALIGN(mksstat_area_size_stat, page_size);
+ return (MKSGuestStatInfoEntry *)(page_addr + area_size_stat_pg);
+}
+
+/**
+ * vmw_mksstat_get_pstrs: Computes the address of the mksGuestStat strings
+ * sequence from the address of the base page.
+ *
+ * @page_addr: Pointer to the base page.
+ * @page_size: Size of page.
+ * Return: Pointer to the mksGuestStat strings sequence.
+ */
+
+static inline char *
+vmw_mksstat_get_pstrs(uint8_t *page_addr, const size_t page_size)
+{
+ const size_t area_size_info_pg = ALIGN(mksstat_area_size_info, page_size);
+ const size_t area_size_stat_pg = ALIGN(mksstat_area_size_stat, page_size);
+ return (char *)(page_addr + area_size_info_pg + area_size_stat_pg);
+}
+
+/**
+ * Add all known mksGuestStats counters for tracking by the host.
+ */
+static int
+vmw_svga_winsys_add_stats(struct vmw_winsys_screen *vws, int slot)
+{
+ const size_t pg_size = getpagesize();
+ const size_t area_size = vmw_svga_winsys_stats_len();
+
+ MKSGuestStatInfoEntry *pinfo;
+ MKSGuestStatCounter *pstat;
+ MKSGuestStatCounterTime *pstatTime;
+ char *pstrs;
+ uint64_t id;
+ size_t i;
+
+ /* Allocate a contiguous area of pages for all info entries, counters and strings. */
+ void *area = mmap(NULL, area_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED | MAP_NORESERVE, -1, 0);
+
+ if (area == MAP_FAILED) {
+ fprintf(stderr, "%s could not mmap memory: %s\n", __FUNCTION__, strerror(errno));
+ return -1;
+ }
+
+ pinfo = vmw_mksstat_get_pinfo(area, pg_size);
+ pstat = vmw_mksstat_get_pstat(area, pg_size);
+ pstrs = vmw_mksstat_get_pstrs(area, pg_size);
+ pstatTime = vmw_mksstat_get_pstat_time(area, pg_size);
+
+ if (mlock(area, area_size)) {
+ fprintf(stderr, "%s could not mlock memory: %s\n", __FUNCTION__, strerror(errno));
+ goto error;
+ }
+
+ /* Suppress pages copy-on-write; for MAP_SHARED this should not really matter; it would if we go MAP_PRIVATE */
+ if (madvise(area, area_size, MADV_DONTFORK)) {
+ fprintf(stderr, "%s could not madvise memory: %s\n", __FUNCTION__, strerror(errno));
+ goto error;
+ }
+
+ /* Set up regular counters first */
+ for (i = 0; i < SVGA_STATS_COUNT_MAX; ++i) {
+ pinfo->name.s = pstrs;
+ pinfo->description.s = pstrs;
+ pinfo->flags = MKS_GUEST_STAT_FLAG_NONE;
+ pinfo->stat.counter = pstat + i;
+ pinfo++;
+
+ memcpy(pstrs, vmw_svga_winsys_stats_count_names[i], strlen(vmw_svga_winsys_stats_count_names[i]));
+ pstrs += strlen(vmw_svga_winsys_stats_count_names[i]) + 1;
+ }
+
+ /* Set up time counters second */
+ for (i = 0; i < SVGA_STATS_TIME_MAX; ++i) {
+ pinfo->name.s = pstrs;
+ pinfo->description.s = pstrs;
+ pinfo->flags = MKS_GUEST_STAT_FLAG_TIME;
+ pinfo->stat.counterTime = pstatTime + i;
+ pinfo++;
+
+ memcpy(pstrs, vmw_svga_winsys_stats_time_names[i], strlen(vmw_svga_winsys_stats_time_names[i]));
+ pstrs += strlen(vmw_svga_winsys_stats_time_names[i]) + 1;
+ }
+
+ { /* ioctl(DRM_VMW_MKSSTAT_ADD) */
+ char desc[64];
+ snprintf(desc, sizeof(desc) - 1, "vmw_winsys_screen=%p pid=%d", vws, gettid());
+
+ struct drm_vmw_mksstat_add_arg arg = {
+ .stat = (uintptr_t)pstat,
+ .info = (uintptr_t)vmw_mksstat_get_pinfo(area, pg_size),
+ .strs = (uintptr_t)vmw_mksstat_get_pstrs(area, pg_size),
+ .stat_len = mksstat_area_size_stat,
+ .info_len = mksstat_area_size_info,
+ .strs_len = vmw_svga_winsys_stats_names_len(),
+ .description = (uintptr_t)desc,
+ .id = -1U
+ };
+ if (drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_MKSSTAT_ADD, &arg, sizeof(arg))) {
+ fprintf(stderr, "%s could not ioctl: %s\n", __FUNCTION__, strerror(errno));
+ goto error;
+ }
+ id = arg.id;
+ }
+
+ vws->mksstat_tls[slot].stat_pages = area;
+ vws->mksstat_tls[slot].stat_id = id;
+ /* Don't update vws->mksstat_tls[].pid as it's reserved. */
+ return 0;
+
+error:
+ munmap(area, area_size);
+ return -1;
+}
+
+/**
+ * Acquire a mksstat TLS slot making it immutable by other parties.
+ */
+static inline int
+vmw_winsys_screen_mksstat_acq_slot(struct vmw_winsys_screen *vws)
+{
+ const pid_t pid = gettid();
+ const size_t base = (size_t)pid % ARRAY_SIZE(vws->mksstat_tls);
+ size_t i;
+
+ if (mksstat_tls_global && vmw_winsys_screen(mksstat_tls_global->sws) == vws) {
+ const size_t slot = mksstat_tls_global->slot;
+ uint32_t expecpid = pid;
+ if (__atomic_compare_exchange_n(&vws->mksstat_tls[slot].pid, &expecpid, -1U, false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
+ return (int)slot;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(vws->mksstat_tls); ++i) {
+ const size_t slot = (i + base) % ARRAY_SIZE(vws->mksstat_tls);
+ uint32_t expecpid = pid;
+ uint32_t expected = 0;
+
+ /* Check if pid is already present */
+ if (__atomic_compare_exchange_n(&vws->mksstat_tls[slot].pid, &expecpid, -1U, false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
+ return (int)slot;
+
+ /* Try to set up a new mksstat for this pid */
+ if (__atomic_compare_exchange_n(&vws->mksstat_tls[slot].pid, &expected, -1U, false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) {
+ const int ret = vmw_svga_winsys_add_stats(vws, slot);
+
+ if (!ret)
+ return (int)slot;
+
+ __atomic_store_n(&vws->mksstat_tls[slot].pid, 0, __ATOMIC_RELEASE);
+ return ret;
+ }
+ }
+
+ return -1;
+}
+
+/**
+ * Release a mksstat TLS slot -- caller still owns the slot but now it is erasable by other parties.
+ */
+static inline void
+vmw_winsys_screen_mksstat_rel_slot(struct vmw_winsys_screen *vws, int slot)
+{
+ assert(slot < ARRAY_SIZE(vws->mksstat_tls));
+
+ __atomic_store_n(&vws->mksstat_tls[slot].pid, gettid(), __ATOMIC_RELEASE);
+}
+
+static inline uint64_t
+rdtsc(void)
+{
+ uint32_t hi, lo;
+ __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
+ return (uint64_t)lo | ((uint64_t)hi << 32);
+}
+
+#endif /* VMX86_STATS */
+
static struct svga_winsys_buffer *
vmw_svga_winsys_buffer_create(struct svga_winsys_screen *sws,
unsigned alignment,
@@ -465,20 +768,110 @@ vmw_svga_winsys_shader_destroy(struct svga_winsys_screen *sws,
vmw_svga_winsys_shader_reference(&d_shader, NULL);
}
+#ifdef VMX86_STATS
static void
-vmw_svga_winsys_stats_inc(enum svga_stats_count index)
+vmw_svga_winsys_stats_inc(struct svga_winsys_screen *sws,
+ enum svga_stats_count index)
{
+ struct vmw_winsys_screen *const vws = vmw_winsys_screen(sws);
+ const int slot = vmw_winsys_screen_mksstat_acq_slot(vws);
+ assert(index < SVGA_STATS_COUNT_MAX);
+
+ if (slot >= 0) {
+ MKSGuestStatCounter *pstat;
+ assert(vws->mksstat_tls[slot].stat_pages);
+ assert(vws->mksstat_tls[slot].stat_id != -1UL);
+
+ pstat = vmw_mksstat_get_pstat(vws->mksstat_tls[slot].stat_pages, getpagesize());
+
+ __atomic_fetch_add(&pstat[index].count.value, 1, __ATOMIC_ACQ_REL);
+
+ vmw_winsys_screen_mksstat_rel_slot(vws, slot);
+ }
}
static void
-vmw_svga_winsys_stats_time_push(enum svga_stats_time index,
+vmw_svga_winsys_stats_time_push(struct svga_winsys_screen *sws,
+ enum svga_stats_time index,
struct svga_winsys_stats_timeframe *tf)
{
+ struct vmw_winsys_screen *const vws = vmw_winsys_screen(sws);
+ const int slot = vmw_winsys_screen_mksstat_acq_slot(vws);
+
+ if (slot < 0)
+ return;
+
+ assert(vws->mksstat_tls[slot].stat_pages);
+ assert(vws->mksstat_tls[slot].stat_id != -1UL);
+
+ tf->counterTime = vmw_mksstat_get_pstat_time(vws->mksstat_tls[slot].stat_pages, getpagesize()) + index;
+
+ vmw_winsys_screen_mksstat_rel_slot(vws, slot);
+
+ tf->startTime = rdtsc();
+ tf->enclosing = mksstat_tls_global;
+ tf->sws = sws;
+ tf->slot = slot;
+
+ mksstat_tls_global = tf;
+}
+
+static void
+vmw_svga_winsys_stats_time_pop(struct svga_winsys_screen *sws)
+{
+ struct svga_winsys_stats_timeframe *const tf = mksstat_tls_global;
+ struct vmw_winsys_screen *const vws = vmw_winsys_screen(sws);
+ const int slot = tf->slot;
+ uint32_t expected = gettid();
+
+ mksstat_tls_global = tf->enclosing;
+
+ if (slot < 0)
+ return;
+
+ if (__atomic_compare_exchange_n(&vws->mksstat_tls[slot].pid, &expected, -1U, false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) {
+ const uint64_t dt = rdtsc() - tf->startTime;
+ MKSGuestStatCounterTime *const counterTime = tf->counterTime;
+
+ assert(vws->mksstat_tls[slot].stat_pages);
+ assert(vws->mksstat_tls[slot].stat_id != -1UL);
+
+ __atomic_fetch_add(&counterTime->counter.count.value, 1, __ATOMIC_ACQ_REL);
+ __atomic_fetch_add(&counterTime->selfCycles.value, dt, __ATOMIC_ACQ_REL);
+ __atomic_fetch_add(&counterTime->totalCycles.value, dt, __ATOMIC_ACQ_REL);
+
+ if (tf->enclosing) {
+ MKSGuestStatCounterTime *const counterTime = tf->enclosing->counterTime;
+
+ assert(counterTime);
+
+ __atomic_fetch_sub(&counterTime->selfCycles.value, dt, __ATOMIC_ACQ_REL);
+ }
+
+ __atomic_store_n(&vws->mksstat_tls[slot].pid, expected, __ATOMIC_RELEASE);
+ }
+}
+
+#endif /* VMX86_STATS */
+static void
+vmw_svga_winsys_stats_inc_noop(struct svga_winsys_screen *sws,
+ enum svga_stats_count index)
+{
+ /* noop */
}
static void
-vmw_svga_winsys_stats_time_pop()
+vmw_svga_winsys_stats_time_push_noop(struct svga_winsys_screen *sws,
+ enum svga_stats_time index,
+ struct svga_winsys_stats_timeframe *tf)
{
+ /* noop */
+}
+
+static void
+vmw_svga_winsys_stats_time_pop_noop(struct svga_winsys_screen *sws)
+{
+ /* noop */
}
boolean
@@ -511,10 +904,23 @@ vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws)
vws->base.query_destroy = vmw_svga_winsys_query_destroy;
vws->base.query_get_result = vmw_svga_winsys_query_get_result;
- vws->base.stats_inc = vmw_svga_winsys_stats_inc;
- vws->base.stats_time_push = vmw_svga_winsys_stats_time_push;
- vws->base.stats_time_pop = vmw_svga_winsys_stats_time_pop;
+#ifdef VMX86_STATS
+ if (vws->ioctl.have_drm_2_19) {
+ vws->base.stats_inc = vmw_svga_winsys_stats_inc;
+ vws->base.stats_time_push = vmw_svga_winsys_stats_time_push;
+ vws->base.stats_time_pop = vmw_svga_winsys_stats_time_pop;
+ } else {
+ vws->base.stats_inc = vmw_svga_winsys_stats_inc_noop;
+ vws->base.stats_time_push = vmw_svga_winsys_stats_time_push_noop;
+ vws->base.stats_time_pop = vmw_svga_winsys_stats_time_pop_noop;
+ }
+
+#else
+ vws->base.stats_inc = vmw_svga_winsys_stats_inc_noop;
+ vws->base.stats_time_push = vmw_svga_winsys_stats_time_push_noop;
+ vws->base.stats_time_pop = vmw_svga_winsys_stats_time_pop_noop;
+#endif
vws->base.host_log = vmw_svga_winsys_host_log;
return TRUE;
diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmwgfx_drm.h b/lib/mesa/src/gallium/winsys/svga/drm/vmwgfx_drm.h
index 9b422e551..9078775fe 100644
--- a/lib/mesa/src/gallium/winsys/svga/drm/vmwgfx_drm.h
+++ b/lib/mesa/src/gallium/winsys/svga/drm/vmwgfx_drm.h
@@ -72,6 +72,9 @@ extern "C" {
#define DRM_VMW_GB_SURFACE_CREATE_EXT 27
#define DRM_VMW_GB_SURFACE_REF_EXT 28
#define DRM_VMW_MSG 29
+#define DRM_VMW_MKSSTAT_RESET 30
+#define DRM_VMW_MKSSTAT_ADD 31
+#define DRM_VMW_MKSSTAT_REMOVE 32
/*************************************************************************/
/**
@@ -86,6 +89,9 @@ extern "C" {
*
* DRM_VMW_PARAM_SM4_1
* SM4_1 support is enabled.
+ *
+ * DRM_VMW_PARAM_SM5
+ * SM5 support is enabled.
*/
#define DRM_VMW_PARAM_NUM_STREAMS 0
@@ -1134,7 +1140,7 @@ struct drm_vmw_handle_close_arg {
* svga3d surface flags split into 2, upper half and lower half.
*/
enum drm_vmw_surface_version {
- drm_vmw_gb_surface_v1
+ drm_vmw_gb_surface_v1,
};
/**
@@ -1233,6 +1239,44 @@ struct drm_vmw_msg_arg {
__u32 receive_len;
};
+/**
+ * struct drm_vmw_mksstat_add_arg
+ *
+ * @stat: Pointer to user-space stat-counters array, page-aligned.
+ * @info: Pointer to user-space counter-infos array, page-aligned.
+ * @strs: Pointer to user-space stat strings, page-aligned.
+ * @stat_len: Length in bytes of stat-counters array.
+ * @info_len: Length in bytes of counter-infos array.
+ * @strs_len: Length in bytes of the stat strings, terminators included.
+ * @description: Pointer to instance descriptor string; will be truncated
+ * to MKS_GUEST_STAT_INSTANCE_DESC_LENGTH chars.
+ * @id: Output identifier of the produced record; -1 if error.
+ *
+ * Argument to the DRM_VMW_MKSSTAT_ADD ioctl.
+ */
+struct drm_vmw_mksstat_add_arg {
+ __u64 stat;
+ __u64 info;
+ __u64 strs;
+ __u64 stat_len;
+ __u64 info_len;
+ __u64 strs_len;
+ __u64 description;
+ __u64 id;
+};
+
+/**
+ * struct drm_vmw_mksstat_remove_arg
+ *
+ * @id: Identifier of the record being disposed, originally obtained through
+ * DRM_VMW_MKSSTAT_ADD ioctl.
+ *
+ * Argument to the DRM_VMW_MKSSTAT_REMOVE ioctl.
+ */
+struct drm_vmw_mksstat_remove_arg {
+ __u64 id;
+};
+
#if defined(__cplusplus)
}
#endif
diff --git a/lib/mesa/src/gallium/winsys/sw/dri/Android.mk b/lib/mesa/src/gallium/winsys/sw/dri/Android.mk
deleted file mode 100644
index 72fb920ff..000000000
--- a/lib/mesa/src/gallium/winsys/sw/dri/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Mesa 3-D graphics library
-#
-# Copyright (C) 2015 Chih-Wei Huang <cwhuang@linux.org.tw>
-# Copyright (C) 2015 Android-x86 Open Source Project
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_sw_dri
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/sw/dri/Makefile.sources b/lib/mesa/src/gallium/winsys/sw/dri/Makefile.sources
deleted file mode 100644
index 5f9178fdb..000000000
--- a/lib/mesa/src/gallium/winsys/sw/dri/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- dri_sw_winsys.c \
- dri_sw_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/sw/kms-dri/Android.mk b/lib/mesa/src/gallium/winsys/sw/kms-dri/Android.mk
deleted file mode 100644
index f5c1ccab1..000000000
--- a/lib/mesa/src/gallium/winsys/sw/kms-dri/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2017 Linaro, Ltd., Rob Herring <robh@kernel.org>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_sw_kms_dri
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/sw/kms-dri/Makefile.sources b/lib/mesa/src/gallium/winsys/sw/kms-dri/Makefile.sources
deleted file mode 100644
index 4bf832bdb..000000000
--- a/lib/mesa/src/gallium/winsys/sw/kms-dri/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- kms_dri_sw_winsys.c \
- kms_dri_sw_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/sw/null/Makefile.sources b/lib/mesa/src/gallium/winsys/sw/null/Makefile.sources
deleted file mode 100644
index b72310bca..000000000
--- a/lib/mesa/src/gallium/winsys/sw/null/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- null_sw_winsys.c \
- null_sw_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/sw/wrapper/Makefile.sources b/lib/mesa/src/gallium/winsys/sw/wrapper/Makefile.sources
deleted file mode 100644
index 742e49b1c..000000000
--- a/lib/mesa/src/gallium/winsys/sw/wrapper/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- wrapper_sw_winsys.c \
- wrapper_sw_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/sw/xlib/Makefile.sources b/lib/mesa/src/gallium/winsys/sw/xlib/Makefile.sources
deleted file mode 100644
index fc6a56d49..000000000
--- a/lib/mesa/src/gallium/winsys/sw/xlib/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- xlib_sw_winsys.c \
- xlib_sw_winsys.h
diff --git a/lib/mesa/src/gallium/winsys/tegra/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/tegra/drm/Makefile.sources
deleted file mode 100644
index 29a0edc9c..000000000
--- a/lib/mesa/src/gallium/winsys/tegra/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- tegra_drm_public.h \
- tegra_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/v3d/drm/Android.mk b/lib/mesa/src/gallium/winsys/v3d/drm/Android.mk
deleted file mode 100644
index 4cdd969c2..000000000
--- a/lib/mesa/src/gallium/winsys/v3d/drm/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_v3d
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/v3d/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/v3d/drm/Makefile.sources
deleted file mode 100644
index 1fdeefbcb..000000000
--- a/lib/mesa/src/gallium/winsys/v3d/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- v3d_drm_public.h \
- v3d_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/vc4/drm/Android.mk b/lib/mesa/src/gallium/winsys/vc4/drm/Android.mk
deleted file mode 100644
index af5813dd2..000000000
--- a/lib/mesa/src/gallium/winsys/vc4/drm/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_vc4
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/vc4/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/vc4/drm/Makefile.sources
deleted file mode 100644
index 19cadf780..000000000
--- a/lib/mesa/src/gallium/winsys/vc4/drm/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- vc4_drm_public.h \
- vc4_drm_winsys.c
diff --git a/lib/mesa/src/gallium/winsys/virgl/common/Android.mk b/lib/mesa/src/gallium/winsys/virgl/common/Android.mk
deleted file mode 100644
index c2b25cbe8..000000000
--- a/lib/mesa/src/gallium/winsys/virgl/common/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2019 Collabora Ltd.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_virgl_common
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/virgl/common/Makefile.sources b/lib/mesa/src/gallium/winsys/virgl/common/Makefile.sources
deleted file mode 100644
index 09a9ba46d..000000000
--- a/lib/mesa/src/gallium/winsys/virgl/common/Makefile.sources
+++ /dev/null
@@ -1,3 +0,0 @@
-C_SOURCES := \
- virgl_resource_cache.h \
- virgl_resource_cache.c
diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk b/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk
deleted file mode 100644
index 5e2500774..000000000
--- a/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_virgl
-
-LOCAL_STATIC_LIBRARIES := libmesa_winsys_virgl_common
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.sources b/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.sources
deleted file mode 100644
index 0430d4ada..000000000
--- a/lib/mesa/src/gallium/winsys/virgl/drm/Makefile.sources
+++ /dev/null
@@ -1,5 +0,0 @@
-C_SOURCES := \
- virgl_drm_public.h \
- virgl_drm_winsys.c \
- virgl_drm_winsys.h \
- virtgpu_drm.h
diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
index b49464d1e..6bb14d727 100644
--- a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
+++ b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c
@@ -48,6 +48,9 @@
#include "virgl_drm_winsys.h"
#include "virgl_drm_public.h"
+// Delete local definitions when virglrenderer_hw.h becomes public
+#define VIRGL_DRM_CAPSET_VIRGL 1
+#define VIRGL_DRM_CAPSET_VIRGL2 2
#define VIRGL_DRM_VERSION(major, minor) ((major) << 16 | (minor))
#define VIRGL_DRM_VERSION_FENCE_FD VIRGL_DRM_VERSION(0, 1)
@@ -63,7 +66,10 @@ static inline boolean can_cache_resource(uint32_t bind)
bind == VIRGL_BIND_VERTEX_BUFFER ||
bind == VIRGL_BIND_CUSTOM ||
bind == VIRGL_BIND_STAGING ||
- bind == VIRGL_BIND_DEPTH_STENCIL;
+ bind == VIRGL_BIND_DEPTH_STENCIL ||
+ bind == VIRGL_BIND_SAMPLER_VIEW ||
+ bind == VIRGL_BIND_RENDER_TARGET ||
+ bind == 0;
}
static void virgl_hw_res_destroy(struct virgl_drm_winsys *qdws,
@@ -176,6 +182,17 @@ virgl_drm_winsys_resource_create_blob(struct virgl_winsys *qws,
struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws);
struct drm_virtgpu_resource_create_blob drm_rc_blob = { 0 };
struct virgl_hw_res *res;
+ struct virgl_resource_params params = { .size = size,
+ .bind = bind,
+ .format = format,
+ .flags = flags,
+ .nr_samples = nr_samples,
+ .width = width,
+ .height = height,
+ .depth = depth,
+ .array_size = array_size,
+ .last_level = last_level,
+ .target = target };
res = CALLOC_STRUCT(virgl_hw_res);
if (!res)
@@ -224,8 +241,7 @@ virgl_drm_winsys_resource_create_blob(struct virgl_winsys *qws,
pipe_reference_init(&res->reference, 1);
p_atomic_set(&res->external, false);
p_atomic_set(&res->num_cs_references, 0);
- virgl_resource_cache_entry_init(&res->cache_entry, size, bind, format,
- flags);
+ virgl_resource_cache_entry_init(&res->cache_entry, params);
return res;
}
@@ -248,6 +264,17 @@ virgl_drm_winsys_resource_create(struct virgl_winsys *qws,
int ret;
struct virgl_hw_res *res;
uint32_t stride = width * util_format_get_blocksize(format);
+ struct virgl_resource_params params = { .size = size,
+ .bind = bind,
+ .format = format,
+ .flags = 0,
+ .nr_samples = nr_samples,
+ .width = width,
+ .height = height,
+ .depth = depth,
+ .array_size = array_size,
+ .last_level = last_level,
+ .target = target };
res = CALLOC_STRUCT(virgl_hw_res);
if (!res)
@@ -289,7 +316,7 @@ virgl_drm_winsys_resource_create(struct virgl_winsys *qws,
*/
p_atomic_set(&res->maybe_busy, for_fencing);
- virgl_resource_cache_entry_init(&res->cache_entry, size, bind, format, 0);
+ virgl_resource_cache_entry_init(&res->cache_entry, params);
return res;
}
@@ -390,14 +417,24 @@ virgl_drm_winsys_resource_cache_create(struct virgl_winsys *qws,
struct virgl_drm_winsys *qdws = virgl_drm_winsys(qws);
struct virgl_hw_res *res;
struct virgl_resource_cache_entry *entry;
+ struct virgl_resource_params params = { .size = size,
+ .bind = bind,
+ .format = format,
+ .flags = flags,
+ .nr_samples = nr_samples,
+ .width = width,
+ .height = height,
+ .depth = depth,
+ .array_size = array_size,
+ .last_level = last_level,
+ .target = target };
if (!can_cache_resource(bind))
goto alloc;
mtx_lock(&qdws->mutex);
- entry = virgl_resource_cache_remove_compatible(&qdws->cache, size,
- bind, format, flags);
+ entry = virgl_resource_cache_remove_compatible(&qdws->cache, params);
if (entry) {
res = cache_entry_container_res(entry);
mtx_unlock(&qdws->mutex);
@@ -1118,6 +1155,47 @@ virgl_drm_resource_cache_entry_release(struct virgl_resource_cache_entry *entry,
virgl_hw_res_destroy(qdws, res);
}
+static int virgl_init_context(int drmFD)
+{
+ int ret;
+ struct drm_virtgpu_context_init init = { 0 };
+ struct drm_virtgpu_context_set_param ctx_set_param = { 0 };
+ uint64_t supports_capset_virgl, supports_capset_virgl2;
+ supports_capset_virgl = supports_capset_virgl2 = 0;
+
+ supports_capset_virgl = ((1 << VIRGL_DRM_CAPSET_VIRGL) &
+ params[param_supported_capset_ids].value);
+
+ supports_capset_virgl2 = ((1 << VIRGL_DRM_CAPSET_VIRGL2) &
+ params[param_supported_capset_ids].value);
+
+ if (!supports_capset_virgl && !supports_capset_virgl2) {
+ _debug_printf("No virgl contexts available on host");
+ return -EINVAL;
+ }
+
+ ctx_set_param.param = VIRTGPU_CONTEXT_PARAM_CAPSET_ID;
+ ctx_set_param.value = (supports_capset_virgl2) ?
+ VIRGL_DRM_CAPSET_VIRGL2 :
+ VIRGL_DRM_CAPSET_VIRGL;
+
+ init.ctx_set_params = (unsigned long)(void *)&ctx_set_param;
+ init.num_params = 1;
+
+ ret = drmIoctl(drmFD, DRM_IOCTL_VIRTGPU_CONTEXT_INIT, &init);
+ /*
+ * EEXIST happens when a compositor does DUMB_CREATE before initializing
+ * virgl.
+ */
+ if (ret && errno != EEXIST) {
+ _debug_printf("DRM_IOCTL_VIRTGPU_CONTEXT_INIT failed with %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
static struct virgl_winsys *
virgl_drm_winsys_create(int drmFD)
{
@@ -1142,6 +1220,12 @@ virgl_drm_winsys_create(int drmFD)
if (drm_version < 0)
return NULL;
+ if (params[param_context_init].value) {
+ ret = virgl_init_context(drmFD);
+ if (ret)
+ return NULL;
+ }
+
qdws = CALLOC_STRUCT(virgl_drm_winsys);
if (!qdws)
return NULL;
diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
index 28fb9715a..5c6c4f9ef 100644
--- a/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
+++ b/lib/mesa/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
@@ -71,6 +71,9 @@ enum param_id {
param_capset_fix,
param_resource_blob,
param_host_visible,
+ param_cross_device,
+ param_context_init,
+ param_supported_capset_ids,
param_max,
};
@@ -80,7 +83,9 @@ struct param params[] = { PARAM(VIRTGPU_PARAM_3D_FEATURES),
PARAM(VIRTGPU_PARAM_CAPSET_QUERY_FIX),
PARAM(VIRTGPU_PARAM_RESOURCE_BLOB),
PARAM(VIRTGPU_PARAM_HOST_VISIBLE),
- PARAM(VIRTGPU_PARAM_CROSS_DEVICE)
+ PARAM(VIRTGPU_PARAM_CROSS_DEVICE),
+ PARAM(VIRTGPU_PARAM_CONTEXT_INIT),
+ PARAM(VIRTGPU_PARAM_SUPPORTED_CAPSET_IDs)
};
struct virgl_drm_winsys
diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk b/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk
deleted file mode 100644
index 5b33f6771..000000000
--- a/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (C) 2014 Emil Velikov <emil.l.velikov@gmail.com>
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-
-LOCAL_PATH := $(call my-dir)
-
-# get C_SOURCES
-include $(LOCAL_PATH)/Makefile.sources
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(C_SOURCES)
-
-LOCAL_MODULE := libmesa_winsys_virgl_vtest
-
-LOCAL_STATIC_LIBRARIES := libmesa_winsys_virgl_common
-
-include $(GALLIUM_COMMON_MK)
-include $(BUILD_STATIC_LIBRARY)
diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources b/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources
deleted file mode 100644
index 12370d96f..000000000
--- a/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources
+++ /dev/null
@@ -1,6 +0,0 @@
-C_SOURCES := \
- virgl_vtest_public.h \
- virgl_vtest_socket.c \
- virgl_vtest_winsys.c \
- virgl_vtest_winsys.h \
- vtest_protocol.h
diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
index 669cd763e..5c7d73ab0 100644
--- a/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
+++ b/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
@@ -238,6 +238,17 @@ virgl_vtest_winsys_resource_create(struct virgl_winsys *vws,
struct virgl_hw_res *res;
static int handle = 1;
int fd = -1;
+ struct virgl_resource_params params = { .size = size,
+ .bind = bind,
+ .format = format,
+ .flags = 0,
+ .nr_samples = nr_samples,
+ .width = width,
+ .height = height,
+ .depth = depth,
+ .array_size = array_size,
+ .last_level = last_level,
+ .target = target };
res = CALLOC_STRUCT(virgl_hw_res);
if (!res)
@@ -291,7 +302,7 @@ virgl_vtest_winsys_resource_create(struct virgl_winsys *vws,
}
out:
- virgl_resource_cache_entry_init(&res->cache_entry, size, bind, format, 0);
+ virgl_resource_cache_entry_init(&res->cache_entry, params);
res->res_handle = handle++;
pipe_reference_init(&res->reference, 1);
p_atomic_set(&res->num_cs_references, 0);
@@ -353,14 +364,24 @@ virgl_vtest_winsys_resource_cache_create(struct virgl_winsys *vws,
struct virgl_vtest_winsys *vtws = virgl_vtest_winsys(vws);
struct virgl_hw_res *res;
struct virgl_resource_cache_entry *entry;
+ struct virgl_resource_params params = { .size = size,
+ .bind = bind,
+ .format = format,
+ .flags = 0,
+ .nr_samples = nr_samples,
+ .width = width,
+ .height = height,
+ .depth = depth,
+ .array_size = array_size,
+ .last_level = last_level,
+ .target = target };
if (!can_cache_resource_with_bind(bind))
goto alloc;
mtx_lock(&vtws->mutex);
- entry = virgl_resource_cache_remove_compatible(&vtws->cache, size,
- bind, format, 0);
+ entry = virgl_resource_cache_remove_compatible(&vtws->cache, params);
if (entry) {
res = cache_entry_container_res(entry);
mtx_unlock(&vtws->mutex);