Skip to content

Commit d40780c

Browse files
committed
-Dev: new 'render' module added with new logic for handling gpu resources
1 parent 37f8c26 commit d40780c

File tree

88 files changed

+4330
-4146
lines changed

Some content is hidden

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

88 files changed

+4330
-4146
lines changed

.clang-format

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ BinPackArguments: false
88
BinPackParameters: false
99

1010
# Column limit to trigger line wrapping
11-
ColumnLimit: 160 # Adjust as needed; lower value ensures more wrapping
11+
# ColumnLimit: 160 # Adjust as needed; lower value ensures more wrapping
1212

1313
IndentWidth: 4
1414
TabWidth: 4
1515
UseTab: Never # Ensures spaces are used instead of tabs
1616

1717
# Break function declarations and calls over multiple lines if they exceed the ColumnLimit
1818
AllowAllParametersOfDeclarationOnNextLine: false
19-
AllowShortFunctionsOnASingleLine: None
19+
# AllowShortFunctionsOnASingleLine: None
2020
AlwaysBreakAfterReturnType: None
2121
BreakConstructorInitializers: BeforeComma
2222
PenaltyBreakBeforeFirstCallParameter: 0
@@ -37,3 +37,14 @@ BraceWrapping:
3737
SplitEmptyRecord: true
3838

3939

40+
IndentCaseLabels: true
41+
42+
# Other convinient flags same than previous clang-format
43+
44+
SpaceBeforeCpp11BracedList: true
45+
AccessModifierOffset: -4 # public, private, protected will be aligned with braces
46+
SpacesInParentheses: true
47+
ColumnLimit: 0 # Using around 120 would allow to split vertically 2 files, fitting in width ( also when merging conflicts comparing side by side ) but probably better to pick unlimited
48+
AllowShortBlocksOnASingleLine: Empty
49+
AllowShortFunctionsOnASingleLine: All
50+

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ set(ENGINE_SOURCES "src/utils.cpp" "src/common.cpp")
6060
set(ENGINE_HEADERS "")
6161
add_module_files(core ENGINE_SOURCES ENGINE_HEADERS)
6262
add_module_files(graphics ENGINE_SOURCES ENGINE_HEADERS)
63+
add_module_files(render ENGINE_SOURCES ENGINE_HEADERS)
6364
add_module_files(systems ENGINE_SOURCES ENGINE_HEADERS)
6465
add_module_files(tools ENGINE_SOURCES ENGINE_HEADERS)
6566
add_library(VulkanEngine STATIC ${ENGINE_SOURCES} ${ENGINE_HEADERS})

