Skip to content

Vulkan: Descriptor Set Layouts - #3679

Draft
ArthurFriedri-ch wants to merge 18 commits into
OGRECave:masterfrom
ArthurFriedri-ch:vulkan_descriptor_sets
Draft

Vulkan: Descriptor Set Layouts#3679
ArthurFriedri-ch wants to merge 18 commits into
OGRECave:masterfrom
ArthurFriedri-ch:vulkan_descriptor_sets

Conversation

@ArthurFriedri-ch

Copy link
Copy Markdown
Contributor

This pull request implements Vulkan's descriptor set layouts.

The primary use case is for enabling compute shaders under Vulkan.
A further layout provides double the texture units for multitexturing use cases; the Terrain sample has been updated to take advantage of it.

@ArthurFriedri-ch ArthurFriedri-ch changed the title Vulkan: Descriptor Sets Layouts Vulkan: Descriptor Set Layouts Jul 20, 2026
Comment on lines +264 to +285
// 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");
}
}

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.

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.

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

@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.

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

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.


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


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.

///
/// 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

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

"Descriptor set profile override. Values: Auto, "
"Graphics, Compute, AllUnits",
PT_STRING ),
&msDescriptorSetProfileCmd );

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.

delete comment

allUnits.writes[i + 2].dstBinding = 2 + i;
allUnits.writes[i + 2].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
allUnits.writes[i + 2].pImageInfo = mImageInfos.data() + i;
allUnits.writes[i + 2].descriptorCount = 1;

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.

Split into sub functions for initialisation

}

mActiveDevice->mGraphicsQueue.getComputeEncoder();
VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer;

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 debug content; assert invariants instead of silently doing nothing

Comment on lines +1424 to +1438
if(!prg)
{
LogManager::getSingleton().logError("[Vulkan] bindGpuProgram got null program");
return;
}

auto shader = dynamic_cast<VulkanProgram*>(prg);
if(!shader)
{
LogManager::getSingleton().logError(
"[Vulkan] bindGpuProgram got non-Vulkan program: name='" + prg->getName() +
"' syntax='" + prg->getSyntaxCode() + "'");
return;
}

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.

compute program automatically switches to compute profile;
else fragment program sets the profile

Comment on lines -1105 to +1461
int dstUBO = gptype % GPT_PIPELINE_COUNT;
// Graphics: vertex → slot 0, fragment → slot 1
// Compute: always → slot 1 (matches Compute descriptor layout)
int dstUBO;
if( gptype == GPT_COMPUTE_PROGRAM )
dstUBO = 1;
else
dstUBO = gptype % GPT_PIPELINE_COUNT;

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

Comment on lines +1583 to +1588
ushort VulkanRenderSystem::_getCurrentPassNumTextureUnits() const
{
return ( mBoundGraphicsProfile == AllUnits )
? mRealCapabilities->getNumTextureUnitsWide()
: mRealCapabilities->getNumTextureUnits();
}

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

Comment on lines +649 to +652
{
(void)access;
(void)textureArrayIndex;
(void)format;

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.

not necessary, remove

(void)textureArrayIndex;
(void)format;

auto *rs = dynamic_cast<VulkanRenderSystem *>( Root::getSingleton().getRenderSystem() );

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.

no dynamic_cast necessary, no if

@@ -2,8 +2,9 @@

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.

introduce OgreUnifiedCompute.h

//////////
// GLSL //
//////////
compute_program Compute/CS_GLSL glsl

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.

glsl + glslang

source ComputeCS.glsl
syntax glsl430
has_sampler_binding true
descriptor_set_profile Compute

@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.

revert except syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant