Skip to content

Commit

Permalink
[vulkan] removed samplers binding and reflection since all samplers a…
Browse files Browse the repository at this point in the history
…re bindless
  • Loading branch information
PanosK92 committed Dec 26, 2024
1 parent bb213ca commit 6e7a187
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 62 deletions.
5 changes: 0 additions & 5 deletions runtime/RHI/D3D12/D3D12_CommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,6 @@ namespace Spartan
SP_ASSERT_MSG(false, "Function is not implemented");
}

void RHI_CommandList::SetSampler(const uint32_t slot, RHI_Sampler* sampler) const
{
SP_ASSERT_MSG(false, "Function is not implemented");
}

void RHI_CommandList::SetTexture(const uint32_t slot, RHI_Texture* texture, const uint32_t mip_index /*= rhi_all_mips*/, uint32_t mip_range /*= 0*/, const bool uav /*= false*/)
{
SP_ASSERT_MSG(false, "Function is not implemented");
Expand Down
4 changes: 0 additions & 4 deletions runtime/RHI/RHI_CommandList.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ namespace Spartan
template<typename T>
void PushConstants(const T& data) { PushConstants(0, sizeof(T), &data); }

// sampler
void SetSampler(const uint32_t slot, RHI_Sampler* sampler) const;
void SetSampler(const uint32_t slot, const std::shared_ptr<RHI_Sampler>& sampler) const { SetSampler(slot, sampler.get()); }

// texture
void SetTexture(const uint32_t slot, RHI_Texture* texture, const uint32_t mip_index = rhi_all_mips, uint32_t mip_range = 0, const bool uav = false);
void SetTexture(const Renderer_BindingsUav slot, RHI_Texture* texture, const uint32_t mip_index = rhi_all_mips, uint32_t mip_range = 0) { SetTexture(static_cast<uint32_t>(slot), texture, mip_index, mip_range, true); }
Expand Down
1 change: 0 additions & 1 deletion runtime/RHI/RHI_Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ namespace Spartan

enum class RHI_Descriptor_Type
{
Sampler,
Texture,
TextureStorage,
PushConstantBuffer,
Expand Down
13 changes: 0 additions & 13 deletions runtime/RHI/RHI_DescriptorSetLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,6 @@ namespace Spartan
}
}

void RHI_DescriptorSetLayout::SetSampler(const uint32_t slot, RHI_Sampler* sampler)
{
for (RHI_Descriptor& descriptor : m_descriptors)
{
if (descriptor.slot == slot + rhi_shader_register_shift_s)
{
descriptor.data = static_cast<void*>(sampler);

return;
}
}
}

void RHI_DescriptorSetLayout::SetTexture(const uint32_t slot, RHI_Texture* texture, const uint32_t mip_index, const uint32_t mip_range)
{
bool mip_specified = mip_index != rhi_all_mips;
Expand Down
1 change: 0 additions & 1 deletion runtime/RHI/RHI_DescriptorSetLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ namespace Spartan
// set
void SetConstantBuffer(const uint32_t slot, RHI_Buffer* constant_buffer);
void SetBuffer(const uint32_t slot, RHI_Buffer* buffer);
void SetSampler(const uint32_t slot, RHI_Sampler* sampler);
void SetTexture(const uint32_t slot, RHI_Texture* texture, const uint32_t mip_index, const uint32_t mip_range);

// dynamic offsets
Expand Down
14 changes: 0 additions & 14 deletions runtime/RHI/Vulkan/Vulkan_CommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,20 +1293,6 @@ namespace Spartan
descriptor_sets::bind_dynamic = true;
}

void RHI_CommandList::SetSampler(const uint32_t slot, RHI_Sampler* sampler) const
{
SP_ASSERT(m_state == RHI_CommandListState::Recording);

if (!m_descriptor_layout_current)
{
SP_LOG_WARNING("Descriptor layout not set, try setting sampler \"%s\" within a render pass", sampler->GetObjectName().c_str());
return;
}

// Set (will only happen if it's not already set)
m_descriptor_layout_current->SetSampler(slot, sampler);
}

