VirtualBox

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

Last change on this file since 61497 was 56292, checked in by vboxsync, 10 years ago

Devices: Updated (C) year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: utils.c 56292 2015-06-09 14:20:46Z vboxsync $ */
2/** @file
3 * DevVMWare/Shaderlib - Utility/Stub Functions & Data.
4 */
5
6/*
7 * Copyright (C) 2013-2015 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/err.h>
19#include <iprt/mem.h>
20#include <iprt/assert.h>
21#include <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 *vs_selected = SHADER_GLSL;
83 *ps_selected = SHADER_GLSL;
84}
85
86const char *debug_glerror(GLenum error) {
87 switch(error) {
88#define GLERROR_TO_STR(u) case u: return #u
89 GLERROR_TO_STR(GL_NO_ERROR);
90 GLERROR_TO_STR(GL_INVALID_ENUM);
91 GLERROR_TO_STR(GL_INVALID_VALUE);
92 GLERROR_TO_STR(GL_INVALID_OPERATION);
93 GLERROR_TO_STR(GL_STACK_OVERFLOW);
94 GLERROR_TO_STR(GL_STACK_UNDERFLOW);
95 GLERROR_TO_STR(GL_OUT_OF_MEMORY);
96 GLERROR_TO_STR(GL_INVALID_FRAMEBUFFER_OPERATION);
97#undef GLERROR_TO_STR
98 default:
99 return "unrecognized";
100 }
101}
102
103void dump_color_fixup_desc(struct color_fixup_desc fixup)
104{
105}
106
107void context_release(struct wined3d_context *context)
108{
109}
110
111static void CDECL wined3d_do_nothing(void)
112{
113}
114
115void (* CDECL wine_tsx11_lock_ptr)(void) = wined3d_do_nothing;
116void (* CDECL wine_tsx11_unlock_ptr)(void) = wined3d_do_nothing;
117
118LPVOID WINAPI VBoxHeapAlloc(HANDLE hHeap, DWORD heaptype,SIZE_T size)
119{
120 return RTMemAllocZ(size);
121}
122
123BOOL WINAPI VBoxHeapFree(HANDLE hHeap, DWORD heaptype,LPVOID ptr)
124{
125 RTMemFree(ptr);
126 return TRUE;
127}
128
129LPVOID WINAPI VBoxHeapReAlloc(HANDLE hHeap,DWORD heaptype,LPVOID ptr ,SIZE_T size)
130{
131 return RTMemRealloc(ptr, size);
132}
133
134void VBoxDebugBreak()
135{
136 AssertFailed();
137}
138
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