Compare commits
266 Commits
devel_23_i
...
devel_25_M
Author | SHA1 | Date | |
---|---|---|---|
6820ee8c74 | |||
ddb5a0b77a | |||
69646971ce | |||
e71ec4be85 | |||
dbe2370a44 | |||
00d2677066 | |||
4208e47534 | |||
2dedeaad90 | |||
083600a95f | |||
902dc20340 | |||
164498446a | |||
cef5ad073b | |||
c2279c553d | |||
d959e7988d | |||
202bff5870 | |||
8437d8d561 | |||
714fc3dcb7 | |||
e030738a5f | |||
28b2b53d03 | |||
8bb742f3f4 | |||
6e8932fc2f | |||
9661336325 | |||
ef84e5c699 | |||
3b106a3b42 | |||
74003df08b | |||
95c67ba857 | |||
f51c7c6964 | |||
3fe8d9f90d | |||
7967150722 | |||
51a6da3d9f | |||
dd047c1644 | |||
df80b1af3b | |||
64235b12b6 | |||
0557ff2bae | |||
b43d4cc5a3 | |||
b72144a28b | |||
d05f1109b5 | |||
3de67f8cf1 | |||
9816592bf6 | |||
82f3ad070b | |||
b021b05cb0 | |||
5749d8ec8a | |||
e6560dfe5f | |||
8f6260f440 | |||
18850b0e27 | |||
de2926a6d5 | |||
1a8bd0a607 | |||
ffaa6b5362 | |||
9d3ea89861 | |||
7f1532dc6e | |||
01cdb7661b | |||
ab6a8435a1 | |||
d17932c7a4 | |||
f4a8406ad8 | |||
22bc5f6653 | |||
fc94ee82b4 | |||
f8fe0e46d6 | |||
e076b72f1a | |||
a04742c347 | |||
1668a0c973 | |||
e2dd652c3a | |||
a2c3438c58 | |||
5521c53c94 | |||
71fd42cfc8 | |||
222ff2961f | |||
ed5aac2a9d | |||
233523231e | |||
3523afc6c2 | |||
6b498d7e91 | |||
fa7ecb91ac | |||
d5b719152f | |||
410a386423 | |||
641ba4431f | |||
c485941342 | |||
198fe55216 | |||
ad7c652cd4 | |||
46b6797bce | |||
c8dbd40333 | |||
35844d52bc | |||
36d872359e | |||
8086fb76f1 | |||
d660691cec | |||
c5699fd1af | |||
9316135942 | |||
8340209697 | |||
aa217c6fc5 | |||
d5b69fbe71 | |||
58c62ddb59 | |||
7f3132236f | |||
f8ff6d9cf0 | |||
8855f0b880 | |||
254264ac5e | |||
9a24aa237d | |||
ff184ecd7a | |||
81ab733429 | |||
05885e443a | |||
71c543413a | |||
d6d2d337c9 | |||
4ef1283fce | |||
7c4a27771f | |||
a97440e1fc | |||
e1cfc1e5b8 | |||
2c602e9045 | |||
f46b1382ee | |||
459fb3afc4 | |||
27f33e07cb | |||
9c956e1c65 | |||
004504e027 | |||
7c3d9ecf91 | |||
3f1b8be5d0 | |||
f3ab0a5608 | |||
8e64816af8 | |||
5718b1795f | |||
c8cbf020eb | |||
9535a4486e | |||
9781e6a9b3 | |||
958183bb29 | |||
abfc84feff | |||
12e64d7ce0 | |||
34b7937ee2 | |||
2336c7cdf1 | |||
21201b1695 | |||
2eac17ac61 | |||
1e03e28f0b | |||
30c736b7c8 | |||
7031270476 | |||
6bdbf87446 | |||
110c141073 | |||
b9bd4f6c4b | |||
8b0ef244e0 | |||
c232feb40a | |||
db0a8ee256 | |||
b26e25df61 | |||
cd03ee8211 | |||
48b5479ade | |||
1ec88c65f8 | |||
ba6af7a596 | |||
d163f914c7 | |||
0e589e8bcd | |||
011fbdb55d | |||
e488b4c3d3 | |||
49f37447d0 | |||
f280068d50 | |||
137248a274 | |||
ec45b977d1 | |||
38f9a2896f | |||
59b02bcb8c | |||
05e96c58ba | |||
cb09767151 | |||
554220699f | |||
3937206fcb | |||
88f23d9a07 | |||
15324d9c86 | |||
6c3e674d23 | |||
fefdc19674 | |||
18a4212935 | |||
0457d28577 | |||
fd39d08fda | |||
8e52595123 | |||
19a20411d8 | |||
8363275b36 | |||
939bbfeb1f | |||
f555c77a83 | |||
160ba000d3 | |||
5f830b8d57 | |||
5d9aab7dda | |||
cde2d9f86b | |||
d26eb482e7 | |||
eb8e0a921b | |||
9fd13680d1 | |||
8af96ed4a5 | |||
57b480754c | |||
ac42dcdb26 | |||
e1c3b95de7 | |||
ee061e4a1a | |||
f2c6c24ddf | |||
76f5dcb884 | |||
157c09eff0 | |||
9f8e63788d | |||
a7c761e1c5 | |||
44620abc21 | |||
8bf1ad2a46 | |||
d26cae0086 | |||
bc9fc9b50f | |||
fb4c8ed8c2 | |||
0dae30fa06 | |||
48b5a978b8 | |||
694add27ae | |||
251bbd2705 | |||
3bfc31b57f | |||
8c8a218a3a | |||
9302cbc3ef | |||
696d3259aa | |||
85530e6d57 | |||
81e2aac321 | |||
35a282ef5e | |||
3a378be660 | |||
aed56a35e0 | |||
09277924f1 | |||
c4a4ec5ebc | |||
703d444cbb | |||
159c808dad | |||
facdec5556 | |||
42f63c5ef1 | |||
5f4dd09f92 | |||
9872f74160 | |||
529d6b7939 | |||
f748301787 | |||
165f9d2a5f | |||
4de8139936 | |||
9ee5f0adaa | |||
555e8fc066 | |||
f564f55e7b | |||
31b5bb6d4f | |||
5ba705cd6b | |||
9cfb88235a | |||
eceaf9ba68 | |||
14e7074b3f | |||
f79599b1d4 | |||
2cc0dca050 | |||
ece7fa5f32 | |||
68b24903bb | |||
6ee832c39f | |||
26f7c915c8 | |||
2ac91b80ac | |||
eed16928e9 | |||
6b8e76b75f | |||
ca36b4454b | |||
ba65d1abf2 | |||
ef8f630056 | |||
7a0acaf63e | |||
d54aff2a42 | |||
84d0dc99c8 | |||
b4dccf7814 | |||
f2d5209681 | |||
0abe38de98 | |||
6536b715c3 | |||
26b907f611 | |||
99939bd83d | |||
844636a46b | |||
a6b71a449e | |||
e31a6cca13 | |||
cce2cab12c | |||
3dbb1c40b7 | |||
af4b9cd6d4 | |||
b35ef27610 | |||
95064488db | |||
df8156cfe1 | |||
f990539633 | |||
2fb443bcb4 | |||
b8a83a25eb | |||
251d851f65 | |||
8fc83ba9b3 | |||
f8646ca880 | |||
fc2c8021ba | |||
b980457ba2 | |||
2e6a8e794f | |||
1bc810d8e9 | |||
cd2f278e84 | |||
bb3b06f168 | |||
cc02b719e6 | |||
981a1adf4c | |||
28e48a0142 | |||
a0a5ab5da4 | |||
d98df3ee9c | |||
12760ab5c5 |
Submodule CMAssetsManage updated: 1e14c1b01d...9582bfafcc
Submodule CMCMakeModule updated: 9899bc1c07...ca9aece201
2
CMCore
2
CMCore
Submodule CMCore updated: 48abdf2a89...072153aa91
Submodule CMPlatform updated: eca08f0ae7...5e8b83cce4
Submodule CMSceneGraph updated: 6682f0050a...bde86e8016
2
CMUtil
2
CMUtil
Submodule CMUtil updated: c3addef6b7...c0990c52eb
@@ -24,6 +24,7 @@ SET(ULRE CMCore
|
||||
CMSceneGraph
|
||||
CMUtil
|
||||
ULRE.Util
|
||||
ULRE.ShaderGen
|
||||
ULRE.SceneGraph
|
||||
${HGL_GLM_LIB}
|
||||
${RENDER_LIBRARY}
|
||||
|
BIN
GLSLCompiler.dll
Normal file
BIN
GLSLCompiler.dll
Normal file
Binary file not shown.
14
README.md
14
README.md
@@ -1,21 +1,25 @@
|
||||
# ULRE
|
||||
experiment project - Ultra Light Rendering Engine
|
||||
experiment project - Ultra Lightweight Rendering Engine
|
||||
|
||||
ULRE is a project of experimental nature,Used to experiment with various rendering related techniques,And do some examples.
|
||||
|
||||
In the future, its compilicated version will be integrated into CMGameEngine.Used to replace the old rendering engine.
|
||||
|
||||
Platform: Windows,Linux (WIP: Android)
|
||||
Platform: Windows,Linux (WIP: Android,macOS,iOS)
|
||||
|
||||
Graphics API: Vulkan
|
||||
|
||||
Milestone:
|
||||
|
||||
On May 6 of 2023, a test was completed, and the entire scene was drawn with only one DrawCall. Although it still has a lot of unfinished work, it is still a very important milestone.
|
||||
|
||||
#
|
||||
ULRE是一个试验性质的工程,用于试验各种渲染相关的技术,以及做一些范例。在未来它的复杂化版本会被整合到CMGameEngine中,用于替代旧的渲染引擎。
|
||||
|
||||
平台: Windows,Linux (开发中: Android)
|
||||
平台: Windows,Linux (开发中: Android,macOS,iOS)
|
||||
|
||||
图形API: Vulkan
|
||||
|
||||
里程碑:
|
||||
|
||||
ULRE是一个试验性质的工程,用于试验各种渲染相关的技术,以及做一些范例。在未来它的复杂化版本会被整合到CMGameEngine中,用于替代旧的渲染引擎。
|
||||
|
||||
2023年5月6日,完成了一个测试,只用了一次DrawCall就绘制出了整个场景。虽然它还有很多未完成的工作,但它依然是一个非常重要的里程碑。
|
@@ -37,9 +37,9 @@ private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
GPUBuffer * ubo_color_material =nullptr;
|
||||
GPUBuffer * ubo_line_config =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_color_material =nullptr;
|
||||
DeviceBuffer * ubo_line_config =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -62,9 +62,9 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
GPUBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
DeviceBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
{
|
||||
GPUBuffer *ubo=db->CreateUBO(size,data);
|
||||
DeviceBuffer *ubo=db->CreateUBO(size,data);
|
||||
|
||||
if(!ubo)
|
||||
return(nullptr);
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
|
||||
{
|
||||
|
||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp_value)
|
||||
return(false);
|
||||
|
@@ -44,8 +44,8 @@ private:
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
GPUBuffer * ubo_rb_config =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_rb_config =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@@ -54,15 +54,15 @@ private:
|
||||
bool InitMaterial()
|
||||
{
|
||||
//2D渲染Position坐标全部是使用整数,这里强制要求Position输入流使用RGBA16I格式
|
||||
VABConfigInfo vab_config;
|
||||
VILConfig vil_config;
|
||||
VAConfig va_cfg;
|
||||
|
||||
va_cfg.format=VF_V4I16;
|
||||
va_cfg.instance=false;
|
||||
|
||||
vab_config.Add("Position",va_cfg);
|
||||
vil_config.Add("Position",va_cfg);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/RoundedBox"),&vab_config);
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/RoundedBox"),&vil_config);
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
@@ -74,9 +74,9 @@ private:
|
||||
return(true);
|
||||
}
|
||||
|
||||
GPUBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
DeviceBuffer *CreateUBO(const AnsiString &name,const VkDeviceSize size,void *data)
|
||||
{
|
||||
GPUBuffer *ubo=db->CreateUBO(size,data);
|
||||
DeviceBuffer *ubo=db->CreateUBO(size,data);
|
||||
|
||||
if(!ubo)
|
||||
return(nullptr);
|
||||
@@ -94,7 +94,7 @@ private:
|
||||
cam.RefreshCameraInfo();
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
@@ -108,7 +108,7 @@ private:
|
||||
}
|
||||
|
||||
{
|
||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp_value)
|
||||
return(false);
|
||||
|
@@ -5,3 +5,16 @@ SET(VULKAN_APP_FRAMEWORK ${CMAKE_CURRENT_SOURCE_DIR}/common/VulkanAppFramework.h
|
||||
add_subdirectory(Vulkan)
|
||||
add_subdirectory(2dVector)
|
||||
add_subdirectory(GUI)
|
||||
|
||||
macro(CreateProject name)
|
||||
add_executable(${name} ${ARGN})
|
||||
target_link_libraries(${name} ${ULRE})
|
||||
|
||||
IF(WIN32)
|
||||
set_target_properties(${name} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${ULRE_RUNTIME_PATH})
|
||||
ENDIF()
|
||||
|
||||
set_property(TARGET ${name} PROPERTY FOLDER "ULRE/Example")
|
||||
endmacro()
|
||||
|
||||
CreateProject(MaterialCreaterTest MaterialCreaterTest.cpp)
|
||||
|
126
example/MaterialCreaterTest.cpp
Normal file
126
example/MaterialCreaterTest.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include<hgl/shadergen/MaterialCreateInfo.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
using namespace hgl::shadergen;
|
||||
|
||||
bool PureColor2DMaterial()
|
||||
{
|
||||
MaterialCreateInfo mc("PureColor2D",1,false); //一个新材质,1个RT输出,默认使用Vertex/Fragment shader
|
||||
|
||||
//vertex部分
|
||||
{
|
||||
ShaderCreateInfoVertex *vsc=mc.GetVS(); //获取vertex shader creater
|
||||
|
||||
//以下代码会被展开为
|
||||
/*
|
||||
layout(location=?) in vec3 Position; //位置属性
|
||||
*/
|
||||
vsc->AddInput("vec2","Position"); //添加一个vec3类型的position属性输入
|
||||
|
||||
vsc->SetShaderCodes(R"(
|
||||
void main()
|
||||
{
|
||||
gl_Position=vec4(Position,0,1);
|
||||
})");
|
||||
}
|
||||
|
||||
//添加一个名称为ColorMaterial的UBO定义,其内部有一个vec4 color的属性
|
||||
//该代码会被展开为
|
||||
/*
|
||||
struct ColorMaterial
|
||||
{
|
||||
vec4 color;
|
||||
};
|
||||
*/
|
||||
mc.AddStruct("ColorMaterial","vec4 color;");
|
||||
|
||||
//添加一个UBO,该代码会被展开为
|
||||
/*
|
||||
layout(set=?,binding=?) uniform ColorMaterial mtl;
|
||||
*/
|
||||
mc.AddUBO( VK_SHADER_STAGE_FRAGMENT_BIT, //这个UBO出现在fragment shader
|
||||
DescriptorSetType::PerMaterial, //它属于材质合集
|
||||
"ColorMaterial", //UBO名称为ColorMaterial
|
||||
"mtl"); //UBO变量名称为mtl
|
||||
|
||||
//fragment部分
|
||||
{
|
||||
ShaderCreateInfoFragment *fsc=mc.GetFS(); //获取fragment shader creater
|
||||
|
||||
//以下代码会被展开为
|
||||
/*
|
||||
layout(location=?) out vec4 Color; //颜色输出
|
||||
*/
|
||||
fsc->AddOutput("vec4","Color"); //添加一个vec4类型的color属性输出
|
||||
|
||||
fsc->SetShaderCodes(R"(
|
||||
void main()
|
||||
{
|
||||
Color=mtl.color;
|
||||
})");
|
||||
}
|
||||
|
||||
mc.CreateShader();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool VertexColor2DMaterial()
|
||||
{
|
||||
MaterialCreateInfo mc("VertexColor2D",1,false);
|
||||
|
||||
//vertex部分
|
||||
{
|
||||
ShaderCreateInfoVertex *vsc=mc.GetVS();
|
||||
|
||||
vsc->AddInput("vec2","Position");
|
||||
vsc->AddInput("vec4","Color");
|
||||
|
||||
vsc->AddOutput("vec4","Color");
|
||||
|
||||
vsc->SetShaderCodes(R"(
|
||||
void main()
|
||||
{
|
||||
Output.Color=Color;
|
||||
|
||||
gl_Position=vec4(Position,0,1);
|
||||
})");
|
||||
}
|
||||
|
||||
//fragment部分
|
||||
{
|
||||
ShaderCreateInfoFragment *fsc=mc.GetFS();
|
||||
|
||||
fsc->AddOutput("vec4","Color");
|
||||
|
||||
fsc->SetShaderCodes(R"(
|
||||
void main()
|
||||
{
|
||||
Color=Input.Color;
|
||||
})");
|
||||
}
|
||||
|
||||
mc.CreateShader();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
namespace glsl_compiler
|
||||
{
|
||||
bool Init();
|
||||
void Close();
|
||||
}//namespace glsl_compiler
|
||||
|
||||
int main()
|
||||
{
|
||||
if(!glsl_compiler::Init())
|
||||
return -1;
|
||||
|
||||
PureColor2DMaterial();
|
||||
VertexColor2DMaterial();
|
||||
|
||||
glsl_compiler::Close();
|
||||
|
||||
return 0;
|
||||
}
|
@@ -40,10 +40,10 @@ private:
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Pipeline * pipeline_solid =nullptr;
|
||||
|
||||
GPUBuffer * ubo_atomsphere =nullptr;
|
||||
DeviceBuffer * ubo_atomsphere =nullptr;
|
||||
AtmosphereData atomsphere_data;
|
||||
|
||||
Primitive * ro_sphere =nullptr;
|
||||
Primitive * ro_sphere =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp)return(false);
|
||||
|
||||
@@ -81,7 +81,7 @@ private:
|
||||
|
||||
bool InitScene()
|
||||
{
|
||||
ro_sphere=inline_geometry::CreateSphere(db,material_instance->GetVAB(),128);
|
||||
ro_sphere=inline_geometry::CreateSphere(db,material_instance->GetVIL(),128);
|
||||
|
||||
render_root.CreateSubNode(scale(100),db->CreateRenderable(ro_sphere,material_instance,pipeline_solid));
|
||||
|
||||
|
@@ -10,41 +10,43 @@
|
||||
set_property(TARGET ${name} PROPERTY FOLDER "ULRE/Example/Vulkan/${group}")
|
||||
endmacro()
|
||||
|
||||
CreateProject("Basic" 1st_triangle first_triangle.cpp)
|
||||
CreateProject("Basic" 2nd_triangle second_triangle.cpp)
|
||||
CreateProject("Basic" 3rd_triangle third_triangle.cpp)
|
||||
CreateProject("Basic" FragCoord FragCoordTest.cpp)
|
||||
CreateProject("Basic" indices_rect indices_rect.cpp)
|
||||
CreateProject("Basic" FullScreenTriangle FullScreenTriangle.cpp)
|
||||
CreateProject("Basic" InstanceTriangle InstanceTriangle.cpp)
|
||||
CreateProject("Basic" 1st_draw_triangle_in_NDC first_triangle.cpp)
|
||||
CreateProject("Basic" 2nd_draw_triangle_use_UBO second_triangle.cpp)
|
||||
CreateProject("Basic" 3rd_AutoInstance third_triangle.cpp)
|
||||
CreateProject("Basic" 4th_AutoMergeMaterialInstance fourth_triangle.cpp)
|
||||
|
||||
#CreateProject("Basic" FragCoord FragCoordTest.cpp)
|
||||
#CreateProject("Basic" indices_rect indices_rect.cpp)
|
||||
#CreateProject("Basic" FullScreenTriangle FullScreenTriangle.cpp)
|
||||
#CreateProject("Basic" InstanceTriangle InstanceTriangle.cpp)
|
||||
|
||||
CreateProject("Texture" TextureFormat TextureFormat.cpp)
|
||||
CreateProject("Texture" texture_rect texture_rect.cpp)
|
||||
#CreateProject("Texture" texture_rect texture_rect.cpp)
|
||||
#CreateProject("Texture" HQFilterTexture HQFilterTexture.cpp)
|
||||
#CreateProject(06.Geometry2D Geometry2D.cpp)
|
||||
|
||||
CreateProject("Geometry2D" RectanglePrimitive RectanglePrimitive.cpp)
|
||||
CreateProject("Tile" DrawTile DrawTile.cpp)
|
||||
CreateProject("Tile" DrawText DrawText.cpp)
|
||||
#CreateProject("Geometry2D" RectanglePrimitive RectanglePrimitive.cpp)
|
||||
#CreateProject("Tile" DrawTile DrawTile.cpp)
|
||||
#CreateProject("Tile" DrawText DrawText.cpp)
|
||||
|
||||
CreateProject("Geometry3D " Geometry3D Geometry3D.cpp)
|
||||
#CreateProject("Geometry3D " Geometry3D Geometry3D.cpp)
|
||||
|
||||
CreateProject("Scene" SceneTree SceneTree.cpp)
|
||||
#CreateProject("Scene" SceneTree SceneTree.cpp)
|
||||
#CreateProject("Scene" LoadStaticMesh LoadStaticMesh.cpp LoadScene.cpp)
|
||||
CreateProject("Scene" InlineGeometryScene InlineGeometryScene.cpp)
|
||||
#CreateProject("Scene" InlineGeometryScene InlineGeometryScene.cpp)
|
||||
|
||||
CreateProject("Scene/Sky" SkyColor SkyColor.cpp)
|
||||
CreateProject("Scene/Sky" Atmosphere Atmosphere.cpp)
|
||||
#CreateProject("Scene/Sky" SkyColor SkyColor.cpp)
|
||||
#CreateProject("Scene/Sky" Atmosphere Atmosphere.cpp)
|
||||
|
||||
CreateProject("Advanced Rendering" OffscreenRender OffscreenRender.cpp)
|
||||
#CreateProject("Advanced Rendering" OffscreenRender OffscreenRender.cpp)
|
||||
|
||||
#CreateProject(12.PBRBasic PBRBasic.cpp)
|
||||
#CreateProject(12.Deferred Deferred.cpp)
|
||||
CreateProject("Advanced Rendering" DeferredRender DeferredRender.cpp)
|
||||
#CreateProject("Advanced Rendering" DeferredRender DeferredRender.cpp)
|
||||
#CreateProject(14.AutoMaterial auto_material.cpp)
|
||||
|
||||
CreateProject("Texture" Cubemap Cubemap.cpp)
|
||||
CreateProject("Texture" EquirectangularMap EquirectangularMap.cpp)
|
||||
CreateProject("Picking" RayPicking RayPicking.cpp)
|
||||
#CreateProject("Texture" Cubemap Cubemap.cpp)
|
||||
#CreateProject("Texture" EquirectangularMap EquirectangularMap.cpp)
|
||||
#CreateProject("Picking" RayPicking RayPicking.cpp)
|
||||
|
||||
CreateProject("Landscape" TerrainSimple TerrainSimple.cpp)
|
||||
#CreateProject("Landscape" TerrainSimple TerrainSimple.cpp)
|
||||
|
@@ -35,8 +35,8 @@ private:
|
||||
Pipeline * sky_pipeline =nullptr;
|
||||
Pipeline * solid_pipeline =nullptr;
|
||||
|
||||
GPUBuffer * ubo_light =nullptr;
|
||||
GPUBuffer * ubo_phong =nullptr;
|
||||
DeviceBuffer * ubo_light =nullptr;
|
||||
DeviceBuffer * ubo_phong =nullptr;
|
||||
|
||||
Sampler * sampler =nullptr;
|
||||
TextureCube * texture =nullptr;
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
sky_mi=db->CreateMaterialInstance(sky_material);
|
||||
if(!sky_mi)return(false);
|
||||
|
||||
if(!sky_mi->BindSampler(DescriptorSetsType::Value,"tex" ,texture, sampler))return(false);
|
||||
if(!sky_mi->BindImageSampler(DescriptorSetType::Value,"tex" ,texture, sampler))return(false);
|
||||
|
||||
sky_pipeline=CreatePipeline(sky_mi,InlinePipeline::Sky,Prim::Triangles);
|
||||
if(!sky_pipeline)return(false);
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
||||
if(!envmap_mi)return(false);
|
||||
|
||||
if(!envmap_mi->BindSampler(DescriptorSetsType::Value,"EnvCubemap" ,texture, sampler))return(false);
|
||||
if(!envmap_mi->BindImageSampler(DescriptorSetType::Value,"EnvCubemap" ,texture, sampler))return(false);
|
||||
|
||||
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
}
|
||||
@@ -128,17 +128,17 @@ private:
|
||||
|
||||
aci.size=GetCameraInfo().zfar;
|
||||
|
||||
ro_axis=CreateAxis(db,axis_mi->GetVAB(),&aci);
|
||||
ro_axis=CreateAxis(db,axis_mi->GetVIL(),&aci);
|
||||
}
|
||||
|
||||
{
|
||||
struct CubeCreateInfo cci;
|
||||
|
||||
ro_cube=CreateCube(db,sky_mi->GetVAB(),&cci);
|
||||
ro_cube=CreateCube(db,sky_mi->GetVIL(),&cci);
|
||||
}
|
||||
|
||||
{
|
||||
ro_sphere=CreateSphere(db,envmap_mi->GetVAB(),64);
|
||||
ro_sphere=CreateSphere(db,envmap_mi->GetVIL(),64);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
bool Submit(GPUSemaphore *sem)
|
||||
bool Submit(Semaphore *sem)
|
||||
{
|
||||
return rt->Submit(cmd,sem);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
|
||||
PhongPointLight lights;
|
||||
|
||||
GPUBuffer *ubo_lights;
|
||||
DeviceBuffer *ubo_lights;
|
||||
|
||||
struct SubpassParam
|
||||
{
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
SubpassParam sp_gbuffer;
|
||||
SubpassParam sp_composition;
|
||||
|
||||
Primitive *ro_plane,
|
||||
Primitive *ro_plane,
|
||||
*ro_cube,
|
||||
*ro_sphere,
|
||||
*ro_torus,
|
||||
@@ -136,6 +136,22 @@ private:
|
||||
};
|
||||
|
||||
gbuffer.sampler=db->CreateSampler(&sci);
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
auto da=device->GetDeviceAttribute();
|
||||
|
||||
if(da->debug_maker)
|
||||
{
|
||||
da->debug_maker->SetSampler(*(gbuffer.sampler), "[debug maker] GBuffer_Sampler");
|
||||
}
|
||||
|
||||
if(da->debug_utils)
|
||||
{
|
||||
da->debug_utils->SetSampler(*(gbuffer.sampler), "[debug utils] GBuffer_Sampler");
|
||||
}
|
||||
}
|
||||
#endif//_DEBUG
|
||||
}
|
||||
|
||||
bool InitGBuffer()
|
||||
@@ -144,7 +160,7 @@ private:
|
||||
|
||||
fbi.SetExtent(SCREEN_WIDTH,SCREEN_HEIGHT);
|
||||
|
||||
gbuffer.rt=device->CreateRenderTarget(&fbi);
|
||||
gbuffer.rt=device->CreateRT(&fbi);
|
||||
|
||||
if(!gbuffer.rt)return(false);
|
||||
|
||||
@@ -154,6 +170,39 @@ private:
|
||||
|
||||
CreateGBufferSampler();
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
auto da=device->GetDeviceAttribute();
|
||||
|
||||
VkQueue q=*(gbuffer.rt->GetQueue());
|
||||
VkFramebuffer fbo= gbuffer.rt->GetFramebuffer()->GetFramebuffer();
|
||||
VkRenderPass rp= gbuffer.rp->GetVkRenderPass();
|
||||
VkSemaphore sem=*(gbuffer.rt->GetRenderCompleteSemaphore());
|
||||
VkCommandBuffer cb=*(gbuffer.cmd);
|
||||
VkSampler s=*(gbuffer.sampler);
|
||||
|
||||
if(da->debug_maker)
|
||||
{
|
||||
da->debug_maker->SetQueue( q, "[debug maker] GBufferQueue");
|
||||
da->debug_maker->SetFramebuffer( fbo,"[debug maker] GBufferFBO");
|
||||
da->debug_maker->SetRenderPass( rp, "[debug maker] GBufferRenderpass");
|
||||
da->debug_maker->SetCommandBuffer( cb, "[debug maker] GBufferCommandBuffer");
|
||||
da->debug_maker->SetSampler( s, "[debug maker] GBufferSampler");
|
||||
da->debug_maker->SetSemaphore( sem,"[debug maker] GBufferSemaphore");
|
||||
}
|
||||
|
||||
if(da->debug_utils)
|
||||
{
|
||||
da->debug_utils->SetQueue( q, "[debug utils] GBufferQueue");
|
||||
da->debug_utils->SetFramebuffer( fbo,"[debug utils] GBufferFBO");
|
||||
da->debug_utils->SetRenderPass( rp, "[debug utils] GBufferRenderpass");
|
||||
da->debug_utils->SetCommandBuffer( cb, "[debug utils] GBufferCommandBuffer");
|
||||
da->debug_utils->SetSampler( s, "[debug utils] GBufferSampler");
|
||||
da->debug_utils->SetSemaphore( sem,"[debug utils] GBufferSemaphore");
|
||||
}
|
||||
}
|
||||
#endif//_DEBUG
|
||||
|
||||
return(gbuffer.rt);
|
||||
}
|
||||
|
||||
@@ -175,9 +224,28 @@ private:
|
||||
return(false);
|
||||
|
||||
sp->pipeline_fan =gbuffer.rp->CreatePipeline(sp->material_instance,InlinePipeline::Solid3D,Prim::Fan);
|
||||
if(!sp->pipeline_fan)
|
||||
return(false);
|
||||
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
auto da=device->GetDeviceAttribute();
|
||||
|
||||
return sp->pipeline_fan;
|
||||
if(da->debug_maker)
|
||||
{
|
||||
da->debug_maker->SetPipeline(*(sp->pipeline_triangles), "[debug maker] GBuffer_Pipeline_Triangles");
|
||||
da->debug_maker->SetPipeline(*(sp->pipeline_fan), "[debug maker] GBuffer_Pipeline_Fan");
|
||||
}
|
||||
|
||||
if(da->debug_utils)
|
||||
{
|
||||
da->debug_utils->SetPipeline(*(sp->pipeline_triangles), "[debug utils] GBuffer_Pipeline_Triangles");
|
||||
da->debug_utils->SetPipeline(*(sp->pipeline_fan), "[debug utils] GBuffer_Pipeline_Fan");
|
||||
}
|
||||
}
|
||||
#endif//_DEBUG
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool InitCompositionPipeline(SubpassParam *sp)
|
||||
@@ -194,7 +262,7 @@ private:
|
||||
}
|
||||
|
||||
Sampler *CreateSampler(Texture *tex)
|
||||
{
|
||||
{
|
||||
VkSamplerCreateInfo sci=
|
||||
{
|
||||
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
@@ -243,50 +311,50 @@ private:
|
||||
BindCameraUBO(sp_gbuffer.material_instance);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp=sp_gbuffer.material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp)
|
||||
return(false);
|
||||
|
||||
mp->BindSampler("TexColor" ,texture.color, texture.color_sampler);
|
||||
mp->BindSampler("TexNormal" ,texture.normal, texture.normal_sampler);
|
||||
mp->BindImageSampler("TexColor" ,texture.color, texture.color_sampler);
|
||||
mp->BindImageSampler("TexNormal" ,texture.normal, texture.normal_sampler);
|
||||
mp->Update();
|
||||
}
|
||||
|
||||
BindCameraUBO(sp_composition.material_instance);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp=sp_composition.material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp)
|
||||
return(false);
|
||||
|
||||
mp->BindUBO("lights",ubo_lights);
|
||||
mp->BindSampler("GB_Color" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Color),gbuffer.sampler);
|
||||
mp->BindSampler("GB_Normal" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Normal),gbuffer.sampler);
|
||||
mp->BindSampler("GB_Depth" ,gbuffer.rt->GetDepthTexture(),gbuffer.sampler);
|
||||
mp->BindImageSampler("GB_Color" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Color),gbuffer.sampler);
|
||||
mp->BindImageSampler("GB_Normal" ,gbuffer.rt->GetColorTexture((uint)GBufferAttachment::Normal),gbuffer.sampler);
|
||||
mp->BindImageSampler("GB_Depth" ,gbuffer.rt->GetDepthTexture(),gbuffer.sampler);
|
||||
mp->Update();
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void CreateRenderObject(const VAB *vab)
|
||||
void CreateRenderObject(const VIL *vil)
|
||||
{
|
||||
using namespace inline_geometry;
|
||||
|
||||
{
|
||||
struct PlaneCreateInfo pci;
|
||||
ro_plane=CreatePlane(db,vab,&pci);
|
||||
ro_plane=CreatePlane(db,vil,&pci);
|
||||
}
|
||||
|
||||
{
|
||||
struct CubeCreateInfo cci;
|
||||
ro_cube=CreateCube(db,vab,&cci);
|
||||
ro_cube=CreateCube(db,vil,&cci);
|
||||
}
|
||||
|
||||
{
|
||||
ro_sphere=CreateSphere(db,vab,64);
|
||||
ro_sphere=CreateSphere(db,vil,64);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -301,7 +369,7 @@ private:
|
||||
tci.uv_scale.x=4;
|
||||
tci.uv_scale.y=1;
|
||||
|
||||
ro_torus=CreateTorus(db,vab,&tci);
|
||||
ro_torus=CreateTorus(db,vil,&tci);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -311,7 +379,7 @@ private:
|
||||
cci.radius=10;
|
||||
cci.numberSlices=32;
|
||||
|
||||
ro_cylinder=CreateCylinder(db,vab,&cci);
|
||||
ro_cylinder=CreateCylinder(db,vil,&cci);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -322,13 +390,13 @@ private:
|
||||
cci.numberSlices=128;
|
||||
cci.numberStacks=32;
|
||||
|
||||
ro_cone=CreateCone(db,vab,&cci);
|
||||
ro_cone=CreateCone(db,vil,&cci);
|
||||
}
|
||||
}
|
||||
|
||||
bool InitCompositionRenderable()
|
||||
{
|
||||
ro_gbc_plane=inline_geometry::CreateGBufferCompositionRectangle(db,sp_composition.material_instance->GetVAB());
|
||||
ro_gbc_plane=inline_geometry::CreateGBufferCompositionRectangle(db,sp_composition.material_instance->GetVIL());
|
||||
if(!ro_gbc_plane)return(false);
|
||||
|
||||
ro_gbc_plane_ri=db->CreateRenderable(ro_gbc_plane,sp_composition.material_instance,sp_composition.pipeline_fan);
|
||||
@@ -339,7 +407,7 @@ private:
|
||||
|
||||
bool InitScene(SubpassParam *sp)
|
||||
{
|
||||
CreateRenderObject(sp->material_instance->GetVAB());
|
||||
CreateRenderObject(sp->material_instance->GetVIL());
|
||||
render_root.CreateSubNode( scale(100,100,1), db->CreateRenderable(ro_plane ,sp->material_instance,sp->pipeline_fan ));
|
||||
render_root.CreateSubNode( db->CreateRenderable(ro_torus ,sp->material_instance,sp->pipeline_triangles));
|
||||
render_root.CreateSubNode( scale(20,20,20), db->CreateRenderable(ro_sphere ,sp->material_instance,sp->pipeline_triangles));
|
||||
@@ -362,12 +430,14 @@ private:
|
||||
if(!gbuffer.cmd->BindFramebuffer(gbuffer.rt->GetRenderPass(),gbuffer.rt->GetFramebuffer()))
|
||||
return(false);
|
||||
|
||||
gbuffer.cmd->BeginRegion("GBuffer Begin",Color4f(1,0,0,1));
|
||||
if(!gbuffer.cmd->BeginRenderPass())
|
||||
return(false);
|
||||
|
||||
render_list->Render(gbuffer.cmd);
|
||||
|
||||
gbuffer.cmd->EndRenderPass();
|
||||
gbuffer.cmd->EndRegion();
|
||||
gbuffer.cmd->End();
|
||||
|
||||
return(true);
|
||||
@@ -404,13 +474,13 @@ public:
|
||||
{
|
||||
const double timer=GetDoubleTime();
|
||||
|
||||
// White
|
||||
lights.position = Vector4f(0.0f, 0.0f, 25.0f, 0.0f);
|
||||
lights.color = Vector4f(15.0f);
|
||||
lights.radius = 155.0f;
|
||||
// White
|
||||
lights.position = Vector4f(0.0f, 0.0f, 25.0f, 0.0f);
|
||||
lights.color = Vector4f(15.0f);
|
||||
lights.radius = 155.0f;
|
||||
|
||||
lights.position.x = sin(rad2deg(timer/100)) * 100.0f;
|
||||
lights.position.y = cos(rad2deg(timer/100)) * 100.0f;
|
||||
lights.position.x = sin(rad2deg(timer/100)) * 100.0f;
|
||||
lights.position.y = cos(rad2deg(timer/100)) * 100.0f;
|
||||
|
||||
ubo_lights->Write(&lights);
|
||||
}
|
||||
@@ -441,8 +511,8 @@ public:
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
render_list->Expend(GetCameraInfo(),&render_root);
|
||||
|
||||
CameraAppFramework::Draw();
|
||||
|
||||
CameraAppFramework::Draw();
|
||||
}
|
||||
};//class TestApp:public CameraAppFramework
|
||||
|
||||
|
@@ -165,7 +165,7 @@ private:
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
|
||||
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",tile_data->GetTexture(),sampler))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@@ -26,8 +26,8 @@ private:
|
||||
|
||||
Pipeline * solid_pipeline =nullptr;
|
||||
|
||||
GPUBuffer * ubo_light =nullptr;
|
||||
GPUBuffer * ubo_phong =nullptr;
|
||||
DeviceBuffer * ubo_light =nullptr;
|
||||
DeviceBuffer * ubo_phong =nullptr;
|
||||
|
||||
Sampler * sampler =nullptr;
|
||||
Texture2D * texture =nullptr;
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
envmap_mi=db->CreateMaterialInstance(OS_TEXT("res/material/EnvEquirectangularMap"));
|
||||
if(!envmap_mi)return(false);
|
||||
|
||||
if(!envmap_mi->BindSampler(DescriptorSetsType::Value,"Envmap" ,texture, sampler))return(false);
|
||||
if(!envmap_mi->BindImageSampler(DescriptorSetType::Value,"Envmap" ,texture, sampler))return(false);
|
||||
}
|
||||
|
||||
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
|
||||
void CreateRenderObject()
|
||||
{
|
||||
ro_sphere=inline_geometry::CreateSphere(db,envmap_mi->GetVAB(),128);
|
||||
ro_sphere=inline_geometry::CreateSphere(db,envmap_mi->GetVIL(),128);
|
||||
}
|
||||
|
||||
bool InitUBO()
|
||||
|
@@ -17,18 +17,18 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
SceneNode render_root;
|
||||
RenderList *render_list=nullptr;
|
||||
SceneNode render_root;
|
||||
RenderList * render_list =nullptr;
|
||||
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
Primitive * ro_plane_grid[3];
|
||||
Primitive * ro_plane_grid[3]{};
|
||||
|
||||
private:
|
||||
|
||||
@@ -76,18 +76,18 @@ private:
|
||||
pgci.color.Set(0.5,0,0,1);
|
||||
pgci.side_color.Set(1,0,0,1);
|
||||
|
||||
const VAB *vab=material_instance->GetVAB();
|
||||
const VIL *vil=material_instance->GetVIL();
|
||||
|
||||
ro_plane_grid[0]=CreatePlaneGrid(db,vab,&pgci);
|
||||
ro_plane_grid[0]=CreatePlaneGrid(db,vil,&pgci);
|
||||
|
||||
pgci.color.Set(0,0.5,0,1);
|
||||
pgci.side_color.Set(0,1,0,1);
|
||||
|
||||
ro_plane_grid[1]=CreatePlaneGrid(db,vab,&pgci);
|
||||
ro_plane_grid[1]=CreatePlaneGrid(db,vil,&pgci);
|
||||
|
||||
pgci.color.Set(0,0,0.5,1);
|
||||
pgci.side_color.Set(0,0,1,1);
|
||||
ro_plane_grid[2]=CreatePlaneGrid(db,vab,&pgci);
|
||||
ro_plane_grid[2]=CreatePlaneGrid(db,vil,&pgci);
|
||||
}
|
||||
|
||||
bool InitScene()
|
||||
|
@@ -49,8 +49,8 @@ private:
|
||||
Pipeline * axis_pipeline =nullptr;
|
||||
Pipeline * pipeline_solid =nullptr;
|
||||
|
||||
GPUBuffer * ubo_light =nullptr;
|
||||
GPUBuffer * ubo_phong =nullptr;
|
||||
DeviceBuffer * ubo_light =nullptr;
|
||||
DeviceBuffer * ubo_phong =nullptr;
|
||||
|
||||
struct
|
||||
{
|
||||
@@ -129,13 +129,13 @@ private:
|
||||
if(!material_instance)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
mp_texture->BindSampler("TexColor" ,texture.color, texture.sampler);
|
||||
mp_texture->BindSampler("TexNormal" ,texture.normal, texture.sampler);
|
||||
mp_texture->BindImageSampler("TexColor" ,texture.color, texture.sampler);
|
||||
mp_texture->BindImageSampler("TexNormal" ,texture.normal, texture.sampler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,10 +154,10 @@ private:
|
||||
|
||||
aci.size=200;
|
||||
|
||||
ro_axis=CreateAxis(db,axis_mi->GetVAB(),&aci);
|
||||
ro_axis=CreateAxis(db,axis_mi->GetVIL(),&aci);
|
||||
}
|
||||
|
||||
const VAB *vab=material_instance->GetVAB();
|
||||
const VIL *vil=material_instance->GetVIL();
|
||||
|
||||
{
|
||||
struct CubeCreateInfo cci;
|
||||
@@ -166,11 +166,11 @@ private:
|
||||
cci.tex_coord=true;
|
||||
cci.color_type=CubeCreateInfo::ColorType::SameColor;
|
||||
cci.color[0]=Vector4f(1,1,1,1);
|
||||
ro_cube=CreateCube(db,vab,&cci);
|
||||
ro_cube=CreateCube(db,vil,&cci);
|
||||
}
|
||||
|
||||
{
|
||||
ro_sphere=CreateSphere(db,vab,64);
|
||||
ro_sphere=CreateSphere(db,vil,64);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
tci.uv_scale.x=4;
|
||||
tci.uv_scale.y=1;
|
||||
|
||||
ro_torus=CreateTorus(db,vab,&tci);
|
||||
ro_torus=CreateTorus(db,vil,&tci);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -195,7 +195,7 @@ private:
|
||||
cci.radius=10;
|
||||
cci.numberSlices=32;
|
||||
|
||||
ro_cylinder=CreateCylinder(db,vab,&cci);
|
||||
ro_cylinder=CreateCylinder(db,vil,&cci);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
cci.numberSlices=128;
|
||||
cci.numberStacks=32;
|
||||
|
||||
ro_cone=CreateCone(db,vab,&cci);
|
||||
ro_cone=CreateCone(db,vil,&cci);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ private:
|
||||
ubo_phong=db->CreateUBO(sizeof(PhongMaterial),&phong);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp_value)
|
||||
return(false);
|
||||
|
@@ -56,8 +56,8 @@ private:
|
||||
Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
if(!primitive)return(false);
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data)))return(false);
|
||||
if(!primitive->Set(VAN::Color, db->CreateVBO(VF_V4F,VERTEX_COUNT,color_data)))return(false);
|
||||
if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data )))return(false);
|
||||
if(!primitive->Set(VAN::Color, db->CreateVBO(VF_V4F,VERTEX_COUNT,color_data )))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
return(true);
|
||||
|
@@ -16,7 +16,7 @@ class TestApp:public CameraAppFramework
|
||||
Camera cam;
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
};
|
||||
|
||||
struct:public RenderObject
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
{
|
||||
FramebufferInfo fbi(UPF_RGBA8,OFFSCREEN_SIZE,OFFSCREEN_SIZE);
|
||||
|
||||
os.render_taget=device->CreateRenderTarget(&fbi);
|
||||
os.render_taget=device->CreateRT(&fbi);
|
||||
if(!os.render_taget)return(false);
|
||||
|
||||
os.command_buffer=device->CreateRenderCommandBuffer();
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
cci.center_color=Vector4f(1,1,1,1);
|
||||
cci.border_color=Vector4f(1,1,1,0);
|
||||
|
||||
Primitive *primitive=CreateCircle(db,os.material_instance->GetVAB(),&cci);
|
||||
Primitive *primitive=CreateCircle(db,os.material_instance->GetVIL(),&cci);
|
||||
if(!primitive)return(false);
|
||||
|
||||
os.renderable=db->CreateRenderable(primitive,os.material_instance,os.pipeline);
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
cube.sampler=db->CreateSampler();
|
||||
if(!cube.sampler)return(false);
|
||||
|
||||
if(!cube.material_instance->BindSampler(DescriptorSetsType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
|
||||
if(!cube.material_instance->BindImageSampler(DescriptorSetType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
|
||||
return(false);
|
||||
|
||||
{
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
|
||||
cci.tex_coord=true;
|
||||
|
||||
Primitive *primitive=CreateCube(db,cube.material_instance->GetVAB(),&cci);
|
||||
Primitive *primitive=CreateCube(db,cube.material_instance->GetVIL(),&cci);
|
||||
if(!primitive)return(false);
|
||||
|
||||
cube.renderable=db->CreateRenderable(primitive,cube.material_instance,cube.pipeline);
|
||||
|
@@ -31,7 +31,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -97,17 +97,17 @@ private:
|
||||
pgci.color.Set(0.25,0,0,1);
|
||||
pgci.side_color.Set(1,0,0,1);
|
||||
|
||||
const VAB *vab=material_instance->GetVAB();
|
||||
const VIL *vil=material_instance->GetVIL();
|
||||
|
||||
ro_plane_grid=CreatePlaneGrid(db,vab,&pgci);
|
||||
ro_plane_grid=CreatePlaneGrid(db,vil,&pgci);
|
||||
}
|
||||
|
||||
{
|
||||
ro_line=db->CreatePrimitive(2);
|
||||
if(!ro_line)return(false);
|
||||
|
||||
if(!ro_line->Set(VAN::Position, vbo_pos=db->CreateVBO(VF_V3F,2,position_data)))return(false);
|
||||
if(!ro_line->Set(VAN::Color, db->CreateVBO(VF_V4F,2,color_data)))return(false);
|
||||
if(!ro_line->Set(VAN::Position, vbo_pos=db->CreateVBO(VF_V3F,2,position_data )))return(false);
|
||||
if(!ro_line->Set(VAN::Color, db->CreateVBO(VF_V4F,2,color_data )))return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
|
@@ -59,7 +59,7 @@ private:
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",texture,sampler))return(false);
|
||||
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@@ -33,8 +33,8 @@ private:
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
|
||||
GPUBuffer * ubo_color =nullptr;
|
||||
GPUBuffer * ubo_sun =nullptr;
|
||||
DeviceBuffer * ubo_color =nullptr;
|
||||
DeviceBuffer * ubo_sun =nullptr;
|
||||
|
||||
Primitive * primitive =nullptr;
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
|
||||
void CreateRenderObject()
|
||||
{
|
||||
primitive=inline_geometry::CreateSphere(db,material_instance->GetVAB(),40);
|
||||
primitive=inline_geometry::CreateSphere(db,material_instance->GetVIL(),40);
|
||||
}
|
||||
|
||||
bool InitUBO()
|
||||
@@ -84,7 +84,7 @@ private:
|
||||
if(!ubo_sun)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
|
||||
MaterialParameters *mp=material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp)return(false);
|
||||
|
||||
|
@@ -21,7 +21,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
SkyColorConfig scc;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,7 +32,7 @@ private:
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
GPUBuffer * ubo_sky_color =nullptr;
|
||||
DeviceBuffer * ubo_sky_color =nullptr;
|
||||
|
||||
Primitive * ro_skyphere =nullptr;
|
||||
|
||||
@@ -71,7 +71,7 @@ private:
|
||||
if(!ubo_sky_color)
|
||||
return(false);
|
||||
|
||||
if(!material_instance->BindUBO(DescriptorSetsType::Value,"sky_color",ubo_sky_color))
|
||||
if(!material_instance->BindUBO(DescriptorSetType::Value,"sky_color",ubo_sky_color))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
@@ -88,9 +88,9 @@ private:
|
||||
|
||||
void CreateRenderObject()
|
||||
{
|
||||
const VAB *vab=material_instance->GetVAB();
|
||||
const VIL *vil=material_instance->GetVIL();
|
||||
|
||||
ro_skyphere=inline_geometry::CreateDome(db,vab,64);
|
||||
ro_skyphere=inline_geometry::CreateDome(db,vil,64);
|
||||
}
|
||||
|
||||
bool InitScene()
|
||||
|
@@ -28,7 +28,7 @@ constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
/**
|
||||
* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
Primitive *CreateRenderableTerrain(RenderResource *db,const VAB *vab,const TerrainCreateInfo *tci)
|
||||
Primitive *CreateRenderableTerrain(RenderResource *db,const VIL *vil,const TerrainCreateInfo *tci)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
GPUBuffer *ubo_color=nullptr;
|
||||
DeviceBuffer *ubo_color=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -95,9 +95,9 @@ private:
|
||||
pgci.color.Set(0.75,0.75,0.75);
|
||||
pgci.side_color.Set(1,0,0,1);
|
||||
|
||||
const VAB *vab=material_instance->GetVAB();
|
||||
const VIL *vil=material_instance->GetVIL();
|
||||
|
||||
renderable=CreatePlaneGrid(db,vab,&pgci);
|
||||
renderable=CreatePlaneGrid(db,vil,&pgci);
|
||||
}
|
||||
|
||||
bool InitScene()
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#include<iostream>
|
||||
#include<iomanip>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKInstance.h>
|
||||
@@ -86,35 +87,36 @@ int main(int,char **)
|
||||
|
||||
for(uint32_t i=0;i<count;i++)
|
||||
{
|
||||
std::cout<<i<<". ";
|
||||
std::cout<<std::setw(4)<<i<<". ";
|
||||
|
||||
std::cout<<" Format [ID:"<<vf->format<<"]["<<vf->name<<"] ";
|
||||
std::cout<<"Format [ID:"<<std::setw(10)<<vf->format<<"]["<<std::setw(16)<<vf->name<<"]";
|
||||
|
||||
if(vf->compress_type!=TextureCompressType::NONE)
|
||||
std::cout<<"use "<<texture_compress_name[size_t(vf->compress_type)]<<" compress.";
|
||||
else
|
||||
std::cout<<vf->bytes<<" bytes/pixel.";
|
||||
|
||||
if(vf->depth!=VulkanNumberType::NONE)
|
||||
std::cout<<"[Depth:"<<data_type_name[size_t(vf->depth)]<<"]";
|
||||
if(vf->depth!=VulkanBaseType::NONE)
|
||||
std::cout<<"[ Depth:"<<std::setw(8)<<data_type_name[size_t(vf->depth)]<<"]";
|
||||
|
||||
if(vf->stencil!=VulkanNumberType::NONE)
|
||||
std::cout<<"[Stencil:"<<data_type_name[size_t(vf->stencil)]<<"]";
|
||||
if(vf->stencil!=VulkanBaseType::NONE)
|
||||
std::cout<<"[Stencil:"<<std::setw(8)<<data_type_name[size_t(vf->stencil)]<<"]";
|
||||
|
||||
if((vf->depth==VulkanNumberType::NONE)
|
||||
&&(vf->stencil==VulkanNumberType::NONE))
|
||||
std::cout<<"[Color:"<<data_type_name[size_t(vf->color)]<<"]";
|
||||
if((vf->depth==VulkanBaseType::NONE)
|
||||
&&(vf->stencil==VulkanBaseType::NONE))
|
||||
std::cout<<"[ Color:"<<std::setw(8)<<data_type_name[size_t(vf->color)]<<"]";
|
||||
|
||||
{
|
||||
const VkFormatProperties fp=physical_device->GetFormatProperties(vf->format);
|
||||
|
||||
if(fp.optimalTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
|
||||
std::cout<<"[Optimal]";
|
||||
if(fp.linearTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
|
||||
std::cout<<"[Linear]";
|
||||
if(fp.bufferFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
|
||||
std::cout<<"[Buffer]";
|
||||
char olb[]="[ ]";
|
||||
|
||||
if(fp.optimalTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )olb[1]='O';
|
||||
if(fp.linearTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )olb[2]='L';
|
||||
if(fp.bufferFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )olb[2]='B';
|
||||
|
||||
std::cout<<olb;
|
||||
}
|
||||
|
||||
if(vf->compress_type!=TextureCompressType::NONE)
|
||||
std::cout<<" use "<<texture_compress_name[size_t(vf->compress_type)]<<" compress.";
|
||||
else
|
||||
std::cout<<std::setw(4)<<vf->bytes<<" bytes/pixel.";
|
||||
|
||||
std::cout<<std::endl;
|
||||
|
||||
|
@@ -3,8 +3,12 @@
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/math/HalfFloat.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/SceneInfo.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/VKRenderablePrimitiveCreater.h>
|
||||
#include<hgl/graph/mtl/2d/Material2DCreateConfig.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
@@ -14,23 +18,55 @@ constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT][2]=
|
||||
constexpr float position_data_float[VERTEX_COUNT*2]=
|
||||
{
|
||||
{ 0.0, -0.5},
|
||||
{-0.5, 0.5},
|
||||
{ 0.5, 0.5}
|
||||
0.0, -0.5,
|
||||
-0.5, 0.5,
|
||||
0.5, 0.5
|
||||
};
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT][4]=
|
||||
{ {1,0,0,1},
|
||||
{0,1,0,1},
|
||||
{0,0,1,1}
|
||||
#define USE_HALF_FLOAT_POSITION
|
||||
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
constexpr VkFormat PositionFormat=VF_V2HF;
|
||||
|
||||
half_float position_data_hf[VERTEX_COUNT*2];
|
||||
|
||||
#define position_data position_data_hf
|
||||
#else
|
||||
constexpr VkFormat PositionFormat=VF_V2F;
|
||||
|
||||
#define position_data position_data_float
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
#define USE_UNORM8_COLOR
|
||||
|
||||
#ifdef USE_UNORM8_COLOR
|
||||
constexpr uint8 color_data[VERTEX_COUNT*4]=
|
||||
{ 255,0,0,255,
|
||||
0,255,0,255,
|
||||
0,0,255,255
|
||||
};
|
||||
|
||||
constexpr VkFormat ColorFormat=VF_V4UN8;
|
||||
#else
|
||||
constexpr float color_data[VERTEX_COUNT*4]=
|
||||
{ 1,0,0,1,
|
||||
0,1,0,1,
|
||||
0,0,1,1
|
||||
};
|
||||
|
||||
constexpr VkFormat ColorFormat=VF_V4F;
|
||||
#endif//USE_UNORM8_COLOR
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
#if defined(USE_HALF_FLOAT_POSITION)||defined(USE_UNORM8_COLOR)
|
||||
VILConfig vil_config;
|
||||
#endif
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
@@ -38,29 +74,52 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
void InitVIL()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2DNDC"));
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
vil_config.Add(VAN::Position,PositionFormat);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
#ifdef USE_UNORM8_COLOR
|
||||
vil_config.Add(VAN::Color,ColorFormat);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
}
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2d");
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci,&vil_config);
|
||||
|
||||
return material_instance;
|
||||
}
|
||||
|
||||
bool InitPipeline()
|
||||
{
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
if(!primitive)return(false);
|
||||
RenderablePrimitiveCreater rpc(db,VERTEX_COUNT);
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data)))return(false);
|
||||
if(!primitive->Set(VAN::Color, db->CreateVBO(VF_V4F,VERTEX_COUNT,color_data)))return(false);
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
Float32toFloat16(position_data_hf,position_data_float,VERTEX_COUNT*2);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
if(!rpc.SetVBO(VAN::Position, PositionFormat, position_data))return(false);
|
||||
if(!rpc.SetVBO(VAN::Color, ColorFormat, color_data ))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
return(true);
|
||||
render_obj=rpc.Create(material_instance,pipeline);
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -70,7 +129,12 @@ public:
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
InitVIL();
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
|
147
example/Vulkan/fourth_triangle.cpp
Normal file
147
example/Vulkan/fourth_triangle.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
// AutoMergeMaterialInstance
|
||||
// 该范例主要演示使用一个材质下的不同材质实例传递颜色参数绘制三角形,并依赖RenderList中的自动合并功能,让同一材质下所有不同材质实例的对象一次渲染完成。
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/VKRenderablePrimitiveCreater.h>
|
||||
#include<hgl/graph/mtl/2d/Material2DCreateConfig.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
#include<hgl/color/Color.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1024;
|
||||
constexpr uint32_t SCREEN_HEIGHT=1024;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT*2]=
|
||||
{
|
||||
0.0, 0.0,
|
||||
-0.1, 0.9,
|
||||
0.1, 0.9
|
||||
};
|
||||
|
||||
constexpr uint DRAW_OBJECT_COUNT=12;
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
SceneNode render_root;
|
||||
RenderList * render_list =nullptr;
|
||||
|
||||
Material * material =nullptr;
|
||||
|
||||
struct
|
||||
{
|
||||
MaterialInstance * mi;
|
||||
Renderable * r;
|
||||
}render_obj[DRAW_OBJECT_COUNT]{};
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"PureColor2D");
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=true;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreatePureColor2D(&cfg);
|
||||
|
||||
material=db->CreateMaterial(mci);
|
||||
|
||||
if(!material)
|
||||
return(false);
|
||||
|
||||
for(uint i=0;i<DRAW_OBJECT_COUNT;i++)
|
||||
{
|
||||
render_obj[i].mi=db->CreateMaterialInstance(material);
|
||||
|
||||
if(!render_obj[i].mi)
|
||||
return(false);
|
||||
|
||||
Color4f color=GetColor4f((COLOR)(i+int(COLOR::Blue)),1.0);
|
||||
|
||||
render_obj[i].mi->WriteMIData(color,sizeof(Color4f)); //设置MaterialInstance的数据
|
||||
}
|
||||
}
|
||||
|
||||
pipeline=CreatePipeline(material,InlinePipeline::Solid2D,Prim::Triangles);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
RenderablePrimitiveCreater rpc(db,VERTEX_COUNT);
|
||||
|
||||
if(!rpc.SetVBO(VAN::Position, VF_V2F, position_data))return(false);
|
||||
|
||||
for(uint i=0;i<DRAW_OBJECT_COUNT;i++)
|
||||
{
|
||||
render_obj[i].r=rpc.Create(render_obj[i].mi,pipeline);
|
||||
|
||||
if(!render_obj[i].r)
|
||||
return(false);
|
||||
|
||||
render_root.CreateSubNode(rotate(deg2rad(360/DRAW_OBJECT_COUNT*i),Vector3f(0,0,1)),render_obj[i].r);
|
||||
}
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
|
||||
render_list->Expend(&render_root);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
~TestApp()
|
||||
{
|
||||
SAFE_CLEAR(render_list);
|
||||
}
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(false);
|
||||
|
||||
render_list=new RenderList(device);
|
||||
|
||||
if(!InitMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
BuildCommandBuffer(render_list);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
VulkanApplicationFramework::Resize(w,h);
|
||||
|
||||
BuildCommandBuffer(render_list);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
TestApp app;
|
||||
|
||||
if(!app.Init())
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,10 +1,12 @@
|
||||
// third_triangle
|
||||
// 该范例主要演示使用2D坐系统直接绘制一个渐变色的三角形
|
||||
// second_triangle
|
||||
// 该范例主要演示使用2D坐系统直接绘制一个渐变色的三角形,使用UBO传递Viewport信息
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/SceneInfo.h>
|
||||
#include<hgl/graph/VKRenderablePrimitiveCreater.h>
|
||||
#include<hgl/graph/mtl/2d/Material2DCreateConfig.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
@@ -14,19 +16,22 @@ constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT][2]=
|
||||
static float position_data[VERTEX_COUNT][2]=
|
||||
{
|
||||
{SCREEN_WIDTH*0.5, SCREEN_HEIGHT*0.25},
|
||||
{SCREEN_WIDTH*0.75, SCREEN_HEIGHT*0.75},
|
||||
{SCREEN_WIDTH*0.25, SCREEN_HEIGHT*0.75}
|
||||
{0.5, 0.25},
|
||||
{0.75, 0.75},
|
||||
{0.25, 0.75}
|
||||
};
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT][4]=
|
||||
{ {1,0,0,1},
|
||||
{
|
||||
{1,0,0,1},
|
||||
{0,1,0,1},
|
||||
{0,0,1,1}
|
||||
};
|
||||
|
||||
//#define USE_ZERO2ONE_COORD //使用左上角0,0右下角1,1的坐标系
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
@@ -40,12 +45,24 @@ private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2D"));
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2D");
|
||||
|
||||
#ifdef USE_ZERO2ONE_COORD
|
||||
cfg.coordinate_system=CoordinateSystem2D::ZeroToOne;
|
||||
#else
|
||||
cfg.coordinate_system=CoordinateSystem2D::Ortho;
|
||||
#endif//USE_ZERO2ONE_COORD
|
||||
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci);
|
||||
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
BindCameraUBO(material_instance);
|
||||
db->global_descriptor.Bind(material_instance->GetMaterial());
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
@@ -55,13 +72,22 @@ private:
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
if(!primitive)return(false);
|
||||
RenderablePrimitiveCreater rpc(db,VERTEX_COUNT);
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data)))return(false);
|
||||
if(!primitive->Set(VAN::Color, db->CreateVBO(VF_V4F,VERTEX_COUNT,color_data)))return(false);
|
||||
#ifndef USE_ZERO2ONE_COORD //使用ortho坐标系
|
||||
|
||||
for(uint i=0;i<VERTEX_COUNT;i++)
|
||||
{
|
||||
position_data[i][0]*=SCREEN_WIDTH;
|
||||
position_data[i][1]*=SCREEN_HEIGHT;
|
||||
}
|
||||
|
||||
#endif//USE_ZERO2ONE_COORD
|
||||
|
||||
if(!rpc.SetVBO(VAN::Position, VF_V2F, position_data))return(false);
|
||||
if(!rpc.SetVBO(VAN::Color, VF_V4F, color_data ))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
render_obj=rpc.Create(material_instance,pipeline);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,7 @@ private:
|
||||
Texture2D * texture =nullptr;
|
||||
Sampler * sampler =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable *renderable =nullptr;
|
||||
Renderable * renderable =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
if(!material_instance->BindSampler(DescriptorSetsType::Value,"tex",texture,sampler))return(false);
|
||||
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@@ -1,29 +1,33 @@
|
||||
// second_triangle
|
||||
// 该范例主要演示使用场景树系统绘制三角形
|
||||
// AutoInstance
|
||||
// 该范例主要演示使用RenderList系统绘制多个三角形,并利用RenderList进行排序以及自动合并进行Instance渲染
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/VKRenderablePrimitiveCreater.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/mtl/2d/Material2DCreateConfig.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
constexpr uint32_t SCREEN_WIDTH=1024;
|
||||
constexpr uint32_t SCREEN_HEIGHT=1024;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT][2]=
|
||||
constexpr float position_data[VERTEX_COUNT*2]=
|
||||
{
|
||||
{SCREEN_WIDTH*0.5, SCREEN_HEIGHT*0.25},
|
||||
{SCREEN_WIDTH*0.25, SCREEN_HEIGHT*0.75},
|
||||
{SCREEN_WIDTH*0.75, SCREEN_HEIGHT*0.75}
|
||||
0.0, 0.0,
|
||||
-0.1, 0.9,
|
||||
0.1, 0.9
|
||||
};
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT][4]=
|
||||
{ {1,0,0,1},
|
||||
{0,1,0,1},
|
||||
{0,0,1,1}
|
||||
constexpr uint8 color_data[VERTEX_COUNT][4]=
|
||||
{ {255,0,0,255},
|
||||
{0,255,0,255},
|
||||
{0,0,255,255}
|
||||
};
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
@@ -42,34 +46,48 @@ private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2D"));
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2D");
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=true;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
VILConfig vil_config;
|
||||
|
||||
vil_config.Add(VAN::Color,VF_V4UN8);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci,&vil_config);
|
||||
}
|
||||
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
BindCameraUBO(material_instance);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
if(!primitive)return(false);
|
||||
RenderablePrimitiveCreater rpc(db,VERTEX_COUNT);
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data)))return(false);
|
||||
if(!primitive->Set(VAN::Color, db->CreateVBO(VF_V4F,VERTEX_COUNT,color_data)))return(false);
|
||||
if(!rpc.SetVBO(VAN::Position, VF_V2F, position_data))return(false);
|
||||
if(!rpc.SetVBO(VAN::Color, VF_V4UN8, color_data ))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
render_obj=rpc.Create(material_instance,pipeline);
|
||||
|
||||
render_root.CreateSubNode(render_obj);
|
||||
if(!render_obj)
|
||||
return(false);
|
||||
|
||||
for(uint i=0;i<12;i++)
|
||||
render_root.CreateSubNode(rotate(deg2rad(30*i),Vector3f(0,0,1)),render_obj);
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
|
||||
render_list->Expend(GetCameraInfo(),&render_root);
|
||||
render_list->Expend(&render_root);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@@ -2,13 +2,13 @@
|
||||
#include<hgl/platform/Window.h>
|
||||
#include<hgl/graph/VKInstance.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKDeviceCreater.h>
|
||||
#include<hgl/graph/VKSemaphore.h>
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
#include<hgl/graph/VKShaderModule.h>
|
||||
#include<hgl/graph/VKImageView.h>
|
||||
#include<hgl/graph/VKPrimitive.h>
|
||||
#include<hgl/graph/VKDescriptorSets.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKRenderPass.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/graph/VKCommandBuffer.h>
|
||||
@@ -20,8 +20,10 @@
|
||||
#include<hgl/graph/VKRenderTarget.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/RenderList.h>
|
||||
#include<hgl/type/Color.h>
|
||||
#include<hgl/graph/mtl/UBOCommon.h>
|
||||
#include<hgl/color/Color.h>
|
||||
#include<hgl/Time.h>
|
||||
#include<hgl/log/LogInfo.h>
|
||||
|
||||
//#include<hgl/graph/LookAtCameraControl.h>
|
||||
#include<hgl/graph/FirstPersonCameraControl.h>
|
||||
@@ -33,6 +35,12 @@ using namespace hgl;
|
||||
using namespace hgl::io;
|
||||
using namespace hgl::graph;
|
||||
|
||||
namespace hgl{namespace graph
|
||||
{
|
||||
bool InitShaderCompiler();
|
||||
void CloseShaderCompiler();
|
||||
}}//namespace hgl::graph
|
||||
|
||||
class VulkanApplicationFramework:WindowEvent
|
||||
{
|
||||
protected:
|
||||
@@ -44,7 +52,7 @@ protected:
|
||||
|
||||
GPUDevice * device =nullptr;
|
||||
RenderPass * device_render_pass =nullptr;
|
||||
SwapchainRenderTarget * sc_render_target =nullptr;
|
||||
RTSwapchain * sc_render_target =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -59,15 +67,16 @@ protected:
|
||||
RenderResource * db =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
Camera * camera =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
|
||||
ViewportInfo vp_info;
|
||||
DeviceBuffer * ubo_vp_info =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~VulkanApplicationFramework()
|
||||
{
|
||||
SAFE_CLEAR(camera);
|
||||
CloseShaderCompiler();
|
||||
|
||||
win->Unjoin(this);
|
||||
|
||||
SAFE_CLEAR(db);
|
||||
@@ -80,6 +89,11 @@ public:
|
||||
|
||||
virtual bool Init(int w,int h)
|
||||
{
|
||||
logger::InitLogger(OS_TEXT("VulkanTest"));
|
||||
|
||||
if(!InitShaderCompiler())
|
||||
return(false);
|
||||
|
||||
clear_color.Set(0,0,0,1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
@@ -105,7 +119,6 @@ public:
|
||||
|
||||
cili.lunarg.standard_validation = true;
|
||||
cili.khronos.validation = true;
|
||||
//cili.RenderDoc.Capture = true;
|
||||
|
||||
inst=CreateInstance("VulkanTest",nullptr,&cili);
|
||||
|
||||
@@ -127,48 +140,20 @@ public:
|
||||
win->Join(this);
|
||||
|
||||
{
|
||||
camera=new Camera;
|
||||
vp_info.Set(w,h);
|
||||
|
||||
camera->width=w;
|
||||
camera->height=h;
|
||||
camera->vp_width=w;
|
||||
camera->vp_height=h;
|
||||
ubo_vp_info=db->CreateUBO(sizeof(ViewportInfo),&vp_info);
|
||||
|
||||
camera->pos=Vector3f(10,10,10);
|
||||
|
||||
camera->RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&camera->info);
|
||||
db->global_descriptor.AddUBO(mtl::SBS_ViewportInfo.name,ubo_vp_info);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
const CameraInfo &GetCameraInfo()
|
||||
{
|
||||
return camera->info;
|
||||
}
|
||||
|
||||
GPUBuffer *GetCameraInfoBuffer()
|
||||
{
|
||||
return ubo_camera_info;
|
||||
}
|
||||
|
||||
bool BindCameraUBO(MaterialInstance *mi)
|
||||
{
|
||||
return mi->BindUBO(DescriptorSetsType::Global,"g_camera",ubo_camera_info);
|
||||
}
|
||||
|
||||
virtual void Resize(int w,int h)
|
||||
{
|
||||
camera->width=w;
|
||||
camera->height=h;
|
||||
camera->vp_width=w;
|
||||
camera->vp_height=h;
|
||||
|
||||
camera->RefreshCameraInfo();
|
||||
|
||||
ubo_camera_info->Write(&camera->info);
|
||||
vp_info.Set(w,h);
|
||||
ubo_vp_info->Write(&vp_info);
|
||||
}
|
||||
|
||||
void SetClearColor(const Color4f &cc)
|
||||
@@ -212,20 +197,20 @@ public:
|
||||
{
|
||||
if(!ri)return(false);
|
||||
|
||||
const IndexBuffer *ib=ri->GetIndexBuffer();
|
||||
const VertexInputData *vid=ri->GetVertexInputData();
|
||||
|
||||
cb->Begin();
|
||||
cb->BindFramebuffer(rp,fb);
|
||||
cb->SetClearColor(0,clear_color);
|
||||
cb->BeginRenderPass();
|
||||
cb->BindPipeline(ri->GetPipeline());
|
||||
cb->BindDescriptorSets(ri);
|
||||
cb->BindDescriptorSets(ri->GetMaterial());
|
||||
cb->BindVBO(ri);
|
||||
|
||||
if (ib)
|
||||
cb->DrawIndexed(ib->GetCount(),ri->GetInstanceCount());
|
||||
if (vid->index_buffer->buffer)
|
||||
cb->DrawIndexed(vid->index_buffer->buffer->GetCount());
|
||||
else
|
||||
cb->Draw(ri->GetDrawCount(),ri->GetInstanceCount());
|
||||
cb->Draw(vid->vertex_count);
|
||||
|
||||
cb->EndRenderPass();
|
||||
cb->End();
|
||||
@@ -456,6 +441,10 @@ class CameraAppFramework:public VulkanApplicationFramework
|
||||
|
||||
protected:
|
||||
|
||||
Camera * camera =nullptr;
|
||||
|
||||
DeviceBuffer * ubo_camera_info =nullptr;
|
||||
|
||||
FirstPersonCameraControl *camera_control=nullptr;
|
||||
|
||||
CameraKeyboardControl * ckc=nullptr;
|
||||
@@ -469,6 +458,7 @@ public:
|
||||
{
|
||||
SAFE_CLEAR(ckc);
|
||||
SAFE_CLEAR(cmc);
|
||||
SAFE_CLEAR(camera);
|
||||
}
|
||||
|
||||
virtual bool Init(int w,int h)
|
||||
@@ -482,7 +472,7 @@ public:
|
||||
|
||||
virtual void InitCamera(int w,int h)
|
||||
{
|
||||
camera_control=new FirstPersonCameraControl(camera);
|
||||
camera_control=new FirstPersonCameraControl(&vp_info,camera);
|
||||
|
||||
camera_control->Refresh(); //更新矩阵计算
|
||||
|
||||
@@ -491,26 +481,47 @@ public:
|
||||
|
||||
win->Join(ckc);
|
||||
win->Join(cmc);
|
||||
|
||||
camera=new Camera;
|
||||
|
||||
camera->pos=Vector3f(10,10,10);
|
||||
|
||||
RefreshCameraInfo(&camera_control->GetCameraInfo(),&vp_info,camera);
|
||||
|
||||
ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&camera_control->GetCameraInfo());
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
camera->width=w;
|
||||
camera->height=h;
|
||||
camera->vp_width=w;
|
||||
camera->vp_height=h;
|
||||
vp_info.Set(w,h);
|
||||
|
||||
camera_control->Refresh();
|
||||
|
||||
ubo_camera_info->Write(&camera->info);
|
||||
ubo_camera_info->Write(&camera_control->GetCameraInfo());
|
||||
}
|
||||
|
||||
const CameraInfo &GetCameraInfo()
|
||||
{
|
||||
return camera_control->GetCameraInfo();
|
||||
}
|
||||
|
||||
DeviceBuffer *GetCameraInfoBuffer()
|
||||
{
|
||||
return ubo_camera_info;
|
||||
}
|
||||
|
||||
bool BindCameraUBO(MaterialInstance *mi)
|
||||
{
|
||||
return mi->BindUBO(DescriptorSetType::Global,"g_camera",ubo_camera_info);
|
||||
}
|
||||
|
||||
virtual void BuildCommandBuffer(uint32_t index)=0;
|
||||
|
||||
virtual void Draw()override
|
||||
{
|
||||
camera_control->Refresh(); //更新相机矩阵
|
||||
ubo_camera_info->Write(&camera->info); //写入缓冲区
|
||||
camera_control->Refresh(); //更新相机矩阵
|
||||
|
||||
ubo_camera_info->Write(&camera_control->GetCameraInfo()); //写入缓冲区
|
||||
|
||||
const uint32_t index=AcquireNextImage();
|
||||
|
||||
|
17
inc/hgl/graph/CoordinateSystem.h
Normal file
17
inc/hgl/graph/CoordinateSystem.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/TypeFunc.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
enum class CoordinateSystem2D
|
||||
{
|
||||
NDC,
|
||||
ZeroToOne, //左上角为0,0;右下角为1,1
|
||||
Ortho, //左上角为0,0;右下角为(width-1),(height-1)
|
||||
|
||||
ENUM_CLASS_RANGE(NDC,Ortho)
|
||||
};
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
@@ -4,7 +4,7 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/math/Vector.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
#include<hgl/graph/AABB.h>
|
||||
namespace hgl
|
||||
{
|
||||
@@ -20,12 +20,12 @@ namespace hgl
|
||||
RectScope2f scope;
|
||||
};//struct RectangleCreateInfo
|
||||
|
||||
Primitive *CreateRectangle(RenderResource *db,const VAB *vab,const RectangleCreateInfo *rci);
|
||||
Primitive *CreateRectangle(RenderResource *db,const VIL *vil,const RectangleCreateInfo *rci);
|
||||
|
||||
/**
|
||||
* 创建延迟渲染用全屏平面
|
||||
*/
|
||||
Primitive *CreateGBufferCompositionRectangle(RenderResource *db,const VAB *vab);
|
||||
Primitive *CreateGBufferCompositionRectangle(RenderResource *db,const VIL *vil);
|
||||
|
||||
/**
|
||||
* 圆角矩形创建信息(扇形/线圈)
|
||||
@@ -36,7 +36,7 @@ namespace hgl
|
||||
uint32_t round_per; ///<圆角精度
|
||||
};//struct RoundRectangleCreateInfo:public RectangleCreateInfo
|
||||
|
||||
Primitive *CreateRoundRectangle(RenderResource *db,const VAB *vab,const RoundRectangleCreateInfo *rci);
|
||||
Primitive *CreateRoundRectangle(RenderResource *db,const VIL *vil,const RoundRectangleCreateInfo *rci);
|
||||
|
||||
/**
|
||||
* 圆形创建信息
|
||||
@@ -56,7 +56,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个2D圆形(扇形/线圈)
|
||||
*/
|
||||
Primitive *CreateCircle(RenderResource *db,const VAB *vab,const CircleCreateInfo *cci);
|
||||
Primitive *CreateCircle(RenderResource *db,const VIL *vil,const CircleCreateInfo *cci);
|
||||
|
||||
/**
|
||||
* 平面网格创建信息
|
||||
@@ -75,7 +75,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个平面网格(线条)
|
||||
*/
|
||||
Primitive *CreatePlaneGrid(RenderResource *db,const VAB *vab,const PlaneGridCreateInfo *pgci);
|
||||
Primitive *CreatePlaneGrid(RenderResource *db,const VIL *vil,const PlaneGridCreateInfo *pgci);
|
||||
|
||||
struct PlaneCreateInfo
|
||||
{
|
||||
@@ -93,7 +93,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个平面(三角形)
|
||||
*/
|
||||
Primitive *CreatePlane(RenderResource *db,const VAB *vab,const PlaneCreateInfo *pci);
|
||||
Primitive *CreatePlane(RenderResource *db,const VIL *vil,const PlaneCreateInfo *pci);
|
||||
|
||||
struct CubeCreateInfo
|
||||
{
|
||||
@@ -129,7 +129,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个立方体(三角形)
|
||||
*/
|
||||
Primitive *CreateCube(RenderResource *db,const VAB *vab,const CubeCreateInfo *cci);
|
||||
Primitive *CreateCube(RenderResource *db,const VIL *vil,const CubeCreateInfo *cci);
|
||||
|
||||
struct BoundingBoxCreateInfo
|
||||
{
|
||||
@@ -160,17 +160,17 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个绑定盒(线条)
|
||||
*/
|
||||
Primitive *CreateBoundingBox(RenderResource *db,const VAB *vab,const BoundingBoxCreateInfo *cci);
|
||||
Primitive *CreateBoundingBox(RenderResource *db,const VIL *vil,const BoundingBoxCreateInfo *cci);
|
||||
|
||||
/**
|
||||
* 创建一个球心坐标为0,0,0,半径为1的球体(三角形)
|
||||
*/
|
||||
Primitive *CreateSphere(RenderResource *db,const VAB *vab,const uint numberSlices);
|
||||
Primitive *CreateSphere(RenderResource *db,const VIL *vil,const uint numberSlices);
|
||||
|
||||
/**
|
||||
* 创建一个穹顶(三角形)
|
||||
*/
|
||||
Primitive *CreateDome(RenderResource *db,const VAB *vab, const uint numberSlices);
|
||||
Primitive *CreateDome(RenderResource *db,const VIL *vil, const uint numberSlices);
|
||||
|
||||
struct TorusCreateInfo
|
||||
{
|
||||
@@ -186,7 +186,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个圆环(三角形)
|
||||
*/
|
||||
Primitive *CreateTorus(RenderResource *db,const VAB *vab,const TorusCreateInfo *tci);
|
||||
Primitive *CreateTorus(RenderResource *db,const VIL *vil,const TorusCreateInfo *tci);
|
||||
|
||||
struct CylinderCreateInfo
|
||||
{
|
||||
@@ -198,7 +198,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个圆柱(三角形)
|
||||
*/
|
||||
Primitive *CreateCylinder(RenderResource *db,const VAB *vab,const CylinderCreateInfo *cci);
|
||||
Primitive *CreateCylinder(RenderResource *db,const VIL *vil,const CylinderCreateInfo *cci);
|
||||
|
||||
struct ConeCreateInfo
|
||||
{
|
||||
@@ -211,7 +211,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个圆锥(三角形)
|
||||
*/
|
||||
Primitive *CreateCone(RenderResource *db,const VAB *vab,const ConeCreateInfo *cci);
|
||||
Primitive *CreateCone(RenderResource *db,const VIL *vil,const ConeCreateInfo *cci);
|
||||
|
||||
struct AxisCreateInfo
|
||||
{
|
||||
@@ -232,7 +232,7 @@ namespace hgl
|
||||
/**
|
||||
* 创建一个坐标线(线条)
|
||||
*/
|
||||
Primitive *CreateAxis(RenderResource *db,const VAB *vab,const AxisCreateInfo *aci);
|
||||
Primitive *CreateAxis(RenderResource *db,const VIL *vil,const AxisCreateInfo *aci);
|
||||
}//namespace inline_geometry
|
||||
}//namespace graph
|
||||
};//namespace hgl
|
||||
|
75
inc/hgl/graph/MaterialRenderList.h
Normal file
75
inc/hgl/graph/MaterialRenderList.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
#include<hgl/graph/RenderNode.h>
|
||||
#include<hgl/graph/VKVBOList.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class RenderAssignBuffer;
|
||||
|
||||
/**
|
||||
* 同一材质的对象渲染列表
|
||||
*/
|
||||
class MaterialRenderList
|
||||
{
|
||||
GPUDevice *device;
|
||||
RenderCmdBuffer *cmd_buf;
|
||||
|
||||
Material *mtl;
|
||||
|
||||
RenderNodeList rn_list;
|
||||
|
||||
private:
|
||||
|
||||
RenderAssignBuffer *assign_buffer;
|
||||
|
||||
struct RenderItem
|
||||
{
|
||||
uint32_t first;
|
||||
uint32_t count;
|
||||
|
||||
Pipeline * pipeline;
|
||||
MaterialInstance * mi;
|
||||
const VertexInputData * vid;
|
||||
|
||||
public:
|
||||
|
||||
void Set(Renderable *);
|
||||
};
|
||||
|
||||
MaterialInstanceSets mi_set;
|
||||
DataArray<RenderItem> ri_array;
|
||||
uint ri_count;
|
||||
|
||||
void StatMI();
|
||||
void Stat();
|
||||
|
||||
protected:
|
||||
|
||||
VBOList * vbo_list;
|
||||
|
||||
const VIL * last_vil;
|
||||
Pipeline * last_pipeline;
|
||||
const VertexInputData * last_vid;
|
||||
uint last_index;
|
||||
|
||||
void Bind(MaterialInstance *);
|
||||
bool Bind(const VertexInputData *,const uint);
|
||||
|
||||
void Render(RenderItem *);
|
||||
|
||||
public:
|
||||
|
||||
MaterialRenderList(GPUDevice *d,Material *m);
|
||||
~MaterialRenderList();
|
||||
|
||||
void Add(Renderable *ri,const Matrix4f &mat);
|
||||
|
||||
void Clear()
|
||||
{
|
||||
rn_list.Clear();
|
||||
}
|
||||
|
||||
void End();
|
||||
|
||||
void Render(RenderCmdBuffer *);
|
||||
};//class MaterialRenderList
|
||||
VK_NAMESPACE_END
|
32
inc/hgl/graph/MaterialRenderMap.h
Normal file
32
inc/hgl/graph/MaterialRenderMap.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include<hgl/graph/MaterialRenderList.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class MaterialRenderMap:public ObjectMap<Material *,MaterialRenderList>
|
||||
{
|
||||
public:
|
||||
|
||||
MaterialRenderMap()=default;
|
||||
virtual ~MaterialRenderMap()=default;
|
||||
|
||||
void Begin()
|
||||
{
|
||||
for(auto *it:data_list)
|
||||
it->value->Clear();
|
||||
}
|
||||
|
||||
void End()
|
||||
{
|
||||
for(auto *it:data_list)
|
||||
it->value->End();
|
||||
}
|
||||
|
||||
void Render(RenderCmdBuffer *rcb)
|
||||
{
|
||||
if(!rcb)return;
|
||||
|
||||
for(auto *it:data_list)
|
||||
it->value->Render(rcb);
|
||||
}
|
||||
};//class MaterialRenderMap
|
||||
VK_NAMESPACE_END
|
@@ -8,45 +8,45 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
struct ShaderStageBind
|
||||
{
|
||||
AnsiString name;
|
||||
uint binding;
|
||||
VAD * data =nullptr;
|
||||
VBO * vbo =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
~ShaderStageBind()
|
||||
{
|
||||
SAFE_CLEAR(data);
|
||||
}
|
||||
};//struct ShaderStageBind
|
||||
|
||||
using ShaderStageBindMap=MapObject<AnsiString,ShaderStageBind>;
|
||||
|
||||
/**
|
||||
* 可绘制图元创建器
|
||||
*/
|
||||
class PrimitiveCreater
|
||||
{
|
||||
struct PrimitiveVertexBuffer
|
||||
{
|
||||
AnsiString name;
|
||||
uint binding;
|
||||
VAD * data =nullptr;
|
||||
VBO * vbo =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
~PrimitiveVertexBuffer()
|
||||
{
|
||||
SAFE_CLEAR(data);
|
||||
}
|
||||
};//struct PrimitiveVertexBuffer
|
||||
|
||||
using PVBMap=ObjectMap<AnsiString,PrimitiveVertexBuffer>;
|
||||
|
||||
protected:
|
||||
|
||||
RenderResource *db;
|
||||
Material *mtl;
|
||||
|
||||
const VAB *vab;
|
||||
const VIL *vil;
|
||||
|
||||
protected:
|
||||
|
||||
uint32 vertices_number;
|
||||
|
||||
IndexBuffer * ibo;
|
||||
ShaderStageBindMap ssb_map;
|
||||
PVBMap vbo_map;
|
||||
|
||||
public:
|
||||
|
||||
PrimitiveCreater(RenderResource *sdb,const VAB *);
|
||||
PrimitiveCreater(RenderResource *sdb,const VIL *);
|
||||
virtual ~PrimitiveCreater()=default;
|
||||
|
||||
virtual bool Init(const uint32 vertices_count); ///<初始化,参数为顶点数量
|
||||
@@ -54,9 +54,9 @@ namespace hgl
|
||||
VAD * CreateVAD(const AnsiString &name); ///<创建一个顶点属性缓冲区
|
||||
|
||||
template<typename T>
|
||||
T * CreateVADA(const AnsiString &name) ///<创建一个顶点属性缓冲区以及访问器
|
||||
T * AccessVAD(const AnsiString &name) ///<创建一个顶点属性缓冲区以及访问器
|
||||
{
|
||||
const VkFormat format=vab->GetFormat(name);
|
||||
const VkFormat format=vil->GetVulkanFormat(name);
|
||||
|
||||
if(format!=T::GetVulkanFormat())
|
||||
return(nullptr);
|
||||
@@ -66,11 +66,11 @@ namespace hgl
|
||||
if(!vad)
|
||||
return(nullptr);
|
||||
|
||||
T *vada=T::Create(vad);
|
||||
T *access=T::Create(vad);
|
||||
|
||||
vada->Begin();
|
||||
access->Begin();
|
||||
|
||||
return vada;
|
||||
return access;
|
||||
}
|
||||
|
||||
bool WriteVAD(const AnsiString &name,const void *data,const uint32_t bytes); ///<直接写入顶点属性数据
|
||||
@@ -78,7 +78,7 @@ namespace hgl
|
||||
uint16 * CreateIBO16(uint count,const uint16 *data=nullptr); ///<创建16位的索引缓冲区
|
||||
uint32 * CreateIBO32(uint count,const uint32 *data=nullptr); ///<创建32位的索引缓冲区
|
||||
|
||||
virtual Primitive * Finish(); ///<结束并创建可渲染对象
|
||||
virtual Primitive * Finish(); ///<结束并创建可渲染对象
|
||||
};//class PrimitiveCreater
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -2,72 +2,42 @@
|
||||
#define HGL_GRAPH_RENDER_LIST_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/Camera.h>
|
||||
#include<hgl/graph/SceneNode.h>
|
||||
#include<hgl/graph/RenderNode.h>
|
||||
#include<hgl/graph/MaterialRenderMap.h>
|
||||
#include<hgl/graph/VKArrayBuffer.h>
|
||||
#include<hgl/graph/SceneInfo.h>
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
#include<hgl/graph/VKMaterial.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
using MVPArrayBuffer=GPUArrayBuffer<MVPMatrix>;
|
||||
using MaterialSets=SortedSets<Material *>;
|
||||
|
||||
/**
|
||||
* 渲染对象列表<br>
|
||||
* 已经展开的渲染对象列表,产生mvp用UBO/SSBO等数据,最终创建RenderCommandBuffer
|
||||
* 该类会长期保存使用过的材质信息,避重新分配造成的时间和空间浪费。如需彻底清空列表请使用Clear()函数
|
||||
*/
|
||||
class RenderList
|
||||
{
|
||||
GPUDevice * device;
|
||||
RenderCmdBuffer *cmd_buf;
|
||||
protected:
|
||||
|
||||
private:
|
||||
GPUDevice * device;
|
||||
|
||||
CameraInfo camera_info;
|
||||
|
||||
RenderNodeList render_node_list; ///<场景节点列表
|
||||
MaterialSets material_sets; ///<材质合集
|
||||
|
||||
RenderNodeComparator render_node_comparator;
|
||||
|
||||
private:
|
||||
|
||||
MVPArrayBuffer *mvp_array;
|
||||
List<Renderable *> ri_list;
|
||||
|
||||
VkDescriptorSet ds_list[(size_t)DescriptorSetsType::RANGE_SIZE];
|
||||
DescriptorSets *renderable_desc_sets;
|
||||
|
||||
uint32_t ubo_offset;
|
||||
uint32_t ubo_align;
|
||||
uint renderable_count; ///<可渲染对象数量
|
||||
MaterialRenderMap mrl_map; ///<按材质分类的渲染列表
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool Begin();
|
||||
virtual bool Expend(SceneNode *);
|
||||
virtual void End();
|
||||
|
||||
private:
|
||||
|
||||
Pipeline * last_pipeline;
|
||||
MaterialParameters *last_mp[(size_t)DescriptorSetsType::RANGE_SIZE];
|
||||
uint32_t last_vbo;
|
||||
|
||||
void Render(Renderable *);
|
||||
virtual bool ExpendNode(SceneNode *);
|
||||
|
||||
public:
|
||||
|
||||
RenderList(GPUDevice *);
|
||||
virtual ~RenderList();
|
||||
|
||||
virtual bool Expend(const CameraInfo &,SceneNode *);
|
||||
virtual bool Expend(SceneNode *); ///<展开场景树到渲染列表
|
||||
|
||||
virtual bool Render(RenderCmdBuffer *);
|
||||
};//class RenderList
|
||||
virtual bool Render(RenderCmdBuffer *); ///<渲染所有对象
|
||||
|
||||
virtual void Clear(); ///<彻底清理
|
||||
};//class RenderList
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_RENDER_LIST_INCLUDE
|
||||
|
@@ -1,39 +1,29 @@
|
||||
#ifndef HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
#define HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
|
||||
#include<hgl/math/Vector.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/graph/SceneInfo.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class Renderable;
|
||||
class Material;
|
||||
class MaterialInstance;
|
||||
class GPUDevice;
|
||||
struct VertexInputData;
|
||||
struct IndexBufferData;
|
||||
|
||||
struct RenderNode
|
||||
{
|
||||
MVPMatrix matrix;
|
||||
|
||||
Vector3f WorldCenter;
|
||||
|
||||
float distance_to_camera_square;
|
||||
// float distance_to_camera;
|
||||
Matrix4f local_to_world;
|
||||
|
||||
Renderable *ri;
|
||||
};
|
||||
|
||||
public:
|
||||
using RenderNodeList=List<RenderNode>;
|
||||
|
||||
/**
|
||||
* 取得渲染对象ubo独占区大小
|
||||
*/
|
||||
virtual const uint32 GetUBOBytes()const{return sizeof(MVPMatrix);}
|
||||
};//struct RenderNode
|
||||
|
||||
using RenderNodeList=List<RenderNode *>;
|
||||
using MaterialInstanceSets=SortedSets<MaterialInstance *>; ///<材质实例集合
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
||||
using RenderNodePointer=hgl::graph::RenderNode *;
|
||||
using RenderNodeComparator=Comparator<RenderNodePointer>;
|
||||
|
||||
#endif//HGL_GRAPH_RENDER_NODE_INCLUDE
|
||||
|
18
inc/hgl/graph/RenderTargetOutputConfig.h
Normal file
18
inc/hgl/graph/RenderTargetOutputConfig.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef HGL_GRAPH_RT_OUTPUT_CONFIG_INCLUDE
|
||||
#define HGL_GRAPH_RT_OUTPUT_CONFIG_INCLUDE
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
struct RenderTargetOutputConfig
|
||||
{
|
||||
uint color; ///<要输出几个颜色缓冲区
|
||||
bool depth; ///<是否输出到深度缓冲区
|
||||
bool stencil; ///<是否输出到模板缓冲区
|
||||
};
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_RT_OUTPUT_CONFIG_INCLUDE
|
@@ -7,7 +7,7 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* MVP矩阵
|
||||
*/
|
||||
struct MVPMatrix
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef HGL_GRAPH_SCENE_NODE_INCLUDE
|
||||
#define HGL_GRAPH_SCENE_NODE_INCLUDE
|
||||
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/ObjectList.h>
|
||||
#include<hgl/graph/SceneOrient.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/AABB.h>
|
||||
@@ -43,7 +43,7 @@ namespace hgl
|
||||
|
||||
void Clear()
|
||||
{
|
||||
SubNode.ClearData();
|
||||
SubNode.Clear();
|
||||
render_obj=nullptr;
|
||||
}
|
||||
|
||||
|
25
inc/hgl/graph/StaticRenderManager.h
Normal file
25
inc/hgl/graph/StaticRenderManager.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef HGL_GRAPH_STATIC_RENDER_MANAGER_INCLUDE
|
||||
#define HGL_GRAPH_STATIC_RENDER_MANAGER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
class RawMesh
|
||||
{
|
||||
};
|
||||
|
||||
/**
|
||||
* 静态渲染管理器<br>
|
||||
* 静态渲染指的是不会产生资源变动的内容,而不是指不会动的内容。
|
||||
*/
|
||||
class StaticRenderManager
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~StaticRenderManager()=default;
|
||||
|
||||
};//class StaticRenderManager
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_STATIC_RENDER_MANAGER_INCLUDE
|
@@ -3,8 +3,8 @@
|
||||
|
||||
#include<hgl/io/InputStream.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/Bitmap.h>
|
||||
#include<hgl/graph/VKFormat.h>
|
||||
#include<hgl/graph/BitmapData.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
|
@@ -1,32 +1,17 @@
|
||||
#ifndef HGL_GRAPH_TILE_DATA_INCLUDE
|
||||
#define HGL_GRAPH_TILE_DATA_INCLUDE
|
||||
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/Pool.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
#include<hgl/graph/Bitmap.h>
|
||||
#include<hgl/graph/BitmapData.h>
|
||||
#include<hgl/graph/ImageRegion.h>
|
||||
#include<hgl/graph/tile/TileObject.h>
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
|
||||
VK_NAMESPACE_USING
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
using TileUVPixel=RectScope2i;
|
||||
using TileUVFloat=RectScope2f;
|
||||
|
||||
using TileUVFloatList=List<TileUVFloat>;
|
||||
using TileUVFloatMap=Map<u32char,TileUVFloat>;
|
||||
|
||||
struct TileObject
|
||||
{
|
||||
int col,row; //当前tile在整个纹理中的tile位置
|
||||
|
||||
TileUVPixel uv_pixel; //以象素为单位的tile位置和尺寸
|
||||
TileUVFloat uv_float; //以浮点为单位的tile位置和尺寸
|
||||
};//struct TileObject
|
||||
|
||||
/**
|
||||
* TileData是一种处理大量等同尺寸及格式贴图的管理机制,程序会自动根据显卡最大贴图处理能力来创建尽可能符合需求的贴图。(注:Tile的大小不必符合2次幂)
|
||||
* Tile的增加或删除,程序会自动排序,尽可能小的减少I/O消耗。
|
||||
@@ -48,7 +33,7 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
GPUBuffer *tile_buffer; ///<Tile暂存缓冲区
|
||||
DeviceBuffer *tile_buffer; ///<Tile暂存缓冲区
|
||||
|
||||
List<Image2DRegion> commit_list;
|
||||
uint8 *commit_ptr;
|
||||
|
@@ -1,11 +1,10 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_INCLUDE
|
||||
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<iostream>
|
||||
#include<hgl/graph/VKNamespace.h>
|
||||
#include<hgl/graph/VKFormat.h>
|
||||
#include<hgl/graph/VKPrimitiveType.h>
|
||||
@@ -33,12 +32,12 @@ class VulkanInstance;
|
||||
class GPUPhysicalDevice;
|
||||
class GPUDevice;
|
||||
struct GPUDeviceAttribute;
|
||||
class GPUQueue;
|
||||
class DeviceQueue;
|
||||
class ImageView;
|
||||
class Framebuffer;
|
||||
struct Swapchain;
|
||||
class RenderTarget;
|
||||
class SwapchainRenderTarget;
|
||||
class RTSwapchain;
|
||||
|
||||
class Texture;
|
||||
class Texture1D;
|
||||
@@ -51,15 +50,21 @@ class TextureCubeArray;
|
||||
|
||||
class Sampler;
|
||||
|
||||
class GPUMemory;
|
||||
class GPUBuffer;
|
||||
struct GPUBufferData;
|
||||
class DeviceMemory;
|
||||
class DeviceBuffer;
|
||||
struct DeviceBufferData;
|
||||
|
||||
class VertexAttribBuffer;
|
||||
using VBO=VertexAttribBuffer;
|
||||
|
||||
class IndexBuffer;
|
||||
|
||||
struct IndexBufferData
|
||||
{
|
||||
IndexBuffer *buffer=nullptr;
|
||||
VkDeviceSize offset=0;
|
||||
};
|
||||
|
||||
class GPUCmdBuffer;
|
||||
class RenderCmdBuffer;
|
||||
class TextureCmdBuffer;
|
||||
@@ -67,46 +72,18 @@ class TextureCmdBuffer;
|
||||
class RenderPass;
|
||||
class DeviceRenderPassManage;
|
||||
|
||||
class GPUFence;
|
||||
class GPUSemaphore;
|
||||
|
||||
enum class DescriptorSetsType
|
||||
{
|
||||
//设计使其对应shader中的set
|
||||
|
||||
Global=0, ///<全局参数(如太阳光等)
|
||||
Material, ///<材质中永远不变的参数
|
||||
// Texture, ///<材质中的纹理参数
|
||||
Value, ///<材质中的变量参数
|
||||
Primitive, ///<渲染实例参数(如Local2World matrix)
|
||||
|
||||
ENUM_CLASS_RANGE(Global,Primitive)
|
||||
};//
|
||||
|
||||
const DescriptorSetsType CheckDescriptorSetsType(const char *str);
|
||||
|
||||
constexpr char *DescriptSetsTypeName[]=
|
||||
{
|
||||
"Global","Material","Value","Renderable"
|
||||
};
|
||||
|
||||
inline const char *GetDescriptorSetsTypeName(const enum class DescriptorSetsType &type)
|
||||
{
|
||||
ENUM_CLASS_RANGE_ERROR_RETURN_NULLPTR(type);
|
||||
|
||||
return DescriptSetsTypeName[(size_t)type];
|
||||
}
|
||||
class Fence;
|
||||
class Semaphore;
|
||||
|
||||
struct PipelineLayoutData;
|
||||
class DescriptorSets;
|
||||
class DescriptorSet;
|
||||
|
||||
struct ShaderStage;
|
||||
struct ShaderAttribute;
|
||||
|
||||
class ShaderResource;
|
||||
class ShaderModule;
|
||||
class VertexShaderModule;
|
||||
class ShaderModuleMap;
|
||||
class MaterialDescriptorSets;
|
||||
class MaterialDescriptorManager;
|
||||
|
||||
class Material;
|
||||
class MaterialParameters;
|
||||
@@ -115,20 +92,14 @@ struct PipelineData;
|
||||
enum class InlinePipeline;
|
||||
class Pipeline;
|
||||
|
||||
struct VAConfig
|
||||
{
|
||||
VkFormat format=PF_UNDEFINED;
|
||||
bool instance=false;
|
||||
struct VAConfig;
|
||||
class VILConfig;
|
||||
class VertexInput;
|
||||
|
||||
public:
|
||||
struct VertexInputFormat;
|
||||
|
||||
CompOperatorMemcmp(const VAConfig &);
|
||||
};
|
||||
|
||||
using VABConfigInfo=Map<AnsiString,VAConfig>;
|
||||
|
||||
class VertexAttributeBinding;
|
||||
using VAB=VertexAttributeBinding;
|
||||
class VertexInputLayout;
|
||||
using VIL=VertexInputLayout;
|
||||
|
||||
class Primitive;
|
||||
class Renderable;
|
||||
@@ -166,38 +137,13 @@ inline const uint32_t GetMipLevel(const VkExtent3D &ext)
|
||||
/**
|
||||
* 索引类型,等同于VkIndexType
|
||||
*/
|
||||
enum IndexType
|
||||
enum IndexType:uint
|
||||
{
|
||||
U16=0,
|
||||
U32
|
||||
U32,
|
||||
U8=VK_INDEX_TYPE_UINT8_EXT,
|
||||
};
|
||||
|
||||
enum class ShaderStageBit
|
||||
{
|
||||
Vertex =VK_SHADER_STAGE_VERTEX_BIT,
|
||||
TessControl =VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
|
||||
TessEval =VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
|
||||
Geometry =VK_SHADER_STAGE_GEOMETRY_BIT,
|
||||
Fragment =VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
Compute =VK_SHADER_STAGE_COMPUTE_BIT
|
||||
};//enum class ShaderStageBit
|
||||
|
||||
inline const uint GetShaderCountByBits(const uint32_t bits)
|
||||
{
|
||||
uint comp=(uint)VK_SHADER_STAGE_VERTEX_BIT;
|
||||
uint result=0;
|
||||
|
||||
for(uint i=0;i<6;i++)
|
||||
{
|
||||
if(bits&comp)
|
||||
++result;
|
||||
|
||||
comp<<=1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* max-lengths:
|
||||
*
|
||||
@@ -218,61 +164,5 @@ inline void copy(VkExtent3D &e3d,const VkExtent2D &e2d,const uint32 depth=1)
|
||||
e3d.height =e2d.height;
|
||||
e3d.depth =depth;
|
||||
}
|
||||
|
||||
inline void debug_out_vk_version(const uint32_t version)
|
||||
{
|
||||
std::cout<<VK_VERSION_MAJOR(version)<<"."
|
||||
<<VK_VERSION_MINOR(version)<<"."
|
||||
<<VK_VERSION_PATCH(version);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline hgl::String<T> VkUUID2String(const uint8_t *pipelineCacheUUID)
|
||||
{
|
||||
T *hstr=new T[VK_UUID_SIZE*2+1];
|
||||
|
||||
DataToLowerHexStr(hstr,pipelineCacheUUID,VK_UUID_SIZE);
|
||||
|
||||
return hgl::String<T>::newOf(hstr,VK_UUID_SIZE*2);
|
||||
}
|
||||
|
||||
inline void debug_out(const char *front,const hgl::List<VkLayerProperties> &layer_properties)
|
||||
{
|
||||
const int property_count=layer_properties.GetCount();
|
||||
|
||||
if(property_count<=0)return;
|
||||
|
||||
const VkLayerProperties *lp=layer_properties.GetData();
|
||||
|
||||
for(int i=0;i<property_count;i++)
|
||||
{
|
||||
std::cout<<front<<" Layer Propertyes ["<<i<<"] : "<<lp->layerName<<" [spec: ";
|
||||
debug_out_vk_version(lp->specVersion);
|
||||
|
||||
std::cout<<", impl: ";
|
||||
debug_out_vk_version(lp->implementationVersion);
|
||||
|
||||
std::cout<<"] desc: "<<lp->description<<std::endl;
|
||||
++lp;
|
||||
}
|
||||
}
|
||||
|
||||
inline void debug_out(const char *front,const hgl::List<VkExtensionProperties> &extension_properties)
|
||||
{
|
||||
const int extension_count=extension_properties.GetCount();
|
||||
|
||||
if(extension_count<=0)return;
|
||||
|
||||
VkExtensionProperties *ep=extension_properties.GetData();
|
||||
for(int i=0;i<extension_count;i++)
|
||||
{
|
||||
std::cout<<front<<" Extension Propertyes ["<<i<<"] : "<<ep->extensionName<<" ver: ";
|
||||
|
||||
debug_out_vk_version(ep->specVersion);
|
||||
|
||||
std::cout<<std::endl;
|
||||
++ep;
|
||||
}
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_INCLUDE
|
||||
|
@@ -1,90 +1,75 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_ARRAY_BUFFER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
#include<hgl/graph/VKMemoryAllocator.h>
|
||||
#include<hgl/type/Collection.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDynamicBufferAccess.h>
|
||||
namespace hgl
|
||||
{
|
||||
class Collection;
|
||||
|
||||
namespace graph
|
||||
{
|
||||
class VKMemoryAllocator;
|
||||
|
||||
/**
|
||||
* GPU数据阵列缓冲区<br>
|
||||
* 它用于储存多份相同格式的数据,常用于多物件渲染,instance等
|
||||
*/
|
||||
template<typename T> class GPUArrayBuffer
|
||||
class GPUArrayBuffer
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUDevice *device;
|
||||
VkBufferUsageFlags buffer_usage_flags;
|
||||
VKMemoryAllocator *vk_ma;
|
||||
uint align_size;
|
||||
uint range_size;
|
||||
|
||||
uint32_t ubo_offset_alignment;
|
||||
VKMemoryAllocator *vk_ma;
|
||||
|
||||
Collection *coll;
|
||||
|
||||
protected:
|
||||
|
||||
void * Map(const uint32 start,const uint32 count);
|
||||
void Flush(const uint32 count);
|
||||
|
||||
private:
|
||||
|
||||
GPUArrayBuffer(VKMemoryAllocator *,const uint,const uint);
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
public:
|
||||
|
||||
GPUArrayBuffer(GPUDevice *dev,VkBufferUsageFlags flags)
|
||||
virtual ~GPUArrayBuffer();
|
||||
|
||||
const uint32_t GetAlignSize()const{return align_size;} ///<数据对齐字节数
|
||||
const uint32_t GetRangeSize()const{return range_size;} ///<单次渲染访问最大字节数
|
||||
|
||||
DeviceBuffer * GetBuffer();
|
||||
|
||||
uint32 Alloc(const uint32 max_count); ///<预分配空间
|
||||
void Clear();
|
||||
|
||||
template<typename T>
|
||||
bool Start(DynamicBufferAccess<T> *dba,const uint32 start,const uint32 count)
|
||||
{
|
||||
device=dev;
|
||||
buffer_usage_flags=flags;
|
||||
if(!dba)return(false);
|
||||
|
||||
{
|
||||
ubo_offset_alignment=device->GetUBOAlign();
|
||||
void *ptr=Map(start,count);
|
||||
|
||||
const uint32_t unit_size=hgl_align<uint32_t>(sizeof(T),ubo_offset_alignment);
|
||||
if(!ptr)return(false);
|
||||
|
||||
vk_ma=new VKMemoryAllocator(device,buffer_usage_flags,unit_size); // construct function is going to set AllocUnitSize by minUniformOffsetAlignment
|
||||
MemoryBlock *mb=new MemoryBlock(vk_ma);
|
||||
|
||||
coll=new Collection(unit_size,mb);
|
||||
}
|
||||
dba->Start((uchar *)ptr,align_size,count);
|
||||
return(true);
|
||||
}
|
||||
|
||||
virtual ~GPUArrayBuffer()
|
||||
template<typename T>
|
||||
void End(DynamicBufferAccess<T> *dba)
|
||||
{
|
||||
delete coll;
|
||||
}
|
||||
if(!dba)return;
|
||||
|
||||
const uint32_t GetOffsetAlignment()const
|
||||
{
|
||||
return ubo_offset_alignment;
|
||||
}
|
||||
Flush(dba->GetCount());
|
||||
|
||||
const uint32_t GetUnitSize()const
|
||||
{
|
||||
return coll->GetUnitBytes();
|
||||
}
|
||||
|
||||
GPUBuffer *GetBuffer()
|
||||
{
|
||||
return vk_ma->GetBuffer();
|
||||
}
|
||||
|
||||
uint32 Alloc(const uint32 max_count) ///<预分配空间
|
||||
{
|
||||
if(!coll->Alloc(max_count))
|
||||
return(0);
|
||||
|
||||
return coll->GetAllocCount();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
coll->Clear();
|
||||
}
|
||||
|
||||
T *Map(const uint32 start,const uint32 count)
|
||||
{
|
||||
return (T *)(coll->Map(start,count));
|
||||
}
|
||||
|
||||
void Flush(const uint32 count)
|
||||
{
|
||||
vk_ma->Flush(count*GetUnitSize());
|
||||
dba->Restart();
|
||||
}
|
||||
};//class GPUArrayBuffer
|
||||
}//namespace graph
|
||||
|
@@ -4,19 +4,19 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKMemory.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct GPUBufferData
|
||||
struct DeviceBufferData
|
||||
{
|
||||
VkBuffer buffer;
|
||||
GPUMemory * memory=nullptr;
|
||||
VkBuffer buffer=nullptr;
|
||||
DeviceMemory * memory=nullptr;
|
||||
VkDescriptorBufferInfo info;
|
||||
};//struct GPUBufferData
|
||||
};//struct DeviceBufferData
|
||||
|
||||
class GPUBuffer
|
||||
class DeviceBuffer
|
||||
{
|
||||
protected:
|
||||
|
||||
VkDevice device;
|
||||
GPUBufferData buf;
|
||||
DeviceBufferData buf;
|
||||
|
||||
private:
|
||||
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
friend class VertexAttribBuffer;
|
||||
friend class IndexBuffer;
|
||||
|
||||
GPUBuffer(VkDevice d,const GPUBufferData &b)
|
||||
DeviceBuffer(VkDevice d,const DeviceBufferData &b)
|
||||
{
|
||||
device=d;
|
||||
buf=b;
|
||||
@@ -32,10 +32,10 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUBuffer();
|
||||
virtual ~DeviceBuffer();
|
||||
|
||||
VkBuffer GetBuffer ()const{return buf.buffer;}
|
||||
GPUMemory * GetMemory ()const{return buf.memory;}
|
||||
DeviceMemory * GetMemory ()const{return buf.memory;}
|
||||
const VkDescriptorBufferInfo * GetBufferInfo ()const{return &buf.info;}
|
||||
|
||||
void * Map () {return buf.memory->Map();}
|
||||
@@ -47,6 +47,6 @@ public:
|
||||
bool Write (const void *ptr,uint32_t start,uint32_t size) {return buf.memory->Write(ptr,start,size);}
|
||||
bool Write (const void *ptr,uint32_t size) {return buf.memory->Write(ptr,0,size);}
|
||||
bool Write (const void *ptr) {return buf.memory->Write(ptr);}
|
||||
};//class GPUBuffer
|
||||
};//class DeviceBuffer
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_BUFFER_INCLUDE
|
||||
|
@@ -2,9 +2,10 @@
|
||||
#define HGL_GRAPH_VULKAN_COMMAND_BUFFER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKVBOList.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/graph/VKDescriptorSets.h>
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUCmdBuffer
|
||||
{
|
||||
@@ -27,11 +28,11 @@ public:
|
||||
bool End(){return(vkEndCommandBuffer(cmd_buf)==VK_SUCCESS);}
|
||||
|
||||
#ifdef _DEBUG
|
||||
void SetDebugName(const char *);
|
||||
void BeginRegion(const char *,const Color4f &);
|
||||
void SetDebugName(const UTF8String &);
|
||||
void BeginRegion(const UTF8String &,const Color4f &);
|
||||
void EndRegion();
|
||||
#else
|
||||
void BeginRegion(const char *,const Color4f &){}
|
||||
void BeginRegion(const UTF8String &,const Color4f &){}
|
||||
void EndRegion(){}
|
||||
#endif//_DEBUG
|
||||
};//class GPUCmdBuffer
|
||||
@@ -105,7 +106,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool BindDescriptorSets(DescriptorSets *dsl)
|
||||
bool BindDescriptorSets(DescriptorSet *dsl)
|
||||
{
|
||||
if(!dsl)return(false);
|
||||
|
||||
@@ -118,7 +119,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool BindDescriptorSets(DescriptorSets *dsl,const uint32_t offset)
|
||||
bool BindDescriptorSets(DescriptorSet *dsl,const uint32_t offset)
|
||||
{
|
||||
if(!dsl)return(false);
|
||||
|
||||
@@ -140,14 +141,14 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool BindDescriptorSets(Renderable *ri);
|
||||
bool BindDescriptorSets(Material *);
|
||||
|
||||
bool PushDescriptorSet(VkPipelineLayout pipeline_layout,uint32_t set,uint32_t count,const VkWriteDescriptorSet *write_desc_set)
|
||||
{
|
||||
vkCmdPushDescriptorSetKHR(cmd_buf,VK_PIPELINE_BIND_POINT_GRAPHICS,pipeline_layout,set,count,write_desc_set);
|
||||
}
|
||||
|
||||
void PushConstants(ShaderStageBit shader_stage_bit,uint32_t offset,uint32_t size,const void *pValues)
|
||||
void PushConstants(VkShaderStageFlagBits shader_stage_bit,uint32_t offset,uint32_t size,const void *pValues)
|
||||
{
|
||||
vkCmdPushConstants(cmd_buf,pipeline_layout,(VkShaderStageFlagBits)shader_stage_bit,offset,size,pValues);
|
||||
}
|
||||
@@ -155,6 +156,24 @@ public:
|
||||
void PushConstants(const void *data,const uint32_t size) {vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0, size,data);}
|
||||
void PushConstants(const void *data,const uint32_t offset,const uint32_t size) {vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,offset, size,data);}
|
||||
|
||||
void BindVBO(const uint32_t first,const uint32_t count,const VkBuffer *vbo,const VkDeviceSize *offsets)
|
||||
{
|
||||
vkCmdBindVertexBuffers(cmd_buf,first,count,vbo,offsets);
|
||||
}
|
||||
|
||||
bool BindVBO(VBOList *vbo_list)
|
||||
{
|
||||
if(!vbo_list)return(false);
|
||||
|
||||
if(!vbo_list->IsFull())return(false);
|
||||
|
||||
vkCmdBindVertexBuffers(cmd_buf,0,vbo_list->binding_count,vbo_list->buffer_list,vbo_list->buffer_offset);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void BindIBO(const IndexBufferData *);
|
||||
|
||||
bool BindVBO(Renderable *);
|
||||
|
||||
void SetViewport (uint32_t first,uint32_t count,const VkViewport *vp) {vkCmdSetViewport(cmd_buf,first,count,vp);}
|
||||
@@ -176,7 +195,7 @@ public: //draw
|
||||
void DrawIndexed (const uint32_t index_count ) {vkCmdDrawIndexed(cmd_buf,index_count,1,0,0,0);}
|
||||
void Draw (const uint32_t vertex_count,const uint32_t instance_count) {vkCmdDraw(cmd_buf,vertex_count,instance_count,0,0);}
|
||||
void DrawIndexed (const uint32_t index_count ,const uint32_t instance_count) {vkCmdDrawIndexed(cmd_buf,index_count,instance_count,0,0,0);}
|
||||
|
||||
|
||||
template<typename ...ARGS> void Draw (ARGS...args) {vkCmdDraw(cmd_buf,args...);}
|
||||
template<typename ...ARGS> void DrawIndexed (ARGS...args) {vkCmdDrawIndexed(cmd_buf,args...);}
|
||||
|
||||
|
@@ -2,65 +2,85 @@
|
||||
#define HGL_GRAPH_VULKAN_DEBUG_MAKER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct DebugMakerFunction
|
||||
{
|
||||
PFN_vkDebugMarkerSetObjectTagEXT SetObjectTag;
|
||||
PFN_vkDebugMarkerSetObjectNameEXT SetObjectName;
|
||||
PFN_vkCmdDebugMarkerBeginEXT Begin;
|
||||
PFN_vkCmdDebugMarkerEndEXT End;
|
||||
PFN_vkCmdDebugMarkerInsertEXT Insert;
|
||||
PFN_vkDebugMarkerSetObjectTagEXT SetObjectTag;
|
||||
PFN_vkDebugMarkerSetObjectNameEXT SetObjectName;
|
||||
PFN_vkCmdDebugMarkerBeginEXT Begin;
|
||||
PFN_vkCmdDebugMarkerEndEXT End;
|
||||
PFN_vkCmdDebugMarkerInsertEXT Insert;
|
||||
};//struct DebugMakerFunction
|
||||
|
||||
class DebugMaker
|
||||
{
|
||||
VkDevice device;
|
||||
|
||||
DebugMakerFunction dmf;
|
||||
VkDevice device;
|
||||
|
||||
DebugMakerFunction dmf;
|
||||
|
||||
protected:
|
||||
|
||||
void SetObjectName(uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name);
|
||||
void SetObjectTag(uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag);
|
||||
void SetObjectName(uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name);
|
||||
void SetObjectTag(uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag);
|
||||
|
||||
private:
|
||||
|
||||
friend DebugMaker *CreateDebugMaker(VkDevice device);
|
||||
friend DebugMaker *CreateDebugMaker(VkDevice device);
|
||||
|
||||
DebugMaker(VkDevice dev,const DebugMakerFunction &f)
|
||||
{
|
||||
device=dev;
|
||||
dmf=f;
|
||||
}
|
||||
DebugMaker(VkDevice dev,const DebugMakerFunction &f)
|
||||
{
|
||||
device=dev;
|
||||
dmf=f;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void Begin(VkCommandBuffer cmdbuffer, const char * pMarkerName, const Color4f &color);
|
||||
void Insert(VkCommandBuffer cmdbuffer, const char *markerName, const Color4f &color);
|
||||
void End(VkCommandBuffer cmdBuffer);
|
||||
|
||||
#define DEBUG_MAKER_SET_FUNC(type,MNAME) void Set##type##Name(Vk##type obj,const char *name){SetObjectName((uint64_t)obj,VK_DEBUG_REPORT_OBJECT_TYPE_##MNAME##_EXT,name);}
|
||||
|
||||
void Begin(VkCommandBuffer cmdbuffer, const char * pMarkerName, const Color4f &color);
|
||||
void Insert(VkCommandBuffer cmdbuffer, const char *markerName, const Color4f &color);
|
||||
void End(VkCommandBuffer cmdBuffer);
|
||||
|
||||
#define DEBUG_MAKER_SET_FUNC(type,MNAME) void Set##type(Vk##type obj,const char *name){SetObjectName((uint64_t)obj,VK_DEBUG_REPORT_OBJECT_TYPE_##MNAME##_EXT,name);}
|
||||
|
||||
DEBUG_MAKER_SET_FUNC(CommandBuffer, COMMAND_BUFFER)
|
||||
DEBUG_MAKER_SET_FUNC(Queue, QUEUE)
|
||||
DEBUG_MAKER_SET_FUNC(Image, IMAGE)
|
||||
DEBUG_MAKER_SET_FUNC(Sampler, SAMPLER)
|
||||
DEBUG_MAKER_SET_FUNC(Buffer, BUFFER)
|
||||
DEBUG_MAKER_SET_FUNC(DeviceMemory, DEVICE_MEMORY)
|
||||
DEBUG_MAKER_SET_FUNC(ShaderModule, SHADER_MODULE)
|
||||
DEBUG_MAKER_SET_FUNC(Pipeline, PIPELINE)
|
||||
DEBUG_MAKER_SET_FUNC(PipelineLayout, PIPELINE_LAYOUT)
|
||||
DEBUG_MAKER_SET_FUNC(RenderPass, RENDER_PASS)
|
||||
DEBUG_MAKER_SET_FUNC(Framebuffer, FRAMEBUFFER)
|
||||
DEBUG_MAKER_SET_FUNC(DescriptorSetLayout, DESCRIPTOR_SET_LAYOUT)
|
||||
DEBUG_MAKER_SET_FUNC(DescriptorSet, DESCRIPTOR_SET)
|
||||
DEBUG_MAKER_SET_FUNC(Semaphore, SEMAPHORE)
|
||||
DEBUG_MAKER_SET_FUNC(Fence, FENCE)
|
||||
DEBUG_MAKER_SET_FUNC(Event, EVENT)
|
||||
|
||||
#undef DEBUG_MAKER_SET_FUNC
|
||||
DEBUG_MAKER_SET_FUNC(Instance, INSTANCE)
|
||||
DEBUG_MAKER_SET_FUNC(PhysicalDevice, PHYSICAL_DEVICE)
|
||||
DEBUG_MAKER_SET_FUNC(Device, DEVICE)
|
||||
DEBUG_MAKER_SET_FUNC(Queue, QUEUE)
|
||||
DEBUG_MAKER_SET_FUNC(Semaphore, SEMAPHORE)
|
||||
DEBUG_MAKER_SET_FUNC(CommandBuffer, COMMAND_BUFFER)
|
||||
DEBUG_MAKER_SET_FUNC(Fence, FENCE)
|
||||
DEBUG_MAKER_SET_FUNC(DeviceMemory, DEVICE_MEMORY)
|
||||
DEBUG_MAKER_SET_FUNC(Buffer, BUFFER)
|
||||
DEBUG_MAKER_SET_FUNC(Image, IMAGE)
|
||||
DEBUG_MAKER_SET_FUNC(Event, EVENT)
|
||||
DEBUG_MAKER_SET_FUNC(QueryPool, QUERY_POOL)
|
||||
DEBUG_MAKER_SET_FUNC(BufferView, BUFFER_VIEW)
|
||||
DEBUG_MAKER_SET_FUNC(ShaderModule, SHADER_MODULE)
|
||||
DEBUG_MAKER_SET_FUNC(PipelineCache, PIPELINE_CACHE)
|
||||
DEBUG_MAKER_SET_FUNC(PipelineLayout, PIPELINE_LAYOUT)
|
||||
DEBUG_MAKER_SET_FUNC(RenderPass, RENDER_PASS)
|
||||
DEBUG_MAKER_SET_FUNC(Pipeline, PIPELINE)
|
||||
DEBUG_MAKER_SET_FUNC(DescriptorSetLayout, DESCRIPTOR_SET_LAYOUT)
|
||||
DEBUG_MAKER_SET_FUNC(Sampler, SAMPLER)
|
||||
DEBUG_MAKER_SET_FUNC(DescriptorPool, DESCRIPTOR_POOL)
|
||||
DEBUG_MAKER_SET_FUNC(DescriptorSet, DESCRIPTOR_SET)
|
||||
DEBUG_MAKER_SET_FUNC(Framebuffer, FRAMEBUFFER)
|
||||
DEBUG_MAKER_SET_FUNC(CommandPool, COMMAND_POOL)
|
||||
DEBUG_MAKER_SET_FUNC(SurfaceKHR, SURFACE_KHR)
|
||||
DEBUG_MAKER_SET_FUNC(SwapchainKHR, SWAPCHAIN_KHR)
|
||||
DEBUG_MAKER_SET_FUNC(DebugReportCallbackEXT, DEBUG_REPORT_CALLBACK_EXT)
|
||||
DEBUG_MAKER_SET_FUNC(DisplayKHR, DISPLAY_KHR)
|
||||
DEBUG_MAKER_SET_FUNC(DisplayModeKHR, DISPLAY_MODE_KHR)
|
||||
DEBUG_MAKER_SET_FUNC(ValidationCacheEXT, VALIDATION_CACHE_EXT)
|
||||
DEBUG_MAKER_SET_FUNC(SamplerYcbcrConversion, SAMPLER_YCBCR_CONVERSION)
|
||||
DEBUG_MAKER_SET_FUNC(DescriptorUpdateTemplate, DESCRIPTOR_UPDATE_TEMPLATE)
|
||||
DEBUG_MAKER_SET_FUNC(CuModuleNVX, CU_MODULE_NVX)
|
||||
DEBUG_MAKER_SET_FUNC(CuFunctionNVX, CU_FUNCTION_NVX)
|
||||
DEBUG_MAKER_SET_FUNC(AccelerationStructureKHR, ACCELERATION_STRUCTURE_KHR)
|
||||
DEBUG_MAKER_SET_FUNC(AccelerationStructureNV, ACCELERATION_STRUCTURE_NV)
|
||||
|
||||
#undef DEBUG_MAKER_SET_FUNC
|
||||
};//class DebugMaker
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DEBUG_MAKER_INCLUDE
|
||||
|
105
inc/hgl/graph/VKDebugUtils.h
Normal file
105
inc/hgl/graph/VKDebugUtils.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_DEBUG_UTILS_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_DEBUG_UTILS_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct DebugUtilsFunction
|
||||
{
|
||||
PFN_vkSetDebugUtilsObjectNameEXT SetName;
|
||||
PFN_vkSetDebugUtilsObjectTagEXT SetTag;
|
||||
|
||||
PFN_vkQueueBeginDebugUtilsLabelEXT QueueBegin;
|
||||
PFN_vkQueueEndDebugUtilsLabelEXT QueueEnd;
|
||||
PFN_vkQueueInsertDebugUtilsLabelEXT QueueInsert;
|
||||
|
||||
PFN_vkCmdBeginDebugUtilsLabelEXT CmdBegin;
|
||||
PFN_vkCmdEndDebugUtilsLabelEXT CmdEnd;
|
||||
PFN_vkCmdInsertDebugUtilsLabelEXT CmdInsert;
|
||||
};//struct DebugUtilsFunction
|
||||
|
||||
class DebugUtils
|
||||
{
|
||||
VkDevice device;
|
||||
|
||||
DebugUtilsFunction duf;
|
||||
|
||||
private:
|
||||
|
||||
friend DebugUtils *CreateDebugUtils(VkDevice);
|
||||
|
||||
DebugUtils(VkDevice dev,const DebugUtilsFunction &f)
|
||||
{
|
||||
device=dev;
|
||||
duf=f;
|
||||
}
|
||||
|
||||
public:
|
||||
~DebugUtils()=default;
|
||||
|
||||
void SetName(VkObjectType,uint64_t,const char *);
|
||||
|
||||
#define DU_FUNC(n,N) void Set##n(Vk##n obj,const char *name){SetName(VK_OBJECT_TYPE_##N,(uint64_t)obj,name);}
|
||||
|
||||
DU_FUNC(Instance ,INSTANCE )
|
||||
DU_FUNC(PhysicalDevice ,PHYSICAL_DEVICE )
|
||||
DU_FUNC(Device ,DEVICE )
|
||||
DU_FUNC(Queue ,QUEUE )
|
||||
DU_FUNC(Semaphore ,SEMAPHORE )
|
||||
DU_FUNC(CommandBuffer ,COMMAND_BUFFER )
|
||||
DU_FUNC(Fence ,FENCE )
|
||||
DU_FUNC(DeviceMemory ,DEVICE_MEMORY )
|
||||
DU_FUNC(Buffer ,BUFFER )
|
||||
DU_FUNC(Image ,IMAGE )
|
||||
DU_FUNC(Event ,EVENT )
|
||||
DU_FUNC(QueryPool ,QUERY_POOL )
|
||||
DU_FUNC(BufferView ,BUFFER_VIEW )
|
||||
DU_FUNC(ImageView ,IMAGE_VIEW )
|
||||
DU_FUNC(ShaderModule ,SHADER_MODULE )
|
||||
DU_FUNC(PipelineCache ,PIPELINE_CACHE )
|
||||
DU_FUNC(PipelineLayout ,PIPELINE_LAYOUT )
|
||||
DU_FUNC(RenderPass ,RENDER_PASS )
|
||||
DU_FUNC(Pipeline ,PIPELINE )
|
||||
DU_FUNC(DescriptorSetLayout ,DESCRIPTOR_SET_LAYOUT )
|
||||
DU_FUNC(Sampler ,SAMPLER )
|
||||
DU_FUNC(DescriptorPool ,DESCRIPTOR_POOL )
|
||||
DU_FUNC(DescriptorSet ,DESCRIPTOR_SET )
|
||||
DU_FUNC(Framebuffer ,FRAMEBUFFER )
|
||||
DU_FUNC(CommandPool ,COMMAND_POOL )
|
||||
|
||||
DU_FUNC(SamplerYcbcrConversion, SAMPLER_YCBCR_CONVERSION)
|
||||
DU_FUNC(DescriptorUpdateTemplate, DESCRIPTOR_UPDATE_TEMPLATE)
|
||||
DU_FUNC(PrivateDataSlot, PRIVATE_DATA_SLOT)
|
||||
DU_FUNC(SurfaceKHR, SURFACE_KHR)
|
||||
DU_FUNC(SwapchainKHR, SWAPCHAIN_KHR)
|
||||
DU_FUNC(DisplayKHR, DISPLAY_KHR)
|
||||
DU_FUNC(DisplayModeKHR, DISPLAY_MODE_KHR)
|
||||
DU_FUNC(DebugReportCallbackEXT, DEBUG_REPORT_CALLBACK_EXT)
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
DU_FUNC(VideoSessionKHR, VIDEO_SESSION_KHR)
|
||||
DU_FUNC(VideoSessionParametersKHR, VIDEO_SESSION_PARAMETERS_KH)
|
||||
#endif//VK_ENABLE_BETA_EXTENSIONS
|
||||
DU_FUNC(CuModuleNVX, CU_MODULE_NVX)
|
||||
DU_FUNC(CuFunctionNVX, CU_FUNCTION_NVX)
|
||||
DU_FUNC(DebugUtilsMessengerEXT, DEBUG_UTILS_MESSENGER_EXT)
|
||||
DU_FUNC(AccelerationStructureKHR, ACCELERATION_STRUCTURE_KHR)
|
||||
DU_FUNC(ValidationCacheEXT, VALIDATION_CACHE_EXT)
|
||||
DU_FUNC(AccelerationStructureNV, ACCELERATION_STRUCTURE_NV)
|
||||
DU_FUNC(PerformanceConfigurationINTEL, PERFORMANCE_CONFIGURATION_INTEL)
|
||||
DU_FUNC(DeferredOperationKHR, DEFERRED_OPERATION_KHR)
|
||||
DU_FUNC(IndirectCommandsLayoutNV, INDIRECT_COMMANDS_LAYOUT_NV)
|
||||
// DU_FUNC(BufferCollectionFuchsia, BUFFER_COLLECTION_FUCHSIA)
|
||||
|
||||
#undef DU_FUNC
|
||||
|
||||
void QueueBegin (VkQueue,const char *,const Color4f &color=Color4f(1,1,1,1));
|
||||
void QueueEnd (VkQueue q){duf.QueueEnd(q);}
|
||||
void QueueInsert (VkQueue q,const char *,const Color4f &color=Color4f(1,1,1,1));
|
||||
|
||||
void CmdBegin (VkCommandBuffer,const char *,const Color4f &color=Color4f(1,1,1,1));
|
||||
void CmdEnd (VkCommandBuffer cmd_buf){duf.CmdEnd(cmd_buf);}
|
||||
void CmdInsert (VkCommandBuffer cmd_buf,const char *,const Color4f &color=Color4f(1,1,1,1));
|
||||
};//class DebugUtils
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DEBUG_UTILS_INCLUDE
|
100
inc/hgl/graph/VKDescriptorBindingManage.h
Normal file
100
inc/hgl/graph/VKDescriptorBindingManage.h
Normal file
@@ -0,0 +1,100 @@
|
||||
#ifndef HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
#define HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VKDescriptorSetType.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class DeviceBuffer;
|
||||
class Texture;
|
||||
class Material;
|
||||
|
||||
class DescriptorBinding
|
||||
{
|
||||
DescriptorSetType set_type;
|
||||
|
||||
Map<AnsiString,DeviceBuffer *> ubo_map;
|
||||
Map<AnsiString,DeviceBuffer *> ssbo_map;
|
||||
Map<AnsiString,Texture *> texture_map;
|
||||
|
||||
public:
|
||||
|
||||
DescriptorBinding(const DescriptorSetType &dst)
|
||||
{
|
||||
set_type=dst;
|
||||
}
|
||||
|
||||
bool AddUBO(const AnsiString &name,DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
|
||||
return ubo_map.Add(name,buf);
|
||||
}
|
||||
|
||||
DeviceBuffer *GetUBO(const AnsiString &name)
|
||||
{
|
||||
if(name.IsEmpty())return(nullptr);
|
||||
|
||||
return GetListObject(ubo_map,name);
|
||||
}
|
||||
|
||||
void RemoveUBO(DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return;
|
||||
|
||||
ubo_map.DeleteByValue(buf);
|
||||
}
|
||||
|
||||
bool AddSSBO(const AnsiString &name,DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
|
||||
return ssbo_map.Add(name,buf);
|
||||
}
|
||||
|
||||
DeviceBuffer *GetSSBO(const AnsiString &name)
|
||||
{
|
||||
if(name.IsEmpty())return(nullptr);
|
||||
|
||||
return GetListObject(ssbo_map,name);
|
||||
}
|
||||
|
||||
void RemoveSSBO(DeviceBuffer *buf)
|
||||
{
|
||||
if(!buf)return;
|
||||
|
||||
ssbo_map.DeleteByValue(buf);
|
||||
}
|
||||
|
||||
bool AddTexture(const AnsiString &name,Texture *tex)
|
||||
{
|
||||
if(!tex)return(false);
|
||||
if(name.IsEmpty())return(false);
|
||||
|
||||
return texture_map.Add(name,tex);
|
||||
}
|
||||
|
||||
Texture *GetTexture(const AnsiString &name)
|
||||
{
|
||||
if(name.IsEmpty())return(nullptr);
|
||||
|
||||
return GetListObject(texture_map,name);
|
||||
}
|
||||
|
||||
void RemoveTexture(Texture *tex)
|
||||
{
|
||||
if(!tex)return;
|
||||
|
||||
texture_map.DeleteByValue(tex);
|
||||
}
|
||||
|
||||
bool Bind(Material *);
|
||||
};//class DescriptorBinding
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_DESCRIPTOR_BINDING_MANAGE_INCLUDE
|
@@ -1,13 +1,14 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE
|
||||
#ifndef HGL_GRAPH_VULKAN_DESCRIPTOR_SET_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_DESCRIPTOR_SET_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/ObjectList.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUBuffer;
|
||||
class DeviceBuffer;
|
||||
|
||||
class DescriptorSets
|
||||
class DescriptorSet
|
||||
{
|
||||
VkDevice device;
|
||||
int binding_count;
|
||||
@@ -23,11 +24,9 @@ class DescriptorSets
|
||||
|
||||
bool is_dirty;
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
DescriptorSets(VkDevice dev,const int bc,VkPipelineLayout pl,VkDescriptorSet ds)
|
||||
DescriptorSet(VkDevice dev,const int bc,VkPipelineLayout pl,VkDescriptorSet ds)
|
||||
{
|
||||
device =dev;
|
||||
binding_count =bc;
|
||||
@@ -37,9 +36,7 @@ private:
|
||||
is_dirty=true;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
~DescriptorSets()=default;
|
||||
~DescriptorSet()=default;
|
||||
|
||||
const uint32_t GetCount ()const{return binding_count;}
|
||||
const VkDescriptorSet GetDescriptorSet ()const{return desc_set;}
|
||||
@@ -49,14 +46,14 @@ public:
|
||||
|
||||
void Clear();
|
||||
|
||||
bool BindUBO (const int binding,const GPUBuffer *buf,bool dynamic=false);
|
||||
bool BindUBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const GPUBuffer *buf,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const GPUBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
bool BindUBO (const int binding,const DeviceBuffer *buf,bool dynamic=false);
|
||||
bool BindUBO (const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const DeviceBuffer *buf,bool dynamic=false);
|
||||
bool BindSSBO (const int binding,const DeviceBuffer *buf,const VkDeviceSize offset,const VkDeviceSize range,bool dynamic=false);
|
||||
|
||||
bool BindSampler(const int binding,Texture *,Sampler *);
|
||||
bool BindImageSampler(const int binding,Texture *,Sampler *);
|
||||
bool BindInputAttachment(const int binding,ImageView *);
|
||||
void Update();
|
||||
};//class DescriptorSets
|
||||
};//class DescriptorSet
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DESCRIPTOR_SETS_LAYOUT_INCLUDE
|
||||
#endif//HGL_GRAPH_VULKAN_DESCRIPTOR_SET_INCLUDE
|
@@ -5,8 +5,9 @@
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
#include<hgl/graph/ImageRegion.h>
|
||||
#include<hgl/platform/Window.h>
|
||||
#include<hgl/graph/Bitmap.h>
|
||||
#include<hgl/graph/BitmapData.h>
|
||||
#include<hgl/graph/font/Font.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDeviceAttribute.h>
|
||||
@@ -15,35 +16,19 @@
|
||||
#include<hgl/graph/VertexAttribData.h>
|
||||
#include<hgl/graph/VKShaderModuleMap.h>
|
||||
#include<hgl/graph/VKArrayBuffer.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class TileData;
|
||||
class TileFont;
|
||||
class FontSource;
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#include<hgl/graph/VKDescriptorSetType.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
/*
|
||||
* GPU设备创建信息
|
||||
*/
|
||||
struct GPUDeviceCreateInfo
|
||||
{
|
||||
VkPhysicalDeviceType device_type =VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM;
|
||||
|
||||
uint32_t swapchain_image_count =0;
|
||||
VkSurfaceFormatKHR color_format ={PF_A2BGR10UN,VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
|
||||
VkFormat depth_format =VK_FORMAT_UNDEFINED;
|
||||
};//struct GPUDeviceCreateInfo
|
||||
class TileData;
|
||||
class TileFont;
|
||||
class FontSource;
|
||||
class GPUArrayBuffer;
|
||||
|
||||
class GPUDevice
|
||||
{
|
||||
GPUDeviceAttribute *attr;
|
||||
|
||||
GPUQueue *texture_queue;
|
||||
DeviceQueue *texture_queue;
|
||||
TextureCmdBuffer *texture_cmd_buf;
|
||||
|
||||
private:
|
||||
@@ -51,9 +36,9 @@ private:
|
||||
DeviceRenderPassManage *render_pass_manage;
|
||||
RenderPass *device_render_pass;
|
||||
|
||||
SwapchainRenderTarget *swapchainRT;
|
||||
RTSwapchain *sc_rt;
|
||||
|
||||
SwapchainRenderTarget *CreateSwapchainRenderTarget();
|
||||
RTSwapchain *CreateSwapchainRenderTarget();
|
||||
|
||||
void InitRenderPassManage();
|
||||
void ClearRenderPassManage();
|
||||
@@ -68,7 +53,7 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
friend GPUDevice *CreateRenderDevice(VulkanInstance *inst,const GPUPhysicalDevice *physical_device,VkSurfaceKHR surface,const VkExtent2D &extent);
|
||||
friend class VulkanDeviceCreater;
|
||||
|
||||
GPUDevice(GPUDeviceAttribute *da);
|
||||
|
||||
@@ -92,9 +77,9 @@ public:
|
||||
|
||||
RenderPass * GetRenderPass () {return device_render_pass;}
|
||||
|
||||
SwapchainRenderTarget * GetSwapchainRT () {return swapchainRT;}
|
||||
RTSwapchain * GetSwapchainRT () {return sc_rt;}
|
||||
|
||||
const VkExtent2D & GetSwapchainSize ()const {return swapchainRT->GetExtent();}
|
||||
const VkExtent2D & GetSwapchainSize ()const {return sc_rt->GetExtent();}
|
||||
|
||||
void WaitIdle ()const {vkDeviceWaitIdle(attr->device);}
|
||||
|
||||
@@ -110,40 +95,45 @@ public:
|
||||
|
||||
public: //内存相关
|
||||
|
||||
GPUMemory *CreateMemory(const VkMemoryRequirements &,const uint32_t properties);
|
||||
GPUMemory *CreateMemory(VkImage,const uint32 flag=VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
DeviceMemory *CreateMemory(const VkMemoryRequirements &,const uint32_t properties);
|
||||
DeviceMemory *CreateMemory(VkImage,const uint32 flag=VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
|
||||
private: //Buffer相关
|
||||
|
||||
bool CreateBuffer(GPUBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode);
|
||||
bool CreateBuffer(GPUBufferData *buf,VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data,SharingMode sharing_mode){return CreateBuffer(buf,buf_usage,size,size,data,sharing_mode);}
|
||||
bool CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode);
|
||||
bool CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data,SharingMode sharing_mode){return CreateBuffer(buf,buf_usage,size,size,data,sharing_mode);}
|
||||
|
||||
public: //Buffer相关
|
||||
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,range,size,nullptr,sm);}
|
||||
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);}
|
||||
GPUBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);}
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,range,size,nullptr,sm);}
|
||||
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);}
|
||||
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);}
|
||||
|
||||
VBO * CreateVBO (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
||||
VBO * CreateVBO (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
|
||||
VBO * CreateVBO (const VAD *vad, SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetVulkanFormat(),vad->GetCount(),vad->GetData(),sm);}
|
||||
VBO * CreateVBO (const VAD *vad, SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetFormat(),vad->GetCount(),vad->GetData(),sm);}
|
||||
|
||||
IndexBuffer * CreateIBO (IndexType type, uint32_t count,const void * data, SharingMode sm=SharingMode::Exclusive);
|
||||
IndexBuffer * CreateIBO8 ( uint32_t count,const void * data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U8, count,(void *)data,sm);}
|
||||
IndexBuffer * CreateIBO16 ( uint32_t count,const uint16 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16, count,(void *)data,sm);}
|
||||
IndexBuffer * CreateIBO32 ( uint32_t count,const uint32 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32, count,(void *)data,sm);}
|
||||
|
||||
IndexBuffer * CreateIBO (IndexType type, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(type, count,nullptr,sm);}
|
||||
IndexBuffer * CreateIBO8 ( uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U8, count,nullptr,sm);}
|
||||
IndexBuffer * CreateIBO16 ( uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16, count,nullptr,sm);}
|
||||
IndexBuffer * CreateIBO32 ( uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32, count,nullptr,sm);}
|
||||
|
||||
const VkDeviceSize GetUBOAlign();
|
||||
const VkDeviceSize GetSSBOAlign();
|
||||
const VkDeviceSize GetUBORange();
|
||||
const VkDeviceSize GetSSBORange();
|
||||
|
||||
#define CREATE_BUFFER_OBJECT(LargeName,type) GPUBuffer *Create##LargeName( VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,data, sm);} \
|
||||
GPUBuffer *Create##LargeName( VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,nullptr, sm);} \
|
||||
GPUBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,data, sm);} \
|
||||
GPUBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,nullptr, sm);}
|
||||
#define CREATE_BUFFER_OBJECT(LargeName,type) DeviceBuffer *Create##LargeName( VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,data, sm);} \
|
||||
DeviceBuffer *Create##LargeName( VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,nullptr, sm);} \
|
||||
DeviceBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,data, sm);} \
|
||||
DeviceBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,nullptr, sm);}
|
||||
|
||||
CREATE_BUFFER_OBJECT(UBO,UNIFORM)
|
||||
CREATE_BUFFER_OBJECT(SSBO,STORAGE)
|
||||
@@ -151,6 +141,9 @@ public: //Buffer相关
|
||||
|
||||
#undef CREATE_BUFFER_OBJECT
|
||||
|
||||
GPUArrayBuffer *CreateArrayInUBO(const VkDeviceSize &uint_size);
|
||||
GPUArrayBuffer *CreateArrayInSSBO(const VkDeviceSize &uint_size);
|
||||
|
||||
public: //Image
|
||||
|
||||
VkImage CreateImage (VkImageCreateInfo *);
|
||||
@@ -158,13 +151,13 @@ public: //Image
|
||||
|
||||
private: //texture
|
||||
|
||||
bool CommitTexture (Texture *,GPUBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool CommitTexture (Texture *,DeviceBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
bool CommitTexture2D (Texture2D *,GPUBuffer *buf,VkPipelineStageFlags stage);
|
||||
bool CommitTexture2DMipmaps (Texture2D *,GPUBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
bool CommitTexture2D (Texture2D *,DeviceBuffer *buf,VkPipelineStageFlags stage);
|
||||
bool CommitTexture2DMipmaps (Texture2D *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool CommitTextureCube (TextureCube *,GPUBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
||||
bool CommitTextureCubeMipmaps (TextureCube *,GPUBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
bool CommitTextureCube (TextureCube *,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
||||
bool CommitTextureCubeMipmaps (TextureCube *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
||||
|
||||
bool SubmitTexture (const VkCommandBuffer *cmd_bufs,const uint32_t count=1); ///<提交纹理处理到队列
|
||||
|
||||
@@ -182,32 +175,9 @@ public: //Texture
|
||||
|
||||
void Clear(TextureCreateInfo *);
|
||||
|
||||
bool ChangeTexture2D(Texture2D *,GPUBuffer *buf,const List<Image2DRegion> &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,GPUBuffer *buf,uint32_t left,uint32_t top,uint32_t width,uint32_t height, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,void *data, uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
template<typename T>
|
||||
bool ChangeTexture2D(Texture2D *tex,GPUBuffer *buf,const RectScope2<T> &rs)
|
||||
{
|
||||
return ChangeTexture2D( tex,
|
||||
buf,
|
||||
rs.GetLeft(),
|
||||
rs.GetTop(),
|
||||
rs.GetWidth(),
|
||||
rs.GetHeight());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool ChangeTexture2D(Texture2D *tex,void *data,const RectScope2<T> &rs,uint32_t size)
|
||||
{
|
||||
return ChangeTexture2D( tex,
|
||||
data,
|
||||
rs.GetLeft(),
|
||||
rs.GetTop(),
|
||||
rs.GetWidth(),
|
||||
rs.GetHeight(),
|
||||
size);
|
||||
}
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const List<Image2DRegion> &,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
bool ChangeTexture2D(Texture2D *,void *data,const uint32_t size,const RectScope2ui &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
public: //
|
||||
|
||||
@@ -216,20 +186,11 @@ public: //
|
||||
|
||||
public: //shader & material
|
||||
|
||||
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorSets *);
|
||||
void Destroy(PipelineLayoutData *);
|
||||
ShaderModule *CreateShaderModule(VkShaderStageFlagBits,const uint32_t *,const size_t);
|
||||
|
||||
DescriptorSets * CreateDescriptorSets(const PipelineLayoutData *,const DescriptorSetsType &type)const;
|
||||
MaterialParameters *CreateMP(const MaterialDescriptorSets *,const PipelineLayoutData *,const DescriptorSetsType &);
|
||||
MaterialParameters *CreateMP(Material *,const DescriptorSetsType &);
|
||||
|
||||
ShaderModule *CreateShaderModule(ShaderResource *);
|
||||
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorSets *);
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
||||
Material *CreateMaterial(const UTF8String &mtl_name,const VertexShaderModule *vertex_shader_module,const ShaderModule *geometry_shader_module,const ShaderModule *fragment_shader_module,MaterialDescriptorSets *);
|
||||
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorManager *desc_manager);
|
||||
|
||||
MaterialInstance *CreateMI(Material *,const VABConfigInfo *vab_cfg=nullptr);
|
||||
MaterialParameters *CreateMP(const MaterialDescriptorManager *desc_manager,const PipelineLayoutData *pld,const DescriptorSetType &desc_set_type);
|
||||
|
||||
public: //Command Buffer 相关
|
||||
|
||||
@@ -238,32 +199,30 @@ public: //Command Buffer 相关
|
||||
|
||||
public:
|
||||
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
||||
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
||||
|
||||
GPUFence * CreateFence(bool);
|
||||
GPUSemaphore * CreateGPUSemaphore();
|
||||
Fence * CreateFence(bool);
|
||||
Semaphore * CreateGPUSemaphore();
|
||||
|
||||
GPUQueue * CreateQueue(const uint32_t fence_count=1,const bool create_signaled=false);
|
||||
DeviceQueue *CreateQueue(const uint32_t fence_count=1,const bool create_signaled=false);
|
||||
|
||||
public: //FrameBuffer相关
|
||||
|
||||
Framebuffer *CreateFramebuffer(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth);
|
||||
// Framebuffer *CreateFramebuffer(RenderPass *,List<ImageView *> &color,ImageView *depth);
|
||||
Framebuffer *CreateFramebuffer(RenderPass *,ImageView *color,ImageView *depth);
|
||||
Framebuffer *CreateFramebuffer(RenderPass *,ImageView *);
|
||||
Framebuffer *CreateFBO(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth);
|
||||
// Framebuffer *CreateFBO(RenderPass *,List<ImageView *> &color,ImageView *depth);
|
||||
Framebuffer *CreateFBO(RenderPass *,ImageView *color,ImageView *depth);
|
||||
Framebuffer *CreateFBO(RenderPass *,ImageView *);
|
||||
|
||||
public:
|
||||
|
||||
RenderTarget *CreateRenderTarget( const FramebufferInfo *fbi,RenderPass *,const uint32_t fence_count=1);
|
||||
RenderTarget *CreateRenderTarget( const FramebufferInfo *fbi,const uint32_t fence_count=1);
|
||||
RenderTarget *CreateRT( const FramebufferInfo *fbi,RenderPass *,const uint32_t fence_count=1);
|
||||
RenderTarget *CreateRT( const FramebufferInfo *fbi,const uint32_t fence_count=1);
|
||||
|
||||
public:
|
||||
|
||||
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
|
||||
|
||||
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
|
||||
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
|
||||
};//class GPUDevice
|
||||
|
||||
GPUDevice *CreateRenderDevice(VulkanInstance *inst,Window *win,const GPUPhysicalDevice *physical_device=nullptr);
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include<hgl/graph/VKDebugMaker.h>
|
||||
#include<hgl/graph/VKDebugUtils.h>
|
||||
#endif//_DEBUG
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@@ -21,17 +22,18 @@ struct GPUDeviceAttribute
|
||||
VkSurfaceKHR surface =VK_NULL_HANDLE;
|
||||
VkSurfaceCapabilitiesKHR surface_caps;
|
||||
|
||||
uint32_t graphics_family =ERROR_FAMILY_INDEX;
|
||||
uint32_t present_family =ERROR_FAMILY_INDEX;
|
||||
uint32_t compute_family =ERROR_FAMILY_INDEX;
|
||||
uint32_t graphics_family =ERROR_FAMILY_INDEX;
|
||||
uint32_t present_family =ERROR_FAMILY_INDEX;
|
||||
uint32_t compute_family =ERROR_FAMILY_INDEX;
|
||||
uint32_t video_decode_family =ERROR_FAMILY_INDEX;
|
||||
|
||||
#ifdef VK_ENABLE_BETA_EXTENSIONS
|
||||
uint32_t video_encode_family =ERROR_FAMILY_INDEX;
|
||||
#endif//VK_ENABLE_BETA_EXTENSIONS
|
||||
|
||||
VkQueue graphics_queue =VK_NULL_HANDLE;
|
||||
VkQueue present_queue =VK_NULL_HANDLE;
|
||||
|
||||
List<VkQueueFamilyProperties> family_properties;
|
||||
List<VkBool32> supports_present;
|
||||
|
||||
List<VkSurfaceFormatKHR> surface_formats_list;
|
||||
VkSurfaceFormatKHR surface_format;
|
||||
List<VkPresentModeKHR> present_modes;
|
||||
|
||||
@@ -44,9 +46,10 @@ struct GPUDeviceAttribute
|
||||
VkDescriptorPool desc_pool =VK_NULL_HANDLE;
|
||||
|
||||
VkPipelineCache pipeline_cache =VK_NULL_HANDLE;
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugMaker * debug_maker =nullptr;
|
||||
DebugUtils * debug_utils =nullptr;
|
||||
#endif//_DEBUG
|
||||
|
||||
public:
|
||||
|
312
inc/hgl/graph/VKDeviceCreater.h
Normal file
312
inc/hgl/graph/VKDeviceCreater.h
Normal file
@@ -0,0 +1,312 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKDevice.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct VulkanHardwareRequirement
|
||||
{
|
||||
uint min_1d_image_size;
|
||||
uint min_2d_image_size;
|
||||
uint min_3d_image_size;
|
||||
uint min_cube_image_size;
|
||||
uint min_array_image_layers;
|
||||
|
||||
uint min_vertex_input_attribute; ///<最小顶点输入属性数量需求
|
||||
uint min_color_attachments; ///<最小颜色输出成份数量需求
|
||||
|
||||
uint min_push_constant_size; ///<最小push constant大小
|
||||
uint min_ubo_range; ///<最小ubo range需求
|
||||
uint min_ssbo_range; ///<最小ssbo range需求
|
||||
|
||||
uint min_draw_indirect_count; ///<最小间接绘制次数需求
|
||||
|
||||
bool geometry_shader; ///<要求支持几何着色器
|
||||
bool tessellation_shader; ///<要求支持细分着色器
|
||||
// bool compute_shader; ///<要求支持计算着色器
|
||||
|
||||
bool multi_draw_indirect; ///<要求支持MultiDrawIndirect
|
||||
|
||||
bool wide_lines; ///<要求支持宽线条
|
||||
bool line_rasterization; ///<要支持线条特性(这功能mac/ios平台不支持)
|
||||
bool large_points; ///<要求支持绘制大点
|
||||
|
||||
bool texture_cube_array; ///<要求支持立方体数组纹理
|
||||
|
||||
bool uint8_draw_index; ///<要求支持8位索引
|
||||
bool uint32_draw_index; ///<要求支持32位索引(不建议使用)
|
||||
|
||||
struct
|
||||
{
|
||||
bool bc,etc2,astc_ldr,astc_hdr,pvrtc; ///<要求支持的压缩纹理格式
|
||||
}texture_compression;
|
||||
|
||||
//dynamic_state VK_EXT_extended_dynamic_state
|
||||
// cull mode
|
||||
// front face
|
||||
// primitive topology
|
||||
// viewport
|
||||
// scissor
|
||||
// bind vbo
|
||||
// depth test
|
||||
// depth write
|
||||
// depth compare op
|
||||
// depth bounds test
|
||||
// stencil test
|
||||
// stencil op
|
||||
//dynamic_state[1] VK_EXT_extended_dynamic_state2
|
||||
// patch control points
|
||||
// rasterizer discard
|
||||
// depth bias
|
||||
// logic op
|
||||
// primitive restart
|
||||
//dynamic_state[2] VK_EXT_extended_dynamic_state3
|
||||
// tess domain origin
|
||||
// depth clamp
|
||||
// discard polygon mode
|
||||
// rasterization samples
|
||||
// sample mask
|
||||
// alpha to coverage
|
||||
// alpha to one
|
||||
// logic op enable
|
||||
// color blend
|
||||
// color blend equation
|
||||
// color write mask
|
||||
// depth clamp
|
||||
// Color blend advanced
|
||||
// line rasterization mode
|
||||
// line stipple
|
||||
// depth clip -1 to 1
|
||||
// shading rate image enable
|
||||
bool dynamic_state[3]; ///<要求支持动态状态
|
||||
|
||||
// 1.3 特性
|
||||
bool dynamic_rendering; ///<要求支持动态渲染
|
||||
|
||||
uint32_t descriptor_pool; ///<描述符池大小(默认1024)
|
||||
|
||||
public:
|
||||
|
||||
VulkanHardwareRequirement()
|
||||
{
|
||||
hgl_zero(*this);
|
||||
|
||||
descriptor_pool=1024;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr const VkFormat SwapchainPreferFormatsLDR[]=
|
||||
{
|
||||
PF_RGB5A1,
|
||||
PF_BGR5A1,
|
||||
PF_A1RGB5,
|
||||
PF_RGB565,
|
||||
PF_BGR565,
|
||||
};
|
||||
|
||||
constexpr const VkFormat SwapchainPreferFormatsSDR[]=
|
||||
{
|
||||
PF_RGBA8UN,//PF_RGBA8s,
|
||||
PF_BGRA8UN,//PF_BGRA8s,
|
||||
PF_ABGR8UN,//PF_ABGR8s,
|
||||
PF_A2RGB10UN,
|
||||
PF_A2BGR10UN,
|
||||
// PF_B10GR11UF
|
||||
};
|
||||
|
||||
constexpr const VkFormat SwapchainPreferFormatsHDR16[]=
|
||||
{
|
||||
PF_RGBA16UN,PF_RGBA16SN,PF_RGBA16F
|
||||
};
|
||||
|
||||
constexpr const VkFormat SwapchainPreferFormatsHDR32[]=
|
||||
{
|
||||
PF_RGB32F,
|
||||
PF_RGBA32F
|
||||
};
|
||||
|
||||
constexpr const VkFormat SwapchainPreferFormatsHDR[]=
|
||||
{
|
||||
PF_RGBA16UN,PF_RGBA16SN,PF_RGBA16F,
|
||||
PF_RGB32F,PF_RGBA32F
|
||||
};
|
||||
|
||||
constexpr const VkFormat SwapchainPreferFormatsDepth[]=
|
||||
{
|
||||
PF_D16UN,
|
||||
PF_X8_D24UN,
|
||||
PF_D16UN_S8U,
|
||||
PF_D24UN_S8U,
|
||||
PF_D32F,
|
||||
PF_D32F_S8U
|
||||
};
|
||||
|
||||
constexpr const VkColorSpaceKHR SwapchainPreferColorSpacesNonlinear[]=
|
||||
{
|
||||
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
|
||||
VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT,
|
||||
VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT,
|
||||
VK_COLOR_SPACE_BT709_NONLINEAR_EXT,
|
||||
VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT,
|
||||
VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT,
|
||||
VK_COLOR_SPACE_DISPLAY_NATIVE_AMD,
|
||||
};
|
||||
|
||||
constexpr const VkColorSpaceKHR SwapchainPreferColorSpacesLinear[]=
|
||||
{
|
||||
VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT,
|
||||
VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT,
|
||||
VK_COLOR_SPACE_BT709_LINEAR_EXT,
|
||||
VK_COLOR_SPACE_BT2020_LINEAR_EXT,
|
||||
VK_COLOR_SPACE_HDR10_ST2084_EXT,
|
||||
VK_COLOR_SPACE_DOLBYVISION_EXT,
|
||||
VK_COLOR_SPACE_HDR10_HLG_EXT,
|
||||
VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT,
|
||||
};
|
||||
|
||||
struct PreferFormats
|
||||
{
|
||||
//偏好格式需从低质量到高质量排列
|
||||
const VkFormat *formats;
|
||||
uint count;
|
||||
|
||||
public:
|
||||
|
||||
const int Find(const VkFormat fmt)const
|
||||
{
|
||||
for(uint i=0;i<count;i++)
|
||||
if(fmt==formats[i])
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
struct PreferColorSpaces
|
||||
{
|
||||
//偏好格式需从低质量到高质量排列
|
||||
const VkColorSpaceKHR *colorspaces;
|
||||
uint count;
|
||||
|
||||
public:
|
||||
|
||||
const int Find(const VkColorSpaceKHR cs)const
|
||||
{
|
||||
for(uint i=0;i<count;i++)
|
||||
if(cs==colorspaces[i])
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr const PreferFormats PreferLDR {SwapchainPreferFormatsLDR, sizeof(SwapchainPreferFormatsLDR )/sizeof(VkFormat)};
|
||||
constexpr const PreferFormats PreferSDR {SwapchainPreferFormatsSDR, sizeof(SwapchainPreferFormatsSDR )/sizeof(VkFormat)};
|
||||
constexpr const PreferFormats PreferHDR16{SwapchainPreferFormatsHDR16, sizeof(SwapchainPreferFormatsHDR16 )/sizeof(VkFormat)};
|
||||
constexpr const PreferFormats PreferHDR32{SwapchainPreferFormatsHDR32, sizeof(SwapchainPreferFormatsHDR32 )/sizeof(VkFormat)};
|
||||
constexpr const PreferFormats PreferHDR {SwapchainPreferFormatsHDR, sizeof(SwapchainPreferFormatsHDR )/sizeof(VkFormat)};
|
||||
constexpr const PreferFormats PreferDepth{SwapchainPreferFormatsDepth, sizeof(SwapchainPreferFormatsDepth )/sizeof(VkFormat)};
|
||||
|
||||
constexpr const PreferColorSpaces PreferNonlinear {SwapchainPreferColorSpacesNonlinear, sizeof(SwapchainPreferColorSpacesNonlinear )/sizeof(VkColorSpaceKHR)};
|
||||
constexpr const PreferColorSpaces PreferLinear {SwapchainPreferColorSpacesLinear, sizeof(SwapchainPreferColorSpacesLinear )/sizeof(VkColorSpaceKHR)};
|
||||
|
||||
/**
|
||||
* Vulkan设备创建器<br>
|
||||
* 将此功能定义为类是为了让开发者方便重载处理
|
||||
*/
|
||||
class VulkanDeviceCreater
|
||||
{
|
||||
protected:
|
||||
|
||||
VulkanInstance *instance;
|
||||
Window *window;
|
||||
const GPUPhysicalDevice *physical_device;
|
||||
|
||||
VulkanHardwareRequirement require;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
const PreferFormats * perfer_color_formats;
|
||||
const PreferColorSpaces * perfer_color_spaces;
|
||||
const PreferFormats * perfer_depth_formats;
|
||||
|
||||
VkSurfaceKHR surface;
|
||||
|
||||
VkSurfaceFormatKHR surface_format;
|
||||
|
||||
CharPointerList ext_list;
|
||||
VkPhysicalDeviceFeatures features={};
|
||||
|
||||
protected:
|
||||
|
||||
VkDevice CreateDevice(const uint32_t);
|
||||
|
||||
public:
|
||||
|
||||
VulkanDeviceCreater(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const PreferFormats *spf_color,
|
||||
const PreferColorSpaces *spf_color_space,
|
||||
const PreferFormats *spf_depth,
|
||||
const VulkanHardwareRequirement *req);
|
||||
|
||||
virtual bool ChoosePhysicalDevice();
|
||||
|
||||
virtual bool RequirementCheck();
|
||||
|
||||
virtual void ChooseSurfaceFormat();
|
||||
|
||||
virtual GPUDevice *CreateRenderDevice();
|
||||
|
||||
public:
|
||||
|
||||
virtual GPUDevice *Create();
|
||||
};//class VulkanDeviceCreater
|
||||
|
||||
inline GPUDevice *CreateRenderDevice( VulkanInstance *vi,
|
||||
Window *win,
|
||||
const PreferFormats * spf_color =&PreferSDR,
|
||||
const PreferColorSpaces * spf_color_space =&PreferNonlinear,
|
||||
const PreferFormats * spf_depth =&PreferDepth,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
VulkanDeviceCreater vdc(vi,win,spf_color,spf_color_space,spf_depth,req);
|
||||
|
||||
return vdc.Create();
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceLDR(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,&PreferLDR,&PreferNonlinear,&PreferDepth,req);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceSDR(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,&PreferSDR,&PreferNonlinear,&PreferDepth,req);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceHDR16( VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,&PreferHDR16,&PreferLinear,&PreferDepth,req);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceHDR32( VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,&PreferHDR32,&PreferLinear,&PreferDepth,req);
|
||||
}
|
||||
|
||||
inline GPUDevice *CreateRenderDeviceHDR(VulkanInstance *vi,
|
||||
Window *win,
|
||||
const VulkanHardwareRequirement *req=nullptr)
|
||||
{
|
||||
return CreateRenderDevice(vi,win,&PreferHDR,&PreferLinear,&PreferDepth,req);
|
||||
}
|
||||
VK_NAMESPACE_END
|
79
inc/hgl/graph/VKDynamicBufferAccess.h
Normal file
79
inc/hgl/graph/VKDynamicBufferAccess.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef HGL_GRAPH_DYNAMIC_BUFFER_ACCESS_INCLUDE
|
||||
#define HGL_GRAPH_DYNAMIC_BUFFER_ACCESS_INCLUDE
|
||||
|
||||
#include<hgl/graph/VKArrayBuffer.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
template<typename T> class DynamicBufferAccess
|
||||
{
|
||||
uchar *pointer;
|
||||
uchar *current;
|
||||
|
||||
uint align_size;
|
||||
|
||||
uint count;
|
||||
uint index;
|
||||
|
||||
private:
|
||||
|
||||
DynamicBufferAccess()
|
||||
{
|
||||
Restart();
|
||||
}
|
||||
|
||||
void Restart()
|
||||
{
|
||||
pointer=nullptr;
|
||||
current=nullptr;
|
||||
align_size=0;
|
||||
count=0;
|
||||
index=0;
|
||||
}
|
||||
|
||||
void Start(uchar *buf,const uint as,const uint c)
|
||||
{
|
||||
current=pointer=buf;
|
||||
align_size=as;
|
||||
count=c;
|
||||
index=0;
|
||||
}
|
||||
|
||||
friend class GPUArrayBuffer;
|
||||
|
||||
public:
|
||||
|
||||
const uint GetCount()const{return count;}
|
||||
const uint GetCurrentIndex()const{return index;}
|
||||
const uint GetOffsetBytes()const{return index*align_size;}
|
||||
|
||||
bool Write(uchar *src)
|
||||
{
|
||||
if(!src)return(false);
|
||||
if(index>=count)return(false);
|
||||
|
||||
memcpy(current,src,sizeof(T));
|
||||
current+=align_size;
|
||||
++index;
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool Write(uchar *src,const uint c)
|
||||
{
|
||||
if(!src)return(false);
|
||||
if(c<=0)return(false);
|
||||
if(index+c>count)return(false);
|
||||
|
||||
for(uint i=0;i<c;i++)
|
||||
{
|
||||
memcpy(current,src,sizeof(T));
|
||||
current+=align_size;
|
||||
src+=sizeof(T);
|
||||
}
|
||||
|
||||
index+=c;
|
||||
|
||||
return(true);
|
||||
}
|
||||
};//template<typename T> class DynamicBufferAccess
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_DYNAMIC_BUFFER_ACCESS_INCLUDE
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUFence
|
||||
class Fence
|
||||
{
|
||||
VkDevice device;
|
||||
VkFence fence;
|
||||
@@ -12,7 +12,7 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
GPUFence(VkDevice d,VkFence f)
|
||||
Fence(VkDevice d,VkFence f)
|
||||
{
|
||||
device=d;
|
||||
fence=f;
|
||||
@@ -20,9 +20,9 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
~GPUFence();
|
||||
~Fence();
|
||||
|
||||
operator VkFence(){return fence;}
|
||||
};//class GPUFence
|
||||
};//class Fence
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_VULKAN_GRAPH_FENCE_INCLUDE
|
||||
|
@@ -35,5 +35,7 @@ public:
|
||||
const uint32_t GetColorCount ()const{return color_count;} ///<取得颜色成分数量
|
||||
const bool HasDepth ()const{return has_depth;} ///<是否包含深度成分
|
||||
};//class Framebuffer
|
||||
|
||||
using FBO=Framebuffer;
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_FRAMEBUFFER_INCLUDE
|
||||
|
@@ -7,7 +7,7 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class IndexBuffer:public GPUBuffer
|
||||
class IndexBuffer:public DeviceBuffer
|
||||
{
|
||||
IndexType index_type;
|
||||
uint32_t count;
|
||||
@@ -16,7 +16,7 @@ namespace hgl
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
IndexBuffer(VkDevice d,const GPUBufferData &vb,IndexType it,uint32_t _count):GPUBuffer(d,vb)
|
||||
IndexBuffer(VkDevice d,const DeviceBufferData &vb,IndexType it,uint32_t _count):DeviceBuffer(d,vb)
|
||||
{
|
||||
index_type=it;
|
||||
count=_count;
|
||||
@@ -26,9 +26,9 @@ namespace hgl
|
||||
|
||||
~IndexBuffer()=default;
|
||||
|
||||
const IndexType GetType ()const{return index_type;}
|
||||
const uint32 GetCount()const{return count;}
|
||||
};//class IndexBuffer:public GPUBuffer
|
||||
const IndexType GetType ()const{return index_type;}
|
||||
const uint32 GetCount()const{return count;}
|
||||
};//class IndexBuffer:public DeviceBuffer
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_VULKAN_INDEX_BUFFER_INCLUDE
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define HGL_GRAPH_VULKAN_INSTANCE_INCLUDE
|
||||
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/ObjectList.h>
|
||||
#include<hgl/platform/Window.h>
|
||||
#include<hgl/graph/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/VKDebugOut.h>
|
||||
@@ -23,7 +23,9 @@ VK_NAMESPACE_BEGIN
|
||||
|
||||
struct
|
||||
{
|
||||
VK_BOOL1BIT(synchronization2)
|
||||
VK_BOOL1BIT(validation)
|
||||
VK_BOOL1BIT(profiles)
|
||||
}khronos;
|
||||
|
||||
struct
|
||||
|
@@ -5,72 +5,88 @@
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VKShaderModuleMap.h>
|
||||
#include<hgl/graph/VKDescriptorSetType.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
class ActiveMemoryBlockManager;
|
||||
}
|
||||
VK_NAMESPACE_BEGIN
|
||||
using ShaderStageCreateInfoList=List<VkPipelineShaderStageCreateInfo>;
|
||||
|
||||
struct MaterialData
|
||||
{
|
||||
UTF8String name;
|
||||
|
||||
ShaderModuleMap *shader_maps;
|
||||
MaterialDescriptorSets *mds;
|
||||
|
||||
VertexShaderModule *vertex_sm;
|
||||
|
||||
ShaderStageCreateInfoList shader_stage_list;
|
||||
|
||||
PipelineLayoutData *pipeline_layout_data;
|
||||
|
||||
struct
|
||||
{
|
||||
MaterialParameters *m,*g,*r;
|
||||
}mp;
|
||||
|
||||
private:
|
||||
|
||||
friend class Material;
|
||||
|
||||
~MaterialData();
|
||||
};//struct MaterialData
|
||||
|
||||
/**
|
||||
* 材质类<br>
|
||||
* 用于管理shader,提供DescriptorSetLayoutCreater
|
||||
*/
|
||||
class Material
|
||||
{
|
||||
MaterialData *data;
|
||||
AnsiString name;
|
||||
|
||||
VertexInput *vertex_input;
|
||||
|
||||
ShaderModuleMap *shader_maps;
|
||||
|
||||
MaterialDescriptorManager *desc_manager;
|
||||
|
||||
ShaderStageCreateInfoList shader_stage_list;
|
||||
|
||||
PipelineLayoutData *pipeline_layout_data;
|
||||
|
||||
MaterialParameters *mp_array[DESCRIPTOR_SET_TYPE_COUNT];
|
||||
|
||||
uint32_t mi_data_bytes; ///<实例数据大小
|
||||
uint32_t mi_max_count; ///<实例一次渲染最大数量限制
|
||||
|
||||
ActiveMemoryBlockManager *mi_data_manager;
|
||||
|
||||
private:
|
||||
|
||||
friend GPUDevice;
|
||||
friend class RenderResource;
|
||||
|
||||
MaterialData *GetMaterialData(){return data;}
|
||||
Material(const AnsiString &);
|
||||
|
||||
public:
|
||||
|
||||
Material(MaterialData *md):data(md){}
|
||||
~Material();
|
||||
virtual ~Material();
|
||||
|
||||
const UTF8String & GetName ()const{return data->name;}
|
||||
const UTF8String & GetName ()const{return name;}
|
||||
|
||||
VertexShaderModule * GetVertexShaderModule () {return data->vertex_sm;}
|
||||
const VertexInput * GetVertexInput ()const{return vertex_input;}
|
||||
|
||||
const ShaderStageCreateInfoList & GetStageList ()const{return data->shader_stage_list;}
|
||||
const ShaderStageCreateInfoList & GetStageList ()const{return shader_stage_list;}
|
||||
|
||||
const MaterialDescriptorSets * GetDescriptorSets ()const{return data->mds;}
|
||||
const MaterialDescriptorManager * GetDescriptorSets ()const{return desc_manager;}
|
||||
const VkPipelineLayout GetPipelineLayout ()const;
|
||||
const PipelineLayoutData * GetPipelineLayoutData ()const{return data->pipeline_layout_data;}
|
||||
const PipelineLayoutData * GetPipelineLayoutData ()const{return pipeline_layout_data;}
|
||||
|
||||
public:
|
||||
|
||||
MaterialParameters * GetMP (const DescriptorSetsType &type)
|
||||
MaterialParameters * GetMP (const DescriptorSetType &type)
|
||||
{
|
||||
if(type==DescriptorSetsType::Material )return data->mp.m;else
|
||||
if(type==DescriptorSetsType::Primitive )return data->mp.r;else
|
||||
if(type==DescriptorSetsType::Global )return data->mp.g;else
|
||||
return(nullptr);
|
||||
RANGE_CHECK_RETURN_NULLPTR(type)
|
||||
|
||||
return mp_array[size_t(type)];
|
||||
}
|
||||
|
||||
const bool hasSet (const DescriptorSetType &type)const;
|
||||
|
||||
const VIL * GetDefaultVIL()const;
|
||||
VIL * CreateVIL(const VILConfig *format_map=nullptr);
|
||||
bool Release(VIL *);
|
||||
const uint GetVILCount();
|
||||
|
||||
public:
|
||||
|
||||
const bool HasMI ()const{return mi_data_bytes>0;}
|
||||
const uint32_t GetMIDataBytes ()const{return mi_data_bytes;}
|
||||
const uint32_t GetMIMaxCount ()const{return mi_max_count;}
|
||||
|
||||
void ReleaseMI(int); ///<释放材质实例
|
||||
void *GetMIData(int); ///<取得指定ID号的材质实例数据访问指针
|
||||
|
||||
MaterialInstance *CreateMI(const VILConfig *vil_cfg=nullptr);
|
||||
};//class Material
|
||||
|
||||
using MaterialSets=SortedSets<Material *>;
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
|
56
inc/hgl/graph/VKMaterialDescriptorManager.h
Normal file
56
inc/hgl/graph/VKMaterialDescriptorManager.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_MANAGER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_MANAGER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKShaderDescriptorSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using BindingMap=Map<AnsiString,int>;
|
||||
using BindingMapArray=BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
class MaterialDescriptorManager
|
||||
{
|
||||
UTF8String mtl_name;
|
||||
|
||||
BindingMapArray binding_map[DESCRIPTOR_SET_TYPE_COUNT];
|
||||
|
||||
private:
|
||||
|
||||
VkDescriptorSetLayoutBinding *all_dslb;
|
||||
|
||||
DescriptorSetLayoutCreateInfo dsl_ci[DESCRIPTOR_SET_TYPE_COUNT];
|
||||
|
||||
public:
|
||||
|
||||
MaterialDescriptorManager(const UTF8String &,ShaderDescriptor *,const uint);
|
||||
MaterialDescriptorManager(const UTF8String &,const ShaderDescriptorSetArray &);
|
||||
~MaterialDescriptorManager();
|
||||
|
||||
const UTF8String &GetMaterialName()const{return mtl_name;}
|
||||
|
||||
const uint GetBindCount(const DescriptorSetType &set_type)const
|
||||
{
|
||||
RANGE_CHECK_RETURN(set_type,0)
|
||||
|
||||
return dsl_ci[size_t(set_type)].bindingCount;
|
||||
}
|
||||
|
||||
const BindingMapArray &GetBindingMap(const DescriptorSetType &set_type)const
|
||||
{
|
||||
return binding_map[size_t(set_type)];
|
||||
}
|
||||
|
||||
const int GetBinding(const DescriptorSetType &set_type,const VkDescriptorType &desc_type,const AnsiString &name)const;
|
||||
|
||||
const int GetUBO (const DescriptorSetType &set_type,const AnsiString &name,bool dynamic)const{return GetBinding(set_type,dynamic?VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,name);}
|
||||
const int GetSSBO (const DescriptorSetType &set_type,const AnsiString &name,bool dynamic)const{return GetBinding(set_type,dynamic?VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);}
|
||||
const int GetImageSampler (const DescriptorSetType &set_type,const AnsiString &name )const{return GetBinding(set_type,VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,name);}
|
||||
const int GetInputAttachment(const DescriptorSetType &set_type,const AnsiString &name )const{return GetBinding(set_type,VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
|
||||
|
||||
const DescriptorSetLayoutCreateInfo *GetDSLCI(const DescriptorSetType &type)const{return dsl_ci+size_t(type);}
|
||||
|
||||
const bool hasSet(const DescriptorSetType &type)const{return dsl_ci[size_t(type)].bindingCount>0;}
|
||||
//!sd_list_by_set_type[size_t(type)].IsEmpty();}
|
||||
};//class MaterialDescriptorManager
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_MANAGER_INCLUDE
|
@@ -1,56 +0,0 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
struct ShaderDescriptor
|
||||
{
|
||||
char name[128];
|
||||
|
||||
VkDescriptorType desc_type;
|
||||
DescriptorSetsType set_type;
|
||||
uint32_t set;
|
||||
uint32_t binding;
|
||||
uint32_t stage_flag;
|
||||
};
|
||||
|
||||
using ShaderDescriptorList=List<ShaderDescriptor *>;
|
||||
|
||||
class MaterialDescriptorSets
|
||||
{
|
||||
UTF8String mtl_name;
|
||||
|
||||
ShaderDescriptor *sd_list;
|
||||
uint sd_count;
|
||||
|
||||
ShaderDescriptorList descriptor_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
Map<AnsiString,ShaderDescriptor *> sd_by_name;
|
||||
Map<AnsiString,int> binding_map[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
int *binding_list[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
private:
|
||||
|
||||
DescriptorSetLayoutCreateInfo sds[size_t(DescriptorSetsType::RANGE_SIZE)];
|
||||
|
||||
public:
|
||||
|
||||
MaterialDescriptorSets(const UTF8String &,ShaderDescriptor *,const uint);
|
||||
~MaterialDescriptorSets();
|
||||
|
||||
const UTF8String &GetMaterialName()const{return mtl_name;}
|
||||
|
||||
const int GetBinding(const VkDescriptorType &desc_type,const AnsiString &name)const;
|
||||
|
||||
const int GetUBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,name);}
|
||||
const int GetSSBO (const AnsiString &name,bool dynamic)const{return GetBinding(dynamic?VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,name);}
|
||||
const int GetSampler (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,name);}
|
||||
const int GetAttachment (const AnsiString &name )const{return GetBinding(VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,name);}
|
||||
|
||||
const DescriptorSetLayoutCreateInfo *GetBinding(const DescriptorSetsType &type)const{return sds+size_t(type);}
|
||||
};//class MaterialDescriptorSets
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_DESCRIPTOR_SETS_INCLUDE
|
@@ -1,37 +1,83 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKMaterial.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* <summary>
|
||||
*
|
||||
* layout(location=?) in uint MaterialInstanceID
|
||||
*
|
||||
* #define MI_MAX_COUNT ??? //该值由引擎根据 UBORange/sizeof(MaterialInstance) 计算出来
|
||||
*
|
||||
* struct MaterialInstance //这部分数据,即为材质实例的具体数据,每一个材质实例类负责提供具体数据。由RenderList合并成一整个UBO
|
||||
* { //该类数据,由DescriptorSetType为PerMaterial的参数构成
|
||||
* vec4 BaseColor;
|
||||
* vec4 Emissive;
|
||||
* vec4 ARM;
|
||||
* };
|
||||
*
|
||||
* layout(set=?,binding=?) uniform Material
|
||||
* {
|
||||
* MaterialInstance mi[MI_MAX_COUNT]
|
||||
* }mtl;
|
||||
*
|
||||
* void main()
|
||||
* {
|
||||
* MaterialInstance mi=mtl.mi[(MaterialInstanceID>=MI_MAX_COUNT)?:0:MaterialInstanceID]; //如果超出范围则使用0号材质实例数据
|
||||
*
|
||||
* vec4 BaseColor =mi.BaseColor;
|
||||
* vec4 Emissive =mi.Emissive;
|
||||
*
|
||||
* float AO =mi.ARM.x;
|
||||
* float Roughness =mi.ARM.y;
|
||||
* float Metallic =mi.ARM.z;
|
||||
*
|
||||
* </summary>
|
||||
*/
|
||||
|
||||
/**
|
||||
* 材质实例类<br>
|
||||
* 材质实例类本质只是提供一个数据区,供RenderList合并成一个大UBO。
|
||||
*/
|
||||
class MaterialInstance
|
||||
{
|
||||
protected:
|
||||
|
||||
Material *material;
|
||||
|
||||
VAB *vab;
|
||||
VIL *vil;
|
||||
|
||||
MaterialParameters *mp_value;
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
MaterialInstance(Material *,VAB *,MaterialParameters *);
|
||||
int mi_id;
|
||||
|
||||
public:
|
||||
|
||||
virtual ~MaterialInstance();
|
||||
Material * GetMaterial () {return material;}
|
||||
|
||||
Material *GetMaterial(){return material;}
|
||||
const VIL * GetVIL ()const {return vil;}
|
||||
|
||||
const VAB *GetVAB()const{return vab;}
|
||||
MaterialParameters *GetMP(){return mp_value;}
|
||||
MaterialParameters *GetMP(const DescriptorSetsType &type);
|
||||
private:
|
||||
|
||||
friend class Material;
|
||||
|
||||
MaterialInstance(Material *,VIL *,const int);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~MaterialInstance()
|
||||
{
|
||||
material->ReleaseMI(mi_id);
|
||||
}
|
||||
|
||||
const int GetMIID ()const{return mi_id;} ///<取得材质实例ID
|
||||
void * GetMIData (){return material->GetMIData(mi_id);} ///<取得材质实例数据
|
||||
void WriteMIData (const void *data,const int size); ///<写入材质实例数据
|
||||
|
||||
bool BindUBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const DescriptorSetsType &type,const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const DescriptorSetsType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
bool BindUBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const DescriptorSetType &type,const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindImageSampler(const DescriptorSetType &type,const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
};//class MaterialInstance
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INSTANCE_INCLUDE
|
||||
|
@@ -1,53 +1,60 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VKDescriptorSets.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKDescriptorSetType.h>
|
||||
#include<hgl/graph/VKMaterialDescriptorManager.h>
|
||||
#include<hgl/graph/VKArrayBuffer.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class MaterialParameters
|
||||
{
|
||||
const MaterialDescriptorSets *mds;
|
||||
protected:
|
||||
|
||||
DescriptorSetsType ds_type;
|
||||
const MaterialDescriptorManager *desc_manager;
|
||||
|
||||
DescriptorSets *descriptor_sets;
|
||||
DescriptorSetType set_type;
|
||||
|
||||
private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
MaterialParameters(const MaterialDescriptorSets *,const DescriptorSetsType &type,DescriptorSets *);
|
||||
DescriptorSet *descriptor_set;
|
||||
|
||||
public:
|
||||
|
||||
const DescriptorSetsType GetType (){return ds_type;}
|
||||
DescriptorSets * GetDescriptorSet (){return descriptor_sets;}
|
||||
const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_sets->GetDescriptorSet();}
|
||||
const DescriptorSetType GetType (){return set_type;}
|
||||
DescriptorSet * GetDescriptorSet (){return descriptor_set;}
|
||||
const VkDescriptorSet GetVkDescriptorSet ()const{return descriptor_set->GetDescriptorSet();}
|
||||
|
||||
const uint32_t GetCount ()const{return descriptor_sets->GetCount();}
|
||||
const bool IsReady ()const{return descriptor_sets->IsReady();}
|
||||
const uint32_t GetDescriptorCount ()const{return desc_manager->GetBindCount(set_type);} ///<获取总共需要绑定的描述符数量
|
||||
const BindingMapArray & GetBindingMap ()const{return desc_manager->GetBindingMap(set_type);}
|
||||
|
||||
const uint32_t GetBoundCount ()const{return descriptor_set->GetCount();} ///<获取已经绑好的数量
|
||||
const bool IsReady ()const{return descriptor_set->IsReady();} ///<是否全部绑好了
|
||||
|
||||
public:
|
||||
|
||||
#define MP_TYPE_IS(name) const bool is##name()const{return ds_type==DescriptorSetsType::name;}
|
||||
MP_TYPE_IS(Material)
|
||||
// MP_TYPE_IS(Texture)
|
||||
MP_TYPE_IS(Value)
|
||||
MP_TYPE_IS(Primitive)
|
||||
#define MP_TYPE_IS(name) const bool is##name()const{return set_type==DescriptorSetType::name;}
|
||||
MP_TYPE_IS(Instance)
|
||||
MP_TYPE_IS(PerMaterial)
|
||||
MP_TYPE_IS(PerFrame)
|
||||
MP_TYPE_IS(Global)
|
||||
#undef MP_TYPE_IS
|
||||
|
||||
public:
|
||||
|
||||
MaterialParameters(const MaterialDescriptorManager *,const DescriptorSetType &type,DescriptorSet *);
|
||||
virtual ~MaterialParameters();
|
||||
|
||||
bool BindUBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const AnsiString &name,GPUBuffer *ubo,bool dynamic=false);
|
||||
bool BindSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
bool BindUBO(const int &index,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const int &index,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindImageSampler(const int &index,Texture *tex,Sampler *sampler);
|
||||
bool BindInputAttachment(const int &index,ImageView *);
|
||||
|
||||
bool BindUBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindSSBO(const AnsiString &name,DeviceBuffer *ubo,bool dynamic=false);
|
||||
bool BindImageSampler(const AnsiString &name,Texture *tex,Sampler *sampler);
|
||||
bool BindInputAttachment(const AnsiString &name,ImageView *);
|
||||
|
||||
void Update();
|
||||
};//class MaterialParameters
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_PARAMETERS_INCLUDE
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUMemory
|
||||
class DeviceMemory
|
||||
{
|
||||
VkDevice device;
|
||||
VkDeviceMemory memory;
|
||||
@@ -18,11 +18,11 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
GPUMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas);
|
||||
DeviceMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUMemory();
|
||||
virtual ~DeviceMemory();
|
||||
|
||||
operator VkDeviceMemory(){return memory;}
|
||||
|
||||
@@ -47,6 +47,6 @@ public:
|
||||
|
||||
void Flush (VkDeviceSize,VkDeviceSize);
|
||||
void Flush (VkDeviceSize size){Flush(0,size);}
|
||||
};//class GPUMemory
|
||||
};//class DeviceMemory
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MEMORY_INCLUDE
|
||||
|
@@ -11,7 +11,7 @@ class VKMemoryAllocator:public AbstractMemoryAllocator
|
||||
|
||||
uint32_t buffer_usage_flag_bits;
|
||||
|
||||
GPUBuffer *gpu_buffer;
|
||||
DeviceBuffer *gpu_buffer;
|
||||
|
||||
VkDeviceSize range; //ubo之类需要一个一次访问范围
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
|
||||
const uint32_t GetBufferUsageFlagBits ()const{return buffer_usage_flag_bits;}
|
||||
|
||||
GPUBuffer * GetBuffer (){return gpu_buffer;}
|
||||
DeviceBuffer * GetBuffer (){return gpu_buffer;}
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -28,19 +28,8 @@ class GPUPhysicalDevice
|
||||
private:
|
||||
|
||||
bool dynamic_state=false;
|
||||
|
||||
public:
|
||||
|
||||
GPUPhysicalDevice(VkInstance,VkPhysicalDevice);
|
||||
~GPUPhysicalDevice()=default;
|
||||
|
||||
operator VkPhysicalDevice() {return physical_device;}
|
||||
operator const VkPhysicalDevice()const {return physical_device;}
|
||||
|
||||
const int GetMemoryType(uint32_t,VkMemoryPropertyFlags)const;
|
||||
|
||||
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
|
||||
const char * GetDeviceName()const{return properties.deviceName;}
|
||||
|
||||
public:
|
||||
|
||||
const VkPhysicalDeviceFeatures & GetFeatures10 ()const{return features;}
|
||||
const VkPhysicalDeviceVulkan11Features &GetFeatures11 ()const{return features11;}
|
||||
@@ -51,19 +40,32 @@ public:
|
||||
const VkPhysicalDeviceMemoryProperties &GetMemoryProperties ()const{return memory_properties;}
|
||||
const VkPhysicalDeviceLimits & GetLimits ()const{return properties.limits;}
|
||||
|
||||
public:
|
||||
|
||||
GPUPhysicalDevice(VkInstance,VkPhysicalDevice);
|
||||
~GPUPhysicalDevice()=default;
|
||||
|
||||
operator VkPhysicalDevice() {return physical_device;}
|
||||
operator const VkPhysicalDevice()const {return physical_device;}
|
||||
|
||||
const uint32_t GetVulkanVersion()const{return properties.apiVersion;}
|
||||
|
||||
const int GetMemoryType(uint32_t,VkMemoryPropertyFlags)const;
|
||||
|
||||
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
|
||||
const char * GetDeviceName()const{return properties.deviceName;}
|
||||
|
||||
const bool GetLayerVersion(const AnsiString &,uint32_t &spec,uint32_t &impl)const;
|
||||
const uint32_t GetExtensionVersion(const AnsiString &name)const;
|
||||
const bool CheckExtensionSupport(const AnsiString &name)const;
|
||||
|
||||
public:
|
||||
|
||||
const uint32_t GetUBORange ()const{return properties.limits.maxUniformBufferRange;}
|
||||
const VkDeviceSize GetUBOAlign ()const{return properties.limits.minUniformBufferOffsetAlignment;}
|
||||
|
||||
const uint32_t GetSSBORange ()const{return properties.limits.maxStorageBufferRange;}
|
||||
const VkDeviceSize GetSSBOAlign ()const{return properties.limits.minStorageBufferOffsetAlignment;}
|
||||
|
||||
const uint32_t GetConstantSize ()const{return properties.limits.maxPushConstantsSize;}
|
||||
const uint32_t GetConstantSize ()const{return properties.limits.maxPushConstantsSize;}
|
||||
|
||||
public:
|
||||
|
||||
@@ -83,6 +85,28 @@ public:
|
||||
const bool isIntegratedGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);} ///<是否是集成显卡
|
||||
const bool isVirtualGPU ()const{return(properties.deviceType==VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU);} ///<是否是虚拟显卡
|
||||
|
||||
#define HGL_VK_IS_BRAND(name) (hgl::stricmp(properties.deviceName,#name,sizeof(#name))==0)
|
||||
|
||||
const bool isMicrosoft ()const{return HGL_VK_IS_BRAND(Microsoft);}
|
||||
const bool isMesa ()const{return HGL_VK_IS_BRAND(Mesa );}
|
||||
const bool isAMD ()const{return HGL_VK_IS_BRAND(AMD )
|
||||
||HGL_VK_IS_BRAND(ATI )
|
||||
||HGL_VK_IS_BRAND(Radeon );}
|
||||
const bool isNvidia ()const{return HGL_VK_IS_BRAND(nVidia )
|
||||
||HGL_VK_IS_BRAND(GeForce )
|
||||
||HGL_VK_IS_BRAND(Quadro )
|
||||
||HGL_VK_IS_BRAND(TITAN )
|
||||
||HGL_VK_IS_BRAND(Tegra );}
|
||||
const bool isIntel ()const{return HGL_VK_IS_BRAND(Intel );}
|
||||
const bool isQualcomm ()const{return HGL_VK_IS_BRAND(Adreno );}
|
||||
const bool isApple ()const{return HGL_VK_IS_BRAND(Apple );}
|
||||
const bool isImgTec ()const{return HGL_VK_IS_BRAND(ImgTec )
|
||||
||HGL_VK_IS_BRAND(PowerVR );}
|
||||
const bool isARM ()const{return HGL_VK_IS_BRAND(Arm )
|
||||
||HGL_VK_IS_BRAND(Mali );}
|
||||
|
||||
#undef HGL_VK_IS_BRAND
|
||||
|
||||
public:
|
||||
|
||||
VkFormatProperties GetFormatProperties(const VkFormat format)const
|
||||
@@ -114,7 +138,6 @@ public:
|
||||
const bool IsSTBAtomicSupport (const VkFormat format)const{return BufferSupport(format,VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT);}
|
||||
const bool IsVBOSupport (const VkFormat format)const{return BufferSupport(format,VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT);}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
const VkBool32 SupportGeometryShader ()const{return features.geometryShader;}
|
||||
@@ -122,26 +145,24 @@ public:
|
||||
|
||||
// support != open, so please don't direct use GetFeatures().
|
||||
// open any features in CreateDevice()&SetDeviceFeatures() functions.
|
||||
const bool SupportMDI ()const
|
||||
const bool SupportMDI ()const
|
||||
{
|
||||
// the device is supported MDI, but MaxDrawIndirectCount is 1.
|
||||
|
||||
return (features.multiDrawIndirect&&properties.limits.maxDrawIndirectCount>1);
|
||||
}
|
||||
|
||||
const uint32_t GetMaxMDICount ()const
|
||||
const uint32_t GetMaxMDICount ()const
|
||||
{
|
||||
return properties.limits.maxDrawIndirectCount;
|
||||
}
|
||||
|
||||
const uint32_t GetMaxImage1D ()const{return properties.limits.maxImageDimension1D;}
|
||||
const uint32_t GetMaxImage2D ()const{return properties.limits.maxImageDimension2D;}
|
||||
const uint32_t GetMaxImage3D ()const{return properties.limits.maxImageDimension3D;}
|
||||
const uint32_t GetMaxImageCube ()const{return properties.limits.maxImageDimensionCube;}
|
||||
const uint32_t GetMaxImageArrayLayers ()const{return properties.limits.maxImageArrayLayers;}
|
||||
const uint32_t GetMaxUBORange ()const{return properties.limits.maxUniformBufferRange;}
|
||||
const uint32_t GetMaxSSBORange ()const{return properties.limits.maxStorageBufferRange;}
|
||||
const uint32_t GetMaxBoundDescriptorSets()const{return properties.limits.maxBoundDescriptorSets;}
|
||||
const uint32_t GetMaxImage1D ()const{return properties.limits.maxImageDimension1D;}
|
||||
const uint32_t GetMaxImage2D ()const{return properties.limits.maxImageDimension2D;}
|
||||
const uint32_t GetMaxImage3D ()const{return properties.limits.maxImageDimension3D;}
|
||||
const uint32_t GetMaxImageCube ()const{return properties.limits.maxImageDimensionCube;}
|
||||
const uint32_t GetMaxImageArrayLayers ()const{return properties.limits.maxImageArrayLayers;}
|
||||
const uint32_t GetMaxBoundDescriptorSets ()const{return properties.limits.maxBoundDescriptorSets;}
|
||||
|
||||
const uint32_t GetMaxVertexInputAttributes ()const{return properties.limits.maxVertexInputAttributes;}
|
||||
const uint32_t GetMaxVertexInputBindings ()const{return properties.limits.maxVertexInputBindings;}
|
||||
|
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
operator VkPipeline(){return pipeline;}
|
||||
|
||||
const PipelineData *GetData()const{return data;}
|
||||
|
||||
const bool IsAlphaTest()const{return data->alpha_test>0;}
|
||||
const bool IsAlphaBlend()const{return data->alpha_blend;}
|
||||
};//class GraphicsPipeline
|
||||
|
@@ -26,10 +26,9 @@ class Primitive
|
||||
|
||||
protected:
|
||||
|
||||
uint32_t draw_count;
|
||||
uint32_t vertex_count;
|
||||
|
||||
IndexBuffer *indices_buffer=nullptr;
|
||||
VkDeviceSize indices_offset=0;
|
||||
IndexBufferData index_buffer_data;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -46,42 +45,34 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
Primitive(const uint32_t dc=0):draw_count(dc){}
|
||||
Primitive(const uint32_t vc=0):vertex_count(vc){}
|
||||
virtual ~Primitive()=default;
|
||||
|
||||
const uint GetRefCount()const{return ref_count;}
|
||||
|
||||
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
|
||||
void SetBoundingBox(const AABB &aabb){BoundingBox=aabb;}
|
||||
const AABB & GetBoundingBox()const {return BoundingBox;}
|
||||
|
||||
bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0);
|
||||
bool Set(const AnsiString &name,VBO *vb,VkDeviceSize offset=0);
|
||||
|
||||
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
|
||||
bool Set(IndexBuffer *ib,VkDeviceSize offset=0)
|
||||
{
|
||||
if(!ib)return(false);
|
||||
|
||||
indices_buffer=ib;
|
||||
indices_offset=offset;
|
||||
index_buffer_data.buffer=ib;
|
||||
index_buffer_data.offset=offset;
|
||||
return(true);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void SetDrawCount(const uint32_t dc){draw_count=dc;} ///<设置当前对象绘制需要多少个顶点
|
||||
virtual const uint32_t GetDrawCount()const ///<取得当前对象绘制需要多少个顶点
|
||||
{
|
||||
if(indices_buffer)
|
||||
return indices_buffer->GetCount();
|
||||
const uint32_t GetVertexCount ()const {return vertex_count;}
|
||||
|
||||
return draw_count;
|
||||
}
|
||||
VBO * GetVBO (const AnsiString &,VkDeviceSize *);
|
||||
VkBuffer GetBuffer (const AnsiString &,VkDeviceSize *);
|
||||
const int GetBufferCount ()const {return buffer_list.GetCount();}
|
||||
|
||||
VBO * GetVBO (const AnsiString &,VkDeviceSize *);
|
||||
VkBuffer GetBuffer (const AnsiString &,VkDeviceSize *);
|
||||
const int GetBufferCount ()const {return buffer_list.GetCount();}
|
||||
|
||||
IndexBuffer * GetIndexBuffer () {return indices_buffer;}
|
||||
const VkDeviceSize GetIndexBufferOffset()const {return indices_offset;}
|
||||
const IndexBufferData * GetIndexBufferData ()const {return &index_buffer_data;}
|
||||
};//class Primitive
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_PRIMITIVE_INCLUDE
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKFence.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUQueue
|
||||
class DeviceQueue
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -12,7 +12,7 @@ protected:
|
||||
VkQueue queue;
|
||||
|
||||
uint32_t current_fence;
|
||||
GPUFence **fence_list;
|
||||
Fence **fence_list;
|
||||
uint32_t fence_count;
|
||||
|
||||
SubmitInfo submit_info;
|
||||
@@ -21,18 +21,20 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
GPUQueue(VkDevice dev,VkQueue q,GPUFence **,const uint32_t fc);
|
||||
DeviceQueue(VkDevice dev,VkQueue q,Fence **,const uint32_t fc);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GPUQueue();
|
||||
virtual ~DeviceQueue();
|
||||
|
||||
operator VkQueue(){return queue;}
|
||||
|
||||
VkResult Present(const VkPresentInfoKHR *pi){return vkQueuePresentKHR(queue,pi);}
|
||||
|
||||
bool WaitQueue();
|
||||
bool WaitFence(const bool wait_all=true,const uint64_t time_out=HGL_NANO_SEC_PER_SEC);
|
||||
bool Submit(const VkCommandBuffer &cmd_buf,GPUSemaphore *wait_sem,GPUSemaphore *complete_sem);
|
||||
bool Submit(const VkCommandBuffer *cmd_buf,const uint32_t count,GPUSemaphore *wait_sem,GPUSemaphore *complete_sem);
|
||||
};//class SumbitQueue
|
||||
bool Submit(const VkCommandBuffer &cmd_buf,Semaphore *wait_sem,Semaphore *complete_sem);
|
||||
bool Submit(const VkCommandBuffer *cmd_buf,const uint32_t count,Semaphore *wait_sem,Semaphore *complete_sem);
|
||||
};//class DeviceQueue
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SUBMIT_QUEUE_INCLUDE
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/ObjectList.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
/**
|
||||
* RenderPass功能封装<br>
|
||||
@@ -25,7 +25,7 @@ protected:
|
||||
|
||||
ObjectList<Pipeline> pipeline_list;
|
||||
|
||||
Pipeline *CreatePipeline(Material *,PipelineData *,const VAB *);
|
||||
Pipeline *CreatePipeline(PipelineData *,const ShaderStageCreateInfoList &,VkPipelineLayout,const VIL *);
|
||||
|
||||
private:
|
||||
|
||||
@@ -54,14 +54,15 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const PipelineData *);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const InlinePipeline &);
|
||||
Pipeline *CreatePipeline(Material *,const VIL *,const PipelineData *, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *,const VIL *,const InlinePipeline &, const Prim &,const bool prim_restart=false);
|
||||
|
||||
public:
|
||||
Pipeline *CreatePipeline(Material *mtl, const PipelineData *, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(Material *mtl, const InlinePipeline &, const Prim &,const bool prim_restart=false);
|
||||
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const InlinePipeline &, const Prim &prim,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const PipelineData *, const Prim &prim,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const OSString &, const Prim &prim,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const InlinePipeline &, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const PipelineData *, const Prim &,const bool prim_restart=false);
|
||||
Pipeline *CreatePipeline(MaterialInstance *, const OSString &, const Prim &,const bool prim_restart=false);
|
||||
};//class RenderPass
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_RENDER_PASS_INCLUDE
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VKMaterial.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/graph/VKDescriptorSets.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKPrimitive.h>
|
||||
#include<hgl/graph/VKBuffer.h>
|
||||
#include<hgl/graph/VKSampler.h>
|
||||
@@ -13,12 +13,15 @@
|
||||
#include<hgl/graph/VertexAttribData.h>
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/graph/font/TextPrimitive.h>
|
||||
#include<hgl/type/ResManage.h>
|
||||
#include<hgl/type/ObjectManage.h>
|
||||
#include<hgl/shadergen/MaterialCreateInfo.h>
|
||||
#include<hgl/graph/VKDescriptorBindingManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
using MaterialID =int;
|
||||
using MaterialInstanceID =int;
|
||||
using BufferID =int;
|
||||
using DescriptorSetsID =int;
|
||||
using DescriptorSetID =int;
|
||||
using PrimitiveID =int;
|
||||
using RenderableID =int;
|
||||
using SamplerID =int;
|
||||
@@ -26,6 +29,9 @@ using TextureID =int;
|
||||
|
||||
class VertexAttribData;
|
||||
|
||||
using ShaderModuleMapByName=ObjectMap<AnsiString,ShaderModule>;
|
||||
constexpr const size_t VK_SHADER_STAGE_TYPE_COUNT=20;//GetBitOffset((uint32_t)VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI)+1;
|
||||
|
||||
/**
|
||||
* 资源管理,用于管理场景内所需的所有数据
|
||||
*/
|
||||
@@ -33,31 +39,36 @@ class RenderResource
|
||||
{
|
||||
GPUDevice *device;
|
||||
|
||||
MapObject<OSString,ShaderModule> shader_module_by_name;
|
||||
Map<OSString,Material *> material_by_name;
|
||||
ShaderModuleMapByName shader_module_by_name[VK_SHADER_STAGE_TYPE_COUNT];
|
||||
Map<AnsiString,Material *> material_by_name;
|
||||
Map<OSString,Texture *> texture_by_name;
|
||||
|
||||
IDResManage<MaterialID, Material> rm_material; ///<材质合集
|
||||
IDResManage<MaterialInstanceID, MaterialInstance> rm_material_instance; ///<材质实例合集
|
||||
IDResManage<DescriptorSetsID, DescriptorSets> rm_desc_sets; ///<描述符合集
|
||||
IDResManage<PrimitiveID, Primitive> rm_primitives; ///<图元合集
|
||||
IDResManage<BufferID, GPUBuffer> rm_buffers; ///<顶点缓冲区合集
|
||||
IDResManage<SamplerID, Sampler> rm_samplers; ///<采样器合集
|
||||
IDResManage<TextureID, Texture> rm_textures; ///<纹理合集
|
||||
IDResManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
||||
IDObjectManage<MaterialID, Material> rm_material; ///<材质合集
|
||||
IDObjectManage<MaterialInstanceID, MaterialInstance> rm_material_instance; ///<材质实例合集
|
||||
IDObjectManage<DescriptorSetID, DescriptorSet> rm_desc_sets; ///<描述符合集
|
||||
IDObjectManage<PrimitiveID, Primitive> rm_primitives; ///<图元合集
|
||||
IDObjectManage<BufferID, DeviceBuffer> rm_buffers; ///<顶点缓冲区合集
|
||||
IDObjectManage<SamplerID, Sampler> rm_samplers; ///<采样器合集
|
||||
IDObjectManage<TextureID, Texture> rm_textures; ///<纹理合集
|
||||
IDObjectManage<RenderableID, Renderable> rm_renderables; ///<渲染实例集合集
|
||||
|
||||
public:
|
||||
|
||||
RenderResource(GPUDevice *dev):device(dev){}
|
||||
//注:并非一定要走这里,这里只是提供一个注册和自动绑定的机制
|
||||
DescriptorBinding global_descriptor; ///<全局属性描述符绑定管理
|
||||
|
||||
public:
|
||||
|
||||
RenderResource(GPUDevice *dev):device(dev),global_descriptor(DescriptorSetType::Global){}
|
||||
virtual ~RenderResource()=default;
|
||||
|
||||
public: //Add
|
||||
|
||||
MaterialID Add(Material * mtl ){return rm_material.Add(mtl);}
|
||||
MaterialInstanceID Add(MaterialInstance * mi ){return rm_material_instance.Add(mi);}
|
||||
DescriptorSetsID Add(DescriptorSets * ds ){return rm_desc_sets.Add(ds);}
|
||||
DescriptorSetID Add(DescriptorSet * ds ){return rm_desc_sets.Add(ds);}
|
||||
PrimitiveID Add(Primitive * p ){return rm_primitives.Add(p);}
|
||||
BufferID Add(GPUBuffer * buf ){return rm_buffers.Add(buf);}
|
||||
BufferID Add(DeviceBuffer * buf ){return rm_buffers.Add(buf);}
|
||||
SamplerID Add(Sampler * s ){return rm_samplers.Add(s);}
|
||||
TextureID Add(Texture * t ){return rm_textures.Add(t);}
|
||||
RenderableID Add(Renderable * r ){return rm_renderables.Add(r);}
|
||||
@@ -66,10 +77,10 @@ public: // VBO/VAO
|
||||
|
||||
VBO *CreateVBO(VkFormat format,uint32_t count,const void *data,SharingMode sm=SharingMode::Exclusive);
|
||||
VBO *CreateVBO(VkFormat format,uint32_t count,SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
|
||||
VBO *CreateVBO(const VAD *vad,SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetVulkanFormat(),vad->GetCount(),vad->GetData(),sm);}
|
||||
VBO *CreateVBO(const VAD *vad,SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetFormat(),vad->GetCount(),vad->GetData(),sm);}
|
||||
|
||||
#define SCENE_DB_CREATE_FUNC(name) GPUBuffer *Create##name(VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \
|
||||
GPUBuffer *Create##name(VkDeviceSize size,SharingMode sm=SharingMode::Exclusive);
|
||||
#define SCENE_DB_CREATE_FUNC(name) DeviceBuffer *Create##name(VkDeviceSize size,void *data,SharingMode sm=SharingMode::Exclusive); \
|
||||
DeviceBuffer *Create##name(VkDeviceSize size,SharingMode sm=SharingMode::Exclusive);
|
||||
|
||||
SCENE_DB_CREATE_FUNC(UBO)
|
||||
SCENE_DB_CREATE_FUNC(SSBO)
|
||||
@@ -87,11 +98,12 @@ public: // VBO/VAO
|
||||
|
||||
public: //Material
|
||||
|
||||
const ShaderModule *CreateShaderModule(const OSString &filename,ShaderResource *shader_resource);
|
||||
const ShaderModule *CreateShaderModule(const AnsiString &shader_module_name,const ShaderCreateInfo *);
|
||||
|
||||
Material * CreateMaterial(const OSString &);
|
||||
MaterialInstance * CreateMaterialInstance(Material *,const VABConfigInfo *vab_cfg=nullptr);
|
||||
MaterialInstance * CreateMaterialInstance(const OSString &,const VABConfigInfo *vab_cfg=nullptr);
|
||||
Material * CreateMaterial(const mtl::MaterialCreateInfo *);
|
||||
|
||||
MaterialInstance * CreateMaterialInstance(Material *,const VILConfig *vil_cfg=nullptr);
|
||||
MaterialInstance * CreateMaterialInstance(const mtl::MaterialCreateInfo *,const VILConfig *vil_cfg=nullptr);
|
||||
|
||||
Primitive * CreatePrimitive(const uint32_t vertex_count=0);
|
||||
|
||||
@@ -109,12 +121,12 @@ public: //Get
|
||||
|
||||
Material * GetMaterial (const MaterialID &id){return rm_material.Get(id);}
|
||||
MaterialInstance * GetMaterialInstance (const MaterialInstanceID &id){return rm_material_instance.Get(id);}
|
||||
DescriptorSets * GetDescSets (const DescriptorSetsID &id){return rm_desc_sets.Get(id);}
|
||||
DescriptorSet * GetDescSets (const DescriptorSetID &id){return rm_desc_sets.Get(id);}
|
||||
Primitive * GetPrimitive (const PrimitiveID &id){return rm_primitives.Get(id);}
|
||||
GPUBuffer * GetBuffer (const BufferID &id){return rm_buffers.Get(id);}
|
||||
DeviceBuffer * GetBuffer (const BufferID &id){return rm_buffers.Get(id);}
|
||||
Sampler * GetSampler (const SamplerID &id){return rm_samplers.Get(id);}
|
||||
Texture * GetTexture (const TextureID &id){return rm_textures.Get(id);}
|
||||
Renderable * GetRenderable (const RenderableID &id){return rm_renderables.Get(id);}
|
||||
Renderable * GetRenderable (const RenderableID &id){return rm_renderables.Get(id);}
|
||||
};//class RenderResource
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_DATABASE_INCLUDE
|
||||
|
@@ -15,14 +15,14 @@ class RenderTarget
|
||||
{
|
||||
protected:
|
||||
|
||||
GPUQueue *queue;
|
||||
DeviceQueue *queue;
|
||||
|
||||
RenderPass *render_pass;
|
||||
Framebuffer *fbo;
|
||||
|
||||
VkExtent2D extent;
|
||||
|
||||
GPUSemaphore *render_complete_semaphore =nullptr;
|
||||
Semaphore *render_complete_semaphore =nullptr;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -34,13 +34,14 @@ protected:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
RenderTarget(GPUQueue *,GPUSemaphore *);
|
||||
RenderTarget(GPUQueue *,GPUSemaphore *,RenderPass *_rp,Framebuffer *_fb,Texture2D **color_texture_list,const uint32_t color_count,Texture2D *depth_texture);
|
||||
RenderTarget(DeviceQueue *,Semaphore *);
|
||||
RenderTarget(DeviceQueue *,Semaphore *,RenderPass *_rp,Framebuffer *_fb,Texture2D **color_texture_list,const uint32_t color_count,Texture2D *depth_texture);
|
||||
|
||||
public:
|
||||
|
||||
virtual ~RenderTarget();
|
||||
|
||||
DeviceQueue * GetQueue () {return queue;}
|
||||
const VkExtent2D & GetExtent ()const {return extent;}
|
||||
virtual RenderPass * GetRenderPass () {return render_pass;}
|
||||
virtual const VkRenderPass GetVkRenderPass ()const {return render_pass->GetVkRenderPass();}
|
||||
@@ -52,8 +53,8 @@ public:
|
||||
|
||||
public: // command buffer
|
||||
|
||||
GPUSemaphore * GetRenderCompleteSemaphore (){return render_complete_semaphore;}
|
||||
virtual bool Submit (RenderCmdBuffer *,GPUSemaphore *present_complete_semaphore=nullptr);
|
||||
Semaphore * GetRenderCompleteSemaphore (){return render_complete_semaphore;}
|
||||
virtual bool Submit (RenderCmdBuffer *,Semaphore *present_complete_semaphore=nullptr);
|
||||
|
||||
bool WaitQueue(){return queue->WaitQueue();}
|
||||
bool WaitFence(){return queue->WaitFence();}
|
||||
@@ -62,23 +63,23 @@ public: // command buffer
|
||||
/**
|
||||
* 交换链专用渲染目标
|
||||
*/
|
||||
class SwapchainRenderTarget:public RenderTarget
|
||||
class RTSwapchain:public RenderTarget
|
||||
{
|
||||
VkDevice device;
|
||||
Swapchain *swapchain;
|
||||
PresentInfo present_info;
|
||||
|
||||
GPUSemaphore *present_complete_semaphore=nullptr;
|
||||
Semaphore *present_complete_semaphore=nullptr;
|
||||
|
||||
uint32_t current_frame;
|
||||
|
||||
public:
|
||||
|
||||
SwapchainRenderTarget(VkDevice dev,Swapchain *sc,GPUQueue *q,GPUSemaphore *rcs,GPUSemaphore *pcs,RenderPass *rp);
|
||||
~SwapchainRenderTarget();
|
||||
RTSwapchain(VkDevice dev,Swapchain *sc,DeviceQueue *q,Semaphore *rcs,Semaphore *pcs,RenderPass *rp);
|
||||
~RTSwapchain();
|
||||
|
||||
Framebuffer * GetFramebuffer ()override {return swapchain->render_frame[current_frame];}
|
||||
Framebuffer * GetFramebuffer (const uint32_t index) {return swapchain->render_frame[index];}
|
||||
Framebuffer * GetFramebuffer ()override {return swapchain->sc_fbo[current_frame];}
|
||||
Framebuffer * GetFramebuffer (const uint32_t index) {return swapchain->sc_fbo[index];}
|
||||
|
||||
const uint32_t GetColorCount ()const override {return 1;}
|
||||
const uint32_t GetImageCount ()const {return swapchain->color_count;}
|
||||
@@ -89,7 +90,7 @@ public:
|
||||
public:
|
||||
|
||||
const uint32_t GetCurrentFrameIndices ()const {return current_frame;}
|
||||
GPUSemaphore * GetPresentCompleteSemaphore () {return present_complete_semaphore;}
|
||||
Semaphore * GetPresentCompleteSemaphore () {return present_complete_semaphore;}
|
||||
|
||||
public:
|
||||
|
||||
@@ -108,7 +109,7 @@ public:
|
||||
bool PresentBackbuffer();
|
||||
|
||||
bool Submit(VkCommandBuffer);
|
||||
bool Submit(VkCommandBuffer,GPUSemaphore *);
|
||||
};//class SwapchainRenderTarget:public RenderTarget
|
||||
bool Submit(VkCommandBuffer,Semaphore *);
|
||||
};//class RTSwapchain:public RenderTarget
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_RENDER_TARGET_INCLUDE
|
||||
|
@@ -3,14 +3,49 @@
|
||||
|
||||
#include<hgl/graph/VKPrimitive.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
#include<hgl/graph/VKDescriptorSets.h>
|
||||
#include<hgl/graph/VKDescriptorSet.h>
|
||||
#include<hgl/graph/VKMaterial.h>
|
||||
#include<hgl/graph/VKMaterialParameters.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/VertexAttrib.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
struct VertexInputData
|
||||
{
|
||||
uint32_t binding_count;
|
||||
VkBuffer *buffer_list;
|
||||
VkDeviceSize *buffer_offset;
|
||||
|
||||
uint32_t vertex_count;
|
||||
|
||||
const IndexBufferData *index_buffer;
|
||||
|
||||
public:
|
||||
|
||||
VertexInputData(const uint32_t,const uint32_t,const IndexBufferData *);
|
||||
~VertexInputData();
|
||||
|
||||
const bool Comp(const VertexInputData *vid)const
|
||||
{
|
||||
if(!vid)return(false);
|
||||
|
||||
if(binding_count!=vid->binding_count)return(false);
|
||||
|
||||
for(uint32_t i=0;i<binding_count;i++)
|
||||
{
|
||||
if(buffer_list[i]!=vid->buffer_list[i])return(false);
|
||||
if(buffer_offset[i]!=vid->buffer_offset[i])return(false);
|
||||
}
|
||||
|
||||
if(vertex_count!=vid->vertex_count)return(false);
|
||||
|
||||
if(index_buffer!=vid->index_buffer)return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
};//struct VertexInputData
|
||||
|
||||
/**
|
||||
* 可渲染对象<br>
|
||||
* RenderList会统一管理Shader中的LocalToWorld数据,使用DynamicUBO/DynamicSSBO实现。
|
||||
*/
|
||||
class Renderable ///可渲染对象实例
|
||||
{
|
||||
@@ -18,17 +53,13 @@ class Renderable
|
||||
MaterialInstance * mat_inst;
|
||||
Primitive * primitive;
|
||||
|
||||
uint32_t buffer_count;
|
||||
VkBuffer * buffer_list;
|
||||
VkDeviceSize * buffer_size;
|
||||
|
||||
uint32_t buffer_hash;
|
||||
VertexInputData * vertex_input;
|
||||
|
||||
private:
|
||||
|
||||
friend Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
|
||||
Renderable(Primitive *,MaterialInstance *,Pipeline *,const uint32_t,VkBuffer *,VkDeviceSize *);
|
||||
Renderable(Primitive *,MaterialInstance *,Pipeline *,VertexInputData *);
|
||||
|
||||
public:
|
||||
|
||||
@@ -43,20 +74,7 @@ public:
|
||||
Primitive * GetPrimitive (){return primitive;}
|
||||
const AABB & GetBoundingBox ()const{return primitive->GetBoundingBox();}
|
||||
|
||||
const uint32_t GetBufferCount ()const{return buffer_count;}
|
||||
VkBuffer * GetBuffer ()const{return buffer_list;}
|
||||
VkDeviceSize * GetBufferSize ()const{return buffer_size;}
|
||||
IndexBuffer * GetIndexBuffer ()const{return primitive->GetIndexBuffer();}
|
||||
const uint32_t GetIndexBufferOffset()const{return primitive->GetIndexBufferOffset();}
|
||||
const uint32_t GetDrawCount ()const{return primitive->GetDrawCount();}
|
||||
|
||||
const uint32_t GetBufferHash ()const{return buffer_hash;}
|
||||
|
||||
MaterialParameters *GetMP (const DescriptorSetsType &type){return mat_inst->GetMP(type);}
|
||||
|
||||
public: //instance support
|
||||
|
||||
virtual const uint32_t GetInstanceCount ()const{return 1;}
|
||||
const VertexInputData * GetVertexInputData ()const{return vertex_input;}
|
||||
};//class Renderable
|
||||
|
||||
Renderable *CreateRenderable(Primitive *,MaterialInstance *,Pipeline *);
|
||||
|
53
inc/hgl/graph/VKRenderablePrimitiveCreater.h
Normal file
53
inc/hgl/graph/VKRenderablePrimitiveCreater.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef HGL_VK_RENDERABLE_PRIMITIVE_CREATER_INCLUDE
|
||||
#define HGL_VK_RENDERABLE_PRIMITIVE_CREATER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class RenderablePrimitiveCreater
|
||||
{
|
||||
RenderResource *rr;
|
||||
|
||||
uint32_t vertex_count;
|
||||
|
||||
Primitive *prim;
|
||||
|
||||
public:
|
||||
|
||||
RenderablePrimitiveCreater(RenderResource *_rr,uint32_t vc)
|
||||
{
|
||||
rr=_rr;
|
||||
vertex_count=vc;
|
||||
|
||||
prim=rr->CreatePrimitive(vertex_count);
|
||||
}
|
||||
|
||||
bool SetVBO(const AnsiString &name,const VkFormat &fmt,const void *buf)
|
||||
{
|
||||
VBO *vbo=rr->CreateVBO(fmt,vertex_count,buf);
|
||||
|
||||
if(!vbo)
|
||||
return(false);
|
||||
|
||||
prim->Set(name,vbo);
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool SetIBO(const IndexType &it,const void *buf)
|
||||
{
|
||||
IndexBuffer *ibo=rr->CreateIBO(it,vertex_count,buf);
|
||||
|
||||
if(!ibo)
|
||||
return(false);
|
||||
|
||||
prim->Set(ibo);
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *Create(MaterialInstance *mi,Pipeline *p)
|
||||
{
|
||||
return rr->CreateRenderable(prim,mi,p);
|
||||
}
|
||||
};//class RenderablePrimitiveCreater
|
||||
VK_NAMESPACE_END
|
||||
#endif // HGL_VK_RENDERABLE_PRIMITIVE_CREATER_INCLUDE
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class GPUSemaphore
|
||||
class Semaphore
|
||||
{
|
||||
VkDevice device;
|
||||
VkSemaphore sem;
|
||||
@@ -12,7 +12,7 @@ private:
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
GPUSemaphore(VkDevice d,VkSemaphore s)
|
||||
Semaphore(VkDevice d,VkSemaphore s)
|
||||
{
|
||||
device=d;
|
||||
sem=s;
|
||||
@@ -20,11 +20,11 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
~GPUSemaphore();
|
||||
~Semaphore();
|
||||
|
||||
operator VkSemaphore(){return sem;}
|
||||
|
||||
operator const VkSemaphore *()const{return &sem;}
|
||||
};//class GPUSemaphore
|
||||
};//class Semaphore
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SEMAPHORE_INCLUDE
|
||||
|
@@ -1,7 +1,8 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
|
||||
#include<hgl/graph/VKShaderResource.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKVertexInputLayout.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@@ -19,13 +20,9 @@ private:
|
||||
|
||||
VkPipelineShaderStageCreateInfo *stage_create_info;
|
||||
|
||||
protected:
|
||||
|
||||
ShaderResource *shader_resource;
|
||||
|
||||
public:
|
||||
|
||||
ShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *);
|
||||
ShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci);
|
||||
virtual ~ShaderModule();
|
||||
|
||||
const int IncRef(){return ++ref_count;}
|
||||
@@ -45,49 +42,8 @@ public:
|
||||
const bool IsMesh ()const{return stage_create_info->stage==VK_SHADER_STAGE_MESH_BIT_NV;}
|
||||
|
||||
const VkPipelineShaderStageCreateInfo * GetCreateInfo ()const{return stage_create_info;}
|
||||
|
||||
operator VkShaderModule ()const{return stage_create_info->module;}
|
||||
};//class ShaderModule
|
||||
|
||||
/**
|
||||
* 顶点Shader模块<br>
|
||||
* 由于顶点shader在最前方执行,所以它比其它shader多了VertexInput的数据
|
||||
*/
|
||||
class VertexShaderModule:public ShaderModule
|
||||
{
|
||||
uint32_t attr_count;
|
||||
VertexAttribType *type_list;
|
||||
const AnsiString **name_list;
|
||||
ShaderStage **ssi_list;
|
||||
|
||||
private:
|
||||
|
||||
SortedSets<VAB *> vab_sets;
|
||||
|
||||
public:
|
||||
|
||||
VertexShaderModule(VkDevice dev,VkPipelineShaderStageCreateInfo *pssci,ShaderResource *sr);
|
||||
virtual ~VertexShaderModule();
|
||||
|
||||
/**
|
||||
* 获取输入流绑定点,需要注意的时,这里获取的binding并非是shader中的binding/location,而是绑定顺序的序列号。对应vkCmdBindVertexBuffer的缓冲区序列号
|
||||
*/
|
||||
const int GetStageInputBinding(const AnsiString &name)const{return shader_resource->GetStageInputBinding(name);}
|
||||
const ShaderStage * GetStageInput (const AnsiString &name)const{return shader_resource->GetStageInput(name);}
|
||||
const uint GetStageInputCount () const{return shader_resource->GetStageInputCount();}
|
||||
const ShaderStageList & GetStageInputs () const{return shader_resource->GetStageInputs();}
|
||||
|
||||
//const uint32_t GetAttrCount()const{return attr_count;}
|
||||
|
||||
//const VkVertexInputBindingDescription * GetDescList ()const{return binding_list;}
|
||||
//const VkVertexInputAttributeDescription * GetAttrList ()const{return attribute_list;}
|
||||
|
||||
//const VkVertexInputBindingDescription * GetDesc (const uint32_t index)const{return (index>=attr_count?nullptr:binding_list+index);}
|
||||
//const VkVertexInputAttributeDescription * GetAttr (const uint32_t index)const{return (index>=attr_count?nullptr:attribute_list+index);}
|
||||
|
||||
public:
|
||||
|
||||
VAB * CreateVAB(const VABConfigInfo *format_map=nullptr);
|
||||
bool Release(VAB *);
|
||||
const uint32_t GetInstanceCount()const{return vab_sets.GetCount();}
|
||||
};//class VertexShaderModule:public ShaderModule
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
|
@@ -4,65 +4,39 @@
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/type/StringList.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKShaderStage.h>
|
||||
#include<hgl/graph/VKStruct.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
struct ShaderStage
|
||||
{
|
||||
AnsiString name;
|
||||
uint location;
|
||||
|
||||
VertexAttribType type; ///<成份数量(如vec4中的4)
|
||||
|
||||
bool global; ///<是否全局数据
|
||||
bool dynamic; ///<是否动态数量
|
||||
};//struct ShaderStage
|
||||
|
||||
using ShaderStageList =ObjectList<ShaderStage>;
|
||||
|
||||
class ShaderResource
|
||||
{
|
||||
VkShaderStageFlagBits stage_flag;
|
||||
|
||||
const void *spv_data;
|
||||
const uint32_t *spv_data;
|
||||
uint32 spv_size;
|
||||
|
||||
ShaderStageList stage_inputs;
|
||||
ShaderStageList stage_outputs;
|
||||
ShaderStageIO stage_io;
|
||||
|
||||
public:
|
||||
|
||||
ShaderResource(const VkShaderStageFlagBits &,const void *,const uint32);
|
||||
virtual ~ShaderResource()=default;
|
||||
ShaderResource(const VkShaderStageFlagBits &,const uint32_t *,const uint32);
|
||||
virtual ~ShaderResource();
|
||||
|
||||
const VkShaderStageFlagBits GetStage ()const {return stage_flag;}
|
||||
const os_char * GetStageName ()const;
|
||||
const VkShaderStageFlagBits GetStage ()const {return stage_flag;}
|
||||
const char * GetStageName ()const {return GetShaderStageName(stage_flag);}
|
||||
|
||||
const uint32_t * GetCode ()const {return (uint32_t *)spv_data;}
|
||||
const uint32_t GetCodeSize ()const {return spv_size;}
|
||||
const uint32_t * GetSPVData ()const {return spv_data;}
|
||||
const uint32_t GetSPVSize ()const {return spv_size;}
|
||||
|
||||
ShaderStageList & GetStageInputs () {return stage_inputs;}
|
||||
ShaderStageList & GetStageOutputs () {return stage_outputs;}
|
||||
ShaderAttributeArray & GetInputs () {return stage_io.input;}
|
||||
// ShaderAttributeArray & GetOutputs () {return stage_io.output;}
|
||||
|
||||
const uint GetStageInputCount ()const {return stage_inputs.GetCount();}
|
||||
const uint GetStageOutputCount ()const {return stage_outputs.GetCount();}
|
||||
const uint GetInputCount ()const {return stage_io.input.count;}
|
||||
// const uint GetOutputCount ()const {return stage_io.output.count;}
|
||||
|
||||
const ShaderStage * GetStageInput (const AnsiString &)const;
|
||||
const int GetStageInputBinding(const AnsiString &)const;
|
||||
const ShaderAttribute * GetInput (const AnsiString &)const;
|
||||
const int GetInputBinding (const AnsiString &)const;
|
||||
};//class ShaderResource
|
||||
|
||||
ShaderResource *LoadShaderResource(const uint8 *origin_filedata,const int64 filesize);
|
||||
|
||||
struct ShaderModuleCreateInfo:public vkstruct_flag<VkShaderModuleCreateInfo,VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO>
|
||||
{
|
||||
public:
|
||||
|
||||
ShaderModuleCreateInfo(ShaderResource *sr)
|
||||
{
|
||||
codeSize=sr->GetCodeSize();
|
||||
pCode =sr->GetCode();
|
||||
}
|
||||
};//struct ShaderModuleCreateInfo
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SHADER_RESOURCE_INCLUDE
|
||||
#endif//HGL_GRAPH_VULKAN_SHADER_RESOURCE_INCLUDE
|
||||
|
@@ -15,12 +15,12 @@ public:
|
||||
|
||||
VkSwapchainKHR swap_chain =VK_NULL_HANDLE;
|
||||
|
||||
uint32_t color_count=0;
|
||||
uint32_t color_count =0;
|
||||
|
||||
Texture2D ** sc_color =nullptr;
|
||||
Texture2D * sc_depth =nullptr;
|
||||
|
||||
Framebuffer ** render_frame =nullptr;
|
||||
Framebuffer ** sc_fbo =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKMemory.h>
|
||||
#include<hgl/graph/VKImageView.h>
|
||||
#include<hgl/graph/Bitmap.h>
|
||||
#include<hgl/graph/BitmapData.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VKTextureCreateInfo.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
VkImageLayout GetImageLayout () {return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
|
||||
VkImageView GetVulkanImageView () {return data?data->image_view->GetImageView():VK_NULL_HANDLE;}
|
||||
|
||||
GPUMemory * GetMemory () {return data?data->memory:nullptr;}
|
||||
DeviceMemory * GetMemory () {return data?data->memory:nullptr;}
|
||||
ImageView * GetImageView () {return data?data->image_view:nullptr;}
|
||||
|
||||
const uint32 GetMipLevel ()const {return data?data->miplevel:0;}
|
||||
|
@@ -20,13 +20,13 @@ struct TextureCreateInfo
|
||||
VkImageLayout image_layout;
|
||||
|
||||
VkImage image; //如果没有IMAGE,则创建。(交换链等会直接提供image,所以存在外部传入现像)
|
||||
GPUMemory * memory; //同时需分配内存并绑定
|
||||
DeviceMemory * memory; //同时需分配内存并绑定
|
||||
|
||||
ImageView * image_view; //如果没有imageview,则创建
|
||||
|
||||
void * pixels; //如果没有buffer但有pixels,则根据pixels和以上条件创建buffer
|
||||
VkDeviceSize total_bytes;
|
||||
GPUBuffer * buffer; //如果pixels也没有,则代表不会立即写入图像数据
|
||||
DeviceBuffer * buffer; //如果pixels也没有,则代表不会立即写入图像数据
|
||||
|
||||
public:
|
||||
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool SetData(GPUBuffer *buf,const VkExtent3D &ext)
|
||||
bool SetData(DeviceBuffer *buf,const VkExtent3D &ext)
|
||||
{
|
||||
if(!buf)return(false);
|
||||
if(ext.width<=0||ext.height<=0||ext.depth<=0)return(false);
|
||||
@@ -292,7 +292,7 @@ struct SwapchainDepthTextureCreateInfo:public TextureCreateInfo
|
||||
|
||||
struct TextureData
|
||||
{
|
||||
GPUMemory * memory;
|
||||
DeviceMemory * memory;
|
||||
VkImage image;
|
||||
VkImageLayout image_layout;
|
||||
ImageView * image_view;
|
||||
|
57
inc/hgl/graph/VKVBOList.h
Normal file
57
inc/hgl/graph/VKVBOList.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VBOList
|
||||
{
|
||||
uint32_t binding_count;
|
||||
VkBuffer *buffer_list;
|
||||
VkDeviceSize *buffer_offset;
|
||||
|
||||
uint32_t write_count;
|
||||
|
||||
friend class RenderCmdBuffer;
|
||||
|
||||
public:
|
||||
|
||||
VBOList(const uint32 bc)
|
||||
{
|
||||
binding_count=bc;
|
||||
buffer_list=new VkBuffer[binding_count];
|
||||
buffer_offset=new VkDeviceSize[binding_count];
|
||||
|
||||
write_count=0;
|
||||
}
|
||||
|
||||
~VBOList()
|
||||
{
|
||||
delete[] buffer_offset;
|
||||
delete[] buffer_list;
|
||||
}
|
||||
|
||||
void Restart()
|
||||
{
|
||||
write_count=0;
|
||||
}
|
||||
|
||||
const bool IsFull()const
|
||||
{
|
||||
return write_count>=binding_count;
|
||||
}
|
||||
|
||||
void Add(const VkBuffer buf,const VkDeviceSize offset)
|
||||
{
|
||||
buffer_list[write_count]=buf;
|
||||
buffer_offset[write_count]=offset;
|
||||
|
||||
++write_count;
|
||||
}
|
||||
|
||||
void Add(const VkBuffer *buf,const VkDeviceSize *offset,const uint32_t count)
|
||||
{
|
||||
hgl_cpy(buffer_list +write_count,buf, count);
|
||||
hgl_cpy(buffer_offset+write_count,offset,count);
|
||||
|
||||
write_count+=count;
|
||||
}
|
||||
};//class VBOList
|
||||
VK_NAMESPACE_END
|
@@ -7,7 +7,7 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
class VertexAttribBuffer:public GPUBuffer
|
||||
class VertexAttribBuffer:public DeviceBuffer
|
||||
{
|
||||
VkFormat format; ///<<3C><><EFBFBD>ݸ<EFBFBD>ʽ
|
||||
uint32_t stride; ///<<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
||||
@@ -17,7 +17,7 @@ namespace hgl
|
||||
|
||||
friend class GPUDevice;
|
||||
|
||||
VertexAttribBuffer(VkDevice d,const GPUBufferData &vb,VkFormat fmt,uint32_t _stride,uint32_t _count):GPUBuffer(d,vb)
|
||||
VertexAttribBuffer(VkDevice d,const DeviceBufferData &vb,VkFormat fmt,uint32_t _stride,uint32_t _count):DeviceBuffer(d,vb)
|
||||
{
|
||||
format=fmt;
|
||||
stride=_stride;
|
||||
@@ -31,7 +31,7 @@ namespace hgl
|
||||
const VkFormat GetFormat()const { return format; }
|
||||
const uint32_t GetStride()const { return stride; }
|
||||
const uint32_t GetCount ()const { return count; }
|
||||
};//class VertexAttribBuffer:public GPUBuffer
|
||||
};//class VertexAttribBuffer:public DeviceBuffer
|
||||
|
||||
using VBO=VertexAttribBuffer;
|
||||
}//namespace graph
|
||||
|
@@ -6,27 +6,6 @@ namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
/**
|
||||
* 预定义一些顶点属性名称,可用可不用。但一般默认shader会使用这些名称
|
||||
*/
|
||||
namespace VertexAttribName
|
||||
{
|
||||
#define VAN_DEFINE(name) constexpr char name[]=#name;
|
||||
VAN_DEFINE(Position)
|
||||
VAN_DEFINE(Normal)
|
||||
VAN_DEFINE(Color)
|
||||
VAN_DEFINE(Tangent)
|
||||
VAN_DEFINE(Bitangent)
|
||||
VAN_DEFINE(TexCoord)
|
||||
VAN_DEFINE(Metallic)
|
||||
VAN_DEFINE(Specular)
|
||||
VAN_DEFINE(Roughness)
|
||||
VAN_DEFINE(Emission)
|
||||
#undef VAN_DEFINE
|
||||
}//namespace VertexAttribName
|
||||
|
||||
#define VAN VertexAttribName
|
||||
|
||||
/**
|
||||
* 顶点属性数据
|
||||
*/
|
||||
@@ -36,18 +15,19 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
const uint32_t vec_size; ///<每个数据成员数(比如二维坐标为2、三维坐标为3)
|
||||
uint32_t count; ///<数据个数
|
||||
VkFormat format;
|
||||
|
||||
const uint32_t stride; ///<每组数据字节数
|
||||
const uint32_t total_bytes; ///<字节数
|
||||
|
||||
VkFormat vk_format; ///<在Vulkan中的数据类型
|
||||
uint32_t count; ///<数据个数
|
||||
uint32_t total_bytes; ///<字节数
|
||||
|
||||
public:
|
||||
|
||||
VertexAttribData(uint32_t c,uint32_t dc,uint32_t cs,VkFormat fmt):count(c),vec_size(dc),stride(cs),total_bytes(cs*c),vk_format(fmt)
|
||||
VertexAttribData(uint32_t c,const VkFormat vf,const uint32_t t)
|
||||
{
|
||||
count=c;
|
||||
format=vf;
|
||||
total_bytes=t;
|
||||
|
||||
mem_data = hgl_malloc(total_bytes); //在很多情况下,hgl_malloc分配的内存是对齐的,这样有效率上的提升
|
||||
}
|
||||
|
||||
@@ -57,10 +37,8 @@ namespace hgl
|
||||
hgl_free(mem_data);
|
||||
}
|
||||
|
||||
const VkFormat GetVulkanFormat ()const{return vk_format;} ///<取得数据类型
|
||||
const uint32_t GetVecSize ()const{return vec_size;} ///<取数缓冲区元数据成份数量
|
||||
const VkFormat GetFormat ()const{return format;} ///<取得数据类型
|
||||
const uint32_t GetCount ()const{return count;} ///<取得数据数量
|
||||
const uint32_t GetStride ()const{return stride;} ///<取得每一组数据字节数
|
||||
void * GetData ()const{return mem_data;} ///<取得数据指针
|
||||
const uint32_t GetTotalBytes ()const{return total_bytes;} ///<取得数据字节数
|
||||
};//class VertexAttribData
|
||||
@@ -70,11 +48,9 @@ namespace hgl
|
||||
/**
|
||||
* 根据格式要求,创建对应的顶点属性数据区(VAD)
|
||||
* @param vertex_count 顶点数量
|
||||
* @param fmt Vulkan格式
|
||||
* @param vec_size vec数量
|
||||
* @param stride 单个数据字节数
|
||||
* @param vif 格式
|
||||
*/
|
||||
VAD *CreateVertexAttribData(const uint32_t vertex_count,const VkFormat fmt,const int vec_size,const uint stride);
|
||||
VAD *CreateVertexAttribData(const uint32_t vertex_count,const VertexInputFormat *vif);
|
||||
//这个函数比较重要,就不搞成CreateVAD的简写了
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#ifndef HGL_GRAPH_VERTEX_ATTRIB_DATA_ACCESS_INCLUDE
|
||||
#define HGL_GRAPH_VERTEX_ATTRIB_DATA_ACCESS_INCLUDE
|
||||
|
||||
#include<hgl/type/Color3f.h>
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/color/Color3f.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
#include<hgl/type/RectScope.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VertexAttribData.h>
|
||||
@@ -60,7 +60,7 @@ namespace hgl
|
||||
{
|
||||
if(!data||offset>=count)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Get() out,offset:")+OSString::valueOf(offset));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Get() out,offset:")+OSString::numberOf(offset));
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace hgl
|
||||
{
|
||||
if(access)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Begin() access!=0,offset:")+OSString::valueOf(offset));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Begin() access!=0,offset:")+OSString::numberOf(offset));
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+C*number>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Write(const T *,number) out,number:")+OSString::valueOf(number));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess::Write(const T *,number) out,number:")+OSString::numberOf(number));
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace hgl
|
||||
{
|
||||
if(!vad)return(nullptr);
|
||||
|
||||
if(vad->GetVulkanFormat()!=VKFMT)
|
||||
if(vad->GetFormat()!=VKFMT)
|
||||
return(nullptr);
|
||||
|
||||
return(new VertexAttribDataAccess1<T,VKFMT>(vad->GetCount(),(T *)vad->GetData()));
|
||||
@@ -201,7 +201,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+count>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess1::Write(const T,")+OSString::valueOf(count)+OS_TEXT(") out"));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess1::Write(const T,")+OSString::numberOf(count)+OS_TEXT(") out"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace hgl
|
||||
{
|
||||
if(!vad)return(nullptr);
|
||||
|
||||
if(vad->GetVulkanFormat()!=VKFMT)
|
||||
if(vad->GetFormat()!=VKFMT)
|
||||
return(nullptr);
|
||||
|
||||
return(new VertexAttribDataAccess2<T,VKFMT>(vad->GetCount(),(T *)vad->GetData()));
|
||||
@@ -328,7 +328,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+(count<<1)>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess1::Write(const Vector2f &,")+OSString::valueOf(count)+OS_TEXT(") out"));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess1::Write(const Vector2f &,")+OSString::numberOf(count)+OS_TEXT(") out"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ namespace hgl
|
||||
{
|
||||
if(!vad)return(nullptr);
|
||||
|
||||
if(vad->GetVulkanFormat()!=VKFMT)
|
||||
if(vad->GetFormat()!=VKFMT)
|
||||
return(nullptr);
|
||||
|
||||
return(new VertexAttribDataAccess3<T,VKFMT>(vad->GetCount(),(T *)vad->GetData()));
|
||||
@@ -633,7 +633,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+(count*3)>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess3::Write(const Vector3f,")+OSString::valueOf(count)+OS_TEXT(") out"));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess3::Write(const Vector3f,")+OSString::numberOf(count)+OS_TEXT(") out"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -657,7 +657,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+(count*3)>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess3::Write(const Vector3f,")+OSString::valueOf(count)+OS_TEXT(") out"));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess3::Write(const Vector3f,")+OSString::numberOf(count)+OS_TEXT(") out"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -798,7 +798,7 @@ namespace hgl
|
||||
{
|
||||
if(!vad)return(nullptr);
|
||||
|
||||
if(vad->GetVulkanFormat()!=VKFMT)
|
||||
if(vad->GetFormat()!=VKFMT)
|
||||
return(nullptr);
|
||||
|
||||
return(new VertexAttribDataAccess4<T,VKFMT>(vad->GetCount(),(T *)vad->GetData()));
|
||||
@@ -948,7 +948,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+(count<<2)>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess4::Write(const Vector4f,")+OSString::valueOf(count)+OS_TEXT(") out"));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess4::Write(const Vector4f,")+OSString::numberOf(count)+OS_TEXT(") out"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -973,7 +973,7 @@ namespace hgl
|
||||
{
|
||||
if(!this->access||this->access+(count<<2)>this->data_end)
|
||||
{
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess4::Write(const Vector4f,")+OSString::valueOf(count)+OS_TEXT(") out"));
|
||||
LOG_HINT(OS_TEXT("VertexAttribDataAccess4::Write(const Vector4f,")+OSString::numberOf(count)+OS_TEXT(") out"));
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
@@ -14,9 +14,9 @@ namespace hgl
|
||||
*/
|
||||
class FontManage
|
||||
{
|
||||
MapObject<Font,FontSource> sources;
|
||||
ObjectMap<Font,FontSource> sources;
|
||||
|
||||
MapObject<FontConfig,TileFont> tilefonts;
|
||||
ObjectMap<FontConfig,TileFont> tilefonts;
|
||||
};//class FontManage
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@@ -73,7 +73,7 @@ namespace hgl
|
||||
|
||||
SortedSets<void *> ref_object;
|
||||
|
||||
MapObject<u32char,CLA> cla_cache;
|
||||
ObjectMap<u32char,CLA> cla_cache;
|
||||
|
||||
public:
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace hgl
|
||||
|
||||
Font fnt;
|
||||
|
||||
MapObject<u32char,FontBitmap> chars_bitmap; ///<字符位图
|
||||
ObjectMap<u32char,FontBitmap> chars_bitmap; ///<字符位图
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define HGL_GRAPH_TEXT_RENDER_INCLUDE
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Color4f.h>
|
||||
#include<hgl/color/Color4f.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
@@ -31,25 +31,25 @@ namespace hgl
|
||||
TextLayout * tl_engine;
|
||||
|
||||
Color4f color;
|
||||
GPUBuffer * ubo_color;
|
||||
DeviceBuffer * ubo_color;
|
||||
|
||||
SortedSets<TextPrimitive *> tr_sets;
|
||||
|
||||
private:
|
||||
|
||||
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,GPUBuffer *,int limit=-1);
|
||||
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit=-1);
|
||||
TextRender(GPUDevice *dev,FontSource *);
|
||||
|
||||
bool InitTileFont(int limit);
|
||||
bool InitTextLayoutEngine();
|
||||
bool InitUBO();
|
||||
bool InitMaterial(RenderPass *,GPUBuffer *);
|
||||
bool InitMaterial(RenderPass *,DeviceBuffer *);
|
||||
|
||||
public:
|
||||
|
||||
~TextRender();
|
||||
|
||||
bool Init(RenderPass *rp,GPUBuffer *ubo_camera_info,int limit);
|
||||
bool Init(RenderPass *rp,DeviceBuffer *ubo_camera_info,int limit);
|
||||
|
||||
public:
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace hgl
|
||||
* 创建一个文本渲染器
|
||||
* @param limit 节数限制(-1表示自动)
|
||||
*/
|
||||
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,GPUBuffer *,int limit);
|
||||
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit);
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_TEXT_RENDER_INCLUDE
|
||||
|
@@ -3,13 +3,15 @@
|
||||
|
||||
#include<hgl/graph/TileData.h>
|
||||
#include<hgl/graph/font/FontSource.h>
|
||||
#include<hgl/type/ResPool.h>
|
||||
#include<hgl/type/RefObjectPool.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
using TileResPool=ResPool<u32char,TileObject *>;
|
||||
using TileUVFloatMap=Map<u32char,RectScope2f>;
|
||||
|
||||
using TileResPool=RefObjectPool<u32char,TileObject *>;
|
||||
|
||||
/**
|
||||
* Tile字符管理<br>
|
||||
|
30
inc/hgl/graph/mtl/2d/Material2DCreateConfig.h
Normal file
30
inc/hgl/graph/mtl/2d/Material2DCreateConfig.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
||||
#define HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
||||
|
||||
#include<hgl/graph/mtl/MaterialConfig.h>
|
||||
#include<hgl/graph/CoordinateSystem.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
{
|
||||
CoordinateSystem2D coordinate_system; ///<使用的坐标系
|
||||
|
||||
bool local_to_world; ///<包含LocalToWorld矩阵
|
||||
|
||||
public:
|
||||
|
||||
Material2DCreateConfig(const GPUDeviceAttribute *da,const AnsiString &name):MaterialCreateConfig(da,name)
|
||||
{
|
||||
rt_output.color=1; //输出一个颜色
|
||||
rt_output.depth=false; //不输出深度
|
||||
rt_output.stencil=false; //不输出stencil
|
||||
|
||||
coordinate_system=CoordinateSystem2D::NDC;
|
||||
local_to_world=false;
|
||||
}
|
||||
};//struct Material2DCreateConfig:public MaterialCreateConfig
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreatePureColor2D(const Material2DCreateConfig *);
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_2D_CREATE_CONFIG_INCLUDE
|
37
inc/hgl/graph/mtl/MaterialConfig.h
Normal file
37
inc/hgl/graph/mtl/MaterialConfig.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef HGL_GRAPH_MTL_CONFIG_INCLUDE
|
||||
#define HGL_GRAPH_MTL_CONFIG_INCLUDE
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/RenderTargetOutputConfig.h>
|
||||
#include<hgl/graph/VK.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
class MaterialCreateInfo;
|
||||
|
||||
/**
|
||||
* 材质配置结构
|
||||
*/
|
||||
struct MaterialCreateConfig
|
||||
{
|
||||
const GPUDeviceAttribute *dev_attr;
|
||||
|
||||
AnsiString mtl_name; ///<材质名称
|
||||
|
||||
RenderTargetOutputConfig rt_output; ///<渲染目标输出配置
|
||||
|
||||
uint32 shader_stage_flag_bit; ///<需要的shader
|
||||
|
||||
public:
|
||||
|
||||
MaterialCreateConfig(const GPUDeviceAttribute *da,const AnsiString &name)
|
||||
{
|
||||
dev_attr=da;
|
||||
|
||||
mtl_name=name;
|
||||
|
||||
shader_stage_flag_bit=VK_SHADER_STAGE_VERTEX_BIT|VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
}
|
||||
};//struct MaterialCreateConfig
|
||||
STD_MTL_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_MTL_CONFIG_INCLUDE
|
46
inc/hgl/graph/mtl/MaterialVertexFormat.h
Normal file
46
inc/hgl/graph/mtl/MaterialVertexFormat.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef HGL_GRAPH_MATERIAL_VERTEX_FORMAT_INCLUDE
|
||||
#define HGL_GRAPH_MATERIAL_VERTEX_FORMAT_INCLUDE
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
/**
|
||||
* Local 2 World <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>
|
||||
*
|
||||
* 1.Push Constants <20><><EFBFBD><EFBFBD>
|
||||
*
|
||||
* 2.UBO <20>д<EFBFBD><D0B4><EFBFBD>matrix4f<34><66><EFBFBD>У<EFBFBD>vertex attrib<69>д<EFBFBD><D0B4><EFBFBD>ID
|
||||
* UBOͨ<4F><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ16k/64k<34><6B>һ<EFBFBD><D2BB>matrix4fΪ64<36>ֽڡ<D6BD>
|
||||
*
|
||||
* 3.Vertex Attribute
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* <20><><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD>ṹ
|
||||
*/
|
||||
union MaterialVertexFormat
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint position:3;
|
||||
bool normal:1;
|
||||
bool tangent:1;
|
||||
bool bitangent:1;
|
||||
uint color:4;
|
||||
uint texcoord:4;
|
||||
|
||||
bool local2world:1;
|
||||
bool skeleton:1;
|
||||
};
|
||||
|
||||
uint32 format;
|
||||
};//union MaterialVertexFormat
|
||||
|
||||
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_MATERIAL_VERTEX_FORMAT_INCLUDE
|
18
inc/hgl/graph/mtl/ShaderBuffer.h
Normal file
18
inc/hgl/graph/mtl/ShaderBuffer.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef HGL_GRAPH_MTL_SHADER_BUFFER_INCLUDE
|
||||
#define HGL_GRAPH_MTL_SHADER_BUFFER_INCLUDE
|
||||
|
||||
#include<hgl/type/DataType.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
struct ShaderBufferSource
|
||||
{
|
||||
const char *struct_name;
|
||||
const char *name;
|
||||
const char *codes;
|
||||
};
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_MTL_SHADER_BUFFER_INCLUDE
|
16
inc/hgl/graph/mtl/StdMaterial.h
Normal file
16
inc/hgl/graph/mtl/StdMaterial.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#define STD_MTL_NAMESPACE_BEGIN namespace hgl{namespace graph{namespace mtl{
|
||||
#define STD_MTL_NAMESPACE_END }}}
|
||||
|
||||
#define STD_MTL_NAMESPACE_USING using namespace hgl::graph::mtl;
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
namespace mtl
|
||||
{
|
||||
}//namespace mtl
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
77
inc/hgl/graph/mtl/UBOCommon.h
Normal file
77
inc/hgl/graph/mtl/UBOCommon.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/graph/mtl/ShaderBuffer.h>
|
||||
|
||||
STD_MTL_NAMESPACE_BEGIN
|
||||
constexpr const ShaderBufferSource SBS_ViewportInfo=
|
||||
{
|
||||
"ViewportInfo",
|
||||
"viewport",
|
||||
|
||||
R"(
|
||||
mat4 ortho_matrix;
|
||||
|
||||
vec2 canvas_resolution;
|
||||
vec2 viewport_resolution;
|
||||
vec2 inv_viewport_resolution;
|
||||
)"
|
||||
};
|
||||
|
||||
constexpr const ShaderBufferSource SBS_CameraInfo=
|
||||
{
|
||||
"CameraInfo",
|
||||
"camera",
|
||||
|
||||
R"(
|
||||
mat4 projection;
|
||||
mat4 inverse_projection;
|
||||
|
||||
mat4 view;
|
||||
mat4 inverse_view;
|
||||
|
||||
mat4 vp;
|
||||
mat4 inverse_vp;
|
||||
|
||||
mat4 sky;
|
||||
|
||||
vec3 pos; //eye
|
||||
vec3 view_line; //pos-target
|
||||
vec3 world_up;
|
||||
|
||||
float znear,zfar;)"
|
||||
};
|
||||
|
||||
// UBO必须严格指定数组的大小
|
||||
// SSBO则不需要,使用[]方式指定为动态大小数组
|
||||
|
||||
constexpr const ShaderBufferSource SBS_LocalToWorld=
|
||||
{
|
||||
"LocalToWorldData",
|
||||
"l2w",
|
||||
|
||||
R"(
|
||||
mat4 mats[L2W_MAX_COUNT];)"
|
||||
};
|
||||
|
||||
constexpr const char MaterialInstanceStruct[]="MaterialInstance";
|
||||
|
||||
constexpr const ShaderBufferSource SBS_MaterialInstance=
|
||||
{
|
||||
"MaterialInstanceData",
|
||||
"mtl",
|
||||
|
||||
R"(
|
||||
MaterialInstance mi[MI_MAX_COUNT];)"
|
||||
};
|
||||
|
||||
constexpr const ShaderBufferSource SBS_JointInfo=
|
||||
{
|
||||
"JointInfo",
|
||||
"joint",
|
||||
|
||||
R"(
|
||||
mat4 mats[];
|
||||
)"
|
||||
};
|
||||
STD_MTL_NAMESPACE_END
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user