Add bindless texture support

This commit is contained in:
Magnus Norddahl 2023-09-19 23:58:17 +02:00
commit bb7a33d7b1
11 changed files with 114 additions and 7 deletions

View file

@ -119,10 +119,20 @@ VulkanRenderDevice::VulkanRenderDevice(void *hMonitor, bool fullscreen, std::sha
{
VulkanDeviceBuilder builder;
builder.OptionalRayQuery();
builder.RequireExtension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
builder.Surface(surface);
builder.SelectDevice(vk_device);
SupportedDevices = builder.FindDevices(surface->Instance);
mDevice = builder.Create(surface->Instance);
bool supportsBindless =
mDevice->EnabledFeatures.DescriptorIndexing.descriptorBindingPartiallyBound &&
mDevice->EnabledFeatures.DescriptorIndexing.runtimeDescriptorArray &&
mDevice->EnabledFeatures.DescriptorIndexing.shaderSampledImageArrayNonUniformIndexing;
if (!supportsBindless)
{
I_FatalError("This GPU does not support the minimum requirements of this application");
}
}
VulkanRenderDevice::~VulkanRenderDevice()
@ -605,3 +615,12 @@ void VulkanRenderDevice::SetSceneRenderTarget(bool useSSAO)
renderstate->SetRenderTarget(&GetBuffers()->SceneColor, GetBuffers()->SceneDepthStencil.View.get(), GetBuffers()->GetWidth(), GetBuffers()->GetHeight(), VK_FORMAT_R16G16B16A16_SFLOAT, GetBuffers()->GetSceneSamples());
}
}
int VulkanRenderDevice::GetBindlessTextureIndex(FMaterial* material, int clampmode, int translation)
{
FMaterialState materialState;
materialState.mMaterial = material;
materialState.mClampMode = clampmode;
materialState.mTranslation = translation;
return static_cast<VkMaterial*>(material)->GetBindlessIndex(materialState);
}