Remove DX9 leftovers

This commit is contained in:
Alayan 2023-12-16 16:05:41 +01:00
parent c11a7236c7
commit 4525411e84
No known key found for this signature in database
15 changed files with 7 additions and 463 deletions

View File

@ -67,7 +67,6 @@ set(GE_SOURCES
src/ge_compressor_bptc_bc7.cpp
src/ge_compressor_s3tc_bc3.cpp
src/ge_culling_tool.cpp
src/ge_dx9_texture.cpp
src/ge_main.cpp
src/ge_texture.cpp
src/ge_vma.cpp

View File

@ -1,229 +0,0 @@
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
#include "ge_dx9_texture.hpp"
#include "ge_main.hpp"
#include "ge_texture.hpp"
#include <IAttributes.h>
#include <vector>
namespace GE
{
GEDX9Texture::GEDX9Texture(const std::string& path,
std::function<void(video::IImage*)> image_mani)
: video::ITexture(path.c_str()), m_image_mani(image_mani),
m_device_9(NULL), m_texture_9(NULL), m_texture_size(0),
m_disable_reload(false)
{
m_max_size = getDriver()->getDriverAttributes()
.getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
getDevice9();
reload();
} // GEDX9Texture
// ----------------------------------------------------------------------------
GEDX9Texture::GEDX9Texture(video::IImage* img, const std::string& name)
: video::ITexture(name.c_str()), m_image_mani(nullptr),
m_device_9(NULL), m_texture_9(NULL), m_texture_size(0),
m_disable_reload(true)
{
getDevice9();
if (!m_device_9 || !img)
{
LoadingFailed = true;
return;
}
uint8_t* data = NULL;
m_size = m_orig_size = img->getDimension();
HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height,
0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
&m_texture_9, NULL);
if (FAILED(hr))
{
LoadingFailed = true;
goto exit;
}
data = (uint8_t*)img->lock();
upload(data);
exit:
img->unlock();
img->drop();
} // GEDX9Texture
// ----------------------------------------------------------------------------
GEDX9Texture::GEDX9Texture(const std::string& name, unsigned int size)
: video::ITexture(name.c_str()), m_image_mani(nullptr),
m_device_9(NULL), m_texture_9(NULL), m_texture_size(0),
m_disable_reload(true)
{
getDevice9();
if (!m_device_9)
{
LoadingFailed = true;
return;
}
m_orig_size.Width = size;
m_orig_size.Height = size;
m_size = m_orig_size;
HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height,
0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
&m_texture_9, NULL);
if (FAILED(hr))
{
LoadingFailed = true;
return;
}
std::vector<uint8_t> data;
data.resize(size * size * 4, 0);
upload(data.data());
} // GEDX9Texture
// ----------------------------------------------------------------------------
GEDX9Texture::~GEDX9Texture()
{
if (m_texture_9)
m_texture_9->Release();
if (m_device_9)
m_device_9->Release();
} // ~GEDX9Texture
// ----------------------------------------------------------------------------
void GEDX9Texture::getDevice9()
{
m_device_9 = GE::getDriver()->getExposedVideoData().D3D9.D3DDev9;
if (m_device_9)
m_device_9->AddRef();
} // getDevice9
// ----------------------------------------------------------------------------
void GEDX9Texture::reload()
{
if (m_disable_reload)
return;
if (!m_device_9)
{
LoadingFailed = true;
return;
}
video::IImage* texture_image = getResizedImage(NamedPath.getPtr(),
m_max_size, &m_orig_size);
if (texture_image == NULL)
{
LoadingFailed = true;
return;
}
m_size = texture_image->getDimension();
if (m_image_mani)
m_image_mani(texture_image);
if (m_texture_9 != NULL)
{
m_texture_9->Release();
m_texture_9 = NULL;
}
uint8_t* data = (uint8_t*)texture_image->lock();
HRESULT hr = m_device_9->CreateTexture(m_size.Width, m_size.Height,
0, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
&m_texture_9, NULL);
if (FAILED(hr))
{
LoadingFailed = true;
goto exit;
}
upload(data);
exit:
texture_image->unlock();
texture_image->drop();
} // reload
// ----------------------------------------------------------------------------
void GEDX9Texture::upload(uint8_t* data)
{
const unsigned int w = m_size.Width;
const unsigned int h = m_size.Height;
HRESULT hr;
D3DLOCKED_RECT rect;
hr = m_texture_9->LockRect(0, &rect, 0, 0);
if (FAILED(hr))
return;
uint8_t* dst = (uint8_t*)rect.pBits;
for (u32 i = 0; i < h; i++)
{
memcpy(dst, data, w * 4);
data += w * 4;
dst += rect.Pitch;
}
hr = m_texture_9->UnlockRect(0);
if (FAILED(hr))
return;
m_texture_9->GenerateMipSubLevels();
m_texture_size = w * h * 4;
} // upload
// ----------------------------------------------------------------------------
void* GEDX9Texture::lock(video::E_TEXTURE_LOCK_MODE mode, u32 mipmap_level)
{
if (mode != video::ETLM_READ_ONLY || !m_texture_9)
return NULL;
HRESULT hr;
D3DLOCKED_RECT rect;
hr = m_texture_9->LockRect(0, &rect, 0,
(mode == video::ETLM_READ_ONLY) ? D3DLOCK_READONLY : 0);
if (FAILED(hr))
return NULL;
return rect.pBits;
} // lock
//-----------------------------------------------------------------------------
void GEDX9Texture::updateTexture(void* data, video::ECOLOR_FORMAT format,
u32 w, u32 h, u32 x, u32 y)
{
if (!m_texture_9)
return;
std::vector<uint8_t> image_data;
uint8_t* src = NULL;
if (format == video::ECF_R8)
{
const unsigned int size = w * h;
image_data.resize(size * 4, 255);
uint8_t* orig_data = (uint8_t*)data;
for (unsigned int i = 0; i < size; i++)
image_data[4 * i + 3] = orig_data[i];
src = image_data.data();
}
else if (format == video::ECF_A8R8G8B8)
{
src = (uint8_t*)data;
}
if (src == NULL)
return;
HRESULT hr;
D3DLOCKED_RECT rect;
RECT subimg;
subimg.left = x;
subimg.top = y;
subimg.right = x + w;
subimg.bottom = y + h;
hr = m_texture_9->LockRect(0, &rect, &subimg, 0);
if (FAILED(hr))
return;
uint8_t* dst = (uint8_t*)rect.pBits;
for (u32 i = 0; i < h; i++)
{
memcpy(dst, src, w * 4);
src += w * 4;
dst += rect.Pitch;
}
hr = m_texture_9->UnlockRect(0);
if (FAILED(hr))
return;
m_texture_9->GenerateMipSubLevels();
} // updateTexture
}
#endif

