Lot of small fixes/improvements

This commit is contained in:
Jérôme Leclercq
2021-05-14 01:48:47 +02:00
parent 9376cfefd2
commit 61dbd91346
22 changed files with 84 additions and 82 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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 */
}

View File

@@ -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();
}
}

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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)
{