include/engine/core/materials/hair_strand.h

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace Core {
2020
/// Epic's Fitted Marschner Workflow. Only works with geometry defined as lines.
2121
class HairStrandMaterial : public IMaterial
2222
{
23-
protected:
24-
Vec4 m_baseColor = {0.27f, 0.14f, 0.04f, 1.0f}; // w for opacity
23+
protected:
24+
Vec4 m_baseColor = { 0.27f, 0.14f, 0.04f, 1.0f }; // w for opacity
2525

2626
float m_thickness = 0.003f;
2727

@@ -47,53 +47,53 @@ class HairStrandMaterial : public IMaterial
4747

4848
std::unordered_map<int, bool> m_textureBindingState;
4949

50-
virtual Graphics::MaterialUniforms get_uniforms() const;
50+
virtual IMaterial::GPUPayload get_uniforms() const;
5151
virtual inline std::unordered_map<int, ITexture*> get_textures() const {
5252
return m_textures;
5353
}
5454

5555
virtual std::unordered_map<int, bool> get_texture_binding_state() const {
5656
return m_textureBindingState;
5757
}
58-
virtual void set_texture_binding_state(int id, bool state) {
58+
virtual void set_texture_binding_state( int id, bool state ) {
5959
m_textureBindingState[id] = state;
6060
}
6161

62-
HairStrandMaterial(Vec4 baseColor, MaterialSettings params, std::string shaderPassID)
63-
: IMaterial(shaderPassID, params)
64-
, m_baseColor(baseColor) {
62+
HairStrandMaterial( Vec4 baseColor, MaterialSettings params, std::string shaderPassID )
63+
: IMaterial( shaderPassID, params )
64+
, m_baseColor( baseColor ) {
6565
}
6666

67-
public:
68-
HairStrandMaterial(Vec4 baseColor = Vec4(1.0f, 1.0f, 0.5f, 1.0f))
69-
: IMaterial("hairstr")
70-
, m_baseColor(baseColor) {
67+
public:
68+
HairStrandMaterial( Vec4 baseColor = Vec4( 1.0f, 1.0f, 0.5f, 1.0f ) )
69+
: IMaterial( "hairstr" )
70+
, m_baseColor( baseColor ) {
7171
}
72-
HairStrandMaterial(Vec4 baseColor, MaterialSettings params)
73-
: IMaterial("hairstr", params)
74-
, m_baseColor(baseColor) {
72+
HairStrandMaterial( Vec4 baseColor, MaterialSettings params )
73+
: IMaterial( "hairstr", params )
74+
, m_baseColor( baseColor ) {
7575
}
7676

7777
inline Vec3 get_base_color() const {
78-
return Vec3(m_baseColor);
78+
return Vec3( m_baseColor );
7979
}
80-
inline void set_base_color(Vec3 c) {
81-
m_baseColor = Vec4(c, m_baseColor.w);
80+
inline void set_base_color( Vec3 c ) {
81+
m_baseColor = Vec4( c, m_baseColor.w );
8282
m_isDirty = true;
8383
}
8484

8585
float get_thickness() const {
8686
return m_thickness;
8787
}
88-
void set_thickness(float thickness) {
88+
void set_thickness( float thickness ) {
8989
m_thickness = thickness;
9090
}
9191

9292
// Primary reflection toggle
9393
bool get_R() const {
9494
return m_R;
9595
}
96-
void set_R(bool R) {
96+
void set_R( bool R ) {
9797
m_R = R;
9898
m_isDirty = true;
9999
}
@@ -102,7 +102,7 @@ class HairStrandMaterial : public IMaterial
102102
float get_Rpower() const {
103103
return m_Rpower;
104104
}
105-
void set_Rpower(float Rpower) {
105+
void set_Rpower( float Rpower ) {
106106
m_Rpower = Rpower;
107107
m_isDirty = true;
108108
}
@@ -111,15 +111,15 @@ class HairStrandMaterial : public IMaterial
111111
bool get_TT() const {
112112
return m_TT;
113113
}
114-
void set_TT(bool TT) {
114+
void set_TT( bool TT ) {
115115
m_TT = TT;
116116
}
117117

118118
// Transmitance reflection scale
119119
float get_TTpower() const {
120120
return m_TTpower;
121121
}
122-
void set_TTpower(float TTpower) {
122+
void set_TTpower( float TTpower ) {
123123
m_TTpower = TTpower;
124124
m_isDirty = true;
125125
}
@@ -128,79 +128,79 @@ class HairStrandMaterial : public IMaterial
128128
bool get_TRT() const {
129129
return m_TRT;
130130
}
131-
void set_TRT(bool TRT) {
131+
void set_TRT( bool TRT ) {
132132
m_TRT = TRT;
133133
}
134134

135135
// Secoundary reflection scale
136136
float get_TRTpower() const {
137137
return m_TRTpower;
138138
}
139-
void set_TRTpower(float TRTpower) {
139+
void set_TRTpower( float TRTpower ) {
140140
m_TRTpower = TRTpower;
141141
m_isDirty = true;
142142
}
143143

144144
float get_roughness() const {
145145
return m_roughness;
146146
}
147-
void set_roughness(float roughness) {
147+
void set_roughness( float roughness ) {
148148
m_roughness = roughness;
149149
m_isDirty = true;
150150
}
151151

152152
float get_scatter() const {
153153
return m_scatter;
154154
}
155-
void set_scatter(float scatter) {
155+
void set_scatter( float scatter ) {
156156
m_scatter = scatter;
157157
m_isDirty = true;
158158
}
159159

160160
float get_shift() const {
161161
return m_shift;
162162
}
163-
void set_shift(float shift) {
163+
void set_shift( float shift ) {
164164
m_shift = shift;
165165
m_isDirty = true;
166166
}
167167

168168
float get_ior() const {
169169
return m_ior;
170170
}
171-
void set_ior(float ior) {
171+
void set_ior( float ior ) {
172172
m_ior = ior;
173173
m_isDirty = true;
174174
}
175175

176176
bool get_glints() const {
177177
return m_glints;
178178
}
179-
void set_glints(bool glints) {
179+
void set_glints( bool glints ) {
180180
m_glints = glints;
181181
m_isDirty = true;
182182
}
183183

184184
bool get_useScatter() const {
185185
return m_useScatter;
186186
}
187-
void set_useScatter(bool useScatter) {
187+
void set_useScatter( bool useScatter ) {
188188
m_useScatter = useScatter;
189189
m_isDirty = true;
190190
}
191191

192192
bool get_coloredScatter() const {
193193
return m_coloredScatter;
194194
}
195-
void set_coloredScatter(bool coloredScatter) {
195+
void set_coloredScatter( bool coloredScatter ) {
196196
m_coloredScatter = coloredScatter;
197197
m_isDirty = true;
198198
}
199199

200200
bool get_occlusion() const {
201201
return m_occlusion;
202202
}
203-
void set_occlusion(bool occlusion) {
203+
void set_occlusion( bool occlusion ) {
204204
m_occlusion = occlusion;
205205
m_isDirty = true;
206206
}
@@ -228,13 +228,13 @@ class HairStrandMaterial2 : public HairStrandMaterial
228228
NGI_TRT = 5,
229229
};
230230

231-
std::unordered_map<int, ITexture*> m_textures{{N1, nullptr},
232-
{N2, nullptr},
233-
{GI, nullptr},
234-
{MGI, nullptr},
235-
{NGI, nullptr},
236-
{NGI_TRT, nullptr}};
237-
virtual Graphics::MaterialUniforms get_uniforms() const;
231+
std::unordered_map<int, ITexture*> m_textures { { N1, nullptr },
232+
{ N2, nullptr },
233+
{ GI, nullptr },
234+
{ MGI, nullptr },
235+
{ NGI, nullptr },
236+
{ NGI_TRT, nullptr } };
237+
virtual IMaterial::GPUPayload get_uniforms() const;
238238

239239
virtual inline std::unordered_map<int, ITexture*> get_textures() const {
240240
return m_textures;
@@ -243,13 +243,13 @@ class HairStrandMaterial2 : public HairStrandMaterial
243243
virtual std::unordered_map<int, bool> get_texture_binding_state() const {
244244
return m_textureBindingState;
245245
}
246-
virtual void set_texture_binding_state(int id, bool state) {
246+
virtual void set_texture_binding_state( int id, bool state ) {
247247
m_textureBindingState[id] = state;
248248
}
249249

250-
public:
251-
HairStrandMaterial2(HairPigmentType pigment = BLONDE)
252-
: HairStrandMaterial(Vec4(0.0), {}, "hairstr2") {
250+
public:
251+
HairStrandMaterial2( HairPigmentType pigment = BLONDE )
252+
: HairStrandMaterial( Vec4( 0.0 ), {}, "hairstr2" ) {
253253
// m_coloredScatter = true;
254254
// TextureSettings settings{};
255255
// settings.useMipmaps = false;

include/engine/core/materials/material.h

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include <engine/core/textures/texture.h>
1313
#include <engine/graphics/shaderpass.h>
14-
#include <engine/graphics/uniforms.h>
1514
#include <unordered_map>
1615

1716
VULKAN_ENGINE_NAMESPACE_BEGIN
@@ -29,7 +28,7 @@ struct MaterialSettings {
2928

3029
class IMaterial
3130
{
32-
protected:
31+
protected:
3332
MaterialSettings m_settings = {};
3433
std::string m_shaderPassID = {};
3534
Graphics::DescriptorSet m_textureDescriptor = {};
@@ -38,51 +37,61 @@ class IMaterial
3837

3938
friend class Renderer;
4039

41-
public:
40+
public:
4241
static IMaterial* debugMaterial;
4342

44-
IMaterial(std::string shaderPassID)
45-
: m_shaderPassID(shaderPassID) {
43+
IMaterial( std::string shaderPassID )
44+
: m_shaderPassID( shaderPassID ) {
4645
}
47-
IMaterial(std::string shaderPassID, MaterialSettings params)
48-
: m_shaderPassID(shaderPassID)
49-
, m_settings(params) {
46+
IMaterial( std::string shaderPassID, MaterialSettings params )
47+
: m_shaderPassID( shaderPassID )
48+
, m_settings( params ) {
5049
}
5150

5251
~IMaterial() {
5352
}
5453

55-
virtual Graphics::MaterialUniforms get_uniforms() const = 0;
56-
virtual std::unordered_map<int, ITexture*> get_textures() const = 0;
57-
virtual std::unordered_map<int, bool> get_texture_binding_state() const = 0;
58-
virtual void set_texture_binding_state(int id, bool state) = 0;
54+
struct GPUPayload {
55+
Vec4 dataSlot1;
56+
Vec4 dataSlot2;
57+
Vec4 dataSlot3;
58+
Vec4 dataSlot4;
59+
Vec4 dataSlot5;
60+
Vec4 dataSlot6;
61+
Vec4 dataSlot7;
62+
Vec4 dataSlot8;
63+
};
64+
virtual IMaterial::GPUPayload get_uniforms() const = 0;
65+
virtual std::unordered_map<int, ITexture*> get_textures() const = 0;
66+
virtual std::unordered_map<int, bool> get_texture_binding_state() const = 0;
67+
virtual void set_texture_binding_state( int id, bool state ) = 0;
5968

6069
virtual std::string get_shaderpass_ID() const {
6170
return m_shaderPassID;
6271
}
6372
virtual inline MaterialSettings get_parameters() const {
6473
return m_settings;
6574
}
66-
virtual void set_parameters(MaterialSettings p) {
75+
virtual void set_parameters( MaterialSettings p ) {
6776
m_settings = p;
6877
}
6978

70-
virtual inline void set_enable_culling(bool op) {
79+
virtual inline void set_enable_culling( bool op ) {
7180
m_settings.faceCulling = op;
7281
}
73-
virtual inline void set_culling_type(CullingMode t) {
82+
virtual inline void set_culling_type( CullingMode t ) {
7483
m_settings.culling = t;
7584
}
76-
virtual inline void enable_depth_test(bool op) {
85+
virtual inline void enable_depth_test( bool op ) {
7786
m_settings.depthTest = op;
7887
}
79-
virtual inline void enable_depth_writes(bool op) {
88+
virtual inline void enable_depth_writes( bool op ) {
8089
m_settings.depthWrite = op;
8190
}
82-
virtual inline void enable_alpha_test(bool op) {
91+
virtual inline void enable_alpha_test( bool op ) {
8392
m_settings.alphaTest = op;
8493
}
85-
virtual inline void enable_blending(bool op) {
94+
virtual inline void enable_blending( bool op ) {
8695
m_settings.blending = op;
8796
}
8897

include/engine/core/materials/phong.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class PhongMaterial : public IMaterial
4848

4949
std::unordered_map<int, bool> m_textureBindingState;
5050

51-
virtual Graphics::MaterialUniforms get_uniforms() const;
51+
virtual IMaterial::GPUPayload get_uniforms() const;
5252
virtual inline std::unordered_map<int, ITexture*> get_textures() const {
5353
return m_textures;
5454
}

0 commit comments

Comments
 (0)