Minor formatting fixes
Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
parent
35d8a7c3b3
commit
77e21207d2
5 changed files with 31 additions and 44 deletions
|
@ -40,7 +40,7 @@ private:
|
|||
std::vector<char const *> m_deviceLayers;
|
||||
std::vector<char const *> m_deviceExtensions;
|
||||
|
||||
VkDebugReportCallbackEXT m_reportCallback = 0;
|
||||
VkDebugReportCallbackEXT m_reportCallback = nullptr;
|
||||
|
||||
PFN_vkCreateDebugReportCallbackEXT m_vkCreateDebugReportCallbackEXT = nullptr;
|
||||
PFN_vkDestroyDebugReportCallbackEXT m_vkDestroyDebugReportCallbackEXT = nullptr;
|
||||
|
|
|
@ -194,11 +194,8 @@ DescriptorSetGroup VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanG
|
|||
|
||||
// Find a pool with available sets.
|
||||
uint32_t poolIndex = 0;
|
||||
while (poolIndex < m_descriptorPools.size() &&
|
||||
m_descriptorPools[poolIndex].m_availableSetsCount == 0)
|
||||
{
|
||||
while (poolIndex < m_descriptorPools.size() && m_descriptorPools[poolIndex].m_availableSetsCount == 0)
|
||||
++poolIndex;
|
||||
}
|
||||
|
||||
// No such a pool, create one.
|
||||
if (poolIndex == m_descriptorPools.size())
|
||||
|
@ -319,8 +316,8 @@ void VulkanObjectManager::DestroyObjectUnsafe(VulkanObject object)
|
|||
CollectObjectsImpl(VulkanObjectArray{object});
|
||||
}
|
||||
|
||||
void VulkanObjectManager::SetMaxUniformBuffers(uint32_t maxUniformBuffers)
|
||||
{
|
||||
void VulkanObjectManager::SetMaxUniformBuffers(uint32_t maxUniformBuffers)
|
||||
{
|
||||
m_maxUniformBuffers = maxUniformBuffers;
|
||||
}
|
||||
|
||||
|
@ -383,8 +380,8 @@ void VulkanObjectManager::CreateDescriptorPool()
|
|||
// Maximum descriptors sets count in the pool.
|
||||
uint32_t constexpr kMaxDescriptorsSetCount = 256 * kMaxInflightFrames;
|
||||
|
||||
CHECK(m_maxUniformBuffers > 0, ());
|
||||
CHECK(m_maxImageSamplers > 0, ());
|
||||
CHECK_GREATER(m_maxUniformBuffers, 0, ());
|
||||
CHECK_GREATER(m_maxImageSamplers, 0, ());
|
||||
std::vector<VkDescriptorPoolSize> poolSizes =
|
||||
{
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, m_maxUniformBuffers * kMaxDescriptorsSetCount},
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include "std/target_os.hpp"
|
||||
#include "gl_program_params.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -55,7 +54,7 @@ void ProgramManager::Destroy(ref_ptr<dp::GraphicsContext> context)
|
|||
DestroyForVulkan(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ProgramManager::InitForOpenGL(ref_ptr<dp::GraphicsContext> context)
|
||||
{
|
||||
std::string globalDefines;
|
||||
|
@ -69,26 +68,26 @@ void ProgramManager::InitForOpenGL(ref_ptr<dp::GraphicsContext> context)
|
|||
globalDefines.append("#define ENABLE_VTF\n"); // VTF == Vertex Texture Fetch
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (dp::SupportManager::Instance().IsSamsungGoogleNexus())
|
||||
globalDefines.append("#define SAMSUNG_GOOGLE_NEXUS\n");
|
||||
|
||||
|
||||
auto const apiVersion = context->GetApiVersion();
|
||||
if (apiVersion == dp::ApiVersion::OpenGLES3)
|
||||
globalDefines.append("#define GLES3\n");
|
||||
|
||||
|
||||
m_pool = make_unique_dp<GLProgramPool>(apiVersion);
|
||||
ref_ptr<GLProgramPool> pool = make_ref(m_pool);
|
||||
pool->SetDefines(globalDefines);
|
||||
|
||||
|
||||
m_paramsSetter = make_unique_dp<GLProgramParamsSetter>();
|
||||
}
|
||||
|
||||
void ProgramManager::InitForVulkan(ref_ptr<dp::GraphicsContext> context)
|
||||
{
|
||||
m_pool = make_unique_dp<vulkan::VulkanProgramPool>(context);
|
||||
m_paramsSetter = make_unique_dp<vulkan::VulkanProgramParamsSetter>(context,
|
||||
make_ref(static_cast<vulkan::VulkanProgramPool *>(m_pool.get())));
|
||||
m_paramsSetter = make_unique_dp<vulkan::VulkanProgramParamsSetter>(context,
|
||||
make_ref(static_cast<vulkan::VulkanProgramPool *>(m_pool.get())));
|
||||
}
|
||||
|
||||
void ProgramManager::DestroyForVulkan(ref_ptr<dp::GraphicsContext> context)
|
||||
|
|
|
@ -28,8 +28,7 @@ public:
|
|||
uint32_t m_freeOffset = 0;
|
||||
};
|
||||
|
||||
VulkanProgramParamsSetter(ref_ptr<dp::vulkan::VulkanBaseContext> context,
|
||||
ref_ptr<VulkanProgramPool> programPool);
|
||||
VulkanProgramParamsSetter(ref_ptr<dp::vulkan::VulkanBaseContext> context, ref_ptr<VulkanProgramPool> programPool);
|
||||
~VulkanProgramParamsSetter() override;
|
||||
|
||||
void Destroy(ref_ptr<dp::vulkan::VulkanBaseContext> context);
|
||||
|
|
|
@ -28,7 +28,7 @@ int8_t constexpr kInvalidBindingIndex = -1;
|
|||
uint32_t constexpr kMaxUniformBuffers = 1;
|
||||
|
||||
std::string const kShadersDir = "vulkan_shaders";
|
||||
std::string const kShadersReflecton = "reflection.json";
|
||||
std::string const kShadersReflection = "reflection.json";
|
||||
std::string const kShadersPackFile = "shaders_pack.spv";
|
||||
|
||||
std::vector<uint8_t> ReadShadersPackFile(std::string const & filename)
|
||||
|
@ -122,8 +122,8 @@ std::map<uint8_t, ReflectionData> ReadReflectionFile(std::string const & filenam
|
|||
for (auto & d : reflectionFile.m_reflectionData)
|
||||
{
|
||||
auto const index = d.m_programIndex;
|
||||
std::sort(d.m_info.m_textures.begin(), d.m_info.m_textures.end(),
|
||||
[](auto const & a, auto const & b) {
|
||||
std::ranges::sort(d.m_info.m_textures, [](auto const & a, auto const & b)
|
||||
{
|
||||
return a.m_index < b.m_index;
|
||||
});
|
||||
result.insert(std::make_pair(index, std::move(d)));
|
||||
|
@ -183,16 +183,14 @@ std::vector<VkDescriptorSetLayoutBinding> GetLayoutBindings(ReflectionInfo const
|
|||
if (!reflectionInfo.m_textures.empty())
|
||||
bindingIndex = static_cast<uint32_t>(reflectionInfo.m_textures.back().m_index) + 1;
|
||||
|
||||
for (uint32_t i = static_cast<uint32_t>(reflectionInfo.m_textures.size());
|
||||
i < maxTextureBindings; ++i)
|
||||
{
|
||||
VkDescriptorSetLayoutBinding emptyBinding = {};
|
||||
emptyBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
emptyBinding.binding = bindingIndex++;
|
||||
emptyBinding.descriptorCount = 1;
|
||||
emptyBinding.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
result.push_back(std::move(emptyBinding));
|
||||
}
|
||||
for (uint32_t i = static_cast<uint32_t>(reflectionInfo.m_textures.size()); i < maxTextureBindings; ++i)
|
||||
result.push_back({
|
||||
.binding = bindingIndex++,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
.pImmutableSamplers = nullptr,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -221,27 +219,21 @@ VulkanProgramPool::VulkanProgramPool(ref_ptr<dp::GraphicsContext> context)
|
|||
ref_ptr<dp::vulkan::VulkanBaseContext> vulkanContext = context;
|
||||
VkDevice device = vulkanContext->GetDevice();
|
||||
|
||||
auto reflection = ReadReflectionFile(base::JoinPath(kShadersDir, kShadersReflecton));
|
||||
auto reflection = ReadReflectionFile(base::JoinPath(kShadersDir, kShadersReflection));
|
||||
CHECK_EQUAL(reflection.size(), static_cast<size_t>(Program::ProgramsCount), ());
|
||||
|
||||
auto packFileData = ReadShadersPackFile(base::JoinPath(kShadersDir, kShadersPackFile));
|
||||
|
||||
for (size_t i = 0; i < static_cast<size_t>(Program::ProgramsCount); ++i)
|
||||
{
|
||||
m_maxImageSamplers = std::max(m_maxImageSamplers,
|
||||
static_cast<uint32_t>(reflection[i].m_info.m_textures.size()));
|
||||
}
|
||||
m_maxImageSamplers = std::max(m_maxImageSamplers, static_cast<uint32_t>(reflection[i].m_info.m_textures.size()));
|
||||
|
||||
for (size_t i = 0; i < static_cast<size_t>(Program::ProgramsCount); ++i)
|
||||
{
|
||||
auto const & refl = reflection[i];
|
||||
m_programData[i].m_vertexShader = LoadShaderModule(device, packFileData,
|
||||
refl.m_vsOffset, refl.m_vsSize);
|
||||
m_programData[i].m_fragmentShader = LoadShaderModule(device, packFileData,
|
||||
refl.m_fsOffset, refl.m_fsSize);
|
||||
auto bindings = GetLayoutBindings(refl.m_info, m_maxImageSamplers);
|
||||
CHECK(bindings.size() == kMaxUniformBuffers + m_maxImageSamplers,
|
||||
("Incorrect bindings count."));
|
||||
m_programData[i].m_vertexShader = LoadShaderModule(device, packFileData, refl.m_vsOffset, refl.m_vsSize);
|
||||
m_programData[i].m_fragmentShader = LoadShaderModule(device, packFileData, refl.m_fsOffset, refl.m_fsSize);
|
||||
auto const bindings = GetLayoutBindings(refl.m_info, m_maxImageSamplers);
|
||||
CHECK(bindings.size() == kMaxUniformBuffers + m_maxImageSamplers, ("Incorrect bindings count."));
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo descriptorLayout = {};
|
||||
descriptorLayout.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
|
|
Reference in a new issue