Hello, I'm trying to add a custom render pass. The current goal is to read some f32 values from a vec and draw a black line to the screen. The x value of any given point on the line would be based on the index in the vec, and the y value would be based on the f32 value. I'm doing something very wrong but I don't know what. Here's what I have so far. It's a bit of a mess...
use std::{f32::consts::PI, num::NonZeroU64};
use bevy::{
prelude::*,
render::{
mesh::PrimitiveTopology,
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, RenderLabel, ViewNode, ViewNodeRunner},
render_resource::{
BindGroupEntry, BindGroupLayout, BindGroupLayoutEntry, BindingResource,
BufferAddress, BufferBindingType, BufferInitDescriptor, BufferSize, BufferUsages,
CachedRenderPipelineId, ColorTargetState, ColorWrites, FragmentState, LoadOp, Operations,
PipelineCache, PrimitiveState, RenderPassColorAttachment, RenderPassDescriptor,
RenderPipelineDescriptor, ShaderStages, StoreOp, TextureFormat,
VertexAttribute, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
},
renderer::{RenderContext, RenderDevice},
view::ViewTarget,
MainWorld, RenderApp,
},
};
use bytemuck::{Pod, Zeroable};
// Must match the value in the shader.
const MAX_POINTS: u32 = 100;
/// Label used in the render graph (similar to PostProcessLabel).
#[derive(Debug, Hash, PartialEq, Eq, Clone, RenderLabel)]
struct SignalRenderLabel;
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
struct SignalVertex {
position: [f32; 2],
color: [f32; 4],
}
#[repr(C)]
#[derive(Clone, Copy, Pod, Zeroable)]
struct SignalUniform {
resolution: [f32; 2],
}
// Our custom pipeline now stores two bind group layouts.
#[derive(Resource)]
struct SignalPipeline {
uniform_bind_group_layout: BindGroupLayout, // group 0: resolution
line_bind_group_layout: BindGroupLayout, // group 1: line data (point count & points)
pipeline_id: CachedRenderPipelineId,
}