Lot of small fixes/improvements
This commit is contained in:
parent
9376cfefd2
commit
61dbd91346
|
|
@ -57,7 +57,7 @@ namespace Nz
|
|||
inline void SetCommandCallback(CommandCallback callback);
|
||||
inline void SetClearColor(std::size_t outputIndex, const std::optional<Color>& color);
|
||||
inline void SetDepthStencilClear(float depth, UInt32 stencil);
|
||||
inline void SetExecutionCallback(CommandCallback callback);
|
||||
inline void SetExecutionCallback(ExecutionCallback callback);
|
||||
|
||||
inline void SetDepthStencilInput(std::size_t attachmentId);
|
||||
inline void SetDepthStencilOutput(std::size_t attachmentId);
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ namespace Nz
|
|||
dsClear.stencil = stencil;
|
||||
}
|
||||
|
||||
inline void FramePass::SetExecutionCallback(CommandCallback callback)
|
||||
inline void FramePass::SetExecutionCallback(ExecutionCallback callback)
|
||||
{
|
||||
m_commandCallback = std::move(callback);
|
||||
m_executionCallback = std::move(callback);
|
||||
}
|
||||
|
||||
inline void FramePass::SetDepthStencilInput(std::size_t attachmentId)
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ namespace Nz
|
|||
|
||||
OpenGLUploadPool& GetUploadPool() override;
|
||||
|
||||
void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) override;
|
||||
|
||||
void Present() override;
|
||||
|
||||
void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) override;
|
||||
|
||||
OpenGLRenderImage& operator=(const OpenGLRenderImage&) = delete;
|
||||
OpenGLRenderImage& operator=(OpenGLRenderImage&&) = delete;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@
|
|||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/WGL/WGLContext.hpp>
|
||||
#include <string>
|
||||
|
||||
#undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos)
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/WGL/WGLFunctions.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace Nz::GL
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ namespace Nz
|
|||
static std::size_t GetSize(StructFieldType fieldType);
|
||||
|
||||
private:
|
||||
static inline std::size_t Align(std::size_t source, std::size_t alignment);
|
||||
|
||||
std::size_t m_largestFieldAlignment;
|
||||
std::size_t m_offsetRounding;
|
||||
std::size_t m_size;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/FieldOffsets.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
|
@ -163,15 +164,6 @@ namespace Nz
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline std::size_t FieldOffsets::Align(std::size_t source, std::size_t alignment)
|
||||
{
|
||||
if (source == 0)
|
||||
return source;
|
||||
|
||||
assert(alignment > 0);
|
||||
return ((source + alignment - 1) / alignment) * alignment;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ size_t StreamWrite(aiFile* file, const char* buffer, size_t size, size_t count);
|
|||
|
||||
struct FileIOUserdata
|
||||
{
|
||||
Nz::Stream* originalStream;
|
||||
const char* originalFilePath;
|
||||
Nz::Stream* originalStream;
|
||||
const char* originalFilePath;
|
||||
};
|
||||
|
||||
aiFile* StreamOpener(aiFileIO* fileIO, const char* filePath, const char* openMode);
|
||||
void StreamCloser(aiFileIO* fileIO, aiFile* file);
|
||||
|
||||
#endif // NAZARA_ASSIMP_CUSTOM_STREAM_HPP
|
||||
#endif // NAZARA_ASSIMP_CUSTOM_STREAM_HPP
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ SOFTWARE.
|
|||
*/
|
||||
|
||||
#include <CustomStream.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
|
|
@ -233,6 +234,8 @@ MeshRef LoadMesh(Stream& stream, const MeshParams& parameters)
|
|||
excludedComponents |= aiComponent_TEXCOORDS;
|
||||
|
||||
aiPropertyStore* properties = aiCreatePropertyStore();
|
||||
CallOnExit releaseProperties([&] { aiReleasePropertyStore(properties); });
|
||||
|
||||
aiSetImportPropertyFloat(properties, AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, float(smoothingAngle));
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_LBW_MAX_WEIGHTS, 4);
|
||||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_SBP_REMOVE, ~aiPrimitiveType_TRIANGLE); //< We only want triangles
|
||||
|
|
@ -241,7 +244,9 @@ MeshRef LoadMesh(Stream& stream, const MeshParams& parameters)
|
|||
aiSetImportPropertyInteger(properties, AI_CONFIG_PP_RVC_FLAGS, excludedComponents);
|
||||
|
||||
const aiScene* scene = aiImportFileExWithProperties(userdata.originalFilePath, postProcess, &fileIO, properties);
|
||||
aiReleasePropertyStore(properties);
|
||||
CallOnExit releaseScene([&] { aiReleaseImport(scene); });
|
||||
|
||||
releaseProperties.CallAndReset();
|
||||
|
||||
if (!scene)
|
||||
{
|
||||
|
|
@ -628,8 +633,6 @@ MeshRef LoadMesh(Stream& stream, const MeshParams& parameters)
|
|||
mesh->Recenter();
|
||||
}
|
||||
|
||||
aiReleaseImport(scene);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -906,6 +906,8 @@ namespace Nz
|
|||
std::size_t passIndex = *itRead;
|
||||
if (seen.find(passIndex) == seen.end())
|
||||
{
|
||||
seen.insert(passIndex);
|
||||
|
||||
if (itRead != itWrite)
|
||||
*itWrite++ = passIndex;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ namespace Nz
|
|||
|
||||
context->glDrawBuffers(GLsizei(colorBufferCount), fboDrawBuffers.data());
|
||||
|
||||
//FIXME: Don't clear when not needed
|
||||
for (std::size_t i = 0; i < colorBufferCount; ++i)
|
||||
{
|
||||
Nz::Color color = command.clearValues[i].color;
|
||||
|
|
@ -127,6 +128,7 @@ namespace Nz
|
|||
GLenum buffer = GL_BACK;
|
||||
context->glDrawBuffers(1, &buffer);
|
||||
|
||||
//FIXME: Don't clear when not needed
|
||||
Nz::Color color = command.clearValues[0].color;
|
||||
context->glClearColor(color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f);
|
||||
context->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace Nz
|
|||
m_commandBuffer.SetViewport(viewportRegion);
|
||||
}
|
||||
|
||||
void OpenGLCommandBufferBuilder::TextureBarrier(PipelineStageFlags srcStageMask, PipelineStageFlags dstStageMask, MemoryAccessFlags srcAccessMask, MemoryAccessFlags dstAccessMask, TextureLayout oldLayout, TextureLayout newLayout, const Texture& texture)
|
||||
void OpenGLCommandBufferBuilder::TextureBarrier(PipelineStageFlags /*srcStageMask*/, PipelineStageFlags /*dstStageMask*/, MemoryAccessFlags /*srcAccessMask*/, MemoryAccessFlags /*dstAccessMask*/, TextureLayout /*oldLayout*/, TextureLayout /*newLayout*/, const Texture& /*texture*/)
|
||||
{
|
||||
/* nothing to do */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,14 +31,15 @@ namespace Nz
|
|||
return m_uploadPool;
|
||||
}
|
||||
|
||||
void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags)
|
||||
void OpenGLRenderImage::Present()
|
||||
{
|
||||
m_owner.Present();
|
||||
m_uploadPool.Reset();
|
||||
}
|
||||
|
||||
void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags /*queueTypeFlags*/)
|
||||
{
|
||||
OpenGLCommandBuffer* oglCommandBuffer = static_cast<OpenGLCommandBuffer*>(commandBuffer);
|
||||
oglCommandBuffer->Execute();
|
||||
}
|
||||
|
||||
void OpenGLRenderImage::Present()
|
||||
{
|
||||
m_owner.Present();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ namespace Nz::GL
|
|||
return false;
|
||||
}
|
||||
|
||||
if (DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0)
|
||||
if (m_loader.DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0)
|
||||
{
|
||||
m_params.bitsPerPixel = descriptor.cColorBits + descriptor.cAlphaBits;
|
||||
m_params.depthBits = descriptor.cDepthBits;
|
||||
|
|
|
|||
|
|
@ -25,14 +25,6 @@ namespace Nz
|
|||
return m_image->GetUploadPool();
|
||||
}
|
||||
|
||||
void RenderFrame::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags)
|
||||
{
|
||||
if (!m_image)
|
||||
throw std::runtime_error("frame is either invalid or has already been presented");
|
||||
|
||||
m_image->SubmitCommandBuffer(commandBuffer, queueTypeFlags);
|
||||
}
|
||||
|
||||
void RenderFrame::Present()
|
||||
{
|
||||
if (!m_image)
|
||||
|
|
@ -41,4 +33,12 @@ namespace Nz
|
|||
m_image->Present();
|
||||
m_image = nullptr;
|
||||
}
|
||||
|
||||
void RenderFrame::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags)
|
||||
{
|
||||
if (!m_image)
|
||||
throw std::runtime_error("frame is either invalid or has already been presented");
|
||||
|
||||
m_image->SubmitCommandBuffer(commandBuffer, queueTypeFlags);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace Nz
|
|||
const ShaderAst::ExpressionType& rightType = GetExpressionType(*node.right);
|
||||
|
||||
ShaderAst::PrimitiveType leftTypeBase = RetrieveBaseType(leftType);
|
||||
ShaderAst::PrimitiveType rightTypeBase = RetrieveBaseType(rightType);
|
||||
//ShaderAst::PrimitiveType rightTypeBase = RetrieveBaseType(rightType);
|
||||
|
||||
|
||||
UInt32 leftOperand = EvaluateExpression(node.left);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ namespace Nz
|
|||
beginInfo.renderArea.offset.y = renderRect.y;
|
||||
beginInfo.renderArea.extent.width = renderRect.width;
|
||||
beginInfo.renderArea.extent.height = renderRect.height;
|
||||
beginInfo.clearValueCount = vkClearValues.size();
|
||||
beginInfo.clearValueCount = UInt32(vkClearValues.size());
|
||||
beginInfo.pClearValues = vkClearValues.data();
|
||||
|
||||
m_commandBuffer.BeginRenderPass(beginInfo);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,15 @@ namespace Nz
|
|||
return m_uploadPool;
|
||||
}
|
||||
|
||||
void VulkanRenderImage::Present()
|
||||
{
|
||||
Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue();
|
||||
if (!graphicsQueue.Submit(UInt32(m_graphicalCommandsBuffers.size()), m_graphicalCommandsBuffers.data(), m_imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, m_renderFinishedSemaphore, m_inFlightFence))
|
||||
throw std::runtime_error("Failed to submit command buffers: " + TranslateVulkanError(graphicsQueue.GetLastErrorCode()));
|
||||
|
||||
m_owner.Present(m_imageIndex, m_renderFinishedSemaphore);
|
||||
}
|
||||
|
||||
void VulkanRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags)
|
||||
{
|
||||
VulkanCommandBuffer& vkCommandBuffer = *static_cast<VulkanCommandBuffer*>(commandBuffer);
|
||||
|
|
@ -81,13 +90,4 @@ namespace Nz
|
|||
throw std::runtime_error("Failed to submit command buffer: " + TranslateVulkanError(graphicsQueue.GetLastErrorCode()));
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanRenderImage::Present()
|
||||
{
|
||||
Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue();
|
||||
if (!graphicsQueue.Submit(UInt32(m_graphicalCommandsBuffers.size()), m_graphicalCommandsBuffers.data(), m_imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, m_renderFinishedSemaphore, m_inFlightFence))
|
||||
throw std::runtime_error("Failed to submit command buffers: " + TranslateVulkanError(graphicsQueue.GetLastErrorCode()));
|
||||
|
||||
m_owner.Present(m_imageIndex, m_renderFinishedSemaphore);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace Nz
|
|||
return colorBlendStates;
|
||||
}
|
||||
|
||||
VkPipelineColorBlendStateCreateInfo VulkanRenderPipeline::BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkPipelineColorBlendAttachmentState>& attachmentState)
|
||||
VkPipelineColorBlendStateCreateInfo VulkanRenderPipeline::BuildColorBlendInfo(const RenderPipelineInfo& /*pipelineInfo*/, const std::vector<VkPipelineColorBlendAttachmentState>& attachmentState)
|
||||
{
|
||||
VkPipelineColorBlendStateCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
||||
|
|
@ -100,7 +100,7 @@ namespace Nz
|
|||
return createInfo;
|
||||
}
|
||||
|
||||
VkPipelineDynamicStateCreateInfo VulkanRenderPipeline::BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkDynamicState>& dynamicStates)
|
||||
VkPipelineDynamicStateCreateInfo VulkanRenderPipeline::BuildDynamicStateInfo(const RenderPipelineInfo& /*pipelineInfo*/, const std::vector<VkDynamicState>& dynamicStates)
|
||||
{
|
||||
VkPipelineDynamicStateCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
||||
|
|
@ -110,7 +110,7 @@ namespace Nz
|
|||
return createInfo;
|
||||
}
|
||||
|
||||
std::vector<VkDynamicState> VulkanRenderPipeline::BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo)
|
||||
std::vector<VkDynamicState> VulkanRenderPipeline::BuildDynamicStateList(const RenderPipelineInfo& /*pipelineInfo*/)
|
||||
{
|
||||
return { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ namespace Nz
|
|||
return createInfo;
|
||||
}
|
||||
|
||||
VkPipelineMultisampleStateCreateInfo VulkanRenderPipeline::BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo)
|
||||
VkPipelineMultisampleStateCreateInfo VulkanRenderPipeline::BuildMultisampleInfo(const RenderPipelineInfo& /*pipelineInfo*/)
|
||||
{
|
||||
VkPipelineMultisampleStateCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
||||
|
|
@ -146,7 +146,7 @@ namespace Nz
|
|||
return createInfo;
|
||||
}
|
||||
|
||||
VkPipelineViewportStateCreateInfo VulkanRenderPipeline::BuildViewportInfo(const RenderPipelineInfo& pipelineInfo)
|
||||
VkPipelineViewportStateCreateInfo VulkanRenderPipeline::BuildViewportInfo(const RenderPipelineInfo& /*pipelineInfo*/)
|
||||
{
|
||||
VkPipelineViewportStateCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||
|
|
@ -229,7 +229,7 @@ namespace Nz
|
|||
return vertexBindings;
|
||||
}
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo VulkanRenderPipeline::BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector<VkVertexInputAttributeDescription>& vertexAttributes, const std::vector<VkVertexInputBindingDescription>& bindingDescriptions)
|
||||
VkPipelineVertexInputStateCreateInfo VulkanRenderPipeline::BuildVertexInputInfo(const RenderPipelineInfo& /*pipelineInfo*/, const std::vector<VkVertexInputAttributeDescription>& vertexAttributes, const std::vector<VkVertexInputBindingDescription>& bindingDescriptions)
|
||||
{
|
||||
VkPipelineVertexInputStateCreateInfo createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
|||
|
||||
std::vector<EntryPoint> entryPoints;
|
||||
|
||||
bool HandleOpcode(const SpirvInstruction& instruction, UInt32 wordCount) override
|
||||
bool HandleOpcode(const SpirvInstruction& instruction, UInt32 /*wordCount*/) override
|
||||
{
|
||||
switch (instruction.op)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,14 +56,15 @@ namespace
|
|||
}
|
||||
|
||||
ShaderGraph::ShaderGraph() :
|
||||
m_flowScene(BuildRegistry()),
|
||||
m_type(ShaderType::NotSet)
|
||||
{
|
||||
m_flowScene.emplace(BuildRegistry());
|
||||
|
||||
m_previewModel = std::make_unique<QuadPreview>();
|
||||
|
||||
QObject::connect(&m_flowScene, &QGraphicsScene::selectionChanged, [&]
|
||||
QObject::connect(&m_flowScene.value(), &QGraphicsScene::selectionChanged, [&]
|
||||
{
|
||||
auto selectedNodes = m_flowScene.selectedNodes();
|
||||
auto selectedNodes = m_flowScene->selectedNodes();
|
||||
if (selectedNodes.size() == 1)
|
||||
OnSelectedNodeUpdate(this, static_cast<ShaderNode*>(selectedNodes.front()->nodeDataModel()));
|
||||
else
|
||||
|
|
@ -78,31 +79,31 @@ m_type(ShaderType::NotSet)
|
|||
|
||||
UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)"));
|
||||
|
||||
auto& node1 = m_flowScene.createNode(std::make_unique<TextureValue>(*this));
|
||||
auto& node1 = m_flowScene->createNode(std::make_unique<TextureValue>(*this));
|
||||
node1.nodeGraphicsObject().setPos(0, 200);
|
||||
|
||||
auto& node2 = m_flowScene.createNode(std::make_unique<InputValue>(*this));
|
||||
auto& node2 = m_flowScene->createNode(std::make_unique<InputValue>(*this));
|
||||
node2.nodeGraphicsObject().setPos(50, 350);
|
||||
|
||||
auto& node3 = m_flowScene.createNode(std::make_unique<SampleTexture>(*this));
|
||||
auto& node3 = m_flowScene->createNode(std::make_unique<SampleTexture>(*this));
|
||||
node3.nodeGraphicsObject().setPos(200, 200);
|
||||
|
||||
auto& node4 = m_flowScene.createNode(std::make_unique<VecMul>(*this));
|
||||
auto& node4 = m_flowScene->createNode(std::make_unique<VecMul>(*this));
|
||||
node4.nodeGraphicsObject().setPos(400, 200);
|
||||
|
||||
auto& node5 = m_flowScene.createNode(std::make_unique<OutputValue>(*this));
|
||||
auto& node5 = m_flowScene->createNode(std::make_unique<OutputValue>(*this));
|
||||
node5.nodeGraphicsObject().setPos(600, 300);
|
||||
|
||||
m_flowScene.createConnection(node3, 0, node1, 0);
|
||||
m_flowScene.createConnection(node3, 1, node2, 0);
|
||||
m_flowScene.createConnection(node4, 0, node3, 0);
|
||||
m_flowScene.createConnection(node4, 1, node3, 0);
|
||||
m_flowScene.createConnection(node5, 0, node4, 0);
|
||||
m_flowScene->createConnection(node3, 0, node1, 0);
|
||||
m_flowScene->createConnection(node3, 1, node2, 0);
|
||||
m_flowScene->createConnection(node4, 0, node3, 0);
|
||||
m_flowScene->createConnection(node4, 1, node3, 0);
|
||||
m_flowScene->createConnection(node5, 0, node4, 0);
|
||||
}
|
||||
|
||||
ShaderGraph::~ShaderGraph()
|
||||
{
|
||||
m_flowScene.clearScene();
|
||||
m_flowScene.reset();
|
||||
}
|
||||
|
||||
std::size_t ShaderGraph::AddBuffer(std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex)
|
||||
|
|
@ -187,8 +188,8 @@ void ShaderGraph::Clear()
|
|||
{
|
||||
m_type = ShaderType::NotSet;
|
||||
|
||||
m_flowScene.clearScene();
|
||||
m_flowScene.clear();
|
||||
m_flowScene->clearScene();
|
||||
m_flowScene->clear();
|
||||
|
||||
m_buffers.clear();
|
||||
m_conditions.clear();
|
||||
|
|
@ -313,10 +314,10 @@ void ShaderGraph::Load(const QJsonObject& data)
|
|||
OnTextureListUpdate(this);
|
||||
|
||||
for (QJsonValueRef node : data["nodes"].toArray())
|
||||
m_flowScene.restoreNode(node.toObject());
|
||||
m_flowScene->restoreNode(node.toObject());
|
||||
|
||||
for (QJsonValueRef connection : data["connections"].toArray())
|
||||
m_flowScene.restoreConnection(connection.toObject());
|
||||
m_flowScene->restoreConnection(connection.toObject());
|
||||
}
|
||||
|
||||
QJsonObject ShaderGraph::Save()
|
||||
|
|
@ -430,14 +431,14 @@ QJsonObject ShaderGraph::Save()
|
|||
|
||||
QJsonArray nodesJsonArray;
|
||||
{
|
||||
for (auto&& [uuid, node] : m_flowScene.nodes())
|
||||
for (auto&& [uuid, node] : m_flowScene->nodes())
|
||||
nodesJsonArray.append(node->save());
|
||||
}
|
||||
sceneJson["nodes"] = nodesJsonArray;
|
||||
|
||||
QJsonArray connectionJsonArray;
|
||||
{
|
||||
for (auto&& [uuid, connection] : m_flowScene.connections())
|
||||
for (auto&& [uuid, connection] : m_flowScene->connections())
|
||||
{
|
||||
QJsonObject connectionJson = connection->save();
|
||||
|
||||
|
|
@ -638,8 +639,12 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview)
|
|||
{
|
||||
assert(textureIndex < m_textures.size());
|
||||
auto& textureEntry = m_textures[textureIndex];
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
textureEntry.preview = std::move(preview);
|
||||
textureEntry.preview.convertTo(QImage::Format_RGBA8888);
|
||||
#else
|
||||
textureEntry.preview = preview.convertToFormat(QImage::Format_RGBA8888);
|
||||
#endif
|
||||
|
||||
OnTexturePreviewUpdate(this, textureIndex);
|
||||
}
|
||||
|
|
@ -844,7 +849,7 @@ std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ShaderGraph::ToFunction
|
|||
|
||||
std::vector<QtNodes::Node*> outputNodes;
|
||||
|
||||
m_flowScene.iterateOverNodes([&](QtNodes::Node* node)
|
||||
m_flowScene->iterateOverNodes([&](QtNodes::Node* node)
|
||||
{
|
||||
if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <nodes/FlowScene>
|
||||
#include <ShaderNode/Enums.hpp>
|
||||
#include <ShaderNode/Previews/PreviewModel.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ class ShaderGraph
|
|||
std::shared_ptr<QtNodes::DataModelRegistry> BuildRegistry();
|
||||
std::unique_ptr<Nz::ShaderAst::DeclareFunctionStatement> ToFunction() const;
|
||||
|
||||
mutable QtNodes::FlowScene m_flowScene;
|
||||
mutable std::optional<QtNodes::FlowScene> m_flowScene;
|
||||
std::vector<BufferEntry> m_buffers;
|
||||
std::vector<ConditionEntry> m_conditions;
|
||||
std::vector<InputEntry> m_inputs;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ inline const PreviewModel& ShaderGraph::GetPreviewModel() const
|
|||
|
||||
inline QtNodes::FlowScene& ShaderGraph::GetScene()
|
||||
{
|
||||
return m_flowScene;
|
||||
return *m_flowScene;
|
||||
}
|
||||
|
||||
inline auto ShaderGraph::GetTexture(std::size_t textureIndex) const -> const TextureEntry&
|
||||
|
|
|
|||
Loading…
Reference in New Issue