Skip to content

Commit

Permalink
Add create bind group for tonemapping
Browse files Browse the repository at this point in the history
  • Loading branch information
hakolao committed Oct 1, 2024
1 parent 03faa25 commit 4e33494
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/pipelines/tonemapping/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use bytemuck::{Pod, Zeroable};
use wgpu::{
util::DeviceExt, BindGroup, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BindingType,
Buffer, ColorTargetState, ColorWrites, CommandEncoder, Device, Operations, PushConstantRange,
RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, SamplerBindingType,
ShaderStages, TextureFormat, TextureSampleType, TextureViewDimension,
RenderPassColorAttachment, RenderPassDescriptor, RenderPipeline, Sampler, SamplerBindingType,
ShaderStages, TextureFormat, TextureSampleType, TextureView, TextureViewDimension,
};

use crate::{
Expand Down Expand Up @@ -35,7 +35,7 @@ impl TonemappingPipeline {
binding: 0,
ty: BindingType::Texture {
sample_type: TextureSampleType::Float {
filterable: true,
filterable: false,
},
view_dimension: TextureViewDimension::D2,
multisampled: false,
Expand All @@ -45,7 +45,7 @@ impl TonemappingPipeline {
},
BindGroupLayoutEntry {
binding: 1,
ty: BindingType::Sampler(SamplerBindingType::Filtering),
ty: BindingType::Sampler(SamplerBindingType::NonFiltering),
visibility: ShaderStages::FRAGMENT,
count: None,
},
Expand Down Expand Up @@ -95,6 +95,30 @@ impl TonemappingPipeline {
}
}

pub fn create_bind_group(
&self,
device: &Device,
image: &TextureView,
sampler: &Sampler,
) -> BindGroup {
let bind_group_layout = self.tonemapping_pipeline.get_bind_group_layout(0);
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
layout: &bind_group_layout,
entries: &[
wgpu::BindGroupEntry {
binding: 0,
resource: wgpu::BindingResource::TextureView(image),
},
wgpu::BindGroupEntry {
binding: 1,
resource: wgpu::BindingResource::Sampler(sampler),
},
],
label: Some("tonemap_bind_group"),
});
bind_group
}

pub fn tonemap(
&self,
encoder: &mut CommandEncoder,
Expand Down

0 comments on commit 4e33494

Please sign in to comment.