save code
This commit is contained in:
+38
-40
@@ -660,6 +660,21 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
||||
|
||||
vkCmdPushConstants(commandBuffer, m_pipelineLayout_bg, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(float), &myFloatValue);
|
||||
|
||||
|
||||
float fsValues[2] = { 0, 0 };
|
||||
if (_curMotionIndex < _curMotions.size())
|
||||
{
|
||||
if (_curFrameIndex < _curMotions[_curMotionIndex].frames.size())
|
||||
{
|
||||
float ux = _curMotions[_curMotionIndex].frames[_curFrameIndex].x;
|
||||
float uy = _curMotions[_curMotionIndex].frames[_curFrameIndex].y;
|
||||
fsValues[0] = ux;
|
||||
fsValues[1] = uy;
|
||||
}
|
||||
}
|
||||
|
||||
vkCmdPushConstants(commandBuffer, m_pipelineLayout_bg, VK_SHADER_STAGE_FRAGMENT_BIT, 4, sizeof(fsValues), fsValues);
|
||||
|
||||
vkCmdDraw(commandBuffer, 6, 1, 0, 0);
|
||||
|
||||
|
||||
@@ -1081,13 +1096,17 @@ void FaceApp::setup_descriptor_set_layout_bg()
|
||||
pipeline_layout_create_info.pSetLayouts = &m_descriptorSetLayout_bg;
|
||||
|
||||
|
||||
VkPushConstantRange pushConstantRange{};
|
||||
pushConstantRange.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; // 只在片段着色器中使用
|
||||
pushConstantRange.offset = 0;
|
||||
pushConstantRange.size = sizeof(float); // 或者 sizeof(PushConstants)
|
||||
VkPushConstantRange pushConstantRanges[2];
|
||||
pushConstantRanges[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; // 只在片段着色器中使用
|
||||
pushConstantRanges[0].offset = 0;
|
||||
pushConstantRanges[0].size = sizeof(float); // 或者 sizeof(PushConstants)
|
||||
|
||||
pipeline_layout_create_info.pushConstantRangeCount = 1;
|
||||
pipeline_layout_create_info.pPushConstantRanges = &pushConstantRange;
|
||||
pushConstantRanges[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; // 只在片段着色器中使用
|
||||
pushConstantRanges[1].offset = sizeof(float);
|
||||
pushConstantRanges[1].size = 2 * sizeof(float); // 或者 sizeof(PushConstants)
|
||||
|
||||
pipeline_layout_create_info.pushConstantRangeCount = 2;
|
||||
pipeline_layout_create_info.pPushConstantRanges = &pushConstantRanges[0];
|
||||
|
||||
VK_CHECK(vkCreatePipelineLayout(device, &pipeline_layout_create_info, nullptr, &m_pipelineLayout_bg));
|
||||
}
|
||||
@@ -1410,13 +1429,8 @@ void FaceApp::loadMotionThread()
|
||||
_callback_loadfinish();
|
||||
}
|
||||
|
||||
void FaceApp::changeMotionList(AnimationFinishedCallback callback, bool loop)
|
||||
void FaceApp::doChangeMotion()
|
||||
{
|
||||
if (_isLoadMotion)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock_changeMotion(changeMotionMtx);
|
||||
|
||||
|
||||
@@ -1433,36 +1447,20 @@ void FaceApp::changeMotionList(AnimationFinishedCallback callback, bool loop)
|
||||
|
||||
update_descriptor_set(m_texs);
|
||||
_curMotions = _preLoadMotions;
|
||||
_animationFinishedCallback = callback;
|
||||
_animationLoop = loop;
|
||||
|
||||
_curFrameIndex = 0;
|
||||
_curMotionIndex = 0;
|
||||
}
|
||||
|
||||
void FaceApp::changeMotionList(AnimationFinishedCallback callback, bool loop)
|
||||
{
|
||||
if (_isLoadMotion)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_animationFinishedCallback = callback;
|
||||
_animationLoop = loop;
|
||||
_needChangeMotion = true;
|
||||
|
||||
// for (int i = 0; i < _curMotion.png_names.size(); ++i)
|
||||
// {
|
||||
//
|
||||
//#ifdef _WIN32
|
||||
// //string path = _curMotion.type + "/" + _curMotion.technique + "/" + _curMotion.step + "/" + _curMotion.show_type;
|
||||
// string path = "pic";
|
||||
// string path_name = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i];// +std::to_string(i) + ".png";
|
||||
// loadTextureExample(UTF8ToWideString(path_name), m_texs[i], true);
|
||||
// if (kThick)
|
||||
// {
|
||||
// string path_name_ex = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i] + std::to_string(i) + "_thick.png";
|
||||
// loadTextureExample(UTF8ToWideString(path_name_ex), m_texs_ex[i], true);
|
||||
// }
|
||||
//#else
|
||||
// //string path = _curMotion.type + "/" + _curMotion.technique + "/" + _curMotion.step + "/" + _curMotion.show_type;
|
||||
// string path = "pic";
|
||||
// string path_name = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i];// +std::to_string(i) + ".png";
|
||||
// loadTexture(path_name, m_texs[i], true);
|
||||
// if (kThick)
|
||||
// {
|
||||
// loadTexture(path_name, m_texs_ex[i], true);
|
||||
// }
|
||||
//#endif // _WIN32
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user