| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,246 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Capabilities.hpp" | ||
|
|
||
| #include "Main/Config.hpp" | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| bool Capabilities::Surface::RenderTarget::R8G8B8 = false; | ||
| bool Capabilities::Surface::RenderTarget::R5G6B5 = true; | ||
| bool Capabilities::Surface::RenderTarget::X1R5G5B5 = true; | ||
| bool Capabilities::Surface::RenderTarget::A1R5G5B5 = true; | ||
| bool Capabilities::Surface::RenderTarget::A4R4G4B4 = true; | ||
| bool Capabilities::Surface::RenderTarget::R3G3B2 = false; | ||
| bool Capabilities::Surface::RenderTarget::A8R3G3B2 = false; | ||
| bool Capabilities::Surface::RenderTarget::X4R4G4B4 = true; | ||
| bool Capabilities::Surface::RenderTarget::A8R8G8B8 = true; | ||
| bool Capabilities::Surface::RenderTarget::X8R8G8B8 = true; | ||
| bool Capabilities::Surface::RenderTarget::A8B8G8R8 = true; | ||
| bool Capabilities::Surface::RenderTarget::X8B8G8R8 = true; | ||
| bool Capabilities::Surface::RenderTarget::G16R16 = true; | ||
| bool Capabilities::Surface::RenderTarget::A2B10G10R10 = true; | ||
|
|
||
| bool Capabilities::Surface::DepthStencil::D32 = true; | ||
| bool Capabilities::Surface::DepthStencil::D24S8 = true; | ||
| bool Capabilities::Surface::DepthStencil::D24X8 = true; | ||
| bool Capabilities::Surface::DepthStencil::D16 = true; | ||
|
|
||
| bool Capabilities::Surface::A8 = true; | ||
| bool Capabilities::Surface::R5G6B5 = true; | ||
| bool Capabilities::Surface::X1R5G5B5 = true; | ||
| bool Capabilities::Surface::A1R5G5B5 = true; | ||
| bool Capabilities::Surface::A4R4G4B4 = true; | ||
| bool Capabilities::Surface::R3G3B2 = true; | ||
| bool Capabilities::Surface::A8R3G3B2 = true; | ||
| bool Capabilities::Surface::X4R4G4B4 = true; | ||
| bool Capabilities::Surface::R8G8B8 = false; | ||
| bool Capabilities::Surface::X8R8G8B8 = true; | ||
| bool Capabilities::Surface::A8R8G8B8 = true; | ||
| bool Capabilities::Surface::X8B8G8R8 = true; | ||
| bool Capabilities::Surface::A8B8G8R8 = true; | ||
| bool Capabilities::Surface::P8 = false; | ||
| bool Capabilities::Surface::A8P8 = false; | ||
| bool Capabilities::Surface::G16R16 = true; | ||
| bool Capabilities::Surface::A2B10G10R10 = true; | ||
| bool Capabilities::Surface::DXT1 = S3TC_SUPPORT; | ||
| bool Capabilities::Surface::DXT2 = S3TC_SUPPORT; | ||
| bool Capabilities::Surface::DXT3 = S3TC_SUPPORT; | ||
| bool Capabilities::Surface::DXT4 = S3TC_SUPPORT; | ||
| bool Capabilities::Surface::DXT5 = S3TC_SUPPORT; | ||
| bool Capabilities::Surface::V8U8 = true; | ||
| bool Capabilities::Surface::L6V5U5 = true; | ||
| bool Capabilities::Surface::X8L8V8U8 = true; | ||
| bool Capabilities::Surface::Q8W8V8U8 = true; | ||
| bool Capabilities::Surface::V16U16 = true; | ||
| bool Capabilities::Surface::A2W10V10U10 = true; | ||
| bool Capabilities::Surface::L8 = true; | ||
| bool Capabilities::Surface::A4L4 = true; | ||
| bool Capabilities::Surface::A8L8 = true; | ||
|
|
||
| bool Capabilities::Volume::A8 = true; | ||
| bool Capabilities::Volume::R5G6B5 = true; | ||
| bool Capabilities::Volume::X1R5G5B5 = true; | ||
| bool Capabilities::Volume::A1R5G5B5 = true; | ||
| bool Capabilities::Volume::A4R4G4B4 = true; | ||
| bool Capabilities::Volume::R3G3B2 = true; | ||
| bool Capabilities::Volume::A8R3G3B2 = true; | ||
| bool Capabilities::Volume::X4R4G4B4 = true; | ||
| bool Capabilities::Volume::R8G8B8 = false; | ||
| bool Capabilities::Volume::X8R8G8B8 = true; | ||
| bool Capabilities::Volume::A8R8G8B8 = true; | ||
| bool Capabilities::Volume::X8B8G8R8 = true; | ||
| bool Capabilities::Volume::A8B8G8R8 = true; | ||
| bool Capabilities::Volume::P8 = false; | ||
| bool Capabilities::Volume::A8P8 = false; | ||
| bool Capabilities::Volume::G16R16 = true; | ||
| bool Capabilities::Volume::A2B10G10R10 = true; | ||
| bool Capabilities::Volume::DXT1 = S3TC_SUPPORT; | ||
| bool Capabilities::Volume::DXT2 = S3TC_SUPPORT; | ||
| bool Capabilities::Volume::DXT3 = S3TC_SUPPORT; | ||
| bool Capabilities::Volume::DXT4 = S3TC_SUPPORT; | ||
| bool Capabilities::Volume::DXT5 = S3TC_SUPPORT; | ||
| bool Capabilities::Volume::V8U8 = true; | ||
| bool Capabilities::Volume::L6V5U5 = true; | ||
| bool Capabilities::Volume::X8L8V8U8 = true; | ||
| bool Capabilities::Volume::Q8W8V8U8 = true; | ||
| bool Capabilities::Volume::V16U16 = true; | ||
| bool Capabilities::Volume::A2W10V10U10 = true; | ||
| bool Capabilities::Volume::L8 = true; | ||
| bool Capabilities::Volume::A4L4 = true; | ||
| bool Capabilities::Volume::A8L8 = true; | ||
|
|
||
| bool Capabilities::CubeMap::RenderTarget::R8G8B8 = false; | ||
| bool Capabilities::CubeMap::RenderTarget::R5G6B5 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::X1R5G5B5 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::A1R5G5B5 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::A4R4G4B4 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::R3G3B2 = false; | ||
| bool Capabilities::CubeMap::RenderTarget::A8R3G3B2 = false; | ||
| bool Capabilities::CubeMap::RenderTarget::X4R4G4B4 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::A8R8G8B8 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::X8R8G8B8 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::A8B8G8R8 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::X8B8G8R8 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::G16R16 = true; | ||
| bool Capabilities::CubeMap::RenderTarget::A2B10G10R10 = true; | ||
|
|
||
| bool Capabilities::CubeMap::DepthStencil::D32 = false; | ||
| bool Capabilities::CubeMap::DepthStencil::D24S8 = false; | ||
| bool Capabilities::CubeMap::DepthStencil::D24X8 = false; | ||
| bool Capabilities::CubeMap::DepthStencil::D16 = false; | ||
|
|
||
| bool Capabilities::CubeMap::A8 = true; | ||
| bool Capabilities::CubeMap::R5G6B5 = true; | ||
| bool Capabilities::CubeMap::X1R5G5B5 = true; | ||
| bool Capabilities::CubeMap::A1R5G5B5 = true; | ||
| bool Capabilities::CubeMap::A4R4G4B4 = true; | ||
| bool Capabilities::CubeMap::R3G3B2 = true; | ||
| bool Capabilities::CubeMap::A8R3G3B2 = true; | ||
| bool Capabilities::CubeMap::X4R4G4B4 = true; | ||
| bool Capabilities::CubeMap::R8G8B8 = false; | ||
| bool Capabilities::CubeMap::X8R8G8B8 = true; | ||
| bool Capabilities::CubeMap::A8R8G8B8 = true; | ||
| bool Capabilities::CubeMap::X8B8G8R8 = true; | ||
| bool Capabilities::CubeMap::A8B8G8R8 = true; | ||
| bool Capabilities::CubeMap::P8 = false; | ||
| bool Capabilities::CubeMap::A8P8 = false; | ||
| bool Capabilities::CubeMap::G16R16 = true; | ||
| bool Capabilities::CubeMap::A2B10G10R10 = true; | ||
| bool Capabilities::CubeMap::DXT1 = S3TC_SUPPORT; | ||
| bool Capabilities::CubeMap::DXT2 = S3TC_SUPPORT; | ||
| bool Capabilities::CubeMap::DXT3 = S3TC_SUPPORT; | ||
| bool Capabilities::CubeMap::DXT4 = S3TC_SUPPORT; | ||
| bool Capabilities::CubeMap::DXT5 = S3TC_SUPPORT; | ||
| bool Capabilities::CubeMap::V8U8 = true; | ||
| bool Capabilities::CubeMap::L6V5U5 = true; | ||
| bool Capabilities::CubeMap::X8L8V8U8 = true; | ||
| bool Capabilities::CubeMap::Q8W8V8U8 = true; | ||
| bool Capabilities::CubeMap::V16U16 = true; | ||
| bool Capabilities::CubeMap::A2W10V10U10 = true; | ||
| bool Capabilities::CubeMap::L8 = true; | ||
| bool Capabilities::CubeMap::A4L4 = true; | ||
| bool Capabilities::CubeMap::A8L8 = true; | ||
|
|
||
| bool Capabilities::VolumeTexture::A8 = true; | ||
| bool Capabilities::VolumeTexture::R5G6B5 = true; | ||
| bool Capabilities::VolumeTexture::X1R5G5B5 = true; | ||
| bool Capabilities::VolumeTexture::A1R5G5B5 = true; | ||
| bool Capabilities::VolumeTexture::A4R4G4B4 = true; | ||
| bool Capabilities::VolumeTexture::R3G3B2 = true; | ||
| bool Capabilities::VolumeTexture::A8R3G3B2 = true; | ||
| bool Capabilities::VolumeTexture::X4R4G4B4 = true; | ||
| bool Capabilities::VolumeTexture::R8G8B8 = false; | ||
| bool Capabilities::VolumeTexture::X8R8G8B8 = true; | ||
| bool Capabilities::VolumeTexture::A8R8G8B8 = true; | ||
| bool Capabilities::VolumeTexture::X8B8G8R8 = true; | ||
| bool Capabilities::VolumeTexture::A8B8G8R8 = true; | ||
| bool Capabilities::VolumeTexture::P8 = false; | ||
| bool Capabilities::VolumeTexture::A8P8 = false; | ||
| bool Capabilities::VolumeTexture::G16R16 = true; | ||
| bool Capabilities::VolumeTexture::A2B10G10R10 = true; | ||
| bool Capabilities::VolumeTexture::DXT1 = S3TC_SUPPORT; | ||
| bool Capabilities::VolumeTexture::DXT2 = S3TC_SUPPORT; | ||
| bool Capabilities::VolumeTexture::DXT3 = S3TC_SUPPORT; | ||
| bool Capabilities::VolumeTexture::DXT4 = S3TC_SUPPORT; | ||
| bool Capabilities::VolumeTexture::DXT5 = S3TC_SUPPORT; | ||
| bool Capabilities::VolumeTexture::V8U8 = true; | ||
| bool Capabilities::VolumeTexture::L6V5U5 = true; | ||
| bool Capabilities::VolumeTexture::X8L8V8U8 = true; | ||
| bool Capabilities::VolumeTexture::Q8W8V8U8 = true; | ||
| bool Capabilities::VolumeTexture::V16U16 = true; | ||
| bool Capabilities::VolumeTexture::A2W10V10U10 = true; | ||
| bool Capabilities::VolumeTexture::L8 = true; | ||
| bool Capabilities::VolumeTexture::A4L4 = true; | ||
| bool Capabilities::VolumeTexture::A8L8 = true; | ||
|
|
||
| bool Capabilities::Texture::RenderTarget::R8G8B8 = false; | ||
| bool Capabilities::Texture::RenderTarget::R5G6B5 = true; | ||
| bool Capabilities::Texture::RenderTarget::X1R5G5B5 = true; | ||
| bool Capabilities::Texture::RenderTarget::A1R5G5B5 = true; | ||
| bool Capabilities::Texture::RenderTarget::A4R4G4B4 = true; | ||
| bool Capabilities::Texture::RenderTarget::R3G3B2 = false; | ||
| bool Capabilities::Texture::RenderTarget::A8R3G3B2 = false; | ||
| bool Capabilities::Texture::RenderTarget::X4R4G4B4 = true; | ||
| bool Capabilities::Texture::RenderTarget::A8R8G8B8 = true; | ||
| bool Capabilities::Texture::RenderTarget::X8R8G8B8 = true; | ||
| bool Capabilities::Texture::RenderTarget::A8B8G8R8 = true; | ||
| bool Capabilities::Texture::RenderTarget::X8B8G8R8 = true; | ||
| bool Capabilities::Texture::RenderTarget::G16R16 = true; | ||
| bool Capabilities::Texture::RenderTarget::A2B10G10R10 = true; | ||
|
|
||
| bool Capabilities::Texture::DepthStencil::D32 = false; | ||
| bool Capabilities::Texture::DepthStencil::D24S8 = false; | ||
| bool Capabilities::Texture::DepthStencil::D24X8 = false; | ||
| bool Capabilities::Texture::DepthStencil::D16 = false; | ||
|
|
||
| bool Capabilities::Texture::A8 = true; | ||
| bool Capabilities::Texture::R5G6B5 = true; | ||
| bool Capabilities::Texture::X1R5G5B5 = true; | ||
| bool Capabilities::Texture::A1R5G5B5 = true; | ||
| bool Capabilities::Texture::A4R4G4B4 = true; | ||
| bool Capabilities::Texture::R3G3B2 = true; | ||
| bool Capabilities::Texture::A8R3G3B2 = true; | ||
| bool Capabilities::Texture::X4R4G4B4 = true; | ||
| bool Capabilities::Texture::R8G8B8 = false; | ||
| bool Capabilities::Texture::X8R8G8B8 = true; | ||
| bool Capabilities::Texture::A8R8G8B8 = true; | ||
| bool Capabilities::Texture::X8B8G8R8 = true; | ||
| bool Capabilities::Texture::A8B8G8R8 = true; | ||
| bool Capabilities::Texture::P8 = false; | ||
| bool Capabilities::Texture::A8P8 = false; | ||
| bool Capabilities::Texture::G16R16 = true; | ||
| bool Capabilities::Texture::A2B10G10R10 = true; | ||
| bool Capabilities::Texture::DXT1 = S3TC_SUPPORT; | ||
| bool Capabilities::Texture::DXT2 = S3TC_SUPPORT; | ||
| bool Capabilities::Texture::DXT3 = S3TC_SUPPORT; | ||
| bool Capabilities::Texture::DXT4 = S3TC_SUPPORT; | ||
| bool Capabilities::Texture::DXT5 = S3TC_SUPPORT; | ||
| bool Capabilities::Texture::V8U8 = true; | ||
| bool Capabilities::Texture::L6V5U5 = true; | ||
| bool Capabilities::Texture::X8L8V8U8 = true; | ||
| bool Capabilities::Texture::Q8W8V8U8 = true; | ||
| bool Capabilities::Texture::V16U16 = true; | ||
| bool Capabilities::Texture::A2W10V10U10 = true; | ||
| bool Capabilities::Texture::L8 = true; | ||
| bool Capabilities::Texture::A4L4 = true; | ||
| bool Capabilities::Texture::A8L8 = true; | ||
|
|
||
| unsigned int pixelShaderVersion = D3DPS_VERSION(1, 4); | ||
| unsigned int vertexShaderVersion = D3DVS_VERSION(1, 1); | ||
|
|
||
| unsigned int textureMemory = 256 * 1024 * 1024; | ||
| unsigned int maxAnisotropy = 16; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,313 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Capabilities_hpp | ||
| #define D3D8_Capabilities_hpp | ||
|
|
||
| #include <d3d8.h> | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| struct Capabilities | ||
| { | ||
| struct Surface | ||
| { | ||
| struct RenderTarget | ||
| { | ||
| static bool R8G8B8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool A8R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| }; | ||
|
|
||
| struct DepthStencil | ||
| { | ||
| static bool D32; | ||
| static bool D24S8; | ||
| static bool D24X8; | ||
| static bool D16; | ||
| }; | ||
|
|
||
| static bool A8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Paletted formats | ||
| static bool P8; | ||
| static bool A8P8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| // Compressed formats | ||
| static bool DXT1; | ||
| static bool DXT2; | ||
| static bool DXT3; | ||
| static bool DXT4; | ||
| static bool DXT5; | ||
| // Bump map formats | ||
| static bool V8U8; | ||
| static bool L6V5U5; | ||
| static bool X8L8V8U8; | ||
| static bool Q8W8V8U8; | ||
| static bool V16U16; | ||
| static bool A2W10V10U10; | ||
| // Luminance formats | ||
| static bool L8; | ||
| static bool A4L4; | ||
| static bool A8L8; | ||
| }; | ||
|
|
||
| struct Volume | ||
| { | ||
| static bool A8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Paletted formats | ||
| static bool P8; | ||
| static bool A8P8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| // Compressed formats | ||
| static bool DXT1; | ||
| static bool DXT2; | ||
| static bool DXT3; | ||
| static bool DXT4; | ||
| static bool DXT5; | ||
| // Bump map formats | ||
| static bool V8U8; | ||
| static bool L6V5U5; | ||
| static bool X8L8V8U8; | ||
| static bool Q8W8V8U8; | ||
| static bool V16U16; | ||
| static bool A2W10V10U10; | ||
| // Luminance formats | ||
| static bool L8; | ||
| static bool A4L4; | ||
| static bool A8L8; | ||
| }; | ||
|
|
||
| struct CubeMap | ||
| { | ||
| struct RenderTarget | ||
| { | ||
| static bool R8G8B8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool A8R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| }; | ||
|
|
||
| struct DepthStencil | ||
| { | ||
| static bool D32; | ||
| static bool D24S8; | ||
| static bool D24X8; | ||
| static bool D16; | ||
| }; | ||
|
|
||
| static bool A8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Paletted formats | ||
| static bool P8; | ||
| static bool A8P8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| // Compressed formats | ||
| static bool DXT1; | ||
| static bool DXT2; | ||
| static bool DXT3; | ||
| static bool DXT4; | ||
| static bool DXT5; | ||
| // Bump map formats | ||
| static bool V8U8; | ||
| static bool L6V5U5; | ||
| static bool X8L8V8U8; | ||
| static bool Q8W8V8U8; | ||
| static bool V16U16; | ||
| static bool A2W10V10U10; | ||
| // Luminance formats | ||
| static bool L8; | ||
| static bool A4L4; | ||
| static bool A8L8; | ||
| }; | ||
|
|
||
| struct VolumeTexture | ||
| { | ||
| static bool A8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Paletted formats | ||
| static bool P8; | ||
| static bool A8P8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| // Compressed formats | ||
| static bool DXT1; | ||
| static bool DXT2; | ||
| static bool DXT3; | ||
| static bool DXT4; | ||
| static bool DXT5; | ||
| // Bump map formats | ||
| static bool V8U8; | ||
| static bool L6V5U5; | ||
| static bool X8L8V8U8; | ||
| static bool Q8W8V8U8; | ||
| static bool V16U16; | ||
| static bool A2W10V10U10; | ||
| // Luminance formats | ||
| static bool L8; | ||
| static bool A4L4; | ||
| static bool A8L8; | ||
| }; | ||
|
|
||
| struct Texture | ||
| { | ||
| struct RenderTarget | ||
| { | ||
| static bool R8G8B8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool A8R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| }; | ||
|
|
||
| struct DepthStencil | ||
| { | ||
| static bool D32; | ||
| static bool D24S8; | ||
| static bool D24X8; | ||
| static bool D16; | ||
| }; | ||
|
|
||
| static bool A8; | ||
| static bool R5G6B5; | ||
| static bool X1R5G5B5; | ||
| static bool A1R5G5B5; | ||
| static bool A4R4G4B4; | ||
| static bool R3G3B2; | ||
| static bool A8R3G3B2; | ||
| static bool X4R4G4B4; | ||
| static bool R8G8B8; | ||
| static bool X8R8G8B8; | ||
| static bool A8R8G8B8; | ||
| static bool A8B8G8R8; | ||
| static bool X8B8G8R8; | ||
| // Paletted formats | ||
| static bool P8; | ||
| static bool A8P8; | ||
| // Integer HDR formats | ||
| static bool G16R16; | ||
| static bool A2B10G10R10; | ||
| // Compressed formats | ||
| static bool DXT1; | ||
| static bool DXT2; | ||
| static bool DXT3; | ||
| static bool DXT4; | ||
| static bool DXT5; | ||
| // Bump map formats | ||
| static bool V8U8; | ||
| static bool L6V5U5; | ||
| static bool X8L8V8U8; | ||
| static bool Q8W8V8U8; | ||
| static bool V16U16; | ||
| static bool A2W10V10U10; | ||
| // Luminance formats | ||
| static bool L8; | ||
| static bool A4L4; | ||
| static bool A8L8; | ||
| }; | ||
| }; | ||
|
|
||
| extern unsigned int pixelShaderVersion; | ||
| extern unsigned int vertexShaderVersion; | ||
|
|
||
| extern unsigned int textureMemory; | ||
| extern unsigned int maxAnisotropy; | ||
| } | ||
|
|
||
| #endif // D3D8_Capabilities_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Direct3D8.hpp" | ||
|
|
||
| #include "resource.h" | ||
|
|
||
| #include <stdio.h> | ||
| #include <assert.h> | ||
|
|
||
| extern "C" | ||
| { | ||
| HINSTANCE dllInstance; | ||
|
|
||
| int __stdcall DllMain(HINSTANCE instance, unsigned long reason, void *reserved) | ||
| { | ||
| dllInstance = instance; | ||
|
|
||
| switch(reason) | ||
| { | ||
| case DLL_PROCESS_DETACH: | ||
| break; | ||
| case DLL_PROCESS_ATTACH: | ||
| DisableThreadLibraryCalls(instance); | ||
| break; | ||
| case DLL_THREAD_ATTACH: | ||
| break; | ||
| case DLL_THREAD_DETACH: | ||
| break; | ||
| default: | ||
| SetLastError(ERROR_INVALID_PARAMETER); | ||
| return FALSE; | ||
| } | ||
|
|
||
| return TRUE; | ||
| } | ||
|
|
||
| IDirect3D8 *__stdcall Direct3DCreate8(unsigned int version) | ||
| { | ||
| // D3D_SDK_VERSION check | ||
| if(version != 120 && // 8.0 | ||
| version != 220) // 8.1 | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| #ifndef NDEBUG | ||
| FILE *file = fopen("debug.txt", "w"); // Clear debug log | ||
| fclose(file); | ||
| #endif | ||
|
|
||
| IDirect3D8 *device = new D3D8::Direct3D8(version, dllInstance); | ||
|
|
||
| if(device) | ||
| { | ||
| device->AddRef(); | ||
| } | ||
|
|
||
| return device; | ||
| } | ||
|
|
||
| int __stdcall CheckFullscreen() // FIXME: __cdecl or __stdcall? | ||
| { | ||
| #ifndef NDEBUG | ||
| // ASSERT(false); // FIXME | ||
| #endif | ||
|
|
||
| return FALSE; | ||
| } | ||
|
|
||
| void __cdecl DebugSetMute(long mute) // FIXME: Return type | ||
| { | ||
| // ASSERT(false); // FIXME | ||
| } | ||
|
|
||
| int __stdcall ValidatePixelShader(long *shader, int x, int y, int z) // FIXME: __cdecl or __stdcall? // FIXME: Argument meanings | ||
| { | ||
| // ASSERT(false); // FIXME | ||
|
|
||
| return TRUE; | ||
| } | ||
|
|
||
| int __stdcall ValidateVertexShader(long *shader, int x, int y, int z) // FIXME: __cdecl or __stdcall? // FIXME: Argument meanings | ||
| { | ||
| // ASSERT(false); // FIXME | ||
|
|
||
| return TRUE; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Microsoft Visual C++ generated resource script. | ||
| // | ||
| #include "resource1.h" | ||
|
|
||
| #define APSTUDIO_READONLY_SYMBOLS | ||
| ///////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // Generated from the TEXTINCLUDE 2 resource. | ||
| // | ||
| #include "Windows.h" | ||
| #include "../Common/Version.h" | ||
| ///////////////////////////////////////////////////////////////////////////// | ||
| #undef APSTUDIO_READONLY_SYMBOLS | ||
|
|
||
| ///////////////////////////////////////////////////////////////////////////// | ||
| // English (United States) resources | ||
|
|
||
| #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
| LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
| #pragma code_page(1252) | ||
|
|
||
| #ifdef APSTUDIO_INVOKED | ||
| ///////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // TEXTINCLUDE | ||
| // | ||
|
|
||
| 1 TEXTINCLUDE | ||
| BEGIN | ||
| "resource1.h\0" | ||
| END | ||
|
|
||
| 2 TEXTINCLUDE | ||
| BEGIN | ||
| "#include ""afxres.h""\r\n" | ||
| "#include ""../Common/Version.h""\0" | ||
| END | ||
|
|
||
| 3 TEXTINCLUDE | ||
| BEGIN | ||
| "\0" | ||
| END | ||
|
|
||
| #endif // APSTUDIO_INVOKED | ||
|
|
||
|
|
||
| ///////////////////////////////////////////////////////////////////////////// | ||
| // | ||
| // Version | ||
| // | ||
|
|
||
| VS_VERSION_INFO VERSIONINFO | ||
| FILEVERSION MAJOR_VERSION,MINOR_VERSION,BUILD_VERSION,BUILD_REVISION | ||
| PRODUCTVERSION MAJOR_VERSION,MINOR_VERSION,BUILD_VERSION,BUILD_REVISION | ||
| FILEFLAGSMASK 0x1fL | ||
| #ifdef _DEBUG | ||
| FILEFLAGS 0x9L | ||
| #else | ||
| FILEFLAGS 0x8L | ||
| #endif | ||
| FILEOS 0x4L | ||
| FILETYPE 0x2L | ||
| FILESUBTYPE 0x0L | ||
| BEGIN | ||
| BLOCK "StringFileInfo" | ||
| BEGIN | ||
| BLOCK "040904b0" | ||
| BEGIN | ||
| VALUE "CompanyName", "Google Inc." | ||
| VALUE "FileDescription", "SwiftShader Direct3D 8 Renderer" | ||
| VALUE "FileVersion", VERSION_STRING | ||
| VALUE "InternalName", "D3D8" | ||
| VALUE "LegalCopyright", "Copyright (C) 2016 Google Inc." | ||
| VALUE "OriginalFilename", "d3d8.dll" | ||
| VALUE "PrivateBuild", REVISION_STRING | ||
| VALUE "ProductName", "SwiftShader Direct3D 8 Renderer" | ||
| VALUE "ProductVersion", VERSION_STRING | ||
| END | ||
| END | ||
| BLOCK "VarFileInfo" | ||
| BEGIN | ||
| VALUE "Translation", 0x409, 1200 | ||
| END | ||
| END | ||
|
|
||
| #endif // English (United States) resources | ||
| ///////////////////////////////////////////////////////////////////////////// | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <ItemGroup> | ||
| <Filter Include="Source Files"> | ||
| <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
| <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
| </Filter> | ||
| <Filter Include="Header Files"> | ||
| <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
| <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
| </Filter> | ||
| <Filter Include="Resource Files"> | ||
| <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
| <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> | ||
| </Filter> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClCompile Include="Capabilities.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="D3D8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3D8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DBaseTexture8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DCubeTexture8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DDevice8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DIndexBuffer8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DPixelShader8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DResource8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DStateBlock8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DSurface8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DSwapChain8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DTexture8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DVertexBuffer8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DVertexDeclaration8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DVertexShader8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DVolume8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Direct3DVolumeTexture8.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Unknown.cpp"> | ||
| <Filter>Source Files</Filter> | ||
| </ClCompile> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClInclude Include="Capabilities.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Debug.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3D8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DBaseTexture8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DCubeTexture8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DDevice8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DIndexBuffer8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DPixelShader8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DResource8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DStateBlock8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DSurface8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DSwapChain8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DTexture8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DVertexBuffer8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DVertexDeclaration8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DVertexShader8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DVolume8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Direct3DVolumeTexture8.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="resource.h"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="resource1.h"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="Unknown.hpp"> | ||
| <Filter>Header Files</Filter> | ||
| </ClInclude> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ResourceCompile Include="D3D8.rc"> | ||
| <Filter>Resource Files</Filter> | ||
| </ResourceCompile> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Include="d3d8.def" /> | ||
| </ItemGroup> | ||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef Debug_hpp | ||
| #define Debug_hpp | ||
|
|
||
| #ifndef WIN32_LEAN_AND_MEAN | ||
| #define WIN32_LEAN_AND_MEAN | ||
| #endif | ||
| #include <windows.h> | ||
| #include <d3d8.h> | ||
| #include <stdio.h> | ||
| #include <guiddef.h> | ||
| #include <assert.h> | ||
|
|
||
| void trace(const char *format, ...); | ||
|
|
||
| #ifndef NDEBUG | ||
| #define TRACE(format, ...) trace("[0x%0.8X]%s("format")\n", this, __FUNCTION__, ##__VA_ARGS__) | ||
| #else | ||
| #define TRACE(...) ((void)0) | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| #define ASSERT(expression) {if(!(expression)) trace("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); assert(expression);} | ||
| #else | ||
| #define ASSERT assert | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| #define UNIMPLEMENTED() {trace("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__); ASSERT(false);} | ||
| #else | ||
| #define UNIMPLEMENTED() ((void)0) | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| #define NOINTERFACE(iid) _NOINTERFACE(__FUNCTION__, iid) | ||
|
|
||
| inline long _NOINTERFACE(const char *function, const IID &iid) | ||
| { | ||
| trace("\t! No interface {0x%0.8X, 0x%0.4X, 0x%0.4X, 0x%0.2X, 0x%0.2X, 0x%0.2X, 0x%0.2X, 0x%0.2X, 0x%0.2X, 0x%0.2X, 0x%0.2X} for %s\n", iid.Data1, iid.Data2, iid.Data3, iid.Data4[0], iid.Data4[1], iid.Data4[2], iid.Data4[3], iid.Data4[4], iid.Data4[5], iid.Data4[6], iid.Data4[7], function); | ||
|
|
||
| return E_NOINTERFACE; | ||
| } | ||
| #else | ||
| #define NOINTERFACE(iid) E_NOINTERFACE | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| inline long INVALIDCALL() | ||
| { | ||
| trace("\t! D3DERR_INVALIDCALL\n"); | ||
|
|
||
| return D3DERR_INVALIDCALL; | ||
| } | ||
| #else | ||
| #define INVALIDCALL() D3DERR_INVALIDCALL | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| inline long OUTOFMEMORY() | ||
| { | ||
| trace("\t! E_OUTOFMEMORY\n"); | ||
|
|
||
| return E_OUTOFMEMORY; | ||
| } | ||
| #else | ||
| #define OUTOFMEMORY() E_OUTOFMEMORY | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| inline long OUTOFVIDEOMEMORY() | ||
| { | ||
| trace("\t! D3DERR_OUTOFVIDEOMEMORY\n"); | ||
|
|
||
| return D3DERR_OUTOFVIDEOMEMORY; | ||
| } | ||
| #else | ||
| #define OUTOFVIDEOMEMORY() D3DERR_OUTOFVIDEOMEMORY | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| inline long NOTAVAILABLE() | ||
| { | ||
| trace("\t! D3DERR_NOTAVAILABLE\n"); | ||
|
|
||
| return D3DERR_NOTAVAILABLE; | ||
| } | ||
| #else | ||
| #define NOTAVAILABLE() D3DERR_NOTAVAILABLE | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| inline long NOTFOUND() | ||
| { | ||
| trace("\t! D3DERR_NOTFOUND\n"); | ||
|
|
||
| return D3DERR_NOTFOUND; | ||
| } | ||
| #else | ||
| #define NOTFOUND() D3DERR_NOTFOUND | ||
| #endif | ||
|
|
||
| #ifndef NDEBUG | ||
| inline long MOREDATA() | ||
| { | ||
| trace("\t! D3DERR_MOREDATA\n"); | ||
|
|
||
| return D3DERR_MOREDATA; | ||
| } | ||
| #else | ||
| #define MOREDATA() D3DERR_MOREDATA | ||
| #endif | ||
|
|
||
| #endif // Debug_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3D8_hpp | ||
| #define D3D8_Direct3D8_hpp | ||
|
|
||
| #include "Unknown.hpp" | ||
|
|
||
| #include <stdio.h> | ||
| #include <initguid.h> | ||
| #include <d3d8.h> | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DDevice8; | ||
|
|
||
| class Direct3D8 : public IDirect3D8, protected Unknown | ||
| { | ||
| public: | ||
| Direct3D8(int version, const HINSTANCE instance); | ||
|
|
||
| virtual ~Direct3D8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3D8 methods | ||
| long __stdcall CheckDepthStencilMatch(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT adapterFormat, D3DFORMAT renderTargetFormat, D3DFORMAT depthStencilFormat); | ||
| long __stdcall CheckDeviceFormat(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT adapaterFormat, unsigned long usage, D3DRESOURCETYPE type, D3DFORMAT checkFormat); | ||
| long __stdcall CheckDeviceMultiSampleType(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT surfaceFormat, int windowed, D3DMULTISAMPLE_TYPE multiSampleType); | ||
| long __stdcall CheckDeviceType(unsigned int adapter, D3DDEVTYPE checkType, D3DFORMAT displayFormat, D3DFORMAT backBufferFormat, int windowed); | ||
| long __stdcall CreateDevice(unsigned int adapter, D3DDEVTYPE deviceType, HWND focusWindow, unsigned long behaviorFlags, D3DPRESENT_PARAMETERS *presentParameters, IDirect3DDevice8 **returnedDeviceInterface); | ||
| long __stdcall EnumAdapterModes(unsigned int adapter, unsigned int index, D3DDISPLAYMODE *mode); | ||
| unsigned int __stdcall GetAdapterCount(); | ||
| long __stdcall GetAdapterDisplayMode(unsigned int adapter, D3DDISPLAYMODE *mode); | ||
| long __stdcall GetAdapterIdentifier(unsigned int adapter, unsigned long flags, D3DADAPTER_IDENTIFIER8 *identifier); | ||
| unsigned int __stdcall GetAdapterModeCount(unsigned int adapter); | ||
| HMONITOR __stdcall GetAdapterMonitor(unsigned int adapter); | ||
| long __stdcall GetDeviceCaps(unsigned int adapter, D3DDEVTYPE deviceType, D3DCAPS8 *caps); | ||
| long __stdcall RegisterSoftwareDevice(void *initializeFunction); | ||
|
|
||
| private: | ||
| void loadSystemD3D8(); | ||
|
|
||
| // Creation parameters | ||
| const int version; | ||
| const HINSTANCE instance; | ||
|
|
||
| DEVMODE *displayMode; | ||
| int numDisplayModes; | ||
|
|
||
| // Real D3D8 library and IDirect3D8 object | ||
| HMODULE d3d8Lib; | ||
| IDirect3D8 *d3d8; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3D8_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Direct3DBaseTexture8.hpp" | ||
|
|
||
| #include "Resource.hpp" | ||
| #include "Debug.hpp" | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| Direct3DBaseTexture8::Direct3DBaseTexture8(Direct3DDevice8 *device, D3DRESOURCETYPE type, unsigned long levels, unsigned long usage) : Direct3DResource8(device, type, 0), levels(levels), usage(usage) | ||
| { | ||
| filterType = D3DTEXF_LINEAR; | ||
| LOD = 0; | ||
|
|
||
| resource = new sw::Resource(0); | ||
| } | ||
|
|
||
| Direct3DBaseTexture8::~Direct3DBaseTexture8() | ||
| { | ||
| resource->destruct(); | ||
| } | ||
|
|
||
| long Direct3DBaseTexture8::QueryInterface(const IID &iid, void **object) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(iid == IID_IDirect3DBaseTexture8 || | ||
| iid == IID_IDirect3DResource8 || | ||
| iid == IID_IUnknown) | ||
| { | ||
| AddRef(); | ||
| *object = this; | ||
|
|
||
| return S_OK; | ||
| } | ||
|
|
||
| *object = 0; | ||
|
|
||
| return NOINTERFACE(iid); | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::AddRef() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::AddRef(); | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::Release() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::Release(); | ||
| } | ||
|
|
||
| long Direct3DBaseTexture8::FreePrivateData(const GUID &guid) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::FreePrivateData(guid); | ||
| } | ||
|
|
||
| long Direct3DBaseTexture8::GetPrivateData(const GUID &guid, void *data, unsigned long *size) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetPrivateData(guid, data, size); | ||
| } | ||
|
|
||
| void Direct3DBaseTexture8::PreLoad() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| Direct3DResource8::PreLoad(); | ||
| } | ||
|
|
||
| long Direct3DBaseTexture8::SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::SetPrivateData(guid, data, size, flags); | ||
| } | ||
|
|
||
| long Direct3DBaseTexture8::GetDevice(IDirect3DDevice8 **device) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetDevice(device); | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::SetPriority(unsigned long newPriority) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::SetPriority(newPriority); | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::GetPriority() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetPriority(); | ||
| } | ||
|
|
||
| D3DRESOURCETYPE Direct3DBaseTexture8::GetType() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetType(); | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::GetLevelCount() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return levels; | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::GetLOD() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return LOD; | ||
| } | ||
|
|
||
| long Direct3DBaseTexture8::SetLOD(long newLOD) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| LOD = newLOD; | ||
|
|
||
| return 0; // TODO | ||
| } | ||
|
|
||
| sw::Resource *Direct3DBaseTexture8::getResource() const | ||
| { | ||
| return resource; | ||
| } | ||
|
|
||
| unsigned long Direct3DBaseTexture8::getInternalLevelCount() | ||
| { | ||
| return levels; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3DBaseTexture8_hpp | ||
| #define D3D8_Direct3DBaseTexture8_hpp | ||
|
|
||
| #include "Direct3DResource8.hpp" | ||
|
|
||
| #include <d3d8.h> | ||
|
|
||
| namespace sw | ||
| { | ||
| class Resource; | ||
| } | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DBaseTexture8 : public IDirect3DBaseTexture8, public Direct3DResource8 | ||
| { | ||
| public: | ||
| Direct3DBaseTexture8(Direct3DDevice8 *device, D3DRESOURCETYPE type, unsigned long levels, unsigned long usage); | ||
|
|
||
| virtual ~Direct3DBaseTexture8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3DResource8 methods | ||
| long __stdcall FreePrivateData(const GUID &guid); | ||
| long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size); | ||
| void __stdcall PreLoad(); | ||
| long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags); | ||
| long __stdcall GetDevice(IDirect3DDevice8 **device); | ||
| unsigned long __stdcall SetPriority(unsigned long newPriority); | ||
| unsigned long __stdcall GetPriority(); | ||
| D3DRESOURCETYPE __stdcall GetType(); | ||
|
|
||
| // IDirect3DBaseTexture8 methods | ||
| unsigned long __stdcall GetLevelCount(); | ||
| unsigned long __stdcall GetLOD(); | ||
| long __stdcall SetLOD(long newLOD); | ||
|
|
||
| // Intenal methods | ||
| sw::Resource *getResource() const; | ||
| unsigned long getInternalLevelCount(); | ||
|
|
||
| protected: | ||
| // Creation paramters | ||
| unsigned long levels; // Recalculated when 0 | ||
| const unsigned long usage; | ||
|
|
||
| sw::Resource *resource; | ||
|
|
||
| private: | ||
| D3DTEXTUREFILTERTYPE filterType; | ||
| unsigned long LOD; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3DBaseTexture8_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,255 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Direct3DCubeTexture8.hpp" | ||
|
|
||
| #include "Direct3DSurface8.hpp" | ||
| #include "Resource.hpp" | ||
| #include "Debug.hpp" | ||
|
|
||
| #include <assert.h> | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| Direct3DCubeTexture8::Direct3DCubeTexture8(Direct3DDevice8 *device, unsigned int edgeLength, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool) : Direct3DBaseTexture8(device, D3DRTYPE_CUBETEXTURE, levels, usage), edgeLength(edgeLength), format(format), pool(pool) | ||
| { | ||
| if(levels == 0) | ||
| { | ||
| this->levels = sw::log2(sw::max((int)edgeLength, 1)) + 1; | ||
| } | ||
|
|
||
| for(unsigned int face = 0; face < 6; face++) | ||
| { | ||
| int width = edgeLength; | ||
| int height = edgeLength; | ||
|
|
||
| for(unsigned int level = 0; level < sw::MIPMAP_LEVELS; level++) | ||
| { | ||
| if(level < this->levels) | ||
| { | ||
| surfaceLevel[face][level] = new Direct3DSurface8(device, this, width, height, format, pool, D3DMULTISAMPLE_NONE, true, usage); | ||
| surfaceLevel[face][level]->bind(); | ||
| } | ||
| else | ||
| { | ||
| surfaceLevel[face][level] = 0; | ||
| } | ||
|
|
||
| width = sw::max(1, width / 2); | ||
| height = sw::max(1, height / 2); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Direct3DCubeTexture8::~Direct3DCubeTexture8() | ||
| { | ||
| resource->lock(sw::DESTRUCT); | ||
|
|
||
| for(unsigned int face = 0; face < 6; face++) | ||
| { | ||
| for(int level = 0; level < sw::MIPMAP_LEVELS; level++) | ||
| { | ||
| if(surfaceLevel[face][level]) | ||
| { | ||
| surfaceLevel[face][level]->unbind(); | ||
| surfaceLevel[face][level] = 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource->unlock(); | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::QueryInterface(const IID &iid, void **object) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(iid == IID_IDirect3DCubeTexture8 || | ||
| iid == IID_IDirect3DBaseTexture8 || | ||
| iid == IID_IDirect3DResource8 || | ||
| iid == IID_IUnknown) | ||
| { | ||
| AddRef(); | ||
| *object = this; | ||
|
|
||
| return S_OK; | ||
| } | ||
|
|
||
| *object = 0; | ||
|
|
||
| return NOINTERFACE(iid); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::AddRef() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::AddRef(); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::Release() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::Release(); | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::FreePrivateData(const GUID &guid) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::FreePrivateData(guid); | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::GetPrivateData(const GUID &guid, void *data, unsigned long *size) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::GetPrivateData(guid, data, size); | ||
| } | ||
|
|
||
| void Direct3DCubeTexture8::PreLoad() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| Direct3DBaseTexture8::PreLoad(); | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::SetPrivateData(guid, data, size, flags); | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::GetDevice(IDirect3DDevice8 **device) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::GetDevice(device); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::SetPriority(unsigned long newPriority) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::SetPriority(newPriority); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::GetPriority() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::GetPriority(); | ||
| } | ||
|
|
||
| D3DRESOURCETYPE Direct3DCubeTexture8::GetType() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::GetType(); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::GetLevelCount() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::GetLevelCount(); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::GetLOD() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::GetLOD(); | ||
| } | ||
|
|
||
| unsigned long Direct3DCubeTexture8::SetLOD(unsigned long newLOD) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DBaseTexture8::SetLOD(newLOD); | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::AddDirtyRect(D3DCUBEMAP_FACES face, const RECT *dirtyRect) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| // UNIMPLEMENTED(); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::GetCubeMapSurface(D3DCUBEMAP_FACES face, unsigned int level , IDirect3DSurface8 **cubeMapSurface) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| *cubeMapSurface = 0; // FIXME: Verify | ||
|
|
||
| if(face >= 6 || level >= GetLevelCount() || !surfaceLevel[face][level]) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| surfaceLevel[face][level]->AddRef(); | ||
| *cubeMapSurface = surfaceLevel[face][level]; | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::GetLevelDesc(unsigned int level, D3DSURFACE_DESC *description) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(!description || level >= GetLevelCount() || !surfaceLevel[0][level]) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| surfaceLevel[0][level]->GetDesc(description); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::LockRect(D3DCUBEMAP_FACES face, unsigned int level, D3DLOCKED_RECT *lockedRect, const RECT *rect, unsigned long flags) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(!lockedRect || face >= 6 || level >= GetLevelCount() || !surfaceLevel[face][level]) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| surfaceLevel[face][level]->LockRect(lockedRect, rect, flags); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DCubeTexture8::UnlockRect(D3DCUBEMAP_FACES face, unsigned int level) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(face >= 6 || level >= GetLevelCount() || !surfaceLevel[face][level]) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| return surfaceLevel[face][level]->UnlockRect(); | ||
| } | ||
|
|
||
| Direct3DSurface8 *Direct3DCubeTexture8::getInternalCubeMapSurface(D3DCUBEMAP_FACES face, unsigned int level) | ||
| { | ||
| return surfaceLevel[face][level]; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3DCubeTexture8_hpp | ||
| #define D3D8_Direct3DCubeTexture8_hpp | ||
|
|
||
| #include "Direct3DBaseTexture8.hpp" | ||
|
|
||
| #include "Config.hpp" | ||
|
|
||
| #include <d3d8.h> | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DSurface8; | ||
|
|
||
| class Direct3DCubeTexture8 : public IDirect3DCubeTexture8, public Direct3DBaseTexture8 | ||
| { | ||
| public: | ||
| Direct3DCubeTexture8(Direct3DDevice8 *device, unsigned int edgeLength, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool); | ||
|
|
||
| virtual ~Direct3DCubeTexture8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3DResource8 methods | ||
| long __stdcall FreePrivateData(const GUID &guid); | ||
| long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size); | ||
| void __stdcall PreLoad(); | ||
| long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags); | ||
| long __stdcall GetDevice(IDirect3DDevice8 **device); | ||
| unsigned long __stdcall SetPriority(unsigned long newPriority); | ||
| unsigned long __stdcall GetPriority(); | ||
| D3DRESOURCETYPE __stdcall GetType(); | ||
|
|
||
| // IDirect3DBaseTexture methods | ||
| unsigned long __stdcall GetLevelCount(); | ||
| unsigned long __stdcall GetLOD(); | ||
| unsigned long __stdcall SetLOD(unsigned long newLOD); | ||
|
|
||
| // IDirect3DCubeTexture8 methods | ||
| long __stdcall AddDirtyRect(D3DCUBEMAP_FACES face, const RECT *dirtyRect); | ||
| long __stdcall GetCubeMapSurface(D3DCUBEMAP_FACES face, unsigned int level , IDirect3DSurface8 **cubeMapSurface); | ||
| long __stdcall GetLevelDesc(unsigned int level, D3DSURFACE_DESC *description); | ||
| long __stdcall LockRect(D3DCUBEMAP_FACES face, unsigned int level, D3DLOCKED_RECT *lockedRect, const RECT *rect, unsigned long flags); | ||
| long __stdcall UnlockRect(D3DCUBEMAP_FACES face, unsigned int level); | ||
|
|
||
| // Internal methods | ||
| Direct3DSurface8 *getInternalCubeMapSurface(D3DCUBEMAP_FACES face, unsigned int level); | ||
|
|
||
| private: | ||
| // Creation parameters | ||
| const unsigned int edgeLength; | ||
| const D3DFORMAT format; | ||
| const D3DPOOL pool; | ||
|
|
||
| Direct3DSurface8 *surfaceLevel[6][sw::MIPMAP_LEVELS]; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3D8_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,272 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3DDevice8_hpp | ||
| #define D3D8_Direct3DDevice8_hpp | ||
|
|
||
| #include "Unknown.hpp" | ||
|
|
||
| #include "Direct3D8.hpp" | ||
| #include "Direct3DStateBlock8.hpp" | ||
| #include "Direct3DVertexDeclaration8.hpp" | ||
| #include "Direct3DSwapChain8.hpp" | ||
|
|
||
| #include "Stream.hpp" | ||
|
|
||
| #include <d3d8.h> | ||
| #include <vector> | ||
| #include <list> | ||
| #include <map> | ||
|
|
||
| namespace sw | ||
| { | ||
| class Renderer; | ||
| class Context; | ||
| } | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DPixelShader8; | ||
| class Direct3DVertexShader8; | ||
| class Direct3DSurface8; | ||
| class Direct3DVertexBuffer8; | ||
| class Direct3DIndexBuffer8; | ||
|
|
||
| class Direct3DDevice8 : public IDirect3DDevice8, protected Unknown | ||
| { | ||
| public: | ||
| Direct3DDevice8(const HINSTANCE instance, Direct3D8 *d3d8, unsigned int adapter, D3DDEVTYPE deviceType, HWND focusWindow, unsigned long behaviourFlags, D3DPRESENT_PARAMETERS *presentParameters); | ||
|
|
||
| virtual ~Direct3DDevice8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3DDevice8 methods | ||
| long __stdcall ApplyStateBlock(unsigned long token); | ||
| long __stdcall BeginScene(); | ||
| long __stdcall BeginStateBlock(); | ||
| long __stdcall CaptureStateBlock(unsigned long token); | ||
| long __stdcall Clear(unsigned long count, const D3DRECT *rects, unsigned long flags, unsigned long color, float z, unsigned long stencil); | ||
| long __stdcall CopyRects(IDirect3DSurface8 *sourceSurface, const RECT *sourceRectsArray, unsigned int rects, IDirect3DSurface8 *destinationSurface, const POINT *destPointsArray); | ||
| long __stdcall CreateAdditionalSwapChain(D3DPRESENT_PARAMETERS *presentParameters, IDirect3DSwapChain8 **swapChain); | ||
| long __stdcall CreateCubeTexture(unsigned int edgeLength, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **cubeTexture); | ||
| long __stdcall CreateDepthStencilSurface(unsigned int width, unsigned int height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multiSample, IDirect3DSurface8 **surface); | ||
| long __stdcall CreateImageSurface(unsigned int width, unsigned int height, D3DFORMAT format, IDirect3DSurface8 **surface); | ||
| long __stdcall CreateIndexBuffer(unsigned int length, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DIndexBuffer8 **indexBuffer); | ||
| long __stdcall CreatePixelShader(const unsigned long *function, unsigned long *handle); | ||
| long __stdcall CreateRenderTarget(unsigned int width, unsigned int height, D3DFORMAT format, D3DMULTISAMPLE_TYPE multiSample, int lockable, IDirect3DSurface8 **surface); | ||
| long __stdcall CreateStateBlock(D3DSTATEBLOCKTYPE type, unsigned long *token); | ||
| long __stdcall CreateTexture(unsigned int width, unsigned int height, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DTexture8 **texture); | ||
| long __stdcall CreateVertexBuffer(unsigned int length, unsigned long usage, unsigned long FVF, D3DPOOL, IDirect3DVertexBuffer8 **vertexBuffer); | ||
| long __stdcall CreateVertexShader(const unsigned long *declaration, const unsigned long *function, unsigned long *handle, unsigned long usage); | ||
| long __stdcall CreateVolumeTexture(unsigned int width, unsigned int height, unsigned int depth, unsigned int levels, unsigned long usage, D3DFORMAT format, D3DPOOL pool, IDirect3DVolumeTexture8 **volumeTexture); | ||
| long __stdcall DeletePatch(unsigned int handle); | ||
| long __stdcall DeletePixelShader(unsigned long handle); | ||
| long __stdcall DeleteStateBlock(unsigned long token); | ||
| long __stdcall DeleteVertexShader(unsigned long handle); | ||
| long __stdcall DrawIndexedPrimitive(D3DPRIMITIVETYPE type, unsigned int minIndex, unsigned int numVertices, unsigned int startIndex, unsigned int primitiveCount); | ||
| long __stdcall DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE type, unsigned int minVertexIndex, unsigned int numVertexIndices, unsigned int PrimitiveCount, const void *indexData, D3DFORMAT indexDataFormat, const void *vertexStreamZeroData, unsigned int VertexStreamZeroStride); | ||
| long __stdcall DrawPrimitive(D3DPRIMITIVETYPE primitiveType, unsigned int startVertex, unsigned int primiveCount); | ||
| long __stdcall DrawPrimitiveUP(D3DPRIMITIVETYPE primitiveType, unsigned int primitiveCount, const void *vertexStreamZeroData, unsigned int vertexStreamZeroStride); | ||
| long __stdcall DrawRectPatch(unsigned int handle, const float *numSegs, const D3DRECTPATCH_INFO *rectPatchInfo); | ||
| long __stdcall DrawTriPatch(unsigned int handle, const float *numSegs, const D3DTRIPATCH_INFO *triPatchInfo); | ||
| long __stdcall EndScene(); | ||
| long __stdcall EndStateBlock(unsigned long *token); | ||
| unsigned int __stdcall GetAvailableTextureMem(); | ||
| long __stdcall GetBackBuffer(unsigned int index, D3DBACKBUFFER_TYPE type, IDirect3DSurface8 **backBuffer); | ||
| long __stdcall GetClipPlane(unsigned long index, float *plane); | ||
| long __stdcall GetClipStatus(D3DCLIPSTATUS8 *clipStatus); | ||
| long __stdcall GetCreationParameters(D3DDEVICE_CREATION_PARAMETERS *parameters); | ||
| long __stdcall GetCurrentTexturePalette(unsigned int *paletteNumber); | ||
| long __stdcall GetDepthStencilSurface(IDirect3DSurface8 **depthStencilSurface); | ||
| long __stdcall GetDeviceCaps(D3DCAPS8 *caps); | ||
| long __stdcall GetDirect3D(IDirect3D8 **D3D); | ||
| long __stdcall GetDisplayMode(D3DDISPLAYMODE *mode); | ||
| long __stdcall GetFrontBuffer(IDirect3DSurface8 *destSurface); | ||
| void __stdcall GetGammaRamp(D3DGAMMARAMP *ramp); | ||
| long __stdcall GetIndices(IDirect3DIndexBuffer8 **indexData, unsigned int *baseVertexIndex); | ||
| long __stdcall GetInfo(unsigned long devInfoID, void *devInfoStruct, unsigned long devInfoStructSize); | ||
| long __stdcall GetLight(unsigned long index, D3DLIGHT8 *p); | ||
| long __stdcall GetLightEnable(unsigned long index , int *enable); | ||
| long __stdcall GetMaterial(D3DMATERIAL8 *material); | ||
| long __stdcall GetPaletteEntries(unsigned int paletteNumber, PALETTEENTRY *entries); | ||
| long __stdcall GetPixelShader(unsigned long *handle); | ||
| long __stdcall GetPixelShaderFunction(unsigned long handle, void *data, unsigned long *sizeOfData); | ||
| long __stdcall GetPixelShaderConstant(unsigned long startRegister, void *constantData, unsigned long constantCount); | ||
| long __stdcall GetRasterStatus(D3DRASTER_STATUS *rasterStatus); | ||
| long __stdcall GetRenderState(D3DRENDERSTATETYPE State, unsigned long *value); | ||
| long __stdcall GetRenderTarget(IDirect3DSurface8 **renderTarget); | ||
| long __stdcall GetStreamSource(unsigned int streamNumber, IDirect3DVertexBuffer8 **streamData, unsigned int *stride); | ||
| long __stdcall GetTexture(unsigned long stage, IDirect3DBaseTexture8 **texture); | ||
| long __stdcall GetTextureStageState(unsigned long stage, D3DTEXTURESTAGESTATETYPE type, unsigned long *value); | ||
| long __stdcall GetTransform(D3DTRANSFORMSTATETYPE state, D3DMATRIX *matrix); | ||
| long __stdcall GetVertexShader(unsigned long *handle); | ||
| long __stdcall GetVertexShaderConstant(unsigned long startRegister, void *constantData, unsigned long constantCount); | ||
| long __stdcall GetVertexShaderDeclaration(unsigned long handle, void *data, unsigned long *size); | ||
| long __stdcall GetVertexShaderFunction(unsigned long handle, void *data, unsigned long *size); | ||
| long __stdcall GetViewport(D3DVIEWPORT8 *viewport); | ||
| long __stdcall LightEnable(unsigned long index, int enable); | ||
| long __stdcall MultiplyTransform(D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix); | ||
| long __stdcall Present(const RECT *sourceRect, const RECT *destRect, HWND destWindowOverride, const RGNDATA *dirtyRegion); | ||
| long __stdcall ProcessVertices(unsigned int srcStartIndex, unsigned int destIndex, unsigned int vertexCount, IDirect3DVertexBuffer8 *destBuffer, unsigned long flags); | ||
| long __stdcall Reset(D3DPRESENT_PARAMETERS *presentParameters); | ||
| long __stdcall ResourceManagerDiscardBytes(unsigned long bytes); | ||
| long __stdcall SetClipPlane(unsigned long index, const float *plane); | ||
| long __stdcall SetClipStatus(const D3DCLIPSTATUS8 *clipStatus); | ||
| long __stdcall SetCurrentTexturePalette(unsigned int paletteNumber); | ||
| void __stdcall SetCursorPosition(int x, int y, unsigned long flags); | ||
| void __stdcall SetCursorPosition(unsigned int x, unsigned int y, unsigned long flags); | ||
| long __stdcall SetCursorProperties(unsigned int x, unsigned int y, IDirect3DSurface8 *cursorBitmap); | ||
| void __stdcall SetGammaRamp(unsigned long flags, const D3DGAMMARAMP *ramp); | ||
| long __stdcall SetIndices(IDirect3DIndexBuffer8 *indexData, unsigned int baseVertexIndex); | ||
| long __stdcall SetLight(unsigned long index, const D3DLIGHT8 *light); | ||
| long __stdcall SetMaterial(const D3DMATERIAL8 *material); | ||
| long __stdcall SetPaletteEntries(unsigned int paletteNumber, const PALETTEENTRY *entries); | ||
| long __stdcall SetPixelShader(unsigned long shader); | ||
| long __stdcall SetPixelShaderConstant(unsigned long startRegister, const void *constantData, unsigned long constantCount); | ||
| long __stdcall SetRenderState(D3DRENDERSTATETYPE state, unsigned long value); | ||
| long __stdcall SetRenderTarget(IDirect3DSurface8 *renderTarget, IDirect3DSurface8 *newZStencil); | ||
| long __stdcall SetStreamSource(unsigned int streamNumber, IDirect3DVertexBuffer8 *streamData, unsigned int stride); | ||
| long __stdcall SetTexture(unsigned long stage, IDirect3DBaseTexture8 *texture); | ||
| long __stdcall SetTextureStageState(unsigned long stage, D3DTEXTURESTAGESTATETYPE type, unsigned long value); | ||
| long __stdcall SetTransform(D3DTRANSFORMSTATETYPE state, const D3DMATRIX *matrix); | ||
| long __stdcall SetVertexShader(unsigned long handle); | ||
| long __stdcall SetVertexShaderConstant(unsigned long startRegister, const void *constantData, unsigned long constantCount); | ||
| long __stdcall SetViewport(const D3DVIEWPORT8 *viewport); | ||
| int __stdcall ShowCursor(int show); | ||
| long __stdcall TestCooperativeLevel(); | ||
| long __stdcall UpdateTexture(IDirect3DBaseTexture8 *sourceTexture, IDirect3DBaseTexture8 *destinationTexture); | ||
| long __stdcall ValidateDevice(unsigned long *numPasses); | ||
|
|
||
| // Internal methods | ||
| long __stdcall updateSurface(IDirect3DSurface8 *sourceSurface, const RECT *sourceRect, IDirect3DSurface8 *destinationSurface, const POINT *destPoint); | ||
|
|
||
| private: | ||
| static int FVFStride(unsigned long FVF); | ||
| static int typeStride(unsigned char streamType); | ||
| static sw::StreamType streamType(int type); | ||
| bool bindData(Direct3DIndexBuffer8 *indexBuffer, int base); | ||
| void bindStreams(int base); | ||
| void bindIndexBuffer(Direct3DIndexBuffer8 *indexBuffer); | ||
| void bindLights(); | ||
| bool bindViewport(); | ||
| void bindTextures(); | ||
| void bindCursor(); | ||
|
|
||
| long updateVolume(IDirect3DVolume8 *sourceVolume, IDirect3DVolume8 *destinationVolume); | ||
| void configureFPU(); | ||
|
|
||
| // Creation parameters | ||
| const HINSTANCE instance; | ||
| Direct3D8 *d3d8; | ||
| const unsigned int adapter; | ||
| const D3DDEVTYPE deviceType; | ||
| const HWND focusWindow; | ||
| const unsigned long behaviourFlags; | ||
| const D3DPRESENT_PARAMETERS presentParameters; | ||
|
|
||
| HWND windowHandle; | ||
|
|
||
| D3DVIEWPORT8 viewport; | ||
| D3DMATRIX matrix[512]; | ||
| Direct3DBaseTexture8 *texture[8]; | ||
| D3DMATERIAL8 material; | ||
| float plane[6][4]; | ||
| D3DCLIPSTATUS8 clipStatus; | ||
|
|
||
| struct Light : D3DLIGHT8 | ||
| { | ||
| Light &operator=(const D3DLIGHT8 &light) | ||
| { | ||
| Type = light.Type; | ||
| Diffuse = light.Diffuse; | ||
| Specular = light.Specular; | ||
| Ambient = light.Ambient; | ||
| Position = light.Position; | ||
| Direction = light.Direction; | ||
| Range = light.Range; | ||
| Falloff = light.Falloff; | ||
| Attenuation0 = light.Attenuation0; | ||
| Attenuation1 = light.Attenuation1; | ||
| Attenuation2 = light.Attenuation2; | ||
| Theta = light.Theta; | ||
| Phi = light.Phi; | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| bool enable; | ||
| }; | ||
|
|
||
| struct Lights : std::map<int, Light> | ||
| { | ||
| bool exists(int index) | ||
| { | ||
| return find(index) != end(); | ||
| } | ||
| }; | ||
|
|
||
| Lights light; | ||
| bool lightsDirty; | ||
|
|
||
| Direct3DVertexBuffer8 *dataStream[16]; | ||
| int streamStride[16]; | ||
| Direct3DIndexBuffer8 *indexData; | ||
| unsigned int baseVertexIndex; | ||
|
|
||
| unsigned long FVF; | ||
|
|
||
| std::vector<Direct3DSwapChain8*> swapChain; | ||
|
|
||
| Direct3DSurface8 *renderTarget; | ||
| Direct3DSurface8 *depthStencil; | ||
|
|
||
| bool recordState; | ||
| std::vector<Direct3DStateBlock8*> stateRecorder; | ||
|
|
||
| unsigned long renderState[D3DRS_NORMALORDER + 1]; | ||
| unsigned long textureStageState[8][D3DTSS_RESULTARG + 1]; | ||
| bool init; // TODO: Deprecate when all state changes implemented | ||
|
|
||
| std::vector<Direct3DPixelShader8*> pixelShader; | ||
| std::vector<Direct3DVertexShader8*> vertexShader; | ||
| unsigned long pixelShaderHandle; | ||
| unsigned long vertexShaderHandle; | ||
| const unsigned long *declaration; | ||
|
|
||
| float pixelShaderConstant[8][4]; | ||
| float vertexShaderConstant[256][4]; | ||
|
|
||
| struct Palette | ||
| { | ||
| PALETTEENTRY entry[256]; | ||
| }; | ||
|
|
||
| unsigned int currentPalette; | ||
| std::map<int, Palette> palette; | ||
|
|
||
| sw::Context *context; | ||
| sw::Renderer *renderer; | ||
|
|
||
| sw::Surface *cursor; | ||
| bool showCursor; | ||
| HCURSOR nullCursor; | ||
| HCURSOR win32Cursor; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3DDevice8_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Direct3DIndexBuffer8.hpp" | ||
|
|
||
| #include "Direct3DDevice8.hpp" | ||
| #include "Resource.hpp" | ||
| #include "Debug.hpp" | ||
|
|
||
| #include <assert.h> | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| Direct3DIndexBuffer8::Direct3DIndexBuffer8(Direct3DDevice8 *device, unsigned int length, unsigned long usage, D3DFORMAT format, D3DPOOL pool) : Direct3DResource8(device, D3DRTYPE_INDEXBUFFER, length), length(length), usage(usage), format(format), pool(pool) | ||
| { | ||
| indexBuffer = new sw::Resource(length + 16); | ||
| } | ||
|
|
||
| Direct3DIndexBuffer8::~Direct3DIndexBuffer8() | ||
| { | ||
| indexBuffer->destruct(); | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::QueryInterface(const IID &iid, void **object) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(iid == IID_IDirect3DIndexBuffer8 || | ||
| iid == IID_IDirect3DResource8 || | ||
| iid == IID_IUnknown) | ||
| { | ||
| AddRef(); | ||
| *object = this; | ||
|
|
||
| return S_OK; | ||
| } | ||
|
|
||
| *object = 0; | ||
|
|
||
| return NOINTERFACE(iid); | ||
| } | ||
|
|
||
| unsigned long Direct3DIndexBuffer8::AddRef() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::AddRef(); | ||
| } | ||
|
|
||
| unsigned long Direct3DIndexBuffer8::Release() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::Release(); | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::FreePrivateData(const GUID &guid) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::FreePrivateData(guid); | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::GetPrivateData(const GUID &guid, void *data, unsigned long *size) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetPrivateData(guid, data, size); | ||
| } | ||
|
|
||
| void Direct3DIndexBuffer8::PreLoad() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| Direct3DResource8::PreLoad(); | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::SetPrivateData(guid, data, size, flags); | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::GetDevice(IDirect3DDevice8 **device) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetDevice(device); | ||
| } | ||
|
|
||
| unsigned long Direct3DIndexBuffer8::SetPriority(unsigned long newPriority) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::SetPriority(newPriority); | ||
| } | ||
|
|
||
| unsigned long Direct3DIndexBuffer8::GetPriority() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetPriority(); | ||
| } | ||
|
|
||
| D3DRESOURCETYPE Direct3DIndexBuffer8::GetType() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Direct3DResource8::GetType(); | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::GetDesc(D3DINDEXBUFFER_DESC *description) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(!description) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| description->Format = format; | ||
| description->Pool = pool; | ||
| description->Size = length; | ||
| description->Type = GetType(); | ||
| description->Usage = usage; | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::Lock(unsigned int offset, unsigned int size, unsigned char **data, unsigned long flags) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(offset == 0 && size == 0) // Lock whole buffer | ||
| { | ||
| size = length; | ||
| } | ||
|
|
||
| if(!data || offset + size > length) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| lockOffset = offset; | ||
| lockSize = size; | ||
|
|
||
| *data = (unsigned char*)indexBuffer->lock(sw::PUBLIC) + offset; | ||
| indexBuffer->unlock(); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DIndexBuffer8::Unlock() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| sw::Resource *Direct3DIndexBuffer8::getResource() const | ||
| { | ||
| return indexBuffer; | ||
| } | ||
|
|
||
| bool Direct3DIndexBuffer8::is32Bit() const | ||
| { | ||
| switch(format) | ||
| { | ||
| case D3DFMT_INDEX16: | ||
| return false; | ||
| case D3DFMT_INDEX32: | ||
| return true; | ||
| default: | ||
| ASSERT(false); | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3DIndexBuffer8_hpp | ||
| #define D3D8_Direct3DIndexBuffer8_hpp | ||
|
|
||
| #include "Direct3DResource8.hpp" | ||
|
|
||
| #include <d3d8.h> | ||
|
|
||
| namespace sw | ||
| { | ||
| class Resource; | ||
| } | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DIndexBuffer8 : public IDirect3DIndexBuffer8, public Direct3DResource8 | ||
| { | ||
| public: | ||
| Direct3DIndexBuffer8(Direct3DDevice8 *device, unsigned int length, unsigned long usage, D3DFORMAT format, D3DPOOL pool); | ||
|
|
||
| virtual ~Direct3DIndexBuffer8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3DResource8 methods | ||
| long __stdcall FreePrivateData(const GUID &guid); | ||
| long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size); | ||
| void __stdcall PreLoad(); | ||
| long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags); | ||
| long __stdcall GetDevice(IDirect3DDevice8 **device); | ||
| unsigned long __stdcall SetPriority(unsigned long newPriority); | ||
| unsigned long __stdcall GetPriority(); | ||
| D3DRESOURCETYPE __stdcall GetType(); | ||
|
|
||
| // IDirect3DIndexBuffer8 methods | ||
| long __stdcall GetDesc(D3DINDEXBUFFER_DESC *description); | ||
| long __stdcall Lock(unsigned int offset, unsigned int size, unsigned char **data, unsigned long flags); | ||
| long __stdcall Unlock(); | ||
|
|
||
| // Internal methods | ||
| sw::Resource *getResource() const; | ||
| bool is32Bit() const; | ||
|
|
||
| private: | ||
| // Creation parameters | ||
| const unsigned int length; | ||
| const long usage; | ||
| const D3DFORMAT format; | ||
| const D3DPOOL pool; | ||
|
|
||
| bool locked; | ||
| unsigned int lockOffset; | ||
| unsigned int lockSize; | ||
| unsigned char *lockData; | ||
|
|
||
| sw::Resource *indexBuffer; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3DIndexBuffer8_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Direct3DPixelShader8.hpp" | ||
|
|
||
| #include "Debug.hpp" | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| Direct3DPixelShader8::Direct3DPixelShader8(Direct3DDevice8 *device, const unsigned long *shaderToken) : device(device), pixelShader(shaderToken) | ||
| { | ||
| const unsigned long *token = shaderToken; | ||
|
|
||
| size = 0; | ||
|
|
||
| while(shaderToken[size] != 0x0000FFFF) | ||
| { | ||
| size++; | ||
| } | ||
|
|
||
| size++; | ||
|
|
||
| this->shaderToken = new unsigned long[size]; | ||
| memcpy(this->shaderToken, shaderToken, size * sizeof(unsigned long)); | ||
| } | ||
|
|
||
| Direct3DPixelShader8::~Direct3DPixelShader8() | ||
| { | ||
| delete[] shaderToken; | ||
| shaderToken = 0; | ||
| } | ||
|
|
||
| long Direct3DPixelShader8::QueryInterface(const IID &iid, void **object) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| ASSERT(false); // Internal object | ||
|
|
||
| return NOINTERFACE(iid); | ||
| } | ||
|
|
||
| unsigned long Direct3DPixelShader8::AddRef() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Unknown::AddRef(); | ||
| } | ||
|
|
||
| unsigned long Direct3DPixelShader8::Release() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Unknown::Release(); | ||
| } | ||
|
|
||
| void Direct3DPixelShader8::GetFunction(void *data, unsigned int *size) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(data) | ||
| { | ||
| memcpy(data, shaderToken, this->size * 4); | ||
| } | ||
|
|
||
| *size = this->size * 4; | ||
| } | ||
|
|
||
| const sw::PixelShader *Direct3DPixelShader8::getPixelShader() const | ||
| { | ||
| return &pixelShader; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3DPixelShader8_hpp | ||
| #define D3D8_Direct3DPixelShader8_hpp | ||
|
|
||
| #include "PixelShader.hpp" | ||
|
|
||
| #include "Unknown.hpp" | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DDevice8; | ||
|
|
||
| class Direct3DPixelShader8 : public Unknown | ||
| { | ||
| public: | ||
| Direct3DPixelShader8(Direct3DDevice8 *device, const unsigned long *shaderToken); | ||
|
|
||
| virtual ~Direct3DPixelShader8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3DPixelShader8 methods | ||
| void __stdcall GetFunction(void *data, unsigned int *size); | ||
|
|
||
| // Internal methods | ||
| const sw::PixelShader *getPixelShader() const; | ||
|
|
||
| private: | ||
| // Creation parameters | ||
| Direct3DDevice8 *const device; | ||
| unsigned long *shaderToken; | ||
| unsigned int size; | ||
|
|
||
| sw::PixelShader pixelShader; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3DPixelShader8_hpp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "Direct3DResource8.hpp" | ||
|
|
||
| #include "Direct3DDevice8.hpp" | ||
| #include "Debug.hpp" | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| unsigned int Direct3DResource8::memoryUsage = 0; | ||
|
|
||
| Direct3DResource8::PrivateData::PrivateData() | ||
| { | ||
| data = 0; | ||
| } | ||
|
|
||
| Direct3DResource8::PrivateData::PrivateData(const void *data, int size, bool managed) | ||
| { | ||
| this->size = size; | ||
| this->managed = managed; | ||
|
|
||
| this->data = (void*)new unsigned char[size]; | ||
| memcpy(this->data, data, size); | ||
|
|
||
| if(managed) | ||
| { | ||
| ((IUnknown*)data)->AddRef(); | ||
| } | ||
| } | ||
|
|
||
| Direct3DResource8::PrivateData &Direct3DResource8::PrivateData::operator=(const PrivateData &privateData) | ||
| { | ||
| size = privateData.size; | ||
| managed = privateData.managed; | ||
|
|
||
| if(data) | ||
| { | ||
| if(managed) | ||
| { | ||
| ((IUnknown*)data)->Release(); | ||
| } | ||
|
|
||
| delete[] data; | ||
| } | ||
|
|
||
| data = (void*)new unsigned char[size]; | ||
| memcpy(data, privateData.data, size); | ||
|
|
||
| return *this; | ||
| } | ||
|
|
||
| Direct3DResource8::PrivateData::~PrivateData() | ||
| { | ||
| if(data && managed) | ||
| { | ||
| ((IUnknown*)data)->Release(); | ||
| } | ||
|
|
||
| delete[] data; | ||
| data = 0; | ||
| } | ||
|
|
||
| Direct3DResource8::Direct3DResource8(Direct3DDevice8 *device, D3DRESOURCETYPE type, unsigned int size) : device(device), type(type), size(size) | ||
| { | ||
| priority = 0; | ||
|
|
||
| memoryUsage += size; | ||
| } | ||
|
|
||
| Direct3DResource8::~Direct3DResource8() | ||
| { | ||
| memoryUsage -= size; | ||
| } | ||
|
|
||
| long Direct3DResource8::QueryInterface(const IID &iid, void **object) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(iid == IID_IDirect3DResource8 || | ||
| iid == IID_IUnknown) | ||
| { | ||
| AddRef(); | ||
| *object = this; | ||
|
|
||
| return S_OK; | ||
| } | ||
|
|
||
| *object = 0; | ||
|
|
||
| return NOINTERFACE(iid); | ||
| } | ||
|
|
||
| unsigned long Direct3DResource8::AddRef() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Unknown::AddRef(); | ||
| } | ||
|
|
||
| unsigned long Direct3DResource8::Release() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return Unknown::Release(); | ||
| } | ||
|
|
||
| long Direct3DResource8::GetDevice(IDirect3DDevice8 **device) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| if(!device) | ||
| { | ||
| return INVALIDCALL(); | ||
| } | ||
|
|
||
| this->device->AddRef(); | ||
| *device = this->device; | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DResource8::SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| privateData[guid] = PrivateData(data, size, flags == D3DSPD_IUNKNOWN); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DResource8::GetPrivateData(const GUID &guid, void *data, unsigned long *size) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| Iterator result = privateData.find(guid); | ||
|
|
||
| if(result == privateData.end()) | ||
| { | ||
| return NOTFOUND(); | ||
| } | ||
|
|
||
| if(result->second.size > *size) | ||
| { | ||
| return MOREDATA(); | ||
| } | ||
|
|
||
| memcpy(data, result->second.data, result->second.size); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| long Direct3DResource8::FreePrivateData(const GUID &guid) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| Iterator result = privateData.find(guid); | ||
|
|
||
| if(result == privateData.end()) | ||
| { | ||
| return D3DERR_NOTFOUND; | ||
| } | ||
|
|
||
| privateData.erase(guid); | ||
|
|
||
| return D3D_OK; | ||
| } | ||
|
|
||
| unsigned long Direct3DResource8::SetPriority(unsigned long newPriority) | ||
| { | ||
| TRACE(""); | ||
|
|
||
| unsigned long oldPriority = priority; | ||
| priority = newPriority; | ||
|
|
||
| return oldPriority; | ||
| } | ||
|
|
||
| unsigned long Direct3DResource8::GetPriority() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return priority; | ||
| } | ||
|
|
||
| void Direct3DResource8::PreLoad() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return; // FIXME: Anything to do? | ||
| } | ||
|
|
||
| D3DRESOURCETYPE Direct3DResource8::GetType() | ||
| { | ||
| TRACE(""); | ||
|
|
||
| return type; | ||
| } | ||
|
|
||
| unsigned int Direct3DResource8::getMemoryUsage() | ||
| { | ||
| return memoryUsage; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // Copyright 2016 The SwiftShader Authors. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef D3D8_Direct3DResource8_hpp | ||
| #define D3D8_Direct3DResource8_hpp | ||
|
|
||
| #include "Unknown.hpp" | ||
|
|
||
| #include <d3d8.h> | ||
|
|
||
| #include <map> | ||
|
|
||
| namespace D3D8 | ||
| { | ||
| class Direct3DDevice8; | ||
|
|
||
| class Direct3DResource8 : public IDirect3DResource8, public Unknown | ||
| { | ||
| public: | ||
| Direct3DResource8(Direct3DDevice8 *device, D3DRESOURCETYPE type, unsigned int size); | ||
|
|
||
| virtual ~Direct3DResource8(); | ||
|
|
||
| // IUnknown methods | ||
| long __stdcall QueryInterface(const IID &iid, void **object); | ||
| unsigned long __stdcall AddRef(); | ||
| unsigned long __stdcall Release(); | ||
|
|
||
| // IDirect3DResource8 methods | ||
| long __stdcall GetDevice(IDirect3DDevice8 **device); | ||
| long __stdcall SetPrivateData(const GUID &guid, const void *data, unsigned long size, unsigned long flags); | ||
| long __stdcall GetPrivateData(const GUID &guid, void *data, unsigned long *size); | ||
| long __stdcall FreePrivateData(const GUID &guid); | ||
| unsigned long __stdcall SetPriority(unsigned long newPriority); | ||
| unsigned long __stdcall GetPriority(); | ||
| void __stdcall PreLoad(); | ||
| D3DRESOURCETYPE __stdcall GetType(); | ||
|
|
||
| // Internal methods | ||
| static unsigned int getMemoryUsage(); | ||
|
|
||
| protected: | ||
| // Creation parameters | ||
| Direct3DDevice8 *const device; | ||
| const D3DRESOURCETYPE type; | ||
| const unsigned int size; | ||
|
|
||
| private: | ||
| unsigned long priority; | ||
|
|
||
| struct PrivateData | ||
| { | ||
| PrivateData(); | ||
| PrivateData(const void *data, int size, bool managed); | ||
|
|
||
| ~PrivateData(); | ||
|
|
||
| PrivateData &operator=(const PrivateData &privateData); | ||
|
|
||
| void *data; | ||
| unsigned long size; | ||
| bool managed; // IUnknown interface | ||
| }; | ||
|
|
||
| struct CompareGUID | ||
| { | ||
| bool operator()(const GUID& left, const GUID& right) const | ||
| { | ||
| return memcmp(&left, &right, sizeof(GUID)) < 0; | ||
| } | ||
| }; | ||
|
|
||
| typedef std::map<GUID, PrivateData, CompareGUID> PrivateDataMap; | ||
| typedef PrivateDataMap::iterator Iterator; | ||
| PrivateDataMap privateData; | ||
|
|
||
| static unsigned int memoryUsage; | ||
| }; | ||
| } | ||
|
|
||
| #endif // D3D8_Direct3DResource8_hpp |