Hook up bindless textures for gl_levelmesh

This commit is contained in:
Magnus Norddahl 2023-10-23 19:52:47 +02:00
commit f550f5b05a
12 changed files with 51 additions and 10 deletions

View file

@ -312,7 +312,7 @@ void VkRaytrace::UploadMeshes(bool dynamicOnly)
}
else
{
info.TextureIndex = -1;
info.TextureIndex = 0;
}
submesh->MeshSurfaceUniforms[j].uTextureIndex = info.TextureIndex; // Bit of a hack, but we don't know the texture index before now

View file

@ -141,6 +141,9 @@ void VkDescriptorSetManager::ResetHWTextureSets()
Bindless.Writer = WriteDescriptors();
Bindless.NextIndex = 0;
// Slot zero always needs to be the null texture
AddBindlessTextureIndex(fb->GetTextureManager()->GetNullTextureView(), fb->GetSamplerManager()->Get(CLAMP_XY_NOMIP));
}
VulkanDescriptorSet* VkDescriptorSetManager::GetNullTextureSet()

View file

@ -151,7 +151,9 @@ VulkanPipelineLayout* VkRenderPassManager::GetPipelineLayout(int numLayers, bool
PipelineLayoutBuilder builder;
builder.AddSetLayout(descriptors->GetFixedLayout());
builder.AddSetLayout(levelmesh ? descriptors->GetLevelMeshLayout() : descriptors->GetRSBufferLayout());
if (numLayers != 0)
if (levelmesh)
builder.AddSetLayout(descriptors->GetBindlessLayout());
else if (numLayers != 0)
builder.AddSetLayout(descriptors->GetTextureLayout(numLayers));
builder.AddPushConstantRange(VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(PushConstants));
builder.DebugName("VkRenderPassManager.PipelineLayout");

View file

@ -321,6 +321,7 @@ FString VkShaderManager::GetVersionBlock()
}
versionBlock << "#extension GL_GOOGLE_include_directive : enable\n";
versionBlock << "#extension GL_EXT_nonuniform_qualifier : enable\r\n";
if (fb->GetDevice()->SupportsExtension(VK_KHR_RAY_QUERY_EXTENSION_NAME) && fb->GetDevice()->PhysicalDevice.Features.RayQuery.rayQuery)
{

View file

@ -218,7 +218,7 @@ void VkTextureManager::CreateLightmap(int newLMTextureSize, int newLMTextureCoun
auto cmdbuffer = fb->GetCommands()->GetTransferCommands();
if (newPixelData.Size() >= (size_t)w * h * count * 3)
if (count > 0 && newPixelData.Size() >= (size_t)w * h * count * 3)
{
assert(newPixelData.Size() == (size_t)w * h * count * 3);

View file

@ -163,6 +163,7 @@ VulkanRenderDevice::~VulkanRenderDevice()
if (mDescriptorSetManager)
mDescriptorSetManager->Deinit();
mCommands->DeleteFrameObjects();
if (mTextureManager)
mTextureManager->Deinit();
if (mBufferManager)
@ -715,7 +716,7 @@ void VulkanRenderDevice::DrawLevelMesh(const HWViewpointUniforms& viewpoint)
uint32_t offsets[] = { viewpointOffset, matrixOffset, lightsOffset };
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptors->GetFixedSet());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 1, descriptors->GetLevelMeshSet(), 3, offsets);
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 2, descriptors->GetNullTextureSet());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 2, descriptors->GetBindlessSet());
PushConstants pushConstants = {};
pushConstants.uDataIndex = 0;