diff --git a/example/Vulkan/VulkanAppFramework.h b/example/Vulkan/VulkanAppFramework.h index 486fb987..4677b62c 100644 --- a/example/Vulkan/VulkanAppFramework.h +++ b/example/Vulkan/VulkanAppFramework.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff --git a/example/Vulkan/first_triangle.cpp b/example/Vulkan/first_triangle.cpp index b3005f73..076ba59d 100644 --- a/example/Vulkan/first_triangle.cpp +++ b/example/Vulkan/first_triangle.cpp @@ -62,8 +62,8 @@ private: bool InitMaterial() { - material=shader_manage->CreateMaterial(OS_TEXT("res/shader/FlatColor.vert.spv"), - OS_TEXT("res/shader/VertexColor.frag.spv")); + material=shader_manage->CreateMaterial(OS_TEXT("res/shader/FlatColor.vert"), + OS_TEXT("res/shader/VertexColor.frag")); if(!material) return(false); @@ -91,13 +91,15 @@ private: return(true); } - void InitVBO() + bool InitVBO() { vertex_buffer =device->CreateVBO(FMT_RG32F, VERTEX_COUNT,vertex_data); color_buffer =device->CreateVBO(FMT_RGB32F, VERTEX_COUNT,color_data); - render_obj->Set("Vertex", vertex_buffer); - render_obj->Set("Color", color_buffer); + if(!render_obj->Set("Vertex", vertex_buffer))return(false); + if(!render_obj->Set("Color", color_buffer))return(false); + + return(true); } bool InitPipeline() @@ -138,7 +140,8 @@ public: if(!InitUBO()) return(false); - InitVBO(); + if(!InitVBO()) + return(false); if(!InitPipeline()) return(false); diff --git a/res b/res index ee094e2e..c8c306e5 160000 --- a/res +++ b/res @@ -1 +1 @@ -Subproject commit ee094e2efb1616014d18388eae4440fd740d07d1 +Subproject commit c8c306e5a7cd3e975af4eb718f20ea16653ca4d3 diff --git a/src/RenderDevice/Vulkan/VKShaderModule.cpp b/src/RenderDevice/Vulkan/VKShaderModule.cpp index a70219f1..6c51d3e2 100644 --- a/src/RenderDevice/Vulkan/VKShaderModule.cpp +++ b/src/RenderDevice/Vulkan/VKShaderModule.cpp @@ -30,12 +30,11 @@ VertexShaderModule::VertexShaderModule(VkDevice dev,int id,VkPipelineShaderStage VkVertexInputBindingDescription *bind=binding_list; VkVertexInputAttributeDescription *attr=attribute_list; - uint32_t binding_index=0; ShaderStage **si=stage_inputs.GetData(); for(uint i=0;ibinding =binding_index; //binding对应在vkCmdBindVertexBuffer中设置的缓冲区的序列号,所以这个数字必须从0开始,而且紧密排列。 + bind->binding =i; //binding对应在vkCmdBindVertexBuffer中设置的缓冲区的序列号,所以这个数字必须从0开始,而且紧密排列。 //在VertexInput类中,buf_list需要严格按照本此binding为序列号排列 bind->stride =GetStrideByFormat((*si)->format); bind->inputRate =VK_VERTEX_INPUT_RATE_VERTEX; @@ -45,14 +44,13 @@ VertexShaderModule::VertexShaderModule(VkDevice dev,int id,VkPipelineShaderStage //比如在一个流中传递{pos,color}这样两个数据,就需要两个attrib //但在我们的设计中,仅支持一个流传递一个attrib - attr->binding =binding_index; + attr->binding =i; attr->location =(*si)->location; //此值对应shader中的layout(location= attr->format =(*si)->format; attr->offset =0; ++attr; ++bind; - ++binding_index; ++si; } diff --git a/src/SceneGraph/shader/ShaderResource.cpp b/src/SceneGraph/shader/ShaderResource.cpp index 8e7a8a10..cc272c99 100644 --- a/src/SceneGraph/shader/ShaderResource.cpp +++ b/src/SceneGraph/shader/ShaderResource.cpp @@ -94,7 +94,7 @@ VK_NAMESPACE_BEGIN for(int i=0;iname) - return (*ss)->location; + return i; ++ss; } @@ -122,7 +122,7 @@ VK_NAMESPACE_BEGIN ShaderResource *LoadShaderResoruce(const OSString &filename) { int64 filesize; - uint8 *origin_filedata=(uint8 *)filesystem::LoadFileToMemory(filename,filesize); + uint8 *origin_filedata=(uint8 *)filesystem::LoadFileToMemory(filename+OS_TEXT(".shader"),filesize); if(!origin_filedata)return(nullptr); @@ -159,10 +159,6 @@ VK_NAMESPACE_BEGIN desc_type=AccessByPointer(filedata,uint32); filedata=LoadShaderDescriptor(sr->GetDescriptorList((VkDescriptorType)desc_type),filedata); - { - delete sr; - return(nullptr); - } } return sr;