reduced codes of rf_test.cpp

This commit is contained in:
hyzboy 2025-01-25 15:25:29 +08:00
parent 82a3ec4922
commit aafdbdd4ea
4 changed files with 36 additions and 48 deletions

View File

@ -21,31 +21,10 @@ constexpr float position_data_float[VERTEX_COUNT*2]=
0.5, 0.5 0.5, 0.5
}; };
#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; constexpr VkFormat PositionFormat=VF_V2F;
#define position_data position_data_float #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]= constexpr float color_data[VERTEX_COUNT*4]=
{ 1,0,0,1, { 1,0,0,1,
0,1,0,1, 0,1,0,1,
@ -53,16 +32,11 @@ constexpr float color_data[VERTEX_COUNT*4]=
}; };
constexpr VkFormat ColorFormat=VF_V4F; constexpr VkFormat ColorFormat=VF_V4F;
#endif//USE_UNORM8_COLOR
class TestApp:public WorkObject class TestApp:public WorkObject
{ {
private: private:
#if defined(USE_HALF_FLOAT_POSITION)||defined(USE_UNORM8_COLOR)
VILConfig vil_config;
#endif
MaterialInstance * material_instance =nullptr; MaterialInstance * material_instance =nullptr;
Renderable * render_obj =nullptr; Renderable * render_obj =nullptr;
@ -70,17 +44,6 @@ private:
private: private:
void InitVIL()
{
#ifdef USE_HALF_FLOAT_POSITION
vil_config.Add(VAN::Position,PositionFormat);
#endif//USE_HALF_FLOAT_POSITION
#ifdef USE_UNORM8_COLOR
vil_config.Add(VAN::Color,ColorFormat);
#endif//USE_HALF_FLOAT_POSITION
}
bool InitAutoMaterial() bool InitAutoMaterial()
{ {
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2d",Prim::Triangles); mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2d",Prim::Triangles);
@ -109,10 +72,6 @@ private:
rpc.Init("Triangle",VERTEX_COUNT); rpc.Init("Triangle",VERTEX_COUNT);
#ifdef USE_HALF_FLOAT_POSITION
Float32toFloat16(position_data_hf,position_data_float,VERTEX_COUNT*2);
#endif//USE_HALF_FLOAT_POSITION
if(!rpc.WriteVAB(VAN::Position, PositionFormat, position_data))return(false); if(!rpc.WriteVAB(VAN::Position, PositionFormat, position_data))return(false);
if(!rpc.WriteVAB(VAN::Color, ColorFormat, color_data ))return(false); if(!rpc.WriteVAB(VAN::Color, ColorFormat, color_data ))return(false);
@ -127,8 +86,6 @@ public:
if(!VulkanApplicationFramework::Init(w,h)) if(!VulkanApplicationFramework::Init(w,h))
return(false); return(false);
InitVIL();
if(!InitAutoMaterial()) if(!InitAutoMaterial())
return(false); return(false);
@ -150,6 +107,12 @@ public:
BuildCommandBuffer(render_obj); BuildCommandBuffer(render_obj);
} }
void Tick(double)override
{}
void Render(double)
{}
};//class TestApp:public VulkanApplicationFramework };//class TestApp:public VulkanApplicationFramework
int main(int,char **) int main(int,char **)
@ -159,7 +122,7 @@ int main(int,char **)
if(rf.Init(SCREEN_WIDTH,SCREEN_HEIGHT)) if(rf.Init(SCREEN_WIDTH,SCREEN_HEIGHT))
return(-1); return(-1);
WorkManager wm; WorkManager wm(&rf);
wm.Start(new TestApp()); wm.Start(new TestApp);
} }

View File

@ -8,6 +8,31 @@
#include<hgl/graph/VKQueue.h> #include<hgl/graph/VKQueue.h>
#include<hgl/graph/VKPipeline.h> #include<hgl/graph/VKPipeline.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
/**
* RenderTarget
*
* 1.
*
* 2.Swapchain
*
*
*
* 1.
*
* 2.PBR GBuffer
*
* RenderTarget的其实是一个多态类
*/
class IRenderTarget
{
public:
IRenderTarget(DeviceQueue *,Semaphore *);
};//class IRenderTarget
/** /**
* *
*/ */
@ -27,6 +52,7 @@ protected:
protected: protected:
uint32_t color_count; uint32_t color_count;
Texture2D **color_textures; Texture2D **color_textures;
Texture2D *depth_texture; Texture2D *depth_texture;

View File

@ -13,9 +13,8 @@ struct SwapchainImage
Texture2D * depth =nullptr; Texture2D * depth =nullptr;
Framebuffer * fbo =nullptr; Framebuffer * fbo =nullptr;
RenderCmdBuffer * cmd_buf =nullptr; RenderCmdBuffer * cmd_buf =nullptr;
public: public:

2
res

@ -1 +1 @@
Subproject commit e1a36d78f0eead5f6bb65493432c4690637b991d Subproject commit 475d8ad43ceee084cd24f5d0bed59de9f6aa36fd