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 D3D8_Direct3DVolume8_hpp 16 #define D3D8_Direct3DVolume8_hpp 17 18 #include "Unknown.hpp" 19 20 #include "Surface.hpp" 21 22 #include <d3d8.h> 23 24 namespace D3D8 25 { 26 class Direct3DDevice8; 27 class Direct3DResource8; 28 class Direct3DVolumeTexture8; 29 30 class Direct3DVolume8 : public IDirect3DVolume8, public Unknown, public sw::Surface 31 { 32 public: 33 Direct3DVolume8(Direct3DDevice8 *device, Direct3DVolumeTexture8 *container, int width, int height, int depth, D3DFORMAT format, D3DPOOL pool, bool locakble, unsigned long usage); 34 35 ~Direct3DVolume8() 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 // IDirect3DVolume8 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(IDirect3DDevice8 **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 Direct3DVolumeTexture8 *const container; 62 const int width; 63 const int height; 64 const int depth; 65 const D3DFORMAT format; 66 const D3DPOOL pool; 67 const bool lockable; 68 const unsigned long usage; 69 70 Direct3DResource8 *resource; 71 }; 72 } 73 74 #endif // D3D8_Direct3DVolume8_hpp 75