{"id":380475,"date":"2021-03-08T21:47:56","date_gmt":"2021-03-08T13:47:56","guid":{"rendered":"http:\/\/4563.org\/?p=380475"},"modified":"2021-03-08T21:47:56","modified_gmt":"2021-03-08T13:47:56","slug":"%e7%94%a8-vulkan-%e6%b8%b2%e6%9f%93%e5%86%99%e4%b8%80%e4%b8%aa-android-gpuimage","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=380475","title":{"rendered":"\u7528 Vulkan \u6e32\u67d3\u5199\u4e00\u4e2a Android GPUImage"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u7528 Vulkan \u6e32\u67d3\u5199\u4e00\u4e2a Android GPUImage               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : glumess <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u8bf4\u7684 GPUImage \u76f8\u4fe1\u5927\u5bb6\u90fd\u4e0d\u964c\u751f\uff0cGPUImage \u662f\u505a\u6ee4\u955c\u3001\u6e32\u67d3\u3001\u7279\u6548\u6700\u4e3b\u6d41\u7684\u6846\u67b6\u4e4b\u4e00\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u5728\u77ed\u89c6\u9891\u5e94\u7528\u4e2d\u3002<\/p>\n<p>GPUImage \u76ee\u524d\u8fd8\u662f\u91c7\u7528 OpenGL \u8fdb\u884c\u6e32\u67d3\u7684\uff0c\u53ef\u968f\u7740\u6280\u672f\u7684\u53d1\u5c55\u8fdb\u6b65\uff0ciOS \u7cfb\u7edf\u90fd\u5f00\u59cb\u629b\u5f03 OpenGL \u62e5\u62b1 Metal \u4e86\uff0cAndroid \u4e5f\u63a8\u51fa\u4e86 Vulkan \u6e32\u67d3\u673a\u5236\u3002<\/p>\n<p>\u5173\u4e8e Vulkan\uff0c\u5927\u5bb6\u53ef\u80fd\u4f1a\u6709\u70b9\u964c\u751f\uff0c\u5b83\u548c OpenGL \u4e00\u6837\u4e5f\u662f\u8de8\u5e73\u53f0\u7684\u6e32\u67d3\u63a5\u53e3\uff0c\u5c31\u662f\u5b66\u4e60\u6210\u672c\u9ad8\u4e86\u4e00\u70b9\uff0c\u8c03\u7528\u6d41\u7a0b\u9ebb\u70e6\u4e86\u4e00\u70b9\uff0c\u4f46\u8fd8\u662f\u53ef\u4ee5\u638c\u63e1\u7684~~~<\/p>\n<p>\u800c\u4e14\u4e00\u65e6\u638c\u63e1\u4e86 Vulkan\uff0c \u518d\u53bb\u770b Metal\uff0c\u6216\u8005 Windows \u5e73\u53f0\u4e0b\u7684 Direct3D\uff0c\u5c31\u4f1a\u53d1\u73b0\u5b83\u4eec\u6709\u5f88\u591a\u5171\u901a\u4e4b\u5904\u7684\uff0c\u5f88\u591a\u6982\u5ff5\u90fd\u662f\u53ef\u4ee5\u4e92\u76f8\u501f\u9274\u7684\uff0c\u5c31\u597d\u6bd4\u7f16\u7a0b\u8bed\u8a00\u4e00\u6837\uff0c\u638c\u63e1\u4e86 Kotlin \u518d\u53bb\u770b Swift \u611f\u89c9\u5c31\u50bb\u50bb\u5206\u4e0d\u6e05\u695a\u4e86\u3002<\/p>\n<p>\u8fd9\u6b21\u8981\u4ecb\u7ecd\u7684\u5c31\u662f\u7528 Vulkan \u5b9e\u73b0\u4e00\u4e2a Android GPUImage \u4e86\u3002<\/p>\n<p>\u6211\u5df2\u7ecf\u5b9e\u73b0\u4e86\u5927\u90e8\u5206\u7684\u4ee3\u7801\uff0c\u7ec4\u5efa\u4e86\u57fa\u672c\u7684\u6e32\u67d3\u94fe\u673a\u5236\uff0c\u590d\u523b\u4e86\u4e00\u4e9b\u7279\u6548\uff0c\u5177\u4f53\u53ef\u4ee5\u770b\u4ee3\u7801\u8be6\u60c5\uff1a<\/p>\n<p>\u4ee3\u7801\u5730\u5740\u5982\u4e0b\uff0c\u6b22\u8fce Star !!!<\/p>\n<blockquote>\n<p>https:\/\/github.com\/glumes\/Vulkan-GPUImage<\/p>\n<\/blockquote>\n<p>\u60f3\u8981\u540e\u7eed\u6dfb\u52a0\u7279\u6548\u4e5f\u662f\u975e\u5e38\u65b9\u4fbf\u7684\uff0c\u4ee5\u66dd\u5149\u7279\u6548\u4e3a\u4f8b\uff1a<\/p>\n<pre><code>static const char *shader =         \"#version 400n\"         \"#extension GL_ARB_separate_shader_objects : enablen\"         \"#extension GL_ARB_shading_language_420pack : enablen\"         \"layout (binding = 0) uniform sampler2D tex;n\"         \"layout (location = 0) in vec2 texcoord;n\"         \"layout (location = 0) out vec4 uFragColor;n\"         \"layout (push_constant) uniform exposure {n\"         \" float exposure;n\"         \"} pushVals;n\"         \"void main() {n\"         \"    vec4 textureColor = texture(tex,  texcoord); n\"         \"   uFragColor = vec4(textureColor.rgb * pow(2.0,pushVals.exposure),textureColor.w);n\"         \"}\";  class ExposureFilter : public VulkanFilter {  public:     ExposureFilter() : VulkanFilter() {         pFragShader = shader;         pushConstant.resize(1);         pushConstant[0] = exposure;     }      virtual void setProcess(uint32_t process);  protected:  private:     float exposure = 1.0f; }; <\/code><\/pre>\n<p>\u9996\u5148\u5b9e\u73b0\u5bf9\u5e94\u7684 Shader\uff0c\u7136\u540e\u5bf9\u5e94\u7279\u6548\u7c7b\u7ee7\u627f\u81ea VulkanFilter\uff0c\u5982\u679c\u7279\u6548\u6ca1\u6709\u9700\u8981\u66f4\u65b0\u7684\u53c2\u6570\uff0c\u53ef\u4ee5\u4e0d\u7528 pushConstant \u3002<\/p>\n<p>\u5982\u679c\u6709\u7684\u8bdd\u628a pushConstant \u7684\u957f\u5ea6\u4fee\u6539\u4e3a\u53c2\u6570\u7684\u4e2a\u6570\uff0c\u6bcf\u4e2a\u53c2\u6570\u5bf9\u5e94 shader \u4e2d\u63a8\u9001\u5e38\u6570\u7684\u503c\u5373\u53ef\u3002<\/p>\n<p>\u7136\u540e\u5728 setProcess \u91cc\u9762\u4fee\u6539\u5bf9\u5e94\u7684 pushConstant \u503c\uff1a<\/p>\n<pre><code>void ExposureFilter::setProcess(uint32_t process) {     pushConstant[0] = FilterUtil::getProcess(process,-10.0f,10.0f); } <\/code><\/pre>\n<p>\u5728\u5e94\u7528\u4e2d\u62d6\u52a8 SeekBar\uff0c\u5c31\u53ef\u4ee5\u66f4\u6539\u5bf9\u5e94\u7684\u5e38\u91cf\u503c\u4e86\uff0c\u4ece\u800c\u4fee\u6539 Shader \u6548\u679c\uff0c\u5bf9\u4e8e\u7b80\u5355\u7684\u7279\u6548\uff0c\u57fa\u672c\u4e0a\u4e0d\u7528\u4e94\u5206\u949f\u5c31\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u6548\u679c\u4e86\uff0c\u5f88\u591a\u5c01\u88c5\u5de5\u4f5c\u90fd\u653e\u5728 VulkanFilter \u91cc\u9762\u4e86\u3002<\/p>\n<p>\u5728\u5b9e\u73b0\u4e0a\u91c7\u7528\u7684\u662f\u591a RenderPass \u7684\u65b9\u5f0f\uff0c\u5176\u5b9e\u4e5f\u53ef\u4ee5\u7528\u591a Subpass \u7684\u65b9\u5f0f\uff0c\u4f46\u662f\u4e0d\u597d\u505a\u6548\u679c\u5207\u6362\uff0c\u5e72\u8106\u5c31\u591a RenderPass \u4e86\uff0c\u5176\u5b9e\u4e5f\u53ef\u4ee5\u4e24\u8005\u6df7\u5408\u3002<\/p>\n<p>\u4ee3\u7801\u5199\u7684\u4e0d\u662f\u7279\u522b\u4f18\u96c5\uff0c\u540e\u9762\u6301\u7eed\u4f18\u5316\u4e86\uff0c\u5404\u4f4d\u8d70\u8fc7\u8def\u8fc7\u4e0d\u8981\u9519\u8fc7\uff0c\u76ee\u524d\u5168\u7f51\u8fd8\u641c\u4e0d\u5230 Vulkan \u505a GPUImage \u76f8\u5173\u7684\u5b9e\u73b0\u5462\uff0c\u7b97\u662f\u5f00\u5f20\u4e86\uff0c\u89c9\u5f97\u6709\u5e2e\u52a9\u5c31\u70b9\u4e2a Star \u5440~~~<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>12<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5487337\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : visionsmile <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8001\u54e5\u725b\u76ae\uff0c\u5df2 star                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487338\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : glumess <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @visionsmile \u611f\u8c22\u8001\u94c1~~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487339\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codehz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Vulkan \u5728\u79fb\u52a8\u5e73\u53f0 \/linux \u684c\u9762\u6d77\u661f\uff0cwindows \u4e0a\u9a71\u52a8\u8fd8\u662f\u95ee\u9898\u5f88\u5927\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487340\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : neoblackcap <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codehz windows \u5e73\u53f0\u5c31\u8001\u5b9e\u7528 DX \u5566\uff0c\u7528 vulkan \u627e\u4e0d\u81ea\u5728\u4e48\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487341\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MCVector <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codehz @neoblackcap Vulkan \u5728 Windows \u4e0b\u7684\u9a71\u52a8\u4f3c\u4e4e\u8fd8\u884c\u5440\u3002\u6211\u7528\u7684 GTX 1070 \u57fa\u672c\u4e0a Vulkan 1.2 \u7684 feature \u90fd\u80fd\u7528\uff0cRay tracing pipeline \u7684\u5927\u90e8\u5206 extensions \u90fd\u652f\u6301                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487342\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MCVector <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u7528 subpass \u7684\u8bdd\u50cf Gaussian blur \u8fd9\u79cd\u9700\u8981\u8bfb\u5468\u56f4 pixel \u7684 pass \u5e94\u8be5\u5c31\u7528\u4e0d\u4e86\u4e86\u5427\uff1f\u8fd9\u6837\u76f4\u63a5\u7528 renderpass \u53ef\u80fd\u4f1a\u66f4\u7075\u6d3b\u4e00\u4e9b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487343\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : neoblackcap <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @MCVector \u53ef\u80fd\u770b\u662f\u54ea\u4e00\u5bb6\u5427\uff0c\u4e0d\u8fc7 Vulkan \u662f\u4e8c\u7b49\u516c\u6c11\uff0c\u80af\u5b9a\u4e0d\u5982 DX \u597d\u4f7f\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487344\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MCVector <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @neoblackcap \u6211\u4e0d\u8ba4\u4e3a DX12 \u5728 Windows \u4e0b\u80fd\u505a\u7684 Vulkan \u505a\u4e0d\u4e86\u3002\u636e\u6211\u6240\u77e5\u57fa\u672c\u4e0a\u652f\u6301 DX12 \u7684\u663e\u5361\u5728 Windows \u4e0b\u90fd\u652f\u6301 Vulkan \u3002\u6240\u4ee5\u6211\u8ba4\u4e3a Vulkan \u662f\u4e8c\u7b49\u516c\u6c11\u7684\u8bf4\u6cd5\u662f\u4e0d\u6210\u7acb\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487345\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : TSai2019 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             filter-&gt; filter \u6ca1\u6709?<br \/>two input \u4e5f\u6ca1\u6709\uff0c\u79bb\u5b8c\u6574 GPUImage \u8fd8\u5dee\u4e0d\u5c11                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487346\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : glumess <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @TSai2019 filter -&gt; fitler \u5e94\u8be5\u6709\u4e86\u554a\uff0c\u91c7\u7528\u4e24\u4e2a renderpass \u7684\u65b9\u5f0f\u5b9e\u73b0\u7684\uff0ctwo input \u8fd8\u5728\u60f3\u600e\u4e48\u641e\u66f4\u597d&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487347\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : glumess <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @MCVector \u9ad8\u65af\u6a21\u7cca\u7684 shader \u5e94\u8be5\u53ef\u4ee5\u5427\uff0c\u5c31\u662f shader \u91cc\u9762\u7684\u64cd\u4f5c\u5440                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5487348\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : MCVector <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @glumess \u54c8\u54c8\u6211\u4e4b\u524d\u4e5f\u662f\u8fd9\u4e48\u60f3\u7684\u3002<br \/>\u5982\u679c\u7528 subpass \u7684\u8bdd\u5728\u5f53\u524d\u7684 fragment shader \u91cc\u53ea\u80fd\u8bfb\u524d\u4e00\u4e2a subpass \u8f93\u51fa\u7684\u540c\u4e00\u4e2a fragment (subpassLoad()), \u800c\u4e0d\u662f\u50cf\u4f20\u7edf\u7684 renderpass \u4e00\u6837\u53ef\u4ee5\u7528 uv \u8bfb\u3002\u9ad8\u65af\u6a21\u7cca\u9700\u8981\u5468\u56f4\u50cf\u7d20\u7684\u4fe1\u606f\u6240\u4ee5\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4f1a\u6709\u9650\u5236\u3002 <br \/>Subpass \u5b58\u5728\u7684\u539f\u56e0\u662f\u544a\u8bc9 GPU \u4e0d\u9700\u8981\u7b49\u5230\u6574\u5f20\u56fe\u7247\u90fd\u5904\u7406\u5b8c\u4e86\u518d\u5f00\u59cb\u4e0b\u4e00\u4e2a pass \u7684\u5904\u7406\uff0c\u800c\u662f\u5f53\u524d fragment \u5904\u7406\u5b8c\u4e86\u4e0b\u4e00\u4e2a pass \u5c31\u53ef\u4ee5\u64cd\u4f5c\u8fd9\u4e2a fragment \u4e86\u3002\u8fd9\u6837\u53ef\u4ee5\u51cf\u5c11\u4e00\u4e9b overhead\uff0c\u540c\u65f6\u4e5f\u9650\u5236\u4e86\u53ea\u80fd\u64cd\u4f5c\u5f53\u524d fragment \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u7528 Vulkan \u6e32\u67d3\u5199\u4e00\u4e2a An&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/380475"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=380475"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/380475\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380475"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}