mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-26 16:12:02 +00:00
Removes RenderPath
We can render the game only with shaders so we don't need to support fixed function pipeline as a separate render path. We only need to know when to warn a user. Fixes #6244
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -96,7 +96,7 @@ bool CObjectEntry::BuildVariation(const std::vector<const std::set<CStr>*>& comp
|
||||
? Renderer::Backend::Sampler::AddressMode::CLAMP_TO_BORDER
|
||||
: Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE);
|
||||
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps);
|
||||
// TODO: Should check which renderpath is selected and only preload the necessary textures.
|
||||
// TODO: Should check which material is selected and only preload the necessary textures.
|
||||
texture->Prefetch();
|
||||
material.AddSampler(CMaterial::TextureSampler(samp.m_SamplerName, texture));
|
||||
}
|
||||
@@ -151,7 +151,7 @@ bool CObjectEntry::BuildVariation(const std::vector<const std::set<CStr>*>& comp
|
||||
CTexturePtr texture = g_Renderer.GetTextureManager().CreateTexture(textureProps);
|
||||
// if we've loaded this model we're probably going to render it soon, so prefetch its texture.
|
||||
// All textures are prefetched even in the fixed pipeline, including the normal maps etc.
|
||||
// TODO: Should check which renderpath is selected and only preload the necessary textures.
|
||||
// TODO: Should check which material is selected and only preload the necessary textures.
|
||||
texture->Prefetch();
|
||||
material.AddSampler(CMaterial::TextureSampler(samp.m_SamplerName, texture));
|
||||
}
|
||||
|
||||
@@ -617,19 +617,6 @@ bool Init(const CmdLineArgs& args, int flags)
|
||||
|
||||
g_GUI = new CGUIManager{scriptContext, scriptInterface};
|
||||
|
||||
|
||||
if (RenderPathEnum::FromString(g_ConfigDB.Get("renderpath", "default"s)) == FIXED)
|
||||
{
|
||||
// It doesn't make sense to continue working here, because we're not
|
||||
// able to display anything.
|
||||
DEBUG_DISPLAY_FATAL_ERROR(
|
||||
L"Your graphics card doesn't appear to be fully compatible with OpenGL shaders."
|
||||
L" The game does not support pre-shader graphics cards."
|
||||
L" You are advised to try installing newer drivers and/or upgrade your graphics card."
|
||||
L" For more information, please see http://www.wildfiregames.com/forum/index.php?showtopic=16734"
|
||||
);
|
||||
}
|
||||
|
||||
g_RenderingOptions.ReadConfigAndSetupHooks();
|
||||
|
||||
// create renderer
|
||||
|
||||
@@ -478,5 +478,18 @@ void RunHardwareDetection(bool writeSystemInfoBeforeDetection, Renderer::Backend
|
||||
|
||||
// Run the detection script:
|
||||
JS::RootedValue global(rq.cx, rq.globalValue());
|
||||
Script::Function::CallVoid(rq, global, "RunHardwareDetection", settings);
|
||||
bool hardwareSupported{true};
|
||||
Script::Function::Call(rq, global, "RunHardwareDetection", hardwareSupported, settings);
|
||||
|
||||
if (!hardwareSupported)
|
||||
{
|
||||
// It doesn't make sense to continue working here, because we're not
|
||||
// able to display anything.
|
||||
DEBUG_DISPLAY_FATAL_ERROR(
|
||||
L"Your graphics card doesn't appear to be fully compatible with OpenGL shaders."
|
||||
L" The game does not support pre-shader graphics cards."
|
||||
L" You are advised to try installing newer drivers and/or upgrade your graphics card."
|
||||
L" For more information, please see http://www.wildfiregames.com/forum/index.php?showtopic=16734"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef std::shared_ptr<ModelRenderer> ModelRendererPtr;
|
||||
* The main purpose of this class over CRenderData is to track which
|
||||
* ModelRenderer the render data belongs to (via the key that is passed
|
||||
* to the constructor). When a model changes the renderer it uses
|
||||
* (e.g. via run-time modification of the renderpath configuration),
|
||||
* (e.g. via run-time modification of the gpu skinning configuration),
|
||||
* the old ModelRenderer's render data is supposed to be replaced by
|
||||
* the new data.
|
||||
*/
|
||||
|
||||
@@ -486,9 +486,6 @@ bool CRenderer::Open(int width, int height)
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
|
||||
// Validate the currently selected render path
|
||||
SetRenderPath(g_RenderingOptions.GetRenderPath());
|
||||
|
||||
m->debugRenderer.Initialize();
|
||||
|
||||
if (m->postprocManager.IsEnabled())
|
||||
@@ -509,24 +506,6 @@ void CRenderer::Resize(int width, int height)
|
||||
m->sceneRenderer.Resize(width, height);
|
||||
}
|
||||
|
||||
void CRenderer::SetRenderPath(RenderPath rp)
|
||||
{
|
||||
if (!m->IsOpen)
|
||||
{
|
||||
// Delay until Open() is called.
|
||||
return;
|
||||
}
|
||||
|
||||
// Renderer has been opened, so validate the selected renderpath
|
||||
if (rp == RenderPath::DEFAULT)
|
||||
rp = RenderPath::SHADER;
|
||||
|
||||
// TODO: remove this once capabilities have been properly extracted and the above checks have been moved elsewhere.
|
||||
g_RenderingOptions.m_RenderPath = rp;
|
||||
|
||||
MakeShadersDirty();
|
||||
}
|
||||
|
||||
bool CRenderer::ShouldRender() const
|
||||
{
|
||||
return !g_app_minimized && (g_app_has_focus || !g_VideoMode.IsInFullscreen());
|
||||
|
||||
@@ -169,11 +169,6 @@ protected:
|
||||
void RenderScreenShot(const bool needsPresent);
|
||||
void RenderBigScreenShot(const bool needsPresent);
|
||||
|
||||
// SetRenderPath: Select the preferred render path.
|
||||
// This may only be called before Open(), because the layout of vertex arrays and other
|
||||
// data may depend on the chosen render path.
|
||||
void SetRenderPath(RenderPath rp);
|
||||
|
||||
void ReloadShaders();
|
||||
|
||||
// Private data that is not needed by inline functions.
|
||||
|
||||
@@ -60,33 +60,6 @@ private:
|
||||
std::vector<CConfigDBHook> hooks;
|
||||
};
|
||||
|
||||
RenderPath RenderPathEnum::FromString(const CStr8& name)
|
||||
{
|
||||
if (name == "default")
|
||||
return DEFAULT;
|
||||
if (name == "fixed")
|
||||
return FIXED;
|
||||
if (name == "shader")
|
||||
return SHADER;
|
||||
|
||||
LOGWARNING("Unknown render path %s", name.c_str());
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
CStr8 RenderPathEnum::ToString(RenderPath path)
|
||||
{
|
||||
switch (path)
|
||||
{
|
||||
case RenderPath::DEFAULT:
|
||||
return "default";
|
||||
case RenderPath::FIXED:
|
||||
return "fixed";
|
||||
case RenderPath::SHADER:
|
||||
return "shader";
|
||||
}
|
||||
return "default"; // Silence warning about reaching end of non-void function.
|
||||
}
|
||||
|
||||
RenderDebugMode RenderDebugModeEnum::FromString(const CStr8& name)
|
||||
{
|
||||
if (name == str_RENDER_DEBUG_MODE_NONE.c_str())
|
||||
@@ -120,7 +93,6 @@ CStrIntern RenderDebugModeEnum::ToString(RenderDebugMode mode)
|
||||
|
||||
CRenderingOptions::CRenderingOptions() : m_ConfigHooks(new ConfigHooks())
|
||||
{
|
||||
m_RenderPath = RenderPath::DEFAULT;
|
||||
m_Shadows = false;
|
||||
m_WaterEffects = false;
|
||||
m_WaterFancyEffects = false;
|
||||
@@ -148,10 +120,6 @@ CRenderingOptions::~CRenderingOptions()
|
||||
|
||||
void CRenderingOptions::ReadConfigAndSetupHooks()
|
||||
{
|
||||
m_ConfigHooks->Setup("renderpath", [this]() {
|
||||
SetRenderPath(RenderPathEnum::FromString(g_ConfigDB.Get("renderpath", std::string{})));
|
||||
});
|
||||
|
||||
m_ConfigHooks->Setup("shadowquality", []() {
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.GetSceneRenderer().GetShadowMap().RecreateTexture();
|
||||
@@ -301,13 +269,6 @@ void CRenderingOptions::SetFog(bool value)
|
||||
g_Renderer.MakeShadersDirty();
|
||||
}
|
||||
|
||||
void CRenderingOptions::SetRenderPath(RenderPath value)
|
||||
{
|
||||
m_RenderPath = value;
|
||||
if (CRenderer::IsInitialised())
|
||||
g_Renderer.SetRenderPath(m_RenderPath);
|
||||
}
|
||||
|
||||
void CRenderingOptions::SetRenderDebugMode(RenderDebugMode value)
|
||||
{
|
||||
m_RenderDebugMode = value;
|
||||
|
||||
@@ -33,25 +33,6 @@
|
||||
|
||||
class CStrIntern;
|
||||
|
||||
enum RenderPath
|
||||
{
|
||||
// If no rendering path is configured explicitly, the renderer
|
||||
// will choose the path when Open() is called.
|
||||
DEFAULT,
|
||||
|
||||
// Classic fixed function.
|
||||
FIXED,
|
||||
|
||||
// Use new GLSL system
|
||||
SHADER
|
||||
};
|
||||
|
||||
struct RenderPathEnum
|
||||
{
|
||||
static RenderPath FromString(const CStr8& name);
|
||||
static CStr8 ToString(RenderPath);
|
||||
};
|
||||
|
||||
enum class RenderDebugMode
|
||||
{
|
||||
NONE,
|
||||
@@ -101,8 +82,6 @@ OPTION_CUSTOM_SETTER(NAME, TYPE); OPTION_GETTER(NAME, TYPE); OPTION_DEF(NAME, TY
|
||||
OPTION_WITH_SIDE_EFFECT(ShadowPCF, bool);
|
||||
OPTION_WITH_SIDE_EFFECT(Fog, bool);
|
||||
|
||||
OPTION_WITH_SIDE_EFFECT(RenderPath, RenderPath);
|
||||
|
||||
OPTION_WITH_SIDE_EFFECT(RenderDebugMode, RenderDebugMode);
|
||||
|
||||
OPTION(WaterEffects, bool);
|
||||
|
||||
@@ -241,7 +241,6 @@ void CSceneRenderer::ReloadShaders([[maybe_unused]] Renderer::Backend::IDevice*
|
||||
|
||||
m->Model.ModShader = LitRenderModifierPtr(new ShaderRenderModifier());
|
||||
|
||||
ENSURE(g_RenderingOptions.GetRenderPath() != RenderPath::FIXED);
|
||||
m->Model.VertexRendererShader = ModelVertexRendererPtr(new CPUSkinnedModelVertexRenderer());
|
||||
m->Model.VertexInstancingShader = ModelVertexRendererPtr(new InstancingModelRenderer());
|
||||
|
||||
|
||||
@@ -47,11 +47,6 @@ IMPLEMENT_BOOLEAN_SCRIPT_SETTING(DisplayShadowsFrustum);
|
||||
|
||||
#undef IMPLEMENT_BOOLEAN_SCRIPT_SETTING
|
||||
|
||||
std::string GetRenderPath()
|
||||
{
|
||||
return RenderPathEnum::ToString(g_RenderingOptions.GetRenderPath());
|
||||
}
|
||||
|
||||
std::string GetRenderDebugMode()
|
||||
{
|
||||
return RenderDebugModeEnum::ToString(g_RenderingOptions.GetRenderDebugMode()).c_str();
|
||||
@@ -83,7 +78,6 @@ Script::Function::Register<&Set##NAME##Enabled>(rq, "Renderer_Set" #NAME "Enable
|
||||
|
||||
void RegisterScriptFunctions(const Script::Request& rq)
|
||||
{
|
||||
Script::Function::Register<&GetRenderPath>(rq, "Renderer_GetRenderPath");
|
||||
Script::Function::Register<&TextureExists>(rq, "TextureExists");
|
||||
Script::Function::Register<&GetRenderDebugMode>(rq, "Renderer_GetRenderDebugMode");
|
||||
Script::Function::Register<&SetRenderDebugMode>(rq, "Renderer_SetRenderDebugMode");
|
||||
|
||||
Reference in New Issue
Block a user