VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/shaderlib/utils.c@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: utils.c 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * DevVMWare/Shaderlib - Utility/Stub Functions & Data.
4 */
5
6/*
7 * Copyright (C) 2013-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#include <iprt/errcore.h>
29#include <iprt/mem.h>
30#include <iprt/assert.h>
31#ifdef _MSC_VER
32# include <iprt/win/windows.h>
33#else
34# include <windows.h>
35#endif
36#include "wined3d_private.h"
37
38
39
40void *wined3d_rb_alloc(size_t size)
41{
42 return RTMemAlloc(size);
43}
44
45void *wined3d_rb_realloc(void *ptr, size_t size)
46{
47 return RTMemRealloc(ptr, size);
48}
49
50void wined3d_rb_free(void *ptr)
51{
52 RTMemFree(ptr);
53}
54
55/* This small helper function is used to convert a bitmask into the number of masked bits */
56unsigned int count_bits(unsigned int mask)
57{
58 unsigned int count;
59 for (count = 0; mask; ++count)
60 {
61 mask &= mask - 1;
62 }
63 return count;
64}
65
66UINT wined3d_log2i(UINT32 x)
67{
68 static const UINT l[] =
69 {
70 ~0U, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
71 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
72 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
73 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
74 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
75 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
76 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
77 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
78 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
79 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
80 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
81 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
82 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
83 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
84 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
85 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
86 };
87 UINT32 i;
88
89 return (i = x >> 16) ? (x = i >> 8) ? l[x] + 24 : l[i] + 16 : (i = x >> 8) ? l[i] + 8 : l[x];
90}
91
92/* Set the shader type for this device, depending on the given capabilities
93 * and the user preferences in wined3d_settings. */
94void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
95{
96 RT_NOREF(gl_info);
97 *vs_selected = SHADER_GLSL;
98 *ps_selected = SHADER_GLSL;
99}
100
101const char *debug_glerror(GLenum error) {
102 switch(error) {
103#define GLERROR_TO_STR(u) case u: return #u
104 GLERROR_TO_STR(GL_NO_ERROR);
105 GLERROR_TO_STR(GL_INVALID_ENUM);
106 GLERROR_TO_STR(GL_INVALID_VALUE);
107 GLERROR_TO_STR(GL_INVALID_OPERATION);
108 GLERROR_TO_STR(GL_STACK_OVERFLOW);
109 GLERROR_TO_STR(GL_STACK_UNDERFLOW);
110 GLERROR_TO_STR(GL_OUT_OF_MEMORY);
111 GLERROR_TO_STR(GL_INVALID_FRAMEBUFFER_OPERATION);
112#undef GLERROR_TO_STR
113 default:
114 return "unrecognized";
115 }
116}
117
118void dump_color_fixup_desc(struct color_fixup_desc fixup)
119{
120 RT_NOREF(fixup);
121}
122
123void context_release(struct wined3d_context *context)
124{
125 RT_NOREF(context);
126}
127
128static void CDECL wined3d_do_nothing(void)
129{
130}
131
132void (* CDECL wine_tsx11_lock_ptr)(void) = wined3d_do_nothing;
133void (* CDECL wine_tsx11_unlock_ptr)(void) = wined3d_do_nothing;
134
135LPVOID WINAPI VBoxHeapAlloc(HANDLE hHeap, DWORD heaptype,SIZE_T size)
136{
137 RT_NOREF(hHeap, heaptype);
138 return RTMemAllocZ(size);
139}
140
141BOOL WINAPI VBoxHeapFree(HANDLE hHeap, DWORD heaptype,LPVOID ptr)
142{
143 RT_NOREF(hHeap, heaptype);
144 RTMemFree(ptr);
145 return TRUE;
146}
147
148LPVOID WINAPI VBoxHeapReAlloc(HANDLE hHeap, DWORD heaptype, LPVOID ptr, SIZE_T size)
149{
150 RT_NOREF(hHeap, heaptype);
151 return RTMemRealloc(ptr, size);
152}
153
154void VBoxDebugBreak(void)
155{
156 AssertFailed();
157}
158
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette