fix output format

This commit is contained in:
numzero 2025-11-24 17:54:42 +03:00
parent 5a6b10965d
commit c40ff3e324
4 changed files with 16 additions and 9 deletions

View File

@ -8,7 +8,10 @@ use rand_distr::Distribution as _;
use crate::{ use crate::{
camera::OrbitalCamera, camera::OrbitalCamera,
ray::Ray, ray::Ray,
render::lines::{LookParams, Mesh, Pipeline, Vertex}, render::{
OUTPUT_FORMAT,
lines::{LookParams, Mesh, Pipeline, Vertex},
},
trace::{Hit, Lambertian, Reflector, Scene, Source, Sphere}, trace::{Hit, Lambertian, Reflector, Scene, Source, Sphere},
}; };
@ -18,8 +21,6 @@ mod render;
mod shape; mod shape;
mod trace; mod trace;
const OUTPUT_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)] #[repr(C)]
pub struct SphericalPosition { pub struct SphericalPosition {
@ -130,8 +131,8 @@ impl Core {
surface, surface,
} = gpu; } = gpu;
let pipeline = Pipeline::new(&device, OUTPUT_FORMAT); let pipeline = Pipeline::new(&device);
let mesh_pipe = render::faces::Pipeline::new(&device, OUTPUT_FORMAT); let mesh_pipe = render::faces::Pipeline::new(&device);
let tripod = new_tripod(&device); let tripod = new_tripod(&device);
queue.submit([]); // flush buffer updates queue.submit([]); // flush buffer updates

View File

@ -4,6 +4,8 @@ use bytemuck::{Pod, Zeroable, bytes_of, cast_slice};
use glam::{Mat4, Vec3}; use glam::{Mat4, Vec3};
use wgpu::util::DeviceExt as _; use wgpu::util::DeviceExt as _;
use crate::render::OUTPUT_FORMAT;
#[derive(Debug, Clone, Copy, Pod, Zeroable)] #[derive(Debug, Clone, Copy, Pod, Zeroable)]
#[repr(C)] #[repr(C)]
pub struct LookParams { pub struct LookParams {
@ -67,7 +69,7 @@ pub struct Pipeline {
} }
impl Pipeline { impl Pipeline {
pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Self { pub fn new(device: &wgpu::Device) -> Self {
let look_buf = device.create_buffer(&wgpu::BufferDescriptor { let look_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: None,
size: size_of::<LookParams>() as u64, size: size_of::<LookParams>() as u64,
@ -118,7 +120,7 @@ impl Pipeline {
entry_point: None, entry_point: None,
compilation_options: wgpu::PipelineCompilationOptions::default(), compilation_options: wgpu::PipelineCompilationOptions::default(),
targets: &[Some(wgpu::ColorTargetState { targets: &[Some(wgpu::ColorTargetState {
format, format: OUTPUT_FORMAT,
blend: Some(wgpu::BlendState::REPLACE), blend: Some(wgpu::BlendState::REPLACE),
write_mask: wgpu::ColorWrites::ALL, write_mask: wgpu::ColorWrites::ALL,
})], })],

View File

@ -4,6 +4,8 @@ use bytemuck::{Pod, Zeroable, bytes_of, cast_slice};
use glam::{Mat4, Vec3}; use glam::{Mat4, Vec3};
use wgpu::util::DeviceExt as _; use wgpu::util::DeviceExt as _;
use crate::render::OUTPUT_FORMAT;
#[derive(Debug, Clone, Copy, Pod, Zeroable)] #[derive(Debug, Clone, Copy, Pod, Zeroable)]
#[repr(C)] #[repr(C)]
pub struct LookParams { pub struct LookParams {
@ -49,7 +51,7 @@ pub struct Pipeline {
} }
impl Pipeline { impl Pipeline {
pub fn new(device: &wgpu::Device, format: wgpu::TextureFormat) -> Self { pub fn new(device: &wgpu::Device) -> Self {
let look_buf = device.create_buffer(&wgpu::BufferDescriptor { let look_buf = device.create_buffer(&wgpu::BufferDescriptor {
label: None, label: None,
size: size_of::<LookParams>() as u64, size: size_of::<LookParams>() as u64,
@ -100,7 +102,7 @@ impl Pipeline {
entry_point: None, entry_point: None,
compilation_options: wgpu::PipelineCompilationOptions::default(), compilation_options: wgpu::PipelineCompilationOptions::default(),
targets: &[Some(wgpu::ColorTargetState { targets: &[Some(wgpu::ColorTargetState {
format, format: OUTPUT_FORMAT,
blend: Some(wgpu::BlendState::REPLACE), blend: Some(wgpu::BlendState::REPLACE),
write_mask: wgpu::ColorWrites::ALL, write_mask: wgpu::ColorWrites::ALL,
})], })],

View File

@ -2,3 +2,5 @@ pub mod faces;
pub mod lines; pub mod lines;
static SIMPLE_SHADER: &str = include_str!("simple.wgsl"); static SIMPLE_SHADER: &str = include_str!("simple.wgsl");
pub const OUTPUT_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Bgra8UnormSrgb;