Skip to content

Commit

Permalink
Merge pull request #946 from vsg-dev/master
Browse files Browse the repository at this point in the history
Merged fixes in VSG master into 1.0 branch
  • Loading branch information
robertosfield authored Aug 29, 2023
2 parents 207a6ea + dcd75d4 commit 6c12dcd
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(vsg
LANGUAGES CXX
)
set(VSG_SOVERSION 14)
SET(VSG_RELEASE_CANDIDATE 2)
SET(VSG_RELEASE_CANDIDATE 3)
set(Vulkan_MIN_VERSION 1.1.70.0)

set(VSG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Root source directory of VulkanSceneGraph.")
Expand Down
2 changes: 1 addition & 1 deletion include/vsg/app/RecordTraversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace vsg
Mask traversalMask = MASK_ALL;
Mask overrideMask = MASK_OFF;

/// Container for CommandBuffers that have been recorded in currrent frame
/// Container for CommandBuffers that have been recorded in current frame
ref_ptr<RecordedCommandBuffers> recordedCommandBuffers;

/// get the current State object used to track state and projection/modelview matrices for the current subgraph being traversed
Expand Down
2 changes: 1 addition & 1 deletion include/vsg/state/ColorBlendState.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace vsg
ColorBlendAttachments attachments;
float blendConstants[4] = {0.0f, 0.0f, 0.0f, 0.0f};

/// configure the assingned attachments, if blendEnable is true then set up standard src_alpha, dest_one_minus_alpha blending otherwise disable blending.
/// configure the assigned attachments, if blendEnable is true then set up standard src_alpha, dest_one_minus_alpha blending, otherwise disable blending.
virtual void configureAttachments(bool blendEnable);

int compare(const Object& rhs) const override;
Expand Down
2 changes: 1 addition & 1 deletion include/vsg/state/StateCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
namespace vsg
{

/// Base class for Vulkan commands associated with state, such as binding graphics pipelines and descriptors sets (textures and uniforms).
/// Base class for Vulkan commands associated with state, such as binding graphics pipelines and descriptor sets (textures and uniforms).
/// StateCommands can be attached directly as nodes in the scene graph, or more typically assigned to StateGroup nodes to enable push/popping of state.
class VSG_DECLSPEC StateCommand : public Inherit<Command, StateCommand>
{
Expand Down
2 changes: 1 addition & 1 deletion src/vsg/app/RecordAndSubmitTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void vsg::updateTasks(RecordAndSubmitTasks& tasks, ref_ptr<CompileManager> compi
}
}

// assign database pager if required
// increase maxSlot if required
for (auto& task : tasks)
{
for (auto& commandGraph : task->commandGraphs)
Expand Down
2 changes: 1 addition & 1 deletion src/vsg/state/BufferInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void BufferInfo::copyDataToBuffer(uint32_t deviceID)
}

void* buffer_data;
VkResult result = dm->map(offset, range, 0, &buffer_data);
VkResult result = dm->map(buffer->getMemoryOffset(deviceID) + offset, range, 0, &buffer_data);
if (result != 0)
{
warn("BufferInfo::copyDataToBuffer() cannot copy data. vkMapMemory(..) failed with result = ", result);
Expand Down
11 changes: 6 additions & 5 deletions src/vsg/state/DescriptorBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
</editor-fold> */

#include <vsg/core/compare.h>
#include <vsg/core/Exception.h>
#include <vsg/io/Logger.h>
#include <vsg/io/Options.h>
#include <vsg/state/DescriptorBuffer.h>
Expand Down Expand Up @@ -177,15 +178,15 @@ void DescriptorBuffer::compile(Context& context)
if (bufferInfo->buffer->getDeviceMemory(deviceID) == nullptr)
{
auto memRequirements = bufferInfo->buffer->getMemoryRequirements(deviceID);
auto memory = vsg::DeviceMemory::create(context.device, memRequirements, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
auto [allocated, offset] = memory->reserve(bufferInfo->buffer->size);
if (allocated)
VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
auto [deviceMemory, offset] = context.deviceMemoryBufferPools->reserveMemory(memRequirements,flags);
if (deviceMemory)
{
bufferInfo->buffer->bind(memory, offset);
bufferInfo->buffer->bind(deviceMemory, offset);
}
else
{
warn("DescriptorBuffer::compile(..) unable to allocate buffer within associated DeviceMemory.");
throw Exception{"Error: DescriptorBuffer::compile(..) failed to allocate buffer from deviceMemoryBufferPools.", VK_ERROR_OUT_OF_DEVICE_MEMORY};
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vsg/utils/Builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ref_ptr<StateGroup> Builder::createStateGroup(const StateInfo& stateInfo)
struct SetPipelineStates : public Visitor
{
const StateInfo& si;
SetPipelineStates(const StateInfo& in) :
explicit SetPipelineStates(const StateInfo& in) :
si(in) {}

void apply(Object& object) override
Expand Down
29 changes: 20 additions & 9 deletions src/vsg/vk/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,32 +215,43 @@ void Context::reserve(const ResourceRequirements& requirements)
}

auto required_maxSets = maxSets;
auto required_descriptorPoolSizes = descriptorPoolSizes;

if (available_maxSets < required_maxSets)
required_maxSets -= available_maxSets;
else
required_maxSets = 0;

for (auto& [type, descriptorCount] : required_descriptorPoolSizes)
DescriptorPoolSizes required_descriptorPoolSizes;
for (const auto& [type, descriptorCount] : descriptorPoolSizes)
{
uint32_t adjustedDescriptorCount = descriptorCount;
for (auto itr = available_descriptorPoolSizes.begin(); itr != available_descriptorPoolSizes.end(); ++itr)
{
if (itr->type == type)
{
if (itr->descriptorCount < descriptorCount)
descriptorCount -= itr->descriptorCount;
if (itr->descriptorCount < adjustedDescriptorCount)
adjustedDescriptorCount -= itr->descriptorCount;
else
descriptorCount = 0;
break;
{
adjustedDescriptorCount = 0;
break;
}
}
}
if (adjustedDescriptorCount > 0)
required_descriptorPoolSizes.push_back(VkDescriptorPoolSize{type, adjustedDescriptorCount});
}

if (required_maxSets > 0)
if (required_maxSets > 0 || !required_descriptorPoolSizes.empty())
{
getDescriptorPoolSizesToUse(required_maxSets, required_descriptorPoolSizes);
descriptorPools.push_back(vsg::DescriptorPool::create(device, required_maxSets, required_descriptorPoolSizes));
if (required_maxSets > 0 && !required_descriptorPoolSizes.empty())
{
descriptorPools.push_back(vsg::DescriptorPool::create(device, required_maxSets, required_descriptorPoolSizes));
}
else
{
warn("Context::reserve(const ResourceRequirements& requirements) invalid combination of required_maxSets (", required_maxSets, ") & required_descriptorPoolSizes (", required_descriptorPoolSizes.size(), ") unable to allocate DescriptorPool.");
}
}
}

Expand Down

0 comments on commit 6c12dcd

Please sign in to comment.