Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batchgroup from material templates #219

Merged
merged 43 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8ade776
Fix Im3D getting rendered into the non-GUI buffer.
Duttenheim May 6, 2024
70722a0
Move BatchGroup to material template compilation.
Duttenheim May 6, 2024
be3efc6
Fix build and testviewer bug
Duttenheim May 7, 2024
20f336c
Fix linux build
Duttenheim May 7, 2024
b7d5232
Frame scripts are now in code
Duttenheim Aug 5, 2024
340330d
Fixes
Duttenheim Aug 5, 2024
a242ccd
Fix build for tests
Duttenheim Aug 5, 2024
645ea1c
Fix linux build
Duttenheim Aug 6, 2024
bcd5d22
Fix extern inline for linux build
Duttenheim Aug 6, 2024
81f016e
Fix for framescript generation
Duttenheim Aug 6, 2024
89cb8c4
Support resize with the new framescript system
Duttenheim Aug 7, 2024
b72b3f9
Fix memory leaks
Duttenheim Aug 10, 2024
694a497
Fix UI related stuff
Duttenheim Aug 10, 2024
ccc95bb
More memleaks squashed
Duttenheim Aug 10, 2024
7ff34d0
Add R9G9B9E5 pixel format
Duttenheim Aug 10, 2024
4a59e7f
Another memleak
Duttenheim Aug 10, 2024
990fe75
Move swap to async compute
Duttenheim Aug 10, 2024
7e8a1b5
Remove unnecessary copies
Duttenheim Aug 10, 2024
bfd0675
Add frame script for editor
Duttenheim Aug 12, 2024
9987640
Editor hacks
Duttenheim Aug 12, 2024
5fc8e9d
Added support for viewports in shaders
Duttenheim Aug 12, 2024
bab97ee
Fix selection and 0 sized viewport
Duttenheim Aug 12, 2024
b007a49
Remove unused render target
Duttenheim Aug 12, 2024
ee2005f
Misc fixes
Duttenheim Aug 12, 2024
183b9f9
Fix build
Duttenheim Aug 12, 2024
cec5d2c
Fix build
Duttenheim Aug 12, 2024
64ddc62
Fix validation errors
Duttenheim Aug 13, 2024
1d382a4
Make sure editor frame script resets all dependencies
Duttenheim Aug 13, 2024
f7f9cd0
Add queue markers for submission types
Duttenheim Aug 14, 2024
9c96720
Better submission order
Duttenheim Aug 14, 2024
d0a768e
Fix problem with high DPI monitors
Duttenheim Aug 15, 2024
8d05fe0
Move command buffer creation for swapchain commands to the swapchain
Duttenheim Aug 15, 2024
27d57d9
Revert use of R9G9B9E5 texture for render targets because it's not su…
Duttenheim Aug 15, 2024
6025140
Better queue handling
Duttenheim Aug 15, 2024
2f2730d
Working on a more efficient bloom
Duttenheim Aug 15, 2024
1189ea2
Trippled bloom performance
Duttenheim Aug 15, 2024
6d1ed38
Fix bloom half pixel offset error and change kernel sizes to 256
Duttenheim Aug 16, 2024
7f72be6
Fix queue setup for empty queues
Duttenheim Aug 16, 2024
242a349
Fix viewport for blur shader
Duttenheim Aug 16, 2024
ffa8b44
Remove unnecessary sync
Duttenheim Aug 16, 2024
09ad550
Fix queues not being correctly setup as unique.
Duttenheim Aug 16, 2024
47aff75
Bundle submissions on queue again
Duttenheim Aug 16, 2024
d27cab4
Change submission order (just to remove bogus validation error)
Duttenheim Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions code/addons/dynui/im3d/im3dcontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "frame/framecode.h"
#include "imgui.h"

#include "frame/default.h"

using namespace Math;
using namespace CoreGraphics;
using namespace Graphics;
Expand Down Expand Up @@ -106,8 +108,6 @@ struct Im3dState
Ptr<Im3dInputHandler> inputHandler;
Im3d::Id depthLayerId;
byte* vertexPtr;

Memory::ArenaAllocator<sizeof(Frame::FrameCode)> frameOpAllocator;
};
static Im3dState imState;

Expand Down Expand Up @@ -167,35 +167,34 @@ Im3dContext::Create()
// map buffer
imState.vertexPtr = (byte*)CoreGraphics::BufferMap(imState.vbo);

Frame::FrameCode* op = imState.frameOpAllocator.Alloc<Frame::FrameCode>();
op->domain = CoreGraphics::BarrierDomain::Pass;
op->func = [](const CoreGraphics::CmdBufferId cmdBuf, const IndexT frame, const IndexT bufferIndex)
FrameScript_default::RegisterSubgraph_Im3D_Pass([](const CoreGraphics::CmdBufferId cmdBuf, const Math::rectangle<int>& viewport, const IndexT frame, const IndexT bufferIndex)
{
Render(cmdBuf, frame);
};
op->buildFunc = [](const CoreGraphics::PassId pass, const uint subpass)
});
FrameScript_default::RegisterSubgraphPipelines_Im3D_Pass([](const CoreGraphics::PassId pass, const uint subpass)
{
if (imState.linesPipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(imState.linesPipeline);
imState.linesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.lines, pass, subpass, CoreGraphics::InputAssemblyKey{CoreGraphics::PrimitiveTopology::LineList, false} });
imState.linesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.lines, pass, subpass, CoreGraphics::InputAssemblyKey{ CoreGraphics::PrimitiveTopology::LineList, false } });