View File

@ -1,88 +0,0 @@
#ifndef HEADER_GE_DX9_TEXTURE_HPP
#define HEADER_GE_DX9_TEXTURE_HPP
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
#include <d3d9.h>
#include <functional>
#include <string>
#include <ITexture.h>
using namespace irr;
namespace GE
{
class GEDX9Texture : public video::ITexture
{
private:
core::dimension2d<u32> m_size, m_orig_size, m_max_size;
std::function<void(video::IImage*)> m_image_mani;
IDirect3DDevice9* m_device_9;
IDirect3DTexture9* m_texture_9;
unsigned int m_texture_size;
const bool m_disable_reload;
// ------------------------------------------------------------------------
void getDevice9();
// ------------------------------------------------------------------------
void upload(uint8_t* data);
public:
// ------------------------------------------------------------------------
GEDX9Texture(const std::string& path,
std::function<void(video::IImage*)> image_mani = nullptr);
// ------------------------------------------------------------------------
GEDX9Texture(video::IImage* img, const std::string& name);
// ------------------------------------------------------------------------
GEDX9Texture(const std::string& name, unsigned int size);
// ------------------------------------------------------------------------
virtual ~GEDX9Texture();
// ------------------------------------------------------------------------
virtual void* lock(video::E_TEXTURE_LOCK_MODE mode =
video::ETLM_READ_WRITE, u32 mipmap_level = 0);
// ------------------------------------------------------------------------
virtual void unlock()
{
if (m_texture_9)
m_texture_9->UnlockRect(0);
}
// ------------------------------------------------------------------------
virtual const core::dimension2d<u32>& getOriginalSize() const
{ return m_orig_size; }
// ------------------------------------------------------------------------
virtual const core::dimension2d<u32>& getSize() const { return m_size; }
// ------------------------------------------------------------------------
virtual video::E_DRIVER_TYPE getDriverType() const
{ return video::EDT_DIRECT3D9; }
// ------------------------------------------------------------------------
virtual video::ECOLOR_FORMAT getColorFormat() const
{ return video::ECF_A8R8G8B8; }
// ------------------------------------------------------------------------
virtual u32 getPitch() const { return 0; }
// ------------------------------------------------------------------------
virtual bool hasMipMaps() const { return true; }
// ------------------------------------------------------------------------
virtual void regenerateMipMapLevels(void* mipmap_data = NULL) {}
// ------------------------------------------------------------------------
virtual u64 getTextureHandler() const { return (u64)m_texture_9; }
// ------------------------------------------------------------------------
virtual unsigned int getTextureSize() const { return m_texture_size; }
// ------------------------------------------------------------------------
virtual void reload();
// ------------------------------------------------------------------------
virtual void updateTexture(void* data, irr::video::ECOLOR_FORMAT format,
u32 w, u32 h, u32 x, u32 y);
}; // GEDX9Texture
}
#endif
#endif

