Starts but segfaults sometimes, yay
This commit is contained in:
+12
-6
@@ -105,19 +105,25 @@ add_subdirectory(src/)
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(_CRT_SECURE_NO_WARNINGS)
|
set(_CRT_SECURE_NO_WARNINGS)
|
||||||
# target_compile_options(SeeleEngine PRIVATE /DEBUG:FASTLINK /Zi)
|
target_compile_options(SeeleEngine PRIVATE /DEBUG:FASTLINK /Zi)
|
||||||
else()
|
else()
|
||||||
target_compile_options(SeeleEngine PRIVATE -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
|
target_compile_options(SeeleEngine PRIVATE -g -Wall -Wextra -Wno-delete-incomplete -pedantic -fcoroutines)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(Seele_unit_tests "")
|
add_executable(Seele_unit_tests "")
|
||||||
add_subdirectory(test/)
|
add_subdirectory(test/)
|
||||||
|
|
||||||
add_custom_target(copy-runtime-files ALL
|
if(WIN32)
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:SeeleEngine>
|
add_custom_target(copy-binaries ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_GLSLANG} $<TARGET_FILE_DIR:SeeleEngine>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_GLSLANG} $<TARGET_FILE_DIR:SeeleEngine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GLFW_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ASSIMP_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ASSIMP_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NSAM_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NSAM_BINARIES} $<TARGET_FILE_DIR:SeeleEngine>)
|
||||||
DEPENDS SeeleEngine)
|
else()
|
||||||
|
add_custom_target(copy-binaries ALL COMMAND "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(copy-runtime-files ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/res $<TARGET_FILE_DIR:SeeleEngine>
|
||||||
|
DEPENDS SeeleEngine copy-binaries)
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ else()
|
|||||||
DOC "The directory where GL/nsam.h resides")
|
DOC "The directory where GL/nsam.h resides")
|
||||||
|
|
||||||
find_file(
|
find_file(
|
||||||
NSAM_BINARY
|
NSAM_LIBRARY
|
||||||
NAMES libGFSDK_Aftermath_Lib.${CMAKE_PLATFORM}.so
|
NAMES libGFSDK_Aftermath_Lib.${CMAKE_PLATFORM}.so
|
||||||
PATHS
|
PATHS
|
||||||
/usr/lib64
|
/usr/lib64
|
||||||
@@ -86,7 +86,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Handle REQUIRD argument, define *_FOUND variable
|
# Handle REQUIRD argument, define *_FOUND variable
|
||||||
find_package_handle_standard_args(NSAM DEFAULT_MSG NSAM_INCLUDE_DIR NSAM_BINARY)
|
find_package_handle_standard_args(NSAM DEFAULT_MSG NSAM_INCLUDE_DIR NSAM_LIBRARY)
|
||||||
|
|
||||||
# Define NSAM_LIBRARIES and NSAM_INCLUDE_DIRS
|
# Define NSAM_LIBRARIES and NSAM_INCLUDE_DIRS
|
||||||
if (NSAM_FOUND)
|
if (NSAM_FOUND)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ ShaderCollection& ShaderMap::createShaders(
|
|||||||
Array<char> buffer(static_cast<uint32>(fileSize));
|
Array<char> buffer(static_cast<uint32>(fileSize));
|
||||||
codeStream.read(buffer.data(), fileSize);
|
codeStream.read(buffer.data(), fileSize);
|
||||||
|
|
||||||
createInfo.shaderCode.add(std::string(buffer.data()));
|
createInfo.shaderCode.add(std::string(buffer.data(), 0, fileSize));
|
||||||
|
|
||||||
collection.vertexShader = graphics->createVertexShader(createInfo);
|
collection.vertexShader = graphics->createVertexShader(createInfo);
|
||||||
|
|
||||||
@@ -113,6 +113,7 @@ void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorTyp
|
|||||||
|
|
||||||
PDescriptorSet DescriptorLayout::allocateDescriptorSet()
|
PDescriptorSet DescriptorLayout::allocateDescriptorSet()
|
||||||
{
|
{
|
||||||
|
std::unique_lock lock(allocatorLock);
|
||||||
PDescriptorSet result;
|
PDescriptorSet result;
|
||||||
allocator->allocateDescriptorSet(result);
|
allocator->allocateDescriptorSet(result);
|
||||||
return result;
|
return result;
|
||||||
@@ -120,6 +121,7 @@ PDescriptorSet DescriptorLayout::allocateDescriptorSet()
|
|||||||
|
|
||||||
void DescriptorLayout::reset()
|
void DescriptorLayout::reset()
|
||||||
{
|
{
|
||||||
|
std::unique_lock lock(allocatorLock);
|
||||||
allocator->reset();
|
allocator->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,24 +131,7 @@ void PipelineLayout::addDescriptorLayout(uint32 setIndex, PDescriptorLayout layo
|
|||||||
{
|
{
|
||||||
descriptorSetLayouts.resize(setIndex + 1);
|
descriptorSetLayouts.resize(setIndex + 1);
|
||||||
}
|
}
|
||||||
// After a second thought, merging descriptor layout bindings is not a good idea
|
|
||||||
/*if (descriptorSetLayouts[setIndex] != nullptr)
|
|
||||||
{
|
|
||||||
auto &thisBindings = descriptorSetLayouts[setIndex]->descriptorBindings;
|
|
||||||
auto &otherBindings = layout->descriptorBindings;
|
|
||||||
thisBindings.resize(otherBindings.size());
|
|
||||||
for (size_t i = 0; i < otherBindings.size(); ++i)
|
|
||||||
{
|
|
||||||
if (otherBindings[i].descriptorType != SE_DESCRIPTOR_TYPE_MAX_ENUM)
|
|
||||||
{
|
|
||||||
thisBindings[i] = otherBindings[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else*/
|
|
||||||
{
|
|
||||||
descriptorSetLayouts[setIndex] = layout;
|
descriptorSetLayouts[setIndex] = layout;
|
||||||
}
|
|
||||||
layout->setIndex = setIndex;
|
layout->setIndex = setIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
Array<DescriptorBinding> descriptorBindings;
|
Array<DescriptorBinding> descriptorBindings;
|
||||||
PDescriptorAllocator allocator;
|
PDescriptorAllocator allocator;
|
||||||
|
std::mutex allocatorLock;
|
||||||
uint32 setIndex;
|
uint32 setIndex;
|
||||||
std::string name;
|
std::string name;
|
||||||
friend class PipelineLayout;
|
friend class PipelineLayout;
|
||||||
|
|||||||
@@ -144,10 +144,6 @@ void BasePass::beginFrame()
|
|||||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||||
for(auto &&meshBatch : passData.staticDrawList)
|
|
||||||
{
|
|
||||||
meshBatch.material->updateDescriptorData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasePass::render()
|
void BasePass::render()
|
||||||
|
|||||||
@@ -125,10 +125,6 @@ void DepthPrepass::beginFrame()
|
|||||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||||
for(auto &&meshBatch : passData.staticDrawList)
|
|
||||||
{
|
|
||||||
meshBatch.material->updateDescriptorData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepthPrepass::render()
|
void DepthPrepass::render()
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
target_sources(SeeleEngine
|
target_sources(SeeleEngine
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
NsightAftermathGpuCrashTracker.h
|
||||||
|
NsightAftermathGpuCrashTracker.cpp
|
||||||
|
NsightAftermathHelpers.h
|
||||||
|
NsightAftermathShaderDatabase.h
|
||||||
|
NsightAftermathShaderDatabase.cpp
|
||||||
VulkanAllocator.h
|
VulkanAllocator.h
|
||||||
VulkanAllocator.cpp
|
VulkanAllocator.cpp
|
||||||
VulkanBuffer.cpp
|
VulkanBuffer.cpp
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ void GpuCrashTracker::OnShaderDebugInfo(const void* pShaderDebugInfo, const uint
|
|||||||
|
|
||||||
// Get shader debug information identifier
|
// Get shader debug information identifier
|
||||||
GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier = {};
|
GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier = {};
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GetShaderDebugInfoIdentifier(
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetShaderDebugInfoIdentifier(
|
||||||
GFSDK_Aftermath_Version_API,
|
GFSDK_Aftermath_Version_API,
|
||||||
pShaderDebugInfo,
|
pShaderDebugInfo,
|
||||||
shaderDebugInfoSize,
|
shaderDebugInfoSize,
|
||||||
@@ -124,7 +124,7 @@ void GpuCrashTracker::WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const u
|
|||||||
{
|
{
|
||||||
// Create a GPU crash dump decoder object for the GPU crash dump.
|
// Create a GPU crash dump decoder object for the GPU crash dump.
|
||||||
GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {};
|
GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {};
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_CreateDecoder(
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_CreateDecoder(
|
||||||
GFSDK_Aftermath_Version_API,
|
GFSDK_Aftermath_Version_API,
|
||||||
pGpuCrashDump,
|
pGpuCrashDump,
|
||||||
gpuCrashDumpSize,
|
gpuCrashDumpSize,
|
||||||
@@ -133,19 +133,19 @@ void GpuCrashTracker::WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const u
|
|||||||
// Use the decoder object to read basic information, like application
|
// Use the decoder object to read basic information, like application
|
||||||
// name, PID, etc. from the GPU crash dump.
|
// name, PID, etc. from the GPU crash dump.
|
||||||
GFSDK_Aftermath_GpuCrashDump_BaseInfo baseInfo = {};
|
GFSDK_Aftermath_GpuCrashDump_BaseInfo baseInfo = {};
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_GetBaseInfo(decoder, &baseInfo));
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetBaseInfo(decoder, &baseInfo));
|
||||||
|
|
||||||
// Use the decoder object to query the application name that was set
|
// Use the decoder object to query the application name that was set
|
||||||
// in the GPU crash dump description.
|
// in the GPU crash dump description.
|
||||||
uint32_t applicationNameLength = 0;
|
uint32_t applicationNameLength = 0;
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize(
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize(
|
||||||
decoder,
|
decoder,
|
||||||
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName,
|
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName,
|
||||||
&applicationNameLength));
|
&applicationNameLength));
|
||||||
|
|
||||||
std::vector<char> applicationName(applicationNameLength, '\0');
|
std::vector<char> applicationName(applicationNameLength, '\0');
|
||||||
|
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_GetDescription(
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetDescription(
|
||||||
decoder,
|
decoder,
|
||||||
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName,
|
GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName,
|
||||||
uint32_t(applicationName.size()),
|
uint32_t(applicationName.size()),
|
||||||
@@ -176,7 +176,7 @@ void GpuCrashTracker::WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const u
|
|||||||
// Decode the crash dump to a JSON string.
|
// Decode the crash dump to a JSON string.
|
||||||
// Step 1: Generate the JSON and get the size.
|
// Step 1: Generate the JSON and get the size.
|
||||||
uint32_t jsonSize = 0;
|
uint32_t jsonSize = 0;
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_GenerateJSON(
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GenerateJSON(
|
||||||
decoder,
|
decoder,
|
||||||
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO,
|
GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO,
|
||||||
GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE,
|
GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE,
|
||||||
@@ -188,7 +188,7 @@ void GpuCrashTracker::WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const u
|
|||||||
&jsonSize));
|
&jsonSize));
|
||||||
// Step 2: Allocate a buffer and fetch the generated JSON.
|
// Step 2: Allocate a buffer and fetch the generated JSON.
|
||||||
std::vector<char> json(jsonSize);
|
std::vector<char> json(jsonSize);
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_GetJSON(
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_GetJSON(
|
||||||
decoder,
|
decoder,
|
||||||
uint32_t(json.size()),
|
uint32_t(json.size()),
|
||||||
json.data()));
|
json.data()));
|
||||||
@@ -203,7 +203,7 @@ void GpuCrashTracker::WriteGpuCrashDumpToFile(const void* pGpuCrashDump, const u
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the GPU crash dump decoder object.
|
// Destroy the GPU crash dump decoder object.
|
||||||
AFTERMATH_CHECK_ERROR(PFN_GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder));
|
AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper for writing shader debug information to a file
|
// Helper for writing shader debug information to a file
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ void CmdBuffer::refreshFence()
|
|||||||
{
|
{
|
||||||
descriptor->unbind();
|
descriptor->unbind();
|
||||||
}
|
}
|
||||||
|
boundDescriptors.clear();
|
||||||
state = State::ReadyBegin;
|
state = State::ReadyBegin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +250,7 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
|
|||||||
{
|
{
|
||||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||||
boundDescriptors.add(descriptor.getHandle());
|
boundDescriptors.add(descriptor.getHandle());
|
||||||
descriptor->bind();
|
descriptor->bind(this);
|
||||||
|
|
||||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr);
|
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr);
|
||||||
@@ -260,7 +261,7 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
|||||||
for(uint32 i = 0; i < descriptorSets.size(); ++i)
|
for(uint32 i = 0; i < descriptorSets.size(); ++i)
|
||||||
{
|
{
|
||||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||||
descriptorSet->bind();
|
descriptorSet->bind(this);
|
||||||
|
|
||||||
boundDescriptors.add(descriptorSet.getHandle());
|
boundDescriptors.add(descriptorSet.getHandle());
|
||||||
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
||||||
@@ -333,7 +334,7 @@ void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet)
|
|||||||
{
|
{
|
||||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||||
boundDescriptors.add(descriptor.getHandle());
|
boundDescriptors.add(descriptor.getHandle());
|
||||||
descriptor->bind();
|
descriptor->bind(this);
|
||||||
//std::cout << "Binding descriptor " << descriptor->getHandle() << " to cmd " << handle << std::endl;
|
//std::cout << "Binding descriptor " << descriptor->getHandle() << " to cmd " << handle << std::endl;
|
||||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr);
|
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), descriptorSet->getSetIndex(), 1, &setHandle, 0, nullptr);
|
||||||
@@ -346,7 +347,7 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
|
|||||||
{
|
{
|
||||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||||
boundDescriptors.add(descriptorSet.getHandle());
|
boundDescriptors.add(descriptorSet.getHandle());
|
||||||
descriptorSet->bind();
|
descriptorSet->bind(this);
|
||||||
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
||||||
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
|
||||||
}
|
}
|
||||||
@@ -393,7 +394,7 @@ PRenderCommand CommandBufferManager::createRenderCommand(const std::string& name
|
|||||||
for (uint32 i = 0; i < allocatedRenderCommands.size(); ++i)
|
for (uint32 i = 0; i < allocatedRenderCommands.size(); ++i)
|
||||||
{
|
{
|
||||||
PRenderCommand cmdBuffer = allocatedRenderCommands[i];
|
PRenderCommand cmdBuffer = allocatedRenderCommands[i];
|
||||||
if (cmdBuffer->ready)
|
if (cmdBuffer->isReady())
|
||||||
{
|
{
|
||||||
cmdBuffer->begin(activeCmdBuffer);
|
cmdBuffer->begin(activeCmdBuffer);
|
||||||
return cmdBuffer;
|
return cmdBuffer;
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet &descriptorS
|
|||||||
//If it hasnt been initialized, allocate it
|
//If it hasnt been initialized, allocate it
|
||||||
VK_CHECK(vkAllocateDescriptorSets(graphics->getDevice(), &allocInfo, &cachedHandles[setIndex]->setHandle));
|
VK_CHECK(vkAllocateDescriptorSets(graphics->getDevice(), &allocInfo, &cachedHandles[setIndex]->setHandle));
|
||||||
}
|
}
|
||||||
cachedHandles[setIndex]->currentlyInUse = true;
|
cachedHandles[setIndex]->allocate();
|
||||||
descriptorSet = cachedHandles[setIndex];
|
descriptorSet = cachedHandles[setIndex];
|
||||||
|
|
||||||
PDescriptorSet vulkanSet = descriptorSet.cast<DescriptorSet>();
|
PDescriptorSet vulkanSet = descriptorSet.cast<DescriptorSet>();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ private:
|
|||||||
};
|
};
|
||||||
DEFINE_REF(PipelineLayout)
|
DEFINE_REF(PipelineLayout)
|
||||||
|
|
||||||
|
DECLARE_REF(SecondaryCmdBuffer)
|
||||||
class DescriptorSet : public Gfx::DescriptorSet
|
class DescriptorSet : public Gfx::DescriptorSet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
: setHandle(VK_NULL_HANDLE)
|
: setHandle(VK_NULL_HANDLE)
|
||||||
, graphics(graphics)
|
, graphics(graphics)
|
||||||
, owner(owner)
|
, owner(owner)
|
||||||
|
, boundBuffer(nullptr)
|
||||||
, currentlyBound(false)
|
, currentlyBound(false)
|
||||||
, currentlyInUse(false)
|
, currentlyInUse(false)
|
||||||
{
|
{
|
||||||
@@ -83,14 +84,20 @@ public:
|
|||||||
{
|
{
|
||||||
return currentlyInUse;
|
return currentlyInUse;
|
||||||
}
|
}
|
||||||
void bind()
|
void bind(PSecondaryCmdBuffer cmdBuffer)
|
||||||
{
|
{
|
||||||
|
boundBuffer = cmdBuffer;
|
||||||
currentlyBound = true;
|
currentlyBound = true;
|
||||||
}
|
}
|
||||||
void unbind()
|
void unbind()
|
||||||
{
|
{
|
||||||
|
boundBuffer = nullptr;
|
||||||
currentlyBound = false;
|
currentlyBound = false;
|
||||||
}
|
}
|
||||||
|
void allocate()
|
||||||
|
{
|
||||||
|
currentlyInUse = true;
|
||||||
|
}
|
||||||
void free()
|
void free()
|
||||||
{
|
{
|
||||||
currentlyInUse = false;
|
currentlyInUse = false;
|
||||||
@@ -112,7 +119,7 @@ private:
|
|||||||
VkDescriptorSet setHandle;
|
VkDescriptorSet setHandle;
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
PDescriptorAllocator owner;
|
PDescriptorAllocator owner;
|
||||||
//PCmdBuffer currentlyBound;
|
PSecondaryCmdBuffer boundBuffer;
|
||||||
bool currentlyBound;
|
bool currentlyBound;
|
||||||
bool currentlyInUse;
|
bool currentlyInUse;
|
||||||
friend class DescriptorAllocator;
|
friend class DescriptorAllocator;
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ void Graphics::setupDebugCallback()
|
|||||||
|
|
||||||
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
VK_CHECK(CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback));
|
||||||
|
|
||||||
//crashTracker.Initialize();
|
crashTracker.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::pickPhysicalDevice()
|
void Graphics::pickPhysicalDevice()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "VulkanGraphicsResources.h"
|
#include "VulkanGraphicsResources.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
|
#include "NsightAftermathGpuCrashTracker.h"
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -98,7 +99,7 @@ protected:
|
|||||||
Map<uint32, PFramebuffer> allocatedFramebuffers;
|
Map<uint32, PFramebuffer> allocatedFramebuffers;
|
||||||
PAllocator allocator;
|
PAllocator allocator;
|
||||||
PStagingManager stagingManager;
|
PStagingManager stagingManager;
|
||||||
//GpuCrashTracker crashTracker;
|
GpuCrashTracker crashTracker;
|
||||||
|
|
||||||
friend class Window;
|
friend class Window;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ Queue::~Queue()
|
|||||||
|
|
||||||
void Queue::submitCommandBuffer(PCmdBuffer cmdBuffer, uint32 numSignalSemaphores, VkSemaphore *signalSemaphores)
|
void Queue::submitCommandBuffer(PCmdBuffer cmdBuffer, uint32 numSignalSemaphores, VkSemaphore *signalSemaphores)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::scoped_lock lck(queueLock);
|
std::scoped_lock lck(queueLock);
|
||||||
assert(cmdBuffer->state == CmdBuffer::State::Ended);
|
assert(cmdBuffer->state == CmdBuffer::State::Ended);
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
|||||||
char const* diagnostics = spGetDiagnosticOutput(request);
|
char const* diagnostics = spGetDiagnosticOutput(request);
|
||||||
std::cout << "Compile error for shader " << createInfo.name << std::endl;
|
std::cout << "Compile error for shader " << createInfo.name << std::endl;
|
||||||
std::cout << diagnostics << std::endl;
|
std::cout << diagnostics << std::endl;
|
||||||
|
std::cout << "Defines: " << std::endl;
|
||||||
|
for(auto define : createInfo.defines)
|
||||||
|
{
|
||||||
|
std::cout << define.key << ": " << define.value << std::endl;
|
||||||
|
}
|
||||||
|
std::cout << "For shader code: " << std::endl;
|
||||||
|
for(auto code : createInfo.shaderCode)
|
||||||
|
{
|
||||||
|
std::cout << code << std::endl;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t dataSize = 0;
|
size_t dataSize = 0;
|
||||||
|
|||||||
@@ -56,77 +56,56 @@ void BlinnPhong::generateMaterialCode(std::ofstream& codeStream, json codeJson)
|
|||||||
{
|
{
|
||||||
for(auto code : codeJson[key].items())
|
for(auto code : codeJson[key].items())
|
||||||
{
|
{
|
||||||
accessorStream << code.value().get<std::string>() << ";" << std::endl;
|
accessorStream << "\t\t" << code.value().get<std::string>() << ";" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
accessorStream << "return " << defaultVal << ";";
|
accessorStream << "\t\treturn " << defaultVal << ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
accessorStream << "float3 getBaseColor(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat3 getBaseColor(MaterialFragmentParameter input) {\n";
|
||||||
generateAccessor(accessorStream, "baseColor", "float3(0.5f, 0.5f, 0.5f)");
|
generateAccessor(accessorStream, "baseColor", "float3(0.5f, 0.5f, 0.5f)");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
accessorStream << "float getMetallic(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat getMetallic(MaterialFragmentParameter input) {\n";
|
||||||
generateAccessor(accessorStream, "metallic", "0.f");
|
generateAccessor(accessorStream, "metallic", "0.f");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
accessorStream << "float3 getNormal(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat3 getNormal(MaterialFragmentParameter input) {\n";
|
||||||
generateAccessor(accessorStream, "normal", "float3(0, 1, 0)");
|
generateAccessor(accessorStream, "normal", "float3(0, 1, 0)");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
accessorStream << "float getSpecular(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat getSpecular(MaterialFragmentParameter input) {\n";
|
||||||
generateAccessor(accessorStream, "specular", "0.f");
|
generateAccessor(accessorStream, "specular", "0.f");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
accessorStream << "float getRoughness(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat getRoughness(MaterialFragmentParameter input) {\n";
|
||||||
generateAccessor(accessorStream, "roughness", "0.f");
|
generateAccessor(accessorStream, "roughness", "0.f");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
accessorStream << "float getSheen(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat getSheen(MaterialFragmentParameter input) {\n";
|
||||||
generateAccessor(accessorStream, "sheen", "0.f");
|
generateAccessor(accessorStream, "sheen", "0.f");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
/*accessorStream << "float getSpecularTint(MaterialFragmentParameter input) {\n";
|
accessorStream << "\tfloat3 getWorldOffset() {\n";
|
||||||
generateAccessor(accessorStream, "specularTint", "0.f");
|
|
||||||
accessorStream << "}";
|
|
||||||
|
|
||||||
accessorStream << "float getAnisotropic(MaterialFragmentParameter input) {\n";
|
|
||||||
generateAccessor(accessorStream, "anisotropic", "0.f");
|
|
||||||
accessorStream << "}";
|
|
||||||
|
|
||||||
|
|
||||||
accessorStream << "float getSheenTint(MaterialFragmentParameter input) {\n";
|
|
||||||
generateAccessor(accessorStream, "sheenTint", "0.f");
|
|
||||||
accessorStream << "}";
|
|
||||||
|
|
||||||
accessorStream << "float getClearCoat(MaterialFragmentParameter input) {\n";
|
|
||||||
generateAccessor(accessorStream, "clearCoat", "0.f");
|
|
||||||
accessorStream << "}";
|
|
||||||
|
|
||||||
accessorStream << "float getClearCoatGloss(MaterialFragmentParameter input) {\n";
|
|
||||||
generateAccessor(accessorStream, "clearCoatGloss", "0.f");
|
|
||||||
accessorStream << "}";*/
|
|
||||||
|
|
||||||
accessorStream << "float3 getWorldOffset() {\n";
|
|
||||||
generateAccessor(accessorStream, "worldOffset", "0.f");
|
generateAccessor(accessorStream, "worldOffset", "0.f");
|
||||||
accessorStream << "}";
|
accessorStream << "\t}\n";
|
||||||
|
|
||||||
codeStream << accessorStream.str();
|
codeStream << accessorStream.str();
|
||||||
|
|
||||||
codeStream << "typedef " << name << " BRDF;" << std::endl;
|
codeStream << "\ttypedef " << name << " BRDF;" << std::endl;
|
||||||
codeStream << name << " prepare(MaterialFragmentParameter geometry){" << std::endl;
|
codeStream << "\t" << name << " prepare(MaterialFragmentParameter geometry) {" << std::endl;
|
||||||
codeStream << name << " result;" << std::endl;
|
codeStream << "\t\t" << name << " result;" << std::endl;
|
||||||
codeStream << "result.baseColor = getBaseColor(geometry);" << std::endl;
|
codeStream << "\t\tresult.baseColor = getBaseColor(geometry);" << std::endl;
|
||||||
codeStream << "result.metallic = getMetallic(geometry);" << std::endl;
|
codeStream << "\t\tresult.metallic = getMetallic(geometry);" << std::endl;
|
||||||
codeStream << "result.normal = getNormal(geometry);" << std::endl;
|
codeStream << "\t\tresult.normal = getNormal(geometry);" << std::endl;
|
||||||
codeStream << "result.specular = getSpecular(geometry);" << std::endl;
|
codeStream << "\t\tresult.specular = getSpecular(geometry);" << std::endl;
|
||||||
codeStream << "result.roughness = getRoughness(geometry);" << std::endl;
|
codeStream << "\t\tresult.roughness = getRoughness(geometry);" << std::endl;
|
||||||
codeStream << "result.sheen = getSheen(geometry);" << std::endl;
|
codeStream << "\t\tresult.sheen = getSheen(geometry);" << std::endl;
|
||||||
codeStream << "return result;" << std::endl;
|
codeStream << "\t\treturn result;" << std::endl;
|
||||||
codeStream << "}" << std::endl;
|
codeStream << "\t}" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_BRDF(BlinnPhong)
|
IMPLEMENT_BRDF(BlinnPhong)
|
||||||
@@ -56,7 +56,7 @@ void Material::compile()
|
|||||||
codeStream << "import VERTEX_INPUT_IMPORT;" << std::endl;
|
codeStream << "import VERTEX_INPUT_IMPORT;" << std::endl;
|
||||||
codeStream << "import Material;" << std::endl;
|
codeStream << "import Material;" << std::endl;
|
||||||
codeStream << "import BRDF;" << std::endl;
|
codeStream << "import BRDF;" << std::endl;
|
||||||
codeStream << "import MaterialParameter;" << std::endl;
|
codeStream << "import MaterialParameter;" << std::endl << std::endl;
|
||||||
|
|
||||||
codeStream << "struct " << materialName << " : IMaterial {" << std::endl;
|
codeStream << "struct " << materialName << " : IMaterial {" << std::endl;
|
||||||
uint32 uniformBufferOffset = 0;
|
uint32 uniformBufferOffset = 0;
|
||||||
@@ -69,7 +69,7 @@ void Material::compile()
|
|||||||
if(type.compare("float") == 0)
|
if(type.compare("float") == 0)
|
||||||
{
|
{
|
||||||
PFloatParameter p = new FloatParameter(param.key(), uniformBufferOffset, 0);
|
PFloatParameter p = new FloatParameter(param.key(), uniformBufferOffset, 0);
|
||||||
codeStream << "layout(offset = " << uniformBufferOffset << ")";
|
codeStream << "\tlayout(offset = " << uniformBufferOffset << ")";
|
||||||
if(uniformBinding == -1)
|
if(uniformBinding == -1)
|
||||||
{
|
{
|
||||||
layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
@@ -85,7 +85,7 @@ void Material::compile()
|
|||||||
else if(type.compare("float3") == 0)
|
else if(type.compare("float3") == 0)
|
||||||
{
|
{
|
||||||
PVectorParameter p = new VectorParameter(param.key(), uniformBufferOffset, 0);
|
PVectorParameter p = new VectorParameter(param.key(), uniformBufferOffset, 0);
|
||||||
codeStream << "layout(offset = " << uniformBufferOffset << ")";
|
codeStream << "\tlayout(offset = " << uniformBufferOffset << ")";
|
||||||
if(uniformBinding == -1)
|
if(uniformBinding == -1)
|
||||||
{
|
{
|
||||||
layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||||
@@ -105,7 +105,6 @@ void Material::compile()
|
|||||||
if(defaultValue != param.value().end())
|
if(defaultValue != param.value().end())
|
||||||
{
|
{
|
||||||
std::string defaultString = defaultValue.value().get<std::string>();
|
std::string defaultString = defaultValue.value().get<std::string>();
|
||||||
std::cout << "Texture parameter " << defaultString << std::endl;
|
|
||||||
p->data = AssetRegistry::findTexture(defaultString);
|
p->data = AssetRegistry::findTexture(defaultString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -127,7 +126,7 @@ void Material::compile()
|
|||||||
{
|
{
|
||||||
std::cout << "Error unsupported parameter type" << std::endl;
|
std::cout << "Error unsupported parameter type" << std::endl;
|
||||||
}
|
}
|
||||||
codeStream << type << " " << param.key() << ";\n";
|
codeStream << "\t" << type << " " << param.key() << ";\n";
|
||||||
}
|
}
|
||||||
uniformDataSize = uniformBufferOffset;
|
uniformDataSize = uniformBufferOffset;
|
||||||
if(uniformDataSize != 0)
|
if(uniformDataSize != 0)
|
||||||
|
|||||||
@@ -150,7 +150,14 @@ bool Transform::equals(const Transform &other, float tolerance)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (abs(rotation.x - other.rotation.x) <= tolerance && abs(rotation.y - other.rotation.y) <= tolerance && abs(rotation.z - other.rotation.z) <= tolerance && abs(rotation.w - other.rotation.w) <= tolerance || abs(rotation.x + other.rotation.x) <= tolerance && abs(rotation.y + other.rotation.y) <= tolerance && abs(rotation.z + other.rotation.z) <= tolerance && abs(rotation.w - other.rotation.w) <= tolerance)
|
if ((abs(rotation.x - other.rotation.x) <= tolerance
|
||||||
|
&& abs(rotation.y - other.rotation.y) <= tolerance
|
||||||
|
&& abs(rotation.z - other.rotation.z) <= tolerance
|
||||||
|
&& abs(rotation.w - other.rotation.w) <= tolerance)
|
||||||
|
|| (abs(rotation.x + other.rotation.x) <= tolerance
|
||||||
|
&& abs(rotation.y + other.rotation.y) <= tolerance
|
||||||
|
&& abs(rotation.z + other.rotation.z) <= tolerance
|
||||||
|
&& abs(rotation.w + other.rotation.w) <= tolerance))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -191,5 +198,5 @@ Transform Transform::operator*(const Transform &other) const
|
|||||||
{
|
{
|
||||||
Transform outTransform;
|
Transform outTransform;
|
||||||
multiply(&outTransform, this, &other);
|
multiply(&outTransform, this, &other);
|
||||||
return std::move(outTransform);
|
return outTransform;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ Scene::~Scene()
|
|||||||
void Scene::tick(double deltaTime)
|
void Scene::tick(double deltaTime)
|
||||||
{
|
{
|
||||||
updater->runUpdates(static_cast<float>(deltaTime));
|
updater->runUpdates(static_cast<float>(deltaTime));
|
||||||
|
for(auto &&meshBatch : staticMeshes)
|
||||||
|
{
|
||||||
|
meshBatch.material->updateDescriptorData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::addActor(PActor actor)
|
void Scene::addActor(PActor actor)
|
||||||
|
|||||||
Reference in New Issue
Block a user