VirtualBox

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

Last change on this file since 62935 was 62935, checked in by vboxsync, 9 years ago

Devices: warnings

  • 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 62935 2016-08-03 17:37:54Z vboxsync $ */
2/** @file
3 * DevVMWare/Shaderlib - Utility/Stub Functions & Data.
4 */
5
6/*
7 * Copyright (C) 2013-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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/err.h>
19#include <iprt/mem.h>
20#include <iprt/assert.h>
21#include <iprt/win/windows.h>
22#include "wined3d_private.h"
23
24
25
26void *wined3d_rb_alloc(size_t size)
27{
28 return RTMemAlloc(size);
29}
30
31void *wined3d_rb_realloc(void *ptr, size_t size)
32{
33 return RTMemRealloc(ptr, size);
34}
35
36void wined3d_rb_free(void *ptr)
37{
38 RTMemFree(ptr);
39}
40
41/* This small helper function is used to convert a bitmask into the number of masked bits */
42unsigned int count_bits(unsigned int mask)
43{
44 unsigned int count;
45 for (count = 0; mask; ++count)
46 {
47 mask &= mask - 1;
48 }
49 return count;
50}
51
52UINT wined3d_log2i(UINT32 x)
53{
54 static const UINT l[] =
55 {
56 ~0U, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
57 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
58 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
59 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
60 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
61 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
62 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
63 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
64 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
65 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
66 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
67 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
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 };
73 UINT32 i;
74
75 return (i = x >> 16) ? (x = i >> 8) ? l[x] + 24 : l[i] + 16 : (i = x >> 8) ? l[i] + 8 : l[x];
76}
77
78/* Set the shader type for this device, depending on the given capabilities
79 * and the user preferences in wined3d_settings. */
80void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
81{
82 RT_NOREF(gl_info);
83 *vs_selected = SHADER_GLSL;
84 *ps_selected = SHADER_GLSL;
85}
86
87const char *debug_glerror(GLenum error) {
88 switch(error) {
89#define GLERROR_TO_STR(u) case u: return #u
90 GLERROR_TO_STR(GL_NO_ERROR);
91 GLERROR_TO_STR(GL_INVALID_ENUM);
92 GLERROR_TO_STR(GL_INVALID_VALUE);
93 GLERROR_TO_STR(GL_INVALID_OPERATION);
94 GLERROR_TO_STR(GL_STACK_OVERFLOW);
95 GLERROR_TO_STR(GL_STACK_UNDERFLOW);
96 GLERROR_TO_STR(GL_OUT_OF_MEMORY);
97 GLERROR_TO_STR(GL_INVALID_FRAMEBUFFER_OPERATION);
98#undef GLERROR_TO_STR
99 default:
100 return "unrecognized";
101 }
102}
103
104void dump_color_fixup_desc(struct color_fixup_desc fixup)
105{
106 RT_NOREF(fixup);
107}
108
109void context_release(struct wined3d_context *context)
110{
111 RT_NOREF(context);
112}
113
114static void CDECL wined3d_do_nothing(void)
115{
116}
117
118void (* CDECL wine_tsx11_lock_ptr)(void) = wined3d_do_nothing;
119void (* CDECL wine_tsx11_unlock_ptr)(void) = wined3d_do_nothing;
120
121LPVOID WINAPI VBoxHeapAlloc(HANDLE hHeap, DWORD heaptype,SIZE_T size)
122{
123 RT_NOREF(hHeap, heaptype);
124 return RTMemAllocZ(size);
125}
126
127BOOL WINAPI VBoxHeapFree(HANDLE hHeap, DWORD heaptype,LPVOID ptr)
128{
129 RT_NOREF(hHeap, heaptype);
130 RTMemFree(ptr);
131 return TRUE;
132}
133
134LPVOID WINAPI VBoxHeapReAlloc(HANDLE hHeap, DWORD heaptype, LPVOID ptr, SIZE_T size)
135{
136 RT_NOREF(hHeap, heaptype);
137 return RTMemRealloc(ptr, size);
138}
139
140void VBoxDebugBreak(void)
141{
142 AssertFailed();
143}
144
Note: See TracBrowser for help on using the repository browser.

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