Index: ps/trunk/binaries/data/config/default.cfg
===================================================================
--- ps/trunk/binaries/data/config/default.cfg
+++ ps/trunk/binaries/data/config/default.cfg
@@ -116,6 +116,7 @@
; Backends for all graphics rendering:
; glarb - GL with legacy assembler-like shaders, might used only for buggy drivers.
; gl - GL with GLSL shaders, should be used by default.
+; dummy - backend that does nothing, allows to check performance without backend drivers.
rendererbackend = "gl"
; Enables additional debug information in renderer backend.
Index: ps/trunk/binaries/data/mods/mod/hwdetect/hwdetect.js
===================================================================
--- ps/trunk/binaries/data/mods/mod/hwdetect/hwdetect.js
+++ ps/trunk/binaries/data/mods/mod/hwdetect/hwdetect.js
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020 Wildfire Games.
+/* Copyright (C) 2022 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -209,10 +209,10 @@
var gfx_mem = settings.gfx_mem;
// Values from glGetString
- var GL_VENDOR = settings.GL_VENDOR;
- var GL_RENDERER = settings.GL_RENDERER;
- var GL_VERSION = settings.GL_VERSION;
- var GL_EXTENSIONS = settings.GL_EXTENSIONS.split(" ");
+ var GL_VENDOR = settings.renderer_backend.GL_VENDOR;
+ var GL_RENDERER = settings.renderer_backend.GL_RENDERER;
+ var GL_VERSION = settings.renderer_backend.GL_VERSION;
+ var GL_EXTENSIONS = settings.renderer_backend.GL_EXTENSIONS.split(" ");
// Enable GLSL on OpenGL 3+, which should be able to properly
// manage GLSL shaders, needed for effects like windy trees
@@ -340,6 +340,10 @@
global.RunHardwareDetection = function(settings)
{
+ // Currently we don't have limitations for other backends than GL and GL ARB.
+ if (settings.renderer_backend.name != 'gl' && settings.renderer_backend.name != 'glarb')
+ return;
+
//print(JSON.stringify(settings, null, 1)+"\n");
var output = RunDetection(settings);
Index: ps/trunk/binaries/data/mods/mod/hwdetect/test.js
===================================================================
--- ps/trunk/binaries/data/mods/mod/hwdetect/test.js
+++ ps/trunk/binaries/data/mods/mod/hwdetect/test.js
@@ -15,9 +15,9 @@
print("
");
print("" + os);
- print(" | " + settings.GL_RENDERER);
+ print(" | " + settings.renderer_backend.GL_RENDERER);
print(" | " + disabled.join(" "));
print(" | " + output.warnings.concat(output.dialog_warnings).join("\n"));
}
Index: ps/trunk/build/premake/premake5.lua
===================================================================
--- ps/trunk/build/premake/premake5.lua
+++ ps/trunk/build/premake/premake5.lua
@@ -786,7 +786,9 @@
"graphics/scripting",
"renderer",
"renderer/backend",
+ "renderer/backend/dummy",
"renderer/backend/gl",
+ "renderer/backend/vulkan",
"renderer/scripting",
"third_party/mikktspace",
"third_party/ogre3d_preprocessor"
Index: ps/trunk/source/graphics/Canvas2D.h
===================================================================
--- ps/trunk/source/graphics/Canvas2D.h
+++ ps/trunk/source/graphics/Canvas2D.h
@@ -20,7 +20,7 @@
#include "graphics/Texture.h"
#include "maths/Vector2D.h"
-#include "renderer/backend/gl/DeviceCommandContext.h"
+#include "renderer/backend/IDeviceCommandContext.h"
#include
#include
@@ -35,7 +35,7 @@
class CCanvas2D
{
public:
- CCanvas2D(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
+ CCanvas2D(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
~CCanvas2D();
CCanvas2D(const CCanvas2D&) = delete;
Index: ps/trunk/source/graphics/Canvas2D.cpp
===================================================================
--- ps/trunk/source/graphics/Canvas2D.cpp
+++ ps/trunk/source/graphics/Canvas2D.cpp
@@ -47,7 +47,7 @@
};
inline void DrawTextureImpl(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CTexturePtr& texture, const PlaneArray2D& vertices, PlaneArray2D uvs,
const CColor& multiply, const CColor& add, const float grayscaleFactor,
const SBindingSlots& bindingSlots)
@@ -85,7 +85,7 @@
class CCanvas2D::Impl
{
public:
- Impl(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+ Impl(Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
: DeviceCommandContext(deviceCommandContext)
{
}
@@ -124,7 +124,7 @@
Tech.reset();
}
- Renderer::Backend::GL::CDeviceCommandContext* DeviceCommandContext;
+ Renderer::Backend::IDeviceCommandContext* DeviceCommandContext = nullptr;
CShaderTechniquePtr Tech;
// We assume that the shader can't be destroyed while it's bound. So these
@@ -133,7 +133,7 @@
};
CCanvas2D::CCanvas2D(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
: m(std::make_unique(deviceCommandContext))
{
Index: ps/trunk/source/graphics/LOSTexture.h
===================================================================
--- ps/trunk/source/graphics/LOSTexture.h
+++ ps/trunk/source/graphics/LOSTexture.h
@@ -20,9 +20,9 @@
#include "graphics/ShaderTechniquePtr.h"
#include "maths/Matrix3D.h"
-#include "renderer/backend/gl/DeviceCommandContext.h"
-#include "renderer/backend/gl/Framebuffer.h"
-#include "renderer/backend/gl/Texture.h"
+#include "renderer/backend/IDeviceCommandContext.h"
+#include "renderer/backend/IFramebuffer.h"
+#include "renderer/backend/ITexture.h"
#include
@@ -53,10 +53,10 @@
* Also potentially switches the current active texture unit, and enables texturing on it.
* The texture is in 8-bit ALPHA format.
*/
- Renderer::Backend::GL::CTexture* GetTexture();
- Renderer::Backend::GL::CTexture* GetTextureSmooth();
+ Renderer::Backend::ITexture* GetTexture();
+ Renderer::Backend::ITexture* GetTextureSmooth();
- void InterpolateLOS(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
+ void InterpolateLOS(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
/**
* Returns a matrix to map (x,y,z) world coordinates onto (u,v) LOS texture
@@ -75,8 +75,8 @@
private:
void DeleteTexture();
bool CreateShader();
- void ConstructTexture(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
- void RecomputeTexture(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
+ void ConstructTexture(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
+ void RecomputeTexture(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
size_t GetBitmapSize(size_t w, size_t h, size_t* pitch);
void GenerateBitmap(const CLosQuerier& los, u8* losData, size_t w, size_t h, size_t pitch);
@@ -87,7 +87,7 @@
bool m_ShaderInitialized = false;
- std::unique_ptr
+ std::unique_ptr
m_Texture, m_SmoothTextures[2];
uint32_t m_WhichTexture = 0;
@@ -95,7 +95,7 @@
// We update textures once a frame, so we change a Framebuffer once a frame.
// That allows us to use two ping-pong FBOs instead of checking completeness
// of Framebuffer each frame.
- std::unique_ptr
+ std::unique_ptr
m_SmoothFramebuffers[2];
CShaderTechniquePtr m_SmoothTech;
Index: ps/trunk/source/graphics/LOSTexture.cpp
===================================================================
--- ps/trunk/source/graphics/LOSTexture.cpp
+++ ps/trunk/source/graphics/LOSTexture.cpp
@@ -26,7 +26,7 @@
#include "ps/CStrInternStatic.h"
#include "ps/Game.h"
#include "ps/Profile.h"
-#include "renderer/backend/gl/Device.h"
+#include "renderer/backend/IDevice.h"
#include "renderer/Renderer.h"
#include "renderer/RenderingOptions.h"
#include "renderer/TimeManager.h"
@@ -106,7 +106,7 @@
m_Dirty = true;
}
-Renderer::Backend::GL::CTexture* CLOSTexture::GetTextureSmooth()
+Renderer::Backend::ITexture* CLOSTexture::GetTextureSmooth()
{
if (CRenderer::IsInitialised() && !g_RenderingOptions.GetSmoothLOS())
return GetTexture();
@@ -114,7 +114,7 @@
return m_SmoothTextures[m_WhichTexture].get();
}
-void CLOSTexture::InterpolateLOS(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+void CLOSTexture::InterpolateLOS(Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
const bool skipSmoothLOS = CRenderer::IsInitialised() && !g_RenderingOptions.GetSmoothLOS();
if (!skipSmoothLOS && !m_ShaderInitialized)
@@ -209,7 +209,7 @@
}
-Renderer::Backend::GL::CTexture* CLOSTexture::GetTexture()
+Renderer::Backend::ITexture* CLOSTexture::GetTexture()
{
ENSURE(!m_Dirty);
return m_Texture.get();
@@ -227,7 +227,7 @@
return m_MinimapTextureMatrix;
}
-void CLOSTexture::ConstructTexture(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+void CLOSTexture::ConstructTexture(Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
CmpPtr cmpRangeManager(m_Simulation, SYSTEM_ENTITY);
if (!cmpRangeManager)
@@ -237,7 +237,7 @@
const size_t textureSize = round_up_to_pow2(round_up((size_t)m_MapSize + g_BlurSize - 1, g_SubTextureAlignment));
- Renderer::Backend::GL::CDevice* backendDevice = deviceCommandContext->GetDevice();
+ Renderer::Backend::IDevice* backendDevice = deviceCommandContext->GetDevice();
const Renderer::Backend::Sampler::Desc defaultSamplerDesc =
Renderer::Backend::Sampler::MakeDefaultSampler(
@@ -311,7 +311,7 @@
}
}
-void CLOSTexture::RecomputeTexture(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+void CLOSTexture::RecomputeTexture(Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
// If the map was resized, delete and regenerate the texture
if (m_Texture)
Index: ps/trunk/source/graphics/MiniMapTexture.h
===================================================================
--- ps/trunk/source/graphics/MiniMapTexture.h
+++ ps/trunk/source/graphics/MiniMapTexture.h
@@ -21,8 +21,8 @@
#include "graphics/Color.h"
#include "graphics/Texture.h"
#include "maths/Vector2D.h"
-#include "renderer/backend/gl/DeviceCommandContext.h"
-#include "renderer/backend/gl/Texture.h"
+#include "renderer/backend/IDeviceCommandContext.h"
+#include "renderer/backend/ITexture.h"
#include "renderer/VertexArray.h"
#include
@@ -46,9 +46,9 @@
/**
* Redraws the texture if it's dirty.
*/
- void Render(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
+ void Render(Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
- Renderer::Backend::GL::CTexture* GetTexture() const { return m_FinalTexture.get(); }
+ Renderer::Backend::ITexture* GetTexture() const { return m_FinalTexture.get(); }
/**
* @return The maximum height for unit passage in water.
@@ -67,14 +67,14 @@
private:
void CreateTextures(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CTerrain* terrain);
void DestroyTextures();
void RebuildTerrainTexture(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CTerrain* terrain);
void RenderFinalTexture(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
CSimulation2& m_Simulation;
@@ -83,10 +83,10 @@
double m_LastFinalTextureUpdate = 0.0;
// minimap texture handles
- std::unique_ptr
+ std::unique_ptr
m_TerrainTexture, m_FinalTexture;
- std::unique_ptr
+ std::unique_ptr
m_FinalTextureFramebuffer;
// texture data
Index: ps/trunk/source/graphics/MiniMapTexture.cpp
===================================================================
--- ps/trunk/source/graphics/MiniMapTexture.cpp
+++ ps/trunk/source/graphics/MiniMapTexture.cpp
@@ -38,7 +38,7 @@
#include "ps/Game.h"
#include "ps/World.h"
#include "ps/XML/Xeromyces.h"
-#include "renderer/backend/gl/Device.h"
+#include "renderer/backend/IDevice.h"
#include "renderer/Renderer.h"
#include "renderer/RenderingOptions.h"
#include "renderer/SceneRenderer.h"
@@ -71,7 +71,7 @@
}
void DrawTexture(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
const float quadUVs[] =
{
@@ -146,7 +146,7 @@
CMiniMapTexture::CMiniMapTexture(CSimulation2& simulation)
: m_Simulation(simulation), m_IndexArray(false),
- m_VertexArray(Renderer::Backend::GL::CBuffer::Type::VERTEX, true)
+ m_VertexArray(Renderer::Backend::IBuffer::Type::VERTEX, true)
{
// Register Relax NG validator.
CXeromyces::AddValidator(g_VFS, "pathfinder", "simulation/data/pathfinder.rng");
@@ -210,7 +210,7 @@
}
}
-void CMiniMapTexture::Render(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+void CMiniMapTexture::Render(Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
const CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
if (!terrain)
@@ -226,7 +226,7 @@
}
void CMiniMapTexture::CreateTextures(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext, const CTerrain* terrain)
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext, const CTerrain* terrain)
{
DestroyTextures();
@@ -238,7 +238,7 @@
Renderer::Backend::Sampler::Filter::LINEAR,
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE);
- Renderer::Backend::GL::CDevice* backendDevice = deviceCommandContext->GetDevice();
+ Renderer::Backend::IDevice* backendDevice = deviceCommandContext->GetDevice();
// Create terrain texture
m_TerrainTexture = backendDevice->CreateTexture2D("MiniMapTerrainTexture",
@@ -272,7 +272,7 @@
}
void CMiniMapTexture::RebuildTerrainTexture(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
const CTerrain* terrain)
{
const u32 x = 0;
@@ -338,7 +338,7 @@
}
void CMiniMapTexture::RenderFinalTexture(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
// only update 2x / second
// (note: since units only move a few pixels per second on the minimap,
@@ -579,7 +579,7 @@
if (m_EntitiesDrawn > 0)
{
- Renderer::Backend::GL::CDeviceCommandContext::Rect scissorRect;
+ Renderer::Backend::IDeviceCommandContext::Rect scissorRect;
scissorRect.x = scissorRect.y = 1;
scissorRect.width = scissorRect.height = FINAL_TEXTURE_SIZE - 2;
deviceCommandContext->SetScissors(1, &scissorRect);
Index: ps/trunk/source/graphics/ParticleEmitter.h
===================================================================
--- ps/trunk/source/graphics/ParticleEmitter.h
+++ ps/trunk/source/graphics/ParticleEmitter.h
@@ -21,7 +21,7 @@
#include "graphics/ModelAbstract.h"
#include "graphics/ParticleEmitterType.h"
#include "maths/Quaternion.h"
-#include "renderer/backend/gl/DeviceCommandContext.h"
+#include "renderer/backend/IDeviceCommandContext.h"
#include "renderer/backend/IShaderProgram.h"
#include "renderer/VertexArray.h"
@@ -123,14 +123,14 @@
* Bind rendering state (textures and blend modes).
*/
void Bind(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
Renderer::Backend::IShaderProgram* shader);
/**
* Draw the vertex array.
*/
void RenderArray(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext);
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext);
/**
* Stop this emitter emitting new particles, and pass responsibility for rendering
Index: ps/trunk/source/graphics/ParticleEmitter.cpp
===================================================================
--- ps/trunk/source/graphics/ParticleEmitter.cpp
+++ ps/trunk/source/graphics/ParticleEmitter.cpp
@@ -33,7 +33,7 @@
m_Type(type), m_Active(true), m_NextParticleIdx(0), m_EmissionRoundingError(0.f),
m_LastUpdateTime(type->m_Manager.GetCurrentTime()),
m_IndexArray(false),
- m_VertexArray(Renderer::Backend::GL::CBuffer::Type::VERTEX, true),
+ m_VertexArray(Renderer::Backend::IBuffer::Type::VERTEX, true),
m_LastFrameNumber(-1)
{
// If we should start with particles fully emitted, pretend that we
@@ -175,7 +175,7 @@
}
void CParticleEmitter::Bind(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
Renderer::Backend::IShaderProgram* shader)
{
m_Type->m_Texture->UploadBackendTextureIfNeeded(deviceCommandContext);
@@ -201,7 +201,7 @@
}
void CParticleEmitter::RenderArray(
- Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext)
+ Renderer::Backend::IDeviceCommandContext* deviceCommandContext)
{
if (m_Particles.empty())
return;
Index: ps/trunk/source/graphics/ShaderDefines.h
===================================================================
--- ps/trunk/source/graphics/ShaderDefines.h
+++ ps/trunk/source/graphics/ShaderDefines.h
@@ -20,7 +20,7 @@
#include "ps/CStr.h"
#include "ps/CStrIntern.h"
-#include "renderer/backend/gl/DeviceCommandContext.h"
+#include "renderer/backend/IDeviceCommandContext.h"
#include "renderer/backend/IShaderProgram.h"
#include |