Path: blob/21.2-virgl/src/gallium/auxiliary/renderonly/renderonly.h
4565 views
/*1* Copyright (C) 2016 Christian Gmeiner <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Christian Gmeiner <[email protected]>24*/2526#ifndef RENDERONLY_H27#define RENDERONLY_H2829#include <stdint.h>30#include "frontend/drm_driver.h"31#include "pipe/p_state.h"3233struct renderonly_scanout {34uint32_t handle;35uint32_t stride;36};3738struct renderonly {39/**40* Create a renderonly_scanout object for scanout resource.41*42* This function creates a renderonly_scanout object based on the provided43* resource. The library is designed that the driver specific pipe_resource44* struct holds a pointer to a renderonly_scanout struct.45*46* struct driver_resource {47* struct pipe_resource base;48* struct renderonly_scanout *scanout;49* ...50* };51*52* The renderonly_scanout object exits for two reasons:53* - Do any special treatment for a scanout resource like importing the GPU54* resource into the scanout hw.55* - Make it easier for a gallium driver to detect if anything special needs56* to be done in flush_resource(..) like a resolve to linear.57*/58struct renderonly_scanout *(*create_for_resource)(struct pipe_resource *rsc,59struct renderonly *ro,60struct winsys_handle *out_handle);61void (*destroy)(struct renderonly *ro);62int kms_fd;63int gpu_fd;64};6566static inline struct renderonly_scanout *67renderonly_scanout_for_resource(struct pipe_resource *rsc,68struct renderonly *ro,69struct winsys_handle *out_handle)70{71return ro->create_for_resource(rsc, ro, out_handle);72}7374void75renderonly_scanout_destroy(struct renderonly_scanout *scanout,76struct renderonly *ro);7778static inline boolean79renderonly_get_handle(struct renderonly_scanout *scanout,80struct winsys_handle *handle)81{82if (!scanout)83return FALSE;8485assert(handle->type == WINSYS_HANDLE_TYPE_KMS);86handle->handle = scanout->handle;87handle->stride = scanout->stride;8889return TRUE;90}9192/**93* Create a dumb buffer object for a resource at scanout hw.94*/95struct renderonly_scanout *96renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource *rsc,97struct renderonly *ro,98struct winsys_handle *out_handle);99100/**101* Import GPU resource into scanout hw.102*/103struct renderonly_scanout *104renderonly_create_gpu_import_for_resource(struct pipe_resource *rsc,105struct renderonly *ro,106struct winsys_handle *out_handle);107108#endif /* RENDERONLY_H_ */109110111