• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef D3D9_Direct3DVolume9_hpp
16 #define D3D9_Direct3DVolume9_hpp
17 
18 #include "Unknown.hpp"
19 
20 #include "Surface.hpp"
21 
22 #include <d3d9.h>
23 
24 namespace D3D9
25 {
26 	class Direct3DDevice9;
27 	class Direct3DResource9;
28 	class Direct3DVolumeTexture9;
29 
30 	class Direct3DVolume9 : public IDirect3DVolume9, public Unknown, public sw::Surface
31 	{
32 	public:
33 		Direct3DVolume9(Direct3DDevice9 *device, Direct3DVolumeTexture9 *container, int width, int height, int depth, D3DFORMAT format, D3DPOOL pool, unsigned long usage);
34 
35 		~Direct3DVolume9() override;
36 
37 		// Surface methods
38 		void *lockInternal(int x, int y, int z, sw::Lock lock, sw::Accessor client) override;
39 		void unlockInternal() override;
40 
41 		// IUnknown methods
42 		long __stdcall QueryInterface(const IID &iid, void **object) override;
43 		unsigned long __stdcall AddRef() override;
44 		unsigned long __stdcall Release() override;
45 
46 		// IDirect3DVolume9 methods
47 		long __stdcall FreePrivateData(const GUID &guid) override;
48 		long __stdcall GetContainer(const IID &iid, void **container) override;
49 		long __stdcall GetDesc(D3DVOLUME_DESC *description) override;
50 		long __stdcall GetDevice(IDirect3DDevice9 **device) override;
51 		long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size) override;
52 		long __stdcall LockBox(D3DLOCKED_BOX *lockedVolume, const D3DBOX *box, unsigned long flags) override;
53 		long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) override;
54 		long __stdcall UnlockBox() override;
55 
56 	private:
57 		static sw::Format translateFormat(D3DFORMAT format);
58 		static unsigned int memoryUsage(int width, int height, int depth, D3DFORMAT format);
59 
60 		// Creation parameters
61 		Direct3DDevice9 *const device;
62 		Direct3DVolumeTexture9 *const container;
63 		const int width;
64 		const int height;
65 		const int depth;
66 		const D3DFORMAT format;
67 		const D3DPOOL pool;
68 		const bool lockable;
69 		const unsigned long usage;
70 
71 		Direct3DResource9 *resource;
72 	};
73 }
74 
75 #endif // D3D9_Direct3DVolume9_hpp
76