diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:17:30 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2021-07-22 10:17:30 +0000 |
commit | ca11beabae33eb59fb981b8adf50b1d47a2a98f0 (patch) | |
tree | 3e4691a396e6e54cd54224a190663d5cf976625b /lib/mesa/src/gallium/winsys | |
parent | 27c8a50e8bbde7d28b1fc46d715a4c469e24f2c4 (diff) |
Import Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/winsys')
56 files changed, 967 insertions, 213 deletions
diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk b/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk index 0b8edf972..90f56e45b 100644 --- a/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk +++ b/lib/mesa/src/gallium/winsys/amdgpu/drm/Android.mk @@ -21,6 +21,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +ifeq ($(MESA_ENABLE_LLVM),true) + LOCAL_PATH := $(call my-dir) # get C_SOURCES @@ -46,3 +48,5 @@ ifneq ($(HAVE_GALLIUM_RADEONSI),) $(eval GALLIUM_LIBS += $(LOCAL_MODULE) $(LOCAL_STATIC_LIBRARIES)) $(eval GALLIUM_SHARED_LIBS += $(LOCAL_SHARED_LIBRARIES)) endif + +endif # MESA_ENABLE_LLVM==true diff --git a/lib/mesa/src/gallium/winsys/amdgpu/drm/meson.build b/lib/mesa/src/gallium/winsys/amdgpu/drm/meson.build index ef2705d52..c73ff3802 100644 --- a/lib/mesa/src/gallium/winsys/amdgpu/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/amdgpu/drm/meson.build @@ -29,8 +29,7 @@ libamdgpuwinsys = static_library( inc_amd, inc_gallium, inc_gallium_aux, inc_include, inc_src, inc_amd_common, inc_amd_common_llvm, ], - c_args : [c_vis_args], - cpp_args : [cpp_vis_args], + gnu_symbol_visibility : 'hidden', link_with : libamdgpu_addrlib, - dependencies : [dep_llvm, dep_libdrm_amdgpu, idep_amdgfxregs_h], + dependencies : [dep_llvm, dep_libdrm_amdgpu, idep_amdgfxregs_h, idep_mesautil], ) diff --git a/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp b/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp new file mode 100644 index 000000000..b96dc5251 --- /dev/null +++ b/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_framebuffer.cpp @@ -0,0 +1,240 @@ +/* + * Copyright © Microsoft 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 (including the next + * paragraph) 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. + */ + +#include "d3d12_wgl_public.h" + +#include <Windows.h> +#include <dxgi1_4.h> +#include <directx/d3d12.h> +#include <wrl.h> + +#include "util/u_memory.h" +#include "util/u_inlines.h" +#include "frontend/api.h" +#include "frontend/winsys_handle.h" + +#include "stw_device.h" +#include "stw_pixelformat.h" +#include "stw_winsys.h" + +#include "d3d12/d3d12_format.h" +#include "d3d12/d3d12_resource.h" +#include "d3d12/d3d12_screen.h" + +using Microsoft::WRL::ComPtr; +constexpr uint32_t num_buffers = 2; + +struct d3d12_wgl_framebuffer { + struct stw_winsys_framebuffer base; + + struct d3d12_screen *screen; + enum pipe_format pformat; + HWND window; + ComPtr<IDXGISwapChain3> swapchain; + struct pipe_resource *buffers[num_buffers]; +}; + +static struct d3d12_wgl_framebuffer * +d3d12_wgl_framebuffer(struct stw_winsys_framebuffer *fb) +{ + return (struct d3d12_wgl_framebuffer *)fb; +} + +static void +d3d12_wgl_framebuffer_destroy(struct stw_winsys_framebuffer *fb, + pipe_context *ctx) +{ + struct d3d12_wgl_framebuffer *framebuffer = d3d12_wgl_framebuffer(fb); + struct pipe_fence_handle *fence = NULL; + + if (ctx) { + /* Ensure all resources are flushed */ + ctx->flush(ctx, &fence, PIPE_FLUSH_HINT_FINISH); + if (fence) { + ctx->screen->fence_finish(ctx->screen, ctx, fence, PIPE_TIMEOUT_INFINITE); + ctx->screen->fence_reference(ctx->screen, &fence, NULL); + } + } + + for (int i = 0; i < num_buffers; ++i) { + if (framebuffer->buffers[i]) { + d3d12_resource_release(d3d12_resource(framebuffer->buffers[i])); + pipe_resource_reference(&framebuffer->buffers[i], NULL); + } + } + + delete framebuffer; +} + +static void +d3d12_wgl_framebuffer_resize(stw_winsys_framebuffer *fb, + pipe_context *ctx, + pipe_resource *templ) +{ + struct d3d12_wgl_framebuffer *framebuffer = d3d12_wgl_framebuffer(fb); + struct d3d12_dxgi_screen *screen = d3d12_dxgi_screen(framebuffer->screen); + + DXGI_SWAP_CHAIN_DESC1 desc = {}; + desc.BufferCount = num_buffers; + desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT; + desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; + desc.Format = d3d12_get_format(templ->format); + desc.Width = templ->width0; + desc.Height = templ->height0; + desc.SampleDesc.Count = 1; + desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; + + framebuffer->pformat = templ->format; + + if (!framebuffer->swapchain) { + ComPtr<IDXGISwapChain1> swapchain1; + if (FAILED(screen->factory->CreateSwapChainForHwnd( + screen->base.cmdqueue, + framebuffer->window, + &desc, + nullptr, + nullptr, + &swapchain1))) { + debug_printf("D3D12: failed to create swapchain"); + return; + } + + swapchain1.As(&framebuffer->swapchain); + + screen->factory->MakeWindowAssociation(framebuffer->window, + DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_PRINT_SCREEN); + } + else { + struct pipe_fence_handle *fence = NULL; + + /* Ensure all resources are flushed */ + ctx->flush(ctx, &fence, PIPE_FLUSH_HINT_FINISH); + if (fence) { + ctx->screen->fence_finish(ctx->screen, ctx, fence, PIPE_TIMEOUT_INFINITE); + ctx->screen->fence_reference(ctx->screen, &fence, NULL); + } + + for (int i = 0; i < num_buffers; ++i) { + if (framebuffer->buffers[i]) { + d3d12_resource_release(d3d12_resource(framebuffer->buffers[i])); + pipe_resource_reference(&framebuffer->buffers[i], NULL); + } + } + if (FAILED(framebuffer->swapchain->ResizeBuffers(num_buffers, desc.Width, desc.Height, desc.Format, desc.Flags))) { + debug_printf("D3D12: failed to resize swapchain"); + } + } +} + +static boolean +d3d12_wgl_framebuffer_present(stw_winsys_framebuffer *fb) +{ + auto framebuffer = d3d12_wgl_framebuffer(fb); + if (!framebuffer->swapchain) { + debug_printf("D3D12: Cannot present; no swapchain"); + return false; + } + + if (stw_dev->swap_interval < 1) + return S_OK == framebuffer->swapchain->Present(0, DXGI_PRESENT_ALLOW_TEARING); + else + return S_OK == framebuffer->swapchain->Present(stw_dev->swap_interval, 0); +} + +static struct pipe_resource * +d3d12_wgl_framebuffer_get_resource(struct stw_winsys_framebuffer *pframebuffer, + st_attachment_type statt) +{ + auto framebuffer = d3d12_wgl_framebuffer(pframebuffer); + auto pscreen = &framebuffer->screen->base; + + if (!framebuffer->swapchain) + return nullptr; + + UINT index = framebuffer->swapchain->GetCurrentBackBufferIndex(); + if (statt == ST_ATTACHMENT_FRONT_LEFT) + index = !index; + + if (framebuffer->buffers[index]) { + pipe_reference(NULL, &framebuffer->buffers[index]->reference); + return framebuffer->buffers[index]; + } + + ID3D12Resource *res; + framebuffer->swapchain->GetBuffer(index, IID_PPV_ARGS(&res)); + if (!res) + return nullptr; + + struct winsys_handle handle; + memset(&handle, 0, sizeof(handle)); + handle.type = WINSYS_HANDLE_TYPE_D3D12_RES; + handle.com_obj = res; + + D3D12_RESOURCE_DESC res_desc = res->GetDesc(); + + struct pipe_resource templ; + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.format = framebuffer->pformat; + templ.width0 = res_desc.Width; + templ.height0 = res_desc.Height; + templ.depth0 = 1; + templ.array_size = res_desc.DepthOrArraySize; + templ.nr_samples = res_desc.SampleDesc.Count; + templ.last_level = res_desc.MipLevels - 1; + templ.bind = PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_RENDER_TARGET; + templ.usage = PIPE_USAGE_DEFAULT; + templ.flags = 0; + + pipe_resource_reference(&framebuffer->buffers[index], + pscreen->resource_from_handle(pscreen, &templ, &handle, + PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE)); + return framebuffer->buffers[index]; +} + +struct stw_winsys_framebuffer * +d3d12_wgl_create_framebuffer(struct pipe_screen *screen, + HDC hDC, + int iPixelFormat) +{ + const struct stw_pixelformat_info *pfi = + stw_pixelformat_get_info(iPixelFormat); + if (!(pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) || + (pfi->pfd.dwFlags & PFD_SUPPORT_GDI)) + return NULL; + + struct d3d12_wgl_framebuffer *fb = CALLOC_STRUCT(d3d12_wgl_framebuffer); + if (!fb) + return NULL; + + new (fb) struct d3d12_wgl_framebuffer(); + + fb->window = WindowFromDC(hDC); + fb->screen = d3d12_screen(screen); + fb->base.destroy = d3d12_wgl_framebuffer_destroy; + fb->base.resize = d3d12_wgl_framebuffer_resize; + fb->base.present = d3d12_wgl_framebuffer_present; + fb->base.get_resource = d3d12_wgl_framebuffer_get_resource; + + return &fb->base; +} diff --git a/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_public.h b/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_public.h new file mode 100644 index 000000000..ac5f2c754 --- /dev/null +++ b/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_public.h @@ -0,0 +1,60 @@ +/* + * Copyright © Microsoft 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 (including the next + * paragraph) 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. + */ + +#ifndef D3D12_WGL_PUBLIC_H +#define D3D12_WGL_PUBLIC_H + +#include <windows.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct pipe_resource; +struct pipe_screen; +struct pipe_context; +struct stw_winsys; + +struct pipe_screen * +d3d12_wgl_create_screen(struct sw_winsys *winsys, + HDC hDC); + +void +d3d12_wgl_present(struct pipe_screen *screen, + struct pipe_context *context, + struct pipe_resource *res, + HDC hDC); + +unsigned +d3d12_wgl_get_pfd_flags(struct pipe_screen *screen); + +struct stw_winsys_framebuffer * +d3d12_wgl_create_framebuffer(struct pipe_screen *screen, + HDC hDC, + int iPixelFormat); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_winsys.c b/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_winsys.c new file mode 100644 index 000000000..65a7be01b --- /dev/null +++ b/lib/mesa/src/gallium/winsys/d3d12/wgl/d3d12_wgl_winsys.c @@ -0,0 +1,58 @@ +/* + * Copyright © Microsoft 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 (including the next + * paragraph) 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. + */ + +#include "d3d12_wgl_public.h" +#include "d3d12/d3d12_public.h" + +#include "stw_device.h" +#include "stw_winsys.h" + +#include "pipe/p_screen.h" +#include "util/u_memory.h" + +struct pipe_screen * +d3d12_wgl_create_screen(struct sw_winsys *winsys, HDC hDC) +{ + LUID *adapter_luid = NULL, local_luid; + if (stw_dev && stw_dev->callbacks.pfnGetAdapterLuid) { + stw_dev->callbacks.pfnGetAdapterLuid(hDC, &local_luid); + adapter_luid = &local_luid; + } + return d3d12_create_dxgi_screen(winsys, adapter_luid); +} + +void +d3d12_wgl_present(struct pipe_screen *screen, + struct pipe_context *ctx, + struct pipe_resource *res, + HDC hDC) +{ + screen->flush_frontbuffer(screen, ctx, res, 0, 0, hDC, NULL); +} + +unsigned +d3d12_wgl_get_pfd_flags(struct pipe_screen *screen) +{ + (void)screen; + return stw_pfd_gdi_support | stw_pfd_double_buffer; +} diff --git a/lib/mesa/src/gallium/winsys/d3d12/wgl/meson.build b/lib/mesa/src/gallium/winsys/d3d12/wgl/meson.build new file mode 100644 index 000000000..0a25f9844 --- /dev/null +++ b/lib/mesa/src/gallium/winsys/d3d12/wgl/meson.build @@ -0,0 +1,33 @@ +# Copyright © Microsoft 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 (including the next +# paragraph) 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. + + +libd3d12winsys = static_library( + 'd3d12winsys', + files('d3d12_wgl_framebuffer.cpp', 'd3d12_wgl_winsys.c'), + include_directories : [inc_src, inc_wgl, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers], + dependencies : [dep_dxheaders], + gnu_symbol_visibility : 'hidden', +) + +winsys_d3d12_wgl = declare_dependency( + link_with : [libd3d12winsys], +) diff --git a/lib/mesa/src/gallium/winsys/etnaviv/drm/meson.build b/lib/mesa/src/gallium/winsys/etnaviv/drm/meson.build index f54919417..ab52587aa 100644 --- a/lib/mesa/src/gallium/winsys/etnaviv/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/etnaviv/drm/meson.build @@ -26,5 +26,5 @@ libetnavivdrm = static_library( inc_etnaviv, ], link_with: libetnaviv_drm, - dependencies : [dep_libdrm, idep_nir_headers], + dependencies : [dep_libdrm, idep_nir_headers, idep_mesautil], ) diff --git a/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk b/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk index 09edab391..669559583 100644 --- a/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk +++ b/lib/mesa/src/gallium/winsys/freedreno/drm/Android.mk @@ -27,6 +27,9 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(C_SOURCES) +LOCAL_C_INCLUDES := \ + $(MESA_TOP)/src/freedreno/common + LOCAL_SHARED_LIBRARIES := libdrm_freedreno LOCAL_STATIC_LIBRARIES := libfreedreno_registers diff --git a/lib/mesa/src/gallium/winsys/freedreno/drm/meson.build b/lib/mesa/src/gallium/winsys/freedreno/drm/meson.build index 765ac887d..7ca3d21e7 100644 --- a/lib/mesa/src/gallium/winsys/freedreno/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/freedreno/drm/meson.build @@ -28,6 +28,9 @@ libfreedrenowinsys = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_freedreno, ], - c_args : [c_vis_args], - dependencies : [dep_libdrm], + gnu_symbol_visibility : 'hidden', + dependencies : [ + dep_libdrm, + idep_mesautil, + ], ) diff --git a/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_buffer.c b/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_buffer.c index 9b525f980..3d24b64e6 100644 --- a/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_buffer.c +++ b/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_buffer.c @@ -1,4 +1,4 @@ -#include "state_tracker/drm_driver.h" +#include "frontend/drm_driver.h" #include "i915_drm_winsys.h" #include "util/u_memory.h" diff --git a/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_winsys.c b/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_winsys.c index d07ee496e..add8ff83e 100644 --- a/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/i915/drm/i915_drm_winsys.c @@ -3,7 +3,7 @@ #include "drm-uapi/i915_drm.h" -#include "state_tracker/drm_driver.h" +#include "frontend/drm_driver.h" #include "i915_drm_winsys.h" #include "i915_drm_public.h" diff --git a/lib/mesa/src/gallium/winsys/iris/drm/iris_drm_winsys.c b/lib/mesa/src/gallium/winsys/iris/drm/iris_drm_winsys.c index 9903f40a8..a7a70283e 100644 --- a/lib/mesa/src/gallium/winsys/iris/drm/iris_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/iris/drm/iris_drm_winsys.c @@ -24,11 +24,16 @@ #include <unistd.h> #include <fcntl.h> +#include "util/os_file.h" + #include "iris_drm_public.h" -#include "iris/iris_screen.h" +extern struct pipe_screen *iris_screen_create(int fd, const struct pipe_screen_config *config); struct pipe_screen * iris_drm_screen_create(int fd, const struct pipe_screen_config *config) { - return iris_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3), config); + int newfd = os_dupfd_cloexec(fd); + if (newfd < 0) + return NULL; + return iris_screen_create(newfd, config); } diff --git a/lib/mesa/src/gallium/winsys/iris/drm/meson.build b/lib/mesa/src/gallium/winsys/iris/drm/meson.build index 3f8e2a8c6..3dcdc4a45 100644 --- a/lib/mesa/src/gallium/winsys/iris/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/iris/drm/meson.build @@ -25,5 +25,5 @@ libiriswinsys = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, ], - c_args : [c_vis_args], + gnu_symbol_visibility : 'hidden', ) diff --git a/lib/mesa/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c b/lib/mesa/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c index bf599a149..790ed7d69 100644 --- a/lib/mesa/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c @@ -36,92 +36,112 @@ #include "pipe/p_screen.h" #include "renderonly/renderonly.h" +#include "util/u_memory.h" + +static void kmsro_ro_destroy(struct renderonly *ro) +{ + if (ro->gpu_fd >= 0) + close(ro->gpu_fd); + + FREE(ro); +} struct pipe_screen *kmsro_drm_screen_create(int fd, const struct pipe_screen_config *config) { struct pipe_screen *screen = NULL; - struct renderonly ro = { - .kms_fd = fd, - .gpu_fd = -1, - }; + struct renderonly *ro = CALLOC_STRUCT(renderonly); + + if (!ro) + return NULL; + + ro->kms_fd = fd; + ro->gpu_fd = -1; + ro->destroy = kmsro_ro_destroy; #if defined(GALLIUM_VC4) - ro.gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER); - if (ro.gpu_fd >= 0) { + ro->gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER); + if (ro->gpu_fd >= 0) { /* Passes the vc4-allocated BO through to the KMS-only DRM device using * PRIME buffer sharing. The VC4 BO must be linear, which the SCANOUT * flag on allocation will have ensured. */ - ro.create_for_resource = renderonly_create_gpu_import_for_resource, - screen = vc4_drm_screen_create_renderonly(&ro, config); + ro->create_for_resource = renderonly_create_gpu_import_for_resource; + screen = vc4_drm_screen_create_renderonly(ro, config); if (!screen) - close(ro.gpu_fd); + goto out_free; return screen; } #endif #if defined(GALLIUM_ETNAVIV) - ro.gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER); - if (ro.gpu_fd >= 0) { - ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, - screen = etna_drm_screen_create_renderonly(&ro); + ro->gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER); + if (ro->gpu_fd >= 0) { + ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource; + screen = etna_drm_screen_create_renderonly(ro); if (!screen) - close(ro.gpu_fd); + goto out_free; return screen; } #endif #if defined(GALLIUM_FREEDRENO) - ro.gpu_fd = drmOpenWithType("msm", NULL, DRM_NODE_RENDER); - if (ro.gpu_fd >= 0) { - ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, - screen = fd_drm_screen_create(ro.gpu_fd, &ro); + ro->gpu_fd = drmOpenWithType("msm", NULL, DRM_NODE_RENDER); + if (ro->gpu_fd >= 0) { + ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource; + screen = fd_drm_screen_create(ro->gpu_fd, ro); if (!screen) - close(ro.gpu_fd); + goto out_free; return screen; } #endif #if defined(GALLIUM_PANFROST) - ro.gpu_fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER); + ro->gpu_fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER); - if (ro.gpu_fd >= 0) { - ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, - screen = panfrost_drm_screen_create_renderonly(&ro); + if (ro->gpu_fd >= 0) { + ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, + screen = panfrost_drm_screen_create_renderonly(ro); if (!screen) - close(ro.gpu_fd); + goto out_free; return screen; } #endif #if defined(GALLIUM_LIMA) - ro.gpu_fd = drmOpenWithType("lima", NULL, DRM_NODE_RENDER); - if (ro.gpu_fd >= 0) { - ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, - screen = lima_drm_screen_create_renderonly(&ro); + ro->gpu_fd = drmOpenWithType("lima", NULL, DRM_NODE_RENDER); + if (ro->gpu_fd >= 0) { + ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, + screen = lima_drm_screen_create_renderonly(ro); if (!screen) - close(ro.gpu_fd); + goto out_free; return screen; } #endif #if defined(GALLIUM_V3D) - ro.gpu_fd = drmOpenWithType("v3d", NULL, DRM_NODE_RENDER); - if (ro.gpu_fd >= 0) { - ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, - screen = v3d_drm_screen_create_renderonly(&ro, config); + ro->gpu_fd = drmOpenWithType("v3d", NULL, DRM_NODE_RENDER); + if (ro->gpu_fd >= 0) { + ro->create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, + screen = v3d_drm_screen_create_renderonly(ro, config); if (!screen) - close(ro.gpu_fd); + goto out_free; return screen; } #endif return screen; + +out_free: + if (ro->gpu_fd >= 0) + close(ro->gpu_fd); + FREE(ro); + + return NULL; } diff --git a/lib/mesa/src/gallium/winsys/kmsro/drm/meson.build b/lib/mesa/src/gallium/winsys/kmsro/drm/meson.build index 13ed5a0ea..cec92b1fa 100644 --- a/lib/mesa/src/gallium/winsys/kmsro/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/kmsro/drm/meson.build @@ -45,7 +45,8 @@ libkmsrowinsys = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_winsys, ], - c_args : [c_vis_args, kmsro_c_args], + c_args : [kmsro_c_args], + gnu_symbol_visibility : 'hidden', dependencies: dep_libdrm, ) diff --git a/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c b/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c index 07690307c..b23f11137 100644 --- a/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/lima/drm/lima_drm_winsys.c @@ -26,6 +26,7 @@ #include <sys/stat.h> #include "c11/threads.h" +#include "util/os_file.h" #include "util/u_hash_table.h" #include "util/u_pointer.h" #include "renderonly/renderonly.h" @@ -34,7 +35,7 @@ #include "lima/lima_screen.h" -static struct util_hash_table *fd_tab = NULL; +static struct hash_table *fd_tab = NULL; static mtx_t lima_screen_mutex = _MTX_INITIALIZER_NP; static void @@ -47,7 +48,7 @@ lima_drm_screen_destroy(struct pipe_screen *pscreen) mtx_lock(&lima_screen_mutex); destroy = --screen->refcnt == 0; if (destroy) - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); + _mesa_hash_table_remove_key(fd_tab, intptr_to_pointer(fd)); mtx_unlock(&lima_screen_mutex); if (destroy) { @@ -57,30 +58,6 @@ lima_drm_screen_destroy(struct pipe_screen *pscreen) } } -static unsigned hash_fd(void *key) -{ - int fd = pointer_to_intptr(key); - struct stat stat; - - fstat(fd, &stat); - - return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ - int fd1 = pointer_to_intptr(key1); - int fd2 = pointer_to_intptr(key2); - struct stat stat1, stat2; - - fstat(fd1, &stat1); - fstat(fd2, &stat2); - - return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - struct pipe_screen * lima_drm_screen_create(int fd) { @@ -88,7 +65,7 @@ lima_drm_screen_create(int fd) mtx_lock(&lima_screen_mutex); if (!fd_tab) { - fd_tab = util_hash_table_create(hash_fd, compare_fd); + fd_tab = util_hash_table_create_fd_keys(); if (!fd_tab) goto unlock; } @@ -97,11 +74,11 @@ lima_drm_screen_create(int fd) if (pscreen) { lima_screen(pscreen)->refcnt++; } else { - int dup_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); + int dup_fd = os_dupfd_cloexec(fd); pscreen = lima_screen_create(dup_fd, NULL); if (pscreen) { - util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen); + _mesa_hash_table_insert(fd_tab, intptr_to_pointer(dup_fd), pscreen); /* Bit of a hack, to avoid circular linkage dependency, * ie. pipe driver having to call in to winsys, we @@ -120,5 +97,5 @@ unlock: struct pipe_screen * lima_drm_screen_create_renderonly(struct renderonly *ro) { - return lima_screen_create(fcntl(ro->gpu_fd, F_DUPFD_CLOEXEC, 3), ro); + return lima_screen_create(os_dupfd_cloexec(ro->gpu_fd), ro); } diff --git a/lib/mesa/src/gallium/winsys/lima/drm/meson.build b/lib/mesa/src/gallium/winsys/lima/drm/meson.build index 2939571e5..cc8a0720e 100644 --- a/lib/mesa/src/gallium/winsys/lima/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/lima/drm/meson.build @@ -26,4 +26,5 @@ liblimawinsys = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, ], + dependencies : idep_mesautil, ) diff --git a/lib/mesa/src/gallium/winsys/nouveau/drm/meson.build b/lib/mesa/src/gallium/winsys/nouveau/drm/meson.build index cf661971f..60671eb37 100644 --- a/lib/mesa/src/gallium/winsys/nouveau/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/nouveau/drm/meson.build @@ -24,6 +24,6 @@ libnouveauwinsys = static_library( include_directories : [ inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, ], - c_args : [c_vis_args], - dependencies : [dep_libdrm_nouveau], + gnu_symbol_visibility : 'hidden', + dependencies : [dep_libdrm_nouveau, idep_mesautil], ) diff --git a/lib/mesa/src/gallium/winsys/panfrost/drm/meson.build b/lib/mesa/src/gallium/winsys/panfrost/drm/meson.build index d19ce2ddb..84aa9ba56 100644 --- a/lib/mesa/src/gallium/winsys/panfrost/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/panfrost/drm/meson.build @@ -25,5 +25,5 @@ libpanfrostwinsys = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, ], - c_args : [c_vis_args], + gnu_symbol_visibility : 'hidden', ) diff --git a/lib/mesa/src/gallium/winsys/panfrost/drm/panfrost_drm_winsys.c b/lib/mesa/src/gallium/winsys/panfrost/drm/panfrost_drm_winsys.c index 1852e1c66..ac47da455 100644 --- a/lib/mesa/src/gallium/winsys/panfrost/drm/panfrost_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/panfrost/drm/panfrost_drm_winsys.c @@ -25,6 +25,8 @@ #include <unistd.h> #include <fcntl.h> +#include "util/os_file.h" + #include "renderonly/renderonly.h" #include "panfrost_drm_public.h" #include "panfrost/pan_public.h" @@ -32,11 +34,11 @@ struct pipe_screen * panfrost_drm_screen_create(int fd) { - return panfrost_create_screen(fcntl(fd, F_DUPFD_CLOEXEC, 3), NULL); + return panfrost_create_screen(os_dupfd_cloexec(fd), NULL); } struct pipe_screen * panfrost_drm_screen_create_renderonly(struct renderonly *ro) { - return panfrost_create_screen(fcntl(ro->gpu_fd, F_DUPFD_CLOEXEC, 3), ro); + return panfrost_create_screen(os_dupfd_cloexec(ro->gpu_fd), ro); } diff --git a/lib/mesa/src/gallium/winsys/radeon/drm/meson.build b/lib/mesa/src/gallium/winsys/radeon/drm/meson.build index d123df050..4341d813d 100644 --- a/lib/mesa/src/gallium/winsys/radeon/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/radeon/drm/meson.build @@ -24,6 +24,6 @@ libradeonwinsys = static_library( 'radeon_drm_cs.h', 'radeon_drm_public.h', 'radeon_drm_surface.c', 'radeon_drm_winsys.c', 'radeon_drm_winsys.h'), include_directories : [inc_src, inc_include, inc_gallium, inc_gallium_aux], - c_args : [c_vis_args], - dependencies : [dep_libdrm_radeon], + gnu_symbol_visibility : 'hidden', + dependencies : [dep_libdrm_radeon, idep_mesautil], ) diff --git a/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.h b/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.h index 4fa007afa..1090dfa40 100644 --- a/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.h +++ b/lib/mesa/src/gallium/winsys/radeon/drm/radeon_drm_cs.h @@ -35,105 +35,104 @@ struct radeon_ctx { }; struct radeon_bo_item { - struct radeon_bo *bo; - union { - struct { - uint32_t priority_usage; - } real; - struct { - unsigned real_idx; - } slab; - } u; + struct radeon_bo *bo; + union { + struct { + uint32_t priority_usage; + } real; + struct { + unsigned real_idx; + } slab; + } u; }; struct radeon_cs_context { - uint32_t buf[16 * 1024]; - - int fd; - struct drm_radeon_cs cs; - struct drm_radeon_cs_chunk chunks[3]; - uint64_t chunk_array[3]; - uint32_t flags[2]; - - /* Buffers. */ - unsigned max_relocs; - unsigned num_relocs; - unsigned num_validated_relocs; - struct radeon_bo_item *relocs_bo; - struct drm_radeon_cs_reloc *relocs; - - unsigned num_slab_buffers; - unsigned max_slab_buffers; - struct radeon_bo_item *slab_buffers; - - int reloc_indices_hashlist[4096]; + uint32_t buf[16 * 1024]; + + int fd; + struct drm_radeon_cs cs; + struct drm_radeon_cs_chunk chunks[3]; + uint64_t chunk_array[3]; + uint32_t flags[2]; + + /* Buffers. */ + unsigned max_relocs; + unsigned num_relocs; + unsigned num_validated_relocs; + struct radeon_bo_item *relocs_bo; + struct drm_radeon_cs_reloc *relocs; + + unsigned num_slab_buffers; + unsigned max_slab_buffers; + struct radeon_bo_item *slab_buffers; + + int reloc_indices_hashlist[4096]; }; struct radeon_drm_cs { - struct radeon_cmdbuf base; - enum ring_type ring_type; - - /* We flip between these two CS. While one is being consumed - * by the kernel in another thread, the other one is being filled - * by the pipe driver. */ - struct radeon_cs_context csc1; - struct radeon_cs_context csc2; - /* The currently-used CS. */ - struct radeon_cs_context *csc; - /* The CS being currently-owned by the other thread. */ - struct radeon_cs_context *cst; - - /* The winsys. */ - struct radeon_drm_winsys *ws; - - /* Flush CS. */ - void (*flush_cs)(void *ctx, unsigned flags, struct pipe_fence_handle **fence); - void *flush_data; - - struct util_queue_fence flush_completed; - struct pipe_fence_handle *next_fence; + enum ring_type ring_type; + + /* We flip between these two CS. While one is being consumed + * by the kernel in another thread, the other one is being filled + * by the pipe driver. */ + struct radeon_cs_context csc1; + struct radeon_cs_context csc2; + /* The currently-used CS. */ + struct radeon_cs_context *csc; + /* The CS being currently-owned by the other thread. */ + struct radeon_cs_context *cst; + + /* The winsys. */ + struct radeon_drm_winsys *ws; + + /* Flush CS. */ + void (*flush_cs)(void *ctx, unsigned flags, struct pipe_fence_handle **fence); + void *flush_data; + + struct util_queue_fence flush_completed; + struct pipe_fence_handle *next_fence; }; int radeon_lookup_buffer(struct radeon_cs_context *csc, struct radeon_bo *bo); static inline struct radeon_drm_cs * -radeon_drm_cs(struct radeon_cmdbuf *base) +radeon_drm_cs(struct radeon_cmdbuf *rcs) { - return (struct radeon_drm_cs*)base; + return (struct radeon_drm_cs*)rcs->priv; } static inline bool radeon_bo_is_referenced_by_cs(struct radeon_drm_cs *cs, struct radeon_bo *bo) { - int num_refs = bo->num_cs_references; - return num_refs == bo->rws->num_cs || - (num_refs && radeon_lookup_buffer(cs->csc, bo) != -1); + int num_refs = bo->num_cs_references; + return num_refs == bo->rws->num_cs || + (num_refs && radeon_lookup_buffer(cs->csc, bo) != -1); } static inline bool radeon_bo_is_referenced_by_cs_for_write(struct radeon_drm_cs *cs, struct radeon_bo *bo) { - int index; + int index; - if (!bo->num_cs_references) - return false; + if (!bo->num_cs_references) + return false; - index = radeon_lookup_buffer(cs->csc, bo); - if (index == -1) - return false; + index = radeon_lookup_buffer(cs->csc, bo); + if (index == -1) + return false; - if (!bo->handle) - index = cs->csc->slab_buffers[index].u.slab.real_idx; + if (!bo->handle) + index = cs->csc->slab_buffers[index].u.slab.real_idx; - return cs->csc->relocs[index].write_domain != 0; + return cs->csc->relocs[index].write_domain != 0; } static inline bool radeon_bo_is_referenced_by_any_cs(struct radeon_bo *bo) { - return bo->num_cs_references != 0; + return bo->num_cs_references != 0; } void radeon_drm_cs_sync_flush(struct radeon_cmdbuf *rcs); diff --git a/lib/mesa/src/gallium/winsys/svga/drm/meson.build b/lib/mesa/src/gallium/winsys/svga/drm/meson.build index 55266ce16..1d91ee207 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/svga/drm/meson.build @@ -37,10 +37,11 @@ files_svgadrm = files( libsvgadrm = static_library( 'svgadrm', files_svgadrm, - c_args : [c_vis_args, c_msvc_compat_args], + c_args : [c_msvc_compat_args], + gnu_symbol_visibility : 'hidden', include_directories : [ inc_src, inc_include, inc_gallium, inc_gallium_aux, include_directories('../../../drivers/svga', '../../../drivers/svga/include'), ], - dependencies : dep_libdrm, + dependencies : [dep_libdrm, idep_mesautil], ) diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c index 34c5e3417..d537c8be9 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.c @@ -63,6 +63,7 @@ struct vmw_gmr_buffer struct vmw_region *region; void *map; unsigned map_flags; + unsigned map_count; }; @@ -100,12 +101,16 @@ vmw_gmr_bufmgr(struct pb_manager *mgr) static void -vmw_gmr_buffer_destroy(struct pb_buffer *_buf) +vmw_gmr_buffer_destroy(void *winsys, struct pb_buffer *_buf) { struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf); - vmw_ioctl_region_unmap(buf->region); - + assert(buf->map_count == 0); + if (buf->map) { + assert(buf->mgr->vws->cache_maps); + vmw_ioctl_region_unmap(buf->region); + } + vmw_ioctl_region_destroy(buf->region); FREE(buf); @@ -126,7 +131,6 @@ vmw_gmr_buffer_map(struct pb_buffer *_buf, if (!buf->map) return NULL; - if ((_buf->usage & VMW_BUFFER_USAGE_SYNC) && !(flags & PB_USAGE_UNSYNCHRONIZED)) { ret = vmw_ioctl_syncforcpu(buf->region, @@ -137,6 +141,7 @@ vmw_gmr_buffer_map(struct pb_buffer *_buf, return NULL; } + buf->map_count++; return buf->map; } @@ -153,6 +158,12 @@ vmw_gmr_buffer_unmap(struct pb_buffer *_buf) !(flags & PB_USAGE_CPU_WRITE), FALSE); } + + assert(buf->map_count > 0); + if (!--buf->map_count && !buf->mgr->vws->cache_maps) { + vmw_ioctl_region_unmap(buf->region); + buf->map = NULL; + } } @@ -211,7 +222,7 @@ vmw_gmr_bufmgr_create_buffer(struct pb_manager *_mgr, goto error1; pipe_reference_init(&buf->base.reference, 1); - buf->base.alignment = pb_desc->alignment; + buf->base.alignment_log2 = util_logbase2(pb_desc->alignment); buf->base.usage = pb_desc->usage & ~VMW_BUFFER_USAGE_SHARED; buf->base.vtbl = &vmw_gmr_buffer_vtbl; buf->mgr = mgr; @@ -343,27 +354,29 @@ vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws, void * vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws, struct svga_winsys_buffer *buf, - enum pipe_transfer_usage flags) + enum pipe_map_flags flags) { void *map; (void)sws; - if (flags & PIPE_TRANSFER_UNSYNCHRONIZED) - flags &= ~PIPE_TRANSFER_DONTBLOCK; + if (flags & PIPE_MAP_UNSYNCHRONIZED) + flags &= ~PIPE_MAP_DONTBLOCK; - /* NOTE: we're passing PIPE_TRANSFER_x flags instead of + /* NOTE: we're passing PIPE_MAP_x flags instead of * PB_USAGE_x flags here. We should probably fix that. */ STATIC_ASSERT((unsigned) PB_USAGE_CPU_READ == - (unsigned) PIPE_TRANSFER_READ); + (unsigned) PIPE_MAP_READ); STATIC_ASSERT((unsigned) PB_USAGE_CPU_WRITE == - (unsigned) PIPE_TRANSFER_WRITE); + (unsigned) PIPE_MAP_WRITE); STATIC_ASSERT((unsigned) PB_USAGE_GPU_READ == - (unsigned) PIPE_TRANSFER_MAP_DIRECTLY); + (unsigned) PIPE_MAP_DIRECTLY); STATIC_ASSERT((unsigned) PB_USAGE_DONTBLOCK == - (unsigned) PIPE_TRANSFER_DONTBLOCK); + (unsigned) PIPE_MAP_DONTBLOCK); STATIC_ASSERT((unsigned) PB_USAGE_UNSYNCHRONIZED == - (unsigned) PIPE_TRANSFER_UNSYNCHRONIZED); + (unsigned) PIPE_MAP_UNSYNCHRONIZED); + STATIC_ASSERT((unsigned) PB_USAGE_PERSISTENT == + (unsigned) PIPE_MAP_PERSISTENT); map = pb_map(vmw_pb_buffer(buf), flags & PB_USAGE_ALL, NULL); diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.h b/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.h index 8ed56d4aa..9e452e7e8 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.h +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_buffer.h @@ -34,8 +34,8 @@ /* These extra flags are used wherever the pb_usage_flags enum type is used */ -#define VMW_BUFFER_USAGE_SHARED (1 << 20) -#define VMW_BUFFER_USAGE_SYNC (1 << 21) +#define VMW_BUFFER_USAGE_SHARED (1 << 14) +#define VMW_BUFFER_USAGE_SYNC (1 << 15) struct SVGAGuestPtr; struct pb_buffer; diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_query.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_query.c index 7baf2c1d7..6f761d7bf 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_query.c +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_query.c @@ -82,7 +82,7 @@ vmw_svga_winsys_query_init(struct svga_winsys_screen *sws, state = (SVGA3dQueryState *) vmw_svga_winsys_buffer_map(sws, query->buf, - PIPE_TRANSFER_WRITE); + PIPE_MAP_WRITE); if (!state) { debug_printf("Failed to map query result memory for initialization\n"); return -1; @@ -110,7 +110,7 @@ vmw_svga_winsys_query_get_result(struct svga_winsys_screen *sws, state = (SVGA3dQueryState *) vmw_svga_winsys_buffer_map(sws, query->buf, - PIPE_TRANSFER_READ); + PIPE_MAP_READ); if (!state) { debug_printf("Failed to lock query result memory\n"); diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.c b/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.c index 56ffdd16f..c1018daf2 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.c +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.c @@ -28,7 +28,9 @@ #include "util/u_debug.h" #include "util/u_memory.h" +#include "vmw_context.h" #include "vmw_shader.h" +#include "vmw_buffer.h" #include "vmw_screen.h" void @@ -63,3 +65,54 @@ vmw_svga_winsys_shader_reference(struct vmw_svga_winsys_shader **pdst, *pdst = src; } + + +/** + * A helper function to create a shader object and upload the + * shader bytecode and signature if specified to the shader memory. + */ +struct vmw_svga_winsys_shader * +vmw_svga_shader_create(struct svga_winsys_screen *sws, + SVGA3dShaderType type, + const uint32 *bytecode, + uint32 bytecodeLen, + const SVGA3dDXShaderSignatureHeader *sgnInfo, + uint32 sgnLen) +{ + struct vmw_svga_winsys_shader *shader; + void *map; + + shader = CALLOC_STRUCT(vmw_svga_winsys_shader); + if (!shader) + return NULL; + + pipe_reference_init(&shader->refcnt, 1); + p_atomic_set(&shader->validated, 0); + shader->screen = vmw_winsys_screen(sws); + shader->buf = sws->buffer_create(sws, 64, + SVGA_BUFFER_USAGE_SHADER, + bytecodeLen + sgnLen); + if (!shader->buf) { + FREE(shader); + return NULL; + } + + map = sws->buffer_map(sws, shader->buf, PIPE_MAP_WRITE); + if (!map) { + FREE(shader); + return NULL; + } + + /* copy the shader bytecode */ + memcpy(map, bytecode, bytecodeLen); + + /* if shader signature is specified, append it to the bytecode. */ + if (sgnLen) { + assert(sws->have_sm5); + map = (char *)map + bytecodeLen; + memcpy(map, sgnInfo, sgnLen); + } + sws->buffer_unmap(sws, shader->buf); + + return shader; +} diff --git a/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.h b/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.h index ae557bcc8..a62a81447 100644 --- a/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.h +++ b/lib/mesa/src/gallium/winsys/svga/drm/vmw_shader.h @@ -65,4 +65,12 @@ void vmw_svga_winsys_shader_reference(struct vmw_svga_winsys_shader **pdst, struct vmw_svga_winsys_shader *src); +struct vmw_svga_winsys_shader * +vmw_svga_shader_create(struct svga_winsys_screen *sws, + SVGA3dShaderType type, + const uint32 *bytecode, + uint32 bytecodeLen, + const SVGA3dDXShaderSignatureHeader *sgnInfo, + uint32 sgnLen); + #endif /* VMW_SHADER_H_ */ diff --git a/lib/mesa/src/gallium/winsys/sw/dri/dri_sw_winsys.h b/lib/mesa/src/gallium/winsys/sw/dri/dri_sw_winsys.h index 47e3777d4..e9fbac0c1 100644 --- a/lib/mesa/src/gallium/winsys/sw/dri/dri_sw_winsys.h +++ b/lib/mesa/src/gallium/winsys/sw/dri/dri_sw_winsys.h @@ -29,7 +29,7 @@ #ifndef DRI_SW_WINSYS #define DRI_SW_WINSYS -#include "state_tracker/drisw_api.h" +#include "frontend/drisw_api.h" struct sw_winsys; diff --git a/lib/mesa/src/gallium/winsys/sw/dri/meson.build b/lib/mesa/src/gallium/winsys/sw/dri/meson.build index 0de62226b..d8ba95ddd 100644 --- a/lib/mesa/src/gallium/winsys/sw/dri/meson.build +++ b/lib/mesa/src/gallium/winsys/sw/dri/meson.build @@ -22,6 +22,7 @@ libswdri = static_library( 'swdri', files('dri_sw_winsys.c', 'dri_sw_winsys.h'), - c_args : c_vis_args, + gnu_symbol_visibility : 'hidden', include_directories : [inc_gallium, inc_include, inc_src, inc_gallium_aux], + dependencies : idep_mesautil, ) diff --git a/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c b/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c index ed22e82ee..87ffbcc06 100644 --- a/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c +++ b/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c @@ -42,7 +42,7 @@ #include "util/format/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" -#include "state_tracker/sw_winsys.h" +#include "frontend/sw_winsys.h" #include "gdi_sw_winsys.h" diff --git a/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h b/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h index 4bbcb4784..c882b1d8d 100644 --- a/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h +++ b/lib/mesa/src/gallium/winsys/sw/gdi/gdi_sw_winsys.h @@ -4,7 +4,7 @@ #include <windows.h> #include "pipe/p_compiler.h" -#include "state_tracker/sw_winsys.h" +#include "frontend/sw_winsys.h" void gdi_sw_display( struct sw_winsys *winsys, struct sw_displaytarget *dt, diff --git a/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.cpp b/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.cpp new file mode 100644 index 000000000..564f9f612 --- /dev/null +++ b/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.cpp @@ -0,0 +1,246 @@ +/************************************************************************** + * + * Copyright 2009 Artur Wyszynski <harakash@gmail.com> + * Copyright 2013-2014 Alexander von Gluck IV <kallisti5@unixzen.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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + +#include <stdio.h> + +#include "pipe/p_compiler.h" +#include "pipe/p_defines.h" +#include "pipe/p_format.h" +#include "util/u_inlines.h" +#include "util/format/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" +#include "frontend/api.h" +#include "frontend/sw_winsys.h" + +#include "hgl_sw_winsys.h" + +#include <Bitmap.h> +#include <OS.h> + +#ifdef DEBUG +# define TRACE(x...) printf("hgl:winsys: " x) +# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) +#else +# define TRACE(x...) +# define CALLED() +#endif +#define ERROR(x...) printf("hgl:winsys: " x) + + +struct haiku_displaytarget +{ + enum pipe_format format; + color_space colorSpace; + + unsigned width; + unsigned height; + unsigned stride; + + unsigned size; + + void* data; + BBitmap* bitmap; +}; + + +// Cast +static inline struct haiku_displaytarget* +hgl_sw_displaytarget(struct sw_displaytarget* target) +{ + return (struct haiku_displaytarget *)target; +} + + +static void +hgl_winsys_destroy(struct sw_winsys* winsys) +{ + FREE(winsys); +} + + +static bool +hgl_winsys_is_displaytarget_format_supported(struct sw_winsys* winsys, + unsigned textureUsage, enum pipe_format format) +{ + // TODO STUB + return true; +} + +static color_space +hgl_winsys_convert_cs(enum pipe_format format) +{ + // TODO: B_RGB24, B_RGB16, B_RGB15? + switch(format) { + case PIPE_FORMAT_B5G6R5_UNORM: + return B_CMAP8; + case PIPE_FORMAT_A8B8G8R8_UNORM: + case PIPE_FORMAT_X8B8G8R8_UNORM: + default: + return B_RGB32; + } +} + +static struct sw_displaytarget* +hgl_winsys_displaytarget_create(struct sw_winsys* winsys, + unsigned textureUsage, enum pipe_format format, unsigned width, + unsigned height, unsigned alignment, const void *front_private, + unsigned* stride) +{ + struct haiku_displaytarget* haikuDisplayTarget + = CALLOC_STRUCT(haiku_displaytarget); + assert(haikuDisplayTarget); + + TRACE("%s: %d x %d\n", __func__, width, height); + + haikuDisplayTarget->colorSpace = hgl_winsys_convert_cs(format); + haikuDisplayTarget->format = format; + haikuDisplayTarget->width = width; + haikuDisplayTarget->height = height; + + size_t formatStride = util_format_get_stride(format, width); + unsigned blockSize = util_format_get_nblocksy(format, height); + + haikuDisplayTarget->stride = align(formatStride, alignment); + haikuDisplayTarget->size = haikuDisplayTarget->stride * blockSize; + + if (textureUsage & PIPE_BIND_DISPLAY_TARGET) { + haikuDisplayTarget->data = NULL; + haikuDisplayTarget->bitmap = new BBitmap( + BRect(0, 0, width - 1, height - 1), + haikuDisplayTarget->colorSpace, + haikuDisplayTarget->stride); + } else { + haikuDisplayTarget->data + = align_malloc(haikuDisplayTarget->size, alignment); + + haikuDisplayTarget->bitmap = NULL; + } + + *stride = haikuDisplayTarget->stride; + + // Cast to ghost sw_displaytarget type + return (struct sw_displaytarget*)haikuDisplayTarget; +} + + +static void +hgl_winsys_displaytarget_destroy(struct sw_winsys* winsys, + struct sw_displaytarget* displayTarget) +{ + struct haiku_displaytarget* haikuDisplayTarget + = hgl_sw_displaytarget(displayTarget); + + if (!haikuDisplayTarget) + return; + + if (haikuDisplayTarget->data != NULL) + align_free(haikuDisplayTarget->data); + + if (haikuDisplayTarget->bitmap != NULL) + delete haikuDisplayTarget->bitmap; + + FREE(haikuDisplayTarget); +} + + +static struct sw_displaytarget* +hgl_winsys_displaytarget_from_handle(struct sw_winsys* winsys, + const struct pipe_resource* templat, struct winsys_handle* whandle, + unsigned* stride) +{ + return NULL; +} + + +static bool +hgl_winsys_displaytarget_get_handle(struct sw_winsys* winsys, + struct sw_displaytarget* displayTarget, struct winsys_handle* whandle) +{ + return false; +} + + +static void* +hgl_winsys_displaytarget_map(struct sw_winsys* winsys, + struct sw_displaytarget* displayTarget, unsigned flags) +{ + struct haiku_displaytarget* haikuDisplayTarget + = hgl_sw_displaytarget(displayTarget); + + if (haikuDisplayTarget->bitmap != NULL) + return haikuDisplayTarget->bitmap->Bits(); + + return haikuDisplayTarget->data; +} + + +static void +hgl_winsys_displaytarget_unmap(struct sw_winsys* winsys, + struct sw_displaytarget* displayTarget) +{ + return; +} + + +static void +hgl_winsys_displaytarget_display(struct sw_winsys* winsys, + struct sw_displaytarget* displayTarget, void* contextPrivate, + struct pipe_box *box) +{ + assert(contextPrivate); + + struct haiku_displaytarget* haikuDisplayTarget + = hgl_sw_displaytarget(displayTarget); + + HGLWinsysContext *context = (HGLWinsysContext*)contextPrivate; + context->Display(haikuDisplayTarget->bitmap, NULL); +} + + +struct sw_winsys* +hgl_create_sw_winsys() +{ + struct sw_winsys* winsys = CALLOC_STRUCT(sw_winsys); + + if (!winsys) + return NULL; + + // Attach winsys hooks for Haiku + winsys->destroy = hgl_winsys_destroy; + winsys->is_displaytarget_format_supported + = hgl_winsys_is_displaytarget_format_supported; + winsys->displaytarget_create = hgl_winsys_displaytarget_create; + winsys->displaytarget_from_handle = hgl_winsys_displaytarget_from_handle; + winsys->displaytarget_get_handle = hgl_winsys_displaytarget_get_handle; + winsys->displaytarget_map = hgl_winsys_displaytarget_map; + winsys->displaytarget_unmap = hgl_winsys_displaytarget_unmap; + winsys->displaytarget_display = hgl_winsys_displaytarget_display; + winsys->displaytarget_destroy = hgl_winsys_displaytarget_destroy; + + return winsys; +} diff --git a/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.h b/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.h index a81f89082..d20c1933a 100644 --- a/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.h +++ b/lib/mesa/src/gallium/winsys/sw/hgl/hgl_sw_winsys.h @@ -28,6 +28,16 @@ #define _HGL_SOFTWAREWINSYS_H #ifdef __cplusplus +class BBitmap; +class BRect; + +class HGLWinsysContext { +public: + virtual void Display(BBitmap *bitmap, BRect *updateRect) = 0; +}; +#endif + +#ifdef __cplusplus extern "C" { #endif diff --git a/lib/mesa/src/gallium/winsys/sw/hgl/meson.build b/lib/mesa/src/gallium/winsys/sw/hgl/meson.build index 8901096bd..81dcf5bb5 100644 --- a/lib/mesa/src/gallium/winsys/sw/hgl/meson.build +++ b/lib/mesa/src/gallium/winsys/sw/hgl/meson.build @@ -20,10 +20,10 @@ libswhgl = static_library( 'swhgl', - files('hgl_sw_winsys.c'), - c_args : c_vis_args, + files('hgl_sw_winsys.cpp'), + gnu_symbol_visibility : 'hidden', include_directories : [inc_gallium, inc_include, inc_src, inc_gallium_aux, - include_directories('../../../state_trackers/hgl') + include_directories('../../../frontends/hgl') ], build_by_default : false, ) diff --git a/lib/mesa/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/lib/mesa/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c index da11be233..f6449274a 100644 --- a/lib/mesa/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c +++ b/lib/mesa/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c @@ -50,8 +50,8 @@ #include "util/u_memory.h" #include "util/list.h" -#include "state_tracker/sw_winsys.h" -#include "state_tracker/drm_driver.h" +#include "frontend/sw_winsys.h" +#include "frontend/drm_driver.h" #include "kms_dri_sw_winsys.h" #ifdef DEBUG @@ -263,8 +263,8 @@ kms_sw_displaytarget_map(struct sw_winsys *ws, if (ret) return NULL; - prot = (flags == PIPE_TRANSFER_READ) ? PROT_READ : (PROT_READ | PROT_WRITE); - void **ptr = (flags == PIPE_TRANSFER_READ) ? &kms_sw_dt->ro_mapped : &kms_sw_dt->mapped; + prot = (flags == PIPE_MAP_READ) ? PROT_READ : (PROT_READ | PROT_WRITE); + void **ptr = (flags == PIPE_MAP_READ) ? &kms_sw_dt->ro_mapped : &kms_sw_dt->mapped; if (*ptr == MAP_FAILED) { void *tmp = mmap(0, kms_sw_dt->size, prot, MAP_SHARED, kms_sw->fd, map_req.offset); @@ -420,7 +420,7 @@ kms_sw_displaytarget_from_handle(struct sw_winsys *ws, } kms_sw_dt->ref_count --; } - /* fallthrough */ + FALLTHROUGH; default: break; } @@ -451,7 +451,7 @@ kms_sw_displaytarget_get_handle(struct sw_winsys *winsys, whandle->offset = plane->offset; return true; } - /* fallthrough */ + FALLTHROUGH; default: whandle->handle = 0; whandle->stride = 0; diff --git a/lib/mesa/src/gallium/winsys/sw/kms-dri/meson.build b/lib/mesa/src/gallium/winsys/sw/kms-dri/meson.build index 9c46d6e54..b352a5e8f 100644 --- a/lib/mesa/src/gallium/winsys/sw/kms-dri/meson.build +++ b/lib/mesa/src/gallium/winsys/sw/kms-dri/meson.build @@ -22,7 +22,7 @@ libswkmsdri = static_library( 'swkmsdri', files('kms_dri_sw_winsys.c', 'kms_dri_sw_winsys.h'), - c_args : c_vis_args, + gnu_symbol_visibility : 'hidden', include_directories : [inc_gallium, inc_include, inc_src, inc_gallium_aux], - dependencies : dep_libdrm, + dependencies : [dep_libdrm, idep_mesautil], ) diff --git a/lib/mesa/src/gallium/winsys/sw/null/meson.build b/lib/mesa/src/gallium/winsys/sw/null/meson.build index 08b0ff7e8..0a937dc6c 100644 --- a/lib/mesa/src/gallium/winsys/sw/null/meson.build +++ b/lib/mesa/src/gallium/winsys/sw/null/meson.build @@ -21,7 +21,8 @@ libws_null = static_library( 'ws_null', files('null_sw_winsys.c', 'null_sw_winsys.h'), - c_args : c_vis_args, + gnu_symbol_visibility : 'hidden', include_directories : [inc_gallium, inc_src, inc_gallium_aux, inc_include], + dependencies : idep_mesautil, build_by_default : false, ) diff --git a/lib/mesa/src/gallium/winsys/sw/null/null_sw_winsys.c b/lib/mesa/src/gallium/winsys/sw/null/null_sw_winsys.c index e897f246d..a39f74c87 100644 --- a/lib/mesa/src/gallium/winsys/sw/null/null_sw_winsys.c +++ b/lib/mesa/src/gallium/winsys/sw/null/null_sw_winsys.c @@ -39,7 +39,7 @@ #include "pipe/p_format.h" #include "util/u_memory.h" -#include "state_tracker/sw_winsys.h" +#include "frontend/sw_winsys.h" #include "null_sw_winsys.h" diff --git a/lib/mesa/src/gallium/winsys/sw/wrapper/meson.build b/lib/mesa/src/gallium/winsys/sw/wrapper/meson.build index 4672261f2..ba1f2d339 100644 --- a/lib/mesa/src/gallium/winsys/sw/wrapper/meson.build +++ b/lib/mesa/src/gallium/winsys/sw/wrapper/meson.build @@ -21,7 +21,8 @@ libwsw = static_library( 'wsw', files('wrapper_sw_winsys.c', 'wrapper_sw_winsys.h'), - c_args : c_vis_args, + gnu_symbol_visibility : 'hidden', include_directories : [inc_gallium, inc_include, inc_src, inc_gallium_aux], + dependencies : idep_mesautil, build_by_default : false, ) diff --git a/lib/mesa/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/lib/mesa/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c index 37c499b94..529d40d15 100644 --- a/lib/mesa/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c +++ b/lib/mesa/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c @@ -29,7 +29,7 @@ #include "pipe/p_format.h" #include "pipe/p_state.h" -#include "state_tracker/sw_winsys.h" +#include "frontend/sw_winsys.h" #include "util/u_memory.h" #include "util/u_inlines.h" @@ -106,7 +106,7 @@ wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride) void *map; map = pipe_transfer_map(pipe, tex, 0, 0, - PIPE_TRANSFER_READ_WRITE, + PIPE_MAP_READ_WRITE, 0, 0, wdt->tex->width0, wdt->tex->height0, &tr); if (!map) return false; @@ -222,7 +222,7 @@ wsw_dt_map(struct sw_winsys *ws, assert(!wdt->transfer); ptr = pipe_transfer_map(pipe, tex, 0, 0, - PIPE_TRANSFER_READ_WRITE, + PIPE_MAP_READ_WRITE, 0, 0, wdt->tex->width0, wdt->tex->height0, &tr); if (!ptr) goto err; diff --git a/lib/mesa/src/gallium/winsys/sw/xlib/meson.build b/lib/mesa/src/gallium/winsys/sw/xlib/meson.build index c7cb0ffe9..c1c7eb5b3 100644 --- a/lib/mesa/src/gallium/winsys/sw/xlib/meson.build +++ b/lib/mesa/src/gallium/winsys/sw/xlib/meson.build @@ -21,7 +21,7 @@ libws_xlib = static_library( 'ws_xlib', files('xlib_sw_winsys.c'), - c_args : c_vis_args, - include_directories : inc_common, + gnu_symbol_visibility : 'hidden', + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux], dependencies : [dep_x11, dep_xext, dep_xcb], ) diff --git a/lib/mesa/src/gallium/winsys/tegra/drm/meson.build b/lib/mesa/src/gallium/winsys/tegra/drm/meson.build index 46a6ab782..c1102c8fd 100644 --- a/lib/mesa/src/gallium/winsys/tegra/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/tegra/drm/meson.build @@ -25,6 +25,7 @@ libtegradrm = static_library( inc_include, inc_src, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_gallium_winsys ], + dependencies : idep_mesautil, ) driver_tegra = declare_dependency( diff --git a/lib/mesa/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c b/lib/mesa/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c index e2a8efb0f..9f1732a54 100644 --- a/lib/mesa/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c @@ -23,6 +23,7 @@ #include <fcntl.h> +#include "util/os_file.h" #include "util/u_debug.h" #include "tegra/tegra_screen.h" @@ -37,7 +38,7 @@ struct pipe_screen *tegra_drm_screen_create(int fd) * NOTE: There are reportedly issues with reusing the file descriptor * as-is related to Xinerama. Duplicate it to side-step any issues. */ - fd = fcntl(fd, F_DUPFD_CLOEXEC, 0); + fd = os_dupfd_cloexec(fd); if (fd < 0) return NULL; diff --git a/lib/mesa/src/gallium/winsys/v3d/drm/meson.build b/lib/mesa/src/gallium/winsys/v3d/drm/meson.build index e5d7b12d1..3d3cc5b3f 100644 --- a/lib/mesa/src/gallium/winsys/v3d/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/v3d/drm/meson.build @@ -25,5 +25,6 @@ libv3dwinsys = static_library( inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, ], - c_args : [c_vis_args], + gnu_symbol_visibility : 'hidden', + dependencies : idep_mesautil, ) diff --git a/lib/mesa/src/gallium/winsys/v3d/drm/v3d_drm_winsys.c b/lib/mesa/src/gallium/winsys/v3d/drm/v3d_drm_winsys.c index 1502cc728..63681e1ba 100644 --- a/lib/mesa/src/gallium/winsys/v3d/drm/v3d_drm_winsys.c +++ b/lib/mesa/src/gallium/winsys/v3d/drm/v3d_drm_winsys.c @@ -24,6 +24,8 @@ #include <unistd.h> #include <fcntl.h> +#include "util/os_file.h" + #include "v3d_drm_public.h" #include "v3d/v3d_screen.h" @@ -31,7 +33,7 @@ struct pipe_screen * v3d_drm_screen_create(int fd, const struct pipe_screen_config *config) { - return v3d_screen_create(fcntl(fd, F_DUPFD_CLOEXEC, 3), config, NULL); + return v3d_screen_create(os_dupfd_cloexec(fd), config, NULL); } struct pipe_screen * diff --git a/lib/mesa/src/gallium/winsys/vc4/drm/meson.build b/lib/mesa/src/gallium/winsys/vc4/drm/meson.build index 55c85734e..34b685a0d 100644 --- a/lib/mesa/src/gallium/winsys/vc4/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/vc4/drm/meson.build @@ -32,9 +32,11 @@ endif libvc4winsys = static_library( 'vc4winsys', files('vc4_drm_winsys.c'), + dependencies : idep_mesautil, include_directories : [ inc_src, inc_include, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_gallium_winsys, ], - c_args : [c_vis_args, vc4_winsys_c_args], + c_args : [vc4_winsys_c_args], + gnu_symbol_visibility : 'hidden', ) diff --git a/lib/mesa/src/gallium/winsys/virgl/common/meson.build b/lib/mesa/src/gallium/winsys/virgl/common/meson.build index 9182b79a6..0fa9e889c 100644 --- a/lib/mesa/src/gallium/winsys/virgl/common/meson.build +++ b/lib/mesa/src/gallium/winsys/virgl/common/meson.build @@ -21,8 +21,8 @@ libvirglcommon = static_library( 'virglcommon', 'virgl_resource_cache.c', - c_args : c_vis_args, - include_directories : [inc_common, inc_gallium_drivers], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers], + gnu_symbol_visibility : 'hidden', ) dep_libvirglcommon = declare_dependency( diff --git a/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.c b/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.c index 21ec987ba..d7d6a610e 100644 --- a/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.c +++ b/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.c @@ -30,11 +30,12 @@ static bool virgl_resource_cache_entry_is_compatible(struct virgl_resource_cache_entry *entry, uint32_t size, uint32_t bind, - uint32_t format) + uint32_t format, uint32_t flags) { return (entry->bind == bind && entry->format == format && entry->size >= size && + entry->flags == flags && /* We don't want to waste space, so don't reuse resource storage to * hold much smaller (< 50%) sizes. */ @@ -96,7 +97,8 @@ virgl_resource_cache_add(struct virgl_resource_cache *cache, struct virgl_resource_cache_entry * virgl_resource_cache_remove_compatible(struct virgl_resource_cache *cache, - uint32_t size, uint32_t bind, uint32_t format) + uint32_t size, uint32_t bind, + uint32_t format, uint32_t flags) { const int64_t now = os_time_get(); struct virgl_resource_cache_entry *compat_entry = NULL; @@ -108,7 +110,8 @@ virgl_resource_cache_remove_compatible(struct virgl_resource_cache *cache, list_for_each_entry_safe(struct virgl_resource_cache_entry, entry, &cache->resources, head) { const bool compatible = - virgl_resource_cache_entry_is_compatible(entry, size, bind, format); + virgl_resource_cache_entry_is_compatible(entry, size, bind, format, + flags); if (compatible) { if (!cache->entry_is_busy_func(entry, cache->user_data)) diff --git a/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.h b/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.h index f57d4af94..e5f710dc2 100644 --- a/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.h +++ b/lib/mesa/src/gallium/winsys/virgl/common/virgl_resource_cache.h @@ -35,6 +35,7 @@ struct virgl_resource_cache_entry { uint32_t size; uint32_t bind; uint32_t format; + uint32_t flags; }; /* Pointer to a function that returns whether the resource represented by @@ -81,7 +82,7 @@ virgl_resource_cache_add(struct virgl_resource_cache *cache, struct virgl_resource_cache_entry * virgl_resource_cache_remove_compatible(struct virgl_resource_cache *cache, uint32_t size, uint32_t bind, - uint32_t format); + uint32_t format, uint32_t flags); /** Empties the resource cache. */ void @@ -90,11 +91,12 @@ virgl_resource_cache_flush(struct virgl_resource_cache *cache); static inline void virgl_resource_cache_entry_init(struct virgl_resource_cache_entry *entry, uint32_t size, uint32_t bind, - uint32_t format) + uint32_t format, uint32_t flags) { entry->size = size; entry->bind = bind; entry->format = format; + entry->flags = flags; } #endif diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk b/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk index 5e2500774..f3d9df79c 100644 --- a/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk +++ b/lib/mesa/src/gallium/winsys/virgl/drm/Android.mk @@ -29,6 +29,8 @@ LOCAL_SRC_FILES := $(C_SOURCES) LOCAL_MODULE := libmesa_winsys_virgl +LOCAL_C_INCLUDES := $(MESA_TOP)/src/virtio + LOCAL_STATIC_LIBRARIES := libmesa_winsys_virgl_common include $(GALLIUM_COMMON_MK) diff --git a/lib/mesa/src/gallium/winsys/virgl/drm/meson.build b/lib/mesa/src/gallium/winsys/virgl/drm/meson.build index cbb5fb9d4..d4decb0cf 100644 --- a/lib/mesa/src/gallium/winsys/virgl/drm/meson.build +++ b/lib/mesa/src/gallium/winsys/virgl/drm/meson.build @@ -21,7 +21,7 @@ libvirgldrm = static_library( 'virgldrm', 'virgl_drm_winsys.c', - c_args : c_vis_args, - include_directories : [inc_common, inc_gallium_drivers], - dependencies : [dep_libdrm, dep_libvirglcommon], + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_virtio], + dependencies : [dep_libdrm, dep_libvirglcommon, idep_mesautil], + gnu_symbol_visibility : 'hidden', ) diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk b/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk index 5b33f6771..454d830d0 100644 --- a/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk +++ b/lib/mesa/src/gallium/winsys/virgl/vtest/Android.mk @@ -29,6 +29,8 @@ LOCAL_SRC_FILES := $(C_SOURCES) LOCAL_MODULE := libmesa_winsys_virgl_vtest +LOCAL_C_INCLUDES := $(MESA_TOP)/src/virtio + LOCAL_STATIC_LIBRARIES := libmesa_winsys_virgl_common include $(GALLIUM_COMMON_MK) diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources b/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources index 12370d96f..cda28e575 100644 --- a/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources +++ b/lib/mesa/src/gallium/winsys/virgl/vtest/Makefile.sources @@ -2,5 +2,4 @@ C_SOURCES := \ virgl_vtest_public.h \ virgl_vtest_socket.c \ virgl_vtest_winsys.c \ - virgl_vtest_winsys.h \ - vtest_protocol.h + virgl_vtest_winsys.h diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/meson.build b/lib/mesa/src/gallium/winsys/virgl/vtest/meson.build index 9befea673..5f9f3d3df 100644 --- a/lib/mesa/src/gallium/winsys/virgl/vtest/meson.build +++ b/lib/mesa/src/gallium/winsys/virgl/vtest/meson.build @@ -21,7 +21,7 @@ libvirglvtest = static_library( 'virglvtest', ['virgl_vtest_socket.c', 'virgl_vtest_winsys.c'], - c_args : c_vis_args, - include_directories : [inc_common, inc_gallium_drivers], - dependencies : dep_libvirglcommon, + include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_gallium_drivers, inc_virtio], + dependencies : [dep_libvirglcommon, idep_mesautil], + gnu_symbol_visibility : 'hidden', ) diff --git a/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c b/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c index 463bff01f..f24116e32 100644 --- a/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c +++ b/lib/mesa/src/gallium/winsys/virgl/vtest/virgl_vtest_socket.c @@ -148,7 +148,7 @@ static int virgl_vtest_negotiate_version(struct virgl_vtest_winsys *vws) uint32_t version_buf[VCMD_PROTOCOL_VERSION_SIZE]; uint32_t busy_wait_buf[VCMD_BUSY_WAIT_SIZE]; uint32_t busy_wait_result[1]; - int ret; + ASSERTED int ret; vtest_hdr[VTEST_CMD_LEN] = VCMD_PING_PROTOCOL_VERSION_SIZE; vtest_hdr[VTEST_CMD_ID] = VCMD_PING_PROTOCOL_VERSION; @@ -521,7 +521,7 @@ int virgl_vtest_busy_wait(struct virgl_vtest_winsys *vws, int handle, uint32_t vtest_hdr[VTEST_HDR_SIZE]; uint32_t cmd[VCMD_BUSY_WAIT_SIZE]; uint32_t result[1]; - int ret; + ASSERTED int ret; vtest_hdr[VTEST_CMD_LEN] = VCMD_BUSY_WAIT_SIZE; vtest_hdr[VTEST_CMD_ID] = VCMD_RESOURCE_BUSY_WAIT; cmd[VCMD_BUSY_WAIT_HANDLE] = handle; |