VirtualBox

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

Last change on this file since 78339 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

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