void RHI_CommandList::SetTexture(const uint32_t slot, RHI_Texture* texture, const uint32_t mip_index /*= all_mips*/, uint32_t mip_range /*= 0*/, const bool uav /*= false*/)
{
SP_ASSERT(m_state == RHI_CommandListState::Recording);
Expand Down
12 changes: 1 addition & 11 deletions runtime/RHI/Vulkan/Vulkan_DescriptorSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,7 @@ namespace Spartan
uint32_t descriptor_index_start = 0;
uint32_t descriptor_count = 1;

if (descriptor.type == RHI_Descriptor_Type::Sampler)
{
image_index++;

info_images[image_index].sampler = static_cast<VkSampler>(static_cast<RHI_Sampler*>(descriptor.data)->GetRhiResource());
info_images[image_index].imageView = nullptr;
info_images[image_index].imageLayout = VK_IMAGE_LAYOUT_UNDEFINED;

descriptor_index_start = image_index;
}
else if (descriptor.type == RHI_Descriptor_Type::Texture || descriptor.type == RHI_Descriptor_Type::TextureStorage)
if (descriptor.type == RHI_Descriptor_Type::Texture || descriptor.type == RHI_Descriptor_Type::TextureStorage)
{
RHI_Texture* texture = static_cast<RHI_Texture*>(descriptor.data);
const bool mip_specified = descriptor.mip != rhi_all_mips;
Expand Down
11 changes: 1 addition & 10 deletions runtime/RHI/Vulkan/Vulkan_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,14 +1671,9 @@ namespace Spartan
uint32_t storage_textures = 0;
uint32_t storage_buffers = 0;
uint32_t dynamic_constant_buffers = 0;
uint32_t samplers = 0;
for (const RHI_Descriptor& descriptor : descriptors_)
{
if (descriptor.type == RHI_Descriptor_Type::Sampler)
{
samplers++;
}
else if (descriptor.type == RHI_Descriptor_Type::Texture)
if (descriptor.type == RHI_Descriptor_Type::Texture)
{
textures++;
}
Expand All @@ -1696,7 +1691,6 @@ namespace Spartan
}
}

SP_ASSERT_MSG(samplers <= rhi_max_array_size, "Descriptor set requires more samplers");
SP_ASSERT_MSG(textures <= rhi_max_array_size, "Descriptor set requires more textures");
SP_ASSERT_MSG(storage_textures <= rhi_max_array_size, "Descriptor set requires more storage textures");
SP_ASSERT_MSG(storage_buffers <= rhi_max_array_size, "Descriptor set requires more dynamic storage buffers");
Expand Down Expand Up @@ -1737,9 +1731,6 @@ namespace Spartan

uint32_t RHI_Device::GetDescriptorType(const RHI_Descriptor& descriptor)
{
if (descriptor.type == RHI_Descriptor_Type::Sampler)
return VkDescriptorType::VK_DESCRIPTOR_TYPE_SAMPLER;

if (descriptor.type == RHI_Descriptor_Type::Texture)
return VkDescriptorType::VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;

Expand Down
5 changes: 2 additions & 3 deletions runtime/RHI/Vulkan/Vulkan_Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,10 @@ namespace Spartan
const CompilerHLSL compiler = CompilerHLSL(ptr, size);
ShaderResources resources = compiler.get_shader_resources();

spirv_resources_to_descriptors(compiler, m_descriptors, resources.separate_images, RHI_Descriptor_Type::Texture, shader_stage); // SRVs
spirv_resources_to_descriptors(compiler, m_descriptors, resources.storage_images, RHI_Descriptor_Type::TextureStorage, shader_stage); // UAVs
spirv_resources_to_descriptors(compiler, m_descriptors, resources.separate_images, RHI_Descriptor_Type::Texture, shader_stage); // srv
spirv_resources_to_descriptors(compiler, m_descriptors, resources.storage_images, RHI_Descriptor_Type::TextureStorage, shader_stage); // uav
spirv_resources_to_descriptors(compiler, m_descriptors, resources.storage_buffers, RHI_Descriptor_Type::StructuredBuffer, shader_stage);
spirv_resources_to_descriptors(compiler, m_descriptors, resources.uniform_buffers, RHI_Descriptor_Type::ConstantBuffer, shader_stage);
spirv_resources_to_descriptors(compiler, m_descriptors, resources.push_constant_buffers, RHI_Descriptor_Type::PushConstantBuffer, shader_stage);
spirv_resources_to_descriptors(compiler, m_descriptors, resources.separate_samplers, RHI_Descriptor_Type::Sampler, shader_stage);
}
}

0 comments on commit 6e7a187

Please sign in to comment.