Merge branch 'master' into nzsl-modules
This commit is contained in:
commit
bcfef75ec2
|
|
@ -840,14 +840,14 @@ int main()
|
||||||
return Nz::FramePassExecution::Execute;
|
return Nz::FramePassExecution::Execute;
|
||||||
});
|
});
|
||||||
|
|
||||||
gbufferPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
gbufferPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Nz::RenderElement>> elements;
|
std::vector<std::unique_ptr<Nz::RenderElement>> elements;
|
||||||
spaceshipModel.BuildElement(forwardPassIndex, modelInstance1, elements, renderArea);
|
spaceshipModel.BuildElement(forwardPassIndex, modelInstance1, elements, env.renderRect);
|
||||||
spaceshipModel.BuildElement(forwardPassIndex, modelInstance2, elements, renderArea);
|
spaceshipModel.BuildElement(forwardPassIndex, modelInstance2, elements, env.renderRect);
|
||||||
planeModel.BuildElement(forwardPassIndex, planeInstance, elements, renderArea);
|
planeModel.BuildElement(forwardPassIndex, planeInstance, elements, env.renderRect);
|
||||||
|
|
||||||
std::vector<Nz::Pointer<const Nz::RenderElement>> elementPointers;
|
std::vector<Nz::Pointer<const Nz::RenderElement>> elementPointers;
|
||||||
std::vector<Nz::ElementRenderer::RenderStates> renderStates(elements.size());
|
std::vector<Nz::ElementRenderer::RenderStates> renderStates(elements.size());
|
||||||
|
|
@ -866,10 +866,10 @@ int main()
|
||||||
return (lightUpdate) ? Nz::FramePassExecution::UpdateAndExecute : Nz::FramePassExecution::Execute;
|
return (lightUpdate) ? Nz::FramePassExecution::UpdateAndExecute : Nz::FramePassExecution::Execute;
|
||||||
});
|
});
|
||||||
|
|
||||||
lightingPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
lightingPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
//builder.BindVertexBuffer(0, vertexBuffer.get());
|
//builder.BindVertexBuffer(0, vertexBuffer.get());
|
||||||
builder.BindIndexBuffer(*coneMeshGfx->GetIndexBuffer(0).get());
|
builder.BindIndexBuffer(*coneMeshGfx->GetIndexBuffer(0).get());
|
||||||
|
|
@ -897,10 +897,10 @@ int main()
|
||||||
lightingPass.SetDepthStencilInput(depthBuffer1);
|
lightingPass.SetDepthStencilInput(depthBuffer1);
|
||||||
|
|
||||||
Nz::FramePass& forwardPass = graph.AddPass("Forward pass");
|
Nz::FramePass& forwardPass = graph.AddPass("Forward pass");
|
||||||
forwardPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
forwardPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
builder.BindShaderBinding(0, *skyboxShaderBinding);
|
builder.BindShaderBinding(0, *skyboxShaderBinding);
|
||||||
|
|
||||||
|
|
@ -911,7 +911,7 @@ int main()
|
||||||
builder.DrawIndexed(Nz::SafeCast<Nz::UInt32>(cubeMeshGfx->GetIndexCount(0)));
|
builder.DrawIndexed(Nz::SafeCast<Nz::UInt32>(cubeMeshGfx->GetIndexCount(0)));
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Nz::RenderElement>> elements;
|
std::vector<std::unique_ptr<Nz::RenderElement>> elements;
|
||||||
flareSprite.BuildElement(forwardPassIndex, flareInstance, elements, renderArea);
|
flareSprite.BuildElement(forwardPassIndex, flareInstance, elements, env.renderRect);
|
||||||
|
|
||||||
std::vector<Nz::Pointer<const Nz::RenderElement>> elementPointers;
|
std::vector<Nz::Pointer<const Nz::RenderElement>> elementPointers;
|
||||||
std::vector<Nz::ElementRenderer::RenderStates> renderStates(elements.size());
|
std::vector<Nz::ElementRenderer::RenderStates> renderStates(elements.size());
|
||||||
|
|
@ -935,12 +935,12 @@ int main()
|
||||||
|
|
||||||
|
|
||||||
Nz::FramePass& occluderPass = graph.AddPass("Occluder pass");
|
Nz::FramePass& occluderPass = graph.AddPass("Occluder pass");
|
||||||
occluderPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
occluderPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Nz::RenderElement>> elements;
|
std::vector<std::unique_ptr<Nz::RenderElement>> elements;
|
||||||
flareSprite.BuildElement(forwardPassIndex, flareInstance, elements, renderArea);
|
flareSprite.BuildElement(forwardPassIndex, flareInstance, elements, env.renderRect);
|
||||||
|
|
||||||
std::vector<Nz::Pointer<const Nz::RenderElement>> elementPointers;
|
std::vector<Nz::Pointer<const Nz::RenderElement>> elementPointers;
|
||||||
std::vector<Nz::ElementRenderer::RenderStates> renderStates(elements.size());
|
std::vector<Nz::ElementRenderer::RenderStates> renderStates(elements.size());
|
||||||
|
|
@ -959,10 +959,10 @@ int main()
|
||||||
occluderPass.SetDepthStencilInput(depthBuffer1);
|
occluderPass.SetDepthStencilInput(depthBuffer1);
|
||||||
|
|
||||||
Nz::FramePass& godraysPass = graph.AddPass("Light scattering pass");
|
Nz::FramePass& godraysPass = graph.AddPass("Light scattering pass");
|
||||||
godraysPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
godraysPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
builder.BindShaderBinding(0, *godRaysShaderBinding);
|
builder.BindShaderBinding(0, *godRaysShaderBinding);
|
||||||
|
|
||||||
|
|
@ -976,10 +976,10 @@ int main()
|
||||||
godraysPass.AddOutput(godRaysTexture);
|
godraysPass.AddOutput(godRaysTexture);
|
||||||
|
|
||||||
Nz::FramePass& bloomBrightPass = graph.AddPass("Bloom pass - extract bright pixels");
|
Nz::FramePass& bloomBrightPass = graph.AddPass("Bloom pass - extract bright pixels");
|
||||||
bloomBrightPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
bloomBrightPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
builder.BindShaderBinding(0, *bloomBrightShaderBinding);
|
builder.BindShaderBinding(0, *bloomBrightShaderBinding);
|
||||||
|
|
||||||
|
|
@ -1000,10 +1000,10 @@ int main()
|
||||||
for (std::size_t i = 0; i < BloomSubdivisionCount; ++i)
|
for (std::size_t i = 0; i < BloomSubdivisionCount; ++i)
|
||||||
{
|
{
|
||||||
Nz::FramePass& bloomBlurPassHorizontal = graph.AddPass("Bloom pass - gaussian blur #" + std::to_string(i) + " - horizontal");
|
Nz::FramePass& bloomBlurPassHorizontal = graph.AddPass("Bloom pass - gaussian blur #" + std::to_string(i) + " - horizontal");
|
||||||
bloomBlurPassHorizontal.SetCommandCallback([&, i](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
bloomBlurPassHorizontal.SetCommandCallback([&, i](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
builder.BindShaderBinding(0, *gaussianBlurShaderBinding[i * 2 + 0]);
|
builder.BindShaderBinding(0, *gaussianBlurShaderBinding[i * 2 + 0]);
|
||||||
builder.BindPipeline(*gaussianBlurPipeline);
|
builder.BindPipeline(*gaussianBlurPipeline);
|
||||||
|
|
@ -1021,10 +1021,10 @@ int main()
|
||||||
bloomBlurPassHorizontal.AddOutput(bloomTextures[bloomTextureIndex]);
|
bloomBlurPassHorizontal.AddOutput(bloomTextures[bloomTextureIndex]);
|
||||||
|
|
||||||
Nz::FramePass& bloomBlurPassVertical = graph.AddPass("Bloom pass - gaussian blur #" + std::to_string(i) + " - vertical");
|
Nz::FramePass& bloomBlurPassVertical = graph.AddPass("Bloom pass - gaussian blur #" + std::to_string(i) + " - vertical");
|
||||||
bloomBlurPassVertical.SetCommandCallback([&, i](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
bloomBlurPassVertical.SetCommandCallback([&, i](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
builder.BindShaderBinding(0, *gaussianBlurShaderBinding[i * 2 + 1]);
|
builder.BindShaderBinding(0, *gaussianBlurShaderBinding[i * 2 + 1]);
|
||||||
builder.BindPipeline(*gaussianBlurPipeline);
|
builder.BindPipeline(*gaussianBlurPipeline);
|
||||||
|
|
@ -1043,10 +1043,10 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
Nz::FramePass& bloomBlendPass = graph.AddPass("Bloom pass - blend");
|
Nz::FramePass& bloomBlendPass = graph.AddPass("Bloom pass - blend");
|
||||||
bloomBlendPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
bloomBlendPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
builder.BindVertexBuffer(0, *fullscreenVertexBuffer);
|
builder.BindVertexBuffer(0, *fullscreenVertexBuffer);
|
||||||
|
|
||||||
// Blend bloom
|
// Blend bloom
|
||||||
|
|
@ -1079,10 +1079,10 @@ int main()
|
||||||
Nz::FramePass& toneMappingPass = graph.AddPass("Tone mapping");
|
Nz::FramePass& toneMappingPass = graph.AddPass("Tone mapping");
|
||||||
toneMappingPass.AddInput(bloomOutput);
|
toneMappingPass.AddInput(bloomOutput);
|
||||||
toneMappingPass.AddOutput(toneMappingOutput);
|
toneMappingPass.AddOutput(toneMappingOutput);
|
||||||
toneMappingPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::Recti& renderArea)
|
toneMappingPass.SetCommandCallback([&](Nz::CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderArea);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderArea);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
builder.BindShaderBinding(0, *toneMappingShaderBinding);
|
builder.BindShaderBinding(0, *toneMappingShaderBinding);
|
||||||
builder.BindPipeline(*toneMappingPipeline);
|
builder.BindPipeline(*toneMappingPipeline);
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,9 @@ int main()
|
||||||
framePipeline.RegisterRenderable(worldInstanceIndex1, &model, 0xFFFFFFFF, scissorBox);
|
framePipeline.RegisterRenderable(worldInstanceIndex1, &model, 0xFFFFFFFF, scissorBox);
|
||||||
framePipeline.RegisterRenderable(worldInstanceIndex2, &model, 0xFFFFFFFF, scissorBox);
|
framePipeline.RegisterRenderable(worldInstanceIndex2, &model, 0xFFFFFFFF, scissorBox);
|
||||||
|
|
||||||
std::shared_ptr<Nz::PointLight> light = std::make_shared<Nz::PointLight>();
|
std::shared_ptr<Nz::SpotLight> light = std::make_shared<Nz::SpotLight>();
|
||||||
light->UpdateColor(Nz::Color::Green);
|
light->UpdateInnerAngle(Nz::DegreeAnglef(15.f));
|
||||||
|
light->UpdateOuterAngle(Nz::DegreeAnglef(20.f));
|
||||||
|
|
||||||
framePipeline.RegisterLight(light, 0xFFFFFFFF);
|
framePipeline.RegisterLight(light, 0xFFFFFFFF);
|
||||||
|
|
||||||
|
|
@ -165,6 +166,7 @@ int main()
|
||||||
camAngles.pitch = Nz::Clamp(camAngles.pitch - event.mouseMove.deltaY*sensitivity, -89.f, 89.f);
|
camAngles.pitch = Nz::Clamp(camAngles.pitch - event.mouseMove.deltaY*sensitivity, -89.f, 89.f);
|
||||||
|
|
||||||
camQuat = camAngles;
|
camQuat = camAngles;
|
||||||
|
light->UpdateRotation(camQuat);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,15 @@ int main()
|
||||||
labelWidget->SetPosition(0.f, 200.f, 0.f);
|
labelWidget->SetPosition(0.f, 200.f, 0.f);
|
||||||
labelWidget->UpdateText(Nz::SimpleTextDrawer::Draw("Je suis un LabelWidget !", 72));
|
labelWidget->UpdateText(Nz::SimpleTextDrawer::Draw("Je suis un LabelWidget !", 72));
|
||||||
|
|
||||||
|
unsigned int clickCount = 0;
|
||||||
|
|
||||||
Nz::ButtonWidget* buttonWidget = canvas2D.Add<Nz::ButtonWidget>();
|
Nz::ButtonWidget* buttonWidget = canvas2D.Add<Nz::ButtonWidget>();
|
||||||
buttonWidget->SetPosition(200.f, 400.f);
|
buttonWidget->SetPosition(200.f, 400.f);
|
||||||
buttonWidget->UpdateText(Nz::SimpleTextDrawer::Draw("Press me senpai", 72));
|
buttonWidget->UpdateText(Nz::SimpleTextDrawer::Draw("Press me senpai", 72));
|
||||||
buttonWidget->Resize(buttonWidget->GetPreferredSize());
|
buttonWidget->Resize(buttonWidget->GetPreferredSize());
|
||||||
buttonWidget->OnButtonTrigger.Connect([=](const Nz::ButtonWidget*)
|
buttonWidget->OnButtonTrigger.Connect([&](const Nz::ButtonWidget*)
|
||||||
{
|
{
|
||||||
buttonWidget->Destroy();
|
labelWidget->UpdateText(Nz::SimpleTextDrawer::Draw("You clicked the button " + std::to_string(++clickCount) + " times", 72));
|
||||||
});
|
});
|
||||||
|
|
||||||
std::shared_ptr<Nz::Material> material = std::make_shared<Nz::Material>();
|
std::shared_ptr<Nz::Material> material = std::make_shared<Nz::Material>();
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ namespace Nz
|
||||||
|
|
||||||
|
|
||||||
template<typename, typename = void>
|
template<typename, typename = void>
|
||||||
struct GetEnumAutoFlag : std::integral_constant<bool, true> {};
|
struct GetEnumAutoFlag : std::bool_constant<true> {};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct GetEnumAutoFlag<T, std::void_t<decltype(T::AutoFlag)>> : std::integral_constant<bool, T::AutoFlag> {};
|
struct GetEnumAutoFlag<T, std::void_t<decltype(T::AutoFlag)>> : std::bool_constant<T::AutoFlag> {};
|
||||||
|
|
||||||
template<typename E>
|
template<typename E>
|
||||||
class Flags
|
class Flags
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,17 @@
|
||||||
#include <Nazara/Graphics/Camera.hpp>
|
#include <Nazara/Graphics/Camera.hpp>
|
||||||
#include <Nazara/Graphics/Config.hpp>
|
#include <Nazara/Graphics/Config.hpp>
|
||||||
#include <Nazara/Graphics/DepthMaterial.hpp>
|
#include <Nazara/Graphics/DepthMaterial.hpp>
|
||||||
|
#include <Nazara/Graphics/DepthPipelinePass.hpp>
|
||||||
#include <Nazara/Graphics/DirectionalLight.hpp>
|
#include <Nazara/Graphics/DirectionalLight.hpp>
|
||||||
#include <Nazara/Graphics/ElementRenderer.hpp>
|
#include <Nazara/Graphics/ElementRenderer.hpp>
|
||||||
#include <Nazara/Graphics/Enums.hpp>
|
#include <Nazara/Graphics/Enums.hpp>
|
||||||
#include <Nazara/Graphics/ForwardFramePipeline.hpp>
|
#include <Nazara/Graphics/ForwardFramePipeline.hpp>
|
||||||
|
#include <Nazara/Graphics/ForwardPipelinePass.hpp>
|
||||||
#include <Nazara/Graphics/FrameGraph.hpp>
|
#include <Nazara/Graphics/FrameGraph.hpp>
|
||||||
#include <Nazara/Graphics/FramePass.hpp>
|
#include <Nazara/Graphics/FramePass.hpp>
|
||||||
#include <Nazara/Graphics/FramePassAttachment.hpp>
|
#include <Nazara/Graphics/FramePassAttachment.hpp>
|
||||||
#include <Nazara/Graphics/FramePipeline.hpp>
|
#include <Nazara/Graphics/FramePipeline.hpp>
|
||||||
|
#include <Nazara/Graphics/FramePipelinePass.hpp>
|
||||||
#include <Nazara/Graphics/GraphicalMesh.hpp>
|
#include <Nazara/Graphics/GraphicalMesh.hpp>
|
||||||
#include <Nazara/Graphics/Graphics.hpp>
|
#include <Nazara/Graphics/Graphics.hpp>
|
||||||
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
|
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
class BakedFrameGraph;
|
||||||
class CommandBufferBuilder;
|
class CommandBufferBuilder;
|
||||||
class FrameGraph;
|
class FrameGraph;
|
||||||
|
class RenderFrame;
|
||||||
|
|
||||||
enum class FramePassExecution
|
enum class FramePassExecution
|
||||||
{
|
{
|
||||||
|
|
@ -29,10 +31,17 @@ namespace Nz
|
||||||
UpdateAndExecute
|
UpdateAndExecute
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FramePassEnvironment
|
||||||
|
{
|
||||||
|
BakedFrameGraph& frameGraph;
|
||||||
|
Recti renderRect;
|
||||||
|
RenderFrame& renderFrame;
|
||||||
|
};
|
||||||
|
|
||||||
class NAZARA_GRAPHICS_API FramePass
|
class NAZARA_GRAPHICS_API FramePass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using CommandCallback = std::function<void(CommandBufferBuilder& builder, const Recti& renderRect)>;
|
using CommandCallback = std::function<void(CommandBufferBuilder& builder, const FramePassEnvironment& env)>;
|
||||||
using ExecutionCallback = std::function<FramePassExecution()>;
|
using ExecutionCallback = std::function<FramePassExecution()>;
|
||||||
struct DepthStencilClear;
|
struct DepthStencilClear;
|
||||||
struct Input;
|
struct Input;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ namespace Nz
|
||||||
case PixelFormat::BGRA8: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
case PixelFormat::BGRA8: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||||
case PixelFormat::BGRA8_SRGB: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
case PixelFormat::BGRA8_SRGB: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||||
case PixelFormat::Depth16: return GLTextureFormat{ GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO };
|
case PixelFormat::Depth16: return GLTextureFormat{ GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO };
|
||||||
|
case PixelFormat::Depth24: return GLTextureFormat{ GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO };
|
||||||
case PixelFormat::Depth24Stencil8: return GLTextureFormat{ GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_RED, GL_GREEN, GL_ZERO, GL_ZERO };
|
case PixelFormat::Depth24Stencil8: return GLTextureFormat{ GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_RED, GL_GREEN, GL_ZERO, GL_ZERO };
|
||||||
case PixelFormat::Depth32F: return GLTextureFormat{ GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO };
|
case PixelFormat::Depth32F: return GLTextureFormat{ GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO };
|
||||||
case PixelFormat::Depth32FStencil8: return GLTextureFormat{ GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_RED, GL_GREEN, GL_ZERO, GL_ZERO };
|
case PixelFormat::Depth32FStencil8: return GLTextureFormat{ GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_RED, GL_GREEN, GL_ZERO, GL_ZERO };
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,23 @@ namespace Nz::ShaderAst
|
||||||
class NAZARA_SHADER_API EliminateUnusedPassVisitor : AstCloner
|
class NAZARA_SHADER_API EliminateUnusedPassVisitor : AstCloner
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct Config;
|
||||||
|
|
||||||
EliminateUnusedPassVisitor() = default;
|
EliminateUnusedPassVisitor() = default;
|
||||||
EliminateUnusedPassVisitor(const EliminateUnusedPassVisitor&) = delete;
|
EliminateUnusedPassVisitor(const EliminateUnusedPassVisitor&) = delete;
|
||||||
EliminateUnusedPassVisitor(EliminateUnusedPassVisitor&&) = delete;
|
EliminateUnusedPassVisitor(EliminateUnusedPassVisitor&&) = delete;
|
||||||
~EliminateUnusedPassVisitor() = default;
|
~EliminateUnusedPassVisitor() = default;
|
||||||
|
|
||||||
StatementPtr Process(Statement& statement);
|
StatementPtr Process(Statement& statement, const Config& config = {});
|
||||||
|
|
||||||
EliminateUnusedPassVisitor& operator=(const EliminateUnusedPassVisitor&) = delete;
|
EliminateUnusedPassVisitor& operator=(const EliminateUnusedPassVisitor&) = delete;
|
||||||
EliminateUnusedPassVisitor& operator=(EliminateUnusedPassVisitor&&) = delete;
|
EliminateUnusedPassVisitor& operator=(EliminateUnusedPassVisitor&&) = delete;
|
||||||
|
|
||||||
|
struct Config
|
||||||
|
{
|
||||||
|
ShaderStageTypeFlags usedShaderStages = ShaderStageType_All;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using AstCloner::Clone;
|
using AstCloner::Clone;
|
||||||
StatementPtr Clone(DeclareExternalStatement& node) override;
|
StatementPtr Clone(DeclareExternalStatement& node) override;
|
||||||
|
|
@ -42,7 +49,7 @@ namespace Nz::ShaderAst
|
||||||
Context* m_context;
|
Context* m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline StatementPtr EliminateUnusedPass(Statement& ast);
|
inline StatementPtr EliminateUnusedPass(Statement& ast, const EliminateUnusedPassVisitor::Config& config = {});
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/Shader/Ast/EliminateUnusedPassVisitor.inl>
|
#include <Nazara/Shader/Ast/EliminateUnusedPassVisitor.inl>
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@
|
||||||
|
|
||||||
namespace Nz::ShaderAst
|
namespace Nz::ShaderAst
|
||||||
{
|
{
|
||||||
inline StatementPtr EliminateUnusedPass(Statement& ast)
|
inline StatementPtr EliminateUnusedPass(Statement& ast, const EliminateUnusedPassVisitor::Config& config)
|
||||||
{
|
{
|
||||||
EliminateUnusedPassVisitor visitor;
|
EliminateUnusedPassVisitor visitor;
|
||||||
return visitor.Process(ast);
|
return visitor.Process(ast, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,7 @@ namespace Nz
|
||||||
case PixelFormat::BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB;
|
case PixelFormat::BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB;
|
||||||
case PixelFormat::Depth16: return VK_FORMAT_D16_UNORM;
|
case PixelFormat::Depth16: return VK_FORMAT_D16_UNORM;
|
||||||
case PixelFormat::Depth16Stencil8: return VK_FORMAT_D16_UNORM_S8_UINT;
|
case PixelFormat::Depth16Stencil8: return VK_FORMAT_D16_UNORM_S8_UINT;
|
||||||
|
case PixelFormat::Depth24: return VK_FORMAT_UNDEFINED;
|
||||||
case PixelFormat::Depth24Stencil8: return VK_FORMAT_D24_UNORM_S8_UINT;
|
case PixelFormat::Depth24Stencil8: return VK_FORMAT_D24_UNORM_S8_UINT;
|
||||||
case PixelFormat::Depth32F: return VK_FORMAT_D32_SFLOAT;
|
case PixelFormat::Depth32F: return VK_FORMAT_D32_SFLOAT;
|
||||||
case PixelFormat::Depth32FStencil8: return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
case PixelFormat::Depth32FStencil8: return VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||||
|
|
@ -265,11 +266,15 @@ namespace Nz
|
||||||
case PixelFormat::RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
|
case PixelFormat::RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
|
||||||
case PixelFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT;
|
case PixelFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||||
case PixelFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT;
|
case PixelFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||||
|
case PixelFormat::Stencil1: return VK_FORMAT_UNDEFINED;
|
||||||
|
case PixelFormat::Stencil4: return VK_FORMAT_UNDEFINED;
|
||||||
|
case PixelFormat::Stencil8: return VK_FORMAT_S8_UINT;
|
||||||
|
case PixelFormat::Stencil16: return VK_FORMAT_UNDEFINED;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
NazaraError("Unhandled PixelFormat 0x" + NumberToString(UnderlyingCast(pixelFormat), 16));
|
NazaraError("Unhandled PixelFormat 0x" + NumberToString(UnderlyingCast(pixelFormat), 16));
|
||||||
return {};
|
return VK_FORMAT_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImageAspectFlags ToVulkan(PixelFormatContent pixelFormatContent)
|
VkImageAspectFlags ToVulkan(PixelFormatContent pixelFormatContent)
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,12 @@ namespace Nz
|
||||||
if (!passData.name.empty())
|
if (!passData.name.empty())
|
||||||
builder.BeginDebugRegion(passData.name, Color::Green);
|
builder.BeginDebugRegion(passData.name, Color::Green);
|
||||||
|
|
||||||
|
FramePassEnvironment env{
|
||||||
|
*this,
|
||||||
|
passData.renderRect,
|
||||||
|
renderFrame
|
||||||
|
};
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto& subpass : passData.subpasses)
|
for (auto& subpass : passData.subpasses)
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +81,7 @@ namespace Nz
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
subpass.commandCallback(builder, passData.renderRect);
|
subpass.commandCallback(builder, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!passData.name.empty())
|
if (!passData.name.empty())
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ namespace Nz
|
||||||
return (m_rebuildCommandBuffer) ? FramePassExecution::UpdateAndExecute : FramePassExecution::Execute;
|
return (m_rebuildCommandBuffer) ? FramePassExecution::UpdateAndExecute : FramePassExecution::Execute;
|
||||||
});
|
});
|
||||||
|
|
||||||
depthPrepass.SetCommandCallback([this](CommandBufferBuilder& builder, const Recti& /*renderRect*/)
|
depthPrepass.SetCommandCallback([this](CommandBufferBuilder& builder, const FramePassEnvironment& /*env*/)
|
||||||
{
|
{
|
||||||
Recti viewport = m_viewer->GetViewport();
|
Recti viewport = m_viewer->GetViewport();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -532,10 +532,10 @@ namespace Nz
|
||||||
mergePass.AddOutput(renderTargetData.finalAttachment);
|
mergePass.AddOutput(renderTargetData.finalAttachment);
|
||||||
mergePass.SetClearColor(0, Color::Black);
|
mergePass.SetClearColor(0, Color::Black);
|
||||||
|
|
||||||
mergePass.SetCommandCallback([&targetViewers](CommandBufferBuilder& builder, const Recti& renderRect)
|
mergePass.SetCommandCallback([&targetViewers](CommandBufferBuilder& builder, const Nz::FramePassEnvironment& env)
|
||||||
{
|
{
|
||||||
builder.SetScissor(renderRect);
|
builder.SetScissor(env.renderRect);
|
||||||
builder.SetViewport(renderRect);
|
builder.SetViewport(env.renderRect);
|
||||||
|
|
||||||
Graphics* graphics = Graphics::Instance();
|
Graphics* graphics = Graphics::Instance();
|
||||||
builder.BindPipeline(*graphics->GetBlitPipeline(false));
|
builder.BindPipeline(*graphics->GetBlitPipeline(false));
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ namespace Nz
|
||||||
return (m_rebuildCommandBuffer) ? FramePassExecution::UpdateAndExecute : FramePassExecution::Execute;
|
return (m_rebuildCommandBuffer) ? FramePassExecution::UpdateAndExecute : FramePassExecution::Execute;
|
||||||
});
|
});
|
||||||
|
|
||||||
forwardPass.SetCommandCallback([this](CommandBufferBuilder& builder, const Recti& /*renderRect*/)
|
forwardPass.SetCommandCallback([this](CommandBufferBuilder& builder, const FramePassEnvironment& /*env*/)
|
||||||
{
|
{
|
||||||
Recti viewport = m_viewer->GetViewport();
|
Recti viewport = m_viewer->GetViewport();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ namespace Nz::ShaderAst
|
||||||
DependencyCheckerVisitor usageChecker;
|
DependencyCheckerVisitor usageChecker;
|
||||||
};
|
};
|
||||||
|
|
||||||
StatementPtr EliminateUnusedPassVisitor::Process(Statement& statement)
|
StatementPtr EliminateUnusedPassVisitor::Process(Statement& statement, const Config& config)
|
||||||
{
|
{
|
||||||
Context context;
|
Context context(config);
|
||||||
statement.Visit(context.usageChecker);
|
statement.Visit(context.usageChecker);
|
||||||
context.usageChecker.Resolve();
|
context.usageChecker.Resolve();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2271,7 +2271,21 @@ namespace Nz::ShaderAst
|
||||||
TypeMustMatch(resolvedType, GetExpressionType(*node.initialExpression));
|
TypeMustMatch(resolvedType, GetExpressionType(*node.initialExpression));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_context->options.makeVariableNameUnique && FindIdentifier(node.varName) != nullptr)
|
node.varIndex = RegisterVariable(node.varName, resolvedType);
|
||||||
|
node.varType = std::move(resolvedType);
|
||||||
|
|
||||||
|
if (m_context->options.makeVariableNameUnique)
|
||||||
|
{
|
||||||
|
// Since we are registered, FindIdentifier will find us
|
||||||
|
auto IgnoreOurself = [varIndex = *node.varIndex](const Identifier& identifier)
|
||||||
|
{
|
||||||
|
if (identifier.type == Identifier::Type::Variable && identifier.index == varIndex)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (FindIdentifier(node.varName, IgnoreOurself) != nullptr)
|
||||||
{
|
{
|
||||||
// Try to make variable name unique by appending _X to its name (incrementing X until it's unique) to the variable name until by incrementing X
|
// Try to make variable name unique by appending _X to its name (incrementing X until it's unique) to the variable name until by incrementing X
|
||||||
unsigned int cloneIndex = 2;
|
unsigned int cloneIndex = 2;
|
||||||
|
|
@ -2280,13 +2294,11 @@ namespace Nz::ShaderAst
|
||||||
{
|
{
|
||||||
candidateName = node.varName + "_" + std::to_string(cloneIndex++);
|
candidateName = node.varName + "_" + std::to_string(cloneIndex++);
|
||||||
}
|
}
|
||||||
while (FindIdentifier(candidateName) != nullptr);
|
while (FindIdentifier(candidateName, IgnoreOurself) != nullptr);
|
||||||
|
|
||||||
node.varName = std::move(candidateName);
|
node.varName = std::move(candidateName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
node.varIndex = RegisterVariable(node.varName, resolvedType);
|
|
||||||
node.varType = std::move(resolvedType);
|
|
||||||
|
|
||||||
SanitizeIdentifier(node.varName);
|
SanitizeIdentifier(node.varName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,8 +180,12 @@ namespace Nz
|
||||||
{
|
{
|
||||||
ShaderAst::StatementPtr tempAst;
|
ShaderAst::StatementPtr tempAst;
|
||||||
|
|
||||||
|
ShaderAst::EliminateUnusedPassVisitor::Config eliminateUnunsedConfig;
|
||||||
|
if (shaderStage)
|
||||||
|
eliminateUnunsedConfig.usedShaderStages = *shaderStage;
|
||||||
|
|
||||||
tempAst = ShaderAst::PropagateConstants(*targetAst);
|
tempAst = ShaderAst::PropagateConstants(*targetAst);
|
||||||
optimizedAst = ShaderAst::EliminateUnusedPass(*tempAst);
|
optimizedAst = ShaderAst::EliminateUnusedPass(*tempAst, eliminateUnunsedConfig);
|
||||||
|
|
||||||
targetAst = optimizedAst.get();
|
targetAst = optimizedAst.get();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,10 @@ namespace Nz
|
||||||
|
|
||||||
bool VulkanDevice::IsTextureFormatSupported(PixelFormat format, TextureUsage usage) const
|
bool VulkanDevice::IsTextureFormatSupported(PixelFormat format, TextureUsage usage) const
|
||||||
{
|
{
|
||||||
|
VkFormat vulkanFormat = ToVulkan(format);
|
||||||
|
if (vulkanFormat == VK_FORMAT_UNDEFINED)
|
||||||
|
return false;
|
||||||
|
|
||||||
VkFormatFeatureFlags flags = 0;
|
VkFormatFeatureFlags flags = 0;
|
||||||
switch (usage)
|
switch (usage)
|
||||||
{
|
{
|
||||||
|
|
@ -116,7 +120,7 @@ namespace Nz
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormatProperties formatProperties = GetInstance().GetPhysicalDeviceFormatProperties(GetPhysicalDevice(), ToVulkan(format));
|
VkFormatProperties formatProperties = GetInstance().GetPhysicalDeviceFormatProperties(GetPhysicalDevice(), vulkanFormat);
|
||||||
return formatProperties.optimalTilingFeatures & flags; //< Assume optimal tiling
|
return formatProperties.optimalTilingFeatures & flags; //< Assume optimal tiling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,9 @@ package("qt5widgets")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
on_fetch(function (package)
|
on_fetch(function (package)
|
||||||
print("on_fetch")
|
|
||||||
local base = package:dep("qt5base")
|
local base = package:dep("qt5base")
|
||||||
local qt = base:data("qtdir")
|
local qt = base:data("qtdir")
|
||||||
if not qt then
|
if not qt then
|
||||||
print("nani")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
13
xmake.lua
13
xmake.lua
|
|
@ -107,6 +107,7 @@ NazaraModules = modules
|
||||||
|
|
||||||
includes("xmake/**.lua")
|
includes("xmake/**.lua")
|
||||||
|
|
||||||
|
set_project("NazaraEngine")
|
||||||
set_xmakever("2.6.3")
|
set_xmakever("2.6.3")
|
||||||
|
|
||||||
add_repositories("local-repo xmake-repo")
|
add_repositories("local-repo xmake-repo")
|
||||||
|
|
@ -117,13 +118,17 @@ add_requires("libvorbis", { configs = { with_vorbisenc = false } })
|
||||||
add_requires("openal-soft", { configs = { shared = true }})
|
add_requires("openal-soft", { configs = { shared = true }})
|
||||||
add_requires("newtondynamics", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux
|
add_requires("newtondynamics", { debug = is_plat("windows") and is_mode("debug") }) -- Newton doesn't like compiling in Debug on Linux
|
||||||
|
|
||||||
set_project("NazaraEngine")
|
add_rules("mode.asan", "mode.debug", "mode.releasedbg")
|
||||||
|
|
||||||
add_rules("mode.asan", "mode.coverage", "mode.debug", "mode.releasedbg")
|
|
||||||
add_rules("plugin.vsxmake.autoupdate")
|
add_rules("plugin.vsxmake.autoupdate")
|
||||||
add_rules("build_rendererplugins")
|
add_rules("build_rendererplugins")
|
||||||
|
|
||||||
set_allowedmodes("debug", "releasedbg", "asan", "coverage")
|
if is_plat("windows") then
|
||||||
|
set_allowedmodes("debug", "releasedbg", "asan")
|
||||||
|
else
|
||||||
|
set_allowedmodes("debug", "releasedbg", "asan", "coverage")
|
||||||
|
add_rules("mode.coverage")
|
||||||
|
end
|
||||||
|
|
||||||
set_allowedplats("windows", "mingw", "linux", "macosx")
|
set_allowedplats("windows", "mingw", "linux", "macosx")
|
||||||
set_allowedarchs("windows|x64", "mingw|x86_64", "linux|x86_64", "macosx|x86_64")
|
set_allowedarchs("windows|x64", "mingw|x86_64", "linux|x86_64", "macosx|x86_64")
|
||||||
set_defaultmode("debug")
|
set_defaultmode("debug")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue