-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEffectDesignerWindow.xaml.h
More file actions
80 lines (67 loc) · 3.55 KB
/
Copy pathEffectDesignerWindow.xaml.h
File metadata and controls
80 lines (67 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include "EffectDesignerWindow.g.h"
#include "Graph/EffectNode.h"
#include "Effects/ShaderCompiler.h"
#include "Effects/CustomPixelShaderEffect.h"
#include "Effects/CustomComputeShaderEffect.h"
namespace winrt::ShaderLab::implementation
{
struct EffectDesignerWindow : EffectDesignerWindowT<EffectDesignerWindow>
{
EffectDesignerWindow();
// Callback to add/update a custom effect node in the main window's graph.
using AddToGraphCallback = std::function<uint32_t(::ShaderLab::Graph::EffectNode)>;
using UpdateInGraphCallback = std::function<void(uint32_t, ::ShaderLab::Graph::CustomEffectDefinition)>;
void SetAddToGraphCallback(AddToGraphCallback cb) { m_addToGraph = std::move(cb); }
void SetUpdateInGraphCallback(UpdateInGraphCallback cb) { m_updateInGraph = std::move(cb); }
// Load an existing custom effect definition for editing.
void LoadDefinition(uint32_t nodeId, const ::ShaderLab::Graph::CustomEffectDefinition& def,
const std::wstring& nodeName = L"");
private:
void OnGenerateScaffold(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
void OnCompile(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
void OnAddToGraph(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
void OnUpdateInGraph(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
void OnShaderTypeChanged(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::Controls::SelectionChangedEventArgs const& args);
void OnAddInput(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
void OnAddParam(
winrt::Windows::Foundation::IInspectable const& sender,
winrt::Microsoft::UI::Xaml::RoutedEventArgs const& args);
// Append one Typed Analysis field row to AnalysisFieldsPanel and
// return it. Used by both the "+ Add Field" button click handler
// and LoadDefinition (when restoring fields from a saved or
// built-in effect definition).
winrt::Microsoft::UI::Xaml::Controls::StackPanel AppendAnalysisFieldRow();
// Build a CustomEffectDefinition from the current UI state.
::ShaderLab::Graph::CustomEffectDefinition BuildDefinition();
// Generate HLSL scaffold from the current definition.
std::wstring GenerateHlsl(const ::ShaderLab::Graph::CustomEffectDefinition& def);
// Compile the current HLSL and update status.
bool CompileHlsl(::ShaderLab::Graph::CustomEffectDefinition& def);
// Format HLSL source for readability.
static std::wstring FormatHlsl(const std::wstring& source);
::ShaderLab::Effects::ShaderCompiler m_compiler;
AddToGraphCallback m_addToGraph;
UpdateInGraphCallback m_updateInGraph;
uint32_t m_editingNodeId{ 0 }; // Non-zero when editing an existing node.
std::vector<uint8_t> m_lastBytecode;
};
}
namespace winrt::ShaderLab::factory_implementation
{
struct EffectDesignerWindow : EffectDesignerWindowT<EffectDesignerWindow, implementation::EffectDesignerWindow>
{
};
}