Vulkan: Descriptor Set Layouts - #3679
Conversation
# Conflicts: # RenderSystems/Vulkan/src/OgreVulkanDevice.cpp # RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp
| // 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"); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Simply set the profile, more is not necessary.
There was a problem hiding this comment.
Revert - do DescriptorProfileHint on the GpuProgram, not here in pass.
There was a problem hiding this comment.
Revert all
There was a problem hiding this comment.
Catch this case in Vulkan
Specifically:
In _setTexture, not here.
| setupBaseParamDictionary(); | ||
| ParamDictionary* dict = getParamDictionary(); | ||
| dict->addParameter(ParameterDef("descriptor_set_profile", "Descriptor set profile override. Values: Auto, " | ||
| "Graphics, Compute, AllUnits", PT_STRING), &msCmdDescriptorSetProfile); |
There was a problem hiding this comment.
This is unused, delete comment.
|
|
||
| mAssemblerProgram = | ||
| GpuProgramManager::getSingleton().createProgram(mName + "/Delegate", mGroup, mSyntaxCode, mType); | ||
| if (!mDescriptorSetProfile.empty()) |
There was a problem hiding this comment.
remove empty check
|
|
||
| static VkInstance createInstance( FastArray<const char *> &extensions, | ||
| FastArray<const char *> &layers, | ||
| PFN_vkDebugReportCallbackEXT debugCallback ); |
There was a problem hiding this comment.
Revert here, include in another branch.
| /// | ||
| /// Thus we generate VkRenderPass and FBOs together | ||
| VkRenderPass mRenderPass; | ||
| VkRenderPass mRenderPassLoad; |
There was a problem hiding this comment.
Revert in this branch
| VkPipelineShaderStageCreateInfo getPipelineShaderStageCi() const; | ||
|
|
||
| uint32 getDrawIdLocation() const { return mDrawIdLocation; } | ||
| DescriptorSetProfileHint getDescriptorSetProfileHint() const { return mDescriptorSetProfileHint; } |
There was a problem hiding this comment.
same naming as GLSLANG
| "Descriptor set profile override. Values: Auto, " | ||
| "Graphics, Compute, AllUnits", | ||
| PT_STRING ), | ||
| &msDescriptorSetProfileCmd ); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Split into sub functions for initialisation
| } | ||
|
|
||
| mActiveDevice->mGraphicsQueue.getComputeEncoder(); | ||
| VkCommandBuffer cmdBuffer = mActiveDevice->mGraphicsQueue.mCurrentCmdBuffer; |
There was a problem hiding this comment.
remove debug content; assert invariants instead of silently doing nothing
| 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; | ||
| } | ||
|
|
There was a problem hiding this comment.
compute program automatically switches to compute profile;
else fragment program sets the profile
| 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; |
| ushort VulkanRenderSystem::_getCurrentPassNumTextureUnits() const | ||
| { | ||
| return ( mBoundGraphicsProfile == AllUnits ) | ||
| ? mRealCapabilities->getNumTextureUnitsWide() | ||
| : mRealCapabilities->getNumTextureUnits(); | ||
| } |
| { | ||
| (void)access; | ||
| (void)textureArrayIndex; | ||
| (void)format; |
There was a problem hiding this comment.
not necessary, remove
| (void)textureArrayIndex; | ||
| (void)format; | ||
|
|
||
| auto *rs = dynamic_cast<VulkanRenderSystem *>( Root::getSingleton().getRenderSystem() ); |
There was a problem hiding this comment.
no dynamic_cast necessary, no if
| @@ -2,8 +2,9 @@ | |||
|
|
|||
There was a problem hiding this comment.
introduce OgreUnifiedCompute.h
| ////////// | ||
| // GLSL // | ||
| ////////// | ||
| compute_program Compute/CS_GLSL glsl |
There was a problem hiding this comment.
glsl + glslang
| source ComputeCS.glsl | ||
| syntax glsl430 | ||
| has_sampler_binding true | ||
| descriptor_set_profile Compute |
There was a problem hiding this comment.
revert except syntax
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.