View File

@ -1,5 +1,4 @@
#include "ge_main.hpp"
#include "ge_dx9_texture.hpp"
#include "ge_gl_texture.hpp"
#include "ge_vulkan_texture.hpp"
#include "ge_texture.hpp"
@ -97,10 +96,6 @@ irr::video::ITexture* createTexture(const std::string& path,
case video::EDT_OPENGL:
case video::EDT_OGLES2:
return new GEGLTexture(path, image_mani);
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
case video::EDT_DIRECT3D9:
return new GEDX9Texture(path, image_mani);
#endif
case video::EDT_VULKAN:
return new GEVulkanTexture(path, image_mani);
default:
@ -117,10 +112,6 @@ irr::video::ITexture* createTexture(video::IImage* img,
case video::EDT_OPENGL:
case video::EDT_OGLES2:
return new GEGLTexture(img, name);
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
case video::EDT_DIRECT3D9:
return new GEDX9Texture(img, name);
#endif
case video::EDT_VULKAN:
return new GEVulkanTexture(img, name);
default:
@ -137,10 +128,6 @@ irr::video::ITexture* createFontTexture(const std::string& name,
case video::EDT_OPENGL:
case video::EDT_OGLES2:
return new GEGLTexture(name, size, single_channel);
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
case video::EDT_DIRECT3D9:
return new GEDX9Texture(name, size);
#endif
case video::EDT_VULKAN:
return new GEVulkanTexture(name, size, single_channel);
default:

View File

@ -26,7 +26,6 @@ else()
add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
add_definitions(-DNO_IRR_COMPILE_WITH_WAYLAND_DEVICE_)
add_definitions(-DNO_IRR_COMPILE_WITH_SDL_DEVICE_)
add_definitions(-DNO_IRR_COMPILE_WITH_DIRECT3D_9_)
add_definitions(-DNO_IRR_COMPILE_WITH_VULKAN_)
endif()

View File

@ -37,16 +37,6 @@ namespace video
contribution. */
EDT_BURNINGSVIDEO,
//! Direct3D8 device, only available on Win32 platforms.
/** Performs hardware accelerated rendering of 3D and 2D
primitives. */
EDT_DIRECT3D8,
//! Direct3D 9 device, only available on Win32 platforms.
/** Performs hardware accelerated rendering of 3D and 2D
primitives. */
EDT_DIRECT3D9,
//! OpenGL device, available on most platforms.
/** Performs hardware accelerated rendering of 3D and 2D
primitives. */

View File

@ -17,7 +17,7 @@ namespace video
/** You can get a list via IrrlichtDevice::getVideoModeList(). If you are confused
now, because you think you have to create an Irrlicht Device with a video
mode before being able to get the video mode list, let me tell you that
there is no need to start up an Irrlicht Device with EDT_DIRECT3D8, EDT_OPENGL or
there is no need to start up an Irrlicht Device with EDT_OPENGL or
EDT_SOFTWARE: For this (and for lots of other reasons) the null device,
EDT_NULL exists.*/
class IVideoModeList : public virtual IReferenceCounted

View File

@ -135,21 +135,6 @@
//! Maximum number of texture an SMaterial can have, up to 8 are supported by Irrlicht.
#define _IRR_MATERIAL_MAX_TEXTURES_ 8
//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to
//! compile the Irrlicht engine with Direct3D8 and/or DIRECT3D9.
/** If you only want to use the software device or opengl you can disable those defines.
This switch is mostly disabled because people do not get the g++ compiler compile
directX header files, and directX is only available on Windows platforms. If you
are using Dev-Cpp, and want to compile this using a DX dev pack, you can define
_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this
to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK
and this to the linker settings: -ld3dx9 -ld3dx8
Microsoft have chosen to remove D3D8 headers from their recent DXSDKs, and
so D3D8 support is now disabled by default. If you really want to build
with D3D8 support, then you will have to source a DXSDK with the appropriate
headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one.
*/
#if defined(_IRR_WINDOWS_API_)
//! Define _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_ if you want to use DirectInput for joystick handling.
@ -160,14 +145,6 @@ If not defined, Windows Multimedia library is used, which offers also broad supp
#undef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
#endif
//! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004
// #define _IRR_COMPILE_WITH_DIRECT3D_8_
#ifdef NO_IRR_COMPILE_WITH_DIRECT3D_9_
#undef _IRR_COMPILE_WITH_DIRECT3D_9_
#else
#define _IRR_COMPILE_WITH_DIRECT3D_9_
#endif
#endif
//! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL.
@ -454,17 +431,6 @@ precision will be lower but speed higher. currently X86 only
#endif // _IRR_WINDOWS_API_
// We need to disable DIRECT3D9 support for Visual Studio 6.0 because
// those $%&$!! disabled support for it since Dec. 2004 and users are complaining
// about linker errors. Comment this out only if you are knowing what you are
// doing. (Which means you have an old DX9 SDK and VisualStudio6).
#ifdef _MSC_VER
#if (_MSC_VER < 1300 && !defined(__GNUC__))
#undef _IRR_COMPILE_WITH_DIRECT3D_9_
#pragma message("Compiling Irrlicht with Visual Studio 6.0, support for DX9 is disabled.")
#endif
#endif
#ifndef _IRR_WINDOWS_API_
#undef _IRR_WCHAR_FILESYSTEM
#endif

View File

@ -111,8 +111,8 @@ namespace irr
/** If you are confused now, because you think you have to
create an Irrlicht Device with a video mode before being able
to get the video mode list, let me tell you that there is no
need to start up an Irrlicht Device with EDT_DIRECT3D8,
EDT_OPENGL or EDT_SOFTWARE: For this (and for lots of other
need to start up an Irrlicht Device with EDT_OPENGL or
EDT_SOFTWARE: For this (and for lots of other
reasons) the null driver, EDT_NULL exists.
\return Pointer to a list with all video modes supported
by the gfx adapter. */
@ -344,18 +344,6 @@ namespace irr
return true;
#else
return false;
#endif
case video::EDT_DIRECT3D8:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
return true;
#else
return false;
#endif
case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
return true;
#else
return false;
#endif
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_

View File

@ -112,8 +112,7 @@ namespace irr
//! Type of video driver used to render graphics.
/** This can currently be video::EDT_NULL, video::EDT_SOFTWARE,
video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8,
video::EDT_DIRECT3D9, and video::EDT_OPENGL.
video::EDT_BURNINGSVIDEO, video::EDT_OPENGL, and video::EDT_VULKAN.
Default: Software. */
video::E_DRIVER_TYPE DriverType;

View File

@ -300,7 +300,7 @@ namespace irr
/** If you need more parameters to be passed to the creation of the Irrlicht Engine device,
use the createDeviceEx() function.
\param deviceType: Type of the device. This can currently be video::EDT_NULL,
video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_DIRECT3D8, video::EDT_DIRECT3D9 and video::EDT_OPENGL.
video::EDT_SOFTWARE, video::EDT_BURNINGSVIDEO, video::EDT_OPENGL and video::EDT_VULKAN.
\param windowSize: Size of the window or the video mode in fullscreen mode.
\param bits: Bits per pixel in fullscreen mode. Ignored if windowed mode.
\param fullscreen: Should be set to true if the device should run in fullscreen. Otherwise

View File

@ -1332,12 +1332,6 @@ void CIrrDeviceLinux::createDriver()
break;
}
case video::EDT_DIRECT3D8:
case video::EDT_DIRECT3D9:
os::Printer::log("This driver is not available in Linux. Try OpenGL or Software renderer.",
ELL_ERROR);
break;
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;

View File

@ -39,10 +39,6 @@ namespace irr
io::IFileSystem* io, CIrrDeviceSDL* device);
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceSDL* device, u32 default_fb);
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
IVideoDriver* createDirectX9Driver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_VULKAN_
IVideoDriver* createVulkanDriver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, SDL_Window* win, IrrlichtDevice* device);
@ -132,13 +128,11 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
{
SDL_VERSION(&Info.version);
#if (defined(IOS_STK) || defined(_IRR_COMPILE_WITH_DIRECT3D_9_)) && !defined(__SWITCH__)
// Only iOS or DirectX9 build uses the Info structure
#if (defined(IOS_STK) && !defined(__SWITCH__))
// Only iOS build uses the Info structure
// Switch doesn't support GetWindowWMInfo
#ifdef IOS_STK
if (!SDL_GetWindowWMInfo(Window, &Info))
#else
if (CreationParams.DriverType == video::EDT_DIRECT3D9 && !SDL_GetWindowWMInfo(Window, &Info))
#endif
return;
#endif
@ -728,16 +722,6 @@ void CIrrDeviceSDL::createDriver()
break;
}
case video::EDT_DIRECT3D9:
{
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, Info.info.win.window);
#else
os::Printer::log("No DirectX 9 support compiled in.", ELL_ERROR);
#endif
break;
}
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;

View File

@ -58,16 +58,6 @@ namespace irr
{
namespace video
{
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
IVideoDriver* createDirectX8Driver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
IVideoDriver* createDirectX9Driver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, HWND window);
#endif
#ifdef _IRR_COMPILE_WITH_OPENGL_
IVideoDriver* createOpenGLDriver(const irr::SIrrlichtCreationParameters& params,
io::IFileSystem* io, CIrrDeviceWin32* device);
@ -1533,36 +1523,6 @@ void CIrrDeviceWin32::createDriver()
{
switch(CreationParams.DriverType)
{
case video::EDT_DIRECT3D8:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
VideoDriver = video::createDirectX8Driver(CreationParams, FileSystem, HWnd);
if (!VideoDriver)
{
os::Printer::log("Could not create DIRECT3D8 Driver.", ELL_ERROR);
}
#else
os::Printer::log("DIRECT3D8 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_8_
break;
case video::EDT_DIRECT3D9:
#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
VideoDriver = video::createDirectX9Driver(CreationParams, FileSystem, HWnd);
if (!VideoDriver)
{
os::Printer::log("Could not create DIRECT3D9 Driver.", ELL_ERROR);
}
#else
os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
break;
case video::EDT_OPENGL:
#ifdef _IRR_COMPILE_WITH_OPENGL_

View File

@ -971,11 +971,6 @@ void CIrrDeviceMacOSX::createDriver()
#endif
break;
case video::EDT_DIRECT3D8:
case video::EDT_DIRECT3D9:
os::Printer::log("This driver is not available in OSX. Try OpenGL or Software renderer.", ELL_ERROR);
break;
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;