if (imState.depthLinesPipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(imState.depthLinesPipeline);
imState.depthLinesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.depthLines, pass, subpass, CoreGraphics::InputAssemblyKey{CoreGraphics::PrimitiveTopology::LineList, false} });
imState.depthLinesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.depthLines, pass, subpass, CoreGraphics::InputAssemblyKey{ CoreGraphics::PrimitiveTopology::LineList, false } });

if (imState.trianglesPipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(imState.trianglesPipeline);
imState.trianglesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.triangles, pass, subpass, CoreGraphics::InputAssemblyKey{CoreGraphics::PrimitiveTopology::TriangleList, false} });
imState.trianglesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.triangles, pass, subpass, CoreGraphics::InputAssemblyKey{ CoreGraphics::PrimitiveTopology::TriangleList, false } });

if (imState.depthTrianglesPipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(imState.depthTrianglesPipeline);
imState.depthTrianglesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.depthTriangles, pass, subpass, CoreGraphics::InputAssemblyKey{CoreGraphics::PrimitiveTopology::TriangleList, false} });
imState.depthTrianglesPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.depthTriangles, pass, subpass, CoreGraphics::InputAssemblyKey{ CoreGraphics::PrimitiveTopology::TriangleList, false } });

if (imState.pointsPipeline != CoreGraphics::InvalidPipelineId)
CoreGraphics::DestroyGraphicsPipeline(imState.pointsPipeline);
imState.pointsPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.points, pass, subpass, CoreGraphics::InputAssemblyKey{CoreGraphics::PrimitiveTopology::PointList, false} });
};
Frame::AddSubgraph("Im3D", { op });
imState.pointsPipeline = CoreGraphics::CreateGraphicsPipeline({ imState.points, pass, subpass, CoreGraphics::InputAssemblyKey{ CoreGraphics::PrimitiveTopology::PointList, false } });
});
Im3d::NewFrame();

}

//------------------------------------------------------------------------------
Expand All @@ -204,7 +203,6 @@ Im3dContext::Create()
void
Im3dContext::Discard()
{
imState.frameOpAllocator.Release();
Input::InputServer::Instance()->RemoveInputHandler(imState.inputHandler.upcast<InputHandler>());
imState.inputHandler = nullptr;
CoreGraphics::BufferUnmap(imState.vbo);
Expand Down Expand Up @@ -368,14 +366,6 @@ Im3dContext::DrawSphere(const Math::point& pos, float radius, const Math::vec4&
Im3d::PopDrawState();
}

//------------------------------------------------------------------------------
/**
*/
void
Im3dContext::NewFrame(const Graphics::FrameContext& ctx)
{
Im3d::NewFrame();
}

//------------------------------------------------------------------------------
/**
Expand All @@ -385,10 +375,11 @@ Im3dContext::OnPrepareView(const Ptr<Graphics::View>& view, const Graphics::Fram
{
AppData& ad = GetAppData();

const Math::rectangle<int>& viewport = view->GetViewport();

ad.m_deltaTime = ctx.frameTime;
SetGizmoSize(128, 4);
auto const & mode = CoreGraphics::WindowGetDisplayMode(CurrentWindow);
ad.m_viewportSize = Vec2((float)mode.GetWidth(), (float)mode.GetHeight());
ad.m_viewportSize = Vec2((float)viewport.width(), (float)viewport.height());

Graphics::GraphicsEntityId cam = view->GetCamera();
Math::mat4 transform = inverse(CameraContext::GetView(cam));
Expand Down Expand Up @@ -535,6 +526,7 @@ Im3dContext::Render(const CoreGraphics::CmdBufferId cmdBuf, const IndexT frameIn
[](Im3d::DrawList const& l) { return l.m_primType == Im3d::DrawPrimitive_Triangles && l.m_layerId == imState.depthLayerId; });

CoreGraphics::BufferFlush(imState.vbo);
Im3d::NewFrame();
}

//------------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions code/addons/dynui/im3d/im3dcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ class Im3dContext : public Graphics::GraphicsContext
/// draw a cone
static void DrawCone(const Math::mat4& modelTransform, const Math::vec4& color, uint32_t renderFlags = CheckDepth | Wireframe);

/// Start a new Im3d frame
static void NewFrame(const Graphics::FrameContext& ctx);

/// called before frame
static void OnPrepareView(const Ptr<Graphics::View>& view, const Graphics::FrameContext& ctx);
/// called when rendering a frame batch
Expand Down
6 changes: 3 additions & 3 deletions code/addons/dynui/im3d/shaders/im3d.fx
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ gsMain(
vec2 pos1 = gl_in[1].gl_Position.xy / gl_in[1].gl_Position.w;

vec2 dir = pos0 - pos1;
dir = normalize(vec2(dir.x, dir.y * RenderTargetDimensions[0].y * RenderTargetDimensions[0].z)); // correct for aspect ratio
dir = normalize(vec2(dir.x, dir.y * RenderTargetParameter[0].Dimensions.y * RenderTargetParameter[0].Dimensions.z)); // correct for aspect ratio
vec2 tng0 = vec2(-dir.y, dir.x);
vec2 tng1 = tng0 * size[1] * RenderTargetDimensions[0].zw;
tng0 = tng0 * size[0] * RenderTargetDimensions[0].zw;
vec2 tng1 = tng0 * size[1] * RenderTargetParameter[0].Dimensions.zw;
tng0 = tng0 * size[0] * RenderTargetParameter[0].Dimensions.zw;

// line start
gl_Position = vec4((pos0 - tng0) * gl_in[0].gl_Position.w, gl_in[0].gl_Position.zw);
Expand Down
Loading
Loading