调整目录结构

This commit is contained in:
Nanako 2024-03-13 12:16:20 +08:00
parent 42396528cb
commit c42ecbd108
2 changed files with 175 additions and 0 deletions

View File

@ -0,0 +1,47 @@
#version 460
layout (local_size_x = 1,local_size_y = 1,local_size_z = 1) in;
layout (std430, binding = 0) buffer Samples
{
float AudioSamples[];
};
layout (std430, binding = 1) buffer Params
{
vec4 WaveColor;
vec4 BgColor;
float LineUV;
};
layout (binding = 2) writeonly uniform image2D Result;
vec4 lerp(vec4 a, vec4 b, float x)
{
return a + x * (b - a);
}
void main()
{
vec2 size = vec2(imageSize(Result));
ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
int X = pos.x;
int Y = pos.y;
float height = size.y;
float Top = AudioSamples[X * 2] + 1; // -1;
float Bottom = AudioSamples[X * 2 + 1] + 1; // 1;
Top = min(Top, 1);
Bottom = max(Bottom, 0);
Top *= height;
Top *= 0.5;
Bottom *= height;
Bottom *= 0.5;
// (id.y >= Top && id.y <= Bottom)
float b1 = min(step(Top, Y), step(Y , Bottom));
// (Y == height / 2)
float b2 = step(Y, height * LineUV) * step(height * LineUV, Y);
float b3 = max(b1, b2);
imageStore(Result, pos, lerp(BgColor, WaveColor, b3));
}

View File

@ -0,0 +1,128 @@
#include "rhi/compute_pipeline.h"
#include "imgui.h"
#include "application/application.h"
#include "rhi/texture.h"
#include "WaveformCS_comp.h"
#include "audio/mixer/mixer.h"
#include "audio/plugin_host/plugin_host.h"
#include "audio/plugin_host/plugin_host_manager.h"
#include "misc/singleton/singleton_manager.h"
#include "thread_message/thread_message_hubs.h"
#include "widget/main_gui.h"
#include "widget/uilts.h"
struct test_param {
ImVec4 WaveColor;
ImVec4 BgColor;
float LineUV;
};
class arona_application : public application {
public:
~arona_application() override = default;
const char* get_entry_model() const override { return "arona"; }
const char* get_draw_ps_vertex_shader_entry() const override { return "defaultDrawPSVertexMain"; }
const char* get_shader_path() override { return R"(E:\Projects\Arona\Arona\shaders)"; }
void tick(float delta_time) override {
}
void draw_gui() override {
gui_->main_gui();
}
void init_imgui(ImGuiContext* in_context) override {
ImGui::SetCurrentContext(in_context);
}
void post_init() {
singleton_manager::get()->init();
get_plugin_host_manager().create_instrument_plugin_host(R"(F:\VST\VST64\Serum_x64.dll)");
gui_ = new arona_gui(ImGui::GetIO(), this);
// get_plugin_host_manager().create_instrument_plugin_host(R"(F:\VST\VST64\Serum_x64.dll)");
// get_plugin_host_manager().create_instrument_plugin_host(R"(F:\VST\VST64\Serum_x64.dll)");
// compute_shader_ = renderer_->load_shader("computeMain");
// pixel_shader_ = renderer_->load_shader("fragmentMain");
// render_target_ = create_render_target(128, 128, texture_format::RGBA32_FLOAT);
// compute_shader_->set_render_target("result", render_target_);
// drawer_ = create_pixel_shader_drawer();
// drawer_->init(128, 128, pixel_shader_);
// texture_2 = load_texture(R"(Z:\NanakoDisk\可爱二次元\35966078_p0_waifu2x_art_noise2_scale.png)");
// texture_ = create_texture(nullptr, width, height, vk::Format::eR8G8B8A8Unorm);
// audio_samples_ = std::make_shared<buffer_vk>();
// param_ = std::make_shared<buffer_vk>();
//
// audio_samples_->create_storage(sizeof(float) * 1024);
// float samples[1024] = {};
// for (int i = 0; i < 1024; i++) {
// samples[i] = sinf(i * 0.1f);
// }
// audio_samples_->update(samples, sizeof(float) * 1024);
//
// param_->create_storage(sizeof(test_param));
// test_param param = {};
// param.WaveColor = ImVec4(1.0f, 0.0f, 0.0f, 1.0f);
// param.BgColor = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
// param.LineUV = 0.5f;
// param_->update(param);
//
// compute_pipeline pipeline;
// pipeline.set_shader(WAVEFORMCS_COMP, sizeof(WAVEFORMCS_COMP));
// pipeline.add_storage_buffer(0, audio_samples_);
// pipeline.add_storage_buffer(1, param_);
// pipeline.add_storage_image(2, texture_);
// pipeline.create();
//
// pipeline.dispatch(width, height, 1);
}
void shutdown() override {
singleton_manager::get()->release();
// render_target_ = nullptr;
// texture_ = nullptr;
// audio_samples_ = nullptr;
// param_ = nullptr;
// texture_2 = nullptr;
// compute_shader_ = nullptr;
// pixel_shader_ = nullptr;
application::shutdown();
}
private:
arona_gui* gui_ = nullptr;
// int width = 512;
// int height = 512;
// std::shared_ptr<render_target> render_target_ = nullptr;
// std::shared_ptr<texture> texture_ = nullptr;
// std::shared_ptr<texture> texture_2 = nullptr;
// std::shared_ptr<buffer_vk> audio_samples_ = nullptr;
// std::shared_ptr<buffer_vk> param_ = nullptr;
};
int main(int argc, char* argv[]) {
arona_application app;
window_params params = {};
params.title = "Hello World";
params.width = 1280;
params.height = 720;
params.hi_dpi = true;
params.resizable = true;
app.init(params, argc, argv);
app.post_init();
return app.run();
}