Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions Components/Terrain/src/OgreTerrainMaterialGeneratorA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,24 +253,36 @@ namespace Ogre
}
// clear everything
mat->removeAllTechniques();

// Automatically disable normal & parallax mapping if card cannot handle it
// We do this rather than having a specific technique for it since it's simpler
auto rsc = Root::getSingletonPtr()->getRenderSystem()->getCapabilities();
if (getRequiredLayers(terrain, mPSSM) > rsc->getNumTextureUnits())
{
setLayerNormalMappingEnabled(false);
setLayerParallaxMappingEnabled(false);
LogManager::getSingleton().logWarning(
"TerrainMaterialGeneratorA: Normal mapping disabled due to lack of texture units");
}


Pass* pass;
pass = mat->createTechnique()->createPass();
pass->getUserObjectBindings().setUserAny("Terrain", terrain);
pass->setSpecular(ColourValue::White);
pass->setShininess(32); // user param

// Automatically disable normal & parallax mapping if card cannot handle it
// We do this rather than having a specific technique for it since it's simpler
auto rsc = Root::getSingletonPtr()->getRenderSystem()->getCapabilities();
const uint8 requiredLayers = getRequiredLayers(terrain, mPSSM);

if( requiredLayers > rsc->getNumTextureUnits() )
{
if( requiredLayers <= rsc->getNumTextureUnitsWide() )
{
// fits in the wider profile — no need to disable features
pass->setDescriptorProfileHint( DescriptorProfileHint::AllUnits );
}
else
{
// still doesn't fit even with the widest available profile — fall back as before
setLayerNormalMappingEnabled(false);
setLayerParallaxMappingEnabled(false);
LogManager::getSingleton().logWarning(
"TerrainMaterialGeneratorA: Normal mapping disabled due to lack of texture units");
}
}

Comment on lines +264 to +285

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply set the profile, more is not necessary.

