Improving performance, but breaking vertex buffers
This commit is contained in:
Vendored
+1
-1
@@ -107,7 +107,7 @@
|
|||||||
"scoped_allocator": "cpp",
|
"scoped_allocator": "cpp",
|
||||||
"stack": "cpp"
|
"stack": "cpp"
|
||||||
},
|
},
|
||||||
"cmake.generator": "Ninja",
|
"cmake.generator": "Visual Studio 16 2019",
|
||||||
"cmake.skipConfigureIfCachePresent": false,
|
"cmake.skipConfigureIfCachePresent": false,
|
||||||
"cmake.configureArgs": [
|
"cmake.configureArgs": [
|
||||||
"-Wno-dev"
|
"-Wno-dev"
|
||||||
|
|||||||
+2
-1
@@ -44,7 +44,7 @@ find_package(Threads REQUIRED)
|
|||||||
find_package(assimp REQUIRED)
|
find_package(assimp REQUIRED)
|
||||||
find_package(JSON REQUIRED)
|
find_package(JSON REQUIRED)
|
||||||
find_package(GLFW REQUIRED)
|
find_package(GLFW REQUIRED)
|
||||||
find_package(SPIRV REQUIRED)
|
#find_package(SPIRV REQUIRED)
|
||||||
find_package(GLM REQUIRED)
|
find_package(GLM REQUIRED)
|
||||||
find_package(STB REQUIRED)
|
find_package(STB REQUIRED)
|
||||||
find_package(SLang REQUIRED)
|
find_package(SLang REQUIRED)
|
||||||
@@ -113,4 +113,5 @@ add_custom_target(copy-runtime-files ALL
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_BINARY} $<TARGET_FILE_DIR:SeeleEngine>
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SLANG_BINARY} $<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>
|
||||||
DEPENDS SeeleEngine)
|
DEPENDS SeeleEngine)
|
||||||
+10
-2
@@ -30,6 +30,13 @@ if (WIN32)
|
|||||||
PATHS
|
PATHS
|
||||||
$ENV{PROGRAMFILES}/lib
|
$ENV{PROGRAMFILES}/lib
|
||||||
${ASSIMP_ROOT}/lib/)
|
${ASSIMP_ROOT}/lib/)
|
||||||
|
|
||||||
|
find_file(
|
||||||
|
ASSIMP_BINARY
|
||||||
|
NAMES assimp-vc${MSVC_TOOLSET_VERSION}-mt${CMAKE_DEBUG_POSTFIX}.dll
|
||||||
|
PATHS
|
||||||
|
$ENV{PROGRAMFILES}/bin
|
||||||
|
${ASSIMP_ROOT}/bin)
|
||||||
else()
|
else()
|
||||||
# Find include files
|
# Find include files
|
||||||
find_path(
|
find_path(
|
||||||
@@ -58,13 +65,14 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Handle REQUIRD argument, define *_FOUND variable
|
# Handle REQUIRD argument, define *_FOUND variable
|
||||||
find_package_handle_standard_args(assimp DEFAULT_MSG ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY)
|
find_package_handle_standard_args(assimp DEFAULT_MSG ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY ASSIMP_BINARY)
|
||||||
|
|
||||||
# Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS
|
# Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS
|
||||||
if (ASSIMP_FOUND)
|
if (ASSIMP_FOUND)
|
||||||
set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY})
|
set(ASSIMP_LIBRARIES ${ASSIMP_LIBRARY})
|
||||||
set(ASSIMP_INCLUDE_DIRS ${ASSIMP_INCLUDE_DIR})
|
set(ASSIMP_INCLUDE_DIRS ${ASSIMP_INCLUDE_DIR})
|
||||||
|
set(ASSIMP_BINARIES ${ASSIMP_BINARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Hide some variables
|
# Hide some variables
|
||||||
mark_as_advanced(ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY)
|
mark_as_advanced(ASSIMP_INCLUDE_DIR ASSIMP_LIBRARY, ASSIMP_BINARY)
|
||||||
@@ -264,8 +264,8 @@ public:
|
|||||||
{
|
{
|
||||||
root = insert(root, key);
|
root = insert(root, key);
|
||||||
_size++;
|
_size++;
|
||||||
}
|
|
||||||
refreshIterators();
|
refreshIterators();
|
||||||
|
}
|
||||||
return root->pair.value;
|
return root->pair.value;
|
||||||
}
|
}
|
||||||
Iterator find(const K &key)
|
Iterator find(const K &key)
|
||||||
|
|||||||
@@ -190,8 +190,6 @@ class DescriptorSet
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~DescriptorSet() {}
|
virtual ~DescriptorSet() {}
|
||||||
virtual void beginFrame() = 0;
|
|
||||||
virtual void endFrame() = 0;
|
|
||||||
virtual void writeChanges() = 0;
|
virtual void writeChanges() = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PStructuredBuffer structuredBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, PStructuredBuffer structuredBuffer) = 0;
|
||||||
@@ -481,6 +479,7 @@ class RenderCommand
|
|||||||
public:
|
public:
|
||||||
RenderCommand();
|
RenderCommand();
|
||||||
virtual ~RenderCommand();
|
virtual ~RenderCommand();
|
||||||
|
virtual void begin() = 0;
|
||||||
virtual void setViewport(Gfx::PViewport viewport) = 0;
|
virtual void setViewport(Gfx::PViewport viewport) = 0;
|
||||||
virtual void bindPipeline(Gfx::PGraphicsPipeline pipeline) = 0;
|
virtual void bindPipeline(Gfx::PGraphicsPipeline pipeline) = 0;
|
||||||
virtual void bindDescriptor(Gfx::PDescriptorSet set) = 0;
|
virtual void bindDescriptor(Gfx::PDescriptorSet set) = 0;
|
||||||
@@ -586,7 +585,7 @@ class SwapchainAttachment : public RenderTargetAttachment
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SwapchainAttachment(PWindow owner,
|
SwapchainAttachment(PWindow owner,
|
||||||
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_LOAD,
|
SeAttachmentLoadOp loadOp = SE_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
SeAttachmentStoreOp storeOp = SE_ATTACHMENT_STORE_OP_STORE,
|
||||||
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
SeAttachmentLoadOp stencilLoadOp = SE_ATTACHMENT_LOAD_OP_DONT_CARE,
|
||||||
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
|
SeAttachmentStoreOp stencilStoreOp = SE_ATTACHMENT_STORE_OP_DONT_CARE)
|
||||||
@@ -595,7 +594,7 @@ public:
|
|||||||
clear.color.float32[0] = 0.0f;
|
clear.color.float32[0] = 0.0f;
|
||||||
clear.color.float32[1] = 0.0f;
|
clear.color.float32[1] = 0.0f;
|
||||||
clear.color.float32[2] = 0.0f;
|
clear.color.float32[2] = 0.0f;
|
||||||
clear.color.float32[3] = 0.0f;
|
clear.color.float32[3] = 1.0f;
|
||||||
componentFlags = SE_COLOR_COMPONENT_R_BIT | SE_COLOR_COMPONENT_G_BIT | SE_COLOR_COMPONENT_B_BIT | SE_COLOR_COMPONENT_A_BIT;
|
componentFlags = SE_COLOR_COMPONENT_R_BIT | SE_COLOR_COMPONENT_G_BIT | SE_COLOR_COMPONENT_B_BIT | SE_COLOR_COMPONENT_A_BIT;
|
||||||
}
|
}
|
||||||
virtual PTexture2D getTexture() override
|
virtual PTexture2D getTexture() override
|
||||||
|
|||||||
@@ -41,7 +41,18 @@ void BasePassMeshProcessor::addMeshBatch(
|
|||||||
descriptorSet->writeChanges();
|
descriptorSet->writeChanges();
|
||||||
cachedPrimitiveSets.add(descriptorSet);
|
cachedPrimitiveSets.add(descriptorSet);
|
||||||
}
|
}
|
||||||
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
|
Gfx::PRenderCommand renderCommand;
|
||||||
|
if (cachedCommandBuffers.size() > 0)
|
||||||
|
{
|
||||||
|
renderCommand = cachedCommandBuffers.back();
|
||||||
|
cachedCommandBuffers.pop();
|
||||||
|
renderCommand->begin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderCommand = graphics->createRenderCommand();
|
||||||
|
renderCommand->begin();
|
||||||
|
}
|
||||||
renderCommand->setViewport(target);
|
renderCommand->setViewport(target);
|
||||||
for(uint32 i = 0; i < batch.elements.size(); ++i)
|
for(uint32 i = 0; i < batch.elements.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -72,6 +83,7 @@ Array<Gfx::PRenderCommand> BasePassMeshProcessor::getRenderCommands()
|
|||||||
|
|
||||||
void BasePassMeshProcessor::clearCommands()
|
void BasePassMeshProcessor::clearCommands()
|
||||||
{
|
{
|
||||||
|
cachedCommandBuffers = renderCommands;
|
||||||
renderCommands.clear();
|
renderCommands.clear();
|
||||||
cachedPrimitiveSets.clear();
|
cachedPrimitiveSets.clear();
|
||||||
cachedPrimitiveIndex = 0;
|
cachedPrimitiveIndex = 0;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public:
|
|||||||
void clearCommands();
|
void clearCommands();
|
||||||
private:
|
private:
|
||||||
Array<Gfx::PRenderCommand> renderCommands;
|
Array<Gfx::PRenderCommand> renderCommands;
|
||||||
|
Array<Gfx::PRenderCommand> cachedCommandBuffers;
|
||||||
Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
|
Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
|
||||||
uint32 cachedPrimitiveIndex;
|
uint32 cachedPrimitiveIndex;
|
||||||
Gfx::PViewport target;
|
Gfx::PViewport target;
|
||||||
|
|||||||
@@ -23,6 +23,5 @@ Seele::SceneView::~SceneView()
|
|||||||
|
|
||||||
void SceneView::keyCallback(KeyCode code, KeyAction action, KeyModifier modifier)
|
void SceneView::keyCallback(KeyCode code, KeyAction action, KeyModifier modifier)
|
||||||
{
|
{
|
||||||
std::cout << "Key callback " << (uint32)code << std::endl;
|
|
||||||
activeCamera->getCameraComponent()->moveOrigin(1);
|
activeCamera->getCameraComponent()->moveOrigin(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,21 +286,22 @@ void StagingManager::clearPending()
|
|||||||
|
|
||||||
PStagingBuffer StagingManager::allocateStagingBuffer(uint32 size, VkBufferUsageFlags usage, bool bCPURead)
|
PStagingBuffer StagingManager::allocateStagingBuffer(uint32 size, VkBufferUsageFlags usage, bool bCPURead)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::unique_lock l(lock);
|
std::unique_lock l(lock);
|
||||||
for (auto it = freeBuffers.begin(); it != freeBuffers.end(); ++it)
|
for (auto it = freeBuffers.begin(); it != freeBuffers.end(); ++it)
|
||||||
{
|
{
|
||||||
auto freeBuffer = *it;
|
auto freeBuffer = *it;
|
||||||
if (freeBuffer->allocation->getSize() == size && freeBuffer->allocation->isReadable() == bCPURead)
|
if (freeBuffer->getSize() == size && freeBuffer->isReadable() == bCPURead && freeBuffer->usage == usage)
|
||||||
{
|
{
|
||||||
|
std::cout << "Reusing staging buffer" << std::endl;
|
||||||
activeBuffers.add(freeBuffer.getHandle());
|
activeBuffers.add(freeBuffer.getHandle());
|
||||||
freeBuffers.remove(it, false);
|
freeBuffers.remove(it, false);
|
||||||
return freeBuffer;
|
return freeBuffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::cout << "Creating new stagingbuffer" << std::endl;
|
||||||
PStagingBuffer stagingBuffer = new StagingBuffer();
|
PStagingBuffer stagingBuffer = new StagingBuffer();
|
||||||
VkBufferCreateInfo stagingBufferCreateInfo = init::BufferCreateInfo(usage, size);
|
VkBufferCreateInfo stagingBufferCreateInfo = init::BufferCreateInfo(usage, size);
|
||||||
|
stagingBufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
VkDevice vulkanDevice = graphics->getDevice();
|
VkDevice vulkanDevice = graphics->getDevice();
|
||||||
|
|
||||||
VK_CHECK(vkCreateBuffer(vulkanDevice, &stagingBufferCreateInfo, nullptr, &stagingBuffer->buffer));
|
VK_CHECK(vkCreateBuffer(vulkanDevice, &stagingBufferCreateInfo, nullptr, &stagingBuffer->buffer));
|
||||||
@@ -322,6 +323,8 @@ PStagingBuffer StagingManager::allocateStagingBuffer(uint32 size, VkBufferUsageF
|
|||||||
|
|
||||||
stagingBuffer->allocation = allocator->allocate(memReqs, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | (bCPURead ? VK_MEMORY_PROPERTY_HOST_COHERENT_BIT : VK_MEMORY_PROPERTY_HOST_CACHED_BIT), stagingBuffer->buffer);
|
stagingBuffer->allocation = allocator->allocate(memReqs, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | (bCPURead ? VK_MEMORY_PROPERTY_HOST_COHERENT_BIT : VK_MEMORY_PROPERTY_HOST_CACHED_BIT), stagingBuffer->buffer);
|
||||||
stagingBuffer->bReadable = bCPURead;
|
stagingBuffer->bReadable = bCPURead;
|
||||||
|
stagingBuffer->size = size;
|
||||||
|
stagingBuffer->usage = usage;
|
||||||
vkBindBufferMemory(graphics->getDevice(), stagingBuffer->buffer, stagingBuffer->getMemoryHandle(), stagingBuffer->getOffset());
|
vkBindBufferMemory(graphics->getDevice(), stagingBuffer->buffer, stagingBuffer->getMemoryHandle(), stagingBuffer->getOffset());
|
||||||
|
|
||||||
activeBuffers.add(stagingBuffer.getHandle());
|
activeBuffers.add(stagingBuffer.getHandle());
|
||||||
|
|||||||
@@ -190,10 +190,20 @@ public:
|
|||||||
{
|
{
|
||||||
return allocation->getOffset();
|
return allocation->getOffset();
|
||||||
}
|
}
|
||||||
|
uint32 getSize() const
|
||||||
|
{
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
bool isReadable() const
|
||||||
|
{
|
||||||
|
return bReadable;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PSubAllocation allocation;
|
PSubAllocation allocation;
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
|
uint32 size;
|
||||||
|
VkBufferUsageFlags usage;
|
||||||
uint8 bReadable;
|
uint8 bReadable;
|
||||||
friend class StagingManager;
|
friend class StagingManager;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ static Map<ShaderBuffer *, PendingBuffer> pendingBuffers;
|
|||||||
ShaderBuffer::ShaderBuffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType)
|
ShaderBuffer::ShaderBuffer(PGraphics graphics, uint32 size, VkBufferUsageFlags usage, Gfx::QueueType queueType)
|
||||||
: graphics(graphics), currentBuffer(0), size(size), currentOwner(queueType)
|
: graphics(graphics), currentBuffer(0), size(size), currentOwner(queueType)
|
||||||
{
|
{
|
||||||
if (usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT ||
|
if (usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT ||
|
||||||
usage & VK_BUFFER_USAGE_INDEX_BUFFER_BIT ||
|
|
||||||
usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT ||
|
usage & VK_BUFFER_USAGE_VERTEX_BUFFER_BIT ||
|
||||||
usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)
|
usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)
|
||||||
{
|
{
|
||||||
@@ -54,7 +53,7 @@ ShaderBuffer::ShaderBuffer(PGraphics graphics, uint32 size, VkBufferUsageFlags u
|
|||||||
vkCreateBuffer(graphics->getDevice(), &info, nullptr, &buffers[i].buffer);
|
vkCreateBuffer(graphics->getDevice(), &info, nullptr, &buffers[i].buffer);
|
||||||
bufferReqInfo.buffer = buffers[i].buffer;
|
bufferReqInfo.buffer = buffers[i].buffer;
|
||||||
vkGetBufferMemoryRequirements2(graphics->getDevice(), &bufferReqInfo, &memRequirements);
|
vkGetBufferMemoryRequirements2(graphics->getDevice(), &bufferReqInfo, &memRequirements);
|
||||||
buffers[i].allocation = graphics->getAllocator()->allocate(memRequirements, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, buffers[i].buffer);
|
buffers[i].allocation = graphics->getAllocator()->allocate(memRequirements, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, buffers[i].buffer);
|
||||||
vkBindBufferMemory(graphics->getDevice(), buffers[i].buffer, buffers[i].allocation->getHandle(), buffers[i].allocation->getOffset());
|
vkBindBufferMemory(graphics->getDevice(), buffers[i].buffer, buffers[i].allocation->getHandle(), buffers[i].allocation->getOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,7 +168,7 @@ void *ShaderBuffer::lock(bool bWriteOnly)
|
|||||||
pending.prevQueue = currentOwner;
|
pending.prevQueue = currentOwner;
|
||||||
if (bWriteOnly)
|
if (bWriteOnly)
|
||||||
{
|
{
|
||||||
requestOwnershipTransfer(Gfx::QueueType::DEDICATED_TRANSFER);
|
//requestOwnershipTransfer(Gfx::QueueType::DEDICATED_TRANSFER);
|
||||||
PStagingBuffer stagingBuffer = graphics->getStagingManager()->allocateStagingBuffer(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
|
PStagingBuffer stagingBuffer = graphics->getStagingManager()->allocateStagingBuffer(size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
|
||||||
data = stagingBuffer->getMappedPointer();
|
data = stagingBuffer->getMappedPointer();
|
||||||
pending.stagingBuffer = stagingBuffer;
|
pending.stagingBuffer = stagingBuffer;
|
||||||
@@ -236,7 +235,7 @@ void ShaderBuffer::unlock()
|
|||||||
region.size = size;
|
region.size = size;
|
||||||
vkCmdCopyBuffer(cmdHandle, stagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
vkCmdCopyBuffer(cmdHandle, stagingBuffer->getHandle(), buffers[currentBuffer].buffer, 1, ®ion);
|
||||||
}
|
}
|
||||||
requestOwnershipTransfer(pending.prevQueue);
|
//requestOwnershipTransfer(pending.prevQueue);
|
||||||
graphics->getStagingManager()->releaseStagingBuffer(pending.stagingBuffer);
|
graphics->getStagingManager()->releaseStagingBuffer(pending.stagingBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,6 +159,11 @@ void SecondaryCmdBuffer::end()
|
|||||||
VK_CHECK(vkEndCommandBuffer(handle));
|
VK_CHECK(vkEndCommandBuffer(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SecondaryCmdBuffer::begin()
|
||||||
|
{
|
||||||
|
begin(graphics->getGraphicsCommands()->getCommands());
|
||||||
|
}
|
||||||
|
|
||||||
void SecondaryCmdBuffer::setViewport(Gfx::PViewport viewport)
|
void SecondaryCmdBuffer::setViewport(Gfx::PViewport viewport)
|
||||||
{
|
{
|
||||||
VkViewport vp = viewport.cast<Viewport>()->getHandle();
|
VkViewport vp = viewport.cast<Viewport>()->getHandle();
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public:
|
|||||||
virtual ~SecondaryCmdBuffer();
|
virtual ~SecondaryCmdBuffer();
|
||||||
void begin(PCmdBuffer parent);
|
void begin(PCmdBuffer parent);
|
||||||
void end();
|
void end();
|
||||||
|
virtual void begin() override;
|
||||||
virtual void setViewport(Gfx::PViewport viewport) override;
|
virtual void setViewport(Gfx::PViewport viewport) override;
|
||||||
virtual void bindPipeline(Gfx::PGraphicsPipeline pipeline) override;
|
virtual void bindPipeline(Gfx::PGraphicsPipeline pipeline) override;
|
||||||
virtual void bindDescriptor(Gfx::PDescriptorSet descriptorSet) override;
|
virtual void bindDescriptor(Gfx::PDescriptorSet descriptorSet) override;
|
||||||
|
|||||||
@@ -111,14 +111,6 @@ DescriptorSet::~DescriptorSet()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSet::beginFrame()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSet::endFrame()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer)
|
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer)
|
||||||
{
|
{
|
||||||
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
|
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~DescriptorSet();
|
virtual ~DescriptorSet();
|
||||||
virtual void beginFrame();
|
|
||||||
virtual void endFrame();
|
|
||||||
virtual void writeChanges();
|
virtual void writeChanges();
|
||||||
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer);
|
virtual void updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer);
|
||||||
virtual void updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer);
|
virtual void updateBuffer(uint32_t binding, Gfx::PStructuredBuffer uniformBuffer);
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ Graphics::~Graphics()
|
|||||||
void Graphics::init(GraphicsInitializer initInfo)
|
void Graphics::init(GraphicsInitializer initInfo)
|
||||||
{
|
{
|
||||||
initInstance(initInfo);
|
initInstance(initInfo);
|
||||||
|
#if ENABLE_VALIDATION
|
||||||
setupDebugCallback();
|
setupDebugCallback();
|
||||||
|
#endif
|
||||||
pickPhysicalDevice();
|
pickPhysicalDevice();
|
||||||
createDevice(initInfo);
|
createDevice(initInfo);
|
||||||
allocator = new Allocator(this);
|
allocator = new Allocator(this);
|
||||||
@@ -121,7 +123,6 @@ Gfx::PIndexBuffer Graphics::createIndexBuffer(const IndexBufferCreateInfo &bulkD
|
|||||||
Gfx::PRenderCommand Graphics::createRenderCommand()
|
Gfx::PRenderCommand Graphics::createRenderCommand()
|
||||||
{
|
{
|
||||||
PSecondaryCmdBuffer cmdBuffer = getGraphicsCommands()->createSecondaryCmdBuffer();
|
PSecondaryCmdBuffer cmdBuffer = getGraphicsCommands()->createSecondaryCmdBuffer();
|
||||||
cmdBuffer->begin(getGraphicsCommands()->getCommands());
|
|
||||||
return cmdBuffer;
|
return cmdBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,26 @@ PipelineCache::~PipelineCache()
|
|||||||
vkDestroyPipelineCache(graphics->getDevice(), cache, nullptr);
|
vkDestroyPipelineCache(graphics->getDevice(), cache, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PipelineCreateHashStruct
|
||||||
|
{
|
||||||
|
uint32 vertexHash;
|
||||||
|
uint32 controlHash;
|
||||||
|
uint32 evalHash;
|
||||||
|
uint32 geometryHash;
|
||||||
|
uint32 fragmentHash;
|
||||||
|
uint32 pipelineLayoutHash;
|
||||||
|
VkPipelineTessellationStateCreateInfo tess;
|
||||||
|
VkVertexInputAttributeDescription attribs[16];
|
||||||
|
VkVertexInputBindingDescription bindings[16];
|
||||||
|
VkPipelineInputAssemblyStateCreateInfo inputAssembly;
|
||||||
|
VkPipelineViewportStateCreateInfo viewport;
|
||||||
|
VkPipelineRasterizationStateCreateInfo rasterization;
|
||||||
|
VkPipelineMultisampleStateCreateInfo multisample;
|
||||||
|
VkPipelineDepthStencilStateCreateInfo depthStencil;
|
||||||
|
VkPipelineColorBlendAttachmentState blendAttachments[16];
|
||||||
|
VkPipelineColorBlendStateCreateInfo blendState;
|
||||||
|
};
|
||||||
|
|
||||||
PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo& gfxInfo)
|
PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo& gfxInfo)
|
||||||
{
|
{
|
||||||
VkGraphicsPipelineCreateInfo createInfo;
|
VkGraphicsPipelineCreateInfo createInfo;
|
||||||
@@ -58,6 +78,8 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
std::memset(&tessInfo, 0, sizeof(VkPipelineTessellationStateCreateInfo));
|
std::memset(&tessInfo, 0, sizeof(VkPipelineTessellationStateCreateInfo));
|
||||||
VkPipelineShaderStageCreateInfo stageInfos[5];
|
VkPipelineShaderStageCreateInfo stageInfos[5];
|
||||||
std::memset(stageInfos, 0, sizeof(stageInfos));
|
std::memset(stageInfos, 0, sizeof(stageInfos));
|
||||||
|
PipelineCreateHashStruct hashStruct;
|
||||||
|
std::memset(&hashStruct, 0, sizeof(PipelineCreateHashStruct));
|
||||||
|
|
||||||
PVertexShader vertexShader = gfxInfo.vertexShader.cast<VertexShader>();
|
PVertexShader vertexShader = gfxInfo.vertexShader.cast<VertexShader>();
|
||||||
VkPipelineShaderStageCreateInfo& vertInfo = stageInfos[createInfo.stageCount++];
|
VkPipelineShaderStageCreateInfo& vertInfo = stageInfos[createInfo.stageCount++];
|
||||||
@@ -65,6 +87,7 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
vertInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
|
vertInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
vertInfo.module = vertexShader->getModuleHandle();
|
vertInfo.module = vertexShader->getModuleHandle();
|
||||||
vertInfo.pName = vertexShader->getEntryPointName();
|
vertInfo.pName = vertexShader->getEntryPointName();
|
||||||
|
hashStruct.vertexHash = vertexShader->getShaderHash();
|
||||||
|
|
||||||
if(gfxInfo.controlShader != nullptr)
|
if(gfxInfo.controlShader != nullptr)
|
||||||
{
|
{
|
||||||
@@ -88,6 +111,10 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
tessInfo.pNext = 0;
|
tessInfo.pNext = 0;
|
||||||
tessInfo.flags = 0;
|
tessInfo.flags = 0;
|
||||||
tessInfo.patchControlPoints = control->getNumPatches();
|
tessInfo.patchControlPoints = control->getNumPatches();
|
||||||
|
|
||||||
|
hashStruct.controlHash = control->getShaderHash();
|
||||||
|
hashStruct.evalHash = eval->getShaderHash();
|
||||||
|
hashStruct.tess = tessInfo;
|
||||||
}
|
}
|
||||||
if(gfxInfo.geometryShader != nullptr)
|
if(gfxInfo.geometryShader != nullptr)
|
||||||
{
|
{
|
||||||
@@ -98,6 +125,8 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
geometryInfo.stage = VK_SHADER_STAGE_GEOMETRY_BIT;
|
geometryInfo.stage = VK_SHADER_STAGE_GEOMETRY_BIT;
|
||||||
geometryInfo.module = geometry->getModuleHandle();
|
geometryInfo.module = geometry->getModuleHandle();
|
||||||
geometryInfo.pName = geometry->getEntryPointName();
|
geometryInfo.pName = geometry->getEntryPointName();
|
||||||
|
|
||||||
|
hashStruct.geometryHash = geometry->getShaderHash();
|
||||||
}
|
}
|
||||||
if(gfxInfo.fragmentShader != nullptr)
|
if(gfxInfo.fragmentShader != nullptr)
|
||||||
{
|
{
|
||||||
@@ -108,6 +137,8 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
fragmentInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
fragmentInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
fragmentInfo.module = fragment->getModuleHandle();
|
fragmentInfo.module = fragment->getModuleHandle();
|
||||||
fragmentInfo.pName = fragment->getEntryPointName();
|
fragmentInfo.pName = fragment->getEntryPointName();
|
||||||
|
|
||||||
|
hashStruct.fragmentHash = fragment->getShaderHash();
|
||||||
}
|
}
|
||||||
VkPipelineVertexInputStateCreateInfo vertexInput =
|
VkPipelineVertexInputStateCreateInfo vertexInput =
|
||||||
init::PipelineVertexInputStateCreateInfo();
|
init::PipelineVertexInputStateCreateInfo();
|
||||||
@@ -180,6 +211,9 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
currAttribute.offset = element.offset;
|
currAttribute.offset = element.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::memcpy(hashStruct.bindings, bindings.data(), bindings.size() * sizeof(VkVertexInputBindingDescription));
|
||||||
|
std::memcpy(hashStruct.attribs, attributes.data(), attributes.size() * sizeof(VkVertexInputAttributeDescription));
|
||||||
|
|
||||||
vertexInput.pVertexBindingDescriptions = bindings.data();
|
vertexInput.pVertexBindingDescriptions = bindings.data();
|
||||||
vertexInput.vertexBindingDescriptionCount = bindings.size();
|
vertexInput.vertexBindingDescriptionCount = bindings.size();
|
||||||
vertexInput.pVertexAttributeDescriptions = attributes.data();
|
vertexInput.pVertexAttributeDescriptions = attributes.data();
|
||||||
@@ -191,6 +225,7 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
0,
|
0,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
hashStruct.inputAssembly = assemblyInfo;
|
||||||
|
|
||||||
VkPipelineViewportStateCreateInfo viewportInfo =
|
VkPipelineViewportStateCreateInfo viewportInfo =
|
||||||
init::PipelineViewportStateCreateInfo(
|
init::PipelineViewportStateCreateInfo(
|
||||||
@@ -198,6 +233,7 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
1,
|
1,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
hashStruct.viewport = viewportInfo;
|
||||||
|
|
||||||
VkPipelineRasterizationStateCreateInfo rasterizationState =
|
VkPipelineRasterizationStateCreateInfo rasterizationState =
|
||||||
init::PipelineRasterizationStateCreateInfo(
|
init::PipelineRasterizationStateCreateInfo(
|
||||||
@@ -214,13 +250,19 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
rasterizationState.lineWidth = gfxInfo.rasterizationState.lineWidth;
|
rasterizationState.lineWidth = gfxInfo.rasterizationState.lineWidth;
|
||||||
rasterizationState.rasterizerDiscardEnable = gfxInfo.rasterizationState.rasterizerDiscardEnable;
|
rasterizationState.rasterizerDiscardEnable = gfxInfo.rasterizationState.rasterizerDiscardEnable;
|
||||||
|
|
||||||
|
hashStruct.rasterization = rasterizationState;
|
||||||
|
|
||||||
VkPipelineMultisampleStateCreateInfo multisampleState =
|
VkPipelineMultisampleStateCreateInfo multisampleState =
|
||||||
init::PipelineMultisampleStateCreateInfo((VkSampleCountFlagBits)gfxInfo.multisampleState.samples, 0);
|
init::PipelineMultisampleStateCreateInfo(
|
||||||
|
(VkSampleCountFlagBits)gfxInfo.multisampleState.samples,
|
||||||
|
0);
|
||||||
multisampleState.alphaToCoverageEnable = gfxInfo.multisampleState.alphaCoverageEnable;
|
multisampleState.alphaToCoverageEnable = gfxInfo.multisampleState.alphaCoverageEnable;
|
||||||
multisampleState.alphaToOneEnable = gfxInfo.multisampleState.alphaToOneEnable;
|
multisampleState.alphaToOneEnable = gfxInfo.multisampleState.alphaToOneEnable;
|
||||||
multisampleState.minSampleShading = gfxInfo.multisampleState.minSampleShading;
|
multisampleState.minSampleShading = gfxInfo.multisampleState.minSampleShading;
|
||||||
multisampleState.sampleShadingEnable = gfxInfo.multisampleState.sampleShadingEnable;
|
multisampleState.sampleShadingEnable = gfxInfo.multisampleState.sampleShadingEnable;
|
||||||
|
|
||||||
|
hashStruct.multisample = multisampleState;
|
||||||
|
|
||||||
VkPipelineDepthStencilStateCreateInfo depthStencilState =
|
VkPipelineDepthStencilStateCreateInfo depthStencilState =
|
||||||
init::PipelineDepthStencilStateCreateInfo(
|
init::PipelineDepthStencilStateCreateInfo(
|
||||||
gfxInfo.depthStencilState.depthTestEnable,
|
gfxInfo.depthStencilState.depthTestEnable,
|
||||||
@@ -228,6 +270,8 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
cast(gfxInfo.depthStencilState.depthCompareOp)
|
cast(gfxInfo.depthStencilState.depthCompareOp)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
hashStruct.depthStencil = depthStencilState;
|
||||||
|
|
||||||
const auto& colorAttachments = gfxInfo.renderPass->getLayout()->colorAttachments;
|
const auto& colorAttachments = gfxInfo.renderPass->getLayout()->colorAttachments;
|
||||||
Array<VkPipelineColorBlendAttachmentState> blendAttachments(colorAttachments.size());
|
Array<VkPipelineColorBlendAttachmentState> blendAttachments(colorAttachments.size());
|
||||||
for(uint32 i = 0; i < colorAttachments.size(); ++i)
|
for(uint32 i = 0; i < colorAttachments.size(); ++i)
|
||||||
@@ -242,6 +286,8 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
blendAttachment.srcAlphaBlendFactor = (VkBlendFactor)attachment.srcAlphaBlendFactor;
|
blendAttachment.srcAlphaBlendFactor = (VkBlendFactor)attachment.srcAlphaBlendFactor;
|
||||||
blendAttachment.dstColorBlendFactor = (VkBlendFactor)attachment.dstColorBlendFactor;
|
blendAttachment.dstColorBlendFactor = (VkBlendFactor)attachment.dstColorBlendFactor;
|
||||||
blendAttachment.srcColorBlendFactor = (VkBlendFactor)attachment.srcColorBlendFactor;
|
blendAttachment.srcColorBlendFactor = (VkBlendFactor)attachment.srcColorBlendFactor;
|
||||||
|
|
||||||
|
hashStruct.blendAttachments[i] = blendAttachment;
|
||||||
}
|
}
|
||||||
VkPipelineColorBlendStateCreateInfo blendState =
|
VkPipelineColorBlendStateCreateInfo blendState =
|
||||||
init::PipelineColorBlendStateCreateInfo(
|
init::PipelineColorBlendStateCreateInfo(
|
||||||
@@ -252,6 +298,9 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
blendState.logicOp = (VkLogicOp)gfxInfo.colorBlend.logicOp;
|
blendState.logicOp = (VkLogicOp)gfxInfo.colorBlend.logicOp;
|
||||||
std::memcpy(blendState.blendConstants, gfxInfo.colorBlend.blendConstants, sizeof(float)*4);
|
std::memcpy(blendState.blendConstants, gfxInfo.colorBlend.blendConstants, sizeof(float)*4);
|
||||||
|
|
||||||
|
hashStruct.blendState = blendState;
|
||||||
|
hashStruct.blendState.pAttachments = nullptr;
|
||||||
|
|
||||||
uint32 numDynamicEnabled = 0;
|
uint32 numDynamicEnabled = 0;
|
||||||
StaticArray<VkDynamicState, 2> dynamicEnabled;
|
StaticArray<VkDynamicState, 2> dynamicEnabled;
|
||||||
dynamicEnabled[numDynamicEnabled++] = VK_DYNAMIC_STATE_VIEWPORT;
|
dynamicEnabled[numDynamicEnabled++] = VK_DYNAMIC_STATE_VIEWPORT;
|
||||||
@@ -265,7 +314,20 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
);
|
);
|
||||||
|
|
||||||
PPipelineLayout layout = gfxInfo.pipelineLayout.cast<PipelineLayout>();
|
PPipelineLayout layout = gfxInfo.pipelineLayout.cast<PipelineLayout>();
|
||||||
|
hashStruct.pipelineLayoutHash = layout->getHash();
|
||||||
|
|
||||||
|
boost::crc_32_type crc;
|
||||||
|
crc.process_bytes(&hashStruct, sizeof(PipelineCreateHashStruct));
|
||||||
|
uint32 hash = crc.checksum();
|
||||||
|
VkPipeline pipelineHandle;
|
||||||
|
|
||||||
|
auto foundPipeline = createdPipelines.find(hash);
|
||||||
|
if (foundPipeline != createdPipelines.end())
|
||||||
|
{
|
||||||
|
pipelineHandle = foundPipeline->value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
createInfo.pStages = stageInfos;
|
createInfo.pStages = stageInfos;
|
||||||
createInfo.pVertexInputState = &vertexInput;
|
createInfo.pVertexInputState = &vertexInput;
|
||||||
createInfo.pInputAssemblyState = &assemblyInfo;
|
createInfo.pInputAssemblyState = &assemblyInfo;
|
||||||
@@ -280,12 +342,13 @@ PGraphicsPipeline PipelineCache::createPipeline(const GraphicsPipelineCreateInfo
|
|||||||
createInfo.layout = layout->getHandle();
|
createInfo.layout = layout->getHandle();
|
||||||
createInfo.subpass = 0;
|
createInfo.subpass = 0;
|
||||||
|
|
||||||
VkPipeline pipelineHandle;
|
|
||||||
auto beginTime = std::chrono::high_resolution_clock::now();
|
auto beginTime = std::chrono::high_resolution_clock::now();
|
||||||
VK_CHECK(vkCreateGraphicsPipelines(graphics->getDevice(), cache, 1, &createInfo, nullptr, &pipelineHandle));
|
VK_CHECK(vkCreateGraphicsPipelines(graphics->getDevice(), cache, 1, &createInfo, nullptr, &pipelineHandle));
|
||||||
auto endTime = std::chrono::high_resolution_clock::now();
|
auto endTime = std::chrono::high_resolution_clock::now();
|
||||||
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count();
|
int64 delta = std::chrono::duration_cast<std::chrono::microseconds>(endTime - beginTime).count();
|
||||||
//std::cout << "Gfx creation time: " << delta << std::endl;
|
createdPipelines[hash] = pipelineHandle;
|
||||||
|
std::cout << "Gfx creation time: " << delta << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
PGraphicsPipeline result = new GraphicsPipeline(graphics, pipelineHandle, layout, gfxInfo);
|
PGraphicsPipeline result = new GraphicsPipeline(graphics, pipelineHandle, layout, gfxInfo);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ private:
|
|||||||
VkPipelineCache cache;
|
VkPipelineCache cache;
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
std::string cacheFile;
|
std::string cacheFile;
|
||||||
|
Map<uint32, VkPipeline> createdPipelines;
|
||||||
};
|
};
|
||||||
DEFINE_REF(PipelineCache);
|
DEFINE_REF(PipelineCache);
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ Map<uint32, PDescriptorLayout> Shader::getDescriptorLayouts()
|
|||||||
return descriptorSets;
|
return descriptorSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 Seele::Vulkan::Shader::getShaderHash() const
|
||||||
|
{
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
static SlangStage getStageFromShaderType(ShaderType type)
|
static SlangStage getStageFromShaderType(ShaderType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -127,4 +132,9 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
|||||||
moduleInfo.codeSize = dataSize;
|
moduleInfo.codeSize = dataSize;
|
||||||
moduleInfo.pCode = data;
|
moduleInfo.pCode = data;
|
||||||
VK_CHECK(vkCreateShaderModule(graphics->getDevice(), &moduleInfo, nullptr, &module));
|
VK_CHECK(vkCreateShaderModule(graphics->getDevice(), &moduleInfo, nullptr, &module));
|
||||||
|
|
||||||
|
boost::crc_32_type result;
|
||||||
|
result.process_bytes(entryPointName.data(), entryPointName.size());
|
||||||
|
result.process_bytes(data, dataSize);
|
||||||
|
hash = result.checksum();
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
return "main";//entryPointName.c_str();
|
return "main";//entryPointName.c_str();
|
||||||
}
|
}
|
||||||
Map<uint32, PDescriptorLayout> getDescriptorLayouts();
|
Map<uint32, PDescriptorLayout> getDescriptorLayouts();
|
||||||
|
uint32 getShaderHash() const;
|
||||||
private:
|
private:
|
||||||
PGraphics graphics;
|
PGraphics graphics;
|
||||||
Map<uint32, PDescriptorLayout> descriptorSets;
|
Map<uint32, PDescriptorLayout> descriptorSets;
|
||||||
@@ -33,6 +34,7 @@ private:
|
|||||||
VkShaderStageFlags stage;
|
VkShaderStageFlags stage;
|
||||||
ShaderType type;
|
ShaderType type;
|
||||||
std::string entryPointName;
|
std::string entryPointName;
|
||||||
|
uint32 hash;
|
||||||
};
|
};
|
||||||
DEFINE_REF(Shader);
|
DEFINE_REF(Shader);
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ using namespace Seele::Vulkan;
|
|||||||
void glfwKeyCallback(GLFWwindow* handle, int key, int scancode, int action, int modifier)
|
void glfwKeyCallback(GLFWwindow* handle, int key, int scancode, int action, int modifier)
|
||||||
{
|
{
|
||||||
Window* window = (Window*)glfwGetWindowUserPointer(handle);
|
Window* window = (Window*)glfwGetWindowUserPointer(handle);
|
||||||
std::cout << "glfw callback: " << key << std::endl;
|
|
||||||
window->keyCallback((KeyCode)key, (KeyAction)action, (KeyModifier)modifier);
|
window->keyCallback((KeyCode)key, (KeyAction)action, (KeyModifier)modifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,10 @@ MaterialAsset::~MaterialAsset()
|
|||||||
|
|
||||||
void MaterialAsset::beginFrame()
|
void MaterialAsset::beginFrame()
|
||||||
{
|
{
|
||||||
descriptorSet->beginFrame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialAsset::endFrame()
|
void MaterialAsset::endFrame()
|
||||||
{
|
{
|
||||||
descriptorSet->endFrame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialAsset::updateDescriptorData()
|
void MaterialAsset::updateDescriptorData()
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
std::scoped_lock lock(registeredObjectsLock);
|
std::scoped_lock lock(registeredObjectsLock);
|
||||||
registeredObjects[ptr] = this;
|
registeredObjects[ptr] = this;
|
||||||
}
|
}
|
||||||
RefObject(const RefObject &rhs)
|
inline RefObject(const RefObject &rhs)
|
||||||
: handle(rhs.handle), refCount(rhs.refCount)
|
: handle(rhs.handle), refCount(rhs.refCount)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ public:
|
|||||||
{
|
{
|
||||||
object->addRef();
|
object->addRef();
|
||||||
}
|
}
|
||||||
RefPtr(const RefPtr &other)
|
inline RefPtr(const RefPtr &other)
|
||||||
: object(other.object)
|
: object(other.object)
|
||||||
{
|
{
|
||||||
if (object != nullptr)
|
if (object != nullptr)
|
||||||
|
|||||||
+1
-1
@@ -20,12 +20,12 @@ int main()
|
|||||||
sceneViewInfo.offsetX = 0;
|
sceneViewInfo.offsetX = 0;
|
||||||
sceneViewInfo.offsetY = 0;
|
sceneViewInfo.offsetY = 0;
|
||||||
PSceneView sceneView = new SceneView(core.getWindowManager()->getGraphics(), window, sceneViewInfo);
|
PSceneView sceneView = new SceneView(core.getWindowManager()->getGraphics(), window, sceneViewInfo);
|
||||||
sceneView->applyArea(URect(1280/2, 720/2, 10, 10));
|
|
||||||
window->addView(sceneView);
|
window->addView(sceneView);
|
||||||
sceneView->setFocused();
|
sceneView->setFocused();
|
||||||
AssetRegistry::init("D:\\Private\\Programming\\C++\\TestSeeleProject");
|
AssetRegistry::init("D:\\Private\\Programming\\C++\\TestSeeleProject");
|
||||||
AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Arissa\\Arissa.fbx");
|
AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Arissa\\Arissa.fbx");
|
||||||
PPrimitiveComponent arissa = new PrimitiveComponent(AssetRegistry::findMesh("Arissa"));
|
PPrimitiveComponent arissa = new PrimitiveComponent(AssetRegistry::findMesh("Arissa"));
|
||||||
|
arissa->addWorldTranslation(Vector(0, 0, 100));
|
||||||
sceneView->getScene()->addPrimitiveComponent(arissa);
|
sceneView->getScene()->addPrimitiveComponent(arissa);
|
||||||
core.renderLoop();
|
core.renderLoop();
|
||||||
core.shutdown();
|
core.shutdown();
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ BOOST_AUTO_TEST_CASE(basic_add)
|
|||||||
{
|
{
|
||||||
List<int> list;
|
List<int> list;
|
||||||
list.add(2);
|
list.add(2);
|
||||||
BOOST_REQUIRE_EQUAL(list.length(), 1);
|
BOOST_REQUIRE_EQUAL(list.size(), 1);
|
||||||
list.add(4);
|
list.add(4);
|
||||||
BOOST_REQUIRE_EQUAL(list.length(), 2);
|
BOOST_REQUIRE_EQUAL(list.size(), 2);
|
||||||
List<int>::Iterator it = list.find(2);
|
List<int>::Iterator it = list.find(2);
|
||||||
BOOST_REQUIRE_EQUAL(*it, 2);
|
BOOST_REQUIRE_EQUAL(*it, 2);
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(basic_insert)
|
|||||||
List<int>::Iterator it = list.find(3);
|
List<int>::Iterator it = list.find(3);
|
||||||
it = list.insert(it, 1);
|
it = list.insert(it, 1);
|
||||||
BOOST_REQUIRE_EQUAL(*it, 1);
|
BOOST_REQUIRE_EQUAL(*it, 1);
|
||||||
BOOST_REQUIRE_EQUAL(list.length(), 4);
|
BOOST_REQUIRE_EQUAL(list.size(), 4);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_CASE(basic_remove)
|
BOOST_AUTO_TEST_CASE(basic_remove)
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(basic_remove)
|
|||||||
List<int>::Iterator it = list.find(3);
|
List<int>::Iterator it = list.find(3);
|
||||||
it = list.remove(it);
|
it = list.remove(it);
|
||||||
BOOST_REQUIRE_EQUAL(*it, 4);
|
BOOST_REQUIRE_EQUAL(*it, 4);
|
||||||
BOOST_REQUIRE_EQUAL(list.length(), 2);
|
BOOST_REQUIRE_EQUAL(list.size(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
Reference in New Issue
Block a user