reduced codes of rf_test.cpp
This commit is contained in:
parent
82a3ec4922
commit
aafdbdd4ea
@ -21,31 +21,10 @@ constexpr float position_data_float[VERTEX_COUNT*2]=
|
||||
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;
|
||||
|
||||
#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,
|
||||
@ -53,16 +32,11 @@ constexpr float color_data[VERTEX_COUNT*4]=
|
||||
};
|
||||
|
||||
constexpr VkFormat ColorFormat=VF_V4F;
|
||||
#endif//USE_UNORM8_COLOR
|
||||
|
||||
class TestApp:public WorkObject
|
||||
{
|
||||
private:
|
||||
|
||||
#if defined(USE_HALF_FLOAT_POSITION)||defined(USE_UNORM8_COLOR)
|
||||
VILConfig vil_config;
|
||||
#endif
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
@ -70,17 +44,6 @@ 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()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2d",Prim::Triangles);
|
||||
@ -109,10 +72,6 @@ private:
|
||||
|
||||
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::Color, ColorFormat, color_data ))return(false);
|
||||
|
||||
@ -127,8 +86,6 @@ public:
|
||||
if(!VulkanApplicationFramework::Init(w,h))
|
||||
return(false);
|
||||
|
||||
InitVIL();
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return(false);
|
||||
|
||||
@ -150,6 +107,12 @@ public:
|
||||
|
||||
BuildCommandBuffer(render_obj);
|
||||
}
|
||||
|
||||
void Tick(double)override
|
||||
{}
|
||||
|
||||
void Render(double)
|
||||
{}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
@ -159,7 +122,7 @@ int main(int,char **)
|
||||
if(rf.Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(-1);
|
||||
|
||||
WorkManager wm;
|
||||
WorkManager wm(&rf);
|
||||
|
||||
wm.Start(new TestApp());
|
||||
wm.Start(new TestApp);
|
||||
}
|
||||
|
@ -8,6 +8,31 @@
|
||||
#include<hgl/graph/VKQueue.h>
|
||||
#include<hgl/graph/VKPipeline.h>
|
||||
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:
|
||||
|
||||
uint32_t color_count;
|
||||
|
||||
Texture2D **color_textures;
|
||||
Texture2D *depth_texture;
|
||||
|
||||
|
@ -14,7 +14,6 @@ struct SwapchainImage
|
||||
|
||||
Framebuffer * fbo =nullptr;
|
||||
|
||||
|
||||
RenderCmdBuffer * cmd_buf =nullptr;
|
||||
|
||||
public:
|
||||
|
2
res
2
res
@ -1 +1 @@
|
||||
Subproject commit e1a36d78f0eead5f6bb65493432c4690637b991d
|
||||
Subproject commit 475d8ad43ceee084cd24f5d0bed59de9f6aa36fd
|
Loading…
x
Reference in New Issue
Block a user