if(mLayerSpecularMappingEnabled)
{
// we use this to inject our specular map
Expand Down
16 changes: 16 additions & 0 deletions OgreMain/include/OgrePass.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert - do DescriptorProfileHint on the GpuProgram, not here in pass.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ namespace Ogre {
IS_UNKNOWN
};

enum class DescriptorProfileHint
{
Default, AllUnits, Compute
};

/** Class defining a single pass of a Technique (of a Material): a single rendering call.

If a pass does not explicitly use a vertex or fragment shader, %Ogre will calculate
Expand Down Expand Up @@ -238,6 +243,8 @@ namespace Ogre {
PolygonMode mPolygonMode;
/// Illumination stage?
IlluminationStage mIlluminationStage;
/// Descriptor set profile hint
DescriptorProfileHint mDescriptorProfileHint;

Light::LightTypes mOnlyLightType;
FogMode mFogMode;
Expand Down Expand Up @@ -1474,6 +1481,15 @@ namespace Ogre {
void setIlluminationStage(IlluminationStage is) { mIlluminationStage = is; }
/// Get the manually assigned illumination stage, if any
IlluminationStage getIlluminationStage() const { return mIlluminationStage; }

/// Manually set the descriptor set profile hint for Vulkan
void setDescriptorProfileHint(DescriptorProfileHint hint)
{
mDescriptorProfileHint = hint;
}
/// Get the manually assigned descriptor set profile hint
DescriptorProfileHint getDescriptorProfileHint() const { return mDescriptorProfileHint; }

/** There are some default hash functions used to order passes so that
render state changes are minimised, this enumerates them.
*/
Expand Down
8 changes: 8 additions & 0 deletions OgreMain/include/OgreRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,14 @@ namespace Ogre
/** Sets how to rasterise triangles, as points, wireframe or solid polys. */
virtual void _setPolygonMode(PolygonMode level) = 0;

/** Sets profile hints for layout */
virtual void _setPassHints( const Pass* pass ) {}

virtual ushort _getCurrentPassNumTextureUnits() const
{
return getCapabilities()->getNumTextureUnits();
}

/** This method allows you to set all the stencil buffer parameters in one call.

Unlike other render states, stencilling is left for the application to turn
Expand Down
60 changes: 40 additions & 20 deletions OgreMain/include/OgreRenderSystemCapabilities.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert all

Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ namespace Ogre
typedef std::set<String> ShaderProfiles;
private:
/// This is used to build a database of RSC's
/// if a RSC with same name, but newer version is introduced, the older one
/// if a RSC with same name, but newer version is introduced, the older one
/// will be removed
DriverVersion mDriverVersion;
/// GPU Vendor
Expand All @@ -277,6 +277,8 @@ namespace Ogre

/// The number of texture units available
ushort mNumTextureUnits;
/// The number of texture units available under an alternate profile, with fallback to the regular number
ushort mNumTextureUnitsWide;
/// The stencil buffer bit depth
ushort mStencilBufferBitDepth;
/// Stores the capabilities flags.
Expand Down Expand Up @@ -308,7 +310,7 @@ namespace Ogre

/// The number of vertex attributes available
ushort mNumVertexAttributes;
public:
public:
RenderSystemCapabilities ();

/** Set the driver version. */
Expand Down Expand Up @@ -355,24 +357,31 @@ namespace Ogre
{
if (mDriverVersion.major < v.major)
return true;
else if (mDriverVersion.major == v.major &&
mDriverVersion.minor < v.minor)
else if (mDriverVersion.major == v.major &&
mDriverVersion.minor < v.minor)
return true;
else if (mDriverVersion.major == v.major &&
mDriverVersion.minor == v.minor &&
mDriverVersion.release < v.release)
else if (mDriverVersion.major == v.major &&
mDriverVersion.minor == v.minor &&
mDriverVersion.release < v.release)
return true;
else if (mDriverVersion.major == v.major &&
mDriverVersion.minor == v.minor &&
mDriverVersion.release == v.release &&
mDriverVersion.build < v.build)
else if (mDriverVersion.major == v.major &&
mDriverVersion.minor == v.minor &&
mDriverVersion.release == v.release &&
mDriverVersion.build < v.build)
return true;
return false;
}

void setNumTextureUnits(ushort num)
{
mNumTextureUnits = num;
if (mNumTextureUnitsWide == 0)
mNumTextureUnitsWide = num;
}

void setNumTextureUnitsWide(ushort num)
{
mNumTextureUnitsWide = num;
}

/// @deprecated do not use
Expand Down Expand Up @@ -401,19 +410,30 @@ namespace Ogre
supports.

For use in rendering, this determines how many texture units the
are available for multitexturing (i.e. rendering multiple
textures in a single pass). Where a Material has multiple
texture layers, it will try to use multitexturing where
are available for multitexturing (i.e. rendering multiple
textures in a single pass). Where a Material has multiple
texture layers, it will try to use multitexturing where
available, and where it is not available, will perform multipass
rendering to achieve the same effect. This property only applies
to the fixed-function pipeline, the number available to the
to the fixed-function pipeline, the number available to the
programmable pipeline depends on the shader model in use.
*/
ushort getNumTextureUnits(void) const
{
return mNumTextureUnits;
}

/** Returns the greater than or equal number of texture units an
alternate profile provides.

Presently specific to Vulkan. For use with the AllUnits descriptor
set profile.
*/
ushort getNumTextureUnitsWide(void) const
{
return mNumTextureUnitsWide;
}

/// @deprecated assume 8-bit stencil buffer
ushort getStencilBufferBitDepth(void) const
{
Expand All @@ -438,17 +458,17 @@ namespace Ogre

/** Adds a capability flag
*/
void setCapability(const Capabilities c)
{
void setCapability(const Capabilities c)
{
int index = (CAPS_CATEGORY_MASK & c) >> OGRE_CAPS_BITSHIFT;
// zero out the index from the stored capability
mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
}

/** Remove a capability flag
*/
void unsetCapability(const Capabilities c)
{
void unsetCapability(const Capabilities c)
{
int index = (CAPS_CATEGORY_MASK & c) >> OGRE_CAPS_BITSHIFT;
// zero out the index from the stored capability
mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
Expand Down Expand Up @@ -630,8 +650,8 @@ namespace Ogre

};

inline String to_string(GPUVendor v) { return RenderSystemCapabilities::vendorToString(v); }
inline String to_string(const DriverVersion& v) { return v.toString(); }
inline String to_string(GPUVendor v) { return RenderSystemCapabilities::vendorToString(v); }

/** @} */
/** @} */
Expand Down
1 change: 1 addition & 0 deletions OgreMain/src/OgrePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ namespace Ogre {
mLightScissoring = oth.mLightScissoring;
mLightClipPlanes = oth.mLightClipPlanes;
mIlluminationStage = oth.mIlluminationStage;
mDescriptorProfileHint = oth.mDescriptorProfileHint;
mLightMask = oth.mLightMask;

for(int i = 0; i < GPT_PIPELINE_COUNT; i++)
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreRenderSystem.cpp

@ArthurFriedri-ch ArthurFriedri-ch Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catch this case in Vulkan
Specifically:
In _setTexture, not here.

Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ namespace Ogre {
//-----------------------------------------------------------------------
void RenderSystem::_setTextureUnitSettings(size_t texUnit, TextureUnitState& tl)
{
if(texUnit >= getCapabilities()->getNumTextureUnits())
if(texUnit >= _getCurrentPassNumTextureUnits())
return;

// This method is only ever called to set a texture unit to valid details
Expand Down
1 change: 1 addition & 0 deletions OgreMain/src/OgreRenderSystemCapabilitiesSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace Ogre

file << endl;
file << "\t" << "num_texture_units " << StringConverter::toString(caps->getNumTextureUnits()) << endl;
file << "\t" << "num_texture_units_wide " << StringConverter::toString(caps->getNumTextureUnitsWide()) << endl;
file << "\t" << "num_multi_render_targets " << StringConverter::toString(caps->getNumMultiRenderTargets()) << endl;
file << "\t" << "vertex_program_constant_float_count " << StringConverter::toString(caps->getConstantFloatCount(GPT_VERTEX_PROGRAM)) << endl;
file << "\t" << "fragment_program_constant_float_count " << StringConverter::toString(caps->getConstantFloatCount(GPT_FRAGMENT_PROGRAM)) << endl;
Expand Down
1 change: 1 addition & 0 deletions OgreMain/src/OgreSceneManager.cpp

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ const Pass* SceneManager::_setPass(const Pass* pass, bool shadowDerivation)
size_t startLightIndex = pass->getStartLight();
size_t shadowTexUnitIndex = 0;
size_t shadowTexIndex = mTextureShadowRenderer.getShadowTexIndex(startLightIndex);
mDestRenderSystem->_setPassHints( pass );
for(auto *pTex : pass->getTextureUnitStates())
{
if (!pass->getIteratePerLight() && isShadowTechniqueTextureBased() &&
Expand Down
4 changes: 4 additions & 0 deletions PlugIns/GLSLang/include/OgreGLSLangProgramManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ class GLSLangProgram : public HighLevelGpuProgram
void prepareImpl() override;

std::vector<uint32> mAssembly;
String mDescriptorSetProfile;
public:
void setDescriptorSetProfile(const String& profile) { mDescriptorSetProfile = profile; }
const String& getDescriptorSetProfile() const { return mDescriptorSetProfile; }

GLSLangProgram(ResourceManager* creator, const String& name, ResourceHandle handle, const String& group,
bool isManual, ManualResourceLoader* loader);
~GLSLangProgram();
Expand Down
20 changes: 20 additions & 0 deletions PlugIns/GLSLang/src/OgreGLSLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,31 @@ static EShLanguage getShLanguage(GpuProgramType type)
return EShLangFragment;
}

class CmdDescriptorSetProfile : public ParamCommand
{
public:
String doGet(const void* target) const override
{
return static_cast<const GLSLangProgram*>(target)->getDescriptorSetProfile();
}
void doSet(void* target, const String& val) override
{
static_cast<GLSLangProgram*>(target)->setDescriptorSetProfile(val);
}
};
static CmdDescriptorSetProfile msCmdDescriptorSetProfile;

GLSLangProgram::GLSLangProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader)
: HighLevelGpuProgram(creator, name, handle, group, isManual, loader)
{
if (createParamDictionary("glslangProgram"))
{
setupBaseParamDictionary();
ParamDictionary* dict = getParamDictionary();
dict->addParameter(ParameterDef("descriptor_set_profile", "Descriptor set profile override. Values: Auto, "
"Graphics, Compute, AllUnits", PT_STRING), &msCmdDescriptorSetProfile);

@ArthurFriedri-ch ArthurFriedri-ch Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused, delete comment.


memset(&DefaultTBuiltInResource.limits, 1, sizeof(TLimits));

if(sizeof(TBuiltInResource) == 420) // replace with build_info.h, when it is universally available
Expand Down Expand Up @@ -369,6 +387,8 @@ void GLSLangProgram::createLowLevelImpl()

mAssemblerProgram =
GpuProgramManager::getSingleton().createProgram(mName + "/Delegate", mGroup, mSyntaxCode, mType);
if (!mDescriptorSetProfile.empty())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty check

mAssemblerProgram->setParameter("descriptor_set_profile", mDescriptorSetProfile);
String assemblyStr((char*)mAssembly.data(), mAssembly.size() * sizeof(uint32));
mAssemblerProgram->setSource(assemblyStr);
mAssembly.clear(); // delegate stores the data now
Expand Down
2 changes: 1 addition & 1 deletion RenderSystems/Vulkan/include/OgreVulkanDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Ogre

static VkInstance createInstance( FastArray<const char *> &extensions,
FastArray<const char *> &layers,
PFN_vkDebugReportCallbackEXT debugCallback );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert here, include in another branch.

void* pNext = nullptr);

void createPhysicalDevice( uint32 deviceIdx );

Expand Down
14 changes: 14 additions & 0 deletions RenderSystems/Vulkan/include/OgreVulkanProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ namespace Ogre
class VulkanProgram : public GpuProgram
{
public:
enum DescriptorSetProfileHint
{
DescriptorSetProfileAuto,
DescriptorSetProfileGraphics,
DescriptorSetProfileCompute,
DescriptorSetProfileAllUnits
};

VulkanProgram( ResourceManager *creator, const String &name, ResourceHandle handle,
const String &group, bool isManual, ManualResourceLoader *loader,
VulkanDevice *device );
Expand All @@ -53,6 +61,11 @@ namespace Ogre
VkPipelineShaderStageCreateInfo getPipelineShaderStageCi() const;

uint32 getDrawIdLocation() const { return mDrawIdLocation; }
DescriptorSetProfileHint getDescriptorSetProfileHint() const { return mDescriptorSetProfileHint; }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same naming as GLSLANG

void setDescriptorSetProfileHint( DescriptorSetProfileHint hint )
{
mDescriptorSetProfileHint = hint;
}

private:
void loadFromSource() override;
Expand All @@ -61,6 +74,7 @@ namespace Ogre
VulkanDevice *mDevice;
VkShaderModule mShaderModule;
uint32 mDrawIdLocation;
DescriptorSetProfileHint mDescriptorSetProfileHint;
};

/** Factory class for Vulkan programs. */
Expand Down
2 changes: 2 additions & 0 deletions RenderSystems/Vulkan/include/OgreVulkanRenderPassDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace Ogre
///
/// Thus we generate VkRenderPass and FBOs together
VkRenderPass mRenderPass;
VkRenderPass mRenderPassLoad;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert in this branch


VulkanFrameBufferDescValue();
};
Expand All @@ -80,6 +81,7 @@ namespace Ogre
VulkanTextureGpu* mDepth;
uint8 mNumColourEntries = 0;
uint8 mSlice = 0;
bool mResuming = false;
private:
// 1 per MRT
// 1 per MRT MSAA resolve
Expand Down
Loading
Loading