Skip to content

Commit 24ab57e

Browse files
committed
合并upstream代码
2 parents 1515e39 + 65352a9 commit 24ab57e

File tree

141 files changed

+2528
-596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2528
-596
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ jobs:
3535
if: runner.os == 'macOS'
3636

3737
- name: Checkout Repo
38-
uses: actions/checkout@v2
38+
uses: actions/checkout@v4
3939

4040
- name: Setup cmake
4141
uses: jwlawson/actions-setup-cmake@v2
4242
with:
4343
cmake-version: ${{env.CMAKE_VERSION}}
4444

4545
- name: Update Cache Files
46-
uses: actions/cache@v2
46+
uses: actions/cache@v4
4747
with:
4848
path: ${{github.workspace}}/ThirdParty/Zip
4949
key: ${{runner.os}}-3rd-zip

Editor/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
2828
)
2929
endif ()
3030

31+
# ---- begin shaders ---------------------------------------------------------------------------------
32+
GetEngineShaderResources(
33+
NAME Editor
34+
OUTPUT EDITOR_RESOURCES
35+
)
36+
37+
file(GLOB_RECURSE SHADERS Shader/*.es*)
38+
foreach (SHADER ${SHADERS})
39+
get_filename_component(SHADER_ABSOLUTE ${SHADER} ABSOLUTE)
40+
string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/Shader ../Shader/Editor COPY_DST ${SHADER_ABSOLUTE})
41+
list(APPEND EDITOR_RESOURCES ${SHADER}->${COPY_DST})
42+
endforeach ()
43+
44+
AddResourcesCopyCommand(
45+
NAME Editor
46+
RES ${EDITOR_RESOURCES}
47+
)
48+
# ---- end shaders -----------------------------------------------------------------------------------
49+
50+
51+
# ---- begin qml -------------------------------------------------------------------------------------
3152
set(EDITOR_QML_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Qml)
3253
set(EDITOR_RESOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/Qml/Resource)
3354
get_filename_component(EDITOR_RESOURCE_ROOT_ABSOLUTE ${EDITOR_RESOURCE_ROOT} ABSOLUTE)
@@ -62,3 +83,4 @@ qt_add_qml_module(
6283
RESOURCES ${RESOURCES}
6384
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Generated/QmlModule
6485
)
86+
# ---- end qml ---------------------------------------------------------------------------------------
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// Created by Kindem on 2025/3/16.
3+
//
4+
5+
#pragma once
6+
7+
#include <QWidget>
8+
#include <QBoxLayout>
9+
10+
#include <Render/ShaderCompiler.h>
11+
#include <Editor/Widget/GraphicsWidget.h>
12+
13+
namespace Editor {
14+
class GraphicsSampleWidget final : public GraphicsWidget {
15+
Q_OBJECT
16+
17+
public:
18+
explicit GraphicsSampleWidget(QWidget* inParent = nullptr);
19+
~GraphicsSampleWidget() override;
20+
21+
protected:
22+
void resizeEvent(QResizeEvent* event) override;
23+
24+
private:
25+
static constexpr uint8_t swapChainTextureNum = 2;
26+
27+
void RecreateSwapChain(uint32_t inWidth, uint32_t inHeight);
28+
void DispatchFrame() const;
29+
void DrawFrame() const;
30+
31+
Common::UniquePtr<RHI::Semaphore> imageReadySemaphore;
32+
Common::UniquePtr<RHI::Semaphore> renderFinishedSemaphore;
33+
Common::UniquePtr<RHI::Fence> frameFence;
34+
Common::UniquePtr<RHI::SwapChain> swapChain;
35+
std::array<RHI::Texture*, 2> swapChainTextures;
36+
std::array<Common::UniquePtr<RHI::TextureView>, 2> swapChainTextureViews;
37+
Render::ShaderCompileOutput vsCompileOutput;
38+
Render::ShaderCompileOutput psCompileOutput;
39+
Common::UniquePtr<RHI::ShaderModule> vsModule;
40+
Common::UniquePtr<RHI::ShaderModule> psModule;
41+
Common::UniquePtr<RHI::BindGroupLayout> bindGroupLayout;
42+
Common::UniquePtr<RHI::PipelineLayout> pipelineLayout;
43+
Common::UniquePtr<RHI::RasterPipeline> pipeline;
44+
Common::UniquePtr<RHI::Buffer> vertexBuffer;
45+
Common::UniquePtr<RHI::BufferView> vertexBufferView;
46+
Common::UniquePtr<RHI::Buffer> uniformBuffer;
47+
Common::UniquePtr<RHI::BufferView> uniformBufferView;
48+
Common::UniquePtr<RHI::BindGroup> bindGroup;
49+
Common::UniquePtr<RHI::CommandBuffer> commandBuffer;
50+
Common::UniquePtr<Common::WorkerThread> drawThread;
51+
std::atomic_bool running;
52+
};
53+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Created by Kindem on 2025/3/16.
3+
//
4+
5+
#pragma once
6+
7+
#include <QWidget>
8+
#include <QTimer>
9+
10+
#include <Common/Memory.h>
11+
#include <RHI/RHI.h>
12+
13+
namespace Editor {
14+
class GraphicsWidget : public QWidget {
15+
Q_OBJECT
16+
17+
public:
18+
explicit GraphicsWidget(QWidget* inParent = nullptr);
19+
~GraphicsWidget() override;
20+
21+
RHI::Device& GetDevice() const;
22+
RHI::Surface& GetSurface() const;
23+
24+
protected:
25+
QPaintEngine* paintEngine() const override;
26+
27+
void WaitDeviceIdle() const;
28+
29+
RHI::Device* device;
30+
Common::UniquePtr<RHI::Surface> surface;
31+
};
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <Platform.esh>
2+
3+
struct FragmentInput {
4+
float4 position : SV_POSITION;
5+
float4 color : COLOR;
6+
};
7+
8+
#if VERTEX_SHADER
9+
cbuffer vsUniform {
10+
float3 vertexColor;
11+
};
12+
13+
FragmentInput VSMain(
14+
uint vertexId : SV_VertexID,
15+
VkLocation(0) float3 position : POSITION)
16+
{
17+
FragmentInput fragmentInput;
18+
fragmentInput.position = float4(position.xyz, 1.0f);
19+
#if VULKAN
20+
fragmentInput.position.y = - fragmentInput.position.y;
21+
#endif
22+
23+
fragmentInput.color = float4(0.0f, 0.0f, 0.0f, 1.0f);
24+
fragmentInput.color[vertexId % 3] = vertexColor[vertexId % 3];
25+
return fragmentInput;
26+
}
27+
#endif
28+
29+
#if PIXEL_SHADER
30+
float4 PSMain(FragmentInput input) : SV_TARGET
31+
{
32+
return input.color;
33+
}
34+
#endif

Editor/Src/Main.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@
1010
#include <Editor/Widget/WidgetSamples.h>
1111

1212
#if BUILD_CONFIG_DEBUG
13-
static ::Core::CmdlineArgValue<bool> caRunSample(
13+
#include <Editor/Widget/GraphicsSampleWidget.h>
14+
15+
static Core::CmdlineArgValue<bool> caGraphicsWindowSample(
16+
"graphicsSample", "-graphicsSample", false,
17+
"Whether to run graphics sample instead of editor");
18+
19+
static Core::CmdlineArgValue<bool> caRunSample(
1420
"widgetSamples", "-widgetSamples", false,
1521
"Whether to run widget samples instead of editor");
1622
#endif
1723

18-
static ::Core::CmdlineArgValue<std::string> caRhiType(
24+
static Core::CmdlineArgValue<std::string> caRhiType(
1925
"rhiType", "-rhi", RHI::GetPlatformDefaultRHIAbbrString(),
2026
"rhi abbr string, can be 'dx12' or 'vulkan'");
2127

22-
static ::Core::CmdlineArgValue<std::string> caProjectRoot(
28+
static Core::CmdlineArgValue<std::string> caProjectRoot(
2329
"projectRoot", "-project", "",
2430
"project root path");
2531

@@ -54,7 +60,9 @@ int main(int argc, char* argv[])
5460

5561
Common::UniquePtr<QWidget> mainWidget;
5662
#if BUILD_CONFIG_DEBUG
57-
if (caRunSample.GetValue()) {
63+
if (caGraphicsWindowSample.GetValue()) {
64+
mainWidget = new Editor::GraphicsSampleWidget();
65+
} else if (caRunSample.GetValue()) {
5866
mainWidget = new Editor::WidgetSamples();
5967
} else
6068
#endif

0 commit comments

Comments
 (0)