diff options
Diffstat (limited to 'src/gpu/effects')
| -rw-r--r-- | src/gpu/effects/chroma_aberration_effect.cc | 8 | ||||
| -rw-r--r-- | src/gpu/effects/distort_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/fade_effect.cc | 9 | ||||
| -rw-r--r-- | src/gpu/effects/fade_effect.h | 2 | ||||
| -rw-r--r-- | src/gpu/effects/flash_cube_effect.cc | 10 | ||||
| -rw-r--r-- | src/gpu/effects/flash_cube_effect.h | 2 | ||||
| -rw-r--r-- | src/gpu/effects/flash_effect.cc | 9 | ||||
| -rw-r--r-- | src/gpu/effects/flash_effect.h | 2 | ||||
| -rw-r--r-- | src/gpu/effects/gaussian_blur_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/heptagon_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/hybrid_3d_effect.cc | 12 | ||||
| -rw-r--r-- | src/gpu/effects/hybrid_3d_effect.h | 2 | ||||
| -rw-r--r-- | src/gpu/effects/moving_ellipse_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/particle_spray_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/particles_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/passthrough_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/solarize_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/theme_modulation_effect.cc | 9 | ||||
| -rw-r--r-- | src/gpu/effects/theme_modulation_effect.h | 3 |
19 files changed, 53 insertions, 71 deletions
diff --git a/src/gpu/effects/chroma_aberration_effect.cc b/src/gpu/effects/chroma_aberration_effect.cc index 6e64988..83c5f2a 100644 --- a/src/gpu/effects/chroma_aberration_effect.cc +++ b/src/gpu/effects/chroma_aberration_effect.cc @@ -5,14 +5,12 @@ #include "gpu/gpu.h" // --- ChromaAberrationEffect --- -ChromaAberrationEffect::ChromaAberrationEffect(WGPUDevice device, - WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +ChromaAberrationEffect::ChromaAberrationEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); - pipeline_ = create_post_process_pipeline(device_, format, + pipeline_ = create_post_process_pipeline(device_, format_, chroma_aberration_shader_wgsl); } void ChromaAberrationEffect::render(WGPURenderPassEncoder pass, float t, diff --git a/src/gpu/effects/distort_effect.cc b/src/gpu/effects/distort_effect.cc index 0d4bb36..abaa2e7 100644 --- a/src/gpu/effects/distort_effect.cc +++ b/src/gpu/effects/distort_effect.cc @@ -5,14 +5,13 @@ #include "gpu/gpu.h" // --- DistortEffect --- -DistortEffect::DistortEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +DistortEffect::DistortEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); pipeline_ = - create_post_process_pipeline(device_, format, distort_shader_wgsl); + create_post_process_pipeline(device_, format_, distort_shader_wgsl); } void DistortEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { diff --git a/src/gpu/effects/fade_effect.cc b/src/gpu/effects/fade_effect.cc index 4d7633c..dce2360 100644 --- a/src/gpu/effects/fade_effect.cc +++ b/src/gpu/effects/fade_effect.cc @@ -5,9 +5,8 @@ #include "gpu/effects/post_process_helper.h" #include <cmath> -FadeEffect::FadeEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +FadeEffect::FadeEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { const char* shader_code = R"( struct VertexOutput { @builtin(position) position: vec4<f32>, @@ -46,9 +45,9 @@ FadeEffect::FadeEffect(WGPUDevice device, WGPUQueue queue, } )"; - pipeline_ = create_post_process_pipeline(device, format, shader_code); + pipeline_ = create_post_process_pipeline(device_, format_, shader_code); uniforms_ = gpu_create_buffer( - device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + device_, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void FadeEffect::update_bind_group(WGPUTextureView input_view) { diff --git a/src/gpu/effects/fade_effect.h b/src/gpu/effects/fade_effect.h index fc91646..2048c2a 100644 --- a/src/gpu/effects/fade_effect.h +++ b/src/gpu/effects/fade_effect.h @@ -8,7 +8,7 @@ class FadeEffect : public PostProcessEffect { public: - FadeEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + FadeEffect(const GpuContext& ctx); void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override; void update_bind_group(WGPUTextureView input_view) override; diff --git a/src/gpu/effects/flash_cube_effect.cc b/src/gpu/effects/flash_cube_effect.cc index 75c71e1..4f58562 100644 --- a/src/gpu/effects/flash_cube_effect.cc +++ b/src/gpu/effects/flash_cube_effect.cc @@ -8,10 +8,8 @@ #include <cmath> #include <iostream> -FlashCubeEffect::FlashCubeEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : Effect(device, queue) { - (void)format; +FlashCubeEffect::FlashCubeEffect(const GpuContext& ctx) + : Effect(ctx) { } void FlashCubeEffect::resize(int width, int height) { @@ -22,9 +20,9 @@ void FlashCubeEffect::resize(int width, int height) { void FlashCubeEffect::init(MainSequence* demo) { (void)demo; - WGPUTextureFormat format = demo->format; + WGPUTextureFormat format = demo->gpu_ctx.format; - renderer_.init(device_, queue_, format); + renderer_.init(device_, queue_, format_); renderer_.resize(width_, height_); // Texture Manager diff --git a/src/gpu/effects/flash_cube_effect.h b/src/gpu/effects/flash_cube_effect.h index 3af13eb..7089af2 100644 --- a/src/gpu/effects/flash_cube_effect.h +++ b/src/gpu/effects/flash_cube_effect.h @@ -11,7 +11,7 @@ class FlashCubeEffect : public Effect { public: - FlashCubeEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + FlashCubeEffect(const GpuContext& ctx); void init(MainSequence* demo) override; void resize(int width, int height) override; void render(WGPURenderPassEncoder pass, float time, float beat, diff --git a/src/gpu/effects/flash_effect.cc b/src/gpu/effects/flash_effect.cc index 176c60c..3dcb48a 100644 --- a/src/gpu/effects/flash_effect.cc +++ b/src/gpu/effects/flash_effect.cc @@ -5,9 +5,8 @@ #include "gpu/effects/post_process_helper.h" #include <cmath> -FlashEffect::FlashEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +FlashEffect::FlashEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { const char* shader_code = R"( struct VertexOutput { @builtin(position) position: vec4<f32>, @@ -48,9 +47,9 @@ FlashEffect::FlashEffect(WGPUDevice device, WGPUQueue queue, } )"; - pipeline_ = create_post_process_pipeline(device, format, shader_code); + pipeline_ = create_post_process_pipeline(device_, format_, shader_code); uniforms_ = gpu_create_buffer( - device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + device_, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void FlashEffect::update_bind_group(WGPUTextureView input_view) { diff --git a/src/gpu/effects/flash_effect.h b/src/gpu/effects/flash_effect.h index 9aa2c67..6be375d 100644 --- a/src/gpu/effects/flash_effect.h +++ b/src/gpu/effects/flash_effect.h @@ -8,7 +8,7 @@ class FlashEffect : public PostProcessEffect { public: - FlashEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + FlashEffect(const GpuContext& ctx); void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override; void update_bind_group(WGPUTextureView input_view) override; diff --git a/src/gpu/effects/gaussian_blur_effect.cc b/src/gpu/effects/gaussian_blur_effect.cc index ad9bf4b..72a93b8 100644 --- a/src/gpu/effects/gaussian_blur_effect.cc +++ b/src/gpu/effects/gaussian_blur_effect.cc @@ -5,14 +5,13 @@ #include "gpu/gpu.h" // --- GaussianBlurEffect --- -GaussianBlurEffect::GaussianBlurEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +GaussianBlurEffect::GaussianBlurEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); pipeline_ = - create_post_process_pipeline(device_, format, gaussian_blur_shader_wgsl); + create_post_process_pipeline(device_, format_, gaussian_blur_shader_wgsl); } void GaussianBlurEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { diff --git a/src/gpu/effects/heptagon_effect.cc b/src/gpu/effects/heptagon_effect.cc index c982912..024f076 100644 --- a/src/gpu/effects/heptagon_effect.cc +++ b/src/gpu/effects/heptagon_effect.cc @@ -5,15 +5,14 @@ #include "gpu/gpu.h" // --- HeptagonEffect --- -HeptagonEffect::HeptagonEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : Effect(device, queue) { +HeptagonEffect::HeptagonEffect(const GpuContext& ctx) + : Effect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); ResourceBinding bindings[] = {{uniforms_, WGPUBufferBindingType_Uniform}}; pass_ = - gpu_create_render_pass(device_, format, main_shader_wgsl, bindings, 1); + gpu_create_render_pass(device_, format_, main_shader_wgsl, bindings, 1); pass_.vertex_count = 21; } void HeptagonEffect::render(WGPURenderPassEncoder pass, float t, float b, diff --git a/src/gpu/effects/hybrid_3d_effect.cc b/src/gpu/effects/hybrid_3d_effect.cc index 8c70c07..6f89bf3 100644 --- a/src/gpu/effects/hybrid_3d_effect.cc +++ b/src/gpu/effects/hybrid_3d_effect.cc @@ -8,10 +8,8 @@ #include <cmath> #include <iostream> -Hybrid3DEffect::Hybrid3DEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : Effect(device, queue) { - (void)format; // Passed to base, not directly used here. +Hybrid3DEffect::Hybrid3DEffect(const GpuContext& ctx) + : Effect(ctx) { } void Hybrid3DEffect::resize(int width, int height) { @@ -23,10 +21,10 @@ void Hybrid3DEffect::resize(int width, int height) { void Hybrid3DEffect::init(MainSequence* demo) { (void)demo; WGPUTextureFormat format = - demo->format; // Get current format from MainSequence (might be different - // than constructor if resized) + demo->gpu_ctx.format; // Get current format from MainSequence (might be different + // than constructor if resized) - renderer_.init(device_, queue_, format); + renderer_.init(device_, queue_, format_); renderer_.resize(width_, height_); // Texture Manager diff --git a/src/gpu/effects/hybrid_3d_effect.h b/src/gpu/effects/hybrid_3d_effect.h index 8e2fef9..3a4e87c 100644 --- a/src/gpu/effects/hybrid_3d_effect.h +++ b/src/gpu/effects/hybrid_3d_effect.h @@ -12,7 +12,7 @@ class Hybrid3DEffect : public Effect { public: - Hybrid3DEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + Hybrid3DEffect(const GpuContext& ctx); virtual ~Hybrid3DEffect() override = default; void init(MainSequence* demo) override; diff --git a/src/gpu/effects/moving_ellipse_effect.cc b/src/gpu/effects/moving_ellipse_effect.cc index 3b73697..1163215 100644 --- a/src/gpu/effects/moving_ellipse_effect.cc +++ b/src/gpu/effects/moving_ellipse_effect.cc @@ -5,15 +5,14 @@ #include "gpu/gpu.h" // --- MovingEllipseEffect --- -MovingEllipseEffect::MovingEllipseEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : Effect(device, queue) { +MovingEllipseEffect::MovingEllipseEffect(const GpuContext& ctx) + : Effect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); ResourceBinding bindings[] = {{uniforms_, WGPUBufferBindingType_Uniform}}; pass_ = - gpu_create_render_pass(device_, format, ellipse_shader_wgsl, bindings, 1); + gpu_create_render_pass(device_, format_, ellipse_shader_wgsl, bindings, 1); pass_.vertex_count = 3; } void MovingEllipseEffect::render(WGPURenderPassEncoder pass, float t, float b, diff --git a/src/gpu/effects/particle_spray_effect.cc b/src/gpu/effects/particle_spray_effect.cc index e8ead0a..452017e 100644 --- a/src/gpu/effects/particle_spray_effect.cc +++ b/src/gpu/effects/particle_spray_effect.cc @@ -6,9 +6,8 @@ #include <vector> // --- ParticleSprayEffect --- -ParticleSprayEffect::ParticleSprayEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : Effect(device, queue) { +ParticleSprayEffect::ParticleSprayEffect(const GpuContext& ctx) + : Effect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); @@ -27,7 +26,7 @@ ParticleSprayEffect::ParticleSprayEffect(WGPUDevice device, WGPUQueue queue, {particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage}, {uniforms_, WGPUBufferBindingType_Uniform}}; render_pass_ = - gpu_create_render_pass(device_, format, particle_render_wgsl, rb, 2); + gpu_create_render_pass(device_, format_, particle_render_wgsl, rb, 2); render_pass_.vertex_count = 6; render_pass_.instance_count = NUM_PARTICLES; } diff --git a/src/gpu/effects/particles_effect.cc b/src/gpu/effects/particles_effect.cc index 6218af9..137150a 100644 --- a/src/gpu/effects/particles_effect.cc +++ b/src/gpu/effects/particles_effect.cc @@ -6,9 +6,8 @@ #include <vector> // --- ParticlesEffect --- -ParticlesEffect::ParticlesEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : Effect(device, queue) { +ParticlesEffect::ParticlesEffect(const GpuContext& ctx) + : Effect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); @@ -25,7 +24,7 @@ ParticlesEffect::ParticlesEffect(WGPUDevice device, WGPUQueue queue, {particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage}, {uniforms_, WGPUBufferBindingType_Uniform}}; render_pass_ = - gpu_create_render_pass(device_, format, particle_render_wgsl, rb, 2); + gpu_create_render_pass(device_, format_, particle_render_wgsl, rb, 2); render_pass_.vertex_count = 6; render_pass_.instance_count = NUM_PARTICLES; } diff --git a/src/gpu/effects/passthrough_effect.cc b/src/gpu/effects/passthrough_effect.cc index 7825c0a..203f912 100644 --- a/src/gpu/effects/passthrough_effect.cc +++ b/src/gpu/effects/passthrough_effect.cc @@ -5,14 +5,13 @@ #include "gpu/gpu.h" // --- PassthroughEffect --- -PassthroughEffect::PassthroughEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +PassthroughEffect::PassthroughEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); pipeline_ = - create_post_process_pipeline(device_, format, passthrough_shader_wgsl); + create_post_process_pipeline(device_, format_, passthrough_shader_wgsl); } void PassthroughEffect::update_bind_group(WGPUTextureView input_view) { struct { diff --git a/src/gpu/effects/solarize_effect.cc b/src/gpu/effects/solarize_effect.cc index a0bc971..b6cf6f9 100644 --- a/src/gpu/effects/solarize_effect.cc +++ b/src/gpu/effects/solarize_effect.cc @@ -5,14 +5,13 @@ #include "gpu/gpu.h" // --- SolarizeEffect --- -SolarizeEffect::SolarizeEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +SolarizeEffect::SolarizeEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(device_, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); pipeline_ = - create_post_process_pipeline(device_, format, solarize_shader_wgsl); + create_post_process_pipeline(device_, format_, solarize_shader_wgsl); } void SolarizeEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { diff --git a/src/gpu/effects/theme_modulation_effect.cc b/src/gpu/effects/theme_modulation_effect.cc index d2705d5..d0d71cb 100644 --- a/src/gpu/effects/theme_modulation_effect.cc +++ b/src/gpu/effects/theme_modulation_effect.cc @@ -6,9 +6,8 @@ #include "gpu/effects/shaders.h" #include <cmath> -ThemeModulationEffect::ThemeModulationEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format) - : PostProcessEffect(device, queue) { +ThemeModulationEffect::ThemeModulationEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { const char* shader_code = R"( struct VertexOutput { @builtin(position) position: vec4<f32>, @@ -48,11 +47,11 @@ ThemeModulationEffect::ThemeModulationEffect(WGPUDevice device, WGPUQueue queue, } )"; - pipeline_ = create_post_process_pipeline(device, format, shader_code); + pipeline_ = create_post_process_pipeline(device_, format_, shader_code); // Create uniform buffer (4 floats: brightness + padding) uniforms_ = gpu_create_buffer( - device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + device_, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void ThemeModulationEffect::update_bind_group(WGPUTextureView input_view) { diff --git a/src/gpu/effects/theme_modulation_effect.h b/src/gpu/effects/theme_modulation_effect.h index ac584e2..ad7322e 100644 --- a/src/gpu/effects/theme_modulation_effect.h +++ b/src/gpu/effects/theme_modulation_effect.h @@ -8,8 +8,7 @@ class ThemeModulationEffect : public PostProcessEffect { public: - ThemeModulationEffect(WGPUDevice device, WGPUQueue queue, - WGPUTextureFormat format); + ThemeModulationEffect(const GpuContext& ctx); void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override; void update_bind_group(WGPUTextureView input_view) override; |
