From 4cf5b0dce34813db43d591d9331b13a52a8e5925 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 12 Jun 2020 15:51:56 +0800 Subject: [PATCH] =?UTF-8?q?PushConstant=E6=9A=82=E6=97=B6=E5=8F=AA?= =?UTF-8?q?=E4=BF=9D=E7=95=99local=5Fto=5Fworld?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/vulkan/VK.h | 3 --- inc/hgl/graph/vulkan/VKCommandBuffer.h | 2 +- src/SceneGraph/RenderList.cpp | 2 +- src/SceneGraph/SceneOrient.cpp | 3 --- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/inc/hgl/graph/vulkan/VK.h b/inc/hgl/graph/vulkan/VK.h index 9c27723f..6f463ff3 100644 --- a/inc/hgl/graph/vulkan/VK.h +++ b/inc/hgl/graph/vulkan/VK.h @@ -75,9 +75,6 @@ enum class ShaderStageBit struct PushConstant { Matrix4f local_to_world; - Matrix3f normal; - Vector3f object_position; - Vector3f object_size; }; constexpr uint32_t MAX_PUSH_CONSTANT_BYTES=sizeof(PushConstant); diff --git a/inc/hgl/graph/vulkan/VKCommandBuffer.h b/inc/hgl/graph/vulkan/VKCommandBuffer.h index 85f1679d..9e04ee99 100644 --- a/inc/hgl/graph/vulkan/VKCommandBuffer.h +++ b/inc/hgl/graph/vulkan/VKCommandBuffer.h @@ -120,7 +120,7 @@ public: vkCmdPushConstants(cmd_buf,pipeline_layout,(VkShaderStageFlagBits)shader_stage_bit,offset,size,pValues); } - void PushConstants(const PushConstant *pc){vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0,sizeof(PushConstant),pc);} + void PushConstants(const void *data,const uint32_t size){vkCmdPushConstants(cmd_buf,pipeline_layout,VK_SHADER_STAGE_VERTEX_BIT,0,size,data);} bool Bind(Renderable *); diff --git a/src/SceneGraph/RenderList.cpp b/src/SceneGraph/RenderList.cpp index b6c3079c..de6d42c5 100644 --- a/src/SceneGraph/RenderList.cpp +++ b/src/SceneGraph/RenderList.cpp @@ -49,7 +49,7 @@ namespace hgl { last_pc=node->GetPushConstant(); - cmd_buf->PushConstants(last_pc); + cmd_buf->PushConstants(last_pc,sizeof(vulkan::PushConstant)); } //更新fin_mvp diff --git a/src/SceneGraph/SceneOrient.cpp b/src/SceneGraph/SceneOrient.cpp index cfbe59ff..80ea9230 100644 --- a/src/SceneGraph/SceneOrient.cpp +++ b/src/SceneGraph/SceneOrient.cpp @@ -12,8 +12,6 @@ namespace hgl LocalToWorldMatrix =Matrix4f::identity; InverseLocalMatrix =Matrix4f::identity; InverseLocalToWorldMatrix =Matrix4f::identity; - - pc.normal =Matrix3f::identity; } Matrix4f &SceneOrient::SetLocalMatrix(const Matrix4f &m) @@ -32,7 +30,6 @@ namespace hgl InverseLocalToWorldMatrix=inverse(LocalToWorldMatrix); pc.local_to_world =LocalToWorldMatrix; - pc.normal =pc.local_to_world.Float3x3Part(); // pc.object_position =; // pc.object_size =;