VirtualBox

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

Last change on this file since 78339 was 53201, checked in by vboxsync, 10 years ago

Devices/Main: vmsvga updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/*
2 * state block implementation
3 *
4 * Copyright 2002 Raphael Junqueira
5 * Copyright 2004 Jason Edmeades
6 * Copyright 2005 Oliver Stieber
7 * Copyright 2007 Stefan Dösinger for CodeWeavers
8 * Copyright 2009 Henri Verbeet for CodeWeavers
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25/*
26 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
27 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
28 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
29 * a choice of LGPL license versions is made available with the language indicating
30 * that LGPLv2 or any later version may be used, or where a choice of which version
31 * of the LGPL is applied is otherwise unspecified.
32 */
33
34#include "config.h"
35#include "wined3d_private.h"
36
37WINE_DEFAULT_DEBUG_CHANNEL(d3d);
38
39/* Allocates the correct amount of space for pixel and vertex shader constants,
40 * along with their set/changed flags on the given stateblock object
41 */
42static HRESULT stateblock_allocate_shader_constants(IWineD3DStateBlockImpl *object)
43{
44 IWineD3DDeviceImpl *device = object->device;
45
46 /* Allocate space for floating point constants */
47 object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
48 sizeof(float) * device->d3d_pshader_constantF * 4);
49 if (!object->pixelShaderConstantF) goto fail;
50
51 object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
52 sizeof(BOOL) * device->d3d_pshader_constantF);
53 if (!object->changed.pixelShaderConstantsF) goto fail;
54
55 object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
56 sizeof(float) * device->d3d_vshader_constantF * 4);
57 if (!object->vertexShaderConstantF) goto fail;
58
59 object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
60 sizeof(BOOL) * device->d3d_vshader_constantF);
61 if (!object->changed.vertexShaderConstantsF) goto fail;
62
63 object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0,
64 sizeof(DWORD) * device->d3d_vshader_constantF);
65 if (!object->contained_vs_consts_f) goto fail;
66
67 object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0,
68 sizeof(DWORD) * device->d3d_pshader_constantF);
69 if (!object->contained_ps_consts_f) goto fail;
70
71 return WINED3D_OK;
72
73fail:
74 ERR("Failed to allocate memory\n");
75 HeapFree(GetProcessHeap(), 0, object->pixelShaderConstantF);
76 HeapFree(GetProcessHeap(), 0, object->changed.pixelShaderConstantsF);
77 HeapFree(GetProcessHeap(), 0, object->vertexShaderConstantF);
78 HeapFree(GetProcessHeap(), 0, object->changed.vertexShaderConstantsF);
79 HeapFree(GetProcessHeap(), 0, object->contained_vs_consts_f);
80 HeapFree(GetProcessHeap(), 0, object->contained_ps_consts_f);
81 return E_OUTOFMEMORY;
82}
83
84static inline void stateblock_set_bits(DWORD *map, UINT map_size)
85{
86 DWORD mask = (1 << (map_size & 0x1f)) - 1;
87 memset(map, 0xff, (map_size >> 5) * sizeof(*map));
88 if (mask) map[map_size >> 5] = mask;
89}
90
91
92HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *device, WINED3DSTATEBLOCKTYPE type)
93{
94 stateblock->ref = 1;
95 stateblock->device = device;
96 stateblock->blockType = type;
97
98 return stateblock_allocate_shader_constants(stateblock);
99}
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