Path: blob/21.2-virgl/src/gallium/frontends/wgl/stw_device.h
4561 views
/**************************************************************************1*2* Copyright 2008 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef STW_DEVICE_H_28#define STW_DEVICE_H_293031#include "pipe/p_compiler.h"32#include "util/u_handle_table.h"33#include "util/u_dynarray.h"34#include <GL/gl.h>35#include "gldrv.h"36#include "stw_pixelformat.h"373839#ifdef __cplusplus40extern "C" {41#endif4243struct pipe_screen;44struct st_api;45struct st_manager;46struct stw_framebuffer;4748struct stw_device49{50const struct stw_winsys *stw_winsys;5152CRITICAL_SECTION screen_mutex;53bool screen_initialized;54struct pipe_screen *screen;5556/* Cache some PIPE_CAP_* */57unsigned max_2d_length;5859struct st_api *stapi;60struct st_manager *smapi;6162LUID AdapterLuid;6364struct util_dynarray pixelformats;65unsigned pixelformat_count;6667struct WGLCALLBACKS callbacks;6869CRITICAL_SECTION ctx_mutex;70struct handle_table *ctx_table;7172/* TODO: use an atomic counter to track the number of locked73* stw_framebuffer objects. Assert that the counter is zero when74* trying to lock this mutex.75*/76CRITICAL_SECTION fb_mutex;77struct stw_framebuffer *fb_head;7879#ifdef DEBUG80unsigned long memdbg_no;81#endif8283/** WGL_EXT_swap_control */84int refresh_rate;85int swap_interval;8687bool initialized;88};899091extern struct stw_device *stw_dev;9293boolean94stw_init_screen(HDC hdc);9596static inline struct stw_context *97stw_lookup_context_locked( DHGLRC dhglrc )98{99if (dhglrc == 0 || stw_dev == NULL)100return NULL;101return (struct stw_context *) handle_table_get(stw_dev->ctx_table, dhglrc);102}103104105static inline void106stw_lock_contexts(struct stw_device *stw_dev)107{108EnterCriticalSection(&stw_dev->ctx_mutex);109}110111112static inline void113stw_unlock_contexts(struct stw_device *stw_dev)114{115LeaveCriticalSection(&stw_dev->ctx_mutex);116}117118119static inline void120stw_lock_framebuffers(struct stw_device *stw_dev)121{122EnterCriticalSection(&stw_dev->fb_mutex);123}124125126static inline void127stw_unlock_framebuffers(struct stw_device *stw_dev)128{129LeaveCriticalSection(&stw_dev->fb_mutex);130}131132#ifdef __cplusplus133}134#endif135136#endif /* STW_DEVICE_H_ */137138139