mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
VBO-related optimizations and improvements (#14395)
This commit is contained in:
parent
d85c842ce9
commit
bb7f57b095
22 changed files with 439 additions and 322 deletions
|
@ -217,13 +217,22 @@ class MainShaderConstantSetter : public IShaderConstantSetter
|
|||
// Texture matrix
|
||||
CachedVertexShaderSetting<float, 16> m_texture{"mTexture"};
|
||||
|
||||
// commonly used way to pass material color to shader
|
||||
video::SColor m_emissive_color;
|
||||
CachedPixelShaderSetting<float, 4> m_emissive_color_setting{"emissiveColor"};
|
||||
|
||||
public:
|
||||
~MainShaderConstantSetter() = default;
|
||||
|
||||
virtual void onSetMaterial(const video::SMaterial& material) override
|
||||
{
|
||||
m_emissive_color = material.EmissiveColor;
|
||||
}
|
||||
|
||||
virtual void onSetConstants(video::IMaterialRendererServices *services) override
|
||||
{
|
||||
video::IVideoDriver *driver = services->getVideoDriver();
|
||||
sanity_check(driver);
|
||||
assert(driver);
|
||||
|
||||
// Set world matrix
|
||||
core::matrix4 world = driver->getTransform(video::ETS_WORLD);
|
||||
|
@ -244,6 +253,9 @@ public:
|
|||
m_world_view.set(worldView, services);
|
||||
m_texture.set(texture, services);
|
||||
}
|
||||
|
||||
video::SColorf emissive_color(m_emissive_color);
|
||||
m_emissive_color_setting.set(emissive_color, services);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -545,11 +557,11 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
return shaderinfo;
|
||||
|
||||
video::IVideoDriver *driver = RenderingEngine::get_video_driver();
|
||||
if (!driver->queryFeature(video::EVDF_ARB_GLSL)) {
|
||||
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
|
||||
if (!driver->queryFeature(video::EVDF_ARB_GLSL) || !gpu) {
|
||||
throw ShaderException(gettext("Shaders are enabled but GLSL is not "
|
||||
"supported by the driver."));
|
||||
}
|
||||
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();
|
||||
|
||||
// Create shaders header
|
||||
bool fully_programmable = driver->getDriverType() == video::EDT_OGLES2 || driver->getDriverType() == video::EDT_OPENGL3;
|
||||
|
@ -610,14 +622,6 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
#define textureFlags texture2
|
||||
)";
|
||||
|
||||
// Since this is the first time we're using the GL bindings be extra careful.
|
||||
// This should be removed before 5.6.0 or similar.
|
||||
if (!GL.GetString) {
|
||||
errorstream << "OpenGL procedures were not loaded correctly, "
|
||||
"please open a bug report with details about your platform/OS." << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
bool use_discard = fully_programmable;
|
||||
// For renderers that should use discard instead of GL_ALPHA_TEST
|
||||
const char *renderer = reinterpret_cast<const char*>(GL.GetString(GL.RENDERER));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue