diff --git a/inc/hgl/graph/TileData.h b/inc/hgl/graph/TileData.h index dd81b042..b28f4d45 100644 --- a/inc/hgl/graph/TileData.h +++ b/inc/hgl/graph/TileData.h @@ -1,103 +1,68 @@ -#ifndef HGL_GRAPH_TILE_DATA_INCLUDE +#ifndef HGL_GRAPH_TILE_DATA_INCLUDE #define HGL_GRAPH_TILE_DATA_INCLUDE -#include +#include + +VK_NAMESPACE_USING + namespace hgl { namespace graph { - class Texture2D; - class Renderable; - class Bitmap2D; - /** - * TileData是一种处理将大量等同贴图的管理机制,程序会自动根据显卡最大贴图处理能力来创建尽可能符合的贴图。(注意:Tile的宽高不必是2的幂)。
- * Tile的增加删除,程序会做自动排序,尽可能小的影响效能。 - */ - class TileData ///Tile数据管理 + * TileData是一种处理大量等同尺寸及格式贴图的管理机制,程序会自动根据显卡最大贴图处理能力来创建尽可能符合需求的贴图。(注:Tile的大小不必符合2次幂) + * Tile的增加或删除,程序会自动排序,尽可能小的减少I/O消耗。 + */ + class TileData ///Tile纹理管理 { public: - struct Object ///Tile对象 + struct Object { int index; - double fl,ft; - double fw,fh; + double fl,ft,fw,fh; int width,height; - }; + };//struct TileObject protected: - Texture2D *tile_texture; /// class VertexBuffer2; - - /** - * 渲染Tile为一个2D矩形数据到顶点缓冲区上 - * @param obj 要渲制的Tile对象 - * @param vertex 渲染到的2d顶点坐标缓冲区 - * @param tex_coord 渲染到的贴图坐标缓冲区 - * @param left 显示的左边界 - * @param top 显示的上边界 - * @param scale_width 宽度缩放比 - * @param scale_height 高度缩放比 - */ - template - __inline void RenderToVB2DRect( VertexBuffer2 *vertex, - VertexBuffer2 *tex_coord, - const TileData::Object *obj, - const float left, - const float top, - const float scale_width=1.0f, - const float scale_height=1.0f) - { - if(!obj||!vertex||!tex_coord)return; - - tex_coord->WriteRect( obj->fl, - obj->ft, - obj->fw, - obj->fh); - - vertex->WriteRect( left, - top, - scale_width*float(obj->width), - scale_height*float(obj->height)); - } }//namespace graph }//namespace hgl #endif//HGL_GRAPH_TILE_DATA_INCLUDE diff --git a/inc/hgl/graph/vulkan/VKPhysicalDevice.h b/inc/hgl/graph/vulkan/VKPhysicalDevice.h index c9aae804..134967b7 100644 --- a/inc/hgl/graph/vulkan/VKPhysicalDevice.h +++ b/inc/hgl/graph/vulkan/VKPhysicalDevice.h @@ -87,5 +87,22 @@ public: VkFormat GetDepthFormat(bool lower_to_high=true)const; VkFormat GetDepthStencilFormat(bool lower_to_high=true)const; + + 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 GetMaxVertexInputAttributes ()const{return properties.limits.maxVertexInputAttributes;} + const uint32_t GetMaxVertexInputBindings ()const{return properties.limits.maxVertexInputBindings;} + + const uint32_t GetMaxColorAttachments ()const{return properties.limits.maxColorAttachments;} + + const void GetPointSize(float &,float &) + };//class PhysicalDevice VK_NAMESPACE_END diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index b864ee9e..d217f637 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -24,6 +24,7 @@ SET(SCENE_GRAPH_HEADER ${ROOT_INCLUDE_PATH}/hgl/graph/Light.h ${ROOT_INCLUDE_PATH}/hgl/graph/RenderableInstance.h ${ROOT_INCLUDE_PATH}/hgl/graph/RenderList.h ${ROOT_INCLUDE_PATH}/hgl/graph/InlineGeometry.h + ${ROOT_INCLUDE_PATH}/hgl/graph/TileData.h #${ROOT_INCLUDE_PATH}/hgl/graph/Mesh.h #${ROOT_INCLUDE_PATH}/hgl/graph/Material.h #${ROOT_INCLUDE_PATH}/hgl/graph/Spline.h @@ -34,6 +35,7 @@ SET(SCENE_GRAPH_SOURCE RenderList.cpp SceneNode.cpp SceneOrient.cpp InlineGeometry.cpp + TileData.cpp #InlinePipeline.cpp #Material.cpp #Mesh.cpp diff --git a/src/SceneGraph/TileData.cpp b/src/SceneGraph/TileData.cpp new file mode 100644 index 00000000..4525c93b --- /dev/null +++ b/src/SceneGraph/TileData.cpp @@ -0,0 +1,63 @@ +#include + +namespace hgl +{ + namespace graph + { + namespace + { + void AnalyseSize(int &fw,int &fh,const int w,const int h,const int count,const int max_texture_size) + { + int total,tw,th,t; + + fw=fh=0; + + tw=max_texture_size; + while(tw>=w) + { + th=max_texture_size; + while(th>=h) + { + t=(tw/w)*(th/h); + + if(!fw) + { + fw=tw; + fh=th; + + total=t; + } + else + { + if(t==count) + { + //正好,就要这么大的 + + fw=tw; + fh=th; + + return; + } + else + if(t>count) //要比要求的最大值大 + { + if(t>=1; + } + + tw>>=1; + } + }//void AnalyseSize + }//namespace + }//namespace graph +}//namespace hgl