Debug模式增加物理设备属性输出
This commit is contained in:
parent
4fdbe6a686
commit
4ead81b44c
@ -1,4 +1,4 @@
|
||||
// 4.Geometry3D
|
||||
// 4.Geometry3D
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
@ -42,6 +42,7 @@ private:
|
||||
vulkan::Buffer * ubo_mvp =nullptr;
|
||||
|
||||
vulkan::Pipeline * pipeline_line =nullptr;
|
||||
vulkan::Pipeline * pipeline_triangles =nullptr;
|
||||
vulkan::CommandBuffer ** cmd_buf =nullptr;
|
||||
|
||||
public:
|
||||
@ -57,19 +58,20 @@ private:
|
||||
|
||||
void InitCamera()
|
||||
{
|
||||
camera.type=CameraType::Perspective;
|
||||
camera.center.Set(0,0,0);
|
||||
camera.eye.Set(100,100,100);
|
||||
camera.up_vector.Set(0,0,1);
|
||||
camera.forward_vector.Set(0,1,0);
|
||||
camera.znear=4;
|
||||
camera.zfar=1000;
|
||||
camera.fov=45;
|
||||
camera.fov=90;
|
||||
camera.width=SCREEN_WIDTH;
|
||||
camera.height=SCREEN_HEIGHT;
|
||||
|
||||
camera.Refresh(); //更新矩阵计算
|
||||
camera.Refresh(); //更新矩阵计算
|
||||
|
||||
world.mvp=camera.projection*camera.modelview;
|
||||
world.mvp=camera.projection*camera.modelview*scale(50,50,50);
|
||||
}
|
||||
|
||||
bool InitMaterial()
|
||||
@ -101,6 +103,15 @@ private:
|
||||
|
||||
ro_plane_grid=CreatePlaneGrid(db,material,&pgci);
|
||||
}
|
||||
|
||||
{
|
||||
struct CubeCreateInfo cci;
|
||||
|
||||
cci.tile.x=0;
|
||||
cci.tile.y=1;
|
||||
|
||||
ro_cube=CreateCube(db,material,&cci);
|
||||
}
|
||||
}
|
||||
|
||||
bool InitUBO()
|
||||
@ -131,7 +142,19 @@ private:
|
||||
pipeline_creater->Set(PRIM_LINES);
|
||||
|
||||
pipeline_line=pipeline_creater->Create();
|
||||
if(!pipeline_line)
|
||||
return(false);
|
||||
|
||||
db->Add(pipeline_line);
|
||||
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
pipeline_triangles=pipeline_creater->Create();
|
||||
if(!pipeline_triangles)
|
||||
return(false);
|
||||
|
||||
db->Add(pipeline_triangles);
|
||||
|
||||
delete pipeline_creater;
|
||||
}
|
||||
|
||||
@ -140,10 +163,12 @@ private:
|
||||
|
||||
bool InitScene()
|
||||
{
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid));
|
||||
//render_root.Add(db->CreateRenderableInstance(pipeline,descriptor_sets,ro_round_rectangle));
|
||||
//render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_triangles,descriptor_sets,ro_cube));
|
||||
//render_root.Add(db->CreateRenderableInstance(pipeline,descriptor_sets,ro_circle));
|
||||
|
||||
Matrix4f s10=scale(10,10,10);
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
render_root.ExpendToList(&render_list);
|
||||
|
||||
|
@ -67,10 +67,6 @@ public:
|
||||
return(false);
|
||||
|
||||
shader_manage=device->CreateShaderModuleManage();
|
||||
|
||||
const vulkan::PhysicalDevice *render_device=device->GetPhysicalDevice();
|
||||
|
||||
std::cout<<"auto select physical device: "<<render_device->GetDeviceName()<<std::endl;
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,10 @@ public:
|
||||
VkPhysicalDeviceType GetDeviceType()const{return properties.deviceType;}
|
||||
const char * GetDeviceName()const{return properties.deviceName;}
|
||||
|
||||
const VkPhysicalDeviceFeatures & GetFeatures ()const{return features;}
|
||||
const VkPhysicalDeviceProperties & GetProperties ()const{return properties;}
|
||||
const VkPhysicalDeviceMemoryProperties &GetMemoryProperties ()const{return memory_properties;}
|
||||
|
||||
const uint32_t GetExtensionSpecVersion(const UTF8String &name)const;
|
||||
|
||||
const VkDriverIdKHR GetDriverId ()const{return driver_properties.driverID;}
|
||||
|
@ -72,8 +72,8 @@ namespace hgl
|
||||
* @param znear 近截面
|
||||
* @param zfar 远截面
|
||||
*/
|
||||
inline Matrix4f perspective(float aspect_ratio,
|
||||
float field_of_view,
|
||||
inline Matrix4f perspective(float field_of_view,
|
||||
float aspect_ratio,
|
||||
float znear,
|
||||
float zfar)
|
||||
{
|
||||
@ -91,8 +91,8 @@ namespace hgl
|
||||
* @param aspect_ratio 宽高比
|
||||
* @param field_of_view 视野
|
||||
*/
|
||||
inline Matrix4f perspective(float aspect_ratio,
|
||||
float field_of_view=45.0f)
|
||||
inline Matrix4f perspective(float field_of_view,
|
||||
float aspect_ratio)
|
||||
{
|
||||
const float f = 1.0f / tan( hgl_ang2rad( 0.5f * field_of_view ) );
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include<iostream>
|
||||
#include<iomanip>
|
||||
#endif//_DEBUG
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
@ -300,6 +301,156 @@ namespace
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void DebugOutVersion(uint32_t version)
|
||||
{
|
||||
std::cout<<VK_VERSION_MAJOR(version)<<"."<<VK_VERSION_MINOR(version)<<"."<<VK_VERSION_PATCH(version)<<std::endl;
|
||||
}
|
||||
|
||||
void DebugOut(const VkPhysicalDeviceLimits &limits)
|
||||
{
|
||||
#define OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(name) std::cout<<std::setw(60)<<std::right<<#name<<": "<<limits.name<<std::endl;
|
||||
#define OUT_PHYSICAL_DEVICE_LIMIT_VECTOR2(name) std::cout<<std::setw(60)<<std::right<<#name<<": "<<limits.name[0]<<", "<<limits.name[1]<<std::endl;
|
||||
#define OUT_PHYSICAL_DEVICE_LIMIT_VECTOR3(name) std::cout<<std::setw(60)<<std::right<<#name<<": "<<limits.name[0]<<", "<<limits.name[1]<<", "<<limits.name[2]<<std::endl;
|
||||
#define OUT_PHYSICAL_DEVICE_LIMIT_BOOLEAN(name) std::cout<<std::setw(60)<<std::right<<#name<<": "<<(limits.name?"true":"false")<<std::endl;
|
||||
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxImageDimension1D)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxImageDimension2D)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxImageDimension3D)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxImageDimensionCube)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxImageArrayLayers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTexelBufferElements)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxUniformBufferRange)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxStorageBufferRange)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPushConstantsSize)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxMemoryAllocationCount)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxSamplerAllocationCount)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(bufferImageGranularity)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(sparseAddressSpaceSize)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxBoundDescriptorSets)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageDescriptorSamplers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageDescriptorUniformBuffers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageDescriptorStorageBuffers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageDescriptorSampledImages)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageDescriptorStorageImages)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageDescriptorInputAttachments)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxPerStageResources)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetSamplers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetUniformBuffers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetUniformBuffersDynamic)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetStorageBuffers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetStorageBuffersDynamic)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetSampledImages)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetStorageImages)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDescriptorSetInputAttachments)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxVertexInputAttributes)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxVertexInputBindings)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxVertexInputAttributeOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxVertexInputBindingStride)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxVertexOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationGenerationLevel)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationPatchSize)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationControlPerVertexInputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationControlPerVertexOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationControlPerPatchOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationControlTotalOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationEvaluationInputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTessellationEvaluationOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxGeometryShaderInvocations)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxGeometryInputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxGeometryOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxGeometryOutputVertices)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxGeometryTotalOutputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFragmentInputComponents)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFragmentOutputAttachments)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFragmentDualSrcAttachments)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFragmentCombinedOutputResources)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxComputeSharedMemorySize)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_VECTOR3(maxComputeWorkGroupCount)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxComputeWorkGroupInvocations)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_VECTOR3(maxComputeWorkGroupSize)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(subPixelPrecisionBits)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(subTexelPrecisionBits)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(mipmapPrecisionBits)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDrawIndexedIndexValue)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxDrawIndirectCount)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxSamplerLodBias)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxSamplerAnisotropy)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxViewports)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_VECTOR2(maxViewportDimensions)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_VECTOR2(viewportBoundsRange)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(viewportSubPixelBits)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minMemoryMapAlignment)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minTexelBufferOffsetAlignment)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minUniformBufferOffsetAlignment)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minStorageBufferOffsetAlignment)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minTexelOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTexelOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minTexelGatherOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxTexelGatherOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(minInterpolationOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxInterpolationOffset)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(subPixelInterpolationOffsetBits)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFramebufferWidth)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFramebufferHeight)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxFramebufferLayers)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(framebufferColorSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(framebufferDepthSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(framebufferStencilSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(framebufferNoAttachmentsSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxColorAttachments)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(sampledImageColorSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(sampledImageIntegerSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(sampledImageDepthSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(sampledImageStencilSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(storageImageSampleCounts)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxSampleMaskWords)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_BOOLEAN(timestampComputeAndGraphics)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(timestampPeriod)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxClipDistances)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxCullDistances)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(maxCombinedClipAndCullDistances)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(discreteQueuePriorities)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_VECTOR2(pointSizeRange)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_VECTOR2(lineWidthRange)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(pointSizeGranularity)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(lineWidthGranularity)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_BOOLEAN(strictLines)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_BOOLEAN(standardSampleLocations)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(optimalBufferCopyOffsetAlignment)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(optimalBufferCopyRowPitchAlignment)
|
||||
OUT_PHYSICAL_DEVICE_LIMIT_INTEGER(nonCoherentAtomSize)
|
||||
|
||||
#undef OUT_PHYSICAL_DEVICE_LIMIT_BOOLEAN
|
||||
#undef OUT_PHYSICAL_DEVICE_LIMIT_VECTOR3
|
||||
#undef OUT_PHYSICAL_DEVICE_LIMIT_VECTOR2
|
||||
#undef OUT_PHYSICAL_DEVICE_LIMIT_INTEGER
|
||||
}
|
||||
|
||||
void DebugOut(const VkPhysicalDeviceProperties &pdp)
|
||||
{
|
||||
constexpr char DeviceTypeString[VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE][16]=
|
||||
{
|
||||
"Other",
|
||||
"Integrated GPU",
|
||||
"Discrete GPU",
|
||||
"Virtual GPU",
|
||||
"CPU"
|
||||
};
|
||||
|
||||
std::cout<<" apiVersion: ";DebugOutVersion(pdp.apiVersion);
|
||||
std::cout<<" driverVersion: ";DebugOutVersion(pdp.driverVersion);
|
||||
std::cout<<" vendorID: "<<pdp.vendorID<<std::endl;
|
||||
std::cout<<" deviceID: "<<pdp.deviceID<<std::endl;
|
||||
std::cout<<" deviceType: "<<DeviceTypeString[pdp.deviceType]<<std::endl;
|
||||
std::cout<<" deviceName: "<<pdp.deviceName<<std::endl;
|
||||
|
||||
UTF8String uuid=HexToString<char>(pdp.pipelineCacheUUID);
|
||||
|
||||
std::cout<<"pipelineCahceUUID: "<<uuid.c_str()<<std::endl;
|
||||
|
||||
DebugOut(pdp.limits);
|
||||
}
|
||||
}//namespace
|
||||
|
||||
Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device,VkSurfaceKHR surface,uint width,uint height)
|
||||
@ -319,6 +470,8 @@ Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device
|
||||
{
|
||||
std::cout<<"Unknow VideoCard Driver"<<std::endl;
|
||||
}
|
||||
|
||||
DebugOut(physical_device->GetProperties());
|
||||
}
|
||||
#endif//_DEBUG
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace hgl
|
||||
void Camera::Refresh()
|
||||
{
|
||||
if(type==CameraType::Perspective)
|
||||
projection=perspective(width/height,fov,znear,zfar);
|
||||
projection=perspective(fov,width/height,znear,zfar);
|
||||
else
|
||||
projection=ortho(width,height,znear,zfar);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user